Ver código fonte

新增垛位接口开发

qiangxuan 8 meses atrás
pai
commit
eae354a00f

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

@@ -327,6 +327,8 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			billetHotsend.setRolloutshippNum(0);
 			billetHotsend.setRollheightNum(0);
 			billetHotsend.setRollclubthreeNum(0);
+			billetHotsend.setAmountTotal(0);
+			billetHotsend.setStackNum(0);
 			baseMapper.insert(billetHotsend);
 			return;
 		}else {

+ 21 - 7
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/controller/StackingAndLoadingVehiclesController.java

@@ -21,6 +21,7 @@ import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.UpdateBatchPar
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingAndLoadingVehiclesService;
 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.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
@@ -86,9 +87,6 @@ public class StackingAndLoadingVehiclesController extends JeecgController<Stacki
 	 @GetMapping(value = "/getListByTypeConfigId")
 	 public Result<?> getListByTypeConfigId(@RequestParam(name="typeConfigId") String typeConfigId){
 		 List<StackingAndLoadingVehicles> res = stackingAndLoadingVehiclesService.getListByTypeConfigId(typeConfigId);
-		 if (oConvertUtils.listIsEmpty(res)){
-			 return Result.OK("获取堆垛信息为空!");
-		 }
 		 return Result.OK(res);
 	 }
 
@@ -116,7 +114,7 @@ public class StackingAndLoadingVehiclesController extends JeecgController<Stacki
 	 @ApiOperation(value="垛位装车-添加或保存", notes="垛位装车-添加或保存")
 	 @PostMapping(value = "/saveOrUpdate")
 	 public Result<String> saveOrUpdate(@RequestBody StackingAndLoadingVehicles stackingAndLoadingVehicles) {
-		 stackingAndLoadingVehiclesService.saveOrUpdate(stackingAndLoadingVehicles);
+		 stackingAndLoadingVehiclesService.save(stackingAndLoadingVehicles);
 		 return Result.OK("添加成功!");
 	 }
 
@@ -278,6 +276,14 @@ public class StackingAndLoadingVehiclesController extends JeecgController<Stacki
         return super.importExcel(request, response, StackingAndLoadingVehicles.class);
     }
 
+
+	 @ApiOperation(value="钢坯-新增堆垛", notes="钢坯-新增堆垛")
+	 @PostMapping(value = "/addStacking")
+	 public Result<?> addStackInfo(@RequestBody LoadingParams loadingParams){
+		 stackingAndLoadingVehiclesService.addStackInfo(loadingParams);
+		 return Result.OK("新增堆垛操作成功");
+	 }
+
      @ApiOperation(value="钢坯-垛位装车", notes="钢坯-垛位装车")
      @PostMapping(value = "/loading")
      public Result<?> loading(@RequestBody LoadingParams loadingParams){
@@ -289,17 +295,26 @@ public class StackingAndLoadingVehiclesController extends JeecgController<Stacki
 			 heats.add(stackingAndLoadingVehicles.getHeatNo());
 		 }
 		 if(heats.size()>3)return Result.error("一次只能选择三种炉次的钢坯");
+		 StorageBill storageBill = loadingParams.getStorageBill();
+		 if (oConvertUtils.isEmpty(storageBill)){
+			 return Result.OK("钢坯装运单不存在,垛位装车失败!");
+		 }
     	 stackingAndLoadingVehiclesService.loadingHandle(loadingParams);
-		return Result.OK("操作成功");
+		return Result.OK("垛位装车操作成功");
      }
 
 
 	 @ApiOperation(value="钢坯-垛位发车", notes="钢坯-垛位发车")
 	 @PostMapping(value = "/stackDepart")
 	 public Result<?> stackDepartHandle(@RequestBody LoadingParams loadingParams){
+
+		 StorageBill storageBill = loadingParams.getStorageBill();
+		 if (oConvertUtils.isEmpty(storageBill)){
+			 return Result.OK("钢坯装运单不存在,垛位发车失败!");
+		 }
 		 stackingAndLoadingVehiclesService.stackDepartHandle(loadingParams);
 //		 operateLogService.add(billetHotsend,null,BilletHotsend.class);
-		 return Result.OK("操作成功");
+		 return Result.OK("垛位发车操作成功");
 	 }
 
      @ApiOperation(value="堆垛-发车", notes="堆垛-发车")
@@ -340,5 +355,4 @@ public class StackingAndLoadingVehiclesController extends JeecgController<Stacki
 		 stackingAndLoadingVehiclesService.startHeight(savVo);
 		 return Result.OK("操作成功");
 	 }
-
 }

+ 2 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/service/IStackingAndLoadingVehiclesService.java

