对公报销单关联付款单反写发票号

This commit is contained in:
XiangLingFeng 2025-12-18 17:17:20 +08:00
parent 9b88ffde84
commit 979e8ef318
12 changed files with 274 additions and 62 deletions

View File

@ -10,6 +10,7 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import java.math.BigDecimal;
import java.util.ArrayList;
@ -20,11 +21,6 @@ import java.util.HashMap;
* 单据界面插件
*/
public class DefaultFeeTypeBillPlugin extends AbstractBillPlugIn implements Plugin {
private static final String TYPE_XYZ = "kdsz_lcm";//应用编码_信用证
private static final String TYPE_GYL = "kdsz_scmf";//应用编码_供应链金融
private static final String TYPE_COMMON = "cdm";//应用编码_票据管理
private static final String TYPE_DB = "gm";//应用编码_担保管理
private static final String TYPE_YX = "cfm";//应用编码_用信申请
//单据分类费用类型对应关系
private static HashMap<String, ArrayList<String>> billTypeMap = new HashMap<>();
//费用类型对象mapkey编码value费用类型对象
@ -37,14 +33,14 @@ public class DefaultFeeTypeBillPlugin extends AbstractBillPlugIn implements Plug
types.add("FY_002");//手续费
types.add("FY_001");//中收费
types.add("FY_014");//减免费用
billTypeMap.put(TYPE_COMMON, types);
billTypeMap.put(AppConfig.KEY_TYPE_PJCOMMON, types);
//信用证管理-默认费用类型
types = new ArrayList<>();
types.add("FY_011");//利率
types.add("FY_017");//其他费率
types.add("FY_002");//手续费
types.add("FY_001");//中收费
billTypeMap.put(TYPE_XYZ, types);
billTypeMap.put(AppConfig.KEY_TYPE_XYZ, types);
//供应链金融管理-默认费用类型
types = new ArrayList<>();
types.add("FY_013");//平台费
@ -53,15 +49,15 @@ public class DefaultFeeTypeBillPlugin extends AbstractBillPlugIn implements Plug
types.add("FY_001");//中收费
types.add("FY_014");//减免费用
types.add("FY_015");//综合利率
billTypeMap.put(TYPE_GYL, types);
billTypeMap.put(AppConfig.KEY_TYPE_GYL, types);
//担保合同
types = new ArrayList<>();
types.add("FY_014");//减免费用
billTypeMap.put(TYPE_DB, types);
billTypeMap.put(AppConfig.KEY_TYPE_DB, types);
//贷款管理
types = new ArrayList<>();
types.add("FY_014");//减免费用
billTypeMap.put(TYPE_YX, types);
billTypeMap.put(AppConfig.KEY_TYPE_YX, types);
}
@Override
@ -69,7 +65,7 @@ public class DefaultFeeTypeBillPlugin extends AbstractBillPlugIn implements Plug
super.afterBindData(e);
FormShowParameter showParameter = this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
if (TYPE_DB.equals(appId) || TYPE_YX.equals(appId)){
if (AppConfig.KEY_TYPE_DB.equals(appId) || AppConfig.KEY_TYPE_YX.equals(appId)){
String billStatus = (String)this.getModel().getValue("billstatus");
BigDecimal amount = (BigDecimal) this.getModel().getValue("amount");
if ("A".equals(billStatus) && amount != null && BigDecimal.ZERO.compareTo( amount) != 0){
@ -94,14 +90,14 @@ public class DefaultFeeTypeBillPlugin extends AbstractBillPlugIn implements Plug
}
}
//费用明细-费用金额改变(供应链金融五类费用金额汇总至综合利率)
if ("feeamt".equals(propertyName) && appId.equals(TYPE_GYL)){
if ("feeamt".equals(propertyName) && appId.equals(AppConfig.KEY_TYPE_GYL)){
ChangeData changeData = e.getChangeSet()[0];
BigDecimal newValue = (BigDecimal)changeData.getNewValue();
BigDecimal oldValue = (BigDecimal)changeData.getOldValue();
int rowIndex = changeData.getRowIndex();
DynamicObject changeRowFeeType = (DynamicObject)this.getModel().getValue("feetype", rowIndex);
//汇总只处理平台费利率费率中收费减免费用
ArrayList<String> addTypes = billTypeMap.get(TYPE_GYL);//需要汇总的费用类型编码
ArrayList<String> addTypes = billTypeMap.get(AppConfig.KEY_TYPE_GYL);//需要汇总的费用类型编码
ArrayList<String> addTypesCopy = (ArrayList<String>)addTypes.clone();
addTypesCopy.remove("FY_015");
//综合利率行 费用金额改变不处理
@ -121,6 +117,20 @@ public class DefaultFeeTypeBillPlugin extends AbstractBillPlugIn implements Plug
}
}
}
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
FormShowParameter showParameter = this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
//费用明细默认分录
BigDecimal amount = (BigDecimal) this.getModel().getValue("amount");
if (amount != null && BigDecimal.ZERO.compareTo( amount) != 0){
//默认费用明细行
defaultFeeType(appId);
}
}
private void defaultFeeType(String appId){
//费用明细分录为空则默认
DynamicObjectCollection feeDetails = this.getModel().getEntryEntity("feedetail");

View File

@ -11,6 +11,7 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import org.apache.commons.lang3.StringUtils;
import java.util.EventObject;
@ -19,11 +20,6 @@ import java.util.EventObject;
* 票据管理开票/收票登记开票申请票据类型根据单据发布应用决定票据类型过滤默认票据类型
*/
public class CdmBillTypeBillPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener {
private static final String XZY_NUM = "CDMT-8D5DCE08";//票据类型信用证编码
private static final String GYL_NUM = "CDMT-25826125";//票据类型供应链金融编码
private static final String TYPE_XYZ = "kdsz_lcm";//应用编码_信用证
private static final String TYPE_GYL = "kdsz_scmf";//应用编码_供应链金融
private static final String TYPE_COMMON = "cdm";//应用编码_票据管理
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
@ -31,10 +27,10 @@ public class CdmBillTypeBillPlugin extends AbstractBillPlugIn implements Plugin,
String appId = showParameter.getAppId();
//信用证供应链金融 票据类型赋默认值
String billTypeNum = "";
if (TYPE_XYZ.equals(appId)){
billTypeNum = XZY_NUM;
} else if (TYPE_GYL.equals(appId)) {
billTypeNum = GYL_NUM;
if (AppConfig.KEY_TYPE_XYZ.equals(appId)){
billTypeNum = AppConfig.DEFAULT_XZY_NUM;
} else if (AppConfig.KEY_TYPE_GYL.equals(appId)) {
billTypeNum = AppConfig.DEFAULT_GYL_NUM;
}
if (StringUtils.isNotBlank(billTypeNum)){
DynamicObject billType = BusinessDataServiceHelper.loadSingle("cdm_billtype", "id",
@ -54,13 +50,13 @@ public class CdmBillTypeBillPlugin extends AbstractBillPlugIn implements Plugin,
String propertyName = beforeF7SelectEvent.getProperty().getName();
if ("draftbilltype".equals(propertyName)) {
QFilter filter = null;
if (TYPE_XYZ.equals(appId)){
filter = new QFilter("number", QCP.equals, XZY_NUM);
} else if (TYPE_GYL.equals(appId)) {
filter = new QFilter("number", QCP.equals, GYL_NUM);
} else if (TYPE_COMMON.equals(appId)) {
filter = new QFilter("number", QCP.not_equals, GYL_NUM)
.and("number", QCP.not_equals, XZY_NUM);
if (AppConfig.KEY_TYPE_XYZ.equals(appId)){
filter = new QFilter("number", QCP.equals, AppConfig.DEFAULT_XZY_NUM);
} else if (AppConfig.KEY_TYPE_GYL.equals(appId)) {
filter = new QFilter("number", QCP.equals, AppConfig.DEFAULT_GYL_NUM);
} else if (AppConfig.KEY_TYPE_PJCOMMON.equals(appId)) {
filter = new QFilter("number", QCP.not_equals, AppConfig.DEFAULT_GYL_NUM)
.and("number", QCP.not_equals, AppConfig.DEFAULT_XZY_NUM);
}
if (filter != null){
ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();

View File

@ -6,13 +6,12 @@ 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;
/**
* 票据管理开票/收票登记开票申请票据类型根据单据发布应用决定票据类型过滤默认票据类型
*/
public class CdmBillTypeFilterListPlugin extends AbstractListPlugin implements Plugin {
private static final String XZY_NUM = "CDMT-8D5DCE08";//票据类型信用证编码
private static final String GYL_NUM = "CDMT-25826125";//票据类型供应链金融编码
@Override
public void setFilter(SetFilterEvent e) {
super.setFilter(e);
@ -20,12 +19,12 @@ public class CdmBillTypeFilterListPlugin extends AbstractListPlugin implements P
String appId = showParameter.getAppId();
QFilter filter = null;
if ("kdsz_lcm".equals(appId)){
filter = new QFilter("draftbilltype.number", QCP.equals, XZY_NUM);
filter = new QFilter("draftbilltype.number", QCP.equals, AppConfig.DEFAULT_XZY_NUM);
} else if ("kdsz_scmf".equals(appId)) {
filter = new QFilter("draftbilltype.number", QCP.equals, GYL_NUM);
filter = new QFilter("draftbilltype.number", QCP.equals, AppConfig.DEFAULT_GYL_NUM);
} else if ("cdm".equals(appId)) {
filter = new QFilter("draftbilltype.number", QCP.not_equals, GYL_NUM)
.and("draftbilltype.number", QCP.not_equals, XZY_NUM);
filter = new QFilter("draftbilltype.number", QCP.not_equals, AppConfig.DEFAULT_GYL_NUM)
.and("draftbilltype.number", QCP.not_equals, AppConfig.DEFAULT_XZY_NUM);
}
if (filter != null){
e.getQFilters().add(filter);

View File

@ -6,12 +6,12 @@ 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;
/**
* 用信管理银行借款下涉及融资品种的进行非银保理过滤
*/
public class BankLoanFilterListPlugin extends AbstractListPlugin implements Plugin {
private static final String FYBL_NUM= "RZPZ-031";//非银保理编码
@Override
public void setFilter(SetFilterEvent e) {
@ -28,9 +28,9 @@ public class BankLoanFilterListPlugin extends AbstractListPlugin implements Plug
QFilter filter = null;
//非银保理管理
if ("kdsz_factoringm".equals(appId)){
filter = new QFilter(financingKey, QCP.equals, FYBL_NUM);
filter = new QFilter(financingKey, QCP.equals, AppConfig.DEFAULT_FYBL_NUM);
} else if ("cfm".equals(appId)) {
filter = new QFilter(financingKey, QCP.not_equals, FYBL_NUM);
filter = new QFilter(financingKey, QCP.not_equals, AppConfig.DEFAULT_FYBL_NUM);
}
if (filter != null){
e.getQFilters().add(filter);

View File

@ -11,6 +11,7 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import java.util.EventObject;
@ -18,7 +19,6 @@ import java.util.EventObject;
* 用信申请表单插件控制融资品种债权人类型
*/
public class BankLoanFinancingBillPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener {
private static final String FYBL_NUM= "RZPZ-031";//非银保理编码
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
@ -27,12 +27,12 @@ public class BankLoanFinancingBillPlugin extends AbstractBillPlugIn implements P
QFilter filter = null;
//非银保理管理
if ("kdsz_factoringm".equals(appId)){
filter = new QFilter("number", QCP.equals, FYBL_NUM).and("enable", QCP.equals, "1");
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) {
this.getModel().setValue("finproduct", fybl);
}else {
this.getView().showMessage("编码为:"+ FYBL_NUM +"且状态为:可用的融资品种不存在");
this.getView().showMessage("编码为:"+ AppConfig.DEFAULT_FYBL_NUM +"且状态为:可用的融资品种不存在");
}
this.getModel().setValue("creditortype","finorg");//债权人类型默认非银金融机构
}
@ -55,9 +55,9 @@ public class BankLoanFinancingBillPlugin extends AbstractBillPlugIn implements P
if ("finproduct".equals(propertyName)){
//非银保理管理
if ("kdsz_factoringm".equals(appId)){
filter = new QFilter("number", QCP.equals, FYBL_NUM);
filter = new QFilter("number", QCP.equals, AppConfig.DEFAULT_FYBL_NUM);
} else if ("cfm".equals(appId)) {
filter = new QFilter("number", QCP.not_equals, FYBL_NUM);
filter = new QFilter("number", QCP.not_equals, AppConfig.DEFAULT_FYBL_NUM);
}
if (filter != null){
ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();

View File

@ -10,6 +10,7 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import kdsz.zyf25.tmc.cfm.common.AppConfig;
import java.util.EventObject;
@ -19,7 +20,6 @@ import static kd.bos.form.ClientActions.insertRow;
* 对公报销在在供应链金融新增时默认
*/
public class PublicReimburseDefaultBillPlugin extends AbstractBillPlugIn implements Plugin {
private static final String TYPE_GYL = "kdsz_scmf";//应用编码_供应链金融
private static final String DEFAULT_EXPENSE_NUM = "FYXM26.05";//费用项目默认财务费用.金融利息支出
@Override
@ -27,8 +27,8 @@ public class PublicReimburseDefaultBillPlugin extends AbstractBillPlugIn impleme
super.afterCreateNewData(e);
FormShowParameter showParameter = this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
if (TYPE_GYL.equals(appId)) {
this.getModel().setValue("kdsz_jxinvoicetype", TYPE_GYL);
if (AppConfig.KEY_TYPE_GYL.equals(appId)) {
this.getModel().setValue("kdsz_jxinvoicetype", AppConfig.KEY_TYPE_GYL);
DynamicObject expense = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "id",
new QFilter[]{new QFilter("number", QCP.equals, DEFAULT_EXPENSE_NUM)});
if (expense != null){
@ -44,7 +44,7 @@ public class PublicReimburseDefaultBillPlugin extends AbstractBillPlugIn impleme
String name = entryProp.getName();
FormShowParameter showParameter = this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
if (TYPE_GYL.equals(appId)) {
if (AppConfig.KEY_TYPE_GYL.equals(appId)) {
if ("expenseentryentity".equals(name)){
RowDataEntity[] rowDatas = e.getRowDataEntities();
DynamicObject expense = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "id",

View File

@ -6,22 +6,22 @@ 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;
/**
* 对公报销单在供应链金融列表过滤
*/
public class PublicReimburseFilterListPlugin extends AbstractListPlugin implements Plugin {
private static final String TYPE_GYL = "kdsz_scmf";//应用编码_供应链金融
@Override
public void setFilter(SetFilterEvent e) {
super.setFilter(e);
FormShowParameter showParameter = this.getView().getFormShowParameter();
String appId = showParameter.getAppId();
if (TYPE_GYL.equals(appId)){
if (AppConfig.KEY_TYPE_GYL.equals(appId)){
e.getQFilters().add(new QFilter("kdsz_jxinvoicetype", QCP.equals, appId));
}else {
e.getQFilters().add(new QFilter("kdsz_jxinvoicetype", QCP.not_equals, TYPE_GYL));
e.getQFilters().add(new QFilter("kdsz_jxinvoicetype", QCP.not_equals, AppConfig.KEY_TYPE_GYL));
}
}
}

View File

@ -158,6 +158,7 @@ public class CdmInterestAccrualPlugin extends AbstractOperationServicePlugIn imp
BigDecimal payAmt = feeAmt.multiply(new BigDecimal(term)).multiply(amountRate)
.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);//付息金额
JXBill.set("kdsz_srcapp",this.getOption().getVariableValue("appnumber"));//来源应用
JXBill.set("kdsz_originbillno", originBillNo);//票据单号
JXBill.set("billstatus","A");
JXBill.set("org", org);//业务组织

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 org.apache.commons.lang3.StringUtils;
import java.util.HashSet;
import java.util.Iterator;
@ -34,18 +35,18 @@ public class InterestAccrualDeletePlugin extends AbstractOperationServicePlugIn
e.addValidator(new AbstractValidator() {
@Override
public void validate() {
ExtendedDataEntity[] extBills = this.getDataEntities();
for (ExtendedDataEntity extBill : extBills) {
DynamicObject bill = extBill.getDataEntity();
DynamicObjectCollection entries = bill.getDynamicObjectCollection("entryentity");
for (DynamicObject entry : entries) {
DynamicObject payBill = entry.getDynamicObject("kdsz_e_paybill");
if (payBill != null) {
addErrorMessage(extBill, "计息单:"+extBill.getBillNo()+"已生成付款单,不允许删除");
}
ExtendedDataEntity[] extBills = this.getDataEntities();
for (ExtendedDataEntity extBill : extBills) {
DynamicObject bill = extBill.getDataEntity();
DynamicObjectCollection entries = bill.getDynamicObjectCollection("entryentity");
for (DynamicObject entry : entries) {
DynamicObject payBill = entry.getDynamicObject("kdsz_e_paybill");
if (payBill != null) {
addErrorMessage(extBill, "计息单:"+extBill.getBillNo()+"已生成付款单,不允许删除");
}
}
}
}
});
}
@ -61,6 +62,7 @@ public class InterestAccrualDeletePlugin extends AbstractOperationServicePlugIn
if (feeBill != null) {
feeBill.set("kdsz_pushjx","A");
SaveServiceHelper.update(feeBill);
DynamicObjectCollection feeEntries = feeBill.getDynamicObjectCollection("entry");
HashSet<Long> srcBillIds = new HashSet<>();
for (DynamicObject feeEntry : feeEntries) {
@ -86,6 +88,11 @@ 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

@ -58,8 +58,8 @@ public class InterestAccrualGenPaymentOperationPlugin extends AbstractOperationS
throw new RuntimeException("未找到编码为【cas_paybill_other_BT_S】的付款单类型【其他付款】");
}
if (settleType == null){
logger.error("未找到编码为【JSFS04】的结算方式【电汇财资)】");
throw new RuntimeException("未找到编码为【JSFS04】的结算方式【电汇财资)】");
logger.error("未找到编码为【JSFS05】的结算方式【电汇网银支付)】");
throw new RuntimeException("未找到编码为【JSFS05】的结算方式【电汇网银支付)】");
}
}
@ -166,8 +166,10 @@ public class InterestAccrualGenPaymentOperationPlugin extends AbstractOperationS
DynamicObject payBankAcc = JxBill.getDynamicObject("kdsz_bankaccnum");//付息银行账号
DynamicObject oppBeBank = JxBill.getDynamicObject("kdsz_oppbebank");//对方开户银行
String oppBankAcc = JxBill.getString("kdsz_oppbankacc");//对方银行账号
String srcApp = JxBill.getString("kdsz_srcapp");//来源应用
// String oppUnitType = JxBill.getString("kdsz_oppunittype");//对方单位类型
DynamicObject oppUnit = JxBill.getDynamicObject("kdsz_oppunit");//对方单位
DynamicObject org = JxBill.getDynamicObject("org");//组织
//当前日期
Date currentDate = Date.from(
LocalDate.now().atStartOfDay() // 将LocalDate转换为当天的LocalDateTime (00:00:00)
@ -176,7 +178,9 @@ public class InterestAccrualGenPaymentOperationPlugin extends AbstractOperationS
);
//创建付款单对象
DynamicObject payBill = BusinessDataServiceHelper.newDynamicObject("cas_paybill");
payBill.set("org",JxBill.getDynamicObject("org"));//付款人
payBill.set("org",org);//付款人
payBill.set("kdsz_srcapp",srcApp);//来源应用
payBill.set("uniformsocialcreditcode",org == null ? null : org.getString("uniformsocialcreditcode"));//付款人组织机构代码
payBill.set("billstatus","A");//单据状态
payBill.set("currency",currency);//付款币种
payBill.set("payerbank",payBank);//付款银行
@ -185,6 +189,7 @@ public class InterestAccrualGenPaymentOperationPlugin extends AbstractOperationS
payBill.set("payeebank",oppBeBank);//收款银行
payBill.set("payeebankname",oppBeBank.getString("name"));//收款银行名称
payBill.set("kdsz_textfield2",oppBeBank.getString("name"));//收款银行账户名称
payBill.set("recbanknumber",oppBeBank.getString("number"));//收款银行行号
}
payBill.set("paymenttype",payType);//付款类型
payBill.set("billtype",payBillType);//单据类型
@ -202,6 +207,7 @@ public class InterestAccrualGenPaymentOperationPlugin extends AbstractOperationS
payBill.set("priority","public");//紧急程度 默认普通
payBill.set("paymentchannel","counter");//支付渠道柜台默认
payBill.set("changestatus","unchange");//变更状态未变更
payBill.set("feepayer","01");//手续费承担方付款方
payBill.set("bizdate", currentDate);//业务日期
payBill.set("settletype",settleType);//结算方式
payBill.set("kdsz_czpaystatue","1");//财资付款状态 默认无需推送

View File

@ -0,0 +1,106 @@
package kdsz.zyf25.tmc.cfm.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.botp.runtime.TableDefine;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.entity.plugin.args.RollbackOperationArgs;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.HashSet;
/**
* 对公报销单审核时如果计息发票所属模块属于供应链金融等时将发票号反写至付款单
*/
public class PublicReimburseAuditOperationPlugin extends AbstractOperationServicePlugIn implements Plugin {
private static final Logger logger = LoggerFactory.getLogger(PublicReimburseAuditOperationPlugin.class);
private static final Long payBillTableId;//付款单tableid
private static final Long publicBillTableId;//对公报销单tableid
static{
TableDefine payTableDefine = EntityMetadataCache.loadTableDefine("cas_paybill", "cas_paybill");
payBillTableId = payTableDefine.getTableId();
logger.info("付款单tableid:{}",payBillTableId);
TableDefine publicBillTableDefine = EntityMetadataCache.loadTableDefine("er_publicreimbursebill", "er_publicreimbursebill");
publicBillTableId = publicBillTableDefine.getTableId();
logger.info("对公报销单tableid:{}",publicBillTableId);
}
@Override
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
e.getFieldKeys().add("kdsz_jxinvoicetype");
e.getFieldKeys().add("kdsz_lkpaybillentry.kdsz_paymentbillid");
e.getFieldKeys().add("invoiceentry.invoiceno");
e.getFieldKeys().add("billhead_lk.seq");
e.getFieldKeys().add("billhead_lk.billhead_lk_stableid");
e.getFieldKeys().add("billhead_lk.billhead_lk_sbillid");
e.getFieldKeys().add("billhead_lk.billhead_lk_sid");
}
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
DynamicObject[] bills = e.getDataEntities();
for (DynamicObject bill : bills) {
String jxInvoiceType = bill.getString("kdsz_jxinvoicetype");
if ("kdsz_scmf".equals(jxInvoiceType)){
DynamicObjectCollection invoiceEntries = bill.getDynamicObjectCollection("invoiceentry");
if (invoiceEntries != null && invoiceEntries.size() > 0){
StringBuilder invoiceNumStr = new StringBuilder();
for (int i = 0; i < invoiceEntries.size(); i++) {
String invoiceNo = invoiceEntries.get(i).getString("invoiceno");
invoiceNumStr.append(invoiceNo);
if (i != invoiceEntries.size() - 1){
invoiceNumStr.append(System.lineSeparator());
}
}
DynamicObjectCollection lkPayEntries = bill.getDynamicObjectCollection("kdsz_lkpaybillentry");
HashSet<Long> payBillIds = new HashSet<>();
for (DynamicObject lkPayEntry : lkPayEntries) {
long payBillId = lkPayEntry.getLong("kdsz_paymentbillid");
payBillIds.add(payBillId);
}
DynamicObjectCollection publicBillLkEntries = bill.getDynamicObjectCollection("billhead_lk");
int size = publicBillLkEntries.size();
HashSet<DynamicObject> botpLkSet = new HashSet<>();
for (Long payBillId : payBillIds) {
DynamicObject publicBillLkEntry = publicBillLkEntries.addNew();
publicBillLkEntry.set("seq",++size);
publicBillLkEntry.set("billhead_lk_stableid",payBillTableId);
publicBillLkEntry.set("billhead_lk_sbillid",payBillId);
publicBillLkEntry.set("billhead_lk_sid",payBillId);
//修复单据关联关系表
DynamicObject botpLk = BusinessDataServiceHelper.newDynamicObject("botp_billtracker");
botpLk.set("createtime",new Date());
botpLk.set("stableid",payBillTableId);
botpLk.set("sbillid",payBillId);
botpLk.set("ttableid",publicBillTableId);
botpLk.set("tbillid",bill.getPkValue());
botpLkSet.add(botpLk);
}
//保存单据关联关系
SaveServiceHelper.save(botpLkSet.toArray(new DynamicObject[0]));
//保存对公报销单关联关系表
SaveServiceHelper.save(new DynamicObject[]{ bill});
DynamicObject[] payBills = BusinessDataServiceHelper.load("cas_paybill", "id,kdsz_invoicenos,kdsz_invoicenum,kdsz_invoicenum_tag",
new QFilter[]{new QFilter("id", QCP.in, payBillIds)});
if (payBills != null && payBills.length > 0){
for (DynamicObject payBill : payBills) {
payBill.set("kdsz_invoicenos", invoiceNumStr);
}
SaveServiceHelper.update(payBills);
}
}
}
}
}
}

View File

@ -0,0 +1,87 @@
package kdsz.zyf25.tmc.cfm.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.botp.runtime.TableDefine;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.DeleteServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.Iterator;
/**
* 对公报销单反审核时如果计息发票所属模块属于供应链金融等时将反写到付款单的发票号码以及预付款单的关联关系清除
*/
public class PublicReimburseUnAuditOperationPlugin extends AbstractOperationServicePlugIn implements Plugin {
private static final Logger logger = LoggerFactory.getLogger(PublicReimburseAuditOperationPlugin.class);
private static final Long payBillTableId;//付款单tableid
private static final Long publicBillTableId;//对公报销单tableid
static{
TableDefine payTableDefine = EntityMetadataCache.loadTableDefine("cas_paybill", "cas_paybill");
payBillTableId = payTableDefine.getTableId();
logger.info("付款单tableid:{}",payBillTableId);
TableDefine publicBillTableDefine = EntityMetadataCache.loadTableDefine("er_publicreimbursebill", "er_publicreimbursebill");
publicBillTableId = publicBillTableDefine.getTableId();
logger.info("对公报销单tableid:{}",publicBillTableId);
}
@Override
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
e.getFieldKeys().add("kdsz_jxinvoicetype");
e.getFieldKeys().add("kdsz_lkpaybillentry.kdsz_paymentbillid");
e.getFieldKeys().add("billhead_lk.billhead_lk_stableid");
e.getFieldKeys().add("billhead_lk.billhead_lk_sid");
}
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
DynamicObject[] bills = e.getDataEntities();
for (DynamicObject bill : bills) {
String jxInvoiceType = bill.getString("kdsz_jxinvoicetype");
if ("kdsz_scmf".equals(jxInvoiceType)) {
DynamicObjectCollection lkPayEntries = bill.getDynamicObjectCollection("kdsz_lkpaybillentry");
HashSet<Long> payBillIds = new HashSet<>();
for (DynamicObject lkPayEntry : lkPayEntries) {
long payBillId = lkPayEntry.getLong("kdsz_paymentbillid");
payBillIds.add(payBillId);
}
DynamicObjectCollection publicBillLkEntries = bill.getDynamicObjectCollection("billhead_lk");
if (publicBillLkEntries != null){
Iterator<DynamicObject> iterator = publicBillLkEntries.iterator();
while (iterator.hasNext()){
DynamicObject publicBillLkEntry = iterator.next();
Long stableId = publicBillLkEntry.getLong("billhead_lk_stableid");
Long sid = publicBillLkEntry.getLong("billhead_lk_sid");
if (stableId.equals(payBillTableId) && payBillIds.contains( sid)){
iterator.remove();
}
}
//删除单据关联关系
QFilter filter = new QFilter("stableid", QCP.equals, payBillTableId).and("sbillid", QCP.in, payBillIds)
.and("ttableid", QCP.equals, publicBillTableId).and("tbillid", QCP.equals, bill.getPkValue());
DeleteServiceHelper.delete("botp_billtracker",new QFilter[]{filter});
}
//删除对公报销单的关联信息表数据
SaveServiceHelper.save(new DynamicObject[]{bill});
DynamicObject[] payBills = BusinessDataServiceHelper.load("cas_paybill", "id,kdsz_invoicenos,kdsz_invoicenum,kdsz_invoicenum_tag",
new QFilter[]{new QFilter("id", QCP.in, payBillIds)});
for (DynamicObject payBill : payBills) {
payBill.set("kdsz_invoicenos", " ");
}
SaveServiceHelper.update(payBills);
}
}
}
}