浏览代码

2024-09-04 浮点类型修改

luguang 2 月之前
父节点
当前提交
965ba0fb74

+ 11 - 8
src/main/java/com/sy/coinage/workshop/component/ScreenComponent.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.sy.coinage.core.constants.CacheKey;
 import com.sy.coinage.core.redis.RedisService;
+import com.sy.coinage.core.util.Arith;
 import com.sy.coinage.core.util.DateUtils;
 import com.sy.coinage.core.util.RandomUtil;
 import com.sy.coinage.core.vo.OptVO;
@@ -207,9 +208,9 @@ public class ScreenComponent {
         }
         ScreenProportionVO info = new ScreenProportionVO();
         info.setProportionStr1("纪念币库存占比");
-        info.setProportion1(proportion1 * 100 / total);
+        info.setProportion1(Arith.div(proportion1 * 100, total, 2));
         info.setProportionStr2("流通币库存占比");
-        info.setProportion2(proportion2 * 100 / total);
+        info.setProportion2(Arith.div(proportion2 * 100, total, 2));
         this.redisService.set("screen_proportion", JSON.toJSONString(info));
     }
 
@@ -219,8 +220,8 @@ public class ScreenComponent {
         if (list != null && list.size() > 0) {
             List<String> securities = list.stream().map(item -> item.getSecurities()).collect(Collectors.toList());
             data.setName(securities);
-            List<Integer> production = new ArrayList<>();
-            List<Integer> inventory = new ArrayList<>();
+            List<Double> production = new ArrayList<>();
+            List<Double> inventory = new ArrayList<>();
             // 获取所有解缴单
             for (ProductPlan productPlan : list) {
                 Integer totalBox = this.getTotalBox(productPlan.getCrownFrom(), productPlan.getCrownTo());
@@ -228,10 +229,11 @@ public class ScreenComponent {
                 if (out != null && out.size() > 0 && totalBox > 0) {
                     // 取合计箱数
                     Integer total = out.stream().mapToInt(s -> s.getTotalBoxAmount()).sum();
-                    Integer r = total * 100 / totalBox;
+                    // Integer r = total * 100 / totalBox;
+                    Double r = Arith.div(total * 100, totalBox, 2);
                     production.add(r);
                 } else {
-                    production.add(0);
+                    production.add(0D);
                 }
                 // 获取所有发货计划
                 Integer totalPalnBox = this.deliveryPlanTotal(productPlan.getProductId());
@@ -240,10 +242,11 @@ public class ScreenComponent {
                 if (delivery != null && delivery.size() > 0 && totalPalnBox > 0) {
                     // 取合计箱数
                     Integer total = delivery.stream().mapToInt(s -> s.getPlanTotalBox()).sum();
-                    Integer r = total * 100 / totalPalnBox;
+//                    Integer r = total * 100 / totalPalnBox;
+                    Double r = Arith.div(total * 100, totalPalnBox, 2);
                     inventory.add(r);
                 } else {
-                    inventory.add(0);
+                    inventory.add(0D);
                 }
             }
             data.setProduction(production);

+ 11 - 11
src/main/java/com/sy/coinage/workshop/controller/ScreenController.java

@@ -112,23 +112,23 @@ public class ScreenController {
         data.setMax(1000);
         data.setName(Arrays.asList(this.dept));
         // 产能开始
-        List<Integer> production = new ArrayList<>();
-        production.add(0);
+        List<Double> production = new ArrayList<>();
+        production.add(0D);
         String yield = this.redisService.get(CacheKey.DEPT_YIELD + d.getName());
         if (StringUtils.isNotBlank(yield) && !"null".equals(yield)) {
-            production.add(Integer.parseInt(yield));
+            production.add(Double.parseDouble(yield));
         } else {
-            production.add(0);
+            production.add(0D);
         }
-        production.add(0);
+        production.add(0D);
         data.setProduction(production);
         // 产能结束
         // 库存开始
-        List<Integer> inventory = new ArrayList<>();
-        inventory.add(0);
-        Integer deptInventory = this.getDeptInventory(Integer.parseInt(d.getRemark()));
+        List<Double> inventory = new ArrayList<>();
+        inventory.add(0D);
+        Double deptInventory = this.getDeptInventory(Integer.parseInt(d.getRemark()));
         inventory.add(deptInventory);
-        inventory.add(0);
+        inventory.add(0D);
         data.setInventory(inventory);
         // 库存结束
         return data;
@@ -157,8 +157,8 @@ public class ScreenController {
         return list;
     }
 
-    private Integer getDeptInventory(Integer wareId) {
-        Integer resp = 0;
+    private Double getDeptInventory(Integer wareId) {
+        Double resp = 0D;
         LambdaQueryWrapper<Stock> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(Stock::getWareId, wareId);
         List<Stock> list = this.stockService.list(queryWrapper);

+ 2 - 2
src/main/java/com/sy/coinage/workshop/vo/ScreenDeptVO.java

@@ -15,10 +15,10 @@ public class ScreenDeptVO implements Serializable {
     private List<String> name;
 
     @ApiModelProperty(value = "昨日产量/收货完成率")
-    private List<Integer> production;
+    private List<Double> production;
 
     @ApiModelProperty(value = "临时库存/发货完成率")
-    private List<Integer> inventory;
+    private List<Double> inventory;
 
 
     @ApiModelProperty(value = "坐标最大值")

+ 2 - 2
src/main/java/com/sy/coinage/workshop/vo/ScreenProportionVO.java

@@ -14,12 +14,12 @@ public class ScreenProportionVO implements Serializable {
     private String proportionStr1;
 
     @ApiModelProperty(value = "占比1")
-    private Integer proportion1;
+    private Double proportion1;
 
     @ApiModelProperty(value = "占比名称2")
     private String proportionStr2;
 
     @ApiModelProperty(value = "占比2")
-    private Integer proportion2;
+    private Double proportion2;
 
 }