收付款单全量更新资金计划科目优化,增加前台日志

This commit is contained in:
yuxueliang0813 2025-07-24 17:16:44 +08:00
parent 26213d6473
commit b3fb47a680
2 changed files with 52 additions and 17 deletions

View File

@ -13,6 +13,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import java.util.*;
@ -21,7 +22,7 @@ public class RecBillZjjhTask extends AbstractTask implements Plugin {
private static final String recbillName = "cas_recbill";//收款单 T_CAS_ReceivingBill
private static final String updateZero = "update T_CAS_ReceivingBill set fk_shjh_planclass=0 where fid=?";//更新资金计划科目为0
// private static final String updateZero = "update T_CAS_ReceivingBill set fk_shjh_planclass=0 where fid=?";//更新资金计划科目为0
private static final String updateKM = "update T_CAS_ReceivingBill set fk_shjh_planclass=? where fid=?";//更新资金计划科目为指定科目
@Override
@ -35,18 +36,31 @@ public class RecBillZjjhTask extends AbstractTask implements Plugin {
}
Map<Object, DynamicObject> recBillMap = BusinessDataServiceHelper.loadFromCache(ids.toArray(), recbillName);
DynamicObject zjaccount;//资金计划科目
DynamicObject oldbillkm;//原单上资金计划科目
String billno;//收款单编号
for (DynamicObject recbill : recBillMap.values()) {
//根据配置表携带资金计划科目
zjaccount = xdMembersubject(recbill);
billno = recbill.getString("billno");
oldbillkm = recbill.getDynamicObject("shjh_planclass");
// recbill.set("shjh_planclass", zjaccount);
// SaveServiceHelper.save(new DynamicObject[]{recbill});
if(zjaccount == null){
logger.info(recbill.getString("billno")+"对应资金计划科目为空");
DB.update(DBRoute.of("fi"), updateZero, new Object[]{recbill.getPkValue()});
}else{
logger.info(recbill.getString("billno")+"对应资金计划科目为"+zjaccount.getLong("id"));
logger.info(billno+"对应资金计划科目为空");
// DB.update(DBRoute.of("fi"), updateZero, new Object[]{recbill.getPkValue()});
}else if(oldbillkm != null && oldbillkm.getLong("id") != zjaccount.getLong("id")){
logger.info(billno+"对应资金计划科目为"+zjaccount.getPkValue());
DB.update(DBRoute.of("fi"), updateKM, new Object[]{zjaccount.getPkValue(), recbill.getPkValue()});
JhzjUtils.saveLog(billno,"收款单更新资金计划科目","原科目id:"+oldbillkm.getPkValue()+" 新科目id:"+zjaccount.getPkValue(),
null,true,"task");
}else if(oldbillkm == null){
//原单上资金计划科目为空现在获取到新的科目需要更新
logger.info(billno+"对应新资金计划科目为"+zjaccount.getPkValue());
DB.update(DBRoute.of("fi"), updateKM, new Object[]{zjaccount.getPkValue(), recbill.getPkValue()});
JhzjUtils.saveLog(billno,"收款单更新资金计划科目","原科目id为空 新科目id:"+zjaccount.getPkValue(),
null,true,"task0");
}
}
}

View File

