Browse Source

2025-07-11

实测值没有小数点,不需要显示0
master
fengyuan_yang 6 months ago
parent
commit
d419a1c8cf
  1. 12
      src/main/java/com/spring/modules/sampleManagement/service/Impl/TechnicalSpecificationServiceImpl.java

12
src/main/java/com/spring/modules/sampleManagement/service/Impl/TechnicalSpecificationServiceImpl.java

@ -59,6 +59,7 @@ import org.springframework.util.StringUtils;
import javax.naming.NamingException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -2233,10 +2234,17 @@ public class TechnicalSpecificationServiceImpl implements TechnicalSpecification
String recordType = "TL";
PartSubPropertiesValueData valueData = technicalSpecificationMapper.getToolPropertiesValue(data.getSite(), tool.getToolId(), recordType, dictData.getDictValue());
if (valueData != null) {
String numberStr = "";
if (valueData.getNumValue() != null) {
// 使用 DecimalFormat 去掉小数点后无意义的0
numberStr = new DecimalFormat("0.#").format(valueData.getNumValue());
} else if (valueData.getTextValue() != null) {
numberStr = valueData.getTextValue();
}
if ("number_across".equals(dictData.getDictLabel())) {
tool.setNumberAcross(valueData.getNumValue() != null ? valueData.getNumValue().toString() : valueData.getTextValue() != null ? valueData.getTextValue() : "");
tool.setNumberAcross(numberStr);
} else if ("number_down".equals(dictData.getDictLabel())) {
tool.setNumberDown(valueData.getNumValue() != null ? valueData.getNumValue().toString() : valueData.getTextValue() != null ? valueData.getTextValue() : "");
tool.setNumberDown(numberStr);
}
}
}

Loading…
Cancel
Save