From c89608a0380832ecba827774d77bdd853306f9e5 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Fri, 6 Jun 2025 14:31:25 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E5=8F=91?= =?UTF-8?q?=E7=A5=A8=E5=AF=BC=E5=85=A5=E6=8F=92=E4=BB=B6=EF=BC=8C=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=8F=91=E7=A5=A8=E4=B8=8E=E5=AF=BC=E5=85=A5=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8F=91=E7=A5=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...aterialInbFinaceConfirmeInvoicePlugin.java | 327 ++++++++++++++++++ 1 file changed, 327 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java new file mode 100644 index 0000000..dd59167 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java @@ -0,0 +1,327 @@ +package zcgj.zcdev.zcdev.pr.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.context.RequestContext; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType; +import kd.bos.dataentity.resource.ResManager; +import kd.bos.entity.datamodel.ListSelectedRow; +import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.form.*; +import kd.bos.form.control.EntryGrid; +import kd.bos.form.events.BeforeDoOperationEventArgs; +import kd.bos.form.events.ClosedCallBackEvent; +import kd.bos.form.operate.FormOperate; +import kd.bos.list.ListShowParameter; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.bos.servicehelper.operation.DeleteServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.ec.basedata.common.invoicecloud.InvoiceDataHandleHelper; +import kd.ec.basedata.common.invoicecloud.bean.InvoiceVO; +import kd.ec.basedata.common.utils.EcSerializeHelper; +import kd.ec.contract.common.enums.DirectionEnum; +import kd.ec.contract.common.utils.DynamicObjectTypeUtils; +import kd.ec.contract.utils.ImportInvoiceUtils; +import kd.fi.ap.piaozone.InvoiceCollectHelper; +import kd.sdk.plugin.Plugin; +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 入库单发票导入插件 + */ +public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn implements Plugin { + private static final Log log = LogFactory.getLog(MaterialInbFinaceConfirmeInvoicePlugin.class); + @Override + public void beforeDoOperation(BeforeDoOperationEventArgs args) { + super.beforeDoOperation(args); + FormOperate operate = (FormOperate)args.getSource(); + String key = operate.getOperateKey(); + if (StringUtils.equals(key, "newsubentry")) { //选择发票 + this.beforeNewSubEntry(args); + } else if (StringUtils.equals(key, "selectinvoice")) { //导入发票 + this.showInvoiceImport(args); + }else if (key.equals("deletesubentry")) { + this.beforeDeleteSubEntry(args); + } + } + + public void closedCallBack(ClosedCallBackEvent event) { + super.closedCallBack(event);//selectInvoice_2220454955754478592 + String actionId = event.getActionId(); + Object returnData = event.getReturnData(); + //returnData = "{\"invoiceData\":[{\"xbrlName\":\"\",\"fileName\":\"\",\"specialTypeMark\":\"\",\"downloadUrl\":\"/dev/2170355234897924096/202505/5b96f486f0de44d4a437a482e830cf95/扬尚发票103417.6.pdf\",\"invoiceAmount\":\"91520\",\"needCheck\":\"1\",\"personFlag\":false,\"type\":\"0\",\"authenticateFlag\":1,\"isElectricInvoice\":\"1\",\"payee\":\"\",\"taxOfdUrl\":\"\",\"salerTaxNo\":\"91320117MADRMAMU8L\",\"invoiceType\":\"27\",\"orgNumber\":\"10006834\",\"invoiceNo\":\"25322000000224247311\",\"salerType\":\"\",\"area\":\"\",\"orgName\":\"南京矿山江苏溧水分公司\",\"buyerTaxNo\":\"913201176867400458\",\"resource\":\"发票助手\",\"selectTime\":\"\",\"originalState\":\"0\",\"companySeal\":\"0\",\"originalInvoiceNo\":\"\",\"xbrlType\":\"\",\"serialNo\":\"c2108f40b42046a986c5891cb59d65cc0\",\"xmlUrl\":\"\",\"checkFlag\":1,\"errorLevel\":\"3\",\"totalAmount\":\"103417.6\",\"xbrlUrl\":\"\",\"salerAddressPhone\":\"江苏省南京市溧水区溧水区晶桥镇枫香岭村配件小区16号 13305141166\",\"checkTime\":\"\",\"authenticateTime\":\"\",\"recordedPurpose\":\"\",\"salelistSum\":0,\"isRevise\":\"1\",\"region\":\"\",\"totalTaxAmount\":\"11897.6\",\"taxAmount\":\"11897.6\",\"recordedTime\":\"\",\"items\":[{\"unitPrice\":\"400\",\"num\":\"228.8\",\"preferentialPolicy\":\"\",\"zeroTaxRateFlag\":\"\",\"taxRate\":\"0.13\",\"unit\":\"时\",\"vatException\":\"\",\"versionNo\":\"\",\"detailAmount\":\"91520\",\"specModel\":\"\",\"discountType\":\"0\",\"goodsCode\":\"3040502019900000000\",\"taxAmount\":\"11897.6\",\"goodsName\":\"*经营租赁*挖机租赁费\",\"seq\":\"0\"}],\"originalInvoiceCode\":\"\",\"deductionFlag\":\"1\",\"salerName\":\"南京扬尚机械租赁有限公司\",\"taxPeriod\":\"\",\"uploadSeq\":1747898704052000000,\"destArea\":\"\",\"proxyMark\":\"0\",\"remark\":\"购方开户银行:中国农业银行股份有限公司南京晶桥支行 银行账号:10127901040003185销方开户银行:中国工商银行股份有限公司南京珍珠南路支行 银行账号:4301031809100080341\",\"delete\":\"1\",\"billCreateTime\":\"2025-05-22 10:45:53\",\"invoice_info\":\"ty_27,st_0,ex_1,ch_1,or_0,au_0,\",\"checkStatus\":\"1\",\"availableAmount\":\"103417.6\",\"imageUrl\":\"/dev/2170355234897924096/202505/rim/22/snap/f4f68a6c6cb84255a3a4e6b35fe710d60.jpg\",\"taxPdfUrl\":\"\",\"pixel\":\"\",\"recordedPeriod\":\"\",\"effectiveTaxAmount\":\"11897.6\",\"invoiceRiskLevel\":\"\",\"buyerAddressPhone\":\"南京市溧水区晶桥镇 18551696115\",\"originalFileName\":\"扬尚发票103417.6.pdf\",\"originalGraphUrl\":\"/dev/2170355234897924096/202505/5b96f486f0de44d4a437a482e830cf95/扬尚发票103417.6.pdf\",\"salerAccount\":\"销方开户银行:中国工商银行股份有限公司南京珍珠南路支行 银行账号:4301031809100080341\",\"amount\":\"91520\",\"fileIndex\":\"\",\"validateMessage\":\"合规性校验通过\",\"drawer\":\"\",\"verifyResult\":[],\"updateTime\":\"2025-05-22 15:24:42\",\"reviewer\":\"\",\"invoiceDate\":\"2025-05-19\",\"buyerName\":\"中国非金属材料南京矿山工程有限公司溧水分公司\",\"invalidDate\":\"\",\"invoiceSource\":\"\",\"pdfurl\":\"/dev/2170355234897924096/202505/5b96f486f0de44d4a437a482e830cf95/扬尚发票103417.6.pdf\",\"sourceArea\":\"\",\"salelistComplete\":\"1\",\"buyerAccount\":\"购方开户银行:中国农业银行股份有限公司南京晶桥支行 银行账号:10127901040003185\",\"rotationAngle\":\"0\",\"recordedStatus\":\"01\",\"snapshotUrl\":\"/dev/2170355234897924096/202505/rim/22/snap/f4f68a6c6cb84255a3a4e6b35fe710d60.jpg\",\"invoiceStatus\":\"0\",\"isModify\":\"0\",\"deductionPurpose\":\"\",\"expendStatus\":\"1\",\"fileType\":\"1\",\"expenseStatus\":\"1\",\"taxXmlUrl\":\"\"}],\"attachData\":[]}"; + if (actionId.toLowerCase().startsWith("zcgj_entryentity") && returnData != null) { + this.invoiceCloseCallBack(event); + } else if (actionId.toLowerCase().startsWith("selectinvoice") && returnData != null) { + this.importInvoiceCallBack(returnData); + } + } + + //选择发票 开始 + protected void beforeNewSubEntry(BeforeDoOperationEventArgs args) { + String billId = this.getModel().getDataEntity().getPkValue().toString(); + if (!billId.equals("0") && "A".equals(this.getModel().getValue("billstatus"))) { + this.showInvoice("zcgj_entryentity"); + } else { + this.getView().showMessage(ResManager.loadKDString("单据不是暂存状态,请先保存单据。", "PaymentApplyEditUI_1", "ec-contract-formplugin", new Object[0])); + args.setCancel(true); + } + } + + private void showInvoice(String entryType) { + long currencyId = ((DynamicObject)this.getModel().getValue("zcgj_currency")).getLong("id"); + long orgId = ((DynamicObject)this.getModel().getValue("zcgj_invoice_org")).getLong("id"); + QFilter filter = new QFilter("org", "=", orgId); + filter.and(new QFilter("isclaimed", "=", false)); + filter.and(new QFilter("billstatus", "=", "C")); + filter.and(new QFilter("currency", "=", currencyId)); + filter.and(new QFilter("invoicestatus", "!=", "2")); + filter.and(new QFilter("unapplyamount", ">", BigDecimal.ZERO)); + QFilter filter1 = new QFilter("isclaimed", "=", true); + filter1.and(new QFilter("billstatus", "=", "C")); + DynamicObject contract = (DynamicObject)this.getModel().getValue("zcgj_contract"); + if (contract != null) { + long contractId = contract.getLong("id"); + filter1.and(new QFilter("contract", "=", contractId)); + filter1.and(new QFilter("unapplyamount", ">", BigDecimal.ZERO)); + DynamicObjectCollection contInvEntryCol = this.getModel().getEntryEntity("zcgj_entryentity"); + if (contInvEntryCol.size() > 0) { + List selectedInvIds = new ArrayList(8); + + for(DynamicObject contInvEntryObj : contInvEntryCol) { + DynamicObject invoice = contInvEntryObj.getDynamicObject("zcgj_invoice"); + selectedInvIds.add(invoice.getLong("id")); + } + + filter1.and(new QFilter("id", "not in", selectedInvIds)); + } + + ListShowParameter param = ShowFormHelper.createShowListForm("ec_in_invoice_f7", true); + param.getListFilterParameter().setFilter(filter.or(filter1)); + param.setMultiSelect(true); + param.setCloseCallBack(new CloseCallBack(this, entryType)); + param.getOpenStyle().setShowType(ShowType.Modal); + this.getView().showForm(param); + } + } + + protected void invoiceCloseCallBack(ClosedCallBackEvent event) { + ListSelectedRowCollection rows = (ListSelectedRowCollection)event.getReturnData(); + DynamicObject[] invArr = new DynamicObject[rows.size()]; + int index = 0; + DynamicObject upContract = (DynamicObject)this.getModel().getValue("zcgj_contract"); + for(ListSelectedRow row : rows) { + Object invoicePk = row.getPrimaryKeyValue().toString(); + int rowIndex = this.getModel().createNewEntryRow("zcgj_entryentity"); + this.getModel().setValue("zcgj_invoice", invoicePk.toString(), rowIndex); + DynamicObject invoice = BusinessDataServiceHelper.loadSingle(invoicePk, "ec_in_invoice", "unapplyinvtax,unapplyamount,isClaimed,contract,project,connecttype,currency,totalamount,totaltax,totaloftaxamount"); + this.getModel().setValue("zcgj_invoicecurrency", invoice.getDynamicObject("currency") == null ? Long.valueOf("0") : invoice.getDynamicObject("currency").getPkValue(), rowIndex); + this.getModel().setValue("zcgj_invoiceamount", invoice.getBigDecimal("totalamount"), rowIndex); + this.getModel().setValue("zcgj_invoicetax", invoice.getBigDecimal("totaltax"), rowIndex); + this.getModel().setValue("zcgj_oftaxinvoiceamount", invoice.getBigDecimal("totaloftaxamount"), rowIndex); + this.getModel().setValue("zcgj_unapplyinvoftaxamt", invoice.getBigDecimal("unapplyamount"), rowIndex); + this.getModel().setValue("zcgj_unapplyinvtax", invoice.getBigDecimal("unapplyinvtax"), rowIndex); + this.getModel().setValue("zcgj_applyinvoftaxamt", invoice.getBigDecimal("unapplyamount"), rowIndex); + invArr[index++] = invoice; + invoice.set("isclaimed", true); + invoice.set("contract", upContract); + invoice.set("project", (DynamicObject)this.getModel().getValue("zcgj_project")); + invoice.set("connecttype", "contract"); + } + SaveServiceHelper.save(invArr); + this.getView().invokeOperation("invoicesave"); + } + + protected BigDecimal getSum(String entryId, String columnId) { + int rowCount = this.getModel().getEntryRowCount(entryId); + BigDecimal totalAmount = BigDecimal.ZERO; + + for(int i = 0; i < rowCount; ++i) { + BigDecimal amount = (BigDecimal)this.getModel().getValue(columnId, i); + amount = amount == null ? BigDecimal.ZERO : amount; + totalAmount = totalAmount.add(amount); + } + + return totalAmount; + } + //选择发票 结束 + + //导入发票 开始 + protected void showInvoiceImport(BeforeDoOperationEventArgs args) { + String billId = this.getModel().getDataEntity().getPkValue().toString(); + if (!billId.equals("0") && "A".equals(this.getModel().getValue("billstatus"))) { + if (this.getModel().getValue("zcgj_invoice_org") == null) { + this.getView().showTipNotification(ResManager.loadKDString("发票企业名称不能为空", "PaymentApplyEditUI_18", "ec-contract-formplugin", new Object[0])); + args.setCancel(true); + } else { + if (!ImportInvoiceUtils.isXhInvoiceCloud()) { + args.setCancel(true); + ImportInvoiceUtils.showImportView(this); + }else{ + args.setCancel(true); + DynamicObject org = (DynamicObject) this.getModel().getValue("zcgj_invoice_org"); + InvoiceCollectHelper.showSelectInvoice(this, org); + } + } + } else { + this.getView().showMessage(ResManager.loadKDString("单据不是暂存状态,请先保存单据。", "PaymentApplyEditUI_1", "ec-contract-formplugin", new Object[0])); + args.setCancel(true); + } + } + + protected void importInvoiceCallBack(Object returnData) { + DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_invoice_org"); + //List invoiceVOList = InvoiceDataHandleHelper.parseXhInvoiceCloudReturnData(returnData); + List invoiceVOList = CustomInvoiceDataHandleHelper.parseXhInvoiceCloudReturnData(returnData); + Map> invoiceMap = InvoiceDataHandleHelper.processInvoiceVO(invoiceVOList, RequestContext.get().getCurrUserId(), + org.getLong("id"), new Date(), "ec_in_invoice", (DynamicObject)this.getModel().getValue("zcgj_currency"), true); + ImportInvoiceUtils invoiceUtils = new ImportInvoiceUtils(this.getView(), this.getPageCache()); + this.addInvoiceToEntry(invoiceUtils, invoiceMap); + } + + protected void addInvoiceToEntry(ImportInvoiceUtils invoiceUtils, Map> invoiceMap) { + if (invoiceMap.isEmpty()) { + this.getView().showTipNotification(ResManager.loadKDString("导入发票为空。", "PaymentApplyEditUI_19", "ec-contract-formplugin", new Object[0])); + } else { + long orgId = (Long)((DynamicObject)this.getModel().getValue("zcgj_invoice_org")).getPkValue(); + Set newInvoices = (Set)invoiceMap.get(Boolean.TRUE); + Set existInvoices = (Set)invoiceMap.get(Boolean.FALSE); + if (newInvoices != null && !newInvoices.isEmpty()) { + for(DynamicObject newInvoice : newInvoices) { + DynamicObject buyerOrg = newInvoice.getDynamicObject("buyer"); + if (buyerOrg != null && buyerOrg.getLong("id") != orgId) { + this.getView().showErrorNotification(ResManager.loadKDString("导入失败:当前发票购买方不为当前财务记账组织,请确认信息。", "PaymentApplyEditUI_20", "ec-contract-formplugin", new Object[0])); + return; + } + } + + this.saveInvoiceData(invoiceUtils, newInvoices, existInvoices); + } else if (existInvoices != null) { + DynamicObjectCollection contInvEntryCol = this.getModel().getEntryEntity("zcgj_entryentity"); + Map entryMap = (Map)contInvEntryCol.stream().collect(Collectors.toMap(this::getInvoicePK, this::getInvoicePK)); + this.initSubEntryEntity(existInvoices, entryMap); + } + + } + } + + protected void saveInvoiceData(ImportInvoiceUtils invoiceUtils, Set newInvoices, Set existInvoices) { + invoiceUtils.saveInvoiceAndGiveTips(newInvoices, existInvoices); + if (newInvoices != null && existInvoices != null) { + newInvoices.addAll(existInvoices); + } + + this.initSubEntryEntity(newInvoices, (Map)null); + } + + protected void initSubEntryEntity(Set invoices, Map entryMap) { + if (invoices != null) { + List invArr = new ArrayList(invoices.size()); + for(DynamicObject invoice : invoices) { + if (entryMap != null && entryMap.get(invoice.getPkValue()) != null) { + this.getView().showTipNotification(String.format(ResManager.loadKDString("发票号码%s,已存在分录行", "PaymentApplyEditUI_22", "ec-contract-formplugin", new Object[0]), invoice.getString("invoiceno"))); + } else { + BigDecimal unApplyAmount = invoice.getBigDecimal("unapplyamount"); + if (unApplyAmount != null && unApplyAmount.doubleValue() <= (double)0.0F) { + this.getView().showTipNotification(String.format(ResManager.loadKDString("发票号码%s,金额已经被关联完毕,不可重复使用", "PaymentApplyEditUI_23", "ec-contract-formplugin", new Object[0]), invoice.getString("invoiceno"))); + } else { + DynamicObject upContract = (DynamicObject)this.getModel().getValue("zcgj_contract"); + int rowIndex = this.getModel().createNewEntryRow("zcgj_entryentity"); + this.getModel().setValue("zcgj_invoice", invoice.getPkValue(), rowIndex); + this.getModel().setValue("zcgj_invoicecurrency", invoice.getDynamicObject("currency") == null ? Long.valueOf("0") : invoice.getDynamicObject("currency").getPkValue(), rowIndex); + this.getModel().setValue("zcgj_invoiceamount", invoice.getBigDecimal("totalamount"), rowIndex); + this.getModel().setValue("zcgj_invoicetax", invoice.getBigDecimal("totaltax"), rowIndex); + this.getModel().setValue("zcgj_oftaxinvoiceamount", invoice.getBigDecimal("totaloftaxamount"), rowIndex); + this.getModel().setValue("zcgj_unapplyinvoftaxamt", invoice.getBigDecimal("unapplyamount"), rowIndex); + this.getModel().setValue("zcgj_unapplyinvtax", invoice.getBigDecimal("unapplyinvtax"), rowIndex); + this.getModel().setValue("zcgj_applyinvoftaxamt", invoice.getBigDecimal("unapplyamount"), rowIndex); + invoice.set("isclaimed", true); + invoice.set("contract", upContract); + invoice.set("project", (DynamicObject)this.getModel().getValue("zcgj_project")); + invoice.set("connecttype", "contract"); + invArr.add(invoice); + } + } + } + + if (invArr.size() > 0) { + SaveServiceHelper.save((DynamicObject[])invArr.toArray(new DynamicObject[invoices.size()])); + } + this.getView().invokeOperation("invoicesave"); + } + } + + protected Object getInvoicePK(DynamicObject object) { + return object.getDynamicObject("invoice").getPkValue(); + } + //导入发票 结束 + + //删除发票 开始 + protected void beforeDeleteSubEntry(BeforeDoOperationEventArgs args) { + EntryGrid subGrid = (EntryGrid)this.getControl("zcgj_entryentity"); + int[] selRows = subGrid.getEntryState().getSelectedRows(); + if (selRows.length == 0) { + this.getView().showMessage(ResManager.loadKDString("请选择发票。", "PaymentApplyEditUI_3", "ec-contract-formplugin", new Object[0])); + args.setCancel(true); + } else { + Object[] delPks = new Object[selRows.length]; + Set updateInvoicePks = new HashSet(selRows.length); + DynamicObjectCollection subEntryEntityCol = this.getModel().getEntryEntity("zcgj_entryentity"); + + for(int i = selRows.length - 1; i >= 0; --i) { + int rowIndex = selRows[i]; + DynamicObject invoice = (DynamicObject)this.getModel().getValue("zcgj_invoice", rowIndex); + updateInvoicePks.add(invoice.getPkValue()); + delPks[i] = ((DynamicObject)subEntryEntityCol.get(selRows[i])).getPkValue(); + this.getModel().deleteEntryRow("zcgj_entryentity", rowIndex); + } + + // this.setApplyAmtByInvoice(this.getModel().getEntryCurrentRowIndex("entryentity")); + // DynamicObjectType entryentityDT = DynamicObjectTypeUtils.getEntryDynamicObjectType("ec_paymentapply", "entryentity"); + DynamicObjectType subDT = this.getModel().getDataEntity().getDynamicObjectCollection("zcgj_entryentity").getDynamicObjectType(); + // DynamicObjectType subDT = this.getModel().getDynamicObjectCollection("zcgj_entryentity").getDynamicObjectType(); + QFilter filter = new QFilter("zcgj_entryentity.zcgj_invoice", "in", updateInvoicePks); + filter.and("id", "!=", this.getModel().getDataEntity().getPkValue()); + DynamicObjectCollection invoiceApplyEntries = QueryServiceHelper.query("zcgj_ecma_materialinb_ext", "zcgj_entryentity.zcgj_invoice", new QFilter[]{filter}); + if (invoiceApplyEntries != null && !invoiceApplyEntries.isEmpty()) { + for(DynamicObject subEntry : invoiceApplyEntries) { + updateInvoicePks.remove(subEntry.get("zcgj_entryentity.zcgj_invoice")); + } + } + + if (!updateInvoicePks.isEmpty()) { + DynamicObject[] invoices = BusinessDataServiceHelper.load("ec_in_invoice", "isinvoiceclaim,isclaimed,contract,project,connecttype", + new QFilter[]{new QFilter("id", "in", updateInvoicePks)}); + + for(DynamicObject invoice : invoices) { + if (!invoice.getBoolean("isinvoiceclaim")) { + invoice.set("isclaimed", false); + invoice.set("contract", (Object)null); + invoice.set("project", (Object)null); + invoice.set("connecttype", "null"); + } + } + + SaveServiceHelper.save(invoices); + } + + DeleteServiceHelper.delete(subDT, delPks); + this.getView().showSuccessNotification("发票删除成功!"); + //this.setEnableByInvoice(); + } + } + //删除发票 结束 +} From a01328a5c6198a180eee08fb470af467c63a3f1b Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Fri, 6 Jun 2025 14:44:49 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=94=AF=E5=87=BA/=E6=94=B6=E5=85=A5?= =?UTF-8?q?=E5=90=88=E5=90=8C=E7=BB=93=E7=AE=97=E4=BD=9C=E5=BA=9F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InContractSettleInvalidListPlugin.java | 83 ++++++++++++ .../form/InContractSettleInvalidPlugin.java | 126 ++++++++++++++++++ .../OutContractSettleInvalidListPlugin.java | 12 +- .../form/OutContractSettleInvalidPlugin.java | 29 ++++ .../form/OutContractSettleReversalPlugin.java | 27 ++++ .../operate/InContractSettlementOp.java | 10 ++ .../InContractSettlementValidator.java | 3 + .../operate/OutContractSettlementOp.java | 1 + ...InContractSettleInvalidWorkFlowPlugin.java | 99 ++++++++++++++ ...ContractSettleFiConfirmWorkFlowPlugin.java | 3 +- ...utContractSettleInvalidWorkFlowPlugin.java | 98 ++++++++++++++ 11 files changed, 488 insertions(+), 3 deletions(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractSettleInvalidListPlugin.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractSettleInvalidPlugin.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/InContractSettleInvalidWorkFlowPlugin.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractSettleInvalidWorkFlowPlugin.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractSettleInvalidListPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractSettleInvalidListPlugin.java new file mode 100644 index 0000000..9d123c8 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractSettleInvalidListPlugin.java @@ -0,0 +1,83 @@ +package zcgj.zcdev.zcdev.pr.plugin.form; + +import kd.bos.bill.BillShowParameter; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.ListSelectedRow; +import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.form.ShowType; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.list.BillList; +import kd.bos.list.plugin.AbstractListPlugin; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; + +/** + * 收入合同结算-作废操作插件 + */ +public class InContractSettleInvalidListPlugin extends AbstractListPlugin implements Plugin { + private static final Log log = LogFactory.getLog(InContractSettleInvalidListPlugin.class); + + + @Override + public void itemClick(ItemClickEvent evt) { + super.itemClick(evt); + String itemKey = evt.getItemKey(); + if("zcgj_invalid".equals(itemKey)) { + BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID); + //获取到选中行的数据 + ListSelectedRowCollection selectedRows = billList.getSelectedRows(); + if(selectedRows.isEmpty()){ + this.getView().showTipNotification(String.format("请选择要作废的数据。")); + return; + } + if(selectedRows.size() > 1){ + this.getView().showTipNotification(String.format("请选择单个数据进行作废操作。。")); + return; + } + for (ListSelectedRow selectedRow : selectedRows) { + BillShowParameter showParameter = new BillShowParameter(); + String billStatus = selectedRow.getBillStatus(); + if("C".equals(billStatus)){ + Long contractSettleId = (Long)selectedRow.getPrimaryKeyValue();//收入合同结算id + String billNo = selectedRow.getBillNo(); + QFilter accountTableFilter = new QFilter("zcgj_invalidbillid", QCP.equals,String.valueOf(contractSettleId)); + DynamicObject data = BusinessDataServiceHelper.loadSingle("ec_out_contract_settle", "id,number,zcgj_is_invalid,zcgj_is_reversabillid", new QFilter[]{accountTableFilter}); + if(data != null){ + if(data.getBoolean("zcgj_is_invalid")){ + this.getView().showTipNotification(String.format("当前结算单为作废单据,无法再次作废。")); + return; + }else if(data.getBoolean("zcgj_is_reversabillid")){ + this.getView().showTipNotification(String.format("当前结算单为冲销单据,无法作废。")); + return; + }else{ + this.getView().showTipNotification(String.format("当前结算单已作废,无法再次作废。")); + return; + } + }else{ + QFilter idFilter = new QFilter("id", QCP.equals,contractSettleId); + DynamicObject selectData = BusinessDataServiceHelper.loadSingle("ec_in_contract_settle", "id,number,zcgj_is_invalid", new QFilter[]{idFilter}); + if(selectData.getBoolean("zcgj_is_invalid")){ + this.getView().showTipNotification(String.format("当前为作废单据,无法再次作废。")); + return; + } + showParameter.setCustomParam("invalidbillid", contractSettleId); + //showParameter.setPkId(contractSettleId); + showParameter.setFormId("ec_in_contract_settle"); + showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); //打开方式 + getView().showForm(showParameter); + } + }else{ + this.getView().showTipNotification(String.format("只有已审核通过的数据才可进行作废操作。")); + return; + } + + } + } + } +} + + diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractSettleInvalidPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractSettleInvalidPlugin.java new file mode 100644 index 0000000..328c4d4 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/InContractSettleInvalidPlugin.java @@ -0,0 +1,126 @@ +package zcgj.zcdev.zcdev.pr.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +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.Toolbar; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.math.BigDecimal; +import java.util.EventObject; + +/** + * 支出合同结算单作废 + */ +public class InContractSettleInvalidPlugin extends AbstractBillPlugIn implements Plugin { + + //注册监听按钮 + @Override + public void registerListener(EventObject e) { + //注册整个工具栏监听器 + Toolbar toolbar = this.getView().getControl("tbmain"); + toolbar.addClickListener(this); + super.registerListener(e); + } + + //操作栏点击事件 + @Override + public void itemClick(ItemClickEvent evt) { + if(evt.getItemKey().equals("zcgj_showinvalidbill")){ //跳转到冲销单据 + boolean isInvalid = (Boolean)this.getModel().getValue("zcgj_is_invalid"); + if(isInvalid){ + String id = (String)this.getModel().getValue("zcgj_invalidbillid"); + BillShowParameter showParameter = new BillShowParameter(); + showParameter.setFormId("ec_in_contract_settle"); + showParameter.setPkId(id); + showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); //打开方式 + getView().showForm(showParameter); + } + } + super.itemClick(evt); + } + + @Override + public void afterBindData(EventObject e) { + super.afterBindData(e); + //如果是新增时 + BillShowParameter bsp=(BillShowParameter)this.getView().getFormShowParameter(); + if(bsp.getStatus()== OperationStatus.ADDNEW ){ + // 获取当前页面的FormShowParameter对象 + FormShowParameter formShowParameter = this.getView().getFormShowParameter(); + if(formShowParameter.getCustomParam("invalidbillid")!=null){ + // 获取自定义参数 + Object contractSettleIdObj = formShowParameter.getCustomParam("invalidbillid"); + if (contractSettleIdObj != null) { + initData(contractSettleIdObj); + this.getView().setEnable(false,"contract","org","period","begindate","enddate","iseqsettle","zcgj_adjustmounttax"); + //this.getView().invokeOperation("save"); + } + } + } + } + + public void initData(Object contractSettleIdObj){ + QFilter accountTableFilter = new QFilter("id", QCP.equals,(Long)contractSettleIdObj); + DynamicObject ecincontractsettle = BusinessDataServiceHelper.loadSingle("ec_in_contract_settle", new QFilter[]{accountTableFilter}); + getModel().setValue("zcgj_invalidbillid",ecincontractsettle.getLong("id")); + getModel().setValue("billname",ecincontractsettle.getString("billname")); + getModel().setValue("contract",ecincontractsettle.getDynamicObject("contract")); + getModel().setValue("contattr",ecincontractsettle.getDynamicObject("contattr")); + getModel().setValue("project",ecincontractsettle.getDynamicObject("project")); + getModel().setValue("period",ecincontractsettle.getDynamicObject("period")); + getModel().setValue("begindate",ecincontractsettle.getDate("begindate")); + getModel().setValue("enddate",ecincontractsettle.getDate("enddate")); + getModel().setValue("conttotaloftaxamount",ecincontractsettle.getBigDecimal("conttotaloftaxamount")); + getModel().setValue("description",ecincontractsettle.getString("description")); + getModel().setValue("currency",ecincontractsettle.getDynamicObject("currency")); + getModel().setValue("ismultirate",ecincontractsettle.getBoolean("ismultirate")); + getModel().setValue("ismulticurrency",ecincontractsettle.getBoolean("ismulticurrency")); + getModel().setValue("isonlist",ecincontractsettle.getBoolean("isonlist")); + getModel().setValue("zcgj_adjustmounttax",ecincontractsettle.getBoolean("zcgj_adjustmounttax")); + getModel().setValue("unitproject",ecincontractsettle.getDynamicObject("unitproject")); + getModel().setValue("zcgj_is_invalid",true); + + DynamicObjectCollection itementry = ecincontractsettle.getDynamicObjectCollection("itementry"); + ////DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("zcgj_itementry"); + DynamicObjectCollection entryEntity1 = this.getModel().getDataEntity(true).getDynamicObjectCollection("itementry"); + entryEntity1.clear(); + BigDecimal settleamount = BigDecimal.ZERO; + BigDecimal taxamount = BigDecimal.ZERO; + BigDecimal settleoftaxamount = BigDecimal.ZERO; + + for (DynamicObject dynamicObject : itementry) { + DynamicObject item = entryEntity1.addNew(); + item.set("payitem",dynamicObject.getDynamicObject("payitem")); + BigDecimal oftaxamount = dynamicObject.getBigDecimal("oftaxamount").multiply(new BigDecimal("-1")); + item.set("oftaxamount",oftaxamount); + BigDecimal amount = dynamicObject.getBigDecimal("amount").multiply(new BigDecimal("-1")); + item.set("amount",amount); + item.set("rate",dynamicObject.getBigDecimal("rate")); + BigDecimal taxamt = dynamicObject.getBigDecimal("taxamt").multiply(new BigDecimal("-1")); + item.set("taxamt",taxamt); + item.set("remark",dynamicObject.getString("remark")); + + settleamount = settleamount.add(amount); + taxamount = taxamount.add(taxamt); + settleoftaxamount = settleoftaxamount.add(oftaxamount); + } + getModel().setValue("settleamount",settleamount); + getModel().setValue("taxamount",taxamount); + getModel().setValue("settleoftaxamount",settleoftaxamount); + if(ecincontractsettle.getBoolean("isonlist")){ + this.getView().setVisible(false,"zcgj_adjustmounttax"); + + } + this.getView().updateView("itementry"); + } + +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleInvalidListPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleInvalidListPlugin.java index 376a8a6..c2adc07 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleInvalidListPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleInvalidListPlugin.java @@ -47,8 +47,16 @@ public class OutContractSettleInvalidListPlugin extends AbstractListPlugin imple QFilter accountTableFilter = new QFilter("zcgj_invalidbillid", QCP.equals,String.valueOf(contractSettleId)); DynamicObject data = BusinessDataServiceHelper.loadSingle("ec_out_contract_settle", "id,number,zcgj_is_invalid", new QFilter[]{accountTableFilter}); if(data != null){ //财务确认单 - this.getView().showTipNotification(String.format("当前结算单已作废,无法再次作废。")); - return; + if(data.getBoolean("zcgj_is_invalid")){ + this.getView().showTipNotification(String.format("当前结算单为作废单据,无法再次作废。")); + return; + }else if(data.getBoolean("zcgj_is_reversabillid")){ + this.getView().showTipNotification(String.format("当前结算单为冲销单据,无法作废。")); + return; + }else{ + this.getView().showTipNotification(String.format("当前结算单已作废,无法再次作废。")); + return; + } }else{ QFilter idFilter = new QFilter("id", QCP.equals,contractSettleId); DynamicObject selectData = BusinessDataServiceHelper.loadSingle("ec_out_contract_settle", "id,number,zcgj_is_invalid", new QFilter[]{idFilter}); diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleInvalidPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleInvalidPlugin.java index c457a20..991712a 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleInvalidPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleInvalidPlugin.java @@ -6,6 +6,10 @@ 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.Button; +import kd.bos.form.control.Toolbar; +import kd.bos.form.control.events.ItemClickEvent; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; @@ -19,6 +23,31 @@ import java.util.EventObject; */ public class OutContractSettleInvalidPlugin extends AbstractBillPlugIn implements Plugin { + //注册监听按钮 + @Override + public void registerListener(EventObject e) { + //注册整个工具栏监听器 + Toolbar toolbar = this.getView().getControl("tbmain"); + toolbar.addClickListener(this); + super.registerListener(e); + } + + //操作栏点击事件 + @Override + public void itemClick(ItemClickEvent evt) { + if(evt.getItemKey().equals("zcgj_showinvalidbill")){ //跳转到冲销单据 + boolean isInvalid = (Boolean)this.getModel().getValue("zcgj_is_invalid"); + if(isInvalid){ + String id = (String)this.getModel().getValue("zcgj_invalidbillid"); + BillShowParameter showParameter = new BillShowParameter(); + showParameter.setFormId("ec_out_contract_settle"); + showParameter.setPkId(id); + showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); //打开方式 + getView().showForm(showParameter); + } + } + super.itemClick(evt); + } @Override public void afterBindData(EventObject e) { diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleReversalPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleReversalPlugin.java index 102c02f..2a81223 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleReversalPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleReversalPlugin.java @@ -11,6 +11,8 @@ import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.form.FormShowParameter; import kd.bos.form.ShowType; import kd.bos.form.control.EntryGrid; +import kd.bos.form.control.Toolbar; +import kd.bos.form.control.events.ItemClickEvent; import kd.bos.form.events.HyperLinkClickEvent; import kd.bos.form.events.HyperLinkClickListener; import kd.bos.orm.query.QCP; @@ -28,6 +30,31 @@ import java.util.EventObject; */ public class OutContractSettleReversalPlugin extends AbstractBillPlugIn implements Plugin { + //注册监听按钮 + @Override + public void registerListener(EventObject e) { + //注册整个工具栏监听器 + Toolbar toolbar = this.getView().getControl("tbmain"); + toolbar.addClickListener(this); + super.registerListener(e); + } + + //操作栏点击事件 + @Override + public void itemClick(ItemClickEvent evt) { + if(evt.getItemKey().equals("zcgj_showreversabill")){ //跳转到冲销单据 + boolean isReversabill = (Boolean)this.getModel().getValue("zcgj_is_reversabillid"); + if(isReversabill){ + String id = (String)this.getModel().getValue("zcgj_reversabillid"); + BillShowParameter showParameter = new BillShowParameter(); + showParameter.setFormId("ec_out_contract_settle"); + showParameter.setPkId(id); + showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); //打开方式 + getView().showForm(showParameter); + } + } + super.itemClick(evt); + } @Override public void afterBindData(EventObject e) { diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettlementOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettlementOp.java index fc08841..ff5bf2c 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettlementOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettlementOp.java @@ -1,5 +1,6 @@ package zcgj.zcdev.zcdev.pr.plugin.operate; import kd.bos.entity.plugin.AddValidatorsEventArgs; +import kd.bos.entity.plugin.PreparePropertysEventArgs; import kd.bos.entity.validate.AbstractValidator; import kd.ec.contract.opplugin.InContractSettleOp; import kd.ec.contract.opplugin.validator.ContractMeasureValidator; @@ -8,6 +9,15 @@ import kd.ec.contract.opplugin.validator.InContractSettleValidator; import java.util.List; public class InContractSettlementOp extends InContractSettleOp { + + @Override + public void onPreparePropertys(PreparePropertysEventArgs e) { + super.onPreparePropertys(e); + List fields = e.getFieldKeys(); + fields.add("zcgj_is_reversabillid"); + fields.add("zcgj_is_invalid"); + } + @Override public void onAddValidators(AddValidatorsEventArgs e) { super.onAddValidators(e); diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettlementValidator.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettlementValidator.java index a59edf5..ed8200b 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettlementValidator.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettlementValidator.java @@ -21,6 +21,9 @@ public class InContractSettlementValidator extends InContractSettleValidator { for (int var4 = 0; var4 < var3; ++var4) { ExtendedDataEntity dataEntity = var2[var4]; + if(dataEntity.getDataEntity().getBoolean("zcgj_is_reversabillid") || dataEntity.getDataEntity().getBoolean("zcgj_is_invalid")){ + return; + } BigDecimal settleOfTaxAmount = dataEntity.getDataEntity().getBigDecimal("settleoftaxamount"); DynamicObject contractTemp = dataEntity.getDataEntity().getDynamicObject("contract"); if (contractTemp == null) { diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettlementOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettlementOp.java index fcb97b1..a824ef3 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettlementOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettlementOp.java @@ -17,6 +17,7 @@ public class OutContractSettlementOp extends OutContractSettleOp { super.onPreparePropertys(e); List fields = e.getFieldKeys(); fields.add("zcgj_is_reversabillid"); + fields.add("zcgj_is_invalid"); } @Override diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/InContractSettleInvalidWorkFlowPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/InContractSettleInvalidWorkFlowPlugin.java new file mode 100644 index 0000000..388cd36 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/InContractSettleInvalidWorkFlowPlugin.java @@ -0,0 +1,99 @@ +package zcgj.zcdev.zcdev.pr.plugin.workflow; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.operate.result.OperationResult; +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.bos.workflow.api.AgentExecution; +import kd.bos.workflow.engine.extitf.IWorkflowPlugin; + +import java.math.BigDecimal; + +/** + * 收入合同结算单-作废单生成财务确认单工作流插件 + */ +public class InContractSettleInvalidWorkFlowPlugin implements IWorkflowPlugin { + + @Override + public void notify(AgentExecution execution) { + String eventName = execution.getEventName(); + String businessKey = execution.getBusinessKey(); + String entityNumber = execution.getEntityNumber(); + DynamicObject inContractSettle = BusinessDataServiceHelper.loadSingle(businessKey, entityNumber); + //如果是作废单据 + boolean isReversabillid = inContractSettle.getBoolean("zcgj_is_invalid"); + + if(isReversabillid) { + DynamicObject inFinaceconfirm =BusinessDataServiceHelper.newDynamicObject("zcgj_ec_in_finaceconfirm"); + + inFinaceconfirm.set("zcgj_ec_in_contract_sett",inContractSettle.getLong("id")); + inFinaceconfirm.set("zcgj_ec_in_contract_name",inContractSettle.getString("billname")); + inFinaceconfirm.set("zcgj_ec_in_contractid", inContractSettle.getLong("id")); //id文本,冗余 + inFinaceconfirm.set("zcgj_billname",inContractSettle.getString("billname")); + inFinaceconfirm.set("zcgj_contract",inContractSettle.getDynamicObject("contract")); + inFinaceconfirm.set("zcgj_contattr",inContractSettle.getDynamicObject("contattr")); + inFinaceconfirm.set("zcgj_project",inContractSettle.getDynamicObject("project")); + inFinaceconfirm.set("zcgj_period",inContractSettle.getDynamicObject("period")); + inFinaceconfirm.set("zcgj_begindate",inContractSettle.getDate("begindate")); + inFinaceconfirm.set("zcgj_enddate",inContractSettle.getDate("enddate")); + inFinaceconfirm.set("zcgj_conttotaloftaxamount",inContractSettle.getBigDecimal("conttotaloftaxamount")); + inFinaceconfirm.set("zcgj_description",inContractSettle.getString("description")); + inFinaceconfirm.set("zcgj_currency",inContractSettle.getDynamicObject("currency")); + inFinaceconfirm.set("zcgj_invoice_org",inContractSettle.getDynamicObject("project").getDynamicObject("projectorg")); + // getModel().setValue("zcgj_jscustomer",ecincontractsettle.getDynamicObject("zcgj_jscustomer")); + inFinaceconfirm.set("billstatus","C"); + inFinaceconfirm.set("zcgj_is_invalid",true); + + DynamicObjectCollection itementry = inContractSettle.getDynamicObjectCollection("itementry"); + + DynamicObjectCollection entryEntity1 = inFinaceconfirm.getDynamicObjectCollection("zcgj_itementry"); + entryEntity1.clear(); + BigDecimal oftaxamountAll = BigDecimal.ZERO; + BigDecimal amountAll = BigDecimal.ZERO; + BigDecimal taxamtAll = BigDecimal.ZERO; + for (DynamicObject dynamicObject : itementry) { + DynamicObject item = entryEntity1.addNew(); + item.set("zcgj_payitem",dynamicObject.getDynamicObject("payitem")); + BigDecimal oftaxamount = dynamicObject.getBigDecimal("oftaxamount"); + item.set("zcgj_oftaxamount",oftaxamount); + oftaxamountAll = oftaxamountAll.add(oftaxamount); + BigDecimal amount = dynamicObject.getBigDecimal("amount"); + item.set("zcgj_amount",amount); + amountAll = amountAll.add(amount); + item.set("zcgj_rate",dynamicObject.getBigDecimal("rate")); + BigDecimal taxamt = dynamicObject.getBigDecimal("taxamt"); + item.set("zcgj_taxamt",taxamt); + taxamtAll = taxamtAll.add(taxamt); + item.set("zcgj_remark",dynamicObject.getString("remark")); + } + inFinaceconfirm.set("zcgj_oftaxamount_all",oftaxamountAll); + inFinaceconfirm.set("zcgj_amount_all",amountAll); + inFinaceconfirm.set("zcgj_taxamt_all",taxamtAll); + + OperationResult ecInFinaceconfirm = SaveServiceHelper.saveOperate("zcgj_ec_in_finaceconfirm", new DynamicObject[]{inFinaceconfirm}, null);//支出合同实体 + if(ecInFinaceconfirm.isSuccess()){ + String sourceBillId = inContractSettle.getString("zcgj_invalidbillid"); + DynamicObject sourceBill = BusinessDataServiceHelper.loadSingle(entityNumber, "id,billstatus,billno", new QFilter[]{new QFilter("id", QCP.equals, Long.valueOf(sourceBillId))}); + sourceBill.set("billstatus","D"); + SaveServiceHelper.update(sourceBill); + + //计量单 + QFilter approvalFilter = new QFilter("settlebillno", QCP.equals,sourceBill.getString("billno") ); + DynamicObject[] incontractmeasures = BusinessDataServiceHelper.load("ec_incontractmeasure", "id,settlebillno,billstatus", new QFilter[]{approvalFilter}); + if (incontractmeasures!=null && incontractmeasures.length>0){ + for (DynamicObject dynamicObject : incontractmeasures) { + dynamicObject.set("billstatus","D"); + SaveServiceHelper.update(dynamicObject); + } + } + } + //生成支出财务确认单 end + } + + + IWorkflowPlugin.super.notify(execution); + } +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractSettleFiConfirmWorkFlowPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractSettleFiConfirmWorkFlowPlugin.java index 5b1dc68..b6ae59c 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractSettleFiConfirmWorkFlowPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractSettleFiConfirmWorkFlowPlugin.java @@ -25,7 +25,8 @@ public class OutContractSettleFiConfirmWorkFlowPlugin implements IWorkflowPlugin String entityNumber = execution.getEntityNumber(); DynamicObject outContractSettle = BusinessDataServiceHelper.loadSingle(businessKey, entityNumber); boolean isReversabillid = outContractSettle.getBoolean("zcgj_is_reversabillid"); - if(!isReversabillid) { + boolean isInvalid = outContractSettle.getBoolean("zcgj_is_invalid"); + if(!isReversabillid && !isInvalid) { //如果时冲销单据 //生成支出财务确认单 start //收入合同结算 diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractSettleInvalidWorkFlowPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractSettleInvalidWorkFlowPlugin.java new file mode 100644 index 0000000..61779c3 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractSettleInvalidWorkFlowPlugin.java @@ -0,0 +1,98 @@ +package zcgj.zcdev.zcdev.pr.plugin.workflow; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.operate.result.OperationResult; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.coderule.CodeRuleServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.bos.workflow.api.AgentExecution; +import kd.bos.workflow.engine.extitf.IWorkflowPlugin; + +import java.math.BigDecimal; + +/** + * 支出合同结算单-作废单审核通过工作流插件 + */ +public class OutContractSettleInvalidWorkFlowPlugin implements IWorkflowPlugin { + + @Override + public void notify(AgentExecution execution) { + String eventName = execution.getEventName(); + String businessKey = execution.getBusinessKey(); + String entityNumber = execution.getEntityNumber(); + DynamicObject outContractSettle = BusinessDataServiceHelper.loadSingle(businessKey, entityNumber); + //如果时冲销单据 + boolean isReversabillid = outContractSettle.getBoolean("zcgj_is_invalid"); + if(isReversabillid) { + DynamicObjectCollection itementry = outContractSettle.getDynamicObjectCollection("itementry"); + + //生成支出财务确认单 start + //收入合同结算 + DynamicObject outFinaceconfirm =BusinessDataServiceHelper.newDynamicObject("zcgj_ec_out_finaceconfirm"); + + outFinaceconfirm.set("zcgj_ec_out_contract_sett",outContractSettle.getLong("id")); + outFinaceconfirm.set("zcgj_ec_out_contract_name",outContractSettle.getString("billname")); + outFinaceconfirm.set("zcgj_ec_out_contractid", outContractSettle.getLong("id")); //id文本,冗余 + outFinaceconfirm.set("zcgj_billname",outContractSettle.getString("billname")); + outFinaceconfirm.set("zcgj_contract",outContractSettle.getDynamicObject("contract")); + outFinaceconfirm.set("zcgj_contattr",outContractSettle.getDynamicObject("contattr")); + outFinaceconfirm.set("zcgj_project",outContractSettle.getDynamicObject("project")); + outFinaceconfirm.set("zcgj_period",outContractSettle.getDynamicObject("period")); + outFinaceconfirm.set("zcgj_begindate",outContractSettle.getDate("begindate")); + outFinaceconfirm.set("zcgj_enddate",outContractSettle.getDate("enddate")); + outFinaceconfirm.set("zcgj_conttotaloftaxamount",outContractSettle.getBigDecimal("conttotaloftaxamount")); + outFinaceconfirm.set("zcgj_description",outContractSettle.getString("description")); + outFinaceconfirm.set("zcgj_currency",outContractSettle.getDynamicObject("currency")); + outFinaceconfirm.set("zcgj_invoice_org",outContractSettle.getDynamicObject("project").getDynamicObject("projectorg")); + outFinaceconfirm.set("zcgj_jscustomer",outContractSettle.getDynamicObject("zcgj_jscustomer")); + outFinaceconfirm.set("billstatus","C"); + outFinaceconfirm.set("zcgj_is_invalid",true); + + DynamicObjectCollection entryEntity1 = outFinaceconfirm.getDynamicObjectCollection("zcgj_itementry"); + entryEntity1.clear(); + BigDecimal oftaxamountAll = BigDecimal.ZERO; + BigDecimal amountAll = BigDecimal.ZERO; + BigDecimal taxamtAll = BigDecimal.ZERO; + for (DynamicObject dynamicObject : itementry) { + DynamicObject item = entryEntity1.addNew(); + item.set("zcgj_payitem",dynamicObject.getDynamicObject("payitem")); + BigDecimal oftaxamount = dynamicObject.getBigDecimal("oftaxamount"); + item.set("zcgj_oftaxamount",oftaxamount); + oftaxamountAll = oftaxamountAll.add(oftaxamount); + BigDecimal amount = dynamicObject.getBigDecimal("amount"); + item.set("zcgj_amount",amount); + amountAll = amountAll.add(amount); + item.set("zcgj_rate",dynamicObject.getBigDecimal("rate")); + BigDecimal taxamt = dynamicObject.getBigDecimal("taxamt"); + item.set("zcgj_taxamt",taxamt); + taxamtAll = taxamtAll.add(taxamt); + item.set("zcgj_remark",dynamicObject.getString("remark")); + } + outFinaceconfirm.set("zcgj_oftaxamount_all",oftaxamountAll); + outFinaceconfirm.set("zcgj_amount_all",amountAll); + outFinaceconfirm.set("zcgj_taxamt_all",taxamtAll); + OperationResult zcgjEcOutFinaceconfirm = SaveServiceHelper.saveOperate("zcgj_ec_out_finaceconfirm", new DynamicObject[]{outFinaceconfirm}, null);//支出合同实体 + if(zcgjEcOutFinaceconfirm.isSuccess()){ + String sourceBillId = outContractSettle.getString("zcgj_invalidbillid"); + DynamicObject sourceBill = BusinessDataServiceHelper.loadSingle(entityNumber, "id,billstatus,billno", new QFilter[]{new QFilter("id", QCP.equals, Long.valueOf(sourceBillId))}); + sourceBill.set("billstatus","D"); + SaveServiceHelper.update(sourceBill); + + //计量单 + QFilter approvalFilter = new QFilter("settlebillno", QCP.equals,sourceBill.getString("billno") ); + DynamicObject[] outcontractmeasures = BusinessDataServiceHelper.load("ec_outcontractmeasure", "id,settlebillno,billstatus", new QFilter[]{approvalFilter}); + if(outcontractmeasures!=null && outcontractmeasures.length>0){ + for (DynamicObject dynamicObject : outcontractmeasures) { + dynamicObject.set("billstatus","D"); + SaveServiceHelper.update(dynamicObject); + } + } + } + //生成支出财务确认单 end + } + IWorkflowPlugin.super.notify(execution); + } +} From 8fc5d49a185e30cfa738977651e33153ae513919 Mon Sep 17 00:00:00 2001 From: zhangzhiguo Date: Fri, 6 Jun 2025 15:06:09 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=94=AF=E5=87=BA/=E6=94=B6=E5=85=A5?= =?UTF-8?q?=E5=90=88=E5=90=8C=E7=BB=93=E7=AE=97=E4=BD=9C=E5=BA=9F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ContractSettleFiConfirmWorkFlowPlugin.java | 94 ++++++++++--------- 1 file changed, 50 insertions(+), 44 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/InContractSettleFiConfirmWorkFlowPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/InContractSettleFiConfirmWorkFlowPlugin.java index d83ac32..c71ac61 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/InContractSettleFiConfirmWorkFlowPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/InContractSettleFiConfirmWorkFlowPlugin.java @@ -22,54 +22,60 @@ public class InContractSettleFiConfirmWorkFlowPlugin implements IWorkflowPlugin String businessKey = execution.getBusinessKey(); String entityNumber = execution.getEntityNumber(); DynamicObject inContractSettle = BusinessDataServiceHelper.loadSingle(businessKey, entityNumber); - DynamicObject inFinaceconfirm =BusinessDataServiceHelper.newDynamicObject("zcgj_ec_in_finaceconfirm"); - inFinaceconfirm.set("zcgj_ec_in_contract_sett",inContractSettle.getLong("id")); - inFinaceconfirm.set("zcgj_ec_in_contract_name",inContractSettle.getString("billname")); - inFinaceconfirm.set("zcgj_ec_in_contractid", inContractSettle.getLong("id")); //id文本,冗余 - inFinaceconfirm.set("zcgj_billname",inContractSettle.getString("billname")); - inFinaceconfirm.set("zcgj_contract",inContractSettle.getDynamicObject("contract")); - inFinaceconfirm.set("zcgj_contattr",inContractSettle.getDynamicObject("contattr")); - inFinaceconfirm.set("zcgj_project",inContractSettle.getDynamicObject("project")); - inFinaceconfirm.set("zcgj_period",inContractSettle.getDynamicObject("period")); - inFinaceconfirm.set("zcgj_begindate",inContractSettle.getDate("begindate")); - inFinaceconfirm.set("zcgj_enddate",inContractSettle.getDate("enddate")); - inFinaceconfirm.set("zcgj_conttotaloftaxamount",inContractSettle.getBigDecimal("conttotaloftaxamount")); - inFinaceconfirm.set("zcgj_description",inContractSettle.getString("description")); - inFinaceconfirm.set("zcgj_currency",inContractSettle.getDynamicObject("currency")); - inFinaceconfirm.set("zcgj_invoice_org",inContractSettle.getDynamicObject("project").getDynamicObject("projectorg")); - // getModel().setValue("zcgj_jscustomer",ecincontractsettle.getDynamicObject("zcgj_jscustomer")); - inFinaceconfirm.set("billstatus","A"); + boolean isReversabillid = inContractSettle.getBoolean("zcgj_is_reversabillid"); + boolean isInvalid = inContractSettle.getBoolean("zcgj_is_invalid"); + if(!isReversabillid && !isInvalid) { + //生成支出财务确认单 start + DynamicObject inFinaceconfirm =BusinessDataServiceHelper.newDynamicObject("zcgj_ec_in_finaceconfirm"); - DynamicObjectCollection itementry = inContractSettle.getDynamicObjectCollection("itementry"); + inFinaceconfirm.set("zcgj_ec_in_contract_sett",inContractSettle.getLong("id")); + inFinaceconfirm.set("zcgj_ec_in_contract_name",inContractSettle.getString("billname")); + inFinaceconfirm.set("zcgj_ec_in_contractid", inContractSettle.getLong("id")); //id文本,冗余 + inFinaceconfirm.set("zcgj_billname",inContractSettle.getString("billname")); + inFinaceconfirm.set("zcgj_contract",inContractSettle.getDynamicObject("contract")); + inFinaceconfirm.set("zcgj_contattr",inContractSettle.getDynamicObject("contattr")); + inFinaceconfirm.set("zcgj_project",inContractSettle.getDynamicObject("project")); + inFinaceconfirm.set("zcgj_period",inContractSettle.getDynamicObject("period")); + inFinaceconfirm.set("zcgj_begindate",inContractSettle.getDate("begindate")); + inFinaceconfirm.set("zcgj_enddate",inContractSettle.getDate("enddate")); + inFinaceconfirm.set("zcgj_conttotaloftaxamount",inContractSettle.getBigDecimal("conttotaloftaxamount")); + inFinaceconfirm.set("zcgj_description",inContractSettle.getString("description")); + inFinaceconfirm.set("zcgj_currency",inContractSettle.getDynamicObject("currency")); + inFinaceconfirm.set("zcgj_invoice_org",inContractSettle.getDynamicObject("project").getDynamicObject("projectorg")); + // getModel().setValue("zcgj_jscustomer",ecincontractsettle.getDynamicObject("zcgj_jscustomer")); + inFinaceconfirm.set("billstatus","A"); - DynamicObjectCollection entryEntity1 = inFinaceconfirm.getDynamicObjectCollection("zcgj_itementry"); - entryEntity1.clear(); - BigDecimal oftaxamountAll = BigDecimal.ZERO; - BigDecimal amountAll = BigDecimal.ZERO; - BigDecimal taxamtAll = BigDecimal.ZERO; - for (DynamicObject dynamicObject : itementry) { - DynamicObject item = entryEntity1.addNew(); - item.set("zcgj_payitem",dynamicObject.getDynamicObject("payitem")); - BigDecimal oftaxamount = dynamicObject.getBigDecimal("oftaxamount"); - item.set("zcgj_oftaxamount",oftaxamount); - oftaxamountAll = oftaxamountAll.add(oftaxamount); - BigDecimal amount = dynamicObject.getBigDecimal("amount"); - item.set("zcgj_amount",amount); - amountAll = amountAll.add(amount); - item.set("zcgj_rate",dynamicObject.getBigDecimal("rate")); - BigDecimal taxamt = dynamicObject.getBigDecimal("taxamt"); - item.set("zcgj_taxamt",taxamt); - taxamtAll = taxamtAll.add(taxamt); - item.set("zcgj_remark",dynamicObject.getString("remark")); + DynamicObjectCollection itementry = inContractSettle.getDynamicObjectCollection("itementry"); + + DynamicObjectCollection entryEntity1 = inFinaceconfirm.getDynamicObjectCollection("zcgj_itementry"); + entryEntity1.clear(); + BigDecimal oftaxamountAll = BigDecimal.ZERO; + BigDecimal amountAll = BigDecimal.ZERO; + BigDecimal taxamtAll = BigDecimal.ZERO; + for (DynamicObject dynamicObject : itementry) { + DynamicObject item = entryEntity1.addNew(); + item.set("zcgj_payitem",dynamicObject.getDynamicObject("payitem")); + BigDecimal oftaxamount = dynamicObject.getBigDecimal("oftaxamount"); + item.set("zcgj_oftaxamount",oftaxamount); + oftaxamountAll = oftaxamountAll.add(oftaxamount); + BigDecimal amount = dynamicObject.getBigDecimal("amount"); + item.set("zcgj_amount",amount); + amountAll = amountAll.add(amount); + item.set("zcgj_rate",dynamicObject.getBigDecimal("rate")); + BigDecimal taxamt = dynamicObject.getBigDecimal("taxamt"); + item.set("zcgj_taxamt",taxamt); + taxamtAll = taxamtAll.add(taxamt); + item.set("zcgj_remark",dynamicObject.getString("remark")); + } + inFinaceconfirm.set("zcgj_oftaxamount_all",oftaxamountAll); + inFinaceconfirm.set("zcgj_amount_all",amountAll); + inFinaceconfirm.set("zcgj_taxamt_all",taxamtAll); + + SaveServiceHelper.saveOperate("zcgj_ec_in_finaceconfirm", new DynamicObject[]{inFinaceconfirm}, null);//支出合同实体 + + //生成支出财务确认单 end } - inFinaceconfirm.set("zcgj_oftaxamount_all",oftaxamountAll); - inFinaceconfirm.set("zcgj_amount_all",amountAll); - inFinaceconfirm.set("zcgj_taxamt_all",taxamtAll); - - SaveServiceHelper.saveOperate("zcgj_ec_in_finaceconfirm", new DynamicObject[]{inFinaceconfirm}, null);//支出合同实体 - - //生成支出财务确认单 end IWorkflowPlugin.super.notify(execution); } From 15f1caf561ae1259829b9866386264363df2872b Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Fri, 6 Jun 2025 15:55:55 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E5=8F=91?= =?UTF-8?q?=E7=A5=A8=E5=AF=BC=E5=85=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...aterialInbFinaceConfirmeInvoicePlugin.java | 126 ++++++++++-------- 1 file changed, 70 insertions(+), 56 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java index dd59167..395a79f 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java @@ -44,16 +44,17 @@ import java.util.stream.Collectors; */ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn implements Plugin { private static final Log log = LogFactory.getLog(MaterialInbFinaceConfirmeInvoicePlugin.class); + @Override public void beforeDoOperation(BeforeDoOperationEventArgs args) { super.beforeDoOperation(args); - FormOperate operate = (FormOperate)args.getSource(); + FormOperate operate = (FormOperate) args.getSource(); String key = operate.getOperateKey(); if (StringUtils.equals(key, "newsubentry")) { //选择发票 this.beforeNewSubEntry(args); - } else if (StringUtils.equals(key, "selectinvoice")) { //导入发票 + } else if (StringUtils.equals(key, "selectinvoice")) { //导入发票 this.showInvoiceImport(args); - }else if (key.equals("deletesubentry")) { + } else if (key.equals("deletesubentry")) { this.beforeDeleteSubEntry(args); } } @@ -65,7 +66,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i //returnData = "{\"invoiceData\":[{\"xbrlName\":\"\",\"fileName\":\"\",\"specialTypeMark\":\"\",\"downloadUrl\":\"/dev/2170355234897924096/202505/5b96f486f0de44d4a437a482e830cf95/扬尚发票103417.6.pdf\",\"invoiceAmount\":\"91520\",\"needCheck\":\"1\",\"personFlag\":false,\"type\":\"0\",\"authenticateFlag\":1,\"isElectricInvoice\":\"1\",\"payee\":\"\",\"taxOfdUrl\":\"\",\"salerTaxNo\":\"91320117MADRMAMU8L\",\"invoiceType\":\"27\",\"orgNumber\":\"10006834\",\"invoiceNo\":\"25322000000224247311\",\"salerType\":\"\",\"area\":\"\",\"orgName\":\"南京矿山江苏溧水分公司\",\"buyerTaxNo\":\"913201176867400458\",\"resource\":\"发票助手\",\"selectTime\":\"\",\"originalState\":\"0\",\"companySeal\":\"0\",\"originalInvoiceNo\":\"\",\"xbrlType\":\"\",\"serialNo\":\"c2108f40b42046a986c5891cb59d65cc0\",\"xmlUrl\":\"\",\"checkFlag\":1,\"errorLevel\":\"3\",\"totalAmount\":\"103417.6\",\"xbrlUrl\":\"\",\"salerAddressPhone\":\"江苏省南京市溧水区溧水区晶桥镇枫香岭村配件小区16号 13305141166\",\"checkTime\":\"\",\"authenticateTime\":\"\",\"recordedPurpose\":\"\",\"salelistSum\":0,\"isRevise\":\"1\",\"region\":\"\",\"totalTaxAmount\":\"11897.6\",\"taxAmount\":\"11897.6\",\"recordedTime\":\"\",\"items\":[{\"unitPrice\":\"400\",\"num\":\"228.8\",\"preferentialPolicy\":\"\",\"zeroTaxRateFlag\":\"\",\"taxRate\":\"0.13\",\"unit\":\"时\",\"vatException\":\"\",\"versionNo\":\"\",\"detailAmount\":\"91520\",\"specModel\":\"\",\"discountType\":\"0\",\"goodsCode\":\"3040502019900000000\",\"taxAmount\":\"11897.6\",\"goodsName\":\"*经营租赁*挖机租赁费\",\"seq\":\"0\"}],\"originalInvoiceCode\":\"\",\"deductionFlag\":\"1\",\"salerName\":\"南京扬尚机械租赁有限公司\",\"taxPeriod\":\"\",\"uploadSeq\":1747898704052000000,\"destArea\":\"\",\"proxyMark\":\"0\",\"remark\":\"购方开户银行:中国农业银行股份有限公司南京晶桥支行 银行账号:10127901040003185销方开户银行:中国工商银行股份有限公司南京珍珠南路支行 银行账号:4301031809100080341\",\"delete\":\"1\",\"billCreateTime\":\"2025-05-22 10:45:53\",\"invoice_info\":\"ty_27,st_0,ex_1,ch_1,or_0,au_0,\",\"checkStatus\":\"1\",\"availableAmount\":\"103417.6\",\"imageUrl\":\"/dev/2170355234897924096/202505/rim/22/snap/f4f68a6c6cb84255a3a4e6b35fe710d60.jpg\",\"taxPdfUrl\":\"\",\"pixel\":\"\",\"recordedPeriod\":\"\",\"effectiveTaxAmount\":\"11897.6\",\"invoiceRiskLevel\":\"\",\"buyerAddressPhone\":\"南京市溧水区晶桥镇 18551696115\",\"originalFileName\":\"扬尚发票103417.6.pdf\",\"originalGraphUrl\":\"/dev/2170355234897924096/202505/5b96f486f0de44d4a437a482e830cf95/扬尚发票103417.6.pdf\",\"salerAccount\":\"销方开户银行:中国工商银行股份有限公司南京珍珠南路支行 银行账号:4301031809100080341\",\"amount\":\"91520\",\"fileIndex\":\"\",\"validateMessage\":\"合规性校验通过\",\"drawer\":\"\",\"verifyResult\":[],\"updateTime\":\"2025-05-22 15:24:42\",\"reviewer\":\"\",\"invoiceDate\":\"2025-05-19\",\"buyerName\":\"中国非金属材料南京矿山工程有限公司溧水分公司\",\"invalidDate\":\"\",\"invoiceSource\":\"\",\"pdfurl\":\"/dev/2170355234897924096/202505/5b96f486f0de44d4a437a482e830cf95/扬尚发票103417.6.pdf\",\"sourceArea\":\"\",\"salelistComplete\":\"1\",\"buyerAccount\":\"购方开户银行:中国农业银行股份有限公司南京晶桥支行 银行账号:10127901040003185\",\"rotationAngle\":\"0\",\"recordedStatus\":\"01\",\"snapshotUrl\":\"/dev/2170355234897924096/202505/rim/22/snap/f4f68a6c6cb84255a3a4e6b35fe710d60.jpg\",\"invoiceStatus\":\"0\",\"isModify\":\"0\",\"deductionPurpose\":\"\",\"expendStatus\":\"1\",\"fileType\":\"1\",\"expenseStatus\":\"1\",\"taxXmlUrl\":\"\"}],\"attachData\":[]}"; if (actionId.toLowerCase().startsWith("zcgj_entryentity") && returnData != null) { this.invoiceCloseCallBack(event); - } else if (actionId.toLowerCase().startsWith("selectinvoice") && returnData != null) { + } else if (actionId.toLowerCase().startsWith("selectinvoice") && returnData != null) { this.importInvoiceCallBack(returnData); } } @@ -82,8 +83,14 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i } private void showInvoice(String entryType) { - long currencyId = ((DynamicObject)this.getModel().getValue("zcgj_currency")).getLong("id"); - long orgId = ((DynamicObject)this.getModel().getValue("zcgj_invoice_org")).getLong("id"); + Boolean ismulticurrency = (Boolean) this.getModel().getValue("ismulticurrency");//多币别 + long currencyId = 0L; + if (ismulticurrency) { + currencyId = ((DynamicObject) this.getModel().getValue("currency")).getLong("id");//签约币别 + } else { + currencyId = ((DynamicObject) this.getModel().getValue("stdcurrency")).getLong("id");//本位币别 + } + long orgId = ((DynamicObject) this.getModel().getValue("fiaccountorg")).getLong("id");//财务记账组织 QFilter filter = new QFilter("org", "=", orgId); filter.and(new QFilter("isclaimed", "=", false)); filter.and(new QFilter("billstatus", "=", "C")); @@ -92,38 +99,38 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i filter.and(new QFilter("unapplyamount", ">", BigDecimal.ZERO)); QFilter filter1 = new QFilter("isclaimed", "=", true); filter1.and(new QFilter("billstatus", "=", "C")); - DynamicObject contract = (DynamicObject)this.getModel().getValue("zcgj_contract"); - if (contract != null) { - long contractId = contract.getLong("id"); - filter1.and(new QFilter("contract", "=", contractId)); - filter1.and(new QFilter("unapplyamount", ">", BigDecimal.ZERO)); - DynamicObjectCollection contInvEntryCol = this.getModel().getEntryEntity("zcgj_entryentity"); - if (contInvEntryCol.size() > 0) { - List selectedInvIds = new ArrayList(8); +// DynamicObject contract = (DynamicObject) this.getModel().getValue("zcgj_contract"); +// if (contract != null) { +// long contractId = contract.getLong("id"); +// filter1.and(new QFilter("contract", "=", contractId)); + filter1.and(new QFilter("unapplyamount", ">", BigDecimal.ZERO)); + DynamicObjectCollection contInvEntryCol = this.getModel().getEntryEntity("zcgj_entryentity"); + if (contInvEntryCol.size() > 0) { + List selectedInvIds = new ArrayList(8); - for(DynamicObject contInvEntryObj : contInvEntryCol) { - DynamicObject invoice = contInvEntryObj.getDynamicObject("zcgj_invoice"); - selectedInvIds.add(invoice.getLong("id")); - } - - filter1.and(new QFilter("id", "not in", selectedInvIds)); + for (DynamicObject contInvEntryObj : contInvEntryCol) { + DynamicObject invoice = contInvEntryObj.getDynamicObject("zcgj_invoice"); + selectedInvIds.add(invoice.getLong("id")); } - ListShowParameter param = ShowFormHelper.createShowListForm("ec_in_invoice_f7", true); - param.getListFilterParameter().setFilter(filter.or(filter1)); - param.setMultiSelect(true); - param.setCloseCallBack(new CloseCallBack(this, entryType)); - param.getOpenStyle().setShowType(ShowType.Modal); - this.getView().showForm(param); + filter1.and(new QFilter("id", "not in", selectedInvIds)); } + + ListShowParameter param = ShowFormHelper.createShowListForm("ec_in_invoice_f7", true); + param.getListFilterParameter().setFilter(filter.or(filter1)); + param.setMultiSelect(true); + param.setCloseCallBack(new CloseCallBack(this, entryType)); + param.getOpenStyle().setShowType(ShowType.Modal); + this.getView().showForm(param); +// } } protected void invoiceCloseCallBack(ClosedCallBackEvent event) { - ListSelectedRowCollection rows = (ListSelectedRowCollection)event.getReturnData(); + ListSelectedRowCollection rows = (ListSelectedRowCollection) event.getReturnData(); DynamicObject[] invArr = new DynamicObject[rows.size()]; int index = 0; - DynamicObject upContract = (DynamicObject)this.getModel().getValue("zcgj_contract"); - for(ListSelectedRow row : rows) { + DynamicObject upContract = (DynamicObject) this.getModel().getValue("zcgj_contract"); + for (ListSelectedRow row : rows) { Object invoicePk = row.getPrimaryKeyValue().toString(); int rowIndex = this.getModel().createNewEntryRow("zcgj_entryentity"); this.getModel().setValue("zcgj_invoice", invoicePk.toString(), rowIndex); @@ -138,7 +145,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i invArr[index++] = invoice; invoice.set("isclaimed", true); invoice.set("contract", upContract); - invoice.set("project", (DynamicObject)this.getModel().getValue("zcgj_project")); + invoice.set("project", (DynamicObject) this.getModel().getValue("zcgj_project")); invoice.set("connecttype", "contract"); } SaveServiceHelper.save(invArr); @@ -149,8 +156,8 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i int rowCount = this.getModel().getEntryRowCount(entryId); BigDecimal totalAmount = BigDecimal.ZERO; - for(int i = 0; i < rowCount; ++i) { - BigDecimal amount = (BigDecimal)this.getModel().getValue(columnId, i); + for (int i = 0; i < rowCount; ++i) { + BigDecimal amount = (BigDecimal) this.getModel().getValue(columnId, i); amount = amount == null ? BigDecimal.ZERO : amount; totalAmount = totalAmount.add(amount); } @@ -163,16 +170,16 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i protected void showInvoiceImport(BeforeDoOperationEventArgs args) { String billId = this.getModel().getDataEntity().getPkValue().toString(); if (!billId.equals("0") && "A".equals(this.getModel().getValue("billstatus"))) { - if (this.getModel().getValue("zcgj_invoice_org") == null) { + if (this.getModel().getValue("fiaccountorg") == null) { this.getView().showTipNotification(ResManager.loadKDString("发票企业名称不能为空", "PaymentApplyEditUI_18", "ec-contract-formplugin", new Object[0])); args.setCancel(true); } else { if (!ImportInvoiceUtils.isXhInvoiceCloud()) { args.setCancel(true); ImportInvoiceUtils.showImportView(this); - }else{ + } else { args.setCancel(true); - DynamicObject org = (DynamicObject) this.getModel().getValue("zcgj_invoice_org"); + DynamicObject org = (DynamicObject) this.getModel().getValue("fiaccountorg"); InvoiceCollectHelper.showSelectInvoice(this, org); } } @@ -183,11 +190,18 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i } protected void importInvoiceCallBack(Object returnData) { - DynamicObject org = (DynamicObject)this.getModel().getValue("zcgj_invoice_org"); + DynamicObject org = (DynamicObject) this.getModel().getValue("fiaccountorg"); //List invoiceVOList = InvoiceDataHandleHelper.parseXhInvoiceCloudReturnData(returnData); List invoiceVOList = CustomInvoiceDataHandleHelper.parseXhInvoiceCloudReturnData(returnData); + Boolean ismulticurrency = (Boolean) this.getModel().getValue("ismulticurrency");//多币别 + DynamicObject currency = null; + if (ismulticurrency) { + currency = (DynamicObject) this.getModel().getValue("currency");//签约币别 + } else { + currency = (DynamicObject) this.getModel().getValue("stdcurrency");//本位币别 + } Map> invoiceMap = InvoiceDataHandleHelper.processInvoiceVO(invoiceVOList, RequestContext.get().getCurrUserId(), - org.getLong("id"), new Date(), "ec_in_invoice", (DynamicObject)this.getModel().getValue("zcgj_currency"), true); + org.getLong("id"), new Date(), "ec_in_invoice", currency, true); ImportInvoiceUtils invoiceUtils = new ImportInvoiceUtils(this.getView(), this.getPageCache()); this.addInvoiceToEntry(invoiceUtils, invoiceMap); } @@ -196,11 +210,11 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i if (invoiceMap.isEmpty()) { this.getView().showTipNotification(ResManager.loadKDString("导入发票为空。", "PaymentApplyEditUI_19", "ec-contract-formplugin", new Object[0])); } else { - long orgId = (Long)((DynamicObject)this.getModel().getValue("zcgj_invoice_org")).getPkValue(); - Set newInvoices = (Set)invoiceMap.get(Boolean.TRUE); - Set existInvoices = (Set)invoiceMap.get(Boolean.FALSE); + long orgId = (Long) ((DynamicObject) this.getModel().getValue("fiaccountorg")).getPkValue(); + Set newInvoices = (Set) invoiceMap.get(Boolean.TRUE); + Set existInvoices = (Set) invoiceMap.get(Boolean.FALSE); if (newInvoices != null && !newInvoices.isEmpty()) { - for(DynamicObject newInvoice : newInvoices) { + for (DynamicObject newInvoice : newInvoices) { DynamicObject buyerOrg = newInvoice.getDynamicObject("buyer"); if (buyerOrg != null && buyerOrg.getLong("id") != orgId) { this.getView().showErrorNotification(ResManager.loadKDString("导入失败:当前发票购买方不为当前财务记账组织,请确认信息。", "PaymentApplyEditUI_20", "ec-contract-formplugin", new Object[0])); @@ -211,7 +225,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i this.saveInvoiceData(invoiceUtils, newInvoices, existInvoices); } else if (existInvoices != null) { DynamicObjectCollection contInvEntryCol = this.getModel().getEntryEntity("zcgj_entryentity"); - Map entryMap = (Map)contInvEntryCol.stream().collect(Collectors.toMap(this::getInvoicePK, this::getInvoicePK)); + Map entryMap = (Map) contInvEntryCol.stream().collect(Collectors.toMap(this::getInvoicePK, this::getInvoicePK)); this.initSubEntryEntity(existInvoices, entryMap); } @@ -224,21 +238,21 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i newInvoices.addAll(existInvoices); } - this.initSubEntryEntity(newInvoices, (Map)null); + this.initSubEntryEntity(newInvoices, (Map) null); } protected void initSubEntryEntity(Set invoices, Map entryMap) { if (invoices != null) { List invArr = new ArrayList(invoices.size()); - for(DynamicObject invoice : invoices) { + for (DynamicObject invoice : invoices) { if (entryMap != null && entryMap.get(invoice.getPkValue()) != null) { this.getView().showTipNotification(String.format(ResManager.loadKDString("发票号码%s,已存在分录行", "PaymentApplyEditUI_22", "ec-contract-formplugin", new Object[0]), invoice.getString("invoiceno"))); } else { BigDecimal unApplyAmount = invoice.getBigDecimal("unapplyamount"); - if (unApplyAmount != null && unApplyAmount.doubleValue() <= (double)0.0F) { + if (unApplyAmount != null && unApplyAmount.doubleValue() <= (double) 0.0F) { this.getView().showTipNotification(String.format(ResManager.loadKDString("发票号码%s,金额已经被关联完毕,不可重复使用", "PaymentApplyEditUI_23", "ec-contract-formplugin", new Object[0]), invoice.getString("invoiceno"))); } else { - DynamicObject upContract = (DynamicObject)this.getModel().getValue("zcgj_contract"); + DynamicObject upContract = (DynamicObject) this.getModel().getValue("zcgj_contract"); int rowIndex = this.getModel().createNewEntryRow("zcgj_entryentity"); this.getModel().setValue("zcgj_invoice", invoice.getPkValue(), rowIndex); this.getModel().setValue("zcgj_invoicecurrency", invoice.getDynamicObject("currency") == null ? Long.valueOf("0") : invoice.getDynamicObject("currency").getPkValue(), rowIndex); @@ -250,7 +264,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i this.getModel().setValue("zcgj_applyinvoftaxamt", invoice.getBigDecimal("unapplyamount"), rowIndex); invoice.set("isclaimed", true); invoice.set("contract", upContract); - invoice.set("project", (DynamicObject)this.getModel().getValue("zcgj_project")); + invoice.set("project", (DynamicObject) this.getModel().getValue("zcgj_project")); invoice.set("connecttype", "contract"); invArr.add(invoice); } @@ -258,7 +272,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i } if (invArr.size() > 0) { - SaveServiceHelper.save((DynamicObject[])invArr.toArray(new DynamicObject[invoices.size()])); + SaveServiceHelper.save((DynamicObject[]) invArr.toArray(new DynamicObject[invoices.size()])); } this.getView().invokeOperation("invoicesave"); } @@ -271,7 +285,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i //删除发票 开始 protected void beforeDeleteSubEntry(BeforeDoOperationEventArgs args) { - EntryGrid subGrid = (EntryGrid)this.getControl("zcgj_entryentity"); + EntryGrid subGrid = (EntryGrid) this.getControl("zcgj_entryentity"); int[] selRows = subGrid.getEntryState().getSelectedRows(); if (selRows.length == 0) { this.getView().showMessage(ResManager.loadKDString("请选择发票。", "PaymentApplyEditUI_3", "ec-contract-formplugin", new Object[0])); @@ -281,11 +295,11 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i Set updateInvoicePks = new HashSet(selRows.length); DynamicObjectCollection subEntryEntityCol = this.getModel().getEntryEntity("zcgj_entryentity"); - for(int i = selRows.length - 1; i >= 0; --i) { + for (int i = selRows.length - 1; i >= 0; --i) { int rowIndex = selRows[i]; - DynamicObject invoice = (DynamicObject)this.getModel().getValue("zcgj_invoice", rowIndex); + DynamicObject invoice = (DynamicObject) this.getModel().getValue("zcgj_invoice", rowIndex); updateInvoicePks.add(invoice.getPkValue()); - delPks[i] = ((DynamicObject)subEntryEntityCol.get(selRows[i])).getPkValue(); + delPks[i] = ((DynamicObject) subEntryEntityCol.get(selRows[i])).getPkValue(); this.getModel().deleteEntryRow("zcgj_entryentity", rowIndex); } @@ -297,7 +311,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i filter.and("id", "!=", this.getModel().getDataEntity().getPkValue()); DynamicObjectCollection invoiceApplyEntries = QueryServiceHelper.query("zcgj_ecma_materialinb_ext", "zcgj_entryentity.zcgj_invoice", new QFilter[]{filter}); if (invoiceApplyEntries != null && !invoiceApplyEntries.isEmpty()) { - for(DynamicObject subEntry : invoiceApplyEntries) { + for (DynamicObject subEntry : invoiceApplyEntries) { updateInvoicePks.remove(subEntry.get("zcgj_entryentity.zcgj_invoice")); } } @@ -306,11 +320,11 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i DynamicObject[] invoices = BusinessDataServiceHelper.load("ec_in_invoice", "isinvoiceclaim,isclaimed,contract,project,connecttype", new QFilter[]{new QFilter("id", "in", updateInvoicePks)}); - for(DynamicObject invoice : invoices) { + for (DynamicObject invoice : invoices) { if (!invoice.getBoolean("isinvoiceclaim")) { invoice.set("isclaimed", false); - invoice.set("contract", (Object)null); - invoice.set("project", (Object)null); + invoice.set("contract", (Object) null); + invoice.set("project", (Object) null); invoice.set("connecttype", "null"); } } From aafc6c63b6a3dd6a4dc42eac5a0e248aba5ad8c2 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Fri, 6 Jun 2025 15:56:11 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=EF=BC=88=E9=A1=B9=E7=9B=AE=E8=B5=84=E9=87=91=EF=BC=89=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E5=95=86=E8=B5=8B=E5=80=BC=E6=94=B6=E6=AC=BE=E9=93=B6?= =?UTF-8?q?=E8=A1=8C=E5=92=8C=E6=94=B6=E6=AC=BE=E8=B4=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/PaymentApplySupplierPlugin.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PaymentApplySupplierPlugin.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PaymentApplySupplierPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PaymentApplySupplierPlugin.java new file mode 100644 index 0000000..b574110 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PaymentApplySupplierPlugin.java @@ -0,0 +1,37 @@ +package zcgj.zcdev.zcdev.pr.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; + +// 付款申请(项目资金)供应商赋值收款银行和收款账号 +public class PaymentApplySupplierPlugin extends AbstractBillPlugIn { + + @Override + public void propertyChanged(PropertyChangedArgs e) { + String propName = e.getProperty().getName(); + if (propName.equals("zcgj_supplier1")) { + //供应商 + ChangeData[] changeSet = e.getChangeSet(); + ChangeData changeData = changeSet[0]; + int rowIndex = changeData.getRowIndex(); //修改行所在行行号 + DynamicObject zcgj_supplier1 = (DynamicObject) changeData.getNewValue();//新值 + if (zcgj_supplier1 != null) { + DynamicObjectCollection entry_bankCollection = zcgj_supplier1.getDynamicObjectCollection("entry_bank");//银行信息分录 + for (DynamicObject entry_bank : entry_bankCollection) { + boolean isdefault_bank = entry_bank.getBoolean("isdefault_bank");//默认 + if (isdefault_bank) { + this.getModel().setValue("zcgj_payerbank", entry_bank.get("bank"), rowIndex);//开户银行 + this.getModel().setValue("zcgj_payeraccountname", entry_bank.get("bankaccount"), rowIndex);//银行账号 + return; + } + } + } else { + this.getModel().setValue("zcgj_payerbank", null, rowIndex);//开户银行 + this.getModel().setValue("zcgj_payeraccountname", null, rowIndex);//银行账号 + } + } + } +} From 3b0deb688dfe89c9cf3ff24b22c4f92f786ec1b5 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Fri, 6 Jun 2025 16:27:06 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E5=8F=91?= =?UTF-8?q?=E7=A5=A8=E5=AF=BC=E5=85=A5=E6=8F=92=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialInbFinaceConfirmeInvoicePlugin.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java index 395a79f..3b88c07 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java @@ -129,7 +129,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i ListSelectedRowCollection rows = (ListSelectedRowCollection) event.getReturnData(); DynamicObject[] invArr = new DynamicObject[rows.size()]; int index = 0; - DynamicObject upContract = (DynamicObject) this.getModel().getValue("zcgj_contract"); +// DynamicObject upContract = (DynamicObject) this.getModel().getValue("zcgj_contract"); for (ListSelectedRow row : rows) { Object invoicePk = row.getPrimaryKeyValue().toString(); int rowIndex = this.getModel().createNewEntryRow("zcgj_entryentity"); @@ -144,8 +144,8 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i this.getModel().setValue("zcgj_applyinvoftaxamt", invoice.getBigDecimal("unapplyamount"), rowIndex); invArr[index++] = invoice; invoice.set("isclaimed", true); - invoice.set("contract", upContract); - invoice.set("project", (DynamicObject) this.getModel().getValue("zcgj_project")); +// invoice.set("contract", upContract); + invoice.set("project", (DynamicObject) this.getModel().getValue("project")); invoice.set("connecttype", "contract"); } SaveServiceHelper.save(invArr); @@ -252,7 +252,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i if (unApplyAmount != null && unApplyAmount.doubleValue() <= (double) 0.0F) { this.getView().showTipNotification(String.format(ResManager.loadKDString("发票号码%s,金额已经被关联完毕,不可重复使用", "PaymentApplyEditUI_23", "ec-contract-formplugin", new Object[0]), invoice.getString("invoiceno"))); } else { - DynamicObject upContract = (DynamicObject) this.getModel().getValue("zcgj_contract"); +// DynamicObject upContract = (DynamicObject) this.getModel().getValue("zcgj_contract"); int rowIndex = this.getModel().createNewEntryRow("zcgj_entryentity"); this.getModel().setValue("zcgj_invoice", invoice.getPkValue(), rowIndex); this.getModel().setValue("zcgj_invoicecurrency", invoice.getDynamicObject("currency") == null ? Long.valueOf("0") : invoice.getDynamicObject("currency").getPkValue(), rowIndex); @@ -263,8 +263,8 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i this.getModel().setValue("zcgj_unapplyinvtax", invoice.getBigDecimal("unapplyinvtax"), rowIndex); this.getModel().setValue("zcgj_applyinvoftaxamt", invoice.getBigDecimal("unapplyamount"), rowIndex); invoice.set("isclaimed", true); - invoice.set("contract", upContract); - invoice.set("project", (DynamicObject) this.getModel().getValue("zcgj_project")); +// invoice.set("contract", upContract); + invoice.set("project", (DynamicObject) this.getModel().getValue("project")); invoice.set("connecttype", "contract"); invArr.add(invoice); } @@ -309,7 +309,7 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i // DynamicObjectType subDT = this.getModel().getDynamicObjectCollection("zcgj_entryentity").getDynamicObjectType(); QFilter filter = new QFilter("zcgj_entryentity.zcgj_invoice", "in", updateInvoicePks); filter.and("id", "!=", this.getModel().getDataEntity().getPkValue()); - DynamicObjectCollection invoiceApplyEntries = QueryServiceHelper.query("zcgj_ecma_materialinb_ext", "zcgj_entryentity.zcgj_invoice", new QFilter[]{filter}); + DynamicObjectCollection invoiceApplyEntries = QueryServiceHelper.query("ecma_materialinbill", "zcgj_entryentity.zcgj_invoice", new QFilter[]{filter}); if (invoiceApplyEntries != null && !invoiceApplyEntries.isEmpty()) { for (DynamicObject subEntry : invoiceApplyEntries) { updateInvoicePks.remove(subEntry.get("zcgj_entryentity.zcgj_invoice"));