diff --git a/com.connor.chint.sap2/src/com/chint/plm/common/service/WorkhourService.java b/com.connor.chint.sap2/src/com/chint/plm/common/service/WorkhourService.java index 7bb4971..39aba7e 100644 --- a/com.connor.chint.sap2/src/com/chint/plm/common/service/WorkhourService.java +++ b/com.connor.chint.sap2/src/com/chint/plm/common/service/WorkhourService.java @@ -18,24 +18,41 @@ public class WorkhourService { * @return */ public static EasyResponse> getProducttype(String companycode) { - String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourType/getProducttype"; + String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getProducttype"; Map paramMap = new LinkedHashMap(); paramMap.put("companycode", companycode); String result = HttpUtils.get(url, paramMap); return JSONObject.parseObject(result, new TypeReference>>(EasyResponse.class){}); } + /** + * 获取电压等级 + * @param companycode + * @param producttype + * @return + */ + public static EasyResponse> getVoltagelevel(String companycode, String producttype) { + String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getVoltagelevel"; + Map paramMap = new LinkedHashMap(); + paramMap.put("companycode", companycode); + paramMap.put("producttype", producttype); + String result = HttpUtils.get(url, paramMap); + return JSONObject.parseObject(result, new TypeReference>>(EasyResponse.class){}); + } + /** * 获取产品型号 * @param companycode * @param producttype + * @param voltagelevel * @return */ - public static EasyResponse> getProductxh(String companycode, String producttype) { - String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourXh/getProductxh"; + public static EasyResponse> getProductxh(String companycode, String producttype, String voltagelevel) { + String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getProductxh"; Map paramMap = new LinkedHashMap(); paramMap.put("companycode", companycode); paramMap.put("producttype", producttype); + paramMap.put("voltagelevel", voltagelevel); String result = HttpUtils.get(url, paramMap); return JSONObject.parseObject(result, new TypeReference>>(EasyResponse.class){}); } @@ -46,7 +63,7 @@ public class WorkhourService { * @return */ public static EasyResponse> getJsask(String companycode) { - String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourAsk/getJsask"; + String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getJsask"; Map paramMap = new LinkedHashMap(); paramMap.put("companycode", companycode); String result = HttpUtils.get(url, paramMap); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/dy/createBOMDifference/BOMDifferenceBean.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/dy/createBOMDifference/BOMDifferenceBean.java index b3c8c2f..48c115b 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/dy/createBOMDifference/BOMDifferenceBean.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/dy/createBOMDifference/BOMDifferenceBean.java @@ -11,37 +11,37 @@ public class BOMDifferenceBean { /** * 旧版本 */ - public TCComponentItemRevision oldRev; + private TCComponentItemRevision oldRev; /** * 新版本 */ - public TCComponentItemRevision newRev; + private TCComponentItemRevision newRev; /** * 旧物料 */ - public TCComponentItemRevision oldPartRev; + private TCComponentItemRevision oldPartRev; /** * 新物料 */ - public TCComponentItemRevision newPartRev; + private TCComponentItemRevision newPartRev; /** * 父项物料 */ - public TCComponentItemRevision parentPartRev; + private TCComponentItemRevision parentPartRev; /** * 父项物料号 */ - public String zt2_MaterialNo_Parent; + private String zt2_MaterialNo_Parent; /** * 父项物料描述 */ - public String object_desc_Parent; + private String object_desc_Parent; /** * 父项物料名称 */ - public String object_name_Parent; + private String object_name_Parent; public String getObject_name_Parent() { return object_name_Parent; @@ -58,17 +58,21 @@ public class BOMDifferenceBean { /** * 新的BOMLine */ - TCComponentBOMLine oldBOMLine; + private TCComponentBOMLine oldBOMLine; /** * 旧的BOMLine */ - TCComponentBOMLine newBOMLine; + private TCComponentBOMLine newBOMLine; /** * 版本类型 */ private String rev_object_type; private TCComponentItemRevision rev; + /** + * 是否框架层 + */ + private boolean isKj; public TCComponentItem getItem() { return item; @@ -276,6 +280,14 @@ public class BOMDifferenceBean { this.rev = rev; } + public boolean isKj() { + return isKj; + } + + public void setKj(boolean isKj) { + this.isKj = isKj; + } + public String getId() { return (zt2_MaterialNo_Parent == null ? "" : zt2_MaterialNo_Parent) + "@" + (item == null ? "" : item); } diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/dy/createBOMDifference/CreateBOMDifferenceDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/dy/createBOMDifference/CreateBOMDifferenceDialog.java index 4a997ca..8728d0a 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/dy/createBOMDifference/CreateBOMDifferenceDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/dy/createBOMDifference/CreateBOMDifferenceDialog.java @@ -323,8 +323,8 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog { if (pb != null) { pb.disposeDialog(); } - MessageBox.post("界面初始化失败:" + e.getMessage(), "", 2); e.printStackTrace(); + MessageBox.post("界面初始化失败:" + e.getMessage(), "", 2); disposeDialog(); } finally { KUtil.setByPass(false); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/lijc/GetDesignDsCommand.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/lijc/GetDesignDsCommand.java index 2e1c6cd..dfe4368 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/lijc/GetDesignDsCommand.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/lijc/GetDesignDsCommand.java @@ -1,9 +1,7 @@ package com.connor.chint.sap2.lijc; import java.sql.ResultSet; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -14,28 +12,15 @@ import com.connor.chint.sap2.dy.createElectricalBOM.WebApiUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.SqlUtil; -import com.connor.chint.sap2.util.ZYFactoryUtil; 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.TCComponentBOMWindow; -import com.teamcenter.rac.kernel.TCComponentBOMWindowType; import com.teamcenter.rac.kernel.TCComponentFolder; -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.TCComponentSchedule; import com.teamcenter.rac.kernel.TCPreferenceService; import com.teamcenter.rac.kernel.TCSession; -import com.teamcenter.rac.kernel.TCTypeService; import com.teamcenter.rac.util.MessageBox; -import com.teamcenter.services.rac.bom._2008_06.StructureManagement.RemoveChildrenFromParentLineResponse; -import com.teamcenter.services.rac.core.DataManagementService; -import com.teamcenter.services.rac.core._2006_03.DataManagement.ReviseResponse; -import com.teamcenter.soa.client.model.ErrorStack; public class GetDesignDsCommand extends KCommand{ @@ -168,7 +153,7 @@ public class GetDesignDsCommand extends KCommand{ if (SqlUtil.getTCDataConnection(database_tc) == null) { throw new Exception("TC数据库连接失败"); } - Map esbMap=new HashMap(); + Map esbMap=new HashMap<>(); try { System.out.println("selectSql==>"+selectSql); ResultSet rs = SqlUtil.read(selectSql); @@ -199,10 +184,15 @@ public class GetDesignDsCommand extends KCommand{ if (pathList.size()>0) { TCComponent[] relatedComponents = xmzx_folder.getRelatedComponents("contents"); TCComponentFolder tptz = null; + String folderName = "铜排图纸"; + if(actionInfo.equals("BOM")) { + //TODO lidy20240725 + folderName = "铜排设计"; + } for(TCComponent relatedComponent:relatedComponents) { String cName = relatedComponent.getProperty("object_name"); System.out.println(">> 找到子对象:" + cName); - if ((relatedComponent instanceof TCComponentFolder) && "铜排图纸".contains(cName)) { + if ((relatedComponent instanceof TCComponentFolder) && folderName.contains(cName)) { tptz = (TCComponentFolder) relatedComponent; } } diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/lijc/SendProjectLcCommand.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/lijc/SendProjectLcCommand.java index d629908..70cbb26 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/lijc/SendProjectLcCommand.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/lijc/SendProjectLcCommand.java @@ -10,10 +10,11 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import com.alibaba.fastjson2.JSON; import com.connor.chint.sap2.KCommand; -import com.connor.chint.sap2.bean.ApplyCodeFactoryBean; import com.connor.chint.sap2.sap_zy.CodeBean; import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.KUtil; @@ -31,7 +32,6 @@ import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCComponentSchedule; -import com.teamcenter.rac.kernel.TCComponentUser; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.util.MessageBox; @@ -133,7 +133,7 @@ public class SendProjectLcCommand extends KCommand { } TCComponent[] allTasks = schedule.getAllTasks(); - if(allTasks== null ||allTasks.length<2) { + if(allTasks == null || allTasks.length < 2) { MessageBox.post(schedule+"时间表下未找到任务,请检查数据","",MessageBox.INFORMATION); return; } @@ -144,7 +144,7 @@ public class SendProjectLcCommand extends KCommand { tpsjTask = allTask; } } - if(tpsjTask==null) { + if(tpsjTask == null) { MessageBox.post("时间表中没有找到名称为铜排设计的任务","提示",2); return; } @@ -153,18 +153,76 @@ public class SendProjectLcCommand extends KCommand { String userId = user == null ? "" : user.getProperty("user_id"); String userName = user == null ? "" : user.getProperty("user_name"); - Map lcApplyMap = new HashMap<>(); + Map lcApplyMap = new HashMap<>(); //获取编码申请的规则 String[] preferences = ChintPreferenceUtil.getPreferences("Chint_lcApplyCode", session); - for(String preference:preferences) { + for(String preference : preferences) { String[] split = preference.split(":"); String[] split2 = split[1].split(";"); - for(String fac:split2) { + for(String fac : split2) { lcApplyMap.put(fac, split[0]); } } + //出厂编号的前缀进行匹配,得到方案号 + Map fahMap = new HashMap<>(); + String prefs = ChintPreferenceUtil.getPreference("CHINT_FactoryNoTPBOM", session); + for(String pref : prefs.split(";")) { + String split = pref.substring(0, pref.indexOf(":")); + String fah = pref.substring(pref.indexOf("|") + 1); + String[] split2 = split.split("、"); + for(String fac : split2) { + fahMap.put(fac, fah); + } + } + StringBuilder err = new StringBuilder(""); + AIFComponentContext[] children = ccbh_folder.getChildren(); + for(AIFComponentContext c : children) {//TODO ccbh + TCComponent ccbh = (TCComponent) c.getComponent(); + System.out.println("ccbh:" + ccbh); + //出厂编号的前缀(前缀取ID号第一个数字前的值)与首选项CHINT_FactoryNoTPBOM里的值进行匹配,得到方案号 + String id = ccbh.getProperty("item_id"); + Pattern pattern = Pattern.compile("[0-9]"); + Matcher matcher = pattern.matcher(id); + int index = 0; + while (matcher.find()) { + index = matcher.start(); + break; + } + String key = id.substring(0, index); + if(!fahMap.containsKey(key)) { + err.append(id).append("在首选项中未找到匹配的前缀\n"); + continue; + } + //根据获取到的方案号去项目对象下“项目执行”下“铜排设计”文件夹获取所有的方案编码 + //检查方案编码版本属性“zt2_MaterialNo”属性(值截取“-”前面的值)进行匹配,匹配的上代表方案编码已创建 + key = fahMap.get(key) + "-"; + boolean check = true; + for(AIFComponentContext t : tpsj.getChildren()) { + TCComponentItemRevision fabm = ((TCComponentItem) t.getComponent()).getLatestItemRevision(); + System.out.println("fabm:" + fabm); + String zt2_MaterialNo = fabm.getProperty("zt2_MaterialNo"); + if(zt2_MaterialNo.startsWith(key)) { + check = false; + //检查方案编码对象版本下的关系文件夹中是否有“出厂编号”对象 + if(KUtil.getPseudoFolder(fabm, "ZT2_FactoryNumber").getChildren().length == 0) { + System.out.println("未关联出厂编号"); + if(!err.toString().contains(zt2_MaterialNo)) + err.append("当前项目中铜排方案编码").append(zt2_MaterialNo).append("未关联出厂编号\n"); + } + break; + } + } + if(check) { + err.append("当前项目").append(id).append("未创建铜排方案编码\n"); + continue; + } + } + if(err.length() > 0) { + MessageBox.post(err.toString(), "提示", MessageBox.ERROR); + return; + } - Map esbMap=new HashMap(); + Map esbMap = new HashMap<>(); String task_id = tpsjTask.getProperty("item_id"); esbMap.put("taskid",task_id); sql1[0] = task_id; @@ -207,18 +265,17 @@ public class SendProjectLcCommand extends KCommand { }else { esbMap.put("startdate",""); } - List strsList = new ArrayList<>(); - List factoryNos = new ArrayList(); +// List strsList = new ArrayList<>(); + List> factoryNos = new ArrayList<>(); List factorys_list = new ArrayList<>(); List cpbm_list = new ArrayList<>(); - AIFComponentContext[] children = ccbh_folder.getChildren(); int lsh = 0; int cno = 1; apply_lists.clear(); // Map codeNum = new HashMap<>(); for(AIFComponentContext child : children) { - Map facCpMap = new HashMap<>(); + Map facCpMap = new HashMap<>(); TCComponent ccbhTarget = (TCComponent) child.getComponent(); //查询出厂编号的引用,判断是否有铜排单元 AIFComponentContext[] contexts22 = ccbhTarget.whereReferencedByTypeRelation( @@ -227,7 +284,7 @@ public class SendProjectLcCommand extends KCommand { Boolean hasFabm = false; List components = new ArrayList<>(); String id = ""; - for(int t=0;t"+lcApplyMap.toString()+"ccbhId==>"+ccbhId); + System.out.println("lcApplyMap===>" + lcApplyMap.toString() + "ccbhId==>" + ccbhId); //编码申请铜排单元 for(String fac : lcApplyMap.keySet()) { if(ccbhId.contains(fac)) { flag = true; - if(apply_lists.size()==0) { - checkTargets(lcApplyMap.get(fac),zt2_WBSNo,session); + if(apply_lists.size() == 0) { + checkTargets(lcApplyMap.get(fac), zt2_WBSNo, session); } - if(apply_lists.size()>0) { - id = applyPart(apply_lists.get(lsh),session,zt2_WBSNo,tpsj,ccbhTarget); + if(apply_lists.size( )> 0) { + id = applyPart(apply_lists.get(lsh), session, zt2_WBSNo, tpsj, ccbhTarget); } - lsh = lsh+1; + lsh = lsh + 1; } } if(!flag) { - MessageBox.post("出厂编号"+ccbhId+"在首选项Chint_lcApplyCode中未配置,请检查","提示",2); + MessageBox.post("出厂编号" + ccbhId + "在首选项Chint_lcApplyCode中未配置,请检查","提示",2); return; } } @@ -410,6 +467,7 @@ public class SendProjectLcCommand extends KCommand { } } // 新的方案编码申请 + @SuppressWarnings("deprecation") public String applyPart(CodeBean bean,TCSession session,String wbsNo,TCComponentFolder tpsj,TCComponent ccbhTarget) throws TCException { @@ -442,10 +500,10 @@ public class SendProjectLcCommand extends KCommand { rev.unlock(); item.unlock(); bean.setRev(rev); - TCComponentUser user = session.getUser(); +// TCComponentUser user = session.getUser(); tpsj.add("contents", item); //addChildToCcp(rev,bean); - TCComponent target = (TCComponent) app.getTargetComponent(); +// TCComponent target = (TCComponent) app.getTargetComponent(); rev.add("ZT2_FactoryNumber", ccbhTarget); // return zt2_MaterialNo; diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/material_query/SearchMaterialDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/material_query/SearchMaterialDialog.java index fd5fa9e..dc2a121 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/material_query/SearchMaterialDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/material_query/SearchMaterialDialog.java @@ -134,6 +134,9 @@ public class SearchMaterialDialog extends AbstractAIFDialog { stopEd(); controller.doSearch(); pb.disposeDialog(); + if(table.getRowCount() == 0) { + MessageBox.post(SearchMaterialDialog.this, "查询不到数据", "", MessageBox.INFORMATION); + } } catch (Exception e) { e.printStackTrace(); pb.disposeDialog(); 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 45bd4df..b57bb10 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 @@ -505,7 +505,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation { SelfMPartBean bean = self_lists.get(i); String spec = bean.getSpec(); System.out.println("===============开始新建物料==============="); - CreateIn createMaterialYH = createMaterialYH(bean, groupID, spec, m_code); //groupID bean.getSpec(); m_code + CreateIn createMaterialYH = createMaterialYH(bean, groupID, spec, m_code); //groupID bean.getSpec(); m_code TODO if(createMaterialYH!=null) { cIList.add(createMaterialYH); } diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_by/BYProcBean.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_by/BYProcBean.java index 52ac94d..4dea960 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_by/BYProcBean.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_by/BYProcBean.java @@ -19,7 +19,7 @@ public class BYProcBean { private int index; private TCComponentItemRevision cpgy; private TCComponentItemRevision tlgx; - private String class_Code; +// private String class_Code; private TCComponentItemRevision cptlgx; private boolean isFeeding; private List meLists = new ArrayList(); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_byq/CreateProcBYQDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_byq/CreateProcBYQDialog.java index 516a899..aeb5e3f 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_byq/CreateProcBYQDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_byq/CreateProcBYQDialog.java @@ -670,6 +670,7 @@ public class CreateProcBYQDialog extends AbstractAIFDialog { @Override public void run() { + System.out.println("btn_expandAll start"); ProgressBar pb = new ProgressBar(CreateProcBYQDialog.this, new Dimension(350, 50)); try { if (SqlUtil2.getTCConnection() == null) { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_byq/CreateProcBYQGSDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_byq/CreateProcBYQGSDialog.java index cd39266..612daf5 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_byq/CreateProcBYQGSDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_byq/CreateProcBYQGSDialog.java @@ -65,6 +65,9 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi // 产品类型 private JLabel labelProducttype; private JComboBox cbbProducttype; + // 电压等级 + private JLabel labelVoltageClasses; + private JComboBox cbbVoltageClasses; // 产品型号 private JLabel labelProductxh; private JComboBox cbbProductxh; @@ -85,7 +88,7 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi protected void initGUI() { this.setTitle("工时计算"); // 设置显示大小 - Dimension dimension = new Dimension(400, 330); + Dimension dimension = new Dimension(400, 380); this.setPreferredSize(dimension); this.setMinimumSize(dimension); this.setMaximumSize(dimension); @@ -97,6 +100,9 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi this.add(labelProducttype = ComponentUtils.createLabel(labelProducttype, "labelProducttype", "产品类型", 20, y, 80, 20)); this.add(cbbProducttype = ComponentUtils.createComboBox(cbbProducttype, "cbbProducttype", 120, y, 260, 20)); y+= 40; + this.add(labelVoltageClasses = ComponentUtils.createLabel(labelVoltageClasses, "labelVoltageClasses", "电压等级", 20, y, 80, 20)); + this.add(cbbVoltageClasses = ComponentUtils.createComboBox(cbbVoltageClasses, "cbbVoltageClasses", 120, y, 260, 20)); + y+= 40; this.add(labelProductxh = ComponentUtils.createLabel(labelProductxh, "labelProductxh", "产品型号", 20, y, 80, 20)); this.add(cbbProductxh = ComponentUtils.createComboBox(cbbProductxh, "cbbProductxh", 120, y, 260, 20)); y+= 40; @@ -113,6 +119,7 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi this.add(btnCancel = ComponentUtils.createButton(btnCancel, "btnCancel", "取消", 290, y, 80, 25, this)); // 事件监听 cbbProducttype.addItemListener(this); + cbbVoltageClasses.addItemListener(this); cbbProductxh.addItemListener(this); // 加载数据 this.loadData(); @@ -236,17 +243,45 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi public void itemStateChanged(ItemEvent e) { if (e.getSource() == cbbProducttype) { ComboItem producttypeItem = (ComboItem) cbbProducttype.getSelectedItem(); + ComboItem voltageClassesItem = (ComboItem) cbbVoltageClasses.getSelectedItem(); if (producttypeItem!=null) { - EasyResponse> productxhResult = WorkhourService.getProductxh(groupId, producttypeItem.getName()); + EasyResponse> voltagelevelResult = WorkhourService.getVoltagelevel(groupId, producttypeItem.getName()); + if (voltagelevelResult.isSuccess()) { + List list = voltagelevelResult.getData(); + if (CollectionUtils.isNotEmpty(list)) { + cbbVoltageClasses.removeAllItems(); + cbbVoltageClasses.addItem(new ComboItem("")); + for (String str : list) { + cbbVoltageClasses.addItem(new ComboItem(str)); + } + } + } + EasyResponse> productxhResult = WorkhourService.getProductxh(groupId, producttypeItem.getName(), voltageClassesItem!=null?voltageClassesItem.getName():""); if (productxhResult.isSuccess()) { List list = productxhResult.getData(); if (CollectionUtils.isNotEmpty(list)) { + cbbProductxh.removeAllItems(); + cbbProductxh.addItem(new ComboItem("")); for (String str : list) { cbbProductxh.addItem(new ComboItem(str)); } } } } + } else if (e.getSource() == cbbVoltageClasses) { + ComboItem producttypeItem = (ComboItem) cbbProducttype.getSelectedItem(); + ComboItem voltageClassesItem = (ComboItem) cbbVoltageClasses.getSelectedItem(); + EasyResponse> productxhResult = WorkhourService.getProductxh(groupId, producttypeItem.getName(), voltageClassesItem!=null?voltageClassesItem.getName():""); + if (productxhResult.isSuccess()) { + List list = productxhResult.getData(); + if (CollectionUtils.isNotEmpty(list)) { + cbbProductxh.removeAllItems(); + cbbProductxh.addItem(new ComboItem("")); + for (String str : list) { + cbbProductxh.addItem(new ComboItem(str)); + } + } + } } } diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_zy/CreateProcZYDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_zy/CreateProcZYDialog.java index fcc41b6..da188d7 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_zy/CreateProcZYDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_zy/CreateProcZYDialog.java @@ -245,25 +245,24 @@ public class CreateProcZYDialog extends AbstractAIFDialog { new Thread(new Runnable() { @Override public void run() { - ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); + ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(400, 50)); setCompEnabled(false); try { + long startTime = System.currentTimeMillis(); value_strings = KUtil.getLOVDisplay_value(session, "zt2_ControlCode"); KUtil.setByPass(true); if (revs.size() == 1) { tree.setRootVisible(false); controller.readData(pb, revs); - long startTime = System.currentTimeMillis(); + System.out.println("usedTime1:" + (System.currentTimeMillis() - startTime) / 1000); controller.readData(pb, rev_nodes.get(revs.get(0))); - long endTime = System.currentTimeMillis(); - long usedTime = (endTime - startTime) / 1000; - System.out.println("usedTime:" + usedTime); + System.out.println("usedTime2:" + (System.currentTimeMillis() - startTime) / 1000); clickNode = rev_nodes.get(revs.get(0)); KUtil.expandTree(tree, new TreePath(topNode)); + System.out.println("usedTime3:" + (System.currentTimeMillis() - startTime) / 1000); } else { controller.readData(pb, revs); } - addListeners(); isAllowExpand = true; pb.disposeDialog(); } catch (Exception e) { @@ -276,9 +275,10 @@ public class CreateProcZYDialog extends AbstractAIFDialog { setCompEnabled(true); } }).start(); + addListeners(); showDialog(); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); pb2.disposeDialog(); MessageBox.post(CreateProcZYDialog.this, "初始化异常:" + e.getMessage(), "", 2); @@ -287,7 +287,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { @Override protected void processWindowEvent(WindowEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub if (e.getID() == WindowEvent.WINDOW_CLOSING && isSecSpec) { try { AIFComponentContext meops[] = bomrev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, @@ -299,7 +299,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { } } catch (TCException e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } } @@ -371,73 +371,71 @@ public class CreateProcZYDialog extends AbstractAIFDialog { if (min != -1) { t_part.scrollRectToVisible(t_part.getCellRect(min, 0, true)); } - } - } }); tree.addTreeExpansionListener(new TreeExpansionListener() { - @Override public void treeExpanded(TreeExpansionEvent event) { - // TODO Auto-generated method stub + // Auto-generated method stub final TreePath path = event.getPath(); if (path != null) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); System.out.println("isAllowExpand:" + isAllowExpand); - if (isAllowExpand && node != null && map_nodes.containsKey(node) - && map_nodes.get(node).size() == 0) { - new Thread(new Runnable() { - - @Override - public void run() { - ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); - setCompEnabled(false); - try { - controller.readData(pb, node); - tree.expandPath(path); - clickNode = node; - pb.disposeDialog(); - } catch (Exception e1) { - pb.disposeDialog(); - MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", - MessageBox.ERROR); - e1.printStackTrace(); + if (isAllowExpand && node != null && map_nodes.containsKey(node)) { + if(map_nodes.get(node).size() == 0) { + new Thread(new Runnable() { + @Override + public void run() { + ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); + setCompEnabled(false); + try { + controller.readData(pb, node); + tree.expandPath(path); + clickNode = node; + pb.disposeDialog(); + } catch (Exception e1) { + pb.disposeDialog(); + MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", + MessageBox.ERROR); + e1.printStackTrace(); + } + setCompEnabled(true); } - setCompEnabled(true); - } - }).start(); - } else { - if (map_nodes.containsKey(node)) { + }).start(); + }else { try { controller.refushTable2(map_nodes.get(node)); clickNode = node; } catch (Exception e1) { - // TODO Auto-generated catch block + // Auto-generated catch block MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", MessageBox.ERROR); e1.printStackTrace(); } } - } - + if (isAllowExpand && node != null && map_nodes.containsKey(node) + && map_nodes.get(node).size() == 0) { + + } else { + if (map_nodes.containsKey(node)) { + + } + } } - } @Override public void treeCollapsed(TreeExpansionEvent event) { - // TODO Auto-generated method stub - + // Auto-generated method stub DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); JTree tree = (JTree) event.getSource(); DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); tree.clearSelection(); KUtil.recurRemove(model, node, tm_part); - } }); @@ -670,7 +668,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { @Override public int compare(String o1, String o2) { - // TODO Auto-generated method stub + // Auto-generated method stub return o2.compareTo(o1); } }); @@ -815,7 +813,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { * MessageBox.post(CreateProcZYDialog.this, "投料异常,ERROR:"+e1.getMessage() , "", * MessageBox.ERROR); e1.printStackTrace(); * }//如果不关闭,会导致BOM被占用,乃至包含BOM的版本不能删除,除非重启TC System.out.println(sb.toString()); - * //TODO 设置最后一列 setTable(bomMap); + * // 设置最后一列 setTable(bomMap); * * if(sb.length()>0) { MessageBox.post(CreateProcZYDialog.this, * "自动投料完成,请进行手工投料", "", MessageBox.WARNING); }else { @@ -901,7 +899,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { } catch (Exception e) { pb.disposeDialog(); - // TODO: handle exception + // : handle exception e.printStackTrace(); MessageBox.post(CreateProcZYDialog.this, "异常:" + e.getMessage(), "提示", 2); } @@ -1022,9 +1020,10 @@ public class CreateProcZYDialog extends AbstractAIFDialog { if (pb == null) { pb = new MyProgressBarCompent("工艺修改", "工艺路线修改中......"); - } else { - pb.setShowLabel("工艺路线修改中......"); - } + } +// else { +// pb.setShowLabel("工艺路线修改中......"); +// } pb.setVisible(true); if (procs == null || procs.size() == 0) { @@ -1091,7 +1090,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings, session); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2); } @@ -1111,7 +1110,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings, session); } catch (Exception e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2); } @@ -1119,7 +1118,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { } }); } catch (Exception e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); } @@ -1197,7 +1196,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { } } catch (Exception e1) { - // TODO Auto-generated catch block + // Auto-generated catch block e1.printStackTrace(); MessageBox.post("PDF打开异常:" + e1.getMessage(), "", 2); } @@ -1209,7 +1208,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub + // Auto-generated method stub // 清除Table for (int i = tm_part.getRowCount() - 1; i > -1; i--) { tm_part.removeRow(i); @@ -1668,7 +1667,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { * tm_part.addRow(new Object[] * {index,item_id,rev.getProperty("object_name"),"","",gy_name}); index++; * gy=null; groupID=""; } System.out.println("结束"); } catch (Exception e) { // - * TODO Auto-generated catch block e.printStackTrace(); }finally { + * Auto-generated catch block e.printStackTrace(); }finally { * KUtil.setByPass(false); } * * } }).start(); @@ -1692,7 +1691,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { @Override public void run() { - // TODO Auto-generated method stub + // Auto-generated method stub ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); setCompEnabled(false); try { @@ -1742,7 +1741,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog { controller.refushTable2(map_nodes.get(node)); clickNode = node; } catch (Exception e1) { - // TODO Auto-generated catch block + // Auto-generated catch block MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", MessageBox.ERROR); e1.printStackTrace(); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_zy/CreateProcZYDialogController.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_zy/CreateProcZYDialogController.java index 27fc98e..1e48087 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_zy/CreateProcZYDialogController.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/proc_zy/CreateProcZYDialogController.java @@ -1,5 +1,6 @@ package com.connor.chint.sap2.proc_zy; +import java.sql.ResultSet; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; @@ -18,6 +19,7 @@ import com.connor.chint.sap2.proc.CreateProcessController; import com.connor.chint.sap2.proc_by.BomBean; import com.connor.chint.sap2.proc_by.BYProcBean; import com.connor.chint.sap2.proc_by.ProcCellEditor; +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.ProgressBar; @@ -30,12 +32,13 @@ import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindowType; import com.teamcenter.rac.kernel.TCComponentContextList; -import com.teamcenter.rac.kernel.TCComponentGroup; import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData; +import com.teamcenter.services.rac.core.DataManagementService; public class CreateProcZYDialogController { @@ -45,14 +48,16 @@ public class CreateProcZYDialogController { private TCSession session; protected List procBeanList = new ArrayList<>(); private ProcCellEditor procEditoe; + private String group; - private TCComponentGroup login_group = null; +// private TCComponentGroup login_group = null; + private Map mepMap = new HashMap<>(); public CreateProcZYDialogController(CreateProcZYDialog createProcBYDialog, AbstractAIFApplication app) { this.dialog = createProcBYDialog; this.app = app; this.session = (TCSession) app.getSession(); - this.login_group = session.getCurrentGroup(); +// this.login_group = session.getCurrentGroup(); } public void readData(ProgressBar pb) throws Exception { @@ -62,6 +67,7 @@ public class CreateProcZYDialogController { if (target == null || !(target instanceof TCComponentItemRevision)) { return; } + group = session.getCurrentGroup().getUid(); System.out.println("检查对象:" + target); TCComponentItemRevision rev = (TCComponentItemRevision) target; TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); @@ -71,7 +77,14 @@ public class CreateProcZYDialogController { topBean = new BomBean(rev, topLine, 1); DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(topBean); dialog.topNode.add(topTreeNode); - readBom(topTreeNode, topLine, pb, rev, topBean, procBeanList); + + List codeList = new ArrayList<>(); + List noList = new ArrayList<>(); +// readTemplate(topLine, rev, topBean, procBeanList); + com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session); + Map bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(topLine, structureService); + readBom(topTreeNode, topLine, bomLineTree, pb, rev, topBean, procBeanList, codeList, noList); + getGY(procBeanList, codeList, noList); KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode)); if (procBeanList.size() > 0) { procEditoe = new ProcCellEditor(procBeanList); @@ -81,33 +94,33 @@ public class CreateProcZYDialogController { win.close(); } - private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb, - TCComponentItemRevision parentRev, BomBean parentBean, List procBeanList) throws Exception { - readTemplate(topLine, parentRev, parentBean, procBeanList); + private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, Map bomLineTree, ProgressBar pb, + TCComponentItemRevision parentRev, BomBean parentBean, List procBeanList, List codeList, List noList) throws Exception {//TODO readBom + readTemplate(topLine, parentRev, parentBean, procBeanList, codeList, noList); BomBean pBean = (BomBean) treeNode.getUserObject(); - pb.setText("加载数据..." + pBean); - AIFComponentContext[] cLines = topLine.getChildren(); + pb.setText("加载数据:" + pBean); +// AIFComponentContext[] cLines = topLine.getChildren(); TCComponentItemRevision parentRev2 = topLine.getItemRevision(); - for (int i = 0; i < cLines.length; i++) { - TCComponentBOMLine cLine = (TCComponentBOMLine) cLines[i].getComponent(); + for (ExpandPSData data : bomLineTree.get(topLine.getUid())) { + TCComponentBOMLine cLine = data.bomLine; if (cLine.getProperty("zt2_Diagram").equals("是")) { System.out.println(cLine.getProperty("object_string") + "为虚拟项,已过滤!"); continue; } - TCComponentItemRevision cRev = cLine.getItemRevision(); + TCComponentItemRevision cRev = data.itemRevOfBOMLine; System.out.println("cRev:" + cRev); BomBean cBean = new BomBean(cRev, cLine, procBeanList.size() + 1); pBean.getChildren().add(cBean); DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean); treeNode.add(cNode); System.out.println("添加:" + cBean); - readBom(cNode, cLine, pb, parentRev2, cBean, procBeanList); + readBom(cNode, cLine, bomLineTree, pb, parentRev2, cBean, procBeanList, codeList, noList); } } private void readBom2(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb, - TCComponentItemRevision parentRev, BomBean parentBean, List procBeanList) throws Exception { - readTemplate(topLine, parentRev, parentBean, procBeanList); + TCComponentItemRevision parentRev, BomBean parentBean, List procBeanList, List codeList, List noList) throws Exception { + readTemplate(topLine, parentRev, parentBean, procBeanList, codeList, noList); BomBean pBean = (BomBean) treeNode.getUserObject(); pb.setText("加载数据..." + pBean); AIFComponentContext[] cLines = topLine.getChildren(); @@ -127,23 +140,25 @@ public class CreateProcZYDialogController { DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean); treeNode.add(cNode); System.out.println("添加:" + cBean); - readBom2(cNode, cLine, pb, parentRev2, cBean, procBeanList); + readBom2(cNode, cLine, pb, parentRev2, cBean, procBeanList, codeList, noList); } } private void readTemplate(TCComponentBOMLine topLine, TCComponentItemRevision parentRev, BomBean parentBean, - List procBeanList) throws Exception { + List procBeanList, List codeList, List noList) throws Exception { TCComponentItemRevision comp = topLine.getItemRevision(); TCComponentItemRevision rev_standard = null; - TCComponentItemRevision bzgy = null; +// TCComponentItemRevision bzgy = null; TCComponentItemRevision tlgx = null; TCComponentItemRevision cptlgx = null; boolean flag = true; List bzgys = new ArrayList(); String zt2_MaterialMark = ""; - System.out.println("type:" + comp.getType()); + String type = comp.getType(); + System.out.println("type:" + type); zt2_MaterialMark = comp.getProperty("zt2_MaterialMark"); - if (comp.getType().equals("ZT2_Design3DRevision")) { + + if (type.equals("ZT2_Design3DRevision")) { String drawingNo = comp.getStringProperty("item_id"); System.out.println("查询标准工艺:" + comp + ", zt2_DrawingNo = " + drawingNo); if (KUtil.isEmpty(drawingNo)) { @@ -158,53 +173,9 @@ public class CreateProcZYDialogController { drawingNo = drawingNo.substring(0, ind); } } - System.out.println("查询图号:" + drawingNo); - // 查询标准图工艺 - Map fields = new LinkedHashMap<>(); - fields.put("DrawingNo", drawingNo); - TCComponentContextList res = KUtil.query(session, "chint_query_TYDH", fields); - if (res != null) { - int len = res.getListCount(); - if (len > 1) { - throw new Exception("通过 DrawingNo = " + drawingNo + " 查询到多个对象"); - } - if (len == 1) { - TCComponentItemRevision rev = (TCComponentItemRevision) res.get(0).getComponent(); - rev_standard = rev; - String zt2_ClassificationCode = rev.getProperty("zt2_ClassificationCode"); - if (zt2_ClassificationCode.length() > 0) { - flag = false; - Map fields2 = new LinkedHashMap<>(); - fields2.put("ID", zt2_ClassificationCode); - TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2); - if (res2 != null) { - int len2 = res2.getListCount(); - - if (len2 > 1) { - throw new Exception("通过 ID = " + zt2_ClassificationCode + " 查询到多个对象"); - } - if (len2 == 1) { - tlgx = (TCComponentItemRevision) res2.get(0).getComponent(); - System.out.println("tlgx type:[" + tlgx.getType() + "]"); - } - } - } - AIFComponentContext[] comps = rev.whereReferencedByTypeRelation( - new String[] { "MEProcessRevision" }, new String[] { "IMAN_METarget" }); - System.out.println("查询到对象:" + rev + ", 引用数量:" + comps.length); - for (int i = 0; i < comps.length; i++) { - InterfaceAIFComponent cc = comps[i].getComponent(); - if (KUtil.isSameGroup((TCComponent) cc, login_group)) { - // 添加到模板 - bzgy = (TCComponentItemRevision) cc; - System.out.println("找到标准工艺:" + bzgy); - bzgys.add(bzgy); - } - } - } - } + codeList.add(drawingNo); } // 若未图纸,则取物料编码 - else if (comp.getType().equals("Part Revision")) { + else if (type.equals("Part Revision")) { String drawingNo = comp.getStringProperty("zt2_MaterialNo"); System.out.println("查询标准工艺:" + comp + ", zt2_MaterialNo = " + drawingNo); if (KUtil.isEmpty(drawingNo)) { @@ -216,82 +187,16 @@ public class CreateProcZYDialogController { drawingNo = drawingNo.substring(0, ind); } // 查询标准图工艺 - Map fields = new LinkedHashMap<>(); - fields.put("零组件 ID", drawingNo); - TCComponentContextList res = KUtil.query(session, "零组件版本...", fields); - if (res != null) { - int len = res.getListCount(); - if (len > 1) { - throw new Exception("通过 DrawingNo = " + drawingNo + " 查询到多个对象"); - } - if (len == 1) { - TCComponentItemRevision rev = (TCComponentItemRevision) res.get(0).getComponent(); - rev_standard = rev; - String zt2_ClassificationCode = rev.getProperty("zt2_ClassificationCode"); - if (zt2_ClassificationCode.length() > 0) { - flag = false; - Map fields2 = new LinkedHashMap<>(); - fields2.put("ID", zt2_ClassificationCode); - TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2); - if (res2 != null) { - int len2 = res2.getListCount(); - - if (len2 > 1) { - throw new Exception("通过 ID = " + zt2_ClassificationCode + " 查询到多个对象"); - } - if (len2 == 1) { - tlgx = (TCComponentItemRevision) res2.get(0).getComponent(); - System.out.println("tlgx type:[" + tlgx.getType() + "]"); - } - } - } - AIFComponentContext[] comps = rev.whereReferencedByTypeRelation( - new String[] { "MEProcessRevision" }, new String[] { "IMAN_METarget" }); - System.out.println("查询到对象:" + rev + ", 引用数量:" + comps.length); - for (int i = 0; i < comps.length; i++) { - InterfaceAIFComponent cc = comps[i].getComponent(); - if (KUtil.isSameGroup((TCComponent) cc, login_group)) { - // 添加到模板 - bzgy = (TCComponentItemRevision) cc; - System.out.println("找到标准工艺:" + bzgy); - bzgys.add(bzgy); - } - } - } - } - } + codeList.add(drawingNo); + }else { + codeList.add(""); + }/**/ String zt2_ClassificationCode = topLine.getProperty("ZT2_ClassificationNo"); System.out.println("[ZT2_ClassificationNo=" + zt2_ClassificationCode + "]"); - if (zt2_ClassificationCode.length() > 0) { - flag = false; - Map fields2 = new LinkedHashMap<>(); - fields2.put("ID", zt2_ClassificationCode); - TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2); - if (res2 != null) { - int len2 = res2.getListCount(); - - if (len2 > 1) { - throw new Exception("通过 ID = " + zt2_ClassificationCode + " 查询到多个对象"); - } - if (len2 == 1) { - cptlgx = (TCComponentItemRevision) res2.get(0).getComponent(); - } - } - } + noList.add(zt2_ClassificationCode); // 查询产品工艺 - TCComponentItemRevision cpgy = null; - AIFComponentContext[] refs = comp.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, - new String[] { "IMAN_METarget" }); - System.out.println("查询产品工艺、投料工序:" + comp + ", 引用数量:" + refs.length); - for (int i = 0; i < refs.length; i++) { - InterfaceAIFComponent c = refs[i].getComponent(); - if (KUtil.isSameGroup((TCComponent) c, login_group)) { - // 添加到模板 - System.out.println("找到产品工艺:" + c); - cpgy = (TCComponentItemRevision) c; - } - } + TCComponentItemRevision cpgy = (TCComponentItemRevision) getMeproces(comp.getUid(), session); BYProcBean bean = new BYProcBean(procBeanList.size() + 1, comp, bzgys, cpgy, tlgx, topLine, cptlgx, parentRev); zt2_ClassificationCode = comp.getProperty("zt2_ClassificationCode"); @@ -374,6 +279,7 @@ public class CreateProcZYDialogController { KUtil.info(dialog, "二次自动投料完成"); } + @SuppressWarnings("deprecation") public void oneAutoFeeding(Map maps, ProgressBar pb) throws Exception { KUtil.stopTableEditing(dialog.t_part); pb.setText("一次自动投料..."); @@ -392,6 +298,7 @@ public class CreateProcZYDialogController { pb.disposeDialog(); } + @SuppressWarnings("deprecation") private void oneFeedingLine(Map maps, TCComponentBOMLine line) throws Exception { AIFComponentContext[] children = line.getChildren(); String zt2_ClassificationCode; @@ -411,7 +318,7 @@ public class CreateProcZYDialogController { } } - private void refushPros(TCComponentBOMLine line, BYProcBean bean) throws TCException { + private void refushPros(TCComponentBOMLine line, BYProcBean bean) throws Exception { System.out.println("line:" + line.getItemRevision() + "|子项:" + bean.getBomRev()); if (line.getItemRevision().equals(bean.getBomRev())) { System.out.println("重新刷新子项可选工序"); @@ -592,13 +499,13 @@ public class CreateProcZYDialogController { dialog.tm_part.setValueAt(proc.getProperty("object_name"), procBean.getIndex() - 1, BYProcBean.INDEX_CPGY); } - private void getGX(TCComponentBOMLine line, List lists) throws TCException { + private void getGX(TCComponentBOMLine line, List lists) throws Exception { TCComponentBOMLine parent = line.parent(); if (parent == null) { return; } boolean flag = false; - AIFComponentContext[] contexts22 = (parent.getItemRevision()).whereReferencedByTypeRelation(null, null); + /*AIFComponentContext[] contexts22 = (parent.getItemRevision()).whereReferencedByTypeRelation(null, null); for (int i = 0; i < contexts22.length; i++) { String type = contexts22[i].getComponent().getType(); System.out.println("type:" + type); @@ -616,11 +523,49 @@ public class CreateProcZYDialogController { } } + }*/ + TCComponent meop = getMeproces(parent.getItemRevision().getUid(), session); + if(meop != null) { + flag = true; + if(!lists.contains(meop) && (meop instanceof TCComponentItemRevision)) + lists.add((TCComponentItemRevision) meop); } if (!flag) { getGX(parent, lists); } - + } + + private TCComponent getMeproces(String uid, TCSession session) throws Exception { + //TODO getMeproces + if(mepMap.containsKey(uid)) { + return mepMap.get(uid); + } +// String sql = SAPUtil.sqlRef.replace("\\?", "'" + uid + "'"); + String sql = "select P.puid as supItemUID,V.puid as supRevUID,P.pitem_id as supItemID,ITRO.Pobject_Name as supItemName," + + "V.Pitem_Revision_Id as supRevID,cP.pitem_id as subItemID,cV.puid as subRevUID,RT.partifactname as 版本与版本关系 " + + "from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g " + + "where g.puid=V.puid and V.Puid = R.Rprimary_Objectu and r.rrelation_typeu = RT.puid and P.Puid = V.Ritems_Tagu and ITRO.Puid = V.Puid " + + "and R.Rsecondary_Objectu = cV.Puid and cP.Puid = cV.Ritems_Tagu and cV.Puid = cITRO.Puid and ITRO.Pactive_Seq<>0 " + + "and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' and g.ROWNING_GROUPU='" + group + "' and cV.PUID = '" + uid + "'"; + try { + ResultSet read = SqlUtil.read(sql);//SAPUtil.sqlRef, new Object[] { uid } +// boolean next = read.next(); + while (read.next()) { + String string = read.getString("supRevUID"); + TCComponent mpComp = session.stringToComponent(string); +// TCComponent mpComp = SAPUtil.getSameGroupProcYH(meops, session); + if(mpComp != null) { + mepMap.put(uid, mpComp); +// SqlUtil.free(); + return mpComp; + } + } +// SqlUtil.free(); + }catch(Exception e) { + System.out.println("sql==>" + sql); + e.printStackTrace(); + } + return null; } public void assignProcess(ProgressBar pb) throws Exception { @@ -682,6 +627,7 @@ public class CreateProcZYDialogController { } // 创建工艺 + @SuppressWarnings("deprecation") public void createProcess(ProgressBar pb, MEProcessBean bean, TCSession session, List revs) throws Exception { if (revs.size() == 0) @@ -725,8 +671,8 @@ public class CreateProcZYDialogController { TCComponentItemRevision rev; TCComponentItemRevision newProc = null; StringBuffer buff = new StringBuffer(); - DefaultMutableTreeNode node; - String object_name = proc.getProperty("object_name"); +// DefaultMutableTreeNode node; +// String object_name = proc.getProperty("object_name"); // pb.setText("工艺路线创建......"); int len = revs.size(); List cout_beans = new ArrayList<>(); @@ -756,7 +702,8 @@ public class CreateProcZYDialogController { BYProcBean.INDEX_CPGY); } if (procBean.getRev_standard() == procBean.getBomRev()) { - procBean.getBzgys().add(newProc); + if(!procBean.getBzgys().contains(newProc)) + procBean.getBzgys().add(newProc); procBean.setTemplate(newProc); if (procBean.isVisible) { dialog.tm_part.setValueAt(newProc.getProperty("object_name"), procBean.getIndex() - 1, @@ -775,7 +722,8 @@ public class CreateProcZYDialogController { procBean = beans.get(j); procBean.setCpgy(proc); if (procBean.getRev_standard() == procBean.getBomRev()) { - procBean.getBzgys().add(proc); + if(!procBean.getBzgys().contains(proc)) + procBean.getBzgys().add(proc); procBean.setTemplate(proc); } } @@ -805,14 +753,19 @@ public class CreateProcZYDialogController { } public void refushTable2(List list) throws Exception { - dialog.tm_part.getDataVector().clear(); - dialog.t_part.clearSelection(); - dialog.t_part.revalidate(); - dialog.t_part.repaint(); +// dialog.tm_part.getDataVector().clear(); +// dialog.t_part.clearSelection(); +// dialog.t_part.revalidate(); +// dialog.t_part.repaint(); + for(int i = dialog.t_part.getRowCount() - 1; i >= 0; i--) { + dialog.tm_part.removeRow(i); + } for (int i = 0, len = list.size(); i < len; i++) { +// long startTime = System.currentTimeMillis(); list.get(i).isVisible = true; dialog.tm_part.addRow(list.get(i).getRowData()); +// System.out.println("addRow:" + (System.currentTimeMillis() - startTime)); } } @@ -875,10 +828,12 @@ public class CreateProcZYDialogController { } public void readData(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception { + long startTime = System.currentTimeMillis(); pb.startProgress(); pb.setText("加载数据..."); dialog.rev_Beans.clear(); // 预先加入的假节点 + group = session.getCurrentGroup().getUid(); int cout = topTreeNode.getChildCount(); TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindow win = bomWinType.create(null); @@ -895,12 +850,53 @@ public class CreateProcZYDialogController { win.setWindowTopLine(rev.getItem(), rev, null, null); TCComponentBOMLine topLine = win.getTopBOMLine(); List procBeanList2 = new ArrayList<>(); + List codeList = new ArrayList<>(); + List noList = new ArrayList<>(); + List bomList = new ArrayList<>(); + List bomRevList = new ArrayList<>(); - readBom(topTreeNode, topLine, pb, rev, topBean, procBeanList2); + // getBomLineTreeNodeSOA + String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session); + if (SqlUtil.getTCDataConnection(prefs) == null) { + MessageBox.post("数据库连接失败,请检查数据库连接配置!", "", 2); + return; + } + //预加载BOM及版本属性,优化速度 + com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session); + Map bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(topLine, structureService); + getBOMList(topLine, bomLineTree, bomList, bomRevList); + DataManagementService dmService = DataManagementService.getService(session); + dmService.getProperties(bomList.toArray(new TCComponent[0]), new String[] { "zt2_Diagram", "object_string", "ZT2_ClassificationNo", "bl_sequence_no" }); + dmService.getProperties(bomRevList.toArray(new TCComponent[0]), new String[] { "object_type", "item_id", "zt2_MaterialNo", "zt2_MaterialMark", "zt2_ClassificationCode" }); + + System.out.println("readData1:" + (System.currentTimeMillis() - startTime) / 1000); + readBom(topTreeNode, topLine, bomLineTree, pb, rev, topBean, procBeanList2, codeList, noList); + System.out.println("readData2:" + (System.currentTimeMillis() - startTime) / 1000); + getGY(procBeanList2, codeList, noList); + System.out.println("readData3:" + (System.currentTimeMillis() - startTime) / 1000); procBeanList.clear(); procBeanList.addAll(procBeanList2); dialog.map_nodes.put(topTreeNode, procBeanList2); + + TCComponent[] revs = new TCComponent[procBeanList2.size()]; + ArrayList gyList = new ArrayList<>(); + for(int i = 0; i < revs.length; i++) { + BYProcBean bean = procBeanList2.get(i); + revs[i] = bean.getBomRev(); + if(bean.getTemplate() != null) + gyList.add(bean.getTemplate()); + if(bean.getCpgy() != null) + gyList.add(bean.getCpgy()); + if(bean.getCptlgx() != null) + gyList.add(bean.getCptlgx()); + if(bean.getTlgx() != null) + gyList.add(bean.getTlgx()); + } + dmService.getProperties(revs, new String[] { "object_type", "item_id", "zt2_MaterialNo", "object_name", "zt2_Source" }); + dmService.getProperties(gyList.toArray(new TCComponent[gyList.size()]), new String[] { "object_name" }); refushTable2(procBeanList2); + System.out.println("readData4:" + (System.currentTimeMillis() - startTime) / 1000); + for (int i = cout - 1; i > -1; i--) { topTreeNode.remove(i); } @@ -910,7 +906,118 @@ public class CreateProcZYDialogController { dialog.t_part.getColumnModel().getColumn(4).setCellEditor(procEditoe); } win.close(); - + SqlUtil.free(); + System.out.println("readData5:" + (System.currentTimeMillis() - startTime) / 1000); + } + + private void getBOMList(TCComponentBOMLine parentLine, Map bomLineTree, List bomList, List bomRevList) { + for (ExpandPSData data : bomLineTree.get(parentLine.getUid())) { + TCComponentBOMLine cLine = data.bomLine; + bomList.add(cLine); + bomRevList.add(data.itemRevOfBOMLine); + getBOMList(cLine, bomLineTree, bomList, bomRevList); + } + } + + private void getGY(List procBeanList, List codeList, List noList) throws Exception { + //TODO getGY + StringBuilder codes = new StringBuilder(""); + ArrayList noSet = new ArrayList<>(); + for(String s : codeList) { + if(noSet.contains(s)) + continue; + noSet.add(s); + codes.append("','").append(s); + } + //查询标准图投料工序和标准图工艺 + StringBuilder sql1 = new StringBuilder("select b.puid,a.pitem_id,b.PZT2_CLASSIFICATIONCODE,t1.puid as tlgx,t2.bzgy from pitem a,pitemrevision b0,PPOM_APPLICATION_OBJECT b1,"); + sql1.append("(select puid,PZT2_CLASSIFICATIONCODE from PZT2_DESIGN3DREVISION union select puid,PZT2_CLASSIFICATIONCODE from PPART_0_REVISION_ALT) b ") + .append("left join (select a2.puid,a1.PITEM_ID from pitem a1,pitemrevision a2 where a2.ritems_tagu=a1.puid) t1 on t1.pitem_id=b.PZT2_CLASSIFICATIONCODE ") + .append("left join (select cV.puid,V.puid as bzgy,ITRO.Pobject_Name as supItemName ") + .append("from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g ") + .append("where g.puid=V.puid and V.Puid=R.Rprimary_Objectu and r.rrelation_typeu=RT.puid and P.Puid=V.Ritems_Tagu and ITRO.Puid=V.Puid and R.Rsecondary_Objectu=cV.Puid ") + .append("and cP.Puid=cV.Ritems_Tagu and cV.Puid=cITRO.Puid and ITRO.Pactive_Seq<>0 and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' and g.ROWNING_GROUPU='" + group + "') t2 on t2.puid=b.puid ") + .append("where b1.PCREATION_DATE in (select max(r3.PCREATION_DATE) from pitem r1,PITEMREVISION r2,PPOM_APPLICATION_OBJECT r3 where r1.puid=r2.ritems_tagu and r2.puid=r3.puid and r1.pitem_id=a.pitem_id) ") + .append("and b.puid=b1.puid and b.puid=b0.puid and b0.ritems_tagu=a.puid and a.pitem_id in (") + .append(codes.substring(2)) + .append("') order by b.puid"); + System.out.println("sql1:\n" + sql1); + ResultSet read = SqlUtil.read(sql1.toString()); + String last = ""; + HashMap uidMap = new HashMap<>(); + while (read.next()) { + String uid = read.getString(1); + String code = read.getString(2); + String classification = read.getString(3); + if(classification == null) + classification = ""; +// System.out.println("code:" + code); + String tlgx = read.getString(4); + String bzgy = read.getString(5); + String one = uid + bzgy; + if(one.equals(last)) + throw new Exception("通过 DrawingNo = " + code + " 查询到多个对象"); +// BYProcBean bean = procBeanList.get(codeList.indexOf(code)); + for(int i = 0; i < codeList.size(); i++) { + if(codeList.get(i).equals(code)) { + BYProcBean bean = procBeanList.get(i); + if(tlgx != null && !tlgx.isEmpty()) { + if(uidMap.containsKey(tlgx)) + bean.setTlgx(uidMap.get(tlgx)); + else { + TCComponentItemRevision tlgxRev = (TCComponentItemRevision) session.stringToComponent(tlgx); + bean.setTlgx(tlgxRev); + uidMap.put(tlgx, tlgxRev); + } + } + if(bzgy != null && !bzgy.isEmpty()) { + TCComponentItemRevision bzgyRev; + if(uidMap.containsKey(bzgy)) + bzgyRev = uidMap.get(bzgy); + else { + bzgyRev = (TCComponentItemRevision) session.stringToComponent(bzgy); + uidMap.put(bzgy, bzgyRev); + } + bean.setTemplate(bzgyRev); + if(!bean.getBzgys().contains(bzgyRev)) + bean.getBzgys().add(bzgyRev); + } + bean.setFeeding(classification.length() <= 0); + bean.setRev_standard((TCComponentItemRevision) session.stringToComponent(uid)); + } + } + + last = one; + } +// SqlUtil.free(); + + StringBuilder nos = new StringBuilder(""); + noSet.clear(); + for(String s : noList) { + if(noSet.contains(s)) + continue; + noSet.add(s); + nos.append("','").append(s); + } + //查询产品图投料工序 + String sql2 = "select b.puid,a.pitem_id from pitem a,pitemrevision b where b.ritems_tagu=a.puid and a.PITEM_ID in (" + nos.substring(2) + "') order by a.pitem_id"; + System.out.println("sql2:\n" + sql2); + read = SqlUtil.read(sql2.toString()); + last = ""; + while (read.next()) { + String id = read.getString(2); + if(id.equals(last)) + throw new Exception("通过 ID = " + id + " 查询到多个对象"); + String uid = read.getString(1); + for(int i = 0; i < noList.size(); i++) { + if(noList.get(i).equals(id)) { + BYProcBean bean = procBeanList.get(i); + bean.setCptlgx((TCComponentItemRevision) session.stringToComponent(uid)); + } + } + last = id; + } +// SqlUtil.free(); } public void readData2(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception { @@ -923,6 +1030,7 @@ public class CreateProcZYDialogController { TCComponentBOMWindow win = bomWinType.create(null); BomBean topBean = (BomBean) topTreeNode.getUserObject(); TCComponentItemRevision rev = topBean.getRev(); + group = session.getCurrentGroup().getUid(); dialog.bomrev = rev; if (dialog.bomrev.getType().equals("Part Revision") @@ -934,8 +1042,11 @@ public class CreateProcZYDialogController { win.setWindowTopLine(rev.getItem(), rev, null, null); TCComponentBOMLine topLine = win.getTopBOMLine(); List procBeanList2 = new ArrayList<>(); + List codeList = new ArrayList<>(); + List noList = new ArrayList<>(); - readBom2(topTreeNode, topLine, pb, rev, topBean, procBeanList2); + readBom2(topTreeNode, topLine, pb, rev, topBean, procBeanList2, codeList, noList); + getGY(procBeanList2, codeList, noList); procBeanList.clear(); procBeanList.addAll(procBeanList2); dialog.map_nodes.put(topTreeNode, procBeanList2); @@ -971,6 +1082,7 @@ public class CreateProcZYDialogController { return nodes; } + @SuppressWarnings("deprecation") public void createProcess(ProgressBar pb, MEProcessBean bean, List beans) throws Exception { TCComponentItemRevision template = bean.getMepRevision(); TCComponentItemRevision proc = null; @@ -1011,8 +1123,8 @@ public class CreateProcZYDialogController { TCComponentItemRevision newProc = null; StringBuffer buff = new StringBuffer(); - DefaultMutableTreeNode node; - String object_name = proc.getProperty("object_name"); +// DefaultMutableTreeNode node; +// String object_name = proc.getProperty("object_name"); pb.setText("工艺路线创建......"); int len = beans.size(); BYProcBean dyccBean; @@ -1037,7 +1149,7 @@ public class CreateProcZYDialogController { newProc.add("IMAN_METarget", bomBean.getRev()); } - node = dialog.rev_nodes.get(bomBean.getRev()); +// node = dialog.rev_nodes.get(bomBean.getRev()); if (dialog.bomLink_maps.containsKey(bomBean)) { dyccBean = dialog.bomLink_maps.get(bomBean); dyccBean.setCpgy(newProc); @@ -1048,7 +1160,8 @@ public class CreateProcZYDialogController { BYProcBean.INDEX_CPGY); } if (dyccBean.getRev_standard() == dyccBean.getBomRev()) { - dyccBean.getBzgys().add(newProc); + if(!dyccBean.getBzgys().contains(newProc)) + dyccBean.getBzgys().add(newProc); dyccBean.setTemplate(newProc); if (dyccBean.isVisible) { dialog.tm_part.setValueAt(newProc.getProperty("object_name"), dyccBean.getIndex() - 1, @@ -1062,7 +1175,7 @@ public class CreateProcZYDialogController { System.out.println("正在为" + bomBean.getRev() + "创建工艺路线"); pb.setText("正在为" + len + "/" + len + " " + bomBean.getRev() + "创建工艺路线"); proc.add("IMAN_METarget", bomBean.getRev()); - node = dialog.rev_nodes.get(bomBean.getRev()); +// node = dialog.rev_nodes.get(bomBean.getRev()); if (dialog.bomLink_maps.containsKey(bomBean)) { dyccBean = dialog.bomLink_maps.get(bomBean); @@ -1074,7 +1187,8 @@ public class CreateProcZYDialogController { BYProcBean.INDEX_CPGY); } if (dyccBean.getRev_standard() == dyccBean.getBomRev()) { - dyccBean.getBzgys().add(proc); + if(!dyccBean.getBzgys().contains(proc)) + dyccBean.getBzgys().add(proc); dyccBean.setTemplate(proc); if (dyccBean.isVisible) { dialog.tm_part.setValueAt(proc.getProperty("object_name"), dyccBean.getIndex() - 1, diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/BomToSapUtil.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/BomToSapUtil.java index a0fbac8..7c44ca8 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/BomToSapUtil.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/BomToSapUtil.java @@ -226,4 +226,46 @@ public class BomToSapUtil { } return bomLineMap; } + /** + * SOA展开BOM,StructureManagement作为参数以节约资源 + * @param bomLine 顶层BOM + * @param structureService StructureManagement对象 + * @return BOM构建成的uid父子对关系 + */ + public static Map getBomLineTreeNodeSOA(TCComponentBOMLine bomLine, StructureManagement structureService) { + long startTime = System.currentTimeMillis(); +// List bomLineNodes = list; + + //预定义BOM父子对map及ItemRev map + Map bomLineMap = new HashMap<>(); +// Map bomLineItemRevMap = new HashMap(); + try { + // 调用SOA方法,批量展开BOM +// com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(RACUIUtil.getTCSession()); + com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo(); + com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref levelPref = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref(); + levelInfo.parentBomLines = new TCComponentBOMLine[] { bomLine }; //输入顶层BOMLine对象 + levelInfo.excludeFilter = "None";//zt2_BOMMaterial + levelPref.expItemRev = false; + levelPref.info = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelationAndTypesFilter[0]; +// levelPref.info[0].relationName = ""; + System.out.println("getBomLineTreeNodeSOA1:" + (System.currentTimeMillis() - startTime) / 1000); + //使用以下方法展开完整的BOM行 + com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsResponse levelResp = structureService.expandPSAllLevels(levelInfo, levelPref); + System.out.println("getBomLineTreeNodeSOA2:" + (System.currentTimeMillis() - startTime) / 1000); + if (levelResp.output.length > 0) { + //将BOM构建成uid父子对关系 + for (ExpandPSAllLevelsOutput data : levelResp.output) { + ExpandPSData[] children = data.children; + TCComponentBOMLine parentBomLine = (TCComponentBOMLine) data.parent.bomLine; + bomLineMap.put(parentBomLine.getUid(), children); + } + } + System.out.println("getBomLineTreeNodeSOA3:" + (System.currentTimeMillis() - startTime) / 1000); + + } catch (Exception e) { + e.printStackTrace(); + } + return bomLineMap; + } } 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 9ebf8db..62ff0fa 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 @@ -86,6 +86,7 @@ import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCComponentListOfValues; import com.teamcenter.rac.kernel.TCComponentListOfValuesType; import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; import com.teamcenter.rac.kernel.TCComponentQuery; import com.teamcenter.rac.kernel.TCComponentQueryType; import com.teamcenter.rac.kernel.TCComponentRevisionRule; @@ -2203,4 +2204,30 @@ public class KUtil { t_part.setValueAt(i + 1, i, 0); } } + /** + * 获取关系文件夹 + * + * @param parent 关系文件夹所属对象 + * @param relation 关系文件夹真实类型 + * @return 关系文件夹对象 + */ + public static TCComponentPseudoFolder getPseudoFolder(TCComponent parent, String relation) throws Exception { + TCComponentPseudoFolder pseudoFolder = null; + AIFComponentContext[] comps = parent.getChildren(); + if (comps != null && comps.length > 0 && comps[0] != null) { + for (int i = 0; i < comps.length; i++) { + TCComponent comp = (TCComponent) comps[i].getComponent(); + if (comp instanceof TCComponentPseudoFolder) { + if (comp.isTypeOf("PseudoFolder")) { +// System.out.println("PseudoFolder type:" + comp.getDefaultPasteRelation()); + if (comp.getDefaultPasteRelation().equalsIgnoreCase(relation)) { + pseudoFolder = (TCComponentPseudoFolder) comp; + break; + } + } + } + } + } + return pseudoFolder; + } } diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SqlUtil.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SqlUtil.java index 4f43046..bae8a63 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SqlUtil.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SqlUtil.java @@ -705,9 +705,9 @@ public class SqlUtil { */ public final static ResultSet read(String sql, Object[] argments) throws SQLException { PreparedStatement ps = SqlUtil.getPs(argments, sql); - System.out.println("read1"); +// System.out.println("read1"); SqlUtil.rs = ps.executeQuery(); - System.out.println("read2"); +// System.out.println("read2"); return SqlUtil.rs; } diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/TableBuilder.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/TableBuilder.java index fc99234..f5025a1 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/TableBuilder.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/TableBuilder.java @@ -262,9 +262,15 @@ public class TableBuilder { //查询界面增加“停用”勾选项,默认不勾选,进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料,若勾选则不过滤。 sql.append(" and \"GoodsFullInfo\" not like '%停用%'"); } - System.out.println("SQL:" + sql); - ResultSet rs = SqlUtil.read(sql.toString() + " order by \"GoodsUsed\"", - params.toArray(new Object[] {})); + System.out.println("SQL1:\n" + sql); + String sql2 = sql.toString();//.replace("?", "'" + input + "'") + " order by \"GoodsUsed\""; + for(String s : params) { + sql2 = sql2.replaceFirst("\\?", "'" + s + "'"); + } + sql2 += " order by \"GoodsUsed\""; + System.out.println("SQL2:\n" + sql2); + + ResultSet rs = SqlUtil.read(sql2);//, params.toArray(new Object[] {}) while (rs.next()) { System.out.println("rs:" + rs.getRow()); TableBean bean = new TableBean(rs.getString(1), ind_index); @@ -301,10 +307,18 @@ public class TableBuilder { //查询界面增加“停用”勾选项,默认不勾选,进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料,若勾选则不过滤。 sql.append(" and \"GoodsFullInfo\" not like '%停用%'"); } - System.out.println("SQL:" + sql); + System.out.println("SQL1:" + sql); System.out.println("PARAMS:" + params); - ResultSet rs = SqlUtil.read(sql.toString() + " order by \"GoodsUsed\"", params.toArray(new Object[] {})); + String sql2 = sql.toString();//.replace("?", "'" + input + "'") + " order by \"GoodsUsed\""; + for(String s : params) { + sql2 = sql2.replaceFirst("\\?", "'" + s + "'"); + } + sql2 += " order by \"GoodsUsed\""; + System.out.println("SQL2:\n" + sql2); +// ResultSet rs = SqlUtil.read(sql.toString() + " order by \"GoodsUsed\"", params.toArray(new Object[] {})); + ResultSet rs = SqlUtil.read(sql2); + System.out.println("index:" + index + " <---> cnt:" + cnt); while (rs.next()) { System.out.println("rs:" + rs.getRow());