@@ -41,4 +41,6 @@ public interface IStackingAndLoadingVehiclesService extends IService<StackingAnd
     void loadingHandle(LoadingParams loadingParams);
 
     void stackDepartHandle(LoadingParams loadingParams);
+
+    void addStackInfo(LoadingParams loadingParams);
 }

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

@@ -1,29 +1,21 @@
 package org.jeecg.modules.billet.stackingAndLoadingVehicles.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.actualControl.billetActual.billetActual.entity.BilletBasicInfo;
 import org.jeecg.modules.actualControl.billetActual.billetActual.service.IBilletBasicInfoService;
 import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsend;
+import org.jeecg.modules.billet.billetHotsend.entity.RollClubCommon;
 import org.jeecg.modules.billet.billetHotsend.entity.RulerDefaultConfig;
-import org.jeecg.modules.billet.billetHotsend.mapper.RulerDefaultConfigMapper;
 import org.jeecg.modules.billet.billetHotsend.service.IBilletHotsendBaseService;
 import org.jeecg.modules.billet.billetHotsend.service.IRulerDefaultConfigService;
 import org.jeecg.modules.billet.billetHotsendConfig.entity.BilletHotsendTypeConfig;
 import org.jeecg.modules.billet.billetHotsendConfig.service.IBilletHotsendTypeConfigService;
-import org.jeecg.modules.billet.rollClubOne.service.IRollClubOneService;
-import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeDetailsService;
-import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeService;
-import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoDetailsService;
-import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoService;
-import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
-import org.jeecg.modules.billet.rollHeight.service.IRollHeightService;
-import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
-import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippService;
+import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingAndLoadingVehicles;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingDownLog;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingUpLog;
@@ -61,41 +53,23 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
     @Autowired
     private IRulerDefaultConfigService rulerDefaultConfigService;
     @Autowired
-    private RulerDefaultConfigMapper rulerDefaultConfigMapper;
-    @Autowired
     private IBilletHotsendBaseService billetHotsendBaseService;
     @Autowired
     private IStorageBillService storageBillService;
     @Autowired
     private IStorageBillModelService storageBillModelService;
     @Autowired
-    private IRollClubOneService rollClubOneService;
-    @Autowired
-    private IRollClubTwoService rollClubTwoService;
-    @Autowired
-    private IRollClubThreeService rollClubThreeService;
-    @Autowired
-    private IRollHeightService rollHeightService;
-    @Autowired
-    private IRollOutShippService rollOutShippService;
-    @Autowired
     private IBilletHotsendTypeConfigService billetHotsendTypeConfigService;
     @Autowired
     private IStackingUpLogService stackingUpLogService;
     @Autowired
     private IStackingDownLogService stackingDownLogService;
     @Autowired
-    private IRollClubTwoDetailsService rollClubTwoDetailsService;
-    @Autowired
-    private IRollClubThreeDetailsService rollClubThreeDetailsService;
-    @Autowired
-    private IRollHeightDetailsService rollHeightDetailsService;
-    @Autowired
-    private IRollOutShippDetailsService rollOutShippDetailsService;
-    @Autowired
     private IBilletBasicInfoService billetBasicInfoService;
     @Autowired
     private IStorageCarLogService storageCarLogService;
