diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/masterData/service/impl/MasterDataServiceImpl.java b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/masterData/service/impl/MasterDataServiceImpl.java index 357a2ec6..4593a65e 100644 --- a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/masterData/service/impl/MasterDataServiceImpl.java +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/masterData/service/impl/MasterDataServiceImpl.java @@ -28,15 +28,15 @@ import java.util.List; @Service("MasterDataServiceImpl") public class MasterDataServiceImpl extends BaseService implements IMasterDataService { - @Autowired + @Autowired private MasterDataDaoImpl masterDataDaoImpl; - @Autowired - private ComparisonServiceImpl comparisonServiceimpl; - @Autowired - private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl; + @Autowired + private ComparisonServiceImpl comparisonServiceimpl; + @Autowired + private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl; - @Autowired - private ApplicationCache applicationCache; + @Autowired + private ApplicationCache applicationCache; private String ts = ""; /** @@ -60,8 +60,8 @@ public class MasterDataServiceImpl extends BaseService for (MdmModuleSourceEntity mdmModuleSourceEntity : list) { // applicationCache.get() // logger.info("入参数据"+jsonObject.toString()); - 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 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");//定时任务执行时传入的结束时间 // logger.info("本次任务查询区间开始时间:{} 结束时间:{}",startTime,endTime); String tableName = ""; try { @@ -71,7 +71,7 @@ public class MasterDataServiceImpl extends BaseService String mdmCode = mdmModuleSourceEntity.getMdmCode(); List listAll = new ArrayList<>(); if("10007".equals(mdmCode)){ - continue; + continue; } // if(!"10003".equals(mdmCode)){ // continue; @@ -92,6 +92,14 @@ public class MasterDataServiceImpl extends BaseService tableName = "mdm_bank"; listAll = binDingBank(jsonObject, mdmModuleSourceEntity, dbCode); 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: logger.info("未匹配到主数据的编码,请检查"); break; @@ -110,6 +118,74 @@ public class MasterDataServiceImpl extends BaseService } return BaseResult.getSuccessMessageEntity("主数据同步成功"); } + + //绑定项目 + private List binDingProject(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception { + List 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> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity); + int i = 0; + if(CollectionUtils.isNotEmpty(hashMaps)){ + for (HashMap 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 binDingSupplier(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception { + List 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> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity); + int i = 0; + if(CollectionUtils.isNotEmpty(hashMaps)){ + for (HashMap 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 binDingBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception { List list = new ArrayList<>(); @@ -187,7 +263,8 @@ public class MasterDataServiceImpl extends BaseService } //绑定OA用户参数 - private List bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception { + private List + bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception { List list = new ArrayList<>(); StringBuffer sb = new StringBuffer(); if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){ @@ -209,7 +286,7 @@ public class MasterDataServiceImpl extends BaseService if(CollectionUtils.isNotEmpty(hashMaps)){ for (HashMap hashMap : hashMaps) { JSONObject main = new JSONObject(); - JSONObject mdm_user = new JSONObject(); + JSONObject mdm_user = new JSONObject(); for(String key:hashMap.keySet()) { mdm_user.put(key, hashMap.get(key)); } @@ -223,51 +300,51 @@ public class MasterDataServiceImpl extends BaseService //查询档案参数组装 public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List hashMaps,String mdmCode,String tableName)throws Exception{ - for (JSONObject hashMap : hashMaps) { - JSONObject main = hashMap.getJSONObject(tableName); + for (JSONObject hashMap : hashMaps) { + JSONObject main = hashMap.getJSONObject(tableName); - JSONObject jsonObjectUser = new JSONObject(); - JSONObject jsonStr = new JSONObject(); - jsonObjectUser.put("data_id", main.get("data_id")); - jsonObjectUser.put("mdmCode", mdmCode); - jsonStr.put("jsonStr", jsonObjectUser); - //先查询编码和名称查询是否存在 - Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr); - logger.info("得到的attribute值为:{}", jsonStr.toJSONString(attribute)); - JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute); - JSONArray jsonArrayList = jsonObjectAttribute.getJSONArray("list"); - //如果jsonArrayList为null,说明没有值,在表中不存在 - if (jsonArrayList == null || jsonArrayList.size() == 0) { + JSONObject jsonObjectUser = new JSONObject(); + JSONObject jsonStr = new JSONObject(); + jsonObjectUser.put("data_id", main.get("data_id")); + jsonObjectUser.put("mdmCode", mdmCode); + jsonStr.put("jsonStr", jsonObjectUser); + //先查询编码和名称查询是否存在 + Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr); + logger.info("得到的attribute值为:{}", jsonStr.toJSONString(attribute)); + JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute); + JSONArray jsonArrayList = jsonObjectAttribute.getJSONArray("list"); + //如果jsonArrayList为null,说明没有值,在表中不存在 + if (jsonArrayList == null || jsonArrayList.size() == 0) { // //将查询出来得数据调用通用接口新增,保存到表中 // JSONObject main = new JSONObject(); // for(String key:hashMap.keySet()) { // main.put(key, hashMap.get(key)); // } // jsonObjectUser.put("main", main); - hashMap.put("appName","数智中台"); - hashMap.put("appCode","800004"); - hashMap.put("mdmCode", mdmCode); - hashMap.put("optionName", "数智中台"); - jsonStr.put("jsonStr", hashMap); - Object result = comparisonServiceimpl.saveEntity(jsonStr); - logger.info("新增结果为:{}", JSON.toJSONString(result)); + hashMap.put("appName","数智中台"); + hashMap.put("appCode","800004"); + hashMap.put("mdmCode", mdmCode); + hashMap.put("optionName", "数智中台"); + jsonStr.put("jsonStr", hashMap); + Object result = comparisonServiceimpl.saveEntity(jsonStr); + logger.info("新增结果为:{}", JSON.toJSONString(result)); // if(!result.isFlag()){ // throw new BaseSystemException("主数据保存失败"+ result.getMsg()); // } - } else { - hashMap.put("appName","数智中台"); - hashMap.put("appCode","800004"); - hashMap.put("mdmCode", mdmCode); - hashMap.put("optionName", "数智中台"); - jsonStr.put("jsonStr", hashMap); - Object result = comparisonServiceimpl.updateEntity(jsonStr); - logger.info("更新结果为:{}", JSON.toJSONString(result)); + } else { + hashMap.put("appName","数智中台"); + hashMap.put("appCode","800004"); + hashMap.put("mdmCode", mdmCode); + hashMap.put("optionName", "数智中台"); + jsonStr.put("jsonStr", hashMap); + Object result = comparisonServiceimpl.updateEntity(jsonStr); + logger.info("更新结果为:{}", JSON.toJSONString(result)); // if(!result.isFlag()){ // //throw new BaseSystemException("主数据更新失败"+ result.getMsg()); // } - } } - return null; + } + return null; } }