From 912cf2b8ef2adbc363ff925b21727159f0564c92 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Mon, 8 Sep 2025 09:42:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=AE=E6=97=85=E6=8A=A5=E9=94=80=E5=8D=95?= =?UTF-8?q?=E5=8F=91=E7=A5=A8=E9=87=91=E9=A2=9D=E7=B2=BE=E7=A1=AE=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/TripReimburseSubmitOpExt.java | 38 +++++ ...ripReimSubmitCheckInvoiceValidatorExt.java | 147 ++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripReimburseSubmitOpExt.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/validator/TripReimSubmitCheckInvoiceValidatorExt.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripReimburseSubmitOpExt.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripReimburseSubmitOpExt.java new file mode 100644 index 0000000..7d21f6f --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/operate/TripReimburseSubmitOpExt.java @@ -0,0 +1,38 @@ +package zcgj.zcdev.zcdev.fs.plugin.operate; + +import kd.bos.context.RequestContext; +import kd.bos.entity.plugin.AddValidatorsEventArgs; +import kd.bos.servicehelper.user.UserServiceHelper; +import kd.fi.er.opplugin.web.TripReimburseSubmitOp; +import kd.fi.er.validator.*; +import zcgj.zcdev.zcdev.fs.plugin.validator.TripReimSubmitCheckInvoiceValidatorExt; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; + +/** + * 差旅报销单发票金额精确调整插件 + */ +public class TripReimburseSubmitOpExt extends TripReimburseSubmitOp { + + @Override + public void onAddValidators(AddValidatorsEventArgs e) { + Long currentUserId = UserServiceHelper.getCurrentUserId(); + // 当前用户所属组织 + Long mainOrgId = UserServiceHelper.getUserMainOrgId(currentUserId); + //当前切换选择的组织 + Long currentOrgId = RequestContext.get().getOrgId(); + //当前所在的组织是属于矿山下的 + if(OrgCheckUtils.isKS(currentOrgId)){ + e.addValidator(new TripReimburseSubmitValidator()); + e.addValidator(new TripReimburseLoanValidator()); + e.addValidator(new TripStandardValidator()); + e.addValidator(new ReverseBillSubmitValidator()); + e.addValidator(new SameCurrencySubmitValidator()); + e.addValidator(new TripNoReimburseOrderValidator()); + e.addValidator(new TripDateControlValidator()); + e.addValidator(new LoanAndAccountCurrencyUniqueValidator()); + e.getValidators().add(new TripReimSubmitCheckInvoiceValidatorExt()); + }else{ + super.onAddValidators(e); + } + } +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/validator/TripReimSubmitCheckInvoiceValidatorExt.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/validator/TripReimSubmitCheckInvoiceValidatorExt.java new file mode 100644 index 0000000..42fc0e8 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/validator/TripReimSubmitCheckInvoiceValidatorExt.java @@ -0,0 +1,147 @@ +package zcgj.zcdev.zcdev.fs.plugin.validator; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.resource.ResManager; +import kd.bos.entity.ExtendedDataEntity; +import kd.bos.entity.validate.AbstractValidator; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.fi.er.business.image.ImageServiceHelper; +import kd.fi.er.business.utils.*; +import org.apache.commons.lang3.StringUtils; +import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils; + +import java.math.BigDecimal; +import java.util.Objects; + +public class TripReimSubmitCheckInvoiceValidatorExt extends AbstractValidator { + + private static final Log log = LogFactory.getLog(TripReimSubmitCheckInvoiceValidatorExt.class); + + public void validate() { + ExtendedDataEntity[] dataEntities = this.getDataEntities(); + + for(ExtendedDataEntity dataEntity : dataEntities) { + DynamicObject bill = dataEntity.getDataEntity(); + DynamicObject company = bill.getDynamicObject("company"); + DynamicObject costcompany = bill.getDynamicObject("costcompany"); + if (company == null || costcompany == null) { + return; + } + + Long companyId = (Long)company.getPkValue(); + this.chechInvoiceImageTemp(bill, dataEntity); + this.checkNoInvoice(bill, dataEntity); + if (ErStdConfig.getInvoiceMustWithExpense()) { + for(String result : InvoiceUtils.checkUnbindInvoice(bill, dataEntity)) { + this.addErrorMessage(dataEntity, result); + } + } + + DynamicObjectCollection invoiceItemEntryDOs = bill.getDynamicObjectCollection("invoiceitementry"); + if (!invoiceItemEntryDOs.isEmpty()) { + Boolean mustCheck = SystemParamterUtil.isAmountOverInvoice(companyId); + if (!mustCheck) { + //如果是矿山下面的组织 + long costcompanyId = costcompany.getLong("id"); + if(OrgCheckUtils.isKS(costcompanyId)){ + //修改位置,重写发票金额校验逻辑 + for(String result : InvoiceUtilsExt.checkAmount(bill, InvoiceUtils.BillEntityType.TripReimburse)) { + this.addErrorMessage(dataEntity, result); + } + }else{ + for(String result : InvoiceUtils.checkAmount(bill, InvoiceUtils.BillEntityType.TripReimburse)) { + this.addErrorMessage(dataEntity, result); + } + } + } + + DynamicObject invoicOrgDO = bill.getDynamicObject("costcompany"); + + for(String result : InvoiceUtils.checkBuyerNameAndTaxNo(bill, ErCommonUtils.getPk(invoicOrgDO), false)) { + this.addErrorMessage(dataEntity, result); + } + } + } + + } + + private void checkNoInvoice(DynamicObject bill, ExtendedDataEntity dataEntity) { + DynamicObject company = bill.getDynamicObject("company"); + if (company != null) { + Long companyId = (Long)company.getPkValue(); + Boolean invoiceIsMust = ReimburseControlUtils.invoiceIsMust(companyId); + if (invoiceIsMust) { + boolean supplementinvoice = bill.getBoolean("needsuppleinvoice"); + if (!supplementinvoice) { + Boolean billHeadNoInvocie = bill.getBoolean("noinvoice"); + if (!billHeadNoInvocie) { + Long invoiceCurrency = SystemParamterUtil.getInvoiceEntryCurrency(companyId); + DynamicObjectCollection tripEntries = bill.getDynamicObjectCollection("tripentry"); + int tripLength = tripEntries.size(); + + for(int tripIndex = 0; tripIndex < tripLength; ++tripIndex) { + DynamicObject tripEntry = (DynamicObject)tripEntries.get(tripIndex); + DynamicObjectCollection entries = tripEntry.getDynamicObjectCollection("entryentity"); + int entryLength = entries.size(); + + for(int entryIndex = 0; entryIndex < entryLength; ++entryIndex) { + DynamicObject entry = (DynamicObject)entries.get(entryIndex); + String orderId = entry.getString("orderformid"); + if (!StringUtils.isNotBlank(orderId)) { + BigDecimal oriEntryAmount = entry.getBigDecimal("orientryamount"); + if (oriEntryAmount.compareTo(BigDecimal.ZERO) != 0) { + DynamicObject expenseItem = entry.getDynamicObject("expenseitem"); + if (expenseItem != null && Objects.equals(invoiceCurrency, ErCommonUtils.getPk(entry.getDynamicObject("entrycurrency")))) { + Boolean itemInvoice = expenseItem.getBoolean("noinvoice"); + if (!itemInvoice) { + String invoiceNo = entry.getString("invoiceno_entry"); + if (StringUtils.isBlank(invoiceNo)) { + String fmt = String.format(ResManager.loadKDString("第%s行差旅明细需要导入发票或关联发票。", "TripReimSubmitCheckInvoiceValidator_1", "fi-er-opplugin", new Object[0]), entryIndex + 1); + if (tripLength > 1) { + String tripInfo = String.format(ResManager.loadKDString("第%s条行程,", "TripReimSubmitCheckInvoiceValidator_2", "fi-er-opplugin", new Object[0]), tripIndex + 1); + fmt = tripInfo.concat(fmt); + } + + this.addErrorMessage(dataEntity, fmt); + } + } + } + } + } + } + } + + } + } + } + } + } + + private void chechInvoiceImageTemp(DynamicObject bill, ExtendedDataEntity dataEntity) { + DynamicObjectCollection invoiceEntrys = bill.getDynamicObjectCollection("invoiceentry"); + if (invoiceEntrys.size() <= 0) { + log.info("发票分录没有发票,不进行校验"); + } else { + DynamicObject company = bill.getDynamicObject("company"); + String mainEntityId = bill.getDataEntityType().getName(); + Long companyId = 0L; + if (company == null) { + log.info("申请人公司为空,不进行校验"); + } else { + companyId = (Long)company.getPkValue(); + boolean isImageTemp = SystemParamterUtil.isMapInvoiceCloudImage(companyId); + if (isImageTemp) { + String configedPrintTemplateFormId = ImageServiceHelper.getConfigedPrintTplFormNumber(bill, mainEntityId, companyId); + if (StringUtils.isBlank(configedPrintTemplateFormId)) { + this.addErrorMessage(dataEntity, ResManager.loadKDString("未设置单据影像模板,请联系管理员设置!", "TripReimSubmitCheckInvoiceValidator_3", "fi-er-opplugin", new Object[0])); + } + } else { + log.info("没有集成发票云影像,不进行校验"); + } + + } + } + } +}