diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createbomdifference/ExtractDiffComd.class b/com.connor.chint.wuhan/bin/com/chint/plm/createbomdifference/ExtractDiffComd.class index 164646b..38a94da 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createbomdifference/ExtractDiffComd.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createbomdifference/ExtractDiffComd.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/AssignProcess$1.class b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/AssignProcess$1.class index 2b0ffab..a289046 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/AssignProcess$1.class and b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/AssignProcess$1.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/AssignProcess.class b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/AssignProcess.class index d90bd4b..b767dad 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/AssignProcess.class and b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/AssignProcess.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand$1$1.class b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand$1$1.class index 7f9c26f..0f87124 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand$1$1.class and b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand$1$1.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand$1.class b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand$1.class index 9c089a1..2bcbcea 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand$1.class and b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand$1.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand.class b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand.class index 38dd3a0..adf5c9e 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand.class and b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/DbomToECommand.class differ diff --git a/com.connor.chint.wuhan/plugin.xml b/com.connor.chint.wuhan/plugin.xml index 21f830c..ca51461 100644 --- a/com.connor.chint.wuhan/plugin.xml +++ b/com.connor.chint.wuhan/plugin.xml @@ -70,7 +70,7 @@ - @@ -111,7 +111,7 @@ - --> + diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/ExtractDiffComd.java b/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/ExtractDiffComd.java index 96aa7ff..e2f178c 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/ExtractDiffComd.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createbomdifference/ExtractDiffComd.java @@ -8,7 +8,6 @@ package com.chint.plm.createbomdifference; import java.util.HashMap; -import java.util.List; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; @@ -17,7 +16,6 @@ import com.chint.plm.createEcn.Util; import com.connor.chint.sap2.util.BomToSapUtil; import com.connor.chint.yunpi.KCommand; import com.teamcenter.rac.aif.AbstractAIFApplication; -import com.teamcenter.rac.aif.kernel.AbstractAIFSession; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentBOMLine; @@ -26,7 +24,6 @@ import com.teamcenter.rac.kernel.TCComponentBOMWindowType; import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentRevisionRule; -import com.teamcenter.rac.kernel.TCComponentRevisionRuleType; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.util.MessageBox; @@ -75,8 +72,8 @@ public class ExtractDiffComd extends KCommand { } readChangeDesign(oldComponents, newComponents, tar); MessageBox.post(resource.getString("SUCC_CHANGE"), "", 2); - } catch (TCException e) { - // TODO Auto-generated catch block + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); } } @@ -92,7 +89,7 @@ public class ExtractDiffComd extends KCommand { */ private void readChangeDesign(TCComponent[] oldComponents, TCComponent[] newComponents, TCComponent tar) throws TCException { - // TODO Auto-generated method stub + // Auto-generated method stub Map itemChangeMap = new HashMap<>(); for (TCComponent oldComponent : oldComponents) { if (oldComponent.getType().equals(ZT_DESIGN3D)) { @@ -161,22 +158,42 @@ public class ExtractDiffComd extends KCommand { continue; PBomBean pBomBeanOld = materialOld.get(materialNo); PBomBean pBomBeanNew = materialNew.get(materialNo); - // 有P物料获取P没有遍历EBOM + // 有P物料获取P没有遍历EBOM + /* TCComponent oldMaterial = pBomBeanOld.getpMaterial() == null ? pBomBeanOld.geteMaterial() : pBomBeanOld.getpMaterial(); TCComponent newMaterial = pBomBeanNew.getpMaterial() == null ? pBomBeanNew.geteMaterial() : pBomBeanNew.getpMaterial(); - // 全展开之后比较单层物料编码的数量 - // 旧的bom修改版本规则 - TCComponentBOMLine oldBomLine = sendToStructureManager((TCComponentItemRevision) oldMaterial, - Util.REVISION_RULE_ANY); - TCComponentBOMLine newBomLine = sendToStructureManager((TCComponentItemRevision) newMaterial, null); - // BOM全展开 - Map oldBomMap = BomToSapUtil.getBomLineTreeNodeSOA(oldBomLine); - Map newBomMap = BomToSapUtil.getBomLineTreeNodeSOA(newBomLine); - addChangeBom(oldBomMap, oldBomLine, newBomMap, newBomLine, tar); - System.out.println("oldBomMap===>" + oldBomMap.toString()); - System.out.println("newBomMap===>" + newBomMap.toString()); + */ + //TODO 20240201修改为遍历PBOM和EBOM + TCComponent oldMaterial = pBomBeanOld.getpMaterial(); + if(oldMaterial != null) { + TCComponent newMaterial = pBomBeanNew.getpMaterial(); + // 全展开之后比较单层物料编码的数量 + // 旧的bom修改版本规则 + TCComponentBOMLine oldBomLine = sendToStructureManager((TCComponentItemRevision) oldMaterial, Util.REVISION_RULE_ANY); + TCComponentBOMLine newBomLine = sendToStructureManager((TCComponentItemRevision) newMaterial, null); + // BOM全展开 + Map oldBomMap = BomToSapUtil.getBomLineTreeNodeSOA(oldBomLine); + Map newBomMap = BomToSapUtil.getBomLineTreeNodeSOA(newBomLine); + addChangeBom(oldBomMap, oldBomLine, newBomMap, newBomLine, tar); + System.out.println("oldBomMap===>" + oldBomMap.toString()); + System.out.println("newBomMap===>" + newBomMap.toString()); + } + oldMaterial = pBomBeanOld.geteMaterial(); + if(oldMaterial != null) { + TCComponent newMaterial = pBomBeanNew.geteMaterial(); + // 全展开之后比较单层物料编码的数量 + // 旧的bom修改版本规则 + TCComponentBOMLine oldBomLine = sendToStructureManager((TCComponentItemRevision) oldMaterial, Util.REVISION_RULE_ANY); + TCComponentBOMLine newBomLine = sendToStructureManager((TCComponentItemRevision) newMaterial, null); + // BOM全展开 + Map oldBomMap = BomToSapUtil.getBomLineTreeNodeSOA(oldBomLine); + Map newBomMap = BomToSapUtil.getBomLineTreeNodeSOA(newBomLine); + addChangeBom(oldBomMap, oldBomLine, newBomMap, newBomLine, tar); + System.out.println("oldBomMap===>" + oldBomMap.toString()); + System.out.println("newBomMap===>" + newBomMap.toString()); + } } } System.out.println("itemChangeMap===>" + itemChangeMap.toString()); @@ -196,7 +213,7 @@ public class ExtractDiffComd extends KCommand { private void addChangeBom(Map oldBomMap, TCComponentBOMLine oldBomLine, Map newBomMap, TCComponentBOMLine newBomLine, TCComponent changeTag) throws TCException { - // TODO Auto-generated method stub + // Auto-generated method stub String oldUid = oldBomLine.getUid(); ExpandPSData[] expandPSDatasOld = oldBomMap.get(oldUid); ExpandPSData[] expandPSDatasNew = newBomMap.get(newBomLine.getUid()); @@ -292,7 +309,7 @@ public class ExtractDiffComd extends KCommand { } return bomWindow.setWindowTopLine(null, tcComponentItemRev, null, null); - } catch (TCException e) { + } catch (Exception e) { e.printStackTrace(); return null; } @@ -306,13 +323,12 @@ public class ExtractDiffComd extends KCommand { * @function */ private Map getMaterialByDesign(TCComponentItemRevision designRev) throws TCException { - // TODO Auto-generated method stub + // Auto-generated method stub Map pbomMap = new HashMap<>(); // 图纸下物料 TCComponent[] represents = designRev.getReferenceListProperty(REPRESENTATION_FOR); for (TCComponent represent : represents) { - String[] matnrProps = represent - .getProperties(new String[] { Util.ZT_MATERIAL_NO, Util.ZT_PROP_PBOM, Util.ITEM_REVIISON_ID }); + String[] matnrProps = represent.getProperties(new String[] { Util.ZT_MATERIAL_NO, Util.ZT_PROP_PBOM, Util.ITEM_REVIISON_ID }); String materialNo = matnrProps[0];// material.getProperty(Util.ZT_MATERIAL_NO); if (pbomMap.containsKey(materialNo)) { PBomBean pBomBean = pbomMap.get(materialNo); @@ -322,8 +338,7 @@ public class ExtractDiffComd extends KCommand { if (matnrProps[1].equals(Util.ZT_VAL_PBOM) && matnrProps[2].compareTo(pBomBean.getpRevision()) > 0) { pBomBean.setpMaterial(represent); pBomBean.setpRevision(matnrProps[2]); - } else if (!matnrProps[1].equals(Util.ZT_VAL_PBOM) - && matnrProps[2].compareTo(pBomBean.geteRevision()) > 0) { + } else if (!matnrProps[1].equals(Util.ZT_VAL_PBOM) && matnrProps[2].compareTo(pBomBean.geteRevision()) > 0) { pBomBean.seteMaterial(represent); pBomBean.seteRevision(matnrProps[2]); } diff --git a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/AssignProcess.java b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/AssignProcess.java index ad36d1d..1e7b39e 100644 --- a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/AssignProcess.java +++ b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/AssignProcess.java @@ -1,6 +1,5 @@ package com.connor.chint.yunpi.command; -import java.sql.Connection; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; @@ -8,32 +7,30 @@ import java.util.Map; import javax.swing.JOptionPane; -//import com.connor.chint.sap2.KCommand; -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.SAPMessageUtilFram; import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.yunpi.KCommand; import com.teamcenter.rac.aif.AbstractAIFApplication; +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.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemRevision; -import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCUserService; import com.teamcenter.rac.util.MessageBox; +@SuppressWarnings("deprecation") public class AssignProcess extends KCommand { - private boolean top = true; +// private boolean top = true; private TCComponentItemRevision rev; - public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException { + public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws Exception { String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo"); if(rev2.getType().equals("Part Revision")) { @@ -66,7 +63,7 @@ public class AssignProcess extends KCommand { } private TCComponentItemRevision getTopZzItem(TCComponentItemRevision rev) { - // TODO Auto-generated method stub + // Auto-generated method stub // item = null; try { TCComponent[] whereUsed = rev.whereUsed((short)0); @@ -95,10 +92,9 @@ public class AssignProcess extends KCommand { return item; } } - } - } catch (TCException e) { - // TODO Auto-generated catch block + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); } return null; @@ -125,26 +121,58 @@ public class AssignProcess extends KCommand { new Thread() { @Override public void run() { - if(!rev.getType().equals("Part Revision")) { MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR); return; } - MyProgressBarCompent comp = null; - try { + TCPreferenceService service = session.getPreferenceService(); // TCComponentItemRevision pRevision = getPRevision(rev); TCComponentItemRevision topZzItem = getTopZzItem(rev); + String name = rev.getProperty("object_name"); String property = topZzItem.getProperty("zt2_ifpbom"); if(!property.equals("P") && topZzItem.getStringProperty("object_desc").contains("1ZDB300000P")) { MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR); return; } + boolean isback = false; + String[] rules = service.getStringValues("CHINT_PROCESS_RULE"); + for(String rule : rules) { + String[] split = rule.split(":"); + if(!split[0].equals(groupID)) + continue; + String[] backs = split[1].split(";"); + for(String back : backs) { + if(name.contains(back)) { + isback = true; + break; + } + } + if(isback) + break; + } TCComponentItemRevision desginRev = (TCComponentItemRevision) topZzItem.getRelatedComponent("TC_Is_Represented_By"); - System.out.println("topZzItem==>"+topZzItem.toString()); - if(desginRev==null) { - MessageBox.post("存在顶层P物料没有关联图纸,请检查.","提示",2); + System.out.println("topZzItem=="+topZzItem.toString()+">>"+isback); + if(isback) { + AIFComponentContext[] folders = topZzItem.getItem() + .whereReferencedByTypeRelation(new String[] { "ZT2_ProjectFolder" }, null);//new String[] { "contents" } + if(folders.length == 0) { + MessageBox.post("未找到产成品文件夹,请检查.", "提示", MessageBox.WARNING); + return; + } + AIFComponentContext[] ccps = folders[0].getComponent().getChildren(); + System.out.println(folders[0].getComponent() + "==>" + ccps.length); + for(AIFComponentContext aifcc : ccps) { + TCComponentItem item = (TCComponentItem) aifcc.getComponent(); + desginRev = (TCComponentItemRevision) item.getLatestItemRevision().getRelatedComponent("TC_Is_Represented_By"); + System.out.println(item + "==>" + desginRev); + if(desginRev != null) + break; + } + } + if(desginRev == null) { + MessageBox.post("存在顶层P物料没有关联图纸,请检查.", "提示", MessageBox.WARNING); return; } Map classificationAttributes = desginRev.getItem().getClassificationAttributes(); @@ -154,7 +182,7 @@ public class AssignProcess extends KCommand { if(key.equals("产品型号")) { String cphx = classificationAttributes.get(key); String sql = "SELECT \"ProductZu\" FROM \"CHINT_WORKHOUR_WhProductXH\" where \"ProductXH\" = '"+cphx+"'"; - String[] prefs = session.getPreferenceService().getStringValues("database_tc"); + String[] prefs = service.getStringValues("database_tc"); SqlUtil.getTCDataConnection(prefs); ResultSet read2 = SqlUtil.read(sql); if(!read2.next()) { @@ -210,7 +238,7 @@ public class AssignProcess extends KCommand { MessageBox.post("一键指派工艺路线完成。","提示",MessageBox.INFORMATION); } } catch (Exception e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); }finally { SqlUtil.freeAll(); diff --git a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/DbomToECommand.java b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/DbomToECommand.java index 6bf90ed..837826c 100644 --- a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/DbomToECommand.java +++ b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/DbomToECommand.java @@ -1,38 +1,28 @@ package com.connor.chint.yunpi.command; -import java.util.Map; - import javax.swing.JOptionPane; -import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; - -import com.connor.chint.sap2.util.BomToSapUtil; 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.SAPMessageUtilFram; import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.yunpi.KCommand; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.kernel.TCComponentBOMLine; -import com.teamcenter.rac.kernel.TCComponentBOMWindow; -import com.teamcenter.rac.kernel.TCComponentBOMWindowType; 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; -import com.teamcenter.rac.kernel.TCTypeService; import com.teamcenter.rac.kernel.TCUserService; import com.teamcenter.rac.util.MessageBox; -import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData; +@SuppressWarnings("deprecation") public class DbomToECommand extends KCommand { - private boolean top = true; +// private boolean top = true; private TCComponentItemRevision rev; public DbomToECommand(AbstractAIFApplication app, String commandId, String actionInfo) { super(app, commandId, actionInfo); @@ -47,8 +37,7 @@ public class DbomToECommand extends KCommand { if(targetComponent instanceof TCComponentBOMLine) { rev = ((TCComponentBOMLine)targetComponent).getItemRevision(); }else if(targetComponent instanceof TCComponentItemRevision) { - TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; - this.rev = rev; + rev = (TCComponentItemRevision) targetComponent; }else { MessageBox.post("请选择BOM行或者版本对象", "", MessageBox.ERROR); return; @@ -112,11 +101,13 @@ public class DbomToECommand extends KCommand { System.out.println("111"); new SAPMessageUtilFram("", "DBOM转EBOM存在异常物料,请检查:\n" + call.toString()).show(); }else { - MessageBox.post("DBOM转换EBOM完成","提示",2); + rev.refresh(); + MessageBox.post("DBOM转换EBOM完成", "提示", MessageBox.INFORMATION); } - } catch (TCException e1) { - // TODO Auto-generated catch block + } catch (Exception e1) { + // Auto-generated catch block e1.printStackTrace(); + MessageBox.post("错误:" + e1.toString(), "ERROR", MessageBox.ERROR); } if(comp!=null) { comp.setVisible(false); @@ -124,14 +115,16 @@ public class DbomToECommand extends KCommand { } }.start(); - } catch (TCException e1) { - // TODO Auto-generated catch block + } catch (Exception e1) { + // Auto-generated catch block e1.printStackTrace(); + MessageBox.post("错误:" + e1.toString(), "ERROR", MessageBox.ERROR); } } }.start(); }catch(Exception e) { e.printStackTrace(); + MessageBox.post("错误:" + e.toString(), "ERROR", MessageBox.ERROR); } } }