MDM公用文件

This commit is contained in:
yuqh 2024-06-25 09:25:06 +08:00
parent 816bdbc51b
commit 5c77244d24
9 changed files with 130 additions and 705 deletions

View File

@ -1,18 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IMasterDataCustoMermanageService extends IBaseService<ComparisonEntity, String> {
/**
*
* @content 查询客户档案同步中台主数据中心
* @author laborer
* @date 2024/6/20 0020 9:54
*
*/
JsonResultEntity queryCustoMermanageArchives(JSONObject jsonObject);
}

View File

@ -1,19 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IMasterDataMemberService extends IBaseService<ComparisonEntity, String> {
/**
*
* @content 查询项目档案
* @Param
* @Return
* @Author hecan
* @Date 2024/6/6 16:10
* **/
JsonResultEntity queryMemberArchives(JSONObject jsonObject);
}

View File

@ -1,19 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IMasterDataOrgsService extends IBaseService<ComparisonEntity, String> {
/**
*
* @content 查询组织档案
* @Param
* @Return
* @Author hecan
* @Date 2024/6/4 16:57
* **/
JsonResultEntity queryOrgsArchives(JSONObject jsonObject);
}

View File

@ -1,19 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IMasterDataProjectService extends IBaseService<ComparisonEntity, String> {
/**
*
* @content 查询项目档案
* @Param
* @Return
* @Author hecan
* @Date 2024/6/6 16:10
* **/
JsonResultEntity queryProjectArchives(JSONObject jsonObject);
}

View File

@ -1,149 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.entity.MdmModuleSourceEntity;
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.service.IMasterDataCustoMermanageService;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataProjectService;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service("MasterDataCustoMermanageServiceImpl")
public class MasterDataCustoMermanageServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataCustoMermanageService {
@Autowired
private MasterDataDaoImpl masterDataDaoImpl;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
private String ts = "";
//同步客户档案到主数据
public JsonResultEntity queryCustoMermanageArchives(JSONObject json){
JSONObject jsonObject = json.getJSONObject("jsonStr");
//查询主数据来源表根据来源类型为插件得进行分类获取来源名称和编码
List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
if (CollectionUtils.isEmpty(list)) {
logger.info("数据来源表中没有类型为插件得数据,无法获取来源名称和来源编码");
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
//通过不同的应用类型用于拼接sql
String appTyp = mdmModuleSourceEntity.getAppType();
String dbCode = mdmModuleSourceEntity.getDbCode();
switch (appTyp) {
case "1":
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("SELECT id as id,field0013 AS code,field0014 AS name,field0016 AS pk_custclass,field0015 AS shortname,field0012 AS pk_org FROM formmain_0226 WHERE 1=1 AND id = '1706533959075383844' " );
mdmModuleSourceEntity.setDataSourceCode(dbCode);
try {
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
logger.info("查询出来的值为:{}",hashMaps);
if (null != hashMaps && hashMaps.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,"10004");
} else {
logger.info("U8C主数据档案客商档案没有需要同步中台的数据");
return null;
}
} catch (Exception e) {
logger.info("查询主数据档案客商档案错误:{}", e.getMessage());
}
break;
default:
break;
}
}
return BaseResult.getSuccessMessageEntity("客商档案同步成功");
}
//查询档案参数组装
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<HashMap<String, Object>> hashMaps,String mdmCode){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject jsonObjectUser = new JSONObject();
JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("id", hashMap.get("id"));
jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser);
//查询明细信息
Long formmainId = (Long) hashMap.get("id");
StringBuffer stringBufferDetails = new StringBuffer();
stringBufferDetails.append("SELECT field0023 AS pk_bankdoc,field0024 AS accnum,field0025 AS combinenum FROM formson_0229 WHERE formmain_id = '"+formmainId+"' " );
List<HashMap<String, Object>> hashMapsDetails = masterDataDaoImpl.queryArchivesByDataSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
//先查询编码和名称查询是否存在
JsonResultEntity jsonResultEntity = comparisonServiceimpl.queryEntityPage(jsonStr);
Object attribute = jsonResultEntity.getAttribute();
logger.info("得到的attribute值为{}", 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);
jsonObjectUser.put("details", hashMapsDetails);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.saveEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案新增用户档案失败,失败原因:{}",e.getMessage());
}
} else {
for (Object o : jsonArrayList) {
JSONObject jsonObjectUpdate = JSON.parseObject(String.valueOf(o));
String id = jsonObjectUpdate.getString("id");
JSONObject main = new JSONObject();
for(String key:hashMap.keySet()) {
main.put(key, hashMap.get(key));
main.put("id",id);
}
jsonObjectUser.put("main", main);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.updateEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案更新用户档案失败,失败原因:{}", e.getMessage());
}
}
}
}
return null;
}
}

