This commit is contained in:
lvleigang 2025-03-28 14:36:29 +08:00
commit d91b75dae4
16 changed files with 521 additions and 88 deletions

View File

@ -470,7 +470,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
}
}
}else {//执行正常下发
logger.info("==========开始执行正常主数据下发=============");
//查询主数据
MdmModuleEntity queryMdmModuleEntity = new MdmModuleEntity();
queryMdmModuleEntity.setSts("Y");
@ -509,13 +509,17 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
queryFildRule.setRuleCode("service");
List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities = mdmModuleDbFiledsRuleDao.queryBase(queryFildRule);
if(mdmModuleEntities.get(i).getMdmCode()!= 10045L){
//新增
doAdd(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//修改
doUpdate(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//删除
doDelete(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
}else{
logger.info("主数据编码为10045已经在业务数据下发执行主数据下发不执行");
continue;
}
}
}
@ -827,6 +831,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
/** body */
String bodys = doObjects.get(i).toJSONString();
if(scriptEntity != null && scriptEntity.getId() != null ){
logger.info("=========开始执行正常主数据修改下发脚本,第一次==============");
groovy.put("code",scriptEntity.getScriptCode());
groovy.put("className",scriptEntity.getClassName());
groovy.put("name",scriptEntity.getScriptName());
@ -854,6 +859,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
headers.putAll(header);
}
if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) {
logger.info("=========正常主数据修改开始执行登录接口==============");
//找到登陆接口
SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort());
if (null == loginApi) {
@ -874,12 +880,15 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
continue;
}
JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString());
logger.info("=======主数据正常修改下发登录返回数据:{}========",attritube.toJSONString());
querys = getQuery(apiEntity,querys,attritube);
headers = getHeaders(apiEntity,headers,attritube);
bodys = getBodys(apiEntity,bodys,attritube);
}
//组装数据发送
logger.info("=========开始执行主业务修改数据下发脚本,第二次==============");
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
logger.info("=====主数据修改下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString());
if(jsonResultEntity.isFlag()){
//保存日志
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"2");
@ -911,7 +920,8 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
* @param mdmModuleDistributeEntities
* @return void
**/
private void doAdd(String mdmId,Long mainCode,List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities,List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities,List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities ) throws Exception {
private void
doAdd(String mdmId,Long mainCode,List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities,List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities,List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities ) throws Exception {
//查询一千条数据
String mainDb = null;
List<JSONObject> objects = new ArrayList<>();
@ -1029,6 +1039,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
/** body */
String bodys = doObjects.get(i).toJSONString();
if(scriptEntity != null && scriptEntity.getId() != null ){
logger.info("=========开始执行正常主数据新增下发脚本,第一次==============");
groovy.put("code",scriptEntity.getScriptCode());
groovy.put("className",scriptEntity.getClassName());
groovy.put("name",scriptEntity.getScriptName());
@ -1056,6 +1067,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
headers.putAll(header);
}
if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) {
logger.info("=========正常主数据新增开始执行登录接口==============");
//找到登陆接口
SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort());
if (null == loginApi) {
@ -1076,15 +1088,19 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
continue;
}
JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString());
logger.info("=======主数据正常新增下发登录返回数据:{}========",attritube.toJSONString());
querys = getQuery(apiEntity,querys,attritube);
headers = getHeaders(apiEntity,headers,attritube);
bodys = getBodys(apiEntity,bodys,attritube);
}
//组装数据发送
logger.info("=========开始执行主业务新增数据下发脚本,第二次==============");
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
logger.info("=====主数据新增下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString());
if(jsonResultEntity.isFlag()){
if (scriptEntity != null && scriptEntity.getId() != null && scriptEntity.getBackScriptData() != null ) {
logger.info("=========开始执行主数据新增返回脚本==============");
JSONObject backScriptJson = new JSONObject();
backScriptJson.put("data", jsonResultEntity.getAttribute());
groovy.put("code", scriptEntity.getScriptCode()+"back");
@ -1124,11 +1140,13 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
//保存日志
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1");
objects.get(i).put("sendsanfzt123",true);
logger.info("========主数据新增下发完成,日志保存为成功============");
continue;
}else {
//保存日志
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1");
objects.get(i).put("sendsanfzt123",false);
logger.info("========主数据新增下发完成,日志保存为失败============");
continue;
}
}

View File

@ -0,0 +1,56 @@
package com.hzya.frame.plugin.payables.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.sysnew.payables.service.IPayablesService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class PayablesPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(PayablesPluginInitializer.class);
@Autowired
private IPayablesService payablesService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "PayablesPluginInitializer";
}
@Override
public String getPluginName() {
return "应付单抽取";
}
@Override
public String getPluginLabel() {
return "PayablesPluginInitializer";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行应付单同步========");
return payablesService.queryPayables(requestJson);
}catch (Exception e){
logger.info("======执行应付单失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -34,6 +34,24 @@ public class ProjectMainFlowEntity extends BaseEntity {
private String auditResult;//审定推送结果
private String archivistResult;//归档推送结果
private String archivistStatus;//归档推送状态
private String def8;//完工服务额
private String def7;//J审定服务金额
public String getDef8() {
return def8;
}
public void setDef8(String def8) {
this.def8 = def8;
}
public String getDef7() {
return def7;
}
public void setDef7(String def7) {
this.def7 = def7;
}
public String getCompletemoney() {
return completemoney;

View File

@ -19,26 +19,26 @@
,'666' as pkOrg -- 公司编码
,field0274 as contractno -- 合同号
,field0279 as contractname -- 合同名称
,field0081 as creator -- 创建人
,m4.name as creator -- 创建人
,field0003 as creationtime -- 创建时间
,field0007 as projectno -- 项目号
,field0120 as completemoney -- 完工金额
,field0116 as completemoney -- 完工金额
,field0294 as completedate -- 完工日期
,field0108 as completepersion -- 完工填单人
,m1.name as completepersion -- 完工填单人
,field0149 as pinspectionmoney -- 初验金额
,field0147 as pinspectiondate -- 初验时间
,field0159 as pinspectionpersion -- 初验填单人
,field0213 as auditmoney -- 审计金额
,m2.name as pinspectionpersion -- 初验填单人
,field0209 as auditmoney -- 审计金额
,field0297 as auditdate -- 审计时间
,field0237 as auditpersion -- 审计填单人
,m3.name as auditpersion -- 审计填单人
,null as forecastRevenue -- 预估收入确认
,field0138 as vnote -- 备注
,field0120 as completemoney -- 完工服务额
,field0120 as def8 -- 完工服务额
,field0320 as def2 -- F完工辅材额公司
,field0321 as def3 -- F完工辅材额自购
,field0294 as completedate -- 完工完成时间
,field0112 as def4 -- F实际完工日期
,field0213 as auditmoney -- J审定服务金额
,field0213 as def7 -- J审定服务金额
,field0354 as def5 -- J审定辅材额公司
,field0355 as def6 -- J审定辅材额自购
,field0297 as auditdate -- 审计完成时间
@ -57,6 +57,10 @@
from formmain_0219
LEFT JOIN COL_SUMMARY ON COL_SUMMARY.FORM_RECORDID = formmain_0219.id
LEFT JOIN CTP_AFFAIR ON CTP_AFFAIR.object_id = COL_SUMMARY.id
LEFT JOIN org_member m1 ON m1.id=field0108
LEFT JOIN org_member m2 ON m2.id=field0159
LEFT JOIN org_member m3 ON m3.id=field0237
LEFT JOIN org_member m4 ON m4.id=field0081
WHERE 1=1
and CTP_AFFAIR.node_policy = '审计完成' AND CTP_AFFAIR.complete_time is not null
and CTP_AFFAIR.state = '4' and CTP_AFFAIR.sub_state = '0' and field0427 is null
@ -72,6 +76,10 @@
from formmain_0219
LEFT JOIN COL_SUMMARY ON COL_SUMMARY.FORM_RECORDID = formmain_0219.id
LEFT JOIN CTP_AFFAIR ON CTP_AFFAIR.object_id = COL_SUMMARY.id
LEFT JOIN org_member m1 ON m1.id=field0108
LEFT JOIN org_member m2 ON m2.id=field0159
LEFT JOIN org_member m3 ON m3.id=field0237
LEFT JOIN org_member m4 ON m4.id=field0081
WHERE 1=1
and CTP_AFFAIR.node_policy = '归档' AND CTP_AFFAIR.complete_time is not null
and CTP_AFFAIR.state = '4' and CTP_AFFAIR.sub_state = '0' and field0425 is null and formmain_0219.id='4000079310249084585'

View File

@ -182,6 +182,8 @@ public class ProjectMainFlowArchivistPluginInitializer extends PluginBaseEntity
htdd01slave4_htdd01slave4.put("def4",projectMainFlowEntity.getDef4());
htdd01slave4_htdd01slave4.put("def5",projectMainFlowEntity.getDef5());
htdd01slave4_htdd01slave4.put("def6",projectMainFlowEntity.getDef6());
htdd01slave4_htdd01slave4.put("def7",projectMainFlowEntity.getDef7());
htdd01slave4_htdd01slave4.put("def8",projectMainFlowEntity.getDef8());
jsonArray.add(htdd01slave4_htdd01slave4);
bill.put("htdd01Master",htdd01Master);
bill.put("htdd01slave4_htdd01slave4",jsonArray);

View File

@ -174,6 +174,8 @@ public class ProjectMainFlowAuditPluginInitializer extends PluginBaseEntity {
htdd01slave4_htdd01slave4.put("def4",projectMainFlowEntity.getDef4());
htdd01slave4_htdd01slave4.put("def5",projectMainFlowEntity.getDef5());
htdd01slave4_htdd01slave4.put("def6",projectMainFlowEntity.getDef6());
htdd01slave4_htdd01slave4.put("def7",projectMainFlowEntity.getDef7());
htdd01slave4_htdd01slave4.put("def8",projectMainFlowEntity.getDef8());
jsonArray.add(htdd01slave4_htdd01slave4);
bill.put("htdd01Master",htdd01Master);
bill.put("htdd01slave4_htdd01slave4",jsonArray);

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>PayablesPluginInitializer</id>
<name>PayablesPluginInitializer插件</name>
<category>90000009</category>
</plugin>

View File

@ -0,0 +1,5 @@
<?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="PayablesPluginInitializer" class="com.hzya.frame.plugin.payables.plugin.PayablesPluginInitializer" />
</beans>

View File

@ -3,4 +3,6 @@
<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" />
<bean name="MarginPaymentPluginInitializer" class="com.hzya.frame.plugin.serviceData.plugin.MarginPaymentPluginInitializer" />
<bean name="ReceivedPluginInitializer" class="com.hzya.frame.plugin.serviceData.plugin.ReceivedPluginInitializer" />
</beans>

View File

@ -80,7 +80,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
case "1":
//通过主数据编码判断不同的接口走不通的查询逻辑
switch (mdmCode){
case "10003"://致远用户信息
/*case "10003"://致远用户信息
tableName = "mdm_user";
listAll = bindingUser(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break;
@ -91,15 +91,19 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
case "10007"://银行信息
tableName = "mdm_bank";
listAll = binDingBank(jsonObject, mdmModuleSourceEntity, dbCode);
break;
case "10046"://BIP供应商档案
break;*/
case "10047"://BIP供应商档案
tableName = "mdm_bip_supplier";
listAll = binDingSupplier(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break;
case "10047"://BIP项目档案
case "10048"://BIP项目档案
tableName = "mdm_bip_project";
listAll = binDingProject(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break;
case "10049"://BIP供应商银行档案
tableName = "mdm_bip_supplier_bank";
listAll = binDingSupplierBank(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break;
default:
logger.info("未匹配到主数据的编码,请检查");
break;
@ -123,15 +127,12 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
private List<JSONObject> binDingProject(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception {
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 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+"'");
if(StrUtil.isNotEmpty(startTime) && StrUtil.isNotEmpty(endTime)){
sb.append(" AND MODIFY_DATE >= TO_DATE('"+startTime+"','yyyy-MM-dd HH24:mi:ss') ");
sb.append(" AND MODIFY_DATE <> TO_DATE('"+endTime+"','yyyy-MM-dd HH24:mi:ss') ");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("");
stringBuffer.append("select * from v_hzya_project where 1=1 "+sb.toString());
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
int i = 0;
@ -140,7 +141,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
JSONObject main = new JSONObject();
JSONObject mdm = new JSONObject();
for(String key:hashMap.keySet()) {
mdm.put(key, hashMap.get(key));
mdm.put(key.toLowerCase(), hashMap.get(key));
}
main.put("mdm_bip_project",mdm);
list.add(main);
@ -149,26 +150,44 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
return list;
}
//绑定供应商银行账户
private List<JSONObject> binDingSupplierBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception {
List<JSONObject> list = new ArrayList<>();
StringBuffer sb = new StringBuffer();
if(StrUtil.isNotEmpty(startTime) && StrUtil.isNotEmpty(endTime)){
sb.append(" AND MODIFY_DATE >= TO_DATE('"+startTime+"','yyyy-MM-dd HH24:mi:ss') ");
sb.append(" AND MODIFY_DATE <> TO_DATE('"+endTime+"','yyyy-MM-dd HH24:mi:ss') ");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select * from v_hzya_supplier_bank where 1=1 "+sb.toString());
mdmModuleSourceEntity.setDataSourceCode(dbCode);
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.toLowerCase(), hashMap.get(key));
}
main.put("mdm_bip_supplier_bank",mdm);
list.add(main);
}
}
return list;
}
//绑定供应商
private List<JSONObject> binDingSupplier(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception {
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 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+"'");
if(StrUtil.isNotEmpty(startTime) && StrUtil.isNotEmpty(endTime)){
sb.append(" AND MODIFY_DATE >= TO_DATE('"+startTime+"','yyyy-MM-dd HH24:mi:ss') ");
sb.append(" AND MODIFY_DATE <> TO_DATE('"+endTime+"','yyyy-MM-dd HH24:mi:ss') ");
}
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') ");
stringBuffer.append("select * from v_hzya_supplier where 1=1 "+sb.toString());
logger.info("主数据抽取供应商的sql语句为:{}",stringBuffer.toString());
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
int i = 0;
@ -177,7 +196,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
JSONObject main = new JSONObject();
JSONObject mdm = new JSONObject();
for(String key:hashMap.keySet()) {
mdm.put(key, hashMap.get(key));
mdm.put(key.toLowerCase(), hashMap.get(key));
}
main.put("mdm_bip_supplier",mdm);
list.add(main);
@ -300,10 +319,11 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
//查询档案参数组装
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<JSONObject> hashMaps,String mdmCode,String tableName)throws Exception{
JSONObject jsonObjectUser = new JSONObject();
List<Object> result=new ArrayList<>();
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);
@ -312,38 +332,33 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr);
logger.info("得到的attribute值为{}", jsonStr.toJSONString(attribute));
JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute);
JSONArray jsonArrayList = jsonObjectAttribute.getJSONArray("list");
JSONObject pageInfo = jsonObjectAttribute.getJSONObject("pageInfo");
JSONArray jsonArrayList = pageInfo.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));
// if(!result.isFlag()){
// throw new BaseSystemException("主数据保存失败"+ result.getMsg());
// }
Object object = comparisonServiceimpl.saveEntity(jsonStr);
logger.info("新增结果为:{}", JSON.toJSONString(object));
result.add(object);
} else {
hashMap.put("appName","数智中台");
hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap);
Object result = comparisonServiceimpl.updateEntity(jsonStr);
Object object = comparisonServiceimpl.updateEntity(jsonStr);
logger.info("更新结果为:{}", JSON.toJSONString(result));
// if(!result.isFlag()){
// //throw new BaseSystemException("主数据更新失败"+ result.getMsg());
// }
result.add(object);
}
}
}catch (Exception e){
logger.info("将数据查询之后进行组装调用通用方法错误:{}",e.getMessage());
e.printStackTrace();
}
return null;
}

