qiangxuan 3 сар өмнө
parent
commit
ca4f880202

+ 30 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/entity/DetailStatistics.java

@@ -0,0 +1,30 @@
+package org.jeecg.modules.billet.storageBill.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class DetailStatistics {
+
+
+    @ApiModelProperty(value = "总支数")
+    private Integer amountTotal;
+
+    /**出坯量*/
+    @ApiModelProperty(value = "总重量")
+    private Double blankOutput;
+
+    /**出坯量*/
+    @ApiModelProperty(value = "总重量")
+    private String size;
+
+    public DetailStatistics(Integer amountTotal, Double blankOutput, String size) {
+        this.amountTotal = amountTotal;
+        this.blankOutput = blankOutput;
+        this.size = size;
+    }
+
+    public DetailStatistics() {
+
+    }
+}

+ 7 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/entity/OnDutyDetailStatistics.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.billet.storageBill.entity;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 @Data
 public class OnDutyDetailStatistics {
@@ -19,4 +20,10 @@ public class OnDutyDetailStatistics {
 
     private BigDecimal stackingTotalWeight;
 
+    private List<DetailStatistics> hotSendDetailStatisticsList;
+
+    private List<DetailStatistics> hotChargeDetailStatisticsList;
+
+    private List<DetailStatistics> stackingDetailStatisticsList;
+
 }

+ 115 - 3
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/impl/StorageBillServiceImpl.java

@@ -1758,6 +1758,12 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             shift = billetHotsendChangeShift.getShift();
         }
 
+        List<DetailStatistics> hotSendDetailStatisticsList = new ArrayList<>();
+
+        List<DetailStatistics> hotChargeDetailStatisticsList = new ArrayList<>();
+
+        List<DetailStatistics> stackingDetailStatisticsList = new ArrayList<>();
+
         int hotSendSum = 0;
         double hotSendTotalWeight = 0d;
         int hotChargeSum = 0;
@@ -1785,6 +1791,14 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             hotSendSum = rollClubOneDetailsList.size();
             // 棒一热送出坯量
             hotSendTotalWeight = rollClubOneDetailsList.stream().mapToDouble(RollClubOneDetails::getBlankOutput).sum();
+
+            rollClubOneDetailsList.forEach(x ->{
+                DetailStatistics detailStatistics = new DetailStatistics();
+                detailStatistics.setAmountTotal(1);
+                detailStatistics.setBlankOutput(x.getBlankOutput());
+                detailStatistics.setSize(x.getSize());
+                hotSendDetailStatisticsList.add(detailStatistics);
+            });
         }
 
         // 根据铸机号、班组、班别、时间范围。查询棒二明细表
@@ -1815,7 +1829,9 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
 
             // 棒二堆垛总支数  获取堆垛编号不为空的条数,即为堆垛
             int count1 = rollClubTwoDetailsList.stream()
-                    .mapToInt(details -> details.getStackAddr() != null && !details.getStackAddr().isEmpty() ? 4 : 1).sum();
+                    .filter(details -> details.getStackAddr() != null && !details.getStackAddr().isEmpty())
+                    .mapToInt(details -> 4)
+                    .sum();
             stackingSum = stackingSum + count1;
             // 棒二堆垛出坯量  获取堆垛编号不为空的条数,即为堆垛
             double stackingTotalBlankOutput = rollClubTwoDetailsList.stream()
@@ -1823,6 +1839,20 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                     .mapToDouble(RollClubTwoDetails::getBlankOutput).sum();
             stackingTotalWeight = stackingTotalWeight + stackingTotalBlankOutput;
 
+            rollClubTwoDetailsList.forEach(x ->{
+                DetailStatistics detailStatistics = new DetailStatistics();
+                if(x.getStackAddr() != null && !x.getStackAddr().isEmpty()){
+                    detailStatistics.setAmountTotal(4);
+                    detailStatistics.setBlankOutput(x.getBlankOutput());
+                    detailStatistics.setSize(x.getSize());
+                    stackingDetailStatisticsList.add(detailStatistics);
+                }else {
+                    detailStatistics.setAmountTotal(1);
+                    detailStatistics.setBlankOutput(x.getBlankOutput());
+                    detailStatistics.setSize(x.getSize());
+                    hotChargeDetailStatisticsList.add(detailStatistics);
+                }
+            });
         }
 
         // 根据铸机号、班组、班别、时间范围。查询棒三明细表
@@ -1851,13 +1881,30 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
 
             // 棒三堆垛总支数
             int count1 = rollClubThreeDetailsList.stream()
-                    .mapToInt(details -> details.getStackAddr() != null && !details.getStackAddr().isEmpty() ? 4 : 1).sum();
+                    .filter(details -> details.getStackAddr() != null && !details.getStackAddr().isEmpty())
+                    .mapToInt(details -> 4)
+                    .sum();
             stackingSum = stackingSum + count1;
             // 棒三堆垛出坯量
             double stackingTotalBlankOutput = rollClubThreeDetailsList.stream()
                     .filter(details -> details.getStackAddr() != null)
                     .mapToDouble(RollClubThreeDetails::getBlankOutput).sum();
             stackingTotalWeight = stackingTotalWeight + stackingTotalBlankOutput;
