推送BIP付款申请,有返回bip单号时候,将支付状态修改为待支付,推送失败,将失败原因回写支付状态中

This commit is contained in:
hecan 2025-04-09 11:23:09 +08:00
parent 9f86196f06
commit b882b4c581
3 changed files with 54 additions and 18 deletions

View File

@ -1155,6 +1155,15 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
//组装数据发送
logger.info("=========开始执行正常业务数据下发脚本,第二次==============");
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
//根据OA单据编号更新BIP付款申请单号
JSONObject jsonObjectBody = JSONObject.parseObject(bodys);
String parent = jsonObjectBody.getString("parent");
JSONObject jsonObjectParent = JSONObject.parseObject(parent);
ServiceDataEntity serviceDataEntity=new ServiceDataEntity();
serviceDataEntity.setBillCode(jsonObjectParent.getString("vdef1"));
serviceDataEntity.setDataSourceCode("SW-OA");
logger.info("========正常业务数据下发开始根据单据编号:{}查询数据==========",jsonObjectParent.getString("vdef1"));
List<ServiceDataEntity> query = serviceDataDao.query(serviceDataEntity);
logger.info("=====业务数据下发调用BIP付款申请返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString());
if(jsonResultEntity.isFlag()){
if (scriptEntity != null && scriptEntity.getId() != null && scriptEntity.getBackScriptData() != null ) {
@ -1187,15 +1196,7 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId());
mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("vbillno"));
mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity);
//根据OA单据编号更新BIP付款申请单号
JSONObject jsonObjectBody = JSONObject.parseObject(bodys);
String parent = jsonObjectBody.getString("parent");
JSONObject jsonObjectParent = JSONObject.parseObject(parent);
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"));
serviceDataEntity.setTabName(query.get(0).getTabName());
@ -1203,6 +1204,14 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
serviceDataEntity.setBipPaymentNumber(backJsonResultEntity.getString("vbillno"));
serviceDataEntity.setId(query.get(0).getId());
serviceDataDao.updateBipPaymentNumber(serviceDataEntity);
//更新支付结果为待支付
serviceDataEntity.setPayResult("待支付");
serviceDataEntity.setPayResultFiled(query.get(0).getPayResultFiled());
serviceDataEntity.setDataSourceCode("SW-OA");
logger.info("====开始根据单据号:{},表名称:{},表单id:{}更新支付状态为待支付======", serviceDataEntity.getBillCode(), serviceDataEntity.getTabName(), serviceDataEntity.getId());
serviceDataDao.updatePayResult(serviceDataEntity);
logger.info("====根据单据号:{},表名称:{},表单id:{}更新支付状态为待支付完成======", serviceDataEntity.getBillCode(), serviceDataEntity.getTabName(), serviceDataEntity.getId());
//修改下发状态
logger.info("===正常下发时候根据OA单据编号{}更新BIP付款申请单号:{}完毕",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno"));
Map<String, Object> updateMap = new HashMap<>();
updateMap.put("tableName",mainDb);
@ -1213,6 +1222,21 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
}else{
logger.info("======正常下发时候根据单据编号:{}未能在三维OA查询到数据Bip付款申请单号不回写",jsonObjectParent.getString("vdef1"));
}
}else {
if (CollectionUtils.isNotEmpty(query)) {
//保存推送BIP返回的错误信息
//将BIP返回的失败信息保存到支付结果中
serviceDataEntity.setPayResult(backJsonResultEntity.getString("message"));
serviceDataEntity.setDataSourceCode("SW-OA");
serviceDataEntity.setPayResultFiled(query.get(0).getPayResultFiled());
serviceDataEntity.setId(query.get(0).getId());
serviceDataEntity.setTabName(query.get(0).getTabName());
logger.info("====开始根据单据号:{},表名称:{},表单id:{}更新支付状态为BIP返回的失败信息======", serviceDataEntity.getBillCode(), serviceDataEntity.getTabName(), serviceDataEntity.getId());
serviceDataDao.updatePayResult(serviceDataEntity);
logger.info("====根据单据号:{},表名称:{},表单id:{}更新支付状态为BIP返回的失败信息======", serviceDataEntity.getBillCode(), serviceDataEntity.getTabName(), serviceDataEntity.getId());
}else{
logger.info("======正常下发时候根据单据编号:{}未能在三维OA查询到数据不将BIP返回的失败信息体现在支付结果中",jsonObjectParent.getString("vdef1"));
}
}
}
} catch (Exception e) {
@ -1231,6 +1255,24 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{
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("========业务数据下发完成,日志保存为失败============");
if (CollectionUtils.isNotEmpty(query)) {
//保存推送BIP返回的错误信息
//将BIP返回的失败信息保存到支付结果中
String str = JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString();
JSONObject jsonObject = JSONObject.parseObject(str);
String attribute = jsonObject.getString("attribute");
JSONObject jsonAttribute = JSONObject.parseObject(attribute);
serviceDataEntity.setPayResult(jsonAttribute.getString("message"));
serviceDataEntity.setDataSourceCode("SW-OA");
serviceDataEntity.setPayResultFiled(query.get(0).getPayResultFiled());
serviceDataEntity.setId(query.get(0).getId());
serviceDataEntity.setTabName(query.get(0).getTabName());
logger.info("====开始根据单据号:{},表名称:{},表单id:{}更新支付状态为BIP返回的失败信息======", serviceDataEntity.getBillCode(), serviceDataEntity.getTabName(), serviceDataEntity.getId());
serviceDataDao.updatePayResult(serviceDataEntity);
logger.info("====根据单据号:{},表名称:{},表单id:{}更新支付状态为BIP返回的失败信息======", serviceDataEntity.getBillCode(), serviceDataEntity.getTabName(), serviceDataEntity.getId());
}else{
logger.info("======正常下发时候根据单据编号:{}未能在三维OA查询到数据不将BIP返回的失败信息体现在支付结果中",jsonObjectParent.getString("vdef1"));
}
continue;
}
}

View File

@ -14,7 +14,7 @@
</resultMap>
<sql id = "ServiceDataEntity_Base_Column_List">
oa_id as id
data_id as id
,tab_name as tabName
,pay_result_field as payResultFiled
,pay_result as payResult

View File

@ -300,11 +300,7 @@ public class ServiceDataServiceImpl extends BaseService<ComparisonEntity,String>
List<JSONObject> list = new ArrayList<>();
try {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select oa_id as data_id,tab_name,title,pay_company,bill_name,pay_result_field,pay_date_field,receipt_filed,\n" +
"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,vdef11,vdef17,vdef20 from v_cmp_apply where 1=1 and vdef1 is not null and push_status is null and applysum >0");
stringBuffer.append("select * 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;
@ -319,9 +315,7 @@ public class ServiceDataServiceImpl extends BaseService<ComparisonEntity,String>
formmainId = cmp_apply.getString("data_id");
vdef1=cmp_apply.getString("vdef1");
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,vdef14 from v_cmp_apply_b where formmain_id= '"+formmainId+"' " );
stringBufferDetails.append("select * from v_cmp_apply_b where f_id= '"+formmainId+"' " );
List<HashMap<String, Object>> hashMapsDetails = serviceDataDao.queryListBySWSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
JSONArray cmp_apply_b = new JSONArray();
if(CollectionUtils.isNotEmpty(hashMapsDetails)){