commit 7a9a6378aeef8492ef77f28643089d467310c322 Author: xuezhou Date: Sat Mar 1 17:22:02 2025 +0800 1.自动匹配工具初始化 diff --git a/Mannual+Tool-2024-11-21 手动工具.xlsx b/Mannual+Tool-2024-11-21 手动工具.xlsx new file mode 100644 index 0000000..46c5d9e Binary files /dev/null and b/Mannual+Tool-2024-11-21 手动工具.xlsx differ diff --git a/com.sq.customization/.classpath b/com.sq.customization/.classpath new file mode 100644 index 0000000..eca7bdb --- /dev/null +++ b/com.sq.customization/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/com.sq.customization/.project b/com.sq.customization/.project new file mode 100644 index 0000000..db6d142 --- /dev/null +++ b/com.sq.customization/.project @@ -0,0 +1,28 @@ + + + com.sq.customization + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/com.sq.customization/.settings/org.eclipse.core.resources.prefs b/com.sq.customization/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/com.sq.customization/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/com.sq.customization/.settings/org.eclipse.jdt.core.prefs b/com.sq.customization/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..9f6ece8 --- /dev/null +++ b/com.sq.customization/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/com.sq.customization/META-INF/MANIFEST.MF b/com.sq.customization/META-INF/MANIFEST.MF new file mode 100644 index 0000000..7694063 --- /dev/null +++ b/com.sq.customization/META-INF/MANIFEST.MF @@ -0,0 +1,26 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Customization +Bundle-SymbolicName: com.sq.customization;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: com.sq.customization.Activator +Bundle-Vendor: SQ +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.aifrcp;bundle-version="13000.3.0", + com.teamcenter.rac.common;bundle-version="13000.3.0", + com.teamcenter.rac.external;bundle-version="13000.3.0", + com.teamcenter.rac.kernel;bundle-version="13000.3.0", + com.teamcenter.rac.pca;bundle-version="13000.3.0", + com.teamcenter.rac.pse;bundle-version="13000.3.0", + com.teamcenter.rac.tcapps;bundle-version="13000.3.0", + com.teamcenter.rac.ui;bundle-version="13000.3.0", + com.teamcenter.rac.ui.views;bundle-version="13000.3.0", + com.teamcenter.rac.util;bundle-version="13000.3.0", + com.teamcenter.rac.pca.kernel;bundle-version="13000.3.0", + com.teamcenter.rac.pse.pca;bundle-version="13000.3.0", + com.teamcenter.rac.cme.kernel;bundle-version="13000.3.0", + org.apache.poi.39;bundle-version="3.9.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Automatic-Module-Name: com.sq.customization +Bundle-ActivationPolicy: lazy diff --git a/com.sq.customization/bin/com/sq/customization/Activator.class b/com.sq.customization/bin/com/sq/customization/Activator.class new file mode 100644 index 0000000..774933e Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/Activator.class differ diff --git a/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$1.class b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$1.class new file mode 100644 index 0000000..a4fa2ac Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$1.class differ diff --git a/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$2.class b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$2.class new file mode 100644 index 0000000..3c019a2 Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$2.class differ diff --git a/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$3$1.class b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$3$1.class new file mode 100644 index 0000000..525df8c Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$3$1.class differ diff --git a/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$3.class b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$3.class new file mode 100644 index 0000000..5e164d0 Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog$3.class differ diff --git a/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog.class b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog.class new file mode 100644 index 0000000..e3b1902 Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/dialogs/AutoTransToolDialog.class differ diff --git a/com.sq.customization/bin/com/sq/customization/dialogs/dialogs.properties b/com.sq.customization/bin/com/sq/customization/dialogs/dialogs.properties new file mode 100644 index 0000000..9304f61 --- /dev/null +++ b/com.sq.customization/bin/com/sq/customization/dialogs/dialogs.properties @@ -0,0 +1,5 @@ +RuleInheritanceDialog.sourcelabel=Source configuration object: +RuleInheritanceDialog.targetlabel=The target configuration object: +RuleInheritanceDialog.handoffbutton=Toggle the source and target +RuleInheritanceDialog.okbutton=OK +RuleInheritanceDialog.cancelbutton=Cancel \ No newline at end of file diff --git a/com.sq.customization/bin/com/sq/customization/dialogs/dialogs_locale_zh_CN.properties b/com.sq.customization/bin/com/sq/customization/dialogs/dialogs_locale_zh_CN.properties new file mode 100644 index 0000000..94fe566 --- /dev/null +++ b/com.sq.customization/bin/com/sq/customization/dialogs/dialogs_locale_zh_CN.properties @@ -0,0 +1,5 @@ +RuleInheritanceDialog.sourcelabel=\u6E90\u914D\u7F6E\u5BF9\u8C61\uFF1A +RuleInheritanceDialog.targetlabel=\u76EE\u6807\u914D\u7F6E\u5BF9\u8C61\uFF1A +RuleInheritanceDialog.handoffbutton=\u5207\u6362\u6E90\u4E0E\u76EE\u6807 +RuleInheritanceDialog.okbutton=\u786E\u5B9A +RuleInheritanceDialog.cancelbutton=\u53D6\u6D88 \ No newline at end of file diff --git a/com.sq.customization/bin/com/sq/customization/handlers/SampleHandler.class b/com.sq.customization/bin/com/sq/customization/handlers/SampleHandler.class new file mode 100644 index 0000000..0d3aaa0 Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/handlers/SampleHandler.class differ diff --git a/com.sq.customization/bin/com/sq/customization/handlers/handlers.properties b/com.sq.customization/bin/com/sq/customization/handlers/handlers.properties new file mode 100644 index 0000000..6796b84 --- /dev/null +++ b/com.sq.customization/bin/com/sq/customization/handlers/handlers.properties @@ -0,0 +1,2 @@ +BOPInitHandler.selecterror=Please select a Mfg0MEPlantBOPRevision\Mfg0MEProcLineRevision\Mfg0MEProcStatnRevision object + diff --git a/com.sq.customization/bin/com/sq/customization/handlers/handlers_locale_zh_CN.properties b/com.sq.customization/bin/com/sq/customization/handlers/handlers_locale_zh_CN.properties new file mode 100644 index 0000000..5739744 --- /dev/null +++ b/com.sq.customization/bin/com/sq/customization/handlers/handlers_locale_zh_CN.properties @@ -0,0 +1,2 @@ +BOPInitHandler.selecterror=\u8BF7\u9009\u62E9\u5BF9\u8C61\u4E3A\u6574\u8F66\uFF0C\u4EA7\u7EBF\uFF0C\u5DE5\u4F4D\uFF0C + diff --git a/com.sq.customization/bin/com/sq/customization/util/ExcelUtil.class b/com.sq.customization/bin/com/sq/customization/util/ExcelUtil.class new file mode 100644 index 0000000..cc8d028 Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/util/ExcelUtil.class differ diff --git a/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$1.class b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$1.class new file mode 100644 index 0000000..b0b1bc4 Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$1.class differ diff --git a/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$2.class b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$2.class new file mode 100644 index 0000000..fbe7ed7 Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$2.class differ diff --git a/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$3.class b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$3.class new file mode 100644 index 0000000..d876bd8 Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$3.class differ diff --git a/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$4.class b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$4.class new file mode 100644 index 0000000..a1415cb Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog$4.class differ diff --git a/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog.class b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog.class new file mode 100644 index 0000000..7465c7f Binary files /dev/null and b/com.sq.customization/bin/com/sq/customization/util/ProgressCustomDialog.class differ diff --git a/com.sq.customization/build.properties b/com.sq.customization/build.properties new file mode 100644 index 0000000..f3f7e80 --- /dev/null +++ b/com.sq.customization/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +javacDefaultEncoding.. = UTF-8 +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/ diff --git a/com.sq.customization/icons/sample.png b/com.sq.customization/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/com.sq.customization/icons/sample.png differ diff --git a/com.sq.customization/icons/sample@2x.png b/com.sq.customization/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/com.sq.customization/icons/sample@2x.png differ diff --git a/com.sq.customization/plugin.xml b/com.sq.customization/plugin.xml new file mode 100644 index 0000000..8d27746 --- /dev/null +++ b/com.sq.customization/plugin.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.sq.customization/src/com/sq/customization/Activator.java b/com.sq.customization/src/com/sq/customization/Activator.java new file mode 100644 index 0000000..f630c51 --- /dev/null +++ b/com.sq.customization/src/com/sq/customization/Activator.java @@ -0,0 +1,44 @@ +package com.sq.customization; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.sq.customization"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/com.sq.customization/src/com/sq/customization/dialogs/AutoTransToolDialog.java b/com.sq.customization/src/com/sq/customization/dialogs/AutoTransToolDialog.java new file mode 100644 index 0000000..f035151 --- /dev/null +++ b/com.sq.customization/src/com/sq/customization/dialogs/AutoTransToolDialog.java @@ -0,0 +1,410 @@ +package com.sq.customization.dialogs; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.filechooser.FileNameExtensionFilter; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.sq.customization.util.ExcelUtil; +import com.sq.customization.util.ProgressCustomDialog; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrOperation; +import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrPart; +import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrPlantBOP; +import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrProcessLine; +import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrProcessStation; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.PropertyTextField; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; + +public class AutoTransToolDialog extends AbstractAIFDialog { + + private PropertyTextField text; + private PropertyTextField idtext; + private PropertyTextField svppstext; + private PropertyTextField FCCtext; + private PropertyTextField FCCDEStext; + private PropertyTextField dongtaitext; + private PropertyTextField KCDStext; + private JButton ok; + private JButton cancel; + private JButton directory; + + private Registry registry = Registry.getRegistry(AutoTransToolDialog.class); + private TCSession session; + private InterfaceAIFComponent target; + Map no_load = new HashMap<>(); + Map op_nodesignmap = new HashMap<>(); + public AutoTransToolDialog(Frame fm,InterfaceAIFComponent target) { + super(fm); + this.target = target; + op_nodesignmap.clear(); + no_load.clear(); + init(); + } + private void init() { + this.setTitle("自动匹配替换工具"); + this.setPreferredSize(new Dimension(500,400)); + this.centerToScreen(); + this.setLayout(new BorderLayout()); + JPanel northPane = new JPanel(new PropertyLayout(10,10,5,5,10,10)); + + northPane.add("1.1.left",new JLabel("零件号:")); + idtext = new PropertyTextField(); + idtext.setColumns(30); + idtext.setRequired(true); + northPane.add("1.2",idtext); + + northPane.add("2.1.left",new JLabel("短SVPPS:")); + svppstext = new PropertyTextField(); + svppstext.setColumns(30); + svppstext.setRequired(true); + northPane.add("2.2",svppstext); + + northPane.add("3.1.left",new JLabel("FCC:")); + FCCtext = new PropertyTextField(); + FCCtext.setColumns(30); + FCCtext.setRequired(true); + northPane.add("3.2",FCCtext); + + northPane.add("4.1.left",new JLabel("FFC中文描述:")); + FCCDEStext = new PropertyTextField(); + FCCDEStext.setColumns(30); + FCCDEStext.setRequired(true); + northPane.add("4.2",FCCDEStext); + + northPane.add("5.1.left",new JLabel("动态扭矩:")); + dongtaitext = new PropertyTextField(); + dongtaitext.setColumns(30); + dongtaitext.setRequired(true); + northPane.add("5.2",dongtaitext); + + northPane.add("6.1.left",new JLabel("KCDS:")); + KCDStext = new PropertyTextField(); + KCDStext.setColumns(30); + KCDStext.setRequired(true); + northPane.add("6.2",KCDStext); + + + northPane.add("7.1.left",new JLabel("数据文件:")); + text = new PropertyTextField(); + text.setColumns(30); + text.setRequired(true); + text.setEnabled(false); + northPane.add("7.2",text); + + directory = new JButton("..."); + northPane.add("7.3",directory); + + JPanel southpanel = new JPanel(new ButtonLayout()); + ok = new JButton("确定"); + cancel = new JButton("取消"); + southpanel.add(ok); + southpanel.add(cancel); + this.add(BorderLayout.CENTER,northPane); + this.add(BorderLayout.SOUTH,southpanel); + this.setVisible(true); + + cancel.addActionListener(new ActionListener(){ + + @Override + public void actionPerformed(ActionEvent e) { + AutoTransToolDialog.this.dispose(); + }}); + directory.addActionListener(new ActionListener(){ + + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser filechooser = new JFileChooser(); + filechooser.setFileSelectionMode(2); + FileNameExtensionFilter filter = new FileNameExtensionFilter( + "所有Excel文件(*.xlsx)", new String[] { "xlsx" }); + filechooser.setFileFilter(filter); + int r = filechooser.showDialog(null, "选择"); + if (r == 0) { + text.setText(filechooser.getSelectedFile().getAbsolutePath()); + if (text.getText() != "") + ok.setEnabled(true); + else + ok.setEnabled(false); + } + else if (r == 1) { + text.setText(""); + ok.setEnabled(false); + } + }}); + ok.addActionListener(new ActionListener(){ + + @Override + public void actionPerformed(ActionEvent e) { + String path = text.getText(); + if( path != null && path.length() > 0) { + String idcol = idtext.getText(); + String svppscol = svppstext.getText(); + String fcccol = FCCtext.getText(); + String fccdescol = FCCDEStext.getText(); + String dongtaicol = dongtaitext.getText(); + String kcdscol = KCDStext.getText(); + File excel = new File(path); + if(!excel.exists()) { + MessageBox.post(AutoTransToolDialog.this,"文件路径不存在", "Message", MessageBox.INFORMATION); + return; + } + if(isValidExcelColumn(idcol) && isValidExcelColumn(svppscol) && isValidExcelColumn(fcccol) + && isValidExcelColumn(fccdescol) && isValidExcelColumn(dongtaicol) && isValidExcelColumn(kcdscol)) { + op_nodesignmap.clear(); + no_load.clear(); + int idcol2 = columnToNumber(idcol.toUpperCase()); + int svppscol2 = columnToNumber(svppscol.toUpperCase()); + int fcccol2 = columnToNumber(fcccol.toUpperCase()); + int fccdescol2 = columnToNumber(fccdescol.toUpperCase()); + int dongtaicol2 = columnToNumber(dongtaicol.toUpperCase()); + int kcdscol2 = columnToNumber(kcdscol.toUpperCase()); + try { + //读取EXCEL + + //先处理选中对象层级有design的工序,获取没有design的工序 + opBOMLineData(target); + if(op_nodesignmap.size() > 0) { + TCComponentBOMLine parent = null; + + if(target instanceof TCComponentMfgBvrProcessStation) { + TCComponentMfgBvrProcessStation station = (TCComponentMfgBvrProcessStation) target; + String id = station.getProperty("bl_item_item_id"); + no_load.put(id, id); + parent = station.parent(); + } + else if(target instanceof TCComponentMfgBvrPlantBOP) { + TCComponentMfgBvrPlantBOP plant = (TCComponentMfgBvrPlantBOP) target; + String id = plant.getProperty("bl_item_item_id"); + no_load.put(id, id); + parent = plant.parent(); + } + else if(target instanceof TCComponentMfgBvrProcessLine) { + TCComponentMfgBvrProcessLine line = (TCComponentMfgBvrProcessLine) target; + String id = line.getProperty("bl_item_item_id"); + no_load.put(id, id); + parent = line.parent(); + } + if(parent != null) { + System.out.println(parent.getClass()+parent.getProperty("bl_indented_title")); + getparent(parent); + } + if(op_nodesignmap.size() > 0) { + System.out.println("整个结构没有匹配的紧固件"); + } + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + AutoTransToolDialog.this.dispose(); + } + else { + MessageBox.post(AutoTransToolDialog.this,"请填写正确的列,比如A,B,C..", "Message", MessageBox.INFORMATION); + + } + Thread thread = new Thread(){ + public void run(){ + ProgressCustomDialog.lbStatus.setText("正在创建 ...."); + + + } + }; + ProgressCustomDialog.show(thread, "执行中", null, null, null); + //session.queueOperation(operation); + + } + else { + MessageBox.post(AutoTransToolDialog.this,"请选择文件", "Message", MessageBox.INFORMATION); + } + + }}); + } + public static int columnToNumber(String column) { + int result = 0; + for (int i = 0; i < column.length(); i++) { + char c = column.charAt(i); + result = result * 26 + (c - 'A' + 1); // 将字母转换为数字 + } + return result; + } + // 判断列名是否符合A-Z, AA, AB等格式,不区分大小写 + public static boolean isValidExcelColumn(String column) { + // 将输入字符串转为大写字母并匹配正则表达式 + return column != null && column.toUpperCase().matches("[A-Z]+"); + } + //先处理选中对象层级有design的工序 + private void opBOMLineData(InterfaceAIFComponent parent) throws Exception { + AIFComponentContext[] children = parent.getChildren(); + for(AIFComponentContext child:children) { + InterfaceAIFComponent childcom = child.getComponent(); + if(childcom instanceof TCComponentMfgBvrOperation) { + + TCComponentMfgBvrOperation op = (TCComponentMfgBvrOperation) childcom; + String bl_rev_object_name = op.getProperty("bl_rev_object_name"); + if(bl_rev_object_name.contains("预紧") || bl_rev_object_name.contains("终紧") + || bl_rev_object_name.contains("紧固")|| bl_rev_object_name.contains("拧紧") + || bl_rev_object_name.contains("接地")|| bl_rev_object_name.contains("搭铁")) { + + AIFComponentContext[] design_children = op.getChildren(); + boolean hasdesign = false; + for(AIFComponentContext designchild:design_children) { + InterfaceAIFComponent designchildcom = designchild.getComponent(); + if(designchildcom instanceof TCComponentMfgBvrPart) { + hasdesign = true; + //获取design + + } + } + if(!hasdesign) { + bl_rev_object_name = bl_rev_object_name.replaceAll("预紧", ""); + bl_rev_object_name = bl_rev_object_name.replaceAll("终紧", ""); + bl_rev_object_name = bl_rev_object_name.replaceAll("紧固", ""); + bl_rev_object_name = bl_rev_object_name.replaceAll("拧紧", ""); +// String bl_item_item_id = op.getProperty("bl_item_item_id"); + op_nodesignmap.put(bl_rev_object_name, op); + + } + } + // + } + else if(childcom instanceof TCComponentMfgBvrProcessStation || childcom instanceof TCComponentMfgBvrProcessLine + || childcom instanceof TCComponentMfgBvrPlantBOP) { + opBOMLineData(childcom); + } + + } + } + + /** + * no_load:已经加载过的数据id下次就不加载了 + * */ + private void getparent(TCComponentBOMLine parent)throws Exception{ + + if(op_nodesignmap.size() > 0) { + String parentid = parent.getProperty("bl_item_item_id"); + AIFComponentContext[] children = parent.getChildren(); + for (AIFComponentContext child : children) { + InterfaceAIFComponent childcom = child.getComponent(); + String id = childcom.getProperty("bl_item_item_id"); + if(op_nodesignmap.size() == 0) { + break; + } + if(no_load.containsKey(id)) { + continue; + } + if(childcom instanceof TCComponentMfgBvrOperation) { + + TCComponentMfgBvrOperation op = (TCComponentMfgBvrOperation) childcom; + final String bl_rev_object_name = op.getProperty("bl_rev_object_name"); + Set keys = op_nodesignmap.keySet(); + boolean found = false; + String haskey = ""; + for (String key : keys) { + if (bl_rev_object_name.contains(key)) { + found = true; + haskey = key; + break; // 一旦找到了就退出循环 + } + } + if(found) { + AIFComponentContext[] design_children = op.getChildren(); + boolean hasdesign = false; + for(AIFComponentContext designchild:design_children) { + InterfaceAIFComponent designchildcom = designchild.getComponent(); + if(designchildcom instanceof TCComponentMfgBvrPart) { + hasdesign = true; + //获取design + + } + } + if(hasdesign) { + op_nodesignmap.remove(haskey); + + } + } + + } + else if(childcom instanceof TCComponentMfgBvrProcessStation || childcom instanceof TCComponentMfgBvrProcessLine + || childcom instanceof TCComponentMfgBvrPlantBOP) { + + getparent((TCComponentBOMLine)childcom); + + } + if(op_nodesignmap.size() > 0) { + no_load.put(id, id); + } + else { + break; + } + } + // + if(op_nodesignmap.size() > 0) { + no_load.put(parentid, parentid); + if(parent.parent() != null) + getparent(parent.parent()); + } + } + } + + + private void readExcel(File excelfile,int start_rownum,int idcol2,int svppscol2,int fcccol2 + ,int fccdescol2,int dongtaicol,int kcdscol2) { + Workbook work = null; + try(InputStream is = new FileInputStream(excelfile);){ + if (excelfile.getAbsolutePath().endsWith(".xls")) + work = new HSSFWorkbook(is); + else { + work = new XSSFWorkbook(is); + } + Sheet sheet = work.getSheetAt(0); + int count = sheet.getPhysicalNumberOfRows(); + for(int i = start_rownum; i < count ;i++) { + Row row = sheet.getRow(i); + String id = ExcelUtil.getStringCellValue(row.getCell(idcol2-1)); + String svpps = ExcelUtil.getStringCellValue(row.getCell(svppscol2-1)); + String fcc = ExcelUtil.getStringCellValue(row.getCell(fcccol2-1)); + String fccdes = ExcelUtil.getStringCellValue(row.getCell(fccdescol2-1)); + String dongtai = ExcelUtil.getStringCellValue(row.getCell(dongtaicol-1)); + String kcds = ExcelUtil.getStringCellValue(row.getCell(kcdscol2-1)); + System.out.println("id:"+id+" svpps:"+svpps+" fcc:"+fcc+" fccdes:"+fccdes+" dongtai:"+dongtai+" kcds:"+kcds); + + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/com.sq.customization/src/com/sq/customization/dialogs/dialogs.properties b/com.sq.customization/src/com/sq/customization/dialogs/dialogs.properties new file mode 100644 index 0000000..9304f61 --- /dev/null +++ b/com.sq.customization/src/com/sq/customization/dialogs/dialogs.properties @@ -0,0 +1,5 @@ +RuleInheritanceDialog.sourcelabel=Source configuration object: +RuleInheritanceDialog.targetlabel=The target configuration object: +RuleInheritanceDialog.handoffbutton=Toggle the source and target +RuleInheritanceDialog.okbutton=OK +RuleInheritanceDialog.cancelbutton=Cancel \ No newline at end of file diff --git a/com.sq.customization/src/com/sq/customization/dialogs/dialogs_locale_zh_CN.properties b/com.sq.customization/src/com/sq/customization/dialogs/dialogs_locale_zh_CN.properties new file mode 100644 index 0000000..94fe566 --- /dev/null +++ b/com.sq.customization/src/com/sq/customization/dialogs/dialogs_locale_zh_CN.properties @@ -0,0 +1,5 @@ +RuleInheritanceDialog.sourcelabel=\u6E90\u914D\u7F6E\u5BF9\u8C61\uFF1A +RuleInheritanceDialog.targetlabel=\u76EE\u6807\u914D\u7F6E\u5BF9\u8C61\uFF1A +RuleInheritanceDialog.handoffbutton=\u5207\u6362\u6E90\u4E0E\u76EE\u6807 +RuleInheritanceDialog.okbutton=\u786E\u5B9A +RuleInheritanceDialog.cancelbutton=\u53D6\u6D88 \ No newline at end of file diff --git a/com.sq.customization/src/com/sq/customization/handlers/SampleHandler.java b/com.sq.customization/src/com/sq/customization/handlers/SampleHandler.java new file mode 100644 index 0000000..3efc33e --- /dev/null +++ b/com.sq.customization/src/com/sq/customization/handlers/SampleHandler.java @@ -0,0 +1,56 @@ +package com.sq.customization.handlers; + + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.sq.customization.dialogs.AutoTransToolDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrPlantBOP; +import com.teamcenter.rac.kernel.TCComponentMECfgLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; + + +public class SampleHandler extends AbstractHandler { + private AbstractAIFUIApplication app; + private TCSession session; +// private Registry registry = Registry.getRegistry(SampleHandler.class); + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + InterfaceAIFComponent[] target = app.getTargetComponents(); + + + +// if(target == null || target.length != 1) { +// MessageBox.post(app.getDesktop(),registry.getString("BOPInitHandler.selecterror"), "Message", MessageBox.INFORMATION); +// return null; +// } + System.out.println(target[0].getType()); + System.out.println(target[0].getClass()); + if("Mfg0BvrPlantBOP".equals(target[0].getType()) || "Mfg0BvrProcessLine".equals(target[0].getType()) || "Mfg0BvrProcessStation".equals(target[0].getType())) { + new AutoTransToolDialog(app.getDesktop(),target[0]); +// TCComponentMfgBvrPlantBOP targetline = (TCComponentMfgBvrPlantBOP) target[0]; +// try { +// AIFComponentContext[] comcontext = targetline.getChildren(); +// for(int i = 0; i < comcontext.length; i++) { +// System.out.println(comcontext[i].getComponent().getProperty("bl_indented_title")); +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + } + return null; + + + } +} diff --git a/com.sq.customization/src/com/sq/customization/handlers/handlers.properties b/com.sq.customization/src/com/sq/customization/handlers/handlers.properties new file mode 100644 index 0000000..6796b84 --- /dev/null +++ b/com.sq.customization/src/com/sq/customization/handlers/handlers.properties @@ -0,0 +1,2 @@ +BOPInitHandler.selecterror=Please select a Mfg0MEPlantBOPRevision\Mfg0MEProcLineRevision\Mfg0MEProcStatnRevision object + diff --git a/com.sq.customization/src/com/sq/customization/handlers/handlers_locale_zh_CN.properties b/com.sq.customization/src/com/sq/customization/handlers/handlers_locale_zh_CN.properties new file mode 100644 index 0000000..5739744 --- /dev/null +++ b/com.sq.customization/src/com/sq/customization/handlers/handlers_locale_zh_CN.properties @@ -0,0 +1,2 @@ +BOPInitHandler.selecterror=\u8BF7\u9009\u62E9\u5BF9\u8C61\u4E3A\u6574\u8F66\uFF0C\u4EA7\u7EBF\uFF0C\u5DE5\u4F4D\uFF0C + diff --git a/com.sq.customization/src/com/sq/customization/util/ExcelUtil.java b/com.sq.customization/src/com/sq/customization/util/ExcelUtil.java new file mode 100644 index 0000000..c4f1ce4 --- /dev/null +++ b/com.sq.customization/src/com/sq/customization/util/ExcelUtil.java @@ -0,0 +1,43 @@ +package com.sq.customization.util; + +import java.text.DecimalFormat; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DateUtil; + +public class ExcelUtil { + public static String getStringCellValue(Cell cell) + { + String strCell = ""; + if(cell == null) + return ""; + switch(cell.getCellType()){ + case Cell.CELL_TYPE_STRING : + strCell = cell.getStringCellValue(); + break; + case Cell.CELL_TYPE_NUMERIC : + if(DateUtil.isCellDateFormatted(cell)) + strCell = cell.getDateCellValue().toString(); + else + // strCell = String.valueOf(cell.getNumericCellValue()); + strCell = new DecimalFormat("#").format(cell.getNumericCellValue()); + break; + case Cell.CELL_TYPE_BOOLEAN : + strCell = String.valueOf(cell.getBooleanCellValue()); + break; + case Cell.CELL_TYPE_FORMULA : + strCell = cell.getCellFormula(); + break; + case Cell.CELL_TYPE_BLANK : + strCell = ""; + break; + default: + strCell = ""; + break; + } + if(strCell == null || strCell.equals("")) + return ""; + + return strCell; + } +} diff --git a/com.sq.customization/src/com/sq/customization/util/ProgressCustomDialog.java b/com.sq.customization/src/com/sq/customization/util/ProgressCustomDialog.java new file mode 100644 index 0000000..0b45e1f --- /dev/null +++ b/com.sq.customization/src/com/sq/customization/util/ProgressCustomDialog.java @@ -0,0 +1,271 @@ +package com.sq.customization.util; + +import java.awt.Dialog; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JProgressBar; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.Registry; + + + + +public class ProgressCustomDialog implements ActionListener +{ + + private static final String DEFAULT_STATUS = "Please Waiting"; + + + private static JDialog dialog; + + private JProgressBar progressBar; + + + public static JLabel lbStatus; + + + private JButton btnCancel; + + + private static Thread thread; //处理业务的线程 + + + private String statusInfo; + + + public static String resultInfo; + + + public static String cancelInfo; + + private Dialog parentDlg ; + + String message = ""; + + + public static void show(Thread thread,Dialog parentDlg) + { + + new ProgressCustomDialog(thread, DEFAULT_STATUS, null, null,parentDlg); + } + + + public static void show(Thread thread, String statusInfo,Dialog parentDlg) + { + new ProgressCustomDialog(thread, statusInfo, null, null,parentDlg); + } + + + public static void show(Thread thread, String statusInfo, + + String resultInfo, String cancelInfo,Dialog parentDlg) + { + new ProgressCustomDialog(thread, statusInfo, resultInfo, cancelInfo,parentDlg); + } + + + private ProgressCustomDialog(Thread thread, String statusInfo, + + String resultInfo, String cancelInfo,Dialog parentDlg) + { + this.thread = thread; + this.statusInfo = statusInfo;//Status + this.resultInfo = resultInfo;//处理完毕 + this.cancelInfo = cancelInfo;//Cancel + this.parentDlg = parentDlg ; + + + initUI(); + startThread(); + dialog.setVisible(true); + } + + private void initUI() + { + + if (parentDlg == null) + { + dialog = new JDialog(); + } + else + { + dialog = new JDialog(parentDlg); + } + + + final JPanel mainPane = new JPanel(null); + progressBar = new JProgressBar(); + lbStatus = new JLabel("" + statusInfo); + btnCancel = new JButton("Cancel"); + progressBar.setIndeterminate(true); + btnCancel.addActionListener(this); + + mainPane.add(progressBar); + mainPane.add(lbStatus); + //mainPane.add(btnCancel); + + dialog.getContentPane().add(mainPane); + //dialog.setUndecorated(true); // 除去title + dialog.setResizable(true); + dialog.setAlwaysOnTop(true); + dialog.setSize(590, 120); + dialog.setLocationRelativeTo(null); //设置此窗口相对于指定组件的位置 + ImageIcon imageicon = Registry.getRegistry(AbstractAIFDialog.class).getImageIcon("aifDesktop.ICON");//new ImageIcon(getClass().getResource("images/aifdesktop_16.png")); + dialog.setIconImage(imageicon.getImage()); + dialog.setTitle("进度信息"); + // System.out.println("set @@@@@@@@@@@@@@@@@@@@#######===="); +// dialog.setModal(true); +// dialog.setAlwaysOnTop(true); +// UIUtilities.centerToScreen(dialog, 1.0D, 0.75D); + dialog.requestFocusInWindow(); + +// dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); // 不允许关闭 + dialog.validate(); + + dialog.addWindowListener(new WindowAdapter() + { + @Override + public void windowClosed(WindowEvent e) + { + + } + + @Override + public void windowClosing(WindowEvent e) + { +// MessageBox.post("提醒", +// "关闭该窗口后报表将无法生成。", MessageBox.INFORMATION); + dialog.dispose(); + thread.stop(); + } + + }); + + mainPane.addComponentListener(new ComponentAdapter() + { + public void componentResized(ComponentEvent e) + { + layout(mainPane.getWidth(), mainPane.getHeight()); + } + }); + } + + private void startThread() + { + new Thread() + { + public void run() + { + try + { + thread.start(); // 处理耗时任务 + // 等待事务处理线程结束 + thread.join(); + } + catch(Exception e) + { + JOptionPane.showMessageDialog(new Dialog(dialog), e.getMessage(), "error", + + JOptionPane.ERROR_MESSAGE); + e.printStackTrace(); + } + finally + { + // 关闭进度提示框 + if (dialog != null) + { + dialog.dispose(); + if(resultInfo != null && !resultInfo.trim().equals("")) + { + String title = "进度信息"; + JOptionPane.showMessageDialog(new Dialog(dialog), resultInfo, title, + + JOptionPane.INFORMATION_MESSAGE); + } + } + + } + } + }.start(); + } + + private void layout(int width, int height) + { + progressBar.setBounds(20, 20, 550, 15); + lbStatus.setBounds(20, 40, 550, 25); + btnCancel.setBounds(width - 85, height - 31, 75, 21); + } + + @SuppressWarnings("deprecation") + public void actionPerformed(ActionEvent e) + { + resultInfo = cancelInfo; + thread.stop(); + } + + public static void StopStatus() + { + if (dialog != null) + dialog.dispose(); + } + + public static void main(String[] args) throws Exception + { + Thread thread = new Thread() + { + public void run() + { + int index = 0; + + while(index < 5) + { + try + { + sleep(1000); + System.out.println(++index); + } + catch(InterruptedException e) + { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + } + } + }; + ProgressCustomDialog.show(thread, "Status", "数据处理完毕", "Cancel",null); + + } + + + public Dialog getParentDlg() { + return parentDlg; + } + + + public void setParentDlg(Dialog parentDlg) { + this.parentDlg = parentDlg; + } + + + public static JDialog getDialog() { + return dialog; + } + + + public static void setDialog(JDialog dialog) { + ProgressCustomDialog.dialog = dialog; + } + +} \ No newline at end of file diff --git a/副本Battery+Tool-2024-11-21 电池工具.xlsx b/副本Battery+Tool-2024-11-21 电池工具.xlsx new file mode 100644 index 0000000..a0d96da Binary files /dev/null and b/副本Battery+Tool-2024-11-21 电池工具.xlsx differ diff --git a/副本EC+Tool-2024-11-21 电动工具.xlsx b/副本EC+Tool-2024-11-21 电动工具.xlsx new file mode 100644 index 0000000..ef4db4e Binary files /dev/null and b/副本EC+Tool-2024-11-21 电动工具.xlsx differ diff --git a/副本Pneumatic+Tool-2024-11-21 气动工具.xlsx b/副本Pneumatic+Tool-2024-11-21 气动工具.xlsx new file mode 100644 index 0000000..ba1bb52 Binary files /dev/null and b/副本Pneumatic+Tool-2024-11-21 气动工具.xlsx differ diff --git a/副本Sleeve-2024-11-21 套筒.xlsx b/副本Sleeve-2024-11-21 套筒.xlsx new file mode 100644 index 0000000..7208b2c Binary files /dev/null and b/副本Sleeve-2024-11-21 套筒.xlsx differ diff --git a/标准件零件管理数据 (20241220).xlsx b/标准件零件管理数据 (20241220).xlsx new file mode 100644 index 0000000..c172701 Binary files /dev/null and b/标准件零件管理数据 (20241220).xlsx differ