+    @Autowired
+    private IOperateLogService operateLogService;
 
     @Override
     public List<List<StackingAndLoadingVehicles>> getListBySatck(String typeConfigId) {
@@ -132,41 +106,41 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
 
     @Override
     public void addBatch(SavVo savVo) {
-        if(oConvertUtils.listIsNotEmpty(savVo.getSavs())){
-            RulerDefaultConfig last = rulerDefaultConfigService.getLast(savVo.getCastMachine());
-            String furnace = null;
-            if(last!=null){
-                furnace = last.getPourHeats();
-                last.setShiftProduct((last.getShiftProduct()==null?0:last.getShiftProduct())+4*savVo.getSavs().size());
-                rulerDefaultConfigMapper.updateById(last);
-            }
-
-            String finalFurnace = furnace;
-            savVo.getSavs().forEach(item->{
-                if(oConvertUtils.isEmpty(item.getHeatNo()))item.setHeatNo(finalFurnace);
-            });
-            this.addBilletHotsend(savVo.getSavs(),"1",null,savVo.getCastMachine(),"5");
-            String destination = "";
-            switch (savVo.getSavs().get(0).getStackAddr()){
-                case "601":
-                    destination = "601堆垛";
-                    break;
-                case "602":
-                    destination = "602堆垛";
-                    break;
-                case "604":
-                    destination = "604堆垛";
-                    break;
-                case "6":
-                    destination = "步进冷床";
-                    break;
-                case "501":
-                    destination = "501堆垛";
-                    break;
-            }
-            addStorageBill(savVo.getSavs(),savVo.getCastMachine(),"默认",destination);
-
-        }
+//        if(oConvertUtils.listIsNotEmpty(savVo.getSavs())){
+//            RulerDefaultConfig last = rulerDefaultConfigService.getLast(savVo.getCastMachine());
+//            String furnace = null;
+//            if(last!=null){
+//                furnace = last.getPourHeats();
+//                last.setShiftProduct((last.getShiftProduct()==null?0:last.getShiftProduct())+4*savVo.getSavs().size());
+//                rulerDefaultConfigMapper.updateById(last);
+//            }
+//
+//            String finalFurnace = furnace;
+//            savVo.getSavs().forEach(item->{
+//                if(oConvertUtils.isEmpty(item.getHeatNo()))item.setHeatNo(finalFurnace);
+//            });
+//            this.addBilletHotsend(savVo.getSavs(),"1",null,savVo.getCastMachine(),"5");
+//            String destination = "";
+//            switch (savVo.getSavs().get(0).getStackAddr()){
+//                case "601":
+//                    destination = "601堆垛";
+//                    break;
+//                case "602":
+//                    destination = "602堆垛";
+//                    break;
+//                case "604":
+//                    destination = "604堆垛";
+//                    break;
+//                case "6":
+//                    destination = "步进冷床";
+//                    break;
+//                case "501":
+//                    destination = "501堆垛";
+//                    break;
+//            }
+//            addStorageBill(savVo.getSavs(),savVo.getCastMachine(),"默认",destination);
+//
+//        }
     }
 
     @Override
@@ -480,7 +454,6 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         BilletHotsend billetHotsend = new BilletHotsend();
         //1 新保存 钢坯热送基础信息
         BeanUtils.copyProperties(loadingParams.getBilletHotsend(), billetHotsend);
-        billetHotsend.setCreateDate(new Date());
         LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
                 .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
@@ -496,10 +469,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             billetHotsendBaseService.save(billetHotsend);
             return;
         }else {
-            if ("stacking_and_loading_vehicles".equals(loadingParams.getBelongTable()) && "1".equals(billetHotsendTypeConfig.getBelongType().toString())){
-                billetHotsend.setStackNum(idExistBh.getStackNum() + stackingAndLoadingVehiclesList.size() * 4); // 堆垛总支数
-            }
-//            billetHotsend.setAmountTotal(billetHotsend.getAmountTotal() + stackingAndLoadingVehiclesList.size()); //总支数
+            billetHotsend.setStackNum(idExistBh.getStackNum() + stackingAndLoadingVehiclesList.size()); // 堆垛总支数
+            billetHotsend.setAmountTotal(idExistBh.getAmountTotal() + stackingAndLoadingVehiclesList.size() * 4); //总支数
             LambdaUpdateWrapper<BilletHotsend> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
                     .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
@@ -507,6 +478,18 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                     .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());;
             billetHotsendBaseService.update(billetHotsend, updateWrapper);
         }
+        // 根据铸机号、位置、层数、类型配置ID更新 容器中的垛位信息
+        stackingAndLoadingVehiclesList.forEach(x ->{
+            LambdaUpdateWrapper<StackingAndLoadingVehicles> queryWrapperSA = new LambdaUpdateWrapper<>();
+            queryWrapperSA.eq(StackingAndLoadingVehicles::getCcmNo, x.getCcmNo())
+                    .eq(StackingAndLoadingVehicles::getLayer, x.getLayer())
+                    .eq(StackingAndLoadingVehicles::getAddress, x.getAddress())
+                    .eq(StackingAndLoadingVehicles::getTypeConfigId, loadingParams.getBilletHotsendTypeConfigId());;
+            StackingAndLoadingVehicles stackingAndLoadingVehicles = new StackingAndLoadingVehicles();
+            BeanUtils.copyProperties(x, stackingAndLoadingVehicles);
+            baseMapper.update(stackingAndLoadingVehicles, queryWrapperSA);
+        });
+
         // 获取所有的坯号集合
         List<String> billetNosList = stackingAndLoadingVehiclesList.stream().map(StackingAndLoadingVehicles::getBilletNos)
                 .flatMap(billetNos -> {
@@ -516,47 +499,21 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                         return java.util.stream.Stream.empty();
                     }
                 }).collect(Collectors.toList());
