下推计息单、付款单及逆向删除关联关系调整为适配多种源单

This commit is contained in:
XiangLingFeng 2025-12-19 14:00:12 +08:00
parent 8a8dea2a00
commit d7705ab3b2
14 changed files with 182 additions and 92 deletions

View File

@ -7,6 +7,8 @@
*/
package kdsz.zyf25.tmc.cfm.common;
import java.util.HashMap;
/**
* tmc云cfm应用-通用常量类<br>
* 代码中不能存在硬编码敏感信息如账号密码http外链ftp外链邮箱等<br>
@ -21,12 +23,20 @@ public class AppConfig {
public static final String DEFAULT_XZY_NUM = "CDMT-8D5DCE08";//票据类型信用证编码
public static final String DEFAULT_GYL_NUM = "CDMT-25826125";//票据类型供应链金融编码
public static final String DEFAULT_FYBL_NUM= "RZPZ-031";//非银保理编码
public static final String KEY_TYPE_XYZ = "kdsz_lcm";//应用编码_信用证
public static final String KEY_TYPE_GYL = "kdsz_scmf";//应用编码_供应链金融
public static final String KEY_TYPE_PJCOMMON = "cdm";//应用编码_票据管理
public static final String DEFAULT_FYBL_NUM= "RZPZ-031";//非银保理编码
public static final String KEY_TYPE_FYBL = "kdsz_factoringm";//应用编码_票据管理
public static final String KEY_TYPE_DB = "gm";//应用编码_担保管理
public static final String KEY_TYPE_YX = "cfm";//应用编码_用信申请
public static HashMap<String, String> appOriEntityMap = new HashMap<>();//下推计息的源单标识与所属应用的map
static {
appOriEntityMap.put(KEY_TYPE_XYZ, "cdm_payablebill");//信用证管理开票登记
appOriEntityMap.put(KEY_TYPE_GYL, "cdm_payablebill");//供应链金融开票登记
appOriEntityMap.put(KEY_TYPE_DB, "gm_guaranteecontract");//担保管理担保合同
}
}

View File

@ -18,11 +18,11 @@ public class CdmBillTypeFilterListPlugin extends AbstractListPlugin implements P
FormShowParameter showParameter = this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
QFilter filter = null;
if ("kdsz_lcm".equals(appId)){
if (AppConfig.KEY_TYPE_XYZ.equals(appId)){
filter = new QFilter("draftbilltype.number", QCP.equals, AppConfig.DEFAULT_XZY_NUM);
} else if ("kdsz_scmf".equals(appId)) {
} else if (AppConfig.KEY_TYPE_GYL.equals(appId)) {
filter = new QFilter("draftbilltype.number", QCP.equals, AppConfig.DEFAULT_GYL_NUM);
} else if ("cdm".equals(appId)) {
} else if (AppConfig.KEY_TYPE_PJCOMMON.equals(appId)) {
filter = new QFilter("draftbilltype.number", QCP.not_equals, AppConfig.DEFAULT_GYL_NUM)
.and("draftbilltype.number", QCP.not_equals, AppConfig.DEFAULT_XZY_NUM);
}

View File

@ -0,0 +1,29 @@
package kdsz.zyf25.tmc.cfm.plugin.form.cdm;
import kd.bos.form.FormShowParameter;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import java.util.HashMap;
/**
* 计息但列表过滤插件
*/
public class InterestAccrualFilterListPlugin extends AbstractListPlugin implements Plugin {
@Override
public void setFilter(SetFilterEvent e) {
super.setFilter(e);
FormShowParameter showParameter = this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
HashMap<String, String> appOriEntityMap = AppConfig.appOriEntityMap;
if (appOriEntityMap.containsKey(appId)){
e.getQFilters().add(new QFilter("kdsz_srcapp", QCP.equals, appId));
}else {
e.getQFilters().add(new QFilter("kdsz_srcapp", QCP.not_in, appOriEntityMap.keySet()));
}
}
}

View File

