From f0138c265894fae3051244b14c0451057802811b Mon Sep 17 00:00:00 2001 From: lijh Date: Fri, 26 Apr 2024 14:55:16 +0800 Subject: [PATCH] =?UTF-8?q?bom=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StandardBOM/DYStandardBOMController.java | 390 +++++++++++++----- .../sap2/StandardBOM/DYStandardBOMDialog.java | 164 +++++--- .../sap2/StandardBOM/DYStandardBomBean.java | 279 +++++++------ 3 files changed, 529 insertions(+), 304 deletions(-) diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBOMController.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBOMController.java index 77da03f..732daa5 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBOMController.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBOMController.java @@ -27,6 +27,7 @@ import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.regex.Pattern; @@ -607,121 +608,290 @@ public class DYStandardBOMController { database_tc = ChintPreferenceUtil.getPreferences("database_tc", session); } - public void readData(ProgressBar pb, List revs) throws Exception { - pb.startProgress(); - pb.setText("加载数据..."); - DYStandardBomBean topBean; - TCComponentItemRevision rev; - TCComponentBOMWindow win = bomWinType.create(null); - TCComponent[] factoryNos; - DefaultMutableTreeNode topTreeNode, childNode; - TCComponentBOMLine topLine; - List paths = new ArrayList<>(); - TreePath path; - - - try { - Connection connection2 = SqlUtil.getConnection2(); - Statement state = connection2.createStatement(); - for (int i = 0, len = revs.size(); i < len; i++) { - rev = revs.get(i); - win.setWindowTopLine(rev.getItem(), rev, null, null); - topLine = win.getTopBOMLine(); - topBean = new DYStandardBomBean(rev, topLine, 1); -// if (KUtil.isTCM(rev)) { -// topBean.setIsTCM("已发布"); -// } +// public void readData(ProgressBar pb, List revs) throws Exception { +// pb.startProgress(); +// pb.setText("加载数据..."); +// DYStandardBomBean topBean; +// TCComponentItemRevision rev; +// TCComponentBOMWindow win = bomWinType.create(null); +// TCComponent[] factoryNos; +// DefaultMutableTreeNode topTreeNode, childNode; +// TCComponentBOMLine topLine; +// List paths = new ArrayList<>(); +// TreePath path; +// +// +// try { +// Connection connection2 = SqlUtil.getConnection2(); +// Statement state = connection2.createStatement(); +// for (int i = 0, len = revs.size(); i < len; i++) { +// rev = revs.get(i); +// win.setWindowTopLine(rev.getItem(), rev, null, null); +// topLine = win.getTopBOMLine(); +// topBean = new DYStandardBomBean(rev, topLine, 1); +//// if (KUtil.isTCM(rev)) { +//// topBean.setIsTCM("已发布"); +//// } +//// +//// //20240401优化速度 用sql查询id +//// +//// +//// factoryNos = rev.getRelatedComponents("ZT2_FactoryNumber"); +//// if (factoryNos != null && factoryNos.length > 0) { +//// for (int j = 0, len2 = factoryNos.length; j < len2; j++) { +//// topBean.addFactoryID(factoryNos[j].getProperty("item_id")); +//// } +//// } // -// //20240401优化速度 用sql查询id +// +// String uid = rev.getUid(); // // -// factoryNos = rev.getRelatedComponents("ZT2_FactoryNumber"); -// if (factoryNos != null && factoryNos.length > 0) { -// for (int j = 0, len2 = factoryNos.length; j < len2; j++) { -// topBean.addFactoryID(factoryNos[j].getProperty("item_id")); -// } -// } - - - String uid = rev.getUid(); - - - //表创建了视图 -// CREATE VIEW CHINT_FACTORY_NUMBER_VIEW AS -// (Select R.RPRIMARY_OBJECTU,R.RSECONDARY_OBJECTU,T.PTYPE_NAME,I.PITEM_ID,R2.PZT2_WEBNO,W.PDATE_RELEASED from PIMANRELATION R -// INNER JOIN PIMANTYPE T -// ON R.RRELATION_TYPEU = T.PUID AND T.PTYPE_NAME = 'ZT2_FactoryNumber' AND R.RPRIMARY_OBJECTU = 'BAmV5Bsjpof3PC' -// INNER JOIN PITEM I -// ON I.PUID = R.RSECONDARY_OBJECTU -// INNER JOIN PPART_0_REVISION_ALT R2 -// ON R.RPRIMARY_OBJECTU = R2.PUID -// INNER JOIN PWORKSPACEOBJECT W -// ON W.PUID = RPRIMARY_OBJECTU) - - -// String sql = "Select I.PITEM_ID from 'PIMANRELATION' R\r\n" + -// " INNER JOIN 'PIMANTYPE' T\r\n" + -// " ON R.RRELATION_TYPEU = T.PUID AND T.PTYPE_NAME = 'ZT2_FactoryNumber' AND R.RPRIMARY_OBJECTU = '"; -// sql += uid+"'\r\n" + -// " INNER JOIN PITEM I\r\n" + -// " ON I.PUID = R.RSECONDARY_OBJECTU"; - - String sql = "SELECT PITEM_ID,PZT2_WEBNO,PDATE_RELEASED FROM CHINT_FACTORY_NUMBER_VIEW WHERE PTYPE_NAME = 'ZT2_FactoryNumber' AND RPRIMARY_OBJECTU = '"; - sql += uid+"'"; - - System.out.println("查询语句:" + sql.toString()); - ResultSet rs = SqlUtil.read(sql.toString()); - - while (rs.next()) { - String itemId = rs.getString(1); - String webNo = rs.getString(2); - String release = rs.getString(3); -// if(release != null && !release.isEmpty()) { -// topBean.setIsTCM("已发布"); -// } - - topBean.setIsTCM(release == null ? "":"已发布"); - topBean.setStatus_BOM(webNo == null ? "":webNo); - topBean.addFactoryID(itemId == null ? "":itemId); - - } +// //表创建了视图 +//// CREATE VIEW CHINT_FACTORY_NUMBER_VIEW AS +//// (Select R.RPRIMARY_OBJECTU,R.RSECONDARY_OBJECTU,T.PTYPE_NAME,I.PITEM_ID,R2.PZT2_WEBNO,W.PDATE_RELEASED from PIMANRELATION R +//// INNER JOIN PIMANTYPE T +//// ON R.RRELATION_TYPEU = T.PUID AND T.PTYPE_NAME = 'ZT2_FactoryNumber' AND R.RPRIMARY_OBJECTU = 'BAmV5Bsjpof3PC' +//// INNER JOIN PITEM I +//// ON I.PUID = R.RSECONDARY_OBJECTU +//// INNER JOIN PPART_0_REVISION_ALT R2 +//// ON R.RPRIMARY_OBJECTU = R2.PUID +//// INNER JOIN PWORKSPACEOBJECT W +//// ON W.PUID = RPRIMARY_OBJECTU) // -// if(rs != null) { -// rs.close(); -// rs = null; -// System.out.println("111111111111111111111111111111111111111111111111111111111111111111111"); -// } -// if(state != null) { -// state.close(); -// } // - - topBean.getFactoryNo(); - topTreeNode = new DefaultMutableTreeNode(topBean); - if (topLine.hasChildren()) { - childNode = new DefaultMutableTreeNode(new DYStandardBomBean(rev, topLine, 1)); - topTreeNode.add(childNode); - path = new TreePath(topTreeNode); - paths.add(path); - } - dialog.parent_nodes.add(topBean); - dialog.topNode.add(topTreeNode); - dialog.rev_nodes.put(rev, topTreeNode); - dialog.node_status.put(topTreeNode, "0"); - } - }catch(Exception e) { - e.printStackTrace(); - }finally { - SqlUtil.freeAll(); - } - for (int i = 0; i < paths.size(); i++) { - dialog.tree.collapsePath(paths.get(i)); - } - dialog.t_model.reload(dialog.topNode); - win.refresh(); - win.close(); - } - +//// String sql = "Select I.PITEM_ID from 'PIMANRELATION' R\r\n" + +//// " INNER JOIN 'PIMANTYPE' T\r\n" + +//// " ON R.RRELATION_TYPEU = T.PUID AND T.PTYPE_NAME = 'ZT2_FactoryNumber' AND R.RPRIMARY_OBJECTU = '"; +//// sql += uid+"'\r\n" + +//// " INNER JOIN PITEM I\r\n" + +//// " ON I.PUID = R.RSECONDARY_OBJECTU"; +// +// String sql = "SELECT PITEM_ID,PZT2_WEBNO,PDATE_RELEASED FROM CHINT_FACTORY_NUMBER_VIEW WHERE PTYPE_NAME = 'ZT2_FactoryNumber' AND RPRIMARY_OBJECTU = '"; +// sql += uid+"'"; +// +// System.out.println("查询语句:" + sql.toString()); +// ResultSet rs = SqlUtil.read(sql.toString()); +// +// while (rs.next()) { +// String itemId = rs.getString(1); +// String webNo = rs.getString(2); +// String release = rs.getString(3); +//// if(release != null && !release.isEmpty()) { +//// topBean.setIsTCM("已发布"); +//// } +// +// topBean.setIsTCM(release == null ? "":"已发布"); +// topBean.setStatus_BOM(webNo == null ? "":webNo); +// topBean.addFactoryID(itemId == null ? "":itemId); +// +// } +//// +//// if(rs != null) { +//// rs.close(); +//// rs = null; +//// System.out.println("111111111111111111111111111111111111111111111111111111111111111111111"); +//// } +//// if(state != null) { +//// state.close(); +//// } +//// +// +// topBean.getFactoryNo(); +// topTreeNode = new DefaultMutableTreeNode(topBean); +// if (topLine.hasChildren()) { +// childNode = new DefaultMutableTreeNode(new DYStandardBomBean(rev, topLine, 1)); +// topTreeNode.add(childNode); +// path = new TreePath(topTreeNode); +// paths.add(path); +// } +// dialog.parent_nodes.add(topBean); +// dialog.topNode.add(topTreeNode); +// dialog.rev_nodes.put(rev, topTreeNode); +// dialog.node_status.put(topTreeNode, "0"); +// } +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// SqlUtil.freeAll(); +// } +// for (int i = 0; i < paths.size(); i++) { +// dialog.tree.collapsePath(paths.get(i)); +// } +// dialog.t_model.reload(dialog.topNode); +// win.refresh(); +// win.close(); +// } + + public void readData(ProgressBar pb, String folderUid) + throws Exception + { + pb.startProgress(); + pb.setText("加载数据..."); + + TCComponentBOMWindow win = this.bomWinType.create(null); + + + List paths = new ArrayList(); + try + { + Connection connection2 = SqlUtil.getConnection2(); + connection2.createStatement(); + String sql = "SELECT RPRIMARY_OBJECTU,PITEM_ID,PZT2_WEBNO,PDATE_RELEASED FROM CHINT_FACTORY_NUMBER_VIEW WHERE PTYPE_NAME = 'ZT2_FactoryNumber' AND FOLDERUID = '"; + sql = sql + folderUid + "'"; + System.out.println("sql2====================" + sql); + ResultSet rs = SqlUtil.read(sql.toString()); + Map beanMap = new LinkedHashMap(); + String itemId; + while (rs.next()) + { + String uid = rs.getString(1); + itemId = rs.getString(2); + String webNo = rs.getString(3); + String release = rs.getString(4); + System.out.println("itemId==" + itemId); + if (!beanMap.containsKey(uid)) + { + TCComponentItemRevision rev = (TCComponentItemRevision)this.session.stringToComponent(uid); + win.setWindowTopLine(rev.getItem(), rev, null, null); + TCComponentBOMLine topLine = win.getTopBOMLine(); + DYStandardBomBean topBean = new DYStandardBomBean(rev, topLine, 1); + topBean.setIsTCM(release == null ? "" : "已发布"); + topBean.setStatus_BOM(webNo == null ? "" : webNo); + topBean.addFactoryID(itemId == null ? "" : itemId); + beanMap.put(uid, topBean); + } + else + { + DYStandardBomBean topBean = (DYStandardBomBean)beanMap.get(uid); + topBean.addFactoryID(itemId == null ? "" : itemId); + } + } + System.out.println("beanMap=================" + beanMap.toString()); + for (Map.Entry entry : beanMap.entrySet()) + { + DYStandardBomBean topBean = (DYStandardBomBean)entry.getValue(); + + + + topBean.getFactoryNo(); + DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(topBean); + TCComponentBOMLine topLine = topBean.getLine(); + TCComponentItemRevision rev = topBean.getRev(); + if (topLine.hasChildren()) + { + DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(new DYStandardBomBean(rev, topLine, 1)); + topTreeNode.add(childNode); + TreePath path = new TreePath(topTreeNode); + paths.add(path); + } + this.dialog.parent_nodes.add(topBean); + this.dialog.topNode.add(topTreeNode); + this.dialog.rev_nodes.put(rev, topTreeNode); + this.dialog.node_status.put(topTreeNode, "0"); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + SqlUtil.freeAll(); + } + for (int i = 0; i < paths.size(); i++) { + this.dialog.tree.collapsePath((TreePath)paths.get(i)); + } + this.dialog.t_model.reload(this.dialog.topNode); + win.refresh(); + win.close(); + } + + public void readData(ProgressBar pb, List revs) + throws Exception + { + pb.startProgress(); + pb.setText("加载数据..."); + + + TCComponentBOMWindow win = this.bomWinType.create(null); + + + + List paths = new ArrayList(); + try + { + Connection connection2 = SqlUtil.getConnection2(); + connection2.createStatement(); + int i = 0; + for (int len = revs.size(); i < len; i++) + { + TCComponentItemRevision rev = (TCComponentItemRevision)revs.get(i); + win.setWindowTopLine(rev.getItem(), rev, null, null); + TCComponentBOMLine topLine = win.getTopBOMLine(); + DYStandardBomBean topBean = new DYStandardBomBean(rev, topLine, 1); + + + + + String uid = rev.getUid(); + + + + + String sql = "SELECT PITEM_ID,PZT2_WEBNO,PDATE_RELEASED FROM CHINT_FACTORY_NUMBER_VIEW WHERE PTYPE_NAME = 'ZT2_FactoryNumber' AND RPRIMARY_OBJECTU = '"; + sql = sql + uid + "'"; + + System.out.println("查询语句:" + sql.toString()); + ResultSet rs = SqlUtil.read(sql.toString()); + while (rs.next()) + { + String itemId = rs.getString(1); + System.out.println("itemId==" + itemId); + String webNo = rs.getString(2); + String release = rs.getString(3); + + + + + topBean.setIsTCM(release == null ? "" : "已发布"); + topBean.setStatus_BOM(webNo == null ? "" : webNo); + topBean.addFactoryID(itemId == null ? "" : itemId); + } + topBean.getFactoryNo(); + DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(topBean); + if (topLine.hasChildren()) + { + DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(new DYStandardBomBean(rev, topLine, 1)); + topTreeNode.add(childNode); + TreePath path = new TreePath(topTreeNode); + paths.add(path); + } + this.dialog.parent_nodes.add(topBean); + this.dialog.topNode.add(topTreeNode); + this.dialog.rev_nodes.put(rev, topTreeNode); + this.dialog.node_status.put(topTreeNode, "0"); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + SqlUtil.freeAll(); + } + for (int i = 0; i < paths.size(); i++) { + this.dialog.tree.collapsePath((TreePath)paths.get(i)); + } + this.dialog.t_model.reload(this.dialog.topNode); + win.refresh(); + win.close(); + } + + + + // 升版修改 private List recureBOM(TCComponentBOMLine line, DefaultMutableTreeNode treeNode, List beans) throws Exception { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBOMDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBOMDialog.java index 3c9c771..af8ad29 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBOMDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBOMDialog.java @@ -20,6 +20,8 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowEvent; import java.io.IOException; import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -63,14 +65,17 @@ import com.connor.chint.sap2.util.ConfirmDialogUtil; import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.POIUtil; import com.connor.chint.sap2.util.ProgressBar; +import com.connor.chint.sap2.util.SqlUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFDialog; import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentFolder; import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.util.MessageBox; public class DYStandardBOMDialog extends AbstractAIFDialog { @@ -100,7 +105,9 @@ public class DYStandardBOMDialog extends AbstractAIFDialog { protected JTextField jtf_num; // 数量 private TCComponentItemRevision select_rev; private DYStandardBOMController controller; - + protected String folderUid = ""; + private TCSession session; + protected List revUidList = new ArrayList(32); public static final String[] HEADER = new String[] { "序号", "物料编码", "代号", "物料描述", "技术要求", "单位", "数量", "备注" }; public static final int[] HEADERWIDTH = new int[] { 60, 180, 120, 400, 180, 60, 60, 120 }; @@ -127,6 +134,7 @@ public class DYStandardBOMDialog extends AbstractAIFDialog { public DYStandardBOMDialog(AbstractAIFApplication app) { super(false); this.app = app; + this.session = ((TCSession)app.getSession()); } @Override @@ -208,63 +216,103 @@ public class DYStandardBOMDialog extends AbstractAIFDialog { return panel; } - @Override - public void run() { - try { - InterfaceAIFComponent comp = app.getTargetComponent(); - if (comp instanceof TCComponentItemRevision) { - revs.add((TCComponentItemRevision) comp); - } else { - folder = (TCComponentFolder) comp; - AIFComponentContext[] children = folder.getChildren(); - TCComponentItem item; - TCComponentItemRevision rev; - for (int i = 0, len = children.length; i < len; i++) { - if (children[i].getComponent() instanceof TCComponentItem) { - item = (TCComponentItem) children[i].getComponent(); - rev = item.getLatestItemRevision(); - if (!revs.contains(rev)) { - revs.add(rev); - } - } else if (children[i].getComponent() instanceof TCComponentItemRevision) { - rev = (TCComponentItemRevision) children[i].getComponent(); - if (!revs.contains(rev)) { - revs.add(rev); - } - } - } - } - if (revs.size() == 0) { - MessageBox.post("未在文件夹中找到版本对象,请检查", "", 2); - return; - } - controller = new DYStandardBOMController(DYStandardBOMDialog.this, app); - controller.initUI(); - initUI(); - test(); - addListener(); - new Thread(new Runnable() { - @Override - public void run() { - ProgressBar pb = new ProgressBar(DYStandardBOMDialog.this, new Dimension(250, 50)); - try { - controller.readData(pb, revs); - pb.disposeDialog(); - } catch (Exception e) { - pb.disposeDialog(); - e.printStackTrace(); - MessageBox.post(DYStandardBOMDialog.this, "异常:" + e.getMessage(), "", 2); - disposeDialog(); - } - } - }).start(); - showDialog(); - } catch (Exception e) { - e.printStackTrace(); - MessageBox.post("异常:" + e.getMessage(), "", 2); - } - - } + public void run() + { + try + { + long time1 = System.nanoTime(); + + + InterfaceAIFComponent comp = this.app.getTargetComponent(); + if ((comp instanceof TCComponentItemRevision)) + { + this.revs.add((TCComponentItemRevision)comp); + } + else + { + Connection connection2 = SqlUtil.getConnection2(); + connection2.createStatement(); + this.folderUid = comp.getUid(); + String sql = "SELECT RPRIMARY_OBJECTU FROM CHINT_FACTORY_NUMBER_VIEW WHERE PTYPE_NAME = 'ZT2_FactoryNumber' AND FOLDERUID = '"; + sql = sql + this.folderUid + "'"; + System.out.println("查询语句:" + sql.toString()); + ResultSet rs = SqlUtil.read(sql.toString()); + while (rs.next()) + { + String revId = rs.getString(1); + if (!this.revUidList.contains(revId)) { + this.revUidList.add(revId); + } + } + System.out.println("revUidList.SIZZ=============" + this.revUidList.size()); + if (connection2 != null) { + SqlUtil.freeAll(); + } + TCComponent[] revsArray = + session.stringToComponent( + (String[])this.revUidList.toArray(new String[this.revUidList.size()])); + for (TCComponent tcComponent : revsArray) { + if ((tcComponent instanceof TCComponentItemRevision)) { + this.revs.add((TCComponentItemRevision)tcComponent); + } + } + System.out.println("revs.SIZZ=============" + this.revs.size()); + } + if (this.revs.size() == 0) + { + MessageBox.post("未在文件夹中找到版本对象,请检查", "", 2); + return; + } + long time2 = System.nanoTime(); + System.out.println("fold==========================================: " + (time2 - time1) / 1000000L); + + + long time5 = System.nanoTime(); + this.controller = new DYStandardBOMController(this, this.app); + this.controller.initUI(); + initUI(); + test(); + addListener(); + long time6 = System.nanoTime(); + System.out.println("initUI==========================================: " + (time6 - time5) / 1000000L); + new Thread(new Runnable() + { + public void run() + { + ProgressBar pb = new ProgressBar(DYStandardBOMDialog.this, new Dimension(250, 50)); + try + { + long time3 = System.nanoTime(); + if (DYStandardBOMDialog.this.folderUid.equals("")) + { + DYStandardBOMDialog.this.controller.readData(pb, DYStandardBOMDialog.this.revs); + } + else + { + System.out.println("111111111111111111111111111111111111111"); + DYStandardBOMDialog.this.controller.readData(pb, DYStandardBOMDialog.this.folderUid); + } + long time4 = System.nanoTime(); + System.out.println("data==========================================: " + (time4 - time3) / 1000000L); + pb.disposeDialog(); + } + catch (Exception e) + { + pb.disposeDialog(); + e.printStackTrace(); + MessageBox.post(DYStandardBOMDialog.this, "异常:" + e.getMessage(), "", 2); + DYStandardBOMDialog.this.disposeDialog(); + } + } + }).start(); + showDialog(); + } + catch (Exception e) + { + e.printStackTrace(); + MessageBox.post("异常:" + e.getMessage(), "", 2); + } + } private void addListener() { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBomBean.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBomBean.java index 7771a67..b44b50b 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBomBean.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/StandardBOM/DYStandardBomBean.java @@ -1,146 +1,153 @@ package com.connor.chint.sap2.StandardBOM; -import java.util.ArrayList; -import java.util.List; - import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.ZYFactoryUtil; import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCException; +import java.util.ArrayList; +import java.util.List; -public class DYStandardBomBean { - - private TCComponentItemRevision rev; - private List children = new ArrayList<>(); - private int index; - - private List factoryNos = new ArrayList<>(); - private List factoryIDs = new ArrayList<>(); - - public String factoryID = ""; - private String status_BOM = ""; - private String isTCM = ""; - - public String getIsTCM() { - return isTCM; - } - - public void setIsTCM(String isTCM) { - this.isTCM = isTCM; - } - - public void changeBOMStatus() throws TCException { - if (KUtil.isEmpty(status_BOM) || "完成".equals(status_BOM)) { - status_BOM = "未完成"; - } else { - status_BOM = "完成"; - } - - rev.setProperty("zt2_WebNo", status_BOM); - - // System.out.println("status_BOM:"+status_BOM); - } - - public DYStandardBomBean(TCComponentItemRevision rev, TCComponentBOMLine line, int index) { - this.rev = rev; - this.index = index; -// try { -// status_BOM = rev.getProperty("zt2_WebNo"); -// } catch (TCException e) { -// e.printStackTrace(); -// } - - } - - public void getFactoryNo() { - if (factoryIDs.size() > 0) { - factoryID = ZYFactoryUtil.getFactory(factoryIDs, 4); - } - - } - - /* - * public DYStandardBomBean getClone() { DYStandardBomBean bean = new - * DYStandardBomBean(rev, line, index); bean.setChildren(children); - * bean.setFactoryIDs(factoryIDs); bean.status_BOM = status_BOM; return bean; } - */ - - @Override - public String toString() { - - if ("完成".equals(status_BOM)) { - - String text = ""; - if (KUtil.isEmpty(factoryID)) { - text = status_BOM + " " + rev.toString(); - } else { - text = status_BOM + " " + rev.toString() + " (" + factoryID + ")"; - } - return KUtil.getRedText(text); - } else { - if (KUtil.isEmpty(factoryID)) { - return status_BOM + " " + rev.toString(); - } else { - return status_BOM + " " + rev.toString() + " (" + factoryID + ")"; - } - } - } - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } - - public TCComponentItemRevision getRev() { - return rev; - } - - public void setRev(TCComponentItemRevision rev) { - this.rev = rev; - } - - public List getFactoryNos() { - return factoryNos; - } - - public void setFactoryNos(List factoryNos) { - this.factoryNos = factoryNos; - } - - public List getFactoryIDs() { - return factoryIDs; - } - - public void setFactoryIDs(List factoryIDs) { - this.factoryIDs = factoryIDs; - } - - public void addFactoryID(String factoryID) { - if (!factoryIDs.contains(factoryID)) { - factoryIDs.add(factoryID); - } - } - - public String getStatus_BOM() { - return status_BOM; - } - - public void setStatus_BOM(String status_BOM) { - this.status_BOM = status_BOM; - } - - +public class DYStandardBomBean +{ + private TCComponentItemRevision rev; + private TCComponentBOMLine line; + private List children = new ArrayList(); + private int index; + private List factoryNos = new ArrayList(); + private List factoryIDs = new ArrayList(); + public String factoryID = ""; + private String status_BOM = ""; + private String isTCM = ""; + + public String getIsTCM() + { + return this.isTCM; + } + + public void setIsTCM(String isTCM) + { + this.isTCM = isTCM; + } + + public void changeBOMStatus() + throws TCException + { + if ((KUtil.isEmpty(this.status_BOM)) || ("完成".equals(this.status_BOM))) { + this.status_BOM = "未完成"; + } else { + this.status_BOM = "完成"; + } + this.rev.setProperty("zt2_WebNo", this.status_BOM); + } + + public DYStandardBomBean(TCComponentItemRevision rev, TCComponentBOMLine line, int index) + { + this.rev = rev; + this.line = line; + this.index = index; + } + + public void getFactoryNo() + { + if (this.factoryIDs.size() > 0) { + this.factoryID = ZYFactoryUtil.getFactory(this.factoryIDs, 4); + } + } + + public String toString() + { + if ("完成".equals(this.status_BOM)) + { + String text = ""; + if (KUtil.isEmpty(this.factoryID)) { + text = this.status_BOM + " " + this.rev.toString(); + } else { + text = this.status_BOM + " " + this.rev.toString() + " (" + this.factoryID + ")"; + } + return KUtil.getRedText(text); + } + if (KUtil.isEmpty(this.factoryID)) { + return this.status_BOM + " " + this.rev.toString(); + } + return this.status_BOM + " " + this.rev.toString() + " (" + this.factoryID + ")"; + } + + public List getChildren() + { + return this.children; + } + + public void setChildren(List children) + { + this.children = children; + } + + public int getIndex() + { + return this.index; + } + + public void setIndex(int index) + { + this.index = index; + } + + public TCComponentItemRevision getRev() + { + return this.rev; + } + + public void setRev(TCComponentItemRevision rev) + { + this.rev = rev; + } + + public List getFactoryNos() + { + return this.factoryNos; + } + + public void setFactoryNos(List factoryNos) + { + this.factoryNos = factoryNos; + } + + public List getFactoryIDs() + { + return this.factoryIDs; + } + + public void setFactoryIDs(List factoryIDs) + { + this.factoryIDs = factoryIDs; + } + + public void addFactoryID(String factoryID) + { + if (!this.factoryIDs.contains(factoryID)) { + this.factoryIDs.add(factoryID); + } + } + + public String getStatus_BOM() + { + return this.status_BOM; + } + + public void setStatus_BOM(String status_BOM) + { + this.status_BOM = status_BOM; + } + + public TCComponentBOMLine getLine() + { + return this.line; + } + + public void setLine(TCComponentBOMLine line) + { + this.line = line; + } }