-        StackingAndLoadingVehicles stackingAndLoadingVehicles = new StackingAndLoadingVehicles();
-        LambdaQueryWrapper<StackingAndLoadingVehicles> queryWrapperSA = new LambdaQueryWrapper<>();
-        queryWrapperSA.eq(StackingAndLoadingVehicles::getCcmNo, billetHotsend.getCcmNo())
-                .eq(StackingAndLoadingVehicles::getHeatNo, billetHotsend.getHeatNo())
-                .eq(StackingAndLoadingVehicles::getShift, billetHotsend.getShift())
-                .eq(StackingAndLoadingVehicles::getShiftGroup, billetHotsend.getShiftGroup());;
-        StackingAndLoadingVehicles isExistSLV = baseMapper.selectOne(queryWrapperSA);
-        if (oConvertUtils.isEmpty(isExistSLV)){
-            stackingAndLoadingVehicles.setId(String.valueOf(IdWorker.getId()));
-            BeanUtils.copyProperties(billetHotsend, stackingAndLoadingVehicles);
-            stackingAndLoadingVehicles.setTypeConfigId(billetHotsendTypeConfig.getId());
-            stackingAndLoadingVehicles.setStackAddr(billetHotsendTypeConfig.getTypeName()); // 垛位
-            stackingAndLoadingVehicles.setBilletNos(String.join(",", billetNosList)); // 坯号集
-//            stackingAndLoadingVehicles.setAddress(); // 所在位置(1-9)
-//            stackingAndLoadingVehicles.setLayer();// 所在层数(1-20)
-            baseMapper.insert(stackingAndLoadingVehicles);
-        }else {
-            // 垛位二次装车
-            BeanUtils.copyProperties(isExistSLV, stackingAndLoadingVehicles);
-            stackingAndLoadingVehicles.setBilletNos(String.join(",", billetNosList)); // 坯号集
-//            stackingAndLoadingVehicles.setLayer();// 所在层数(1-20)
-//            stackingAndLoadingVehicles.setAddress(); // 所在位置(1-9)
-            stackingAndLoadingVehicles.setUpdateTime(new Date());
-            baseMapper.updateById(stackingAndLoadingVehicles);
-        }
-        StorageBill storageBill = loadingParams.getStorageBill();
-        // 3 保存 起垛日志    stacking_up_log
-        List<StackingUpLog> stackingUpLogList = new ArrayList<>();
+
+        // 3 保存 下垛日志    stacking_up_log
+        List<StackingDownLog> stackingDownLogList = new ArrayList<>();
         stackingAndLoadingVehiclesList.forEach(x ->{
-            StackingUpLog stackingUpLog = new StackingUpLog();
-            BeanUtils.copyProperties(x, stackingUpLog);
-            stackingUpLog.setBilletNo(x.getBilletNos());
-            stackingUpLog.setAmount(stackingAndLoadingVehiclesList.size() * 4); // 支数
-            stackingUpLog.setLayer(x.getLayer());// 堆垛层号(1-20)
-            stackingUpLog.setAddress(x.getAddress());// 堆垛编号(1-9)
-            stackingUpLog.setStackAddr(billetHotsendTypeConfig.getTypeName());
-            stackingUpLog.setFromStackingId(stackingAndLoadingVehicles.getId());
-            stackingUpLog.setCreateDate(new Date());
-            stackingUpLogList.add(stackingUpLog);
+            StackingDownLog stackingDownLog = new StackingDownLog();
+            BeanUtils.copyProperties(x, stackingDownLog);
+            stackingDownLog.setBilletNo(x.getBilletNos());
+            stackingDownLog.setStorageBillId(loadingParams.getStorageBill().getId());
+            stackingDownLog.setStackStorey(x.getLayer());// 堆垛层号(1-20)
+            stackingDownLog.setStackNum(x.getAddress());// 堆垛编号(1-9)
+            stackingDownLog.setStackAddr(billetHotsendTypeConfig.getTypeName());
+//            stackingUpLog.setFromStackingId(stackingAndLoadingVehicles.getId());
+            stackingDownLogList.add(stackingDownLog);
         });
-        stackingUpLogService.saveBatch(stackingUpLogList);
+        stackingDownLogService.saveBatch(stackingDownLogList);
         //5 查询并批量更新钢坯基础信息 belongTable
         LambdaQueryWrapper<BilletBasicInfo> queryWrapperBB = new LambdaQueryWrapper<BilletBasicInfo>()
                 .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
@@ -564,9 +521,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 .in(BilletBasicInfo::getBilletNo, billetNosList);
         List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperBB);
         billetBasicInfoList.forEach(x ->{
-            if ("stacking_and_loading_vehicles".equals(loadingParams.getBelongTable())){
-                x.setBelongTable("stacking_and_loading_vehicles");
-            }
+            x.setBelongTable("stacking_and_loading_vehicles");
             x.setUpdateTime(new Date());
             x.setBhtcId(loadingParams.getBilletHotsendTypeConfigId());
         });
@@ -581,31 +536,61 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         BilletHotsend billetHotsend = new BilletHotsend();
         //1 新保存 钢坯热送基础信息
         BeanUtils.copyProperties(loadingParams.getBilletHotsend(), billetHotsend);
