Bläddra i källkod

aps-增加公共方法,去除bigdecimal的小数位后多余的0

sucheng 1 år sedan
förälder
incheckning
5ae9a4b13a

+ 9 - 0
bs-common/src/main/java/com/rongwei/safecommon/utils/CXCommonUtils.java

@@ -31,6 +31,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.util.*;
 import java.util.function.BooleanSupplier;
@@ -366,4 +367,12 @@ public class CXCommonUtils {
             }
         }
     }
+
+    /**
+     * 去除小数点后面多余的0,输入BigDecimal,输出String
+     */
+    public static String removeExtraZerosAndDecimal(BigDecimal bd) {
+        bd = bd.stripTrailingZeros();
+        return bd.toPlainString();
+    }
 }

+ 4 - 8
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsBlankOrderServiceImpl.java

@@ -108,10 +108,6 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
     @Autowired
     private ReportCheckService reportCheckService;
 
-    public static String removeExtraZerosAndDecimal(BigDecimal bd) {
-        bd = bd.stripTrailingZeros();
-        return bd.toPlainString();
-    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -2386,9 +2382,9 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
                     String outputResult = "";
                     outputResult += (alloy + alloystatus + newProductType + " ");
                     //获取长宽高
-                    String thickness = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getThickness()) ? removeExtraZerosAndDecimal(apsProcessOutputProductDo.getThickness()) : "";
-                    String prowidth = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getProwidth()) ? removeExtraZerosAndDecimal(apsProcessOutputProductDo.getProwidth()) : "";
-                    String prolength = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getProlength()) ? removeExtraZerosAndDecimal(apsProcessOutputProductDo.getProlength()) : "";
+                    String thickness = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getThickness()) ? CXCommonUtils.removeExtraZerosAndDecimal(apsProcessOutputProductDo.getThickness()) : "";
+                    String prowidth = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getProwidth()) ? CXCommonUtils.removeExtraZerosAndDecimal(apsProcessOutputProductDo.getProwidth()) : "";
+                    String prolength = ObjectUtil.isNotEmpty(apsProcessOutputProductDo.getProlength()) ? CXCommonUtils.removeExtraZerosAndDecimal(apsProcessOutputProductDo.getProlength()) : "";
                     outputResult += ("厚" + thickness + "*宽" + prowidth);
                     if (ObjectUtil.isNotEmpty(prolength)) {
                         outputResult += ("*长" + prolength);
@@ -2453,7 +2449,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
                 String[] s = outputresult.split(" ");
                 String res = s[0] + " " + s[1];
                 if (ObjectUtil.isNotEmpty(item.getOutputonerollweigth()) && ObjectUtil.isNotEmpty(item.getPlanoutputrollcount())) {
-                    res = res + " " + removeExtraZerosAndDecimal(item.getOutputonerollweigth()) + "吨 * " + item.getPlanoutputrollcount() + "卷 = " + removeExtraZerosAndDecimal(item.getPlanoutputonerollweight());
+                    res = res + " " + CXCommonUtils.removeExtraZerosAndDecimal(item.getOutputonerollweigth()) + "吨 * " + item.getPlanoutputrollcount() + "卷 = " + CXCommonUtils.removeExtraZerosAndDecimal(item.getPlanoutputonerollweight());
                 }
                 return res;
             }).sorted(String::compareTo).collect(Collectors.toList());

+ 1 - 1
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsProductDetailServiceImpl.java

@@ -541,7 +541,7 @@ public class ApsProductDetailServiceImpl extends ServiceImpl<ApsProductDetailDao
                         //拼接输出成品的输出物料规格字段
                         apsProcessOutputProductDo.setOutmaterspecification(alloy + alloyStatus + productType + " " + apsProcessOutputProductDo.getProductname().split(" ")[1]);
                         //拼接输出成品的输出成品字段
-                        apsProcessOutputProductDo.setOutputresult(apsProcessOutputProductDo.getOutmaterspecification() + " " + vo.getOutputonerollweigth() + "吨 * " + vo.getPlanoutputorderroll() + "卷");
+                        apsProcessOutputProductDo.setOutputresult(apsProcessOutputProductDo.getOutmaterspecification() + " " + CXCommonUtils.removeExtraZerosAndDecimal(vo.getOutputonerollweigth()) + "吨 * " + vo.getPlanoutputorderroll() + "卷");
 
                         apsProcessOutputProductService.updateById(apsProcessOutputProductDo);
                         needUpdateBlankIds.add(vo.getBlankId());