parent
18c645cc01
commit
e15d0451ed
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue