获取数据来源插件编码
This commit is contained in:
parent
603d7331b8
commit
fa81637f50
|
@ -0,0 +1,23 @@
|
||||||
|
package com.hzya.frame.sysnew.comparison.masterData.dao;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.hzya.frame.basedao.service.IBaseService;
|
||||||
|
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IMasterDataDao extends IBaseService<ComparisonEntity, String> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 查询U8C档案
|
||||||
|
* @Param
|
||||||
|
* @Return
|
||||||
|
* @Author hecan
|
||||||
|
* @Date 2024/6/6 11:56
|
||||||
|
* **/
|
||||||
|
@DS("swu8c")
|
||||||
|
List<HashMap<String, Object>> queryArchives(String str);
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.hzya.frame.sysnew.comparison.masterData.dao.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.hzya.frame.basedao.service.impl.BaseService;
|
||||||
|
import com.hzya.frame.execsql.service.IExecSqlService;
|
||||||
|
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
|
||||||
|
import com.hzya.frame.sysnew.comparison.masterData.dao.IMasterDataDao;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository(value = "masterDataDaoImpl")
|
||||||
|
public class MasterDataDaoImpl extends BaseService<ComparisonEntity, String> implements IMasterDataDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IExecSqlService execSqlService;
|
||||||
|
|
||||||
|
@DS("swu8c")
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> queryArchives(String str) {
|
||||||
|
try {
|
||||||
|
List<HashMap<String, Object>> hashMaps = execSqlService.execSelectSql(str, "");
|
||||||
|
return hashMaps;
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("U8C主数据档案用户档案没有需要同步中台的数据");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
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);
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
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("sourceName",mdmModuleSourceEntity.getSourceName());
|
||||||
|
jsonObjectUser.put("code",mdmModuleSourceEntity.getSourceCode());
|
||||||
|
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("sourceName",mdmModuleSourceEntity.getSourceName());
|
||||||
|
jsonObjectUser.put("code",mdmModuleSourceEntity.getSourceCode());
|
||||||
|
jsonObjectUser.put("optionName", "数智中台");
|
||||||
|
jsonStr.put("jsonStr", jsonObjectUser);
|
||||||
|
try {
|
||||||
|
comparisonServiceimpl.updateEntity(jsonStr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.info("U8C主数据档案更新档案失败,失败原因:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
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("sourceName",mdmModuleSourceEntity.getSourceName());
|
||||||
|
jsonObjectUser.put("code",mdmModuleSourceEntity.getSourceCode());
|
||||||
|
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("sourceName",mdmModuleSourceEntity.getSourceName());
|
||||||
|
jsonObjectUser.put("code",mdmModuleSourceEntity.getSourceCode());
|
||||||
|
jsonObjectUser.put("optionName", "数智中台");
|
||||||
|
jsonStr.put("jsonStr", jsonObjectUser);
|
||||||
|
try {
|
||||||
|
comparisonServiceimpl.updateEntity(jsonStr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.info("U8C主数据档案更新用户档案失败,失败原因:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue