Bläddra i källkod

堆垛信息维护字段新增

qiangxuan 5 månader sedan
förälder
incheckning
d7b5ae8ce4

+ 14 - 8
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsend/service/impl/BilletHotsendBaseServiceImpl.java

@@ -504,7 +504,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			rollClubOne.setSize(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getLength())); //定尺
 			rollClubOne.setSteel(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getGrade())); //钢种
 			rollClubOne.setSpec(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getSpec())); //规格
-			rollClubOne.setBlankOutput(rollClubCommonList.stream().findFirst().orElse(null).getBilletWeight());//出坯量
+			rollClubOne.setBlankOutput(rollClubCommonList.stream().mapToDouble(RollClubCommon::getBilletWeight).sum());//出坯量总和
 			LambdaQueryWrapper<RollClubOne> queryWrapper1 = new LambdaQueryWrapper<>();
 			queryWrapper1.eq(RollClubOne::getCcmNo, billetHotsend.getCcmNo())
 					.eq(RollClubOne::getHeatNo, billetHotsend.getHeatNo())
@@ -548,12 +548,14 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			rollClubTwo.setSize(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getLength())); //定尺
 			rollClubTwo.setSteel(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getGrade())); //钢种
 			rollClubTwo.setSpec(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getSpec())); //规格
-			rollClubTwo.setBlankOutput(rollClubCommonList.stream().findFirst().orElse(null).getBilletWeight());//出坯量
+			rollClubTwo.setBlankOutput(rollClubCommonList.stream().mapToDouble(RollClubCommon::getBilletWeight).sum());//出坯量总和
+			rollClubTwo.setStorageBillId(storageBill.getId());
 			LambdaQueryWrapper<RollClubTwo> queryWrapper1 = new LambdaQueryWrapper<>();
 			queryWrapper1.eq(RollClubTwo::getCcmNo, billetHotsend.getCcmNo())
 					.eq(RollClubTwo::getHeatNo, billetHotsend.getHeatNo())
 					.eq(RollClubTwo::getShift, billetHotsend.getShift())
-					.eq(RollClubTwo::getShiftGroup, billetHotsend.getShiftGroup());
+					.eq(RollClubTwo::getShiftGroup, billetHotsend.getShiftGroup())
+					.eq(RollClubTwo::getStorageBillId, storageBill.getId());;
 			RollClubTwo rollClubTwo1 = rollClubTwoService.getOne(queryWrapper1);
 			if (oConvertUtils.isEmpty(rollClubTwo1)){
 				rollClubTwo.setCreateDate(new Date());
@@ -592,12 +594,14 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			rollClubThree.setSize(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getLength())); //定尺
 			rollClubThree.setSteel(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getGrade())); //钢种
 			rollClubThree.setSpec(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getSpec())); //规格
-			rollClubThree.setBlankOutput(rollClubCommonList.stream().findFirst().orElse(null).getBilletWeight());//出坯量
+			rollClubThree.setBlankOutput(rollClubCommonList.stream().mapToDouble(RollClubCommon::getBilletWeight).sum());//出坯量总和
+			rollClubThree.setStorageBillId(storageBill.getId());
 			LambdaQueryWrapper<RollClubThree> queryWrapper1 = new LambdaQueryWrapper<>();
 			queryWrapper1.eq(RollClubThree::getCcmNo, billetHotsend.getCcmNo())
 					.eq(RollClubThree::getHeatNo, billetHotsend.getHeatNo())
 					.eq(RollClubThree::getShift, billetHotsend.getShift())
-					.eq(RollClubThree::getShiftGroup, billetHotsend.getShiftGroup());
+					.eq(RollClubThree::getShiftGroup, billetHotsend.getShiftGroup())
+					.eq(RollClubThree::getStorageBillId, storageBill.getId());
 			RollClubThree rollClubThree1 = rollClubThreeService.getOne(queryWrapper1);
 			if (oConvertUtils.isEmpty(rollClubThree1)){
 				rollClubThree.setCreateDate(new Date());
@@ -638,7 +642,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			rollHeight.setSize(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getLength())); //定尺
 			rollHeight.setSteel(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getGrade())); //钢种
 			rollHeight.setSpec(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getSpec())); //规格
-			rollHeight.setBlankOutput(rollClubCommonList.stream().findFirst().orElse(null).getBilletWeight());//出坯量
+			rollHeight.setBlankOutput(rollClubCommonList.stream().mapToDouble(RollClubCommon::getBilletWeight).sum());//出坯量总和
 			LambdaQueryWrapper<RollHeight> queryWrapper1 = new LambdaQueryWrapper<>();
 			queryWrapper1.eq(RollHeight::getCcmNo, billetHotsend.getCcmNo())
 					.eq(RollHeight::getHeatNo, billetHotsend.getHeatNo())
@@ -685,12 +689,14 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			rollOutShipp.setSize(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getLength())); //定尺
 			rollOutShipp.setSteel(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getGrade())); //钢种
 			rollOutShipp.setSpec(String.valueOf(rollClubCommonList.stream().findFirst().orElse(null).getSpec())); //规格