View File

@ -304,7 +304,7 @@ public class ServiceDataServiceImpl extends BaseService<ComparisonEntity,String>
"push_status_field,summary_id,bip_payment_number_field,bip_amount_field,\n" +
"vdef1,pk_acceptorg,creator,pk_group,pk_org,applydate,pk_trantypecode,pk_busitype,vdef2,pk_currtype,\n" +
"pk_supplier,pk_bankacc_r,pk_bankacc_p,pk_decidedept,vdef10,vdef12,vdef3,vdef4,vdef5,vdef6,applysum,\n" +
"vdef7,vdef8,vdef9,vdef21 from v_cmp_apply where 1=1 and vdef1 is not null and push_status is null and applysum >0");
"vdef7,vdef8,vdef9,vdef21,vdef11,vdef17,vdef20 from v_cmp_apply where 1=1 and vdef1 is not null and push_status is null and applysum >0");
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = serviceDataDao.queryListBySWSource(stringBuffer.toString(), mdmModuleSourceEntity);
int i = 0;
@ -321,7 +321,7 @@ public class ServiceDataServiceImpl extends BaseService<ComparisonEntity,String>
StringBuffer stringBufferDetails = new StringBuffer();
stringBufferDetails.append("select d_id as data_id,tab_name,pk_balatype,pk_acceptorg,pk_org,pk_group,pk_busitype,rowno,\n" +
"pk_supplier,pk_bankacc_r,customer,pk_currtype,pk_decidedept,gllcrate,applysum,applymny,vdef1,pk_project,vdef2,vdef3,\n" +
"vdef4,vdef10 from v_cmp_apply_b where formmain_id= '"+formmainId+"' " );
"vdef4,vdef10,vdef14 from v_cmp_apply_b where formmain_id= '"+formmainId+"' " );
List<HashMap<String, Object>> hashMapsDetails = serviceDataDao.queryListBySWSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
JSONArray cmp_apply_b = new JSONArray();
if(CollectionUtils.isNotEmpty(hashMapsDetails)){

View File

@ -0,0 +1,21 @@
package com.hzya.frame.sysnew.payables.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.sysnew.payables.entity.PayablesEntity;
import java.util.HashMap;
import java.util.List;
public interface IPayablesDao extends IBaseDao<PayablesEntity,String> {
/**
*
* @content 查询三维应付单数据
* @Param
* @Return
* @Author hecan
* @Date 2024-11-28 14:50
* **/
List<HashMap<String, Object>> queryListByPayables(String str , MdmModuleSourceEntity entity);
}

View File

@ -0,0 +1,35 @@
package com.hzya.frame.sysnew.payables.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.payables.dao.IPayablesDao;
import com.hzya.frame.sysnew.payables.entity.PayablesEntity;
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 = "PayablesDaoImpl")
public class PayablesDaoImpl extends MybatisGenericDao<PayablesEntity,String> implements IPayablesDao {
@Autowired
private IExecSqlService execSqlService;
private Logger logger = LogManager.getLogger(super.getClass());
@DS("#entity.dataSourceCode")
@Override
public List<HashMap<String, Object>> queryListByPayables(String str, MdmModuleSourceEntity entity) {
try {
List<HashMap<String, Object>> hashMaps = execSqlService.execSelectSql(str, "");
return hashMaps;
}catch (Exception e){
logger.info("三维应付单中没有需要同步中台的数据");
return null;
}
}
}

