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 91ca764..2c894e0 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 @@ -35,198 +35,206 @@ import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.scene.control.TextField; -public class ButtonCellEditor extends AbstractCellEditor implements TableCellEditor{ - - - private JButton button; - private JTable table; - private List quotations; - private Boolean flag = false; - public static Quotation quotation; - public static Cusquotation cusquotation; - public static List tableList; - public static TCSession session; - public static TCComponent project; - public static TCComponent f; - private JFrame frame; - public ButtonCellEditor(JTable jTable2,List quotations,TCSession session, TCComponent f,JFrame frame) { - button = new JButton(); - this.table = jTable2; - this.quotations = quotations; - this.session = session; - this.f = f; - this.frame = frame; - button.addActionListener(e -> { - // 这里可以添加按钮的点击事件响应逻辑 - int selectedRow = table.getSelectedRow(); - System.out.println("点击了第"+selectedRow+"行"); - String text = button.getText(); - System.out.println("点击按钮名称:"+text); - if("打开".equals(text)) { - String url = quotations.get(selectedRow).getTechnical(); - try { - browse2(url); - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - }else if("创建".equals(text)){ - Object valueAt = table.getValueAt(table.getSelectedRow(), 4); - if("已创建".equals(valueAt)) { - MessageBox.post("请勿重复创建", "提示", MessageBox.INFORMATION); - return; - } - /*将报价成本单进行存储到数据库表3和表4中并将数据库1中“状态”字段改为已创建, - 同时在“项目执行”文件夹下的“1-电磁设计”下创建成本单对象。 - */ - //修改表一数据,改变表格内容 - try { - String update = "UPDATE \"CHINT_ QUOTATION_TITLE_TEMPLATE\" set \"state\"='已创建' where \"tennumber\" = '"+quotations.get(selectedRow).getTennumber()+"'"; - System.out.println("update:"+update); - int state = SqlUtil.update(update); - System.out.println("修改数据库:"+state); - - String insert = "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('"+ - "报价成本单','"+ - project.getStringProperty("item_id")+"','"+ - "01','"+ - quotations.get(selectedRow).getFactory()+"','"+ - quotations.get(selectedRow).getProname()+"','"+ - quotations.get(selectedRow).getTennumber()+"','"+ - quotations.get(selectedRow).getPromanager()+"','"+ - quotations.get(selectedRow).getQuantity()+"','"+ - quotations.get(selectedRow).getTramodel()+"','"+ - quotations.get(selectedRow).getCapfactor()+"','"+ - quotations.get(selectedRow).getVolratio()+"','"+ - quotations.get(selectedRow).getNoloadloss()+"','"+ - quotations.get(selectedRow).getLoadloss()+"','"+ - quotations.get(selectedRow).getImpvoltage()+"','"+ - quotations.get(selectedRow).getTraweight()+"','"+ - quotations.get(selectedRow).getTotweight()+"','"+ - quotations.get(selectedRow).getCopconsumption()+"','"+ - quotations.get(selectedRow).getCmarketprice()+"','"+ - quotations.get(selectedRow).getVollevel()+"')"; - System.out.println("insert:"+insert); - int write = SqlUtil.write(insert); - System.out.println("插入数据库:"+write); - - //修改表格内容 - table.setValueAt("已创建", table.getSelectedRow(), 4); - - //创建对象挂载 - TCComponentItemType tccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_COSTSHEET"); - String itemId = tccomponentitemtype.getNewID(); - String itemRev = tccomponentitemtype.getNewRev(null); - TCComponentItem item = tccomponentitemtype.create(itemId,itemRev,"ZT2_COSTSHEET","报价成本单","",null); - item.getLatestItemRevision().setProperty("zt2_cbdlx", "报价成本单"); - item.getLatestItemRevision().setProperty("object_desc", project.getStringProperty("item_id")); - //挂在选中的文件夹下面 - f.add("contents",item); - flag = true; - //查询表三的内容,表二的内容,注入窗口 - String select1 = "SELECT * FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" WHERE \"tennumber\"='"+quotations.get(selectedRow).getTennumber()+"'"; - System.out.println("select1:"+select1); - ResultSet resultSet1 = SqlUtil.read(select1); - while(resultSet1.next()) { - cusquotation = new Cusquotation(resultSet1.getString("cbdlx"),resultSet1.getString("projectid"),resultSet1.getString("revision"), - resultSet1.getString("proname"),resultSet1.getString("tennumber"),resultSet1.getString("promanager"),resultSet1.getString("quantity"), - resultSet1.getString("tramodel"),resultSet1.getString("capfactor"),resultSet1.getString("volratio"),resultSet1.getString("noloadloss"), - resultSet1.getString("loadloss"),resultSet1.getString("impvoltage"),resultSet1.getString("traweight"),resultSet1.getString("totweight"), - QuotationUtil.formatString(resultSet1.getString("copconsumption")),QuotationUtil.formatString(resultSet1.getString("cmarketprice")),resultSet1.getString("vollevel"),resultSet1.getString("factory")); - break; - } - - String select4 = "SELECT * FROM \"CHINT_ QUOTATION_ DETAILS_TEMPLATE\" WHERE \"tennumber\"='"+quotations.get(selectedRow).getTennumber()+"'"; - System.out.println("select4:"+select4); - ResultSet resultSet4 = SqlUtil.read(select4); - List insertList = new ArrayList(); - while(resultSet4.next()) { - String insert1 = "INSERT INTO \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\"(\"cbdlx\",\"projectid\",\"revision\",\"matgroup\",\"mgsnumber\",\"matcname\",\"matcnumber\",\"matcatname\",\"specifications\",\"manufacturer\",\"nwquantity\",\"utirate\",\"unit\",\"amomoney\",\"unitprice\",\"no\",\"totalprice\") values('"+ - "报价成本单"+"','"+ - project.getStringProperty("item_id")+"','"+ - "01"+"','"+ - resultSet4.getString("matgroup")+"','"+ - resultSet4.getString("mgsnumber")+"','"+ - resultSet4.getString("matcname")+"','"+ - resultSet4.getString("matcnumber")+"','"+ - resultSet4.getString("matcatname")+"','"+ - resultSet4.getString("specifications")+"','"+ - resultSet4.getString("manufacturer")+"','"+ - resultSet4.getString("nwquantity")+"','"+ - resultSet4.getString("utirate")+"','"+ - resultSet4.getString("unit")+"','"+ - resultSet4.getString("amomoney")+"','"+ - resultSet4.getString("unitprice")+"','"+ - resultSet4.getString("no")+"','"+ - resultSet4.getString("totalprice")+"')"; - insertList.add(insert1); - - } - for(String insertsql : insertList) { - System.out.println("insert:"+insertsql); - SqlUtil.write(insertsql); - } - - String select2 = "SELECT * FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" WHERE \"projectid\"='"+project.getStringProperty("item_id")+"' and \"cbdlx\" = '报价成本单' order by \"matgroup\" asc ,TO_NUMBER(\"mgsnumber\") asc ,TO_NUMBER(\"matcnumber\") asc,TO_NUMBER(\"no\") asc"; - System.out.println("select2:"+select2); - ResultSet resultSet2 = SqlUtil.read(select2); - tableList = new ArrayList(); - while(resultSet2.next()) { - QuotationMX quotationMX = new QuotationMX(); - quotationMX.setCbdlx(resultSet2.getString("cbdlx")); - quotationMX.setProjectid(resultSet2.getString("projectid")); - quotationMX.setRevision(resultSet2.getString("revision")); - quotationMX.setMatgroup(new SimpleStringProperty(resultSet2.getString("matgroup"))); - quotationMX.setMgsnumber(new SimpleStringProperty(resultSet2.getString("mgsnumber"))); - quotationMX.setMatcname(new SimpleStringProperty(resultSet2.getString("matcname"))); - quotationMX.setMatcnumber(new SimpleStringProperty(resultSet2.getString("matcnumber"))); - quotationMX.setMatcatname(new SimpleStringProperty(resultSet2.getString("matcatname"))); - quotationMX.setSpecifications(new SimpleStringProperty(resultSet2.getString("specifications"))); - quotationMX.setManufacturer(new SimpleStringProperty(resultSet2.getString("manufacturer"))); - quotationMX.setNwquantity(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("nwquantity")))); - quotationMX.setUtirate(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("utirate")))); - quotationMX.setUnit(new SimpleStringProperty(resultSet2.getString("unit"))); - quotationMX.setAmomoney(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("amomoney")))); - quotationMX.setUnitprice(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("unitprice")))); - quotationMX.setNo(new SimpleStringProperty(resultSet2.getString("no"))); - quotationMX.setContrastPrice(new SimpleStringProperty("")); - quotationMX.setTotalprice(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("totalprice")))); - tableList.add(quotationMX); - } - - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - +public class ButtonCellEditor extends AbstractCellEditor implements TableCellEditor { + + private JButton button; + private JTable table; + private List quotations; + private Boolean flag = false; + public static Quotation quotation; + public static Cusquotation cusquotation; + public static List tableList; + public static TCSession session; + public static TCComponent project; + public static TCComponent f; + private JFrame frame; + + public ButtonCellEditor(JTable jTable2, List quotations, TCSession session, TCComponent f, + JFrame frame) { + button = new JButton(); + this.table = jTable2; + this.quotations = quotations; + this.session = session; + this.f = f; + this.frame = frame; + button.addActionListener(e -> { + // 这里可以添加按钮的点击事件响应逻辑 + int selectedRow = table.getSelectedRow(); + System.out.println("点击了第" + selectedRow + "行"); + String text = button.getText(); + System.out.println("点击按钮名称:" + text); + if ("打开".equals(text)) { + String url = quotations.get(selectedRow).getTechnical(); + try { + browse2(url); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if ("创建".equals(text)) { + Object valueAt = table.getValueAt(table.getSelectedRow(), 4); + if ("已创建".equals(valueAt)) { + MessageBox.post("请勿重复创建", "提示", MessageBox.INFORMATION); + return; + } + /* + * 将报价成本单进行存储到数据库表3和表4中并将数据库1中“状态”字段改为已创建, 同时在“项目执行”文件夹下的“1-电磁设计”下创建成本单对象。 + */ + // 修改表一数据,改变表格内容 + try { + String update = "UPDATE \"CHINT_ QUOTATION_TITLE_TEMPLATE\" set \"state\"='已创建' where \"tennumber\" = '" + + quotations.get(selectedRow).getTennumber() + "'"; + System.out.println("update:" + update); + int state = SqlUtil.update(update); + System.out.println("修改数据库:" + state); + + String insert = "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('" + + "报价成本单','" + project.getStringProperty("item_id") + "','" + "01','" + + quotations.get(selectedRow).getFactory() + "','" + + quotations.get(selectedRow).getProname() + "','" + + quotations.get(selectedRow).getTennumber() + "','" + + quotations.get(selectedRow).getPromanager() + "','" + + quotations.get(selectedRow).getQuantity() + "','" + + quotations.get(selectedRow).getTramodel() + "','" + + quotations.get(selectedRow).getCapfactor() + "','" + + quotations.get(selectedRow).getVolratio() + "','" + + quotations.get(selectedRow).getNoloadloss() + "','" + + quotations.get(selectedRow).getLoadloss() + "','" + + quotations.get(selectedRow).getImpvoltage() + "','" + + quotations.get(selectedRow).getTraweight() + "','" + + quotations.get(selectedRow).getTotweight() + "','" + + quotations.get(selectedRow).getCopconsumption() + "','" + + quotations.get(selectedRow).getCmarketprice() + "','" + + quotations.get(selectedRow).getVollevel() + "')"; + System.out.println("insert:" + insert); + int write = SqlUtil.write(insert); + System.out.println("插入数据库:" + write); + + // 修改表格内容 + table.setValueAt("已创建", table.getSelectedRow(), 4); + + // 创建对象挂载 + TCComponentItemType tccomponentitemtype = (TCComponentItemType) session + .getTypeComponent("ZT2_COSTSHEET"); + String itemId = tccomponentitemtype.getNewID(); + String itemRev = tccomponentitemtype.getNewRev(null); + TCComponentItem item = tccomponentitemtype.create(itemId, itemRev, "ZT2_COSTSHEET", "报价成本单", "", + null); + item.getLatestItemRevision().setProperty("zt2_cbdlx", "报价成本单"); + item.getLatestItemRevision().setProperty("object_desc", project.getStringProperty("item_id")); + // 挂在选中的文件夹下面 + f.add("contents", item); + flag = true; + // 查询表三的内容,表二的内容,注入窗口 + String select1 = "SELECT * FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" WHERE \"tennumber\"='" + + quotations.get(selectedRow).getTennumber() + "'"; + System.out.println("select1:" + select1); + ResultSet resultSet1 = SqlUtil.read(select1); + while (resultSet1.next()) { + cusquotation = new Cusquotation(resultSet1.getString("cbdlx"), + resultSet1.getString("projectid"), resultSet1.getString("revision"), + resultSet1.getString("proname"), resultSet1.getString("tennumber"), + resultSet1.getString("promanager"), resultSet1.getString("quantity"), + resultSet1.getString("tramodel"), resultSet1.getString("capfactor"), + resultSet1.getString("volratio"), resultSet1.getString("noloadloss"), + resultSet1.getString("loadloss"), resultSet1.getString("impvoltage"), + resultSet1.getString("traweight"), resultSet1.getString("totweight"), + QuotationUtil.formatString(resultSet1.getString("copconsumption")), + QuotationUtil.formatString(resultSet1.getString("cmarketprice")), + resultSet1.getString("vollevel"), resultSet1.getString("factory")); + break; + } + + String select4 = "SELECT * FROM \"CHINT_ QUOTATION_ DETAILS_TEMPLATE\" WHERE \"tennumber\"='" + + quotations.get(selectedRow).getTennumber() + "'"; + System.out.println("select4:" + select4); + ResultSet resultSet4 = SqlUtil.read(select4); + List insertList = new ArrayList(); + while (resultSet4.next()) { + String insert1 = "INSERT INTO \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\"(\"cbdlx\",\"projectid\",\"revision\",\"matgroup\",\"mgsnumber\",\"matcname\",\"matcnumber\",\"matcatname\",\"specifications\",\"manufacturer\",\"nwquantity\",\"utirate\",\"unit\",\"amomoney\",\"unitprice\",\"no\",\"totalprice\") values('" + + "报价成本单" + "','" + project.getStringProperty("item_id") + "','" + "01" + "','" + + resultSet4.getString("matgroup") + "','" + resultSet4.getString("mgsnumber") + "','" + + resultSet4.getString("matcname") + "','" + resultSet4.getString("matcnumber") + "','" + + resultSet4.getString("matcatname") + "','" + resultSet4.getString("specifications") + + "','" + resultSet4.getString("manufacturer") + "','" + + resultSet4.getString("nwquantity") + "','" + resultSet4.getString("utirate") + "','" + + resultSet4.getString("unit") + "','" + resultSet4.getString("amomoney") + "','" + + resultSet4.getString("unitprice") + "','" + resultSet4.getString("no") + "','" + + resultSet4.getString("totalprice") + "')"; + insertList.add(insert1); + + } + for (String insertsql : insertList) { + System.out.println("insert:" + insertsql); + SqlUtil.write(insertsql); + } + + String select2 = "SELECT * FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" WHERE \"projectid\"='" + + project.getStringProperty("item_id") + + "' and \"cbdlx\" = '报价成本单' order by \"matgroup\" asc ,TO_NUMBER(\"mgsnumber\") asc ,TO_NUMBER(\"matcnumber\") asc,TO_NUMBER(\"no\") asc"; + System.out.println("select2:" + select2); + ResultSet resultSet2 = SqlUtil.read(select2); + tableList = new ArrayList(); + while (resultSet2.next()) { + QuotationMX quotationMX = new QuotationMX(); + quotationMX.setCbdlx(resultSet2.getString("cbdlx")); + quotationMX.setProjectid(resultSet2.getString("projectid")); + quotationMX.setRevision(resultSet2.getString("revision")); + quotationMX.setMatgroup(new SimpleStringProperty(resultSet2.getString("matgroup"))); + quotationMX.setMgsnumber(new SimpleStringProperty(resultSet2.getString("mgsnumber"))); + quotationMX.setMatcname(new SimpleStringProperty(resultSet2.getString("matcname"))); + quotationMX.setMatcnumber(new SimpleStringProperty(resultSet2.getString("matcnumber"))); + quotationMX.setMatcatname(new SimpleStringProperty(resultSet2.getString("matcatname"))); + quotationMX.setSpecifications(new SimpleStringProperty(resultSet2.getString("specifications"))); + quotationMX.setManufacturer(new SimpleStringProperty(resultSet2.getString("manufacturer"))); + quotationMX.setNwquantity(new SimpleStringProperty( + QuotationUtil.formatString(resultSet2.getString("nwquantity")))); + quotationMX.setUtirate( + new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("utirate")))); + quotationMX.setUnit(new SimpleStringProperty(resultSet2.getString("unit"))); + quotationMX.setAmomoney( + new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("amomoney")))); + quotationMX.setUnitprice(new SimpleStringProperty( + QuotationUtil.formatString(resultSet2.getString("unitprice")))); + quotationMX.setNo(new SimpleStringProperty(resultSet2.getString("no"))); + quotationMX.setContrastPrice(new SimpleStringProperty("")); + quotationMX.setTotalprice(new SimpleStringProperty( + QuotationUtil.formatString(resultSet2.getString("totalprice")))); + tableList.add(quotationMX); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // quotation = new Quotation(); // quotation.setProname("test"); - this.frame.dispose(); - new JDBFrame(); - - - } - }); - - } - private void browse2(String url) throws Exception { - Desktop desktop = Desktop.getDesktop(); - if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) { - URI uri = new URI(url); - desktop.browse(uri); - } - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, - int row, int column) { - button.setText(value != null ? value.toString() : ""); - return button; - } - - @Override - public Object getCellEditorValue() { - return button.getText(); - } + this.frame.dispose(); + new JDBFrame(); + + } + }); + + } + + private void browse2(String url) throws Exception { + Desktop desktop = Desktop.getDesktop(); + if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) { + URI uri = new URI(url); + desktop.browse(uri); + } + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + button.setText(value != null ? value.toString() : ""); + return button; + } + + @Override + public Object getCellEditorValue() { + return button.getText(); + } } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/ButtonCellRenderer.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/ButtonCellRenderer.java index b847704..51c1746 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/ButtonCellRenderer.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/ButtonCellRenderer.java @@ -30,29 +30,31 @@ import javafx.stage.WindowEvent; class ButtonCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer { - private JButton button; - private JTable table; - private List quotations; - private TCSession session; - private TCComponent f; - private JFrame frame; - public ButtonCellRenderer(JTable jTable2, List quotations,TCSession session, TCComponent f,JFrame frame) { - button = new JButton(); - this.quotations = quotations; - this.table = jTable2; - this.session = session; - this.f = f; - this.frame = frame; - } - public interface CostPageCallback { - void onOpenCostPage(); - } - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, - boolean hasFocus, int row, int column) { - button.setText(value != null ? value.toString() : ""); - return button; - } + private JButton button; + private JTable table; + private List quotations; + private TCSession session; + private TCComponent f; + private JFrame frame; + + public ButtonCellRenderer(JTable jTable2, List quotations, TCSession session, TCComponent f, + JFrame frame) { + button = new JButton(); + this.quotations = quotations; + this.table = jTable2; + this.session = session; + this.f = f; + this.frame = frame; + } + + public interface CostPageCallback { + void onOpenCostPage(); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + button.setText(value != null ? value.toString() : ""); + return button; + } } - - 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 2ba543f..dfb20f9 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 @@ -35,194 +35,239 @@ import javafx.beans.property.SimpleStringProperty; /** * 成本单管理 - * @author hongcj - * 2023/11/16 + * + * @author hongcj 2023/11/16 */ -public class CostListManagementHandler extends AbstractHandler{ +public class CostListManagementHandler extends AbstractHandler { - @Override - public Object execute(ExecutionEvent arg0) { - // TODO Auto-generated method stub - AbstractAIFApplication app = AIFUtility.getCurrentApplication(); - TCSession session = (TCSession)app.getSession(); - try { - new Thread() { - @Override - public void run() { - // 获取tc当前选择的操作 - InterfaceAIFComponent target = app.getTargetComponent(); - if(target instanceof TCComponent) { - - TCComponent project = (TCComponent)target; - try { - String stringProperty = project.getStringProperty("object_type"); - if(!"ZT2_ProjectItem".equals(stringProperty)) { - MessageBox.post("请选择项目零组件对象", "提示", MessageBox.INFORMATION); - return; - } - } catch (TCException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - /* - * 遍历项目下“项目执行”文件夹下的“1-电磁设计”有无成本单(ZT2_COSTSHEET)对象, - * 如果没有直接切换到查询界面,如果有直接显示报价成本单界面。 - */ - AIFComponentContext[] children = null; - try { - children = project.getChildren(); - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - for(AIFComponentContext child : children) { - TCComponent component = (TCComponent)child.getComponent(); - try { - System.out.println(component.getProperty("object_name")); - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - try { - if("项目执行".equals(component.getProperty("object_name"))) { - AIFComponentContext[] children2 = component.getChildren(); - for(AIFComponentContext child2 : children2) { - TCComponent component2 = (TCComponent)child2.getComponent(); - System.out.println(component2.getProperty("object_name")); - if("1-电磁设计".equals(component2.getProperty("object_name"))) { - System.out.println("开始查看1-电磁设计下的文件是否含有成本单"); - AIFComponentContext[] children3 = component2.getChildren(); - int count = 0; - if(children3 == null || children3.length==0) { - //显示查询界面 - System.out.println("没有找到成本单对象,进入查询界面===============》》》》》》"); - QueryQuotationFram queryQuotationFram = new QueryQuotationFram(session,component2); - ButtonCellEditor.project = project; - session.queueOperation(queryQuotationFram); - } - for(AIFComponentContext child3 : children3) { - TCComponent component3 = (TCComponent)child3.getComponent(); - String typeString = component3.getProperty("object_type"); - System.out.println("typeString:"+typeString); + @Override + public Object execute(ExecutionEvent arg0) { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + new Thread() { + @Override + public void run() { + // 获取tc当前选择的操作 + InterfaceAIFComponent target = app.getTargetComponent(); + if (target instanceof TCComponent) { + + TCComponent project = (TCComponent) target; + try { + String stringProperty = project.getStringProperty("object_type"); + if (!"ZT2_ProjectItem".equals(stringProperty)) { + MessageBox.post("请选择项目零组件对象", "提示", MessageBox.INFORMATION); + return; + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + /* + * 遍历项目下“项目执行”文件夹下的“1-电磁设计”有无成本单(ZT2_COSTSHEET)对象, 如果没有直接切换到查询界面,如果有直接显示报价成本单界面。 + */ + AIFComponentContext[] children = null; + try { + children = project.getChildren(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + for (AIFComponentContext child : children) { + TCComponent component = (TCComponent) child.getComponent(); + try { + System.out.println(component.getProperty("object_name")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + if ("项目执行".equals(component.getProperty("object_name"))) { + AIFComponentContext[] children2 = component.getChildren(); + for (AIFComponentContext child2 : children2) { + TCComponent component2 = (TCComponent) child2.getComponent(); + System.out.println(component2.getProperty("object_name")); + if ("1-电磁设计".equals(component2.getProperty("object_name"))) { + System.out.println("开始查看1-电磁设计下的文件是否含有成本单"); + AIFComponentContext[] children3 = component2.getChildren(); + int count = 0; + if (children3 == null || children3.length == 0) { + // 显示查询界面 + System.out.println("没有找到成本单对象,进入查询界面===============》》》》》》"); + QueryQuotationFram queryQuotationFram = new QueryQuotationFram(session, + component2); + ButtonCellEditor.project = project; + session.queueOperation(queryQuotationFram); + } + for (AIFComponentContext child3 : children3) { + TCComponent component3 = (TCComponent) child3.getComponent(); + String typeString = component3.getProperty("object_type"); + System.out.println("typeString:" + typeString); + + if ("ZT2_COSTSHEET".equals(component3.getStringProperty("object_type")) + || "变压器投标成本单".equals(component3.getProperty("object_type"))) { + // 显示报价单页面 + System.out.println("显示报价页面"); + try { + String[] prefs = session.getPreferenceService() + .getStringValues("database_tc"); + System.out.println("===============开始连接tc数据库==============="); + long time31 = System.nanoTime(); + Connection conn = SqlUtil.getTCDataConnection(prefs); + long time32 = System.nanoTime(); + System.out.println("===============连接tc数据库用时(ms): " + + ((time32 - time31) / 1000000L) + "==============="); + // 给Controller层外部变量赋值 + // 查询表三的内容,表二的内容,注入窗口 + String select1 = "SELECT * FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" WHERE \"projectid\"='" + + project.getStringProperty("item_id") + + "' and \"cbdlx\" = '报价成本单' order by \"revision\" desc "; + System.out.println("select1:" + select1); + ResultSet resultSet1 = SqlUtil.read(select1); + Cusquotation cusquotation = null; + String tennumber = ""; + + while (resultSet1.next()) { + cusquotation = new Cusquotation( + resultSet1.getString("cbdlx"), + resultSet1.getString("projectid"), + resultSet1.getString("revision"), + resultSet1.getString("proname"), + resultSet1.getString("tennumber"), + resultSet1.getString("promanager"), + resultSet1.getString("quantity"), + resultSet1.getString("tramodel"), + resultSet1.getString("capfactor"), + resultSet1.getString("volratio"), + resultSet1.getString("noloadloss"), + resultSet1.getString("loadloss"), + resultSet1.getString("impvoltage"), + resultSet1.getString("traweight"), + resultSet1.getString("totweight"), + QuotationUtil.formatString( + resultSet1.getString("copconsumption")), + QuotationUtil.formatString( + resultSet1.getString("cmarketprice")), + resultSet1.getString("vollevel"), + resultSet1.getString("factory")); + tennumber = resultSet1.getString("tennumber"); + break; + } + ButtonCellEditor.cusquotation = cusquotation; + ButtonCellEditor.session = session; + + // 查询最高版本 + // 开始刷新对比结果数据 + // 获取数据库该类型成本单最新的版本 + String getLastRevSql1 = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"projectid\" = '" + + project.getStringProperty("item_id") + + "' and \"cbdlx\" = '" + "报价成本单" + + "' order by \"revision\" desc"; + System.out.println("getLastRevSql:" + getLastRevSql1); + List revList = new ArrayList(); + try { + ResultSet resultSet4 = SqlUtil.read(getLastRevSql1); + while (resultSet4.next()) { + revList.add(resultSet4.getString("revision")); + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + String select2 = "SELECT * FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" WHERE \"projectid\"='" + + project.getStringProperty("item_id") + + "' and \"cbdlx\" = '报价成本单' and \"revision\" = '" + + revList.get(0) + + "' order by \"matgroup\" asc,TO_NUMBER(\"mgsnumber\") asc ,TO_NUMBER(\"matcnumber\") asc,TO_NUMBER(\"no\") asc"; + System.out.println("select2:" + select2); + ResultSet resultSet2 = SqlUtil.read(select2); + List tableList = new ArrayList(); + while (resultSet2.next()) { + QuotationMX quotationMX = new QuotationMX(); + quotationMX.setCbdlx(resultSet2.getString("cbdlx")); + quotationMX.setProjectid(resultSet2.getString("projectid")); + quotationMX.setRevision(resultSet2.getString("revision")); + quotationMX.setMatgroup(new SimpleStringProperty( + resultSet2.getString("matgroup"))); + quotationMX.setMgsnumber(new SimpleStringProperty( + resultSet2.getString("mgsnumber"))); + quotationMX.setMatcname(new SimpleStringProperty( + resultSet2.getString("matcname"))); + quotationMX.setMatcnumber(new SimpleStringProperty( + resultSet2.getString("matcnumber"))); + quotationMX.setMatcatname(new SimpleStringProperty( + resultSet2.getString("Matcatname"))); + quotationMX.setSpecifications(new SimpleStringProperty( + resultSet2.getString("specifications"))); + quotationMX.setManufacturer(new SimpleStringProperty( + resultSet2.getString("manufacturer"))); + quotationMX.setNwquantity( + new SimpleStringProperty(QuotationUtil.formatString( + resultSet2.getString("nwquantity")))); + quotationMX.setUtirate( + new SimpleStringProperty(QuotationUtil.formatString( + resultSet2.getString("utirate")))); + quotationMX.setUnit(new SimpleStringProperty( + resultSet2.getString("unit"))); + quotationMX.setAmomoney( + new SimpleStringProperty(QuotationUtil.formatString( + resultSet2.getString("amomoney")))); + quotationMX.setUnitprice( + new SimpleStringProperty(QuotationUtil.formatString( + resultSet2.getString("unitprice")))); + quotationMX.setNo(new SimpleStringProperty( + resultSet2.getString("no"))); + quotationMX.setContrastPrice(new SimpleStringProperty("")); + quotationMX.setTotalprice( + new SimpleStringProperty(QuotationUtil.formatString( + resultSet2.getString("totalprice")))); + tableList.add(quotationMX); + } + + ButtonCellEditor.tableList = tableList; + ButtonCellEditor.f = component2; + ButtonCellEditor.project = project; + new JDBFrame(); + break; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } else { + count++; + } + if (count == children3.length) { + // 显示查询界面 + System.out.println("没有找到成本单对象,进入查询界面===============》》》》》》"); + QueryQuotationFram queryQuotationFram = new QueryQuotationFram( + session, component2); + session.queueOperation(queryQuotationFram); + ButtonCellEditor.project = project; + } + } + break; + } + } + break; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } else { + MessageBox.post("请选择TC对象操作", "提示", MessageBox.INFORMATION); + } + + } + }.start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } - if("ZT2_COSTSHEET".equals(component3.getStringProperty("object_type")) || "变压器投标成本单".equals(component3.getProperty("object_type"))) { - //显示报价单页面 - System.out.println("显示报价页面"); - try { - String[] prefs = session.getPreferenceService().getStringValues("database_tc"); - System.out.println("===============开始连接tc数据库==============="); - long time31 = System.nanoTime(); - Connection conn = SqlUtil.getTCDataConnection(prefs); - long time32 = System.nanoTime(); - System.out.println("===============连接tc数据库用时(ms): " + ((time32 - time31) / 1000000L)+"==============="); - //给Controller层外部变量赋值 - //查询表三的内容,表二的内容,注入窗口 - String select1 = "SELECT * FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" WHERE \"projectid\"='"+project.getStringProperty("item_id")+"' and \"cbdlx\" = '报价成本单' order by \"revision\" desc "; - System.out.println("select1:"+select1); - ResultSet resultSet1 = SqlUtil.read(select1); - Cusquotation cusquotation = null; - String tennumber = ""; - - while(resultSet1.next()) { - cusquotation = new Cusquotation(resultSet1.getString("cbdlx"),resultSet1.getString("projectid"),resultSet1.getString("revision"), - resultSet1.getString("proname"),resultSet1.getString("tennumber"),resultSet1.getString("promanager"),resultSet1.getString("quantity"), - resultSet1.getString("tramodel"),resultSet1.getString("capfactor"),resultSet1.getString("volratio"),resultSet1.getString("noloadloss"), - resultSet1.getString("loadloss"),resultSet1.getString("impvoltage"),resultSet1.getString("traweight"),resultSet1.getString("totweight"), - QuotationUtil.formatString(resultSet1.getString("copconsumption")),QuotationUtil.formatString(resultSet1.getString("cmarketprice")),resultSet1.getString("vollevel"),resultSet1.getString("factory")); - tennumber = resultSet1.getString("tennumber"); - break; - } - ButtonCellEditor.cusquotation = cusquotation; - ButtonCellEditor.session = session; - - - //查询最高版本 - //开始刷新对比结果数据 - //获取数据库该类型成本单最新的版本 - String getLastRevSql1 = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"projectid\" = '"+project.getStringProperty("item_id")+"' and \"cbdlx\" = '" + "报价成本单" + "' order by \"revision\" desc" ; - System.out.println("getLastRevSql:"+getLastRevSql1); - List revList = new ArrayList(); - try { - ResultSet resultSet4 = SqlUtil.read(getLastRevSql1); - while(resultSet4.next()) { - revList.add(resultSet4.getString("revision")); - } - } catch (SQLException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - - String select2 = "SELECT * FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" WHERE \"projectid\"='"+project.getStringProperty("item_id")+"' and \"cbdlx\" = '报价成本单' and \"revision\" = '" + revList.get(0) + "' order by \"matgroup\" asc,TO_NUMBER(\"mgsnumber\") asc ,TO_NUMBER(\"matcnumber\") asc,TO_NUMBER(\"no\") asc"; - System.out.println("select2:"+select2); - ResultSet resultSet2 = SqlUtil.read(select2); - List tableList = new ArrayList(); - while(resultSet2.next()) { - QuotationMX quotationMX = new QuotationMX(); - quotationMX.setCbdlx(resultSet2.getString("cbdlx")); - quotationMX.setProjectid(resultSet2.getString("projectid")); - quotationMX.setRevision(resultSet2.getString("revision")); - quotationMX.setMatgroup(new SimpleStringProperty(resultSet2.getString("matgroup"))); - quotationMX.setMgsnumber(new SimpleStringProperty(resultSet2.getString("mgsnumber"))); - quotationMX.setMatcname(new SimpleStringProperty(resultSet2.getString("matcname"))); - quotationMX.setMatcnumber(new SimpleStringProperty(resultSet2.getString("matcnumber"))); - quotationMX.setMatcatname(new SimpleStringProperty(resultSet2.getString("Matcatname"))); - quotationMX.setSpecifications(new SimpleStringProperty(resultSet2.getString("specifications"))); - quotationMX.setManufacturer(new SimpleStringProperty(resultSet2.getString("manufacturer"))); - quotationMX.setNwquantity(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("nwquantity")))); - quotationMX.setUtirate(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("utirate")))); - quotationMX.setUnit(new SimpleStringProperty(resultSet2.getString("unit"))); - quotationMX.setAmomoney(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("amomoney")))); - quotationMX.setUnitprice(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("unitprice")))); - quotationMX.setNo(new SimpleStringProperty(resultSet2.getString("no"))); - quotationMX.setContrastPrice(new SimpleStringProperty("")); - quotationMX.setTotalprice(new SimpleStringProperty(QuotationUtil.formatString(resultSet2.getString("totalprice")))); - tableList.add(quotationMX); - } - - ButtonCellEditor.tableList = tableList; - ButtonCellEditor.f = component2; - ButtonCellEditor.project = project; - new JDBFrame(); - break; - } catch (Exception e) { - // TODO: handle exception - e.printStackTrace(); - } - - }else { - count++; - } - if(count == children3.length) { - //显示查询界面 - System.out.println("没有找到成本单对象,进入查询界面===============》》》》》》"); - QueryQuotationFram queryQuotationFram = new QueryQuotationFram(session,component2); - session.queueOperation(queryQuotationFram); - ButtonCellEditor.project = project; - } - } - break; - } - } - break; - } - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }else { - MessageBox.post("请选择TC对象操作", "提示", MessageBox.INFORMATION); - } - - - - } - }.start(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/DateChooser.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/DateChooser.java index 6cf4567..2019199 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/DateChooser.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/DateChooser.java @@ -41,658 +41,658 @@ import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; public class DateChooser extends JPanel { - private static final long serialVersionUID = 4529266044762990227L; - private Date initDate; - private Calendar now; - private Calendar select; - private JPanel monthPanel; - private DateChooser.JP1 jp1; - private DateChooser.JP2 jp2; - private DateChooser.JP3 jp3; - private DateChooser.JP4 jp4; - private Font font; - private final DateChooser.LabelManager lm; - private SimpleDateFormat sdf; - private boolean isShow; - private Popup pop; - private JComponent showDate; - - public static DateChooser getInstance() { - return new DateChooser(); - } - - public static DateChooser getInstance(Date date) { - return new DateChooser(date); - } - - public static DateChooser getInstance(String format) { - return new DateChooser(format); - } - - public static DateChooser getInstance(Date date, String format) { - return new DateChooser(date, format); - } - - private DateChooser() { - this(new Date()); - } - - private DateChooser(Date date) { - this(date, "yyyy年MM月dd日"); - } - - private DateChooser(String format) { - this(new Date(), format); - } - - private DateChooser(Date date, String format) { - this.now = Calendar.getInstance(); - this.font = new Font("宋体", 0, 12); - this.lm = new DateChooser.LabelManager(); - this.isShow = false; - this.initDate = date; - this.sdf = new SimpleDateFormat(format); - this.select = Calendar.getInstance(); - this.select.setTime(this.initDate); - this.initPanel(); - } - - public void setEnabled(boolean b) { - super.setEnabled(b); - this.showDate.setEnabled(b); - } - - public Date getDate() { - return this.select.getTime(); - } - - public String getStrDate() { - return this.sdf.format(this.select.getTime()); - } - - public String getStrDate(String format) { - this.sdf = new SimpleDateFormat(format); - return this.sdf.format(this.select.getTime()); - } - - private void initPanel() { - this.monthPanel = new JPanel(new BorderLayout()); - this.monthPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE)); - JPanel up = new JPanel(new BorderLayout()); - up.add(this.jp1 = new DateChooser.JP1(), "North"); - up.add(this.jp2 = new DateChooser.JP2(), "Center"); - this.monthPanel.add(this.jp3 = new DateChooser.JP3(), "Center"); - this.monthPanel.add(up, "North"); - this.monthPanel.add(this.jp4 = new DateChooser.JP4(), "South"); - this.addAncestorListener(new AncestorListener() { - public void ancestorAdded(AncestorEvent event) { - } - - public void ancestorRemoved(AncestorEvent event) { - } - - public void ancestorMoved(AncestorEvent event) { - DateChooser.this.hidePanel(); - } - }); - } - - public void register(final JComponent showDate) { - this.showDate = showDate; - showDate.setRequestFocusEnabled(true); - showDate.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent me) { - showDate.requestFocusInWindow(); - } - }); - this.setBackground(Color.WHITE); - this.add(showDate, "Center"); - this.setPreferredSize(new Dimension(90, 25)); - this.setBorder(BorderFactory.createLineBorder(Color.GRAY)); - showDate.addMouseListener(new MouseAdapter() { - public void mouseEntered(MouseEvent me) { - if (showDate.isEnabled()) { - showDate.setCursor(new Cursor(12)); - showDate.setForeground(Color.RED); - } - - } - - public void mouseExited(MouseEvent me) { - if (showDate.isEnabled()) { - showDate.setCursor(new Cursor(0)); - showDate.setForeground(Color.BLACK); - } - - } - - public void mousePressed(MouseEvent me) { - if (showDate.isEnabled()) { - showDate.setForeground(Color.CYAN); - if (DateChooser.this.isShow) { - DateChooser.this.hidePanel(); - } else { - DateChooser.this.showPanel(showDate); - } - } - - } - - public void mouseReleased(MouseEvent me) { - if (showDate.isEnabled()) { - showDate.setForeground(Color.BLACK); - } - - } - }); - showDate.addFocusListener(new FocusListener() { - public void focusLost(FocusEvent e) { - DateChooser.this.hidePanel(); - } - - public void focusGained(FocusEvent e) { - } - }); - } - - private void refresh() { - this.jp1.updateDate(); - this.jp2.updateDate(); - this.jp3.updateDate(); - this.jp4.updateDate(); - SwingUtilities.updateComponentTreeUI(this); - } - - private void commit() { - if (this.showDate instanceof JTextField) { - ((JTextField) this.showDate).setText(this.sdf.format(this.select.getTime())); - } else if (this.showDate instanceof JLabel) { - ((JLabel) this.showDate).setText(this.sdf.format(this.select.getTime())); - } - - this.hidePanel(); - } - - private void hidePanel() { - if (this.pop != null) { - this.isShow = false; - this.pop.hide(); - this.pop = null; - } - - } - - private void showPanel(Component owner) { - if (this.pop != null) { - this.pop.hide(); - } - - Point show = new Point(0, this.showDate.getHeight()); - SwingUtilities.convertPointToScreen(show, this.showDate); - Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); - int x = show.x; - int y = show.y; - if (x < 0) { - x = 0; - } - - if (x > size.width - 295) { - x = size.width - 295; - } - - if (y >= size.height - 170) { - y -= 188; - } - - this.pop = PopupFactory.getSharedInstance().getPopup(owner, this.monthPanel, x, y); - this.pop.show(); - this.isShow = true; - } - - public static void main(String[] args) { - DateChooser dateChooser1 = getInstance("yyyy-MM-dd HH:mm"); - DateChooser dateChooser2 = getInstance("yyyy-MM-dd"); - JTextField showDate1 = new JTextField("单击选择日期"); - JLabel showDate2 = new JLabel("单击选择日期"); - dateChooser1.register(showDate1); - dateChooser2.register(showDate2); - JFrame jf = new JFrame("测试日期选择器"); - jf.add(showDate1, "North"); - jf.add(showDate2, "South"); - jf.pack(); - jf.setLocationRelativeTo((Component) null); - jf.setVisible(true); - jf.setDefaultCloseOperation(3); - } - - private class JP1 extends JPanel { - private static final long serialVersionUID = -5638853772805561174L; - JLabel yearleft; - JLabel yearright; - JLabel monthleft; - JLabel monthright; - JLabel center; - JLabel centercontainer; - - public JP1() { - super(new BorderLayout()); - this.setBackground(new Color(160, 185, 215)); - this.initJP1(); - } - - private void initJP1() { - this.yearleft = new JLabel(" <<", 0); - this.yearleft.setToolTipText("上一年"); - this.yearright = new JLabel(">> ", 0); - this.yearright.setToolTipText("下一年"); - this.yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); - this.yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); - this.monthleft = new JLabel(" <", 4); - this.monthleft.setToolTipText("上一月"); - this.monthright = new JLabel("> ", 2); - this.monthright.setToolTipText("下一月"); - this.monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); - this.monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); - this.centercontainer = new JLabel("", 0); - this.centercontainer.setLayout(new BorderLayout()); - this.center = new JLabel("", 0); - this.centercontainer.add(this.monthleft, "West"); - this.centercontainer.add(this.center, "Center"); - this.centercontainer.add(this.monthright, "East"); - this.add(this.yearleft, "West"); - this.add(this.centercontainer, "Center"); - this.add(this.yearright, "East"); - this.setPreferredSize(new Dimension(295, 25)); - this.updateDate(); - this.yearleft.addMouseListener(new MouseAdapter() { - public void mouseEntered(MouseEvent me) { - JP1.this.yearleft.setCursor(new Cursor(12)); - JP1.this.yearleft.setForeground(Color.RED); - } - - public void mouseExited(MouseEvent me) { - JP1.this.yearleft.setCursor(new Cursor(0)); - JP1.this.yearleft.setForeground(Color.BLACK); - } - - public void mousePressed(MouseEvent me) { - DateChooser.this.select.add(1, -1); - JP1.this.yearleft.setForeground(Color.WHITE); - DateChooser.this.refresh(); - } - - public void mouseReleased(MouseEvent me) { - JP1.this.yearleft.setForeground(Color.BLACK); - } - }); - this.yearright.addMouseListener(new MouseAdapter() { - public void mouseEntered(MouseEvent me) { - JP1.this.yearright.setCursor(new Cursor(12)); - JP1.this.yearright.setForeground(Color.RED); - } - - public void mouseExited(MouseEvent me) { - JP1.this.yearright.setCursor(new Cursor(0)); - JP1.this.yearright.setForeground(Color.BLACK); - } - - public void mousePressed(MouseEvent me) { - DateChooser.this.select.add(1, 1); - JP1.this.yearright.setForeground(Color.WHITE); - DateChooser.this.refresh(); - } - - public void mouseReleased(MouseEvent me) { - JP1.this.yearright.setForeground(Color.BLACK); - } - }); - this.monthleft.addMouseListener(new MouseAdapter() { - public void mouseEntered(MouseEvent me) { - JP1.this.monthleft.setCursor(new Cursor(12)); - JP1.this.monthleft.setForeground(Color.RED); - } - - public void mouseExited(MouseEvent me) { - JP1.this.monthleft.setCursor(new Cursor(0)); - JP1.this.monthleft.setForeground(Color.BLACK); - } - - public void mousePressed(MouseEvent me) { - DateChooser.this.select.add(2, -1); - JP1.this.monthleft.setForeground(Color.WHITE); - DateChooser.this.refresh(); - } - - public void mouseReleased(MouseEvent me) { - JP1.this.monthleft.setForeground(Color.BLACK); - } - }); - this.monthright.addMouseListener(new MouseAdapter() { - public void mouseEntered(MouseEvent me) { - JP1.this.monthright.setCursor(new Cursor(12)); - JP1.this.monthright.setForeground(Color.RED); - } - - public void mouseExited(MouseEvent me) { - JP1.this.monthright.setCursor(new Cursor(0)); - JP1.this.monthright.setForeground(Color.BLACK); - } - - public void mousePressed(MouseEvent me) { - DateChooser.this.select.add(2, 1); - JP1.this.monthright.setForeground(Color.WHITE); - DateChooser.this.refresh(); - } - - public void mouseReleased(MouseEvent me) { - JP1.this.monthright.setForeground(Color.BLACK); - } - }); - } - - private void updateDate() { - this.center.setText(DateChooser.this.select.get(1) + "年" + (DateChooser.this.select.get(2) + 1) + "月"); - } - } - - private class JP2 extends JPanel { - private static final long serialVersionUID = -8176264838786175724L; - - public JP2() { - this.setPreferredSize(new Dimension(295, 20)); - } - - protected void paintComponent(Graphics g) { - g.setFont(DateChooser.this.font); - g.drawString("星期日 星期一 星期二 星期三 星期四 星期五 星期六", 5, 10); - g.drawLine(0, 15, this.getWidth(), 15); - } - - private void updateDate() { - } - } - - private class JP3 extends JPanel { - private static final long serialVersionUID = 43157272447522985L; - - public JP3() { - super(new GridLayout(6, 7)); - this.setPreferredSize(new Dimension(295, 100)); - this.initJP3(); - } - - private void initJP3() { - this.updateDate(); - } - - public void updateDate() { - this.removeAll(); - DateChooser.this.lm.clear(); - Date temp = DateChooser.this.select.getTime(); - Calendar select = Calendar.getInstance(); - select.setTime(temp); - select.set(5, 1); - int index = select.get(7); - int sum = index == 1 ? 8 : index; - select.add(5, 0 - sum); - - for (int i = 0; i < 42; ++i) { - select.add(5, 1); - DateChooser.this.lm.addLabel(DateChooser.this.new MyLabel(select.get(1), select.get(2), select.get(5))); - } - - Iterator var6 = DateChooser.this.lm.getLabels().iterator(); - - while (var6.hasNext()) { - DateChooser.MyLabel my = (DateChooser.MyLabel) var6.next(); - this.add(my); - } - - select.setTime(temp); - } - } - - private class JP4 extends JPanel { - private static final long serialVersionUID = -6391305687575714469L; - - public JP4() { - super(new BorderLayout()); - this.setPreferredSize(new Dimension(295, 20)); - this.setBackground(new Color(160, 185, 215)); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); - final JLabel jl = new JLabel("今天: " + sdf.format(new Date())); - jl.setToolTipText("点击选择今天日期"); - this.add(jl, "Center"); - jl.addMouseListener(new MouseAdapter() { - public void mouseEntered(MouseEvent me) { - jl.setCursor(new Cursor(12)); - jl.setForeground(Color.RED); - } - - public void mouseExited(MouseEvent me) { - jl.setCursor(new Cursor(0)); - jl.setForeground(Color.BLACK); - } - - public void mousePressed(MouseEvent me) { - jl.setForeground(Color.WHITE); - DateChooser.this.select.setTime(new Date()); - DateChooser.this.refresh(); - DateChooser.this.commit(); - } - - public void mouseReleased(MouseEvent me) { - jl.setForeground(Color.BLACK); - } - }); - } - - private void updateDate() { - } - } - - private class LabelManager { - private List list = new ArrayList(); - - public LabelManager() { - } - - public List getLabels() { - return this.list; - } - - public void addLabel(DateChooser.MyLabel my) { - this.list.add(my); - } - - public void clear() { - this.list.clear(); - } - - public void setSelect(DateChooser.MyLabel my, boolean b) { - Iterator var4 = this.list.iterator(); - - while (var4.hasNext()) { - DateChooser.MyLabel m = (DateChooser.MyLabel) var4.next(); - if (m.equals(my)) { - m.setSelected(true, b); - } else { - m.setSelected(false, b); - } - } - - } - - public void setSelect(Point p, boolean b) { - if (b) { - boolean findPrevious = false; - boolean findNext = false; - Iterator var6 = this.list.iterator(); - - while (var6.hasNext()) { - DateChooser.MyLabel mx = (DateChooser.MyLabel) var6.next(); - if (mx.contains(p)) { - findNext = true; - if (mx.getIsSelected()) { - findPrevious = true; - } else { - mx.setSelected(true, b); - } - } else if (mx.getIsSelected()) { - findPrevious = true; - mx.setSelected(false, b); - } - - if (findPrevious && findNext) { - return; - } - } - } else { - DateChooser.MyLabel temp = null; - Iterator var9 = this.list.iterator(); - - while (var9.hasNext()) { - DateChooser.MyLabel m = (DateChooser.MyLabel) var9.next(); - if (m.contains(p)) { - temp = m; - } else if (m.getIsSelected()) { - m.setSelected(false, b); - } - } - - if (temp != null) { - temp.setSelected(true, b); - } - } - - } - } - - private class MyLabel extends JLabel - implements Comparator, MouseListener, MouseMotionListener { - private static final long serialVersionUID = 3668734399227577214L; - private int year; - private int month; - private int day; - private boolean isSelected; - - public MyLabel(int year, int month, int day) { - super("" + day, 0); - this.year = year; - this.day = day; - this.month = month; - this.addMouseListener(this); - this.addMouseMotionListener(this); - this.setFont(DateChooser.this.font); - if (month == DateChooser.this.select.get(2)) { - this.setForeground(Color.BLACK); - } else { - this.setForeground(Color.LIGHT_GRAY); - } - - if (day == DateChooser.this.select.get(5)) { - this.setBackground(new Color(160, 185, 215)); - } else { - this.setBackground(Color.WHITE); - } - - } - - public boolean getIsSelected() { - return this.isSelected; - } - - public void setSelected(boolean b, boolean isDrag) { - this.isSelected = b; - if (b && !isDrag) { - int temp = DateChooser.this.select.get(2); - DateChooser.this.select.set(this.year, this.month, this.day); - if (temp == this.month) { - SwingUtilities.updateComponentTreeUI(DateChooser.this.jp3); - } else { - DateChooser.this.refresh(); - } - } - - this.repaint(); - } - - protected void paintComponent(Graphics g) { - if (this.day == DateChooser.this.select.get(5) && this.month == DateChooser.this.select.get(2)) { - g.setColor(new Color(160, 185, 215)); - g.fillRect(0, 0, this.getWidth(), this.getHeight()); - } - - if (this.year == DateChooser.this.now.get(1) && this.month == DateChooser.this.now.get(2) - && this.day == DateChooser.this.now.get(5)) { - Graphics2D gdx = (Graphics2D) g; - gdx.setColor(Color.RED); - Polygon p = new Polygon(); - p.addPoint(0, 0); - p.addPoint(this.getWidth() - 1, 0); - p.addPoint(this.getWidth() - 1, this.getHeight() - 1); - p.addPoint(0, this.getHeight() - 1); - gdx.drawPolygon(p); - } - - if (this.isSelected) { - Stroke s = new BasicStroke(1.0F, 2, 2, 1.0F, new float[] { 2.0F, 2.0F }, 1.0F); - Graphics2D gd = (Graphics2D) g; - gd.setStroke(s); - gd.setColor(Color.BLACK); - Polygon px = new Polygon(); - px.addPoint(0, 0); - px.addPoint(this.getWidth() - 1, 0); - px.addPoint(this.getWidth() - 1, this.getHeight() - 1); - px.addPoint(0, this.getHeight() - 1); - gd.drawPolygon(px); - } - - super.paintComponent(g); - } - - public boolean contains(Point p) { - return this.getBounds().contains(p); - } - - private void update() { - this.repaint(); - } - - public void mouseClicked(MouseEvent e) { - } - - public void mousePressed(MouseEvent e) { - this.isSelected = true; - this.update(); - } - - public void mouseReleased(MouseEvent e) { - Point p = SwingUtilities.convertPoint(this, e.getPoint(), DateChooser.this.jp3); - DateChooser.this.lm.setSelect(p, false); - DateChooser.this.commit(); - } - - public void mouseEntered(MouseEvent e) { - } - - public void mouseExited(MouseEvent e) { - } - - public void mouseDragged(MouseEvent e) { - Point p = SwingUtilities.convertPoint(this, e.getPoint(), DateChooser.this.jp3); - DateChooser.this.lm.setSelect(p, true); - } - - public void mouseMoved(MouseEvent e) { - } - - public int compare(DateChooser.MyLabel o1, DateChooser.MyLabel o2) { - Calendar c1 = Calendar.getInstance(); - c1.set(o1.year, o2.month, o1.day); - Calendar c2 = Calendar.getInstance(); - c2.set(o2.year, o2.month, o2.day); - return c1.compareTo(c2); - } - } + private static final long serialVersionUID = 4529266044762990227L; + private Date initDate; + private Calendar now; + private Calendar select; + private JPanel monthPanel; + private DateChooser.JP1 jp1; + private DateChooser.JP2 jp2; + private DateChooser.JP3 jp3; + private DateChooser.JP4 jp4; + private Font font; + private final DateChooser.LabelManager lm; + private SimpleDateFormat sdf; + private boolean isShow; + private Popup pop; + private JComponent showDate; + + public static DateChooser getInstance() { + return new DateChooser(); + } + + public static DateChooser getInstance(Date date) { + return new DateChooser(date); + } + + public static DateChooser getInstance(String format) { + return new DateChooser(format); + } + + public static DateChooser getInstance(Date date, String format) { + return new DateChooser(date, format); + } + + private DateChooser() { + this(new Date()); + } + + private DateChooser(Date date) { + this(date, "yyyy年MM月dd日"); + } + + private DateChooser(String format) { + this(new Date(), format); + } + + private DateChooser(Date date, String format) { + this.now = Calendar.getInstance(); + this.font = new Font("宋体", 0, 12); + this.lm = new DateChooser.LabelManager(); + this.isShow = false; + this.initDate = date; + this.sdf = new SimpleDateFormat(format); + this.select = Calendar.getInstance(); + this.select.setTime(this.initDate); + this.initPanel(); + } + + public void setEnabled(boolean b) { + super.setEnabled(b); + this.showDate.setEnabled(b); + } + + public Date getDate() { + return this.select.getTime(); + } + + public String getStrDate() { + return this.sdf.format(this.select.getTime()); + } + + public String getStrDate(String format) { + this.sdf = new SimpleDateFormat(format); + return this.sdf.format(this.select.getTime()); + } + + private void initPanel() { + this.monthPanel = new JPanel(new BorderLayout()); + this.monthPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE)); + JPanel up = new JPanel(new BorderLayout()); + up.add(this.jp1 = new DateChooser.JP1(), "North"); + up.add(this.jp2 = new DateChooser.JP2(), "Center"); + this.monthPanel.add(this.jp3 = new DateChooser.JP3(), "Center"); + this.monthPanel.add(up, "North"); + this.monthPanel.add(this.jp4 = new DateChooser.JP4(), "South"); + this.addAncestorListener(new AncestorListener() { + public void ancestorAdded(AncestorEvent event) { + } + + public void ancestorRemoved(AncestorEvent event) { + } + + public void ancestorMoved(AncestorEvent event) { + DateChooser.this.hidePanel(); + } + }); + } + + public void register(final JComponent showDate) { + this.showDate = showDate; + showDate.setRequestFocusEnabled(true); + showDate.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + showDate.requestFocusInWindow(); + } + }); + this.setBackground(Color.WHITE); + this.add(showDate, "Center"); + this.setPreferredSize(new Dimension(90, 25)); + this.setBorder(BorderFactory.createLineBorder(Color.GRAY)); + showDate.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + if (showDate.isEnabled()) { + showDate.setCursor(new Cursor(12)); + showDate.setForeground(Color.RED); + } + + } + + public void mouseExited(MouseEvent me) { + if (showDate.isEnabled()) { + showDate.setCursor(new Cursor(0)); + showDate.setForeground(Color.BLACK); + } + + } + + public void mousePressed(MouseEvent me) { + if (showDate.isEnabled()) { + showDate.setForeground(Color.CYAN); + if (DateChooser.this.isShow) { + DateChooser.this.hidePanel(); + } else { + DateChooser.this.showPanel(showDate); + } + } + + } + + public void mouseReleased(MouseEvent me) { + if (showDate.isEnabled()) { + showDate.setForeground(Color.BLACK); + } + + } + }); + showDate.addFocusListener(new FocusListener() { + public void focusLost(FocusEvent e) { + DateChooser.this.hidePanel(); + } + + public void focusGained(FocusEvent e) { + } + }); + } + + private void refresh() { + this.jp1.updateDate(); + this.jp2.updateDate(); + this.jp3.updateDate(); + this.jp4.updateDate(); + SwingUtilities.updateComponentTreeUI(this); + } + + private void commit() { + if (this.showDate instanceof JTextField) { + ((JTextField) this.showDate).setText(this.sdf.format(this.select.getTime())); + } else if (this.showDate instanceof JLabel) { + ((JLabel) this.showDate).setText(this.sdf.format(this.select.getTime())); + } + + this.hidePanel(); + } + + private void hidePanel() { + if (this.pop != null) { + this.isShow = false; + this.pop.hide(); + this.pop = null; + } + + } + + private void showPanel(Component owner) { + if (this.pop != null) { + this.pop.hide(); + } + + Point show = new Point(0, this.showDate.getHeight()); + SwingUtilities.convertPointToScreen(show, this.showDate); + Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); + int x = show.x; + int y = show.y; + if (x < 0) { + x = 0; + } + + if (x > size.width - 295) { + x = size.width - 295; + } + + if (y >= size.height - 170) { + y -= 188; + } + + this.pop = PopupFactory.getSharedInstance().getPopup(owner, this.monthPanel, x, y); + this.pop.show(); + this.isShow = true; + } + + public static void main(String[] args) { + DateChooser dateChooser1 = getInstance("yyyy-MM-dd HH:mm"); + DateChooser dateChooser2 = getInstance("yyyy-MM-dd"); + JTextField showDate1 = new JTextField("单击选择日期"); + JLabel showDate2 = new JLabel("单击选择日期"); + dateChooser1.register(showDate1); + dateChooser2.register(showDate2); + JFrame jf = new JFrame("测试日期选择器"); + jf.add(showDate1, "North"); + jf.add(showDate2, "South"); + jf.pack(); + jf.setLocationRelativeTo((Component) null); + jf.setVisible(true); + jf.setDefaultCloseOperation(3); + } + + private class JP1 extends JPanel { + private static final long serialVersionUID = -5638853772805561174L; + JLabel yearleft; + JLabel yearright; + JLabel monthleft; + JLabel monthright; + JLabel center; + JLabel centercontainer; + + public JP1() { + super(new BorderLayout()); + this.setBackground(new Color(160, 185, 215)); + this.initJP1(); + } + + private void initJP1() { + this.yearleft = new JLabel(" <<", 0); + this.yearleft.setToolTipText("上一年"); + this.yearright = new JLabel(">> ", 0); + this.yearright.setToolTipText("下一年"); + this.yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + this.yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + this.monthleft = new JLabel(" <", 4); + this.monthleft.setToolTipText("上一月"); + this.monthright = new JLabel("> ", 2); + this.monthright.setToolTipText("下一月"); + this.monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); + this.monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); + this.centercontainer = new JLabel("", 0); + this.centercontainer.setLayout(new BorderLayout()); + this.center = new JLabel("", 0); + this.centercontainer.add(this.monthleft, "West"); + this.centercontainer.add(this.center, "Center"); + this.centercontainer.add(this.monthright, "East"); + this.add(this.yearleft, "West"); + this.add(this.centercontainer, "Center"); + this.add(this.yearright, "East"); + this.setPreferredSize(new Dimension(295, 25)); + this.updateDate(); + this.yearleft.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + JP1.this.yearleft.setCursor(new Cursor(12)); + JP1.this.yearleft.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + JP1.this.yearleft.setCursor(new Cursor(0)); + JP1.this.yearleft.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + DateChooser.this.select.add(1, -1); + JP1.this.yearleft.setForeground(Color.WHITE); + DateChooser.this.refresh(); + } + + public void mouseReleased(MouseEvent me) { + JP1.this.yearleft.setForeground(Color.BLACK); + } + }); + this.yearright.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + JP1.this.yearright.setCursor(new Cursor(12)); + JP1.this.yearright.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + JP1.this.yearright.setCursor(new Cursor(0)); + JP1.this.yearright.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + DateChooser.this.select.add(1, 1); + JP1.this.yearright.setForeground(Color.WHITE); + DateChooser.this.refresh(); + } + + public void mouseReleased(MouseEvent me) { + JP1.this.yearright.setForeground(Color.BLACK); + } + }); + this.monthleft.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + JP1.this.monthleft.setCursor(new Cursor(12)); + JP1.this.monthleft.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + JP1.this.monthleft.setCursor(new Cursor(0)); + JP1.this.monthleft.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + DateChooser.this.select.add(2, -1); + JP1.this.monthleft.setForeground(Color.WHITE); + DateChooser.this.refresh(); + } + + public void mouseReleased(MouseEvent me) { + JP1.this.monthleft.setForeground(Color.BLACK); + } + }); + this.monthright.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + JP1.this.monthright.setCursor(new Cursor(12)); + JP1.this.monthright.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + JP1.this.monthright.setCursor(new Cursor(0)); + JP1.this.monthright.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + DateChooser.this.select.add(2, 1); + JP1.this.monthright.setForeground(Color.WHITE); + DateChooser.this.refresh(); + } + + public void mouseReleased(MouseEvent me) { + JP1.this.monthright.setForeground(Color.BLACK); + } + }); + } + + private void updateDate() { + this.center.setText(DateChooser.this.select.get(1) + "年" + (DateChooser.this.select.get(2) + 1) + "月"); + } + } + + private class JP2 extends JPanel { + private static final long serialVersionUID = -8176264838786175724L; + + public JP2() { + this.setPreferredSize(new Dimension(295, 20)); + } + + protected void paintComponent(Graphics g) { + g.setFont(DateChooser.this.font); + g.drawString("星期日 星期一 星期二 星期三 星期四 星期五 星期六", 5, 10); + g.drawLine(0, 15, this.getWidth(), 15); + } + + private void updateDate() { + } + } + + private class JP3 extends JPanel { + private static final long serialVersionUID = 43157272447522985L; + + public JP3() { + super(new GridLayout(6, 7)); + this.setPreferredSize(new Dimension(295, 100)); + this.initJP3(); + } + + private void initJP3() { + this.updateDate(); + } + + public void updateDate() { + this.removeAll(); + DateChooser.this.lm.clear(); + Date temp = DateChooser.this.select.getTime(); + Calendar select = Calendar.getInstance(); + select.setTime(temp); + select.set(5, 1); + int index = select.get(7); + int sum = index == 1 ? 8 : index; + select.add(5, 0 - sum); + + for (int i = 0; i < 42; ++i) { + select.add(5, 1); + DateChooser.this.lm.addLabel(DateChooser.this.new MyLabel(select.get(1), select.get(2), select.get(5))); + } + + Iterator var6 = DateChooser.this.lm.getLabels().iterator(); + + while (var6.hasNext()) { + DateChooser.MyLabel my = (DateChooser.MyLabel) var6.next(); + this.add(my); + } + + select.setTime(temp); + } + } + + private class JP4 extends JPanel { + private static final long serialVersionUID = -6391305687575714469L; + + public JP4() { + super(new BorderLayout()); + this.setPreferredSize(new Dimension(295, 20)); + this.setBackground(new Color(160, 185, 215)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); + final JLabel jl = new JLabel("今天: " + sdf.format(new Date())); + jl.setToolTipText("点击选择今天日期"); + this.add(jl, "Center"); + jl.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + jl.setCursor(new Cursor(12)); + jl.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + jl.setCursor(new Cursor(0)); + jl.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + jl.setForeground(Color.WHITE); + DateChooser.this.select.setTime(new Date()); + DateChooser.this.refresh(); + DateChooser.this.commit(); + } + + public void mouseReleased(MouseEvent me) { + jl.setForeground(Color.BLACK); + } + }); + } + + private void updateDate() { + } + } + + private class LabelManager { + private List list = new ArrayList(); + + public LabelManager() { + } + + public List getLabels() { + return this.list; + } + + public void addLabel(DateChooser.MyLabel my) { + this.list.add(my); + } + + public void clear() { + this.list.clear(); + } + + public void setSelect(DateChooser.MyLabel my, boolean b) { + Iterator var4 = this.list.iterator(); + + while (var4.hasNext()) { + DateChooser.MyLabel m = (DateChooser.MyLabel) var4.next(); + if (m.equals(my)) { + m.setSelected(true, b); + } else { + m.setSelected(false, b); + } + } + + } + + public void setSelect(Point p, boolean b) { + if (b) { + boolean findPrevious = false; + boolean findNext = false; + Iterator var6 = this.list.iterator(); + + while (var6.hasNext()) { + DateChooser.MyLabel mx = (DateChooser.MyLabel) var6.next(); + if (mx.contains(p)) { + findNext = true; + if (mx.getIsSelected()) { + findPrevious = true; + } else { + mx.setSelected(true, b); + } + } else if (mx.getIsSelected()) { + findPrevious = true; + mx.setSelected(false, b); + } + + if (findPrevious && findNext) { + return; + } + } + } else { + DateChooser.MyLabel temp = null; + Iterator var9 = this.list.iterator(); + + while (var9.hasNext()) { + DateChooser.MyLabel m = (DateChooser.MyLabel) var9.next(); + if (m.contains(p)) { + temp = m; + } else if (m.getIsSelected()) { + m.setSelected(false, b); + } + } + + if (temp != null) { + temp.setSelected(true, b); + } + } + + } + } + + private class MyLabel extends JLabel + implements Comparator, MouseListener, MouseMotionListener { + private static final long serialVersionUID = 3668734399227577214L; + private int year; + private int month; + private int day; + private boolean isSelected; + + public MyLabel(int year, int month, int day) { + super("" + day, 0); + this.year = year; + this.day = day; + this.month = month; + this.addMouseListener(this); + this.addMouseMotionListener(this); + this.setFont(DateChooser.this.font); + if (month == DateChooser.this.select.get(2)) { + this.setForeground(Color.BLACK); + } else { + this.setForeground(Color.LIGHT_GRAY); + } + + if (day == DateChooser.this.select.get(5)) { + this.setBackground(new Color(160, 185, 215)); + } else { + this.setBackground(Color.WHITE); + } + + } + + public boolean getIsSelected() { + return this.isSelected; + } + + public void setSelected(boolean b, boolean isDrag) { + this.isSelected = b; + if (b && !isDrag) { + int temp = DateChooser.this.select.get(2); + DateChooser.this.select.set(this.year, this.month, this.day); + if (temp == this.month) { + SwingUtilities.updateComponentTreeUI(DateChooser.this.jp3); + } else { + DateChooser.this.refresh(); + } + } + + this.repaint(); + } + + protected void paintComponent(Graphics g) { + if (this.day == DateChooser.this.select.get(5) && this.month == DateChooser.this.select.get(2)) { + g.setColor(new Color(160, 185, 215)); + g.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + if (this.year == DateChooser.this.now.get(1) && this.month == DateChooser.this.now.get(2) + && this.day == DateChooser.this.now.get(5)) { + Graphics2D gdx = (Graphics2D) g; + gdx.setColor(Color.RED); + Polygon p = new Polygon(); + p.addPoint(0, 0); + p.addPoint(this.getWidth() - 1, 0); + p.addPoint(this.getWidth() - 1, this.getHeight() - 1); + p.addPoint(0, this.getHeight() - 1); + gdx.drawPolygon(p); + } + + if (this.isSelected) { + Stroke s = new BasicStroke(1.0F, 2, 2, 1.0F, new float[] { 2.0F, 2.0F }, 1.0F); + Graphics2D gd = (Graphics2D) g; + gd.setStroke(s); + gd.setColor(Color.BLACK); + Polygon px = new Polygon(); + px.addPoint(0, 0); + px.addPoint(this.getWidth() - 1, 0); + px.addPoint(this.getWidth() - 1, this.getHeight() - 1); + px.addPoint(0, this.getHeight() - 1); + gd.drawPolygon(px); + } + + super.paintComponent(g); + } + + public boolean contains(Point p) { + return this.getBounds().contains(p); + } + + private void update() { + this.repaint(); + } + + public void mouseClicked(MouseEvent e) { + } + + public void mousePressed(MouseEvent e) { + this.isSelected = true; + this.update(); + } + + public void mouseReleased(MouseEvent e) { + Point p = SwingUtilities.convertPoint(this, e.getPoint(), DateChooser.this.jp3); + DateChooser.this.lm.setSelect(p, false); + DateChooser.this.commit(); + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mouseDragged(MouseEvent e) { + Point p = SwingUtilities.convertPoint(this, e.getPoint(), DateChooser.this.jp3); + DateChooser.this.lm.setSelect(p, true); + } + + public void mouseMoved(MouseEvent e) { + } + + public int compare(DateChooser.MyLabel o1, DateChooser.MyLabel o2) { + Calendar c1 = Calendar.getInstance(); + c1.set(o1.year, o2.month, o1.day); + Calendar c2 = Calendar.getInstance(); + c2.set(o2.year, o2.month, o2.day); + return c1.compareTo(c2); + } + } } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/NewJFrame.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/NewJFrame.java index 65cce37..bada305 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/NewJFrame.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/NewJFrame.java @@ -40,24 +40,25 @@ import com.teamcenter.rac.util.MessageBox; */ public class NewJFrame extends javax.swing.JFrame { + private TCSession session; + private Connection conn; + private TCComponent f; + private JFrame frame; - private TCSession session; - private Connection conn; - private TCComponent f; - private JFrame frame; /** * Creates new form NewJFrame - * @param session + * + * @param session */ - public NewJFrame(TCSession session,TCComponent f) { - String[] prefs = session.getPreferenceService().getStringValues("database_tc"); - System.out.println("===============开始连接tc数据库==============="); - long time31 = System.nanoTime(); - conn = SqlUtil.getTCDataConnection(prefs); - long time32 = System.nanoTime(); - System.out.println("===============连接tc数据库用时(ms): " + ((time32 - time31) / 1000000L)+"==============="); - this.session = session; - this.f = f; + public NewJFrame(TCSession session, TCComponent f) { + String[] prefs = session.getPreferenceService().getStringValues("database_tc"); + System.out.println("===============开始连接tc数据库==============="); + long time31 = System.nanoTime(); + conn = SqlUtil.getTCDataConnection(prefs); + long time32 = System.nanoTime(); + System.out.println("===============连接tc数据库用时(ms): " + ((time32 - time31) / 1000000L) + "==============="); + this.session = session; + this.f = f; initComponents(); frame = this; } @@ -68,7 +69,7 @@ public class NewJFrame extends javax.swing.JFrame { * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") - // + // private void initComponents() { jScrollPane2 = new javax.swing.JScrollPane(); @@ -109,21 +110,15 @@ public class NewJFrame extends javax.swing.JFrame { jScrollPane3 = new javax.swing.JScrollPane(); jTable2 = new javax.swing.JTable(); - jTable1.setModel(new javax.swing.table.DefaultTableModel( - new Object [][] { - {null, null, null, null}, - {null, null, null, null}, - {null, null, null, null}, - {null, null, null, null} - }, - new String [] { - "Title 1", "Title 2", "Title 3", "Title 4" - } - )); + jTable1.setModel( + new javax.swing.table.DefaultTableModel( + new Object[][] { { null, null, null, null }, { null, null, null, null }, + { null, null, null, null }, { null, null, null, null } }, + new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); jScrollPane2.setViewportView(jTable1); - + setBackground(new java.awt.Color(255, 255, 255)); - // this.setBackground(new java.awt.Color(255, 255, 255)); + // this.setBackground(new java.awt.Color(255, 255, 255)); jPanel1.setBackground(new java.awt.Color(255, 255, 255)); jPanel1.setBorder(new TitledBorder(new EtchedBorder())); jLabel2.setText("项目名称"); @@ -178,99 +173,96 @@ public class NewJFrame extends javax.swing.JFrame { jButton2.setText("查询"); jButton2.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent actionEvent) { - - - if (conn == null) { - System.out.println("连接TC数据库失败"); - // MessageBox.post(MaterialNoDialog.this, "连接TC数据库失败", "", MessageBox.ERROR); - return; - } - String sql = "select * from \"CHINT_ QUOTATION_TITLE_TEMPLATE\" where 1=1 "; - if(jTextField1.getText()!=null && !"".equals(jTextField1.getText().trim())) { - sql += "and \"proname\" = \'" + jTextField1.getText() +"\'"; - } - if(jTextField2.getText()!=null && !"".equals(jTextField2.getText().trim())) { - sql += "and \"promanager\" = \'" + jTextField2.getText() +"\'"; - } - if(jTextField3.getText()!=null && !"".equals(jTextField3.getText().trim())) { - sql += "and \"tramodel\" = \'" + jTextField3.getText() +"\'"; - } - if(jTextField4.getText()!=null && !"".equals(jTextField4.getText().trim())) { - sql += "and \"noloadloss\" = \'" + jTextField4.getText() +"\'"; - } - if(jTextField5.getText()!=null && !"".equals(jTextField5.getText().trim())) { - sql += "and \"loadloss\" = \'" + jTextField5.getText() +"\'"; - } - if(jTextField13.getText()!=null && !"".equals(jTextField13.getText().trim())) { - sql += "and \"tennumber\" = \'" + jTextField13.getText() +"\'"; - } - if(jTextField8.getText()!=null && !"".equals(jTextField8.getText().trim())) { - sql += "and \"impvoltage\" = \'" + jTextField8.getText() +"\'"; - } - if(jTextField7.getText()!=null && !"".equals(jTextField7.getText().trim())) { - sql += "and \"volratio\" = \'" + jTextField7.getText() +"\'"; - } - if(jTextField9.getText()!=null && !"".equals(jTextField9.getText().trim())) { - sql += "and \"traweight\" = \'" + jTextField9.getText() +"\'"; - } - if(jTextField10.getText()!=null && !"".equals(jTextField10.getText().trim())) { - sql += "and \"quantity\" = \'" + jTextField10.getText() +"\'"; - } - if(jTextField11.getText()!=null && !"".equals(jTextField11.getText().trim())) { - sql += "and \"totweight\" = \'" + jTextField11.getText() +"\'"; - } - if(jTextField14.getText()!=null && !"".equals(jTextField14.getText().trim())) { - sql += "and \"rectime\" = \'" + jTextField14.getText() +"\'"; - } - System.out.println("sql:"+sql); - PreparedStatement statement; - try { - statement = conn.prepareStatement(sql); - ResultSet res = statement.executeQuery(); - List quotations = new ArrayList(); - if(!res.next()) { - MessageBox.post("未查询到匹配的数据", "提示", MessageBox.INFORMATION); - return; - } - while (res.next()) { - Quotation quotation = new Quotation( - res.getString("technical") != null ? res.getString("technical") : "", - res.getString("factory") != null ? res.getString("factory") : "", - res.getString("proname") != null ? res.getString("proname") : "", - res.getString("tennumber") != null ? res.getString("tennumber") : "", - res.getString("promanager") != null ? res.getString("promanager") : "", - res.getString("quantity") != null ? res.getString("quantity") : "", - res.getString("tramodel") != null ? res.getString("tramodel") : "", - res.getString("capfactor") != null ? res.getString("capfactor") : "", - res.getString("volratio") != null ? res.getString("volratio") : "", - res.getString("noloadloss") != null ? res.getString("noloadloss") : "", - res.getString("loadloss") != null ? res.getString("loadloss") : "", - res.getString("impvoltage") != null ? res.getString("impvoltage") : "", - res.getString("traweight") != null ? res.getString("traweight") : "", - res.getString("totweight") != null ? res.getString("totweight") : "", - res.getString("copconsumption") != null ? res.getString("copconsumption") : "", - res.getString("cmarketprice") != null ? res.getString("cmarketprice") : "", - res.getString("vollevel") != null ? res.getString("vollevel") : "", - res.getString("rectime") != null ? res.getString("rectime") : "", - res.getString("state") != null ? res.getString("state") : "" - ); - quotations.add(quotation); - } - //将数据插入到表格 - String[] title = new String [] { "序号", "投标编号", "技术评审表", "创建报价成本单","状态"}; + @Override + public void actionPerformed(ActionEvent actionEvent) { + + if (conn == null) { + System.out.println("连接TC数据库失败"); + // MessageBox.post(MaterialNoDialog.this, "连接TC数据库失败", "", MessageBox.ERROR); + return; + } + String sql = "select * from \"CHINT_ QUOTATION_TITLE_TEMPLATE\" where 1=1 "; + if (jTextField1.getText() != null && !"".equals(jTextField1.getText().trim())) { + sql += "and \"proname\" = \'" + jTextField1.getText() + "\'"; + } + if (jTextField2.getText() != null && !"".equals(jTextField2.getText().trim())) { + sql += "and \"promanager\" = \'" + jTextField2.getText() + "\'"; + } + if (jTextField3.getText() != null && !"".equals(jTextField3.getText().trim())) { + sql += "and \"tramodel\" = \'" + jTextField3.getText() + "\'"; + } + if (jTextField4.getText() != null && !"".equals(jTextField4.getText().trim())) { + sql += "and \"noloadloss\" = \'" + jTextField4.getText() + "\'"; + } + if (jTextField5.getText() != null && !"".equals(jTextField5.getText().trim())) { + sql += "and \"loadloss\" = \'" + jTextField5.getText() + "\'"; + } + if (jTextField13.getText() != null && !"".equals(jTextField13.getText().trim())) { + sql += "and \"tennumber\" = \'" + jTextField13.getText() + "\'"; + } + if (jTextField8.getText() != null && !"".equals(jTextField8.getText().trim())) { + sql += "and \"impvoltage\" = \'" + jTextField8.getText() + "\'"; + } + if (jTextField7.getText() != null && !"".equals(jTextField7.getText().trim())) { + sql += "and \"volratio\" = \'" + jTextField7.getText() + "\'"; + } + if (jTextField9.getText() != null && !"".equals(jTextField9.getText().trim())) { + sql += "and \"traweight\" = \'" + jTextField9.getText() + "\'"; + } + if (jTextField10.getText() != null && !"".equals(jTextField10.getText().trim())) { + sql += "and \"quantity\" = \'" + jTextField10.getText() + "\'"; + } + if (jTextField11.getText() != null && !"".equals(jTextField11.getText().trim())) { + sql += "and \"totweight\" = \'" + jTextField11.getText() + "\'"; + } + if (jTextField14.getText() != null && !"".equals(jTextField14.getText().trim())) { + sql += "and \"rectime\" = \'" + jTextField14.getText() + "\'"; + } + System.out.println("sql:" + sql); + PreparedStatement statement; + try { + statement = conn.prepareStatement(sql); + ResultSet res = statement.executeQuery(); + List quotations = new ArrayList(); + while (res.next()) { + Quotation quotation = new Quotation( + res.getString("technical") != null ? res.getString("technical") : "", + res.getString("factory") != null ? res.getString("factory") : "", + res.getString("proname") != null ? res.getString("proname") : "", + res.getString("tennumber") != null ? res.getString("tennumber") : "", + res.getString("promanager") != null ? res.getString("promanager") : "", + res.getString("quantity") != null ? res.getString("quantity") : "", + res.getString("tramodel") != null ? res.getString("tramodel") : "", + res.getString("capfactor") != null ? res.getString("capfactor") : "", + res.getString("volratio") != null ? res.getString("volratio") : "", + res.getString("noloadloss") != null ? res.getString("noloadloss") : "", + res.getString("loadloss") != null ? res.getString("loadloss") : "", + res.getString("impvoltage") != null ? res.getString("impvoltage") : "", + res.getString("traweight") != null ? res.getString("traweight") : "", + res.getString("totweight") != null ? res.getString("totweight") : "", + res.getString("copconsumption") != null ? res.getString("copconsumption") : "", + res.getString("cmarketprice") != null ? res.getString("cmarketprice") : "", + res.getString("vollevel") != null ? res.getString("vollevel") : "", + res.getString("rectime") != null ? res.getString("rectime") : "", + res.getString("state") != null ? res.getString("state") : ""); + quotations.add(quotation); + } + if (quotations.size() == 0) { + MessageBox.post("未查询到匹配的数据", "提示", MessageBox.INFORMATION); + return; + } + // 将数据插入到表格 + String[] title = new String[] { "序号", "投标编号", "技术评审表", "创建报价成本单", "状态" }; // DefaultTableModel model = new DefaultTableModel(new Object [][] {},title); - DefaultTableModel model = new DefaultTableModel(new Object [][] {},title) { - - // 重写isCellEditable方法,禁止第一列 第二列 第五列单元格编辑 - @Override - public boolean isCellEditable(int row, int column) { - // 将第一列、第二列和第五列设置为不可编辑 - return !(column == 0 || column == 1 || column == 4); - } - }; - + DefaultTableModel model = new DefaultTableModel(new Object[][] {}, title) { + + // 重写isCellEditable方法,禁止第一列 第二列 第五列单元格编辑 + @Override + public boolean isCellEditable(int row, int column) { + // 将第一列、第二列和第五列设置为不可编辑 + return !(column == 0 || column == 1 || column == 4); + } + }; // Object[][] str = {{"数据1列1", "数据1列2", "打卡", "创建", "数据1列5"},{"数据1列1", "数据1列2", "打卡", "创建", "数据1列5"}}; // DefaultTableModel model = new DefaultTableModel(str,title) { @@ -281,34 +273,37 @@ public class NewJFrame extends javax.swing.JFrame { // return !(column == 0 || column == 1 || column == 4); // } // }; - jTable2.setModel(model); - TableColumn column_1 = jTable2.getColumn(title[0]); - column_1.setMinWidth(40); - for(int i = 0;i + }// /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + // + /* + * If Nimbus (introduced in Java SE 6) is not available, stay with the default + * look and feel. For details see + * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ // try { // for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { @@ -531,32 +555,32 @@ public class NewJFrame extends javax.swing.JFrame { // } catch (javax.swing.UnsupportedLookAndFeelException ex) { // java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); // } - // + // /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - NewJFrame newJFrame = new NewJFrame(null,null); - int width2 = newJFrame.getWidth(); - int height2 = newJFrame.getHeight(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸 - int screenWidth = screenSize.width; // 获取屏幕宽度 - int screenHeight = screenSize.height; // 获取屏幕高度 - int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标 - int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标 - newJFrame.setTitle("报价成本单查询"); + public void run() { + NewJFrame newJFrame = new NewJFrame(null, null); + int width2 = newJFrame.getWidth(); + int height2 = newJFrame.getHeight(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸 + int screenWidth = screenSize.width; // 获取屏幕宽度 + int screenHeight = screenSize.height; // 获取屏幕高度 + int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标 + int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标 + newJFrame.setTitle("报价成本单查询"); // this.getContentPane().setBackground(Color.red); - newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255)); - newJFrame.setSize(width2, height2); // 设置Frame的大小 - newJFrame.setLocation(x, y); // 设置Frame的位置 - newJFrame.setResizable(false); - newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作 - newJFrame.setVisible(true); - } - }); + newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255)); + newJFrame.setSize(width2, height2); // 设置Frame的大小 + newJFrame.setLocation(x, y); // 设置Frame的位置 + newJFrame.setResizable(false); + newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作 + newJFrame.setVisible(true); + } + }); } - // Variables declaration - do not modify + // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; @@ -594,5 +618,5 @@ public class NewJFrame extends javax.swing.JFrame { private javax.swing.JTextField jTextField7; private javax.swing.JTextField jTextField8; private javax.swing.JTextField jTextField9; - // End of variables declaration + // End of variables declaration } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/QueryQuotationFram.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/QueryQuotationFram.java index d51ed67..4d67242 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/QueryQuotationFram.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/QueryQuotationFram.java @@ -7,19 +7,20 @@ import com.teamcenter.rac.aif.AbstractAIFOperation; import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCSession; -public class QueryQuotationFram extends AbstractAIFOperation{ +public class QueryQuotationFram extends AbstractAIFOperation { - TCSession session; - private TCComponent f; - public QueryQuotationFram(TCSession session, TCComponent component2) { - this.f = component2; - this.session = session; - // TODO Auto-generated constructor stub - } + TCSession session; + private TCComponent f; - @Override - public void executeOperation() throws Exception { - // TODO Auto-generated method stub + public QueryQuotationFram(TCSession session, TCComponent component2) { + this.f = component2; + this.session = session; + // TODO Auto-generated constructor stub + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub // try { // for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { // if ("Nimbus".equals(info.getName())) { @@ -36,29 +37,29 @@ public class QueryQuotationFram extends AbstractAIFOperation{ // } catch (javax.swing.UnsupportedLookAndFeelException ex) { // java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); // } - // + // /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { - NewJFrame newJFrame = new NewJFrame(session,f); - int width2 = newJFrame.getWidth(); - int height2 = newJFrame.getHeight(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸 - int screenWidth = screenSize.width; // 获取屏幕宽度 - int screenHeight = screenSize.height; // 获取屏幕高度 - int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标 - int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标 - newJFrame.setTitle("报价成本单查询"); + NewJFrame newJFrame = new NewJFrame(session, f); + int width2 = newJFrame.getWidth(); + int height2 = newJFrame.getHeight(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸 + int screenWidth = screenSize.width; // 获取屏幕宽度 + int screenHeight = screenSize.height; // 获取屏幕高度 + int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标 + int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标 + newJFrame.setTitle("报价成本单查询"); // this.getContentPane().setBackground(Color.red); - newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255)); - newJFrame.setSize(width2, height2); // 设置Frame的大小 - newJFrame.setLocation(x, y); // 设置Frame的位置 - newJFrame.setResizable(false); - newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作 - newJFrame.setVisible(true); + newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255)); + newJFrame.setSize(width2, height2); // 设置Frame的大小 + newJFrame.setLocation(x, y); // 设置Frame的位置 + newJFrame.setResizable(false); + newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作 + newJFrame.setVisible(true); } }); - } + } } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/QuotationUtil.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/QuotationUtil.java index c1f3f1e..02eff83 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/QuotationUtil.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/QuotationUtil.java @@ -1,18 +1,18 @@ package com.connor.plm.CostListManagement; public class QuotationUtil { - - public static String formatString(String input) { + + public static String formatString(String input) { if (input == null || input.length() == 0) { return input; } - + double number = Double.parseDouble(input); if (number == (int) number) { return String.valueOf((int) number); } else { return String.format("%.3f", number).replaceAll("0*$", "").replaceAll("\\.$", ""); } - } + } } 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 716d8ed..f2d91cb 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 @@ -1,176 +1,212 @@ package com.connor.plm.CostListManagement.pojo; public class Cusquotation { - private String cbdlx; - private String projectid; - private String revision; - private String proname; - private String tennumber; - private String promanager; - private String quantity; - private String tramodel; - private String capfactor; - private String volratio; - private String noloadloss; - private String loadloss; - private String impvoltage; - private String traweight; - private String totweight; - private String copconsumption; - private String cmarketprice; - private String vollevel; - private String factory; - 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) { - super(); - this.cbdlx = cbdlx; - this.projectid = projectid; - this.revision = revision; - this.proname = proname; - this.tennumber = tennumber; - this.promanager = promanager; - this.quantity = quantity; - this.tramodel = tramodel; - this.capfactor = capfactor; - this.volratio = volratio; - this.noloadloss = noloadloss; - this.loadloss = loadloss; - this.impvoltage = impvoltage; - this.traweight = traweight; - this.totweight = totweight; - this.copconsumption = copconsumption; - this.cmarketprice = cmarketprice; - this.vollevel = vollevel; - this.factory = factory; - } - public String getCbdlx() { - return cbdlx; - } - public void setCbdlx(String cbdlx) { - this.cbdlx = cbdlx; - } - public String getProjectid() { - return projectid; - } - public void setProjectid(String projectid) { - this.projectid = projectid; - } - public String getRevision() { - return revision; - } - public void setRevision(String revision) { - this.revision = revision; - } - public String getProname() { - return proname; - } - public void setProname(String proname) { - this.proname = proname; - } - public String getTennumber() { - return tennumber; - } - public void setTennumber(String tennumber) { - this.tennumber = tennumber; - } - public String getPromanager() { - return promanager; - } - public void setPromanager(String promanager) { - this.promanager = promanager; - } - public String getQuantity() { - return quantity; - } - public void setQuantity(String quantity) { - this.quantity = quantity; - } - public String getTramodel() { - return tramodel; - } - public void setTramodel(String tramodel) { - this.tramodel = tramodel; - } - public String getCapfactor() { - return capfactor; - } - public void setCapfactor(String capfactor) { - this.capfactor = capfactor; - } - public String getVolratio() { - return volratio; - } - public void setVolratio(String volratio) { - this.volratio = volratio; - } - public String getNoloadloss() { - return noloadloss; - } - public void setNoloadloss(String noloadloss) { - this.noloadloss = noloadloss; - } - public String getLoadloss() { - return loadloss; - } - public void setLoadloss(String loadloss) { - this.loadloss = loadloss; - } - public String getImpvoltage() { - return impvoltage; - } - public void setImpvoltage(String impvoltage) { - this.impvoltage = impvoltage; - } - public String getTraweight() { - return traweight; - } - public void setTraweight(String traweight) { - this.traweight = traweight; - } - public String getTotweight() { - return totweight; - } - public void setTotweight(String totweight) { - this.totweight = totweight; - } - public String getCopconsumption() { - return copconsumption; - } - public void setCopconsumption(String copconsumption) { - this.copconsumption = copconsumption; - } - public String getCmarketprice() { - return cmarketprice; - } - public void setCmarketprice(String cmarketprice) { - this.cmarketprice = cmarketprice; - } - public String getVollevel() { - return vollevel; - } - public void setVollevel(String vollevel) { - this.vollevel = vollevel; - } - - public String getFactory() { - return factory; - } - public void setFactory(String factory) { - this.factory = factory; - } - @Override - public String toString() { - return "Cusquotation [cbdlx=" + cbdlx + ", projectid=" + projectid + ", revision=" + revision + ", proname=" - + proname + ", tennumber=" + tennumber + ", promanager=" + promanager + ", quantity=" + quantity - + ", tramodel=" + tramodel + ", capfactor=" + capfactor + ", volratio=" + volratio + ", noloadloss=" - + noloadloss + ", loadloss=" + loadloss + ", impvoltage=" + impvoltage + ", traweight=" + traweight - + ", totweight=" + totweight + ", copconsumption=" + copconsumption + ", cmarketprice=" + cmarketprice - + ", vollevel=" + vollevel + ", factory=" + factory + "]"; - } - - - + private String cbdlx; + private String projectid; + private String revision; + private String proname; + private String tennumber; + private String promanager; + private String quantity; + private String tramodel; + private String capfactor; + private String volratio; + private String noloadloss; + private String loadloss; + private String impvoltage; + private String traweight; + private String totweight; + private String copconsumption; + private String cmarketprice; + private String vollevel; + private String factory; + + 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) { + super(); + this.cbdlx = cbdlx; + this.projectid = projectid; + this.revision = revision; + this.proname = proname; + this.tennumber = tennumber; + this.promanager = promanager; + this.quantity = quantity; + this.tramodel = tramodel; + this.capfactor = capfactor; + this.volratio = volratio; + this.noloadloss = noloadloss; + this.loadloss = loadloss; + this.impvoltage = impvoltage; + this.traweight = traweight; + this.totweight = totweight; + this.copconsumption = copconsumption; + this.cmarketprice = cmarketprice; + this.vollevel = vollevel; + this.factory = factory; + } + + public String getCbdlx() { + return cbdlx; + } + + public void setCbdlx(String cbdlx) { + this.cbdlx = cbdlx; + } + + public String getProjectid() { + return projectid; + } + + public void setProjectid(String projectid) { + this.projectid = projectid; + } + + public String getRevision() { + return revision; + } + + public void setRevision(String revision) { + this.revision = revision; + } + + public String getProname() { + return proname; + } + + public void setProname(String proname) { + this.proname = proname; + } + + public String getTennumber() { + return tennumber; + } + + public void setTennumber(String tennumber) { + this.tennumber = tennumber; + } + + public String getPromanager() { + return promanager; + } + + public void setPromanager(String promanager) { + this.promanager = promanager; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getTramodel() { + return tramodel; + } + + public void setTramodel(String tramodel) { + this.tramodel = tramodel; + } + + public String getCapfactor() { + return capfactor; + } + + public void setCapfactor(String capfactor) { + this.capfactor = capfactor; + } + + public String getVolratio() { + return volratio; + } + + public void setVolratio(String volratio) { + this.volratio = volratio; + } + + public String getNoloadloss() { + return noloadloss; + } + + public void setNoloadloss(String noloadloss) { + this.noloadloss = noloadloss; + } + + public String getLoadloss() { + return loadloss; + } + + public void setLoadloss(String loadloss) { + this.loadloss = loadloss; + } + + public String getImpvoltage() { + return impvoltage; + } + + public void setImpvoltage(String impvoltage) { + this.impvoltage = impvoltage; + } + + public String getTraweight() { + return traweight; + } + + public void setTraweight(String traweight) { + this.traweight = traweight; + } + + public String getTotweight() { + return totweight; + } + + public void setTotweight(String totweight) { + this.totweight = totweight; + } + + public String getCopconsumption() { + return copconsumption; + } + + public void setCopconsumption(String copconsumption) { + this.copconsumption = copconsumption; + } + + public String getCmarketprice() { + return cmarketprice; + } + + public void setCmarketprice(String cmarketprice) { + this.cmarketprice = cmarketprice; + } + + public String getVollevel() { + return vollevel; + } + + public void setVollevel(String vollevel) { + this.vollevel = vollevel; + } + + public String getFactory() { + return factory; + } + + public void setFactory(String factory) { + this.factory = factory; + } + + @Override + public String toString() { + return "Cusquotation [cbdlx=" + cbdlx + ", projectid=" + projectid + ", revision=" + revision + ", proname=" + + proname + ", tennumber=" + tennumber + ", promanager=" + promanager + ", quantity=" + quantity + + ", tramodel=" + tramodel + ", capfactor=" + capfactor + ", volratio=" + volratio + ", noloadloss=" + + noloadloss + ", loadloss=" + loadloss + ", impvoltage=" + impvoltage + ", traweight=" + traweight + + ", totweight=" + totweight + ", copconsumption=" + copconsumption + ", cmarketprice=" + cmarketprice + + ", vollevel=" + vollevel + ", factory=" + factory + "]"; + } } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/GzxqBean.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/GzxqBean.java index 52da8ee..cb3ddf4 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/GzxqBean.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/GzxqBean.java @@ -1,232 +1,164 @@ package com.connor.plm.CostListManagement.pojo; public class GzxqBean { - private String instanceId; - private String factory; - private String sfId; - private String head; - private String scheduledtime; - private String model; - private String productname; - private String toolnumber; - private String toolname; - private String toolinglevel; - private String reason; - private String jsgyrequirements; - private String link; - private String state; + private String instanceId; + private String factory; + private String sfId; + private String head; + private String scheduledtime; + private String model; + private String productname; + private String toolnumber; + private String toolname; + private String toolinglevel; + private String reason; + private String jsgyrequirements; + private String link; + private String state; + + public GzxqBean() { + super(); + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getFactory() { + return factory; + } + + public void setFactory(String factory) { + this.factory = factory; + } + + public String getSfId() { + return sfId; + } + + public void setSfId(String sfId) { + this.sfId = sfId; + } + + public String getHead() { + return head; + } + + public void setHead(String head) { + this.head = head; + } + + public String getScheduledtime() { + return scheduledtime; + } + + public void setScheduledtime(String scheduledtime) { + this.scheduledtime = scheduledtime; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public String getProductname() { + return productname; + } + + public void setProductname(String productname) { + this.productname = productname; + } + + public String getToolnumber() { + return toolnumber; + } + + public void setToolnumber(String toolnumber) { + this.toolnumber = toolnumber; + } + + public String getToolname() { + return toolname; + } + + public void setToolname(String toolname) { + this.toolname = toolname; + } + + public String getToolinglevel() { + return toolinglevel; + } + + public void setToolinglevel(String toolinglevel) { + this.toolinglevel = toolinglevel; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public String getJsgyrequirements() { + return jsgyrequirements; + } + + public void setJsgyrequirements(String jsgyrequirements) { + this.jsgyrequirements = jsgyrequirements; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public GzxqBean(String instanceId, String factory, String sfId, String head, String scheduledtime, String model, + String productname, String toolnumber, String toolname, String toolinglevel, String reason, + String jsgyrequirements, String link, String state) { + super(); + this.instanceId = instanceId; + this.factory = factory; + this.sfId = sfId; + this.head = head; + this.scheduledtime = scheduledtime; + this.model = model; + this.productname = productname; + this.toolnumber = toolnumber; + this.toolname = toolname; + this.toolinglevel = toolinglevel; + this.reason = reason; + this.jsgyrequirements = jsgyrequirements; + this.link = link; + this.state = state; + } + + @Override + public String toString() { + return "GzxqBean [instanceId=" + instanceId + ", factory=" + factory + ", sfId=" + sfId + ", head=" + head + + ", scheduledtime=" + scheduledtime + ", model=" + model + ", productname=" + productname + + ", toolnumber=" + toolnumber + ", toolname=" + toolname + ", toolinglevel=" + toolinglevel + + ", reason=" + reason + ", jsgyrequirements=" + jsgyrequirements + ", link=" + link + ", state=" + + state + "]"; + } - - - public GzxqBean() { - super(); - } - - - - public String getInstanceId() { - return instanceId; - } - - - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - - - public String getFactory() { - return factory; - } - - - - public void setFactory(String factory) { - this.factory = factory; - } - - - - public String getSfId() { - return sfId; - } - - - - public void setSfId(String sfId) { - this.sfId = sfId; - } - - - - public String getHead() { - return head; - } - - - - public void setHead(String head) { - this.head = head; - } - - - - public String getScheduledtime() { - return scheduledtime; - } - - - - public void setScheduledtime(String scheduledtime) { - this.scheduledtime = scheduledtime; - } - - - - public String getModel() { - return model; - } - - - - public void setModel(String model) { - this.model = model; - } - - - - public String getProductname() { - return productname; - } - - - - public void setProductname(String productname) { - this.productname = productname; - } - - - - public String getToolnumber() { - return toolnumber; - } - - - - public void setToolnumber(String toolnumber) { - this.toolnumber = toolnumber; - } - - - - public String getToolname() { - return toolname; - } - - - - public void setToolname(String toolname) { - this.toolname = toolname; - } - - - - public String getToolinglevel() { - return toolinglevel; - } - - - - public void setToolinglevel(String toolinglevel) { - this.toolinglevel = toolinglevel; - } - - - - public String getReason() { - return reason; - } - - - - public void setReason(String reason) { - this.reason = reason; - } - - - - public String getJsgyrequirements() { - return jsgyrequirements; - } - - - - public void setJsgyrequirements(String jsgyrequirements) { - this.jsgyrequirements = jsgyrequirements; - } - - - - public String getLink() { - return link; - } - - - - public void setLink(String link) { - this.link = link; - } - - - - public String getState() { - return state; - } - - - - public void setState(String state) { - this.state = state; - } - - - - public GzxqBean(String instanceId, String factory, String sfId, String head, String scheduledtime, String model, - String productname, String toolnumber, String toolname, String toolinglevel, String reason, - String jsgyrequirements, String link, String state) { - super(); - this.instanceId = instanceId; - this.factory = factory; - this.sfId = sfId; - this.head = head; - this.scheduledtime = scheduledtime; - this.model = model; - this.productname = productname; - this.toolnumber = toolnumber; - this.toolname = toolname; - this.toolinglevel = toolinglevel; - this.reason = reason; - this.jsgyrequirements = jsgyrequirements; - this.link = link; - this.state = state; - } - - - - @Override - public String toString() { - return "GzxqBean [instanceId=" + instanceId + ", factory=" + factory + ", sfId=" + sfId + ", head=" + head - + ", scheduledtime=" + scheduledtime + ", model=" + model + ", productname=" + productname - + ", toolnumber=" + toolnumber + ", toolname=" + toolname + ", toolinglevel=" + toolinglevel - + ", reason=" + reason + ", jsgyrequirements=" + jsgyrequirements + ", link=" + link + ", state=" - + state + "]"; - } - - - - - - - } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/Quotation.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/Quotation.java index 7293509..065b324 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/Quotation.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/Quotation.java @@ -3,178 +3,216 @@ package com.connor.plm.CostListManagement.pojo; import com.teamcenter.soaictstubs.stringSeq_tHolder; public class Quotation { - private String technical; - private String factory; - private String proname; - private String tennumber; - private String promanager; - private String quantity; - private String tramodel; - private String capfactor; - private String volratio; - private String noloadloss; - private String loadloss; - private String impvoltage; - private String traweight; - private String totweight; - private String copconsumption; - private String cmarketprice; - private String vollevel; - private String rectime; - private String state; - - - public Quotation() { - super(); - } - public Quotation(String technical, String factory, 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 rectime, String state) { - super(); - this.technical = technical; - this.factory = factory; - this.proname = proname; - this.tennumber = tennumber; - this.promanager = promanager; - this.quantity = quantity; - this.tramodel = tramodel; - this.capfactor = capfactor; - this.volratio = volratio; - this.noloadloss = noloadloss; - this.loadloss = loadloss; - this.impvoltage = impvoltage; - this.traweight = traweight; - this.totweight = totweight; - this.copconsumption = copconsumption; - this.cmarketprice = cmarketprice; - this.vollevel = vollevel; - this.rectime = rectime; - this.state = state; - } - public String getTechnical() { - return technical; - } - public void setTechnical(String technical) { - this.technical = technical; - } - public String getFactory() { - return factory; - } - public void setFactory(String factory) { - this.factory = factory; - } - public String getProname() { - return proname; - } - public void setProname(String proname) { - this.proname = proname; - } - public String getTennumber() { - return tennumber; - } - public void setTennumber(String tennumber) { - this.tennumber = tennumber; - } - public String getPromanager() { - return promanager; - } - public void setPromanager(String promanager) { - this.promanager = promanager; - } - public String getQuantity() { - return quantity; - } - public void setQuantity(String quantity) { - this.quantity = quantity; - } - public String getTramodel() { - return tramodel; - } - public void setTramodel(String tramodel) { - this.tramodel = tramodel; - } - public String getCapfactor() { - return capfactor; - } - public void setCapfactor(String capfactor) { - this.capfactor = capfactor; - } - public String getVolratio() { - return volratio; - } - public void setVolratio(String volratio) { - this.volratio = volratio; - } - public String getNoloadloss() { - return noloadloss; - } - public void setNoloadloss(String noloadloss) { - this.noloadloss = noloadloss; - } - public String getLoadloss() { - return loadloss; - } - public void setLoadloss(String loadloss) { - this.loadloss = loadloss; - } - public String getImpvoltage() { - return impvoltage; - } - public void setImpvoltage(String impvoltage) { - this.impvoltage = impvoltage; - } - public String getTraweight() { - return traweight; - } - public void setTraweight(String traweight) { - this.traweight = traweight; - } - public String getTotweight() { - return totweight; - } - public void setTotweight(String totweight) { - this.totweight = totweight; - } - public String getCopconsumption() { - return copconsumption; - } - public void setCopconsumption(String copconsumption) { - this.copconsumption = copconsumption; - } - public String getCmarketprice() { - return cmarketprice; - } - public void setCmarketprice(String cmarketprice) { - this.cmarketprice = cmarketprice; - } - public String getVollevel() { - return vollevel; - } - public void setVollevel(String vollevel) { - this.vollevel = vollevel; - } - public String getRectime() { - return rectime; - } - public void setRectime(String rectime) { - this.rectime = rectime; - } - public String getState() { - return state; - } - public void setState(String state) { - this.state = state; - } - @Override - public String toString() { - return "Quotation [technical=" + technical + ", totalprice=" + ", factory=" + factory - + ", proname=" + proname + ", tennumber=" + tennumber + ", promanager=" + promanager + ", quantity=" - + quantity + ", tramodel=" + tramodel + ", capfactor=" + capfactor + ", volratio=" + volratio - + ", noloadloss=" + noloadloss + ", loadloss=" + loadloss + ", impvoltage=" + impvoltage - + ", traweight=" + traweight + ", totweight=" + totweight + ", copconsumption=" + copconsumption - + ", cmarketprice=" + cmarketprice + ", vollevel=" + vollevel + ", rectime=" + rectime + ", state=" - + state + "]"; - } - + private String technical; + private String factory; + private String proname; + private String tennumber; + private String promanager; + private String quantity; + private String tramodel; + private String capfactor; + private String volratio; + private String noloadloss; + private String loadloss; + private String impvoltage; + private String traweight; + private String totweight; + private String copconsumption; + private String cmarketprice; + private String vollevel; + private String rectime; + private String state; + + public Quotation() { + super(); + } + + public Quotation(String technical, String factory, 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 rectime, String state) { + super(); + this.technical = technical; + this.factory = factory; + this.proname = proname; + this.tennumber = tennumber; + this.promanager = promanager; + this.quantity = quantity; + this.tramodel = tramodel; + this.capfactor = capfactor; + this.volratio = volratio; + this.noloadloss = noloadloss; + this.loadloss = loadloss; + this.impvoltage = impvoltage; + this.traweight = traweight; + this.totweight = totweight; + this.copconsumption = copconsumption; + this.cmarketprice = cmarketprice; + this.vollevel = vollevel; + this.rectime = rectime; + this.state = state; + } + + public String getTechnical() { + return technical; + } + + public void setTechnical(String technical) { + this.technical = technical; + } + + public String getFactory() { + return factory; + } + + public void setFactory(String factory) { + this.factory = factory; + } + + public String getProname() { + return proname; + } + + public void setProname(String proname) { + this.proname = proname; + } + + public String getTennumber() { + return tennumber; + } + + public void setTennumber(String tennumber) { + this.tennumber = tennumber; + } + + public String getPromanager() { + return promanager; + } + + public void setPromanager(String promanager) { + this.promanager = promanager; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getTramodel() { + return tramodel; + } + + public void setTramodel(String tramodel) { + this.tramodel = tramodel; + } + + public String getCapfactor() { + return capfactor; + } + + public void setCapfactor(String capfactor) { + this.capfactor = capfactor; + } + + public String getVolratio() { + return volratio; + } + + public void setVolratio(String volratio) { + this.volratio = volratio; + } + + public String getNoloadloss() { + return noloadloss; + } + + public void setNoloadloss(String noloadloss) { + this.noloadloss = noloadloss; + } + + public String getLoadloss() { + return loadloss; + } + + public void setLoadloss(String loadloss) { + this.loadloss = loadloss; + } + + public String getImpvoltage() { + return impvoltage; + } + + public void setImpvoltage(String impvoltage) { + this.impvoltage = impvoltage; + } + + public String getTraweight() { + return traweight; + } + + public void setTraweight(String traweight) { + this.traweight = traweight; + } + + public String getTotweight() { + return totweight; + } + + public void setTotweight(String totweight) { + this.totweight = totweight; + } + + public String getCopconsumption() { + return copconsumption; + } + + public void setCopconsumption(String copconsumption) { + this.copconsumption = copconsumption; + } + + public String getCmarketprice() { + return cmarketprice; + } + + public void setCmarketprice(String cmarketprice) { + this.cmarketprice = cmarketprice; + } + + public String getVollevel() { + return vollevel; + } + + public void setVollevel(String vollevel) { + this.vollevel = vollevel; + } + + public String getRectime() { + return rectime; + } + + public void setRectime(String rectime) { + this.rectime = rectime; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + @Override + public String toString() { + return "Quotation [technical=" + technical + ", totalprice=" + ", factory=" + factory + ", proname=" + proname + + ", tennumber=" + tennumber + ", promanager=" + promanager + ", quantity=" + quantity + ", tramodel=" + + tramodel + ", capfactor=" + capfactor + ", volratio=" + volratio + ", noloadloss=" + noloadloss + + ", loadloss=" + loadloss + ", impvoltage=" + impvoltage + ", traweight=" + traweight + ", totweight=" + + totweight + ", copconsumption=" + copconsumption + ", cmarketprice=" + cmarketprice + ", vollevel=" + + vollevel + ", rectime=" + rectime + ", state=" + state + "]"; + } + } 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 67e64a0..af07b6a 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 @@ -4,295 +4,180 @@ import javafx.beans.property.SimpleStringProperty; import javafx.scene.control.TextField; public class QuotationMX { - private String cbdlx; - private String projectid; - private String revision; - private SimpleStringProperty matgroup; - private SimpleStringProperty mgsnumber; - private SimpleStringProperty materialNameColumn; - private SimpleStringProperty matcnumber; - private SimpleStringProperty relatedMaterialColumn; - private SimpleStringProperty specificationColumn; - private SimpleStringProperty manufacturerColumn; - private SimpleStringProperty quantityColumn; - private SimpleStringProperty utilizationRateColumn; - private SimpleStringProperty unitColumn; - private SimpleStringProperty amomoney; - private SimpleStringProperty unitPriceColumn; - private SimpleStringProperty no; - private SimpleStringProperty totalprice; - private SimpleStringProperty contrastPrice; - public QuotationMX() { - super(); - } - - public String getCbdlx() { - return cbdlx; - } + private String cbdlx; + private String projectid; + private String revision; + private SimpleStringProperty matgroup; + private SimpleStringProperty mgsnumber; + private SimpleStringProperty materialNameColumn; + private SimpleStringProperty matcnumber; + private SimpleStringProperty relatedMaterialColumn; + private SimpleStringProperty specificationColumn; + private SimpleStringProperty manufacturerColumn; + private SimpleStringProperty quantityColumn; + private SimpleStringProperty utilizationRateColumn; + private SimpleStringProperty unitColumn; + private SimpleStringProperty amomoney; + private SimpleStringProperty unitPriceColumn; + private SimpleStringProperty no; + private SimpleStringProperty totalprice; + private SimpleStringProperty contrastPrice; + + public QuotationMX() { + super(); + } + + public String getCbdlx() { + return cbdlx; + } + + public String getContrastPrice() { + return contrastPrice.get(); + } + + public void setContrastPrice(SimpleStringProperty contrastPrice) { + this.contrastPrice = contrastPrice; + } + + public void setCbdlx(String cbdlx) { + this.cbdlx = cbdlx; + } + + public String getProjectid() { + return projectid; + } + + public void setProjectid(String projectid) { + this.projectid = projectid; + } + + public String getRevision() { + return revision; + } + + public void setRevision(String revision) { + this.revision = revision; + } + + public String getMatgroup() { + return matgroup.get(); + } + + public void setMatgroup(SimpleStringProperty matgroup) { + this.matgroup = matgroup; + } + + public String getMgsnumber() { + return mgsnumber.get(); + } + + public void setMgsnumber(SimpleStringProperty mgsnumber) { + this.mgsnumber = mgsnumber; + } + + public String getMatcname() { + return materialNameColumn.get(); + } + + public void setMatcname(SimpleStringProperty matcname) { + this.materialNameColumn = matcname; + } + + public String getMatcnumber() { + return matcnumber.get(); + } + + public void setMatcnumber(SimpleStringProperty matcnumber) { + this.matcnumber = matcnumber; + } + + public String getMatcatname() { + return relatedMaterialColumn.get(); + } + + public void setMatcatname(SimpleStringProperty matcatname) { + this.relatedMaterialColumn = matcatname; + } + + public String getSpecifications() { + return specificationColumn.get(); + } + + public void setSpecifications(SimpleStringProperty specifications) { + this.specificationColumn = specifications; + } + + public String getManufacturer() { + return manufacturerColumn.get(); + } + + public void setManufacturer(SimpleStringProperty manufacturer) { + this.manufacturerColumn = manufacturer; + } + + public String getNwquantity() { + return quantityColumn.get(); + } + + public void setNwquantity(SimpleStringProperty nwquantity) { + this.quantityColumn = nwquantity; + } - public String getContrastPrice() { - return contrastPrice.get(); - } + public String getUtirate() { + return utilizationRateColumn.get(); + } + public void setUtirate(SimpleStringProperty utirate) { + this.utilizationRateColumn = utirate; + } - public void setContrastPrice(SimpleStringProperty contrastPrice) { - this.contrastPrice = contrastPrice; - } - - public void setCbdlx(String cbdlx) { - this.cbdlx = cbdlx; - } + public String getUnit() { + return unitColumn.get(); + } - public String getProjectid() { - return projectid; - } + public void setUnit(SimpleStringProperty unit) { + this.unitColumn = unit; + } - public void setProjectid(String projectid) { - this.projectid = projectid; - } + public String getAmomoney() { + return amomoney.get(); + } + public void setAmomoney(SimpleStringProperty amomoney) { + this.amomoney = amomoney; + } - public String getRevision() { - return revision; - } + public String getUnitprice() { + return unitPriceColumn.get(); + } - public void setRevision(String revision) { - this.revision = revision; - } + public void setUnitprice(SimpleStringProperty unitprice) { + this.unitPriceColumn = unitprice; + } + public String getNo() { + return no.get(); + } + public void setNo(SimpleStringProperty no) { + this.no = no; + } + public String getTotalprice() { + return totalprice.get(); + } + public void setTotalprice(SimpleStringProperty totalprice) { + this.totalprice = totalprice; + } - public String getMatgroup() { - return matgroup.get(); - } + @Override + public String toString() { + return "QuotationMX [matgroup=" + matgroup + ", mgsnumber=" + mgsnumber + ", matcname=" + materialNameColumn + + ", matcnumber=" + matcnumber + ", matcatname=" + relatedMaterialColumn + ", specifications=" + + specificationColumn + ", manufacturer=" + manufacturerColumn + ", nwquantity=" + quantityColumn + + ", utirate=" + utilizationRateColumn + ", unit=" + unitColumn + ", amomoney=" + amomoney + + ", unitprice=" + unitPriceColumn + ", no=" + no + ", totalprice=" + totalprice + "]"; + } - - public void setMatgroup(SimpleStringProperty matgroup) { - this.matgroup = matgroup; - } - - - public String getMgsnumber() { - return mgsnumber.get(); - } - - - public void setMgsnumber(SimpleStringProperty mgsnumber) { - this.mgsnumber = mgsnumber; - } - - public String getMatcname() { - return materialNameColumn.get(); - } - - public void setMatcname(SimpleStringProperty matcname) { - this.materialNameColumn = matcname; - } - - - - - - - public String getMatcnumber() { - return matcnumber.get(); - } - - public void setMatcnumber(SimpleStringProperty matcnumber) { - this.matcnumber = matcnumber; - } - - - public String getMatcatname() { - return relatedMaterialColumn.get(); - } - - - - - - - public void setMatcatname(SimpleStringProperty matcatname) { - this.relatedMaterialColumn = matcatname; - } - - - - - - - public String getSpecifications() { - return specificationColumn.get(); - } - - - - - - - public void setSpecifications(SimpleStringProperty specifications) { - this.specificationColumn = specifications; - } - - - - - - - public String getManufacturer() { - return manufacturerColumn.get(); - } - - - - - - - public void setManufacturer(SimpleStringProperty manufacturer) { - this.manufacturerColumn = manufacturer; - } - - - - - - - public String getNwquantity() { - return quantityColumn.get(); - } - - - - - - - public void setNwquantity(SimpleStringProperty nwquantity) { - this.quantityColumn = nwquantity; - } - - - - - - - public String getUtirate() { - return utilizationRateColumn.get(); - } - - - - - - - public void setUtirate(SimpleStringProperty utirate) { - this.utilizationRateColumn = utirate; - } - - - - - - - public String getUnit() { - return unitColumn.get(); - } - - - - - - - public void setUnit(SimpleStringProperty unit) { - this.unitColumn = unit; - } - - - - - - - public String getAmomoney() { - return amomoney.get(); - } - - - - - - - public void setAmomoney(SimpleStringProperty amomoney) { - this.amomoney = amomoney; - } - - - - - - - public String getUnitprice() { - return unitPriceColumn.get(); - } - - - - - - - public void setUnitprice(SimpleStringProperty unitprice) { - this.unitPriceColumn = unitprice; - } - - - - - - - public String getNo() { - return no.get(); - } - - - - - - - public void setNo(SimpleStringProperty no) { - this.no = no; - } - - - - - - - public String getTotalprice() { - return totalprice.get(); - } - - - - - - - public void setTotalprice(SimpleStringProperty totalprice) { - this.totalprice = totalprice; - } - - - - - - - @Override - public String toString() { - return "QuotationMX [matgroup=" + matgroup + ", mgsnumber=" + mgsnumber - + ", matcname=" + materialNameColumn + ", matcnumber=" + matcnumber + ", matcatname=" + relatedMaterialColumn - + ", specifications=" + specificationColumn + ", manufacturer=" + manufacturerColumn + ", nwquantity=" + quantityColumn - + ", utirate=" + utilizationRateColumn + ", unit=" + unitColumn + ", amomoney=" + amomoney + ", unitprice=" + unitPriceColumn - + ", no=" + no + ", totalprice=" + totalprice + "]"; - } - - } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/test.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/test.java index 4030bd8..109da5c 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/test.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/test.java @@ -13,20 +13,20 @@ import java.util.Calendar; import java.util.Date; public class test { - public static String formatString(String input) { - if (input == null || input.length() == 0) { - return input; - } - - double number = Double.parseDouble(input); - if (number == (int) number) { - return String.valueOf((int) number); - } else { - return String.format("%.3f", number).replaceAll("0*$", "").replaceAll("\\.$", ""); - } - } - - public static void main(String[] args) { + public static String formatString(String input) { + if (input == null || input.length() == 0) { + return input; + } + + double number = Double.parseDouble(input); + if (number == (int) number) { + return String.valueOf((int) number); + } else { + return String.format("%.3f", number).replaceAll("0*$", "").replaceAll("\\.$", ""); + } + } + + public static void main(String[] args) { // String input1 = "10"; // String input2 = "0.41"; // String input3 = ".40"; @@ -36,6 +36,6 @@ public class test { // System.out.println(formatString(input2)); // 输出:0.4 // System.out.println(formatString(input3)); // 输出:0.4 // System.out.println(formatString(input4)); // 输出:12.345 - MessageBox.post( "提示", "未选择成本单类型", MessageBox.INFORMATION); - } + MessageBox.post("提示", "未选择成本单类型", MessageBox.INFORMATION); + } } \ No newline at end of file diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/EditingCell.java b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/EditingCell.java index fc3a1e6..7b3ea2a 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/EditingCell.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/EditingCell.java @@ -1,6 +1,5 @@ package com.connor.plm.CreateOuotation; - import javafx.beans.property.SimpleStringProperty; import javafx.event.Event; import javafx.geometry.Pos; @@ -67,8 +66,7 @@ public class EditingCell extends TableCell { TableView table = getTableView(); if (table != null) { TableColumn col = getTableColumn(); - CellEditEvent event = new CellEditEvent<>(table, - new TablePosition<>(table, getIndex(), col), + CellEditEvent event = new CellEditEvent<>(table, new TablePosition<>(table, getIndex(), col), TableColumn.editCommitEvent(), newValue); Event.fireEvent(col, event); System.out.println("开始利用反射将数据写入对象"); @@ -95,9 +93,9 @@ public class EditingCell extends TableCell { } private Object convertValue(String value, Class type) { - if(type == SimpleStringProperty.class) { - return new SimpleStringProperty(value); - }else if (type == String.class) { + if (type == SimpleStringProperty.class) { + return new SimpleStringProperty(value); + } else if (type == String.class) { return value; } else if (type == Integer.class) { return new IntegerStringConverter().fromString(value); diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/EditingCellOR.java b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/EditingCellOR.java index 1eb593d..25d2471 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/EditingCellOR.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/EditingCellOR.java @@ -1,6 +1,5 @@ package com.connor.plm.CreateOuotation; - import javafx.beans.property.SimpleStringProperty; import javafx.event.Event; import javafx.geometry.Pos; @@ -67,8 +66,7 @@ public class EditingCellOR extends TableCell { TableView table = getTableView(); if (table != null) { TableColumn col = getTableColumn(); - CellEditEvent event = new CellEditEvent<>(table, - new TablePosition<>(table, getIndex(), col), + CellEditEvent event = new CellEditEvent<>(table, new TablePosition<>(table, getIndex(), col), TableColumn.editCommitEvent(), newValue); Event.fireEvent(col, event); System.out.println("开始利用反射将数据写入对象"); @@ -95,9 +93,9 @@ public class EditingCellOR extends TableCell { } private Object convertValue(String value, Class type) { - if(type == SimpleStringProperty.class) { - return new SimpleStringProperty(value); - }else if (type == String.class) { + if (type == SimpleStringProperty.class) { + return new SimpleStringProperty(value); + } else if (type == String.class) { return value; } else if (type == Integer.class) { return new IntegerStringConverter().fromString(value); diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/JDBFrame.java b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/JDBFrame.java index ca8066f..7bfa43e 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/JDBFrame.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/JDBFrame.java @@ -12,27 +12,25 @@ import com.connor.plm.CostListManagement.pojo.Quotation; import javafx.embed.swing.JFXPanel; import javafx.scene.Scene; -public class JDBFrame extends KFrame{ - private Quotation quotation; - - - - @Override - protected void initUI() throws Exception { - this.setTitle("变压器投标成本单"); - this.setLayout(new BorderLayout()); - this.setPreferredSize(new Dimension(1350, 850)); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸 - int screenWidth = screenSize.width; // 获取屏幕宽度 - int screenHeight = screenSize.height; // 获取屏幕高度 - int x = (screenWidth - 1350) / 2; // 计算Frame的左上角x坐标 - int y = (screenHeight - 850) / 2; // 计算Frame的左上角y坐标 - this.setLocation(x, y); // 设置Frame的位置 - JFXPanel panel = new JFXPanel(); - panel.setScene(new JDBfxPanel(this).getScene()); - this.add(BorderLayout.CENTER, panel); +public class JDBFrame extends KFrame { + private Quotation quotation; + + @Override + protected void initUI() throws Exception { + this.setTitle("变压器投标成本单"); + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(1350, 850)); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸 + int screenWidth = screenSize.width; // 获取屏幕宽度 + int screenHeight = screenSize.height; // 获取屏幕高度 + int x = (screenWidth - 1350) / 2; // 计算Frame的左上角x坐标 + int y = (screenHeight - 850) / 2; // 计算Frame的左上角y坐标 + this.setLocation(x, y); // 设置Frame的位置 + JFXPanel panel = new JFXPanel(); + panel.setScene(new JDBfxPanel(this).getScene()); + this.add(BorderLayout.CENTER, panel); // this.setResizable(false); - this.setAlwaysOnTop(true); - } + this.setAlwaysOnTop(true); + } } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/JDBfxPanel.java b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/JDBfxPanel.java index b3c11f4..14e2325 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/JDBfxPanel.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/JDBfxPanel.java @@ -1,13 +1,15 @@ package com.connor.plm.CreateOuotation; + import java.awt.Window; import com.connor.plm.CostListManagement.pojo.Quotation; -public class JDBfxPanel extends KFXPanel{ - private Quotation quotation; - public JDBfxPanel(Window dialog) { - super(dialog); - // TODO Auto-generated constructor stub - } +public class JDBfxPanel extends KFXPanel { + private Quotation quotation; + + public JDBfxPanel(Window dialog) { + super(dialog); + // TODO Auto-generated constructor stub + } } \ No newline at end of file diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/KFXPanel.java b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/KFXPanel.java index 4739af0..9bf2df9 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/KFXPanel.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/KFXPanel.java @@ -13,116 +13,113 @@ import javafx.stage.Stage; //import sun.util.logging.PlatformLogger; public abstract class KFXPanel extends Application { - protected Scene scene; - - protected KFXPanelController aifController; - - protected Parent root; - - protected String cssForm; - - protected Window parentDialog; - - private FXMLLoader fxmlLoader; - - - - - static { - Platform.setImplicitExit(false); + protected Scene scene; + + protected KFXPanelController aifController; + + protected Parent root; + + protected String cssForm; + + protected Window parentDialog; + + private FXMLLoader fxmlLoader; + + static { + Platform.setImplicitExit(false); // Logging.getCSSLogger().setLevel(Platform.class...STYLESHEET_CASPIAN....Level.OFF); - } - - public KFXPanel(Window dialog) { - setParentDialog(dialog); - initUI(); - initData(); - } - - public KFXPanel(Window dialog, Class c, String css) { - setParentDialog(dialog); - this.cssForm = c.getResource(css).toExternalForm(); - initUI(); - initData(); - } - - public void setParentDialog(Window dialog) { - this.parentDialog = dialog; - } - - public Window getParentDialog() { - return this.parentDialog; - } - - public Parent getRoot() { - return this.root; - } - - public KFXPanelController getController() { - return this.aifController; - } - - public Scene getScene() { - if (this.scene == null) { - this.scene = new Scene(this.root); - this.scene.setFill(null); - } - return this.scene; - } - - public void initData() { - try { - this.aifController.initData(this); - - } catch (Exception e) { - e.printStackTrace(); - post(this.parentDialog, e.getMessage(), "", 1); - } - } - - protected void initUI() { - try { - fxmlLoader = new FXMLLoader(); - String resource = "PersonOverview.fxml"; - fxmlLoader.setLocation(getClass().getResource(resource)); - root = fxmlLoader.load(); - - this.aifController = (KFXPanelController)fxmlLoader.getController(); - if (this.cssForm != null) - this.root.getStylesheets().add(this.cssForm); - } catch (Exception e) { - e.printStackTrace(); - post(this.parentDialog, e.getMessage(), "", 1); - } - } - - public static void post(Window dialog, final String msg, final String title, int msgType) { - if (dialog == null) { - Platform.runLater(new Runnable() { - public void run() { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle(title); - alert.setHeaderText(""); - alert.setContentText(msg); - alert.showAndWait(); - } - }); - } else { - MessageBox.post(dialog, msg, title, msgType); - } - } + } + + public KFXPanel(Window dialog) { + setParentDialog(dialog); + initUI(); + initData(); + } + + public KFXPanel(Window dialog, Class c, String css) { + setParentDialog(dialog); + this.cssForm = c.getResource(css).toExternalForm(); + initUI(); + initData(); + } + + public void setParentDialog(Window dialog) { + this.parentDialog = dialog; + } + + public Window getParentDialog() { + return this.parentDialog; + } + + public Parent getRoot() { + return this.root; + } + + public KFXPanelController getController() { + return this.aifController; + } + + public Scene getScene() { + if (this.scene == null) { + this.scene = new Scene(this.root); + this.scene.setFill(null); + } + return this.scene; + } + + public void initData() { + try { + this.aifController.initData(this); + + } catch (Exception e) { + e.printStackTrace(); + post(this.parentDialog, e.getMessage(), "", 1); + } + } + + protected void initUI() { + try { + fxmlLoader = new FXMLLoader(); + String resource = "PersonOverview.fxml"; + fxmlLoader.setLocation(getClass().getResource(resource)); + root = fxmlLoader.load(); + + this.aifController = (KFXPanelController) fxmlLoader.getController(); + if (this.cssForm != null) + this.root.getStylesheets().add(this.cssForm); + } catch (Exception e) { + e.printStackTrace(); + post(this.parentDialog, e.getMessage(), "", 1); + } + } + + public static void post(Window dialog, final String msg, final String title, int msgType) { + if (dialog == null) { + Platform.runLater(new Runnable() { + public void run() { + Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.setTitle(title); + alert.setHeaderText(""); + alert.setContentText(msg); + alert.showAndWait(); + } + }); + } else { + MessageBox.post(dialog, msg, title, msgType); + } + } + // protected Stage primaryStage; - public void start(Stage primaryStage) throws Exception { - initUI(); - initData(); + public void start(Stage primaryStage) throws Exception { + initUI(); + initData(); // this.primaryStage = primaryStage; - primaryStage.setScene(getScene()); - primaryStage.show(); - } - - public static void main(String[] args) { - launch(args); - } + primaryStage.setScene(getScene()); + primaryStage.show(); + } + public static void main(String[] args) { + launch(args); + } } \ No newline at end of file diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/KFXPanelController.java b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/KFXPanelController.java index ca82520..bc8b35f 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/KFXPanelController.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/KFXPanelController.java @@ -1,6 +1,5 @@ package com.connor.plm.CreateOuotation; - import com.connor.plm.CostListManagement.pojo.Quotation; import javafx.application.Platform; @@ -8,23 +7,23 @@ import javafx.fxml.FXML; import javafx.scene.layout.AnchorPane; public abstract class KFXPanelController { - @FXML - protected AnchorPane coverPane; - - public abstract void initData(KFXPanel paramKFXPanel) throws Exception; - - public void setCoverVisible(final boolean visible) { - if (this.coverPane != null) { - Platform.runLater(new Runnable() { - public void run() { - KFXPanelController.this.coverPane.setVisible(visible); + @FXML + protected AnchorPane coverPane; + + public abstract void initData(KFXPanel paramKFXPanel) throws Exception; + + public void setCoverVisible(final boolean visible) { + if (this.coverPane != null) { + Platform.runLater(new Runnable() { + public void run() { + KFXPanelController.this.coverPane.setVisible(visible); + } + }); + try { + Thread.sleep(10L); + } catch (Exception e) { + e.printStackTrace(); } - }); - try { - Thread.sleep(10L); - } catch (Exception e) { - e.printStackTrace(); - } - } - } + } + } } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/MainApp.java b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/MainApp.java index 42dd574..e05c45f 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/MainApp.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/CreateOuotation/MainApp.java @@ -1,6 +1,5 @@ package com.connor.plm.CreateOuotation; - import java.io.IOException; import javax.swing.SwingUtilities; @@ -17,13 +16,12 @@ public class MainApp extends Application { private Stage primaryStage; private Pane rootLayout; - - + @Override public void start(Stage primaryStage) throws IOException { try { - System.out.println("1"); - this.primaryStage = primaryStage; + System.out.println("1"); + this.primaryStage = primaryStage; this.primaryStage.setTitle("变压器投标成本单"); FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("PersonOverview.fxml")); 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 8d2ef18..a04a545 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 @@ -50,18 +50,17 @@ import javafx.stage.Window; import javafx.util.Callback; public class MyController extends KFXPanelController { - private List dbRevList = null; - private List moneyList = null; - private List dbmatcatnameList = null; - private List dbnwquantityList = null; - private List dbutirateList = null; - private List dbunitList = null; - private List dbunitpriceList = null; - private List DbnoList = null; - private List dbtotalpriceList = null; - - - @FXML + private List dbRevList = null; + private List moneyList = null; + private List dbmatcatnameList = null; + private List dbnwquantityList = null; + private List dbutirateList = null; + private List dbunitList = null; + private List dbunitpriceList = null; + private List DbnoList = null; + private List dbtotalpriceList = null; + + @FXML private AnchorPane coverPane; @FXML @@ -195,43 +194,43 @@ public class MyController extends KFXPanelController { @FXML private BorderPane tablePane; - + @FXML private TableView materialsTable; - + @FXML private TableColumn no; - + @FXML private TableColumn materialNameColumn; - + @FXML private TableColumn relatedMaterialColumn; - + @FXML private TableColumn specificationColumn; - + @FXML private TableColumn manufacturerColumn; - + @FXML private TableColumn quantityColumn; - + @FXML private TableColumn utilizationRateColumn; - + @FXML private TableColumn unitColumn; - + @FXML private TableColumn unitPriceColumn; - + @FXML private TableColumn amountColumn; - + @FXML private TableColumn comparedResultColumn; - + @FXML private BorderPane bordPane; @@ -240,1073 +239,1048 @@ public class MyController extends KFXPanelController { @FXML private TextField totalPriceCompareTextField; - + private DecimalFormat df = new DecimalFormat("#.00"); - + private String rev = "01"; - - + public void editWrite() { - materialsTable.setEditable(true); - //头表 - costSheetTypeComboBox.setEditable(false); - projectNameTextField.setEditable(true); - transformerModelTextField.setEditable(true); - noLoadLossTextField.setEditable(true); - loadLossTextField.setEditable(true); - biddingNumberTextField.setEditable(true); - capacityRatioTextField.setEditable(true); - impedanceVoltageTextField.setEditable(true); - projectManagerTextField.setEditable(true); - voltageRatioTextField.setEditable(true); - transportationWeightTextField.setEditable(true); - quantityTextField.setEditable(true); - totalWeightTextField.setEditable(true); - copperAmountTextField.setEditable(true); - copperMarketPriceTextField.setEditable(true); - voltageLevelTextField.setEditable(true); - totalPriceTextField.setEditable(false); - //明细表 - no.setCellFactory((tableColumn) -> new EditingCellOR()); - materialNameColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - relatedMaterialColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - specificationColumn.setCellFactory((tableColumn) -> new EditingCell()); - manufacturerColumn.setCellFactory((tableColumn) -> new EditingCell()); - quantityColumn.setCellFactory((tableColumn) -> new EditingCell()); - utilizationRateColumn.setCellFactory((tableColumn) -> new EditingCell()); - unitColumn.setCellFactory((tableColumn) -> new EditingCell()); - unitPriceColumn.setCellFactory((tableColumn) -> new EditingCell()); - amountColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - comparedResultColumn.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); // 设置单元格内容居中对齐 - } - } - }; - }); + materialsTable.setEditable(true); + // 头表 + costSheetTypeComboBox.setEditable(false); + projectNameTextField.setEditable(true); + transformerModelTextField.setEditable(true); + noLoadLossTextField.setEditable(true); + loadLossTextField.setEditable(true); + biddingNumberTextField.setEditable(true); + capacityRatioTextField.setEditable(true); + impedanceVoltageTextField.setEditable(true); + projectManagerTextField.setEditable(true); + voltageRatioTextField.setEditable(true); + transportationWeightTextField.setEditable(true); + quantityTextField.setEditable(true); + totalWeightTextField.setEditable(true); + copperAmountTextField.setEditable(true); + copperMarketPriceTextField.setEditable(true); + voltageLevelTextField.setEditable(true); + totalPriceTextField.setEditable(false); + // 明细表 + no.setCellFactory((tableColumn) -> new EditingCellOR()); + materialNameColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + relatedMaterialColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + specificationColumn.setCellFactory((tableColumn) -> new EditingCell()); + manufacturerColumn.setCellFactory((tableColumn) -> new EditingCell()); + quantityColumn.setCellFactory((tableColumn) -> new EditingCell()); + utilizationRateColumn.setCellFactory((tableColumn) -> new EditingCell()); + unitColumn.setCellFactory((tableColumn) -> new EditingCell()); + unitPriceColumn.setCellFactory((tableColumn) -> new EditingCell()); + amountColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + comparedResultColumn.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); // 设置单元格内容居中对齐 + } + } + }; + }); } - + public void onlyRead() { - - //头表 - costSheetTypeComboBox.setEditable(false); - projectNameTextField.setEditable(false); - transformerModelTextField.setEditable(false); - noLoadLossTextField.setEditable(false); - loadLossTextField.setEditable(false); - biddingNumberTextField.setEditable(false); - capacityRatioTextField.setEditable(false); - impedanceVoltageTextField.setEditable(false); - projectManagerTextField.setEditable(false); - voltageRatioTextField.setEditable(false); - transportationWeightTextField.setEditable(false); - quantityTextField.setEditable(false); - totalWeightTextField.setEditable(false); - copperAmountTextField.setEditable(false); - copperMarketPriceTextField.setEditable(false); - voltageLevelTextField.setEditable(false); - totalPriceTextField.setEditable(false); - //明细表 - materialsTable.setEditable(false); - no.setCellFactory((tableColumn) -> new EditingCellOR()); - materialNameColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - relatedMaterialColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - specificationColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - manufacturerColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - quantityColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - utilizationRateColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - unitColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - unitPriceColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - amountColumn.setCellFactory((tableColumn) -> new EditingCellOR()); - comparedResultColumn.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); // 设置单元格内容居中对齐 - } - } - }; - }); + + // 头表 + costSheetTypeComboBox.setEditable(false); + projectNameTextField.setEditable(false); + transformerModelTextField.setEditable(false); + noLoadLossTextField.setEditable(false); + loadLossTextField.setEditable(false); + biddingNumberTextField.setEditable(false); + capacityRatioTextField.setEditable(false); + impedanceVoltageTextField.setEditable(false); + projectManagerTextField.setEditable(false); + voltageRatioTextField.setEditable(false); + transportationWeightTextField.setEditable(false); + quantityTextField.setEditable(false); + totalWeightTextField.setEditable(false); + copperAmountTextField.setEditable(false); + copperMarketPriceTextField.setEditable(false); + voltageLevelTextField.setEditable(false); + totalPriceTextField.setEditable(false); + // 明细表 + materialsTable.setEditable(false); + no.setCellFactory((tableColumn) -> new EditingCellOR()); + materialNameColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + relatedMaterialColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + specificationColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + manufacturerColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + quantityColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + utilizationRateColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + unitColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + unitPriceColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + amountColumn.setCellFactory((tableColumn) -> new EditingCellOR()); + comparedResultColumn.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); // 设置单元格内容居中对齐 + } + } + }; + }); } - @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)); - 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)); - - - String sql1 = "SELECT DISTINCT \"cbdlx\" FROM \"CHINT_ QUOTATION_LOV\""; - System.out.println(sql1); - ResultSet resultSet1 = SqlUtil.read(sql1); - List type = new ArrayList(); - while(resultSet1.next()) { - type.add(resultSet1.getString("cbdlx")); - } - costSheetTypeComboBox.getItems().addAll(type); - - costSheetTypeComboBox.getSelectionModel().select(type.indexOf("报价成本单")); - - //查询版次 - - String sql2 = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '"+ButtonCellEditor.cusquotation.getProjectid()+"' and \"cbdlx\" = '" +"报价成本单"+ "'"; - System.out.println(sql2); - ResultSet resultSet2 = SqlUtil.read(sql2); - List revision = new ArrayList(); - while(resultSet2.next()) { - revision.add(resultSet2.getString("revision")); - } - if(revision.size()>0) { - editionComboBox.getItems().addAll(revision); - editionComboBox.getSelectionModel().select(revision.size()-1); - }else { - List revList= new ArrayList(); - revList.add("01"); - editionComboBox.getItems().addAll(revList); - editionComboBox.getSelectionModel().select(0); - } - - projectNameTextField.setText(ButtonCellEditor.cusquotation.getProname()); - - transformerModelTextField.setText(ButtonCellEditor.cusquotation.getTramodel()); - - noLoadLossTextField.setText(ButtonCellEditor.cusquotation.getLoadloss()); - - loadLossTextField.setText(ButtonCellEditor.cusquotation.getLoadloss()); - - biddingNumberTextField.setText(ButtonCellEditor.cusquotation.getTennumber()); - - capacityRatioTextField.setText(ButtonCellEditor.cusquotation.getCapfactor()); - - impedanceVoltageTextField.setText(ButtonCellEditor.cusquotation.getImpvoltage()); - - projectManagerTextField.setText(ButtonCellEditor.cusquotation.getPromanager()); - - voltageRatioTextField.setText(ButtonCellEditor.cusquotation.getVolratio()); - - transportationWeightTextField.setText(ButtonCellEditor.cusquotation.getTraweight()); - - quantityTextField.setText(ButtonCellEditor.cusquotation.getQuantity()); - - totalWeightTextField.setText(ButtonCellEditor.cusquotation.getTotweight()); - - copperAmountTextField.setText(QuotationUtil.formatString(ButtonCellEditor.cusquotation.getCopconsumption())); - - copperMarketPriceTextField.setText(QuotationUtil.formatString(ButtonCellEditor.cusquotation.getCmarketprice())); - - voltageLevelTextField.setText(ButtonCellEditor.cusquotation.getVollevel()); - - if(ButtonCellEditor.tableList.size()>0) { - totalPriceTextField.setText(ButtonCellEditor.tableList.get(0).getTotalprice()); - } - - - //设置只读 - totalPriceTextField.setEditable(false); - totalPriceCompareTextField.setEditable(false); - - - //给表哥添加内容 - ObservableList data = FXCollections.observableArrayList(); - data.addAll(ButtonCellEditor.tableList); - // 将列与类的属性绑定 - no.setCellValueFactory(new PropertyValueFactory<>("matgroup")); - no.setSortable(false); - - materialNameColumn.setCellValueFactory(new PropertyValueFactory<>("matcname")); - materialNameColumn.setSortable(false); - - relatedMaterialColumn.setCellValueFactory(new PropertyValueFactory<>("matcatname")); - relatedMaterialColumn.setSortable(false); - - specificationColumn.setCellValueFactory(new PropertyValueFactory<>("specifications")); - specificationColumn.setSortable(false); - - manufacturerColumn.setCellValueFactory(new PropertyValueFactory<>("manufacturer")); - manufacturerColumn.setSortable(false); - - quantityColumn.setCellValueFactory(new PropertyValueFactory<>("nwquantity")); - quantityColumn.setSortable(false); - - utilizationRateColumn.setCellValueFactory(new PropertyValueFactory<>("utirate")); - utilizationRateColumn.setSortable(false); - - unitColumn.setCellValueFactory(new PropertyValueFactory<>("unit")); - unitColumn.setSortable(false); - - unitPriceColumn.setCellValueFactory(new PropertyValueFactory<>("unitprice")); - unitPriceColumn.setSortable(false); - - amountColumn.setCellValueFactory(new PropertyValueFactory<>("amomoney")); - amountColumn.setSortable(false); - - - - - comparedResultColumn.setCellValueFactory(new PropertyValueFactory<>("contrastPrice")); - comparedResultColumn.setSortable(false); - - materialsTable.setEditable(true); - - - //设置可编辑状态 - editWrite(); - - - // 将personList设置为TableView的数据源 - materialsTable.setItems(data); - - //记录初始金额值 - List oldamountList = new ArrayList(); - for(QuotationMX quotationMX : materialsTable.getItems()) { - String amomoney = quotationMX.getAmomoney(); - oldamountList.add(amomoney); - } - //记录版本最开始的值 - rev = editionComboBox.getSelectionModel().getSelectedItem(); - - //成本单类型下拉框,按钮监听 - costSheetTypeComboBox.setOnAction(event->{ - String selectedItemType = 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")); - } - //清空版本下拉框 - editionComboBox.getItems().clear(); - if(revisions.size()>0) { - editionComboBox.getItems().addAll(revisions); - editionComboBox.getSelectionModel().select(revisions.size()-1); - }else { - List revList= new ArrayList(); - revList.add("01"); - editionComboBox.getItems().addAll(revList); - editionComboBox.getSelectionModel().select(0); - } - //改变版本下拉框初始值 - - rev = editionComboBox.getSelectionModel().getSelectedItem(); - }catch(Exception e) { - e.printStackTrace(); - } - - - - - //开始刷新数据,设置只能查看数据 - 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\" = '"+ButtonCellEditor.cusquotation.getProjectid()+"' and \"revision\" = '"+rev+"' and \"cbdlx\" = '" +costSheetTypeComboBox.getSelectionModel().getSelectedItem()+ "'"; - //根据查询结果更新数据 - System.out.println(selSQL); - try { - ResultSet result = SqlUtil.read(selSQL); - while(result.next()) { - //costSheetTypeComboBox.setValue(result.getString("cbdlx")); - projectNameTextField.setText(result.getString("proname")); - transformerModelTextField.setText(result.getString("tramodel")); - noLoadLossTextField.setText(result.getString("noloadloss")); - loadLossTextField.setText(result.getString("loadloss")); - biddingNumberTextField.setText(result.getString("tennumber")); - capacityRatioTextField.setText(result.getString("capfactor")); - impedanceVoltageTextField.setText(result.getString("impvoltage")); - projectManagerTextField.setText(result.getString("promanager")); - voltageRatioTextField.setText(result.getString("volratio")); - transportationWeightTextField.setText(result.getString("traweight")); - quantityTextField.setText(result.getString("quantity")); - totalWeightTextField.setText(result.getString("totweight")); - copperAmountTextField.setText(QuotationUtil.formatString(result.getString("copconsumption"))); - copperMarketPriceTextField.setText(QuotationUtil.formatString(result.getString("cmarketprice"))); - voltageLevelTextField.setText(result.getString("vollevel")); - } - } catch (SQLException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - 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+"' 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(); - while(reSql1.next()) { - System.out.println("获取数据"); - QuotationMX quotationMX = new QuotationMX(); - quotationMX.setCbdlx(reSql1.getString("cbdlx")); - quotationMX.setProjectid(reSql1.getString("projectid")); - quotationMX.setRevision(reSql1.getString("revision")); - quotationMX.setMatgroup(new SimpleStringProperty(reSql1.getString("matgroup"))); - quotationMX.setMgsnumber(new SimpleStringProperty(reSql1.getString("mgsnumber"))); - quotationMX.setMatcname(new SimpleStringProperty(reSql1.getString("matcname"))); - quotationMX.setMatcnumber(new SimpleStringProperty(reSql1.getString("matcnumber"))); - quotationMX.setMatcatname(new SimpleStringProperty(reSql1.getString("matcatname"))); - quotationMX.setSpecifications(new SimpleStringProperty(reSql1.getString("specifications"))); - quotationMX.setManufacturer(new SimpleStringProperty(reSql1.getString("manufacturer"))); - quotationMX.setNwquantity(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("nwquantity")))); - quotationMX.setUtirate(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("utirate")))); - quotationMX.setUnit(new SimpleStringProperty(reSql1.getString("unit"))); - quotationMX.setAmomoney(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("amomoney")))); - quotationMX.setUnitprice(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("unitprice")))); - quotationMX.setNo(new SimpleStringProperty(reSql1.getString("no"))); - quotationMX.setContrastPrice(new SimpleStringProperty("")); - quotationMX.setTotalprice(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("totalprice")))); - tableList.add(quotationMX); - } - System.out.println("表格数据:"+tableList.size()); - System.out.println("表格数据:"+tableList.toString()); - if(tableList.size()>0) { - System.out.println("查询到了明细数据,开始插入"); - //循环插入刷新明细数据 - for(int j=0;j{ - - 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\" = '"+ButtonCellEditor.cusquotation.getProjectid()+"' and \"revision\" = '"+selectedItem+"' and \"cbdlx\" = '" +costSheetTypeComboBox.getSelectionModel().getSelectedItem()+ "'"; - //根据查询结果更新数据 - System.out.println(selSQL); - try { - ResultSet result = SqlUtil.read(selSQL); - while(result.next()) { - //costSheetTypeComboBox.setValue(result.getString("cbdlx")); - projectNameTextField.setText(result.getString("proname")); - transformerModelTextField.setText(result.getString("tramodel")); - noLoadLossTextField.setText(result.getString("noloadloss")); - loadLossTextField.setText(result.getString("loadloss")); - biddingNumberTextField.setText(result.getString("tennumber")); - capacityRatioTextField.setText(result.getString("capfactor")); - impedanceVoltageTextField.setText(result.getString("impvoltage")); - projectManagerTextField.setText(result.getString("promanager")); - voltageRatioTextField.setText(result.getString("volratio")); - transportationWeightTextField.setText(result.getString("traweight")); - quantityTextField.setText(result.getString("quantity")); - totalWeightTextField.setText(result.getString("totweight")); - copperAmountTextField.setText(QuotationUtil.formatString(result.getString("copconsumption"))); - copperMarketPriceTextField.setText(QuotationUtil.formatString(result.getString("cmarketprice"))); - voltageLevelTextField.setText(result.getString("vollevel")); - } - } catch (SQLException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - - 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+"' 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(); - while(reSql1.next()) { - System.out.println("获取数据"); - QuotationMX quotationMX = new QuotationMX(); - quotationMX.setCbdlx(reSql1.getString("cbdlx")); - quotationMX.setProjectid(reSql1.getString("projectid")); - quotationMX.setRevision(reSql1.getString("revision")); - quotationMX.setMatgroup(new SimpleStringProperty(reSql1.getString("matgroup"))); - quotationMX.setMgsnumber(new SimpleStringProperty(reSql1.getString("mgsnumber"))); - quotationMX.setMatcname(new SimpleStringProperty(reSql1.getString("matcname"))); - quotationMX.setMatcnumber(new SimpleStringProperty(reSql1.getString("matcnumber"))); - quotationMX.setMatcatname(new SimpleStringProperty(reSql1.getString("matcatname"))); - quotationMX.setSpecifications(new SimpleStringProperty(reSql1.getString("specifications"))); - quotationMX.setManufacturer(new SimpleStringProperty(reSql1.getString("manufacturer"))); - quotationMX.setNwquantity(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("nwquantity")))); - quotationMX.setUtirate(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("utirate")))); - quotationMX.setUnit(new SimpleStringProperty(reSql1.getString("unit"))); - quotationMX.setAmomoney(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("amomoney")))); - quotationMX.setUnitprice(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("unitprice")))); - quotationMX.setNo(new SimpleStringProperty(reSql1.getString("no"))); - quotationMX.setContrastPrice(new SimpleStringProperty("")); - quotationMX.setTotalprice(new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("totalprice")))); - tableList.add(quotationMX); - } - System.out.println("表格数据:"+tableList.size()); - System.out.println("表格数据:"+tableList.toString()); - if(tableList.size()>0) { - System.out.println("查询到了明细数据,开始插入"); - //循环插入刷新明细数据 - for(int j=0;j{ - //校验数据 - String selectedItem = costSheetTypeComboBox.getSelectionModel().getSelectedItem(); - if(selectedItem == null || "".equals(selectedItem)) { + @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)); + 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)); + + String sql1 = "SELECT DISTINCT \"cbdlx\" FROM \"CHINT_ QUOTATION_LOV\""; + System.out.println(sql1); + ResultSet resultSet1 = SqlUtil.read(sql1); + List type = new ArrayList(); + while (resultSet1.next()) { + type.add(resultSet1.getString("cbdlx")); + } + costSheetTypeComboBox.getItems().addAll(type); + + costSheetTypeComboBox.getSelectionModel().select(type.indexOf("报价成本单")); + + // 查询版次 + + String sql2 = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '" + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" + "报价成本单" + "'"; + System.out.println(sql2); + ResultSet resultSet2 = SqlUtil.read(sql2); + List revision = new ArrayList(); + while (resultSet2.next()) { + revision.add(resultSet2.getString("revision")); + } + if (revision.size() > 0) { + editionComboBox.getItems().addAll(revision); + editionComboBox.getSelectionModel().select(revision.size() - 1); + } else { + List revList = new ArrayList(); + revList.add("01"); + editionComboBox.getItems().addAll(revList); + editionComboBox.getSelectionModel().select(0); + } + + projectNameTextField.setText(ButtonCellEditor.cusquotation.getProname()); + + transformerModelTextField.setText(ButtonCellEditor.cusquotation.getTramodel()); + + noLoadLossTextField.setText(ButtonCellEditor.cusquotation.getLoadloss()); + + loadLossTextField.setText(ButtonCellEditor.cusquotation.getLoadloss()); + + biddingNumberTextField.setText(ButtonCellEditor.cusquotation.getTennumber()); + + capacityRatioTextField.setText(ButtonCellEditor.cusquotation.getCapfactor()); + + impedanceVoltageTextField.setText(ButtonCellEditor.cusquotation.getImpvoltage()); + + projectManagerTextField.setText(ButtonCellEditor.cusquotation.getPromanager()); + + voltageRatioTextField.setText(ButtonCellEditor.cusquotation.getVolratio()); + + transportationWeightTextField.setText(ButtonCellEditor.cusquotation.getTraweight()); + + quantityTextField.setText(ButtonCellEditor.cusquotation.getQuantity()); + + totalWeightTextField.setText(ButtonCellEditor.cusquotation.getTotweight()); + + copperAmountTextField.setText(QuotationUtil.formatString(ButtonCellEditor.cusquotation.getCopconsumption())); + + copperMarketPriceTextField.setText(QuotationUtil.formatString(ButtonCellEditor.cusquotation.getCmarketprice())); + + voltageLevelTextField.setText(ButtonCellEditor.cusquotation.getVollevel()); + + if (ButtonCellEditor.tableList.size() > 0) { + totalPriceTextField.setText(ButtonCellEditor.tableList.get(0).getTotalprice()); + } + + // 设置只读 + totalPriceTextField.setEditable(false); + totalPriceCompareTextField.setEditable(false); + + // 给表哥添加内容 + ObservableList data = FXCollections.observableArrayList(); + data.addAll(ButtonCellEditor.tableList); + // 将列与类的属性绑定 + no.setCellValueFactory(new PropertyValueFactory<>("matgroup")); + no.setSortable(false); + + materialNameColumn.setCellValueFactory(new PropertyValueFactory<>("matcname")); + materialNameColumn.setSortable(false); + + relatedMaterialColumn.setCellValueFactory(new PropertyValueFactory<>("matcatname")); + relatedMaterialColumn.setSortable(false); + + specificationColumn.setCellValueFactory(new PropertyValueFactory<>("specifications")); + specificationColumn.setSortable(false); + + manufacturerColumn.setCellValueFactory(new PropertyValueFactory<>("manufacturer")); + manufacturerColumn.setSortable(false); + + quantityColumn.setCellValueFactory(new PropertyValueFactory<>("nwquantity")); + quantityColumn.setSortable(false); + + utilizationRateColumn.setCellValueFactory(new PropertyValueFactory<>("utirate")); + utilizationRateColumn.setSortable(false); + + unitColumn.setCellValueFactory(new PropertyValueFactory<>("unit")); + unitColumn.setSortable(false); + + unitPriceColumn.setCellValueFactory(new PropertyValueFactory<>("unitprice")); + unitPriceColumn.setSortable(false); + + amountColumn.setCellValueFactory(new PropertyValueFactory<>("amomoney")); + amountColumn.setSortable(false); + + comparedResultColumn.setCellValueFactory(new PropertyValueFactory<>("contrastPrice")); + comparedResultColumn.setSortable(false); + + materialsTable.setEditable(true); + + // 设置可编辑状态 + editWrite(); + + // 将personList设置为TableView的数据源 + materialsTable.setItems(data); + + // 记录初始金额值 + List oldamountList = new ArrayList(); + for (QuotationMX quotationMX : materialsTable.getItems()) { + String amomoney = quotationMX.getAmomoney(); + oldamountList.add(amomoney); + } + // 记录版本最开始的值 + rev = editionComboBox.getSelectionModel().getSelectedItem(); + + // 成本单类型下拉框,按钮监听 + costSheetTypeComboBox.setOnAction(event -> { + String selectedItemType = 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")); + } + // 清空版本下拉框 + editionComboBox.getItems().clear(); + if (revisions.size() > 0) { + editionComboBox.getItems().addAll(revisions); + editionComboBox.getSelectionModel().select(revisions.size() - 1); + } else { + List revList = new ArrayList(); + revList.add("01"); + editionComboBox.getItems().addAll(revList); + editionComboBox.getSelectionModel().select(0); + } + // 改变版本下拉框初始值 + + rev = editionComboBox.getSelectionModel().getSelectedItem(); + } catch (Exception e) { + e.printStackTrace(); + } + + // 开始刷新数据,设置只能查看数据 + 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\" = '" + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"revision\" = '" + rev + + "' and \"cbdlx\" = '" + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "'"; + // 根据查询结果更新数据 + System.out.println(selSQL); + try { + ResultSet result = SqlUtil.read(selSQL); + while (result.next()) { + // costSheetTypeComboBox.setValue(result.getString("cbdlx")); + projectNameTextField.setText(result.getString("proname")); + transformerModelTextField.setText(result.getString("tramodel")); + noLoadLossTextField.setText(result.getString("noloadloss")); + loadLossTextField.setText(result.getString("loadloss")); + biddingNumberTextField.setText(result.getString("tennumber")); + capacityRatioTextField.setText(result.getString("capfactor")); + impedanceVoltageTextField.setText(result.getString("impvoltage")); + projectManagerTextField.setText(result.getString("promanager")); + voltageRatioTextField.setText(result.getString("volratio")); + transportationWeightTextField.setText(result.getString("traweight")); + quantityTextField.setText(result.getString("quantity")); + totalWeightTextField.setText(result.getString("totweight")); + copperAmountTextField.setText(QuotationUtil.formatString(result.getString("copconsumption"))); + copperMarketPriceTextField.setText(QuotationUtil.formatString(result.getString("cmarketprice"))); + voltageLevelTextField.setText(result.getString("vollevel")); + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + 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 + + "' 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(); + while (reSql1.next()) { + System.out.println("获取数据"); + QuotationMX quotationMX = new QuotationMX(); + quotationMX.setCbdlx(reSql1.getString("cbdlx")); + quotationMX.setProjectid(reSql1.getString("projectid")); + quotationMX.setRevision(reSql1.getString("revision")); + quotationMX.setMatgroup(new SimpleStringProperty(reSql1.getString("matgroup"))); + quotationMX.setMgsnumber(new SimpleStringProperty(reSql1.getString("mgsnumber"))); + quotationMX.setMatcname(new SimpleStringProperty(reSql1.getString("matcname"))); + quotationMX.setMatcnumber(new SimpleStringProperty(reSql1.getString("matcnumber"))); + quotationMX.setMatcatname(new SimpleStringProperty(reSql1.getString("matcatname"))); + quotationMX.setSpecifications(new SimpleStringProperty(reSql1.getString("specifications"))); + quotationMX.setManufacturer(new SimpleStringProperty(reSql1.getString("manufacturer"))); + quotationMX.setNwquantity( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("nwquantity")))); + quotationMX.setUtirate( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("utirate")))); + quotationMX.setUnit(new SimpleStringProperty(reSql1.getString("unit"))); + quotationMX.setAmomoney( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("amomoney")))); + quotationMX.setUnitprice( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("unitprice")))); + quotationMX.setNo(new SimpleStringProperty(reSql1.getString("no"))); + quotationMX.setContrastPrice(new SimpleStringProperty("")); + quotationMX.setTotalprice( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("totalprice")))); + tableList.add(quotationMX); + } + System.out.println("表格数据:" + tableList.size()); + System.out.println("表格数据:" + tableList.toString()); + if (tableList.size() > 0) { + System.out.println("查询到了明细数据,开始插入"); + // 循环插入刷新明细数据 + for (int j = 0; j < materialsTable.getItems().size(); j++) { + QuotationMX quotationMX = materialsTable.getItems().get(j); + quotationMX.setCbdlx(tableList.get(j).getCbdlx()); + quotationMX.setProjectid(tableList.get(j).getProjectid()); + quotationMX.setRevision(tableList.get(j).getRevision()); + quotationMX.setMatgroup(new SimpleStringProperty(tableList.get(j).getMatgroup())); + quotationMX.setMgsnumber(new SimpleStringProperty(tableList.get(j).getMgsnumber())); + quotationMX.setMatcname(new SimpleStringProperty(tableList.get(j).getMatcname())); + quotationMX.setMatcnumber(new SimpleStringProperty(tableList.get(j).getMatcnumber())); + quotationMX.setMatcatname(new SimpleStringProperty(tableList.get(j).getMatcatname())); + quotationMX.setSpecifications(new SimpleStringProperty(tableList.get(j).getSpecifications())); + quotationMX.setManufacturer(new SimpleStringProperty(tableList.get(j).getManufacturer())); + quotationMX.setNwquantity(new SimpleStringProperty(tableList.get(j).getNwquantity())); + quotationMX.setUtirate(new SimpleStringProperty(tableList.get(j).getUtirate())); + quotationMX.setUnit(new SimpleStringProperty(tableList.get(j).getUnit())); + 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.setContrastPrice(new SimpleStringProperty("")); + // quotationMX.setTotalprice(new + // SimpleStringProperty(reSql1.getString("totalprice"))); + + } + System.out.println("刷新表格"); + materialsTable.refresh(); + totalPriceTextField.setText(tableList.get(0).getTotalprice()); + } else { + System.out.println("没有找到明细数据,清空金额和对比结果数据"); + // 计算金额 + for (QuotationMX quotationMX : materialsTable.getItems()) { + quotationMX.setAmomoney((new SimpleStringProperty(""))); + quotationMX.setContrastPrice((new SimpleStringProperty(""))); + } + materialsTable.refresh(); + } + // 设置可编辑 + editWrite(); + + } catch (Exception e) { + e.printStackTrace(); + } + + }); + + // 版本下拉框,按钮监听 + 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\" = '" + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"revision\" = '" + selectedItem + + "' and \"cbdlx\" = '" + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "'"; + // 根据查询结果更新数据 + System.out.println(selSQL); + try { + ResultSet result = SqlUtil.read(selSQL); + while (result.next()) { + // costSheetTypeComboBox.setValue(result.getString("cbdlx")); + projectNameTextField.setText(result.getString("proname")); + transformerModelTextField.setText(result.getString("tramodel")); + noLoadLossTextField.setText(result.getString("noloadloss")); + loadLossTextField.setText(result.getString("loadloss")); + biddingNumberTextField.setText(result.getString("tennumber")); + capacityRatioTextField.setText(result.getString("capfactor")); + impedanceVoltageTextField.setText(result.getString("impvoltage")); + projectManagerTextField.setText(result.getString("promanager")); + voltageRatioTextField.setText(result.getString("volratio")); + transportationWeightTextField.setText(result.getString("traweight")); + quantityTextField.setText(result.getString("quantity")); + totalWeightTextField.setText(result.getString("totweight")); + copperAmountTextField.setText(QuotationUtil.formatString(result.getString("copconsumption"))); + copperMarketPriceTextField.setText(QuotationUtil.formatString(result.getString("cmarketprice"))); + voltageLevelTextField.setText(result.getString("vollevel")); + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + 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 + + "' 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(); + while (reSql1.next()) { + System.out.println("获取数据"); + QuotationMX quotationMX = new QuotationMX(); + quotationMX.setCbdlx(reSql1.getString("cbdlx")); + quotationMX.setProjectid(reSql1.getString("projectid")); + quotationMX.setRevision(reSql1.getString("revision")); + quotationMX.setMatgroup(new SimpleStringProperty(reSql1.getString("matgroup"))); + quotationMX.setMgsnumber(new SimpleStringProperty(reSql1.getString("mgsnumber"))); + quotationMX.setMatcname(new SimpleStringProperty(reSql1.getString("matcname"))); + quotationMX.setMatcnumber(new SimpleStringProperty(reSql1.getString("matcnumber"))); + quotationMX.setMatcatname(new SimpleStringProperty(reSql1.getString("matcatname"))); + quotationMX.setSpecifications(new SimpleStringProperty(reSql1.getString("specifications"))); + quotationMX.setManufacturer(new SimpleStringProperty(reSql1.getString("manufacturer"))); + quotationMX.setNwquantity( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("nwquantity")))); + quotationMX.setUtirate( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("utirate")))); + quotationMX.setUnit(new SimpleStringProperty(reSql1.getString("unit"))); + quotationMX.setAmomoney( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("amomoney")))); + quotationMX.setUnitprice( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("unitprice")))); + quotationMX.setNo(new SimpleStringProperty(reSql1.getString("no"))); + quotationMX.setContrastPrice(new SimpleStringProperty("")); + quotationMX.setTotalprice( + new SimpleStringProperty(QuotationUtil.formatString(reSql1.getString("totalprice")))); + tableList.add(quotationMX); + } + System.out.println("表格数据:" + tableList.size()); + System.out.println("表格数据:" + tableList.toString()); + if (tableList.size() > 0) { + System.out.println("查询到了明细数据,开始插入"); + // 循环插入刷新明细数据 + for (int j = 0; j < materialsTable.getItems().size(); j++) { + QuotationMX quotationMX = materialsTable.getItems().get(j); + quotationMX.setCbdlx(tableList.get(j).getCbdlx()); + quotationMX.setProjectid(tableList.get(j).getProjectid()); + quotationMX.setRevision(tableList.get(j).getRevision()); + quotationMX.setMatgroup(new SimpleStringProperty(tableList.get(j).getMatgroup())); + quotationMX.setMgsnumber(new SimpleStringProperty(tableList.get(j).getMgsnumber())); + quotationMX.setMatcname(new SimpleStringProperty(tableList.get(j).getMatcname())); + quotationMX.setMatcnumber(new SimpleStringProperty(tableList.get(j).getMatcnumber())); + quotationMX.setMatcatname(new SimpleStringProperty(tableList.get(j).getMatcatname())); + quotationMX.setSpecifications(new SimpleStringProperty(tableList.get(j).getSpecifications())); + quotationMX.setManufacturer(new SimpleStringProperty(tableList.get(j).getManufacturer())); + quotationMX.setNwquantity(new SimpleStringProperty(tableList.get(j).getNwquantity())); + quotationMX.setUtirate(new SimpleStringProperty(tableList.get(j).getUtirate())); + quotationMX.setUnit(new SimpleStringProperty(tableList.get(j).getUnit())); + 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.setContrastPrice(new SimpleStringProperty("")); + // quotationMX.setTotalprice(new + // SimpleStringProperty(reSql1.getString("totalprice"))); + + } + System.out.println("刷新表格"); + materialsTable.refresh(); + totalPriceTextField.setText(tableList.get(0).getTotalprice()); + } else { + System.out.println("没有找到明细数据,清空金额和对比结果数据"); + // 计算金额 + for (QuotationMX quotationMX : materialsTable.getItems()) { + quotationMX.setAmomoney((new SimpleStringProperty(""))); + quotationMX.setContrastPrice((new SimpleStringProperty(""))); + } + materialsTable.refresh(); + } + // 修改明细是否可以编辑 + if (!rev.equals(selectedItem)) { + // 设置不可编辑 + onlyRead(); + } else { + // 设置可编辑 + editWrite(); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + }); + + // 保存按钮 + saveButton.setOnAction(event -> { + // 校验数据 + String selectedItem = costSheetTypeComboBox.getSelectionModel().getSelectedItem(); + if (selectedItem == null || "".equals(selectedItem)) { // MessageBox.post("未选择成本单类型","提示", MessageBox.INFORMATION); - MessageBox.post(paramKFXPanel.getParentDialog(), "未选择成本单类型", "提示", MessageBox.INFORMATION); - return; - } - if("报价成本单".equals(selectedItem)) { - MessageBox.post(paramKFXPanel.getParentDialog(), "不能选择“报价成本单”进行保存", "提示", MessageBox.INFORMATION); + MessageBox.post(paramKFXPanel.getParentDialog(), "未选择成本单类型", "提示", MessageBox.INFORMATION); + return; + } + if ("报价成本单".equals(selectedItem)) { + MessageBox.post(paramKFXPanel.getParentDialog(), "不能选择“报价成本单”进行保存", "提示", MessageBox.INFORMATION); // MessageBox.post("不能选择“报价成本单”进行保存", "提示", MessageBox.INFORMATION); - return; - } - //保存或者更新头表 - String newCbdlx = costSheetTypeComboBox.getSelectionModel().getSelectedItem(); - String newProjectid = ButtonCellEditor.cusquotation.getProjectid(); - String newRevision = editionComboBox.getSelectionModel().getSelectedItem(); - String newFactory = ButtonCellEditor.cusquotation.getFactory(); - String newProname = projectNameTextField.getText(); - String newTennumber = biddingNumberTextField.getText(); - String newPromanager = projectManagerTextField.getText(); - String newQuantity = quantityTextField.getText(); - String newTramodel = transformerModelTextField.getText(); - String newCapfactor = capacityRatioTextField.getText(); - String newVolratio = voltageRatioTextField.getText(); - String newNoloadloss = noLoadLossTextField.getText(); - String newLoadloss = loadLossTextField.getText(); - String newImpvoltage = impedanceVoltageTextField.getText(); - String newTraweight = transportationWeightTextField.getText(); - String newTotweight = totalWeightTextField.getText(); - String newCopconsumption = copperAmountTextField.getText(); - String newCmarketprice = copperMarketPriceTextField.getText(); - String newVollevel = voltageLevelTextField.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() + "'"; - System.out.println("set:"+set); - try { - ResultSet read = SqlUtil.read(set); - if(read.next()) { - isExist = false; - //更新数据 - 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()+"' and \"revision\" = '" + editionComboBox.getSelectionModel().getSelectedItem() + "'"; - System.out.println("insertTop:"+updateTop); - SqlUtil.update(updateTop); - System.out.println("更新数据成功"); - - //将关联的明细表数据删除,重新插入数据 - - String deleSql = "DELETE FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"cbdlx\" = '" + costSheetTypeComboBox.getSelectionModel().getSelectedItem() +"' 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() + "'"; - 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('"+ - newCbdlx+"','"+ - newProjectid+"','"+ - newRevision+"','"+ - newFactory+"','"+ - newProname+"','"+ - newTennumber+"','"+ - newPromanager+"','"+ - newQuantity+"','"+ - newTramodel+"','"+ - newCapfactor+"','"+ - newVolratio+"','"+ - newNoloadloss+"','"+ - newLoadloss+"','"+ - newImpvoltage+"','"+ - newTraweight+"','"+ - newTotweight+"','"+ - newCopconsumption+"','"+ - newCmarketprice+"','"+ - newVollevel+"')"; - System.out.println("insertTop:"+insertTop); - SqlUtil.write(insertTop); - System.out.println("插入数据成功"); - } - } catch (SQLException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } - - //保存明细 - for(int a=0;a0) { - //保存成本单对比结果信息表 - //保存明细表 - 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()+"','"+ - ButtonCellEditor.cusquotation.getProjectid()+"','"+ - editionComboBox.getSelectionModel().getSelectedItem()+"','"+ - dbRevList.get(a)+"','"+ - dbjg+"','"+ - newFactory+"','"+ - group+"','"+ - Mgsnumber+"','"+ - Matcname+"','"+ - Matcnumber+"','"+ - Matcatname+"','"+ - dbmatcatnameList.get(a)+"','"+ - Specifications+"','"+ - Manufacturer+"','"+ - Nwquantity+"','"+ - dbnwquantityList.get(a)+"','"+ - Utirate+"','"+ - dbutirateList.get(a)+"','"+ - Unit+"','"+ - dbunitList.get(a)+"','"+ - Amomoney+"','"+ - moneyList.get(a)+"','"+ - Unitprice+"','"+ - dbunitpriceList.get(a)+"','"+ - No+"','"+ - DbnoList.get(a)+"','"+ - Totalprice+"','"+ - dbtotalpriceList.get(a)+"')"; - - System.out.println("insert:"+insert1); - System.out.println("插入数据库:"+insert1); - int write1 = SqlUtil.write(insert1); - System.out.println("受影响的行:"+write1); - } - - } - if(isExist) { - //创建新对象 - try { - TCComponentItemType tccomponentitemtype = (TCComponentItemType)ButtonCellEditor.session.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()); - item.getLatestItemRevision().setProperty("object_desc", ButtonCellEditor.cusquotation.getProjectid()); - //挂在选中的文件夹下面 - ButtonCellEditor.f.add("contents",item); - } catch (TCException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - MessageBox.post(paramKFXPanel.getParentDialog(), "保存成功", "提示", MessageBox.INFORMATION); - + return; + } + // 保存或者更新头表 + String newCbdlx = costSheetTypeComboBox.getSelectionModel().getSelectedItem(); + String newProjectid = ButtonCellEditor.cusquotation.getProjectid(); + String newRevision = editionComboBox.getSelectionModel().getSelectedItem(); + String newFactory = ButtonCellEditor.cusquotation.getFactory(); + String newProname = projectNameTextField.getText(); + String newTennumber = biddingNumberTextField.getText(); + String newPromanager = projectManagerTextField.getText(); + String newQuantity = quantityTextField.getText(); + String newTramodel = transformerModelTextField.getText(); + String newCapfactor = capacityRatioTextField.getText(); + String newVolratio = voltageRatioTextField.getText(); + String newNoloadloss = noLoadLossTextField.getText(); + String newLoadloss = loadLossTextField.getText(); + String newImpvoltage = impedanceVoltageTextField.getText(); + String newTraweight = transportationWeightTextField.getText(); + String newTotweight = totalWeightTextField.getText(); + String newCopconsumption = copperAmountTextField.getText(); + String newCmarketprice = copperMarketPriceTextField.getText(); + String newVollevel = voltageLevelTextField.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() + "'"; + System.out.println("set:" + set); + try { + ResultSet read = SqlUtil.read(set); + if (read.next()) { + isExist = false; + // 更新数据 + 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() + + "' and \"revision\" = '" + editionComboBox.getSelectionModel().getSelectedItem() + "'"; + System.out.println("insertTop:" + updateTop); + SqlUtil.update(updateTop); + System.out.println("更新数据成功"); + + // 将关联的明细表数据删除,重新插入数据 + + String deleSql = "DELETE FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"cbdlx\" = '" + + costSheetTypeComboBox.getSelectionModel().getSelectedItem() + "' 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() + "'"; + 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('" + + newCbdlx + "','" + newProjectid + "','" + newRevision + "','" + newFactory + "','" + + newProname + "','" + newTennumber + "','" + newPromanager + "','" + newQuantity + "','" + + newTramodel + "','" + newCapfactor + "','" + newVolratio + "','" + newNoloadloss + "','" + + newLoadloss + "','" + newImpvoltage + "','" + newTraweight + "','" + newTotweight + "','" + + newCopconsumption + "','" + newCmarketprice + "','" + newVollevel + "')"; + System.out.println("insertTop:" + insertTop); + SqlUtil.write(insertTop); + System.out.println("插入数据成功"); + } + } catch (SQLException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + // 保存明细 + for (int a = 0; a < materialsTable.getItems().size(); a++) { + QuotationMX quotationMX = materialsTable.getItems().get(a); + // 将数据保存到数据库CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE中 + String group = ""; + if (quotationMX.getMatgroup() != null) { + group = quotationMX.getMatgroup(); + } + String Mgsnumber = ""; + if (quotationMX.getMgsnumber() != null) { + Mgsnumber = quotationMX.getMgsnumber(); + } + String Matcname = ""; + if (quotationMX.getMatcname() != null) { + Matcname = quotationMX.getMatcname(); + } + String Matcnumber = ""; + if (quotationMX.getMatcnumber() != null) { + Matcnumber = quotationMX.getMatcnumber(); + } + String Matcatname = ""; + if (quotationMX.getMatcatname() != null) { + Matcatname = quotationMX.getMatcatname(); + } + String Specifications = ""; + if (quotationMX.getSpecifications() != null) { + Specifications = quotationMX.getSpecifications(); + } + String Manufacturer = ""; + if (quotationMX.getManufacturer() != null) { + Manufacturer = quotationMX.getManufacturer(); + } + + String Nwquantity = ""; + if (quotationMX.getNwquantity() != null) { + Nwquantity = quotationMX.getNwquantity(); + } + String Utirate = ""; + if (quotationMX.getUtirate() != null) { + Utirate = quotationMX.getUtirate(); + } + String Unit = ""; + if (quotationMX.getUnit() != null) { + Unit = quotationMX.getUnit(); + } + String Amomoney = ""; + if (quotationMX.getAmomoney() != null) { + Amomoney = quotationMX.getAmomoney(); + } + String Unitprice = ""; + if (quotationMX.getUnitprice() != null) { + Unitprice = quotationMX.getUnitprice(); + } + String No = ""; + if (quotationMX.getNo() != null) { + No = quotationMX.getNo(); + } + String Totalprice = ""; + if (quotationMX.getTotalprice() != null) { + Totalprice = totalPriceTextField.getText(); + } + String dbjg = ""; + if (quotationMX.getContrastPrice() != null) { + dbjg = quotationMX.getContrastPrice(); + } + // 保存明细表 + 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() + "','" + + editionComboBox.getSelectionModel().getSelectedItem() + "','" + group + "','" + Mgsnumber + + "','" + Matcname + "','" + Matcnumber + "','" + Matcatname + "','" + Specifications + "','" + + Manufacturer + "','" + Nwquantity + "','" + Utirate + "','" + Unit + "','" + Amomoney + "','" + + Unitprice + "','" + No + "','" + Totalprice + "')"; + System.out.println("insert:" + insert); + System.out.println("插入数据库:" + insert); + int write = SqlUtil.write(insert); + System.out.println("受影响的行:" + write); + + 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() + "','" + + ButtonCellEditor.cusquotation.getProjectid() + "','" + + editionComboBox.getSelectionModel().getSelectedItem() + "','" + dbRevList.get(a) + "','" + + dbjg + "','" + newFactory + "','" + group + "','" + Mgsnumber + "','" + Matcname + "','" + + Matcnumber + "','" + Matcatname + "','" + dbmatcatnameList.get(a) + "','" + Specifications + + "','" + Manufacturer + "','" + Nwquantity + "','" + dbnwquantityList.get(a) + "','" + + Utirate + "','" + dbutirateList.get(a) + "','" + Unit + "','" + dbunitList.get(a) + "','" + + Amomoney + "','" + moneyList.get(a) + "','" + Unitprice + "','" + dbunitpriceList.get(a) + + "','" + No + "','" + DbnoList.get(a) + "','" + Totalprice + "','" + + dbtotalpriceList.get(a) + "')"; + + System.out.println("insert:" + insert1); + System.out.println("插入数据库:" + insert1); + int write1 = SqlUtil.write(insert1); + System.out.println("受影响的行:" + write1); + } + + } + if (isExist) { + // 创建新对象 + try { + TCComponentItemType tccomponentitemtype = (TCComponentItemType) ButtonCellEditor.session + .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()); + item.getLatestItemRevision().setProperty("object_desc", + ButtonCellEditor.cusquotation.getProjectid()); + // 挂在选中的文件夹下面 + ButtonCellEditor.f.add("contents", item); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + MessageBox.post(paramKFXPanel.getParentDialog(), "保存成功", "提示", MessageBox.INFORMATION); + // MessageBox.post("保存成功", "提示", MessageBox.INFORMATION); - }); - - //计算金额按钮 - 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); + }); + + // 计算金额按钮 + 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+"")); - - }); - - - - selectComparisonButton.setOnAction(event->{ - //选择对比按钮 - String sql3 = "SELECT \"cbdlx\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '"+ButtonCellEditor.cusquotation.getProjectid()+"'"; - System.out.println(sql3); - ResultSet resultSet3 = null; - try { - resultSet3 = SqlUtil.read(sql3); - } catch (SQLException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } - Set selectType = new HashSet(); - try { - while(resultSet3.next()) { - selectType.add(resultSet3.getString("cbdlx")); - } - } catch (SQLException e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); - } - //弹出对比窗口 - System.out.println("弹出对比窗口"); + 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 + "")); + + }); + + selectComparisonButton.setOnAction(event -> { + // 选择对比按钮 + String sql3 = "SELECT \"cbdlx\" FROM \"CHINT_ CUSQUOTATION_TITLE_TEMPLATE\" where \"projectid\" = '" + + ButtonCellEditor.cusquotation.getProjectid() + "'"; + System.out.println(sql3); + ResultSet resultSet3 = null; + try { + resultSet3 = SqlUtil.read(sql3); + } catch (SQLException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + Set selectType = new HashSet(); + try { + while (resultSet3.next()) { + selectType.add(resultSet3.getString("cbdlx")); + } + } catch (SQLException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + // 弹出对比窗口 + 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]); - if (selectedOption != null) { - moneyList = new ArrayList(); - dbRevList = new ArrayList(); - dbmatcatnameList = new ArrayList(); - dbnwquantityList = new ArrayList(); - dbutirateList = new ArrayList(); - dbunitList = new ArrayList(); - dbunitpriceList = new ArrayList(); - DbnoList = new ArrayList(); - dbtotalpriceList = new ArrayList(); - System.out.println("用户选择的选项:" + selectedOption); - //获取数据库该类型成本单最新的版本 - String getLastRevSql = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"projectid\" = '"+ButtonCellEditor.cusquotation.getProjectid()+"' and \"cbdlx\" = '" + selectedOption + "' order by \"revision\" desc" ; - System.out.println("getLastRevSql:"+getLastRevSql); - try { - ResultSet resultSet4 = SqlUtil.read(getLastRevSql); - while(resultSet4.next()) { - dbRevList.add(resultSet4.getString("revision")); - } - } catch (SQLException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - - String sql4 = "SELECT \"matcatname\",\"nwquantity\",\"utirate\",\"unit\",\"amomoney\",\"unitprice\",\"no\",\"totalprice\" FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"projectid\" = '"+ButtonCellEditor.cusquotation.getProjectid()+"' and \"cbdlx\" = '" + selectedOption + "' and \"revision\" = '" +dbRevList.get(0)+ "' order by \"matgroup\" asc,TO_NUMBER(\"mgsnumber\") asc ,TO_NUMBER(\"matcnumber\") asc,TO_NUMBER(\"no\") asc"; - System.out.println("sql4:"+sql4); - Boolean zjdbjg = false; - if(totalPriceCompareTextField.getText()==null || "".equals(totalPriceCompareTextField.getText())) { - zjdbjg = true; - } - try { - ResultSet resultSet4 = SqlUtil.read(sql4); - - while(resultSet4.next()) { - dbmatcatnameList.add(resultSet4.getString("matcatname")); - dbnwquantityList.add(resultSet4.getString("nwquantity")); - dbutirateList.add(resultSet4.getString("utirate")); - dbunitList.add(resultSet4.getString("unit")); - moneyList.add(resultSet4.getString("amomoney")); - dbunitpriceList.add(resultSet4.getString("unitprice")); - DbnoList.add(resultSet4.getString("no")); - if(zjdbjg) { - dbtotalpriceList.add("0"); - }else { - dbtotalpriceList.add(totalPriceCompareTextField.getText()); - } - - - } - } catch (SQLException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - //开始刷新对比结果数据 - //获取数据库该类型成本单最新的版本 - String getLastRevSql1 = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"projectid\" = '"+ButtonCellEditor.cusquotation.getProjectid()+"' and \"cbdlx\" = '" + selectedOption + "' order by \"revision\" desc" ; - System.out.println("getLastRevSql:"+getLastRevSql1); - List revList = new ArrayList(); - try { - ResultSet resultSet4 = SqlUtil.read(getLastRevSql1); - while(resultSet4.next()) { - revList.add(resultSet4.getString("revision")); - } - } catch (SQLException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - 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 +"' 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(); - while(reSql1.next()) { - tableList.add(QuotationUtil.formatString(reSql1.getString("dbjg"))); - } - if(tableList.size()>0) { - System.out.println("查询到了对比结果明细数据,开始插入"); - //循环插入刷新明细数据 - for(int j=0;j{ - if(moneyList == null) { - MessageBox.post(paramKFXPanel.getParentDialog(), "请选择需要对比的类型操作", "提示", MessageBox.INFORMATION); + 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]); + if (selectedOption != null) { + moneyList = new ArrayList(); + dbRevList = new ArrayList(); + dbmatcatnameList = new ArrayList(); + dbnwquantityList = new ArrayList(); + dbutirateList = new ArrayList(); + dbunitList = new ArrayList(); + dbunitpriceList = new ArrayList(); + DbnoList = new ArrayList(); + dbtotalpriceList = new ArrayList(); + System.out.println("用户选择的选项:" + selectedOption); + // 获取数据库该类型成本单最新的版本 + String getLastRevSql = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"projectid\" = '" + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" + selectedOption + + "' order by \"revision\" desc"; + System.out.println("getLastRevSql:" + getLastRevSql); + try { + ResultSet resultSet4 = SqlUtil.read(getLastRevSql); + while (resultSet4.next()) { + dbRevList.add(resultSet4.getString("revision")); + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + String sql4 = "SELECT \"matcatname\",\"nwquantity\",\"utirate\",\"unit\",\"amomoney\",\"unitprice\",\"no\",\"totalprice\" FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"projectid\" = '" + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" + selectedOption + + "' and \"revision\" = '" + dbRevList.get(0) + + "' order by \"matgroup\" asc,TO_NUMBER(\"mgsnumber\") asc ,TO_NUMBER(\"matcnumber\") asc,TO_NUMBER(\"no\") asc"; + System.out.println("sql4:" + sql4); + Boolean zjdbjg = false; + if (totalPriceCompareTextField.getText() == null || "".equals(totalPriceCompareTextField.getText())) { + zjdbjg = true; + } + try { + ResultSet resultSet4 = SqlUtil.read(sql4); + + while (resultSet4.next()) { + dbmatcatnameList.add(resultSet4.getString("matcatname")); + dbnwquantityList.add(resultSet4.getString("nwquantity")); + dbutirateList.add(resultSet4.getString("utirate")); + dbunitList.add(resultSet4.getString("unit")); + moneyList.add(resultSet4.getString("amomoney")); + dbunitpriceList.add(resultSet4.getString("unitprice")); + DbnoList.add(resultSet4.getString("no")); + if (zjdbjg) { + dbtotalpriceList.add("0"); + } else { + dbtotalpriceList.add(totalPriceCompareTextField.getText()); + } + + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // 开始刷新对比结果数据 + // 获取数据库该类型成本单最新的版本 + String getLastRevSql1 = "SELECT \"revision\" FROM \"CHINT_ CUSQUOTATION_ DETAILS_TEMPLATE\" where \"projectid\" = '" + + ButtonCellEditor.cusquotation.getProjectid() + "' and \"cbdlx\" = '" + selectedOption + + "' order by \"revision\" desc"; + System.out.println("getLastRevSql:" + getLastRevSql1); + List revList = new ArrayList(); + try { + ResultSet resultSet4 = SqlUtil.read(getLastRevSql1); + while (resultSet4.next()) { + revList.add(resultSet4.getString("revision")); + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + 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 + + "' 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(); + while (reSql1.next()) { + tableList.add(QuotationUtil.formatString(reSql1.getString("dbjg"))); + } + if (tableList.size() > 0) { + System.out.println("查询到了对比结果明细数据,开始插入"); + // 循环插入刷新明细数据 + for (int j = 0; j < materialsTable.getItems().size(); j++) { + QuotationMX quotationMX = materialsTable.getItems().get(j); + if (tableList.get(j) == null || "".equals(tableList.get(j))) { + tableList.set(j, "0"); + } + System.out.println(tableList.get(j)); + quotationMX.setContrastPrice( + new SimpleStringProperty(QuotationUtil.formatString(tableList.get(j)))); + } + System.out.println("刷新表格"); + materialsTable.refresh(); + // 填入对比结果 + Double total = 0.00; + for (String amomoney : tableList) { + if (amomoney == null || "".equals(amomoney.trim())) { + amomoney = "0"; + } + System.out.println(amomoney); + Double money = Double.valueOf(amomoney); + total += money; + } + totalPriceCompareTextField.setText(QuotationUtil.formatString(total + "")); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + } else { + selectedOption = ""; + System.out.println("用户取消了选择"); + } + // 填入要对比的成本单 + comparedCostSheetTextField.setText(selectedOption); + }); + + // 对比按钮 + compareButton.setOnAction(event -> { + if (moneyList == null) { + MessageBox.post(paramKFXPanel.getParentDialog(), "请选择需要对比的类型操作", "提示", MessageBox.INFORMATION); // MessageBox.post("请选择需要对比的类型操作", "提示", MessageBox.INFORMATION); - return; - } - - if(costSheetTypeComboBox.getSelectionModel().getSelectedItem() == null || "".equals(costSheetTypeComboBox.getSelectionModel().getSelectedItem())) { - MessageBox.post(paramKFXPanel.getParentDialog(), "请选择对比成本单", "提示", MessageBox.INFORMATION); + return; + } + + if (costSheetTypeComboBox.getSelectionModel().getSelectedItem() == null + || "".equals(costSheetTypeComboBox.getSelectionModel().getSelectedItem())) { + MessageBox.post(paramKFXPanel.getParentDialog(), "请选择对比成本单", "提示", MessageBox.INFORMATION); // MessageBox.post("请选择对比成本单", "提示", MessageBox.INFORMATION); - return; - } - //判断数量、利用率、单价是否为数字 - for(int i=0;i processRouteFiles; - - private List esopFiles; - - + private String factoryCode; - public Process() { - super(); - } + private String processName; + private String processCode; + private String workCenter; - public Process(String factoryCode, String processName, String processCode, String workCenter, String processType, - List processRouteFiles, List esopFiles) { - super(); - this.factoryCode = factoryCode; - this.processName = processName; - this.processCode = processCode; - this.workCenter = workCenter; - this.processType = processType; - this.processRouteFiles = processRouteFiles; - this.esopFiles = esopFiles; - } + private String processType; + private List processRouteFiles; + private List esopFiles; - public String getFactoryCode() { - return factoryCode; - } + public Process() { + super(); + } + public Process(String factoryCode, String processName, String processCode, String workCenter, String processType, + List processRouteFiles, List esopFiles) { + super(); + this.factoryCode = factoryCode; + this.processName = processName; + this.processCode = processCode; + this.workCenter = workCenter; + this.processType = processType; + this.processRouteFiles = processRouteFiles; + this.esopFiles = esopFiles; + } + public String getFactoryCode() { + return factoryCode; + } - public void setFactoryCode(String factoryCode) { - this.factoryCode = factoryCode; - } + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + public String getProcessName() { + return processName; + } + public void setProcessName(String processName) { + this.processName = processName; + } - public String getProcessName() { - return processName; - } + public String getProcessCode() { + return processCode; + } + public void setProcessCode(String processCode) { + this.processCode = processCode; + } + public String getWorkCenter() { + return workCenter; + } - public void setProcessName(String processName) { - this.processName = processName; - } + public void setWorkCenter(String workCenter) { + this.workCenter = workCenter; + } + public String getProcessType() { + return processType; + } + public void setProcessType(String processType) { + this.processType = processType; + } - public String getProcessCode() { - return processCode; - } + public List getProcessRouteFiles() { + return processRouteFiles; + } + public void setProcessRouteFiles(List processRouteFiles) { + this.processRouteFiles = processRouteFiles; + } + public List getEsopFiles() { + return esopFiles; + } - public void setProcessCode(String processCode) { - this.processCode = processCode; - } + public void setEsopFiles(List esopFiles) { + this.esopFiles = esopFiles; + } + @Override + public String toString() { + return "Process [factoryCode=" + factoryCode + ", processName=" + processName + ", processCode=" + processCode + + ", workCenter=" + workCenter + ", processType=" + processType + ", processRouteFiles=" + + processRouteFiles + ", esopFiles=" + esopFiles + "]"; + } - - public String getWorkCenter() { - return workCenter; - } - - - - public void setWorkCenter(String workCenter) { - this.workCenter = workCenter; - } - - - - public String getProcessType() { - return processType; - } - - - - public void setProcessType(String processType) { - this.processType = processType; - } - - - - public List getProcessRouteFiles() { - return processRouteFiles; - } - - - - public void setProcessRouteFiles(List processRouteFiles) { - this.processRouteFiles = processRouteFiles; - } - - - - public List getEsopFiles() { - return esopFiles; - } - - - - public void setEsopFiles(List esopFiles) { - this.esopFiles = esopFiles; - } - - - - @Override - public String toString() { - return "Process [factoryCode=" + factoryCode + ", processName=" + processName + ", processCode=" + processCode - + ", workCenter=" + workCenter + ", processType=" + processType + ", processRouteFiles=" - + processRouteFiles + ", esopFiles=" + esopFiles + "]"; - } - - - } diff --git a/com.connor.chint.wuhan/src/com/connor/plm/SendGXToMOM/sendGXToMOMHandler.java b/com.connor.chint.wuhan/src/com/connor/plm/SendGXToMOM/sendGXToMOMHandler.java index 0a3c286..4718cb9 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/SendGXToMOM/sendGXToMOMHandler.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/SendGXToMOM/sendGXToMOMHandler.java @@ -30,45 +30,43 @@ import javafx.beans.property.SimpleStringProperty; /** * 标准工序传递MOM - * @author hongcj - * 2023/11/29 + * + * @author hongcj 2023/11/29 */ -public class sendGXToMOMHandler extends AbstractHandler{ - @Override - public Object execute(ExecutionEvent arg0) throws ExecutionException { - // TODO Auto-generated method stub - AbstractAIFApplication app = AIFUtility.getCurrentApplication(); - TCSession session = (TCSession)app.getSession(); - try { - new Thread() { - @Override - public void run() { - // 获取tc当前选择的操作 - InterfaceAIFComponent target = app.getTargetComponent(); - if(target instanceof TCComponentItemRevision) { - TCComponentItemRevision revision = (TCComponentItemRevision)target; - try { - String type = revision.getStringProperty("object_type"); - if("ZT2_FirstOPRevision".equals(type) || "MEOPRevision".equals(type)) { - sendGXToMOMOperation sendGXToMOMOperation = new sendGXToMOMOperation(session,revision); - session.queueOperation(sendGXToMOMOperation); - }else { - MessageBox.post("请选择标准工序对象操作", "提示", MessageBox.INFORMATION); - } - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - }else { - MessageBox.post("请选择版本对象操作", "提示", MessageBox.INFORMATION); - } - } - }.start(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } +public class sendGXToMOMHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + new Thread() { + @Override + public void run() { + // 获取tc当前选择的操作 + InterfaceAIFComponent target = app.getTargetComponent(); + if (target instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) target; + try { + String type = revision.getStringProperty("object_type"); + if ("ZT2_FirstOPRevision".equals(type) || "MEOPRevision".equals(type)) { + sendGXToMOMOperation sendGXToMOMOperation = new sendGXToMOMOperation(session, revision); + session.queueOperation(sendGXToMOMOperation); + } else { + MessageBox.post("请选择标准工序对象操作", "提示", MessageBox.INFORMATION); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + MessageBox.post("请选择版本对象操作", "提示", MessageBox.INFORMATION); + } + } + }.start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } } - - diff --git a/com.connor.chint.wuhan/src/com/connor/plm/SendGXToMOM/sendGXToMOMOperation.java b/com.connor.chint.wuhan/src/com/connor/plm/SendGXToMOM/sendGXToMOMOperation.java index c1dac35..e3aa0e4 100644 --- a/com.connor.chint.wuhan/src/com/connor/plm/SendGXToMOM/sendGXToMOMOperation.java +++ b/com.connor.chint.wuhan/src/com/connor/plm/SendGXToMOM/sendGXToMOMOperation.java @@ -24,166 +24,173 @@ import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.util.MessageBox; -public class sendGXToMOMOperation extends AbstractAIFOperation{ - private TCSession session; - private TCComponentItemRevision revision; - - public sendGXToMOMOperation(TCSession session, TCComponentItemRevision revision) { - // TODO Auto-generated constructor stub - this.session = session; - this.revision = revision; - } - - @Override - public void executeOperation() throws Exception { - // TODO Auto-generated method stub - System.out.println("开始获取信息传递"); - System.out.println("获取工厂"); - Process process = new Process(); - String groupID = SAPUtil.getGroupID(session); - System.out.println(groupID); - process.setFactoryCode(groupID); - - System.out.println("获取工序名称"); - String name = revision.getStringProperty("object_name"); - System.out.println(name); - process.setProcessName(name); - - System.out.println("获取工序编码"); - String code = revision.getStringProperty("zt2_ClassificationCode"); - System.out.println(code); - process.setProcessCode(code); - - System.out.println("获取工作中心"); - String center = revision.getStringProperty("zt2_WorkCenter"); - System.out.println(center); - process.setProcessCode(center); - - System.out.println("获取工序类型"); - String type = revision.getStringProperty("object_type"); - System.out.println(type); - if("ZT2_FirstOPRevision".equals(type)) { - process.setProcessType("1"); - List fileJsons = new ArrayList(); - process.setProcessRouteFiles(fileJsons); - List fileJsons1 = new ArrayList(); - process.setEsopFiles(fileJsons1); - }else { - process.setProcessType("2"); - System.out.println("开始获取file数组1"); - TCComponent[] referenceListProperty = revision.getReferenceListProperty("ZT2_ProcessRuleRelation"); - List fileJsons = new ArrayList(); - if(referenceListProperty!=null && referenceListProperty.length>0) { - for(TCComponent component : referenceListProperty) { - String gxType = component.getStringProperty("object_type"); - if("ZT2_ProcessRule".equals(gxType)) { - TCComponentItemRevision latestItemRevision = ((TCComponentItem)component).getLatestItemRevision(); - TCComponent[] referenceListProperty2 = latestItemRevision.getReferenceListProperty("IMAN_specification"); - if(referenceListProperty2!=null && referenceListProperty2.length>0) { - for(TCComponent component2 : referenceListProperty2) { - String typePdf = component2.getStringProperty("object_type"); - if("PDF".equals(typePdf) || "pdf".equals(typePdf)) { - FileJson fileJson = new FileJson(); - fileJson.setName(component2.getStringProperty("object_name")); - fileJson.setUid(component2.getUid()); - fileJson.setNo((fileJsons.size()+1)*10+""); - fileJsons.add(fileJson); - } - } - } - - } - } - } - - System.out.println(fileJsons.toString()); - process.setProcessRouteFiles(fileJsons); - - System.out.println("开始获取file数组2"); - TCComponent[] referenceListProperty1 = revision.getReferenceListProperty("ZT2_ProcGuidBookRelation"); - List fileJsons1 = new ArrayList(); - if(referenceListProperty1!=null && referenceListProperty1.length>0) { - for(TCComponent component : referenceListProperty1) { - String gxType = component.getStringProperty("object_type"); - if("ZT2_ProcGuidBook".equals(gxType)) { - TCComponentItemRevision latestItemRevision = ((TCComponentItem)component).getLatestItemRevision(); - TCComponent[] referenceListProperty2 = latestItemRevision.getReferenceListProperty("IMAN_specification"); - if(referenceListProperty2!=null && referenceListProperty2.length>0) { - for(TCComponent component2 : referenceListProperty2) { - String typePdf = component2.getStringProperty("object_type"); - if("PDF".equals(typePdf) || "pdf".equals(typePdf)) { - FileJson fileJson = new FileJson(); - fileJson.setName(component2.getStringProperty("object_name")); - fileJson.setUid(component2.getUid()); - fileJson.setNo((fileJsons1.size()+1)*10+""); - fileJsons1.add(fileJson); - } - } - } - - } - } - } - - System.out.println(fileJsons1.toString()); - process.setEsopFiles(fileJsons1); - } - - - System.out.println("要发送的数据"+process.toString()); - - String json = JSON.toJSONString(process); - System.out.println("要发送的json"+json); - - String url = session.getPreferenceService().getStringValue("CHINT_SENDGXTOMOMURL"); - if(url==null) { - MessageBox.post("首选项【CHINT_SENDGXTOMOMURL】配置有误,请检查", "错误", MessageBox.ERROR); - return; - }else { - System.out.println(url); - String sendJsonHttpPost = sendJsonHttpPost(url,json); - JSONObject parseObject = JSONObject.parseObject(sendJsonHttpPost); - - - MessageBox.post(parseObject.getString("msg"), "提示", MessageBox.INFORMATION); - } - - } - - public String sendJsonHttpPost(String url, String json) { - - CloseableHttpClient httpclient = HttpClients.createDefault(); - String responseInfo = null; - try { - HttpPost httpPost = new HttpPost(url); - // 设置请求头部 - httpPost.setHeader("Content-Type", "application/json"); - if(url.contains("10.128.11.12")) { - httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg="); - //http://10.128.11.12:7788/gateway/chint/bop-sync - }else { - httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg="); - } - // 设置请求体 - StringEntity entityReq = new StringEntity(json, StandardCharsets.UTF_8); - httpPost.setEntity(entityReq); - - CloseableHttpResponse response = httpclient.execute(httpPost); - HttpEntity entity = response.getEntity(); - int status = response.getStatusLine().getStatusCode(); - String string = EntityUtils.toString(entity); - System.out.println("MOM status:" + status + "responseInfo:" + string); - return string; - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - httpclient.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return responseInfo; - } +public class sendGXToMOMOperation extends AbstractAIFOperation { + private TCSession session; + private TCComponentItemRevision revision; + + public sendGXToMOMOperation(TCSession session, TCComponentItemRevision revision) { + // TODO Auto-generated constructor stub + this.session = session; + this.revision = revision; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + System.out.println("开始获取信息传递"); + System.out.println("获取工厂"); + Process process = new Process(); + String groupID = SAPUtil.getGroupID(session); + System.out.println(groupID); + process.setFactoryCode(groupID); + + System.out.println("获取工序名称"); + String name = revision.getStringProperty("object_name"); + System.out.println(name); + process.setProcessName(name); + + System.out.println("获取工序编码"); + String code = revision.getStringProperty("zt2_ClassificationCode"); + System.out.println(code); + process.setProcessCode(code); + + System.out.println("获取工作中心"); + String center = revision.getStringProperty("zt2_WorkCenter"); + System.out.println(center); + process.setProcessCode(center); + + System.out.println("获取工序类型"); + String type = revision.getStringProperty("object_type"); + System.out.println(type); + if ("ZT2_FirstOPRevision".equals(type)) { + process.setProcessType("1"); + // FileJson fileJson = new FileJson(); + + List fileJsons = new ArrayList(); + // fileJsons.add(fileJson); + process.setProcessRouteFiles(fileJsons); + + List fileJsons1 = new ArrayList(); + // fileJsons1.add(fileJson); + process.setEsopFiles(fileJsons1); + } else { + process.setProcessType("2"); + System.out.println("开始获取file数组1"); + TCComponent[] referenceListProperty = revision.getReferenceListProperty("ZT2_ProcessRuleRelation"); + List fileJsons = new ArrayList(); + if (referenceListProperty != null && referenceListProperty.length > 0) { + for (TCComponent component : referenceListProperty) { + String gxType = component.getStringProperty("object_type"); + if ("ZT2_ProcessRule".equals(gxType)) { + TCComponentItemRevision latestItemRevision = ((TCComponentItem) component) + .getLatestItemRevision(); + TCComponent[] referenceListProperty2 = latestItemRevision + .getReferenceListProperty("IMAN_specification"); + if (referenceListProperty2 != null && referenceListProperty2.length > 0) { + for (TCComponent component2 : referenceListProperty2) { + String typePdf = component2.getStringProperty("object_type"); + if ("PDF".equals(typePdf) || "pdf".equals(typePdf)) { + FileJson fileJson = new FileJson(); + fileJson.setName(component2.getStringProperty("object_name")); + fileJson.setUid(component2.getUid()); + fileJson.setNo((fileJsons.size() + 1) * 10 + ""); + fileJsons.add(fileJson); + } + } + } + + } + } + } + + System.out.println(fileJsons.toString()); + process.setProcessRouteFiles(fileJsons); + + System.out.println("开始获取file数组2"); + TCComponent[] referenceListProperty1 = revision.getReferenceListProperty("ZT2_ProcGuidBookRelation"); + List fileJsons1 = new ArrayList(); + if (referenceListProperty1 != null && referenceListProperty1.length > 0) { + for (TCComponent component : referenceListProperty1) { + String gxType = component.getStringProperty("object_type"); + if ("ZT2_ProcGuidBook".equals(gxType)) { + TCComponentItemRevision latestItemRevision = ((TCComponentItem) component) + .getLatestItemRevision(); + TCComponent[] referenceListProperty2 = latestItemRevision + .getReferenceListProperty("IMAN_specification"); + if (referenceListProperty2 != null && referenceListProperty2.length > 0) { + for (TCComponent component2 : referenceListProperty2) { + String typePdf = component2.getStringProperty("object_type"); + if ("PDF".equals(typePdf) || "pdf".equals(typePdf)) { + FileJson fileJson = new FileJson(); + fileJson.setName(component2.getStringProperty("object_name")); + fileJson.setUid(component2.getUid()); + fileJson.setNo((fileJsons1.size() + 1) * 10 + ""); + fileJsons1.add(fileJson); + } + } + } + + } + } + } + + System.out.println(fileJsons1.toString()); + process.setEsopFiles(fileJsons1); + } + + System.out.println("要发送的数据" + process.toString()); + + String json = JSON.toJSONString(process); + System.out.println("要发送的json" + json); + + String url = session.getPreferenceService().getStringValue("CHINT_SENDGXTOMOMURL"); + if (url == null) { + MessageBox.post("首选项【CHINT_SENDGXTOMOMURL】配置有误,请检查", "错误", MessageBox.ERROR); + return; + } else { + System.out.println(url); + String sendJsonHttpPost = sendJsonHttpPost(url, json); + JSONObject parseObject = JSONObject.parseObject(sendJsonHttpPost); + + MessageBox.post(parseObject.getString("msg"), "提示", MessageBox.INFORMATION); + } + + } + + public String sendJsonHttpPost(String url, String json) { + + CloseableHttpClient httpclient = HttpClients.createDefault(); + String responseInfo = null; + try { + HttpPost httpPost = new HttpPost(url); + // 设置请求头部 + httpPost.setHeader("Content-Type", "application/json"); + if (url.contains("10.128.11.12")) { + httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg="); + // http://10.128.11.12:7788/gateway/chint/bop-sync + } else { + httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg="); + } + // 设置请求体 + StringEntity entityReq = new StringEntity(json, StandardCharsets.UTF_8); + httpPost.setEntity(entityReq); + + CloseableHttpResponse response = httpclient.execute(httpPost); + HttpEntity entity = response.getEntity(); + int status = response.getStatusLine().getStatusCode(); + String string = EntityUtils.toString(entity); + System.out.println("MOM status:" + status + "responseInfo:" + string); + return string; + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return responseInfo; + } }