From db81623732989aa38c70cf689574021edbe8561b Mon Sep 17 00:00:00 2001 From: hongcj Date: Wed, 10 Jan 2024 16:30:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CostListManagement/ButtonCellEditor.java | 4 +- .../CostListManagementHandler.java | 6 +- .../CostListManagement/pojo/Cusquotation.java | 20 +- .../CostListManagement/pojo/QuotationMX.java | 18 + .../plm/CreateOuotation/MyController.java | 671 +++++++++++++----- .../plm/CreateOuotation/PersonOverview.fxml | 58 +- .../com/connor/plm/CreateOuotation/test.java | 2 +- .../plm/SendGXToMOM/sendGXToMOMOperation.java | 11 +- 8 files changed, 596 insertions(+), 194 deletions(-) diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/ButtonCellEditor.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/ButtonCellEditor.java index 2c894e0..8d036d4 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/ButtonCellEditor.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/ButtonCellEditor.java @@ -141,7 +141,7 @@ public class ButtonCellEditor extends AbstractCellEditor implements TableCellEdi resultSet1.getString("traweight"), resultSet1.getString("totweight"), QuotationUtil.formatString(resultSet1.getString("copconsumption")), QuotationUtil.formatString(resultSet1.getString("cmarketprice")), - resultSet1.getString("vollevel"), resultSet1.getString("factory")); + resultSet1.getString("vollevel"), resultSet1.getString("factory"),resultSet1.getString("changereason")); break; } @@ -197,6 +197,8 @@ public class ButtonCellEditor extends AbstractCellEditor implements TableCellEdi quotationMX.setUnitprice(new SimpleStringProperty( QuotationUtil.formatString(resultSet2.getString("unitprice")))); quotationMX.setNo(new SimpleStringProperty(resultSet2.getString("no"))); + quotationMX.setComparedQuantityColumn(new SimpleStringProperty("")); + quotationMX.setComparedUnitPriceColumn(new SimpleStringProperty("")); quotationMX.setContrastPrice(new SimpleStringProperty("")); quotationMX.setTotalprice(new SimpleStringProperty( QuotationUtil.formatString(resultSet2.getString("totalprice")))); diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/CostListManagementHandler.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/CostListManagementHandler.java index dfb20f9..14eba3f 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/CostListManagementHandler.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/CostListManagementHandler.java @@ -30,6 +30,7 @@ import com.teamcenter.rac.kernel.TCComponentProject; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.ResizablePopupMenu; import javafx.beans.property.SimpleStringProperty; @@ -150,7 +151,8 @@ public class CostListManagementHandler extends AbstractHandler { QuotationUtil.formatString( resultSet1.getString("cmarketprice")), resultSet1.getString("vollevel"), - resultSet1.getString("factory")); + resultSet1.getString("factory"), + resultSet1.getString("changereason")); tennumber = resultSet1.getString("tennumber"); break; } @@ -219,6 +221,8 @@ public class CostListManagementHandler extends AbstractHandler { resultSet2.getString("unitprice")))); quotationMX.setNo(new SimpleStringProperty( resultSet2.getString("no"))); + quotationMX.setComparedQuantityColumn(new SimpleStringProperty("")); + quotationMX.setComparedUnitPriceColumn(new SimpleStringProperty("")); quotationMX.setContrastPrice(new SimpleStringProperty("")); quotationMX.setTotalprice( new SimpleStringProperty(QuotationUtil.formatString( diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/Cusquotation.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/Cusquotation.java index f2d91cb..936ad87 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/Cusquotation.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/Cusquotation.java @@ -20,11 +20,12 @@ public class Cusquotation { private String cmarketprice; private String vollevel; private String factory; + private String changereason; public Cusquotation(String cbdlx, String projectid, String revision, String proname, String tennumber, String promanager, String quantity, String tramodel, String capfactor, String volratio, String noloadloss, String loadloss, String impvoltage, String traweight, String totweight, String copconsumption, - String cmarketprice, String vollevel, String factory) { + String cmarketprice, String vollevel, String factory,String changereason) { super(); this.cbdlx = cbdlx; this.projectid = projectid; @@ -45,8 +46,20 @@ public class Cusquotation { this.cmarketprice = cmarketprice; this.vollevel = vollevel; this.factory = factory; + this.changereason = changereason; } + + public String getChangereason() { + return changereason; + } + + + public void setChangereason(String changereason) { + this.changereason = changereason; + } + + public String getCbdlx() { return cbdlx; } @@ -199,6 +212,7 @@ public class Cusquotation { this.factory = factory; } + @Override public String toString() { return "Cusquotation [cbdlx=" + cbdlx + ", projectid=" + projectid + ", revision=" + revision + ", proname=" @@ -206,7 +220,9 @@ public class Cusquotation { + ", tramodel=" + tramodel + ", capfactor=" + capfactor + ", volratio=" + volratio + ", noloadloss=" + noloadloss + ", loadloss=" + loadloss + ", impvoltage=" + impvoltage + ", traweight=" + traweight + ", totweight=" + totweight + ", copconsumption=" + copconsumption + ", cmarketprice=" + cmarketprice - + ", vollevel=" + vollevel + ", factory=" + factory + "]"; + + ", vollevel=" + vollevel + ", factory=" + factory + ", changereason=" + changereason + "]"; } + + } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/QuotationMX.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/QuotationMX.java index af07b6a..1294f6c 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/QuotationMX.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/QuotationMX.java @@ -18,6 +18,8 @@ public class QuotationMX { private SimpleStringProperty utilizationRateColumn; private SimpleStringProperty unitColumn; private SimpleStringProperty amomoney; + private SimpleStringProperty comparedQuantityColumn; + private SimpleStringProperty comparedUnitPriceColumn; private SimpleStringProperty unitPriceColumn; private SimpleStringProperty no; private SimpleStringProperty totalprice; @@ -147,6 +149,22 @@ public class QuotationMX { this.amomoney = amomoney; } + public String getComparedQuantityColumn() { + return comparedQuantityColumn.get(); + } + + public void setComparedQuantityColumn(SimpleStringProperty comparedQuantityColumn) { + this.comparedQuantityColumn = comparedQuantityColumn; + } + + public String getComparedUnitPriceColumn() { + return comparedUnitPriceColumn.get(); + } + + public void setComparedUnitPriceColumn(SimpleStringProperty comparedUnitPriceColumn) { + this.comparedUnitPriceColumn = comparedUnitPriceColumn; + } + public String getUnitprice() { return unitPriceColumn.get(); } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/MyController.java b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/MyController.java index a04a545..3f735d5 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/MyController.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/MyController.java @@ -1,36 +1,29 @@ package com.connor.plm.CreateOuotation; -import java.awt.Component; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; import java.math.BigDecimal; -import java.math.RoundingMode; import java.sql.ResultSet; import java.sql.SQLException; import java.text.DecimalFormat; -import java.text.NumberFormat; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; import com.connor.chint.sap2.util.SqlUtil; import com.connor.plm.CostListManagement.ButtonCellEditor; import com.connor.plm.CostListManagement.QuotationUtil; import com.connor.plm.CostListManagement.pojo.QuotationMX; +import com.itextpdf.text.pdf.PdfStructTreeController.returnType; import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.util.MessageBox; -import javafx.application.Platform; import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import javafx.embed.swing.JFXPanel; import javafx.fxml.FXML; import javafx.geometry.Pos; import javafx.scene.control.Button; @@ -39,6 +32,7 @@ import javafx.scene.control.Label; import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; +import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.AnchorPane; @@ -46,8 +40,25 @@ import javafx.scene.layout.BorderPane; import javafx.scene.layout.FlowPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.Pane; -import javafx.stage.Window; -import javafx.util.Callback; + +/** + * + * @ClassName: MyController + * @Description: 创建报价成本单窗口控制层 + * @author hcj + * @date 2023年11月20日 + * @change 1. 保存时要自动计算金额。 + * @change 2. 总价取整数,小数点后一位自动四舍五入。 + * @change 3. 保存时要自动对比,保存的时候,如果没有选择要对比的报价单的时候不需要弹框提示。 + * @change 4. 对比结果,颜色框内颜色“-”值用绿色“+”值有红色 + * @change 5. 增加“单价”与“数量”对比,对比逻辑与“金额”对比一致,(界面已更新) + * @change 6. 界面上增加颜色备注,“橙色:代表盈利,绿色:代表亏损” + * @change 7. 界面增加更改原因,手输。 + * @change 8. 若选择的成本单类型未创建,切换成本单时自动显示上一成本单的信息。成本单排序:1. 报价成本单2. 报审成本单(电磁部分)3. + * 报审成本单(结构部分)4. 设计成本单(电磁)5. 设计成本单(布置) + * @changeDate 2023年12月29日 + * + */ public class MyController extends KFXPanelController { private List dbRevList = null; @@ -59,6 +70,7 @@ public class MyController extends KFXPanelController { private List dbunitpriceList = null; private List DbnoList = null; private List dbtotalpriceList = null; + private final static String[] QUOTATIONTYPE = { "报价成本单", "报审成本单(电磁部分)", "报审成本单(结构部分)", "设计成本单(电磁)", "设计成本单(布置)" }; @FXML private AnchorPane coverPane; @@ -228,6 +240,12 @@ public class MyController extends KFXPanelController { @FXML private TableColumn amountColumn; + @FXML + private TableColumn comparedQuantityColumn; + + @FXML + private TableColumn comparedUnitPriceColumn; + @FXML private TableColumn comparedResultColumn; @@ -240,10 +258,15 @@ public class MyController extends KFXPanelController { @FXML private TextField totalPriceCompareTextField; + @FXML + private TextArea changeReason; + private DecimalFormat df = new DecimalFormat("#.00"); private String rev = "01"; + private String operationType; + public void editWrite() { materialsTable.setEditable(true); // 头表 @@ -274,7 +297,72 @@ public class MyController extends KFXPanelController { utilizationRateColumn.setCellFactory((tableColumn) -> new EditingCell()); unitColumn.setCellFactory((tableColumn) -> new EditingCell()); unitPriceColumn.setCellFactory((tableColumn) -> new EditingCell()); - amountColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + amountColumn.setCellFactory(column -> { + return new TableCell() { + @Override + protected void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + if (item != null && !empty && !item.isEmpty()) { + BigDecimal decimal = new BigDecimal(item); + int roundedInt = decimal.setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); + setText(roundedInt+""); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } + } + }; + }); + comparedQuantityColumn.setCellFactory(column -> { + return new TableCell() { + @Override + protected void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + if (item != null && !empty && !item.isEmpty()) { + double contrastPrice = Double.parseDouble(item); + if (contrastPrice == 0) { + // 不做格式 + setStyle(""); + } else if (contrastPrice < 0) { + setStyle("-fx-background-color: #FF6600;"); + } else { + setStyle("-fx-background-color: #A9D08E;"); + } + + setText(getItem()); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } else { + setStyle(""); + setText(empty ? null : getItem()); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } + } + }; + }); + comparedUnitPriceColumn.setCellFactory(column -> { + return new TableCell() { + @Override + protected void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + if (item != null && !empty && !item.isEmpty()) { + double contrastPrice = Double.parseDouble(item); + if (contrastPrice == 0) { + // 不做格式 + setStyle(""); + } else if (contrastPrice < 0) { + setStyle("-fx-background-color: #FF6600;"); + } else { + setStyle("-fx-background-color: #A9D08E;"); + } + + setText(getItem()); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } else { + setStyle(""); + setText(empty ? null : getItem()); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } + } + }; + }); comparedResultColumn.setCellFactory(column -> { return new TableCell() { @Override @@ -334,7 +422,72 @@ public class MyController extends KFXPanelController { utilizationRateColumn.setCellFactory((tableColumn) -> new EditingCellOR()); unitColumn.setCellFactory((tableColumn) -> new EditingCellOR()); unitPriceColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - amountColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + amountColumn.setCellFactory(column -> { + return new TableCell() { + @Override + protected void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + if (item != null && !empty && !item.isEmpty()) { + BigDecimal decimal = new BigDecimal(item); + int roundedInt = decimal.setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); + setText(roundedInt+""); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } + } + }; + }); + comparedQuantityColumn.setCellFactory(column -> { + return new TableCell() { + @Override + protected void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + if (item != null && !empty && !item.isEmpty()) { + double contrastPrice = Double.parseDouble(item); + if (contrastPrice == 0) { + // 不做格式 + setStyle(""); + } else if (contrastPrice < 0) { + setStyle("-fx-background-color: #FF6600;"); + } else { + setStyle("-fx-background-color: #A9D08E;"); + } + + setText(getItem()); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } else { + setStyle(""); + setText(empty ? null : getItem()); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } + } + }; + }); + comparedUnitPriceColumn.setCellFactory(column -> { + return new TableCell() { + @Override + protected void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + if (item != null && !empty && !item.isEmpty()) { + double contrastPrice = Double.parseDouble(item); + if (contrastPrice == 0) { + // 不做格式 + setStyle(""); + } else if (contrastPrice < 0) { + setStyle("-fx-background-color: #FF6600;"); + } else { + setStyle("-fx-background-color: #A9D08E;"); + } + + setText(getItem()); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } else { + setStyle(""); + setText(empty ? null : getItem()); + setAlignment(Pos.CENTER); // 设置单元格内容居中对齐 + } + } + }; + }); comparedResultColumn.setCellFactory(column -> { return new TableCell() { @Override @@ -366,17 +519,19 @@ public class MyController extends KFXPanelController { @Override public void initData(KFXPanel paramKFXPanel) throws Exception { // 设置表格单元格的间距比例 - no.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.06)); - materialNameColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.1)); - relatedMaterialColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.1)); - specificationColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.2)); - manufacturerColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.15)); - quantityColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.07)); + no.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.05)); + materialNameColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.07)); + relatedMaterialColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.07)); + specificationColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.17)); + manufacturerColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.16)); + quantityColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.06)); utilizationRateColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.05)); unitColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.05)); unitPriceColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.06)); - amountColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.07)); - comparedResultColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.09)); + amountColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.06)); + comparedQuantityColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.06)); + comparedUnitPriceColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.06)); + comparedResultColumn.prefWidthProperty().bind(materialsTable.widthProperty().multiply(0.08)); String sql1 = "SELECT DISTINCT \"cbdlx\" FROM \"CHINT_ QUOTATION_LOV\""; System.out.println(sql1); @@ -389,6 +544,8 @@ public class MyController extends KFXPanelController { costSheetTypeComboBox.getSelectionModel().select(type.indexOf("报价成本单")); + operationType = "报价成本单"; + // 查询版次 String sql2 = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '" @@ -439,8 +596,15 @@ public class MyController extends KFXPanelController { voltageLevelTextField.setText(ButtonCellEditor.cusquotation.getVollevel()); + if (ButtonCellEditor.cusquotation.getChangereason() == null) { + ButtonCellEditor.cusquotation.setChangereason(""); + } + changeReason.setText(ButtonCellEditor.cusquotation.getChangereason()); + if (ButtonCellEditor.tableList.size() > 0) { - totalPriceTextField.setText(ButtonCellEditor.tableList.get(0).getTotalprice()); + BigDecimal decimal = new BigDecimal(ButtonCellEditor.tableList.get(0).getTotalprice()); + int roundedInt = decimal.setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); + totalPriceTextField.setText(roundedInt + ""); } // 设置只读 @@ -481,6 +645,12 @@ public class MyController extends KFXPanelController { amountColumn.setCellValueFactory(new PropertyValueFactory<>("amomoney")); amountColumn.setSortable(false); + comparedQuantityColumn.setCellValueFactory(new PropertyValueFactory<>("comparedQuantityColumn")); + comparedQuantityColumn.setSortable(false); + + comparedUnitPriceColumn.setCellValueFactory(new PropertyValueFactory<>("comparedUnitPriceColumn")); + comparedUnitPriceColumn.setSortable(false); + comparedResultColumn.setCellValueFactory(new PropertyValueFactory<>("contrastPrice")); comparedResultColumn.setSortable(false); @@ -503,20 +673,15 @@ public class MyController extends KFXPanelController { // 成本单类型下拉框,按钮监听 costSheetTypeComboBox.setOnAction(event -> { - String selectedItemType = costSheetTypeComboBox.getSelectionModel().getSelectedItem(); + operationType = costSheetTypeComboBox.getSelectionModel().getSelectedItem(); // 根据选择的成本单类型刷新版本下拉框 try { - String revsql = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '" - + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" + selectedItemType - + "' order by \"revision\" asc"; - System.out.println(revsql); - ResultSet resultRev = SqlUtil.read(revsql); List revisions = new ArrayList(); - while (resultRev.next()) { - revisions.add(resultRev.getString("revision")); - } + // 递归获取成本单数据 + getOperationData(paramKFXPanel, revisions); + // 清空版本下拉框 editionComboBox.getItems().clear(); if (revisions.size() > 0) { @@ -537,9 +702,9 @@ public class MyController extends KFXPanelController { // 开始刷新数据,设置只能查看数据 System.out.println("开始刷新头表数据"); - String selSQL = "SELECT \"cbdlx\",\"projectid\",\"revision\",\"factory\",\"proname\",\"tennumber\",\"promanager\",\"quantity\",\"tramodel\",\"capfactor\",\"volratio\",\"noloadloss\",\"loadloss\",\"impvoltage\",\"traweight\",\"totweight\",\"copconsumption\",\"cmarketprice\",\"vollevel\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '" + String selSQL = "SELECT \"cbdlx\",\"projectid\",\"revision\",\"factory\",\"proname\",\"tennumber\",\"promanager\",\"quantity\",\"tramodel\",\"capfactor\",\"volratio\",\"noloadloss\",\"loadloss\",\"impvoltage\",\"traweight\",\"totweight\",\"copconsumption\",\"cmarketprice\",\"vollevel\",\"changereason\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '" + ButtonCellEditor.cusquotation.getProjectid() + "' and \"revision\" = '" + rev - + "' and \"cbdlx\" = '" + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "'"; + + "' and \"cbdlx\" = '" + operationType + "'"; // 根据查询结果更新数据 System.out.println(selSQL); try { @@ -561,6 +726,13 @@ public class MyController extends KFXPanelController { copperAmountTextField.setText(QuotationUtil.formatString(result.getString("copconsumption"))); copperMarketPriceTextField.setText(QuotationUtil.formatString(result.getString("cmarketprice"))); voltageLevelTextField.setText(result.getString("vollevel")); + // 处理更改原因字段 + if (result.getString("changereason") == null) { + changeReason.setText(""); + } else { + changeReason.setText(result.getString("changereason")); + } + } } catch (SQLException e1) { // TODO Auto-generated catch block @@ -570,8 +742,8 @@ public class MyController extends KFXPanelController { System.out.println("开始刷新明细数据"); try { String reSql = "SELECT * FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" WHERE \"projectid\"='" - + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" - + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "' and \"revision\" = '" + rev + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" + operationType + + "' and \"revision\" = '" + rev + "' order by \"matgroup\" asc,TO_NUMBER(\"mgsnumber\") asc ,TO_NUMBER(\"matcnumber\") asc,TO_NUMBER(\"no\") asc"; System.out.println("reSql:" + reSql); ResultSet reSql1 = SqlUtil.read(reSql); @@ -599,6 +771,8 @@ public class MyController extends KFXPanelController { quotationMX.setUnitprice( new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("unitprice")))); quotationMX.setNo(new SimpleStringProperty(reSql1.getString("no"))); + quotationMX.setComparedQuantityColumn(new SimpleStringProperty("")); + quotationMX.setComparedUnitPriceColumn(new SimpleStringProperty("")); quotationMX.setContrastPrice(new SimpleStringProperty("")); quotationMX.setTotalprice( new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("totalprice")))); @@ -627,6 +801,8 @@ public class MyController extends KFXPanelController { quotationMX.setAmomoney(new SimpleStringProperty(tableList.get(j).getAmomoney())); quotationMX.setUnitprice(new SimpleStringProperty(tableList.get(j).getUnitprice())); quotationMX.setNo(new SimpleStringProperty(tableList.get(j).getNo())); + quotationMX.setComparedQuantityColumn(new SimpleStringProperty("")); + quotationMX.setComparedUnitPriceColumn(new SimpleStringProperty("")); quotationMX.setContrastPrice(new SimpleStringProperty("")); // quotationMX.setTotalprice(new // SimpleStringProperty(reSql1.getString("totalprice"))); @@ -634,12 +810,16 @@ public class MyController extends KFXPanelController { } System.out.println("刷新表格"); materialsTable.refresh(); - totalPriceTextField.setText(tableList.get(0).getTotalprice()); + BigDecimal decimal = new BigDecimal(tableList.get(0).getTotalprice()); + int roundedInt = decimal.setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); + totalPriceTextField.setText(roundedInt + ""); } else { System.out.println("没有找到明细数据,清空金额和对比结果数据"); // 计算金额 for (QuotationMX quotationMX : materialsTable.getItems()) { quotationMX.setAmomoney((new SimpleStringProperty(""))); + quotationMX.setComparedQuantityColumn(new SimpleStringProperty("")); + quotationMX.setComparedUnitPriceColumn(new SimpleStringProperty("")); quotationMX.setContrastPrice((new SimpleStringProperty(""))); } materialsTable.refresh(); @@ -654,15 +834,16 @@ public class MyController extends KFXPanelController { }); // 版本下拉框,按钮监听 + editionComboBox.setOnAction(event -> { String selectedItem = editionComboBox.getSelectionModel().getSelectedItem(); // 开始刷新数据,设置只能查看数据 System.out.println("开始刷新头表数据"); - String selSQL = "SELECT \"cbdlx\",\"projectid\",\"revision\",\"factory\",\"proname\",\"tennumber\",\"promanager\",\"quantity\",\"tramodel\",\"capfactor\",\"volratio\",\"noloadloss\",\"loadloss\",\"impvoltage\",\"traweight\",\"totweight\",\"copconsumption\",\"cmarketprice\",\"vollevel\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '" + String selSQL = "SELECT \"cbdlx\",\"projectid\",\"revision\",\"factory\",\"proname\",\"tennumber\",\"promanager\",\"quantity\",\"tramodel\",\"capfactor\",\"volratio\",\"noloadloss\",\"loadloss\",\"impvoltage\",\"traweight\",\"totweight\",\"copconsumption\",\"cmarketprice\",\"vollevel\",\"changereason\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '" + ButtonCellEditor.cusquotation.getProjectid() + "' and \"revision\" = '" + selectedItem - + "' and \"cbdlx\" = '" + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "'"; + + "' and \"cbdlx\" = '" + operationType + "'"; // 根据查询结果更新数据 System.out.println(selSQL); try { @@ -684,6 +865,12 @@ public class MyController extends KFXPanelController { copperAmountTextField.setText(QuotationUtil.formatString(result.getString("copconsumption"))); copperMarketPriceTextField.setText(QuotationUtil.formatString(result.getString("cmarketprice"))); voltageLevelTextField.setText(result.getString("vollevel")); + // 处理更改原因字段 + if (result.getString("changereason") == null) { + changeReason.setText(""); + } else { + changeReason.setText(result.getString("changereason")); + } } } catch (SQLException e1) { // TODO Auto-generated catch block @@ -693,9 +880,8 @@ public class MyController extends KFXPanelController { System.out.println("开始刷新明细数据"); try { String reSql = "SELECT * FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" WHERE \"projectid\"='" - + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" - + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "' and \"revision\" = '" - + selectedItem + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" + operationType + + "' and \"revision\" = '" + selectedItem + "' order by \"matgroup\" asc,TO_NUMBER(\"mgsnumber\") asc ,TO_NUMBER(\"matcnumber\") asc,TO_NUMBER(\"no\") asc"; System.out.println("reSql:" + reSql); ResultSet reSql1 = SqlUtil.read(reSql); @@ -723,6 +909,8 @@ public class MyController extends KFXPanelController { quotationMX.setUnitprice( new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("unitprice")))); quotationMX.setNo(new SimpleStringProperty(reSql1.getString("no"))); + quotationMX.setComparedQuantityColumn(new SimpleStringProperty("")); + quotationMX.setComparedUnitPriceColumn(new SimpleStringProperty("")); quotationMX.setContrastPrice(new SimpleStringProperty("")); quotationMX.setTotalprice( new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("totalprice")))); @@ -751,6 +939,8 @@ public class MyController extends KFXPanelController { quotationMX.setAmomoney(new SimpleStringProperty(tableList.get(j).getAmomoney())); quotationMX.setUnitprice(new SimpleStringProperty(tableList.get(j).getUnitprice())); quotationMX.setNo(new SimpleStringProperty(tableList.get(j).getNo())); + quotationMX.setComparedQuantityColumn(new SimpleStringProperty("")); + quotationMX.setComparedUnitPriceColumn(new SimpleStringProperty("")); quotationMX.setContrastPrice(new SimpleStringProperty("")); // quotationMX.setTotalprice(new // SimpleStringProperty(reSql1.getString("totalprice"))); @@ -758,12 +948,16 @@ public class MyController extends KFXPanelController { } System.out.println("刷新表格"); materialsTable.refresh(); - totalPriceTextField.setText(tableList.get(0).getTotalprice()); + BigDecimal decimal = new BigDecimal(tableList.get(0).getTotalprice()); + int roundedInt = decimal.setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); + totalPriceTextField.setText(roundedInt + ""); } else { System.out.println("没有找到明细数据,清空金额和对比结果数据"); // 计算金额 for (QuotationMX quotationMX : materialsTable.getItems()) { quotationMX.setAmomoney((new SimpleStringProperty(""))); + quotationMX.setComparedQuantityColumn(new SimpleStringProperty("")); + quotationMX.setComparedUnitPriceColumn(new SimpleStringProperty("")); quotationMX.setContrastPrice((new SimpleStringProperty(""))); } materialsTable.refresh(); @@ -797,8 +991,16 @@ public class MyController extends KFXPanelController { // MessageBox.post("不能选择“报价成本单”进行保存", "提示", MessageBox.INFORMATION); return; } + // 计算金额 + calculate(paramKFXPanel); + + // 自动对比 + if (moneyList != null && selectedItem != null && !"".equals(selectedItem)) { + compare(paramKFXPanel); + } + // 保存或者更新头表 - String newCbdlx = costSheetTypeComboBox.getSelectionModel().getSelectedItem(); + String newCbdlx = selectedItem; String newProjectid = ButtonCellEditor.cusquotation.getProjectid(); String newRevision = editionComboBox.getSelectionModel().getSelectedItem(); String newFactory = ButtonCellEditor.cusquotation.getFactory(); @@ -817,12 +1019,12 @@ public class MyController extends KFXPanelController { String newCopconsumption = copperAmountTextField.getText(); String newCmarketprice = copperMarketPriceTextField.getText(); String newVollevel = voltageLevelTextField.getText(); + String newchangeReason = changeReason.getText(); // 判断数据库中是否已经存在表行 boolean isExist = true; - String set = "select * from \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"cbdlx\" = '" - + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "' and \"projectid\" = '" - + ButtonCellEditor.cusquotation.getProjectid() + "' and \"revision\" = '" - + editionComboBox.getSelectionModel().getSelectedItem() + "'"; + String set = "select * from \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"cbdlx\" = '" + selectedItem + + "' and \"projectid\" = '" + ButtonCellEditor.cusquotation.getProjectid() + + "' and \"revision\" = '" + editionComboBox.getSelectionModel().getSelectedItem() + "'"; System.out.println("set:" + set); try { ResultSet read = SqlUtil.read(set); @@ -832,15 +1034,15 @@ public class MyController extends KFXPanelController { String updateTop = "UPDATE \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" SET \"cbdlx\" = '" + newCbdlx + "', \"projectid\" = '" + newProjectid + "', \"revision\" = '" + newRevision + "', \"factory\" = '" + newFactory + "', \"proname\" = '" + newProname - + "', \"tennumber\" = '" + newTennumber + "', \"promanager\" = '" + newPromanager - + "', \"quantity\" = '" + newQuantity + "', \"tramodel\" = '" + newTramodel - + "', \"capfactor\" = '" + newCapfactor + "', \"volratio\" = '" + newVolratio - + "', \"noloadloss\" = '" + newNoloadloss + "', \"loadloss\" = '" + newLoadloss - + "', \"impvoltage\" = '" + newImpvoltage + "', \"traweight\" = '" + newTraweight - + "', \"totweight\" = '" + newTotweight + "', \"copconsumption\" = '" + newCopconsumption - + "', \"cmarketprice\" = '" + newCmarketprice + "', \"vollevel\" = '" + newVollevel - + "' where \"cbdlx\" = '" + costSheetTypeComboBox.getSelectionModel().getSelectedItem() - + "' and \"projectid\" = '" + ButtonCellEditor.cusquotation.getProjectid() + + "', \"changereason\" = '" + newchangeReason + "', \"tennumber\" = '" + newTennumber + + "', \"promanager\" = '" + newPromanager + "', \"quantity\" = '" + newQuantity + + "', \"tramodel\" = '" + newTramodel + "', \"capfactor\" = '" + newCapfactor + + "', \"volratio\" = '" + newVolratio + "', \"noloadloss\" = '" + newNoloadloss + + "', \"loadloss\" = '" + newLoadloss + "', \"impvoltage\" = '" + newImpvoltage + + "', \"traweight\" = '" + newTraweight + "', \"totweight\" = '" + newTotweight + + "', \"copconsumption\" = '" + newCopconsumption + "', \"cmarketprice\" = '" + + newCmarketprice + "', \"vollevel\" = '" + newVollevel + "' where \"cbdlx\" = '" + + selectedItem + "' and \"projectid\" = '" + ButtonCellEditor.cusquotation.getProjectid() + "' and \"revision\" = '" + editionComboBox.getSelectionModel().getSelectedItem() + "'"; System.out.println("insertTop:" + updateTop); SqlUtil.update(updateTop); @@ -849,26 +1051,25 @@ public class MyController extends KFXPanelController { // 将关联的明细表数据删除,重新插入数据 String deleSql = "DELETE FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"cbdlx\" = '" - + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "' and \"projectid\" = '" - + ButtonCellEditor.cusquotation.getProjectid() + "' and \"revision\" = '" - + editionComboBox.getSelectionModel().getSelectedItem() + "'"; + + selectedItem + "' and \"projectid\" = '" + ButtonCellEditor.cusquotation.getProjectid() + + "' and \"revision\" = '" + editionComboBox.getSelectionModel().getSelectedItem() + "'"; SqlUtil.delete(deleSql); // 将关联的对比结果信息表删除,重新插入数据 String deleteDataSql = "DELETE FROM \"CHINT_DBCUSQUOTATION_ DETAILS_TEMPLATE\" where \"cbdlx\" = '" - + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "' and \"projectid\" = '" - + ButtonCellEditor.cusquotation.getProjectid() + "' and \"revision\" = '" - + editionComboBox.getSelectionModel().getSelectedItem() + "' and \"dbcbdlx\" = '" - + comparedCostSheetTextField.getText() + "'"; + + selectedItem + "' and \"projectid\" = '" + ButtonCellEditor.cusquotation.getProjectid() + + "' and \"revision\" = '" + editionComboBox.getSelectionModel().getSelectedItem() + + "' and \"dbcbdlx\" = '" + comparedCostSheetTextField.getText() + "'"; SqlUtil.delete(deleteDataSql); } else { // 插入数据 - String insertTop = "INSERT INTO \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\"(\"cbdlx\",\"projectid\",\"revision\",\"factory\",\"proname\",\"tennumber\",\"promanager\",\"quantity\",\"tramodel\",\"capfactor\",\"volratio\",\"noloadloss\",\"loadloss\",\"impvoltage\",\"traweight\",\"totweight\",\"copconsumption\",\"cmarketprice\",\"vollevel\") values('" + String insertTop = "INSERT INTO \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\"(\"cbdlx\",\"projectid\",\"revision\",\"factory\",\"proname\",\"tennumber\",\"promanager\",\"quantity\",\"tramodel\",\"capfactor\",\"volratio\",\"noloadloss\",\"loadloss\",\"impvoltage\",\"traweight\",\"totweight\",\"copconsumption\",\"cmarketprice\",\"vollevel\",\"changereason\") values('" + newCbdlx + "','" + newProjectid + "','" + newRevision + "','" + newFactory + "','" + newProname + "','" + newTennumber + "','" + newPromanager + "','" + newQuantity + "','" + newTramodel + "','" + newCapfactor + "','" + newVolratio + "','" + newNoloadloss + "','" + newLoadloss + "','" + newImpvoltage + "','" + newTraweight + "','" + newTotweight + "','" - + newCopconsumption + "','" + newCmarketprice + "','" + newVollevel + "')"; + + newCopconsumption + "','" + newCmarketprice + "','" + newVollevel + "','" + + newchangeReason + "')"; System.out.println("insertTop:" + insertTop); SqlUtil.write(insertTop); System.out.println("插入数据成功"); @@ -943,10 +1144,17 @@ public class MyController extends KFXPanelController { if (quotationMX.getContrastPrice() != null) { dbjg = quotationMX.getContrastPrice(); } + String dbjgquantity = ""; + if (quotationMX.getComparedQuantityColumn() != null) { + dbjgquantity = quotationMX.getComparedQuantityColumn(); + } + String dbjgunit = ""; + if (quotationMX.getComparedUnitPriceColumn() != null) { + dbjgunit = quotationMX.getComparedUnitPriceColumn(); + } // 保存明细表 String insert = "INSERT INTO \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\"(\"cbdlx\",\"projectid\",\"revision\",\"matgroup\",\"mgsnumber\",\"matcname\",\"matcnumber\",\"matcatname\",\"specifications\",\"manufacturer\",\"nwquantity\",\"utirate\",\"unit\",\"amomoney\",\"unitprice\",\"no\",\"totalprice\") values('" - + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "','" - + ButtonCellEditor.cusquotation.getProjectid() + "','" + + selectedItem + "','" + ButtonCellEditor.cusquotation.getProjectid() + "','" + editionComboBox.getSelectionModel().getSelectedItem() + "','" + group + "','" + Mgsnumber + "','" + Matcname + "','" + Matcnumber + "','" + Matcatname + "','" + Specifications + "','" + Manufacturer + "','" + Nwquantity + "','" + Utirate + "','" + Unit + "','" + Amomoney + "','" @@ -959,9 +1167,8 @@ public class MyController extends KFXPanelController { if (dbmatcatnameList != null && dbmatcatnameList.size() > 0) { // 保存成本单对比结果信息表 // 保存明细表 - String insert1 = "INSERT INTO \"CHINT_DBCUSQUOTATION_ DETAILS_TEMPLATE\"(\"cbdlx\",\"dbcbdlx\",\"projectid\",\"revision\",\"dbrevision\",\"dbjg\",\"factory\",\"matgroup\",\"mgsnumber\",\"matcname\",\"matcnumber\",\"matcatname\",\"dbmatcatname\",\"specifications\",\"manufacturer\",\"nwquantity\",\"dbnwquantity\",\"utirate\",\"dbutirate\",\"unit\",\"dbunit\",\"amomoney\",\"dbamomoney\",\"unitprice\",\"dbunitprice\",\"no\",\"Dbno\",\"totalprice\",\"dbtotalprice\") values('" - + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "','" - + comparedCostSheetTextField.getText() + "','" + String insert1 = "INSERT INTO \"CHINT_DBCUSQUOTATION_ DETAILS_TEMPLATE\"(\"cbdlx\",\"dbcbdlx\",\"projectid\",\"revision\",\"dbrevision\",\"dbjg\",\"factory\",\"matgroup\",\"mgsnumber\",\"matcname\",\"matcnumber\",\"matcatname\",\"dbmatcatname\",\"specifications\",\"manufacturer\",\"nwquantity\",\"dbnwquantity\",\"utirate\",\"dbutirate\",\"unit\",\"dbunit\",\"amomoney\",\"dbamomoney\",\"unitprice\",\"dbunitprice\",\"no\",\"Dbno\",\"totalprice\",\"dbtotalprice\",\"dbjgquantity\",\"dbjgunit\") values('" + + selectedItem + "','" + comparedCostSheetTextField.getText() + "','" + ButtonCellEditor.cusquotation.getProjectid() + "','" + editionComboBox.getSelectionModel().getSelectedItem() + "','" + dbRevList.get(a) + "','" + dbjg + "','" + newFactory + "','" + group + "','" + Mgsnumber + "','" + Matcname + "','" @@ -970,7 +1177,7 @@ public class MyController extends KFXPanelController { + Utirate + "','" + dbutirateList.get(a) + "','" + Unit + "','" + dbunitList.get(a) + "','" + Amomoney + "','" + moneyList.get(a) + "','" + Unitprice + "','" + dbunitpriceList.get(a) + "','" + No + "','" + DbnoList.get(a) + "','" + Totalprice + "','" - + dbtotalpriceList.get(a) + "')"; + + dbtotalpriceList.get(a) + "','" + dbjgquantity + "','" + dbjgunit + "')"; System.out.println("insert:" + insert1); System.out.println("插入数据库:" + insert1); @@ -986,10 +1193,9 @@ public class MyController extends KFXPanelController { .getTypeComponent("ZT2_COSTSHEET"); String itemId = tccomponentitemtype.getNewID(); String itemRev = tccomponentitemtype.getNewRev(null); - TCComponentItem item = tccomponentitemtype.create(itemId, itemRev, "ZT2_COSTSHEET", - costSheetTypeComboBox.getSelectionModel().getSelectedItem(), "", null); - item.getLatestItemRevision().setProperty("zt2_cbdlx", - costSheetTypeComboBox.getSelectionModel().getSelectedItem()); + TCComponentItem item = tccomponentitemtype.create(itemId, itemRev, "ZT2_COSTSHEET", selectedItem, + "", null); + item.getLatestItemRevision().setProperty("zt2_cbdlx", selectedItem); item.getLatestItemRevision().setProperty("object_desc", ButtonCellEditor.cusquotation.getProjectid()); // 挂在选中的文件夹下面 @@ -1007,35 +1213,7 @@ public class MyController extends KFXPanelController { // 计算金额按钮 calculateButton.setOnAction(event -> { - // 计算金额 - for (QuotationMX quotationMX : materialsTable.getItems()) { - if (quotationMX.getUnitprice() == null || "".equals(quotationMX.getUnitprice()) - || quotationMX.getNwquantity() == null || "".equals(quotationMX.getNwquantity()) - || quotationMX.getUtirate() == null || "".equals(quotationMX.getUtirate()) - || quotationMX.getUnit() == null || "".equals(quotationMX.getUnit())) { - MessageBox.post(paramKFXPanel.getParentDialog(), "数量、单价、利用率、单位存在为空。请检查", "提示", - MessageBox.INFORMATION); -// MessageBox.post("数量、单价、利用率、单位存在为空。请检查", "提示", MessageBox.INFORMATION); - return; - } - double price = Double.valueOf(quotationMX.getUnitprice()); - double quantity = Double.valueOf(quotationMX.getNwquantity()); - double utirate = Double.valueOf(quotationMX.getUtirate()); - double amomoney = (price * quantity) / utirate; - quotationMX.setAmomoney(new SimpleStringProperty(QuotationUtil.formatString(df.format(amomoney) + ""))); - } - materialsTable.refresh(); - // 计算总价 - Double total = 0.00; - for (QuotationMX quotationMX : materialsTable.getItems()) { - String amomoney = quotationMX.getAmomoney(); - if (amomoney == null || "".equals(amomoney)) { - amomoney = "0"; - } - Double money = Double.valueOf(amomoney); - total += money; - } - totalPriceTextField.setText(QuotationUtil.formatString(total + "")); + calculate(paramKFXPanel); }); @@ -1062,14 +1240,8 @@ public class MyController extends KFXPanelController { } // 弹出对比窗口 System.out.println("弹出对比窗口"); -// //获取父窗口 -// Window parentWindow = selectComparisonButton.getScene().getWindow(); -// java.awt.Window awtWindow = null; -// if (Platform.isFxApplicationThread()) { -// awtWindow = new java.awt.Window((java.awt.Frame) SwingUtilities.getAncestorOfClass(java.awt.Frame.class, new JFXPanel())); -// } + String[] options = selectType.toArray(new String[selectType.size()]); - // String[] options = { "Option 1", "Option 2", "Option 3" }; String selectedOption = (String) JOptionPane.showInputDialog(paramKFXPanel.getParentDialog(), "选择要对比的成本单", "选择成本单", JOptionPane.PLAIN_MESSAGE, null, options, options[0]); @@ -1119,6 +1291,7 @@ public class MyController extends KFXPanelController { moneyList.add(resultSet4.getString("amomoney")); dbunitpriceList.add(resultSet4.getString("unitprice")); DbnoList.add(resultSet4.getString("no")); + if (zjdbjg) { dbtotalpriceList.add("0"); } else { @@ -1149,17 +1322,20 @@ public class MyController extends KFXPanelController { if (revList.size() > 0) { try { - String reSql = "SELECT \"dbjg\" FROM \"CHINT_DBCUSQUOTATION_ DETAILS_TEMPLATE\" WHERE \"projectid\"='" - + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" - + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "' and \"revision\" = '" - + editionComboBox.getSelectionModel().getSelectedItem() + "' and \"dbrevision\" = '" - + revList.get(0) + "' and \"dbcbdlx\"='" + selectedOption + String reSql = "SELECT \"dbjg\",\"dbjgquantity\",\"dbjgunit\" FROM \"CHINT_DBCUSQUOTATION_ DETAILS_TEMPLATE\" WHERE \"projectid\"='" + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" + operationType + + "' and \"revision\" = '" + editionComboBox.getSelectionModel().getSelectedItem() + + "' and \"dbrevision\" = '" + revList.get(0) + "' and \"dbcbdlx\"='" + selectedOption + "' order by \"matgroup\" asc,TO_NUMBER(\"mgsnumber\") asc ,TO_NUMBER(\"matcnumber\") asc,TO_NUMBER(\"no\") asc"; System.out.println("reSql:" + reSql); ResultSet reSql1 = SqlUtil.read(reSql); ArrayList tableList = new ArrayList(); + ArrayList dbjgquantityList = new ArrayList(); + ArrayList dbjgunitlList = new ArrayList(); while (reSql1.next()) { tableList.add(QuotationUtil.formatString(reSql1.getString("dbjg"))); + dbjgquantityList.add(QuotationUtil.formatString(reSql1.getString("dbjgquantity"))); + dbjgunitlList.add(QuotationUtil.formatString(reSql1.getString("dbjgunit"))); } if (tableList.size() > 0) { System.out.println("查询到了对比结果明细数据,开始插入"); @@ -1169,7 +1345,19 @@ public class MyController extends KFXPanelController { if (tableList.get(j) == null || "".equals(tableList.get(j))) { tableList.set(j, "0"); } + if (dbjgquantityList.get(j) == null || "".equals(dbjgquantityList.get(j))) { + dbjgquantityList.set(j, "0"); + } + if (dbjgunitlList.get(j) == null || "".equals(dbjgunitlList.get(j))) { + dbjgunitlList.set(j, "0"); + } System.out.println(tableList.get(j)); + System.out.println(dbjgquantityList.get(j)); + System.out.println(dbjgunitlList.get(j)); + quotationMX.setComparedQuantityColumn( + new SimpleStringProperty(QuotationUtil.formatString(dbjgquantityList.get(j)))); + quotationMX.setComparedUnitPriceColumn( + new SimpleStringProperty(QuotationUtil.formatString(dbjgunitlList.get(j)))); quotationMX.setContrastPrice( new SimpleStringProperty(QuotationUtil.formatString(tableList.get(j)))); } @@ -1208,79 +1396,212 @@ public class MyController extends KFXPanelController { return; } - if (costSheetTypeComboBox.getSelectionModel().getSelectedItem() == null - || "".equals(costSheetTypeComboBox.getSelectionModel().getSelectedItem())) { + if (operationType == null || "".equals(operationType)) { MessageBox.post(paramKFXPanel.getParentDialog(), "请选择对比成本单", "提示", MessageBox.INFORMATION); // MessageBox.post("请选择对比成本单", "提示", MessageBox.INFORMATION); return; } - // 判断数量、利用率、单价是否为数字 - for (int i = 0; i < materialsTable.getItems().size(); i++) { - QuotationMX quotationMX = materialsTable.getItems().get(i); - String nwquantity = quotationMX.getNwquantity(); - try { - Double.parseDouble(nwquantity); - } catch (NumberFormatException e) { - MessageBox.post(paramKFXPanel.getParentDialog(), "表格数量存在非法数,请修正", "提示", MessageBox.INFORMATION); - return; - } + compare(paramKFXPanel); - String utirate = quotationMX.getUtirate(); - try { - Double.parseDouble(utirate); - } catch (NumberFormatException e) { - MessageBox.post(paramKFXPanel.getParentDialog(), "表格利用率存在非法数,请修正", "提示", MessageBox.INFORMATION); - return; - } + }); - String unitprice = quotationMX.getUnitprice(); - try { - Double.parseDouble(unitprice); - } catch (NumberFormatException e) { - MessageBox.post(paramKFXPanel.getParentDialog(), "表格单价存在非法数,请修正", "提示", MessageBox.INFORMATION); - return; + } + + /** + * + * @param revisions + * @param operationType + * @Title: getOperationData + * @Description: 根据选择的成本单类型,判断是否有数据,没有数据则依次往上查找数据 + * @param 参数 + * @return void 返回类型 + * @throws SQLException + * @throws + */ + private void getOperationData(KFXPanel paramKFXPanel, List revisions) + throws SQLException { + // TODO Auto-generated method stub + String revsql = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '" + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" + operationType + + "' order by \"revision\" asc"; + System.out.println(revsql); + ResultSet resultRev = SqlUtil.read(revsql); + while (resultRev.next()) { + revisions.add(resultRev.getString("revision")); + } + if (revisions.size() == 0) { + + // 查找目标字符串在数组中的索引 + int index = -1; + for (int i = 0; i < QUOTATIONTYPE.length; i++) { + if (QUOTATIONTYPE[i].equals(operationType)) { + index = i; + break; } } + if (index > 0) { + String previousString = QUOTATIONTYPE[index - 1]; + operationType = previousString; + getOperationData(paramKFXPanel, revisions); + } else { + MessageBox.post(paramKFXPanel.getParentDialog(), "查询报价单出了问题,请联系管理员查看数据库类型数据是否为" + QUOTATIONTYPE, "提示", + MessageBox.INFORMATION); + return; + } - System.out.println("表格长度:" + materialsTable.getItems().size()); - // 获取当前表格用户填写情况 - for (int i = 0; i < materialsTable.getItems().size(); i++) { - QuotationMX quotationMX = materialsTable.getItems().get(i); - String amomoney = quotationMX.getAmomoney(); - if (amomoney == null || "".equals(amomoney.trim())) { - amomoney = "0"; - } - BigDecimal newjine = new BigDecimal(Double.valueOf(amomoney)); - if (moneyList.get(i) == null || "".equals(moneyList.get(i))) { - moneyList.set(i, "0"); - } - BigDecimal oldjine = new BigDecimal(Double.valueOf(moneyList.get(i))); - double absPercent = newjine.subtract(oldjine).doubleValue(); // 减法 - System.out.println(absPercent + ""); - quotationMX.setContrastPrice( - new SimpleStringProperty(QuotationUtil.formatString(df.format(absPercent) + ""))); + } + } + + /** + * + * @Title: calculate + * @Description: 计算金额逻辑 + * @param @param paramKFXPanel 参数 + * @return void 返回类型 + * @throws + */ + public void calculate(KFXPanel paramKFXPanel) { + // 计算金额 + for (QuotationMX quotationMX : materialsTable.getItems()) { + if (quotationMX.getUnitprice() == null || "".equals(quotationMX.getUnitprice()) + || quotationMX.getNwquantity() == null || "".equals(quotationMX.getNwquantity()) + || quotationMX.getUtirate() == null || "".equals(quotationMX.getUtirate()) + || quotationMX.getUnit() == null || "".equals(quotationMX.getUnit())) { + MessageBox.post(paramKFXPanel.getParentDialog(), "数量、单价、利用率、单位存在为空。请检查", "提示", MessageBox.INFORMATION); +// MessageBox.post("数量、单价、利用率、单位存在为空。请检查", "提示", MessageBox.INFORMATION); + return; } - materialsTable.refresh(); - // 计算总价 - Double total = 0.00; - for (String amomoney : moneyList) { - if (amomoney == null || "".equals(amomoney.trim())) { - amomoney = "0"; - } - System.out.println(amomoney); - Double money = Double.valueOf(amomoney); - total += money; + double price = Double.valueOf(quotationMX.getUnitprice()); + double quantity = Double.valueOf(quotationMX.getNwquantity()); + double utirate = Double.valueOf(quotationMX.getUtirate()); + double amomoney = (price * quantity) / utirate; + quotationMX.setAmomoney(new SimpleStringProperty(QuotationUtil.formatString(df.format(amomoney) + ""))); + } + materialsTable.refresh(); + // 计算总价 + Double total = 0.00; + for (QuotationMX quotationMX : materialsTable.getItems()) { + String amomoney = quotationMX.getAmomoney(); + if (amomoney == null || "".equals(amomoney)) { + amomoney = "0"; } - BigDecimal newTotalPrice = new BigDecimal(Double.valueOf(totalPriceTextField.getText())); - System.out.println("当前页面选择的对比单总金额为:" + newTotalPrice.toString()); - BigDecimal oldTotalPrice = new BigDecimal(total); - System.out.println("选择的要对比的对比单单总金额为:" + oldTotalPrice.toString()); - double absPercent = newTotalPrice.subtract(oldTotalPrice).doubleValue(); // 减法 - System.out.println("当前对比单减选择的对比单得:" + absPercent); - totalPriceCompareTextField.setText(QuotationUtil.formatString(absPercent + "")); + Double money = Double.valueOf(amomoney); + total += money; + } + totalPriceTextField.setText(QuotationUtil.formatString(total + "")); + } - }); + /** + * + * @Title: compare + * @Description: 对比逻辑 + * @param @param paramKFXPanel 参数 + * @return void 返回类型 + * @throws + */ + public void compare(KFXPanel paramKFXPanel) { + // 判断数量、利用率、单价是否为数字 + for (int i = 0; i < materialsTable.getItems().size(); i++) { + QuotationMX quotationMX = materialsTable.getItems().get(i); + String nwquantity = quotationMX.getNwquantity(); + try { + Double.parseDouble(nwquantity); + } catch (NumberFormatException e) { + MessageBox.post(paramKFXPanel.getParentDialog(), "表格数量存在非法数,请修正", "提示", MessageBox.INFORMATION); + return; + } + + String utirate = quotationMX.getUtirate(); + try { + Double.parseDouble(utirate); + } catch (NumberFormatException e) { + MessageBox.post(paramKFXPanel.getParentDialog(), "表格利用率存在非法数,请修正", "提示", MessageBox.INFORMATION); + return; + } + + String unitprice = quotationMX.getUnitprice(); + try { + Double.parseDouble(unitprice); + } catch (NumberFormatException e) { + MessageBox.post(paramKFXPanel.getParentDialog(), "表格单价存在非法数,请修正", "提示", MessageBox.INFORMATION); + return; + } + } + + System.out.println("表格长度:" + materialsTable.getItems().size()); + // 获取当前表格用户填写情况 + for (int i = 0; i < materialsTable.getItems().size(); i++) { + QuotationMX quotationMX = materialsTable.getItems().get(i); + + // 获取对比数量 + String quantity = quotationMX.getNwquantity(); + if (quantity == null || "".equals(quantity.trim())) { + quantity = "0"; + } + BigDecimal newquantity = new BigDecimal(Double.valueOf(quantity)); + + if (dbnwquantityList.get(i) == null || "".equals(dbnwquantityList.get(i))) { + dbnwquantityList.set(i, "0"); + } + BigDecimal oldquantity = new BigDecimal(Double.valueOf(dbnwquantityList.get(i))); + + double dbQuantity = newquantity.subtract(oldquantity).doubleValue(); // 减法 + System.out.println(dbQuantity + ""); + // 获取对比单价 + String unitPrice = quotationMX.getUnitprice(); + if (unitPrice == null || "".equals(unitPrice.trim())) { + unitPrice = "0"; + } + BigDecimal newunitPrice = new BigDecimal(Double.valueOf(unitPrice)); + + if (dbunitpriceList.get(i) == null || "".equals(dbunitpriceList.get(i))) { + dbunitpriceList.set(i, "0"); + } + BigDecimal oldunitPrice = new BigDecimal(Double.valueOf(dbunitpriceList.get(i))); + double dbUnitPriceResult = newunitPrice.subtract(oldunitPrice).doubleValue(); // 减法 + System.out.println(dbUnitPriceResult + ""); + + // 获取对比金额 + String amomoney = quotationMX.getAmomoney(); + if (amomoney == null || "".equals(amomoney.trim())) { + amomoney = "0"; + } + BigDecimal newjine = new BigDecimal(Double.valueOf(amomoney)); + + if (moneyList.get(i) == null || "".equals(moneyList.get(i))) { + moneyList.set(i, "0"); + } + BigDecimal oldjine = new BigDecimal(Double.valueOf(moneyList.get(i))); + double absPercent = newjine.subtract(oldjine).doubleValue(); // 减法 + System.out.println(absPercent + ""); + + quotationMX.setComparedQuantityColumn( + new SimpleStringProperty(QuotationUtil.formatString(df.format(dbQuantity) + ""))); + quotationMX.setComparedUnitPriceColumn( + new SimpleStringProperty(QuotationUtil.formatString(df.format(dbUnitPriceResult) + ""))); + quotationMX + .setContrastPrice(new SimpleStringProperty(QuotationUtil.formatString(df.format(absPercent) + ""))); + materialsTable.refresh(); + } + + // 计算总价 + Double total = 0.00; + for (String amomoney : moneyList) { + if (amomoney == null || "".equals(amomoney.trim())) { + amomoney = "0"; + } + System.out.println(amomoney); + Double money = Double.valueOf(amomoney); + total += money; + } + BigDecimal newTotalPrice = new BigDecimal(Double.valueOf(totalPriceTextField.getText())); + System.out.println("当前页面选择的对比单总金额为:" + newTotalPrice.toString()); + BigDecimal oldTotalPrice = new BigDecimal(total); + System.out.println("选择的要对比的对比单单总金额为:" + oldTotalPrice.toString()); + double absPercent = newTotalPrice.subtract(oldTotalPrice).doubleValue(); // 减法 + System.out.println("当前对比单减选择的对比单得:" + absPercent); + totalPriceCompareTextField.setText(QuotationUtil.formatString(absPercent + "")); } } \ No newline at end of file diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/PersonOverview.fxml b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/PersonOverview.fxml index 87923a0..65aaaf8 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/PersonOverview.fxml +++ b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/PersonOverview.fxml @@ -6,6 +6,7 @@ + @@ -78,17 +79,19 @@
- - - - - - - - - - - + + + + + + + + + + + + +
@@ -97,13 +100,42 @@
+ + + + + + + + + + + + + + + + +
- +