Bläddra i källkod

编辑目的地和看板确认同步临时表数据逻辑开发

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

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

@@ -45,6 +45,7 @@ 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.StackingUpLog;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingUpLogService;
 import org.jeecg.modules.billet.storageBill.entity.*;
@@ -2774,8 +2775,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
         JSONObject result = new JSONObject();
         try {
             log.info("{}{}", "编辑装运单未知目的地数据同步装运单信息:", JSON.toJSON(storageBill));
-            List<RollClubCommon> rollClubCommonList = new ArrayList<>();
-            // 根据装运单ID查询钢坯临时表
+
+            // 根据装运单ID查询钢坯临时表 棒线数据同步、堆垛数据同步
             List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(new LambdaQueryWrapper<BilletAutoTmp>()
                     .eq(BilletAutoTmp::getStorageBillId, storageBill.getId()));
             if (oConvertUtils.listIsEmpty(billetAutoTmpList)){
@@ -2783,77 +2784,210 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 result.put("fail", "编辑装运单未知目的地明细不存在,更新目的地成功!");
                 return result;
             }
-            billetAutoTmpList.forEach(x ->{
-                RollClubCommon rollClubCommon = new RollClubCommon();
-                BeanUtils.copyProperties(x, rollClubCommon);
-                rollClubCommon.setGrade(x.getSteel());
-                rollClubCommon.setLength(Integer.valueOf(x.getSize()));
-                rollClubCommon.setBilletWeight(x.getBlankOutput());
-                rollClubCommonList.add(rollClubCommon);
-            });
 
-            log.info("{}{}", "编辑装运单未知目的地数据同步临时表总条数:", rollClubCommonList.size());
+            List<BilletAutoTmp> billetAutoTmpHotChargeList = new ArrayList<>();
+            List<BilletAutoTmp> billetAutoTmpStackList = new ArrayList<>();
 
-            // 根据ID获取钢坯配置信息
-            BilletHotsend billetHotsend = new BilletHotsend();
-            billetHotsend.setCcmNo(storageBill.getCcmNo());
-            BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
+            List<RollClubCommon> rollClubCommonList = new ArrayList<>();
+            List<RollClubCommon> rollClubCommonHotChargeList = new ArrayList<>();
+            List<RollClubCommon> rollClubCommonStackList = new ArrayList<>();
 
-            BilletHotsendDetailsVo billetHotsendDetailsVo = new BilletHotsendDetailsVo();
-            billetHotsendDetailsVo.setBelongTable(billetHotsendTypeConfig.getBelongTable());
-            billetHotsendDetailsVo.setBelongTypeName(billetHotsendTypeConfig.getTypeName());
+            List<BilletBasicInfo> billetBasicInfoAllList = new ArrayList<>();
+            List<BilletBasicInfo> billetBasicInfoHotChargeList = new ArrayList<>();
+            List<BilletBasicInfo> billetBasicInfoStackList = new ArrayList<>();
 
-            billetHotsendDetailsVo.setDestination(billetHotsendTypeConfig.getTypeName());
-            billetHotsendDetailsVo.setDestinationId(billetHotsendTypeConfig.getId());
-            billetHotsendDetailsVo.setBilletHotsendTypeConfigId(billetHotsendTypeConfig.getId());
+            if (billetAutoTmpList != null && !billetAutoTmpList.isEmpty()) {
+                for (BilletAutoTmp billetAutoTmp : billetAutoTmpList) {
+                    if (billetAutoTmp.getStartNum() != null && billetAutoTmp.getEndNum() != null) {
+                        billetAutoTmpHotChargeList.add(billetAutoTmp);
+                    }
+                    if (billetAutoTmp.getStackStorey() != null && billetAutoTmp.getStackNum() != null) {
+                        billetAutoTmpStackList.add(billetAutoTmp);
+                    }
+                }
+            }
 
-            billetHotsendDetailsVo.setStorageBill(storageBill);
-            billetHotsendDetailsVo.setBilletHotsend(billetHotsend);
-            billetHotsendDetailsVo.setRollClubCommonList(rollClubCommonList);
+            // 棒线数据同步
+            if (oConvertUtils.listIsNotEmpty(billetAutoTmpHotChargeList)){
+                billetAutoTmpHotChargeList.forEach(x ->{
+                    RollClubCommon rollClubCommon = new RollClubCommon();
+                    BeanUtils.copyProperties(x, rollClubCommon);
+                    rollClubCommon.setGrade(x.getSteel());
+                    rollClubCommon.setLength(Integer.valueOf(x.getSize()));
+                    rollClubCommon.setBilletWeight(x.getBlankOutput());
+                    rollClubCommonHotChargeList.add(rollClubCommon);
+                });
+                log.info("{}{}", "装运单编辑,棒线临时表数据同步总条数:", rollClubCommonHotChargeList.size());
+
+                // 根据ID获取钢坯配置信息
+                BilletHotsend billetHotsend = new BilletHotsend();
+                billetHotsend.setCcmNo(storageBill.getCcmNo());
+
+                BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
+
+                BilletHotsendDetailsVo billetHotsendDetailsVo = new BilletHotsendDetailsVo();
+                billetHotsendDetailsVo.setBelongTable(billetHotsendTypeConfig.getBelongTable());
+                billetHotsendDetailsVo.setBelongTypeName(billetHotsendTypeConfig.getTypeName());
+
+                billetHotsendDetailsVo.setDestination(billetHotsendTypeConfig.getTypeName());
+                billetHotsendDetailsVo.setDestinationId(billetHotsendTypeConfig.getId());
+                billetHotsendDetailsVo.setBilletHotsendTypeConfigId(billetHotsendTypeConfig.getId());
+
+                billetHotsendDetailsVo.setStorageBill(storageBill);
+                billetHotsendDetailsVo.setBilletHotsend(billetHotsend);
+                billetHotsendDetailsVo.setRollClubCommonList(rollClubCommonHotChargeList);
+
+                Map<String, List<RollClubCommon>> rollClubCommonLists = groupByShiftAttributes(rollClubCommonHotChargeList);
+                /**
+                 * 维护热送单炉信息 保存棒二或或棒三明细 更新钢坯基础信息
+                 * 在这里可以添加更多针对每个分组(键和对应列表)的业务逻辑操作,比如遍历列表中的元素等
+                 */
+                for (Map.Entry<String, List<RollClubCommon>> entry : rollClubCommonLists.entrySet()) {
+                    String[] parts = entry.getKey().split(",");
+                    billetHotsend.setHeatNo(parts[0]);// 炉号
+                    billetHotsend.setShiftGroup(parts[1]);// 班组
+                    billetHotsend.setShift(parts[2]);// 班别
+                    List<RollClubCommon> groupRollClubCommonList = entry.getValue();
+                    JSONObject jsonObject = commonBilletHotsenAndDetailsHandle(billetHotsend, billetHotsendDetailsVo, billetHotsendTypeConfig, storageBill, groupRollClubCommonList, null);
+                    if (jsonObject.containsKey("fail")) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        log.info("{}{}", "编辑装运单,未知目的地数据同步操作失败,事务回滚!", jsonObject);
+                        result.put("fail", "编辑装运单,未知目的地数据同步操作失败!");
+                        return result;
+                    }
+                }
+                List<String> billetNos = rollClubCommonHotChargeList.stream().map(RollClubCommon::getBilletNo).collect(Collectors.toList());
+                //查询并批量更新钢坯基础信息 belongTable
+                LambdaQueryWrapper<BilletBasicInfo> queryWrapperls = new LambdaQueryWrapper<BilletBasicInfo>()
+                        .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
+                        .in(BilletBasicInfo::getBilletNo, billetNos);
+                billetBasicInfoHotChargeList = billetBasicInfoService.list(queryWrapperls);
+
+                billetBasicInfoHotChargeList.forEach(x ->{
+                    if ("roll_club_two".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_club_two");
+                    }else if ("roll_club_three".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_club_three");
+                    }else if ("roll_out_shipp".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_out_shipp");
+                    }
+                    x.setBhtcId(billetHotsendTypeConfig.getId());
+                    x.setUpdateTime(new Date());
+                });
+                billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoHotChargeList);
 