+
+            rollClubThreeDetailsList.forEach(x ->{
+                DetailStatistics detailStatistics = new DetailStatistics();
+                if(x.getStackAddr() != null && !x.getStackAddr().isEmpty()){
+                    detailStatistics.setAmountTotal(4);
+                    detailStatistics.setBlankOutput(x.getBlankOutput());
+                    detailStatistics.setSize(x.getSize());
+                    stackingDetailStatisticsList.add(detailStatistics);
+                }else {
+                    detailStatistics.setAmountTotal(1);
+                    detailStatistics.setBlankOutput(x.getBlankOutput());
+                    detailStatistics.setSize(x.getSize());
+                    hotChargeDetailStatisticsList.add(detailStatistics);
+                }
+            });
         }
 
         // 根据铸机号、班组、班别、时间范围。查询高线明细表
@@ -1882,6 +1929,18 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             // 高线总出坯量    高线属于热送
             double hotChargeHeightTotalWeight = rollHeightDetailsList.stream().mapToDouble(RollHeightDetails::getBlankOutput).sum();
             hotSendTotalWeight = hotSendTotalWeight + hotChargeHeightTotalWeight;
+
+            rollHeightDetailsList.forEach(x ->{
+                DetailStatistics detailStatistics = new DetailStatistics();
+                if(x.getStackAddr() == null){
+                    detailStatistics.setAmountTotal(1);
+                }else {
+                    detailStatistics.setAmountTotal(4);
+                }
+                detailStatistics.setBlankOutput(x.getBlankOutput());
+                detailStatistics.setSize(x.getSize());
+                hotSendDetailStatisticsList.add(detailStatistics);
+            });
         }
 
         // 根据铸机号、班组、班别、时间范围。查询上若明细表
@@ -1909,13 +1968,31 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             hotChargeTotalWeight = hotChargeTotalWeight + hotChargeShippTotalWeight;
             // 上若堆垛总支数
             int count1 = rollOutShippDetailsList.stream()
-                    .mapToInt(details -> details.getStackAddr() != null && !details.getStackAddr().isEmpty() ? 4 : 1).sum();
+                    .filter(details -> details.getStackAddr() != null && !details.getStackAddr().isEmpty())
+                    .mapToInt(details -> 4)
+                    .sum();
+
             stackingSum = stackingSum + count1;
             // 上若堆垛出坯量
             double stackingShippTotalWeight = rollOutShippDetailsList.stream()
                     .filter(details -> details.getStackAddr() != null)
                     .mapToDouble(RollOutShippDetails::getBlankOutput).sum();
             stackingTotalWeight = stackingTotalWeight + stackingShippTotalWeight;
+
+            rollOutShippDetailsList.forEach(x ->{
+                DetailStatistics detailStatistics = new DetailStatistics();
+                if(x.getStackAddr() != null && !x.getStackAddr().isEmpty()){
+                    detailStatistics.setAmountTotal(4);
+                    detailStatistics.setBlankOutput(x.getBlankOutput());
+                    detailStatistics.setSize(x.getSize());
+                    stackingDetailStatisticsList.add(detailStatistics);
+                }else {
+                    detailStatistics.setAmountTotal(1);
+                    detailStatistics.setBlankOutput(x.getBlankOutput());
+                    detailStatistics.setSize(x.getSize());
+                    hotChargeDetailStatisticsList.add(detailStatistics);
+                }
+            });
         }
         BigDecimal finalHotChargeTotalWeight = BigDecimal.valueOf(hotChargeTotalWeight).setScale(4, BigDecimal.ROUND_HALF_UP);
         BigDecimal finalHotSendTotalWeight = BigDecimal.valueOf(hotSendTotalWeight).setScale(4, BigDecimal.ROUND_HALF_UP);
@@ -1926,9 +2003,44 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
         onDutyDetailStatistics.setHotSendTotalWeight(finalHotSendTotalWeight);
         onDutyDetailStatistics.setStackingSum(stackingSum);
         onDutyDetailStatistics.setStackingTotalWeight(finalStackingTotalWeight);
+
+        // 分组统计热送   根据 size 分组,统计 amountTotal 和 blankOutput 总和
+        List<DetailStatistics> hotSendResult = calculateStatistics(hotSendDetailStatisticsList);
+        List<DetailStatistics> hotChargeResult = calculateStatistics(hotChargeDetailStatisticsList);
+        List<DetailStatistics> stackingResult = calculateStatistics(stackingDetailStatisticsList);
+
+        onDutyDetailStatistics.setHotChargeDetailStatisticsList(hotChargeResult);
+        onDutyDetailStatistics.setHotSendDetailStatisticsList(hotSendResult);
+        onDutyDetailStatistics.setStackingDetailStatisticsList(stackingResult);
         return onDutyDetailStatistics;
     }
 
+
+    private static List<DetailStatistics> calculateStatistics(List<DetailStatistics> inputList) {
+        Map<String, DetailStatistics> groupedStatistics = inputList.stream()
+                .collect(Collectors.groupingBy(DetailStatistics::getSize,
+                        Collectors.collectingAndThen(
+                                Collectors.toList(),
+                                list -> {
+                                    int totalAmount = list.stream()
+                                            .mapToInt(DetailStatistics::getAmountTotal)
+                                            .sum();
+                                    double totalBlankOutput = list.stream()
+                                            .mapToDouble(DetailStatistics::getBlankOutput)
+                                            .sum();
+                                    BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
+                                    double roundedBlankOutput = bd.doubleValue();
+                                    return new DetailStatistics(totalAmount, roundedBlankOutput, list.get(0).getSize());
+                                }
+                        )
+                ));
+
+        return groupedStatistics.values().stream()
+                .sorted(Comparator.comparing(DetailStatistics::getSize))
+                .collect(Collectors.toList());
+    }
+
+
     @Override
     public List<OnDutySizeVo> queryOnDutySize(String ccmNo, String changeShiftId) {
         List<OnDutySizeVo> list = new ArrayList<>();