From e75ccb8f5dc30513e204498e5fd0273bb9d6aa0a Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Thu, 23 Oct 2025 11:17:18 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=94=B6=E5=85=A5=E3=80=81=E6=94=AF?= =?UTF-8?q?=E5=87=BA=E5=90=88=E5=90=8C=E7=A1=AE=E8=AE=A4=E5=8D=95=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=97=B6=E5=8F=8D=E5=AE=A1=E6=A0=B8=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E5=90=88=E5=90=8C=E7=BB=93=E7=AE=97=E5=8D=95=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=E7=BB=99=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E5=8D=95=E5=8F=91=E8=B5=B7=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/InFinaceconfirmBackSettleOp.java | 107 +++++++++++++++++ .../operate/OutFinaceconfirmBackSettleOp.java | 113 ++++++++++++++++++ 2 files changed, 220 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InFinaceconfirmBackSettleOp.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutFinaceconfirmBackSettleOp.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InFinaceconfirmBackSettleOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InFinaceconfirmBackSettleOp.java new file mode 100644 index 0000000..647ac9b --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InFinaceconfirmBackSettleOp.java @@ -0,0 +1,107 @@ +package zcgj.zcdev.zcdev.pr.plugin.operate; + +import kd.bos.dataentity.OperateOption; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.LocaleString; +import kd.bos.entity.operate.OperateOptionConst; +import kd.bos.entity.operate.result.OperationResult; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.PreparePropertysEventArgs; +import kd.bos.entity.plugin.args.EndOperationTransactionArgs; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.message.api.MessageChannels; +import kd.bos.metadata.dao.MetaCategory; +import kd.bos.metadata.dao.MetadataDao; +import kd.bos.metadata.form.FormMetadata; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.DeleteServiceHelper; +import kd.bos.servicehelper.operation.OperationServiceHelper; +import kd.bos.servicehelper.workflow.MessageCenterServiceHelper; +import kd.bos.workflow.engine.msg.info.MessageInfo; + +import java.util.ArrayList; +import java.util.List; + +/** + * 支出财务确认单删除时退回支出合同结算单 + */ +public class InFinaceconfirmBackSettleOp extends AbstractOperationServicePlugIn { + + private static final Log log = LogFactory.getLog(InFinaceconfirmBackSettleOp.class); +//OperationResult result = OperationServiceHelper.executeOperate("submit", "ec_out_contract_settle", new DynamicObject[]{outContractSettle}, option); +// + public void onPreparePropertys(PreparePropertysEventArgs e) { + e.getFieldKeys().add("zcgj_ec_in_contractid"); //支出结算单id + + } + @Override + public void endOperationTransaction(EndOperationTransactionArgs e) { + String operationKey = e.getOperationKey(); + DynamicObject[] dataEntities = e.getDataEntities(); + switch (operationKey) { + case "delback"://删除 + delOutFincBackSettle(dataEntities, true); + break; + } + } + + protected void delOutFincBackSettle(DynamicObject[] dataEntities, boolean isSubmit){ + List updateData = new ArrayList<>(); + for (DynamicObject dataEntity : dataEntities) { + long id = dataEntity.getLong("id"); + long contractseetid = dataEntity.getLong("zcgj_ec_in_contractid"); + + DynamicObject outContractSettle = BusinessDataServiceHelper.loadSingle(contractseetid, "ec_in_contract_settle"); + + String billstatus = outContractSettle.getString("billstatus"); + if(billstatus.equals("C")){ + OperateOption option= OperateOption.create(); + option.setVariableValue(OperateOptionConst.ISHASRIGHT, String.valueOf(true));//跳过权限校验 + OperationResult result = OperationServiceHelper.executeOperate("unaudit", "ec_in_contract_settle", new DynamicObject[]{outContractSettle}, option); + + if(result.isSuccess()){ + QFilter idFilter = new QFilter("id", "=", id); + int zcgjEcInFinaceconfirm = DeleteServiceHelper.delete("zcgj_ec_in_finaceconfirm", new QFilter[]{idFilter}); + + DynamicObject creator = outContractSettle.getDynamicObject("creator"); + long userId = creator.getLong("id"); + String billno = outContractSettle.getString("billno"); + List userids= new ArrayList(); + userids.add(userId); + sendMessage(userids,"ec_in_contract_settle",billno); + }else{ + log.info("InFinaceconfirmBackSettleOp:"+result.getMessage()); + } + } + + } + + } + + //结算单的创建人 + //支出合同结算单XXXX已被驳回。 + public void sendMessage(List userIds,String entityNumber,String billno) { + String id = MetadataDao.getIdByNumber(entityNumber, MetaCategory.Form); + FormMetadata formMeta = (FormMetadata) MetadataDao.readRuntimeMeta(id, MetaCategory.Form); + //单据名称: + String billName = formMeta.getName().getLocaleValue(); + //messageinfo 使用工作流包下的对象 + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setTitle(billName+"-驳回提醒"); + + LocaleString localeString = new LocaleString(); + localeString.setLocaleValue_zh_CN("收入合同结算单"+billno+"已被驳回。"); + messageInfo.setMessageContent(localeString); + + messageInfo.setUserIds(userIds); + //messageInfo.setType(MessageInfo.TYPE_TASK); + messageInfo.setType(MessageInfo.TYPE_MESSAGE); + messageInfo.setTag(billName+"-驳回提醒"); + messageInfo.setEntityNumber(entityNumber); + messageInfo.setNotifyType(MessageChannels.MC.getNumber()); + MessageCenterServiceHelper.sendMessage(messageInfo); + } + +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutFinaceconfirmBackSettleOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutFinaceconfirmBackSettleOp.java new file mode 100644 index 0000000..5af898d --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutFinaceconfirmBackSettleOp.java @@ -0,0 +1,113 @@ +package zcgj.zcdev.zcdev.pr.plugin.operate; + +import kd.bos.dataentity.OperateOption; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.entity.LocaleString; +import kd.bos.db.tx.TX; +import kd.bos.db.tx.TXHandle; +import kd.bos.entity.operate.OperateOptionConst; +import kd.bos.entity.operate.result.OperationResult; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.PreparePropertysEventArgs; +import kd.bos.entity.plugin.args.EndOperationTransactionArgs; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.message.api.MessageChannels; +import kd.bos.metadata.dao.MetaCategory; +import kd.bos.metadata.dao.MetadataDao; +import kd.bos.metadata.form.FormMetadata; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.DeleteServiceHelper; +import kd.bos.servicehelper.operation.OperationServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.bos.servicehelper.workflow.MessageCenterServiceHelper; +import kd.bos.workflow.engine.msg.info.MessageInfo; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * 支出财务确认单删除时退回支出合同结算单 + */ +public class OutFinaceconfirmBackSettleOp extends AbstractOperationServicePlugIn { + + private static final Log log = LogFactory.getLog(OutFinaceconfirmBackSettleOp.class); +//OperationResult result = OperationServiceHelper.executeOperate("submit", "ec_out_contract_settle", new DynamicObject[]{outContractSettle}, option); +// + public void onPreparePropertys(PreparePropertysEventArgs e) { + e.getFieldKeys().add("zcgj_ec_out_contractid"); //支出结算单id + + } + @Override + public void endOperationTransaction(EndOperationTransactionArgs e) { + String operationKey = e.getOperationKey(); + DynamicObject[] dataEntities = e.getDataEntities(); + switch (operationKey) { + case "delback"://删除 + delOutFincBackSettle(dataEntities, true); + break; + } + } + + protected void delOutFincBackSettle(DynamicObject[] dataEntities, boolean isSubmit){ + List updateData = new ArrayList<>(); + for (DynamicObject dataEntity : dataEntities) { + long id = dataEntity.getLong("id"); + long contractseetid = dataEntity.getLong("zcgj_ec_out_contractid"); + + DynamicObject outContractSettle = BusinessDataServiceHelper.loadSingle(contractseetid, "ec_out_contract_settle"); + + String billstatus = outContractSettle.getString("billstatus"); + if(billstatus.equals("C")){ + OperateOption option= OperateOption.create(); + option.setVariableValue(OperateOptionConst.ISHASRIGHT, String.valueOf(true));//跳过权限校验 + OperationResult result = OperationServiceHelper.executeOperate("unaudit", "ec_out_contract_settle", new DynamicObject[]{outContractSettle}, option); + + if(result.isSuccess()){ + QFilter idFilter = new QFilter("id", "=", id); + int zcgjEcInFinaceconfirm = DeleteServiceHelper.delete("zcgj_ec_out_finaceconfirm", new QFilter[]{idFilter}); + + DynamicObject creator = outContractSettle.getDynamicObject("creator"); + long userId = creator.getLong("id"); + String billno = outContractSettle.getString("billno"); + List userids= new ArrayList(); + userids.add(userId); + sendMessage(userids,"ec_out_contract_settle",billno); + }else{ + log.info("OutFinaceconfirmBackSettleOp:"+result.getMessage()); + } + } + + } + + } + + //结算单的创建人 + //支出合同结算单XXXX已被驳回。 + public void sendMessage(List userIds,String entityNumber,String billno) { + String id = MetadataDao.getIdByNumber(entityNumber, MetaCategory.Form); + FormMetadata formMeta = (FormMetadata) MetadataDao.readRuntimeMeta(id, MetaCategory.Form); + //单据名称: + String billName = formMeta.getName().getLocaleValue(); + //messageinfo 使用工作流包下的对象 + MessageInfo messageInfo = new MessageInfo(); + messageInfo.setTitle(billName+"-驳回提醒"); + + LocaleString localeString = new LocaleString(); + localeString.setLocaleValue_zh_CN("支出合同结算单"+billno+"已被驳回。"); + messageInfo.setMessageContent(localeString); + + messageInfo.setUserIds(userIds); + //messageInfo.setType(MessageInfo.TYPE_TASK); + messageInfo.setType(MessageInfo.TYPE_MESSAGE); + messageInfo.setTag(billName+"-驳回提醒"); + messageInfo.setEntityNumber(entityNumber); + messageInfo.setNotifyType(MessageChannels.MC.getNumber()); + MessageCenterServiceHelper.sendMessage(messageInfo); + } + +} From 5af3b351a0b6f462d44d2cbdd8accd7807521410 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Thu, 23 Oct 2025 11:17:53 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=94=AF=E5=87=BA=E5=90=88=E5=90=8C?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=86=B2=E9=94=80=E5=8D=95=E5=8F=8D=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=A0=A1=E9=AA=8C=E6=98=AF=E5=90=A6=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=94=B6=E5=85=A5=E5=90=88=E5=90=8C=E5=86=B2=E9=94=80=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OutContractSettleUnauditCheckOp.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettleUnauditCheckOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettleUnauditCheckOp.java index 5df747c..efaffbb 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettleUnauditCheckOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettleUnauditCheckOp.java @@ -10,6 +10,7 @@ import kd.bos.entity.validate.AbstractValidator; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.DeleteServiceHelper; import java.math.BigDecimal; @@ -52,14 +53,24 @@ public class OutContractSettleUnauditCheckOp extends AbstractOperationServicePlu } } - DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_ec_out_finaceconfirm", "id,zcgj_ec_out_contractid", new QFilter[]{new QFilter("zcgj_ec_out_contractid", QCP.equals, billId)}); + DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_ec_out_finaceconfirm", "id,zcgj_ec_out_contractid,billstatus", new QFilter[]{new QFilter("zcgj_ec_out_contractid", QCP.equals, billId)}); if (load != null && load.length > 0) { - if(isReversabillid){ - this.addFatalErrorMessage(extendedDataEntity, "支出合同结算冲销单【"+billno+"】存在支出合同确认单,请删除支出合同确认单后再进行反审核操作。"); - }else{ - this.addFatalErrorMessage(extendedDataEntity, "支出合同结算单【"+billno+"】存在支出合同确认单,请删除支出合同确认单后再进行反审核操作。"); + for (DynamicObject dynamicObject : load) { + String billstatus = dynamicObject.getString("billstatus"); + if("C".equals(billstatus) || "B".equals(billstatus)) { + if(isReversabillid){ + this.addFatalErrorMessage(extendedDataEntity, "支出合同结算冲销单【"+billno+"】存在支出合同确认单,请删除支出合同确认单后再进行反审核操作。"); + }else{ + this.addFatalErrorMessage(extendedDataEntity, "支出合同结算单【"+billno+"】存在支出合同确认单,请删除支出合同确认单后再进行反审核操作。"); + } + return; + }else{ + QFilter idFilter = new QFilter("id", "=", dynamicObject.getLong("id")); + QFilter statusFilter = new QFilter("billstatus", "=", "A"); + DeleteServiceHelper.delete("zcgj_ec_out_finaceconfirm", new QFilter[]{idFilter.and(statusFilter)}); + } } - return; + } } } From 72e5464e3df005b62c46c49d73b407c1678536b2 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Thu, 23 Oct 2025 11:18:38 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=97=A0=E5=90=88=E5=90=8C=E4=BB=98?= =?UTF-8?q?=E6=AC=BE=E6=B7=BB=E5=8A=A0=E5=8F=91=E7=A5=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PublicreimbursebillNoContractPlugin.java | 211 +++++++++++++++++- 1 file changed, 205 insertions(+), 6 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillNoContractPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillNoContractPlugin.java index c1faf3f..0b15454 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillNoContractPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillNoContractPlugin.java @@ -7,18 +7,18 @@ import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.LocaleString; import kd.bos.dataentity.metadata.IDataEntityProperty; +import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType; import kd.bos.dataentity.resource.ResManager; import kd.bos.entity.datamodel.IDataModel; +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.ClientProperties; -import kd.bos.form.FormShowParameter; +import kd.bos.form.*; import kd.bos.form.control.AttachmentPanel; import kd.bos.form.control.EntryGrid; import kd.bos.form.control.events.ItemClickEvent; -import kd.bos.form.events.AfterDoOperationEventArgs; -import kd.bos.form.events.PreOpenFormEventArgs; -import kd.bos.form.events.SetFilterEvent; +import kd.bos.form.events.*; import kd.bos.form.field.BasedataEdit; import kd.bos.form.field.ComboEdit; import kd.bos.form.field.ComboItem; @@ -32,8 +32,11 @@ import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.QueryServiceHelper; -import org.apache.commons.lang.StringUtils; +import kd.bos.servicehelper.operation.DeleteServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import org.apache.commons.lang3.StringUtils; +import java.math.BigDecimal; import java.util.*; /** @@ -113,6 +116,202 @@ public class PublicreimbursebillNoContractPlugin extends AbstractBillPlugIn impl } + @Override + public void beforeDoOperation(BeforeDoOperationEventArgs args) { + super.beforeDoOperation(args); + FormOperate operate = (FormOperate)args.getSource(); + String key = operate.getOperateKey(); + if (org.apache.commons.lang3.StringUtils.equals(key, "newsubentryinvoice")) { //选择发票 + this.beforeNewsubentryinvoice(args); + }/* else if (StringUtils.equals(key, "selectinvoice")) { //导入发票 + this.showInvoiceImport(args); + }*/else if (key.equals("deletesubentryinvoice")) { + this.beforeDeleteSubEntry(args); + } + } + + //选择发票 开始 + protected void beforeNewsubentryinvoice(BeforeDoOperationEventArgs args) { + String billId = this.getModel().getDataEntity().getPkValue().toString(); + if (!billId.equals("0") && "A".equals(this.getModel().getValue("billstatus"))) { + this.showInvoice("invoiceentry"); + } 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("currency")).getLong("id"); + DynamicObject costcompany = (DynamicObject) this.getModel().getValue("costcompany"); + if (costcompany == null){ + this.getView().showErrorNotification("清先填写发票企业名称!"); + return; + } + DynamicObject project = (DynamicObject) this.getModel().getValue("zcgj_ec_project"); + if (project == null){ + this.getView().showErrorNotification("请先选择工程项目!"); + return; + } + long orgId = costcompany.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)); + filter.and(new QFilter("project", "=", project.getLong("id"))); + + //QFilter filter1 = new QFilter("isclaimed", "=", true); + //filter1.and(new QFilter("billstatus", "=", "C")); + //filter1.and(new QFilter("unapplyamount", ">", BigDecimal.ZERO)); + DynamicObjectCollection contInvEntryCol = this.getModel().getEntryEntity("invoiceentry"); + if (contInvEntryCol.size() > 0) { + List selectedInvIds = new ArrayList(8); + + for(DynamicObject contInvEntryObj : contInvEntryCol) { + Long ecinvoiceid = contInvEntryObj.getLong("zcgj_ecinvoiceid"); + selectedInvIds.add(ecinvoiceid); + } + + filter.and(new QFilter("id", "not in", selectedInvIds)); + } + + DynamicObject[] invoices = BusinessDataServiceHelper.load("ec_in_invoice", "id", new QFilter[]{filter}); + ListShowParameter param = ShowFormHelper.createShowListForm("ec_in_invoice_f7", true); + + if(invoices.length > 0){ + List ids = new ArrayList<>(invoices.length); + for (DynamicObject invoice : invoices) { + ids.add(invoice.getLong("id")); + } + param.getListFilterParameter().setFilter(new QFilter("id", "in", ids)); + }else{ + param.getListFilterParameter().setFilter(new QFilter("id", "in", new ArrayList())); + } + param.setMultiSelect(true); + param.setCloseCallBack(new CloseCallBack(this, entryType)); + param.getOpenStyle().setShowType(ShowType.Modal); + this.getView().showForm(param); + } + + 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("invoiceentry") && returnData != null) { + this.invoiceCloseCallBack(event); + } + } + + protected void invoiceCloseCallBack(ClosedCallBackEvent event) { + ListSelectedRowCollection rows = (ListSelectedRowCollection)event.getReturnData(); + DynamicObject[] invArr = new DynamicObject[rows.size()]; + int index = 0; + DynamicObject project = (DynamicObject)this.getModel().getValue("zcgj_ec_project"); + for(ListSelectedRow row : rows) { + Object invoicePk = row.getPrimaryKeyValue().toString(); + int rowIndex = this.getModel().createNewEntryRow("invoiceentry"); + this.getModel().setValue("zcgj_ecinvoiceid", Long.valueOf(invoicePk.toString()), rowIndex);//发票id + DynamicObject invoice = BusinessDataServiceHelper.loadSingle(invoicePk, "ec_in_invoice", + "invoicecode,invoiceno,invoicedate,invoicetypeid,unapplyinvtax,unapplyamount,entryentity,entryentity.taxrate,isClaimed,contract,project,connecttype,currency,totalamount,totaltax,totaloftaxamount,seller"); + DynamicObject invoicetypeid = invoice.getDynamicObject("invoicetypeid"); + if(invoicetypeid != null) { + this.getModel().setValue("invoicetype", invoicetypeid.getString("number"), rowIndex); + } + this.getModel().setValue("invoicecode", invoice.getString("invoicecode"), rowIndex); //发票代码 invoicecode + this.getModel().setValue("invoiceno", invoice.getString("invoiceno"), rowIndex); //发票号码 invoiceno + this.getModel().setValue("invoicedate", invoice.getDate("invoicedate"), rowIndex); //开票日期 invoicedate + this.getModel().setValue("invoicecurrency", invoice.getDynamicObject("currency") == null ? Long.valueOf("0") : invoice.getDynamicObject("currency").getPkValue(), rowIndex); //发票币别 + this.getModel().setValue("totalamount", invoice.getBigDecimal("totaloftaxamount"), rowIndex); //价税合计 totaloftaxamount + this.getModel().setValue("taxamount_invoice", invoice.getBigDecimal("totaltax"), rowIndex); //税额 totaltax + this.getModel().setValue("invoicenotaxamount", invoice.getBigDecimal("totalamount"), rowIndex); //不含税金额 totalamount + DynamicObject seller = invoice.getDynamicObject("seller"); + if(seller != null) { + this.getModel().setValue("makeoutcompname", seller.getString("name"), rowIndex); //开票公司 seller.name + } + DynamicObjectCollection dynamicObjectCollection = invoice.getDynamicObjectCollection("entryentity"); + if(dynamicObjectCollection != null && !dynamicObjectCollection.isEmpty()) { + if(dynamicObjectCollection.size() == 1) { + DynamicObject taxrate = dynamicObjectCollection.get(0).getDynamicObject("taxrate"); + BigDecimal taxrate1 = taxrate.getBigDecimal("taxrate"); + this.getModel().setValue("alltaxrate", taxrate1.multiply(new BigDecimal(100)), rowIndex); //税率 + }else{ + //税率 = 税额/不含税金额 + BigDecimal totaltax = invoice.getBigDecimal("totaltax"); + BigDecimal totalamount = invoice.getBigDecimal("totalamount"); + if(totaltax !=null && totalamount != null && totalamount.compareTo(BigDecimal.ZERO) != 0) { + BigDecimal divide = totaltax.divide(totalamount, 2, BigDecimal.ROUND_HALF_UP); + this.getModel().setValue("alltaxrate", divide.multiply(new BigDecimal(100)), rowIndex); //税率 + } + } + } + + invArr[index++] = invoice; + invoice.set("isclaimed", true); + invoice.set("project", project); + // invoice.set("project", (DynamicObject)this.getModel().getValue("zcgj_project")); + //invoice.set("connecttype", "contract"); + } + SaveServiceHelper.save(invArr); + this.getView().invokeOperation("invoicesave"); + this.getView().updateView("invoiceentry"); + } + + protected void beforeDeleteSubEntry(BeforeDoOperationEventArgs args) { + EntryGrid subGrid = (EntryGrid)this.getControl("invoiceentry"); + 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("invoiceentry"); + + for(int i = selRows.length - 1; i >= 0; --i) { + int rowIndex = selRows[i]; + Long ecinvoiceid = (Long)this.getModel().getValue("zcgj_ecinvoiceid", rowIndex); + if(ecinvoiceid!=null){ + updateInvoicePks.add(ecinvoiceid); + delPks[i] = ((DynamicObject)subEntryEntityCol.get(selRows[i])).getPkValue(); + } + this.getModel().deleteEntryRow("invoiceentry", rowIndex); + } + + DynamicObjectType subDT = this.getModel().getDataEntity().getDynamicObjectCollection("invoiceentry").getDynamicObjectType(); + QFilter filter = new QFilter("invoiceentry.zcgj_ecinvoiceid", "in", updateInvoicePks); + filter.and("id", "!=", this.getModel().getDataEntity().getPkValue()); + DynamicObjectCollection invoiceApplyEntries = QueryServiceHelper.query("er_publicreimbursebill", "invoiceentry.zcgj_ecinvoiceid", new QFilter[]{filter}); + if (invoiceApplyEntries != null && !invoiceApplyEntries.isEmpty()) { + for(DynamicObject subEntry : invoiceApplyEntries) { + updateInvoicePks.remove(subEntry.get("invoiceentry.zcgj_ecinvoiceid")); + } + } + + 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("project", (Object)null); + invoice.set("connecttype", "null"); + } + } + + //SaveServiceHelper.save(invoices); + } + + DeleteServiceHelper.delete(subDT, delPks); + this.getView().showSuccessNotification("发票删除成功!"); + //this.setEnableByInvoice(); + } + } + @Override public void preOpenForm(PreOpenFormEventArgs e) { super.preOpenForm(e); From 696a84f1b915ece50542e1a9f03c10588ed10586 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Thu, 23 Oct 2025 11:19:11 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E7=A7=91=E7=9B=AE=E4=BD=99=E9=A2=9D?= =?UTF-8?q?=E5=B7=A5=E5=BA=8F=E5=8F=96=E6=95=B0=E8=A1=A8=EF=BC=8C=E5=8F=96?= =?UTF-8?q?=E6=95=B0=E5=85=AC=E5=8F=B8=E9=80=9A=E8=BF=87=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=A1=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/common/SubjectbalanceAutoData.java | 59 ++++++++++++++----- .../fs/plugin/form/SubjectbalancePlugin.java | 28 ++++++++- 2 files changed, 70 insertions(+), 17 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/common/SubjectbalanceAutoData.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/common/SubjectbalanceAutoData.java index 285188f..0f93093 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/common/SubjectbalanceAutoData.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/common/SubjectbalanceAutoData.java @@ -27,14 +27,14 @@ public class SubjectbalanceAutoData { private static final String[] asseestypeArrays = new String[]{"0032","0017",""}; - public static void getData() { + public static void getData(Long periodId,boolean isAuto) { String[] selectorsArray = new String[]{"beginlocal", "endlocal", "yeardebitfor", "yearcreditfor", "debitlocal", "creditlocal"}; QFilter filteraccountTable = new QFilter("number", QCP.equals, "0003"); DynamicObject accountTableLoad = BusinessDataServiceHelper.loadSingle("bd_accounttable", "id", new QFilter[]{filteraccountTable}); // 查询核算组织 - QFilter number = new QFilter("fisaccounting", "=", "1"); + /*QFilter number = new QFilter("fisaccounting", "=", "1"); QFilter structure = new QFilter("structure.longnumber", QCP.like, "10000000!10006431%"); QFilter isleaf = new QFilter("structure.isleaf", QCP.equals, true); DynamicObject[] load = BusinessDataServiceHelper.load("bos_org", "id,structure.longnumber,structure.view", new QFilter[]{number, structure, isleaf}); @@ -59,6 +59,22 @@ public class SubjectbalanceAutoData { orgNumberMap.put(dynamicObject.getString("number"), dynamicObject); orgIds.add(dynamicObject.getLong("id")); } + }*/ + + //通过配置表取公司 + Map orgNumberMap = new HashMap<>(); + List orgIds = new ArrayList<>(); + DynamicObject[] companybelongs = BusinessDataServiceHelper.load("zcgj_companybelong", "id,zcgj_companyblentry.zcgj_org", new QFilter[]{}); + for (DynamicObject companybelong : companybelongs) { + DynamicObjectCollection companyblentryCollection = companybelong.getDynamicObjectCollection("zcgj_companyblentry"); + for (DynamicObject dynamicObject : companyblentryCollection) { + DynamicObject zcgjOrg = dynamicObject.getDynamicObject("zcgj_org"); + if(zcgjOrg!=null){ + long id = zcgjOrg.getLong("id"); + orgIds.add(id); + orgNumberMap.put(zcgjOrg.getString("number"), zcgjOrg); + } + } } // 查询组织下对应的当前期间数据 @@ -72,11 +88,14 @@ public class SubjectbalanceAutoData { } // 标记旧数据为非最新 - List sqlparams = new ArrayList<>(); - Object[] sqlparam = new Object[]{false}; - sqlparams.add(sqlparam); - DB.executeBatch(DBRoute.of("fi"), - "update tk_zcgj_rpt_assistbalangx set fk_zcgj_isnew = ? ", sqlparams); + if(isAuto) { //使用自动执行时标记旧数据 + List sqlparams = new ArrayList<>(); + Object[] sqlparam = new Object[]{false}; + sqlparams.add(sqlparam); + DB.executeBatch(DBRoute.of("fi"), + "update tk_zcgj_rpt_assistbalangx set fk_zcgj_isnew = ? ", sqlparams); + } + for (String asseestype : asseestypeArrays) { // 查询科目余额配置表 @@ -102,17 +121,25 @@ public class SubjectbalanceAutoData { DynamicObject orgObj = orgNumberMap.get(orgNumber); DynamicObject periodObj = orgByCurperiodMap.get(orgObj.getLong("id")); DynamicObject curperiod = null; - if (periodObj != null) { - curperiod = periodObj.getDynamicObject("curperiod"); - if (curperiod != null) { - balanceQueryParamApi.setPeriodNumber(curperiod.getString("number")); // + if(periodId==null){ + if (periodObj != null) { + curperiod = periodObj.getDynamicObject("curperiod"); + if (curperiod != null) { + balanceQueryParamApi.setPeriodNumber(curperiod.getString("number")); // + } else { + continue; + } } else { continue; } - } else { - continue; + }else{ + QFilter idFilter = new QFilter("id", QCP.equals, periodId); + curperiod = BusinessDataServiceHelper.loadSingle("bd_period", "id,number", new QFilter[]{idFilter}); + String periodNumber = curperiod.getString("number"); + balanceQueryParamApi.setPeriodNumber(periodNumber); // } + List groupBy = new ArrayList<>(); if (!StringUtils.isEmpty(asseestype)) { Map>> accountAssgrp = new HashMap<>(); @@ -161,7 +188,7 @@ public class SubjectbalanceAutoData { assistbalance.set("zcgj_accounttable", accountTableLoad); assistbalance.set("zcgj_account", record.getAccount()); assistbalance.set("zcgj_period", curperiod); - assistbalance.set("zcgj_isnew", true); + assistbalance.set("zcgj_isnew", isAuto); assistbalance.set("zcgj_sourcetype", asseestype); Map assgrp = record.getAssgrp(); @@ -186,9 +213,9 @@ public class SubjectbalanceAutoData { try { // ✅ 删除旧数据(保证每个组织、每个期间只保留一份最新的) Long orgId = orgObj.getLong("id"); - Long periodId = curperiod.getLong("id"); + Long periodIddelete = curperiod.getLong("id"); QFilter orgFilter = new QFilter("zcgj_org", QCP.equals, orgId); - QFilter periodFilter = new QFilter("zcgj_period", QCP.equals, periodId); + QFilter periodFilter = new QFilter("zcgj_period", QCP.equals, periodIddelete); QFilter sourcetypeFilter = new QFilter("zcgj_sourcetype", QCP.equals, asseestype); QFilter isnewFilter = new QFilter("zcgj_isnew", QCP.equals, false); DeleteServiceHelper.delete("zcgj_rpt_assistbalancegx", new QFilter[]{orgFilter.and(periodFilter).and(sourcetypeFilter).and(isnewFilter)}); diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/SubjectbalancePlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/SubjectbalancePlugin.java index 0a39283..020667e 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/SubjectbalancePlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/SubjectbalancePlugin.java @@ -1,12 +1,19 @@ package zcgj.zcdev.zcdev.fs.plugin.form; +import kd.bos.entity.filter.ControlFilters; import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.list.IListView; import kd.bos.list.plugin.AbstractListPlugin; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.operation.DeleteServiceHelper; import kd.sdk.plugin.Plugin; +import zcgj.zcdev.zcdev.fs.plugin.common.AssetsLiabilitiesbalanceAutoData; import zcgj.zcdev.zcdev.fs.plugin.common.SubjectbalanceAutoData; +import java.util.List; + /** * 核算维度余额取数表(矿山二开) */ @@ -20,7 +27,26 @@ public class SubjectbalancePlugin extends AbstractListPlugin implements Plugin String itemKey = evt.getItemKey(); if("zcgj_gatdata".equals(itemKey)) { //科目余额表自动取数 - SubjectbalanceAutoData.getData();//其他 + SubjectbalanceAutoData.getData(null,true);//其他 + }else if("zcgj_gatdataperiod".equals(itemKey)) { + //获取列表查询参数 + ControlFilters filters = ((IListView)this.getView()).getControlFilters(); + List filter = filters.getFilter("zcgj_period.id"); + if(filter.isEmpty()) { + this.getView().showMessage("请选择期间!"); + }else{ + for (Object periodId : filter) { + if(periodId instanceof String) { + SubjectbalanceAutoData.getData(Long.valueOf((String)periodId),false);//其他 + } + } + //重新执行一下拉取最新的数据,解决历史数据最新勾选问题 + //AssetsLiabilitiesbalanceAutoData.getData(null);//其他 + } + + }else if("zcgj_deleteall".equals(itemKey)) { + int zcgjRptAssistbalanZcfz = DeleteServiceHelper.delete("zcgj_rpt_assistbalancegx", new QFilter[]{}); + this.getView().showMessage("操作完成!"); } } From a61824e72faa5b81190362718a553db15d40b1b9 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Thu, 23 Oct 2025 11:19:21 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=94=AF=E5=87=BA=E8=B4=A2=E5=8A=A1?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=8D=95=E6=8F=90=E4=BA=A4=E6=97=B6=E5=86=B2?= =?UTF-8?q?=E9=94=80=E9=87=91=E9=A2=9D=E6=A0=A1=E9=AA=8C=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialinbillReversalamountCkOp.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinbillReversalamountCkOp.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinbillReversalamountCkOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinbillReversalamountCkOp.java new file mode 100644 index 0000000..10adbfa --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialinbillReversalamountCkOp.java @@ -0,0 +1,81 @@ +package zcgj.zcdev.zcdev.pr.plugin.operate; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.ExtendedDataEntity; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.AddValidatorsEventArgs; +import kd.bos.entity.plugin.PreparePropertysEventArgs; +import kd.bos.entity.validate.AbstractValidator; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.servicehelper.BusinessDataServiceHelper; + +import java.math.BigDecimal; + +/** + * 支出财务确认单提交时冲销金额校验插件 + */ +public class MaterialinbillReversalamountCkOp extends AbstractOperationServicePlugIn { + + private static final Log log = LogFactory.getLog(MaterialinbillReversalamountCkOp.class); + + public void onPreparePropertys(PreparePropertysEventArgs e) { + e.getFieldKeys().add("zcgj_prepayentry"); + e.getFieldKeys().add("zcgj_prepayentry.zcgj_sourceapplybillid"); + e.getFieldKeys().add("zcgj_prepayentry.zcgj_sourceapplyentryid"); + e.getFieldKeys().add("zcgj_prepayentry.zcgj_boltamount"); + e.getFieldKeys().add("zcgj_isprepay"); + } + + @Override + public void onAddValidators(AddValidatorsEventArgs e) { + super.onAddValidators(e); + e.getValidators().add(new ValidatorExt()); + } + + class ValidatorExt extends AbstractValidator { + @Override + public void validate() { + ExtendedDataEntity[] extendedDataEntities = this.getDataEntities(); + for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) { + DynamicObject dataEntity = extendedDataEntity.getDataEntity();//支出财务确认单 + DynamicObjectCollection entryEntityCollection = dataEntity.getDynamicObjectCollection("zcgj_prepayentry");//付款信息分录 + for (int i = 0; i < entryEntityCollection.size(); i++) { + DynamicObject entryEntity = entryEntityCollection.get(i); + DynamicObjectCollection prepayentryCollection = dataEntity.getDynamicObjectCollection("zcgj_prepayentry");//冲销预付分录 + String isprepay = dataEntity.getString("zcgj_isprepay"); + if("10".equals(isprepay)){ + if(prepayentryCollection == null || prepayentryCollection.isEmpty()){ + this.addFatalErrorMessage(extendedDataEntity, String.format("请录入冲销预付明细数据!")); + }else{ + int seq = 0; + for (DynamicObject prepay : prepayentryCollection) { + seq++; + long sourceapplybillid = prepay.getLong("zcgj_sourceapplybillid"); + long sourceapplyentryid = prepay.getLong("zcgj_sourceapplyentryid"); + BigDecimal boltamount = prepay.getBigDecimal("zcgj_boltamount");//入库单冲销金额 + DynamicObject paymentapply = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "ec_paymentapply");//工程资金付款申请单 + if (paymentapply != null) { + DynamicObjectCollection entryentityCollection = paymentapply.getDynamicObjectCollection("entryentity"); + + for (DynamicObject dynamicObject : entryentityCollection) { + BigDecimal thisrealpayamt = dynamicObject.getBigDecimal("thisrealpayamt");//付款申请单本次实付金额 + long pkValue = (long)dynamicObject.getPkValue(); + if(pkValue==sourceapplyentryid){ + BigDecimal zcgjYreversalamount = dynamicObject.getBigDecimal("zcgj_yreversalamount"); + zcgjYreversalamount = zcgjYreversalamount.add(boltamount); + if(thisrealpayamt.subtract(zcgjYreversalamount).compareTo(BigDecimal.ZERO) < 0){ + this.addFatalErrorMessage(extendedDataEntity, String.format("冲销预付分录第%d行,冲销金额超限!",seq)); + } + } + } + } + } + } + } + } + } + } + } +} From 4c8243252e985bd9e2fcd2f29367cee464d4df67 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Thu, 23 Oct 2025 11:19:46 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8F=91=E7=A5=A8=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/form/MaterialInbFinaceConfirmeInvoicePlugin.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 1d5476f..9470881 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 @@ -346,8 +346,10 @@ public class MaterialInbFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i 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(); + if(invoice!=null){ + updateInvoicePks.add(invoice.getPkValue()); + delPks[i] = ((DynamicObject) subEntryEntityCol.get(selRows[i])).getPkValue(); + } this.getModel().deleteEntryRow("zcgj_entryentity", rowIndex); } From 57e06cfb4d6742959ac0745bd4d212c3c2a35888 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Thu, 23 Oct 2025 11:19:52 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=94=B6=E5=85=A5=E5=90=88=E5=90=8C?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=86=B2=E9=94=80=E5=8D=95=E5=8F=8D=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=A0=A1=E9=AA=8C=E6=98=AF=E5=90=A6=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=94=B6=E5=85=A5=E5=90=88=E5=90=8C=E5=86=B2=E9=94=80=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/InContractSettleUnauditCheckOp.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettleUnauditCheckOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettleUnauditCheckOp.java index 0b86b7c..e0e2664 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettleUnauditCheckOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/InContractSettleUnauditCheckOp.java @@ -9,6 +9,7 @@ import kd.bos.entity.validate.AbstractValidator; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.DeleteServiceHelper; /** * 收入合同结算冲销单反审核校验是否生成收入合同冲销单 @@ -47,10 +48,20 @@ public class InContractSettleUnauditCheckOp extends AbstractOperationServicePlug } }*/ - DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_ec_in_finaceconfirm", "id,zcgj_ec_in_contractid", new QFilter[]{new QFilter("zcgj_ec_in_contractid", QCP.equals, billId)}); + DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_ec_in_finaceconfirm", "id,zcgj_ec_in_contractid,billstatus", new QFilter[]{new QFilter("zcgj_ec_in_contractid", QCP.equals, billId)}); if (load != null && load.length > 0) { - this.addFatalErrorMessage(extendedDataEntity, "收入合同结算单【"+billno+"】存在收入合同确认单,请删除收入合同确认单后再进行反审核操作。"); - return; + for (DynamicObject dynamicObject : load) { + String billstatus = dynamicObject.getString("billstatus"); + if("C".equals(billstatus) || "B".equals(billstatus)) { + this.addFatalErrorMessage(extendedDataEntity, "收入合同结算单【"+billno+"】存在收入合同确认单,请删除收入合同确认单后再进行反审核操作。"); + return; + }else{ + QFilter idFilter = new QFilter("id", "=", dynamicObject.getLong("id")); + QFilter statusFilter = new QFilter("billstatus", "=", "A"); + DeleteServiceHelper.delete("zcgj_ec_in_finaceconfirm", new QFilter[]{idFilter.and(statusFilter)}); + } + } + } } } From 115a00af422b2655da952637056934b3ffa71a2b Mon Sep 17 00:00:00 2001 From: zhangzhiguo <421587375@qq.com> Date: Thu, 23 Oct 2025 11:20:27 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E7=A7=91=E7=9B=AE=E4=BD=99=E9=A2=9D?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E8=A1=A8=20-=20=E8=B5=84=E4=BA=A7=E8=B4=9F?= =?UTF-8?q?=E5=80=BA=E8=8E=B7=E5=8F=96=E5=85=AC=E5=8F=B8=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=A1=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssetsLiabilitiesbalanceAutoData.java | 35 ++++++++++++++----- .../form/AssetsLiabilitiesbalancePlugin.java | 31 ++++++++++++++-- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/common/AssetsLiabilitiesbalanceAutoData.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/common/AssetsLiabilitiesbalanceAutoData.java index 9ed28b6..c2d48bb 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/common/AssetsLiabilitiesbalanceAutoData.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/common/AssetsLiabilitiesbalanceAutoData.java @@ -27,14 +27,14 @@ public class AssetsLiabilitiesbalanceAutoData { private static final String[] asseestypeArrays = new String[]{"0001","0005","0003"}; - public static void getData(Long periodId) { + public static void getData(Long periodId,boolean isAuto) { String[] selectorsArray = new String[]{"beginlocal", "endlocal", "yeardebitfor", "yearcreditfor", "debitlocal", "creditlocal"}; QFilter filteraccountTable = new QFilter("number", QCP.equals, "0003"); DynamicObject accountTableLoad = BusinessDataServiceHelper.loadSingle("bd_accounttable", "id", new QFilter[]{filteraccountTable}); // 查询核算组织 - QFilter number = new QFilter("fisaccounting", "=", "1"); + /*QFilter number = new QFilter("fisaccounting", "=", "1"); QFilter structure = new QFilter("structure.longnumber", QCP.like, "10000000!10006431%"); QFilter isleaf = new QFilter("structure.isleaf", QCP.equals, true); DynamicObject[] load = BusinessDataServiceHelper.load("bos_org", "id,structure.longnumber,structure.view", new QFilter[]{number, structure, isleaf}); @@ -59,8 +59,25 @@ public class AssetsLiabilitiesbalanceAutoData { orgNumberMap.put(dynamicObject.getString("number"), dynamicObject); orgIds.add(dynamicObject.getLong("id")); } + }*/ + + //通过配置表取公司 + Map orgNumberMap = new HashMap<>(); + List orgIds = new ArrayList<>(); + DynamicObject[] companybelongs = BusinessDataServiceHelper.load("zcgj_companybelong", "id,zcgj_companyblentry.zcgj_org", new QFilter[]{}); + for (DynamicObject companybelong : companybelongs) { + DynamicObjectCollection companyblentryCollection = companybelong.getDynamicObjectCollection("zcgj_companyblentry"); + for (DynamicObject dynamicObject : companyblentryCollection) { + DynamicObject zcgjOrg = dynamicObject.getDynamicObject("zcgj_org"); + if(zcgjOrg!=null){ + long id = zcgjOrg.getLong("id"); + orgIds.add(id); + orgNumberMap.put(zcgjOrg.getString("number"), zcgjOrg); + } + } } + // 查询组织下对应的当前期间数据 DynamicObject[] orgByCurperiod = BusinessDataServiceHelper.load("gl_accountbook", "org,curperiod", @@ -72,11 +89,13 @@ public class AssetsLiabilitiesbalanceAutoData { } // 标记旧数据为非最新 - List sqlparams = new ArrayList<>(); - Object[] sqlparam = new Object[]{false}; - sqlparams.add(sqlparam); - DB.executeBatch(DBRoute.of("fi"), - "update tk_zcgj_rpt_assistbalangx set fk_zcgj_isnew = ? ", sqlparams); + if(isAuto){ //使用自动执行时标记旧数据 + List sqlparams = new ArrayList<>(); + Object[] sqlparam = new Object[]{false}; + sqlparams.add(sqlparam); + DB.executeBatch(DBRoute.of("fi"), + "update tk_zcgj_rpt_assistbalzcfz set fk_zcgj_isnew = ? ", sqlparams); + } for (String asseestype : asseestypeArrays) { // 查询科目余额配置表 @@ -168,7 +187,7 @@ public class AssetsLiabilitiesbalanceAutoData { assistbalance.set("zcgj_accounttable", accountTableLoad); assistbalance.set("zcgj_account", record.getAccount()); assistbalance.set("zcgj_period", curperiod); - assistbalance.set("zcgj_isnew", true); + assistbalance.set("zcgj_isnew", isAuto); assistbalance.set("zcgj_sourcetype", asseestype); Map assgrp = record.getAssgrp(); diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AssetsLiabilitiesbalancePlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AssetsLiabilitiesbalancePlugin.java index 21df182..afbaa74 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AssetsLiabilitiesbalancePlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/AssetsLiabilitiesbalancePlugin.java @@ -1,5 +1,6 @@ package zcgj.zcdev.zcdev.fs.plugin.form; +import kd.bos.dataentity.entity.DynamicObject; import kd.bos.entity.filter.ControlFilters; import kd.bos.form.control.events.ItemClickEvent; import kd.bos.list.IListView; @@ -7,10 +8,16 @@ import kd.bos.list.ListShowParameter; 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.bos.servicehelper.operation.DeleteServiceHelper; import kd.sdk.plugin.Plugin; import zcgj.zcdev.zcdev.fs.plugin.common.AssetsLiabilitiesbalanceAutoData; import zcgj.zcdev.zcdev.fs.plugin.common.SubjectbalanceAutoData; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.List; /** @@ -25,7 +32,22 @@ public class AssetsLiabilitiesbalancePlugin extends AbstractListPlugin implement String itemKey = evt.getItemKey(); if("zcgj_gatdata".equals(itemKey)) { //科目余额表自动取数 - AssetsLiabilitiesbalanceAutoData.getData(null);//其他 + //获取当前自然月作为最新期间 + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + // 定义格式器 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM"); + // 格式化为字符串 + String currentMonth = currentDate.format(formatter); + + QFilter idFilter = new QFilter("number", QCP.equals, currentMonth); + DynamicObject curperiod = BusinessDataServiceHelper.loadSingle("bd_period", "id,number", new QFilter[]{idFilter}); + if(curperiod!=null){ + AssetsLiabilitiesbalanceAutoData.getData(curperiod.getLong("id"),true);//其他 + }else{ + this.getView().showMessage("获取当前期间有误!"); + } + }else if("zcgj_gatdataperiod".equals(itemKey)) { //获取列表查询参数 ControlFilters filters = ((IListView)this.getView()).getControlFilters(); @@ -35,13 +57,16 @@ public class AssetsLiabilitiesbalancePlugin extends AbstractListPlugin implement }else{ for (Object periodId : filter) { if(periodId instanceof String) { - AssetsLiabilitiesbalanceAutoData.getData(Long.valueOf((String)periodId));//其他 + AssetsLiabilitiesbalanceAutoData.getData(Long.valueOf((String)periodId),false);//其他 } } //重新执行一下拉取最新的数据,解决历史数据最新勾选问题 - AssetsLiabilitiesbalanceAutoData.getData(null);//其他 + //AssetsLiabilitiesbalanceAutoData.getData(null);//其他 } + }else if("zcgj_deleteall".equals(itemKey)) { + int zcgjRptAssistbalanZcfz = DeleteServiceHelper.delete("zcgj_rpt_assistbalan_zcfz", new QFilter[]{}); + this.getView().showMessage("操作完成!"); } }