提交人:邹江涛

时间:2025-12-15 11:09
提交内容:BIP打回增加终止流程重试方案
This commit is contained in:
Tao 2025-12-15 11:10:21 +08:00
parent 18c645cc01
commit e15d0451ed
1 changed files with 83 additions and 40 deletions

View File

@ -17,6 +17,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.servicehelper.workflow.WorkflowServiceHelper;
import kd.sdk.plugin.Plugin;
import shkd.sys.sys.mservice.ApiService;
@ -63,10 +64,8 @@ public class PaymentProcessingListPlugin extends AbstractListPlugin implements P
if (businessname != null) {
String shkd_businessname = businessname.toString();
if (("共享系统".equals(shkd_businessname) || "XK".equals(shkd_businessname)) && (("B".equals(billstatus) || "C".equals(billstatus)))) {
try {
abandonByBusienssKey(loadSingle.getPkValue().toString());
} catch (Exception ignored) {
}
boolean outcome = whetherToInterruptTheProcess(loadSingle.getPkValue().toString());
if (outcome) {
OperationResult operation;
if ("共享系统".equals(shkd_businessname)) {
DynamicObject[] objects = BusinessDataServiceHelper.load("cas_paybill",
@ -109,6 +108,9 @@ public class PaymentProcessingListPlugin extends AbstractListPlugin implements P
logger.info("单据:{}打回成功", billno);
list.refresh();
}
} else {
this.getView().showTipNotification("流程中断失败,请找业务老师处理");
}
} else {
this.getView().showTipNotification("来源系统为BIP或星空且单据状态为提交或审核才允许打回");
logger.info("单据:{}打回失败失败原因来源系统为BIP或星空且单据状态为提交或审核才允许打回", billno);
@ -133,4 +135,45 @@ public class PaymentProcessingListPlugin extends AbstractListPlugin implements P
}
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;
}
}