From 4300500e973b420bc05c1fa1fcd30d138bb77848 Mon Sep 17 00:00:00 2001 From: "lidy@connor.net.cn" Date: Thu, 11 Apr 2024 17:53:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4=E7=AE=A1=E7=90=86-=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=9B=B4=E6=94=B9=E5=90=8E=E6=94=BE=E7=9A=84=E7=89=A9?= =?UTF-8?q?=E6=96=99=E7=89=88=E6=9C=AC=E4=B8=BAA=E7=89=88=EF=BC=8C?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=B7=AE=E5=BC=82=E9=A1=B9=E9=9C=80=E6=8C=89?= =?UTF-8?q?=E7=89=A9=E6=96=99=E6=96=B0=E5=A2=9E=E9=80=BB=E8=BE=91=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E5=A4=84=E7=90=86=20=E6=AD=A6=E6=B1=89BOM=E4=BC=A0?= =?UTF-8?q?=E9=80=92=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.connor.chint.wuhan/bin/.gitignore | 1 - .../chint/plm/applyMatnr/ApplyMatnrOp.java | 85 +++++++++---------- .../com/chint/plm/applyMatnr/RemarkUtil.java | 13 +-- .../CreateBOMDifference_DYController.java | 26 +++--- .../chint/yunpi/command/BomSapWhBjOp.java | 21 +++-- 5 files changed, 72 insertions(+), 74 deletions(-) delete mode 100644 com.connor.chint.wuhan/bin/.gitignore diff --git a/com.connor.chint.wuhan/bin/.gitignore b/com.connor.chint.wuhan/bin/.gitignore deleted file mode 100644 index c2d9872..0000000 --- a/com.connor.chint.wuhan/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/com/ diff --git a/com.connor.chint.wuhan/src/com/chint/plm/applyMatnr/ApplyMatnrOp.java b/com.connor.chint.wuhan/src/com/chint/plm/applyMatnr/ApplyMatnrOp.java index 5ed9a16..90688f9 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/applyMatnr/ApplyMatnrOp.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/applyMatnr/ApplyMatnrOp.java @@ -2,7 +2,6 @@ package com.chint.plm.applyMatnr; import java.awt.Dimension; import java.io.IOException; -import java.rmi.RemoteException; import java.sql.Connection; import java.sql.ResultSet; import java.text.SimpleDateFormat; @@ -13,8 +12,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Vector; -import java.util.Map.Entry; - import com.connor.chint.sap2.materialno.bean.PMPC; import com.connor.chint.sap2.materialno.bean.PRD; //import com.connor.chint.sap2.operation.SelfMPartBean; @@ -32,7 +29,6 @@ import com.connor.chint.sap2.util.SqlUtil; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFOperation; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; -import com.teamcenter.rac.kernel.ListOfValuesInfo; import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMWindow; @@ -43,8 +39,6 @@ import com.teamcenter.rac.kernel.TCComponentGroup; import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemType; -import com.teamcenter.rac.kernel.TCComponentListOfValues; -import com.teamcenter.rac.kernel.TCComponentUnitOfMeasureType; import com.teamcenter.rac.kernel.TCComponentUser; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCProperty; @@ -86,7 +80,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { public List prds3 = new ArrayList(); private static String S_CODE = "220103001"; - private List applyRevs = new ArrayList(); +// private List applyRevs = new ArrayList(); // private List generalRevs = new ArrayList(); // private List s_Revs = new ArrayList(); @@ -101,7 +95,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { private Map> general_maps = new HashMap>(); private Map> apply_maps = new HashMap>(); private List mess = new ArrayList(); - private Map rev_objs = new HashMap(); +// private Map rev_objs = new HashMap(); // private String INSERT_SQL = "insert into infodba.CHINT_MATERIAL // values(?,?,?,?,?,?,?,?,?,?,?,?,to_date(?,'yyyyMMdd HH24:mi:ss'),?,?)"; public static String INSERT_SQL = "insert into chint_material(\"Code\",\"PUID\",\"PmpcCode\",\"GoodsCode\",\"GoodsName\",\"UnitCode\",\"CompanyCode\",\"BpNo\",\"Spec\",\"TeRe\",\"State\",\"User\",\"Time\",\"Condition\",\"Info\")" @@ -119,7 +113,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { protected String sql_query = "select FeatureList from CcemVW_GoodsFeature where GoodsCode =? "; Map idBeanMap = new HashMap(); - private String actionInfo; +// private String actionInfo; private TCComponentItemType itemType; public ApplyMatnrOp(AbstractAIFApplication app, String actionInfo) { this.app = app; @@ -130,11 +124,11 @@ public class ApplyMatnrOp extends AbstractAIFOperation { try { itemType = (TCComponentItemType) this.session.getTypeComponent("Part"); groupID = SAPUtil.getGroupID(session); - } catch (TCException e) { - // TODO Auto-generated catch block + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); } - this.actionInfo = actionInfo; +// this.actionInfo = actionInfo; } @Override @@ -142,7 +136,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { // List nameList = new ArrayList(); InterfaceAIFComponent[] comps = app.getTargetComponents(); TCComponent target = null; - List lines = new ArrayList(); +// List lines = new ArrayList(); if (comps == null || comps.length == 0) { MessageBox.post("请选中版本对象", "", MessageBox.WARNING); @@ -154,6 +148,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { MessageBox.post("请选中版本对象", "", MessageBox.WARNING); return; } + System.out.println("target:" + target); List nameList = new ArrayList(); List nameList2 = new ArrayList(); dcproxy = KUtil.getUser("dcproxy", session); @@ -292,7 +287,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { pmpc2 = new PMPC(S_CODE, pmpcPrhCode, pmpcPType, pmpcMType); Object obj3[] = new Object[] { pmpcPrhCode }; ResultSet rs3 = SqlUtil.read(Sql2, obj3); - long time17 = System.nanoTime(); +// long time17 = System.nanoTime(); while (rs3.next()) { String prdFeatureCode = rs3.getString(4); String featureName = rs3.getString(5); @@ -341,6 +336,11 @@ public class ApplyMatnrOp extends AbstractAIFOperation { TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindow win = bomWinType.create(null); TCComponentItemRevision rev = (TCComponentItemRevision) target; + xqxs = RemarkUtil.getXqxs(rev.getProperty("item_id"), session); + if(xqxs == 0) { + MessageBox.post("总装图纸没有填写线圈相数,请检查.", "提示", MessageBox.INFORMATION); + return; + } win.setWindowTopLine(rev.getItem(), rev, null, null); TCComponentBOMLine bomline = win.getTopBOMLine(); StringBuilder error = new StringBuilder(); @@ -351,14 +351,9 @@ public class ApplyMatnrOp extends AbstractAIFOperation { Map listBOM = BomToSapUtil.getBomLineTreeNodeSOA(bomline); gbBuff.setLength(0); xqErrBuff.setLength(0); - xqxs = RemarkUtil.getXqxs(rev.getProperty("item_id"),session); - if(xqxs ==0 ) { - MessageBox.post("总装图纸没有填写线圈相数,请检查.", "提示", MessageBox.INFORMATION); - return; - } - readBom(listBOM,bomline,error); - if(gbBuff.length()>0) { - MessageBox.post("以下图纸没有物料请检查:\n"+gbBuff.toString(), "提示", MessageBox.INFORMATION); + readBom(listBOM, bomline, error); + if(gbBuff.length() > 0) { + MessageBox.post("以下图纸没有物料请检查:\n" + gbBuff.toString(), "提示", MessageBox.INFORMATION); return; } // for(TCComponentBOMLine line:listBOM) { @@ -434,13 +429,13 @@ public class ApplyMatnrOp extends AbstractAIFOperation { System.out.println("===============开始创建物料==============="); System.out.println("共需要创建"+self_lists.size()+"个物料!"); - long time45 = System.nanoTime(); +// long time45 = System.nanoTime(); List itemList = new ArrayList(); // tzList.clear(); //批量创建和批量搭关系 TCComponentFolder newStuFolder = user.getNewStuffFolder(); if(self_lists.size()>0) { - List cIList = new ArrayList(); + List cIList = new ArrayList<>(); for (int i = 0; i < self_lists.size(); i++) { int t = i+1; System.out.println("正在创建第"+t+"个物料!"); @@ -474,7 +469,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { StringBuffer req_mess = new StringBuffer(); System.out.println("===============开始发送请求==============="); System.out.println("一共需要发送的请求数量:"+drequests.size()); - long time37 = System.nanoTime(); +// long time37 = System.nanoTime(); for (int i = 0; i < drequests.size(); i++) { System.out.println("[" + i + "]请求内容:" + drequests.get(i)); String req = HttpUtil.sendJsonHttpPost(url, drequests.get(i)); @@ -499,7 +494,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { System.out.println("删除记录"); KUtil.setByPass(true); SelfMPartBean selfMPartBean = deleteMap.get(bean.getCode()); - TCComponentItemRevision pRev = selfMPartBean.getRev(); +// TCComponentItemRevision pRev = selfMPartBean.getRev(); TCComponentItemRevision cRev = selfMPartBean.getMatnrRev(); // pRev.remove("representation_for", cRev); TCComponentItem item = cRev.getItem(); @@ -592,7 +587,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } @@ -606,9 +601,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { 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) { + } catch (Exception e) { e.printStackTrace(); } // TXTUtil.writeTXT(logPath, "AM消息推送结束"); @@ -616,7 +609,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { // List tzList = new ArrayList(); public CreateIn createMaterialYH(SelfMPartBean bean, String companyCode, String zt2_Specifications, String code) throws TCException, ServiceException { - Object[] result = new Object[2]; +// Object[] result = new Object[2]; // TCComponentItem item = null; // 自动按照编码规则获取ID @@ -753,6 +746,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { } + @SuppressWarnings("deprecation") public TCComponentBOMLine getNewBOMLine(TCComponentItemRevision itemR) { TCComponentBOMWindowType bomWinType; try { @@ -844,8 +838,8 @@ public class ApplyMatnrOp extends AbstractAIFOperation { String zt2_ProductModel = properties[4];//rev.getProperty("zt2_ProductModel"); String teRe = ""; String state = ""; // 申请时为空 - String wbs = ""; - String product = ""; +// String wbs = ""; +// String product = ""; String user = userID; String time = now; String condition = "审核中";// 默认审核中 @@ -998,8 +992,8 @@ public class ApplyMatnrOp extends AbstractAIFOperation { String zt2_ProductModel = properties[4];//rev.getProperty("zt2_ProductModel"); String teRe = ""; String state = ""; // 申请时为空 - String wbs = ""; - String product = ""; +// String wbs = ""; +// String product = ""; String user = userID; String time = now; String condition = "审核中";// 默认审核中 @@ -1087,12 +1081,12 @@ public class ApplyMatnrOp extends AbstractAIFOperation { TCComponentItemRevision rev = line.getItemRevision(); System.out.println(rev); if (isNeedApply(rev)) { - boolean flag = true; +// boolean flag = true; String item_id = rev.getProperty("item_id"); if (item_id.length() >= 3) { String stuf = item_id.substring(0, 3); if (stuf.equalsIgnoreCase("2ZD") || stuf.equalsIgnoreCase("4ZD") || stuf.equalsIgnoreCase("1ZD")) { - flag = false; +// flag = false; // 开始根据通用件规格属性来判断是否需要申请物料 String zt2_TYJSpec = line.getProperty("ZT2_TYSpecifications"); if (zt2_TYJSpec == null || zt2_TYJSpec.length() == 0) { @@ -1312,6 +1306,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { // } // return flag; // } + /* private String getValue(TCProperty property) throws TCException { TCComponentListOfValues lov = property.getLOV(); if (lov != null) {// 判断是否lov @@ -1329,7 +1324,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { } return "外购"; - } + }*/ // public Object[] createMaterial(TCComponentItemRevision tzRev, String companyCode, // String zt2_Specifications, String code) throws TCException, ServiceException { @@ -1455,7 +1450,7 @@ public class ApplyMatnrOp extends AbstractAIFOperation { String item_id = "8zdk.177.999"; System.out.println(item_id.substring(0, 8)); } - + /* private List listBOM(TCComponentBOMLine bomlineObj) { com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session); com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo(); @@ -1469,11 +1464,11 @@ public class ApplyMatnrOp extends AbstractAIFOperation { if (levelResp.output.length <= 0) { return null; } - /* - * levelResp中的Output有所有的BOMLine - * StructureManagement.ExpandPSData[] children List of ExpandPSData children found for this parent. - StructureManagement.ExpandPSParentData parent ExpandPSParentData member - */ + +// levelResp中的Output有所有的BOMLine +// StructureManagement.ExpandPSData[] children List of ExpandPSData children found for this parent. +// StructureManagement.ExpandPSParentData parent ExpandPSParentData member + List bomlineList = new ArrayList(levelResp.output.length); List itemRevList = new ArrayList(levelResp.output.length); @@ -1493,5 +1488,5 @@ public class ApplyMatnrOp extends AbstractAIFOperation { } } return bomlineList; - } + }*/ } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/applyMatnr/RemarkUtil.java b/com.connor.chint.wuhan/src/com/chint/plm/applyMatnr/RemarkUtil.java index da3dd47..a0482dc 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/applyMatnr/RemarkUtil.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/applyMatnr/RemarkUtil.java @@ -3,9 +3,7 @@ import java.util.Map; import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentItem; -import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemType; -import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCSession; public class RemarkUtil { @@ -16,21 +14,24 @@ public class RemarkUtil { try { String[] split = itemId.split("-"); String topId = "1ZDB300000P-"+split[1]; + System.out.println("topId:" + topId); TCComponentItemType partType = (TCComponentItemType) session.getTypeComponent("ZT2_Design3D"); - TCComponentItem find = partType.find(topId); + TCComponentItem find = partType.findItems(topId)[0]; Map classificationAttributes = find.getClassificationAttributes(); // System.out.println(classificationAttributes.toString()); - for(String key:classificationAttributes.keySet()) { + for(String key : classificationAttributes.keySet()) { + System.out.println("key:" + key); if(key.equals("相数")) { String cphx = classificationAttributes.get(key); len = Integer.valueOf(cphx); + System.out.println("len:" + len); break; } } } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } return len; @@ -65,7 +66,7 @@ public class RemarkUtil { } // TCComponentItemRevision itemRevision = bomline.getItemRevision(); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/CreateBOMDifference_DYController.java b/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/CreateBOMDifference_DYController.java index 1b1e014..e891fb3 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/CreateBOMDifference_DYController.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/CreateBOMDifference_DYController.java @@ -279,20 +279,24 @@ public class CreateBOMDifference_DYController { bean = entry.getValue(); oldRev = bean.getOldRev(); newRev = bean.getNewRev(); - if (oldRev != null && newRev != null && oldRev != newRev) { - win.setWindowTopLine(item, bean.getOldRev(), null, null); - win2.setWindowTopLine(item, bean.getNewRev(), null, null); - win.refresh(); - win2.refresh(); - bean.setNewBOMLine(win2.getTopBOMLine()); - bean.setOldBOMLine(win.getTopBOMLine()); + if (oldRev != newRev) {//lidy 20240411 oldRev != null && newRev != null && zt2_MaterialNo = ""; object_desc = ""; parentRev = null; - parentRev = SAPUtil.getSAPPart(bean.getNewBOMLine(), session); - if (parentRev != null) { - zt2_MaterialNo = parentRev.getProperty("zt2_MaterialNo"); - object_desc = parentRev.getProperty("object_desc"); + if(oldRev != null) { + win.setWindowTopLine(item, oldRev, null, null); + win.refresh(); + bean.setOldBOMLine(win.getTopBOMLine()); + } + if(newRev != null) { + win2.setWindowTopLine(item, newRev, null, null); + win2.refresh(); + bean.setNewBOMLine(win2.getTopBOMLine()); + parentRev = SAPUtil.getSAPPart(bean.getNewBOMLine(), session); + if (parentRev != null) { + zt2_MaterialNo = parentRev.getProperty("zt2_MaterialNo"); + object_desc = parentRev.getProperty("object_desc"); + } } bean.setZt2_MaterialNo_Parent(zt2_MaterialNo); bean.setObject_desc_Parent(object_desc); diff --git a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSapWhBjOp.java b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSapWhBjOp.java index f258bf8..abbf814 100644 --- a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSapWhBjOp.java +++ b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSapWhBjOp.java @@ -152,17 +152,6 @@ public class BomSapWhBjOp extends AbstractAIFOperation { // Auto-generated method stub MyProgressBarCompent comp = null; try { - - String strs[] = session.getPreferenceService().getStringValues("database_tc"); - if (SqlUtil.getTCDataConnection(strs) == null) { - MessageBox.post("数据库连接失败,请检查首选项", "", 2); - return; - } - String code = BomUtilWh.getCode().toString(); - - - String batchNum = code + "-00001"; - groupName = SAPUtil.getGroupID(session); if (KUtil.isEmpty(groupName) || groupName.equalsIgnoreCase("dba")) { MessageBox.post("当前登录组[" + groupName + "]不可使用该功能", "", MessageBox.INFORMATION); @@ -203,6 +192,16 @@ public class BomSapWhBjOp extends AbstractAIFOperation { } } + String strs[] = session.getPreferenceService().getStringValues("database_tc"); + if (SqlUtil.getTCDataConnection(strs) == null) { + MessageBox.post("数据库连接失败,请检查首选项", "", 2); + return; + } + String code = BomUtilWh.getCode().toString(); + + + String batchNum = code + "-00001"; + comp = new MyProgressBarCompent("", "正在进行部件BOM传递SAP...."); TCComponentItemRevision pRevision = getPRevision(degignRev); // 获取PBOM List cppRevision = getCPPPRevision(degignRev);