View File

@ -0,0 +1,6 @@
package com.hzya.frame.sysnew.payables.entity;
import com.hzya.frame.web.entity.BaseEntity;
public class PayablesEntity extends BaseEntity {
}

View File

@ -0,0 +1,18 @@
package com.hzya.frame.sysnew.payables.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.payables.entity.PayablesEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IPayablesService extends IBaseService<PayablesEntity,String> {
/**
*
* @content 查询需要抽取得数据
* @Param
* @Return
* @Author hecan
* @Date 2024-11-28 14:54
* **/
JsonResultEntity queryPayables(JSONObject json);
}

View File

@ -0,0 +1,221 @@
package com.hzya.frame.sysnew.payables.service.impl;
import cn.hutool.core.date.DateUtil;
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.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.sysnew.comparison.serviceData.entity.ServiceDataEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.sysnew.payables.dao.impl.PayablesDaoImpl;
import com.hzya.frame.sysnew.payables.entity.PayablesEntity;
import com.hzya.frame.sysnew.payables.service.IPayablesService;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import lombok.Value;
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.Date;
import java.util.HashMap;
import java.util.List;
@Service(value = "PayablesServiceImpl")
public class PayablesServiceImpl extends BaseService<PayablesEntity,String> implements IPayablesService {
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
@Autowired
private PayablesDaoImpl payablesDao;
@Autowired
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Override
public JsonResultEntity queryPayables(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 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 tableName = "";
List<Object> object=new ArrayList<>();
List<JSONObject> listAll = new ArrayList<>();
try {
String appTyp = mdmModuleSourceEntity.getAppType();//系统类型 1致远OA 2用友U8C 3用友BIP
String dbCode = mdmModuleSourceEntity.getDbCode();//数据源编码
String mdmCode = mdmModuleSourceEntity.getMdmCode();//主数据编码
switch (appTyp){
case "1":
switch (mdmCode){
case "10050"://应付单
tableName = "mdm_payables";
listAll = bindingPayables(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break;
default:
break;
}
break;
default:
break;
}
//将查询出来的数据进行组装调用通用方法新增或者更新
if (null != listAll && listAll.size() > 0) {
ParametricDocument(listAll, mdmCode, tableName);
} else {
logger.info("三维应付单没有需要同步中台的数据");
}
}catch (Exception e){
logger.info("应付单同步失败:{}",e.getMessage());
saveTaskLivingDetails(JSONObject.parseObject(listAll.get(0).getString("mdm_payables")).getString("data_id"),JSONObject.parseObject(listAll.get(0).getString("mdm_payables")).getString("sourcecode"),listAll.get(0).toString(),JSON.parseObject(JSON.toJSONString(object)).getString("msg")==null?JSON.parseObject(JSON.toJSONString(object)).getString("list"):JSON.parseObject(JSON.toJSONString(object)).getString("msg"),false);
e.printStackTrace();
}
}
return BaseResult.getSuccessMessageEntity("业务数据同步成功");
}
private List<JSONObject> bindingPayables(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime) {
String formmainId=null;
String vdef1=null;
List<JSONObject> list = new ArrayList<>();
try {
StringBuffer sb = new StringBuffer();
if(StrUtil.isNotEmpty(startTime) && StrUtil.isNotEmpty(endTime)){
sb.append(" AND MODIFY_DATE >= TO_DATE('"+startTime+"','yyyy-MM-dd HH24:mi:ss') ");
sb.append(" AND MODIFY_DATE <> TO_DATE('"+endTime+"','yyyy-MM-dd HH24:mi:ss') ");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select * from v_hzya_payables where 1=1 "+sb.toString());
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = payablesDao.queryListByPayables(stringBuffer.toString(), mdmModuleSourceEntity);
int i = 0;
if (CollectionUtils.isNotEmpty(hashMaps)) {
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject();
JSONObject payables = new JSONObject();
for (String key : hashMap.keySet()) {
payables.put(key.toLowerCase(), hashMap.get(key));
}
//获取明细信息
formmainId = payables.getString("data_id");
StringBuffer stringBufferDetails = new StringBuffer();
stringBufferDetails.append("select * from v_hzya_payables_details where f_id= '"+formmainId+"' " );
List<HashMap<String, Object>> hashMapsDetails = payablesDao.queryListByPayables(stringBufferDetails.toString(),mdmModuleSourceEntity);
JSONArray payables_details = new JSONArray();
if(CollectionUtils.isNotEmpty(hashMapsDetails)){
for (HashMap<String, Object> detailsMap : hashMapsDetails) {
JSONObject details = new JSONObject();
for (String key : detailsMap.keySet()) {
details.put(key.toLowerCase(), detailsMap.get(key));
}
payables_details.add(details);
}
}
main.put("mdm_payables_details",payables_details);
main.put("mdm_payables", payables);
list.add(main);
}
}
return list;
} catch (Exception e) {
logger.info("组装单据是图查询参数失败:{}", e.getMessage());
//保存业务数据日志
saveTaskLivingDetails(formmainId,vdef1,list.toString(),null,false);
e.printStackTrace();
}
return null;
}
private List<Object> ParametricDocument(List<JSONObject> hashMaps,String mdmCode,String tableName){
JSONObject jsonObjectUser = new JSONObject();
List<Object> result=new ArrayList<>();
try {
for (JSONObject hashMap : hashMaps) {
JSONObject main = hashMap.getJSONObject(tableName);
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 object = comparisonServiceimpl.saveEntity(jsonStr);
logger.info("应付单新增结果为:{}", JSON.toJSONString(object));
result.add(object);
} else {
hashMap.put("appName","数智中台");
hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap);
Object object = comparisonServiceimpl.updateEntity(jsonStr);
logger.info("应付单更新结果为:{}", JSON.toJSONString(result));
result.add(object);
}
}
return result;
}catch (Exception e){
logger.info("将数据查询之后进行组装调用通用方法错误:{}",e.getMessage());
//保存业务数据日志
saveTaskLivingDetails(jsonObjectUser.getString("data_id"),hashMaps.get(0).getString("sourcecode"),hashMaps.get(0).toString(),result.toString(),false);
e.printStackTrace();
}
return null;
}
private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag) {
try {
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
integrationTaskLivingDetailsEntity.setSts("Y");
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
integrationTaskLivingDetailsEntity.setModify_user_id("1");
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
integrationTaskLivingDetailsEntity.setModify_time(new Date());
integrationTaskLivingDetailsEntity.setOrg_id("0");
integrationTaskLivingDetailsEntity.setCompanyId("0");
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill);
integrationTaskLivingDetailsEntity.setPluginId("PayablesPluginInitializer");
integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo);
if(flag){
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
}else {
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
}
}catch (Exception e){
logger.info("应付单抽取保存日志到集成任务日志明细中失败:{}",e.getMessage());
e.printStackTrace();
}
}
}