From 9bc576366e2289af9e28c06054343c3348c502e2 Mon Sep 17 00:00:00 2001 From: ptt <2403326863@qq.com> Date: Tue, 29 Apr 2025 13:59:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=9B=E6=A0=87=E4=B8=AD=E5=BF=83=EF=BC=8C?= =?UTF-8?q?=E5=95=86=E5=8A=A1=E8=B0=88=E5=88=A4=EF=BC=8C=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E7=A8=8E=E7=8E=87=EF=BC=8C=E7=BB=A7=E6=89=BF?= =?UTF-8?q?=E6=A0=87=E5=93=81=E6=8F=92=E4=BB=B6=EF=BC=8C=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E9=97=A8=E6=88=B7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BidBustalk4REBMEditUIExtends.java | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 main/java/shkd/repc/rebm/formplugin/BidBustalk4REBMEditUIExtends.java diff --git a/main/java/shkd/repc/rebm/formplugin/BidBustalk4REBMEditUIExtends.java b/main/java/shkd/repc/rebm/formplugin/BidBustalk4REBMEditUIExtends.java new file mode 100644 index 0000000..30a45bf --- /dev/null +++ b/main/java/shkd/repc/rebm/formplugin/BidBustalk4REBMEditUIExtends.java @@ -0,0 +1,157 @@ +package shkd.repc.rebm.formplugin; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.datamodel.IEntryOperate; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.entity.report.CellStyle; +import kd.bos.form.control.AbstractGrid; +import kd.bos.form.control.EntryGrid; +import kd.repc.rebm.common.util.crlutil.CrlUtil; +import kd.repc.rebm.formplugin.bill.BidBustalk4REBMEditUI; + +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +public class BidBustalk4REBMEditUIExtends extends BidBustalk4REBMEditUI { + + @Override + public void propertyChanged(PropertyChangedArgs arg0) { + DynamicObject dataEntity = this.getModel().getDataEntity(); + DynamicObject bidProject = dataEntity.getDynamicObject("bidproject"); + boolean isEnableList = bidProject.getBoolean("isenablelist"); + if (!isEnableList) { + super.propertyChanged(arg0); + ChangeData cd = arg0.getChangeSet()[0]; + Object newVal = cd.getNewValue(); + Object oldVal = cd.getOldValue(); + String fieldKey = arg0.getProperty().getName(); + if (StringUtils.equals("new_price", fieldKey) || StringUtils.equals("taxrate", fieldKey)) { + if (newVal != null && newVal.equals(oldVal)) { + return; + } + + DynamicObject bustalk = this.getModel().getDataEntity(true); + EntryGrid sectionEntryGrid = (EntryGrid)this.getView().getControl("bidsection"); + AbstractGrid.GridState sectionEntryState = sectionEntryGrid.getEntryState(); + int sectionEntryFocusRow = sectionEntryState.getFocusRow(); + EntryGrid supplierEntryGrid = (EntryGrid)this.getView().getControl("supplierentry"); + AbstractGrid.GridState supplierEntryState = supplierEntryGrid.getEntryState(); + int supplierEntryFocusRow = supplierEntryState.getFocusRow(); + DynamicObject sectionEntryRow = (DynamicObject)bustalk.getDynamicObjectCollection("bidsection").get(sectionEntryFocusRow); + if (supplierEntryFocusRow > -1) { + this.getView().updateView("supplierentry"); + DynamicObject supplierEntryRow = (DynamicObject)sectionEntryRow.getDynamicObjectCollection("supplierentry").get(supplierEntryFocusRow); + BigDecimal finalprice = supplierEntryRow.getBigDecimal("new_price"); + if (StringUtils.equals("new_price", fieldKey)) { + finalprice = (BigDecimal)newVal; + } + + BigDecimal finaltaxrate = supplierEntryRow.getBigDecimal("taxrate").divide(new BigDecimal(100)); + BigDecimal upprice = supplierEntryRow.getBigDecimal("up_price"); + BigDecimal finaltax = BigDecimal.ZERO; + BigDecimal finalnotTaxTenderPrice = BigDecimal.ZERO; + BigDecimal decline1; + if (finaltaxrate.compareTo(BigDecimal.ZERO) > 0 && finalprice.compareTo(BigDecimal.ZERO) > 0) { + decline1 = finalprice.multiply(finaltaxrate); + BigDecimal addNumbner = finaltaxrate.add(new BigDecimal(1)); + finaltax = decline1.divide(addNumbner, 2, 4); + finalnotTaxTenderPrice = finalprice.subtract(finaltax); + supplierEntryRow.set("pricevat", finaltax); + if (upprice.compareTo(BigDecimal.ZERO) == 1) { + BigDecimal decline = finalprice.subtract(upprice).divide(upprice, 4, 4); + supplierEntryRow.set("decline", decline); + List styles = new ArrayList(); + DecimalFormat df = new DecimalFormat("0.00"); + String declineStr = df.format(decline.multiply(new BigDecimal("100"))); + declineStr = declineStr.replaceAll("-", ""); + CellStyle style = new CellStyle(); + style.setRow(supplierEntryFocusRow); + style.setFieldKey("decline_back"); + if (decline.compareTo(BigDecimal.ZERO) == 1) { + supplierEntryRow.set("decline_back", declineStr + "% ↑"); + style.setForeColor("#18BC71"); + } else if (decline.compareTo(BigDecimal.ZERO) == -1) { + supplierEntryRow.set("decline_back", declineStr + "% ↓"); + style.setForeColor("#FD6C6A"); + } else { + supplierEntryRow.set("decline_back", "0.00%"); + style.setForeColor("#000"); + } + + supplierEntryGrid.setCellStyle(styles); + } + + this.getModel().setValue("bus_exceptvat", finalnotTaxTenderPrice, supplierEntryFocusRow); + this.getView().updateView("supplierentry"); + } else if (finaltaxrate.compareTo(BigDecimal.ZERO) == 0) { + if (upprice.compareTo(BigDecimal.ZERO) == 1) { + decline1 = finalprice.subtract(upprice).divide(upprice, 4, 4); + supplierEntryRow.set("decline", decline1); + List styles = new ArrayList(); + DecimalFormat df = new DecimalFormat("0.00"); + String declineStr = df.format(decline1.multiply(new BigDecimal("100"))); + declineStr = declineStr.replaceAll("-", ""); + CellStyle style = new CellStyle(); + style.setRow(supplierEntryFocusRow); + style.setFieldKey("decline_back"); + if (decline1.compareTo(BigDecimal.ZERO) == 1) { + supplierEntryRow.set("decline_back", declineStr + "% ↑"); + style.setForeColor("#18BC71"); + } else if (decline1.compareTo(BigDecimal.ZERO) == -1) { + supplierEntryRow.set("decline_back", declineStr + "% ↓"); + style.setForeColor("#FD6C6A"); + } else { + supplierEntryRow.set("decline_back", "0.00%"); + style.setForeColor("#000"); + } + + supplierEntryGrid.setCellStyle(styles); + } + + this.getModel().setValue("bus_exceptvat", finalprice, supplierEntryFocusRow); + this.getView().updateView("supplierentry"); + } + } + } + + EntryGrid grid = (EntryGrid)this.getView().getControl("supplierentry"); + IEntryOperate operate = grid.getModel(); + DynamicObjectCollection supllierEntry = operate.getEntryEntity("supplierentry"); + this.changeEntryFieldColor(grid, supllierEntry); + } + } + + private void changeEntryFieldColor(EntryGrid grid, DynamicObjectCollection supllierEntry) { + DecimalFormat df = new DecimalFormat("0.00"); + List styles = new ArrayList(); + + for(int j = 0; j < supllierEntry.size(); ++j) { + DynamicObject entry = (DynamicObject)supllierEntry.get(j); + BigDecimal decline = entry.getBigDecimal("decline"); + String declineStr = df.format(decline.multiply(new BigDecimal("100"))); + declineStr = declineStr.replaceAll("-", ""); + CellStyle style = new CellStyle(); + style.setRow(j); + style.setFieldKey("decline_back"); + if (decline.compareTo(BigDecimal.ZERO) == 1) { + this.getModel().setValue("decline_back", declineStr + "% ↑", j); + style.setForeColor("#18BC71"); + } else if (decline.compareTo(BigDecimal.ZERO) == -1) { + this.getModel().setValue("decline_back", declineStr + "% ↓", j); + style.setForeColor("#FD6C6A"); + } else { + this.getModel().setValue("decline_back", "0.00%", j); + style.setForeColor("#000"); + } + + styles.add(style); + } + + grid.setCellStyle(styles); + } +}