View File

@ -1,144 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.entity.MdmModuleSourceEntity;
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.service.IMasterDataMemberService;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataProjectService;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service("MasterDataMemberServiceImpl")
public class MasterDataMemberServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataMemberService {
@Autowired
private MasterDataDaoImpl masterDataDaoImpl;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
private String ts = "";
//同步用户信息到主数据
public JsonResultEntity queryMemberArchives(JSONObject json){
JSONObject jsonObject = json.getJSONObject("jsonStr");
//查询主数据来源表根据来源类型为插件得进行分类获取来源名称和编码
List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
if (CollectionUtils.isEmpty(list)) {
logger.info("数据来源表中没有类型为插件得数据,无法获取来源名称和来源编码");
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
//通过不同的应用类型用于拼接sql
String appTyp = mdmModuleSourceEntity.getAppType();
String dbCode = mdmModuleSourceEntity.getDbCode();
switch (appTyp) {
case "1":
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select a.id as 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" +
" WHERE 1=1 " + sb.toString());
mdmModuleSourceEntity.setDataSourceCode(dbCode);
try {
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
logger.info("查询出来的值为:{}",hashMaps);
if (null != hashMaps && hashMaps.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,"10003");
} else {
logger.info("U8C主数据用户档案没有需要同步中台的数据");
return null;
}
} catch (Exception e) {
logger.info("查询主数据档案用户档案错误:{}", e.getMessage());
}
break;
default:
break;
}
}
return BaseResult.getSuccessMessageEntity("用户档案同步成功");
}
//查询档案参数组装
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<HashMap<String, Object>> hashMaps,String mdmCode){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject jsonObjectUser = new JSONObject();
JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("id", hashMap.get("id"));
jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser);
//先查询编码和名称查询是否存在
JsonResultEntity jsonResultEntity = comparisonServiceimpl.queryEntityPage(jsonStr);
Object attribute = jsonResultEntity.getAttribute();
logger.info("得到的attribute值为{}", 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);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.saveEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案新增用户档案失败,失败原因:{}",e.getMessage());
}
} else {
for (Object o : jsonArrayList) {
JSONObject jsonObjectUpdate = JSON.parseObject(String.valueOf(o));
String id = jsonObjectUpdate.getString("id");
JSONObject main = new JSONObject();
for(String key:hashMap.keySet()) {
main.put(key, hashMap.get(key));
main.put("id",id);
}
jsonObjectUser.put("main", main);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.updateEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案更新用户档案失败,失败原因:{}", e.getMessage());
}
}
}
}
return null;
}
}

View File

@ -1,138 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.entity.MdmModuleSourceEntity;
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.service.IMasterDataOrgsService;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataProjectService;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service("masterDataOrgsServiceImpl")
public class MasterDataOrgsServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataOrgsService {
@Autowired
private MasterDataDaoImpl masterDataDaoImpl;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
private String ts = "";
//查询用户档案并同步中台
@Override
public JsonResultEntity queryOrgsArchives(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr");
//查询主数据来源表根据来源类型为插件得进行分类获取来源名称和编码
List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
if (CollectionUtils.isEmpty(list)) {
logger.info("数据来源表中没有类型为插件得数据,无法获取来源名称和来源编码");
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
//此处应该根据来源编码进行case 暂时测试使用U8C
switch (mdmModuleSourceEntity.getPluginCode()) {
case "MdmOrgPlugin":
if (null == ts || "".equals(ts)) {
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
}
ts = "'" + ts + "'";
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select pk_corp as id,unitcode as org_code,unitname as org_name,");
stringBuffer.append("saleaddr as org_address,countryarea as org_countryzone,memo as org_memo,");
stringBuffer.append("industry as org_ncindustry,fathercorp as org_fatherorg,legalbodycode as org_principal,");
stringBuffer.append("phone1 as org_tel from bd_corp where dr='0' and ts>"+ts);
try {
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchives(stringBuffer.toString());
logger.info("查询出来的值为:{}",hashMaps);
if (null != hashMaps && hashMaps.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,"10001");
} else {
logger.info("U8C主数据档案组织档案没有需要同步中台的数据");
return null;
}
} catch (Exception e) {
logger.info("查询主数据档案组织档案错误:{}", e.getMessage());
}
break;
default:
break;
}
}
return BaseResult.getSuccessMessageEntity("组织档案同步成功");
}
//查询档案参数组装
private void ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<HashMap<String, Object>> hashMaps,String mdmCode){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject jsonObjectUser = new JSONObject();
JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("id", hashMap.get("id"));
jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser);
//先查询编码和名称查询是否存在
JsonResultEntity jsonResultEntity = comparisonServiceimpl.queryEntityPage(jsonStr);
Object attribute = jsonResultEntity.getAttribute();
logger.info("得到的attribute值为{}", 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);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.saveEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案新增档案失败,失败原因:{}",e.getMessage());
}
} else {
for (Object o : jsonArrayList) {
JSONObject jsonObjectUpdate = JSON.parseObject(String.valueOf(o));
String id = jsonObjectUpdate.getString("id");
JSONObject main = new JSONObject();
for(String key:hashMap.keySet()) {
main.put(key, hashMap.get(key));
main.put("id",id);
}
jsonObjectUser.put("main", main);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.updateEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案更新档案失败,失败原因:{}", e.getMessage());
}
}
}
}
}
}