@ -5,6 +5,7 @@ import kd.bos.bill.BillShowParameter;
import kd.bos.bill.OperationStatus;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.list.ListFilterParameter;
@ -13,8 +14,10 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import java.util.EventObject;
import java.util.HashMap;
import java.util.HashSet;
/**
@ -41,6 +44,8 @@ public class InterestAccrualLookUpBillPlugin extends AbstractBillPlugIn implemen
this.getView().showMessage("暂无源单,可能已被删除");
return;
}
HashMap<String, String> appOriEntityMap = AppConfig.appOriEntityMap;
String srcApp = (String) this.getModel().getValue("kdsz_srcapp");
HashSet<Long> srcBillIds = new HashSet<>();
for (DynamicObject feeBill : feeBills) {
srcBillIds.add(feeBill.getLong("srcbillid"));
@ -49,7 +54,7 @@ public class InterestAccrualLookUpBillPlugin extends AbstractBillPlugIn implemen
Long[] srcBillArray = srcBillIds.toArray(new Long[0]);
//打开单据
BillShowParameter billShowParameter = new BillShowParameter();
billShowParameter.setFormId("cdm_payablebill");
billShowParameter.setFormId(appOriEntityMap.get(srcApp));
billShowParameter.setPkId(srcBillArray[0]);//单据内码
billShowParameter.getOpenStyle().setShowType(ShowType.Modal);
billShowParameter.setStatus(OperationStatus.EDIT);
@ -57,7 +62,7 @@ public class InterestAccrualLookUpBillPlugin extends AbstractBillPlugIn implemen
} else {
//打开列表
ListShowParameter listShowParameter = new ListShowParameter();
listShowParameter.setFormId("cdm_payablebill");
listShowParameter.setFormId(appOriEntityMap.get(srcApp));
ListFilterParameter listFilterParameter = new ListFilterParameter();
listFilterParameter.setFilter(new QFilter("id",QCP.in,srcBillIds));
listShowParameter.setListFilterParameter(listFilterParameter);

View File

@ -1,7 +1,7 @@
package kdsz.zyf25.tmc.cfm.plugin.form.cfm;
import kd.bos.form.FormShowParameter;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.ListShowParameter;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
@ -16,9 +16,9 @@ public class BankLoanFilterListPlugin extends AbstractListPlugin implements Plug
@Override
public void setFilter(SetFilterEvent e) {
super.setFilter(e);
FormShowParameter showParameter = this.getView().getFormShowParameter();
ListShowParameter showParameter = (ListShowParameter)this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
String formId = showParameter.getFormId();
String formId = showParameter.getBillFormId();
String financingKey = "";//融资品种过滤key
if ("cfm_rateadjustbill".equals(formId)){
financingKey = "loancontractbill.finproduct.number";
@ -27,9 +27,9 @@ public class BankLoanFilterListPlugin extends AbstractListPlugin implements Plug
}
QFilter filter = null;
//非银保理管理
if ("kdsz_factoringm".equals(appId)){
if (AppConfig.KEY_TYPE_FYBL.equals(appId)){
filter = new QFilter(financingKey, QCP.equals, AppConfig.DEFAULT_FYBL_NUM);
} else if ("cfm".equals(appId)) {
} else if (AppConfig.KEY_TYPE_YX.equals(appId)) {
filter = new QFilter(financingKey, QCP.not_equals, AppConfig.DEFAULT_FYBL_NUM);
}
if (filter != null){

View File

@ -26,7 +26,7 @@ public class BankLoanFinancingBillPlugin extends AbstractBillPlugIn implements P
String appId = showParameter.getAppId();
QFilter filter = null;
//非银保理管理
if ("kdsz_factoringm".equals(appId)){
if (AppConfig.KEY_TYPE_FYBL.equals(appId)){
filter = new QFilter("number", QCP.equals, AppConfig.DEFAULT_FYBL_NUM).and("enable", QCP.equals, "1");
DynamicObject fybl = BusinessDataServiceHelper.loadSingle("cfm_financingvarieties", "id", new QFilter[]{filter});
if (fybl != null) {
@ -54,9 +54,9 @@ public class BankLoanFinancingBillPlugin extends AbstractBillPlugIn implements P
QFilter filter = null;
if ("finproduct".equals(propertyName)){
//非银保理管理
if ("kdsz_factoringm".equals(appId)){
if (AppConfig.KEY_TYPE_FYBL.equals(appId)){
filter = new QFilter("number", QCP.equals, AppConfig.DEFAULT_FYBL_NUM);
} else if ("cfm".equals(appId)) {
} else if (AppConfig.KEY_TYPE_YX.equals(appId)) {
filter = new QFilter("number", QCP.not_equals, AppConfig.DEFAULT_FYBL_NUM);
}
if (filter != null){

View File

@ -0,0 +1,28 @@
package kdsz.zyf25.tmc.cfm.plugin.form.fi;
import kd.bos.form.FormShowParameter;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.sdk.plugin.Plugin;
import java.util.EventObject;
/**
* 付款处理F7列表过滤
*/
public class PaymentF7ListPlugin extends AbstractListPlugin implements Plugin {
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
FormShowParameter showParameter = this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
if (appId.equals("kdsz_scmf")) {
this.getModel().setValue("isshowdisabled",true);
}
}
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
}
}

