qiangxuan 3 сар өмнө
parent
commit
94a3ab435f

+ 63 - 54
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/service/impl/BilletHotsendChangeShiftServiceImpl.java

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 
 /**
  * @Description: 钢坯交班记录
@@ -42,62 +43,70 @@ public class BilletHotsendChangeShiftServiceImpl extends ServiceImpl<BilletHotse
     public JSONObject billetHotsendChangeShiftHandle(BilletHotsendChangeShift billetHotsendChangeShiftVo) {
 
         JSONObject result = new JSONObject();
-        //先更新班组班别缓存
-        String keyShiftGroup = String.format("class:shift:group:%s", billetHotsendChangeShiftVo.getCcmNo());
-        String keyShift = String.format("class:shift:%s", billetHotsendChangeShiftVo.getCcmNo());
-        redisTemplate.opsForValue().set(keyShiftGroup, billetHotsendChangeShiftVo.getShiftGroup());
-        redisTemplate.opsForValue().set(keyShift, billetHotsendChangeShiftVo.getShift());
-        // 获取当前班组班别
-        BilletHotsendChangeShift billetHotsendChangeShift = baseMapper.selectOne(new LambdaQueryWrapper<BilletHotsendChangeShift>()
-                .eq(BilletHotsendChangeShift::getCcmNo, billetHotsendChangeShiftVo.getCcmNo())
-                .orderByDesc(BilletHotsendChangeShift::getCreateTime).last("limit 1"));
-        if (oConvertUtils.isEmpty(billetHotsendChangeShift)){
-            result.put("fail", "当班查询为空,交班操作失败!");
-        }
-        // 更新当前班次的更新时间,相当于上一个班交班的结束时间
-        billetHotsendChangeShift.setUpdateTime(new Date());
-        baseMapper.updateById(billetHotsendChangeShift);
-        // 获取当前最新炉号
-        BilletBasicInfo billetBasicInfo = billetBasicInfoService.list(new LambdaQueryWrapper<BilletBasicInfo>().orderByDesc(BilletBasicInfo::getCreateTime)).stream().findFirst().orElse(null);
-        if (oConvertUtils.isNotEmpty(billetBasicInfo)){
-            // 根据当前炉号、铸机号、班组、班别查询总生产的钢坯数
-            LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<BilletBasicInfo>()
-                    .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsendChangeShiftVo.getCcmNo()))
-                    .eq(BilletBasicInfo::getHeatNo, billetBasicInfo.getHeatNo())
-                    .eq(BilletBasicInfo::getShift, billetHotsendChangeShift.getShift())
-                    .eq(BilletBasicInfo::getShiftGroup, billetHotsendChangeShift.getShiftGroup())
-                    .orderByDesc(BilletBasicInfo::getCreateTime);
-            List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
-            if (oConvertUtils.listIsNotEmpty(billetBasicInfoList)){
-                List<BilletBasicInfo> updateBilletBasicInfo = extractRemainderData(billetBasicInfoList);
-                updateBilletBasicInfo.forEach(x ->{
-                    x.setShift(billetHotsendChangeShiftVo.getShift());
-                    x.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
-                    x.setUpdateTime(new Date());
-                });
-                billetBasicInfoService.saveOrUpdateBatch(updateBilletBasicInfo);
+        try {
+            //先更新班组班别缓存
+            String keyShiftGroup = String.format("class:shift:group:%s", billetHotsendChangeShiftVo.getCcmNo());
+            String keyShift = String.format("class:shift:%s", billetHotsendChangeShiftVo.getCcmNo());
+            redisTemplate.opsForValue().set(keyShiftGroup, billetHotsendChangeShiftVo.getShiftGroup());
+            redisTemplate.opsForValue().set(keyShift, billetHotsendChangeShiftVo.getShift());
+            // 获取当前班组班别
+            BilletHotsendChangeShift billetHotsendChangeShift = baseMapper.selectOne(new LambdaQueryWrapper<BilletHotsendChangeShift>()
+                    .eq(BilletHotsendChangeShift::getCcmNo, billetHotsendChangeShiftVo.getCcmNo())
+                    .orderByDesc(BilletHotsendChangeShift::getCreateTime).last("limit 1"));
+            if (oConvertUtils.isEmpty(billetHotsendChangeShift)){
+                result.put("fail", "当班信息查询为空,交班操作失败!");
+                return result;
+            }
+            // 更新当前班次的更新时间,相当于上一个班交班的结束时间
+            billetHotsendChangeShift.setUpdateTime(new Date());
+            baseMapper.updateById(billetHotsendChangeShift);
+            // 获取当前最新炉号
+            BilletBasicInfo billetBasicInfo = Optional.ofNullable(billetBasicInfoService.list(new LambdaQueryWrapper<BilletBasicInfo>()
+                            .orderByDesc(BilletBasicInfo::getCreateTime)))
+                    .flatMap(list -> list.stream().findFirst())
+                    .orElse(null);
+            if (oConvertUtils.isNotEmpty(billetBasicInfo)){
+                // 根据当前炉号、铸机号、班组、班别查询总生产的钢坯数
+                LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<BilletBasicInfo>()
+                        .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsendChangeShiftVo.getCcmNo()))
+                        .eq(BilletBasicInfo::getHeatNo, billetBasicInfo.getHeatNo())
+                        .eq(BilletBasicInfo::getShift, billetHotsendChangeShift.getShift())
+                        .eq(BilletBasicInfo::getShiftGroup, billetHotsendChangeShift.getShiftGroup())
+                        .orderByDesc(BilletBasicInfo::getCreateTime);
+                List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
+                if (oConvertUtils.listIsNotEmpty(billetBasicInfoList)){
+                    List<BilletBasicInfo> updateBilletBasicInfo = extractRemainderData(billetBasicInfoList);
+                    updateBilletBasicInfo.forEach(x ->{
+                        x.setShift(billetHotsendChangeShiftVo.getShift());
+                        x.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
+                        x.setUpdateTime(new Date());
+                    });
+                    billetBasicInfoService.saveOrUpdateBatch(updateBilletBasicInfo);
+                }
             }
-        }
-
-        // 生成新的交班记录 初始化并保存入库
-        BilletHotsendChangeShift billetHotsendChangeShift1 = new BilletHotsendChangeShift();
-        billetHotsendChangeShift1.setId(String.valueOf(IdWorker.getId()));
-        billetHotsendChangeShift1.setCcmNo(billetHotsendChangeShiftVo.getCcmNo());
-        billetHotsendChangeShift1.setShift(billetHotsendChangeShiftVo.getShift());
-        billetHotsendChangeShift1.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
-        billetHotsendChangeShift1.setHotfeignAmount(0);// 当前热装支数
-        billetHotsendChangeShift1.setProductAmount(0);//当前生产支数
-        billetHotsendChangeShift1.setHotsendAmount(0);// 当前热送支数
-        billetHotsendChangeShift1.setStackAmount(0);//当前起垛支数
-        billetHotsendChangeShift1.setOutCarNum(0);//车次
-        billetHotsendChangeShift1.setShiftSum(0);//当班总数
-        billetHotsendChangeShift1.setShiftProduct(0d); // 当班总重
-        billetHotsendChangeShift1.setWasteAmount(0);// 当前废品支数
-        billetHotsendChangeShift1.setCreateTime(new Date());
-        baseMapper.insert(billetHotsendChangeShift1);
-        operateLogService.add(billetHotsendChangeShift1,null, BilletHotsendChangeShift.class);
 
-        result.put("success", "交班操作成功!");
+            // 生成新的交班记录 初始化并保存入库
+            BilletHotsendChangeShift billetHotsendChangeShift1 = new BilletHotsendChangeShift();
+            billetHotsendChangeShift1.setId(String.valueOf(IdWorker.getId()));
+            billetHotsendChangeShift1.setCcmNo(billetHotsendChangeShiftVo.getCcmNo());
+            billetHotsendChangeShift1.setShift(billetHotsendChangeShiftVo.getShift());
+            billetHotsendChangeShift1.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
+            billetHotsendChangeShift1.setHotfeignAmount(0);// 当前热装支数
+            billetHotsendChangeShift1.setProductAmount(0);//当前生产支数
+            billetHotsendChangeShift1.setHotsendAmount(0);// 当前热送支数
+            billetHotsendChangeShift1.setStackAmount(0);//当前起垛支数
+            billetHotsendChangeShift1.setOutCarNum(0);//车次
+            billetHotsendChangeShift1.setShiftSum(0);//当班总数
+            billetHotsendChangeShift1.setShiftProduct(0d); // 当班总重
+            billetHotsendChangeShift1.setWasteAmount(0);// 当前废品支数
+            billetHotsendChangeShift1.setCreateTime(new Date());
+            baseMapper.insert(billetHotsendChangeShift1);
+            operateLogService.add(billetHotsendChangeShift1,null, BilletHotsendChangeShift.class);
+            result.put("success", "交班操作成功!");
+        }catch (Exception e) {
+            log.error("交班操作出现异常", e);
+            result.put("fail", "交班操作失败,出现异常!");
+        }
         return result;
     }
 

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

@@ -181,14 +181,14 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 .collect(Collectors.toList());
         if (oConvertUtils.listIsEmpty(idList)){
             log.info("{}{}", "装运单ID为空,装运明细查询失败", JSON.toJSON(storageBill));
-            return null;
+            return result;
         }
 
         //根据部门orgCode查询部门,需要将职位id进行传递
         BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
         if (oConvertUtils.isEmpty(billetHotsendTypeConfig)){
             log.info("{}{}", "钢坯类型配置信息查询为空,装运明细查询失败", JSON.toJSON(storageBill));
-            return null;
+            return result;
         }
         if ("billet_auto_tmp".equals(billetHotsendTypeConfig.getBelongTable())){
             List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(new LambdaQueryWrapper<BilletAutoTmp>().in(BilletAutoTmp::getStorageBillId, idList));
@@ -249,21 +249,21 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 .collect(Collectors.toList());
         if (oConvertUtils.listIsEmpty(idList)){
             log.info("{}{}", "装运单ID为空,装运明细查询失败", JSON.toJSON(storageBill));
-            return null;
+            return result;
         }
 
         List<String> typeConfigIds = Arrays.stream(storageBill.getTypeConfigId().split(","))
                 .collect(Collectors.toList());
         if (oConvertUtils.listIsEmpty(typeConfigIds)){
             log.info("{}{}", "钢坯配置类型ID为空,装运明细查询失败", JSON.toJSON(storageBill));
-            return null;
+            return result;
         }
 
         //根据部门orgCode查询部门,需要将职位id进行传递
         List<BilletHotsendTypeConfig> billetHotsendTypeConfigs = billetHotsendTypeConfigService.listByIds(typeConfigIds);
         if (CollectionUtils.isEmpty(billetHotsendTypeConfigs)){
             log.info("{}{}", "钢坯类型配置信息查询为空,装运明细查询失败", JSON.toJSON(storageBill));
-            return null;
+            return result;
         }
         for (BilletHotsendTypeConfig billetHotsendTypeConfig : billetHotsendTypeConfigs) {
             if ("billet_auto_tmp".equals(billetHotsendTypeConfig.getBelongTable())){
@@ -1604,9 +1604,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             log.info("{}{}", "查询当班装运单信息为空!", ccmNo);
             return onDutyStorageBillStatistics;
         }
-        Integer allCarNum = storageBillList.stream()
-                .map(StorageBill::getCarNum)
-                .reduce(0, Integer::sum);
+        Integer allCarNum = storageBillList.stream().map(StorageBill::getCarNum).reduce(0, Integer::sum);
 
         List<DestinationStatisticsDetails> statisticsDetailsList1 = new ArrayList<>();
         List<DestinationStatisticsDetails> statisticsDetailsList2 = new ArrayList<>();
@@ -1634,18 +1632,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                                 double finalBlankOutput = bd.doubleValue();
                                 String ccmNos = group.isEmpty() ? null : group.get(0).getCcmNo();
                                 return new DestinationStatisticsDetails(size, nums, finalBlankOutput, ccmNos);
-                            })
-                            .collect(Collectors.toList());
+                            }).collect(Collectors.toList());
                     statisticsDetailsList1.addAll(currentList1);
-
-                    int totalNums = currentList1.stream()
-                            .mapToInt(DestinationStatisticsDetails::getNums)
-                            .sum();
-                    onDutyStorageBillStatistics.setCounts(totalNums);
-
-                    double totalBlankOutputs = rollClubTwoDetailsList.stream().mapToDouble(RollClubTwoDetails::getBlankOutput).sum();
-                    BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
-                    onDutyStorageBillStatistics.setBlankOutputs(bd);
                 }
             }
 
@@ -1670,18 +1658,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                                 double finalBlankOutput = bd.doubleValue();
                                 String ccmNos = group.isEmpty() ? null : group.get(0).getCcmNo();
                                 return new DestinationStatisticsDetails(size, nums, finalBlankOutput, ccmNos);
-                            })
-                            .collect(Collectors.toList());
+                            }).collect(Collectors.toList());
                     statisticsDetailsList2.addAll(currentList2);
-
-                    int totalNums = currentList2.stream()
-                            .mapToInt(DestinationStatisticsDetails::getNums)
-                            .sum();
-                    onDutyStorageBillStatistics.setCounts(totalNums);
-
-                    double totalBlankOutputs = rollClubThreeDetailsList.stream().mapToDouble(RollClubThreeDetails::getBlankOutput).sum();
-                    BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
-                    onDutyStorageBillStatistics.setBlankOutputs(bd);
                 }
             }
 
@@ -1706,18 +1684,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                                 double finalBlankOutput = bd.doubleValue();
                                 String ccmNos = group.isEmpty() ? null : group.get(0).getCcmNo();
                                 return new DestinationStatisticsDetails(size, nums, finalBlankOutput, ccmNos);
-                            })
-                            .collect(Collectors.toList());
+                            }).collect(Collectors.toList());
                     statisticsDetailsList3.addAll(currentList3);
-
-                    int totalNums = currentList3.stream()
-                            .mapToInt(DestinationStatisticsDetails::getNums)
-                            .sum();
-                    onDutyStorageBillStatistics.setCounts(totalNums);
-
-                    double totalBlankOutputs = rollOutShippDetailsList.stream().mapToDouble(RollOutShippDetails::getBlankOutput).sum();
-                    BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
-                    onDutyStorageBillStatistics.setBlankOutputs(bd);
                 }
             }
         }
@@ -1726,8 +1694,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
         List<DestinationStatisticsDetails> mergedList = Stream.concat(
                         Stream.concat(statisticsDetailsList1.stream(), statisticsDetailsList2.stream()),
                         statisticsDetailsList3.stream()
-                )
-                .collect(Collectors.groupingBy(DestinationStatisticsDetails::getSize))
+                ).collect(Collectors.groupingBy(DestinationStatisticsDetails::getSize))
                 .entrySet().stream()
                 .map(entry -> {
                     String size = entry.getKey();
@@ -1738,8 +1705,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                     double finalBlankOutput = bd.doubleValue();
                     String ccmNoForGroup = group.isEmpty() ? null : group.get(0).getCcmNo();
                     return new DestinationStatisticsDetails(size, totalNums, finalBlankOutput, ccmNoForGroup);
-                })
-                .collect(Collectors.toList());
+                }).collect(Collectors.toList());
         // 遍历mergedList获取nums总和
         int finalAmountTotal = mergedList.stream().mapToInt(DestinationStatisticsDetails::getNums).sum();
         // 遍历mergedList获取blankOutput总和