提交内容:定时任务

备注:定时推送单据至BIP
提交人:邹江涛
This commit is contained in:
zoujiangtao 2024-12-16 17:04:00 +08:00
parent 63a0a083eb
commit bf1810ac7c
2 changed files with 62 additions and 29 deletions

View File

@ -15,6 +15,7 @@ import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import shkd.sys.sys.mservice.ApiService;
@ -109,6 +110,18 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
if ("shkd_testapi".equals(itemKey)) {
String responseBody = ApiService.paymentSlipsJson(billObject, "BIP");
JSONObject jsonObject = JSON.parseObject(responseBody);
String code = jsonObject.getString("code");
if ("200".equals(code)) {
JSONObject data = jsonObject.getJSONObject("data");
billObject.set("shkd_businessnumber", data.getString("code"));
billObject.set("shkd_businessid", data.getString("id"));
billObject.set("shkd_businessname", "BIP");
billObject.set("shkd_pushstatus", "已推送");
SaveServiceHelper.save(new DynamicObject[]{billObject});
} else {
logger.info("推送 → 失败\n失败单据编号{}\n推送失败接口返回数据{}", billObject.getString("billno"), responseBody);
}
this.getView().showTipNotification("返回结果:" + responseBody);
}

View File

@ -51,6 +51,8 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
String billName = null;
List<DynamicObject> dynamicObjects = new ArrayList<>();
List<DynamicObject> objects = new ArrayList<>();
String finalBillName;
if (billMark != null) {
switch (billMark.toString()) {
// 付款处理
@ -58,45 +60,12 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
DynamicObject[] objects1 = BusinessDataServiceHelper.load("cas_paybill",
"id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," +
"payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," +
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus"
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus"
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送")
.and("billstatus", QCP.equals, "D").toArray());
dynamicObjects = Arrays.asList(objects1);
billName = "付款处理";
break;
// 收款处理
case "cas_recbill":
DynamicObject[] objects2 = BusinessDataServiceHelper.load("cas_recbill",
"id,billno,entry,entry.e_expenseitem,settletype,entry.e_remark,receivingtype," +
"payertype,org,bizdate,accountbank,payernumber,actrecamt,txt_description,shkd_pushstatus," +
"shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus"
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
dynamicObjects = Arrays.asList(objects2);
billName = "收款处理";
break;
// 银行收付处理
case "bei_transdetail_cas":
DynamicObject[] objects3 = BusinessDataServiceHelper.load("bei_transdetail_cas",
"id,bizdate,oppbank,oppunit,accountbank,description,company,oppbanknumber," +
"bankdetailno,transbalance,description,debitamount,creditamount,shkd_pushstatus," +
"shkd_businessnumber,shkd_businessid,shkd_businessname"
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
dynamicObjects = Arrays.asList(objects3);
billName = "银行收付处理";
break;
// 支付结果付款处理支付结果定时推送
case "cas_paybill_result":
DynamicObject[] objects4 = BusinessDataServiceHelper.load("cas_paybill",
"id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," +
"payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," +
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus"
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
default:
return;
}
}
List<DynamicObject> objects = new ArrayList<>();
String finalBillName = billName;
finalBillName = billName;
dynamicObjects.forEach(dynamicObject -> {
String responseBody = ApiService.paymentSlipsJson(dynamicObject, "BIP");
logger.info("推送 → {} → 开始\n推送单据编号{}\n接口响应数据{}", finalBillName, dynamicObject.getString("billno"), responseBody);
@ -118,5 +87,56 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
}
});
SaveServiceHelper.save(objects.toArray(new DynamicObject[0]));
break;
// 收款处理
case "cas_recbill":
DynamicObject[] objects2 = BusinessDataServiceHelper.load("cas_recbill",
"id,billno,entry,entry.e_expenseitem,settletype,entry.e_remark,receivingtype," +
"payertype,org,bizdate,accountbank,payernumber,actrecamt,txt_description,shkd_pushstatus," +
"shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus"
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
dynamicObjects = Arrays.asList(objects2);
billName = "收款处理";
break;
// 银行收付处理
case "bei_transdetail_cas":
DynamicObject[] objects3 = BusinessDataServiceHelper.load("bei_transdetail_cas",
"id,bizdate,oppbank,oppunit,accountbank,description,company,oppbanknumber," +
"bankdetailno,transbalance,description,debitamount,creditamount,shkd_pushstatus," +
"shkd_businessnumber,shkd_businessid,shkd_businessname"
, new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
dynamicObjects = Arrays.asList(objects3);
billName = "银行收付处理";
break;
// 支付失败付款处理支付结果定时推送
case "cas_paybill_result":
DynamicObject[] objects4 = BusinessDataServiceHelper.load("cas_paybill",
"id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," +
"payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," +
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus"
, new QFilter("bizdate", QCP.large_equals, date).and("bankpaystatus", QCP.in, new String[]{"TF", "NC", "OF"}).toArray());
dynamicObjects = Arrays.asList(objects4);
finalBillName = billName;
dynamicObjects.forEach(dynamicObject -> {
String responseBody = ApiService.paymentSlipsJson(dynamicObject, "BIPNO");
logger.info("推送 → {} → 开始\n推送单据编号{}\n接口响应数据{}", finalBillName, dynamicObject.getString("billno"), responseBody);
if (!responseBody.contains("失败")) {
JSONObject jsonObject = JSON.parseObject(responseBody);
String code = jsonObject.getString("code");
if ("200".equals(code)) {
dynamicObject.set("billstatus", "A");
objects.add(dynamicObject);
} else {
logger.info("推送 → {} → 失败\n失败单据编号{}\n推送失败接口返回数据{}", finalBillName, dynamicObject.getString("billno"), responseBody);
}
} else {
logger.info("推送 → {} → 失败,失败单据编号:{}", finalBillName, dynamicObject.getString("billno"));
}
});
SaveServiceHelper.save(objects.toArray(new DynamicObject[0]));
default:
return;
}
}
}
}