Quellcode durchsuchen

托书处理小数位问题

zengtx vor 2 Jahren
Ursprung
Commit
f54c76bbc6

+ 10 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/syShippingOrder/service/impl/SyShippingOrderServiceImpl.java

@@ -33,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.ZonedDateTime;
@@ -623,6 +624,7 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
         List<Map<String,Object>> listmaps = new ArrayList<>();
 
         SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd 00:00:00.000");
+        DecimalFormat df = new DecimalFormat("#.00");
 
         //记录每次ID
         String id = "";
@@ -725,8 +727,10 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
                     maps.put("cSPVCode", cCode);//销售支出单号
                      //金额 = 以销售订单号为维度计算对应销售订单号下的毛重合计数/总毛重“费用支出金额
                      Double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
-                     BigDecimal  imoney = new BigDecimal(money).multiply(new BigDecimal(rmb.get("amount").toString())).setScale(2,BigDecimal.ROUND_HALF_UP);
-                     sumImoney = sumImoney.add(imoney);
+                    Double  imoney = money * Double.parseDouble(rmb.get("amount").toString());
+
+                    sumImoney = sumImoney.add(new BigDecimal(df.format(imoney)));
+
 
                     maps.put("iMoney", imoney);
                     maps.put("INatMoney", imoney);
@@ -781,11 +785,12 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
                     Map<String, Object> maps = new HashMap<>();
                     maps.put("cSPVCode", cCode);//销售支出单号
                     Double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
-                    BigDecimal  imoney = new BigDecimal(money).multiply(new BigDecimal(usd.get("amount").toString())).setScale(2,BigDecimal.ROUND_HALF_UP);
-                    sumImoney = sumImoney.add(imoney);
+                    Double  imoney = money * Double.parseDouble(usd.get("amount").toString());
+
+                    sumImoney = sumImoney.add(new BigDecimal(df.format(imoney)));
 
                     maps.put("cbSysBarCode", "||SA09|"+cCode+"|"+ii);
-                    maps.put("INatMoney", imoney.multiply(new BigDecimal(nflat)).setScale(2,BigDecimal.ROUND_HALF_UP));
+                    maps.put("INatMoney", df.format(imoney*Double.parseDouble(nflat)));
                     maps.put("iMoney", imoney);
                     maps.put("cExpCode",usd.get("itemColumn"));//项目编码
                     maps.put("ID", id);