-//		billetHotsend.setAmountTotal(rollClubCommonList.size()); //总支数
         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 = billetHotsendBaseService.getOne(queryWrapper);
-        if (oConvertUtils.isNotEmpty(idExistBh) && oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)){
-            return;
-        }
-        if (oConvertUtils.isEmpty(idExistBh) && oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)){
-            billetHotsend.setStackNum(0);
-            billetHotsendBaseService.save(billetHotsend);
-            return;
-        }else {
-            if ("stacking_and_loading_vehicles".equals(loadingParams.getBelongTable()) && "1".equals(billetHotsendTypeConfig.getBelongType().toString())){
-                billetHotsend.setStackNum(idExistBh.getStackNum() + stackingAndLoadingVehiclesList.size() * 4); // 堆垛总支数
+        if ((oConvertUtils.isNotEmpty(idExistBh) && oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)) || (oConvertUtils.isEmpty(idExistBh) && oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList))) {
+            if (oConvertUtils.isEmpty(idExistBh)) {
+                billetHotsend.setStackNum(0);
+                billetHotsendBaseService.save(billetHotsend);
+                log.info("{}{}", "stackingAndLoadingVehiclesList为空,新增钢坯热送基础信息", JSON.toJSON(loadingParams));
             }
+            return;
+        } else {
+            billetHotsend.setStackNum(idExistBh.getStackNum() + stackingAndLoadingVehiclesList.size()); // 堆垛总支数
+            billetHotsend.setAmountTotal(idExistBh.getAmountTotal() + stackingAndLoadingVehiclesList.size() * 4); //总支数
             LambdaUpdateWrapper<BilletHotsend> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
                     .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
                     .eq(BilletHotsend::getShift, billetHotsend.getShift())
                     .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());;
-            billetHotsendBaseService.update(billetHotsend,  updateWrapper);
+            billetHotsendBaseService.update(billetHotsend, updateWrapper);
         }
+
+        // 3 发车后,动态更新容器中的垛位信息 初始化
+        stackingAndLoadingVehiclesList.forEach(x ->{
+            LambdaUpdateWrapper<StackingAndLoadingVehicles> queryWrapperSA = new LambdaUpdateWrapper<>();
+            queryWrapperSA.eq(StackingAndLoadingVehicles::getCcmNo, x.getCcmNo())
+                    .eq(StackingAndLoadingVehicles::getLayer, x.getLayer())
+                    .eq(StackingAndLoadingVehicles::getAddress, x.getAddress())
+                    .eq(StackingAndLoadingVehicles::getTypeConfigId, loadingParams.getBilletHotsendTypeConfigId());;
+            StackingAndLoadingVehicles stackingAndLoadingVehicles = createInitializedVehicle();
+            BeanUtils.copyProperties(x, stackingAndLoadingVehicles);
+            stackingAndLoadingVehicles.setBilletNos(null);
+            stackingAndLoadingVehicles.setSpec(null);
+            stackingAndLoadingVehicles.setSteel(null);
+            stackingAndLoadingVehicles.setSize(null);
+            stackingAndLoadingVehicles.setShift(null);
+            stackingAndLoadingVehicles.setHeatNo(null);
+            stackingAndLoadingVehicles.setShiftGroup(null);
+            stackingAndLoadingVehicles.setCreateDate(null);
+            baseMapper.update(stackingAndLoadingVehicles, queryWrapperSA);
+        });
+
+        // 4 保存 下垛日志    stacking_down_log
+        List<StackingDownLog> stackingDownLogList = new ArrayList<>();
+        stackingAndLoadingVehiclesList.forEach(x ->{
+            StackingDownLog stackingDownLog = new StackingDownLog();
+            BeanUtils.copyProperties(x, stackingDownLog);
+            stackingDownLog.setBilletNo(x.getBilletNos());
+            stackingDownLog.setStorageBillId(loadingParams.getStorageBill().getId());// 装运单ID
+            stackingDownLogList.add(stackingDownLog);
+        });
+        stackingDownLogService.saveBatch(stackingDownLogList);
+
         // 获取所有的坯号集合
         List<String> billetNosList = stackingAndLoadingVehiclesList.stream().map(StackingAndLoadingVehicles::getBilletNos)
                 .flatMap(billetNos -> {
@@ -615,90 +600,136 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                         return java.util.stream.Stream.empty();
                     }
                 }).collect(Collectors.toList());
