From dd022b157860ea2fca13c1d7b8977586152dfba7 Mon Sep 17 00:00:00 2001 From: chenshaoxin <1981897232@qq.com> Date: Mon, 11 Nov 2024 09:34:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4=20?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BA=BA=EF=BC=9A=E9=99=88=E7=BB=8D=E9=91=AB?= =?UTF-8?q?=20=E6=97=B6=E9=97=B4=EF=BC=9A2024/11/11=20=E5=86=85=E5=AE=B9?= =?UTF-8?q?=EF=BC=9A=E6=88=90=E6=9C=AC=E6=B5=8B=E7=AE=97=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=92=E4=BB=B6=E4=BB=A5=E5=8F=8A=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shkd/repc/recos/domain/Calculation.java | 29 ++++++- .../formplugin/RecosMeasurecosFormPlugin.java | 78 +++++++++++++++---- 2 files changed, 89 insertions(+), 18 deletions(-) diff --git a/main/java/shkd/repc/recos/domain/Calculation.java b/main/java/shkd/repc/recos/domain/Calculation.java index 5e212fb..0ab8d17 100644 --- a/main/java/shkd/repc/recos/domain/Calculation.java +++ b/main/java/shkd/repc/recos/domain/Calculation.java @@ -20,12 +20,22 @@ public class Calculation { //合价(含税) Double entry_amount; - public Calculation(String entry_longnumber, String entry_accountname, String entry_workloadunit, Double entry_adjustcoefficient, Double entry_amount) { + //单价 + Double entry_price; + + //工程量 + Double entry_workload; + + + + public Calculation(String entry_longnumber, String entry_accountname, String entry_workloadunit, Double entry_adjustcoefficient, Double entry_amount,Double entry_price,Double entry_workload) { this.entry_longnumber = entry_longnumber; this.entry_accountname = entry_accountname; this.entry_workloadunit = entry_workloadunit; this.entry_adjustcoefficient = entry_adjustcoefficient; this.entry_amount = entry_amount; + this.entry_price = entry_price; + this.entry_workload = entry_workload; } public String getEntry_longnumber() { @@ -68,6 +78,23 @@ public class Calculation { this.entry_amount = entry_amount; } + + public Double getEntry_price() { + return entry_price; + } + + public void setEntry_price(Double entry_price) { + this.entry_price = entry_price; + } + + public Double getEntry_workload() { + return entry_workload; + } + + public void setEntry_workload(Double entry_workload) { + this.entry_workload = entry_workload; + } + public Calculation() { } } diff --git a/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java b/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java index c5b3843..4c1d606 100644 --- a/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java +++ b/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java @@ -2,28 +2,29 @@ package shkd.repc.recos.formplugin; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.form.IFormView; import kd.bos.form.control.AttachmentPanel; import kd.bos.form.control.events.UploadListener; import kd.bos.form.events.AfterDoOperationEventArgs; import kd.bos.form.events.BeforeDoOperationEventArgs; import kd.bos.form.operate.FormOperate; import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.mvc.bill.BillView; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.AttachmentDto; import kd.bos.servicehelper.AttachmentServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.QueryServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; import org.apache.poi.ss.usermodel.*; import shkd.repc.recos.domain.Calculation; import java.io.FileInputStream; import java.io.IOException; -import java.util.ArrayList; -import java.util.EventObject; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.regex.Pattern; +import java.util.stream.Collectors; public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements UploadListener { @@ -45,6 +46,19 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl case "qeug_test": Long id = (Long) this.getModel().getValue("id");//获取单据id + Map result = new HashMap<>(); + //获取不同楼对应标签得pageid + Map all = this.getPageCache().getAll(); + for (Map.Entry entry : all.entrySet()) { + if (entry.getKey().startsWith("tab_measureci")) {//建安测算 + IFormView view = this.getView().getView(entry.getValue());//标签里面的页面 + Long producttypeid = (Long) view.getModel().getValue("producttypeid");//产品类型id + DynamicObject single = BusinessDataServiceHelper.loadSingle(producttypeid,"repmd_producttypes"); + String fullname = single.getString("fullname"); + result.put(fullname, entry.getValue()); + } + } + //遍历附件前校验 AttachmentPanel att = this.getView().getControl("attachmentpanelap"); if (att.getAttachmentData().size()==0){ @@ -88,11 +102,13 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl row.getCell(9).getStringCellValue(),//单位 //Double.parseDouble(row.getCell(12).getStringCellValue().replace("%", ""))/100.0, Double.parseDouble(row.getCell(12).toString()),// 调整系数 - row.getCell(17).getNumericCellValue()//合价(含税) + row.getCell(17).getNumericCellValue(),//合价(含税) + row.getCell(16).getNumericCellValue(),//单价 + row.getCell(13).getNumericCellValue()//工程量 ); arrayList.add(calculation); } - String res = updateRecosMeasurecos(arrayList, sheetName); + String res = updateRecosMeasurecos(arrayList, sheetName,result); if (!"success".equals(res)){ this.getView().showSuccessNotification("功能失败:"+res); return; @@ -102,6 +118,8 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl throw new RuntimeException(e); } } + this.getView().showSuccessNotification("功能成功"); + break; } } @@ -120,19 +138,45 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl /* * 根据入参信息修改成本测算方法 * */ - public String updateRecosMeasurecos(List arrayList,String sheetName) { + public String updateRecosMeasurecos(List arrayList,String sheetName,Map result) { try { //处理 - System.out.println(arrayList); - System.out.println(sheetName); -// QFilter filter = new QFilter("measurecostid", QCP.equals, (Long) this.getModel().getValue("id")); -// DynamicObject[] DynamicObjects = BusinessDataServiceHelper.load("recos_measureci", "id,status,cientry", filter.toArray()); -// Long fid = (Long) DynamicObjects[0].get("id"); -// DynamicObject loadSingle = BusinessDataServiceHelper.loadSingle(fid,"recos_measureci"); -// DynamicObjectCollection cientry = loadSingle.getDynamicObjectCollection("cientry"); -// cientry.get(4).set("entry_amount",666); -// Object[] save = SaveServiceHelper.save(new DynamicObject[]{loadSingle}); -// System.out.println(save); + List numberStrings = arrayList.stream() + .map(calculation -> String.valueOf(calculation.getEntry_longnumber())) + .collect(Collectors.toList()); + String sheetNamepage = result.get(sheetName); + BillView sheetNameView = (BillView) this.getView().getView(sheetNamepage); + DynamicObject dataEntity = sheetNameView.getModel().getDataEntity(true); + DynamicObjectCollection cientry = dataEntity.getDynamicObjectCollection("cientry"); + + Map hashMap = new HashMap<>();//存储修改的数据和下标 + for (DynamicObject dynamicObject : cientry) { + if (numberStrings.contains(dynamicObject.getString("entry_longnumber"))){ + Calculation res = arrayList.stream() + .filter(calculation -> dynamicObject.getString("entry_longnumber").equals(calculation.getEntry_longnumber())) + .findFirst() // 获取第一个匹配的元素 + .orElse(null); + hashMap.put((int) dynamicObject.get("seq")-1,res); + } + } + hashMap.forEach((key, value) -> { + + String entry_workloadunit = value.getEntry_workloadunit(); + DynamicObject unit = QueryServiceHelper.queryOne("bd_measureunits", "id,name,number", new QFilter("name", QCP.equals, entry_workloadunit).toArray()); + DynamicObject single = BusinessDataServiceHelper.loadSingle(unit.getString("id"),"bd_measureunits"); + sheetNameView.getModel().setValue("entry_workloadunit",single,key);//单位 + + sheetNameView.getModel().setValue("entry_adjustcoefficient",value.getEntry_adjustcoefficient(),key);//调整系数 + + sheetNameView.getModel().setValue("entry_price",value.getEntry_price(),key);//单价 + + sheetNameView.getModel().setValue("entry_workload",value.getEntry_workload(),key);//工程量 + + sheetNameView.getModel().setValue("entry_amount",value.getEntry_amount(),key);//合价(含税) + + }); + + getView().sendFormAction(sheetNameView); return "success"; } catch (Exception e) { return e.getMessage();