From 1260a85868ccdd0bdd1965b7a3e728841e6224a9 Mon Sep 17 00:00:00 2001 From: zouxk Date: Wed, 18 Mar 2020 14:45:14 +0800 Subject: [PATCH] 3/18 --- .../jd/plm/action/WLTZReviseAction.java | 6 +- .../jd/plm/dialog/DocumentTemplate.java | 39 +++++ .../plm/dialog/EditClassificationDialog.java | 3 + .../jd/plm/form/SampleConfirmationForm.java | 161 ++++++++++++++++-- .../com/connor/jd/plm/table/MyCellEditor.java | 9 + .../connor/jd/plm/table/MyCellEditor2.java | 10 ++ 6 files changed, 214 insertions(+), 14 deletions(-) create mode 100644 com.connor.jd.plm/src/com/connor/jd/plm/dialog/DocumentTemplate.java diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java b/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java index ffcfac1..02ddfb6 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/action/WLTZReviseAction.java @@ -19,8 +19,6 @@ import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.ics.ICSProperty; import com.teamcenter.rac.util.MessageBox; -import cn.hutool.http.HttpUtil; - public class WLTZReviseAction extends AbstractAIFAction { private AbstractAIFApplication app; private TCSession session; @@ -51,7 +49,9 @@ public class WLTZReviseAction extends AbstractAIFAction { return; } TCComponentItem item = rev.getItem(); + session.getUserService().call("bs_bypass", new Object[] { true }); TCComponentItemRevision newRev = rev.saveAs(item.getNewRev()); + session.getUserService().call("bs_bypass", new Object[] { false }); TCComponentICO ico = rev.getClassificationObjects()[0]; ICSProperty[] oldICSProps = ico.getICSProperties(true); int[] ids = new int[oldICSProps.length]; @@ -88,7 +88,7 @@ public class WLTZReviseAction extends AbstractAIFAction { @Override public void run() { // TODO Auto-generated method stub - HttpUtil.post(URL, PARAMMAP); + cn.hutool.http.HttpUtil.post(URL, PARAMMAP); System.out.println("success"); } }).start(); diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/DocumentTemplate.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/DocumentTemplate.java new file mode 100644 index 0000000..60a256a --- /dev/null +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/DocumentTemplate.java @@ -0,0 +1,39 @@ +package com.connor.jd.plm.dialog; + +public class DocumentTemplate { + private String type;// 模板类型 + private String[] relation;// 数据集关系 + private String uid;// 模板uid + + public DocumentTemplate(String type, String uid, String[] relation) { + super(); + this.type = type; + this.relation = relation; + this.uid = uid; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String[] getRelation() { + return relation; + } + + public void setRelation(String[] relation) { + this.relation = relation; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + +} diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java index 372419d..76f3a88 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/dialog/EditClassificationDialog.java @@ -52,6 +52,9 @@ public class EditClassificationDialog extends AbstractAIFDialog { this.session = (TCSession) app.getSession(); this.myService = session.getClassificationService(); this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + System.out.println(target.getType()); + System.out.println(target instanceof TCComponentItemRevision ? "是" : "否"); + if (target instanceof TCComponentItemRevision) { try { initUI(); diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java index 7d8d4b5..dd0a7df 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/form/SampleConfirmationForm.java @@ -23,6 +23,7 @@ import java.util.Map.Entry; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JMenuItem; @@ -31,6 +32,7 @@ import javax.swing.JPopupMenu; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; import javax.swing.filechooser.FileFilter; import javax.swing.table.DefaultTableCellRenderer; @@ -86,6 +88,10 @@ public class SampleConfirmationForm extends AbstractRendering { private List disableEdit2; private JRadioPanel yssl; private JCheckPanel mqjd; + private JComboBox bpdj; + private JComboBox fl; + private JComboBox zt; + private JComboBox jued; private String[] colNames = { "jd2_no", "jd2_gg", "jd2_gg1", "jd2_gc", "jd2_gc1", "jd2_1", "jd2_2", "jd2_3", "jd2_4", "jd2_5", "jd2_6", "jd2_7", "jd2_8", "jd2_9", "jd2_10", "jd2_min", "jd2_max", "jd2_jg" }; private String[] colNames1 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", @@ -94,6 +100,7 @@ public class SampleConfirmationForm extends AbstractRendering { "jd2_ctq7", "jd2_ctq8" }; private String[] colNames3 = { "jd2_ctq1", "jd2_ctq2", "jd2_ctq3", "jd2_ctq4", "jd2_ctq5", "jd2_ctq6", "jd2_ctq7", "jd2_ctq8" }; + private Map jgItems = new HashMap(); private JMenuItem addP; private JMenuItem delP; private JMenuItem addR; @@ -102,6 +109,7 @@ public class SampleConfirmationForm extends AbstractRendering { private JMenuItem addR2; private JMenuItem insertR2; private JMenuItem delR2; + private TCComponentItemRevision rev; public SampleConfirmationForm(TCComponent arg0) throws Exception { super(arg0); @@ -115,9 +123,17 @@ public class SampleConfirmationForm extends AbstractRendering { @Override public void loadRendering() throws TCException { + jgItems.put("合格", "0"); + jgItems.put("拒绝", "1"); + jgItems.put("保留", "2"); + jgItems.put("更改图纸", "3"); + AIFComponentContext[] ref = form.whereReferenced(); + rev = (TCComponentItemRevision) ref[0].getComponent(); + setLayout(new BorderLayout()); JPanel root = new JPanel(new BorderLayout()); root.setPreferredSize(new Dimension(800, 600)); + root.setBorder(new EmptyBorder(0, 0, 0, 25)); // 头部 JPanel buttons = new JPanel(new FlowLayout(FlowLayout.LEFT)); JButton confirm = new JButton("样品确认单"); @@ -173,6 +189,9 @@ public class SampleConfirmationForm extends AbstractRendering { if (value instanceof JPanel) { return (JPanel) value; } + if (value instanceof JComboBox) { + return (JComboBox) value; + } int maxPreferredHeight = 0; for (int i = 0; i < table.getColumnCount(); i++) { @@ -237,6 +256,9 @@ public class SampleConfirmationForm extends AbstractRendering { if (value instanceof JLabel) { return (JLabel) value; } + if (value instanceof JComboBox) { + return (JComboBox) value; + } int maxPreferredHeight = 0; for (int i = 0; i < table.getColumnCount(); i++) { @@ -348,6 +370,7 @@ public class SampleConfirmationForm extends AbstractRendering { if (prop.containsKey("jd2_ypqrdtable")) { String[][] tableRows = TCTableUtil.getTableRows(form, "jd2_ypqrdtable", colNames); System.out.println(Arrays.deepToString(tableRows)); + for (int i = 0; i < tableRows.length; i++) { for (int ii = 0; ii < tableRows[0].length; ii++) { if (i + top + 2 > bottom) { @@ -357,7 +380,16 @@ public class SampleConfirmationForm extends AbstractRendering { model.combine(new int[] { bottom }, new int[] { 2, 3, 4 }); bottom = model.getRowCount() - end; } - model.setValueAt(tableRows[i][ii], i + top + 2, ii > 2 ? ii + 2 : ii); + if (ii == tableRows[0].length - 1) { + JComboBox jgComBox = new JComboBox(); + for (Entry entry : jgItems.entrySet()) { + jgComBox.addItem(entry.getKey()); + } + jgComBox.setSelectedItem(tableRows[i][ii]); + model.setValueAt(jgComBox, i + top + 2, ii + 2); + } else { + model.setValueAt(tableRows[i][ii], i + top + 2, ii > 2 ? ii + 2 : ii); + } } } } else { @@ -618,7 +650,18 @@ public class SampleConfirmationForm extends AbstractRendering { general.put("jd2_xh", new int[] { 6, 10 }); model.setValueAt("分类", 6, 14); disableEdit.add("6,14"); - general.put("jd2_fl", new int[] { 6, 17 }); + fl = new JComboBox(); + try { + String[] items = form.getTCProperty("jd2_fl").getLOV().getListOfValues().getLOVDisplayValues(); + for (String s : items) { + fl.addItem(s); + } + fl.setSelectedItem(form.getProperty("jd2_fl")); + model.setValueAt(fl, 6, 17); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } model.setValueAt("物料编码", 7, 0); disableEdit.add("7,0"); general.put("jd2_wlbm", new int[] { 7, 2 }); @@ -628,10 +671,32 @@ public class SampleConfirmationForm extends AbstractRendering { model.setValueAt(yssl, 7, 10); model.setValueAt("状态", 7, 14); disableEdit.add("7,14"); - general.put("jd2_zt", new int[] { 7, 17 }); + zt = new JComboBox(); + try { + String[] items = form.getTCProperty("jd2_zt").getLOV().getListOfValues().getLOVDisplayValues(); + for (String s : items) { + zt.addItem(s); + } + zt.setSelectedItem(form.getProperty("jd2_zt")); + model.setValueAt(zt, 7, 17); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } model.setValueAt("部品等级", 8, 0); disableEdit.add("8,0"); - general.put("jd2_bpdj", new int[] { 8, 2 }); + bpdj = new JComboBox(); + try { + String[] items = form.getTCProperty("jd2_bpdj").getLOV().getListOfValues().getLOVDisplayValues(); + for (String s : items) { + bpdj.addItem(s); + } + bpdj.setSelectedItem(form.getProperty("jd2_bpdj")); + model.setValueAt(bpdj, 8, 2); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } model.setValueAt("参考物料", 8, 8); disableEdit.add("8,8"); model.setValueAt("jd2_ckwl", 8, 10); @@ -678,6 +743,11 @@ public class SampleConfirmationForm extends AbstractRendering { model.setValueAt(i - 1 - top, i, 0); disableEdit.add(i + ",0"); model.combine(new int[] { i }, new int[] { 2, 3, 4 }); + JComboBox jgComBox = new JComboBox(); + for (Entry entry : jgItems.entrySet()) { + jgComBox.addItem(entry.getKey()); + } + model.setValueAt(jgComBox, i, model.getColumnCount() - 1); } model.combine(new int[] { 0, 1 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); @@ -800,7 +870,18 @@ public class SampleConfirmationForm extends AbstractRendering { pic.put("jd2_icqjyzds", new int[] { 10, 4 }); model3.setValueAt("决定", 11, 12); disableEdit3.add(11 + ",12"); - general3.put("jd2_jued", new int[] { 11, 15 }); + jued = new JComboBox(); + try { + String[] items = form.getTCProperty("jd2_jued").getLOV().getListOfValues().getLOVDisplayValues(); + for (String s : items) { + jued.addItem(s); + } + jued.setSelectedItem(form.getProperty("jd2_jued")); + model3.setValueAt(jued, 11, 15); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } pic.put("jd2_qtbg", new int[] { 9, 7 }); model3.combine(new int[] { 0 }, new int[] { 0, 1, 2, 3, 4, 5 }); @@ -873,6 +954,34 @@ public class SampleConfirmationForm extends AbstractRendering { } form.setProperty("jd2_mqjd", value); } + if (prop.containsKey("jd2_bpdj")) { + String value = bpdj.getSelectedItem() == null ? "" : bpdj.getSelectedItem().toString(); + if (form.getTCProperty("jd2_bpdj").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_bpdj").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_bpdj", value); + } + if (prop.containsKey("jd2_fl")) { + String value = fl.getSelectedItem() == null ? "" : fl.getSelectedItem().toString(); + if (form.getTCProperty("jd2_fl").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_fl").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_fl", value); + } + if (prop.containsKey("jd2_zt")) { + String value = zt.getSelectedItem() == null ? "" : zt.getSelectedItem().toString(); + if (form.getTCProperty("jd2_zt").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_zt").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_zt", value); + } + if (prop.containsKey("jd2_jued")) { + String value = jued.getSelectedItem() == null ? "" : jued.getSelectedItem().toString(); + if (form.getTCProperty("jd2_jued").getLOV() != null && !"".equals(value)) { + value = (String) form.getTCProperty("jd2_jued").getLOV().getListOfValues().getRealValue(value); + } + form.setProperty("jd2_jued", value); + } } catch (TCException e) { // TODO Auto-generated catch block @@ -919,10 +1028,11 @@ public class SampleConfirmationForm extends AbstractRendering { String[] row = new String[18]; for (int ii = 0; ii < row.length; ii++) { Object object = model.getValueAt(top + 2 + num, ii > 2 ? ii + 2 : ii); - if (object == null) { - row[ii] = ""; + if (ii == row.length - 1) { + object = ((JComboBox) object).getSelectedItem(); + row[ii] = object == null ? "" : jgItems.get(object.toString()); } else { - row[ii] = object.toString(); + row[ii] = object == null ? "" : object.toString(); } } data.add(row); @@ -1123,14 +1233,23 @@ public class SampleConfirmationForm extends AbstractRendering { TCComponentDataset dataset = datasetType.create(file.getName(), "", "Image"); dataset.setFiles(as1, as2); TCComponent[] comps = form.getRelatedComponents(); - AIFComponentContext[] ref = form.whereReferenced(); - TCComponentItemRevision rev = (TCComponentItemRevision) ref[0].getComponent(); rev.add("IMAN_specification", dataset); String uid = dataset.getUid(); System.out.println("uid:" + uid); ImageIcon icon = new ImageIcon(file.getPath()); int row = table3.getSelectedRow(); int col = table3.getSelectedColumn(); + String str = ((JLabel) model3.getValueAt(row, col)).getToolTipText(); + if (str != null && !"".equals(str)) { + try { + TCComponentDataset oldDataset = (TCComponentDataset) session.stringToComponent(str); + rev.cutOperation("IMAN_specification", new TCComponent[] { oldDataset }); + oldDataset.delete(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } int[] arr = model3.getSpan(row, col); System.out.println("row:" + arr[0] + ",col:" + arr[1]); icon.setImage(icon.getImage().getScaledInstance( @@ -1142,6 +1261,8 @@ public class SampleConfirmationForm extends AbstractRendering { label.addMouseListener(showImg(file.getPath())); label.setToolTipText(uid); model3.setValueAt(label, table3.getSelectedRow(), table3.getSelectedColumn()); + table3.revalidate(); + table3.repaint(); } catch (TCException e1) { // TODO Auto-generated catch block e1.printStackTrace(); @@ -1161,7 +1282,20 @@ public class SampleConfirmationForm extends AbstractRendering { // TODO Auto-generated method stub int row = table3.getSelectedRow(); int col = table3.getSelectedColumn(); + String uid = ((JLabel) model3.getValueAt(row, col)).getToolTipText(); + if (uid != null && !"".equals(uid)) { + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(uid); + rev.cutOperation("IMAN_specification", new TCComponent[] { dataset }); + dataset.delete(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } model3.setValueAt(new JLabel(""), row, col); + table3.revalidate(); + table3.repaint(); } }; @@ -1183,7 +1317,6 @@ public class SampleConfirmationForm extends AbstractRendering { // initModel(); table.revalidate(); table.repaint(); - } }; return actionListener; @@ -1199,6 +1332,8 @@ public class SampleConfirmationForm extends AbstractRendering { model2.insertRow(++bottom2); model2.setValueAt(num + 1, bottom2, 0); model2.combine(new int[] { bottom2 }, new int[] { 0, 1 }); + table2.revalidate(); + table2.repaint(); } }; return actionListener; @@ -1242,6 +1377,8 @@ public class SampleConfirmationForm extends AbstractRendering { model2.setValueAt(num + i - row, i, 0); } model2.combine(new int[] { row }, new int[] { 0, 1 }); + table2.revalidate(); + table2.repaint(); } }; return actionListener; @@ -1287,6 +1424,8 @@ public class SampleConfirmationForm extends AbstractRendering { model2.setValueAt(num + i - row, i, 0); } } + table2.revalidate(); + table2.repaint(); } }; return actionListener; diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java index badae70..241a37f 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor.java @@ -3,6 +3,7 @@ package com.connor.jd.plm.table; import java.awt.Component; import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; import javax.swing.JTable; import javax.swing.JTextField; @@ -11,6 +12,7 @@ import com.teamcenter.rac.util.MessageBox; public class MyCellEditor extends DefaultCellEditor { private JRadioPanel radio = null; private JCheckPanel check = null; + private JComboBox comboBox = null; private int type = -1; private int row; private int col; @@ -42,6 +44,10 @@ public class MyCellEditor extends DefaultCellEditor { check = (JCheckPanel) value; type = 2; return check; + } else if (value instanceof JComboBox) { + comboBox = (JComboBox) value; + type = 3; + return comboBox; } this.row = row; this.col = column; @@ -59,6 +65,9 @@ public class MyCellEditor extends DefaultCellEditor { if (type == 2) { return check; } + if (type == 3) { + return comboBox; + } Object obj = super.getCellEditorValue(); if (obj != null && !"".equals(obj.toString().trim()) && row >= top && row <= bottom && col >= 7 diff --git a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java index c4774b3..ccdef61 100644 --- a/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java +++ b/com.connor.jd.plm/src/com/connor/jd/plm/table/MyCellEditor2.java @@ -3,12 +3,14 @@ package com.connor.jd.plm.table; import java.awt.Component; import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.JTextField; public class MyCellEditor2 extends DefaultCellEditor { private JLabel img = null; + private JComboBox jued = null; private int type = -1; public MyCellEditor2(JTextField var1) { @@ -23,6 +25,11 @@ public class MyCellEditor2 extends DefaultCellEditor { type = 1; return img; } + if (value instanceof JComboBox) { + jued = (JComboBox) value; + type = 2; + return jued; + } type = 0; return super.getTableCellEditorComponent(table, value, isSelected, row, column); } @@ -32,6 +39,9 @@ public class MyCellEditor2 extends DefaultCellEditor { if (type == 1) { return img; } + if (type == 2) { + return jued; + } return super.getCellEditorValue(); }