优化结算方式,支付渠道,会计科目,临期定时任务

--s
This commit is contained in:
weiyunlong 2025-07-02 17:24:55 +08:00
parent 2c0202d516
commit d9ef0ae37e
3 changed files with 178 additions and 59 deletions

View File

@ -39,32 +39,40 @@ public class TextFieldDemo extends AbstractFormPlugin {
}
}
DynamicObject paymentidentify = (DynamicObject)this.getView().getModel().getValue("paymentidentify");//付款单标识
if (null != paymentidentify) {
//FKBS01 主动付款 FKBS02 被动付款
String number = paymentidentify.getString("number");//付款单标识
//再加个判断如果是 主动付款不进行必填校验
if (!"FKBS01".equals(number)) {
// 获取成本中心和利润中心的控件
BasedataEdit shjh_costcenter = this.getView().getControl("shjh_costcenter");
BasedataEdit shjh_profitcenter = this.getView().getControl("shjh_pc");
//根据业务小类设置 成本中心,利润中心是否必填
DynamicObject shjhBizsmall = (DynamicObject)this.getView().getModel().getValue("shjh_bizsmall");
BasedataProp tp = (BasedataProp) shjh_costcenter.getProperty();
BasedataProp td = (BasedataProp) shjh_profitcenter.getProperty();
// 获取成本中心和利润中心的控件
BasedataEdit shjh_costcenter = this.getView().getControl("shjh_costcenter");
BasedataEdit shjh_profitcenter = this.getView().getControl("shjh_pc");
//根据业务小类设置 成本中心,利润中心是否必填
DynamicObject shjhBizsmall = (DynamicObject)this.getView().getModel().getValue("shjh_bizsmall");
BasedataProp tp = (BasedataProp) shjh_costcenter.getProperty();
BasedataProp td = (BasedataProp) shjh_profitcenter.getProperty();
if (null != shjhBizsmall) {
shjhBizsmall = BusinessDataServiceHelper.loadSingle(shjhBizsmall.getPkValue(),"shjh_bizsmalltype");
// 获取成本中心的必填配置
boolean shjhCc = shjhBizsmall.getBoolean("shjh_cc");
shjh_costcenter.setMustInput(shjhCc);
tp.setMustInput(shjhCc);
// 获取利润中心的必填配置
boolean shjhPc = shjhBizsmall.getBoolean("shjh_pc");
shjh_profitcenter.setMustInput(shjhPc);
td.setMustInput(shjhPc);
}else {
shjh_costcenter.setMustInput(false);
tp.setMustInput(false);
shjh_profitcenter.setMustInput(false);
td.setMustInput(false);
if (null != shjhBizsmall) {
shjhBizsmall = BusinessDataServiceHelper.loadSingle(shjhBizsmall.getPkValue(),"shjh_bizsmalltype");
// 获取成本中心的必填配置
boolean shjhCc = shjhBizsmall.getBoolean("shjh_cc");
shjh_costcenter.setMustInput(shjhCc);
tp.setMustInput(shjhCc);
// 获取利润中心的必填配置
boolean shjhPc = shjhBizsmall.getBoolean("shjh_pc");
shjh_profitcenter.setMustInput(shjhPc);
td.setMustInput(shjhPc);
}else {
shjh_costcenter.setMustInput(false);
tp.setMustInput(false);
shjh_profitcenter.setMustInput(false);
td.setMustInput(false);
}
}
}
//赋值结算方式
this.getView().getModel().setValue("shjh_jsfs",this.getView().getModel().getValue("settletype"));
}
@ -72,32 +80,40 @@ public class TextFieldDemo extends AbstractFormPlugin {
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
DynamicObject paymentidentify = (DynamicObject)this.getView().getModel().getValue("paymentidentify");//付款单标识
if (null != paymentidentify) {
//FKBS01 主动付款 FKBS02 被动付款
String number = paymentidentify.getString("number");//付款单标识
//再加个判断如果是 主动付款不进行必填校验
if (!"FKBS01".equals(number)) {
// 获取成本中心和利润中心的控件
BasedataEdit shjh_costcenter = this.getView().getControl("shjh_costcenter");
BasedataEdit shjh_profitcenter = this.getView().getControl("shjh_pc");
//根据业务小类设置 成本中心,利润中心是否必填
DynamicObject shjhBizsmall = (DynamicObject)this.getView().getModel().getValue("shjh_bizsmall");
BasedataProp tp = (BasedataProp) shjh_costcenter.getProperty();
BasedataProp td = (BasedataProp) shjh_profitcenter.getProperty();
// 获取成本中心和利润中心的控件
BasedataEdit shjh_costcenter = this.getView().getControl("shjh_costcenter");
BasedataEdit shjh_profitcenter = this.getView().getControl("shjh_pc");
//根据业务小类设置 成本中心,利润中心是否必填
DynamicObject shjhBizsmall = (DynamicObject)this.getView().getModel().getValue("shjh_bizsmall");
BasedataProp tp = (BasedataProp) shjh_costcenter.getProperty();
BasedataProp td = (BasedataProp) shjh_profitcenter.getProperty();
if (null != shjhBizsmall) {
shjhBizsmall = BusinessDataServiceHelper.loadSingle(shjhBizsmall.getPkValue(),"shjh_bizsmalltype");
// 获取成本中心的必填配置
boolean shjhCc = shjhBizsmall.getBoolean("shjh_cc");
shjh_costcenter.setMustInput(shjhCc);
tp.setMustInput(shjhCc);
// 获取利润中心的必填配置
boolean shjhPc = shjhBizsmall.getBoolean("shjh_pc");
shjh_profitcenter.setMustInput(shjhPc);
td.setMustInput(shjhPc);
}else {
shjh_costcenter.setMustInput(false);
tp.setMustInput(false);
shjh_profitcenter.setMustInput(false);
td.setMustInput(false);
if (null != shjhBizsmall) {
shjhBizsmall = BusinessDataServiceHelper.loadSingle(shjhBizsmall.getPkValue(),"shjh_bizsmalltype");
// 获取成本中心的必填配置
boolean shjhCc = shjhBizsmall.getBoolean("shjh_cc");
shjh_costcenter.setMustInput(shjhCc);
tp.setMustInput(shjhCc);
// 获取利润中心的必填配置
boolean shjhPc = shjhBizsmall.getBoolean("shjh_pc");
shjh_profitcenter.setMustInput(shjhPc);
td.setMustInput(shjhPc);
}else {
shjh_costcenter.setMustInput(false);
tp.setMustInput(false);
shjh_profitcenter.setMustInput(false);
td.setMustInput(false);
}
}
}
//赋值结算方式
if ("shjh_jsfs".equals(e.getProperty().getName())) {
this.getView().getModel().setValue("settletype",this.getView().getModel().getValue("shjh_jsfs"));

View File

@ -1,5 +1,6 @@
package shjh.jhzj7.fi.fi.plugin.operate;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
@ -11,6 +12,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.EsbUtils;
/**
* 修复数据操作
@ -20,10 +22,15 @@ public class TestssOperation extends AbstractOperationServicePlugIn implements P
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
//付款申请单,只处理来源SAP,付款状态(未付款,部分付款)
QFilter q1 = new QFilter("shjh_sourcesystem", QCP.equals, "A");
QFilter q2 = new QFilter("paystatus", QCP.equals, "Unpaid");
QFilter q3 = new QFilter("paystatus", QCP.equals, "Inpayment");
DynamicObject[] ap_payapplys = BusinessDataServiceHelper.load("ap_payapply",
"id,applyorg,entry,entry.e_asstacttype,entry.e_asstact,entry.e_settlementtype,billno", new QFilter[]{new QFilter("billno", QCP.not_equals, "")});
"id,applyorg,entry,entry.e_asstacttype,entry.e_asstact,entry.e_settlementtype,billno",
new QFilter[]{q1.and(q2.or(q3))});
for (DynamicObject apPayapply : ap_payapplys) {
DynamicObject settlementtype = null;
DynamicObject org = apPayapply.getDynamicObject("applyorg");
if (null == org) {
continue;
@ -33,14 +40,14 @@ public class TestssOperation extends AbstractOperationServicePlugIn implements P
String e_asstacttype = dynamicObject.getString("e_asstacttype");
if ("bd_supplier".equals(e_asstacttype)) {
DynamicObject party = dynamicObject.getDynamicObject("e_asstact");
if (party!= null) {
if (null != party) {
party = BusinessDataServiceHelper.loadSingle(party.getPkValue(),"bd_supplier");
DynamicObjectCollection shjhEntrySap = party.getDynamicObjectCollection("shjh_entry_sap");
if (!shjhEntrySap.isEmpty()) {
for (DynamicObject object : shjhEntrySap) {
if (org.getString("number").equals(object.getString("shjh_companynum"))) {
// 结算方式(付款方式)
DynamicObject settlementtype = BusinessDataServiceHelper.loadSingle("bd_settlementtype",
settlementtype = BusinessDataServiceHelper.loadSingle("bd_settlementtype",
new QFilter[]{new QFilter("number", QCP.equals, object.getString("shjh_settlementmethod"))});
if (settlementtype != null) {
dynamicObject.set("e_settlementtype", settlementtype);
@ -54,6 +61,86 @@ public class TestssOperation extends AbstractOperationServicePlugIn implements P
}
}
SaveServiceHelper.save(new DynamicObject[]{apPayapply});
//查付款申请下游的付款单 另外如果是成网银(U)付款渠道需要是柜台如果是银企直联支付渠道需要是银企互联
DynamicObject[] paybills = BusinessDataServiceHelper.load("cas_paybill", "id,settletype,shjh_jsfs,paymentchannel",
new QFilter[]{new QFilter("sourcebillid", QCP.equals, apPayapply.getPkValue())});
for (DynamicObject paybill : paybills) {
if (null != settlementtype) {
paybill.set("settletype", settlementtype);
paybill.set("shjh_jsfs", settlementtype);
String string = settlementtype.getString("number");
if ("U".equals(string)) {
paybill.set("paymentchannel", "counter");//支付渠道
}
if ("T".equals(string)) {
paybill.set("paymentchannel", "bei");
}
SaveServiceHelper.save(new DynamicObject[]{paybill});
//查付款单下游的排程单 另外如果是成网银(U)付款渠道需要是柜台如果是银企直联支付渠道需要是银企互联
DynamicObject[] schedulebills = BusinessDataServiceHelper.load("psd_schedulebill", "id,applysettletype,applypaychannel",
new QFilter[]{new QFilter("sourcebillid", QCP.equals, apPayapply.getPkValue())});
for (DynamicObject schedulebill : schedulebills) {
schedulebill.set("applysettletype", settlementtype);//申请结算方式
if ("U".equals(string)) {
schedulebill.set("applypaychannel", "counter");//申请支付渠道
}
if ("T".equals(string)) {
schedulebill.set("applypaychannel", "bei");
}
SaveServiceHelper.save(new DynamicObject[]{schedulebill});
}
}
}
}
//更新会计科目
QFilter q4 = new QFilter("billno", QCP.not_equals, "");
DynamicObject[] ap_payapplyss = BusinessDataServiceHelper.load("ap_payapply",
"id,applyorg,billno,shjh_sapkjkm",
new QFilter[]{q4});
for (DynamicObject apPayapplyss : ap_payapplyss) {
DynamicObject accountview = null;
DynamicObject org = apPayapplyss.getDynamicObject("applyorg");
if (null == org) {
continue;
}
DynamicObject accountingsubject = apPayapplyss.getDynamicObject("shjh_sapkjkm");
if (null != accountingsubject) {
QFilter Q8 = new QFilter("number", QCP.equals, accountingsubject.getString("number"));//会计科目编号
Q8.and("createorg.id", QCP.equals, org.getPkValue());//当前公司ID
//如果当前数据中心是测试的则使用测试库科目表ID否则用正式的
if("2162562979827025920".equals(RequestContext.get().getAccountId())){
Q8.and("accounttable.id", QCP.equals, 2125524820924832768L);//测试科目表
}else{
Q8.and("accounttable.id", QCP.equals, EsbUtils.ACCTABLE);//正式科目表
}
accountview = BusinessDataServiceHelper.loadSingle("bd_accountview", Q8.toArray());
if(null != accountview ){
apPayapplyss.set("shjh_sapkjkm", accountview);
}
}
SaveServiceHelper.save(new DynamicObject[]{apPayapplyss});
//查付款申请下游的付款单
DynamicObject[] paybills = BusinessDataServiceHelper.load("cas_paybill",
"id,settletype,shjh_jsfs,paymentchannel,entry,entry.shjh_sapkjkm",
new QFilter[]{new QFilter("sourcebillid", QCP.equals, apPayapplyss.getPkValue())});
for (DynamicObject paybill : paybills) {
if (null != accountview) {
DynamicObjectCollection entry = paybill.getDynamicObjectCollection("entry");
for (DynamicObject dynamicObject : entry) {
dynamicObject.set("shjh_sapkjkm",accountview);
}
SaveServiceHelper.save(new DynamicObject[]{paybill});
//查付款单下游的排程单
DynamicObject[] schedulebills = BusinessDataServiceHelper.load("psd_schedulebill", "id,shjh_sapkjkm",
new QFilter[]{new QFilter("sourcebillid", QCP.equals, apPayapplyss.getPkValue())});
for (DynamicObject schedulebill : schedulebills) {
schedulebill.set("shjh_sapkjkm", accountview);
SaveServiceHelper.save(new DynamicObject[]{schedulebill});
}
}
}
}
}
}

View File

@ -44,23 +44,39 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
// 获取临期天数并转换
String lq = (String) map.get("临期");
if (StringUtils.isEmpty(lq)) {
String lq = (String) map.get("临期_后");
String lq1 = (String) map.get("临期_前");
// 检查是否有有效的临期数据
if (StringUtils.isEmpty(lq) && StringUtils.isEmpty(lq1)) {
return;
}
int daysToAdd = Integer.parseInt(lq); // 将临期字符串转为整数天数
// 获取当前日期
LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDate endDate = currentDate.plusDays(daysToAdd);
// 格式化日期
String formattedoldDate = currentDate.format(formatter); //开始日期 当前日期
String formattedNewDate = endDate.format(formatter); //结束日期当前日期 + 临期天数
// 计算开始日期临期_前表示今天之前的天数
LocalDate startDate = currentDate;
if (StringUtils.isNotEmpty(lq1)) {
int daysBefore = Integer.parseInt(lq1);
startDate = currentDate.minusDays(daysBefore);
}
// 计算结束日期临期_后表示今天之后的天数
LocalDate endDate = currentDate;
if (StringUtils.isNotEmpty(lq)) {
int daysAfter = Integer.parseInt(lq);
endDate = currentDate.plusDays(daysAfter);
}
String formattedoldDate = startDate.format(formatter); // 开始日期
String formattedNewDate = endDate.format(formatter); // 结束日期
JSONArray IT_LIST = new JSONArray();
// 添加SAP应付凭到期日过滤条件
addFilterCondition(IT_LIST, "FAEDT", formattedoldDate, formattedNewDate);
JSONObject result = vouchers_payable(IT_LIST, "临期:"+lq);
JSONObject result = vouchers_payable(IT_LIST,lq+ "临期:"+lq1);
if (null != result && result.containsKey("data")) {
// 处理查询结果
JSONObject data = (JSONObject) result.get("data");