清账单自动下推明细单优化判断条件

This commit is contained in:
yuxueliang0813 2025-07-05 14:49:36 +08:00
parent 20e09dace3
commit 2ec1ac69a3
2 changed files with 34 additions and 7 deletions

View File

@ -62,6 +62,21 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
private static final String pzbName = "shjh_jgqzcust";//结构性清账客户映射表
private static final String voucherName = "gl_voucher";//凭证
private boolean isNeedOperationCheck(String eok){
if ("unclearacctount_check".equals(eok)) {
return true;
}else if ("clearacctount".equals(eok)) {
return true;
}else if ("invalid".equals(eok)) {
return true;
}else if ("copyqz".equals(eok)) {
return true;
}else if ("updatestatus".equals(eok)) {
return true;
}
return false;
}
/**
* 操作校验通过之后开启事务之前触发此事件
* 插件可以在此事件对通过校验的数据进行整理
@ -71,13 +86,17 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
super.beforeExecuteOperationTransaction(e);
//反清账作废复制修改清账单状态增加校验
String eok = e.getOperationKey();
//如果是由后台定时任务触发收款单自动下推清账单时需要判断操作代码防止首次保存操作进来单子还未存数据库从而load不到
if(!isNeedOperationCheck(eok)){
return;
}
DynamicObject[] dos = e.getDataEntities();
DynamicObject prinfo;
String billno;
String billstatus;
String clearstatus;
for (int i = 0; i < dos.length; i++) {
//反审核操作之前系统未把info对象所有属性加载出来尤其是二开的字段需要在此处重新load一下
//清账反清账作废等操作在列表界面触发时系统未把info对象所有属性加载出来尤其是二开的字段需要在此处重新load一下
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName(),
"id,billno,billstatus,shjh_clearstatus,shjh_pzh,shjh_recebillno,shjh_unclearway,shjh_iscopy,shjh_unclaimamount");
billno = prinfo.getString("billno");
@ -326,9 +345,17 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
String eok = e.getOperationKey();
for (int i = 0; i < dos.length; i++) {
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName());
//保存操作时判断下推明细单结果如果未下推成功则处理否则按清账按钮原逻辑处理
if("save".equals(eok) && "A".equals(prinfo.getString("shjh_pushdetail"))){
continue;
//保存操作时判断下推明细单结果如果未下推成功则先判断是否满足条件再自动下推否则按清账按钮原逻辑处理
if("save".equals(eok)){
//清账单单据状态=暂存 and清账状态=待清账 and 未认领收款金额0才允许自动下推
if (!"A".equals(prinfo.getString("billstatus")) || !"B".equals(prinfo.getString("shjh_clearstatus")) ||
JhzjUtils.isZERO(prinfo.getBigDecimal("shjh_unclaimamount"))) {
continue;
}
//清账单已下推成功
if("A".equals(prinfo.getString("shjh_pushdetail"))){
continue;
}
}
//判断当前清账单是否由收款单补推如果是则根据清账单上的被通知人进行通知否则根据配置表
@ -359,7 +386,9 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
if (pzbs.length == 0) {
//更新清账单下推明细单结果
DB.update(DBRoute.of("fi"), updatePushStatus, new Object[]{"B", prinfo.getPkValue()});
addErrorInfo(prinfo,"根据结构性清账客户映射表未找到对应通知人,无法下推清账明细单");
if(!"save".equals(eok)){
addErrorInfo(prinfo,"根据结构性清账客户映射表未找到对应通知人,无法下推清账明细单");
}
continue;
}
pzbinfo = BusinessDataServiceHelper.loadSingle(pzbs[0].getLong("id"), pzbName);

View File

@ -16,9 +16,7 @@ import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
import java.security.Timestamp;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Map;