Parcourir la source

6号机堆垛发车新增去高线逻辑

qiangxuan il y a 5 mois
Parent
commit
7e22526287

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

@@ -31,6 +31,10 @@ 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.rollHeight.entity.RollHeight;
+import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
+import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
+import org.jeecg.modules.billet.rollHeight.service.IRollHeightService;
 import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShipp;
 import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
 import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
@@ -44,6 +48,8 @@ import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingDown
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingUpLogService;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.vo.LoadingParams;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.vo.SavVo;
+import org.jeecg.modules.billet.storageBill.entity.ShiftEnum;
+import org.jeecg.modules.billet.storageBill.entity.ShiftGroupEnum;
 import org.jeecg.modules.billet.storageBill.entity.StorageBill;
 import org.jeecg.modules.billet.storageBill.service.IStorageBillService;
 import org.jeecg.modules.billet.storageCarLog.entity.StorageCarLog;
@@ -108,6 +114,10 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
     private IRollClubThreeService rollClubThreeService;
     @Autowired
     private IRollOutShippService rollOutShippService;
+    @Autowired
+    private IRollHeightService rollHeightService;
+    @Autowired
+    private IRollHeightDetailsService rollHeightDetailsService;
     @Override
     public List<List<StackingAndLoadingVehicles>> getListBySatck(String typeConfigId) {
         LambdaQueryWrapper<StackingAndLoadingVehicles> wrapper = new LambdaQueryWrapper<>();
@@ -515,8 +525,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         });
 
         StorageBill storageBill =loadingParams.getStorageBill();
-
-        handleStackDepartCommon(billetHotsend, stackingAndLoadingVehiclesList, loadingParams, billetHotsendTypeConfig, storageBill);
+        String rollHeightStorageBillId = String.valueOf(IdWorker.getId());
+        handleStackDepartCommon(billetHotsend, stackingAndLoadingVehiclesList, loadingParams, billetHotsendTypeConfig, storageBill, rollHeightStorageBillId);
 
         // 先根据垛位容器中的铸机号和炉号 查询钢坯热送基础信息
         Map<String, List<RollClubCommon>> rollClubCommonListttt = groupByShiftAttributes(rollClubCommonList);
@@ -578,7 +588,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
      * @param billetHotsendTypeConfig
      * @param storageBill
      */