View File

@ -8,6 +8,8 @@ import kd.bos.orm.query.QFilter;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import java.util.HashMap;
/**
* 对公报销单在供应链金融列表过滤
*/
@ -18,10 +20,11 @@ public class PublicReimburseFilterListPlugin extends AbstractListPlugin implemen
super.setFilter(e);
FormShowParameter showParameter = this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
if (AppConfig.KEY_TYPE_GYL.equals(appId)){
HashMap<String, String> appOriEntityMap = AppConfig.appOriEntityMap;
if (appOriEntityMap.containsKey(appId)){
e.getQFilters().add(new QFilter("kdsz_jxinvoicetype", QCP.equals, appId));
}else {
e.getQFilters().add(new QFilter("kdsz_jxinvoicetype", QCP.not_equals, AppConfig.KEY_TYPE_GYL));
e.getQFilters().add(new QFilter("kdsz_jxinvoicetype", QCP.not_in, appOriEntityMap.keySet()));
}
}
}

View File

@ -16,6 +16,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -47,8 +48,14 @@ public class CdmInterestAccrualPlugin extends AbstractOperationServicePlugIn imp
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
e.getFieldKeys().add("billno");
String appNumber = this.getOption().getVariableValue("appnumber");
if (AppConfig.KEY_TYPE_GYL.equals(appNumber) || AppConfig.KEY_TYPE_XYZ.equals(appNumber)){
e.getFieldKeys().add("issuedate");
e.getFieldKeys().add("draftbillexpiredate");
} else if (AppConfig.KEY_TYPE_DB.equals(appNumber)) {
e.getFieldKeys().add("begindate");
e.getFieldKeys().add("enddate");
}
e.getFieldKeys().add("kdsz_payentry.kdsz_interestbill");
e.getFieldKeys().add("kdsz_payentry.kdsz_interestbillno");
e.getFieldKeys().add("kdsz_payentry.kdsz_interestbillid");
@ -61,10 +68,22 @@ public class CdmInterestAccrualPlugin extends AbstractOperationServicePlugIn imp
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
super.beforeExecuteOperationTransaction(e);
DynamicObject[] bills = e.getDataEntities();
//不同单据开始结束时间标识不一致
String appNumber = this.getOption().getVariableValue("appnumber");
String startDateKey = "";
String endDateKey = "";
if (AppConfig.KEY_TYPE_GYL.equals(appNumber) || AppConfig.KEY_TYPE_XYZ.equals(appNumber)){
startDateKey = "issuedate";
endDateKey = "draftbillexpiredate";
} else if (AppConfig.KEY_TYPE_DB.equals(appNumber)) {
startDateKey = "begindate";
endDateKey = "enddate";
}
AppConfig.appOriEntityMap.get(appNumber);
for (DynamicObject bill : bills) {
String billNo = bill.getString("billno");
Date issueDate = bill.getDate("issuedate");//出票日
Date draftbillexpireDate = bill.getDate("draftbillexpiredate");//票据到期日
Date issueDate = bill.getDate(startDateKey);//出票日
Date draftbillexpireDate = bill.getDate(endDateKey);//票据到期日
//生成计息单除费用明细外的参数
HashMap<String, Object> dataMap = new HashMap<>();
dataMap.put("issueDate",issueDate);
@ -107,15 +126,6 @@ public class CdmInterestAccrualPlugin extends AbstractOperationServicePlugIn imp
}
SaveServiceHelper.update(feeBills);
}
// else {
// //部分生成则删除
// OperationResult deleteResult = deleteBills(successPkIds);
// if (!deleteResult.isSuccess()){
// logger.info("应付票据:" + billNo + "下推计息单部分成功的单据删除失败!");
// }else {
// logger.info("应付票据:" + billNo + "下推计息单部分成功的单据删除成功!");
// }
// }
}else {
List<IOperateInfo> errors = result.getAllErrorOrValidateInfo();
StringBuilder errorStr = new StringBuilder();

View File

@ -12,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 kdsz.zyf25.tmc.cfm.common.AppConfig;
import org.apache.commons.lang3.StringUtils;
import java.util.HashSet;
@ -71,9 +72,11 @@ public class InterestAccrualDeletePlugin extends AbstractOperationServicePlugIn
}
//根据费用明细分录的上游id查询上游单据的付息记录并将本条计息单的记录删除
QFilter filter = new QFilter("id", "in", srcBillIds);
// TODO: 2025/12/10 暂时定为开票登记
Long id = bill.getLong("id");
DynamicObject[] srcBills = BusinessDataServiceHelper.load("cdm_payablebill",
String appNum = this.getOption().getVariableValue("appnumber");//当前应用
String oriEntityKey = AppConfig.appOriEntityMap.get(appNum);
if (StringUtils.isNotBlank(oriEntityKey)){
DynamicObject[] srcBills = BusinessDataServiceHelper.load(oriEntityKey,
"id,kdsz_payentry.kdsz_interestbillid", new QFilter[]{filter});
for (DynamicObject srcBill : srcBills) {
DynamicObjectCollection srcPayEntries = srcBill.getDynamicObjectCollection("kdsz_payentry");
@ -88,13 +91,9 @@ public class InterestAccrualDeletePlugin extends AbstractOperationServicePlugIn
}
}
}
// String srcApp = bill.getString("kdsz_srcapp");//来源应用
// String oriBillNo = bill.getString("kdsz_originbillno");//触发生成计息的单据单号
// if (StringUtils.isNotBlank(srcApp) && StringUtils.isNotBlank(oriBillNo)){
// BusinessDataServiceHelper.loadSingle("","")
// }
SaveServiceHelper.save(srcBills);
}
}
}
}
}