View File

@ -1,132 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.entity.MdmModuleSourceEntity;
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.service.IMasterDataProjectService;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service("masterDataProjectServiceImpl")
public class MasterDataProjectServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataProjectService {
@Autowired
private MasterDataDaoImpl masterDataDaoImpl;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
private String ts = "";
//同步项目档案
public JsonResultEntity queryProjectArchives(JSONObject json){
JSONObject jsonObject = json.getJSONObject("jsonStr");
//查询主数据来源表根据来源类型为插件得进行分类获取来源名称和编码
List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
if (CollectionUtils.isEmpty(list)) {
logger.info("数据来源表中没有类型为插件得数据,无法获取来源名称和来源编码");
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
//此处应该根据来源编码进行case 暂时测试使用U8C
switch (mdmModuleSourceEntity.getPluginCode()) {
case "MdmProjectPlugin":
if (null == ts || "".equals(ts)) {
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
}
ts = "'" + ts + "'";
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select pk_jobbasfil as id,jobcode as project_code, jobname as project_name from bd_jobbasfil where dr='0' and ts>" + ts);
try {
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchives(stringBuffer.toString());
logger.info("查询出来的值为:{}",hashMaps);
if (null != hashMaps && hashMaps.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,"10002");
} else {
logger.info("U8C主数据档案项目档案没有需要同步中台的数据");
return null;
}
} catch (Exception e) {
logger.info("查询主数据档案项目档案错误:{}", e.getMessage());
}
break;
default:
break;
}
}
return BaseResult.getSuccessMessageEntity("项目档案同步成功");
}
//查询档案参数组装
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<HashMap<String, Object>> hashMaps,String mdmCode){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject jsonObjectUser = new JSONObject();
JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("id", hashMap.get("id"));
jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser);
//先查询编码和名称查询是否存在
JsonResultEntity jsonResultEntity = comparisonServiceimpl.queryEntityPage(jsonStr);
Object attribute = jsonResultEntity.getAttribute();
logger.info("得到的attribute值为{}", 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);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.saveEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案新增用户档案失败,失败原因:{}",e.getMessage());
}
} else {
for (Object o : jsonArrayList) {
JSONObject jsonObjectUpdate = JSON.parseObject(String.valueOf(o));
String id = jsonObjectUpdate.getString("id");
JSONObject main = new JSONObject();
for(String key:hashMap.keySet()) {
main.put(key, hashMap.get(key));
main.put("id",id);
}
jsonObjectUser.put("main", main);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.updateEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案更新用户档案失败,失败原因:{}", e.getMessage());
}
}
}
}
return null;
}
}

View File

