增加供应商和项目抽取

This commit is contained in:
hecan 2025-02-19 11:23:10 +08:00
parent 99e32b0c9e
commit e4257357d2
1 changed files with 120 additions and 43 deletions

View File

@ -28,15 +28,15 @@ import java.util.List;
@Service("MasterDataServiceImpl") @Service("MasterDataServiceImpl")
public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataService { public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataService {
@Autowired @Autowired
private MasterDataDaoImpl masterDataDaoImpl; private MasterDataDaoImpl masterDataDaoImpl;
@Autowired @Autowired
private ComparisonServiceImpl comparisonServiceimpl; private ComparisonServiceImpl comparisonServiceimpl;
@Autowired @Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl; private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
@Autowired @Autowired
private ApplicationCache applicationCache; private ApplicationCache applicationCache;
private String ts = ""; private String ts = "";
/** /**
@ -60,8 +60,8 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) { for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
// applicationCache.get() // applicationCache.get()
// logger.info("入参数据"+jsonObject.toString()); // logger.info("入参数据"+jsonObject.toString());
String startTime = DateUtil.format(json.getDate("startTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的开始时间 String startTime = DateUtil.format(json.getDate("startTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的开始时间
String endTime = DateUtil.format(json.getDate("endTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的结束时间 String endTime = DateUtil.format(json.getDate("endTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的结束时间
// logger.info("本次任务查询区间开始时间:{} 结束时间:{}",startTime,endTime); // logger.info("本次任务查询区间开始时间:{} 结束时间:{}",startTime,endTime);
String tableName = ""; String tableName = "";
try { try {
@ -71,7 +71,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
String mdmCode = mdmModuleSourceEntity.getMdmCode(); String mdmCode = mdmModuleSourceEntity.getMdmCode();
List<JSONObject> listAll = new ArrayList<>(); List<JSONObject> listAll = new ArrayList<>();
if("10007".equals(mdmCode)){ if("10007".equals(mdmCode)){
continue; continue;
} }
// if(!"10003".equals(mdmCode)){ // if(!"10003".equals(mdmCode)){
// continue; // continue;
@ -92,6 +92,14 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
tableName = "mdm_bank"; tableName = "mdm_bank";
listAll = binDingBank(jsonObject, mdmModuleSourceEntity, dbCode); listAll = binDingBank(jsonObject, mdmModuleSourceEntity, dbCode);
break; break;
case "10046"://BIP供应商档案
tableName = "mdm_bip_supplier";
listAll = binDingSupplier(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break;
case "10047"://BIP项目档案
tableName = "mdm_bip_project";
listAll = binDingProject(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break;
default: default:
logger.info("未匹配到主数据的编码,请检查"); logger.info("未匹配到主数据的编码,请检查");
break; break;
@ -110,6 +118,74 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
} }
return BaseResult.getSuccessMessageEntity("主数据同步成功"); return BaseResult.getSuccessMessageEntity("主数据同步成功");
} }
//绑定项目
private List<JSONObject> binDingProject(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception {
List<JSONObject> list = new ArrayList<>();
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sb.append(" and code = '"+code+"'");
}else{
sb.append(" and to_char(main.update_time,'yyyy-MM-dd HH:mm:ss') >= '"+startTime+"'");
sb.append(" and to_char(main.update_time,'yyyy-MM-dd HH:mm:ss') <> '"+endTime+"'");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("");
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
int i = 0;
if(CollectionUtils.isNotEmpty(hashMaps)){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject();
JSONObject mdm = new JSONObject();
for(String key:hashMap.keySet()) {
mdm.put(key, hashMap.get(key));
}
main.put("mdm_bip_project",mdm);
list.add(main);
}
}
return list;
}
//绑定供应商
private List<JSONObject> binDingSupplier(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception {
List<JSONObject> list = new ArrayList<>();
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sb.append(" and code = '"+code+"'");
}else{
sb.append(" and to_char(main.update_time,'yyyy-MM-dd HH:mm:ss') >= '"+startTime+"'");
sb.append(" and to_char(main.update_time,'yyyy-MM-dd HH:mm:ss') <> '"+endTime+"'");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select \n" +
"main.id as data_id,field0139 as orgcode,field0123 as code,field0125 as abbreviate,field0124 as name,\n" +
"field0148 as category_code,field0127 as taxpayerid,field0142 as linkaddress,field0132 as linkman,\n" +
"field0121 as telephone\n" +
"from formmain_11208 main\n" +
" LEFT JOIN COL_SUMMARY ON COL_SUMMARY.FORM_RECORDID = main.id\n" +
" left join ORG_MEMBER ORG_MEMBER on main.field0001=ORG_MEMBER.id\n" +
" WHERE 1=1 and summary.state in ('1','3') ");
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
int i = 0;
if(CollectionUtils.isNotEmpty(hashMaps)){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject();
JSONObject mdm = new JSONObject();
for(String key:hashMap.keySet()) {
mdm.put(key, hashMap.get(key));
}
main.put("mdm_bip_supplier",mdm);
list.add(main);
}
}
return list;
}
//绑定银行 //绑定银行
private List<JSONObject> binDingBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception { private List<JSONObject> binDingBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception {
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();
@ -187,7 +263,8 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
} }
//绑定OA用户参数 //绑定OA用户参数
private List<JSONObject> bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception { private List<JSONObject>
bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception {
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){ if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
@ -209,7 +286,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
if(CollectionUtils.isNotEmpty(hashMaps)){ if(CollectionUtils.isNotEmpty(hashMaps)){
for (HashMap<String, Object> hashMap : hashMaps) { for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject(); JSONObject main = new JSONObject();
JSONObject mdm_user = new JSONObject(); JSONObject mdm_user = new JSONObject();
for(String key:hashMap.keySet()) { for(String key:hashMap.keySet()) {
mdm_user.put(key, hashMap.get(key)); mdm_user.put(key, hashMap.get(key));
} }
@ -223,51 +300,51 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
//查询档案参数组装 //查询档案参数组装
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<JSONObject> hashMaps,String mdmCode,String tableName)throws Exception{ public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<JSONObject> hashMaps,String mdmCode,String tableName)throws Exception{
for (JSONObject hashMap : hashMaps) { for (JSONObject hashMap : hashMaps) {
JSONObject main = hashMap.getJSONObject(tableName); JSONObject main = hashMap.getJSONObject(tableName);
JSONObject jsonObjectUser = new JSONObject(); JSONObject jsonObjectUser = new JSONObject();
JSONObject jsonStr = new JSONObject(); JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("data_id", main.get("data_id")); jsonObjectUser.put("data_id", main.get("data_id"));
jsonObjectUser.put("mdmCode", mdmCode); jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser); jsonStr.put("jsonStr", jsonObjectUser);
//先查询编码和名称查询是否存在 //先查询编码和名称查询是否存在
Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr); Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr);
logger.info("得到的attribute值为{}", jsonStr.toJSONString(attribute)); logger.info("得到的attribute值为{}", jsonStr.toJSONString(attribute));
JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute); JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute);
JSONArray jsonArrayList = jsonObjectAttribute.getJSONArray("list"); JSONArray jsonArrayList = jsonObjectAttribute.getJSONArray("list");
//如果jsonArrayList为null说明没有值在表中不存在 //如果jsonArrayList为null说明没有值在表中不存在
if (jsonArrayList == null || jsonArrayList.size() == 0) { if (jsonArrayList == null || jsonArrayList.size() == 0) {
// //将查询出来得数据调用通用接口新增保存到表中 // //将查询出来得数据调用通用接口新增保存到表中
// JSONObject main = new JSONObject(); // JSONObject main = new JSONObject();
// for(String key:hashMap.keySet()) { // for(String key:hashMap.keySet()) {
// main.put(key, hashMap.get(key)); // main.put(key, hashMap.get(key));
// } // }
// jsonObjectUser.put("main", main); // jsonObjectUser.put("main", main);
hashMap.put("appName","数智中台"); hashMap.put("appName","数智中台");
hashMap.put("appCode","800004"); hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode); hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台"); hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap); jsonStr.put("jsonStr", hashMap);
Object result = comparisonServiceimpl.saveEntity(jsonStr); Object result = comparisonServiceimpl.saveEntity(jsonStr);
logger.info("新增结果为:{}", JSON.toJSONString(result)); logger.info("新增结果为:{}", JSON.toJSONString(result));
// if(!result.isFlag()){ // if(!result.isFlag()){
// throw new BaseSystemException("主数据保存失败"+ result.getMsg()); // throw new BaseSystemException("主数据保存失败"+ result.getMsg());
// } // }
} else { } else {
hashMap.put("appName","数智中台"); hashMap.put("appName","数智中台");
hashMap.put("appCode","800004"); hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode); hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台"); hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap); jsonStr.put("jsonStr", hashMap);
Object result = comparisonServiceimpl.updateEntity(jsonStr); Object result = comparisonServiceimpl.updateEntity(jsonStr);
logger.info("更新结果为:{}", JSON.toJSONString(result)); logger.info("更新结果为:{}", JSON.toJSONString(result));
// if(!result.isFlag()){ // if(!result.isFlag()){
// //throw new BaseSystemException("主数据更新失败"+ result.getMsg()); // //throw new BaseSystemException("主数据更新失败"+ result.getMsg());
// } // }
}
} }
return null; }
return null;
} }
} }