From bfd607f01980dbb434ccd2932070b8a37dbb1431 Mon Sep 17 00:00:00 2001 From: weiyunlong Date: Fri, 15 Nov 2024 20:11:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E5=80=BC=E7=A1=AE=E8=AE=A4=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BC=98=E5=8C=96(=E6=AF=8F=E6=AC=A1=E5=AE=8C?= =?UTF-8?q?=E5=B7=A5=E9=87=8F=E9=9A=94=E7=A6=BB)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recon/formplugin/ContractFormPlugin.java | 29 +++++++- .../formplugin/WorkloadcfmbillFormPlugin.java | 74 ++++++++++--------- .../opplugin/IntroduceContractPlugin.java | 23 ++++-- 3 files changed, 79 insertions(+), 47 deletions(-) diff --git a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java index c6d2f8b..cea7b7a 100644 --- a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java +++ b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java @@ -10,6 +10,7 @@ import kd.bos.entity.BasedataEntityType; import kd.bos.entity.datamodel.IDataModel; import kd.bos.entity.datamodel.events.BeforeDeleteEntryEventArgs; import kd.bos.entity.datamodel.events.IDataModelChangeListener; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.entity.property.BasedataProp; import kd.bos.entity.property.EntryProp; import kd.bos.entity.property.MulBasedataProp; @@ -205,6 +206,25 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis this.getView().invokeOperation("refresh"); return result; } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + + super.propertyChanged(e); + String name = e.getProperty().getName();//字段名称 + if("qeug_chmentpanel_f".equals(name)){ + Object qeugChmentpanelF = this.getModel().getValue("qeug_chmentpanel_f"); + if (qeugChmentpanelF instanceof Number) { + int pkLongValue = ((Number) qeugChmentpanelF).intValue(); // 转换为 long + if (pkLongValue == 0) { + this.getView().getModel().getEntryEntity("qeug_invoiceentryinfo").clear(); + this.getView().updateView("qeug_invoiceentryinfo"); + } + } + } + } + @Override public void afterDoOperation(AfterDoOperationEventArgs args) { @@ -244,8 +264,9 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis for (Map fileMap : attachments) { Object attPkId = fileMap.get("attPkId"); if (null == attPkId) { - this.getView().showTipNotification("请先保存单据"); - return; +// this.getView().showTipNotification("请先保存单据"); +// return; + this.getView().invokeOperation("save");//调用保存 } List> attachmentes = AttachmentServiceHelper.getAttachments("recon_contractbill", this.getModel().getValue("id"), "qeug_attachmentpanelap"); for (Map attachment : attachmentes) { @@ -307,7 +328,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis case 0: double num = Double.parseDouble(cell.toString()); int result = (int)num; - contractsummarylist.set("qeug_seq",String.valueOf(result));//序号 + contractsummarylist.set("qeug_seqs",result);//序号 break; case 1: contractsummarylist.set("qeug_projectnumber",cell);//项目编码 @@ -392,7 +413,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis } this.getView().updateView("qeug_invoiceentryinfo"); SaveServiceHelper.save(new DynamicObject[]{this.getView().getModel().getDataEntity()}); - this.getView().showSuccessNotification("清单汇总识别成功"); +// this.getView().showSuccessNotification("清单汇总识别成功"); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/main/java/shkd/repc/recon/formplugin/WorkloadcfmbillFormPlugin.java b/main/java/shkd/repc/recon/formplugin/WorkloadcfmbillFormPlugin.java index 310d56c..07077b0 100644 --- a/main/java/shkd/repc/recon/formplugin/WorkloadcfmbillFormPlugin.java +++ b/main/java/shkd/repc/recon/formplugin/WorkloadcfmbillFormPlugin.java @@ -36,13 +36,16 @@ import java.util.Map; */ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements TabSelectListener { - - - @Override public void beforeDoOperation(BeforeDoOperationEventArgs args) { super.beforeDoOperation(args); + DynamicObject cqcontract = (DynamicObject) this.getModel().getValue("contractbill"); + long id = 0; + if (null != cqcontract) { + id = cqcontract.getLong("id"); + } + FormOperate source = (FormOperate) args.getSource(); String operateKey = source.getOperateKey(); switch (operateKey) { @@ -54,14 +57,35 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab this.getView().showTipNotification("新增行无法查看明细"); return; } - DynamicObject cqcontract = (DynamicObject) this.getModel().getValue("contractbill"); - long id = 0; - if (null != cqcontract) { - id = cqcontract.getLong("id"); - } getListShowParamer(this.getView(), this.getModel(),String.valueOf(id)); break; + case "audit": + //产值确认--清单明细 + DynamicObjectCollection invoiceentryinfos = this.getModel().getDataEntity(true).getDynamicObjectCollection("qeug_invoiceentryinfo"); + //产值确认审核时,将所有明细的完成百分比覆盖掉合同看的清单 + for (DynamicObject invoiceentryinfo : invoiceentryinfos) { + QFilter q3 = new QFilter("qeug_sheetname", QCP.equals, invoiceentryinfo.getString("qeug_summarycontent")); + QFilter q4 = new QFilter("qeug_contractid",QCP.equals, String.valueOf(id)); + QFilter q5 = new QFilter("qeug_workloadcfmid",QCP.equals, String.valueOf(this.getModel().getDataEntity().getPkValue())); + DynamicObject[] recon_contractbills = BusinessDataServiceHelper.load("qeug_contractsummarylist", + "id,qeug_seq,qeug_seqs,qeug_projectnumber,qeug_projectname,qeug_featuredescript,qeug_engincontent," + + "qeug_unit,qeug_decimalqty,qeug_unitprice,qeug_amounttotal,qeug_artificial,qeug_provisional," + + "qeug_remarks,qeug_contractid,qeug_sheetname,qeug_cumulativepreofpro", new QFilter[]{q3,q4,q5}); + if (recon_contractbills.length > 0) { + for (int i = 0; i < recon_contractbills.length; i++) { + DynamicObject contractsummarylist = recon_contractbills[i]; + QFilter q6 = new QFilter("qeug_workloadcfmid",QCP.equals, "");//未作产值确认时的清单 + QFilter q7 = new QFilter("qeug_seqs",QCP.equals, contractsummarylist.getBigDecimal("qeug_seqs"));//项目编码 + DynamicObject add = BusinessDataServiceHelper.loadSingle("qeug_contractsummarylist", new QFilter[]{q3, q4, q6, q7}); + if (null != add) { + add.set("qeug_cumulativepreofpro",contractsummarylist.getBigDecimal("qeug_cumulativepreofpro"));//累计进度百分比(%) + SaveServiceHelper.save(new DynamicObject[]{add}); + } + } + } + } + break; default: break; } @@ -73,32 +97,14 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab * @param model 模型 */ private void getListShowParamer(IFormView formView, IDataModel model,String contentId) { - -// ListShowParameter parameter = ShowFormHelper.createShowListForm("qeug_contractsummarylist", true); -// parameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);//Floating MainNewTabPage NewBrowserPage NewTabPage -// parameter.setBillFormId("qeug_contractsummarylist"); -// parameter.setHasRight(true); -// StyleCss styleCss = new StyleCss(); -// styleCss.setWidth("1500"); -// styleCss.setHeight("800"); -// parameter.getOpenStyle().setInlineStyleCss(styleCss); DynamicObjectCollection dynColl = formView.getModel().getEntryEntity("qeug_invoiceentryinfo"); int index = model.getEntryCurrentRowIndex("qeug_invoiceentryinfo"); DynamicObject dynamicObject = dynColl.get(index); String qeug_summarycontent = dynamicObject.getString("qeug_summarycontent");//汇总内容(sheetName) //// Object pkValue = formView.getModel().getDataEntity().getPkValue();//合同ID -// QFilter q1 = new QFilter("qeug_sheetname", QCP.equals, qeug_summarycontent); QFilter q2 = new QFilter("qeug_contractid",QCP.equals, contentId); QFilter q3 = new QFilter("qeug_workloadcfmid",QCP.equals,String.valueOf(this.getModel().getDataEntity().getPkValue())); -// List listQF = Lists.newArrayList(); -// listQF.add(q1.and(q2)); -// parameter.setListFilterParameter(new ListFilterParameter(listQF, null)); -// parameter.setCustomParam("qeug_sheetname",qeug_summarycontent); -// parameter.setCustomParam("qeug_contractid",contentId); -// parameter.setStatus(OperationStatus.ADDNEW); -// this.getView().showForm(parameter); -// OpenFormUtils.openListPage(); Map map = new HashMap(); map.put("Workloadcfmbill_id", this.getModel().getDataEntity().getPkValue()); OpenFormUtils.openListPage(this.getView(), "qeug_contractsummarylist", ShowType.MainNewTabPage,map, q1.and(q2).and(q3), (CloseCallBack) null); @@ -139,11 +145,6 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab add.set("qeug_isnew", qeug_invoiceentryinfo.get("qeug_isnew")); add.set("qeug_remarks", qeug_invoiceentryinfo.get("qeug_remarks")); add.set("qeug_currencylist", qeug_invoiceentryinfo.get("qeug_currencylist")); -// this.getModel().setValue("qeug_summarycontent", qeug_invoiceentryinfo.get("qeug_summarycontent"), i);//汇总内容 -// this.getModel().setValue("qeug_amount", qeug_invoiceentryinfo.get("qeug_amount"), i);//金额(元) -// this.getModel().setValue("qeug_isnew", qeug_invoiceentryinfo.get("qeug_isnew"), i);//是否新增行 -// this.getModel().setValue("qeug_remarks", qeug_invoiceentryinfo.get("qeug_remarks"), i);//备注 -// this.getModel().setValue("qeug_currencylist", qeug_invoiceentryinfo.get("qeug_currencylist"), i);//清单币别 } //携带工程经理 @@ -162,16 +163,16 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab QFilter q4 = new QFilter("qeug_contractid",QCP.equals, String.valueOf(id)); QFilter q5 = new QFilter("qeug_workloadcfmid",QCP.equals, "");//防止第二次产值确认时,id覆盖确认过的清单产值确认 DynamicObject[] recon_contractbills = BusinessDataServiceHelper.load("qeug_contractsummarylist", - "id,qeug_seq,qeug_projectnumber,qeug_projectname,qeug_featuredescript,qeug_engincontent," + + "id,qeug_seqs,qeug_projectnumber,qeug_projectname,qeug_featuredescript,qeug_engincontent," + "qeug_unit,qeug_decimalqty,qeug_unitprice,qeug_amounttotal,qeug_artificial,qeug_provisional," + - "qeug_remarks,qeug_contractid,qeug_sheetname", new QFilter[]{q3,q4,q5}); + "qeug_remarks,qeug_contractid,qeug_sheetname,qeug_cumulativepreofpro", new QFilter[]{q3,q4,q5}); if (recon_contractbills.length > 0) { for (int i = 0; i < recon_contractbills.length; i++) { DynamicObject contractsummarylist = recon_contractbills[i]; DynamicObject add = BusinessDataServiceHelper.newDynamicObject("qeug_contractsummarylist"); - add.set("qeug_seq", contractsummarylist.getString("qeug_seq")); - add.set("qeug_projectnumber", contractsummarylist.getString("qeug_projectnumber")); - add.set("qeug_projectname", contractsummarylist.getString("qeug_projectname")); + add.set("qeug_seqs", contractsummarylist.getString("qeug_seqs")); + add.set("qeug_projectnumber", contractsummarylist.getString("qeug_projectnumber").trim()); + add.set("qeug_projectname", contractsummarylist.getString("qeug_projectname").trim()); add.set("qeug_featuredescript", contractsummarylist.getString("qeug_featuredescript")); add.set("qeug_engincontent", contractsummarylist.getString("qeug_engincontent")); add.set("qeug_unit", contractsummarylist.getString("qeug_unit")); @@ -183,6 +184,7 @@ public class WorkloadcfmbillFormPlugin extends AbstractFormPlugin implements Tab add.set("qeug_remarks", contractsummarylist.getString("qeug_remarks")); add.set("qeug_contractid", contractsummarylist.getString("qeug_contractid")); add.set("qeug_sheetname", contractsummarylist.getString("qeug_sheetname")); + add.set("qeug_cumulativepreofpro", contractsummarylist.getString("qeug_cumulativepreofpro"));//累计完成百分比 add.set("qeug_workloadcfmid",String.valueOf(this.getModel().getDataEntity().getPkValue())); add.set("enable","1");//使用状态 add.set("status","A");//数据状态 diff --git a/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java b/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java index 63ed8b5..5f43837 100644 --- a/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java +++ b/main/java/shkd/repc/recon/opplugin/IntroduceContractPlugin.java @@ -21,11 +21,9 @@ public class IntroduceContractPlugin extends BatchImportPlugin { while (iterator.hasNext()){ ImportBillData importBillData = iterator.next(); JSONObject data = importBillData.getData(); - String qeug_bcdecimalqtys = (String) data.get("qeug_bcdecimalqtys");//本次完工量 String qeug_decimalqty = (String) data.get("qeug_decimalqty");//工程量 - String qeug_preofpro = (String) data.get("qeug_preofpro");//进度百分比 - String qeug_workloadcfmid = (String) data.get("qeug_workloadcfmid");//产值确认id - BigDecimal bcdecimalqty = null; + String qeug_preofpro = (String) data.get("qeug_preofpro");//当前进度百分比 + String qeug_cumulativepreofpro = (String) data.get("qeug_cumulativepreofpro");//累计进度百分比 BigDecimal decimalqty =null; BigDecimal preofpro =null; if (qeug_decimalqty != null && qeug_preofpro!= null) { @@ -37,11 +35,17 @@ public class IntroduceContractPlugin extends BatchImportPlugin { logger.log(importBillData.getStartIndex(),"工程量数据格式有误").fail(); iterator.remove(); } - // 本次完工量 = 工程量 * 进度百分比 + // 本次完工量 = 工程量 * (当前进度百分比-累计完成百分比) BigDecimal bd1 = new BigDecimal(qeug_decimalqty); BigDecimal bd2 = new BigDecimal(qeug_preofpro); - BigDecimal result = bd1.multiply(bd2).multiply(BigDecimal.valueOf(0.01)); -// result = result.setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal bd3; + if (StringUtils.isEmpty(qeug_cumulativepreofpro)) { + bd3 = BigDecimal.ZERO; // 如果 qeug_cumulativepreofpro 为空,则赋值为 0 + } else { + bd3 = new BigDecimal(qeug_cumulativepreofpro); + } + BigDecimal bd4 = bd2.subtract(bd3); + BigDecimal result = bd1.multiply(bd4).multiply(BigDecimal.valueOf(0.01)); data.put("qeug_bcdecimalqtys",result); if (StringUtils.isNotEmpty(qeug_preofpro)) { preofpro = new BigDecimal(qeug_preofpro); @@ -51,6 +55,11 @@ public class IntroduceContractPlugin extends BatchImportPlugin { logger.log(importBillData.getStartIndex(), "进度百分比不能大于100").fail(); iterator.remove(); } + if (bd3.compareTo(bd2) > 0) { + logger.log(importBillData.getStartIndex(), "当前进度百分比不能小于累计完成百分比").fail(); + iterator.remove(); + } + data.put("qeug_cumulativepreofpro",bd2); } }