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.pde.core.requiredPlugins"/>
<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"/>
</classpath>

@ -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

@ -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

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

@ -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<ExcelBean> 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<ExcelBean> 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; }
//}

@ -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())) {

@ -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<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