diff --git a/com.sq.customization/.classpath b/com.sq.customization/.classpath
index de52b6b..eca7bdb 100644
--- a/com.sq.customization/.classpath
+++ b/com.sq.customization/.classpath
@@ -3,20 +3,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/com.sq.customization/META-INF/MANIFEST.MF b/com.sq.customization/META-INF/MANIFEST.MF
index ba0eb33..8b1c789 100644
--- a/com.sq.customization/META-INF/MANIFEST.MF
+++ b/com.sq.customization/META-INF/MANIFEST.MF
@@ -7,35 +7,23 @@ 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"
+ com.teamcenter.rac.aifrcp,
+ com.teamcenter.rac.common,
+ com.teamcenter.rac.external,
+ com.teamcenter.rac.kernel,
+ com.teamcenter.rac.pca,
+ com.teamcenter.rac.pse,
+ com.teamcenter.rac.tcapps,
+ com.teamcenter.rac.ui,
+ com.teamcenter.rac.ui.views,
+ com.teamcenter.rac.util,
+ com.teamcenter.rac.pca.kernel,
+ com.teamcenter.rac.pse.pca,
+ com.teamcenter.rac.cme.kernel,
+ org.apache.poi.39
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: com.sq.customization
Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: lib/cglib-3.3.0.jar,
- lib/commons-collections4-4.1.jar,
- lib/easyexcel-3.2.0.jar,
- lib/easyexcel-core-3.2.0.jar,
- lib/easyexcel-support-3.2.0.jar,
- lib/poi-3.17.jar,
- lib/poi-examples-3.17.jar,
- lib/poi-excelant-3.17.jar,
- lib/poi-ooxml-3.17.jar,
- lib/poi-ooxml-schemas-3.17.jar,
- lib/poi-scratchpad-3.17.jar,
- lib/serializer-2.7.2.jar,
- lib/slf4j-api-1.7.5.jar,
- lib/xalan-2.7.2.jar,
- lib/xml-apis-1.4.01.jar,
- lib/xmlbeans-2.6.0.jar
+Export-Package: com.sq.customization,
+ com.sq.customization.dialogs,
+ com.sq.customization.handlers
diff --git a/com.sq.customization/build.properties b/com.sq.customization/build.properties
index 2cf1c63..c637e8e 100644
--- a/com.sq.customization/build.properties
+++ b/com.sq.customization/build.properties
@@ -1,21 +1,8 @@
+source.. = src/
output.. = bin/
javacDefaultEncoding.. = UTF-8
bin.includes = plugin.xml,\
META-INF/,\
+ .,\
icons/,\
- lib/cglib-3.3.0.jar,\
- lib/commons-collections4-4.1.jar,\
- lib/easyexcel-3.2.0.jar,\
- lib/easyexcel-core-3.2.0.jar,\
- lib/easyexcel-support-3.2.0.jar,\
- lib/poi-3.17.jar,\
- lib/poi-examples-3.17.jar,\
- lib/poi-excelant-3.17.jar,\
- lib/poi-ooxml-3.17.jar,\
- lib/poi-ooxml-schemas-3.17.jar,\
- lib/poi-scratchpad-3.17.jar,\
- lib/serializer-2.7.2.jar,\
- lib/slf4j-api-1.7.5.jar,\
- lib/xalan-2.7.2.jar,\
- lib/xml-apis-1.4.01.jar,\
- lib/xmlbeans-2.6.0.jar
+ build.properties
diff --git a/com.sq.customization/plugin.xml b/com.sq.customization/plugin.xml
index 8d27746..ef1493f 100644
--- a/com.sq.customization/plugin.xml
+++ b/com.sq.customization/plugin.xml
@@ -1,23 +1,22 @@
+
+
+
+
-
-
-
-
diff --git a/com.sq.customization/src/com/sq/customization/bean/ExcelBean.java b/com.sq.customization/src/com/sq/customization/bean/ExcelBean.java
index 6464d16..05838d1 100644
--- a/com.sq.customization/src/com/sq/customization/bean/ExcelBean.java
+++ b/com.sq.customization/src/com/sq/customization/bean/ExcelBean.java
@@ -1,140 +1,140 @@
-package com.sq.customization.bean;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.poi.EncryptedDocumentException;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.ss.usermodel.Cell;
-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.ss.usermodel.WorkbookFactory;
-
-import com.alibaba.excel.EasyExcel;
-import com.alibaba.excel.annotation.ExcelProperty;
-import com.sq.customization.util.ExcelUtil;
-
-public class ExcelBean {
- @ExcelProperty("工序信息")
- private String bl_indented_title;
- @ExcelProperty("紧固件号")
- private String item_id;
- @ExcelProperty("SSVPPS")
- private String SSVPPS;
- @ExcelProperty("FCC")
- private String FCC;
- @ExcelProperty("动态扭矩")
- private String dongtai;
- @ExcelProperty("KCDS")
- private String KCDS;
- @ExcelProperty("头部形式")
- private String headForm;
- @ExcelProperty("头部尺寸")
- private String headSize;
- @ExcelProperty("工具组合")
- private String alltool;
- @ExcelProperty("工具")
- private String SleeveResourceType;
- @ExcelProperty("套筒")
- private String ToolResourceType;
-
- public ExcelBean() {}
-
- public ExcelBean(String bl_indented_title, String item_id, String SSVPPS, String FCC, String dongtai,
- String KCDS, String headForm, String headSize, String alltool, String SleeveResourceType,
- String ToolResourceType) {
- this.bl_indented_title = bl_indented_title;
- this.item_id = item_id;
- this.SSVPPS = SSVPPS;
- this.FCC = FCC;
- this.dongtai = dongtai;
- this.KCDS = KCDS;
- this.headForm = headForm;
- this.headSize = headSize;
- this.alltool = alltool;
- this.SleeveResourceType = SleeveResourceType;
- this.ToolResourceType = ToolResourceType;
- }
-
- // Getter 和 Setter(保持不变,省略以节省篇幅)
-
- public static void main(String[] args) {
- List data = Arrays.asList(
- new ExcelBean("工序1", "ID001", "SSVPPS1", "FCC1", "动态1", "KCDS1", "圆头", "10mm", "工具A", "工具类型1", "套筒1"),
- new ExcelBean("工序2", "ID002", "SSVPPS2", "FCC2", "动态2", "KCDS2", "平头", "12mm", "工具B", "工具类型2", "套筒2")
- );
-
- String fileName = "C:\\Users\\TEMP.CNSHI6P1090.000.001.002.003.004.005.006\\Desktop\\新建文件夹\\cust_rule_data.xlsx"; // 修改为可写路径
- try (FileOutputStream fos = new FileOutputStream(fileName)) {
- EasyExcel.write(fos, ExcelBean.class)
- .sheet("Sheet1")
- .doWrite(data);
- System.out.println("数据已成功导出到 " + fileName);
- } catch (Exception e) {
- System.err.println("导出失败: " + e.getMessage());
- e.printStackTrace(); // 打印详细异常信息
- }
-// String filePath = "C:\\Users\\YourName\\Desktop\\cust_rule_data.xlsx"; // 替换为你的 Excel 文件路径
-
- try (FileInputStream fis = new FileInputStream(fileName)) {
- // 使用 WorkbookFactory 自动适配 .xls 和 .xlsx
- Workbook workbook = WorkbookFactory.create(fis);
-
- // 获取第一个工作表(Sheet1)
- Sheet sheet = workbook.getSheetAt(0); // 或使用 getSheet("Sheet1") 指定名称
-
- // 遍历所有行
- for (Row row : sheet) {
- // 遍历每行中的单元格
- for (Cell cell : row) {
- // 根据单元格类型读取数据
- String value = ExcelUtil.getStringCellValue(cell);
- System.out.println(value);
- }
- System.out.println(); // 每行结束后换行
- }
-
- // 关闭工作簿
- workbook.close();
- System.out.println("Excel 文件读取完成");
-
- } catch (IOException e) {
- System.err.println("读取 Excel 失败: " + e.getMessage());
- e.printStackTrace();
- } catch (EncryptedDocumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- // Getter 和 Setter(以下为完整代码,之前省略的部分)
- public String getBl_indented_title() { return bl_indented_title; }
- public void setBl_indented_title(String bl_indented_title) { this.bl_indented_title = bl_indented_title; }
- public String getItem_id() { return item_id; }
- public void setItem_id(String item_id) { this.item_id = item_id; }
- public String getSSVPPS() { return SSVPPS; }
- public void setSSVPPS(String SSVPPS) { this.SSVPPS = SSVPPS; }
- public String getFCC() { return FCC; }
- public void setFCC(String FCC) { this.FCC = FCC; }
- public String getDongtai() { return dongtai; }
- public void setDongtai(String dongtai) { this.dongtai = dongtai; }
- public String getKCDS() { return KCDS; }
- public void setKCDS(String KCDS) { this.KCDS = KCDS; }
- public String getHeadForm() { return headForm; }
- public void setHeadForm(String headForm) { this.headForm = headForm; }
- public String getHeadSize() { return headSize; }
- public void setHeadSize(String headSize) { this.headSize = headSize; }
- public String getAlltool() { return alltool; }
- public void setAlltool(String alltool) { this.alltool = alltool; }
- public String getSleeveResourceType() { return SleeveResourceType; }
- public void setSleeveResourceType(String SleeveResourceType) { this.SleeveResourceType = SleeveResourceType; }
- public String getToolResourceType() { return ToolResourceType; }
- public void setToolResourceType(String ToolResourceType) { this.ToolResourceType = ToolResourceType; }
-}
+//package com.sq.customization.bean;
+//
+//import java.io.FileInputStream;
+//import java.io.FileOutputStream;
+//import java.io.IOException;
+//import java.util.Arrays;
+//import java.util.List;
+//
+//import org.apache.poi.EncryptedDocumentException;
+//import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+//import org.apache.poi.ss.usermodel.Cell;
+//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.ss.usermodel.WorkbookFactory;
+//
+//import com.alibaba.excel.EasyExcel;
+//import com.alibaba.excel.annotation.ExcelProperty;
+//import com.sq.customization.util.ExcelUtil;
+//
+//public class ExcelBean {
+// @ExcelProperty("工序信息")
+// private String bl_indented_title;
+// @ExcelProperty("紧固件号")
+// private String item_id;
+// @ExcelProperty("SSVPPS")
+// private String SSVPPS;
+// @ExcelProperty("FCC")
+// private String FCC;
+// @ExcelProperty("动态扭矩")
+// private String dongtai;
+// @ExcelProperty("KCDS")
+// private String KCDS;
+// @ExcelProperty("头部形式")
+// private String headForm;
+// @ExcelProperty("头部尺寸")
+// private String headSize;
+// @ExcelProperty("工具组合")
+// private String alltool;
+// @ExcelProperty("工具")
+// private String SleeveResourceType;
+// @ExcelProperty("套筒")
+// private String ToolResourceType;
+//
+// public ExcelBean() {}
+//
+// public ExcelBean(String bl_indented_title, String item_id, String SSVPPS, String FCC, String dongtai,
+// String KCDS, String headForm, String headSize, String alltool, String SleeveResourceType,
+// String ToolResourceType) {
+// this.bl_indented_title = bl_indented_title;
+// this.item_id = item_id;
+// this.SSVPPS = SSVPPS;
+// this.FCC = FCC;
+// this.dongtai = dongtai;
+// this.KCDS = KCDS;
+// this.headForm = headForm;
+// this.headSize = headSize;
+// this.alltool = alltool;
+// this.SleeveResourceType = SleeveResourceType;
+// this.ToolResourceType = ToolResourceType;
+// }
+//
+// // Getter 和 Setter(保持不变,省略以节省篇幅)
+//
+// public static void main(String[] args) {
+// List data = Arrays.asList(
+// new ExcelBean("工序1", "ID001", "SSVPPS1", "FCC1", "动态1", "KCDS1", "圆头", "10mm", "工具A", "工具类型1", "套筒1"),
+// new ExcelBean("工序2", "ID002", "SSVPPS2", "FCC2", "动态2", "KCDS2", "平头", "12mm", "工具B", "工具类型2", "套筒2")
+// );
+//
+// String fileName = "C:\\Users\\TEMP.CNSHI6P1090.000.001.002.003.004.005.006\\Desktop\\新建文件夹\\cust_rule_data.xlsx"; // 修改为可写路径
+// try (FileOutputStream fos = new FileOutputStream(fileName)) {
+// EasyExcel.write(fos, ExcelBean.class)
+// .sheet("Sheet1")
+// .doWrite(data);
+// System.out.println("数据已成功导出到 " + fileName);
+// } catch (Exception e) {
+// System.err.println("导出失败: " + e.getMessage());
+// e.printStackTrace(); // 打印详细异常信息
+// }
+//// String filePath = "C:\\Users\\YourName\\Desktop\\cust_rule_data.xlsx"; // 替换为你的 Excel 文件路径
+//
+// try (FileInputStream fis = new FileInputStream(fileName)) {
+// // 使用 WorkbookFactory 自动适配 .xls 和 .xlsx
+// Workbook workbook = WorkbookFactory.create(fis);
+//
+// // 获取第一个工作表(Sheet1)
+// Sheet sheet = workbook.getSheetAt(0); // 或使用 getSheet("Sheet1") 指定名称
+//
+// // 遍历所有行
+// for (Row row : sheet) {
+// // 遍历每行中的单元格
+// for (Cell cell : row) {
+// // 根据单元格类型读取数据
+// String value = ExcelUtil.getStringCellValue(cell);
+// System.out.println(value);
+// }
+// System.out.println(); // 每行结束后换行
+// }
+//
+// // 关闭工作簿
+// workbook.close();
+// System.out.println("Excel 文件读取完成");
+//
+// } catch (IOException e) {
+// System.err.println("读取 Excel 失败: " + e.getMessage());
+// e.printStackTrace();
+// } catch (EncryptedDocumentException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// } catch (InvalidFormatException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// }
+//
+// // Getter 和 Setter(以下为完整代码,之前省略的部分)
+// public String getBl_indented_title() { return bl_indented_title; }
+// public void setBl_indented_title(String bl_indented_title) { this.bl_indented_title = bl_indented_title; }
+// public String getItem_id() { return item_id; }
+// public void setItem_id(String item_id) { this.item_id = item_id; }
+// public String getSSVPPS() { return SSVPPS; }
+// public void setSSVPPS(String SSVPPS) { this.SSVPPS = SSVPPS; }
+// public String getFCC() { return FCC; }
+// public void setFCC(String FCC) { this.FCC = FCC; }
+// public String getDongtai() { return dongtai; }
+// public void setDongtai(String dongtai) { this.dongtai = dongtai; }
+// public String getKCDS() { return KCDS; }
+// public void setKCDS(String KCDS) { this.KCDS = KCDS; }
+// public String getHeadForm() { return headForm; }
+// public void setHeadForm(String headForm) { this.headForm = headForm; }
+// public String getHeadSize() { return headSize; }
+// public void setHeadSize(String headSize) { this.headSize = headSize; }
+// public String getAlltool() { return alltool; }
+// public void setAlltool(String alltool) { this.alltool = alltool; }
+// public String getSleeveResourceType() { return SleeveResourceType; }
+// public void setSleeveResourceType(String SleeveResourceType) { this.SleeveResourceType = SleeveResourceType; }
+// public String getToolResourceType() { return ToolResourceType; }
+// public void setToolResourceType(String ToolResourceType) { this.ToolResourceType = ToolResourceType; }
+//}
diff --git a/com.sq.customization/src/com/sq/customization/dialogs/AutoTransToolDialog.java b/com.sq.customization/src/com/sq/customization/dialogs/AutoTransToolDialog.java
index 65f75f4..7cfb00f 100644
--- a/com.sq.customization/src/com/sq/customization/dialogs/AutoTransToolDialog.java
+++ b/com.sq.customization/src/com/sq/customization/dialogs/AutoTransToolDialog.java
@@ -8,10 +8,16 @@ import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -23,6 +29,7 @@ import javax.swing.JPanel;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
@@ -63,16 +70,18 @@ import com.teamcenter.rac.util.Registry;
public class AutoTransToolDialog extends AbstractAIFDialog {
private PropertyTextField text;
+ private PropertyTextField dirtext;
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 JButton directory2;
// private Registry registry = Registry.getRegistry(AutoTransToolDialog.class);
private TCSession session;
private InterfaceAIFComponent target;
@@ -92,6 +101,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
private Map StandardPartMap = new HashMap<>();//excel标准件
private Map> SleeveMap = new HashMap<>();//excel套筒
private int times = 0;
+ private int row_num = 1;
public AutoTransToolDialog(Frame fm,InterfaceAIFComponent target,TCSession session) {
super(fm);
this.target = target;
@@ -163,6 +173,16 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
directory = new JButton("...");
northPane.add("7.3",directory);
+ northPane.add("8.1.left",new JLabel("导出路径:"));
+ dirtext = new PropertyTextField();
+ dirtext.setColumns(30);
+ dirtext.setRequired(true);
+ dirtext.setEnabled(false);
+ northPane.add("8.2",dirtext);
+
+ directory2 = new JButton("...");
+ northPane.add("8.3",directory);
+
JPanel southpanel = new JPanel(new ButtonLayout());
ok = new JButton("确定");
cancel = new JButton("取消");
@@ -178,6 +198,23 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
public void actionPerformed(ActionEvent e) {
AutoTransToolDialog.this.dispose();
}});
+ directory2.addActionListener(new ActionListener(){
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JFileChooser filechooser = new JFileChooser();
+ filechooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+// FileNameExtensionFilter filter = new FileNameExtensionFilter(
+// "所有Excel文件(*.xlsx)", new String[] { "xlsx" });
+// filechooser.setFileFilter(filter);
+ int r = filechooser.showDialog(null, "选择");
+ if (r == 0) {
+ dirtext.setText(filechooser.getSelectedFile().getAbsolutePath());
+ }
+ else if (r == 1) {
+ dirtext.setText("");
+ }
+ }});
directory.addActionListener(new ActionListener(){
@Override
@@ -190,14 +227,10 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
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(){
@@ -205,14 +238,16 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
String path = text.getText();
- if( path != null && path.length() > 0) {
+ String path2 = dirtext.getText();
+ if( path != null && path.length() > 0 && path2 != null && path2.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);
+
+ final File excel = new File(path);
if(!excel.exists()) {
MessageBox.post(AutoTransToolDialog.this,"文件路径不存在", "Message", MessageBox.INFORMATION);
return;
@@ -261,69 +296,89 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
try {
TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(rule_pref[0]);
File[] files = dataset.getFiles("excel");
- if(files != null || files.length == 0 || !files[0].exists()) {
+ if(files == null || files.length == 0 || !files[0].exists()) {
MessageBox.post(AutoTransToolDialog.this,"请检查自定义首选项cust_rule_excel对应的规则数据集中的文件", "Message", MessageBox.INFORMATION);
return;
}
TCComponentDataset cust_electric_exceldataset = (TCComponentDataset) session.stringToComponent(cust_electric_excel[0]);
File[] cust_electric_excelfiles = cust_electric_exceldataset.getFiles("excel");
- if(cust_electric_excelfiles != null || cust_electric_excelfiles.length == 0 || !cust_electric_excelfiles[0].exists()) {
+ if(cust_electric_excelfiles == null || cust_electric_excelfiles.length == 0 || !cust_electric_excelfiles[0].exists()) {
MessageBox.post(AutoTransToolDialog.this,"请检查自定义首选项cust_electric_excel对应的数据集中的文件", "Message", MessageBox.INFORMATION);
return;
}
TCComponentDataset cust_battery_exceldataset = (TCComponentDataset) session.stringToComponent(cust_battery_excel[0]);
File[] cust_battery_exceldatasetfiles = cust_battery_exceldataset.getFiles("excel");
- if(cust_battery_exceldatasetfiles != null || cust_battery_exceldatasetfiles.length == 0 || !cust_battery_exceldatasetfiles[0].exists()) {
+ if(cust_battery_exceldatasetfiles == null || cust_battery_exceldatasetfiles.length == 0 || !cust_battery_exceldatasetfiles[0].exists()) {
MessageBox.post(AutoTransToolDialog.this,"请检查自定义首选项cust_battery_excel对应的数据集中的文件", "Message", MessageBox.INFORMATION);
return;
}
TCComponentDataset cust_pneumatic_exceldataset = (TCComponentDataset) session.stringToComponent(cust_pneumatic_excel[0]);
File[] cust_pneumatic_excelfiles = cust_pneumatic_exceldataset.getFiles("excel");
- if(cust_pneumatic_excelfiles != null || cust_pneumatic_excelfiles.length == 0 || !cust_pneumatic_excelfiles[0].exists()) {
+ if(cust_pneumatic_excelfiles == null || cust_pneumatic_excelfiles.length == 0 || !cust_pneumatic_excelfiles[0].exists()) {
MessageBox.post(AutoTransToolDialog.this,"请检查自定义首选项cust_pneumatic_excel对应的数据集中的文件", "Message", MessageBox.INFORMATION);
return;
}
TCComponentDataset cust_manual_exceldataset = (TCComponentDataset) session.stringToComponent(cust_manual_excel[0]);
File[] cust_manual_excelfiles = cust_manual_exceldataset.getFiles("excel");
- if(cust_manual_excelfiles != null || cust_manual_excelfiles.length == 0 || !cust_manual_excelfiles[0].exists()) {
+ if(cust_manual_excelfiles == null || cust_manual_excelfiles.length == 0 || !cust_manual_excelfiles[0].exists()) {
MessageBox.post(AutoTransToolDialog.this,"请检查自定义首选项cust_manual_excel对应的数据集中的文件", "Message", MessageBox.INFORMATION);
return;
}
TCComponentDataset cust_standardpart_exceldataset = (TCComponentDataset) session.stringToComponent(cust_standardpart_excel[0]);
File[] cust_standardpart_excelfiles = cust_standardpart_exceldataset.getFiles("excel");
- if(cust_standardpart_excelfiles != null || cust_standardpart_excelfiles.length == 0 || !cust_standardpart_excelfiles[0].exists()) {
+ if(cust_standardpart_excelfiles == null || cust_standardpart_excelfiles.length == 0 || !cust_standardpart_excelfiles[0].exists()) {
MessageBox.post(AutoTransToolDialog.this,"请检查自定义首选项cust_standardpart_excel对应的数据集中的文件", "Message", MessageBox.INFORMATION);
return;
}
TCComponentDataset cust_sleeve_exceldataset = (TCComponentDataset) session.stringToComponent(cust_sleeve_excel[0]);
File[] cust_sleeve_excelfiles = cust_sleeve_exceldataset.getFiles("excel");
- if(cust_sleeve_excelfiles != null || cust_sleeve_excelfiles.length == 0 || !cust_sleeve_excelfiles[0].exists()) {
+ if(cust_sleeve_excelfiles == null || cust_sleeve_excelfiles.length == 0 || !cust_sleeve_excelfiles[0].exists()) {
MessageBox.post(AutoTransToolDialog.this,"请检查自定义首选项cust_sleeve_excel对应的数据集中的文件", "Message", MessageBox.INFORMATION);
return;
}
- File excelfile = files[0];
- File electricfile = cust_electric_excelfiles[0];
- File batteryfile = cust_battery_exceldatasetfiles[0];
- File pneumaticfile = cust_pneumatic_excelfiles[0];
- File manualfile = cust_manual_excelfiles[0];
- File standardpartfile = cust_standardpart_excelfiles[0];
- File sleevefile = cust_sleeve_excelfiles[0];
+ final File excelfile = files[0];
+ final File electricfile = cust_electric_excelfiles[0];
+ final File batteryfile = cust_battery_exceldatasetfiles[0];
+ final File pneumaticfile = cust_pneumatic_excelfiles[0];
+ final File manualfile = cust_manual_excelfiles[0];
+ final File standardpartfile = cust_standardpart_excelfiles[0];
+ final File sleevefile = cust_sleeve_excelfiles[0];
if(isValidExcelColumn(idcol) && isValidExcelColumn(svppscol) && isValidExcelColumn(fcccol)
&& isValidExcelColumn(fccdescol) && isValidExcelColumn(dongtaicol) && isValidExcelColumn(kcdscol)) {
op_nodesignmap.clear();
no_load.clear();
DesignPartBeanMap.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());
+ final int idcol2 = columnToNumber(idcol.toUpperCase());
+ final int svppscol2 = columnToNumber(svppscol.toUpperCase());
+ final int fcccol2 = columnToNumber(fcccol.toUpperCase());
+ final int fccdescol2 = columnToNumber(fccdescol.toUpperCase());
+ final int dongtaicol2 = columnToNumber(dongtaicol.toUpperCase());
+ final int kcdscol2 = columnToNumber(kcdscol.toUpperCase());
Thread thread = new Thread(){
public void run(){
ProgressCustomDialog.lbStatus.setText("正在创建 ....");
- try {
+ Workbook workbook = null;
+ FileOutputStream outputStream = null;
+ try {
+ SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HHmmssSSS");
+ String time = fm.format(new Date());
+ outputStream = new FileOutputStream(path2+"/匹配工具表导出"+time+".xlsx");
+ workbook = new XSSFWorkbook();
+ Sheet sheet = workbook.createSheet("Data");
+ // 创建表头
+ Row headerRow = sheet.createRow(0);
+ headerRow.createCell(0).setCellValue("工序信息");
+ headerRow.createCell(1).setCellValue("紧固件号");
+ headerRow.createCell(2).setCellValue("SVPPS");
+ headerRow.createCell(3).setCellValue("FCC");
+ headerRow.createCell(4).setCellValue("动态扭矩");
+ headerRow.createCell(5).setCellValue("KCDS");
+ headerRow.createCell(6).setCellValue("头部形式");
+ headerRow.createCell(7).setCellValue("头部尺寸");
+ headerRow.createCell(8).setCellValue("工具组合");
+ headerRow.createCell(9).setCellValue("工具");
+ headerRow.createCell(10).setCellValue("工具套筒");
//读取自定义的表
if(times == 0) {
readRuleExcel(excelfile);
@@ -335,13 +390,13 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
readsleevefile(sleevefile,1);
times = 1;
}
-
+ row_num = 1;
//读取EXCEL
readExcel(excel,2,idcol2,svppscol2,fcccol2,fccdescol2,dongtaicol2,kcdscol2);
//先处理选中对象层级有design的工序,获取没有design的工序
- opBOMLineData(target);
+ opBOMLineData(target,sheet);
if(op_nodesignmap.size() > 0) {
TCComponentBOMLine parent = null;
@@ -365,10 +420,20 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
}
if(parent != null) {
System.out.println(parent.getClass()+parent.getProperty("bl_indented_title"));
- getparent(parent);
+ getparent(parent,sheet);
}
if(op_nodesignmap.size() > 0) {
System.out.println("整个结构没有匹配的紧固件");
+ for(String key:op_nodesignmap.keySet()) {
+ TCComponentMfgBvrOperation op = op_nodesignmap.get(key);
+ String bl_indented_title = op.getProperty("bl_indented_title");
+ Row row = sheet.createRow(row_num);
+ row_num ++;
+ Cell optitle_cell = row.createCell(0);
+ optitle_cell.setCellValue(bl_indented_title);
+ Cell des_cell = row.createCell(1);
+ des_cell.setCellValue("无紧固件");
+ }
}
}
@@ -376,6 +441,17 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
// TODO Auto-generated catch block
e1.printStackTrace();
}
+ finally {
+ try {
+ workbook.write(outputStream);
+ outputStream.flush();
+ if(outputStream != null)outputStream.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
}
};
@@ -416,7 +492,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
return column != null && column.toUpperCase().matches("[A-Z]+");
}
//先处理选中对象层级有design的工序
- private void opBOMLineData(InterfaceAIFComponent parent) throws Exception {
+ private void opBOMLineData(InterfaceAIFComponent parent,Sheet sheet) throws Exception {
AIFComponentContext[] children = parent.getChildren();
for(AIFComponentContext child:children) {
InterfaceAIFComponent childcom = child.getComponent();
@@ -424,15 +500,17 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
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("搭铁")) {
-
+ String bl_indented_title = op.getProperty("bl_indented_title");
AIFComponentContext[] design_children = op.getChildren();
boolean hasdesign = false;
for(AIFComponentContext designchild:design_children) {
InterfaceAIFComponent designchildcom = designchild.getComponent();
- if(designchildcom instanceof TCComponentMfgBvrPart) {
+ String bl_item_object_type = op.getProperty("bl_item_object_type");
+ if("Design Part".equalsIgnoreCase(bl_item_object_type)) {
hasdesign = true;
//获取符合的数据
Map> Tool = new HashMap<>();
@@ -442,6 +520,13 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
.replaceAll("终紧", "")
.replaceAll("紧固", "")
.replaceAll("拧紧", "");
+ Row row = sheet.createRow(row_num);
+ row_num ++;
+ Cell optitle_cell = row.createCell(0);
+ optitle_cell.setCellValue(bl_indented_title);
+ Cell designid_cell = row.createCell(1);
+ designid_cell.setCellValue(designid);
+
String key = designid+"|"+newname;
System.out.println("看design是否匹配:"+key);
if(DesignPartBeanMap.containsKey(key)) {
@@ -457,7 +542,14 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
}
}
}
-
+ Cell svpps_cell = row.createCell(2);
+ svpps_cell.setCellValue(bean.getSVPPS());
+ Cell fcc_cell = row.createCell(3);
+ fcc_cell.setCellValue(bean.getFCC());
+ Cell dongtai_cell = row.createCell(4);
+ dongtai_cell.setCellValue(bean.getDongtai());
+ Cell kcds_cell = row.createCell(5);
+ kcds_cell.setCellValue(bean.getKCDS());
//优先执行特殊工艺规则和电动工具新型号规则,若无匹配全量跑后续规则
boolean processrule = false;
for(int i = 0; i< processrules.size(); i++) {
@@ -621,9 +713,11 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
}
}
if(!autotoolrule) {
- //看读取哪个表
- Map excelname = new HashMap<>();
+
+ Map resourcename = new HashMap<>();
//拧紧性质规则
+ //看读取哪个表
+ Map Tightenexcelname = new HashMap<>();
for(int i = 0; i< Tightenrules.size(); i++) {
CustRuleBean rulebean = Tightenrules.get(i);
String rule_svpps = rulebean.getSVPPS();
@@ -670,19 +764,21 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
if(resourceType != null && resourceType.length() > 0) {
String[] res = resourceType.split("\\|", -1);
for(String re:res) {
- if(excelname.containsKey(re)) {
- int count = excelname.get(re);
- excelname.put(re, count+1);
+ if(Tightenexcelname.containsKey(re)) {
+//
}
else {
- excelname.put(re, 1);
+ Tightenexcelname.put(re, 1);
}
}
}
+ break;
}
}
//KCDS
+ //看读取哪个表
+ Map KCDSexcelname = new HashMap<>();
for(int i = 0; i< KCDSrules.size(); i++) {
CustRuleBean rulebean = KCDSrules.get(i);
String rule_svpps = rulebean.getSVPPS();
@@ -711,19 +807,19 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
if(resourceType != null && resourceType.length() > 0) {
String[] res = resourceType.split("\\|", -1);
for(String re:res) {
- if(excelname.containsKey(re)) {
- int count = excelname.get(re);
- excelname.put(re, count+1);
+ if(KCDSexcelname.containsKey(re)) {
}
else {
- excelname.put(re, 1);
+ KCDSexcelname.put(re, 1);
}
}
}
+ break;
}
}
//拧紧方式
+ Map TightenMethodexcelname = new HashMap<>();
for(int i = 0; i< TightenMethodrules.size(); i++) {
CustRuleBean rulebean = TightenMethodrules.get(i);
String rule_svpps = rulebean.getSVPPS();
@@ -769,20 +865,19 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
if(resourceType != null && resourceType.length() > 0) {
String[] res = resourceType.split("\\|", -1);
for(String re:res) {
- if(excelname.containsKey(re)) {
- int count = excelname.get(re);
- excelname.put(re, count+1);
+ if(TightenMethodexcelname.containsKey(re)) {
}
else {
- excelname.put(re, 1);
+ TightenMethodexcelname.put(re, 1);
}
}
}
+ break;
}
}
//扭矩值
-
+ Map Torqueexcelname = new HashMap<>();
for(int i = 0; i< Torquerules.size(); i++) {
CustRuleBean rulebean = Torquerules.get(i);
String rule_svpps = rulebean.getSVPPS();
@@ -829,60 +924,88 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
if(resourceType != null && resourceType.length() > 0) {
String[] res = resourceType.split("\\|", -1);
for(String re:res) {
- if(excelname.containsKey(re)) {
- int count = excelname.get(re);
- excelname.put(re, count+1);
+ if(Torqueexcelname.containsKey(re)) {
}
else {
- excelname.put(re, 1);
+ Torqueexcelname.put(re, 1);
+ }
+ }
+ }
+ if(resourceName != null && resourceName.length() > 0) {
+ String[] res = resourceName.split("\\|", -1);
+ for(String re:res) {
+ if(resourcename.containsKey(re)) {
+
+ }
+ else {
+ resourcename.put(re, re);
}
}
}
+ break;
}
}
-
+ // 将所有 Map 放入一个列表
+// List