MDM公用文件

This commit is contained in:
yuqh 2024-06-28 09:09:56 +08:00
parent 1b2fe8d78a
commit 32275b018e
4 changed files with 38 additions and 21 deletions

View File

@ -814,7 +814,7 @@ where id = #{id}
SELECT SELECT
LOWER(COLUMN_NAME) as fileds LOWER(COLUMN_NAME) as fileds
FROM FROM
INFORMATION_SCHEMA. COLUMNS USER_TAB_COLUMNS
WHERE WHERE
TABLE_NAME = #{tableName} TABLE_NAME = #{tableName}

View File

@ -66,7 +66,8 @@
<!--根据mdm_module的id和mdm_module_db的id查询单据规则--> <!--根据mdm_module的id和mdm_module_db的id查询单据规则-->
<select id="queryComparisonById" resultMap="get-ComparisonEntity-result"> <select id="queryComparisonById" resultMap="get-ComparisonEntity-result">
select group_concat(db_value SEPARATOR '') as documentRule from mdm_table_code_rule <!-- select group_concat(db_value SEPARATOR '') as documentRule from mdm_table_code_rule-->
select replace(WM_CONCAT(db_value),',','') as documentRule from mdm_table_code_rule
where mdm_id=#{mId} and sts='Y' where mdm_id=#{mId} and sts='Y'
</select> </select>

View File

