cad拆单配件汇总修改为长宽高只对比小数后三位

This commit is contained in:
gaoqr
2026-04-02 14:31:11 +08:00
parent 1f40f5bb4c
commit 60b269cf54
2 changed files with 39 additions and 2 deletions
@@ -75,6 +75,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@@ -1719,7 +1720,7 @@ public class WebCadOrderImportAsyncFactory {
String brand = part.getBrand(); String brand = part.getBrand();
// 分类配件的键组合 // 分类配件的键组合
String groupKey = composite + partType + factory + model + spec + height + width + thickness + unit + brand; String groupKey = composite + partType + factory + model + spec + scale3(height) + scale3(width) + scale3(thickness) + unit + brand;
Long orderPartId = orderPartMap.get(groupKey); Long orderPartId = orderPartMap.get(groupKey);
if (ObjectUtil.isNull(orderPartId)) { if (ObjectUtil.isNull(orderPartId)) {
@@ -1783,6 +1784,23 @@ public class WebCadOrderImportAsyncFactory {
} }
} }
/**
* 保留三位小数展示
*
* @param value
* @return
*/
private String scale3(String value) {
if (StringUtils.isNotEmpty(value)) return value;
try {
BigDecimal bd = new BigDecimal(value);
bd = bd.setScale(3, RoundingMode.HALF_UP);
return bd.toPlainString();
} catch (NumberFormatException e) {
// 不是数字就原样返回
return value;
}
}
/** /**
* 处理cad部件数据 * 处理cad部件数据
@@ -66,6 +66,7 @@ import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
@@ -1648,7 +1649,7 @@ public class WebCadOrderImportFactory {
String brand = part.getBrand(); String brand = part.getBrand();
// 分类配件的键组合 // 分类配件的键组合
String groupKey = composite + partType + factory + model + spec + height + width + thickness + unit + brand; String groupKey = composite + partType + factory + model + spec + scale3(height) + scale3(width) + scale3(thickness) + unit + brand;
Long orderPartId = orderPartMap.get(groupKey); Long orderPartId = orderPartMap.get(groupKey);
if (ObjectUtil.isNull(orderPartId)) { if (ObjectUtil.isNull(orderPartId)) {
@@ -1712,6 +1713,24 @@ public class WebCadOrderImportFactory {
} }
} }
/**
* 保留三位小数展示
*
* @param value
* @return
*/
private String scale3(String value) {
if (StringUtils.isNotEmpty(value)) return value;
try {
BigDecimal bd = new BigDecimal(value);
bd = bd.setScale(3, RoundingMode.HALF_UP);
return bd.toPlainString();
} catch (NumberFormatException e) {
// 不是数字就原样返回
return value;
}
}
/** /**
* 从规格中获取属性,例:material、color * 从规格中获取属性,例:material、color
* *