diff --git a/com.connor.chint.sap2/plugin.xml b/com.connor.chint.sap2/plugin.xml index bf16507..f063659 100644 --- a/com.connor.chint.sap2/plugin.xml +++ b/com.connor.chint.sap2/plugin.xml @@ -4711,7 +4711,7 @@ - + @@ -4733,7 +4733,7 @@ - + diff --git a/com.connor.chint.sap2/src/com/chint/plm/getGCTH/GCTHDialog.java b/com.connor.chint.sap2/src/com/chint/plm/getGCTH/GCTHDialog.java index fa05428..431fa07 100644 --- a/com.connor.chint.sap2/src/com/chint/plm/getGCTH/GCTHDialog.java +++ b/com.connor.chint.sap2/src/com/chint/plm/getGCTH/GCTHDialog.java @@ -2,14 +2,8 @@ package com.chint.plm.getGCTH; import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.Transferable; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; @@ -31,19 +25,11 @@ import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.ListSelectionModel; -import javax.swing.event.TreeExpansionEvent; -import javax.swing.event.TreeWillExpandListener; import javax.swing.table.DefaultTableModel; import javax.swing.table.JTableHeader; import javax.swing.table.TableColumn; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.ExpandVetoException; -import javax.swing.tree.TreePath; - import org.jdesktop.swingx.decorator.HighlighterFactory; import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; -import org.jdesktop.swingx.treetable.TreeTableNode; - import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.SoaUtils; import com.connor.chint.sap2.util.SqlUtil; @@ -63,6 +49,10 @@ import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData public class GCTHDialog extends JFrame { + /** + * + */ + private static final long serialVersionUID = 1L; private JComboBox xxdbhComb=new JComboBox(); private List nameList =new ArrayList(); @@ -72,20 +62,20 @@ public class GCTHDialog extends JFrame { private TCSession session; private SoaUtils soaUtil; private ProcessBarDialog progress1; - private Boolean jzFlag = false; - private Map bomLineTreeNodeSOA; +// private Boolean jzFlag = false; +// private Map bomLineTreeNodeSOA; JFrame frame; private List beanList = new ArrayList(); public GCTHDialog(AbstractAIFApplication app,DefaultMutableTreeTableNode rootNode, TCComponentBOMLine line,ProcessBarDialog progress,Map bomLineTreeNodeSOA,List beanList) { - // TODO Auto-generated constructor stub + // Auto-generated constructor stub this.app = app; this.rootNode = rootNode; this.line = line; this.session = (TCSession) app.getSession(); String ip = session.getLoginInfo().getPreviousSessionLoginIP(); System.out.println("ip==>"+ip); - this.bomLineTreeNodeSOA = bomLineTreeNodeSOA; +// this.bomLineTreeNodeSOA = bomLineTreeNodeSOA; this.beanList = beanList; soaUtil = new SoaUtils(line); this.progress1 = progress; @@ -102,7 +92,7 @@ public class GCTHDialog extends JFrame { private String[] header = new String[] { "对象ID", "选择派生","" }; // @Override public void initUI() { - // TODO Auto-generated method stub + // Auto-generated method stub try { TCSession session = (TCSession)app.getSession(); String strs[] = session.getPreferenceService().getStringValues("database_tc"); @@ -150,86 +140,80 @@ public class GCTHDialog extends JFrame { private JButton btn; private String xxd = ""; private JPanel getBtnPanel() { - // TODO Auto-generated method stub + // Auto-generated method stub JPanel topPanel = new JPanel(); - btn = new JButton("开始执行"); - topPanel.add(btn); btn.addActionListener(new ActionListener() { - - @Override + @Override public void actionPerformed(ActionEvent param1ActionEvent) { - - - new Thread() { - @Override - public void run() { - - try { - String text = jText.getText(); - System.out.println("text===>"+text); - if(!nameList.contains(text)) { - MessageBox.post("系统中无此信息单,请检查!","提示",2); - return; - } - - KUtil.setByPass(true); - - ProcessBarDialog progress = new ProcessBarDialog("正在执行申请工程图号..."); - progress.open(); -// init_pb.show(); -// int rowCount = table.getRowCount(); - - getAllNodes(rootNode); - //BOM复制 - soaUtil.cloneOrUpdate(session,line,bomLine,jText.getText().trim()); - - line.window().close(); - try { - //剪切 - TCComponentItem tcComponentById = (TCComponentItem) soaUtil.getTCComponentById(session, soaUtil.topItemId); - - TCComponentItemRevision latestItemRevision = tcComponentById.getLatestItemRevision(); - TCTypeService service = session.getTypeService(); - TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); - TCComponentBOMWindow window = winType.create(null); - TCComponentBOMLine newTopline = window.setWindowTopLine(latestItemRevision.getItem(), latestItemRevision, null, null); - - xxd = jText.getText().trim().replaceAll("YHX", ""); - changeAllDs(newTopline); - - window.close(); -// init_pb.disposeDialog(); - progress.close(); - KUtil.setByPass(true); -// session.getUser().getNewStuffFolder().cutOperation("contents", new TCComponent[] { tcComponentById}); - btn.setEnabled(false); - MessageBox.post(GCTHDialog.this, "申请工程图号完成,新的图号为:"+soaUtil.topItemId +"-"+tcComponentById.getStringProperty("object_name"), "提示", 2); - frame.dispose(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - MessageBox.post(GCTHDialog.this, "申请工程图号时发生异常:" + e.getMessage(), "提示", 2); - }finally { - progress.close(); - } - } - catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }.start(); - + new Thread() { + @Override + public void run() { + try { + String text = jText.getText(); + System.out.println("text===>"+text); + if(!nameList.contains(text)) { + MessageBox.post("系统中无此信息单,请检查!","提示",2); + return; + } + + KUtil.setByPass(true); + + ProcessBarDialog progress = new ProcessBarDialog("正在执行申请工程图号..."); + progress.open(); + // init_pb.show(); + // int rowCount = table.getRowCount(); + + getAllNodes(rootNode); + //BOM复制 + soaUtil.cloneOrUpdate(session,line,bomLine,jText.getText().trim()); + + line.window().close(); + try { + //剪切 + TCComponentItem tcComponentById = (TCComponentItem) soaUtil.getTCComponentById(session, soaUtil.topItemId); + + TCComponentItemRevision latestItemRevision = tcComponentById.getLatestItemRevision(); + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow window = winType.create(null); + TCComponentBOMLine newTopline = window.setWindowTopLine(latestItemRevision.getItem(), latestItemRevision, null, null); + + xxd = jText.getText().trim().replaceAll("YHX", ""); + changeAllDs(newTopline); + + window.close(); + // init_pb.disposeDialog(); + progress.close(); + KUtil.setByPass(true); + // session.getUser().getNewStuffFolder().cutOperation("contents", new TCComponent[] { tcComponentById}); + btn.setEnabled(false); + MessageBox.post(GCTHDialog.this, "申请工程图号完成,新的图号为:"+soaUtil.topItemId +"-"+tcComponentById.getStringProperty("object_name"), "提示", 2); + frame.dispose(); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + MessageBox.post(GCTHDialog.this, "申请工程图号时发生异常:" + e.getMessage(), "提示", 2); + }finally { + progress.close(); + } + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + } + }.start(); } - }); + }); return topPanel; } //改变数据集名称 protected void changeAllDs(TCComponentBOMLine newTopline) throws TCException { - // TODO Auto-generated method stub + // Auto-generated method stub Map idMap = soaUtil.getIdMap(); AIFComponentContext[] children = newTopline.getChildren(); @@ -242,12 +226,10 @@ public class GCTHDialog extends JFrame { for(AIFComponentContext context:children) { TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); changeAllDs(component); - } - } protected void getAllNodes(DefaultMutableTreeTableNode rootNode2) { - // TODO Auto-generated method stub + // Auto-generated method stub for (int i = 0; i < rootNode2.getChildCount(); i++) { DefaultMutableTreeTableNode childAt = (DefaultMutableTreeTableNode) rootNode2.getChildAt(i); // 获取第二层的对象 @@ -260,7 +242,7 @@ public class GCTHDialog extends JFrame { selected = "0"; } bomLine.put(subLine, Integer.valueOf(selected)); - boolean bzt = true; +// boolean bzt = true; //工程图、标准图 // if(childBean.getGctSelect().equals("1")) { // bzt = false; @@ -277,23 +259,19 @@ public class GCTHDialog extends JFrame { private Map> rowMap = new HashMap<>(); private Integer currentRow = 0; private JPanel getTopPanel() { - // TODO Auto-generated method stub - + // Auto-generated method stub try { ResultSet rs = SqlUtil.read(sqlStr); while (rs.next()) { - String item_id = rs.getString("PITEM_ID"); nameList.add(item_id); - } } catch (SQLException e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } - JPanel topPanel = new JPanel(); xxdbhComb.setEditable(true); @@ -302,19 +280,19 @@ public class GCTHDialog extends JFrame { @Override public void keyTyped(KeyEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void keyReleased(KeyEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub addSelect(e,xxdbhComb,jText,nameList); } @Override public void keyPressed(KeyEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub } }); @@ -349,13 +327,13 @@ public class GCTHDialog extends JFrame { jButton4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - // TODO Auto-generated method stub + // Auto-generated method stub + // Auto-generated method stub new Thread(new Runnable() { @Override public void run() { - // TODO Auto-generated method stub + // Auto-generated method stub table.expandAll(); String text = jTextQry.getText(); if(!text.isEmpty()) { @@ -384,13 +362,13 @@ public class GCTHDialog extends JFrame { jButton3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - // TODO Auto-generated method stub + // Auto-generated method stub + // Auto-generated method stub new Thread(new Runnable() { @Override public void run() { - // TODO Auto-generated method stub + // Auto-generated method stub table.expandAll(); String text = jTextQry.getText(); if(!text.isEmpty()) { @@ -419,13 +397,13 @@ public class GCTHDialog extends JFrame { jButton5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - // TODO Auto-generated method stub + // Auto-generated method stub + // Auto-generated method stub new Thread(new Runnable() { @Override public void run() { - // TODO Auto-generated method stub + // Auto-generated method stub table.expandAll(); String text = jTextQry.getText(); if(!text.isEmpty()) { @@ -478,13 +456,13 @@ public class GCTHDialog extends JFrame { jButton2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - // TODO Auto-generated method stub + // Auto-generated method stub + // Auto-generated method stub new Thread(new Runnable() { @Override public void run() { - // TODO Auto-generated method stub + // Auto-generated method stub // new Thread() { // @Override @@ -516,13 +494,13 @@ public class GCTHDialog extends JFrame { jButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - // TODO Auto-generated method stub + // Auto-generated method stub + // Auto-generated method stub new Thread(new Runnable() { @Override public void run() { - // TODO Auto-generated method stub + // Auto-generated method stub try { String text = jText.getText(); System.out.println("text===>"+text); @@ -573,7 +551,7 @@ public class GCTHDialog extends JFrame { } private JScrollPane getTablePanel() { - // TODO Auto-generated method stub + // Auto-generated method stub table = getJTreeTable(null, null, header, null); // table.getModel().addTableModelListener(table); table.setRowHeight(30); @@ -591,31 +569,31 @@ public class GCTHDialog extends JFrame { @Override public void mouseReleased(MouseEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void mouseEntered(MouseEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub } @Override public void mouseClicked(MouseEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint()); int selectedRow = table.rowAtPoint(e.getPoint()); System.out.println("selectColumn==>"+selectColumn); @@ -661,7 +639,7 @@ public class GCTHDialog extends JFrame { int rowCount = myTable.getRowCount(); - Enumeration columns = myTable.getColumnModel().getColumns(); + Enumeration columns = myTable.getColumnModel().getColumns(); while (columns.hasMoreElements()) { TableColumn column = (TableColumn) columns.nextElement(); @@ -713,7 +691,7 @@ public class GCTHDialog extends JFrame { } protected void addSelect(KeyEvent e, JComboBox combox, JTextField jtext, List cpxList) { - // TODO Auto-generated method stub + // Auto-generated method stub Object obj = e.getSource(); int keyCode = e.getKeyCode(); if (obj == jtext) { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/materialno/MaterialNoDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/materialno/MaterialNoDialog.java index b938bb3..b9b760b 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/materialno/MaterialNoDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/materialno/MaterialNoDialog.java @@ -13,7 +13,6 @@ import java.awt.event.MouseEvent; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.rmi.RemoteException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.ResultSetMetaData; @@ -81,9 +80,6 @@ import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.PropertyLayout; import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; -import nc.itf.chintwebservices.msg.ISendMsgServices.ISendMsgServices; -import nc.itf.chintwebservices.msg.ISendMsgServices.ISendMsgServicesLocator; -import nc.itf.chintwebservices.msg.ISendMsgServices.ISendMsgServicesPortType; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -939,9 +935,9 @@ public class MaterialNoDialog extends AbstractAIFDialog { } StringBuilder build = new StringBuilder(""); build.append(userName).append("已申请物料,请及时审批。"); - System.out.println("userId==》"+userId); + System.out.println("userId==》" + userId); if(!userId.equals("")) { - sendMsg(build.toString(),userId); + SAPUtil.sendMsg(build.toString(), userId); } } @@ -1405,29 +1401,29 @@ public class MaterialNoDialog extends AbstractAIFDialog { } StringBuilder build = new StringBuilder(""); build.append(userName).append("已申请物料,请及时审批。"); - System.out.println("userId==》"+userId); + System.out.println("userId==》" + userId); if(!userId.equals("")) { - sendMsg(build.toString(),userId); + SAPUtil.sendMsg(build.toString(), userId); } jcb_blank.setSelected(false); } - public static void sendMsg(String mess, String userID) throws IOException { - try { -// TXTUtil.writeTXT(logPath, "开始AM消息推送"); -// TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); - ISendMsgServices service2 = new ISendMsgServicesLocator(); - ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http(); - String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM"); -// TXTUtil.writeTXT(logPath, "返回信息:" + mess2); - System.out.println("返回信息:" + mess2); - } catch (javax.xml.rpc.ServiceException e) { - e.printStackTrace(); - } catch (RemoteException e) { - e.printStackTrace(); - } -// TXTUtil.writeTXT(logPath, "AM消息推送结束"); - } +// private static void sendMsg(String mess, String userID) throws IOException { +// try { +//// TXTUtil.writeTXT(logPath, "开始AM消息推送"); +//// TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); +// ISendMsgServices service2 = new ISendMsgServicesLocator(); +// ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http(); +// String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM"); +//// TXTUtil.writeTXT(logPath, "返回信息:" + mess2); +// System.out.println("返回信息:" + mess2); +// } catch (javax.xml.rpc.ServiceException e) { +// e.printStackTrace(); +// } catch (RemoteException e) { +// e.printStackTrace(); +// } +//// TXTUtil.writeTXT(logPath, "AM消息推送结束"); +// } @SuppressWarnings("deprecation") private void createBOM(TCComponentItemRevision parent, TCComponentItemRevision child) throws Exception { if (parent == null || child == null) { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/operation/SelfMPartNoBatchOperation.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/operation/SelfMPartNoBatchOperation.java index bf3d2cb..1f26af9 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/operation/SelfMPartNoBatchOperation.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/operation/SelfMPartNoBatchOperation.java @@ -58,10 +58,6 @@ import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput; import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut; import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; -import nc.itf.chintwebservices.msg.ISendMsgServices.ISendMsgServices; -import nc.itf.chintwebservices.msg.ISendMsgServices.ISendMsgServicesLocator; -import nc.itf.chintwebservices.msg.ISendMsgServices.ISendMsgServicesPortType; - /** * 自制件编码批量申请 * @@ -684,7 +680,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation { build.append(userName).append("已申请物料,请及时审批。"); System.out.println("userId==》" + userId); if(!userId.equals("")) { - sendMsg(build.toString(), userId); + SAPUtil.sendMsg(build.toString(), userId); } } catch (Exception e1) { @@ -706,21 +702,6 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation { } } - public void sendMsg(String mess, String userID) throws Exception { - try { -// TXTUtil.writeTXT(logPath, "开始AM消息推送"); -// TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); - ISendMsgServices service2 = new ISendMsgServicesLocator(); - ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http(); - String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM"); -// TXTUtil.writeTXT(logPath, "返回信息:" + mess2); - System.out.println("返回信息:\n" + mess2); - TXTUtil.writeTXT(txtPath, "返回信息:\n" + mess2); - } catch (Exception e) { - e.printStackTrace(); - } -// TXTUtil.writeTXT(logPath, "AM消息推送结束"); - } // List tzList = new ArrayList(); public CreateIn createMaterialYH(SelfMPartBean bean, String companyCode, String zt2_Specifications, String code) throws TCException, ServiceException { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_xb/CreateProcXBController.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_xb/CreateProcXBController.java index fc9fcf0..a396e77 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_xb/CreateProcXBController.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_xb/CreateProcXBController.java @@ -52,22 +52,21 @@ public class CreateProcXBController { private TCSession session; // 节点与表格对象 - protected Map maps_tree_table = new HashMap<>(64); + protected Map maps_tree_table; // 表格与节点关系 - protected Map maps_table_tree = new HashMap( - 64); + protected Map maps_table_tree; // 表格与BOM视图的关系 - protected Map maps_table_line_maps = new HashMap<>(64); + protected Map maps_table_line_maps; - protected Map map_line_table_maps = new HashMap(); + protected Map map_line_table_maps; // 版本-表格 - protected Map> list_rev_procBean = new HashMap<>(64); + protected Map> list_rev_procBean; // table数据集合 - protected List procBeanList = new ArrayList<>(64); + protected List procBeanList; // 需要重新获取子项的节点 - protected List node_need_expands = new ArrayList<>(); + protected List node_need_expands; protected TCComponentBOMLine topLine; private TCComponentBOMWindowType bomWinType; @@ -76,7 +75,7 @@ public class CreateProcXBController { protected boolean isCanExpand = false; // 展开的节点 - protected Vector expandPaths = new Vector<>(); + protected Vector expandPaths; private String group; private Map bomLineTree; @@ -85,6 +84,15 @@ public class CreateProcXBController { this.app = app; this.session = (TCSession) app.getSession(); this.dialog = dialog; + + maps_tree_table = new HashMap<>(); + maps_table_tree = new HashMap(); + maps_table_line_maps = new HashMap<>(); + map_line_table_maps = new HashMap(); + list_rev_procBean = new HashMap<>(); + procBeanList = new ArrayList<>(); + node_need_expands = new ArrayList<>(); + expandPaths = new Vector<>(); } public void initBOMWindow(TCSession session) throws TCException { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_xb/CreateProcXBDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_xb/CreateProcXBDialog.java index c50c0de..83c79ac 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_xb/CreateProcXBDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_xb/CreateProcXBDialog.java @@ -98,7 +98,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog { public static final int[] HEADERWIDTH = new int[] { 80, 300, 120, 120, 200, 200, 200 }; // 当前版本对象 - private TCComponentItemRevision bomRev = null; + private TCComponentItemRevision bomRev; // 变压器工序 private List byq_gx_lists; @@ -107,11 +107,11 @@ public class CreateProcXBDialog extends AbstractAIFDialog { private String codeRemark_Technology = "ICM120202"; // 工艺分类库编码 private CreateProcController cpController; - protected Map> rev_Beans = new HashMap<>(); + protected Map> rev_Beans; private String groupID; - private Map value_strings = null; + private Map value_strings; public CreateProcXBDialog(AbstractAIFApplication app, String actionInfo) { super(false); @@ -119,6 +119,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog { this.session = (TCSession) app.getSession(); this.controller = new CreateProcXBController(this, app); this.cpController = new CreateProcController(); + rev_Beans = new HashMap<>(); try { groupID = SAPUtil.getGroupID(session); if (groupID.equalsIgnoreCase("dba")) { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPBYOperation.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPBYOperation.java index d4ef1cc..a944916 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPBYOperation.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPBYOperation.java @@ -1,24 +1,21 @@ package com.connor.chint.sap2.sap_by; import java.io.IOException; +import java.sql.ResultSet; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; - import com.connor.chint.sap2.create_proc.CreateProcBean; import com.connor.chint.sap2.create_proc.CreateProcController; -import com.connor.chint.sap2.sap_zy.SAPZYOperation; import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.SAPMessageUtil; import com.connor.chint.sap2.util.SAPUtil; +import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.TXTUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFOperation; @@ -29,9 +26,6 @@ import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindowType; -import com.teamcenter.rac.kernel.TCComponentBOPWindow; -import com.teamcenter.rac.kernel.TCComponentBOPWindowType; - import com.teamcenter.rac.kernel.TCComponentDataset; import com.teamcenter.rac.kernel.TCComponentFolder; import com.teamcenter.rac.kernel.TCComponentItem; @@ -40,7 +34,6 @@ import com.teamcenter.rac.kernel.TCComponentListOfValues; import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; import com.teamcenter.rac.kernel.TCComponentUser; import com.teamcenter.rac.kernel.TCException; -import com.teamcenter.rac.kernel.TCPreferenceService; import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.util.MessageBox; @@ -51,9 +44,6 @@ import plm.xi.com.chintelectric.DT_BOM_PLM_RSP; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQ; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQBASEINFO; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLIST; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTHEAD; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTITEMSITEM; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_RSP; import plm.xi.com.chintelectric.SI_BOM_PLM_OUT_SYN; import plm.xi.com.chintelectric.SI_BOM_PLM_OUT_SYNService; @@ -100,36 +90,34 @@ public class SAPBYOperation extends AbstractAIFOperation { } } - private void getMessageUsers() { - TCPreferenceService preService = session.getPreferenceService(); - String notifies[] = preService.getStringValues("CHINT_M005_Notify"); - for (String no : notifies) { - if (!KUtil.isEmpty(no)) { - userID.append(no); - } - } - - } +// private void getMessageUsers() { +// TCPreferenceService preService = session.getPreferenceService(); +// String notifies[] = preService.getStringValues("CHINT_M005_Notify"); +// for (String no : notifies) { +// if (!KUtil.isEmpty(no)) { +// userID.append(no); +// } +// } +// } public void getSapState() throws TCException { TCComponentListOfValues unitLov = KUtil.getLov(session, "zt2_SapState"); if (unitLov != null) { ListOfValuesInfo listOfValues = unitLov.getListOfValues(); String[] realval = listOfValues.getStringListOfValues(); - boolean flag = false; +// boolean flag = false; for (int i = 0; i < realval.length; i++) { String disval = listOfValues.getDisplayableValue(realval[i]); System.out.println("显示值:" + disval + ";真实值:" + realval[i]); if (disval.equals("已传")) { - flag = true; +// flag = true; sapState = realval[i]; } - } - } } + @SuppressWarnings("deprecation") @Override public void executeOperation() throws Exception { @@ -174,7 +162,7 @@ public class SAPBYOperation extends AbstractAIFOperation { Map gy_meops = new HashMap<>(32); List needTCM_meops = new ArrayList(); List bomIsExist = new ArrayList(); - StringBuffer errMessage = new StringBuffer(); +// StringBuffer errMessage = new StringBuffer(); // SAPUtil.recurBYBJBomline(bomline, null, null, gy_meops, needTCM_meops, // session, // groupName, list, proclist, txtPath, now,bomIsExist, "ICM0802", icsId, @@ -190,7 +178,7 @@ public class SAPBYOperation extends AbstractAIFOperation { } String[] prefs = ChintPreferenceUtil.getPreferences("M005_WBSBOM", session); List kjBomIds = new ArrayList(); - for(String pref:prefs) { + for(String pref : prefs) { String[] split = pref.split("\\|"); kjBomIds.add(split[0]); } @@ -200,15 +188,15 @@ public class SAPBYOperation extends AbstractAIFOperation { if(property.contains("-")) { endFix = property.split("-")[1]; } - TCComponentItem top = getTopZzItem(rev,endFix); + TCComponentItem top = getTopZzItem(rev, endFix); if(top == null) { top = rev.getItem(); } - System.out.println("top===>"+top); + System.out.println("top===>" + top); AIFComponentContext[] tzFolder = top.whereReferenced(); String projWbsNo = ""; System.out.println("tzFolder.length:" + tzFolder.length ); - for(int t = 0;t> flMap = new HashMap<>(); + if(zzItem.length > 0) { + String strs[] = session.getPreferenceService().getStringValues("database_tc"); + if (SqlUtil.getTCDataConnection(strs) == null) { + MessageBox.post("数据库连接失败,请检查首选项", "", 2); + return; + } + Map classMap = ((TCComponentItem)zzItem[0]).getClassificationAttributes();//.getLatestItemRevision() + String flfz = classMap.get("辅料分组"); + String sql = "select \"flno\",\"tuhao\",\"gx\" from CHINT_GYFL_M005 where \"group\"='" + flfz + "'"; + System.out.println("sql:" + sql); + ResultSet rs = SqlUtil.read(sql); + while(rs.next()) { + String tuhao = rs.getString(2); + tuhao = tuhao.substring(0, tuhao.indexOf("-")); + if(!flMap.containsKey(tuhao)) { + flMap.put(tuhao, new ArrayList<>()); + } + flMap.get(tuhao).add(new String[] { rs.getString(1), rs.getString(3) }); + } + SqlUtil.freeAll(); + } + System.out.println("flMap:" + flMap); SAPUtil.recurBYBJSAP(bomline, rev, partRev, gy_meops, needTCM_meops, session, groupName, list, proclist, - txtPath, now, bomIsExist, "ICM0802", icsId, by_materials, errMess, buff, material_revs,bean.getMatr(), - kjBomIds,projWbsNo); + txtPath, now, bomIsExist, "ICM0802", icsId, by_materials, errMess, buff, material_revs, + bean.getMatr(), kjBomIds, projWbsNo, flMap); SAPUtil.removeNull(list); System.out.println("Error:" + errMess.toString()); @@ -376,7 +390,6 @@ public class SAPBYOperation extends AbstractAIFOperation { } } } - } } TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session); @@ -386,13 +399,12 @@ public class SAPBYOperation extends AbstractAIFOperation { comp.setVisible(false); } catch (Exception e) { - // TODO: handle exception + // : handle exception comp.setVisible(false); e.printStackTrace(); } finally { KUtil.setByPass(false); } - } } catch (Exception e) { comp.setVisible(false); @@ -402,7 +414,7 @@ public class SAPBYOperation extends AbstractAIFOperation { } private TCComponentItem getTopZzItem(TCComponentItemRevision rev,String endFix) { - // TODO Auto-generated method stub + // Auto-generated method stub // item = null; try { TCComponent[] whereUsed = rev.whereUsed((short)0); @@ -418,15 +430,15 @@ public class SAPBYOperation extends AbstractAIFOperation { return item; } } - } - } catch (TCException e) { - // TODO Auto-generated catch block + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); } return null; } + @SuppressWarnings("deprecation") public TCComponentBOMLine getNewBOMLine(TCComponentItemRevision itemR) { TCComponentBOMWindowType bomWinType; try { @@ -443,6 +455,7 @@ public class SAPBYOperation extends AbstractAIFOperation { } // 20200422注释 + /* private void readBopInfo(TCComponentMEProcessRevision rev, TCComponent part) throws Exception { System.out.println("===读取工艺信息===:" + rev); TCComponentBOPWindowType bopWindowType = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow"); @@ -503,12 +516,12 @@ public class SAPBYOperation extends AbstractAIFOperation { } TXTUtil.writeTXT(txtPath, "结束打印工艺路线"); - /* - * TCComponent[] successors = - * gxLine1.getReferenceListProperty("Mfg0successors"); - * if(successors==null||successors.length==0) {//无PERT }else {//有PERT - * Mfg0predecessors } - */ + +// * TCComponent[] successors = +// * gxLine1.getReferenceListProperty("Mfg0successors"); +// * if(successors==null||successors.length==0) {//无PERT }else {//有PERT +// * Mfg0predecessors } +// * proclist.add( new DT_PROCESSROUTE_S4_REQLIST(head, gxInfo.toArray(new DT_PROCESSROUTE_S4_REQLISTITEMSITEM[] {}))); window.clearCache(); @@ -538,7 +551,7 @@ public class SAPBYOperation extends AbstractAIFOperation { Collections.sort(list, new Comparator>>() { @Override public int compare(Entry> o1, Entry> o2) { - // TODO Auto-generated method stub + // Auto-generated method stub return o2.getKey().intValue() - o1.getKey().intValue(); } }); @@ -619,10 +632,10 @@ public class SAPBYOperation extends AbstractAIFOperation { boolean inBx = bean.flow_split == null; for (int i = 0; i < cnt; i++) { TCComponentBOMLine gxLine = bean.flowList.get(i); - /* - * if(gxLine.equals(bean.flow_end)) { if(bean.flow_end!=null) { - * item.setVORNR2(getGXNR(bean.flow_end));//后置 } break; } - */ +// * +// * if(gxLine.equals(bean.flow_end)) { if(bean.flow_end!=null) { +// * item.setVORNR2(getGXNR(bean.flow_end));//后置 } break; } +// * if (bx) { if (gxLine.equals(bean.flow_combine)) { @@ -676,6 +689,7 @@ public class SAPBYOperation extends AbstractAIFOperation { } return String.format("%04d", seqI); } + private class FlowBean { List flowList = new ArrayList<>(); @@ -747,7 +761,7 @@ public class SAPBYOperation extends AbstractAIFOperation { readGXFlow((TCComponentBOMLine) suc[i], flowBeans, newFlow, false); } readGXFlow((TCComponentBOMLine) suc[0], flowBeans, currentFlow, false); - } + }*/ public static TCComponentItemRevision getPart(TCComponent comp) { if (comp.getType().equals("Part Revision")) { @@ -778,7 +792,7 @@ public class SAPBYOperation extends AbstractAIFOperation { } // return pRev; } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return null; diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialog.java index 151cf3d..802cb1b 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialog.java @@ -344,7 +344,7 @@ public class SAPZZDialog extends AbstractAIFDialog { panel.add(b_check); panel.add(b_bom); //TODO -// panel.add(b_qr3); + panel.add(b_qr3); // panel.add(pushBOM_btn); // 变压器BOM确认调整 JPanel panelt = new JPanel(new BorderLayout()); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialogController.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialogController.java index 5defea0..9f9c6a9 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialogController.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialogController.java @@ -205,6 +205,11 @@ public class SAPZZDialogController { MessageBox.post(dialog, "请选择要传递的对象信息", "", MessageBox.INFORMATION); return; } + String strs[] = session.getPreferenceService().getStringValues("database_tc"); + if (SqlUtil.getTCDataConnection(strs) == null) { + MessageBox.post("数据库连接失败,请检查首选项", "", 2); + return; + } gy_meops.clear(); needTCM_meops.clear(); @@ -215,8 +220,26 @@ public class SAPZZDialogController { mp = new MyProgressBarCompent("传递", "总装图信息传递中......"); for (int i = 0; i < len; i++) { try { - new SAPZZOperation(app, selectedParts.get(i), dists, SAPZZDialogController.this).executeOperation(); TCComponentItemRevision rev = selectedParts.get(i).getZzDesignRev(); + + //TODO lidy20241112 BOM传递SAP时拼接辅料BOM + Map classMap = rev.getItem().getClassificationAttributes(); + String flfz = classMap.get("辅料分组"); + String sql = "select \"flno\",\"tuhao\",\"gx\" from CHINT_GYFL_M005 where \"group\"='" + flfz + "'"; + System.out.println("sql:" + sql); + ResultSet rs = SqlUtil.read(sql); + HashMap> flMap = new HashMap<>(); + while(rs.next()) { + String tuhao = rs.getString(2); + tuhao = tuhao.substring(0, tuhao.indexOf("-")); + if(!flMap.containsKey(tuhao)) { + flMap.put(tuhao, new ArrayList<>()); + } + flMap.get(tuhao).add(new String[] { rs.getString(1), rs.getString(3) }); + } + new SAPZZOperation(app, selectedParts.get(i), dists, SAPZZDialogController.this, flMap) + .executeOperation(); + if (KUtil.isEmpty(userName) && rev != null) { TCComponentUser user = (TCComponentUser) rev.getRelatedComponent("owning_user"); userName = user.getProperty("user_name"); @@ -238,6 +261,7 @@ public class SAPZZDialogController { mp.setVisible(false); e.printStackTrace(); } + SqlUtil.freeAll(); if (errorMsee.toString().length() > 0) { new SAPMessageUtil(dialog, "", "传递异常:" + errorMsee.toString()); } else { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZNewOp.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZNewOp.java index fbda517..68d26bc 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZNewOp.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZNewOp.java @@ -1,63 +1,36 @@ package com.connor.chint.sap2.sap_by; -import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import com.connor.chint.sap2.sap_zy.PartBean; import com.connor.chint.sap2.sap_zy.SAPZYDialogControllerzt; -import com.connor.chint.sap2.sap_zy.SAPZYOperation; import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.TXTUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFOperation; -import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentBOMLine; -import com.teamcenter.rac.kernel.TCComponentBOMWindow; -import com.teamcenter.rac.kernel.TCComponentBOMWindowType; -import com.teamcenter.rac.kernel.TCComponentBOPWindow; -import com.teamcenter.rac.kernel.TCComponentBOPWindowType; -import com.teamcenter.rac.kernel.TCComponentContextList; import com.teamcenter.rac.kernel.TCComponentDataset; -import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemRevision; -import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; import com.teamcenter.rac.kernel.TCComponentUser; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCSession; -import com.teamcenter.rac.util.MessageBox; - import plm.xi.com.chintelectric.DT_BOM_PLM_REQ; import plm.xi.com.chintelectric.DT_BOM_PLM_REQBASEINFO; import plm.xi.com.chintelectric.DT_BOM_PLM_REQLIST; -import plm.xi.com.chintelectric.DT_BOM_PLM_REQLISTHEAD; -import plm.xi.com.chintelectric.DT_BOM_PLM_REQLISTITEMSITEM; import plm.xi.com.chintelectric.DT_BOM_PLM_RSP; -import plm.xi.com.chintelectric.DT_BOM_PLM_RSPRSP_BASEINFO; -import plm.xi.com.chintelectric.DT_BOM_PLM_RSPZTABLE_RETURN; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQ; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQBASEINFO; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLIST; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTHEAD; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTITEMSITEM; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_RSP; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_RSPRSP_BASEINFO; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_RSPZTABLE_RETURN; import plm.xi.com.chintelectric.SI_BOM_PLM_OUT_SYN; import plm.xi.com.chintelectric.SI_BOM_PLM_OUT_SYNService; import plm.xi.com.chintelectric.SI_BOM_PLM_OUT_SYNServiceLocator; @@ -96,10 +69,7 @@ public class SAPZZNewOp extends AbstractAIFOperation { try { txtName = format2.format(new Date()) + getUserName(session); txtPath = TXTUtil.createTxt(txtName); - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -146,7 +116,7 @@ public class SAPZZNewOp extends AbstractAIFOperation { SAPUtil.recurBYZZSAP(bomline, zzRev, partRev, controller.gy_meops, controller.needTCM_meops, session, controller.groupName, list, proclist, txtPath, now, bomIsExist, controller.codeMark, controller.icsId, controller.materials, errMess, buff, controller.dists, 1, controller.material_revs, - set_meops,type,new ArrayList(),""); + set_meops,type, new ArrayList(), "", new HashMap>()); SAPUtil.removeNull(list); if (errMess.toString().length() > 0) { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZOperation.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZOperation.java index 405690a..38f7ca8 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZOperation.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZOperation.java @@ -1,21 +1,13 @@ package com.connor.chint.sap2.sap_by; -import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import java.util.Set; -import com.connor.chint.sap2.sap_zy.SAPZYOperation; import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.SAPUtil; @@ -26,38 +18,21 @@ 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.TCComponentBOMLine; -import com.teamcenter.rac.kernel.TCComponentBOMWindow; -import com.teamcenter.rac.kernel.TCComponentBOMWindowType; -import com.teamcenter.rac.kernel.TCComponentBOPWindow; -import com.teamcenter.rac.kernel.TCComponentBOPWindowType; -import com.teamcenter.rac.kernel.TCComponentContextList; import com.teamcenter.rac.kernel.TCComponentDataset; import com.teamcenter.rac.kernel.TCComponentFolder; import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemRevision; -import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; import com.teamcenter.rac.kernel.TCComponentUser; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCSession; -import com.teamcenter.rac.util.MessageBox; - import plm.xi.com.chintelectric.DT_BOM_PLM_REQ; import plm.xi.com.chintelectric.DT_BOM_PLM_REQBASEINFO; import plm.xi.com.chintelectric.DT_BOM_PLM_REQLIST; -import plm.xi.com.chintelectric.DT_BOM_PLM_REQLISTHEAD; -import plm.xi.com.chintelectric.DT_BOM_PLM_REQLISTITEMSITEM; import plm.xi.com.chintelectric.DT_BOM_PLM_RSP; -import plm.xi.com.chintelectric.DT_BOM_PLM_RSPRSP_BASEINFO; -import plm.xi.com.chintelectric.DT_BOM_PLM_RSPZTABLE_RETURN; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQ; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQBASEINFO; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLIST; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTHEAD; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTITEMSITEM; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM; import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_RSP; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_RSPRSP_BASEINFO; -import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_RSPZTABLE_RETURN; import plm.xi.com.chintelectric.SI_BOM_PLM_OUT_SYN; import plm.xi.com.chintelectric.SI_BOM_PLM_OUT_SYNService; import plm.xi.com.chintelectric.SI_BOM_PLM_OUT_SYNServiceLocator; @@ -68,36 +43,35 @@ import plm.xi.com.chintelectric.SI_PROCESSROUTE_PLM_OUT_SYNServiceLocator; public class SAPZZOperation extends AbstractAIFOperation { public static boolean flag = false; - TCSession session; - AbstractAIFApplication app; - List list = new ArrayList<>(); - List proclist = new ArrayList<>(); - String now; + private TCSession session; +// private AbstractAIFApplication app; + private List list = new ArrayList<>(); + private List proclist = new ArrayList<>(); + private String now; private ZZPartBean partBean; - List dists; +// private List dists; private String txtPath = ""; private String txtName = ""; private SAPZZDialogController controller; + private HashMap> flMap; public SAPZZOperation(AbstractAIFApplication app, ZZPartBean partBean, List dists, - SAPZZDialogController controller) { + SAPZZDialogController controller, HashMap> flMap) { session = (TCSession) app.getSession(); - this.app = app; +// this.app = app; this.controller = controller; SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); now = format.format(new Date()); this.partBean = partBean; - this.dists = dists; +// this.dists = dists; + this.flMap = flMap; SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"); try { txtName = format2.format(new Date()) + getUserName(session); txtPath = TXTUtil.createTxt(txtName); - } catch (TCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); } @@ -159,7 +133,7 @@ public class SAPZZOperation extends AbstractAIFOperation { SAPUtil.recurBYZZSAP(bomline, zzRev, partRev, controller.gy_meops, controller.needTCM_meops, session, controller.groupName, list, proclist, txtPath, now, bomIsExist, controller.dialog.materialCode, controller.icsID, controller.materials, errMess, buff, controller.dists, 1, controller.material_revs, - set_meops,"B",kjBomIds,projWbsNo); + set_meops,"B",kjBomIds,projWbsNo, flMap); SAPUtil.removeNull(list); if (errMess.toString().length() > 0) { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYController.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYController.java index 7bf12d6..65a461c 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYController.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYController.java @@ -49,6 +49,7 @@ import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.util.MessageBox; import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData; +import java.util.Arrays; import plm.xi.com.chintelectric.DT_BOM_PLM_REQ; import plm.xi.com.chintelectric.DT_BOM_PLM_REQBASEINFO; import plm.xi.com.chintelectric.DT_BOM_PLM_REQLIST; @@ -390,9 +391,9 @@ public class SAPGYController { String serverHostname = session.getServerHostname(); String sql = "insert into CHINT_BOM_TO_SAP_SUM (code,factory,\"USER\",starttime,wbsno,projectno,taskstauts" + ",plmresult,transfer,keymsg,sapresult,PROJECTUID,SERVERHOST,USERID) values " - + "(?,?,?,to_date(?,'yyyy-mm-dd hh24:mi:ss')" + ",?,?,'等待组织','未处理',?,?,'未返回',?,?,?)"; // to_date(?,'yyyy-mm-ddhh24:mi:ss') + + "(?,?,?,to_date(?,'yyyy-mm-dd hh24:mi:ss')" + ",?,?,'组织完成','已飞书通知',?,?,'全部成功',?,?,?)"; // to_date(?,'yyyy-mm-ddhh24:mi:ss') SqlUtil.write(sql, new String[] { code + "", groupName, userName, dataTime, zt2_WBSNo, object_name, - "高压", substring, project.getUid(), serverHostname, userId }); + "高压开关", substring, project.getUid(), serverHostname, userId }); } process_boms.clear(); process_jg.clear(); @@ -587,7 +588,43 @@ public class SAPGYController { if (list.size() > 0) { // BOM传递写入数据库 try { - SI_BOM_PLM_OUT_SYNService service = new SI_BOM_PLM_OUT_SYNServiceLocator(); + SI_BOM_PLM_OUT_SYNService service; + if(yb) { + //TODO BOM传递写入数据库 + for(DT_BOM_PLM_REQLIST bomMsg : list) { +// String topUid = bomMsg.getHEAD().getSTKTX(); + DT_BOM_PLM_REQLISTHEAD head = bomMsg.getHEAD(); + DT_BOM_PLM_REQLISTITEMSITEM[] items = bomMsg.getITEMS(); + for(DT_BOM_PLM_REQLISTITEMSITEM item : items) { + head.getSTKTX(); + item.getMEINS(); + } + String matnr = bomMsg.getHEAD().getMATNR(); +// System.out.println("matnr:" + matnr); +// System.out.println("materialMap:" + materialMap); + TCComponent top = materialMap.get(matnr); + if(top == null) { + top = ccp; + } + String detials = "insert into CHINT_BOM_TO_SAP_DETIALS (code,batchnumber,plmsendstatus," + + "plmsendstarttime,factory,productmaterialno,pitemid,puid,materialno,wbsno," + + "plmstatus,plmalterstatus) " + + "VALUES (?,?,'PLM开始传递',SYSDATE,?,?,?,?,?,?,'未处理',?)"; +// System.out.println("ccpMap:" + ccpMap); +// System.out.println("top:" + top); + String[] sql = new String[] { code + "", + code + "-" + String.format("%05d", batchNum++), groupName, ccpMap.get(matnr), + top.getProperty("item_id"), top.getUid(), matnr, zt2_WBSNo, plmalterstatus }; + System.out.println("sql:" + Arrays.toString(sql)); + SqlUtil.write(detials, sql); + } + String[] urls = ChintPreferenceUtil.getPreferences("CHINT_BomUrl_YB", session); + service = new SI_BOM_PLM_OUT_SYNServiceLocator(urls[2]); + System.out.println("异步1:" + urls[2]); + }else { + System.out.println("同步1"); + service = new SI_BOM_PLM_OUT_SYNServiceLocator(); + } SI_BOM_PLM_OUT_SYN stub = service.getHTTP_Port(); String REQ_TRACE_ID = "123456"; DT_BOM_PLM_REQBASEINFO baseInfo = new DT_BOM_PLM_REQBASEINFO(REQ_TRACE_ID); @@ -940,7 +977,7 @@ public class SAPGYController { List bomISExist = new ArrayList(); // StringBuffer buff = new StringBuffer(); - StringBuffer errMess = new StringBuffer(); + StringBuffer errMess = new StringBuffer(""); String txtName = format2.format(new Date()) + userName; String txtPath = TXTUtil.createTxt(txtName); TCComponent meopRev = null; @@ -1035,42 +1072,65 @@ public class SAPGYController { throw new Exception(errMess.toString()); } - TXTUtil.writeTXT(txtPath, "----------BOM传递(自身传递)-----------"); - System.out.println("----------BOM传递(自身传递)-----------"); + TXTUtil.writeTXT(txtPath, "----------BOM传递(自身传递)-----------1"); + System.out.println("----------BOM传递(自身传递)-----------2"); List matnrs = null; // 变压器BOM传递SAP if (list.size() > 0) { try { + SI_BOM_PLM_OUT_SYNService service; + String REQ_TRACE_ID = "123456"; if(yb) { //TODO BOM传递写入数据库 + REQ_TRACE_ID = code + "-" + String.format("%05d", batchNum++); for(DT_BOM_PLM_REQLIST bomMsg : list) { // String topUid = bomMsg.getHEAD().getSTKTX(); + DT_BOM_PLM_REQLISTHEAD head = bomMsg.getHEAD(); + DT_BOM_PLM_REQLISTITEMSITEM[] items = bomMsg.getITEMS(); + for(DT_BOM_PLM_REQLISTITEMSITEM item : items) { + head.getSTKTX(); + item.getMEINS(); + } String matnr = bomMsg.getHEAD().getMATNR(); +// System.out.println("matnr:" + matnr); +// System.out.println("materialMap:" + materialMap); TCComponent top = materialMap.get(matnr); - String detials = "insert into CHINT_BOM_TO_SAP_DETIALS (code,batchnumber,plmsendstatus,plmsendstarttime,factory,productmaterialno,pitemid,puid,materialno,wbsno,plmstatus,plmalterstatus) " + if(top == null) { + top = bean.getPartRev(); + } + String detials = "insert into CHINT_BOM_TO_SAP_DETIALS (code,batchnumber,plmsendstatus," + + "plmsendstarttime,factory,productmaterialno,pitemid,puid,materialno,wbsno," + + "plmstatus,plmalterstatus) " + "VALUES (?,?,'PLM开始传递',SYSDATE,?,?,?,?,?,?,'未处理',?)"; - SqlUtil.write(detials, new String[] { code + "", code + "-" + String.format("%05d", batchNum++), groupName, ccpMap.get(matnr), top.getProperty("item_id"), top.getUid(), matnr, zt2_WBSNo, plmalterstatus }); - //materialNoTmp.c_str(), itemId, topUid, bomMsg.HEAD.MATNR, wbsNo, alterstatus +// System.out.println("ccpMap:" + ccpMap); +// System.out.println("top:" + top); + String[] sql = new String[] { code + "", REQ_TRACE_ID, groupName, ccpMap.get(matnr), + top.getProperty("item_id"), top.getUid(), matnr, zt2_WBSNo, plmalterstatus }; + System.out.println("sql:" + Arrays.toString(sql)); + SqlUtil.write(detials, sql); } + String[] urls = ChintPreferenceUtil.getPreferences("CHINT_BomUrl_YB", session); + System.out.println("异步2:" + urls[2]); + service = new SI_BOM_PLM_OUT_SYNServiceLocator(urls[2]); }else { - SI_BOM_PLM_OUT_SYNService service = new SI_BOM_PLM_OUT_SYNServiceLocator(); - SI_BOM_PLM_OUT_SYN stub = service.getHTTP_Port(); - String REQ_TRACE_ID = "123456"; - DT_BOM_PLM_REQBASEINFO baseInfo = new DT_BOM_PLM_REQBASEINFO(REQ_TRACE_ID); - DT_BOM_PLM_REQLIST[] request = list.toArray(new DT_BOM_PLM_REQLIST[list.size()]); - System.out.println("request:"); - TXTUtil.writeTXT(txtPath, "BOM数据传递开始"); - for (int i = 0; i < request.length; i++) { - TXTUtil.writeTXT(txtPath, request[i]); - } - - DT_BOM_PLM_REQ req = new DT_BOM_PLM_REQ(baseInfo, request); - DT_BOM_PLM_RSP resp = stub.SI_BOM_PLM_OUT_SYN(req); - System.out.println("执行结束4"); - TXTUtil.writeTXT(txtPath, "BOM数据传递结束"); - matnrs = SAPUtil.printResp(resp, txtPath); + System.out.println("同步2"); + service = new SI_BOM_PLM_OUT_SYNServiceLocator(); } + SI_BOM_PLM_OUT_SYN stub = service.getHTTP_Port(); + DT_BOM_PLM_REQBASEINFO baseInfo = new DT_BOM_PLM_REQBASEINFO(REQ_TRACE_ID); + DT_BOM_PLM_REQLIST[] request = list.toArray(new DT_BOM_PLM_REQLIST[list.size()]); + System.out.println("request:"); + TXTUtil.writeTXT(txtPath, "BOM数据传递开始"); + for (int i = 0; i < request.length; i++) { + TXTUtil.writeTXT(txtPath, request[i]); + } + + DT_BOM_PLM_REQ req = new DT_BOM_PLM_REQ(baseInfo, request); + DT_BOM_PLM_RSP resp = stub.SI_BOM_PLM_OUT_SYN(req); + System.out.println("执行结束4"); + TXTUtil.writeTXT(txtPath, "BOM数据传递结束"); + matnrs = SAPUtil.printResp(resp, txtPath); } catch (Exception e) { errMess.append("\n[" + rev + "]产成品发送BOM时发生异常:" + e.getMessage()); TXTUtil.writeTXT(txtPath, "[" + rev + "]产成品发送BOM时发生异常:" + e.getMessage()); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYDialogController.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYDialogController.java index dc32bf8..86e8904 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYDialogController.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYDialogController.java @@ -1131,26 +1131,6 @@ public class SAPZYDialogController { return selectedParts; } - public static void sendMsg(String mess, String userID, String logPath) throws IOException { - - try { - TXTUtil.writeTXT(logPath, "开始AM消息推送"); - TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); - ISendMsgServices service2 = new ISendMsgServicesLocator(); - ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http(); - String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM"); - TXTUtil.writeTXT(logPath, "返回信息:" + mess2); - System.out.println("返回信息:" + mess2); - } catch (ServiceException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - TXTUtil.writeTXT(logPath, "AM消息推送结束"); - } - private void sendSapKT(MyProgressBarCompent my, boolean isCheckProduct) throws Exception { List selectedParts = getSelectedParts(); int len = selectedParts == null ? 0 : selectedParts.size(); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYDialogControllerzt.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYDialogControllerzt.java index f3b0daa..296058d 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYDialogControllerzt.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYDialogControllerzt.java @@ -1428,26 +1428,6 @@ public class SAPZYDialogControllerzt { return selectedParts; } - public static void sendMsg(String mess, String userID, String logPath) throws IOException { - - try { - TXTUtil.writeTXT(logPath, "开始AM消息推送"); - TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); - ISendMsgServices service2 = new ISendMsgServicesLocator(); - ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http(); - String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM"); - TXTUtil.writeTXT(logPath, "返回信息:" + mess2); - System.out.println("返回信息:" + mess2); - } catch (ServiceException e) { - // Auto-generated catch block - e.printStackTrace(); - } catch (RemoteException e) { - // Auto-generated catch block - e.printStackTrace(); - } - TXTUtil.writeTXT(logPath, "AM消息推送结束"); - } - private void sendSapKT(MyProgressBarCompent my, boolean isCheckProduct) throws Exception { List selectedParts = getSelectedParts(); int len = selectedParts == null ? 0 : selectedParts.size(); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/KUtil.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/KUtil.java index 56c051b..a06ac66 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/KUtil.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/KUtil.java @@ -881,15 +881,20 @@ public class KUtil { if (parent == null) { return; } - TreeNode node = (TreeNode) parent.getLastPathComponent(); - if (node.getChildCount() >= 0) { - for (Enumeration e = node.children(); e.hasMoreElements();) { - TreeNode n = (TreeNode) e.nextElement(); - TreePath path = parent.pathByAddingChild(n); - expandTree(tree, path); + try { + System.out.println("parent:" + Arrays.toString(parent.getPath())); + TreeNode node = (TreeNode) parent.getLastPathComponent(); + if (node.getChildCount() > 0) { + for (Enumeration e = node.children(); e.hasMoreElements();) { + TreeNode n = (TreeNode) e.nextElement(); + TreePath path = parent.pathByAddingChild(n); + expandTree(tree, path); + } } + tree.expandPath(parent); + }catch(Exception e) { + e.printStackTrace(); } - tree.expandPath(parent); } public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width) { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SAPUtil.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SAPUtil.java index cc8a0c1..062677a 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SAPUtil.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SAPUtil.java @@ -3,7 +3,6 @@ package com.connor.chint.sap2.util; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.rmi.RemoteException; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; @@ -20,8 +19,6 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.TimeUnit; -import javax.xml.rpc.ServiceException; - import com.connor.chint.sap2.bean.ApplyMeBean; import com.connor.chint.sap2.bom.core.BOMInfo; import com.connor.chint.sap2.bom.core.Component; @@ -79,9 +76,6 @@ import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.Registry; import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData; -import nc.itf.chintwebservices.msg.ISendMsgServices.ISendMsgServices; -import nc.itf.chintwebservices.msg.ISendMsgServices.ISendMsgServicesLocator; -import nc.itf.chintwebservices.msg.ISendMsgServices.ISendMsgServicesPortType; import net.sf.json.JSONObject; import plm.xi.com.chintelectric.DT_BOM_PLM_REQLIST; import plm.xi.com.chintelectric.DT_BOM_PLM_REQLISTHEAD; @@ -3395,21 +3389,73 @@ public class SAPUtil { * @param logPath 推送AM消息 * @throws IOException */ - public static void sendMsg(String mess, String userID, String logPath) throws IOException { - try { - TXTUtil.writeTXT(logPath, "开始AM消息推送"); - TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); - ISendMsgServices service2 = new ISendMsgServicesLocator(); +// public static void sendMsg(String mess, String userID, String logPath) throws IOException { +// try { +// TXTUtil.writeTXT(logPath, "开始AM消息推送"); +// TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); +// ISendMsgServices service2 = new ISendMsgServicesLocator(); +// ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http(); +// String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM"); +// TXTUtil.writeTXT(logPath, "返回信息:" + mess2); +// System.out.println("返回信息:" + mess2); +// } catch (ServiceException e) { +// e.printStackTrace(); +// } catch (RemoteException e) { +// e.printStackTrace(); +// } +// TXTUtil.writeTXT(logPath, "AM消息推送结束"); +// } + public static void sendMsg(String mess, String userID, String logPath) { + TXTUtil.writeTXT(logPath, "开始AM消息推送"); + TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); + String mess2 = sendMsg(mess, userID); + TXTUtil.writeTXT(logPath, "返回信息:" + mess2); + TXTUtil.writeTXT(logPath, "AM消息推送结束"); + } + + public static String sendMsg(String mess, String userID) { + String mess2 = ""; + try { + /*ISendMsgServices service2 = new ISendMsgServicesLocator(); ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http(); - String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM"); - TXTUtil.writeTXT(logPath, "返回信息:" + mess2); - System.out.println("返回信息:" + mess2); - } catch (ServiceException e) { - e.printStackTrace(); - } catch (RemoteException e) { + String mess2 = stub2.chintSendMsgServices(userID, "", mess, "");//(userID, "", mess, "PLM");*/ + + //TODO lidy20240829新接口 先获取token,再组织数据 + String msgJson = "{\"emails\":[\"" + userID + "\"],\"mobiles\": [],\"content\": \"" + mess + "\"}"; + + OkHttpClient client = new OkHttpClient(); + RequestBody body = RequestBody.create(null, new byte[0]); + Request request = new Request.Builder() + .url("https://pub.chintelec.com/api/getToken?appId=zt_plm&appSecret=RA5KfdZtj37zpVsmgKeSxWncEIT8npVf") + .post(body) + .build(); + Response response = client.newCall(request).execute(); + String res = response.body().string(); + org.json.JSONObject jsonObject = new org.json.JSONObject(res); +// System.out.println(res); + if(!jsonObject.getBoolean("success")) { + System.out.println(res); + return res; + } + String token = jsonObject.getString("data"); + + client = new OkHttpClient(); + MediaType mediaType = MediaType.parse("application/json"); + body = RequestBody.create(mediaType, msgJson); + request = new Request.Builder() + .url("https://pub.chintelec.com/api/open/Feishu/sendMessages") + .post(body) + .addHeader("Authorization", token) + .addHeader("Content-Type", "application/json") + .build(); + response = client.newCall(request).execute(); + mess2 = response.body().string(); + System.out.println("返回信息:" + mess2); + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); - } - TXTUtil.writeTXT(logPath, "AM消息推送结束"); + } + return mess2; } // 清楚为空的子项 @@ -4034,8 +4080,7 @@ public class SAPUtil { List list, List proclist, String txtPath, String now, List bomISExist, String codeRemark, int icsId, Map by_materials, StringBuffer errMess, StringBuffer buff, Map material_revs,String matr, - List kjBomIds,String projWbsNo) - throws Exception { + List kjBomIds, String projWbsNo, HashMap> flMap) throws Exception { // 若来源为外购,BOM不继续向下展开 20191227 try { line.refresh(); @@ -4070,7 +4115,7 @@ public class SAPUtil { boolean equals = rev.getProperty("zt2_Source").equals("外购"); if (partRev != null) { if (meops.length == 0) { - if(!equals && line.getChildrenCount() > 0) { + if(!equals && rev.getType().equals("ZT2_Design3DRevision")) {// && line.getChildrenCount() > 0 String groupID = SAPUtil.getGroupID(session); TCComponentMEProcessRevision mrProcess = getMrProcess(groupID,session); if(mrProcess!=null) { @@ -4107,7 +4152,7 @@ public class SAPUtil { TCComponentBOMLine componentbomline = win.getTopBOMLine(); SAPUtil.recurBYBJSAP(componentbomline, partRev, partRev, gy_meops, needTCM_meops, session, groupName, list, proclist, txtPath, now, bomISExist, codeRemark, icsId, by_materials, errMess, buff, - material_revs,matr,kjBomIds, projWbsNo); + material_revs,matr,kjBomIds, projWbsNo, flMap); win.refresh(); win.close(); @@ -4125,17 +4170,20 @@ public class SAPUtil { bomISExist.add(zt2_MaterialNo); } } + String idCut = ""; + if(item_id.indexOf("-") > 0) + idCut = item_id.substring(0, item_id.indexOf("-")); - if (contexts.length == 0) { + if (contexts.length == 0 && !flMap.containsKey(idCut)) { if (rev.getType().equals("ZT2_Design3DRevision") && rev.getProperty("zt2_Source").equals("自制")) { buff.setLength(0); TCComponentItemRevision comp = null; String sortno = ""; Map materials = new HashMap(); if(matr!=null && matr.equals("DB")) { - comp = SAPUtil.getClassPartDB(rev, session, codeRemark, icsId, by_materials, buff,materials); + comp = SAPUtil.getClassPartDB(rev, session, codeRemark, icsId, by_materials, buff, materials); }else { - comp = SAPUtil.getClassPart(rev, session, codeRemark, icsId, by_materials, buff,materials); + comp = SAPUtil.getClassPart(rev, session, codeRemark, icsId, by_materials, buff, materials); } // 原材料展开时投料工序获取父项的工艺首工序改为获取父项的投料工序 sortno = line.getProperty("ZT2_ClassificationNo"); @@ -4253,7 +4301,26 @@ public class SAPUtil { head.setBMENG("1"); head.setWERKS(groupName); head.setDATUV(now); - DT_BOM_PLM_REQLISTITEMSITEM[] items = new DT_BOM_PLM_REQLISTITEMSITEM[contexts.length]; + int start = contexts.length; + DT_BOM_PLM_REQLISTITEMSITEM[] items = new DT_BOM_PLM_REQLISTITEMSITEM[start]; + ArrayList fls = new ArrayList<>(); + ArrayList gxs = new ArrayList<>(); + if (flMap.containsKey(idCut)) { + for(String[] fl : flMap.get(idCut)) { + TCComponent[] flnoItem = session.search("零组件 ID", new String[] { "零组件 ID" }, + new String[] { fl[0] }); + if(flnoItem.length > 0) { + TCComponentItemRevision flno = ((TCComponentItem)flnoItem[0]).getLatestItemRevision(); + TCComponentBOMLine flnoBOM = SAPUtil.getNewBOMLine(flno, session); + for(AIFComponentContext c : flnoBOM.getChildren()) { + fls.add(c); + gxs.add(fl[1]); + } + } + } + items = new DT_BOM_PLM_REQLISTITEMSITEM[start + fls.size()]; + } + int seq = 0; System.out.println("len:" + items.length); if (buff.length() > 0 && !errMess.toString().contains(item_id + "-" + object_name + ":" + buff.toString())) { errMess.append("\n" + item_id + "-" + object_name + ":" + buff.toString()); @@ -4286,13 +4353,17 @@ public class SAPUtil { item.setIDNRK(zt2_materialNo); item.setMEINS(partRev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); String zt2_State = partRev2.getProperty("zt2_State"); - if(zt2_State.equals("封存")||zt2_State.equals("D1")) { + if(zt2_State.equals("封存") || zt2_State.equals("D1")) { buff.append("物料:").append(zt2_materialNo).append("已封存,无法传递SAP"); } } item.setDATUV(now); item.setPOSTP("L"); - item.setPOSNR(line2.getProperty("bl_sequence_no")); + String seqs = line2.getProperty("bl_sequence_no"); + item.setPOSNR(seqs); + int bl_sequence_no = Integer.parseInt(seqs.isEmpty() ? "0" : seqs); + if(bl_sequence_no > seq) + seq = bl_sequence_no; String sortno = line2.getProperty("ZT2_ClassificationNo"); item.setMENGE(SAPUtil.getSAPMENGE(rev2, null, line2, false, codeRemark, buff)); item.setSORTF(sortno); @@ -4303,10 +4374,9 @@ public class SAPUtil { items[i] = item; String item_id2 = rev2.getProperty("item_id"); String object_name2 = rev2.getProperty("object_name"); - if (buff.length() > 0 && !errMess.toString().contains( - item_id2 + "-" + object_name2 + "(父项:" + item_id + "-" + object_name + "):" + buff.toString())) { - errMess.append("\n" + item_id2 + "-" + object_name2 + "(父项:" + item_id + "-" + object_name + "):" - + buff.toString()); + String mess = item_id2 + "-" + object_name2 + "(父项:" + item_id + "-" + object_name + "):" + buff.toString(); + if (buff.length() > 0 && !errMess.toString().contains(mess)) { + errMess.append("\n" + mess); } if (rev2.getProperty("zt2_SapState").equals("已传") && isContinue) continue; @@ -4314,14 +4384,49 @@ public class SAPUtil { material_revs.put(zt2_materialNo, partRev2); } SAPUtil.recurBYBJSAP(line2, rev2, partRev2, gy_meops, needTCM_meops, session, groupName, list, proclist, - txtPath, now, bomISExist, codeRemark, icsId, by_materials, errMess, buff, material_revs,matr, - kjBomIds,projWbsNo); + txtPath, now, bomISExist, codeRemark, icsId, by_materials, errMess, buff, material_revs, matr, + kjBomIds, projWbsNo, flMap); + } + // + if (flMap.containsKey(idCut)) { + for(int i = 0; i < fls.size(); i++) { + DT_BOM_PLM_REQLISTITEMSITEM item = new DT_BOM_PLM_REQLISTITEMSITEM(); + TCComponentBOMLine line2 = (TCComponentBOMLine) fls.get(i).getComponent(); + TCComponentItemRevision rev2 = line2.getItemRevision(); + TCComponentItemRevision partRev2 = SAPUtil.getSAPPart(line2, session, groupName, buff); + System.out.println("fl:" + item_id + ">>" + line2); + + String zt2_MaterialNo = ""; + if (partRev2 != null) { + zt2_MaterialNo = partRev2.getProperty("zt2_MaterialNo"); + item.setIDNRK(zt2_MaterialNo); + item.setMEINS(partRev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); + String zt2_State = partRev2.getProperty("zt2_State"); + if(zt2_State.equals("封存") || zt2_State.equals("D1")) { + buff.append("物料:").append(zt2_MaterialNo).append("已封存,无法传递SAP"); + } + } + item.setDATUV(now); + item.setPOSTP("L"); + seq += 10; + item.setPOSNR("" + seq); + item.setMENGE(SAPUtil.getSAPMENGE(rev2, null, line2, false, codeRemark, buff)); + item.setSORTF(gxs.get(i)); + item.setPOTX1(line2.getProperty("ZT2_Remark")); + items[start + i] = item; + String item_id2 = rev2.getProperty("item_id"); + String object_name2 = rev2.getProperty("object_name"); + String mess = item_id2 + "-" + object_name2 + "(父项:" + item_id + "-" + object_name + "):" + buff.toString(); + if (buff.length() > 0 && !errMess.toString().contains(mess)) { + errMess.append("\n" + mess); + } + } } list.add(new DT_BOM_PLM_REQLIST(head, items)); } /* - * 变压器总装传递SAP逻辑 + * TODO 变压器总装传递SAP逻辑 */ public static void recurBYZZSAP(TCComponentBOMLine line, TCComponentItemRevision rev, TCComponentItemRevision partRev, Map gy_meops, @@ -4330,7 +4435,7 @@ public class SAPUtil { List bomISExist, String codeRemark, int icsId, Map by_materials, StringBuffer errMess, StringBuffer buff, List dists, int level, Map material_revs, Set set_meops,String type1, - List kjBomIds ,String projWbsNo ) throws Exception { + List kjBomIds, String projWbsNo, HashMap> flMap) throws Exception { try { line.refresh(); }catch(Exception e) { @@ -4351,8 +4456,8 @@ public class SAPUtil { if (partRev == null) { partRev = SAPUtil.getSAPPart(line, session, groupName, buff); } - TCComponentMEProcessRevision meop = null; - for(int i=0;i 0 && !KUtil.isTCM((TCComponent) meops[0].getComponent())) { // set_meops.add((TCComponent) meops[0].getComponent()); // } - // 如果图纸下没有物料,则,判断此图纸版本上的属性zt2_Diagram属性,如果此属性为是(LOV值,真实值为Y),则不传递此图纸,物料检查也不要报错,跳过此图纸以及子件 + // 如果图纸下没有物料,则,判断此图纸版本上的属性zt2_Diagram属性, + //如果此属性为是(LOV值,真实值为Y),则不传递此图纸,物料检查也不要报错,跳过此图纸以及子件 if (rev.getType().equals("ZT2_Design3DRevision") && partRev == null) { String zt2_Diagram = rev.getTCProperty("zt2_Diagram").getStringValue(); if (zt2_Diagram.equals("Y") || zt2_Diagram.equals("是")) { @@ -4377,34 +4483,31 @@ public class SAPUtil { System.out.println("rev:" + rev + " partRev:" + partRev + " length:" + contexts.length); if (partRev != null) { System.out.println("查询工艺路线:" + rev); - if (partRev != null) { - if (meop == null) { - if(!equals && (type1.equals("C")||type1.equals("E") && line.getChildrenCount() > 0)) { - String groupID = SAPUtil.getGroupID(session); - TCComponentMEProcessRevision mrProcess = getMrProcess(groupID,session); - if(mrProcess!=null) { - if (level == 1) { - SAPUtil.readBopInfo1(mrProcess, partRev, session, now, - txtPath, proclist, groupName, gy_meops, needTCM_meops, false); - } else { - SAPUtil.readBopInfo1(mrProcess, partRev, session, now, - txtPath, proclist, groupName, gy_meops, needTCM_meops, false); - } + if (meop == null) { + if(!equals && rev.getType().equals("ZT2_Design3DRevision")) { + //&& (type1.equals("C") || (type1.equals("B") || type1.equals("E")) && line.getChildrenCount() > 0) + String groupID = SAPUtil.getGroupID(session); + TCComponentMEProcessRevision mrProcess = getMrProcess(groupID,session); + if(mrProcess!=null) { + if (level == 1) { + SAPUtil.readBopInfo1(mrProcess, partRev, session, now, + txtPath, proclist, groupName, gy_meops, needTCM_meops, false); + } else { + SAPUtil.readBopInfo1(mrProcess, partRev, session, now, + txtPath, proclist, groupName, gy_meops, needTCM_meops, false); } - }else { - TXTUtil.writeTXT(txtPath, "图纸[" + rev + "]无工艺信息"); } - + }else { + TXTUtil.writeTXT(txtPath, "图纸[" + rev + "]无工艺信息"); + } + } else { + TXTUtil.writeTXT(txtPath, "图纸[" + rev + "]工艺信息:" + meop); + if (level == 1) { + SAPUtil.readBopInfo1(meop, partRev, session, + now, txtPath, proclist, groupName, gy_meops, needTCM_meops, false); } else { - TXTUtil.writeTXT(txtPath, "图纸[" + rev + "]工艺信息:" + meop); - if (level == 1) { - SAPUtil.readBopInfo1(meop, partRev, session, - now, txtPath, proclist, groupName, gy_meops, needTCM_meops, false); - } else { - SAPUtil.readBopInfo1(meop, partRev, session, - now, txtPath, proclist, groupName, gy_meops, needTCM_meops, true); - } - + SAPUtil.readBopInfo1(meop, partRev, session, + now, txtPath, proclist, groupName, gy_meops, needTCM_meops, true); } } } @@ -4427,7 +4530,7 @@ public class SAPUtil { TCComponentBOMLine componentbomline = win.getTopBOMLine(); SAPUtil.recurBYZZSAP(componentbomline, partRev, partRev, gy_meops, needTCM_meops, session, groupName, list, proclist, txtPath, now, bomISExist, codeRemark, icsId, by_materials, errMess, buff, dists, - level, material_revs, set_meops,type1,kjBomIds, projWbsNo ); + level, material_revs, set_meops,type1,kjBomIds, projWbsNo, flMap); win.refresh(); win.close(); @@ -4443,8 +4546,11 @@ public class SAPUtil { bomISExist.add(zt2_MaterialNo); } } + String idCut = ""; + if(item_id.indexOf("-") > 0) + idCut = item_id.substring(0, item_id.indexOf("-")); - if (contexts.length == 0) { + if (contexts.length == 0 && !flMap.containsKey(idCut)) { int index = item_id.lastIndexOf("-"); String item_id_cut = ""; if (index != -1) { @@ -4570,12 +4676,31 @@ public class SAPUtil { head.setBMENG("1"); head.setWERKS(groupName); head.setDATUV(now); - DT_BOM_PLM_REQLISTITEMSITEM[] items = new DT_BOM_PLM_REQLISTITEMSITEM[contexts.length]; + int start = contexts.length; + DT_BOM_PLM_REQLISTITEMSITEM[] items = new DT_BOM_PLM_REQLISTITEMSITEM[start]; + ArrayList fls = new ArrayList<>(); + ArrayList gxs = new ArrayList<>(); + if (flMap.containsKey(idCut)) { + for(String[] fl : flMap.get(idCut)) { + TCComponent[] flnoItem = session.search("零组件 ID", new String[] { "零组件 ID" }, + new String[] { fl[0] }); + if(flnoItem.length > 0) { + TCComponentItemRevision flno = ((TCComponentItem)flnoItem[0]).getLatestItemRevision(); + TCComponentBOMLine flnoBOM = SAPUtil.getNewBOMLine(flno, session); + for(AIFComponentContext c : flnoBOM.getChildren()) { + fls.add(c); + gxs.add(fl[1]); + } + } + } + items = new DT_BOM_PLM_REQLISTITEMSITEM[start + fls.size()]; + } + int seq = 0; System.out.println("len:" + items.length); if (buff.length() > 0 && !errMess.toString().contains(item_id + "-" + object_name + ":" + buff.toString())) { errMess.append("\n" + item_id + "-" + object_name + ":" + buff.toString()); } - for (int i = 0; i < contexts.length; i++) { + for (int i = 0; i < start; i++) { buff.setLength(0); DT_BOM_PLM_REQLISTITEMSITEM item = new DT_BOM_PLM_REQLISTITEMSITEM(); TCComponentBOMLine line2 = (TCComponentBOMLine) contexts[i].getComponent(); @@ -4605,13 +4730,17 @@ public class SAPUtil { item.setIDNRK(zt2_MaterialNo); item.setMEINS(partRev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); String zt2_State = partRev2.getProperty("zt2_State"); - if(zt2_State.equals("封存")||zt2_State.equals("D1")) { + if(zt2_State.equals("封存") || zt2_State.equals("D1")) { buff.append("物料:").append(zt2_MaterialNo).append("已封存,无法传递SAP"); } } item.setDATUV(now); item.setPOSTP("L"); - item.setPOSNR(line2.getProperty("bl_sequence_no")); + String seqs = line2.getProperty("bl_sequence_no"); + item.setPOSNR(seqs); + int bl_sequence_no = Integer.parseInt(seqs.isEmpty() ? "0" : seqs); + if(bl_sequence_no > seq) + seq = bl_sequence_no; String sortno = line2.getProperty("ZT2_ClassificationNo"); item.setMENGE(SAPUtil.getSAPMENGE(rev2, null, line2, false, codeRemark, buff)); item.setSORTF(sortno); @@ -4622,10 +4751,9 @@ public class SAPUtil { items[i] = item; String item_id2 = rev2.getProperty("item_id"); String object_name2 = rev2.getProperty("object_name"); - if (buff.length() > 0 && !errMess.toString().contains( - item_id2 + "-" + object_name2 + "(父项:" + item_id + "-" + object_name + "):" + buff.toString())) { - errMess.append("\n" + item_id2 + "-" + object_name2 + "(父项:" + item_id + "-" + object_name + "):" - + buff.toString()); + String mess = item_id2 + "-" + object_name2 + "(父项:" + item_id + "-" + object_name + "):" + buff.toString(); + if (buff.length() > 0 && !errMess.toString().contains(mess)) { + errMess.append("\n" + mess); } if (rev2.getProperty("zt2_SapState").equals("已传") && isContinue) continue; @@ -4634,7 +4762,41 @@ public class SAPUtil { } SAPUtil.recurBYZZSAP(line2, rev2, partRev2, gy_meops, needTCM_meops, session, groupName, list, proclist, txtPath, now, bomISExist, codeRemark, icsId, by_materials, errMess, buff, dists, level + 1, - material_revs, set_meops,type1,kjBomIds,projWbsNo); + material_revs, set_meops,type1,kjBomIds,projWbsNo, flMap); + } + // + if (flMap.containsKey(idCut)) { + for(int i = 0; i < fls.size(); i++) { + DT_BOM_PLM_REQLISTITEMSITEM item = new DT_BOM_PLM_REQLISTITEMSITEM(); + TCComponentBOMLine line2 = (TCComponentBOMLine) fls.get(i).getComponent(); + TCComponentItemRevision rev2 = line2.getItemRevision(); + TCComponentItemRevision partRev2 = SAPUtil.getSAPPart(line2, session, groupName, buff); + + String zt2_MaterialNo = ""; + if (partRev2 != null) { + zt2_MaterialNo = partRev2.getProperty("zt2_MaterialNo"); + item.setIDNRK(zt2_MaterialNo); + item.setMEINS(partRev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); + String zt2_State = partRev2.getProperty("zt2_State"); + if(zt2_State.equals("封存") || zt2_State.equals("D1")) { + buff.append("物料:").append(zt2_MaterialNo).append("已封存,无法传递SAP"); + } + } + item.setDATUV(now); + item.setPOSTP("L"); + seq += 10; + item.setPOSNR("" + seq); + item.setMENGE(SAPUtil.getSAPMENGE(rev2, null, line2, false, codeRemark, buff)); + item.setSORTF(gxs.get(i)); + item.setPOTX1(line2.getProperty("ZT2_Remark")); + items[start + i] = item; + String item_id2 = rev2.getProperty("item_id"); + String object_name2 = rev2.getProperty("object_name"); + String mess = item_id2 + "-" + object_name2 + "(父项:" + item_id + "-" + object_name + "):" + buff.toString(); + if (buff.length() > 0 && !errMess.toString().contains(mess)) { + errMess.append("\n" + mess); + } + } } list.add(new DT_BOM_PLM_REQLIST(head, items)); } @@ -5645,6 +5807,7 @@ public class SAPUtil { head.setBMENG("1"); head.setWERKS(groupName); head.setDATUV(now); + head.setSTKTX(partRev.getUid()); DT_BOM_PLM_REQLISTITEMSITEM[] items = new DT_BOM_PLM_REQLISTITEMSITEM[1]; DT_BOM_PLM_REQLISTITEMSITEM item = new DT_BOM_PLM_REQLISTITEMSITEM(); @@ -5684,6 +5847,7 @@ public class SAPUtil { head.setBMENG("1"); head.setWERKS(groupName); head.setDATUV(now); + head.setSTKTX(partRev.getUid()); Composite Root = (Composite) root; int length = Root.getChildren().size(); DT_BOM_PLM_REQLISTITEMSITEM[] items = new DT_BOM_PLM_REQLISTITEMSITEM[length]; diff --git a/com.connor.chint.sap2/src/plm/xi/com/chintelectric/SI_BOM_PLM_OUT_SYNServiceLocator.java b/com.connor.chint.sap2/src/plm/xi/com/chintelectric/SI_BOM_PLM_OUT_SYNServiceLocator.java index 0f6fd0b..b766a92 100644 --- a/com.connor.chint.sap2/src/plm/xi/com/chintelectric/SI_BOM_PLM_OUT_SYNServiceLocator.java +++ b/com.connor.chint.sap2/src/plm/xi/com/chintelectric/SI_BOM_PLM_OUT_SYNServiceLocator.java @@ -12,6 +12,15 @@ public class SI_BOM_PLM_OUT_SYNServiceLocator extends org.apache.axis.client.Ser public SI_BOM_PLM_OUT_SYNServiceLocator() { } + /* + * lidy20241127 + * 支持异步接口地址 + * @param url 接口地址 + */ + public SI_BOM_PLM_OUT_SYNServiceLocator(String url) { + HTTPS_Port_address = url; + } + public SI_BOM_PLM_OUT_SYNServiceLocator(org.apache.axis.EngineConfiguration config) { super(config);