1.电动工具新型号直接输出资源,直接获取该工具的输出尺寸,匹配套筒

2.执行完特殊工艺规则及电动工具新型号两个规则后,优先判定工序名称是否包含预紧,若包含,选用电池工具,直接进入扭矩值判定,不用执行excel中后续规则
3.此界面增加一行。【操作类型】,填写BOM表中对应列,获取BOM表中数据时,过滤掉【操作类型】为“D”的数据
4.若FFC中文描述里有“-”,则取-后的文字进行模糊查询
5.若动态扭矩未A±B时,如60±5,用60执行扭矩值判定规则 扭矩值填写规范 增加N.M NM N·M 不区分大小写··
main
xuezhou 1 week ago
parent 32a871c418
commit 7661cdd74d

@ -86,6 +86,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
private PropertyTextField FCCDEStext; private PropertyTextField FCCDEStext;
private PropertyTextField dongtaitext; private PropertyTextField dongtaitext;
private PropertyTextField KCDStext; private PropertyTextField KCDStext;
private PropertyTextField operationTypetext;
private JButton ok; private JButton ok;
private JButton cancel; private JButton cancel;
@ -178,26 +179,32 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
KCDStext.setRequired(true); KCDStext.setRequired(true);
northPane.add("6.2",KCDStext); northPane.add("6.2",KCDStext);
northPane.add("7.1.left",new JLabel("操作类型:"));
operationTypetext = new PropertyTextField();
operationTypetext.setColumns(30);
operationTypetext.setRequired(true);
northPane.add("7.2",operationTypetext);
northPane.add("7.1.left",new JLabel("数据文件:"));
northPane.add("8.1.left",new JLabel("数据文件:"));
text = new PropertyTextField(); text = new PropertyTextField();
text.setColumns(30); text.setColumns(30);
text.setRequired(true); text.setRequired(true);
text.setEnabled(false); text.setEnabled(false);
northPane.add("7.2",text); northPane.add("8.2",text);
directory = new JButton("..."); directory = new JButton("...");
northPane.add("7.3",directory); northPane.add("8.3",directory);
northPane.add("8.1.left",new JLabel("导出路径:")); northPane.add("9.1.left",new JLabel("导出路径:"));
dirtext = new PropertyTextField(); dirtext = new PropertyTextField();
dirtext.setColumns(30); dirtext.setColumns(30);
dirtext.setRequired(true); dirtext.setRequired(true);
dirtext.setEnabled(false); dirtext.setEnabled(false);
northPane.add("8.2",dirtext); northPane.add("9.2",dirtext);
directory2 = new JButton("..."); directory2 = new JButton("...");
northPane.add("8.3",directory2); northPane.add("9.3",directory2);
JPanel southpanel = new JPanel(new ButtonLayout()); JPanel southpanel = new JPanel(new ButtonLayout());
ok = new JButton("确定"); ok = new JButton("确定");
@ -262,6 +269,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String fccdescol = FCCDEStext.getText(); String fccdescol = FCCDEStext.getText();
String dongtaicol = dongtaitext.getText(); String dongtaicol = dongtaitext.getText();
String kcdscol = KCDStext.getText(); String kcdscol = KCDStext.getText();
String operationTypecol = operationTypetext.getText();
final File excel = new File(path); final File excel = new File(path);
if(!excel.exists()) { if(!excel.exists()) {
@ -361,7 +369,9 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
final File standardpartfile = cust_standardpart_excelfiles[0]; final File standardpartfile = cust_standardpart_excelfiles[0];
final File sleevefile = cust_sleeve_excelfiles[0]; final File sleevefile = cust_sleeve_excelfiles[0];
if(isValidExcelColumn(idcol) && isValidExcelColumn(svppscol) && isValidExcelColumn(fcccol) if(isValidExcelColumn(idcol) && isValidExcelColumn(svppscol) && isValidExcelColumn(fcccol)
&& isValidExcelColumn(fccdescol) && isValidExcelColumn(dongtaicol) && isValidExcelColumn(kcdscol)) { && isValidExcelColumn(fccdescol) && isValidExcelColumn(dongtaicol) && isValidExcelColumn(kcdscol)
&& isValidExcelColumn(operationTypecol)
) {
op_nodesignmap.clear(); op_nodesignmap.clear();
no_load.clear(); no_load.clear();
DesignPartBeanMap.clear(); DesignPartBeanMap.clear();
@ -383,6 +393,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
final int fccdescol2 = columnToNumber(fccdescol.toUpperCase()); final int fccdescol2 = columnToNumber(fccdescol.toUpperCase());
final int dongtaicol2 = columnToNumber(dongtaicol.toUpperCase()); final int dongtaicol2 = columnToNumber(dongtaicol.toUpperCase());
final int kcdscol2 = columnToNumber(kcdscol.toUpperCase()); final int kcdscol2 = columnToNumber(kcdscol.toUpperCase());
final int operationTypecol2 = columnToNumber(operationTypecol.toUpperCase());
Thread thread = new Thread(){ Thread thread = new Thread(){
public void run(){ public void run(){
ProgressCustomDialog.lbStatus.setText("正在创建 ...."); ProgressCustomDialog.lbStatus.setText("正在创建 ....");
@ -406,7 +417,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
headerRow.createCell(6).setCellValue("头部尺寸"); headerRow.createCell(6).setCellValue("头部尺寸");
headerRow.createCell(7).setCellValue("工具组合"); headerRow.createCell(7).setCellValue("工具组合");
headerRow.createCell(8).setCellValue("工具"); headerRow.createCell(8).setCellValue("工具");
headerRow.createCell(9).setCellValue("工具套筒"); headerRow.createCell(9).setCellValue("套筒");
//读取自定义的表 //读取自定义的表
readRuleExcel(excelfile); readRuleExcel(excelfile);
readElectricfile(electricfile,1); readElectricfile(electricfile,1);
@ -417,7 +428,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
readsleevefile(sleevefile,1); readsleevefile(sleevefile,1);
row_num = 1; row_num = 1;
//读取EXCEL //读取EXCEL
readExcel(excel,2,idcol2,svppscol2,fcccol2,fccdescol2,dongtaicol2,kcdscol2); readExcel(excel,2,idcol2,svppscol2,fcccol2,fccdescol2,dongtaicol2,kcdscol2,operationTypecol2);
//先处理选中对象层级有design的工序获取没有design的工序 //先处理选中对象层级有design的工序获取没有design的工序
@ -480,7 +491,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
} }
}; };
ProgressCustomDialog.show(thread, "执行中", null, null, null); ProgressCustomDialog.show(thread, "执行中", "执行结束", null, null);
AutoTransToolDialog.this.dispose(); AutoTransToolDialog.this.dispose();
} }
@ -594,10 +605,20 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String niuju = ""; String niuju = "";
String dongtai = bean.getDongtai(); String dongtai = bean.getDongtai();
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// niuju = split[0];
// }
// }
System.out.println("dongtai:"+dongtai);
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
System.out.println("使用正则表达式分隔符 NM, N.M, N·M不区分大小写");
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length ==2) { if(split!= null && split.length ==2) {
niuju = split[0]; niuju = split[0];
System.out.println("BOM 扭矩:"+niuju);
} }
} }
} }
@ -630,10 +651,19 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String rule_dongtai = rulebean.getDongtai(); String rule_dongtai = rulebean.getDongtai();
if(rule_dongtai != null && rule_dongtai.length() > 0) { if(rule_dongtai != null && rule_dongtai.length() > 0) {
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// niuju = split[0];
// boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
// if(!result)
// is_ok = false;
// }
// }
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) { if(split!= null && split.length == 2) {
niuju = split[0];
boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]); boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
if(!result) if(!result)
is_ok = false; is_ok = false;
@ -736,45 +766,59 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String resourceType = rulebean.getResourceType(); String resourceType = rulebean.getResourceType();
System.out.println("匹配上电动工具,资源型号:"+resourceType); System.out.println("匹配上电动工具,资源型号:"+resourceType);
if(eleTool.containsKey(resourceType)) { if(eleTool.containsKey(resourceType)) {
System.out.println("后续和套筒匹配");
List<ToolBean> tools = eleTool.get(resourceType); List<ToolBean> tools = eleTool.get(resourceType);
for(ToolBean tool:tools) { for(ToolBean tool:tools) {
String range = tool.getRange(); String range = tool.getRange();
String outSize = tool.getOutSize(); String outSize = tool.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);
}
System.out.print("判断BOM表中扭矩是否符合"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" ");
isWithinRange = RangChecker.isWithinRange(newniuju, newrange);
if(isWithinRange) {
System.out.println("新扭矩和新扭矩范围匹配");
}
else {
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;
}
if(isWithinRange) {
System.out.println("后续和套筒匹配");
Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(tool); Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(tool);
// 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("新扭矩和新扭矩范围不匹配");
// }
// }
// 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(tool);
// }
} }
} }
else {
System.out.println("没有电动工具和套筒匹配");
} }
} }
} }
} }
if(!autotoolrule) { if(!autotoolrule) {
Set<String> commonKeys = null;
Map<String,String> resourcename = new HashMap<>(); Map<String,String> resourcename = new HashMap<>();
if(bl_rev_object_name.contains("预紧")) {
commonKeys= new HashSet<>();
commonKeys.add("电池工具");
resourcename.put("枪式电池枪", "枪式电池枪");
}
else {
//拧紧性质规则 //拧紧性质规则
//看读取哪个表 //看读取哪个表
Map<String,Integer> Tightenexcelname = new HashMap<>(); Map<String,Integer> Tightenexcelname = new HashMap<>();
@ -798,8 +842,17 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
if(rule_dongtai != null && rule_dongtai.length() > 0) { if(rule_dongtai != null && rule_dongtai.length() > 0) {
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
// if(!result)
// is_ok = false;
// }
// }
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) { if(split!= null && split.length == 2) {
boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]); boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
if(!result) if(!result)
@ -901,8 +954,17 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String rule_dongtai = rulebean.getDongtai(); String rule_dongtai = rulebean.getDongtai();
if(rule_dongtai != null && rule_dongtai.length() > 0) { if(rule_dongtai != null && rule_dongtai.length() > 0) {
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
// if(!result)
// is_ok = false;
// }
// }
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) { if(split!= null && split.length == 2) {
boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]); boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
if(!result) if(!result)
@ -960,8 +1022,17 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String rule_dongtai = rulebean.getDongtai(); String rule_dongtai = rulebean.getDongtai();
if(rule_dongtai != null && rule_dongtai.length() > 0) { if(rule_dongtai != null && rule_dongtai.length() > 0) {
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
// if(!result)
// is_ok = false;
// }
// }
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) { if(split!= null && split.length == 2) {
boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]); boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
if(!result) if(!result)
@ -1012,12 +1083,14 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
} }
// 将所有 Map 放入一个列表 // 将所有 Map 放入一个列表
// List<Map<String, Integer>> maps = Arrays.asList(Tightenexcelname, KCDSexcelname, TightenMethodexcelname, Torqueexcelname); // List<Map<String, Integer>> maps = Arrays.asList(Tightenexcelname, KCDSexcelname, TightenMethodexcelname, Torqueexcelname);
Set<String> commonKeys = new HashSet<>(Tightenexcelname.keySet()); commonKeys = new HashSet<>(Tightenexcelname.keySet());
// 保留 map2、map3、map4 中也有的键 // 保留 map2、map3、map4 中也有的键
commonKeys.retainAll(KCDSexcelname.keySet()); commonKeys.retainAll(KCDSexcelname.keySet());
commonKeys.retainAll(TightenMethodexcelname.keySet()); commonKeys.retainAll(TightenMethodexcelname.keySet());
commonKeys.retainAll(Torqueexcelname.keySet()); commonKeys.retainAll(Torqueexcelname.keySet());
}
System.out.println("四个 Map 都有的 key: " + commonKeys); System.out.println("四个 Map 都有的 key: " + commonKeys);
//读取工具excel数据 //读取工具excel数据
for(String name:commonKeys) { for(String name:commonKeys) {
@ -1195,6 +1268,8 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
if(SleeveMap.containsKey(key2)) { if(SleeveMap.containsKey(key2)) {
System.out.println("找到匹配"); System.out.println("找到匹配");
Cell all_cell = row.createCell(7); Cell all_cell = row.createCell(7);
Cell tool_cell = row.createCell(8);
Cell tong_cell = row.createCell(9);
String all = ""; String all = "";
List<SleeveBean> SleeveBeans = SleeveMap.get(key2); List<SleeveBean> SleeveBeans = SleeveMap.get(key2);
for(SleeveBean sleevebean:SleeveBeans) { for(SleeveBean sleevebean:SleeveBeans) {
@ -1219,6 +1294,8 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType); System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType);
has = true; has = true;
all = all+resourcetype+"+"+resourceType; all = all+resourcetype+"+"+resourceType;
tool_cell.setCellValue(resourcetype);
tong_cell.setCellValue(resourceType);
break; break;
} }
} }
@ -1226,6 +1303,8 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType); System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType);
all = all+resourcetype+"+"+resourceType; all = all+resourcetype+"+"+resourceType;
tool_cell.setCellValue(resourcetype);
tong_cell.setCellValue(resourceType);
has = true; has = true;
break; break;
} }
@ -1495,10 +1574,20 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String niuju = ""; String niuju = "";
String dongtai = bean.getDongtai(); String dongtai = bean.getDongtai();
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// niuju = split[0];
// }
// }
System.out.println("dongtai:"+dongtai);
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
System.out.println("使用正则表达式分隔符 NM, N.M, N·M不区分大小写");
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) { if(split!= null && split.length == 2) {
niuju = split[0]; niuju = split[0];
System.out.println("BOM 扭矩:"+niuju);
} }
} }
} }
@ -1531,10 +1620,19 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String rule_dongtai = rulebean.getDongtai(); String rule_dongtai = rulebean.getDongtai();
if(rule_dongtai != null && rule_dongtai.length() > 0) { if(rule_dongtai != null && rule_dongtai.length() > 0) {
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// niuju = split[0];
// boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
// if(!result)
// is_ok = false;
// }
// }
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) { if(split!= null && split.length == 2) {
niuju = split[0];
boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]); boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
if(!result) if(!result)
is_ok = false; is_ok = false;
@ -1637,45 +1735,59 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String resourceType = rulebean.getResourceType(); String resourceType = rulebean.getResourceType();
System.out.println("匹配上电动工具,资源型号:"+resourceType); System.out.println("匹配上电动工具,资源型号:"+resourceType);
if(eleTool.containsKey(resourceType)) { if(eleTool.containsKey(resourceType)) {
System.out.println("后续和套筒匹配");
List<ToolBean> tools = eleTool.get(resourceType); List<ToolBean> tools = eleTool.get(resourceType);
for(ToolBean tool:tools) { for(ToolBean tool:tools) {
String range = tool.getRange(); String range = tool.getRange();
String outSize = tool.getOutSize(); String outSize = tool.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);
}
System.out.print("判断BOM表中扭矩是否符合"+niuju+"新扭矩:"+newniuju+" 扭矩范围:"+range+" 新扭矩范围:"+newrange+" 资源型号:"+resourceType+" 输出尺寸:"+outSize+" ");
isWithinRange = RangChecker.isWithinRange(newniuju, newrange);
if(isWithinRange) {
System.out.println("新扭矩和新扭矩范围匹配");
}
else {
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;
}
if(isWithinRange) {
System.out.println("后续和套筒匹配");
Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(tool); Tool.computeIfAbsent(resourceType, key2 -> new ArrayList<>()).add(tool);
// 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("新扭矩和新扭矩范围不匹配");
// }
// }
// 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(tool);
// }
} }
} }
else {
System.out.println("没有电动工具和套筒匹配");
} }
} }
} }
} }
if(!autotoolrule) { if(!autotoolrule) {
Set<String> commonKeys = null;
Map<String,String> resourcename = new HashMap<>(); Map<String,String> resourcename = new HashMap<>();
if(bl_rev_object_name.contains("预紧")) {
commonKeys= new HashSet<>();
commonKeys.add("电池工具");
resourcename.put("枪式电池枪", "枪式电池枪");
}
else {
//拧紧性质规则 //拧紧性质规则
//看读取哪个表 //看读取哪个表
Map<String,Integer> Tightenexcelname = new HashMap<>(); Map<String,Integer> Tightenexcelname = new HashMap<>();
@ -1699,8 +1811,17 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
if(rule_dongtai != null && rule_dongtai.length() > 0) { if(rule_dongtai != null && rule_dongtai.length() > 0) {
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
// if(!result)
// is_ok = false;
// }
// }
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) { if(split!= null && split.length == 2) {
boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]); boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
if(!result) if(!result)
@ -1802,8 +1923,17 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String rule_dongtai = rulebean.getDongtai(); String rule_dongtai = rulebean.getDongtai();
if(rule_dongtai != null && rule_dongtai.length() > 0) { if(rule_dongtai != null && rule_dongtai.length() > 0) {
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
// if(!result)
// is_ok = false;
// }
// }
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) { if(split!= null && split.length == 2) {
boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]); boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
if(!result) if(!result)
@ -1861,8 +1991,17 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String rule_dongtai = rulebean.getDongtai(); String rule_dongtai = rulebean.getDongtai();
if(rule_dongtai != null && rule_dongtai.length() > 0) { if(rule_dongtai != null && rule_dongtai.length() > 0) {
if(dongtai.length() > 0) { if(dongtai.length() > 0) {
if(dongtai.contains("N.M")) { // if(dongtai.contains("N.M")) {
String[] split = dongtai.split("N.M", -1); // String[] split = dongtai.split("N.M", -1);
// if(split!= null && split.length == 2) {
// boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
// if(!result)
// is_ok = false;
// }
// }
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) { if(split!= null && split.length == 2) {
boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]); boolean result = ConditionChecker.checkCondition(rule_dongtai, split[1], split[0]);
if(!result) if(!result)
@ -1913,12 +2052,14 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
} }
// 将所有 Map 放入一个列表 // 将所有 Map 放入一个列表
// List<Map<String, Integer>> maps = Arrays.asList(Tightenexcelname, KCDSexcelname, TightenMethodexcelname, Torqueexcelname); // List<Map<String, Integer>> maps = Arrays.asList(Tightenexcelname, KCDSexcelname, TightenMethodexcelname, Torqueexcelname);
Set<String> commonKeys = new HashSet<>(Tightenexcelname.keySet()); commonKeys = new HashSet<>(Tightenexcelname.keySet());
// 保留 map2、map3、map4 中也有的键 // 保留 map2、map3、map4 中也有的键
commonKeys.retainAll(KCDSexcelname.keySet()); commonKeys.retainAll(KCDSexcelname.keySet());
commonKeys.retainAll(TightenMethodexcelname.keySet()); commonKeys.retainAll(TightenMethodexcelname.keySet());
commonKeys.retainAll(Torqueexcelname.keySet()); commonKeys.retainAll(Torqueexcelname.keySet());
}
System.out.println("四个 Map 都有的 key: " + commonKeys); System.out.println("四个 Map 都有的 key: " + commonKeys);
//读取工具excel数据 //读取工具excel数据
for(String name:commonKeys) { for(String name:commonKeys) {
@ -2096,6 +2237,8 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
if(SleeveMap.containsKey(key2)) { if(SleeveMap.containsKey(key2)) {
System.out.println("找到匹配"); System.out.println("找到匹配");
Cell all_cell = row.createCell(7); Cell all_cell = row.createCell(7);
Cell tool_cell = row.createCell(8);
Cell tong_cell = row.createCell(9);
String all = ""; String all = "";
List<SleeveBean> SleeveBeans = SleeveMap.get(key2); List<SleeveBean> SleeveBeans = SleeveMap.get(key2);
for(SleeveBean sleevebean:SleeveBeans) { for(SleeveBean sleevebean:SleeveBeans) {
@ -2120,6 +2263,8 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType); System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType);
has = true; has = true;
all = all+resourcetype+"+"+resourceType; all = all+resourcetype+"+"+resourceType;
tool_cell.setCellValue(resourcetype);
tong_cell.setCellValue(resourceType);
break; break;
} }
} }
@ -2127,6 +2272,8 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType); System.out.println("工具匹配上套筒,工具的输出尺寸:"+outsize+" 套筒输入尺寸:"+inputsize+" 长度:"+length +" 资源类型:"+resourceType);
all = all+resourcetype+"+"+resourceType; all = all+resourcetype+"+"+resourceType;
tool_cell.setCellValue(resourcetype);
tong_cell.setCellValue(resourceType);
has = true; has = true;
break; break;
} }
@ -2371,7 +2518,7 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
// } // }
// } // }
private void readExcel(File excelfile,int start_rownum,int idcol2,int svppscol2,int fcccol2 private void readExcel(File excelfile,int start_rownum,int idcol2,int svppscol2,int fcccol2
,int fccdescol2,int dongtaicol,int kcdscol2) { ,int fccdescol2,int dongtaicol,int kcdscol2,int operationTypecol2) {
// 自定义监听器 // 自定义监听器
AnalysisEventListener<Map<Integer, String>> listener = new AnalysisEventListener<Map<Integer, String>>() { AnalysisEventListener<Map<Integer, String>> listener = new AnalysisEventListener<Map<Integer, String>>() {
@ -2383,13 +2530,16 @@ public class AutoTransToolDialog extends AbstractAIFDialog {
String fccdes = rowData.get(fccdescol2-1) != null ? rowData.get(fccdescol2-1) : ""; String fccdes = rowData.get(fccdescol2-1) != null ? rowData.get(fccdescol2-1) : "";
String kcds = rowData.get(kcdscol2-1) != null ? rowData.get(kcdscol2-1) : ""; String kcds = rowData.get(kcdscol2-1) != null ? rowData.get(kcdscol2-1) : "";
String svpps = rowData.get(svppscol2-1) != null ? rowData.get(svppscol2-1) : ""; String svpps = rowData.get(svppscol2-1) != null ? rowData.get(svppscol2-1) : "";
String operationType = rowData.get(operationTypecol2-1) != null ? rowData.get(operationTypecol2-1) : "";
String key = id; String key = id;
if (!DesignPartBeanMap.containsKey(key)) { if (!"D".equalsIgnoreCase(operationType.trim()) && !DesignPartBeanMap.containsKey(key)) {
DesignPartBean bean = new DesignPartBean(); DesignPartBean bean = new DesignPartBean();
// 设置值,确保不会为 null // 设置值,确保不会为 null
bean.setDongtai(dongtai); bean.setDongtai(dongtai);
bean.setFCC(fcc); bean.setFCC(fcc);
if(fccdes.contains("-")) {
fccdes = fccdes.substring(fccdes.indexOf("-")+1);
}
bean.setFCCDES(fccdes); bean.setFCCDES(fccdes);
bean.setKCDS(kcds); bean.setKCDS(kcds);
bean.setSVPPS(svpps); bean.setSVPPS(svpps);

@ -97,9 +97,11 @@ public class ConditionChecker {
double end = Double.parseDouble(parts[1].trim()); double end = Double.parseDouble(parts[1].trim());
return new double[]{start, end}; return new double[]{start, end};
} else if (range.contains("±")) { } else if (range.contains("±")) {
String[] parts = range.split("±"); String[] parts = range.split("±");
double center = Double.parseDouble(parts[0].trim()); double center = Double.parseDouble(parts[0].trim());
double delta = Double.parseDouble(parts[1].trim()); // double delta = Double.parseDouble(parts[1].trim());
double delta = 0;
return new double[]{center - delta, center + delta}; return new double[]{center - delta, center + delta};
} }
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {

@ -1,5 +1,14 @@
package com.sq.customization.util; package com.sq.customization.util;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.sq.customization.bean.DesignPartBean;
public class RangeAdjuster { public class RangeAdjuster {
public static String adjustRange(String range) { public static String adjustRange(String range) {
if (range == null || range.trim().isEmpty()) { if (range == null || range.trim().isEmpty()) {
@ -75,12 +84,61 @@ public class RangeAdjuster {
return range; // 不支持的格式,返回原字符串 return range; // 不支持的格式,返回原字符串
} }
} }
private static void readExcel(File excelfile,int start_rownum,int idcol2,int dongtaicol) {
// 自定义监听器
AnalysisEventListener<Map<Integer, String>> listener = new AnalysisEventListener<Map<Integer, String>>() {
@Override
public void invoke(Map<Integer, String> rowData, AnalysisContext context) {
String id = rowData.get(idcol2-1) != null ? rowData.get(idcol2-1) : "";
String dongtai = rowData.get(dongtaicol-1) != null ? rowData.get(dongtaicol-1) : "";
String key = id;
System.out.println(id+dongtai);
if (!DesignPartBeanMap.containsKey(key)) {
DesignPartBean bean = new DesignPartBean();
// 设置值,确保不会为 null
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
System.out.println(dongtai);
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
System.out.println(split.length);
}
DesignPartBeanMap.put(key, bean);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
System.out.println("读取完成,共 " + DesignPartBeanMap.size() + " 行数据");
}
};
// 执行读取
EasyExcel.read(excelfile, listener)
.sheet(0) // 指定 sheet 索引
.headRowNumber(start_rownum) // 从第0行开始读取包含标题行则设为1
.doRead();
}
private static Map<String,DesignPartBean> DesignPartBeanMap = new HashMap<>();
public static void main(String[] args) { public static void main(String[] args) {
// 测试用例 // 测试用例
String[] tests = {"3±1", "1-4", "1-", "-4", ""}; // String[] tests = {"3±1", "1-4", "1-", "-4", ""};
for (String test : tests) { // for (String test : tests) {
System.out.println("Input: " + test + " -> Output: " + adjustRange(test)); // System.out.println("Input: " + test + " -> Output: " + adjustRange(test));
// }
DesignPartBeanMap.clear();
File file = new File("C:\\Users\\Administrator\\Desktop\\123.xlsx");
readExcel(file,2,13,682);
// for(String id:DesignPartBeanMap.keySet()) {
//
// }
String dongtai = "123±1N.M";
if (dongtai.matches(".*(?i)(NM|N.M|N·M).*")) {
// 使用正则表达式分隔符 NM, N.M, N·M不区分大小写
String[] split = dongtai.split("(?i)NM|N.M|N·M",-1);
if(split!= null && split.length == 2) {
System.out.println(split[0]);
}
} }
} }
} }

Loading…
Cancel
Save