@ -10,7 +10,6 @@ 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.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.IMasterDataProjectService;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataService; import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataService;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl; import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.web.entity.BaseResult; import com.hzya.frame.web.entity.BaseResult;
@ -54,30 +53,31 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
return BaseResult.getFailureMessageEntity("数据来源表无插件类型"); return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
} }
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) { for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
String tableName = "";
try { try {
//通过不同的应用类型用于拼接sql //通过不同的应用类型用于拼接sql
String appTyp = mdmModuleSourceEntity.getAppType(); String appTyp = mdmModuleSourceEntity.getAppType();
String dbCode = mdmModuleSourceEntity.getDbCode(); String dbCode = mdmModuleSourceEntity.getDbCode();
String mdmCode = mdmModuleSourceEntity.getMdmCode(); String mdmCode = mdmModuleSourceEntity.getMdmCode();
List<HashMap<String, Object>>hashMaps = new ArrayList<>(); List<JSONObject> listAll = new ArrayList<>();
List<HashMap<String, Object>> hashMapsDetails = new ArrayList<>(); if(!"10007".equals(mdmCode)){
continue;
}
switch (appTyp) {//1致远OA 2用友U8C 3用友BIP switch (appTyp) {//1致远OA 2用友U8C 3用友BIP
case "1": case "1":
//通过主数据编码判断不同的接口走不通的查询逻辑 //通过主数据编码判断不同的接口走不通的查询逻辑
switch (mdmCode){ switch (mdmCode){
case "10003"://致远用户信息 case "10003"://致远用户信息
bindingUser(jsonObject, mdmModuleSourceEntity, dbCode); tableName = "mdm_user";
listAll = bindingUser(jsonObject, mdmModuleSourceEntity, dbCode);
break; break;
case "10004"://致远客商信息 case "10004"://致远客商信息
hashMaps = binDingCust(jsonObject, mdmModuleSourceEntity, dbCode); tableName = "mdm_customer";
//查询明细数据 listAll = binDingCust(jsonObject, mdmModuleSourceEntity, dbCode);
for (HashMap<String, Object> hashMap : hashMaps) { break;
//查询明细信息 case "10007"://致远客商信息
Long formmainId = (Long) hashMap.get("id"); tableName = "mdm_bank";
StringBuffer stringBufferDetails = new StringBuffer(); listAll = binDingBank(jsonObject, mdmModuleSourceEntity, dbCode);
stringBufferDetails.append("SELECT field0023 AS pk_bankdoc,field0024 AS accnum,field0025 AS combinenum FROM formson_0229 WHERE formmain_id = '"+formmainId+"' " );
hashMapsDetails = masterDataDaoImpl.queryArchivesByDataSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
}
break; break;
default: default:
logger.info("未匹配到主数据的编码,请检查"); logger.info("未匹配到主数据的编码,请检查");
@ -85,8 +85,8 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
} }
} }
//调用主数据接口进行数据推送或更新 //调用主数据接口进行数据推送或更新
if (null != hashMaps && hashMaps.size() > 0) { if (null != listAll && listAll.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,mdmCode,hashMapsDetails); ParametricAssembly(mdmModuleSourceEntity,listAll,mdmCode,tableName);
} else { } else {
logger.info("U8C主数据档案没有需要同步中台的数据"); logger.info("U8C主数据档案没有需要同步中台的数据");
} }
@ -95,52 +95,123 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
e.printStackTrace(); e.printStackTrace();
} }
} }
return BaseResult.getSuccessMessageEntity("项目档案同步成功"); return BaseResult.getSuccessMessageEntity("主数据同步成功");
} }
//绑定客户档案 //绑定银行
private List<HashMap<String, Object>> binDingCust(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) { private List<JSONObject> binDingBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
List<HashMap<String, Object>> hashMap; List<JSONObject> list = new ArrayList<>();
StringBuffer sbCust = 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");
sbCust.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");
sbCust.append(" and a.update_time >= '"+ts+"'"); sb.append(" and a.update_time >= '"+ts+"'");
} }
StringBuffer stringBufferCust = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
stringBufferCust.append("SELECT id as id,field0013 AS code,field0014 AS name,field0016 AS pk_custclass,field0015 AS shortname,field0012 AS pk_org FROM formmain_0226 WHERE 1=1 "+ sbCust.toString()); stringBuffer.append("select *from bank");
mdmModuleSourceEntity.setDataSourceCode(dbCode); mdmModuleSourceEntity.setDataSourceCode(dbCode);
return masterDataDaoImpl.queryArchivesByDataSource(stringBufferCust.toString(),mdmModuleSourceEntity); 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_bank",mdm);
list.add(main);
}
}
return list;
}
//绑定客户档案
private List<JSONObject> binDingCust(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
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 a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("SELECT id as 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 ");
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
if(CollectionUtils.isNotEmpty(hashMaps)){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject();
JSONObject mdm_cust = new JSONObject();
for(String key:hashMap.keySet()) {
mdm_cust.put(key, hashMap.get(key));
}
//获取明细信息
Long formmainId = (Long) hashMap.get("id");
StringBuffer stringBufferDetails = new StringBuffer();
stringBufferDetails.append("SELECT id as id ,field0023 AS pk_bankdoc,field0024 AS accnum,field0025 AS combinenum FROM formson_0229 WHERE formmain_id = '"+formmainId+"' " );
List<HashMap<String, Object>> hashMapsDetails = masterDataDaoImpl.queryArchivesByDataSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
JSONArray mdm_customer_bank = new JSONArray();
if(CollectionUtils.isNotEmpty(hashMapsDetails)){
for (HashMap<String, Object> detailsMap : hashMapsDetails) {
JSONObject details = new JSONObject();
for (String key : detailsMap.keySet()) {
details.put(key, detailsMap.get(key));
}
mdm_customer_bank.add(details);
}
}
main.put("mdm_customer_bank",mdm_customer_bank);
main.put("mdm_customer",mdm_cust);
list.add(main);
}
}
return list;
} }
//绑定OA用户参数 //绑定OA用户参数
private JSONArray bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) { private List<JSONObject> bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
StringBuffer sbUser = new StringBuffer(); List<JSONObject> list = new ArrayList<>();
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");
sbUser.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");
sbUser.append(" and a.update_time >= '"+ts+"'"); sb.append(" and a.update_time >= '"+ts+"'");
} }
StringBuffer stringBufferUser = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
stringBufferUser.append("SELECT id as id,field0013 AS code,field0014 AS name,field0016 AS pk_custclass,field0015 AS shortname,field0012 AS pk_org FROM formmain_0226 WHERE 1=1 "+ sbUser.toString()); stringBuffer.append("select a.id as 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" +
" WHERE 1=1 " + sb.toString());
mdmModuleSourceEntity.setDataSourceCode(dbCode); mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBufferUser.toString(),mdmModuleSourceEntity); List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
for (HashMap<String, Object> hashMap : hashMaps) { int i = 0;
if(CollectionUtils.isNotEmpty(hashMaps)){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject();
JSONObject mdm_user = new JSONObject();
for(String key:hashMap.keySet()) {
mdm_user.put(key, hashMap.get(key));
}
main.put("mdm_user",mdm_user);
list.add(main);
}
} }
return null; return list;
} }
//查询档案参数组装 //查询档案参数组装
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<HashMap<String, Object>> hashMaps,String mdmCode,List<HashMap<String, Object>> hashMapsDetails){ public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<JSONObject> hashMaps,String mdmCode,String tableName){
for (HashMap<String, Object> hashMap : hashMaps) { for (JSONObject hashMap : hashMaps) {
JSONObject main = hashMap.getJSONObject(tableName);
JSONObject jsonObjectUser = new JSONObject(); JSONObject jsonObjectUser = new JSONObject();
JSONObject jsonStr = new JSONObject(); JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("id", hashMap.get("id")); jsonObjectUser.put("id", main.get("id"));
jsonObjectUser.put("mdmCode", mdmCode); jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser); jsonStr.put("jsonStr", jsonObjectUser);
//先查询编码和名称查询是否存在 //先查询编码和名称查询是否存在
@ -151,40 +222,32 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
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);
jsonObjectUser.put("appName","数智中台"); hashMap.put("appName","数智中台");
jsonObjectUser.put("appCode","800004"); hashMap.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台"); hashMap.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser); hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap);
try { try {
comparisonServiceimpl.saveEntity(jsonStr); JsonResultEntity result = comparisonServiceimpl.saveEntity(jsonStr);
} catch (Exception e) { } catch (Exception e) {
logger.info("U8C主数据档案新增用户档案失败,失败原因:{}",e.getMessage()); logger.info("U8C主数据档案新增用户档案失败,失败原因:{}",e.getMessage());
} }
} else { } else {
for (Object o : jsonArrayList) { hashMap.put("appName","数智中台");
JSONObject jsonObjectUpdate = JSON.parseObject(String.valueOf(o)); hashMap.put("appCode","800004");
String id = jsonObjectUpdate.getString("id"); hashMap.put("mdmCode", mdmCode);
JSONObject main = new JSONObject(); hashMap.put("optionName", "数智中台");
for(String key:hashMap.keySet()) { jsonStr.put("jsonStr", hashMap);
main.put(key, hashMap.get(key)); try {
main.put("id",id); comparisonServiceimpl.updateEntity(jsonStr);
} } catch (Exception e) {
jsonObjectUser.put("main", main); logger.info("U8C主数据档案更新用户档案失败,失败原因:{}", e.getMessage());
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.updateEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案更新用户档案失败,失败原因:{}", e.getMessage());
}
} }
} }
} }