+        //5 查询并批量更新钢坯基础信息 belongTable
+        LambdaQueryWrapper<BilletBasicInfo> queryWrapperBB = new LambdaQueryWrapper<BilletBasicInfo>()
+                .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
+                .eq(BilletBasicInfo::getHeatNo, billetHotsend.getHeatNo())
+                .in(BilletBasicInfo::getBilletNo, billetNosList);
+        List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperBB);
+        billetBasicInfoList.forEach(x ->{
+            x.setBelongTable("stacking_and_loading_vehicles");
+            x.setBhtcId(loadingParams.getBilletHotsendTypeConfigId());
+        });
+        billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
+        // 6 更新装运单 storage_bill 新增储运信息
+        StorageBill storageBill = loadingParams.getStorageBill();
+        storageBill.setCarAllNum(oConvertUtils.isEmpty(storageBill.getCarAllNum()) ? "1" : String.valueOf(Integer.valueOf(storageBill.getCarAllNum())+1));// 车次总序号
+        storageBill.setCarNum(storageBill.getCarNum() == 0 ? 0 : storageBill.getCarNum() + 1);// 本车车次
+        storageBillService.updateById(storageBill);
+        // 7 发车后,新增钢坯堆垛储运信息,生成储运单 storage_car_log
+        StorageCarLog storageCarLog = new StorageCarLog();
+        BeanUtils.copyProperties(storageBill, storageCarLog);
+        storageCarLog.setDestination(billetHotsendTypeConfig.getTypeName());// 目的地
+        storageCarLog.setCarNm(String.valueOf(storageBill.getCarNum()));// 车号
+        storageCarLog.setOutCarNum(storageBill.getLicensePlate()); // 出车号
+        storageCarLog.setTypeConfigId(billetHotsendTypeConfig.getId()); // 钢坯配置类型ID
+        storageCarLog.setHeatNo(billetHotsend.getHeatNo());
+//			  storageCarLog.setFixedWeight();// 定重
+//            storageCarLog.setSize();// 定尺
+        // 查询上垛记录,计算出总支数
+        LambdaQueryWrapper<StackingUpLog> queryWrapperSU = new LambdaQueryWrapper<>();
+        queryWrapperSU.eq(StackingUpLog::getCcmNo, billetHotsend.getCcmNo())
+                .eq(StackingUpLog::getHeatNo, billetHotsend.getHeatNo())
+                .eq(StackingUpLog::getShift, billetHotsend.getShift())
+                .eq(StackingUpLog::getShiftGroup, billetHotsend.getShiftGroup());
+        List<StackingUpLog> stackingUpLogList = stackingUpLogService.list(queryWrapperSU);
+        storageCarLog.setAmount(oConvertUtils.listIsNotEmpty(stackingUpLogList) ? stackingUpLogList.size() : 0);// 支数
+        storageCarLogService.save(storageCarLog);
+    }
 