View File

@ -21,6 +21,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -268,17 +269,14 @@ public class InterestAccrualGenPaymentOperationPlugin extends AbstractOperationS
SaveServiceHelper.update(JxBill);
//反写计息的源单
// TODO: 2025/12/11 暂定为开票登记
// String payableBillSelectStr = "kdsz_payentry.kdsz_interestbillid,kdsz_payentry.kdsz_paylinkentry," +
// "kdsz_payentry.kdsz_paylinkentry.kdsz_paymentbill,kdsz_payentry.kdsz_paylinkentry.seq," +
// "kdsz_payentry.kdsz_paylinkentry.kdsz_paybillid,kdsz_payentry.kdsz_paylinkentry.kdsz_paybillno," +
// "kdsz_payentry.kdsz_paylinkentry.kdsz_netinterestpaid";
// DynamicObject[] payableBills = BusinessDataServiceHelper.load("cdm_payablebill", payableBillSelectStr,
// new QFilter[]{new QFilter("kdsz_payentry.kdsz_interestbillid", QCP.equals, JxBill.getPkValue())});
DynamicObject[] payableBills = BusinessDataServiceHelper.load("cdm_payablebill", "id",
String appNum = this.getOption().getVariableValue("appnumber");//当前应用
String oriEntityKey = AppConfig.appOriEntityMap.get(appNum);
if (StringUtils.isNotBlank(oriEntityKey)){
DynamicObject[] oriBills = BusinessDataServiceHelper.load(oriEntityKey, "id",
new QFilter[]{new QFilter("kdsz_payentry.kdsz_interestbillid", QCP.equals, JxBill.getPkValue())});
for (int i = 0; i < payableBills.length; i++) {
payableBills[i] = BusinessDataServiceHelper.loadSingle(payableBills[i].getPkValue(), "cdm_payablebill");
DynamicObjectCollection payEntries = payableBills[i].getDynamicObjectCollection("kdsz_payentry");
for (int i = 0; i < oriBills.length; i++) {
oriBills[i] = BusinessDataServiceHelper.loadSingle(oriBills[i].getPkValue(), oriEntityKey);
DynamicObjectCollection payEntries = oriBills[i].getDynamicObjectCollection("kdsz_payentry");
for (DynamicObject payEntry : payEntries) {
long lk_jxBillId = payEntry.getLong("kdsz_interestbillid");
long JxId = JxBill.getLong("id");
@ -294,6 +292,7 @@ public class InterestAccrualGenPaymentOperationPlugin extends AbstractOperationS
}
}
}
SaveServiceHelper.save(payableBills);
SaveServiceHelper.save(oriBills);
}
}
}