-			rollOutShipp.setBlankOutput(rollClubCommonList.stream().findFirst().orElse(null).getBilletWeight());//出坯量
+			rollOutShipp.setBlankOutput(rollClubCommonList.stream().mapToDouble(RollClubCommon::getBilletWeight).sum());//出坯量总和
+			rollOutShipp.setStorageBillId(storageBill.getId());
 			LambdaQueryWrapper<RollOutShipp> queryWrapper1 = new LambdaQueryWrapper<>();
 			queryWrapper1.eq(RollOutShipp::getCcmNo, billetHotsend.getCcmNo())
 					.eq(RollOutShipp::getHeatNo, billetHotsend.getHeatNo())
 					.eq(RollOutShipp::getShift, billetHotsend.getShift())
-					.eq(RollOutShipp::getShiftGroup, billetHotsend.getShiftGroup());
+					.eq(RollOutShipp::getShiftGroup, billetHotsend.getShiftGroup())
+					.eq(RollOutShipp::getStorageBillId, storageBill.getId());
 			RollOutShipp rollOutShipp1 = rollOutShippService.getOne(queryWrapper1);
 			if (oConvertUtils.isEmpty(rollOutShipp1)){
 				rollOutShipp.setCreateDate(new Date());

+ 5 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubThree/entity/RollClubThree.java

@@ -131,4 +131,9 @@ public class RollClubThree implements Serializable {
     @Excel(name = "是否已编辑", width = 15)
     @ApiModelProperty(value = "是否已编辑")
     private Boolean isUpd;
+
+    /**装运单ID*/
+    @Excel(name = "装运单ID", width = 15)
+    @ApiModelProperty(value = "装运单ID")
+    private String storageBillId;
 }

+ 42 - 27
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubThree/service/impl/RollClubThreeServiceImpl.java

@@ -14,6 +14,7 @@ import org.jeecg.modules.billet.rollHeight.entity.DestinationStatisticsDetails;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -35,21 +36,21 @@ public class RollClubThreeServiceImpl extends ServiceImpl<RollClubThreeMapper, R
     public DestinationStatistics queryByCcmNoHandle(String ccmNo) {
 
         DestinationStatistics destinationStatistics = new DestinationStatistics();
-//        LambdaQueryWrapper<RollClubThree> queryWrapper = new LambdaQueryWrapper<>();
-//        if (oConvertUtils.isNotEmpty(ccmNo)){
-//            queryWrapper.eq(RollClubThree::getCcmNo, ccmNo);
-//        }
-//        List<RollClubThree> rollClubThreeList = baseMapper.selectList(queryWrapper);
-//        if (oConvertUtils.listIsEmpty(rollClubThreeList)){
-//            return null;
-//        }
-//        Integer amountTotal = rollClubThreeList.stream().map(RollClubThree::getAmountTotal).reduce(0, Integer::sum);
-//        // 先将每个RollHeight对象中的heightValue属性值乘以blankOutput,再求和
-//        double sumResult = rollClubThreeList.stream().mapToDouble(x -> x.getAmountTotal() * x.getBlankOutput()).sum();
-//        BigDecimal bd = BigDecimal.valueOf(sumResult).setScale(2, BigDecimal.ROUND_HALF_UP);
-//        double finalResult = bd.doubleValue();
-//        destinationStatistics.setCounts(amountTotal);
-//        destinationStatistics.setBlankOutput(finalResult);
+        LambdaQueryWrapper<RollClubThree> queryWrapper = new LambdaQueryWrapper<>();
+        if (oConvertUtils.isNotEmpty(ccmNo)){
+            queryWrapper.eq(RollClubThree::getCcmNo, ccmNo);
+        }
+        List<RollClubThree> rollClubThreeList = baseMapper.selectList(queryWrapper);
+        if (oConvertUtils.listIsEmpty(rollClubThreeList)){
+            return null;
+        }
+        Integer amountTotal = rollClubThreeList.stream().map(RollClubThree::getAmountTotal).reduce(0, Integer::sum);
+        // 先将每个RollHeight对象中的heightValue属性值乘以blankOutput,再求和
+        double sumResult = rollClubThreeList.stream().map(RollClubThree::getBlankOutput).filter(blankOutput -> blankOutput!= null).mapToDouble(Double::doubleValue).sum();
+        BigDecimal bd = BigDecimal.valueOf(sumResult).setScale(4, BigDecimal.ROUND_HALF_UP);
+        double finalResult = bd.doubleValue();
+        destinationStatistics.setCounts(amountTotal);
+        destinationStatistics.setBlankOutput(finalResult);
         LambdaQueryWrapper<RollClubThreeDetails> queryWrapperDetails = new LambdaQueryWrapper<>();
         if (oConvertUtils.isNotEmpty(ccmNo)){
             queryWrapperDetails.eq(RollClubThreeDetails::getCcmNo, ccmNo);
@@ -61,7 +62,21 @@ public class RollClubThreeServiceImpl extends ServiceImpl<RollClubThreeMapper, R
         // 根据size属性进行分组,并统计每组的总数和总重
         Map<String, Double> sumBySize = rollClubThreeDetailsList.stream()
                 .collect(Collectors.groupingBy(RollClubThreeDetails::getSize,Collectors.summingDouble(RollClubThreeDetails::getBlankOutput)));
-        Map<String, Long> countBySize = rollClubThreeDetailsList.stream().collect(Collectors.groupingBy(RollClubThreeDetails::getSize, Collectors.counting()));
+
+        Map<String, Long> countBySize = rollClubThreeDetailsList.stream()
+                // 先按照size进行分组
+                .collect(Collectors.groupingBy(RollClubThreeDetails::getSize,
+                        // 自定义一个Collector来实现类似功能
+                        Collectors.collectingAndThen(
+                                Collectors.toList(),
+                                list -> list.stream().mapToLong(roll -> {
+                                    if (oConvertUtils.isEmpty(roll.getStackAddr())) {
+                                        return 1L;
+                                    }
+                                    return 4L;
+                                }).sum()
+                        )
+                ));
 
         List<DestinationStatisticsDetails> rollClubThreeDetailsStatisticsList = new ArrayList<>();
         sumBySize.forEach((size, totalWeight) -> {
@@ -75,17 +90,17 @@ public class RollClubThreeServiceImpl extends ServiceImpl<RollClubThreeMapper, R
             rollClubThreeDetailsStatisticsList.add(new DestinationStatisticsDetails(size, (int) count, totalWeight, ccmNos));
         });
 
-        Integer sums = rollClubThreeDetailsStatisticsList.stream()
-                .map(DestinationStatisticsDetails::getNums)
-                .reduce(0, Integer::sum);
-        // 使用String.format方法对求和结果保留两位小数
-        double blankOutputSum = rollClubThreeDetailsStatisticsList.stream()
-                .mapToDouble(DestinationStatisticsDetails::getBlankOutput)
-                .sum();
-        String formattedResult = String.format("%.4f", blankOutputSum);
-        double finalBlankOutputSum = Double.parseDouble(formattedResult);
-        destinationStatistics.setCounts(sums);
-        destinationStatistics.setBlankOutput(finalBlankOutputSum);
+//        Integer sums = rollClubThreeDetailsStatisticsList.stream()
+//                .map(DestinationStatisticsDetails::getNums)
+//                .reduce(0, Integer::sum);
+//        // 使用String.format方法对求和结果保留两位小数
+//        double blankOutputSum = rollClubThreeDetailsStatisticsList.stream()
+//                .mapToDouble(DestinationStatisticsDetails::getBlankOutput)
+//                .sum();
+//        String formattedResult = String.format("%.4f", blankOutputSum);
+//        double finalBlankOutputSum = Double.parseDouble(formattedResult);
+//        destinationStatistics.setCounts(sums);
+//        destinationStatistics.setBlankOutput(finalBlankOutputSum);
 
         destinationStatistics.setStatisticsDetailsList(rollClubThreeDetailsStatisticsList);
         return destinationStatistics;

+ 5 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubTwo/entity/RollClubTwo.java

@@ -131,4 +131,9 @@ public class RollClubTwo implements Serializable {
     @Excel(name = "是否已编辑", width = 15)
     @ApiModelProperty(value = "是否已编辑")
     private Boolean isUpd;
+
+    /**装运单ID*/
+    @Excel(name = "装运单ID", width = 15)
+    @ApiModelProperty(value = "装运单ID")
+    private String storageBillId;
 }

+ 43 - 27
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubTwo/service/impl/RollClubTwoServiceImpl.java

@@ -13,6 +13,7 @@ import org.jeecg.modules.billet.rollHeight.entity.DestinationStatisticsDetails;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -33,21 +34,21 @@ public class RollClubTwoServiceImpl extends ServiceImpl<RollClubTwoMapper, RollC
     @Override
     public DestinationStatistics queryByCcmNoHandle(String ccmNo) {
         DestinationStatistics destinationStatistics = new DestinationStatistics();
-//        LambdaQueryWrapper<RollClubTwo> queryWrapper = new LambdaQueryWrapper<>();
-//        if (oConvertUtils.isNotEmpty(ccmNo)){
-//            queryWrapper.eq(RollClubTwo::getCcmNo, ccmNo);
-//        }
-//        List<RollClubTwo> rollClubTwoList = baseMapper.selectList(queryWrapper);
-//        if (oConvertUtils.listIsEmpty(rollClubTwoList)){
-//            return null;
-//        }
-//        Integer amountTotal = rollClubTwoList.stream().map(RollClubTwo::getAmountTotal).reduce(0, Integer::sum);
-//        // 先将每个RollHeight对象中的heightValue属性值乘以blankOutput,再求和
-//        double sumResult = rollClubTwoList.stream().mapToDouble(x -> x.getAmountTotal() * x.getBlankOutput()).sum();
-//        BigDecimal bd = BigDecimal.valueOf(sumResult).setScale(2, BigDecimal.ROUND_HALF_UP);
-//        double finalResult = bd.doubleValue();
-//        destinationStatistics.setCounts(amountTotal);
-//        destinationStatistics.setBlankOutput(finalResult);
+        LambdaQueryWrapper<RollClubTwo> queryWrapper = new LambdaQueryWrapper<>();
+        if (oConvertUtils.isNotEmpty(ccmNo)){
+            queryWrapper.eq(RollClubTwo::getCcmNo, ccmNo);
+        }
+        List<RollClubTwo> rollClubTwoList = baseMapper.selectList(queryWrapper);
+        if (oConvertUtils.listIsEmpty(rollClubTwoList)){
+            return null;
+        }
+        Integer amountTotal = rollClubTwoList.stream().map(RollClubTwo::getAmountTotal).reduce(0, Integer::sum);
+        // 先将每个RollHeight对象中的heightValue属性值乘以blankOutput,再求和
+        double sumResult = rollClubTwoList.stream().map(RollClubTwo::getBlankOutput).filter(blankOutput -> blankOutput!= null).mapToDouble(Double::doubleValue).sum();
+        BigDecimal bd = BigDecimal.valueOf(sumResult).setScale(4, BigDecimal.ROUND_HALF_UP);
+        double finalResult = bd.doubleValue();
+        destinationStatistics.setCounts(amountTotal);
+        destinationStatistics.setBlankOutput(finalResult);
         LambdaQueryWrapper<RollClubTwoDetails> queryWrapperDetails = new LambdaQueryWrapper<>();
         if (oConvertUtils.isNotEmpty(ccmNo)){
             queryWrapperDetails.eq(RollClubTwoDetails::getCcmNo, ccmNo);
@@ -59,7 +60,22 @@ public class RollClubTwoServiceImpl extends ServiceImpl<RollClubTwoMapper, RollC
         // 根据size属性进行分组,并统计每组的总数和总重
         Map<String, Double> sumBySize = rollClubTwoDetailsList.stream()
                 .collect(Collectors.groupingBy(RollClubTwoDetails::getSize,Collectors.summingDouble(RollClubTwoDetails::getBlankOutput)));
-        Map<String, Long> countBySize = rollClubTwoDetailsList.stream().collect(Collectors.groupingBy(RollClubTwoDetails::getSize, Collectors.counting()));
+
+
+        Map<String, Long> countBySize = rollClubTwoDetailsList.stream()
+                // 先按照size进行分组
+                .collect(Collectors.groupingBy(RollClubTwoDetails::getSize,
+                        // 自定义一个Collector来实现类似功能
+                        Collectors.collectingAndThen(
+                                Collectors.toList(),
+                                list -> list.stream().mapToLong(roll -> {
+                                    if (oConvertUtils.isEmpty(roll.getStackAddr())) {
+                                        return 1L;
+                                    }
+                                    return 4L;
+                                }).sum()
+                        )
+                ));
 
         List<DestinationStatisticsDetails> rollClubTwoDetailsStatisticsList = new ArrayList<>();
         sumBySize.forEach((size, totalWeight) -> {
@@ -73,17 +89,17 @@ public class RollClubTwoServiceImpl extends ServiceImpl<RollClubTwoMapper, RollC
             rollClubTwoDetailsStatisticsList.add(new DestinationStatisticsDetails(size, (int) count, totalWeight, ccmNos));
         });
 
-        Integer sums = rollClubTwoDetailsStatisticsList.stream()
-                .map(DestinationStatisticsDetails::getNums)
-                .reduce(0, Integer::sum);
-        // 使用String.format方法对求和结果保留两位小数
-        double blankOutputSum = rollClubTwoDetailsStatisticsList.stream()
-                .mapToDouble(DestinationStatisticsDetails::getBlankOutput)
-                .sum();
-        String formattedResult = String.format("%.4f", blankOutputSum);
-        double finalBlankOutputSum = Double.parseDouble(formattedResult);
-        destinationStatistics.setCounts(sums);
-        destinationStatistics.setBlankOutput(finalBlankOutputSum);
+//        Integer sums = rollClubTwoDetailsStatisticsList.stream()
+//                .map(DestinationStatisticsDetails::getNums)
+//                .reduce(0, Integer::sum);
+//        // 使用String.format方法对求和结果保留两位小数
+//        double blankOutputSum = rollClubTwoDetailsStatisticsList.stream()
+//                .mapToDouble(DestinationStatisticsDetails::getBlankOutput)
+//                .sum();
+//        String formattedResult = String.format("%.4f", blankOutputSum);
+//        double finalBlankOutputSum = Double.parseDouble(formattedResult);
+//        destinationStatistics.setCounts(sums);
+//        destinationStatistics.setBlankOutput(finalBlankOutputSum);
         destinationStatistics.setStatisticsDetailsList(rollClubTwoDetailsStatisticsList);
         return destinationStatistics;
     }

+ 5 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollOutShipp/entity/RollOutShipp.java

@@ -131,4 +131,9 @@ public class RollOutShipp implements Serializable {
     @Excel(name = "是否已编辑", width = 15)
     @ApiModelProperty(value = "是否已编辑")
     private Boolean isUpd;
+
+    /**装运单ID*/
+    @Excel(name = "装运单ID", width = 15)
+    @ApiModelProperty(value = "装运单ID")
+    private String storageBillId;
 }

+ 42 - 31
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollOutShipp/service/impl/RollOutShippServiceImpl.java

@@ -13,6 +13,7 @@ import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -35,21 +36,21 @@ public class RollOutShippServiceImpl extends ServiceImpl<RollOutShippMapper, Rol
     public DestinationStatistics queryByCcmNoHandle(String ccmNo) {
 
         DestinationStatistics destinationStatistics = new DestinationStatistics();
-//        LambdaQueryWrapper<RollOutShipp> queryWrapper = new LambdaQueryWrapper<>();
-//        if (oConvertUtils.isNotEmpty(ccmNo)){
-//            queryWrapper.eq(RollOutShipp::getCcmNo, ccmNo);
-//        }
-//        List<RollOutShipp> rollOutShippsList = baseMapper.selectList(queryWrapper);
-//        if (oConvertUtils.listIsEmpty(rollOutShippsList)){
-//            return null;
-//        }
-//        Integer amountTotal = rollOutShippsList.stream().map(RollOutShipp::getAmountTotal).reduce(0, Integer::sum);
-//        // 先将每个RollHeight对象中的heightValue属性值乘以blankOutput,再求和
-//        double sumResult = rollOutShippsList.stream().mapToDouble(x -> x.getAmountTotal() * x.getBlankOutput()).sum();
-//        BigDecimal bd = BigDecimal.valueOf(sumResult).setScale(2, BigDecimal.ROUND_HALF_UP);
-//        double finalResult = bd.doubleValue();
-//        destinationStatistics.setCounts(amountTotal);
-//        destinationStatistics.setBlankOutput(finalResult);
+        LambdaQueryWrapper<RollOutShipp> queryWrapper = new LambdaQueryWrapper<>();
+        if (oConvertUtils.isNotEmpty(ccmNo)){
+            queryWrapper.eq(RollOutShipp::getCcmNo, ccmNo);
+        }
+        List<RollOutShipp> rollOutShippsList = baseMapper.selectList(queryWrapper);
+        if (oConvertUtils.listIsEmpty(rollOutShippsList)){
+            return null;
+        }
+        Integer amountTotal = rollOutShippsList.stream().map(RollOutShipp::getAmountTotal).reduce(0, Integer::sum);
+        // 先将每个RollHeight对象中的heightValue属性值乘以blankOutput,再求和
+        double sumResult = rollOutShippsList.stream().map(RollOutShipp::getBlankOutput).filter(blankOutput -> blankOutput!= null).mapToDouble(Double::doubleValue).sum();
+        BigDecimal bd = BigDecimal.valueOf(sumResult).setScale(4, BigDecimal.ROUND_HALF_UP);
+        double finalResult = bd.doubleValue();
+        destinationStatistics.setCounts(amountTotal);
+        destinationStatistics.setBlankOutput(finalResult);
         LambdaQueryWrapper<RollOutShippDetails> queryWrapperDetails = new LambdaQueryWrapper<>();
         if (oConvertUtils.isNotEmpty(ccmNo)){
             queryWrapperDetails.eq(RollOutShippDetails::getCcmNo, ccmNo);
@@ -60,12 +61,21 @@ public class RollOutShippServiceImpl extends ServiceImpl<RollOutShippMapper, Rol
         }
         // 根据size属性进行分组,并统计每组的总数和总重
         Map<String, Double> sumBySize = rollOutShippDetailsList.stream().collect(Collectors.groupingBy(RollOutShippDetails::getSize,Collectors.summingDouble(RollOutShippDetails::getBlankOutput)));
-        Map<String, Double> resultMap = sumBySize.entrySet().stream()
-                .collect(Collectors.toMap(
-                        Map.Entry::getKey,
-                        entry -> Double.parseDouble(String.format("%.2f", entry.getValue()))
+
+        Map<String, Long> countBySize = rollOutShippDetailsList.stream()
+                // 先按照size进行分组
+                .collect(Collectors.groupingBy(RollOutShippDetails::getSize,
+                        // 自定义一个Collector来实现类似功能
+                        Collectors.collectingAndThen(
+                                Collectors.toList(),
+                                list -> list.stream().mapToLong(roll -> {
+                                    if (oConvertUtils.isEmpty(roll.getStackAddr())) {
+                                        return 1L;
+                                    }
+                                    return 4L;
+                                }).sum()
+                        )
                 ));
-        Map<String, Long> countBySize = rollOutShippDetailsList.stream().collect(Collectors.groupingBy(RollOutShippDetails::getSize, Collectors.counting()));
 
         List<DestinationStatisticsDetails> rollOutShippDetailsStatisticsList = new ArrayList<>();
         sumBySize.forEach((size, totalWeight) -> {
@@ -78,17 +88,18 @@ public class RollOutShippServiceImpl extends ServiceImpl<RollOutShippMapper, Rol
                     .orElse(null);
             rollOutShippDetailsStatisticsList.add(new DestinationStatisticsDetails(size, (int) count, totalWeight, ccmNos));
         });
-        Integer sums = rollOutShippDetailsStatisticsList.stream()
-                .map(DestinationStatisticsDetails::getNums)
-                .reduce(0, Integer::sum);
-        // 使用String.format方法对求和结果保留两位小数
-        double blankOutputSum = rollOutShippDetailsStatisticsList.stream()
-                .mapToDouble(DestinationStatisticsDetails::getBlankOutput)
-                .sum();
-        String formattedResult = String.format("%.4f", blankOutputSum);
-        double finalBlankOutputSum = Double.parseDouble(formattedResult);
-        destinationStatistics.setCounts(sums);
-        destinationStatistics.setBlankOutput(finalBlankOutputSum);
+//        Integer sums = rollOutShippDetailsStatisticsList.stream()
+//                .map(DestinationStatisticsDetails::getNums)
+//                .reduce(0, Integer::sum);
+//        // 使用String.format方法对求和结果保留两位小数
+//        double blankOutputSum = rollOutShippDetailsStatisticsList.stream()
+//                .mapToDouble(DestinationStatisticsDetails::getBlankOutput)
+//                .sum();
+//        String formattedResult = String.format("%.4f", blankOutputSum);
+//        double finalBlankOutputSum = Double.parseDouble(formattedResult);
+//        destinationStatistics.setCounts(sums);
+//        destinationStatistics.setBlankOutput(finalBlankOutputSum);
+
         destinationStatistics.setStatisticsDetailsList(rollOutShippDetailsStatisticsList);
         return destinationStatistics;
     }

+ 130 - 12
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/service/impl/StackingAndLoadingVehiclesServiceImpl.java

@@ -23,12 +23,18 @@ import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendC
 import org.jeecg.modules.billet.billetHotsendConfig.entity.BilletHotsendTypeConfig;
 import org.jeecg.modules.billet.billetHotsendConfig.service.IBilletHotsendTypeConfigService;
 import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
+import org.jeecg.modules.billet.rollClubThree.entity.RollClubThree;
 import org.jeecg.modules.billet.rollClubThree.entity.RollClubThreeDetails;
 import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeDetailsService;
+import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeService;
+import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwo;
 import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwoDetails;
 import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoDetailsService;
+import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoService;
+import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShipp;
 import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
 import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
+import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippService;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingAndLoadingVehicles;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingDownLog;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingUpLog;
@@ -39,7 +45,6 @@ import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingUpLo
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.vo.LoadingParams;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.vo.SavVo;
 import org.jeecg.modules.billet.storageBill.entity.StorageBill;
-import org.jeecg.modules.billet.storageBill.service.IStorageBillModelService;
 import org.jeecg.modules.billet.storageBill.service.IStorageBillService;
 import org.jeecg.modules.billet.storageCarLog.entity.StorageCarLog;
 import org.jeecg.modules.billet.storageCarLog.service.IStorageCarLogService;
@@ -97,7 +102,12 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
     private IBilletHotsendAbandonsService billetHotsendAbandonsService;
     @Autowired
     public RedisTemplate redisTemplate;
-
+    @Autowired
+    private IRollClubTwoService rollClubTwoService;
+    @Autowired
+    private IRollClubThreeService rollClubThreeService;
+    @Autowired
+    private IRollOutShippService rollOutShippService;
     @Override
     public List<List<StackingAndLoadingVehicles>> getListBySatck(String typeConfigId) {
         LambdaQueryWrapper<StackingAndLoadingVehicles> wrapper = new LambdaQueryWrapper<>();
@@ -604,9 +614,13 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<>();
             queryWrapper.in(BilletBasicInfo::getBilletNo, Arrays.asList(parts));
             List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
+            if (oConvertUtils.listIsEmpty(billetBasicInfoList)){
+                return;
+            }
             BilletBasicInfo billetBasicInfo = billetBasicInfoList.stream().findFirst().orElse(null);
             List<String> heatNos = billetBasicInfoList.stream().map(BilletBasicInfo::getHeatNo).distinct().collect(Collectors.toList());
-            double amountTotal = billetBasicInfoList.stream().mapToDouble(BilletBasicInfo::getBilletWeight).sum();
+            double billetWeightTotal = billetBasicInfoList.stream().mapToDouble(BilletBasicInfo::getBilletWeight).sum();
+
             stackingDownLog.setHeatNo(String.join(",", heatNos));
             stackingDownLog.setBilletNo(x.getBilletNos());
             stackingDownLog.setStorageBillId(storageBill.getId());
@@ -618,6 +632,40 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
 //            stackingUpLog.setFromStackingId(stackingAndLoadingVehicles.getId());
             stackingDownLogList.add(stackingDownLog);
             if ("roll_club_two".equals(loadingParams.getDestinationTable())){
+                billetBasicInfoList.forEach(y ->{
+                    LambdaQueryWrapper<RollClubTwo> queryWrapper1 = new LambdaQueryWrapper<>();
+                    queryWrapper1.eq(RollClubTwo::getCcmNo, y.getCcmNo().toString())
+                            .eq(RollClubTwo::getHeatNo, y.getHeatNo())
+                            .eq(RollClubTwo::getShift, y.getShift())
+                            .eq(RollClubTwo::getShiftGroup, y.getShiftGroup())
+                            .eq(RollClubTwo::getStorageBillId, storageBill.getId());
+                    RollClubTwo rollClubTwo1 = rollClubTwoService.getOne(queryWrapper1);
+                    RollClubTwo rollClubTwo = new RollClubTwo();
+                    if (oConvertUtils.isEmpty(rollClubTwo1)){
+                        // 堆垛保存时 目的地为为棒二 保存棒二信息
+                        rollClubTwo.setId(String.valueOf(IdWorker.getId()));
+                        rollClubTwo.setCcmNo(y.getCcmNo().toString());
+                        rollClubTwo.setHeatNo(y.getHeatNo());
+                        rollClubTwo.setSize(y.getLength().toString());
+                        rollClubTwo.setAmountTotal(1);
+                        rollClubTwo.setSteel(y.getGrade());
+                        rollClubTwo.setSpec(y.getSpec());
+                        rollClubTwo.setShiftGroup(y.getShiftGroup());
+                        rollClubTwo.setShift(y.getShift());
+                        rollClubTwo.setBlankOutput(oConvertUtils.isEmpty(y.getBilletWeight()) ? 0l : y.getBilletWeight());
+                        rollClubTwo.setStorageBillId(storageBill.getId());
+                        rollClubTwo.setCreateDate(new Date());
+                        rollClubTwo.setCreateTime(new Date());
+                        rollClubTwoService.save(rollClubTwo);
+                    }else {
+                        // 堆垛发车时
+                        rollClubTwo.setId(rollClubTwo1.getId());
+                        rollClubTwo.setAmountTotal(rollClubTwo1.getAmountTotal() + 1);// 总支数
+                        rollClubTwo.setBlankOutput(rollClubTwo1.getBlankOutput() + y.getBilletWeight());
+                        rollClubTwo.setUpdateTime(new Date());
+                        rollClubTwoService.updateById(rollClubTwo);
+                    }
+                });
                 RollClubTwoDetails rollClubTwoDetails = new RollClubTwoDetails();
                 BeanUtils.copyProperties(x, rollClubTwoDetails);
                 rollClubTwoDetails.setHeatNo(String.join(",", heatNos));
@@ -625,21 +673,56 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollClubTwoDetails.setStorageBillId(storageBill.getId());
                 rollClubTwoDetails.setStackStorey(x.getLayer());
                 rollClubTwoDetails.setStackNum(x.getAddress());
-                rollClubTwoDetails.setShiftGroup(billetBasicInfo.getShiftGroup());
-                rollClubTwoDetails.setShift(billetBasicInfo.getShift());
+                rollClubTwoDetails.setShiftGroup(x.getShiftGroup());
+                rollClubTwoDetails.setShift(x.getShift());
                 rollClubTwoDetails.setLicensePlate(storageBill.getLicensePlate());
                 rollClubTwoDetails.setCreateTime(new Date());
                 rollClubTwoDetails.setUpdateTime(new Date());
                 rollClubTwoDetails.setId(String.valueOf(IdWorker.getId()));
-                rollClubTwoDetails.setBlankOutput(amountTotal);//出坯量
+                rollClubTwoDetails.setBlankOutput(billetWeightTotal);//出坯量
                 addRollClubTwoDetailsList.add(rollClubTwoDetails);
             }else if ("roll_club_three".equals(loadingParams.getDestinationTable())){
+                billetBasicInfoList.forEach(y ->{
+                    LambdaQueryWrapper<RollClubThree> queryWrapper1 = new LambdaQueryWrapper<>();
+                    queryWrapper1.eq(RollClubThree::getCcmNo, y.getCcmNo().toString())
+                            .eq(RollClubThree::getHeatNo, y.getHeatNo())
+                            .eq(RollClubThree::getShift, y.getShift())
+                            .eq(RollClubThree::getShiftGroup, y.getShiftGroup())
+                            .eq(RollClubThree::getStorageBillId, storageBill.getId());
+                    RollClubThree rollClubThree1 = rollClubThreeService.getOne(queryWrapper1);
+                    RollClubThree rollClubThree = new RollClubThree();
+                    if (oConvertUtils.isEmpty(rollClubThree1)){
+                        // 堆垛保存发车时  目的地为为棒三 保存棒三信息
+                        rollClubThree.setId(String.valueOf(IdWorker.getId()));
+                        rollClubThree.setCcmNo(y.getCcmNo().toString());
+                        rollClubThree.setHeatNo(y.getHeatNo());
+                        rollClubThree.setSize(y.getLength().toString());
+                        rollClubThree.setAmountTotal(1);
+                        rollClubThree.setSteel(y.getGrade());
+                        rollClubThree.setSpec(y.getSpec());
+                        rollClubThree.setShiftGroup(y.getShiftGroup());
+                        rollClubThree.setShift(y.getShift());
+                        rollClubThree.setBlankOutput(oConvertUtils.isEmpty(y.getBilletWeight()) ? 0l : y.getBilletWeight());
+                        rollClubThree.setStorageBillId(storageBill.getId());
+                        rollClubThree.setCreateDate(new Date());
+                        rollClubThree.setCreateTime(new Date());
+                        rollClubThreeService.save(rollClubThree);
+                    }else {
+                        // 堆垛保存发车时  目的地为为棒三 更新棒三信息
+                        rollClubThree.setId(rollClubThree1.getId());
+                        rollClubThree.setAmountTotal(rollClubThree1.getAmountTotal() + 1);// 总支数
+                        rollClubThree.setBlankOutput(rollClubThree1.getBlankOutput() + y.getBilletWeight());
+                        rollClubThree.setUpdateTime(new Date());
+                        rollClubThreeService.updateById(rollClubThree);
+                    }
+                });
+                // 棒三明细
                 RollClubThreeDetails rollClubThreeDetails = new RollClubThreeDetails();
                 BeanUtils.copyProperties(x, rollClubThreeDetails);
                 rollClubThreeDetails.setHeatNo(String.join(",", heatNos));
                 rollClubThreeDetails.setBilletNo(x.getBilletNos());
-                rollClubThreeDetails.setShiftGroup(billetBasicInfo.getShiftGroup());
-                rollClubThreeDetails.setShift(billetBasicInfo.getShift());
+                rollClubThreeDetails.setShiftGroup(x.getShiftGroup());
+                rollClubThreeDetails.setShift(x.getShift());
                 rollClubThreeDetails.setStorageBillId(storageBill.getId());
                 rollClubThreeDetails.setStackStorey(x.getLayer());
                 rollClubThreeDetails.setStackNum(x.getAddress());
@@ -647,15 +730,50 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollClubThreeDetails.setCreateTime(new Date());
                 rollClubThreeDetails.setUpdateTime(new Date());
                 rollClubThreeDetails.setId(String.valueOf(IdWorker.getId()));
-                rollClubThreeDetails.setBlankOutput(amountTotal);//出坯量
+                rollClubThreeDetails.setBlankOutput(billetWeightTotal);//出坯量
                 addRollClubThreeDetailsList.add(rollClubThreeDetails);
             }else if ("roll_out_shipp".equals(loadingParams.getDestinationTable())){
+                billetBasicInfoList.forEach(y ->{
+                    LambdaQueryWrapper<RollOutShipp> queryWrapper1 = new LambdaQueryWrapper<>();
+                    queryWrapper1.eq(RollOutShipp::getCcmNo, y.getCcmNo().toString())
+                            .eq(RollOutShipp::getHeatNo, y.getHeatNo())
+                            .eq(RollOutShipp::getShift, y.getShift())
+                            .eq(RollOutShipp::getShiftGroup, y.getShiftGroup())
+                            .eq(RollOutShipp::getStorageBillId, storageBill.getId());
+                    RollOutShipp rollOutShipp1 = rollOutShippService.getOne(queryWrapper1);
+                    RollOutShipp rollOutShipp = new RollOutShipp();
+                    if (oConvertUtils.isEmpty(rollOutShipp1)){
+                        // 堆垛保存发车时 目的地为为上若 保存上若信息
+                        rollOutShipp.setId(String.valueOf(IdWorker.getId()));
+                        rollOutShipp.setCcmNo(y.getCcmNo().toString());
+                        rollOutShipp.setHeatNo(y.getHeatNo());
+                        rollOutShipp.setSize(y.getLength().toString());
+                        rollOutShipp.setAmountTotal(1);
+                        rollOutShipp.setSteel(y.getGrade());
+                        rollOutShipp.setSpec(y.getSpec());
+                        rollOutShipp.setShiftGroup(y.getShiftGroup());
+                        rollOutShipp.setShift(y.getShift());
+                        rollOutShipp.setBlankOutput(oConvertUtils.isEmpty(y.getBilletWeight()) ? 0l : y.getBilletWeight());
+                        rollOutShipp.setStorageBillId(storageBill.getId());
+                        rollOutShipp.setCreateDate(new Date());
+                        rollOutShipp.setCreateTime(new Date());
+                        rollOutShippService.save(rollOutShipp);
+                    }else {
+                        // 堆垛保存发车时 目的地为为上若 更新上若信息
+                        rollOutShipp.setId(rollOutShipp1.getId());
+                        rollOutShipp.setAmountTotal(rollOutShipp1.getAmountTotal() + 1);// 总支数
+                        rollOutShipp.setBlankOutput(rollOutShipp1.getBlankOutput() + y.getBilletWeight());
+                        rollOutShipp.setUpdateTime(new Date());
+                        rollOutShippService.updateById(rollOutShipp);
+                    }
+                });
+
                 RollOutShippDetails rollOutShippDetails = new RollOutShippDetails();
                 BeanUtils.copyProperties(x, rollOutShippDetails);
                 rollOutShippDetails.setHeatNo(String.join(",", heatNos));
                 rollOutShippDetails.setBilletNo(x.getBilletNos());
-                rollOutShippDetails.setShiftGroup(billetBasicInfo.getShiftGroup());
-                rollOutShippDetails.setShift(billetBasicInfo.getShift());
+                rollOutShippDetails.setShiftGroup(x.getShiftGroup());
+                rollOutShippDetails.setShift(x.getShift());
                 rollOutShippDetails.setStorageBillId(storageBill.getId());
                 rollOutShippDetails.setStackStorey(x.getLayer());
                 rollOutShippDetails.setStackNum(x.getAddress());
@@ -663,7 +781,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollOutShippDetails.setId(String.valueOf(IdWorker.getId()));
                 rollOutShippDetails.setCreateTime(new Date());
                 rollOutShippDetails.setUpdateTime(new Date());
-                rollOutShippDetails.setBlankOutput(amountTotal);//出坯量
+                rollOutShippDetails.setBlankOutput(billetWeightTotal);//出坯量
                 addRollOutShippDetailsList.add(rollOutShippDetails);
             }
         });