-        StackingAndLoadingVehicles stackingAndLoadingVehicles = new StackingAndLoadingVehicles();
-        LambdaQueryWrapper<StackingAndLoadingVehicles> queryWrapperSA = new LambdaQueryWrapper<>();
-        queryWrapperSA.eq(StackingAndLoadingVehicles::getCcmNo, billetHotsend.getCcmNo())
-                .eq(StackingAndLoadingVehicles::getHeatNo, billetHotsend.getHeatNo())
-                .eq(StackingAndLoadingVehicles::getShift, billetHotsend.getShift())
-                .eq(StackingAndLoadingVehicles::getShiftGroup, billetHotsend.getShiftGroup());;
-        StackingAndLoadingVehicles isExistSLV = baseMapper.selectOne(queryWrapperSA);
-        if (oConvertUtils.isEmpty(isExistSLV)){
-            stackingAndLoadingVehicles.setId(String.valueOf(IdWorker.getId()));
-            BeanUtils.copyProperties(billetHotsend, stackingAndLoadingVehicles);
-            stackingAndLoadingVehicles.setTypeConfigId(billetHotsendTypeConfig.getId());
-            stackingAndLoadingVehicles.setStackAddr(billetHotsendTypeConfig.getTypeName()); // 垛位
-            stackingAndLoadingVehicles.setBilletNos(String.join(",", billetNosList)); // 坯号集
-//            stackingAndLoadingVehicles.setAddress(); // 所在位置(1-9)
-//            stackingAndLoadingVehicles.setLayer();// 所在层数(1-20)
-            baseMapper.insert(stackingAndLoadingVehicles);
+    @Override
+    public void addStackInfo(LoadingParams loadingParams) {
+        // 根据billetHotsendTypeConfigId 查询基础垛位信息
+        BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(loadingParams.getBilletHotsendTypeConfigId());
+        List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = loadingParams.getStackingAndLoadingVehiclesList();
+        List<RollClubCommon> rollClubCommonList = loadingParams.getRollClubCommonList();
+        BilletHotsend billetHotsend = new BilletHotsend();
+        //1 新保存 钢坯热送基础信息
+        BeanUtils.copyProperties(loadingParams.getBilletHotsend(), billetHotsend);
+        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 = billetHotsendBaseService.getOne(queryWrapper);
+        if (oConvertUtils.isNotEmpty(idExistBh) && oConvertUtils.listIsEmpty(rollClubCommonList)){
+            return;
+        }
+        if (oConvertUtils.isEmpty(idExistBh) && oConvertUtils.listIsEmpty(rollClubCommonList)){
+            billetHotsend.setStackNum(0);
+            billetHotsend.setAmountTotal(0);
+            billetHotsendBaseService.save(billetHotsend);
+            return;
         }else {
-            // 垛位二次装车
-            BeanUtils.copyProperties(isExistSLV, stackingAndLoadingVehicles);
-            stackingAndLoadingVehicles.setBilletNos(String.join(",", billetNosList)); // 坯号集
-//            stackingAndLoadingVehicles.setLayer();// 所在层数(1-20)
-//            stackingAndLoadingVehicles.setAddress(); // 所在位置(1-9)
-            stackingAndLoadingVehicles.setUpdateTime(new Date());
-            baseMapper.updateById(stackingAndLoadingVehicles);
+            billetHotsend.setStackNum(idExistBh.getStackNum() + stackingAndLoadingVehiclesList.size()); // 堆垛总支数
+            billetHotsend.setAmountTotal(idExistBh.getAmountTotal() + stackingAndLoadingVehiclesList.size() * 4); //总支数
+            LambdaUpdateWrapper<BilletHotsend> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
+                    .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
+                    .eq(BilletHotsend::getShift, billetHotsend.getShift())
+                    .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());;
+            billetHotsendBaseService.update(billetHotsend, updateWrapper);
         }
-        StorageBill storageBill = loadingParams.getStorageBill();
-        // 3 保存 下垛日志    stacking_down_log
-        List<StackingDownLog> stackingDownLogList = new ArrayList<>();
+
+        // 2 发车后,动态更新容器中的垛位信息 初始化
         stackingAndLoadingVehiclesList.forEach(x ->{
-            StackingDownLog stackingDownLog = new StackingDownLog();
-            BeanUtils.copyProperties(x, stackingDownLog);
-            stackingDownLog.setBilletNo(x.getBilletNos());
-            if (storageBill != null){
-                stackingDownLog.setStorageBillId(storageBill.getId());// 装运单ID
-            }
-            stackingDownLog.setStackStorey(x.getLayer());// 堆垛层号(1-20)
-            stackingDownLog.setStackNum(x.getAddress());// 堆垛编号(1-9)
-            stackingDownLogList.add(stackingDownLog);
+            LambdaUpdateWrapper<StackingAndLoadingVehicles> queryWrapperSA = new LambdaUpdateWrapper<>();
+            queryWrapperSA.eq(StackingAndLoadingVehicles::getCcmNo, x.getCcmNo())
+                    .eq(StackingAndLoadingVehicles::getLayer, x.getLayer())
+                    .eq(StackingAndLoadingVehicles::getAddress, x.getAddress())
+                    .eq(StackingAndLoadingVehicles::getTypeConfigId, loadingParams.getBilletHotsendTypeConfigId());;
+            StackingAndLoadingVehicles stackingAndLoadingVehicles = createInitializedVehicle();
+            BeanUtils.copyProperties(x, stackingAndLoadingVehicles);
+            stackingAndLoadingVehicles.setCreateDate(new Date());
+            baseMapper.update(stackingAndLoadingVehicles, queryWrapperSA);
         });
-        stackingDownLogService.saveBatch(stackingDownLogList);
 
-        // 4 删除垛位容器中的信息
-        baseMapper.deleteById(stackingAndLoadingVehicles);
+        // 3 保存 起垛日志    stacking_up_log
+        List<StackingUpLog> stackingUpLogList = new ArrayList<>();
+        stackingAndLoadingVehiclesList.forEach(x ->{
+            StackingUpLog stackingUpLog = new StackingUpLog();
+            BeanUtils.copyProperties(x, stackingUpLog);
+            stackingUpLog.setBilletNo(x.getBilletNos());
+            stackingUpLog.setAmount(4); // 支数
+            stackingUpLog.setLayer(x.getLayer());// 堆垛层号(1-20)
+            stackingUpLog.setAddress(x.getAddress());// 堆垛编号(1-9)
+            stackingUpLog.setStackAddr(billetHotsendTypeConfig.getTypeName());
+            stackingUpLogList.add(stackingUpLog);
+        });
+        stackingUpLogService.saveBatch(stackingUpLogList);
+        //4 获取所有的坯号集合
+        List<String> billetNos = rollClubCommonList.stream().map(RollClubCommon::getBilletNo).collect(Collectors.toList());
 
         //5 查询并批量更新钢坯基础信息 belongTable
         LambdaQueryWrapper<BilletBasicInfo> queryWrapperBB = new LambdaQueryWrapper<BilletBasicInfo>()
                 .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
                 .eq(BilletBasicInfo::getHeatNo, billetHotsend.getHeatNo())
-                .in(BilletBasicInfo::getBilletNo, billetNosList);
+                .in(BilletBasicInfo::getBilletNo, billetNos);
         List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperBB);
         billetBasicInfoList.forEach(x ->{
-            if ("stacking_and_loading_vehicles".equals(loadingParams.getBelongTable())){
-                x.setBelongTable("stacking_and_loading_vehicles");
-            }
-            x.setUpdateTime(new Date());
+            x.setBelongTable("stacking_and_loading_vehicles");
             x.setBhtcId(loadingParams.getBilletHotsendTypeConfigId());
         });
         billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