-    private void handleStackDepartCommon(BilletHotsend billetHotsend, List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList, LoadingParams loadingParams, BilletHotsendTypeConfig billetHotsendTypeConfig, StorageBill storageBill){
+    private void handleStackDepartCommon(BilletHotsend billetHotsend, List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList, LoadingParams loadingParams, BilletHotsendTypeConfig billetHotsendTypeConfig, StorageBill storageBill, String rollHeightStorageBillId){
         String keyShiftGroup = String.format("class:shift:group:%s", billetHotsend.getCcmNo());
         String keyShift = String.format("class:shift:%s", billetHotsend.getCcmNo());
         String finalCacheShintGroup = redisTemplate.opsForValue().get(keyShiftGroup).toString();
@@ -604,6 +614,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         List<RollClubTwoDetails> addRollClubTwoDetailsList = new ArrayList<>();
         List<RollClubThreeDetails> addRollClubThreeDetailsList = new ArrayList<>();
         List<RollOutShippDetails> addRollOutShippDetailsList = new ArrayList<>();
+        List<RollHeightDetails> rollHeightDetailsList = new ArrayList<>();
+
         stackingAndLoadingVehiclesList.forEach(x ->{
             StackingDownLog stackingDownLog = new StackingDownLog();
             BeanUtils.copyProperties(x, stackingDownLog);
@@ -615,10 +627,11 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             queryWrapper.in(BilletBasicInfo::getBilletNo, Arrays.asList(parts));
             List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
             if (oConvertUtils.listIsEmpty(billetBasicInfoList)){
+                log.info("{}{}", "未查询到钢坯基础信息,堆垛操作失败!:", Arrays.asList(parts));
                 return;
             }
-            BilletBasicInfo billetBasicInfo = billetBasicInfoList.stream().findFirst().orElse(null);
             List<String> heatNos = billetBasicInfoList.stream().map(BilletBasicInfo::getHeatNo).distinct().collect(Collectors.toList());
+
             double billetWeightTotal = billetBasicInfoList.stream().mapToDouble(BilletBasicInfo::getBilletWeight).sum();
 
             stackingDownLog.setHeatNo(String.join(",", heatNos));
@@ -783,6 +796,53 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollOutShippDetails.setUpdateTime(new Date());
                 rollOutShippDetails.setBlankOutput(billetWeightTotal);//出坯量
                 addRollOutShippDetailsList.add(rollOutShippDetails);
+            }else if ("roll_height".equals(loadingParams.getDestinationTable())){
+                billetBasicInfoList.forEach(y ->{
+                    LambdaQueryWrapper<RollHeight> queryWrapper1 = new LambdaQueryWrapper<>();
+                    queryWrapper1.eq(RollHeight::getCcmNo, billetHotsend.getCcmNo())
+                            .eq(RollHeight::getHeatNo, billetHotsend.getHeatNo())
+                            .eq(RollHeight::getShift, billetHotsend.getShift())
+                            .eq(RollHeight::getShiftGroup, billetHotsend.getShiftGroup());
+                    RollHeight rollHeight1 = rollHeightService.getOne(queryWrapper1);
+                    RollHeight rollHeight = new RollHeight();
+                    if (oConvertUtils.isEmpty(rollHeight1)){
+                        // 堆垛保存发车时 目的地为高线时 保存上若信息
+                        rollHeight.setId(String.valueOf(IdWorker.getId()));
+                        rollHeight.setCcmNo(y.getCcmNo().toString());
+                        rollHeight.setHeatNo(y.getHeatNo());
+                        rollHeight.setSize(y.getLength().toString());
+                        rollHeight.setAmountTotal(1);
+                        rollHeight.setSteel(y.getGrade());
+                        rollHeight.setSpec(y.getSpec());
+                        rollHeight.setShiftGroup(y.getShiftGroup());
+                        rollHeight.setShift(y.getShift());
+                        rollHeight.setBlankOutput(oConvertUtils.isEmpty(y.getBilletWeight()) ? 0l : y.getBilletWeight());
+                        rollHeight.setCreateDate(new Date());
+                        rollHeight.setCreateTime(new Date());
+                        rollHeightService.save(rollHeight);
+                    }else {
+                        // 堆垛发车时 目的地为高线 更新高线信息
+                        rollHeight.setId(rollHeight1.getId());
+                        rollHeight.setAmountTotal(rollHeight1.getAmountTotal() + 1);// 总支数
+                        rollHeight.setBlankOutput(rollHeight1.getBlankOutput() + y.getBilletWeight());
+                        rollHeight.setUpdateTime(new Date());
+                        rollHeightService.updateById(rollHeight);
+                    }
+                });
+                // 保存高线明细信息
+                RollHeightDetails rollHeightDetails = new RollHeightDetails();
+                BeanUtils.copyProperties(x, rollHeightDetails);
+                rollHeightDetails.setHeatNo(String.join(",", heatNos));
+                rollHeightDetails.setBilletNo(x.getBilletNos());
+                rollHeightDetails.setShiftGroup(x.getShiftGroup());
+                rollHeightDetails.setShift(x.getShift());
+                rollHeightDetails.setLicensePlate("堆垛辊道");
+                rollHeightDetails.setStorageBillId(rollHeightStorageBillId);
+                rollHeightDetails.setId(String.valueOf(IdWorker.getId()));
+                rollHeightDetails.setCreateTime(new Date());
+                rollHeightDetails.setUpdateTime(new Date());
+                rollHeightDetails.setBlankOutput(billetWeightTotal);//出坯量
+                rollHeightDetailsList.add(rollHeightDetails);
             }
         });
         stackingDownLogService.saveBatch(stackingDownLogList);
@@ -793,6 +853,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             rollClubThreeDetailsService.saveBatch(addRollClubThreeDetailsList);
         }else if ("roll_out_shipp".equals(loadingParams.getDestinationTable())){
             rollOutShippDetailsService.saveBatch(addRollOutShippDetailsList);
+        }else if ("roll_height".equals(loadingParams.getDestinationTable())){
+            rollHeightDetailsService.saveBatch(rollHeightDetailsList);
         }
     }
 
