调整OA对接BIP代码

This commit is contained in:
hecan 2024-12-20 11:13:32 +08:00
parent c996ade1ee
commit 71c1d1bfb3
7 changed files with 193 additions and 109 deletions

View File

@ -135,9 +135,22 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
String id = requestJson.getString("integration_task_living_details_id");
//执行重新发送
if (StrUtil.isNotEmpty(id)) {
logger.info("========开始执行业务数据下发重推接口,重推id为{}=======", id);
//查询日志表
IntegrationTaskLivingDetailsEntity taskDetailEntity = taskLivingDetailsService.get(id);
if (null != taskDetailEntity && JSONUtil.isTypeJSON(taskDetailEntity.getRootAppPk())) {
ServiceDataEntity zt = new ServiceDataEntity();
zt.setBillCode(taskDetailEntity.getRootAppBill());
List<ServiceDataEntity> list = serviceDataDao.queryDataByVdef1(zt);
if (list == null || list.size() == 0) {
logger.info("重试id{}该数据下发状态已经为1不再重推", id);
taskDetailEntity.setResult("发送成功");
taskLivingDetailsService.saveLogFailToSuccess(taskDetailEntity);
return BaseResult.getFailureMessageEntity("发送成功");
} else {
//拿到这张表的源系统ID
JSONObject jsonObject = JSONObject.parseObject(taskDetailEntity.getRootAppPk());
Long mdmCode = jsonObject.getLong("mdmCode");//主数据编码
@ -251,15 +264,23 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
queryFildRule.setRuleCode("service");
List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities = mdmModuleDbFiledsRuleDao.queryBase(queryFildRule);
String mainDb = null;
String mainId = null;
//获取主数据db对应的实体表的数据
JSONObject object = new JSONObject();
for (int i = 0; i < mdmModuleDbEntities.size(); i++) {
if ("1".equals(mdmModuleDbEntities.get(i).getDbType())) {
mainDb = mdmModuleDbEntities.get(i).getDbName();
Map<String, Object> map = new HashMap<>();
map.put("tableName", mdmModuleDbEntities.get(i).getDbName());
map.put("documentRule", documentRule);
object = mdmModuleDao.queryMdmST(map);
object = toLowerCaseKeys(object);
mainId = object.getString("id");
if (object.getString("id") == null || "".equals(object.getString("id"))) {
taskDetailEntity.setResult("当前数据不存在");
taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity);
@ -346,6 +367,8 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
object.put(mdmModuleDbEntities.get(i).getDbName(), detail);
}
}
logger.info("=========开始执行业务数据下发重试脚本,第一次==========");
//执行脚本
JSONObject groovy = new JSONObject();
JSONObject parameterJson = new JSONObject();
@ -403,6 +426,7 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
headers.putAll(header);
}
if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) {
logger.info("========业务数据下发重试开始执行登录接口==========");
//找到登陆接口
SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort());
if (null == loginApi) {
@ -425,17 +449,21 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
return BaseResult.getFailureMessageEntity("发送错误:" + rzjsonResultEntity.getMsg());
}
JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString());
logger.info("=======业务数据下发重试登录返回数据:{}========", attritube.toJSONString());
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("=====业务数据下发重试调用BIP付款申请返回结果为:{}", JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString());
if (jsonResultEntity.isFlag()) {
if ("1".equals(type)) {//保存三方返回id
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");
@ -464,17 +492,18 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
ServiceDataEntity serviceDataEntity = new ServiceDataEntity();
serviceDataEntity.setBillCode(jsonObjectParent.getString("vdef1"));
serviceDataEntity.setDataSourceCode("SW-OA");
logger.info("========业务数据下发重试中开始根据单据编号:{}查询数据=============", jsonObjectParent.getString("vdef1"));
List<ServiceDataEntity> query = serviceDataDao.query(serviceDataEntity);
if (CollectionUtils.isNotEmpty(query)) {
logger.info("===下发时候开始根据OA单据编号{}更新BIP付款申请单号:{}",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno"));
logger.info("===重试下发时候开始根据OA单据编号{}更新BIP付款申请单号:{}", jsonObjectParent.getString("vdef1"), backJsonResultEntity.getString("vbillno"));
serviceDataEntity.setTabName(query.get(0).getTabName());
serviceDataEntity.setBipPaymentNumberField(query.get(0).getBipPaymentNumberField());
serviceDataEntity.setBipPaymentNumber(query.get(0).getBipPaymentNumber());
serviceDataEntity.setBipPaymentNumber(backJsonResultEntity.getString("vbillno"));
serviceDataEntity.setId(query.get(0).getId());
serviceDataDao.updateBipPaymentNumber(serviceDataEntity);
logger.info("===下发时候根据OA单据编号{}更新BIP付款申请单号:{}完毕",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno"));
logger.info("===重试下发时候根据OA单据编号{}更新BIP付款申请单号:{}完毕", jsonObjectParent.getString("vdef1"), backJsonResultEntity.getString("vbillno"));
} else {
logger.info("======下发时候根据单据编号:{}未能在三维OA查询到数据Bip付款申请单号不回写",jsonObjectParent.getString("vdef1"));
logger.info("======重试下发时候根据单据编号:{}未能在三维OA查询到数据Bip付款申请单号不回写", jsonObjectParent.getString("vdef1"));
}
}
}
@ -489,6 +518,16 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
}
taskDetailEntity.setResult("发送成功");
taskLivingDetailsService.saveLogFailToSuccess(taskDetailEntity);
logger.info("=======业务数据重试完毕开始根据id:{},表名称:{}更新新增下发状态============", mainId, mainDb);
if (StrUtil.isNotEmpty(mainId)) {
Map<String, Object> updateMap = new HashMap<>();
updateMap.put("tableName", mainDb);
updateMap.put("addStatus", "1");
updateMap.put("id", mainId);
mdmModuleDao.updateMdmSTs(updateMap);
}
return BaseResult.getFailureMessageEntity("发送成功");
} else {
taskDetailEntity.setResult("发送错误");
@ -496,8 +535,9 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
return BaseResult.getFailureMessageEntity("发送错误");
}
}
}
}else {//执行正常下发
logger.info("==========开始执行正常业务数据下发=============");
//查询主数据
MdmModuleEntity queryMdmModuleEntity = new MdmModuleEntity();
queryMdmModuleEntity.setSts("Y");
@ -1030,7 +1070,6 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
continue;
}
getDetailData(mdmModuleDbEntities,doObjects.get(i),mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//执行脚本
JSONObject groovy = new JSONObject();
JSONObject parameterJson = new JSONObject();
@ -1057,6 +1096,7 @@ public class ServiceDataDistributePluginInitializer 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());
@ -1084,7 +1124,7 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
headers.putAll(header);
}
if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) {
logger.info("=========正常业务数据开始执行登录接口==============");
//找到登陆接口
SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort());
if (null == loginApi) {
@ -1105,15 +1145,19 @@ public class ServiceDataDistributePluginInitializer 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("=====业务数据下发重试调用BIP付款申请返回结果为:{}",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");
@ -1149,17 +1193,18 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
ServiceDataEntity serviceDataEntity=new ServiceDataEntity();
serviceDataEntity.setBillCode(jsonObjectParent.getString("vdef1"));
serviceDataEntity.setDataSourceCode("SW-OA");
logger.info("========正常业务数据下发开始根据单据编号:{}查询数据==========",jsonObjectParent.getString("vdef1"));
List<ServiceDataEntity> query = serviceDataDao.query(serviceDataEntity);
if(CollectionUtils.isNotEmpty(query)){
logger.info("===下发时候开始根据OA单据编号{}更新BIP付款申请单号:{}",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno"));
logger.info("===正常下发时候开始根据OA单据编号{}更新BIP付款申请单号:{}",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno"));
serviceDataEntity.setTabName(query.get(0).getTabName());
serviceDataEntity.setBipPaymentNumberField(query.get(0).getBipPaymentNumberField());
serviceDataEntity.setBipPaymentNumber(backJsonResultEntity.getString("vbillno"));
serviceDataEntity.setId(query.get(0).getId());
serviceDataDao.updateBipPaymentNumber(serviceDataEntity);
logger.info("===下发时候根据OA单据编号{}更新BIP付款申请单号:{}完毕",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno"));
logger.info("===正常下发时候根据OA单据编号{}更新BIP付款申请单号:{}完毕",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno"));
}else{
logger.info("======下发时候根据单据编号:{}未能在三维OA查询到数据Bip付款申请单号不回写",jsonObjectParent.getString("vdef1"));
logger.info("======正常下发时候根据单据编号:{}未能在三维OA查询到数据Bip付款申请单号不回写",jsonObjectParent.getString("vdef1"));
}
}
}
@ -1235,7 +1280,7 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
aa.put("distributeId",distributeId);//发送表id
aa.put("type",option_type);//发送类型1新增2修改3删除
integrationTaskLivingDetailsEntity.setRootAppPk(aa.toJSONString());
integrationTaskLivingDetailsEntity.setRootAppBill(jsonObject.getString("document_rule"));
integrationTaskLivingDetailsEntity.setRootAppBill(jsonObject.getString("vdef1"));
integrationTaskLivingDetailsEntity.setPluginId("ServiceDataDistributePluginInitializer");
integrationTaskLivingDetailsEntity.setRootAppNewData(source_data);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(remark);

View File

@ -3,7 +3,7 @@ logging:
#日志级别 指定目录级别
level:
root: info
encodings: UTF-8
encodings: GBK
file:
# 日志保存路径
path: D:\yongansystem\kangarooDataCenter\v3\logs
@ -16,7 +16,7 @@ spring:
# username: root
# password: bd993088e8a7c3dc5f44441617f9b4bf
# driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
url: jdbc:mysql://ufidahz.com.cn:9014/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
url: jdbc:mysql://127.0.0.1:3307/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
username: root
password: 62e4295b615a30dbf3b8ee96f41c820b
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
@ -27,4 +27,4 @@ savefile:
# tomcatpath: D:\apache-tomcat-9.0.69\webapps\kangarooDataCenter\WEB-INF\classes\
tomcatpath: /home/webservice/zt/tomcatV3/webapps/kangarooDataCenterV3/WEB-INF/classes/
zt:
url: http://127.0.0.1:8901/kangarooDataCenterV3/entranceController/externalCallInterface
url: http://127.0.0.1:9011/kangarooDataCenterV3/entranceController/externalCallInterface

View File

@ -170,7 +170,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
JSONObject jsonObjectMain=new JSONObject();
JSONArray jsonArray=new JSONArray();
List<JSONArray> arrayList=new ArrayList<>();
logger.info("=========通用新增接口中获取主表和明细表信息完成===============");
String tableName=null;
//根据dbtype和dbname分组拿到表名称和表类型
Map<String, Map<String, List<ComparisonEntity>>> collect = comparisonEntities.stream().collect(Collectors.groupingBy(ComparisonEntity::getDbName, Collectors.groupingBy(ComparisonEntity::getDbType)));
@ -187,6 +187,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
if(main!=null){
jsonObjectMain = JSONObject.parseObject(main);
if(!checkStr(jsonObjectMain.getString("data_id"))){
logger.info("=======新增时候主表data_id不能为空============");
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("新增时候主表data_id不能为空");
@ -201,6 +202,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
JSONObject jsonObjectDetails = jsonArray.getJSONObject(i);
jsonObjectDetails.put("table_name", keyPair.getKey());
if(!checkStr(jsonObjectDetails.getString("data_id"))){
logger.info("=======新增时候明细data_id不能为空============");
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("新增时候明细data_id不能为空");
@ -210,6 +212,8 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
}
}
logger.info("=========根据dbtype和dbname分组拿到表名称和表类型完成===============");
if(jsonObjectMain!=null && jsonObjectMain.size()>0) {
Map<String, Object> map = new HashMap<>();//将主表数据存到map中
List<List<Map<String, Object>>> mapDetails = new ArrayList<>();//将子表数据存到map中
@ -412,6 +416,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("根据主数据编码查询信息错误:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("更新失败");
}
logger.info("=========通用更新接口中获取主表和明细表信息完成===============");
JSONObject jsonObjectMain=new JSONObject();
JSONArray jsonArray=new JSONArray();
List<JSONArray> arrayList=new ArrayList<>();
@ -790,6 +795,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
//根据主数据编码获取主表和明细表表名称表字段信息
public List<ComparisonEntity> getComparisonEntityCache(ComparisonEntity comparison,String type){
try {
List<ComparisonEntity> comparisonEntities = new ArrayList<>();
//根据主数据编号获取模板主表
MdmModuleEntity mdmModuleEntity = mdmServiceCache.getMdmModuleEntity(Long.valueOf(comparison.getMdmCode()));
@ -805,6 +811,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
mdmModuleViewEntity.setMdmId(mdmModuleEntity.getId());
List<MdmModuleViewEntity> mdmModuleViewEntities = mdmModuleViewDao.query(mdmModuleViewEntity);
//根据mdm_id查询mdm_module_db的信息
MdmModuleDbEntity mdmModuleDbEntity = new MdmModuleDbEntity();
mdmModuleDbEntity.setMdmId(mdmModuleEntity.getId());
@ -891,6 +898,9 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
return comparisonEntities;
}
}catch (Exception e){
logger.info("====通用数据中根据主数据编码获取主表和明细表表名称,表字段信息错误:{}",e.getMessage());
}
return null;
}

View File

@ -77,4 +77,14 @@ public interface IServiceDataDao extends IBaseDao<ServiceDataEntity,String> {
* @Date 2024-12-09 11:56
* **/
Integer updateElectronic(ServiceDataEntity entity);
/**
*
* @content 根据单据编号查询中台中相关表的下发数据,避免重推时候将所有未下发数据都推送过去
* @Param
* @Return
* @Author hecan
* @Date 2024-12-19 10:49
* **/
List<ServiceDataEntity> queryDataByVdef1(ServiceDataEntity entity);
}

View File

@ -63,8 +63,15 @@ public class ServiceDataDaoImpl extends MybatisGenericDao<ServiceDataEntity,Stri
return (List<ServiceDataEntity>) super.selectList("queryServiceElectronic",entity);
}
@DS("#entity.dataSourceCode")
@Override
public Integer updateElectronic(ServiceDataEntity entity) {
return super.update("updateElectronic",entity);
}
@DS("#entity.dataSourceCode")
@Override
public List<ServiceDataEntity> queryDataByVdef1(ServiceDataEntity entity) {
return super.query("queryDataByVdef1",entity);
}
}

View File

@ -55,6 +55,18 @@
</trim>
</select>
<!-- 查询 采用==查询 -->
<select id="queryDataByVdef1" resultMap="get-ServiceDataEntity-result" parameterType = "com.hzya.frame.sysnew.comparison.serviceData.entity.ServiceDataEntity">
select
*
from cmp_apply
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> and id = #{id} </if>
<if test="billCode != null and billCode != ''"> and vdef1 = #{billCode} </if>
and add_status='0' order by modify_time desc limit 1
</trim>
</select>
<!-- 查询 采用==查询 -->
<select id="queryServiceElectronic" resultMap="get-ServiceDataEntity-result" parameterType = "com.hzya.frame.sysnew.comparison.serviceData.entity.ServiceDataEntity">
select

View File

@ -295,7 +295,7 @@ public class ServiceDataServiceImpl extends BaseService<ComparisonEntity,String>
"push_status_field,summary_id,bip_payment_number_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 from v_cmp_apply where 1=1 and vdef1 is not null and push_status is null ");
"vdef7,vdef8,vdef9 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;