@ -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 < String > dbRevList = null ;
@ -59,6 +70,7 @@ public class MyController extends KFXPanelController {
private List < String > dbunitpriceList = null ;
private List < String > DbnoList = null ;
private List < String > dbtotalpriceList = null ;
private final static String [ ] QUOTATIONTYPE = { "报价成本单" , "报审成本单(电磁部分)" , "报审成本单(结构部分)" , "设计成本单(电磁)" , "设计成本单(布置)" } ;
@FXML
private AnchorPane coverPane ;
@ -228,6 +240,12 @@ public class MyController extends KFXPanelController {
@FXML
private TableColumn < QuotationMX , String > amountColumn ;
@FXML
private TableColumn < QuotationMX , String > comparedQuantityColumn ;
@FXML
private TableColumn < QuotationMX , String > comparedUnitPriceColumn ;
@FXML
private TableColumn < QuotationMX , String > 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 < QuotationMX > ( ) ) ;
unitColumn . setCellFactory ( ( tableColumn ) - > new EditingCell < QuotationMX > ( ) ) ;
unitPriceColumn . setCellFactory ( ( tableColumn ) - > new EditingCell < QuotationMX > ( ) ) ;
amountColumn . setCellFactory ( ( tableColumn ) - > new EditingCellOR < QuotationMX > ( ) ) ;
amountColumn . setCellFactory ( column - > {
return new TableCell < QuotationMX , String > ( ) {
@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 < QuotationMX , String > ( ) {
@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 < QuotationMX , String > ( ) {
@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 < QuotationMX , String > ( ) {
@Override
@ -334,7 +422,72 @@ public class MyController extends KFXPanelController {
utilizationRateColumn . setCellFactory ( ( tableColumn ) - > new EditingCellOR < QuotationMX > ( ) ) ;
unitColumn . setCellFactory ( ( tableColumn ) - > new EditingCellOR < QuotationMX > ( ) ) ;
unitPriceColumn . setCellFactory ( ( tableColumn ) - > new EditingCellOR < QuotationMX > ( ) ) ;
amountColumn . setCellFactory ( ( tableColumn ) - > new EditingCellOR < QuotationMX > ( ) ) ;
amountColumn . setCellFactory ( column - > {
return new TableCell < QuotationMX , String > ( ) {
@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 < QuotationMX , String > ( ) {
@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 < QuotationMX , String > ( ) {
@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 < QuotationMX , String > ( ) {
@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.0 6 ) ) ;
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.1 5 ) ) ;
quantityColumn . prefWidthProperty ( ) . bind ( materialsTable . widthProperty ( ) . multiply ( 0.0 7 ) ) ;
no . prefWidthProperty ( ) . bind ( materialsTable . widthProperty ( ) . multiply ( 0.0 5 ) ) ;
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.1 6 ) ) ;
quantityColumn . prefWidthProperty ( ) . bind ( materialsTable . widthProperty ( ) . multiply ( 0.0 6 ) ) ;
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 selectedItem Type = costSheetTypeComboBox . getSelectionModel ( ) . getSelectedItem ( ) ;
operation Type = 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 < String > revisions = new ArrayList < String > ( ) ;
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\" = '" + newPromanag er
+ "', \" quantity\" = '" + newQuantity + "', \"tramodel\" = '" + newTramodel
+ "', \" capfactor\" = '" + newCapfactor + "', \"volratio\" = '" + newVolratio
+ "', \" noloadloss\" = '" + newNoloadloss + "', \"loadloss\" = '" + newL oadloss
+ "', \" impvoltage\" = '" + newImpvoltage + "', \"traweight\" = '" + newTraweight
+ "', \"t otweight\" = '" + newTotweight + "', \"copconsumption\" = '" + newCopconsumption
+ "', \"c marketprice\" = '" + newCmarketprice + "', \"vollevel\" = '" + newVollevel
+ "' where \"cbdlx\" = '" + costSheetTypeComboBox . getSelectionModel ( ) . getSelectedItem ( )
+ "' and \"projectid\" = '" + ButtonCellEditor . cusquotation . getProjectid ( )
+ "', \" changereason\" = '" + newchangeReason + "', \"tennumber\" = '" + newTennumb er
+ "', \" promanager\" = '" + newPromanager + "', \"quantity\" = '" + newQuantity
+ "', \" tramodel\" = '" + newTramodel + "', \"capfactor\" = '" + newCapfactor
+ "', \" volratio\" = '" + newVolratio + "', \"noloadloss\" = '" + newNol oadloss
+ "', \" loadloss\" = '" + newLoadloss + "', \"impvoltage\" = '" + newImpvoltage
+ "', \"t raweight\" = '" + newTraweight + "', \"totweight\" = '" + newTotweight
+ "', \"c opconsumption\" = '" + 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 < String > tableList = new ArrayList < String > ( ) ;
ArrayList < String > dbjgquantityList = new ArrayList < String > ( ) ;
ArrayList < String > dbjgunitlList = new ArrayList < String > ( ) ;
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 < String > 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 + "" ) ) ;
}
}