@@ -828,8 +890,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         });
 
         StorageBill storageBill =loadingParams.getStorageBill();
-
-        handleStackDepartCommon(billetHotsend, stackingAndLoadingVehiclesList, loadingParams, billetHotsendTypeConfig, storageBill);
+        String rollHeightStorageBillId = String.valueOf(IdWorker.getId());
+        handleStackDepartCommon(billetHotsend, stackingAndLoadingVehiclesList, loadingParams, billetHotsendTypeConfig, storageBill, rollHeightStorageBillId);
         Map<String, List<RollClubCommon>> rollClubCommonListttt = groupByShiftAttributes(rollClubCommonList);
         for (Map.Entry<String, List<RollClubCommon>> entry : rollClubCommonListttt.entrySet()) {
             String[] parts = entry.getKey().split(",");
@@ -857,6 +919,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 billetHotsend.setRollclubthreeNum(oConvertUtils.isNotEmpty(idExistBh.getRollclubthreeNum()) ? idExistBh.getRollclubthreeNum() + groupRollClubCommonList.size() : groupRollClubCommonList.size());
             }else if ("roll_out_shipp".equals(loadingParams.getDestinationTable())){
                 billetHotsend.setRolloutshippNum(oConvertUtils.isNotEmpty(idExistBh.getRolloutshippNum()) ? idExistBh.getRolloutshippNum() + groupRollClubCommonList.size() : groupRollClubCommonList.size());
+            }else if ("roll_height".equals(loadingParams.getDestinationTable())){
+                billetHotsend.setRollheightNum(oConvertUtils.isNotEmpty(idExistBh.getRollheightNum()) ? idExistBh.getRollheightNum() + groupRollClubCommonList.size() : groupRollClubCommonList.size());
             }
             billetHotsend.setUpdateTime(new Date());
             billetHotsendBaseService.updateById(billetHotsend);
@@ -871,7 +935,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         //根据铸机号、钢坯转运单ID查询定尺信息
         List<String> sizeList = new ArrayList<>();
         List<String> heatNoList = new ArrayList<>();
-        long count = 0l;
+
+        long count = 0L;
         if ("roll_club_two".equals(loadingParams.getDestinationTable())){
             LambdaQueryWrapper<RollClubTwoDetails> queryWrapperRC = new LambdaQueryWrapper();
             queryWrapperRC.eq(RollClubTwoDetails::getCcmNo, storageBill.getCcmNo()).eq(RollClubTwoDetails::getStorageBillId, storageBill.getId());
@@ -908,8 +973,22 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 count = rollOutShippDetailsList.stream().count();
             }
         }
-        // 6 更新装运单 storage_bill
-        // 取最新的第一条钢坯信息更新钢种和规格
+        if ("roll_height".equals(loadingParams.getDestinationTable())){
+            heatNoList = rollClubCommonList.stream().map(RollClubCommon::getHeatNo).distinct().collect(Collectors.toList());
+            List<Integer> sizeHeightList = rollClubCommonList.stream().map(RollClubCommon::getLength).distinct().collect(Collectors.toList());
+            List<String> sizeLists = sizeHeightList.stream().map(String::valueOf).collect(Collectors.toList());
+            // 生成钢坯装运单记录
+            StorageBill storageBillInfo = createStorageBill(loadingParams, rollClubCommonList, sizeLists);
+            storageBillInfo.setId(rollHeightStorageBillId);
+            storageBillService.save(storageBillInfo);
+            // 生成钢坯储运单记录
+            StorageCarLog storageCarLog = createStorageCarLog(storageBillInfo, rollClubCommonList, heatNoList, sizeLists);
+            storageCarLogService.save(storageCarLog);
+            result.put("success", "堆垛去高线发车操作成功!");
+            return result;
+
+        }
+        // 6 更新装运单 storage_bill 取最新的第一条钢坯信息更新钢种和规格
         RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
         storageBill.setSteel(rollClubCommon.getGrade());//钢种
         storageBill.setSpec(rollClubCommon.getSpec());//规格
