From fc277af345f78f86181b4a24bc79d96211ca4950 Mon Sep 17 00:00:00 2001 From: chenshaoxin <1981897232@qq.com> Date: Wed, 6 Nov 2024 17:39:26 +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/06=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=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=95=B0=E6=8D=AE=E6=8F=92=E4=BB=B6=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=AE=9E=E4=BD=93=E7=B1=BB=EF=BC=8C=E6=BD=9C=E5=9C=A8?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E8=B5=84=E8=B4=A8=E9=A2=84=E5=AE=A1?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=89=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recon/formplugin/ContractFormPlugin.java | 1 - .../shkd/repc/recos/domain/Calculation.java | 73 +++++++++ .../formplugin/RecosMeasurecosFormPlugin.java | 142 ++++++++++++++++++ .../formplugin/TycQzSupplierFormPlugin.java | 67 ++++++++- 4 files changed, 275 insertions(+), 8 deletions(-) create mode 100644 main/java/shkd/repc/recos/domain/Calculation.java create mode 100644 main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java diff --git a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java index 20e34ef..0c02fbd 100644 --- a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java +++ b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java @@ -193,7 +193,6 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadList Map amounttotalMap = new HashMap<>(); for (Sheet sheet : workbook) { int rowNum = 0; - int a=0; // 获取总行数 int rowCountsheet = sheet.getPhysicalNumberOfRows();//总行数 for (Row cells : sheet) { diff --git a/main/java/shkd/repc/recos/domain/Calculation.java b/main/java/shkd/repc/recos/domain/Calculation.java new file mode 100644 index 0000000..5e212fb --- /dev/null +++ b/main/java/shkd/repc/recos/domain/Calculation.java @@ -0,0 +1,73 @@ +package shkd.repc.recos.domain; + +/* +* 成本测算附件信息对象 +* */ +public class Calculation { + + //科目长编码 + String entry_longnumber; + + //科目名称 + String entry_accountname; + + //单位 + String entry_workloadunit; + + //调整系数 + Double entry_adjustcoefficient; + + //合价(含税) + Double entry_amount; + + public Calculation(String entry_longnumber, String entry_accountname, String entry_workloadunit, Double entry_adjustcoefficient, Double entry_amount) { + 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; + } + + public String getEntry_longnumber() { + return entry_longnumber; + } + + public void setEntry_longnumber(String entry_longnumber) { + this.entry_longnumber = entry_longnumber; + } + + public String getEntry_accountname() { + return entry_accountname; + } + + public void setEntry_accountname(String entry_accountname) { + this.entry_accountname = entry_accountname; + } + + public String getEntry_workloadunit() { + return entry_workloadunit; + } + + public void setEntry_workloadunit(String entry_workloadunit) { + this.entry_workloadunit = entry_workloadunit; + } + + public Double getEntry_adjustcoefficient() { + return entry_adjustcoefficient; + } + + public void setEntry_adjustcoefficient(Double entry_adjustcoefficient) { + this.entry_adjustcoefficient = entry_adjustcoefficient; + } + + public Double getEntry_amount() { + return entry_amount; + } + + public void setEntry_amount(Double entry_amount) { + this.entry_amount = entry_amount; + } + + public Calculation() { + } +} diff --git a/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java b/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java new file mode 100644 index 0000000..e612f6f --- /dev/null +++ b/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java @@ -0,0 +1,142 @@ +package shkd.repc.recos.formplugin; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +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.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.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.regex.Pattern; + +public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements UploadListener { + + private static boolean attPk = true; + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + //注册附件监听 + AttachmentPanel attachmentPanel = getControl("attachmentpanelap"); + attachmentPanel.addUploadListener(this); + } + + @Override + public void beforeDoOperation(BeforeDoOperationEventArgs args) { + super.beforeDoOperation(args); + FormOperate source = (FormOperate) args.getSource(); + String operateKey = source.getOperateKey(); + switch (operateKey){ + case "qeug_test": + Long id = (Long) this.getModel().getValue("id");//获取单据id + + //遍历附件前校验 + AttachmentPanel att = this.getView().getControl("attachmentpanelap"); + if (att.getAttachmentData().size()==0){ + this.getView().showMessage("请上传附件"); + return; + } + Object attPkId = att.getAttachmentData().get(0).get("attPkId"); + if (null == attPkId) { + attPk = false; + this.getView().invokeOperation("save");//调用保存 + } + + AttachmentPanel attachmentpanelap = this.getView().getControl("attachmentpanelap"); + List> attachments = attachmentpanelap.getAttachmentData(); + for (Map attachment : attachments) { + AttachmentDto attachmentDto = AttachmentServiceHelper.getAttachmentInfoByAttPk(attachment.get("attPkId")); + String fileUrl = attachmentDto.getResourcePath();//真实路径 + try { + FileInputStream in = new FileInputStream(fileUrl); + Workbook workbook = WorkbookFactory.create(in); + for (Sheet sheet : workbook) { + List arrayList = new ArrayList<>();//修改的集合 + String sheetName = sheet.getSheetName();//获取excl标签名称 + int rowNum = 0; + int rowCountsheet = sheet.getPhysicalNumberOfRows();//总行数 + for (Row cells : sheet) { + String billno = cells.getCell(0).toString(); + //第一列属于数字 + Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$"); + boolean matches = pattern.matcher(billno).matches(); + if (matches) { + rowNum = cells.getRowNum();//记录序号出现的下标 + break; + } + } + for (int j = rowNum; j <= rowCountsheet - 2; j++){//序号行至最后一行总计前一行 + Row row = sheet.getRow(j); + Calculation calculation = new Calculation( + row.getCell(5).toString(),//科目编码 + row.getCell(6).toString(),//科目名称 + row.getCell(9).getStringCellValue(),//单位 + //Double.parseDouble(row.getCell(12).getStringCellValue().replace("%", ""))/100.0, + Double.parseDouble(row.getCell(12).toString()),// 调整系数 + row.getCell(17).getNumericCellValue()//合价(含税) + ); + arrayList.add(calculation); + } + String res = updateRecosMeasurecos(arrayList, sheetName); + if (!"success".equals(res)){ + this.getView().showSuccessNotification("功能失败"); + return; + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + } + + @Override + public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) { + super.afterDoOperation(afterDoOperationEventArgs); + String operateKey = afterDoOperationEventArgs.getOperateKey(); + if ("save".equals(operateKey)&&afterDoOperationEventArgs.getOperationResult().isSuccess()){ + if (!attPk){//附件功能调用的保存取消提示 + afterDoOperationEventArgs.getOperationResult().setShowMessage(false); + attPk = true; + } + } + } + + /* + * 根据入参信息修改成本测算方法 + * */ + public String updateRecosMeasurecos(List arrayList,String sheetName) { + 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); + return "success"; + } catch (Exception e) { + return e.getMessage(); + //throw new RuntimeException(e); + } + } +} diff --git a/main/java/shkd/repc/resm/formplugin/TycQzSupplierFormPlugin.java b/main/java/shkd/repc/resm/formplugin/TycQzSupplierFormPlugin.java index ae3118e..c7a0a3e 100644 --- a/main/java/shkd/repc/resm/formplugin/TycQzSupplierFormPlugin.java +++ b/main/java/shkd/repc/resm/formplugin/TycQzSupplierFormPlugin.java @@ -2,12 +2,16 @@ package shkd.repc.resm.formplugin; import kd.bos.bill.BillShowParameter; import kd.bos.bill.OperationStatus; +import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.resource.ResManager; +import kd.bos.dataentity.utils.StringUtils; import kd.bos.entity.EntityMetadataCache; import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.entity.operate.result.OperationResult; import kd.bos.form.ShowType; +import kd.bos.form.control.events.BeforeItemClickEvent; import kd.bos.form.events.AfterDoOperationEventArgs; import kd.bos.form.events.BeforeDoOperationEventArgs; import kd.bos.form.operate.FormOperate; @@ -15,8 +19,11 @@ import kd.bos.form.plugin.AbstractFormPlugin; import kd.bos.orm.query.QFilter; import kd.bos.orm.util.CollectionUtils; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.OperationServiceHelper; +import kd.repc.common.enums.PersontypeEnum; import kd.repc.common.enums.resm.RegSupplierStatusEnum; import kd.repc.common.util.PermissionUtils; +import kd.repc.common.util.resm.SupplierAptUtils; import kd.repc.common.util.resm.SupplierStrategyUtil; //import kd.repc.common.util.resm.SupplierStrategyUtil; //import kd.repc.common.util.MultiLangEnumBridge; @@ -27,6 +34,45 @@ import java.util.stream.Collectors; public class TycQzSupplierFormPlugin extends AbstractFormPlugin { + private static final String KEY_BUT_MENU = "tbmain"; + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + this.addItemClickListeners(KEY_BUT_MENU); + } + + public void beforeItemClick(BeforeItemClickEvent evt) { + if (evt.getItemKey().equals("qeug_preaudit")) { + DynamicObject regSupplier = BusinessDataServiceHelper.loadSingle(this.getModel().getDataEntity().getPkValue(), "resm_regsupplier"); + String socode = regSupplier.getString("societycreditcode"); + String personType = regSupplier.getString("persontype"); + if (!PersontypeEnum.PERSONAL.getVal().equals(personType) && StringUtils.isEmpty(socode)) { + this.getView().showMessage(ResManager.loadKDString("社会统一信用代码不能为空。", "ImportRegSupplierList_2", "repc-resm-formplugin", new Object[0])); + evt.setCancel(true); + return; + } + + OperationResult result = OperationServiceHelper.executeOperate("save", "resm_regsupplier", new DynamicObject[]{regSupplier}, OperateOption.create()); + if (!result.isSuccess()) { + evt.setCancel(true); + StringJoiner joiner = new StringJoiner("\n"); + result.getAllErrorOrValidateInfo().forEach((info) -> { + joiner.add(info.getMessage()); + }); + this.getView().showMessage(joiner.toString()); + return; + } + + boolean isSuccess = SupplierAptUtils.checkAptitudeFile(this.getView(), regSupplier); + if (!isSuccess) { + evt.setCancel(true); + return; + } + } + + } + @Override public void beforeDoOperation(BeforeDoOperationEventArgs args) { super.beforeDoOperation(args); @@ -40,12 +86,14 @@ public class TycQzSupplierFormPlugin extends AbstractFormPlugin { } } + + protected boolean checkIsCanDo(BeforeDoOperationEventArgs args) { if (!SupplierStrategyUtil.isPreTrial()) { return true; } else { - ListSelectedRowCollection listSelectedData = args.getListSelectedData(); - QFilter qFilter = new QFilter("id", "in", listSelectedData.getPrimaryKeyValues()); + DynamicObject dataEntity = this.getModel().getDataEntity(true); + QFilter qFilter = new QFilter("id", "in", dataEntity.getPkValue()); DynamicObject[] regSupplierArr = BusinessDataServiceHelper.load("resm_regsupplier", "status", qFilter.toArray()); boolean isExist = Arrays.stream(regSupplierArr).anyMatch((item) -> { return item.getString("status").equals(RegSupplierStatusEnum.SAVE.getValue()); @@ -96,16 +144,22 @@ public class TycQzSupplierFormPlugin extends AbstractFormPlugin { this.getView().showErrorNotification(ResManager.loadKDString("很抱歉!您没有[潜在供应商]的操作[资质预审]的功能权限,请联系管理员。", "RegSupplierList_21", "repc-resm-formplugin", new Object[0])); args.setCancel(true); } else { + DynamicObjectCollection dynamicObjects=new DynamicObjectCollection(); + dynamicObjects.add(this.getModel().getDataEntity(true)); ListSelectedRowCollection listSelectedData = args.getListSelectedData(); - Set selectRowSet = (Set)listSelectedData.stream().map((item) -> { - return item.getPrimaryKeyValue(); +// Set selectRowSet = (Set)listSelectedData.stream().map((item) -> { +// return item.getPrimaryKeyValue(); +// }).collect(Collectors.toSet()); + Set selectRowSet = (Set)dynamicObjects.stream().map((item) -> { + return item.getPkValue(); }).collect(Collectors.toSet()); List groupId = new ArrayList(); if (selectRowSet.size() > 1) { this.getView().showErrorNotification(ResManager.loadKDString("不允许对多条记录进行操作。", "RegSupplierList_18", "repc-resm-formplugin", new Object[0])); args.setCancel(true); } else { - DynamicObject[] regSuppliers = BusinessDataServiceHelper.load(listSelectedData.getPrimaryKeyValues(), EntityMetadataCache.getDataEntityType("resm_regsupplier")); + //DynamicObject[] regSuppliers = BusinessDataServiceHelper.load(listSelectedData.getPrimaryKeyValues(), EntityMetadataCache.getDataEntityType("resm_regsupplier")); + DynamicObject[] regSuppliers = BusinessDataServiceHelper.load(new Object[]{dynamicObjects.get(0).getPkValue()}, EntityMetadataCache.getDataEntityType("resm_regsupplier")); StringBuilder preQulicaStatus = new StringBuilder(); DynamicObject[] var8 = regSuppliers; int var9 = regSuppliers.length; @@ -200,8 +254,7 @@ public class TycQzSupplierFormPlugin extends AbstractFormPlugin { } } -// DynamicObject serviceOrg = regSuppliers[0].getDynamicObject("serviceorg"); - DynamicObject serviceOrg = this.getModel().getDataEntity().getDynamicObject("serviceorg"); + DynamicObject serviceOrg = regSuppliers[0].getDynamicObject("serviceorg"); BillShowParameter billShowParameter = new BillShowParameter(); billShowParameter.setFormId("resm_prequalification"); // billShowParameter.setCustomParam("regSupplierId", listSelectedData.getPrimaryKeyValues()[0]);