1.匹配套筒逻辑
parent
c10a034108
commit
8a5a36da5f
@ -1,7 +1,21 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
javacDefaultEncoding.. = UTF-8
|
||||
bin.includes = plugin.xml,\
|
||||
META-INF/,\
|
||||
.,\
|
||||
icons/
|
||||
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
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,39 @@
|
||||
package com.sq.customization.bean;
|
||||
|
||||
public class SleeveBean {
|
||||
private String resourceType;
|
||||
private String inputSize;
|
||||
private String outSize;
|
||||
private String length;
|
||||
private String headform;
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
public String getInputSize() {
|
||||
return inputSize;
|
||||
}
|
||||
public void setInputSize(String inputSize) {
|
||||
this.inputSize = inputSize;
|
||||
}
|
||||
public String getOutSize() {
|
||||
return outSize;
|
||||
}
|
||||
public void setOutSize(String outSize) {
|
||||
this.outSize = outSize;
|
||||
}
|
||||
public String getLength() {
|
||||
return length;
|
||||
}
|
||||
public void setLength(String length) {
|
||||
this.length = length;
|
||||
}
|
||||
public String getHeadform() {
|
||||
return headform;
|
||||
}
|
||||
public void setHeadform(String headform) {
|
||||
this.headform = headform;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.sq.customization.bean;
|
||||
|
||||
public class StandardPartBean {
|
||||
private String specification;
|
||||
private String length;
|
||||
private String headform;
|
||||
private String headsize;
|
||||
public String getSpecification() {
|
||||
return specification;
|
||||
}
|
||||
public void setSpecification(String specification) {
|
||||
this.specification = specification;
|
||||
}
|
||||
public String getLength() {
|
||||
return length;
|
||||
}
|
||||
public void setLength(String length) {
|
||||
this.length = length;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.sq.customization.bean;
|
||||
|
||||
public class ToolBean {
|
||||
private String resourceType;
|
||||
private String resourceName;
|
||||
private String range;//扭矩范围
|
||||
private String outSize;
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
public String getResourceName() {
|
||||
return resourceName;
|
||||
}
|
||||
public void setResourceName(String resourceName) {
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
public String getRange() {
|
||||
return range;
|
||||
}
|
||||
public void setRange(String range) {
|
||||
this.range = range;
|
||||
}
|
||||
public String getOutSize() {
|
||||
return outSize;
|
||||
}
|
||||
public void setOutSize(String outSize) {
|
||||
this.outSize = outSize;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,77 @@
|
||||
package com.sq.customization.util;
|
||||
|
||||
public class RangChecker {
|
||||
// 解析范围并返回 [min, max] 数组
|
||||
private static double[] parseRange(String range) {
|
||||
if (range == null || range.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
double minValue, maxValue;
|
||||
|
||||
if (range.contains("±")) {
|
||||
// 处理 "3±1" 格式
|
||||
String[] parts = range.split("±");
|
||||
if (parts.length != 2) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
double center = Double.parseDouble(parts[0].trim());
|
||||
double offset = Double.parseDouble(parts[1].trim());
|
||||
minValue = center - offset;
|
||||
maxValue = center + offset;
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
} else if (range.contains("-")) {
|
||||
// 处理 "1-4" 格式
|
||||
String[] parts = range.split("-");
|
||||
String minStr = parts.length > 0 ? parts[0].trim() : "";
|
||||
String maxStr = parts.length > 1 ? parts[1].trim() : "";
|
||||
|
||||
try {
|
||||
minValue = minStr.isEmpty() ? Double.NEGATIVE_INFINITY : Double.parseDouble(minStr);
|
||||
maxValue = maxStr.isEmpty() ? Double.POSITIVE_INFINITY : Double.parseDouble(maxStr);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new double[]{minValue, maxValue};
|
||||
}
|
||||
|
||||
// 判断 inputRange 是否在 targetRange 内
|
||||
public static boolean isWithinRange(String inputRange, String targetRange) {
|
||||
// 解析输入范围
|
||||
double[] input = parseRange(inputRange);
|
||||
if (input == null) {
|
||||
return false; // 输入范围无效
|
||||
}
|
||||
double inputMin = input[0];
|
||||
double inputMax = input[1];
|
||||
|
||||
// 解析目标范围
|
||||
double[] target = parseRange(targetRange);
|
||||
if (target == null) {
|
||||
return false; // 目标范围无效
|
||||
}
|
||||
double targetMin = target[0];
|
||||
double targetMax = target[1];
|
||||
|
||||
// 判断输入范围是否完全在目标范围内
|
||||
return inputMin >= targetMin && inputMax <= targetMax;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 测试用例
|
||||
String targetRange = "2-5.5"; // 动态目标范围
|
||||
String[] inputRanges = {"1-4.4", "3±1", "2-5.6", "6-7", "1-", "-4", "2-6"};
|
||||
|
||||
for (String input : inputRanges) {
|
||||
System.out.println("Input: " + input + " -> Within " + targetRange + ": " +
|
||||
isWithinRange(input, targetRange));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.sq.customization.util;
|
||||
|
||||
public class RangeAdjuster {
|
||||
public static String adjustRange(String range) {
|
||||
if (range == null || range.trim().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 判断格式:± 或 -
|
||||
if (range.contains("±")) {
|
||||
// 处理 "3±1" 格式
|
||||
String[] parts = range.split("±");
|
||||
if (parts.length != 2) {
|
||||
return range; // 格式错误,返回原字符串
|
||||
}
|
||||
|
||||
try {
|
||||
double center = Double.parseDouble(parts[0].trim()); // 中心值
|
||||
double offset = Double.parseDouble(parts[1].trim()); // 偏移量
|
||||
|
||||
double minValue = center - offset; // 最小值
|
||||
double maxValue = center + offset; // 最大值
|
||||
|
||||
// 调整最小值和最大值
|
||||
double adjustedMin = minValue * 0.33;
|
||||
double adjustedMax = maxValue * 0.33;
|
||||
|
||||
return String.format("%.3f-%.3f", adjustedMin, adjustedMax); // 保留两位小数
|
||||
} catch (NumberFormatException e) {
|
||||
return range; // 无法解析数字,返回原字符串
|
||||
}
|
||||
} else if (range.contains("-")) {
|
||||
// 处理 "1-4" 格式
|
||||
String[] parts = range.split("-");
|
||||
String minStr = parts.length > 0 ? parts[0].trim() : "";
|
||||
String maxStr = parts.length > 1 ? parts[1].trim() : "";
|
||||
|
||||
String adjustedMin, adjustedMax;
|
||||
|
||||
// 处理最小值
|
||||
if (minStr.isEmpty()) {
|
||||
adjustedMin = "";
|
||||
} else {
|
||||
try {
|
||||
double minValue = Double.parseDouble(minStr);
|
||||
adjustedMin = String.format("%.3f", minValue * 0.33); // 保留两位小数
|
||||
} catch (NumberFormatException e) {
|
||||
adjustedMin = minStr; // 解析失败,保留原值
|
||||
}
|
||||
}
|
||||
|
||||
// 处理最大值
|
||||
if (maxStr.isEmpty()) {
|
||||
adjustedMax = "";
|
||||
} else {
|
||||
try {
|
||||
double maxValue = Double.parseDouble(maxStr);
|
||||
adjustedMax = String.format("%.3f", maxValue * 0.33); // 保留两位小数
|
||||
} catch (NumberFormatException e) {
|
||||
adjustedMax = maxStr; // 解析失败,保留原值
|
||||
}
|
||||
}
|
||||
|
||||
// 拼接结果
|
||||
if (adjustedMin.isEmpty() && adjustedMax.isEmpty()) {
|
||||
return "";
|
||||
} else if (adjustedMin.isEmpty()) {
|
||||
return "-" + adjustedMax;
|
||||
} else if (adjustedMax.isEmpty()) {
|
||||
return adjustedMin + "-";
|
||||
} else {
|
||||
return adjustedMin + "-" + adjustedMax;
|
||||
}
|
||||
} else {
|
||||
return range; // 不支持的格式,返回原字符串
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 测试用例
|
||||
String[] tests = {"3±1", "1-4", "1-", "-4", ""};
|
||||
for (String test : tests) {
|
||||
System.out.println("Input: " + test + " -> Output: " + adjustRange(test));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.sq.customization.util;
|
||||
|
||||
public class RangeCalculator {
|
||||
public static String adjustRange(String range) {
|
||||
// 如果输入为空,直接返回空字符串或抛出异常(根据需求)
|
||||
if (range == null || range.trim().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 分割字符串,基于 "-"
|
||||
String[] parts = range.split("-");
|
||||
String minStr = parts.length > 0 ? parts[0].trim() : "";
|
||||
String maxStr = parts.length > 1 ? parts[1].trim() : "";
|
||||
|
||||
// 处理最小值
|
||||
String adjustedMin = minStr.isEmpty() ? "" : minStr;
|
||||
|
||||
// 处理最大值
|
||||
String adjustedMax;
|
||||
if (maxStr.isEmpty()) {
|
||||
adjustedMax = ""; // 最大值为空,不需要乘以 0.85
|
||||
} else {
|
||||
try {
|
||||
double maxValue = Double.parseDouble(maxStr); // 转换为 double
|
||||
double adjustedValue = maxValue * 0.85; // 最大值乘以 0.85
|
||||
adjustedMax = String.valueOf(adjustedValue); // 转换回字符串
|
||||
} catch (NumberFormatException e) {
|
||||
adjustedMax = maxStr; // 如果无法解析为数字,保持原样
|
||||
}
|
||||
}
|
||||
|
||||
// 拼接结果
|
||||
if (adjustedMin.isEmpty() && adjustedMax.isEmpty()) {
|
||||
return "";
|
||||
} else if (adjustedMin.isEmpty()) {
|
||||
return "-" + adjustedMax;
|
||||
} else if (adjustedMax.isEmpty()) {
|
||||
return adjustedMin + "-";
|
||||
} else {
|
||||
return adjustedMin + "-" + adjustedMax;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 测试用例
|
||||
String[] tests = {"1.2-6", "1.2-", "-6", ""};
|
||||
for (String test : tests) {
|
||||
System.out.println("Input: " + test + " -> Output: " + adjustRange(test));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue