diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/assignfactoryno/FactoryNoZYDialog2zt.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/assignfactoryno/FactoryNoZYDialog2zt.java index 3f51a75..10ed3d0 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/assignfactoryno/FactoryNoZYDialog2zt.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/assignfactoryno/FactoryNoZYDialog2zt.java @@ -48,6 +48,10 @@ import com.teamcenter.rac.util.PropertyLayout; public class FactoryNoZYDialog2zt extends AbstractAIFDialog { + /** + * + */ + private static final long serialVersionUID = 1L; private TCSession session; private AbstractAIFApplication app; // 表格 @@ -81,7 +85,7 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { private Map map_types = new HashMap<>(); // 存储为!的特殊情况 ,都申请 private List prefList = new ArrayList(); - private List indList = new ArrayList(); +// private List indList = new ArrayList(); // 存储出厂编号类型对应的流水号 private Map map_types_flow = new HashMap<>(); // 存储出厂编号类型中M007 配电变压器的日期+固定数 @@ -102,6 +106,7 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { private Map> map_type_factoryNos = new HashMap>(); // String groupID = ""; protected boolean isHave = false; // 针对DX + private boolean isAdd = false; public FactoryNoZYDialog2zt(AbstractAIFApplication app, String actionInfo, ProgressBar init_pb) { super(false); @@ -118,8 +123,8 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { try { groupID = SAPUtil.getGroupID(session); - } catch (TCException e) { - // TODO Auto-generated catch block + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); } @@ -183,6 +188,11 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); tm_bom = new DefaultTableModel(); t_bom = new JTable(tm_bom) { + /** + * + */ + private static final long serialVersionUID = 1L; + @Override public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑 if (column == 6) { @@ -235,9 +245,7 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { public void run() { try { int rowCout = t_bom.getRowCount(); - SimpleDateFormat sdf = new SimpleDateFormat("yyMM"); Date date = new Date(); - String dateString = sdf.format(date); System.out.println("map_fn_size:" + map_fn_size); System.out.println("map_num:" + map_num); for (int i = 0; i < rowCout; i++) { @@ -262,15 +270,19 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { isM006 = true; try { t_bom.setValueAt("K-" + project.getProperty(prefix0), i, 5); - } catch (TCException e) { - // TODO Auto-generated catch block + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); } }else if(prefix0.equals(ztsvg)) { t_bom.setValueAt(prefix0, i, 5); - } - else { + }else if(isAdd) { + t_bom.setValueAt(prefix0, i, 5); + prefix0 = prefix0.substring(0, prefix0.length() - 4); + }else { + SimpleDateFormat sdf = new SimpleDateFormat("yyMM"); + String dateString = sdf.format(date); t_bom.setValueAt(prefix0 + dateString, i, 5); } // if(isM006 || isM007) { @@ -320,14 +332,14 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { StringBuilder sb = new StringBuilder(""); int rowCout = t_bom.getRowCount(); Map repeatMap = new HashMap<>(); - FactoryNoZYBean bean; +// FactoryNoZYBean bean; for (int i = 0; i < rowCout; i++) { String prefix = (String) t_bom.getValueAt(i, 5);// 流水码前缀 if(prefix.equals("/")) { continue; } String flowNo = (String) t_bom.getValueAt(i, 6);// 流水码 - bean = (FactoryNoZYBean) t_bom.getValueAt(i, 0); +// bean = (FactoryNoZYBean) t_bom.getValueAt(i, 0); if (flowNo.trim().length() > 0) { if (repeatMap.containsValue(prefix + flowNo)) { for (Map.Entry me : repeatMap.entrySet()) { @@ -402,7 +414,9 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { } SqlUtil.free(); if (factorNoFolder != null) { + KUtil.setByPass(false); FactoryNoBean.sortFactory(factorNoFolder); + KUtil.setByPass(true); } } else { @@ -422,13 +436,21 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { new String[] { item_id }); // TCComponent[] comps = rev.getRelatedComponents(BomBuildDialogController.REL_FACTORYNO); // rev.cutOperation(BomBuildDialogController.REL_FACTORYNO, comps); + AIFComponentContext pf = rev.getChildren(BomBuildDialogController.REL_FACTORYNO)[0]; + for(AIFComponentContext c : pf.getComponent().getChildren()) { + TCComponent sub = (TCComponent) c.getComponent(); + if(sub.getUid().equals(item[0].getUid())) { + rev.remove(BomBuildDialogController.REL_FACTORYNO, sub); + } + } + rev.refresh(); rev.add(BomBuildDialogController.REL_FACTORYNO, item[0]); } pb.disposeDialog(); KUtil.info(FactoryNoZYDialog2zt.this, "保存出厂编号结束"); } catch (Exception e) { - KUtil.setByPass(false); + //KUtil.setByPass(false); pb.disposeDialog(); MessageBox.post(FactoryNoZYDialog2zt.this, "分配出厂编号发生异常:" + e.getMessage(), "", MessageBox.ERROR); @@ -479,12 +501,12 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { if(numMap.size()>0) { isM007 = true; } - Map lenMap = new HashMap(); +// Map lenMap = new HashMap(); list_fn_types = new ArrayList<>(map_types.keySet()); Collections.sort(list_fn_types, new Comparator() { @Override public int compare(String o1, String o2) { - // TODO Auto-generated method stub + // Auto-generated method stub return o2.compareTo(o1); } }); @@ -513,10 +535,10 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { String prefix; String p_code; String temp; - int indexs[]; +// int indexs[]; int size = 1; String zt2_Quantity = ""; - int num, assign_num = 0; +// int num, assign_num = 0; int ind = 0; List list_factoryNos; for (int i = 0, len = children.length; i < len; i++) { @@ -560,10 +582,10 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { zt2_Quantity = rev.getStringProperty("zt2_Quantity"); if (KUtil.isEmpty(zt2_Quantity)) { zt2_Quantity = "1"; - indexs = new int[] { 1 }; +// indexs = new int[] { 1 }; } else { - int size2 = POIUtil.getIntValue(zt2_Quantity) == 0 ? 1 : POIUtil.getIntValue(zt2_Quantity); - indexs = new int[size2]; +// int size2 = POIUtil.getIntValue(zt2_Quantity) == 0 ? 1 : POIUtil.getIntValue(zt2_Quantity); +// indexs = new int[size2]; } bean.setMaterialName(object_name); @@ -641,6 +663,7 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { map_fn_size.put(prefix, new Integer(size)); } } +// System.out.println("proPrefix1:" + proPrefix); if (!map_type_factoryNos.containsKey(prefix)) { list_factoryNos = new ArrayList(); @@ -658,9 +681,11 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { }else if (!KUtil.isEmpty(factoryID) && !KUtil.isEmpty(prefix) && !KUtil.isEmpty(p_code)) { Integer integer = map_types_flow.get(proPrefix); pref2 = factoryID.substring(0, factoryID.length() - integer); + isAdd = true; }else { pref2 = proPrefix; } +// System.out.println("pref21:" + pref2); bean.setFactNoItem(factoryItem); bean.setFactNoItemID(factoryID); bean.setPrefix(pref2); @@ -784,7 +809,7 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { System.out.println(map_fn_size); Date date = new Date(); String dateString = sdf.format(date); - String query = "select * from \"CHINT_M008_FactoryNo\" WHERE TIME='" + dateString + "'"; +// String query = "select * from \"CHINT_M008_FactoryNo\" WHERE TIME='" + dateString + "'"; ResultSet rs = null; String selectQuery = "select * from \"CHINT_M008_FactoryNo\" where TYPE=? and TIME=?"; String insertQuery = "insert into \"CHINT_M008_FactoryNo\" (TYPE,TIME,FLOW) values (?,?,'001')"; @@ -835,7 +860,7 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { try { factoryID = "K-" + project.getProperty(type); } catch (TCException e) { - // TODO Auto-generated catch block + // Auto-generated catch block e.printStackTrace(); } @@ -861,9 +886,7 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { try { int rowCout = t_bom.getRowCount(); - SimpleDateFormat sdf = new SimpleDateFormat("yyMM"); Date date = new Date(); - String dateString = sdf.format(date); System.out.println("map_fn_size:" + map_fn_size); System.out.println("map_num:" + map_num); for(String key : map_num.keySet()) { @@ -897,15 +920,19 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { try { ylId = "K-" + project.getProperty(prefix0); // t_bom.setValueAt("K-" + project.getProperty(prefix0), i, 5); - } catch (TCException e) { - // TODO Auto-generated catch block + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); } }else if(prefix0.equals(ztsvg)) { ylId = prefix0; - } - else { + }else if(isAdd) { + ylId = prefix0; + prefix0 = prefix0.substring(0, prefix0.length() - 4); + }else { + SimpleDateFormat sdf = new SimpleDateFormat("yyMM"); + String dateString = sdf.format(date); ylId = prefix0 + dateString; // t_bom.setValueAt(prefix0 + dateString, i, 5); } @@ -913,13 +940,15 @@ public class FactoryNoZYDialog2zt extends AbstractAIFDialog { if (map_fn_size.containsKey(prefix0)) { int numX = map_num_yl.get(prefix0); Integer integer = map_types_flow.get(prefix0); - String c = "%0"+integer+"d"; + String c = "%0" + integer + "d"; ylId = ylId + String.format(c, numX); +// System.out.println("ylId1==>" + ylId); // t_bom.setValueAt(String.format(c, numX), i, 6); - int numXx = numX+1; + int numXx = numX + 1; map_num_yl.put(prefix0, numXx); } ylId = KUtil.getRedText(ylId); +// System.out.println("ylId2==>" + ylId); this.t_bom.setValueAt(ylId, i, 7); } // n_assign.setEnabled(false); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/bean/FactoryNoBean.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/bean/FactoryNoBean.java index e622cb0..ce02aba 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/bean/FactoryNoBean.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/bean/FactoryNoBean.java @@ -1,19 +1,16 @@ package com.connor.chint.sap2.bean; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.POIUtil; -import com.connor.chint.sap2.util.ZYFactoryUtil; import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentFolder; import com.teamcenter.rac.kernel.TCComponentItemRevision; -import com.teamcenter.rac.kernel.TCException; public class FactoryNoBean { private TCComponentItemRevision rev; @@ -153,8 +150,8 @@ public class FactoryNoBean { public Object[] getDYCCRowData2() { String factoryID = ""; - String prefix = ""; - String flowNo = ""; +// String prefix = ""; +// String flowNo = ""; String temp; System.out.println("this.prefix:" + this.prefix); if (factoryIDs != null && factoryIDs.size() > 0) { @@ -171,7 +168,7 @@ public class FactoryNoBean { // 箱变 public Object[] getXBRowData() { String factoryID = ""; - String prefix = ""; +// String prefix = ""; String flowNo = ""; String temp; System.out.println("this.prefix:" + this.prefix); @@ -251,7 +248,7 @@ public class FactoryNoBean { KUtil.setByPass(true); AIFComponentContext[] childs = folder.getChildren(); int size = childs.length; - List factoryNos = new ArrayList<>(size); + List factoryNos = new ArrayList<>(); for (int i = 0; i < size; i++) { factoryNos.add((TCComponent) childs[i].getComponent()); } @@ -262,28 +259,28 @@ public class FactoryNoBean { @Override public int compare(TCComponent o1, TCComponent o2) { - // TODO Auto-generated method stub + // Auto-generated method stub try { String item_id1 = o1.getProperty("item_id"); String item_id2 = o2.getProperty("item_id"); return item_id1.compareTo(item_id2); - } catch (TCException e) { - // TODO Auto-generated catch block + } catch (Exception e) { + // Auto-generated catch block e.printStackTrace(); } return 0; } }); - // for(int i=0,len=factoryNos.size();i lists = new ArrayList(); + List lists = new ArrayList<>(); lists.add("20102"); lists.add("DX12011260004"); lists.add("DX32011260001");