View File

@ -9,6 +9,8 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import org.apache.commons.lang3.StringUtils;
import java.util.HashSet;
import java.util.Iterator;
@ -67,12 +69,14 @@ public class PaymentBillDeleteLkOperationPlugin extends AbstractOperationService
}
//根据费用明细分录的上游id查询上游单据的付息记录并将本条计息单的记录删除
QFilter filter = new QFilter("id", "in", oriBillIds);
//TODO: 2025/12/10 暂时定为开票登记
String appNum = this.getOption().getVariableValue("appnumber");//当前应用
String oriEntityKey = AppConfig.appOriEntityMap.get(appNum);
if (StringUtils.isNotBlank(oriEntityKey)){
Long jxId = srcBill.getLong("id");//计息单id
DynamicObject[] oriBills = BusinessDataServiceHelper.load("cdm_payablebill", "id",
DynamicObject[] oriBills = BusinessDataServiceHelper.load(oriEntityKey, "id",
new QFilter[]{filter});
for (int i = 0; i < oriBills.length; i++) {
oriBills[i] = BusinessDataServiceHelper.loadSingle(oriBills[i].getPkValue(),"cdm_payablebill");
oriBills[i] = BusinessDataServiceHelper.loadSingle(oriBills[i].getPkValue(),oriEntityKey);
DynamicObjectCollection srcPayEntries = oriBills[i].getDynamicObjectCollection("kdsz_payentry");
for (DynamicObject srcPayEntry : srcPayEntries) {
Long srcJXBillId = srcPayEntry.getLong("kdsz_interestbillid");
@ -94,3 +98,4 @@ public class PaymentBillDeleteLkOperationPlugin extends AbstractOperationService
}
}
}
}

View File

@ -13,6 +13,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -52,7 +53,7 @@ public class PublicReimburseAuditOperationPlugin extends AbstractOperationServic
DynamicObject[] bills = e.getDataEntities();
for (DynamicObject bill : bills) {
String jxInvoiceType = bill.getString("kdsz_jxinvoicetype");
if ("kdsz_scmf".equals(jxInvoiceType)){
if (AppConfig.appOriEntityMap.containsKey(jxInvoiceType)){
DynamicObjectCollection invoiceEntries = bill.getDynamicObjectCollection("invoiceentry");
if (invoiceEntries != null && invoiceEntries.size() > 0){
StringBuilder invoiceNumStr = new StringBuilder();

View File

@ -13,6 +13,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.DeleteServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -50,7 +51,7 @@ public class PublicReimburseUnAuditOperationPlugin extends AbstractOperationServ
DynamicObject[] bills = e.getDataEntities();
for (DynamicObject bill : bills) {
String jxInvoiceType = bill.getString("kdsz_jxinvoicetype");
if ("kdsz_scmf".equals(jxInvoiceType)) {
if (AppConfig.appOriEntityMap.containsKey(jxInvoiceType)) {
DynamicObjectCollection lkPayEntries = bill.getDynamicObjectCollection("kdsz_lkpaybillentry");
HashSet<Long> payBillIds = new HashSet<>();
for (DynamicObject lkPayEntry : lkPayEntries) {