@ -1,13 +1,14 @@
package com.hzya.frame.sysnew.comparison.masterData.service.impl; package com.hzya.frame.sysnew.comparison.masterData.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService; import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.dateutil.DateUtil;
import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl; import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.sysnew.application.service.impl.ApplicationCache;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity; import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.sysnew.comparison.masterData.dao.impl.MasterDataDaoImpl; import com.hzya.frame.sysnew.comparison.masterData.dao.impl.MasterDataDaoImpl;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataService; import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataService;
@ -34,6 +35,8 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
@Autowired @Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl; private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
@Autowired
private ApplicationCache applicationCache;
private String ts = ""; private String ts = "";
/** /**
@ -46,6 +49,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
@Override @Override
public JsonResultEntity queryArchives(JSONObject json){ public JsonResultEntity queryArchives(JSONObject json){
logger.info("第一次入参"+String.valueOf(json));
JSONObject jsonObject = json.getJSONObject("jsonStr"); JSONObject jsonObject = json.getJSONObject("jsonStr");
//查询主数据来源表根据来源类型为插件得进行分类获取来源名称和编码 //查询主数据来源表根据来源类型为插件得进行分类获取来源名称和编码
List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType(); List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
@ -54,6 +58,11 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
return BaseResult.getFailureMessageEntity("数据来源表无插件类型"); return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
} }
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) { 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");//定时任务执行时传入的结束时间
// logger.info("本次任务查询区间开始时间:{} 结束时间:{}",startTime,endTime);
String tableName = ""; String tableName = "";
try { try {
//通过不同的应用类型用于拼接sql //通过不同的应用类型用于拼接sql
@ -61,7 +70,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
String dbCode = mdmModuleSourceEntity.getDbCode(); String dbCode = mdmModuleSourceEntity.getDbCode();
String mdmCode = mdmModuleSourceEntity.getMdmCode(); String mdmCode = mdmModuleSourceEntity.getMdmCode();
List<JSONObject> listAll = new ArrayList<>(); List<JSONObject> listAll = new ArrayList<>();
if(!"10004".equals(mdmCode)){ if(!"10003".equals(mdmCode)){
continue; continue;
} }
switch (appTyp) {//1致远OA 2用友U8C 3用友BIP switch (appTyp) {//1致远OA 2用友U8C 3用友BIP
@ -70,13 +79,13 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
switch (mdmCode){ switch (mdmCode){
case "10003"://致远用户信息 case "10003"://致远用户信息
tableName = "mdm_user"; tableName = "mdm_user";
listAll = bindingUser(jsonObject, mdmModuleSourceEntity, dbCode); listAll = bindingUser(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break; break;
case "10004"://致远客商信息 case "10004"://致远客商信息
tableName = "mdm_customer"; tableName = "mdm_customer";
listAll = binDingCust(jsonObject, mdmModuleSourceEntity, dbCode); listAll = binDingCust(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break; break;
case "10007"://致远客商信息 case "10007"://银行信息
tableName = "mdm_bank"; tableName = "mdm_bank";
listAll = binDingBank(jsonObject, mdmModuleSourceEntity, dbCode); listAll = binDingBank(jsonObject, mdmModuleSourceEntity, dbCode);
break; break;
@ -106,7 +115,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
String code = jsonObject.getString("code"); String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'"); sb.append(" and a.code = '"+code+"'");
}else{ }else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss"); // ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'"); sb.append(" and a.update_time >= '"+ts+"'");
} }
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
@ -129,18 +138,19 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
} }
//绑定客户档案 //绑定客户档案
private List<JSONObject> binDingCust(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception { private List<JSONObject> binDingCust(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"))){
String code = jsonObject.getString("code"); String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'"); sb.append(" and a.code = '"+code+"'");
}else{ }else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss"); // ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'"); sb.append(" and a.modify_date >= '"+startTime+"'");
sb.append(" and a.modify_date < '"+endTime+"'");
} }
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("SELECT id as data_id,field0013 AS code,field0014 AS name,field0016 AS pk_custclass,field0015 AS shortname,field0012 AS pk_org FROM formmain_0226 a WHERE 1=1 "); stringBuffer.append("SELECT id as data_id,field0013 AS code,field0014 AS name,field0016 AS pk_custclass,field0015 AS shortname,field0012 AS pk_org FROM formmain_0177 a WHERE 1=1 " );
mdmModuleSourceEntity.setDataSourceCode(dbCode); mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity); List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
if(CollectionUtils.isNotEmpty(hashMaps)){ if(CollectionUtils.isNotEmpty(hashMaps)){
@ -153,7 +163,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
//获取明细信息 //获取明细信息
Long formmainId = (Long) hashMap.get("data_id"); Long formmainId = (Long) hashMap.get("data_id");
StringBuffer stringBufferDetails = new StringBuffer(); StringBuffer stringBufferDetails = new StringBuffer();
stringBufferDetails.append("SELECT id as data_id ,field0023 AS pk_bankdoc,field0024 AS accnum,field0025 AS combinenum FROM formson_0229 WHERE formmain_id = '"+formmainId+"' " ); stringBufferDetails.append("SELECT id as data_id ,field0019 AS pk_bankdoc,field0020 AS accnum,field0021 AS combinenum FROM formson_0230 WHERE formmain_id = '"+formmainId+"' " );
List<HashMap<String, Object>> hashMapsDetails = masterDataDaoImpl.queryArchivesByDataSource(stringBufferDetails.toString(),mdmModuleSourceEntity); List<HashMap<String, Object>> hashMapsDetails = masterDataDaoImpl.queryArchivesByDataSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
JSONArray mdm_customer_bank = new JSONArray(); JSONArray mdm_customer_bank = new JSONArray();
if(CollectionUtils.isNotEmpty(hashMapsDetails)){ if(CollectionUtils.isNotEmpty(hashMapsDetails)){
@ -174,19 +184,22 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
} }
//绑定OA用户参数 //绑定OA用户参数
private List<JSONObject> bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)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"))){
String code = jsonObject.getString("code"); String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'"); sb.append(" and a.code = '"+code+"'");
}else{ }else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss"); // ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'"); sb.append(" and a.update_time >= '"+startTime+"'");
sb.append(" and a.update_time <> '"+endTime+"'");
} }
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select a.id as data_id, a.name as user_name, e.LOGIN_NAME as user_code FROM org_member a left join org_principal e on a.id = e.MEMBER_ID" + stringBuffer.append("select a.id as data_id, a.name as user_name, a.code AS user_code,e.LOGIN_NAME as login_name,CASE WHEN EXT_ATTR_11 = '1' \n" +
" WHERE 1=1 " + sb.toString()); "THEN '男' WHEN EXT_ATTR_11 = '2' THEN '女' ELSE NULL END AS gender,CASE WHEN (a.EXT_ATTR_1 IS NULL OR a.EXT_ATTR_1 ='') THEN '11111111111' ELSE a.EXT_ATTR_1 END AS mobile FROM org_member a left join org_principal e on a.id = e.MEMBER_ID\n" +
// " WHERE 1=1 and e.LOGIN_NAME IS not null " + sb.toString());
" WHERE 1=1 and a.id = '-2698997042624247722'");
mdmModuleSourceEntity.setDataSourceCode(dbCode); mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity); List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
int i = 0; int i = 0;

View File

@ -254,6 +254,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage()); logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage());
//保存操作日志 //保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2"); controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("保存失败"); return BaseResult.getFailureMessageEntity("保存失败");
} }
} }
@ -261,6 +262,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage()); logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage());
//保存操作日志 //保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2"); controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("保存失败"); return BaseResult.getFailureMessageEntity("保存失败");
} }
try { try {
@ -326,6 +328,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("保存通用数据时候错误:{}", e.getMessage()); logger.info("保存通用数据时候错误:{}", e.getMessage());
//保存操作日志 //保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2"); controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("保存失败"); return BaseResult.getFailureMessageEntity("保存失败");
} }
} }