@@ -1192,4 +1271,65 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
         }
     }
+
+
+    /**
+     * 处理高线 装运单信息
+     * @param loadingParams
+     * @param rollClubCommonList
+     * @param sizeList
+     * @return
+     */
+    private StorageBill createStorageBill(LoadingParams loadingParams, List<RollClubCommon> rollClubCommonList, List<String> sizeList) {
+        StorageBill storageBillInfo = new StorageBill();
+        storageBillInfo.setBtype("0");
+        storageBillInfo.setTypeConfigId(loadingParams.getBilletHotsendTypeConfigId());
+        storageBillInfo.setDestination("高线");
+        storageBillInfo.setShiftGroup(loadingParams.getBilletHotsend().getShiftGroup());
+        storageBillInfo.setSteel(loadingParams.getBilletHotsend().getSteel());
+        storageBillInfo.setSpec(loadingParams.getBilletHotsend().getSpec());
+        storageBillInfo.setShift(loadingParams.getBilletHotsend().getShift());
+        storageBillInfo.setAmountTotal(rollClubCommonList.size());
+        LambdaQueryWrapper<StorageBill> queryWrapper1 = new LambdaQueryWrapper<>();
+        queryWrapper1.eq(StorageBill::getCcmNo, loadingParams.getBilletHotsend().getCcmNo())
+                .eq(StorageBill::getLicensePlate, "堆垛辊道")
+                .eq(StorageBill::getShiftGroup, loadingParams.getBilletHotsend().getShiftGroup())
+                .eq(StorageBill::getShift, loadingParams.getBilletHotsend().getShift())
+                .between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
+        List<StorageBill> storageBillList = storageBillService.list(queryWrapper1);
+        LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
+        queryWrapper2.eq(StorageBill::getCcmNo, loadingParams.getBilletHotsend().getCcmNo())
+                .between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
+        List<StorageBill> storageBillList2 = storageBillService.list(queryWrapper2);
+        storageBillInfo.setCarNum(oConvertUtils.listIsNotEmpty(storageBillList) ? storageBillList.size() + 1 : 1);
+        storageBillInfo.setCarAllNum(oConvertUtils.listIsNotEmpty(storageBillList2) ? storageBillList.size() + 1 : 1);
+        storageBillInfo.setLicensePlate("堆垛辊道");
+        storageBillInfo.setCcmNo(loadingParams.getBilletHotsend().getCcmNo());
+        storageBillInfo.setSize(String.join(",", sizeList));
+        storageBillInfo.setDateTime(new Date());
+        storageBillInfo.setCreateTime(new Date());
+        String uniqueCode = DateUtils.date2Str(new Date(), DateUtils.yyyymmddhhmmss.get()) + "-" + loadingParams.getBilletHotsend().getCcmNo() + "#" + ShiftEnum.fromCode(loadingParams.getBilletHotsend().getShift()).name() + "-" + ShiftGroupEnum.fromCode(loadingParams.getBilletHotsend().getShiftGroup()).name() ;
+        storageBillInfo.setUniqueCode(uniqueCode);
+        return storageBillInfo;
+    }
+
+    /**
+     * 处理储运记录
+     * @param storageBill
+     * @param rollClubCommonList
+     * @param heatNoList
+     * @param sizeList
+     * @return
+     */
+    private StorageCarLog createStorageCarLog(StorageBill storageBill, List<RollClubCommon> rollClubCommonList, List<String> heatNoList, List<String> sizeList) {
+        StorageCarLog storageCarLog = new StorageCarLog();
+        BeanUtils.copyProperties(storageBill, storageCarLog);
+        storageCarLog.setCarNm("堆垛辊道");
+        storageCarLog.setDestination("高线");
+        storageCarLog.setHeatNo(String.join(",", heatNoList));
+        storageCarLog.setSize(String.join(",", sizeList));
+        storageCarLog.setAmount(rollClubCommonList.size());
+        storageCarLog.setDataTime(new Date());
+        return storageCarLog;
+    }
 }