-            Map<String, List<RollClubCommon>> rollClubCommonLists = groupByShiftAttributes(rollClubCommonList);
-            /**
-             * 维护热送单炉信息 保存棒二或或棒三明细 更新钢坯基础信息
-             * 在这里可以添加更多针对每个分组(键和对应列表)的业务逻辑操作,比如遍历列表中的元素等
-             */
-            for (Map.Entry<String, List<RollClubCommon>> entry : rollClubCommonLists.entrySet()) {
-                String[] parts = entry.getKey().split(",");
-                billetHotsend.setHeatNo(parts[0]);// 炉号
-                billetHotsend.setShiftGroup(parts[1]);// 班组
-                billetHotsend.setShift(parts[2]);// 班别
-                List<RollClubCommon> groupRollClubCommonList = entry.getValue();
-                JSONObject jsonObject = commonBilletHotsenAndDetailsHandle(billetHotsend, billetHotsendDetailsVo, billetHotsendTypeConfig, storageBill, groupRollClubCommonList, null);
-                if (jsonObject.containsKey("fail")) {
-                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                    log.info("{}{}", "编辑装运单未知目的地数据同步操作失败,事务回滚!", jsonObject);
-                    result.put("fail", "编辑装运单未知目的地数据同步操作失败!");
+            }
+            // 堆垛数据同步
+            if (oConvertUtils.listIsNotEmpty(billetAutoTmpStackList)){
+
+                billetAutoTmpStackList.forEach(x ->{
+                    RollClubCommon rollClubCommon = new RollClubCommon();
+                    BeanUtils.copyProperties(x, rollClubCommon);
+                    rollClubCommon.setGrade(x.getSteel());
+                    rollClubCommon.setLength(Integer.valueOf(x.getSize()));
+                    rollClubCommon.setBilletWeight(x.getBlankOutput());
+                    rollClubCommonStackList.add(rollClubCommon);
+                });
+
+                // 根据ID获取钢坯配置信息
+                BilletHotsend billetHotsend = new BilletHotsend();
+                billetHotsend.setCcmNo(storageBill.getCcmNo());
+                billetHotsend.setShiftGroup(storageBill.getShiftGroup());
+                billetHotsend.setShift(storageBill.getShift());
+
+                BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
+                List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = new ArrayList<>();
+                billetAutoTmpStackList.forEach(x ->{
+                    StackingAndLoadingVehicles stackingAndLoadingVehicles = new StackingAndLoadingVehicles();
+                    BeanUtils.copyProperties(x, stackingAndLoadingVehicles);
+                    stackingAndLoadingVehicles.setBilletNos(x.getBilletNo());
+                    stackingAndLoadingVehicles.setAddress(x.getStackNum());
+                    stackingAndLoadingVehicles.setLayer(x.getStackStorey());
+                    stackingAndLoadingVehicles.setTypeConfigId(billetHotsendTypeConfig.getId());
+                    stackingAndLoadingVehiclesList.add(stackingAndLoadingVehicles);
+                });
+                // 保存明细
+                stackDataSynCommon(billetHotsend, billetHotsendTypeConfig, stackingAndLoadingVehiclesList, storageBill, rollClubCommonStackList);
+
+                // 先根据垛位容器中的铸机号和炉号 查询钢坯热送基础信息
+                Map<String, List<RollClubCommon>> rollClubCommonListttt = groupByShiftAttributes(rollClubCommonStackList);
+                for (Map.Entry<String, List<RollClubCommon>> entry : rollClubCommonListttt.entrySet()) {
+                    String[] parts = entry.getKey().split(",");
+                    billetHotsend.setHeatNo(parts[0]);// 炉号
+                    billetHotsend.setShiftGroup(parts[1]);// 班组
+                    billetHotsend.setShift(parts[2]);// 班别
+                    List<RollClubCommon> groupRollClubCommonList = entry.getValue();
+                    LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
+                    queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
+                            .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
+                            .eq(BilletHotsend::getShift,  billetHotsend.getShift())
+                            .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
+                    BilletHotsend idExistBh = billetHotsendBaseMapper.selectOne(queryWrapper);
+                    if (oConvertUtils.isEmpty(idExistBh)){
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        log.info("{}{}", "编辑装运单,钢坯热送单为空,堆垛数据同步失败:", JSON.toJSON(billetHotsend));
+                        result.put("fail", "编辑装运单,钢坯热送单为空,堆垛数据同步操作失败!");
+                        return result;
+                    }
+                    billetHotsend.setId(idExistBh.getId());
+                    // 钢坯热送基础信息存在,但是钢坯信息不存在 直接返回
+                    if ("roll_club_two".equals(billetHotsendTypeConfig.getBelongTable())){
+                        billetHotsend.setRollclubtwoNum(oConvertUtils.isNotEmpty(idExistBh.getRollclubtwoNum()) ? idExistBh.getRollclubtwoNum() + groupRollClubCommonList.size() : groupRollClubCommonList.size());
+                    }else if ("roll_club_three".equals(billetHotsendTypeConfig.getBelongTable())){
+                        billetHotsend.setRollclubthreeNum(oConvertUtils.isNotEmpty(idExistBh.getRollclubthreeNum()) ? idExistBh.getRollclubthreeNum() + groupRollClubCommonList.size() : groupRollClubCommonList.size());
+                    }else if ("roll_out_shipp".equals(billetHotsendTypeConfig.getBelongTable())){
+                        billetHotsend.setRolloutshippNum(oConvertUtils.isNotEmpty(idExistBh.getRolloutshippNum()) ? idExistBh.getRolloutshippNum() + groupRollClubCommonList.size() : groupRollClubCommonList.size());
+                    }
+                    billetHotsendBaseMapper.updateById(billetHotsend);
+                }
+
+                // 获取所有的坯号集合
+                List<String> billetNosList = rollClubCommonStackList.stream().map(RollClubCommon::getBilletNo)
+                        .flatMap(billetNos -> {
+                            if (billetNos != null) {
+                                return java.util.stream.Stream.of(billetNos.split(","));
+                            } else {
+                                return java.util.stream.Stream.empty();
+                            }
+                        }).collect(Collectors.toList());
+
+                //查询并批量更新钢坯基础信息 belongTable
+                LambdaQueryWrapper<BilletBasicInfo> queryWrapperls = new LambdaQueryWrapper<BilletBasicInfo>()
+                        .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
+                        .in(BilletBasicInfo::getBilletNo, billetNosList);
+                billetBasicInfoStackList = billetBasicInfoService.list(queryWrapperls);
+                if (oConvertUtils.listIsEmpty(billetBasicInfoStackList)) {
+                    result.put("fail", "编辑装运单,钢坯基础信息为空,堆垛数据同步失败!");
                     return result;
                 }
+                //5 查询并批量更新钢坯基础信息 belongTable
+                billetBasicInfoStackList.forEach(x ->{
+                    if ("roll_club_two".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_club_two");
+                    }else if ("roll_club_three".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_club_three");
+                    }else if ("roll_out_shipp".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_out_shipp");
+                    }
+                    x.setBhtcId(billetHotsendTypeConfig.getId());
+                    x.setUpdateTime(new Date());
+                });
+                billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoStackList);
+
             }
-            List<String> billetNos = rollClubCommonList.stream().map(RollClubCommon::getBilletNo).collect(Collectors.toList());
-            //查询并批量更新钢坯基础信息 belongTable
-            LambdaQueryWrapper<BilletBasicInfo> queryWrapperls = new LambdaQueryWrapper<BilletBasicInfo>()
-                    .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
-                    .in(BilletBasicInfo::getBilletNo, billetNos);
-            List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperls);
-            billetBasicInfoList.forEach(x ->{
-                if ("roll_club_two".equals(billetHotsendDetailsVo.getBelongTable())){
-                    x.setBelongTable("roll_club_two");
-                }else if ("roll_club_three".equals(billetHotsendDetailsVo.getBelongTable())){
-                    x.setBelongTable("roll_club_three");
-                }else if ("roll_out_shipp".equals(billetHotsendDetailsVo.getBelongTable())){
-                    x.setBelongTable("roll_out_shipp");
-                }
-                x.setBhtcId(billetHotsendDetailsVo.getBilletHotsendTypeConfigId());
-                x.setUpdateTime(new Date());
-            });
-            billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
 
-            log.info("{}{}", "B端编辑装运单未知目的地数据同步时,装运单总支数:", storageBill.getAmountTotal());
+            // 合并堆垛数据、棒线数据
+            rollClubCommonList.addAll(rollClubCommonStackList);
+            rollClubCommonList.addAll(rollClubCommonHotChargeList);
+            int amountTotal = calculateTotal(rollClubCommonList);
+
+            // 合并钢坯基础信息
+            billetBasicInfoAllList.addAll(billetBasicInfoStackList);
+            billetBasicInfoAllList.addAll(billetBasicInfoHotChargeList);
+
             // 维护总支数
-            storageBill.setAmountTotal(storageBill.getAmountTotal() + rollClubCommonList.size());
+            storageBill.setAmountTotal(storageBill.getAmountTotal() + amountTotal);
 
-            log.info("{}{}", "B端编辑装运单未知目的地数据同步后,累加临时表后的装运单总支数:", storageBill.getAmountTotal());
             // 取最新的第一条钢坯信息
             RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
             if (rollClubCommon != null) {
@@ -2865,9 +2999,9 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             String sizeString = String.join(",", sizeList.stream().map(String::valueOf).collect(Collectors.toList()));
             storageBill.setSize(sizeString);// 定尺
 
-            List<String> assemblyNumberList = billetBasicInfoList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
+            List<String> assemblyNumberList = billetBasicInfoAllList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
             if(oConvertUtils.listIsNotEmpty(assemblyNumberList)) {
-                String distinctAssemblyNumber = billetBasicInfoList.stream()
+                String distinctAssemblyNumber = billetBasicInfoAllList.stream()
                         .map(BilletBasicInfo::getAssemblyNumber)
                         .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
                         .distinct().collect(Collectors.joining(","));
@@ -2877,7 +3011,6 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                         .orElse(distinctAssemblyNumber);
                 storageBill.setAssemblyNumber(finalAssemblyNumber);
             }
-            storageBill.setUpdateTime(new Date());
             baseMapper.updateById(storageBill);
 
             // 物理删除钢坯临时表记录
@@ -2900,86 +3033,220 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
     public JSONObject billetAutoTmpDataSynConfirm(StorageBill storageBill) {
         JSONObject result = new JSONObject();
         try {
-            log.info("{}{}", "看板确认目的地数据同步装运单信息:", JSON.toJSON(storageBill));
-            List<RollClubCommon> rollClubCommonList = new ArrayList<>();
-            // 根据装运单ID查询钢坯临时表
+            log.info("{}{}", "监控看板确认目的地,数据同步装运单信息:", JSON.toJSON(storageBill));
+
+            // 根据装运单ID查询钢坯临时表 棒线数据同步、堆垛数据同步
             List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(new LambdaQueryWrapper<BilletAutoTmp>()
                     .eq(BilletAutoTmp::getStorageBillId, storageBill.getId()));
             if (oConvertUtils.listIsEmpty(billetAutoTmpList)){
                 baseMapper.updateById(storageBill);
-                result.put("fail", "钢坯轧钢外运未知目的地明细不存在,看板确认目的地更新成功!");
+                result.put("success", "更新目的地成功!");
                 return result;
             }
-            billetAutoTmpList.forEach(x ->{
-                RollClubCommon rollClubCommon = new RollClubCommon();
-                BeanUtils.copyProperties(x, rollClubCommon);
-                rollClubCommon.setGrade(x.getSteel());
-                rollClubCommon.setLength(Integer.valueOf(x.getSize()));
-                rollClubCommon.setBilletWeight(x.getBlankOutput());
-                rollClubCommonList.add(rollClubCommon);
-            });
 
-            log.info("{}{}", "看板确认目的地同步临时表总条数:", rollClubCommonList.size());
+            List<BilletAutoTmp> billetAutoTmpHotChargeList = new ArrayList<>();
+            List<BilletAutoTmp> billetAutoTmpStackList = new ArrayList<>();
 
-            // 根据ID获取钢坯配置信息
-            BilletHotsend billetHotsend = new BilletHotsend();
-            billetHotsend.setCcmNo(storageBill.getCcmNo());
-            BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
+            List<RollClubCommon> rollClubCommonList = new ArrayList<>();
+            List<RollClubCommon> rollClubCommonHotChargeList = new ArrayList<>();
+            List<RollClubCommon> rollClubCommonStackList = new ArrayList<>();
 
-            BilletHotsendDetailsVo billetHotsendDetailsVo = new BilletHotsendDetailsVo();
-            billetHotsendDetailsVo.setBelongTable(billetHotsendTypeConfig.getBelongTable());
-            billetHotsendDetailsVo.setBelongTypeName(billetHotsendTypeConfig.getTypeName());
+            List<BilletBasicInfo> billetBasicInfoAllList = new ArrayList<>();
+            List<BilletBasicInfo> billetBasicInfoHotChargeList = new ArrayList<>();
+            List<BilletBasicInfo> billetBasicInfoStackList = new ArrayList<>();
 
-            billetHotsendDetailsVo.setDestination(billetHotsendTypeConfig.getTypeName());
-            billetHotsendDetailsVo.setDestinationId(billetHotsendTypeConfig.getId());
-            billetHotsendDetailsVo.setBilletHotsendTypeConfigId(billetHotsendTypeConfig.getId());
+            if (billetAutoTmpList != null && !billetAutoTmpList.isEmpty()) {
+                for (BilletAutoTmp billetAutoTmp : billetAutoTmpList) {
+                    if (billetAutoTmp.getStartNum() != null && billetAutoTmp.getEndNum() != null) {
+                        billetAutoTmpHotChargeList.add(billetAutoTmp);
+                    }
+                    if (billetAutoTmp.getStackStorey() != null && billetAutoTmp.getStackNum() != null) {
+                        billetAutoTmpStackList.add(billetAutoTmp);
+                    }
+                }
+            }
 
-            billetHotsendDetailsVo.setStorageBill(storageBill);
-            billetHotsendDetailsVo.setBilletHotsend(billetHotsend);
-            billetHotsendDetailsVo.setRollClubCommonList(rollClubCommonList);
+            // 棒线数据同步
+            if (oConvertUtils.listIsNotEmpty(billetAutoTmpHotChargeList)){
+                billetAutoTmpHotChargeList.forEach(x ->{
+                    RollClubCommon rollClubCommon = new RollClubCommon();
+                    BeanUtils.copyProperties(x, rollClubCommon);
+                    rollClubCommon.setGrade(x.getSteel());
+                    rollClubCommon.setLength(Integer.valueOf(x.getSize()));
+                    rollClubCommon.setBilletWeight(x.getBlankOutput());
+                    rollClubCommonHotChargeList.add(rollClubCommon);
+                });
+                log.info("{}{}", "监控看板确认目的地,棒线临时表数据同步总条数:", rollClubCommonHotChargeList.size());
+
+                // 根据ID获取钢坯配置信息
+                BilletHotsend billetHotsend = new BilletHotsend();
+                billetHotsend.setCcmNo(storageBill.getCcmNo());
+
+                BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
+
+                BilletHotsendDetailsVo billetHotsendDetailsVo = new BilletHotsendDetailsVo();
+                billetHotsendDetailsVo.setBelongTable(billetHotsendTypeConfig.getBelongTable());
+                billetHotsendDetailsVo.setBelongTypeName(billetHotsendTypeConfig.getTypeName());
+
+                billetHotsendDetailsVo.setDestination(billetHotsendTypeConfig.getTypeName());
+                billetHotsendDetailsVo.setDestinationId(billetHotsendTypeConfig.getId());
+                billetHotsendDetailsVo.setBilletHotsendTypeConfigId(billetHotsendTypeConfig.getId());
+
+                billetHotsendDetailsVo.setStorageBill(storageBill);
+                billetHotsendDetailsVo.setBilletHotsend(billetHotsend);
+                billetHotsendDetailsVo.setRollClubCommonList(rollClubCommonHotChargeList);
+
+                Map<String, List<RollClubCommon>> rollClubCommonLists = groupByShiftAttributes(rollClubCommonHotChargeList);
+                /**
+                 * 维护热送单炉信息 保存棒二或或棒三明细 更新钢坯基础信息
+                 * 在这里可以添加更多针对每个分组(键和对应列表)的业务逻辑操作,比如遍历列表中的元素等
+                 */
+                for (Map.Entry<String, List<RollClubCommon>> entry : rollClubCommonLists.entrySet()) {
+                    String[] parts = entry.getKey().split(",");
+                    billetHotsend.setHeatNo(parts[0]);// 炉号
+                    billetHotsend.setShiftGroup(parts[1]);// 班组
+                    billetHotsend.setShift(parts[2]);// 班别
+                    List<RollClubCommon> groupRollClubCommonList = entry.getValue();
+                    JSONObject jsonObject = commonBilletHotsenAndDetailsHandle(billetHotsend, billetHotsendDetailsVo, billetHotsendTypeConfig, storageBill, groupRollClubCommonList, null);
+                    if (jsonObject.containsKey("fail")) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        log.info("{}{}", "监控看板确认目的地,未知目的地数据同步操作失败,事务回滚!", jsonObject);
+                        result.put("fail", "监控看板确认目的地,未知目的地数据同步操作失败!");
+                        return result;
+                    }
+                }
+                List<String> billetNos = rollClubCommonHotChargeList.stream().map(RollClubCommon::getBilletNo).collect(Collectors.toList());
+                //查询并批量更新钢坯基础信息 belongTable
+                LambdaQueryWrapper<BilletBasicInfo> queryWrapperls = new LambdaQueryWrapper<BilletBasicInfo>()
+                        .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
+                        .in(BilletBasicInfo::getBilletNo, billetNos);
+                billetBasicInfoHotChargeList = billetBasicInfoService.list(queryWrapperls);
+
+                billetBasicInfoHotChargeList.forEach(x ->{
+                    if ("roll_club_two".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_club_two");
+                    }else if ("roll_club_three".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_club_three");
+                    }else if ("roll_out_shipp".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_out_shipp");
+                    }
+                    x.setBhtcId(billetHotsendTypeConfig.getId());
+                    x.setUpdateTime(new Date());
+                });
+                billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoHotChargeList);
 
-            Map<String, List<RollClubCommon>> rollClubCommonLists = groupByShiftAttributes(rollClubCommonList);
-            /**
-             * 维护热送单炉信息 保存棒二或或棒三明细 更新钢坯基础信息
-             * 在这里可以添加更多针对每个分组(键和对应列表)的业务逻辑操作,比如遍历列表中的元素等
-             */
-            for (Map.Entry<String, List<RollClubCommon>> entry : rollClubCommonLists.entrySet()) {
-                String[] parts = entry.getKey().split(",");
-                billetHotsend.setHeatNo(parts[0]);// 炉号
-                billetHotsend.setShiftGroup(parts[1]);// 班组
-                billetHotsend.setShift(parts[2]);// 班别
-                List<RollClubCommon> groupRollClubCommonList = entry.getValue();
-                JSONObject jsonObject = commonBilletHotsenAndDetailsHandle(billetHotsend, billetHotsendDetailsVo, billetHotsendTypeConfig, storageBill, groupRollClubCommonList, null);
-                if (jsonObject.containsKey("fail")) {
-                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                    log.info("{}{}", "B端钢坯装运单未知目的地数据同步操作失败,看板确认目的地事务回滚!", jsonObject);
-                    result.put("fail", "B端钢坯装运单看板确认目的地同步操作失败!");
+            }
+            // 堆垛数据同步
+            if (oConvertUtils.listIsNotEmpty(billetAutoTmpStackList)){
+
+                billetAutoTmpStackList.forEach(x ->{
+                    RollClubCommon rollClubCommon = new RollClubCommon();
+                    BeanUtils.copyProperties(x, rollClubCommon);
+                    rollClubCommon.setGrade(x.getSteel());
+                    rollClubCommon.setLength(Integer.valueOf(x.getSize()));
+                    rollClubCommon.setBilletWeight(x.getBlankOutput());
+                    rollClubCommonStackList.add(rollClubCommon);
+                });
+
+                // 根据ID获取钢坯配置信息
+                BilletHotsend billetHotsend = new BilletHotsend();
+                billetHotsend.setCcmNo(storageBill.getCcmNo());
+                billetHotsend.setShiftGroup(storageBill.getShiftGroup());
+                billetHotsend.setShift(storageBill.getShift());
+
+                BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
+                List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = new ArrayList<>();
+                billetAutoTmpStackList.forEach(x ->{
+                    StackingAndLoadingVehicles stackingAndLoadingVehicles = new StackingAndLoadingVehicles();
+                    BeanUtils.copyProperties(x, stackingAndLoadingVehicles);
+                    stackingAndLoadingVehicles.setBilletNos(x.getBilletNo());
+                    stackingAndLoadingVehicles.setAddress(x.getStackNum());
+                    stackingAndLoadingVehicles.setLayer(x.getStackStorey());
+                    stackingAndLoadingVehicles.setTypeConfigId(billetHotsendTypeConfig.getId());
+                    stackingAndLoadingVehiclesList.add(stackingAndLoadingVehicles);
+                });
+                // 保存明细
+                stackDataSynCommon(billetHotsend, billetHotsendTypeConfig, stackingAndLoadingVehiclesList, storageBill, rollClubCommonStackList);
+
+                // 先根据垛位容器中的铸机号和炉号 查询钢坯热送基础信息
+                Map<String, List<RollClubCommon>> rollClubCommonListttt = groupByShiftAttributes(rollClubCommonStackList);
+                for (Map.Entry<String, List<RollClubCommon>> entry : rollClubCommonListttt.entrySet()) {
+                    String[] parts = entry.getKey().split(",");
+                    billetHotsend.setHeatNo(parts[0]);// 炉号
+                    billetHotsend.setShiftGroup(parts[1]);// 班组
+                    billetHotsend.setShift(parts[2]);// 班别
+                    List<RollClubCommon> groupRollClubCommonList = entry.getValue();
+                    LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
+                    queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
+                            .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
+                            .eq(BilletHotsend::getShift,  billetHotsend.getShift())
+                            .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
+                    BilletHotsend idExistBh = billetHotsendBaseMapper.selectOne(queryWrapper);
+                    if (oConvertUtils.isEmpty(idExistBh)){
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        log.info("{}{}", "监控看板确认目的地,钢坯热送单为空,堆垛数据同步失败:", JSON.toJSON(billetHotsend));
+                        result.put("fail", "监控看板确认目的地,钢坯热送单为空,堆垛数据同步操作失败!");
+                        return result;
+                    }
+                    billetHotsend.setId(idExistBh.getId());
+                    // 钢坯热送基础信息存在,但是钢坯信息不存在 直接返回
+                    if ("roll_club_two".equals(billetHotsendTypeConfig.getBelongTable())){
+                        billetHotsend.setRollclubtwoNum(oConvertUtils.isNotEmpty(idExistBh.getRollclubtwoNum()) ? idExistBh.getRollclubtwoNum() + groupRollClubCommonList.size() : groupRollClubCommonList.size());
+                    }else if ("roll_club_three".equals(billetHotsendTypeConfig.getBelongTable())){
+                        billetHotsend.setRollclubthreeNum(oConvertUtils.isNotEmpty(idExistBh.getRollclubthreeNum()) ? idExistBh.getRollclubthreeNum() + groupRollClubCommonList.size() : groupRollClubCommonList.size());
+                    }else if ("roll_out_shipp".equals(billetHotsendTypeConfig.getBelongTable())){
+                        billetHotsend.setRolloutshippNum(oConvertUtils.isNotEmpty(idExistBh.getRolloutshippNum()) ? idExistBh.getRolloutshippNum() + groupRollClubCommonList.size() : groupRollClubCommonList.size());
+                    }
+                    billetHotsendBaseMapper.updateById(billetHotsend);
+                }
+
+                // 获取所有的坯号集合
+                List<String> billetNosList = rollClubCommonStackList.stream().map(RollClubCommon::getBilletNo)
+                        .flatMap(billetNos -> {
+                            if (billetNos != null) {
+                                return java.util.stream.Stream.of(billetNos.split(","));
+                            } else {
+                                return java.util.stream.Stream.empty();
+                            }
+                        }).collect(Collectors.toList());
+
+                //查询并批量更新钢坯基础信息 belongTable
+                LambdaQueryWrapper<BilletBasicInfo> queryWrapperls = new LambdaQueryWrapper<BilletBasicInfo>()
+                        .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
+                        .in(BilletBasicInfo::getBilletNo, billetNosList);
+                billetBasicInfoStackList = billetBasicInfoService.list(queryWrapperls);
+                if (oConvertUtils.listIsEmpty(billetBasicInfoStackList)) {
+                    result.put("fail", "监控看板确认目的地,钢坯基础信息为空,堆垛数据同步失败!");
                     return result;
                 }
+                //5 查询并批量更新钢坯基础信息 belongTable
+                billetBasicInfoStackList.forEach(x ->{
+                    if ("roll_club_two".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_club_two");
+                    }else if ("roll_club_three".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_club_three");
+                    }else if ("roll_out_shipp".equals(billetHotsendTypeConfig.getBelongTable())){
+                        x.setBelongTable("roll_out_shipp");
+                    }
+                    x.setBhtcId(billetHotsendTypeConfig.getId());
+                    x.setUpdateTime(new Date());
+                });
+                billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoStackList);
+
             }
-            List<String> billetNos = rollClubCommonList.stream().map(RollClubCommon::getBilletNo).collect(Collectors.toList());
-            //查询并批量更新钢坯基础信息 belongTable
-            LambdaQueryWrapper<BilletBasicInfo> queryWrapperls = new LambdaQueryWrapper<BilletBasicInfo>()
-                    .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
-                    .in(BilletBasicInfo::getBilletNo, billetNos);
-            List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperls);
-            billetBasicInfoList.forEach(x ->{
-                if ("roll_club_two".equals(billetHotsendDetailsVo.getBelongTable())){
-                    x.setBelongTable("roll_club_two");
-                }else if ("roll_club_three".equals(billetHotsendDetailsVo.getBelongTable())){
-                    x.setBelongTable("roll_club_three");
-                }else if ("roll_out_shipp".equals(billetHotsendDetailsVo.getBelongTable())){
-                    x.setBelongTable("roll_out_shipp");
-                }
-                x.setBhtcId(billetHotsendDetailsVo.getBilletHotsendTypeConfigId());
-                x.setUpdateTime(new Date());
-            });
-            billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
-            log.info("{}{}", "B端看板确认目的地数据同步时,装运单总支数:", storageBill.getAmountTotal());
+
+            // 合并堆垛数据、棒线数据
+            rollClubCommonList.addAll(rollClubCommonStackList);
+            rollClubCommonList.addAll(rollClubCommonHotChargeList);
+            int amountTotal = calculateTotal(rollClubCommonList);
+
+            // 合并钢坯基础信息
+            billetBasicInfoAllList.addAll(billetBasicInfoStackList);
+            billetBasicInfoAllList.addAll(billetBasicInfoHotChargeList);
+
             // 维护总支数
-            storageBill.setAmountTotal(storageBill.getAmountTotal() + rollClubCommonList.size());
+            storageBill.setAmountTotal(storageBill.getAmountTotal() + amountTotal);
 
-            log.info("{}{}", "B端看板确认目的地数据同步后,累加临时表后的装运单总支数:", storageBill.getAmountTotal());
             // 取最新的第一条钢坯信息
             RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
             if (rollClubCommon != null) {
@@ -2991,9 +3258,9 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             String sizeString = String.join(",", sizeList.stream().map(String::valueOf).collect(Collectors.toList()));
             storageBill.setSize(sizeString);// 定尺
 
-            List<String> assemblyNumberList = billetBasicInfoList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
+            List<String> assemblyNumberList = billetBasicInfoAllList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
             if(oConvertUtils.listIsNotEmpty(assemblyNumberList)) {
-                String distinctAssemblyNumber = billetBasicInfoList.stream()
+                String distinctAssemblyNumber = billetBasicInfoAllList.stream()
                         .map(BilletBasicInfo::getAssemblyNumber)
                         .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
                         .distinct().collect(Collectors.joining(","));
@@ -3003,22 +3270,30 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                         .orElse(distinctAssemblyNumber);
                 storageBill.setAssemblyNumber(finalAssemblyNumber);
             }
-            storageBill.setUpdateTime(new Date());
             baseMapper.updateById(storageBill);
 
             // 物理删除钢坯临时表记录
             billetAutoTmpService.removeBatchByIds(billetAutoTmpList.stream().map(BilletAutoTmp::getId).collect(Collectors.toList()));
-            result.put("success", "B端看板确认目的地明细同步成功!");
+            result.put("success", "B端监控看板确认目的地同步成功!");
             return result;
         }catch (Exception e){
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             // 记录异常日志
-            log.error("B端钢坯轧钢外运未知目的地明细同步发生异常", e.getMessage());
+            log.error("B端监控看板确认目的地,同步发生异常", e.getMessage());
             result.put("fail", "系统错误,请稍后再试!");
             return result;
         }
     }
 
+    public static int calculateTotal(List<RollClubCommon> rollClubCommonList) {
+        return rollClubCommonList.stream()
+                .mapToInt(item -> {
+                    String stackAddr = item.getStackAddr();
+                    return (stackAddr != null && !stackAddr.isEmpty()) ? 4 : 1;
+                })
+                .sum();
+    }
+
 
     @Override
     public SteelDetailsVo queryOnDutySteelReceive(String ccmNo) {
@@ -4678,4 +4953,217 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
         }
     }
 
+    /**
+     * 堆垛数据同步
+     * @param billetHotsend
+     * @param stackingAndLoadingVehiclesList
+     * @param storageBill
+     * @param rollClubCommonList
+     */
+    private void stackDataSynCommon(BilletHotsend billetHotsend, BilletHotsendTypeConfig billetHotsendTypeConfig, List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList, StorageBill storageBill, List<RollClubCommon> rollClubCommonList){
+
+        List<RollClubTwoDetails> addRollClubTwoDetailsList = new ArrayList<>();
+        List<RollClubThreeDetails> addRollClubThreeDetailsList = new ArrayList<>();
+        List<RollOutShippDetails> addRollOutShippDetailsList = new ArrayList<>();
+
+        stackingAndLoadingVehiclesList.forEach(x ->{
+            // 根据坯号查询 对应的钢坯基础信息,获取到炉号
+            String[] parts = x.getBilletNos().split(",");
+            //4 获取所有的坯号集合
+            LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(BilletBasicInfo::getBilletNo, Arrays.asList(parts));
+            List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
+            if (oConvertUtils.listIsEmpty(billetBasicInfoList)){
+                log.info("{}{}", "自动化堆垛数据同步保存失败,钢坯基础信息不存在!", x.getBilletNos());
+                return;
+            }
+            List<String> heatNos = billetBasicInfoList.stream().map(BilletBasicInfo::getHeatNo).distinct().collect(Collectors.toList());
+            double billetWeightTotal = billetBasicInfoList.stream().mapToDouble(BilletBasicInfo::getBilletWeight).sum();
+
+            if ("roll_club_two".equals(billetHotsendTypeConfig.getBelongTable())){
+                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 {
+                        // 堆垛发车时
+                        rollClubTwo1.setAmountTotal(rollClubTwo1.getAmountTotal() + 1);// 总支数
+                        rollClubTwo1.setBlankOutput(rollClubTwo1.getBlankOutput() + y.getBilletWeight());
+                        rollClubTwo1.setUpdateTime(new Date());
+                        rollClubTwoService.updateById(rollClubTwo1);
+                    }
+                });
+                RollClubTwoDetails rollClubTwoDetails = new RollClubTwoDetails();
+                BeanUtils.copyProperties(x, rollClubTwoDetails);
+                rollClubTwoDetails.setHeatNo(String.join(",", heatNos));
+                rollClubTwoDetails.setBilletNo(x.getBilletNos());
+                rollClubTwoDetails.setStorageBillId(storageBill.getId());
+                rollClubTwoDetails.setStackStorey(x.getLayer());
+                rollClubTwoDetails.setStackNum(x.getAddress());
+                rollClubTwoDetails.setShiftGroup(billetHotsend.getShiftGroup());
+                rollClubTwoDetails.setShift(billetHotsend.getShift());
+                rollClubTwoDetails.setLicensePlate(storageBill.getLicensePlate());
+                rollClubTwoDetails.setCreateTime(new Date());
+                rollClubTwoDetails.setId(String.valueOf(IdWorker.getId()));
+                rollClubTwoDetails.setBlankOutput(billetWeightTotal);//出坯量
+                rollClubTwoDetails.setSpec(billetBasicInfoList.get(0).getSpec());
+                rollClubTwoDetails.setSize(billetBasicInfoList.get(0).getLength().toString());
+                rollClubTwoDetails.setSteel(billetBasicInfoList.get(0).getGrade());
+                String distinctAssemblyNumber = rollClubCommonList.stream()
+                        .map(RollClubCommon::getAssemblyNumber)
+                        .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
+                        .distinct()
+                        .collect(Collectors.joining(","));
+                rollClubTwoDetails.setAssemblyNumber(distinctAssemblyNumber);
+                addRollClubTwoDetailsList.add(rollClubTwoDetails);
+            }else if ("roll_club_three".equals(billetHotsendTypeConfig.getBelongTable())){
+                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 {
+                        // 堆垛保存发车时  目的地为为棒三 更新棒三信息
+                        rollClubThree1.setAmountTotal(rollClubThree1.getAmountTotal() + 1);// 总支数
+                        rollClubThree1.setBlankOutput(rollClubThree1.getBlankOutput() + y.getBilletWeight());
+                        rollClubThree1.setUpdateTime(new Date());
+                        rollClubThreeService.updateById(rollClubThree1);
+                    }
+                });
+                // 棒三明细
+                RollClubThreeDetails rollClubThreeDetails = new RollClubThreeDetails();
+                BeanUtils.copyProperties(x, rollClubThreeDetails);
+                rollClubThreeDetails.setHeatNo(String.join(",", heatNos));
+                rollClubThreeDetails.setBilletNo(x.getBilletNos());
+                rollClubThreeDetails.setShiftGroup(billetHotsend.getShiftGroup());
+                rollClubThreeDetails.setShift(billetHotsend.getShift());
+                rollClubThreeDetails.setStorageBillId(storageBill.getId());
+                rollClubThreeDetails.setStackStorey(x.getLayer());
+                rollClubThreeDetails.setStackNum(x.getAddress());
+                rollClubThreeDetails.setLicensePlate(storageBill.getLicensePlate());
+                rollClubThreeDetails.setCreateTime(new Date());
+                rollClubThreeDetails.setId(String.valueOf(IdWorker.getId()));
+                rollClubThreeDetails.setBlankOutput(billetWeightTotal);//出坯量
+                rollClubThreeDetails.setSpec(billetBasicInfoList.get(0).getSpec());
+                rollClubThreeDetails.setSize(billetBasicInfoList.get(0).getLength().toString());
+                rollClubThreeDetails.setSteel(billetBasicInfoList.get(0).getGrade());
+                String distinctAssemblyNumber = rollClubCommonList.stream()
+                        .map(RollClubCommon::getAssemblyNumber)
+                        .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
+                        .distinct()
+                        .collect(Collectors.joining(","));
+                rollClubThreeDetails.setAssemblyNumber(distinctAssemblyNumber);
+                addRollClubThreeDetailsList.add(rollClubThreeDetails);
+            }else if ("roll_out_shipp".equals(billetHotsendTypeConfig.getBelongTable())){
+                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 {
+                        // 堆垛保存发车时 目的地为为上若 更新上若信息
+                        rollOutShipp1.setAmountTotal(rollOutShipp1.getAmountTotal() + 1);// 总支数
+                        rollOutShipp1.setBlankOutput(rollOutShipp1.getBlankOutput() + y.getBilletWeight());
+                        rollOutShipp1.setUpdateTime(new Date());
+                        rollOutShippService.updateById(rollOutShipp1);
+                    }
+                });
+
+                RollOutShippDetails rollOutShippDetails = new RollOutShippDetails();
+                BeanUtils.copyProperties(x, rollOutShippDetails);
+                rollOutShippDetails.setHeatNo(String.join(",", heatNos));
+                rollOutShippDetails.setBilletNo(x.getBilletNos());
+                rollOutShippDetails.setShiftGroup(billetHotsend.getShiftGroup());
+                rollOutShippDetails.setShift(billetHotsend.getShift());
+                rollOutShippDetails.setStorageBillId(storageBill.getId());
+                rollOutShippDetails.setStackStorey(x.getLayer());
+                rollOutShippDetails.setStackNum(x.getAddress());
+                rollOutShippDetails.setLicensePlate(storageBill.getLicensePlate());
+                rollOutShippDetails.setId(String.valueOf(IdWorker.getId()));
+                rollOutShippDetails.setCreateTime(new Date());
+                rollOutShippDetails.setBlankOutput(billetWeightTotal);//出坯量
+                rollOutShippDetails.setSpec(billetBasicInfoList.get(0).getSpec());
+                rollOutShippDetails.setSize(billetBasicInfoList.get(0).getLength().toString());
+                rollOutShippDetails.setSteel(billetBasicInfoList.get(0).getGrade());
+                String distinctAssemblyNumber = rollClubCommonList.stream()
+                        .map(RollClubCommon::getAssemblyNumber)
+                        .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
+                        .distinct()
+                        .collect(Collectors.joining(","));
+                rollOutShippDetails.setAssemblyNumber(distinctAssemblyNumber);
+                addRollOutShippDetailsList.add(rollOutShippDetails);
+            }
+        });
+
+        // 根据所去的目的地 保存到对应的明细表
+        if ("roll_club_two".equals(billetHotsendTypeConfig.getBelongTable())){
+            rollClubTwoDetailsService.saveBatch(addRollClubTwoDetailsList);
+        }else if ("roll_club_three".equals(billetHotsendTypeConfig.getBelongTable())){
+            rollClubThreeDetailsService.saveBatch(addRollClubThreeDetailsList);
+        }else if ("roll_out_shipp".equals(billetHotsendTypeConfig.getBelongTable())){
+            rollOutShippDetailsService.saveBatch(addRollOutShippDetailsList);
+        }
+
+    }
 }