-        // 6 更新装运单 storage_bill 新增储运信息
-        if (oConvertUtils.isNotEmpty(stackingAndLoadingVehiclesList) && oConvertUtils.isNotEmpty(storageBill)){
-            storageBill.setCarAllNum(oConvertUtils.isEmpty(storageBill.getCarAllNum()) ? "1" : String.valueOf(Integer.valueOf(storageBill.getCarAllNum())+1));// 车次总序号
-            storageBill.setCarNum(storageBill.getCarNum() == 0 ? 0 : storageBill.getCarNum() + 1);// 本车车次
-            storageBillService.updateById(storageBill);
-            // 7 发车后,新增钢坯堆垛储运信息,生成储运单 storage_car_log
-            StorageCarLog storageCarLog = new StorageCarLog();
-            BeanUtils.copyProperties(storageBill, storageCarLog);
-            storageCarLog.setDestination(billetHotsendTypeConfig.getTypeName());// 目的地
-            storageCarLog.setCarNm(String.valueOf(storageBill.getCarNum()));// 车号
-            storageCarLog.setOutCarNum(storageBill.getLicensePlate()); // 出车号
-            storageCarLog.setTypeConfigId(billetHotsendTypeConfig.getId()); // 钢坯配置类型ID
-            storageCarLog.setHeatNo(billetHotsend.getHeatNo());
-//			  storageCarLog.setFixedWeight();// 定重
-//            storageCarLog.setSize();// 定尺
-            // 查询上垛记录,计算出总支数
-            LambdaQueryWrapper<StackingUpLog> queryWrapperSU = new LambdaQueryWrapper<>();
-            queryWrapperSU.eq(StackingUpLog::getCcmNo, billetHotsend.getCcmNo())
-                    .eq(StackingUpLog::getHeatNo, billetHotsend.getHeatNo())
-                    .eq(StackingUpLog::getShift, billetHotsend.getShift())
-                    .eq(StackingUpLog::getShiftGroup, billetHotsend.getShiftGroup());
-            List<StackingUpLog> stackingUpLogList = stackingUpLogService.list(queryWrapperSU);
-            storageCarLog.setAmount(oConvertUtils.listIsNotEmpty(stackingUpLogList) ? stackingUpLogList.size() : 0);// 支数
-            storageCarLogService.save(storageCarLog);
-        }
+
+    }
+
+
+    /**
+     * 初始化StackingAndLoadingVehicles对象
+     * @return
+     */
+    private StackingAndLoadingVehicles createInitializedVehicle() {
+        StackingAndLoadingVehicles vehicle = new StackingAndLoadingVehicles();
+        vehicle.setBilletNos(null);
+        vehicle.setSpec(null);
+        vehicle.setSteel(null);
+        vehicle.setSize(null);
+        vehicle.setShift(null);
+        vehicle.setHeatNo(null);
+        vehicle.setShiftGroup(null);
+        vehicle.setCreateDate(null);
+        return vehicle;
     }
 
     public void addStorageBill(List<StackingAndLoadingVehicles> savs,String castMachine,String carNum,String destination){

+ 6 - 4
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/vo/LoadingParams.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.billet.stackingAndLoadingVehicles.vo;
 
 import lombok.Data;
 import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsend;
+import org.jeecg.modules.billet.billetHotsend.entity.RollClubCommon;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingAndLoadingVehicles;
 import org.jeecg.modules.billet.storageBill.entity.StorageBill;
 
@@ -9,15 +10,16 @@ import java.util.List;
 
 @Data
 public class LoadingParams {
+
     /**
-     * 已选择的 拼接好的钢坯基础信息 4个钢坯号为1组数据
+     * 钢坯基础信息
      */
-    private List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList;
+    private List<RollClubCommon> rollClubCommonList;
 
     /**
-     * 已选择的 拆分为四个的所有钢坯号集合
+     * 已选择的 拼接好的钢坯基础信息 4个钢坯号为1组数据
      */
-    private List<String> billetNos;
+    private List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList;
 
     /**
      * 钢坯热送基础信息