parent
18c645cc01
commit
e15d0451ed
|
|
@ -17,6 +17,7 @@ import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import kd.bos.servicehelper.workflow.WorkflowServiceHelper;
|
||||||
import kd.sdk.plugin.Plugin;
|
import kd.sdk.plugin.Plugin;
|
||||||
import shkd.sys.sys.mservice.ApiService;
|
import shkd.sys.sys.mservice.ApiService;
|
||||||
|
|
||||||
|
|
@ -63,51 +64,52 @@ public class PaymentProcessingListPlugin extends AbstractListPlugin implements P
|
||||||
if (businessname != null) {
|
if (businessname != null) {
|
||||||
String shkd_businessname = businessname.toString();
|
String shkd_businessname = businessname.toString();
|
||||||
if (("共享系统".equals(shkd_businessname) || "XK".equals(shkd_businessname)) && (("B".equals(billstatus) || "C".equals(billstatus)))) {
|
if (("共享系统".equals(shkd_businessname) || "XK".equals(shkd_businessname)) && (("B".equals(billstatus) || "C".equals(billstatus)))) {
|
||||||
try {
|
boolean outcome = whetherToInterruptTheProcess(loadSingle.getPkValue().toString());
|
||||||
abandonByBusienssKey(loadSingle.getPkValue().toString());
|
if (outcome) {
|
||||||
} catch (Exception ignored) {
|
OperationResult operation;
|
||||||
}
|
if ("共享系统".equals(shkd_businessname)) {
|
||||||
OperationResult operation;
|
DynamicObject[] objects = BusinessDataServiceHelper.load("cas_paybill",
|
||||||
if ("共享系统".equals(shkd_businessname)) {
|
"id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,acttradedate," +
|
||||||
DynamicObject[] objects = BusinessDataServiceHelper.load("cas_paybill",
|
"payeebanknum,payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype," +
|
||||||
"id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,acttradedate," +
|
"org,bizdate,description,shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname," +
|
||||||
"payeebanknum,payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype," +
|
"billstatus,bankpaystatus", new QFilter("billno", QCP.equals, loadSingle.getString("billno")).toArray());
|
||||||
"org,bizdate,description,shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname," +
|
List<DynamicObject> dynamicObjects = new ArrayList<>();
|
||||||
"billstatus,bankpaystatus", new QFilter("billno", QCP.equals, loadSingle.getString("billno")).toArray());
|
String pushResult = ApiService.paymentSlipsJson(objects[0], "BIPRE", dynamicObjects, null);
|
||||||
List<DynamicObject> dynamicObjects = new ArrayList<>();
|
logger.info("result信息:{}", pushResult);
|
||||||
String pushResult = ApiService.paymentSlipsJson(objects[0], "BIPRE", dynamicObjects, null);
|
if (pushResult.contains("成功")) {
|
||||||
logger.info("result信息:{}", pushResult);
|
SaveServiceHelper.save(dynamicObjects.toArray(new DynamicObject[0]));
|
||||||
if (pushResult.contains("成功")) {
|
|
||||||
SaveServiceHelper.save(dynamicObjects.toArray(new DynamicObject[0]));
|
|
||||||
} else {
|
|
||||||
String returnResults = extractMessageFromResult(pushResult);
|
|
||||||
if (!returnResults.isEmpty()) {
|
|
||||||
this.getView().showTipNotification("打回失败,失败原因:BIP单据" + returnResults);
|
|
||||||
} else {
|
} else {
|
||||||
this.getView().showTipNotification("打回失败,请找业务老师处理");
|
String returnResults = extractMessageFromResult(pushResult);
|
||||||
|
if (!returnResults.isEmpty()) {
|
||||||
|
this.getView().showTipNotification("打回失败,失败原因:BIP单据" + returnResults);
|
||||||
|
} else {
|
||||||
|
this.getView().showTipNotification("打回失败,请找业务老师处理");
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("B".equals(dynamicObject.getString("billstatus"))) {
|
||||||
|
operation = OperationServiceHelper.executeOperate("unsubmit", "cas_paybill", new DynamicObject[]{dynamicObject}, OperateOption.create());
|
||||||
|
} else if ("C".equals(dynamicObject.getString("billstatus"))) {
|
||||||
|
operation = OperationServiceHelper.executeOperate("unaudit", "cas_paybill", new DynamicObject[]{dynamicObject}, OperateOption.create());
|
||||||
|
} else {
|
||||||
|
this.getView().showTipNotification("单据不为已提交或已审核状态,无法打回");
|
||||||
|
logger.info("单据:{}打回失败,失败原因:单据不为已提交或已审核状态", billno);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
List<IOperateInfo> allErrorOrValidateInfo = operation.getAllErrorOrValidateInfo();
|
||||||
|
if (!allErrorOrValidateInfo.isEmpty()) {
|
||||||
if ("B".equals(dynamicObject.getString("billstatus"))) {
|
this.getView().showTipNotification("打回失败,失败原因:撤销(反审核)操作失败 → " + allErrorOrValidateInfo.get(0).getMessage());
|
||||||
operation = OperationServiceHelper.executeOperate("unsubmit", "cas_paybill", new DynamicObject[]{dynamicObject}, OperateOption.create());
|
logger.info("单据:{}打回失败,失败原因:撤销(反审核)操作失败 → " + allErrorOrValidateInfo.get(0).getMessage());
|
||||||
} else if ("C".equals(dynamicObject.getString("billstatus"))) {
|
return;
|
||||||
operation = OperationServiceHelper.executeOperate("unaudit", "cas_paybill", new DynamicObject[]{dynamicObject}, OperateOption.create());
|
} else {
|
||||||
|
this.getView().showSuccessNotification("打回成功");
|
||||||
|
logger.info("单据:{}打回成功", billno);
|
||||||
|
list.refresh();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.getView().showTipNotification("单据不为已提交或已审核状态,无法打回");
|
this.getView().showTipNotification("流程中断失败,请找业务老师处理");
|
||||||
logger.info("单据:{}打回失败,失败原因:单据不为已提交或已审核状态", billno);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<IOperateInfo> allErrorOrValidateInfo = operation.getAllErrorOrValidateInfo();
|
|
||||||
if (!allErrorOrValidateInfo.isEmpty()) {
|
|
||||||
this.getView().showTipNotification("打回失败,失败原因:撤销(反审核)操作失败 → " + allErrorOrValidateInfo.get(0).getMessage());
|
|
||||||
logger.info("单据:{}打回失败,失败原因:撤销(反审核)操作失败 → " + allErrorOrValidateInfo.get(0).getMessage());
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
this.getView().showSuccessNotification("打回成功");
|
|
||||||
logger.info("单据:{}打回成功", billno);
|
|
||||||
list.refresh();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.getView().showTipNotification("来源系统为(BIP或星空)且单据状态为(提交或审核)才允许打回");
|
this.getView().showTipNotification("来源系统为(BIP或星空)且单据状态为(提交或审核)才允许打回");
|
||||||
|
|
@ -133,4 +135,45 @@ public class PaymentProcessingListPlugin extends AbstractListPlugin implements P
|
||||||
}
|
}
|
||||||
return ""; // 如果没有找到,则返回空字符串
|
return ""; // 如果没有找到,则返回空字符串
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean whetherToInterruptTheProcess(String billId) {
|
||||||
|
int maxRetries = 3;
|
||||||
|
int retryCount = 0;
|
||||||
|
|
||||||
|
while (retryCount < maxRetries) {
|
||||||
|
try {
|
||||||
|
// 中断流程
|
||||||
|
abandonByBusienssKey(billId);
|
||||||
|
|
||||||
|
// 等待一段时间再检查
|
||||||
|
Thread.sleep(1000); // 等待1秒
|
||||||
|
|
||||||
|
// 判断单据是否在流程中
|
||||||
|
boolean inProcess = WorkflowServiceHelper.inProcess(billId);
|
||||||
|
|
||||||
|
// 如果不在流程中,返回true
|
||||||
|
if (!inProcess) {
|
||||||
|
logger.info("流程中断成功,单据ID: {}", billId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果仍在流程中,增加重试次数
|
||||||
|
retryCount++;
|
||||||
|
logger.warn("流程中断失败,第{}次重试,单据ID: {}", retryCount, billId);
|
||||||
|
|
||||||
|
// 如果还没达到最大重试次数,等待更长时间
|
||||||
|
if (retryCount < maxRetries) {
|
||||||
|
Thread.sleep(1000L * retryCount); // 逐步增加等待时间
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("中断流程时发生异常,重试次数:" + retryCount + ",单据ID: " + billId, e);
|
||||||
|
retryCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重试3次后仍然在流程中,返回false
|
||||||
|
logger.error("流程中断失败,已达最大重试次数,单据ID: {}", billId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue