定时抽取业务数据和定时下发业务数据
This commit is contained in:
parent
eb13e0e40d
commit
8a098cf6d4
|
@ -50,6 +50,12 @@
|
||||||
<profile.active>sw</profile.active>
|
<profile.active>sw</profile.active>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>hclocal</id> <!--何灿-->
|
||||||
|
<properties>
|
||||||
|
<profile.active>hclocal</profile.active>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
<build>
|
<build>
|
||||||
<finalName>kangarooDataCenterV3</finalName>
|
<finalName>kangarooDataCenterV3</finalName>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,62 @@
|
||||||
|
package com.hzya.frame.plugin.serviceData.plugin;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.base.PluginBaseEntity;
|
||||||
|
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataService;
|
||||||
|
import com.hzya.frame.sysnew.comparison.serviceData.service.IServiceDataService;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务数据同步
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-06-21 13:52:35
|
||||||
|
*/
|
||||||
|
public class ServiceDataPluginInitializer extends PluginBaseEntity{
|
||||||
|
Logger logger = LoggerFactory.getLogger(ServiceDataPluginInitializer.class);
|
||||||
|
@Autowired
|
||||||
|
private IServiceDataService serviceDataService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginId() {
|
||||||
|
return "ServiceDataPluginInitializer";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginName() {
|
||||||
|
return "业务数据抽取";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginLabel() {
|
||||||
|
return "ServiceDataPluginInitializer";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginType() {
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity executeBusiness(JSONObject requestJson) {
|
||||||
|
try {
|
||||||
|
logger.info("======开始执行业务数据信息同步========");
|
||||||
|
return serviceDataService.queryDocumentView(requestJson);
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("======执行业务数据同步失败:{}========",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,5 +23,8 @@ spring:
|
||||||
savefile:
|
savefile:
|
||||||
# 文件保存路径
|
# 文件保存路径
|
||||||
path: D:\yongansystem\kangarooDataCenter\v3\logs
|
path: D:\yongansystem\kangarooDataCenter\v3\logs
|
||||||
|
pluginpath: /home/webservice/zt/plugin
|
||||||
|
# tomcatpath: D:\apache-tomcat-9.0.69\webapps\kangarooDataCenter\WEB-INF\classes\
|
||||||
|
tomcatpath: /home/webservice/zt/tomcatV3/webapps/kangarooDataCenterV3/WEB-INF/classes/
|
||||||
zt:
|
zt:
|
||||||
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
|
url: http://127.0.0.1:8901/kangarooDataCenterV3/entranceController/externalCallInterface
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<plugin>
|
||||||
|
<id>ServiceDataPluginInitializer</id>
|
||||||
|
<name>ServiceDataPluginInitializer插件</name>
|
||||||
|
<category>90000001</category>
|
||||||
|
</plugin>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||||
|
<beans default-autowire="byName">
|
||||||
|
<bean name="ServiceDataPluginInitializer" class="com.hzya.frame.plugin.serviceData.plugin.ServiceDataPluginInitializer" />
|
||||||
|
<bean name="ServiceDataDistributePluginInitializer" class="com.hzya.frame.plugin.serviceData.plugin.ServiceDataDistributePluginInitializer" />
|
||||||
|
</beans>
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.hzya.frame.sysnew.comparison.serviceData.dao;
|
||||||
|
|
||||||
|
import com.hzya.frame.basedao.dao.IBaseDao;
|
||||||
|
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
|
||||||
|
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IServiceDataDao extends IBaseDao<ComparisonEntity,String> {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 查询三维单据视图
|
||||||
|
* @Param
|
||||||
|
* @Return
|
||||||
|
* @Author hecan
|
||||||
|
* @Date 2024-11-28 14:50
|
||||||
|
* **/
|
||||||
|
List<HashMap<String, Object>> queryListBySWSource(String str , MdmModuleSourceEntity entity);
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.hzya.frame.sysnew.comparison.serviceData.dao.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.hzya.frame.basedao.dao.MybatisGenericDao;
|
||||||
|
import com.hzya.frame.execsql.service.IExecSqlService;
|
||||||
|
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
|
||||||
|
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
|
||||||
|
import com.hzya.frame.sysnew.comparison.serviceData.dao.IServiceDataDao;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
@Repository(value = "ServiceDataDaoImpl")
|
||||||
|
public class ServiceDataDaoImpl extends MybatisGenericDao<ComparisonEntity,String> implements IServiceDataDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IExecSqlService execSqlService;
|
||||||
|
|
||||||
|
private Logger logger = LogManager.getLogger(super.getClass());
|
||||||
|
@DS("#entity.dataSourceCode")
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> queryListBySWSource(String str, MdmModuleSourceEntity entity) {
|
||||||
|
try {
|
||||||
|
List<HashMap<String, Object>> hashMaps = execSqlService.execSelectSql(str, "");
|
||||||
|
return hashMaps;
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("三维单据视图中没有需要同步中台的数据");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.hzya.frame.sysnew.comparison.serviceData.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 IServiceDataService extends IBaseService<ComparisonEntity,String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 查询数据
|
||||||
|
* @Param
|
||||||
|
* @Return
|
||||||
|
* @Author hecan
|
||||||
|
* @Date 2024-11-28 14:54
|
||||||
|
* **/
|
||||||
|
JsonResultEntity queryDocumentView(JSONObject json);
|
||||||
|
}
|
|
@ -0,0 +1,167 @@
|
||||||
|
package com.hzya.frame.sysnew.comparison.serviceData.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.dao.MybatisGenericDao;
|
||||||
|
import com.hzya.frame.basedao.service.impl.BaseService;
|
||||||
|
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.service.impl.ComparisonServiceImpl;
|
||||||
|
import com.hzya.frame.sysnew.comparison.serviceData.dao.IServiceDataDao;
|
||||||
|
import com.hzya.frame.sysnew.comparison.serviceData.dao.impl.ServiceDataDaoImpl;
|
||||||
|
import com.hzya.frame.sysnew.comparison.serviceData.service.IServiceDataService;
|
||||||
|
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.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service(value = "ServiceDataServiceImpl")
|
||||||
|
public class ServiceDataServiceImpl extends BaseService<ComparisonEntity,String> implements IServiceDataService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ServiceDataDaoImpl serviceDataDao;
|
||||||
|
@Autowired
|
||||||
|
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
|
||||||
|
@Autowired
|
||||||
|
private ComparisonServiceImpl comparisonServiceimpl;
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity queryDocumentView(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) {
|
||||||
|
String tableName = "";
|
||||||
|
try {
|
||||||
|
String appTyp = mdmModuleSourceEntity.getAppType();//系统类型 1、致远OA 2、用友U8C 3、用友BIP
|
||||||
|
String dbCode = mdmModuleSourceEntity.getDbCode();//数据源编码
|
||||||
|
String mdmCode = mdmModuleSourceEntity.getMdmCode();//主数据编码
|
||||||
|
List<JSONObject> listAll = new ArrayList<>();
|
||||||
|
switch (appTyp){
|
||||||
|
case "1":
|
||||||
|
switch (mdmCode){
|
||||||
|
case "10045"://付款申请
|
||||||
|
tableName = "cmp_apply";
|
||||||
|
listAll = bindingDocument(jsonObject, mdmModuleSourceEntity, dbCode);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//将查询出来的数据进行组装,调用通用方法新增或者更新
|
||||||
|
if (null != listAll && listAll.size() > 0) {
|
||||||
|
ParametricDocument(listAll, mdmCode, tableName);
|
||||||
|
} else {
|
||||||
|
logger.info("U8C主数据档案没有需要同步中台的数据");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("业务数据同步失败:{}",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BaseResult.getSuccessMessageEntity("业务数据同步成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<JSONObject> bindingDocument(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
|
||||||
|
try {
|
||||||
|
List<JSONObject> list = new ArrayList<>();
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
stringBuffer.append("select oa_id as data_id,vdef1 as vdef1,applysum,pk_acceptorg,pk_group,pk_trantypecode,pk_busitype,\n" +
|
||||||
|
" pk_supplier,pk_bankacc_r as pk_bankacc_r\n" +
|
||||||
|
" from v_OA_TO_BIP where 1=1 " + sb.toString());
|
||||||
|
mdmModuleSourceEntity.setDataSourceCode(dbCode);
|
||||||
|
List<HashMap<String, Object>> hashMaps = serviceDataDao.queryListBySWSource(stringBuffer.toString(), mdmModuleSourceEntity);
|
||||||
|
int i = 0;
|
||||||
|
if (CollectionUtils.isNotEmpty(hashMaps)) {
|
||||||
|
for (HashMap<String, Object> hashMap : hashMaps) {
|
||||||
|
JSONObject main = new JSONObject();
|
||||||
|
JSONObject cmp_apply = new JSONObject();
|
||||||
|
for (String key : hashMap.keySet()) {
|
||||||
|
cmp_apply.put(key, hashMap.get(key));
|
||||||
|
}
|
||||||
|
//获取明细信息
|
||||||
|
String formmainId = (String) hashMap.get("data_id");
|
||||||
|
StringBuffer stringBufferDetails = new StringBuffer();
|
||||||
|
stringBufferDetails.append("select d_id as data_id,tab_name,pk_supplier,pk_bankacc_r,pk_currtype,vdef1,vdef2,vdef3,vdef4\n" +
|
||||||
|
" from v_OA_TO_BIP_DETAILS where formmain_id= '"+formmainId+"' " );
|
||||||
|
List<HashMap<String, Object>> hashMapsDetails = serviceDataDao.queryListBySWSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
|
||||||
|
JSONArray cmp_apply_b = 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));
|
||||||
|
}
|
||||||
|
cmp_apply_b.add(details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
main.put("cmp_apply_b",cmp_apply_b);
|
||||||
|
main.put("cmp_apply", cmp_apply);
|
||||||
|
list.add(main);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.info("组装单据是图查询参数失败:{}", e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonResultEntity ParametricDocument(List<JSONObject> hashMaps,String mdmCode,String tableName){
|
||||||
|
try {
|
||||||
|
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);
|
||||||
|
JSONObject pageInfo = jsonObjectAttribute.getJSONObject("pageInfo");
|
||||||
|
JSONArray jsonArrayList = pageInfo.getJSONArray("list");
|
||||||
|
//如果jsonArrayList为null,说明没有值,在表中不存在
|
||||||
|
if (jsonArrayList == null || jsonArrayList.size() == 0) {
|
||||||
|
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));
|
||||||
|
} 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("将数据查询之后进行组装调用通用方法错误:{}",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue