1.报表输出

main
xuezhou 1 month ago
parent 8a5a36da5f
commit 460db9f6c6

@ -3,20 +3,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/easyexcel-core-3.2.0.jar"/>
<classpathentry kind="lib" path="lib/commons-collections4-4.1.jar"/>
<classpathentry kind="lib" path="lib/poi-3.17.jar"/>
<classpathentry kind="lib" path="lib/poi-examples-3.17.jar"/>
<classpathentry kind="lib" path="lib/poi-excelant-3.17.jar"/>
<classpathentry kind="lib" path="lib/poi-ooxml-3.17.jar"/>
<classpathentry kind="lib" path="lib/poi-ooxml-schemas-3.17.jar"/>
<classpathentry kind="lib" path="lib/poi-scratchpad-3.17.jar"/>
<classpathentry kind="lib" path="lib/xmlbeans-2.6.0.jar"/>
<classpathentry kind="lib" path="lib/xml-apis-1.4.01.jar"/>
<classpathentry kind="lib" path="lib/xalan-2.7.2.jar"/>
<classpathentry kind="lib" path="lib/serializer-2.7.2.jar"/>
<classpathentry kind="lib" path="lib/cglib-3.3.0.jar"/>
<classpathentry kind="lib" path="lib/easyexcel-support-3.2.0.jar"/>
<classpathentry kind="lib" path="lib/easyexcel-3.2.0.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

@ -7,35 +7,23 @@ Bundle-Activator: com.sq.customization.Activator
Bundle-Vendor: SQ Bundle-Vendor: SQ
Require-Bundle: org.eclipse.ui, Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime, org.eclipse.core.runtime,
com.teamcenter.rac.aifrcp;bundle-version="13000.3.0", com.teamcenter.rac.aifrcp,
com.teamcenter.rac.common;bundle-version="13000.3.0", com.teamcenter.rac.common,
com.teamcenter.rac.external;bundle-version="13000.3.0", com.teamcenter.rac.external,
com.teamcenter.rac.kernel;bundle-version="13000.3.0", com.teamcenter.rac.kernel,
com.teamcenter.rac.pca;bundle-version="13000.3.0", com.teamcenter.rac.pca,
com.teamcenter.rac.pse;bundle-version="13000.3.0", com.teamcenter.rac.pse,
com.teamcenter.rac.tcapps;bundle-version="13000.3.0", com.teamcenter.rac.tcapps,
com.teamcenter.rac.ui;bundle-version="13000.3.0", com.teamcenter.rac.ui,
com.teamcenter.rac.ui.views;bundle-version="13000.3.0", com.teamcenter.rac.ui.views,
com.teamcenter.rac.util;bundle-version="13000.3.0", com.teamcenter.rac.util,
com.teamcenter.rac.pca.kernel;bundle-version="13000.3.0", com.teamcenter.rac.pca.kernel,
com.teamcenter.rac.pse.pca;bundle-version="13000.3.0", com.teamcenter.rac.pse.pca,
com.teamcenter.rac.cme.kernel;bundle-version="13000.3.0" com.teamcenter.rac.cme.kernel,
org.apache.poi.39
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: com.sq.customization Automatic-Module-Name: com.sq.customization
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-ClassPath: lib/cglib-3.3.0.jar, Export-Package: com.sq.customization,
lib/commons-collections4-4.1.jar, com.sq.customization.dialogs,
lib/easyexcel-3.2.0.jar, com.sq.customization.handlers
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

@ -1,21 +1,8 @@
source.. = src/
output.. = bin/ output.. = bin/
javacDefaultEncoding.. = UTF-8 javacDefaultEncoding.. = UTF-8
bin.includes = plugin.xml,\ bin.includes = plugin.xml,\
META-INF/,\ META-INF/,\
.,\
icons/,\ icons/,\
lib/cglib-3.3.0.jar,\ build.properties
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

@ -1,23 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?> <?eclipse version="3.4"?>
<plugin> <plugin>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.sq.customization.handlers.SampleHandler"
commandId="com.sq.customization.commands.sampleCommand">
</handler>
</extension>
<extension <extension
point="org.eclipse.ui.commands"> point="org.eclipse.ui.commands">
<command <command
categoryId="com.sq.customization.commands.category"
name="【自动匹配替换工具】" name="【自动匹配替换工具】"
id="com.sq.customization.commands.sampleCommand"> id="com.sq.customization.commands.sampleCommand">
</command> </command>
</extension> </extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.sq.customization.handlers.SampleHandler"
commandId="com.sq.customization.commands.sampleCommand">
</handler>
</extension>
<extension <extension
point="org.eclipse.ui.menus"> point="org.eclipse.ui.menus">

@ -1,140 +1,140 @@
package com.sq.customization.bean; //package com.sq.customization.bean;
//
import java.io.FileInputStream; //import java.io.FileInputStream;
import java.io.FileOutputStream; //import java.io.FileOutputStream;
import java.io.IOException; //import java.io.IOException;
import java.util.Arrays; //import java.util.Arrays;
import java.util.List; //import java.util.List;
//
import org.apache.poi.EncryptedDocumentException; //import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; //import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell; //import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; //import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; //import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; //import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory; //import org.apache.poi.ss.usermodel.WorkbookFactory;
//
import com.alibaba.excel.EasyExcel; //import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty; //import com.alibaba.excel.annotation.ExcelProperty;
import com.sq.customization.util.ExcelUtil; //import com.sq.customization.util.ExcelUtil;
//
public class ExcelBean { //public class ExcelBean {
@ExcelProperty("工序信息") // @ExcelProperty("工序信息")
private String bl_indented_title; // private String bl_indented_title;
@ExcelProperty("紧固件号") // @ExcelProperty("紧固件号")
private String item_id; // private String item_id;
@ExcelProperty("SSVPPS") // @ExcelProperty("SSVPPS")
private String SSVPPS; // private String SSVPPS;
@ExcelProperty("FCC") // @ExcelProperty("FCC")
private String FCC; // private String FCC;
@ExcelProperty("动态扭矩") // @ExcelProperty("动态扭矩")
private String dongtai; // private String dongtai;
@ExcelProperty("KCDS") // @ExcelProperty("KCDS")
private String KCDS; // private String KCDS;
@ExcelProperty("头部形式") // @ExcelProperty("头部形式")
private String headForm; // private String headForm;
@ExcelProperty("头部尺寸") // @ExcelProperty("头部尺寸")
private String headSize; // private String headSize;
@ExcelProperty("工具组合") // @ExcelProperty("工具组合")
private String alltool; // private String alltool;
@ExcelProperty("工具") // @ExcelProperty("工具")
private String SleeveResourceType; // private String SleeveResourceType;
@ExcelProperty("套筒") // @ExcelProperty("套筒")
private String ToolResourceType; // private String ToolResourceType;
//
public ExcelBean() {} // public ExcelBean() {}
//
public ExcelBean(String bl_indented_title, String item_id, String SSVPPS, String FCC, String dongtai, // 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 KCDS, String headForm, String headSize, String alltool, String SleeveResourceType,
String ToolResourceType) { // String ToolResourceType) {
this.bl_indented_title = bl_indented_title; // this.bl_indented_title = bl_indented_title;
this.item_id = item_id; // this.item_id = item_id;
this.SSVPPS = SSVPPS; // this.SSVPPS = SSVPPS;
this.FCC = FCC; // this.FCC = FCC;
this.dongtai = dongtai; // this.dongtai = dongtai;
this.KCDS = KCDS; // this.KCDS = KCDS;
this.headForm = headForm; // this.headForm = headForm;
this.headSize = headSize; // this.headSize = headSize;
this.alltool = alltool; // this.alltool = alltool;
this.SleeveResourceType = SleeveResourceType; // this.SleeveResourceType = SleeveResourceType;
this.ToolResourceType = ToolResourceType; // this.ToolResourceType = ToolResourceType;
} // }
//
// Getter 和 Setter保持不变省略以节省篇幅 // // Getter 和 Setter保持不变省略以节省篇幅
//
public static void main(String[] args) { // public static void main(String[] args) {
List<ExcelBean> data = Arrays.asList( // List<ExcelBean> data = Arrays.asList(
new ExcelBean("工序1", "ID001", "SSVPPS1", "FCC1", "动态1", "KCDS1", "圆头", "10mm", "工具A", "工具类型1", "套筒1"), // new ExcelBean("工序1", "ID001", "SSVPPS1", "FCC1", "动态1", "KCDS1", "圆头", "10mm", "工具A", "工具类型1", "套筒1"),
new ExcelBean("工序2", "ID002", "SSVPPS2", "FCC2", "动态2", "KCDS2", "平头", "12mm", "工具B", "工具类型2", "套筒2") // 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"; // 修改为可写路径 // String fileName = "C:\\Users\\TEMP.CNSHI6P1090.000.001.002.003.004.005.006\\Desktop\\新建文件夹\\cust_rule_data.xlsx"; // 修改为可写路径
try (FileOutputStream fos = new FileOutputStream(fileName)) { // try (FileOutputStream fos = new FileOutputStream(fileName)) {
EasyExcel.write(fos, ExcelBean.class) // EasyExcel.write(fos, ExcelBean.class)
.sheet("Sheet1") // .sheet("Sheet1")
.doWrite(data); // .doWrite(data);
System.out.println("数据已成功导出到 " + fileName); // System.out.println("数据已成功导出到 " + fileName);
} catch (Exception e) { // } catch (Exception e) {
System.err.println("导出失败: " + e.getMessage()); // System.err.println("导出失败: " + e.getMessage());
e.printStackTrace(); // 打印详细异常信息 // e.printStackTrace(); // 打印详细异常信息
} // }
// String filePath = "C:\\Users\\YourName\\Desktop\\cust_rule_data.xlsx"; // 替换为你的 Excel 文件路径 //// String filePath = "C:\\Users\\YourName\\Desktop\\cust_rule_data.xlsx"; // 替换为你的 Excel 文件路径
//
try (FileInputStream fis = new FileInputStream(fileName)) { // try (FileInputStream fis = new FileInputStream(fileName)) {
// 使用 WorkbookFactory 自动适配 .xls 和 .xlsx // // 使用 WorkbookFactory 自动适配 .xls 和 .xlsx
Workbook workbook = WorkbookFactory.create(fis); // Workbook workbook = WorkbookFactory.create(fis);
//
// 获取第一个工作表Sheet1 // // 获取第一个工作表Sheet1
Sheet sheet = workbook.getSheetAt(0); // 或使用 getSheet("Sheet1") 指定名称 // Sheet sheet = workbook.getSheetAt(0); // 或使用 getSheet("Sheet1") 指定名称
//
// 遍历所有行 // // 遍历所有行
for (Row row : sheet) { // for (Row row : sheet) {
// 遍历每行中的单元格 // // 遍历每行中的单元格
for (Cell cell : row) { // for (Cell cell : row) {
// 根据单元格类型读取数据 // // 根据单元格类型读取数据
String value = ExcelUtil.getStringCellValue(cell); // String value = ExcelUtil.getStringCellValue(cell);
System.out.println(value); // System.out.println(value);
} // }
System.out.println(); // 每行结束后换行 // System.out.println(); // 每行结束后换行
} // }
//
// 关闭工作簿 // // 关闭工作簿
workbook.close(); // workbook.close();
System.out.println("Excel 文件读取完成"); // System.out.println("Excel 文件读取完成");
//
} catch (IOException e) { // } catch (IOException e) {
System.err.println("读取 Excel 失败: " + e.getMessage()); // System.err.println("读取 Excel 失败: " + e.getMessage());
e.printStackTrace(); // e.printStackTrace();
} catch (EncryptedDocumentException e) { // } catch (EncryptedDocumentException e) {
// TODO Auto-generated catch block // // TODO Auto-generated catch block
e.printStackTrace(); // e.printStackTrace();
} catch (InvalidFormatException e) { // } catch (InvalidFormatException e) {
// TODO Auto-generated catch block // // TODO Auto-generated catch block
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
//
// Getter 和 Setter以下为完整代码之前省略的部分 // // Getter 和 Setter以下为完整代码之前省略的部分
public String getBl_indented_title() { return bl_indented_title; } // 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 void setBl_indented_title(String bl_indented_title) { this.bl_indented_title = bl_indented_title; }
public String getItem_id() { return item_id; } // public String getItem_id() { return item_id; }
public void setItem_id(String item_id) { this.item_id = item_id; } // public void setItem_id(String item_id) { this.item_id = item_id; }
public String getSSVPPS() { return SSVPPS; } // public String getSSVPPS() { return SSVPPS; }
public void setSSVPPS(String SSVPPS) { this.SSVPPS = SSVPPS; } // public void setSSVPPS(String SSVPPS) { this.SSVPPS = SSVPPS; }
public String getFCC() { return FCC; } // public String getFCC() { return FCC; }
public void setFCC(String FCC) { this.FCC = FCC; } // public void setFCC(String FCC) { this.FCC = FCC; }
public String getDongtai() { return dongtai; } // public String getDongtai() { return dongtai; }
public void setDongtai(String dongtai) { this.dongtai = dongtai; } // public void setDongtai(String dongtai) { this.dongtai = dongtai; }
public String getKCDS() { return KCDS; } // public String getKCDS() { return KCDS; }
public void setKCDS(String KCDS) { this.KCDS = KCDS; } // public void setKCDS(String KCDS) { this.KCDS = KCDS; }
public String getHeadForm() { return headForm; } // public String getHeadForm() { return headForm; }
public void setHeadForm(String headForm) { this.headForm = headForm; } // public void setHeadForm(String headForm) { this.headForm = headForm; }
public String getHeadSize() { return headSize; } // public String getHeadSize() { return headSize; }
public void setHeadSize(String headSize) { this.headSize = headSize; } // public void setHeadSize(String headSize) { this.headSize = headSize; }
public String getAlltool() { return alltool; } // public String getAlltool() { return alltool; }
public void setAlltool(String alltool) { this.alltool = alltool; } // public void setAlltool(String alltool) { this.alltool = alltool; }
public String getSleeveResourceType() { return SleeveResourceType; } // public String getSleeveResourceType() { return SleeveResourceType; }
public void setSleeveResourceType(String SleeveResourceType) { this.SleeveResourceType = SleeveResourceType; } // public void setSleeveResourceType(String SleeveResourceType) { this.SleeveResourceType = SleeveResourceType; }
public String getToolResourceType() { return ToolResourceType; } // public String getToolResourceType() { return ToolResourceType; }
public void setToolResourceType(String ToolResourceType) { this.ToolResourceType = ToolResourceType; } // public void setToolResourceType(String ToolResourceType) { this.ToolResourceType = ToolResourceType; }
} //}

@ -7,33 +7,25 @@ import org.eclipse.core.commands.ExecutionException;
import com.sq.customization.dialogs.AutoTransToolDialog; import com.sq.customization.dialogs.AutoTransToolDialog;
import com.teamcenter.rac.aif.AbstractAIFUIApplication; import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility; 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.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.Registry;
public class SampleHandler extends AbstractHandler { public class SampleHandler extends AbstractHandler {
private AbstractAIFUIApplication app; private AbstractAIFUIApplication app;
private TCSession session; private TCSession session;
// private Registry registry = Registry.getRegistry(SampleHandler.class);
@Override @Override
public Object execute(ExecutionEvent event) throws ExecutionException { public Object execute(ExecutionEvent event) throws ExecutionException {
app = AIFUtility.getCurrentApplication(); app = AIFUtility.getCurrentApplication();
session = (TCSession) app.getSession(); session = (TCSession) app.getSession();
InterfaceAIFComponent[] target = app.getTargetComponents(); InterfaceAIFComponent[] target = app.getTargetComponents();
if(target == null || target.length != 1) {
MessageBox.post(app.getDesktop(),"请选择对象", "Message", MessageBox.INFORMATION);
return null;
// if(target == null || target.length != 1) { }
// MessageBox.post(app.getDesktop(),registry.getString("BOPInitHandler.selecterror"), "Message", MessageBox.INFORMATION);
// return null;
// }
System.out.println(target[0].getType()); System.out.println(target[0].getType());
System.out.println(target[0].getClass()); System.out.println(target[0].getClass());
if("Mfg0BvrPlantBOP".equals(target[0].getType()) || "Mfg0BvrProcessLine".equals(target[0].getType()) || "Mfg0BvrProcessStation".equals(target[0].getType())) { if("Mfg0BvrPlantBOP".equals(target[0].getType()) || "Mfg0BvrProcessLine".equals(target[0].getType()) || "Mfg0BvrProcessStation".equals(target[0].getType())) {

@ -1,5 +1,15 @@
package com.sq.customization.util; 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 { public class RangChecker {
// 解析范围并返回 [min, max] 数组 // 解析范围并返回 [min, max] 数组
private static double[] parseRange(String range) { private static double[] parseRange(String range) {
@ -73,5 +83,34 @@ public class RangChecker {
System.out.println("Input: " + input + " -> Within " + targetRange + ": " + System.out.println("Input: " + input + " -> Within " + targetRange + ": " +
isWithinRange(input, targetRange)); isWithinRange(input, targetRange));
} }
Map<String, Integer> map1 = new HashMap<>();
map1.put("a", 1);
map1.put("b", 2);
map1.put("c", 3);
Map<String, Integer> map2 = new HashMap<>();
map2.put("b", 10);
map2.put("c", 20);
map2.put("d", 30);
Map<String, Integer> map3 = new HashMap<>();
map3.put("c", 5);
map3.put("b", 6);
map3.put("e", 7);
Map<String, Integer> map4 = new HashMap<>();
map4.put("c", 100);
map4.put("b", 200);
Set<String> 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);
} }
} }

Loading…
Cancel
Save