@ -14,6 +14,7 @@ import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.util.StringUtils;
import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import java.util.*;
@ -27,7 +28,7 @@ public class ZjjhTask extends AbstractTask implements Plugin {
private static final String payapplyName = "ap_payapply";//付款申请单
private static final String updateZero = "update T_CAS_PaymentBill set fk_shjh_membersubject=0 where fid=?";//更新资金计划科目为0
// private static final String updateZero = "update T_CAS_PaymentBill set fk_shjh_membersubject=0 where fid=?";//更新资金计划科目为0
private static final String updateKM = "update T_CAS_PaymentBill set fk_shjh_membersubject=? where fid=?";//更新资金计划科目为指定科目
@Override
@ -45,21 +46,33 @@ public class ZjjhTask extends AbstractTask implements Plugin {
}
Map<Object, DynamicObject> recBillMap = BusinessDataServiceHelper.loadFromCache(ids.toArray(), paybillName);
String paymentidentify;
String billno;//付款单编号
DynamicObject payapply;
DynamicObject zjjhkm;
DynamicObject zjjhkm;//新资金计划科目
DynamicObject oldbillkm;//原单上资金计划科目
for (DynamicObject cas_paybill : recBillMap.values()) {
paymentidentify = cas_paybill.getString("paymentidentify.number");
billno = cas_paybill.getString("billno");
oldbillkm = cas_paybill.getDynamicObject("shjh_membersubject");
//被动 如果是被动付款则将现有付款单保存操作后获取资金计划科目的代码直接复制拷贝至此
if ("FKBS02".equals(paymentidentify)) {
zjjhkm = xdMembersubject(cas_paybill);
if(zjjhkm == null){
//科目为空将单子上的字段值置为0
logger.info(cas_paybill.getString("billno")+"对应资金计划科目为空");
DB.update(DBRoute.of("fi"), updateZero, new Object[]{cas_paybill.getPkValue()});
}else{
//将科目id更新到表字段上
logger.info(cas_paybill.getString("billno")+"对应资金计划科目为"+zjjhkm.getLong("id"));
//科目为空将单子上的字段值置为0--经讨论不用处理
logger.info(billno+"对应资金计划科目为空");
// DB.update(DBRoute.of("fi"), updateZero, new Object[]{cas_paybill.getPkValue()});
}else if(oldbillkm != null && oldbillkm.getLong("id") != zjjhkm.getLong("id")){
//当单据上原科目和这次查询到科目不一致时将科目id更新到表字段上--增加前台日志
logger.info(billno+"对应资金计划科目为"+zjjhkm.getPkValue());
DB.update(DBRoute.of("fi"), updateKM, new Object[]{zjjhkm.getPkValue(), cas_paybill.getPkValue()});
JhzjUtils.saveLog(billno,"付款单更新资金计划科目","原科目id:"+oldbillkm.getPkValue()+" 新科目id:"+zjjhkm.getPkValue(),
null,true,"task");
}else if(oldbillkm == null){
//原单上资金计划科目为空现在获取到新的科目需要更新
logger.info(billno+"对应新资金计划科目为"+zjjhkm.getPkValue());
DB.update(DBRoute.of("fi"), updateKM, new Object[]{zjjhkm.getPkValue(), cas_paybill.getPkValue()});
JhzjUtils.saveLog(billno,"付款单更新资金计划科目","原科目id为空 新科目id:"+zjjhkm.getPkValue(),
null,true,"task0");
}
// cas_paybill.set("shjh_membersubject", );
// SaveServiceHelper.save(new DynamicObject[]{cas_paybill});
@ -75,12 +88,20 @@ public class ZjjhTask extends AbstractTask implements Plugin {
zjjhkm = getzjkmbyapply(payapply);
if(zjjhkm == null){
//科目为空将单子上的字段值置为0
logger.info(cas_paybill.getString("billno")+"对应资金计划科目为空");
DB.update(DBRoute.of("fi"), updateZero, new Object[]{cas_paybill.getPkValue()});
}else{
logger.info(billno+"对应资金计划科目为空");
// DB.update(DBRoute.of("fi"), updateZero, new Object[]{cas_paybill.getPkValue()});
}else if(oldbillkm != null && oldbillkm.getLong("id") != zjjhkm.getLong("id")){
//将科目id更新到表字段上
logger.info(cas_paybill.getString("billno")+"对应资金计划科目为"+zjjhkm.getLong("id"));
logger.info(billno+"对应资金计划科目为"+zjjhkm.getPkValue());
DB.update(DBRoute.of("fi"), updateKM, new Object[]{zjjhkm.getPkValue(), cas_paybill.getPkValue()});
JhzjUtils.saveLog(billno,"付款单更新资金计划科目","原科目id:"+oldbillkm.getPkValue()+" 新科目id:"+zjjhkm.getPkValue(),
null,true,"task");
}else if(oldbillkm == null){
//原单上资金计划科目为空现在获取到新的科目需要更新
logger.info(billno+"对应新资金计划科目为"+zjjhkm.getPkValue());
DB.update(DBRoute.of("fi"), updateKM, new Object[]{zjjhkm.getPkValue(), cas_paybill.getPkValue()});
JhzjUtils.saveLog(billno,"付款单更新资金计划科目","原科目id为空 新科目id:"+zjjhkm.getPkValue(),
null,true,"task0");
}
// cas_paybill.set("shjh_membersubject", xdMembersubject);
// SaveServiceHelper.save(new DynamicObject[]{cas_paybill});