资金计划调度新增-调度范围日期、日志

This commit is contained in:
李贵强 2025-10-30 10:35:44 +08:00
parent 90e13be260
commit c76fd12984
1 changed files with 83 additions and 47 deletions

View File

@ -12,10 +12,14 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
import kd.bos.util.StringUtils;
import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import static shjh.jhzj7.fi.fi.plugin.operate.PayBillSaveOperation.xdMembersubject;
@ -33,11 +37,31 @@ public class ZjjhTask extends AbstractTask implements Plugin {
@Override
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
if (map.size()==0){
logger.info("未配置调度参数,不执行任务");
return;
}
QFilter q1 = new QFilter("paymentidentify.number", QCP.equals, "FKBS02");//付款标识为被动付款
QFilter q2 = new QFilter("paymentidentify.number", QCP.equals, "FKBS01");//付款标识为主动付款
QFilter q3 = new QFilter("shjh_sourcesystem", QCP.equals, "A");//来源系统,A_sap,B_fk
QFilter q4 = new QFilter("shjh_sourcesystem", QCP.equals, "B");//来源系统,A_sap,B_fk
QFilter filter = q1.or(q2.and(q3.or(q4)));//filter条件为被动付款 或者 主动付款且来源系统为sap或费控
QFilter q5 = new QFilter("billno", QCP.equals, "FKZJ2025074480");//来源系统,A_sap,B_fk
QFilter filter = q1.or(q2.and(q3.or(q4))).and(q5);//filter条件为被动付款 或者 主动付款且来源系统为sap或费控
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
for (Map.Entry<String, Object> objectEntry : map.entrySet()) {
LocalDate localDate = LocalDate.parse((String) objectEntry.getValue(), formatter);
if (objectEntry.getKey().equals("开始日期")){
QFilter startFilter=new QFilter("bizdate",QCP.large_equals,localDate);
filter.and(startFilter);
}
if (objectEntry.getKey().equals("结束日期")){
QFilter endFilter= new QFilter("bizdate",QCP.less_equals,localDate);
filter.and(endFilter);
}
}
DynamicObject[] paybills = BusinessDataServiceHelper.load(paybillName, "id", filter.toArray());
if (paybills.length != 0) {
ArrayList<Long> ids = new ArrayList<>();
@ -73,13 +97,22 @@ public class ZjjhTask extends AbstractTask implements Plugin {
DB.update(DBRoute.of("fi"), updateKM, new Object[]{zjjhkm.getPkValue(), cas_paybill.getPkValue()});
JhzjUtils.saveLog(billno, "付款单更新资金计划科目", "原科目id为空 新科目id:" + zjjhkm.getPkValue(),
null, true, "task0");
}else {
logger.info("被动付款"+billno+"原有资金计划科目=条件查询计划科目,不执行更新");
}
// cas_paybill.set("shjh_membersubject", );
// SaveServiceHelper.save(new DynamicObject[]{cas_paybill});
} else if ("FKBS01".equals(paymentidentify)) {
//主动 如果是主动付款根据付款单查找到上游某一个付款申请单即可再根据付款申请单对象将现有付款申请单保存操作后获取资金计划科目的代码直接复制拷贝至此
//根据付款单查找到上游某一个付款申请单即可
payapply = BusinessDataServiceHelper.loadSingle(cas_paybill.getLong("sourcebillid"), payapplyName);
Map<String, HashSet<Long>> sourceBills = BFTrackerServiceHelper.findSourceBills(paybillName, new Long[]{(Long) cas_paybill.getPkValue()});
if (sourceBills.containsKey(payapplyName)) {
Set<Long> billIds = sourceBills.get(payapplyName);
for (Long billId : billIds) {
payapply = BusinessDataServiceHelper.loadSingle(billId, payapplyName);
//payapply = BusinessDataServiceHelper.loadSingle(cas_paybill.getLong("sourcebillid"), payapplyName);
if (null != payapply) {
// DynamicObject xdMembersubject = xdMembersubject(payapply);
// payapply.set("shjh_membersubject",xdMembersubject);
@ -89,7 +122,6 @@ public class ZjjhTask extends AbstractTask implements Plugin {
if (zjjhkm == null) {
//科目为空将单子上的字段值置为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());
@ -102,6 +134,8 @@ public class ZjjhTask extends AbstractTask implements Plugin {
DB.update(DBRoute.of("fi"), updateKM, new Object[]{zjjhkm.getPkValue(), cas_paybill.getPkValue()});
JhzjUtils.saveLog(billno, "付款单更新资金计划科目", "原科目id为空 新科目id:" + zjjhkm.getPkValue(),
null, true, "task0");
}else {
logger.info("主动付款"+billno+"原有资金计划科目=条件查询计划科目,不执行更新");
}
// cas_paybill.set("shjh_membersubject", xdMembersubject);
// SaveServiceHelper.save(new DynamicObject[]{cas_paybill});
@ -110,6 +144,8 @@ public class ZjjhTask extends AbstractTask implements Plugin {
}
}
}
}
}
public DynamicObject getzjkmbyapply(DynamicObject bill) {
//SAP应付凭证生成付款申请单后系统自动根据配置表(shjh_request_account)带出资金计划科目