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> maps = Arrays.asList(Tightenexcelname, KCDSexcelname, TightenMethodexcelname, Torqueexcelname); + Set commonKeys = new HashSet<>(Tightenexcelname.keySet()); + + // 保留 map2、map3、map4 中也有的键 + commonKeys.retainAll(KCDSexcelname.keySet()); + commonKeys.retainAll(TightenMethodexcelname.keySet()); + commonKeys.retainAll(Torqueexcelname.keySet()); + //读取工具excel数据 - for(String name:excelname.keySet()) { + for(String name:commonKeys) { if("电动工具".equals(name)){ for(String resourceType:eleTool.keySet()) { List toolbeans = eleTool.get(resourceType); for(ToolBean toolbean:toolbeans) { String range = toolbean.getRange(); String outSize = toolbean.getOutSize(); - boolean isWithinRange = false; - if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { - range = range.replace("|", "-"); - String newrange = RangeCalculator.adjustRange(range); - - String newniuju = niuju; - if(bl_rev_object_name.contains("预紧")) { - newniuju = RangeAdjuster.adjustRange(niuju); + String resourceName = toolbean.getResourceName(); + if(resourcename.containsKey(resourceName)) { + boolean isWithinRange = false; + if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { + range = range.replace("|", "-"); + String newrange = RangeCalculator.adjustRange(range); + + String newniuju = niuju; + if(bl_rev_object_name.contains("预紧")) { + newniuju = RangeAdjuster.adjustRange(niuju); + } + System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); + isWithinRange = RangChecker.isWithinRange(newniuju, newrange); + if(isWithinRange) { + System.out.println("新扭矩和新扭矩范围匹配"); + } + else { + System.out.println("新扭矩和新扭矩范围不匹配"); + } } - System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); - isWithinRange = RangChecker.isWithinRange(newniuju, newrange); - if(isWithinRange) { - System.out.println("新扭矩和新扭矩范围匹配"); + else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { + System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); + isWithinRange = true; } - else { - System.out.println("新扭矩和新扭矩范围不匹配"); + if(isWithinRange) { + System.out.println("后续和套筒匹配"); + Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); } } - else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { - System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); - isWithinRange = true; - } - if(isWithinRange) { - System.out.println("后续和套筒匹配"); - Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); - } + } } } else if("手动工具".equals(name)){ for(String resourceType:eleTool.keySet()) { List toolbeans = eleTool.get(resourceType); - Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).addAll(toolbeans); + for(ToolBean toolbean:toolbeans) { + String resourceName = toolbean.getResourceName(); + if(resourcename.containsKey(resourceName)) { + Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); + } + } +// Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).addAll(toolbeans); } } else if("气动工具".equals(name)){ @@ -891,32 +1014,35 @@ public class AutoTransToolDialog extends AbstractAIFDialog { for(ToolBean toolbean:toolbeans) { String range = toolbean.getRange(); String outSize = toolbean.getOutSize(); - boolean isWithinRange = false; - if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { - range = range.replace("|", "-"); - String newrange = RangeCalculator.adjustRange(range); - - String newniuju = niuju; - if(bl_rev_object_name.contains("预紧")) { - newniuju = RangeAdjuster.adjustRange(niuju); + String resourceName = toolbean.getResourceName(); + if(resourcename.containsKey(resourceName)) { + boolean isWithinRange = false; + if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { + range = range.replace("|", "-"); + String newrange = RangeCalculator.adjustRange(range); + + String newniuju = niuju; + if(bl_rev_object_name.contains("预紧")) { + newniuju = RangeAdjuster.adjustRange(niuju); + } + System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); + isWithinRange = RangChecker.isWithinRange(newniuju, newrange); + if(isWithinRange) { + System.out.println("新扭矩和新扭矩范围匹配"); + } + else { + System.out.println("新扭矩和新扭矩范围不匹配"); + } } - System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); - isWithinRange = RangChecker.isWithinRange(newniuju, newrange); - if(isWithinRange) { - System.out.println("新扭矩和新扭矩范围匹配"); + else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { + System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); + isWithinRange = true; } - else { - System.out.println("新扭矩和新扭矩范围不匹配"); + if(isWithinRange) { + System.out.println("后续和套筒匹配"); + Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); } } - else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { - System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); - isWithinRange = true; - } - if(isWithinRange) { - System.out.println("后续和套筒匹配"); - Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); - } } } } @@ -926,32 +1052,35 @@ public class AutoTransToolDialog extends AbstractAIFDialog { for(ToolBean toolbean:toolbeans) { String range = toolbean.getRange(); String outSize = toolbean.getOutSize(); - boolean isWithinRange = false; - if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { - range = range.replace("|", "-"); - String newrange = RangeCalculator.adjustRange(range); - - String newniuju = niuju; - if(bl_rev_object_name.contains("预紧")) { - newniuju = RangeAdjuster.adjustRange(niuju); + String resourceName = toolbean.getResourceName(); + if(resourcename.containsKey(resourceName)) { + boolean isWithinRange = false; + if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { + range = range.replace("|", "-"); + String newrange = RangeCalculator.adjustRange(range); + + String newniuju = niuju; + if(bl_rev_object_name.contains("预紧")) { + newniuju = RangeAdjuster.adjustRange(niuju); + } + System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); + isWithinRange = RangChecker.isWithinRange(newniuju, newrange); + if(isWithinRange) { + System.out.println("新扭矩和新扭矩范围匹配"); + } + else { + System.out.println("新扭矩和新扭矩范围不匹配"); + } } - System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); - isWithinRange = RangChecker.isWithinRange(newniuju, newrange); - if(isWithinRange) { - System.out.println("新扭矩和新扭矩范围匹配"); + else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { + System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); + isWithinRange = true; } - else { - System.out.println("新扭矩和新扭矩范围不匹配"); + if(isWithinRange) { + System.out.println("后续和套筒匹配"); + Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); } } - else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { - System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); - isWithinRange = true; - } - if(isWithinRange) { - System.out.println("后续和套筒匹配"); - Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); - } } } } @@ -971,10 +1100,16 @@ public class AutoTransToolDialog extends AbstractAIFDialog { StandardPartBean stdbean = StandardPartMap.get(designid); String headform = stdbean.getHeadform(); String headsize = stdbean.getHeadsize(); + Cell headform_cell = row.createCell(6); + headform_cell.setCellValue(headform); + Cell headsize_cell = row.createCell(7); + headsize_cell.setCellValue(headsize); String key2 = headsize+"|"+headform; System.out.println("寻找套筒 头部尺寸|头部形式:"+key2); if(SleeveMap.containsKey(key2)) { System.out.println("找到匹配"); + Cell all_cell = row.createCell(8); + String all = ""; List SleeveBeans = SleeveMap.get(key2); for(SleeveBean sleevebean:SleeveBeans) { String inputsize = sleevebean.getInputSize(); @@ -983,19 +1118,35 @@ public class AutoTransToolDialog extends AbstractAIFDialog { //后续工具与套筒匹配 for(String resourcetype:Tool.keySet()) { List toolsbean = Tool.get(resourcetype); +// Cell toolresourceType_cell = row.createCell(8); +// toolresourceType_cell.setCellValue(resourcetype); + boolean has = false; for(ToolBean toolbean:toolsbean) { String outsize = toolbean.getOutSize(); if(outsize != null && outsize.length() > 0 && inputsize != null && inputsize.length() > 0) { if(outsize.equals(inputsize)) { System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType); + has = true; + all = all+resourcetype+"-"+resourceType; + break; } } else if((outsize == null || outsize.length() == 0) && (inputsize == null || inputsize.length() == 0)){ System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType); + + all = all+resourcetype+"-"+resourceType; + has = true; + break; } } + if(has) { +// Cell resourceType_cell = row.createCell(9); +// resourceType_cell.setCellValue(resourceType); + break; + } } } + all_cell.setCellValue(all); } else System.out.println("没有找到匹配"); @@ -1003,6 +1154,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog { } else { System.out.println("未找到匹配的"); + } } } @@ -1020,7 +1172,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog { } else if(childcom instanceof TCComponentMfgBvrProcessStation || childcom instanceof TCComponentMfgBvrProcessLine || childcom instanceof TCComponentMfgBvrPlantBOP) { - opBOMLineData(childcom); + opBOMLineData(childcom,sheet); } } @@ -1029,7 +1181,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog { /** * no_load:已经加载过的数据id下次就不加载了 * */ - private void getparent(TCComponentBOMLine parent)throws Exception{ + private void getparent(TCComponentBOMLine parent,Sheet sheet)throws Exception{ if(op_nodesignmap.size() > 0) { String parentid = parent.getProperty("bl_item_item_id"); @@ -1047,6 +1199,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog { TCComponentMfgBvrOperation op = (TCComponentMfgBvrOperation) childcom; final String bl_rev_object_name = op.getProperty("bl_rev_object_name"); + String bl_indented_title = op.getProperty("bl_indented_title"); Set keys = op_nodesignmap.keySet(); boolean found = false; String haskey = ""; @@ -1062,9 +1215,9 @@ public class AutoTransToolDialog extends AbstractAIFDialog { 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; - //获取design //获取符合的数据 Map> Tool = new HashMap<>(); //获取design @@ -1073,6 +1226,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)) { @@ -1088,7 +1248,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++) { @@ -1252,9 +1419,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(); @@ -1301,19 +1470,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(); @@ -1342,19 +1513,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(); @@ -1400,20 +1571,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(); @@ -1460,60 +1630,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> maps = Arrays.asList(Tightenexcelname, KCDSexcelname, TightenMethodexcelname, Torqueexcelname); + Set commonKeys = new HashSet<>(Tightenexcelname.keySet()); + + // 保留 map2、map3、map4 中也有的键 + commonKeys.retainAll(KCDSexcelname.keySet()); + commonKeys.retainAll(TightenMethodexcelname.keySet()); + commonKeys.retainAll(Torqueexcelname.keySet()); + //读取工具excel数据 - for(String name:excelname.keySet()) { + for(String name:commonKeys) { if("电动工具".equals(name)){ for(String resourceType:eleTool.keySet()) { List toolbeans = eleTool.get(resourceType); for(ToolBean toolbean:toolbeans) { String range = toolbean.getRange(); String outSize = toolbean.getOutSize(); - boolean isWithinRange = false; - if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { - range = range.replace("|", "-"); - String newrange = RangeCalculator.adjustRange(range); - - String newniuju = niuju; - if(bl_rev_object_name.contains("预紧")) { - newniuju = RangeAdjuster.adjustRange(niuju); + String resourceName = toolbean.getResourceName(); + if(resourcename.containsKey(resourceName)) { + boolean isWithinRange = false; + if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { + range = range.replace("|", "-"); + String newrange = RangeCalculator.adjustRange(range); + + String newniuju = niuju; + if(bl_rev_object_name.contains("预紧")) { + newniuju = RangeAdjuster.adjustRange(niuju); + } + System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); + isWithinRange = RangChecker.isWithinRange(newniuju, newrange); + if(isWithinRange) { + System.out.println("新扭矩和新扭矩范围匹配"); + } + else { + System.out.println("新扭矩和新扭矩范围不匹配"); + } } - System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); - isWithinRange = RangChecker.isWithinRange(newniuju, newrange); - if(isWithinRange) { - System.out.println("新扭矩和新扭矩范围匹配"); + else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { + System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); + isWithinRange = true; } - else { - System.out.println("新扭矩和新扭矩范围不匹配"); + if(isWithinRange) { + System.out.println("后续和套筒匹配"); + Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); } } - else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { - System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); - isWithinRange = true; - } - if(isWithinRange) { - System.out.println("后续和套筒匹配"); - Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); - } + } } } else if("手动工具".equals(name)){ for(String resourceType:eleTool.keySet()) { List toolbeans = eleTool.get(resourceType); - Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).addAll(toolbeans); + for(ToolBean toolbean:toolbeans) { + String resourceName = toolbean.getResourceName(); + if(resourcename.containsKey(resourceName)) { + Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); + } + } +// Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).addAll(toolbeans); } } else if("气动工具".equals(name)){ @@ -1522,32 +1720,35 @@ public class AutoTransToolDialog extends AbstractAIFDialog { for(ToolBean toolbean:toolbeans) { String range = toolbean.getRange(); String outSize = toolbean.getOutSize(); - boolean isWithinRange = false; - if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { - range = range.replace("|", "-"); - String newrange = RangeCalculator.adjustRange(range); - - String newniuju = niuju; - if(bl_rev_object_name.contains("预紧")) { - newniuju = RangeAdjuster.adjustRange(niuju); + String resourceName = toolbean.getResourceName(); + if(resourcename.containsKey(resourceName)) { + boolean isWithinRange = false; + if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { + range = range.replace("|", "-"); + String newrange = RangeCalculator.adjustRange(range); + + String newniuju = niuju; + if(bl_rev_object_name.contains("预紧")) { + newniuju = RangeAdjuster.adjustRange(niuju); + } + System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); + isWithinRange = RangChecker.isWithinRange(newniuju, newrange); + if(isWithinRange) { + System.out.println("新扭矩和新扭矩范围匹配"); + } + else { + System.out.println("新扭矩和新扭矩范围不匹配"); + } } - System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); - isWithinRange = RangChecker.isWithinRange(newniuju, newrange); - if(isWithinRange) { - System.out.println("新扭矩和新扭矩范围匹配"); + else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { + System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); + isWithinRange = true; } - else { - System.out.println("新扭矩和新扭矩范围不匹配"); + if(isWithinRange) { + System.out.println("后续和套筒匹配"); + Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); } } - else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { - System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); - isWithinRange = true; - } - if(isWithinRange) { - System.out.println("后续和套筒匹配"); - Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); - } } } } @@ -1557,32 +1758,35 @@ public class AutoTransToolDialog extends AbstractAIFDialog { for(ToolBean toolbean:toolbeans) { String range = toolbean.getRange(); String outSize = toolbean.getOutSize(); - boolean isWithinRange = false; - if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { - range = range.replace("|", "-"); - String newrange = RangeCalculator.adjustRange(range); - - String newniuju = niuju; - if(bl_rev_object_name.contains("预紧")) { - newniuju = RangeAdjuster.adjustRange(niuju); + String resourceName = toolbean.getResourceName(); + if(resourcename.containsKey(resourceName)) { + boolean isWithinRange = false; + if(range!= null && range.length() > 0 && niuju != null && niuju.length() > 0) { + range = range.replace("|", "-"); + String newrange = RangeCalculator.adjustRange(range); + + String newniuju = niuju; + if(bl_rev_object_name.contains("预紧")) { + newniuju = RangeAdjuster.adjustRange(niuju); + } + System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); + isWithinRange = RangChecker.isWithinRange(newniuju, newrange); + if(isWithinRange) { + System.out.println("新扭矩和新扭矩范围匹配"); + } + else { + System.out.println("新扭矩和新扭矩范围不匹配"); + } } - System.out.print("判断BOM表中扭矩是否符合:"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" "); - isWithinRange = RangChecker.isWithinRange(newniuju, newrange); - if(isWithinRange) { - System.out.println("新扭矩和新扭矩范围匹配"); + else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { + System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); + isWithinRange = true; } - else { - System.out.println("新扭矩和新扭矩范围不匹配"); + if(isWithinRange) { + System.out.println("后续和套筒匹配"); + Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); } } - else if((range == null || range.length() == 0) && (niuju == null || niuju.length() == 0)) { - System.out.print("判断BOM表中扭矩是否符合:"+niuju+" 扭矩范围:"+range+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" 匹配扭矩"); - isWithinRange = true; - } - if(isWithinRange) { - System.out.println("后续和套筒匹配"); - Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(toolbean); - } } } } @@ -1602,10 +1806,16 @@ public class AutoTransToolDialog extends AbstractAIFDialog { StandardPartBean stdbean = StandardPartMap.get(designid); String headform = stdbean.getHeadform(); String headsize = stdbean.getHeadsize(); + Cell headform_cell = row.createCell(6); + headform_cell.setCellValue(headform); + Cell headsize_cell = row.createCell(7); + headsize_cell.setCellValue(headsize); String key2 = headsize+"|"+headform; System.out.println("寻找套筒 头部尺寸|头部形式:"+key2); if(SleeveMap.containsKey(key2)) { System.out.println("找到匹配"); + Cell all_cell = row.createCell(8); + String all = ""; List SleeveBeans = SleeveMap.get(key2); for(SleeveBean sleevebean:SleeveBeans) { String inputsize = sleevebean.getInputSize(); @@ -1614,19 +1824,35 @@ public class AutoTransToolDialog extends AbstractAIFDialog { //后续工具与套筒匹配 for(String resourcetype:Tool.keySet()) { List toolsbean = Tool.get(resourcetype); +// Cell toolresourceType_cell = row.createCell(8); +// toolresourceType_cell.setCellValue(resourcetype); + boolean has = false; for(ToolBean toolbean:toolsbean) { String outsize = toolbean.getOutSize(); if(outsize != null && outsize.length() > 0 && inputsize != null && inputsize.length() > 0) { if(outsize.equals(inputsize)) { System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType); + has = true; + all = all+resourcetype+"-"+resourceType; + break; } } else if((outsize == null || outsize.length() == 0) && (inputsize == null || inputsize.length() == 0)){ System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType); + + all = all+resourcetype+"-"+resourceType; + has = true; + break; } } + if(has) { +// Cell resourceType_cell = row.createCell(9); +// resourceType_cell.setCellValue(resourceType); + break; + } } } + all_cell.setCellValue(all); } else System.out.println("没有找到匹配"); @@ -1634,6 +1860,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog { } else { System.out.println("未找到匹配的"); + } } } @@ -1647,7 +1874,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog { else if(childcom instanceof TCComponentMfgBvrProcessStation || childcom instanceof TCComponentMfgBvrProcessLine || childcom instanceof TCComponentMfgBvrPlantBOP) { - getparent((TCComponentBOMLine)childcom); + getparent((TCComponentBOMLine)childcom,sheet); } if(op_nodesignmap.size() > 0) { @@ -1661,7 +1888,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog { if(op_nodesignmap.size() > 0) { no_load.put(parentid, parentid); if(parent.parent() != null) - getparent(parent.parent()); + getparent(parent.parent(),sheet); } } } @@ -1894,12 +2121,14 @@ public class AutoTransToolDialog extends AbstractAIFDialog { String ResourceType = ExcelUtil.getStringCellValue(row.getCell(1)); String Torque = ExcelUtil.getStringCellValue(row.getCell(6)); String outSize = ExcelUtil.getStringCellValue(row.getCell(8)); + String resourceName = ExcelUtil.getStringCellValue(row.getCell(2)); if(ResourceType != null && ResourceType.length() > 0) { // 使用 computeIfAbsent 简化操作 ToolBean tool = new ToolBean(); tool.setOutSize(outSize); tool.setRange(Torque); + tool.setResourceName(resourceName); eleTool.computeIfAbsent(ResourceType, key -> new ArrayList<>()).add(tool); } diff --git a/com.sq.customization/src/com/sq/customization/handlers/SampleHandler.java b/com.sq.customization/src/com/sq/customization/handlers/SampleHandler.java index 13364d5..3b7ff2e 100644 --- a/com.sq.customization/src/com/sq/customization/handlers/SampleHandler.java +++ b/com.sq.customization/src/com/sq/customization/handlers/SampleHandler.java @@ -7,33 +7,25 @@ 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; -// } + if(target == null || target.length != 1) { + MessageBox.post(app.getDesktop(),"请选择对象", "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())) { diff --git a/com.sq.customization/src/com/sq/customization/util/RangChecker.java b/com.sq.customization/src/com/sq/customization/util/RangChecker.java index 1ffc069..131c898 100644 --- a/com.sq.customization/src/com/sq/customization/util/RangChecker.java +++ b/com.sq.customization/src/com/sq/customization/util/RangChecker.java @@ -1,5 +1,15 @@ package com.sq.customization.util; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; + public class RangChecker { // 解析范围并返回 [min, max] 数组 private static double[] parseRange(String range) { @@ -73,5 +83,34 @@ public class RangChecker { System.out.println("Input: " + input + " -> Within " + targetRange + ": " + isWithinRange(input, targetRange)); } + + Map map1 = new HashMap<>(); + map1.put("a", 1); + map1.put("b", 2); + map1.put("c", 3); + + Map map2 = new HashMap<>(); + map2.put("b", 10); + map2.put("c", 20); + map2.put("d", 30); + + Map map3 = new HashMap<>(); + map3.put("c", 5); + map3.put("b", 6); + map3.put("e", 7); + + Map map4 = new HashMap<>(); + map4.put("c", 100); + map4.put("b", 200); + + Set commonKeys = new HashSet<>(map1.keySet()); + + // 保留 map2、map3、map4 中也有的键 + commonKeys.retainAll(map2.keySet()); + commonKeys.retainAll(map3.keySet()); + commonKeys.retainAll(map4.keySet()); + + // 输出四个 Map 都有的 key + System.out.println("四个 Map 都有的 key: " + commonKeys); } }