소스 검색

堆垛逻辑拆分

qiangxuan 8 달 전
부모
커밋
eae2469bf0

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

@@ -308,7 +308,6 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(billetHotsendDetailsVo.getBilletHotsendTypeConfigId());
 		List<RollClubCommon> rollClubCommonList = billetHotsendDetailsVo.getRollClubCommonList();
 		BilletHotsend billetHotsend = new BilletHotsend();
-		StorageBill storageBill = billetHotsendDetailsVo.getStorageBill();
 		// 新保存 钢坯热送基础信息
 		BeanUtils.copyProperties(billetHotsendDetailsVo.getBilletHotsend(), billetHotsend);
 		billetHotsend.setCreateDate(new Date());
@@ -350,6 +349,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			baseMapper.update(billetHotsend,  updateWrapper);
 		}
 		List<String> billetNos = new ArrayList<>();
+		StorageBill storageBill = billetHotsendDetailsVo.getStorageBill();
 		// 保存 钢坯热送单炉支数传递单明细
 		if ("roll_club_one".equals(billetHotsendDetailsVo.getBelongTable())){
 			// 保存棒一信息
@@ -601,7 +601,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		// 根据billetHotsendTypeConfigId 查询基础垛位信息
 		BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(billetHotsendDetailsVo.getBilletHotsendTypeConfigId());
 		List<RollClubCommon> rollClubCommonList = billetHotsendDetailsVo.getRollClubCommonList();
-		StorageBill storageBill = billetHotsendDetailsVo.getStorageBill();
+
 		BilletHotsend billetHotsend = new BilletHotsend();
 		// 新保存 钢坯热送基础信息
 		BeanUtils.copyProperties(billetHotsendDetailsVo.getBilletHotsend(), billetHotsend);
@@ -650,6 +650,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 					.eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());;
 			baseMapper.update(billetHotsend,  updateWrapper);
 		}
+		StorageBill storageBill = billetHotsendDetailsVo.getStorageBill();
 		List<String> billetNos = new ArrayList<>();
 		// 保存 钢坯热送单炉支数传递单明细
 		if ("roll_club_one".equals(billetHotsendDetailsVo.getBelongTable())){
@@ -798,7 +799,6 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		if ("roll_out_shipp".equals(billetHotsendDetailsVo.getBelongTable())){
 			RollOutShipp rollOutShipp = new RollOutShipp();
 			BeanUtils.copyProperties(billetHotsend, rollOutShipp);
-
 			rollOutShipp.setSize(rollClubCommonList.stream().findFirst().orElse(null).getSize()); //定尺
 //			rollOutShipp.setBlankOutput();// 出坯量
 //			rollOutShipp.setDecideWeight();// 定重
@@ -909,7 +909,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		storageCarLog.setTypeConfigId(billetHotsendDetailsVo.getBilletHotsendTypeConfigId()); // 钢坯配置类型ID
 		storageCarLog.setHeatNo(String.join(",", heatNoList));
 		storageCarLog.setSize(String.join(",", sizeList));// 定尺
-		storageCarLog.setAmount(String.valueOf(count));// 支数
+		storageCarLog.setAmount(Integer.valueOf((int) count));// 支数
 		storageCarLog.setDataTime(new Date());
 		storageCarLogService.save(storageCarLog);
 

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

@@ -3,7 +3,6 @@ package org.jeecg.modules.billet.stackingAndLoadingVehicles.controller;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -13,7 +12,6 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsend;
 import org.jeecg.modules.billet.billetHotsend.entity.RulerDefaultConfig;
 import org.jeecg.modules.billet.billetHotsend.service.IBilletHotsendBaseService;
 import org.jeecg.modules.billet.billetHotsend.service.IRulerDefaultConfigService;
@@ -280,7 +278,7 @@ public class StackingAndLoadingVehiclesController extends JeecgController<Stacki
         return super.importExcel(request, response, StackingAndLoadingVehicles.class);
     }
 
-     @ApiOperation(value="垛位装车-发车", notes="垛位装车-发车")
+     @ApiOperation(value="钢坯-垛位装车", notes="钢坯-垛位装车")
      @PostMapping(value = "/loading")
      public Result<?> loading(@RequestBody LoadingParams loadingParams){
     	 if(loadingParams.getStackingAndLoadingVehiclesList() == null || loadingParams.getStackingAndLoadingVehiclesList().size() < 3){
@@ -291,20 +289,19 @@ public class StackingAndLoadingVehiclesController extends JeecgController<Stacki
 			 heats.add(stackingAndLoadingVehicles.getHeatNo());
 		 }
 		 if(heats.size()>3)return Result.error("一次只能选择三种炉次的钢坯");
-		 BilletHotsend billetHotsend = loadingParams.getBilletHotsend();
-		 billetHotsend.setId(String.valueOf(IdWorker.getId()));
-		 loadingParams.setBilletHotsend(billetHotsend);
-		 LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
-		 queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo()).eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo());
-		 BilletHotsend check = billetHotsendBaseService.getOne(queryWrapper);
-		 if (oConvertUtils.isNotEmpty(check) && billetHotsend.getIsUpd() ){
-			 return Result.OK("该铸机和炉号信息已存在,钢坯装运单操作失败!");
-		 }
     	 stackingAndLoadingVehiclesService.loadingHandle(loadingParams);
-		 operateLogService.add(billetHotsend,null,BilletHotsend.class);
 		return Result.OK("操作成功");
      }
 
+
+	 @ApiOperation(value="钢坯-垛位发车", notes="钢坯-垛位发车")
+	 @PostMapping(value = "/stackDepart")
+	 public Result<?> stackDepartHandle(@RequestBody LoadingParams loadingParams){
+		 stackingAndLoadingVehiclesService.stackDepartHandle(loadingParams);
+//		 operateLogService.add(billetHotsend,null,BilletHotsend.class);
+		 return Result.OK("操作成功");
+	 }
+
      @ApiOperation(value="堆垛-发车", notes="堆垛-发车")
      @PostMapping(value = "/startCar")
      public Result<?> startCar(@RequestBody SavVo savVo){

+ 1 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/entity/StackingUpLog.java

@@ -75,7 +75,7 @@ public class StackingUpLog implements Serializable {
 	/**支数*/
 	@Excel(name = "支数", width = 15)
     @ApiModelProperty(value = "支数")
-    private String amount;
+    private Integer amount;
 	/**所在层数(1-20)*/
 	@Excel(name = "所在层数(1-20)", width = 15)
     @ApiModelProperty(value = "所在层数(1-20)")

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

@@ -39,4 +39,6 @@ public interface IStackingAndLoadingVehiclesService extends IService<StackingAnd
     List<StackingAndLoadingVehicles> getListByTypeConfigId(String typeConfigId);
 
     void loadingHandle(LoadingParams loadingParams);
+
+    void stackDepartHandle(LoadingParams loadingParams);
 }

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

@@ -1,8 +1,8 @@
 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;
@@ -16,18 +16,12 @@ 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.entity.RollClubThree;
-import org.jeecg.modules.billet.rollClubThree.entity.RollClubThreeDetails;
 import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeDetailsService;
 import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeService;
-import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwo;
-import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwoDetails;
 import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoDetailsService;
 import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoService;
 import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
 import org.jeecg.modules.billet.rollHeight.service.IRollHeightService;
-import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShipp;
-import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
 import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
 import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippService;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingAndLoadingVehicles;
@@ -480,40 +474,177 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
 
     @Override
     public void loadingHandle(LoadingParams loadingParams) {
-        //  根据billetHotsendTypeConfigId 查询基础垛位信息
+        // 根据billetHotsendTypeConfigId 查询基础垛位信息
         BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(loadingParams.getBilletHotsendTypeConfigId());
-        if (oConvertUtils.isEmpty(billetHotsendTypeConfig)){
-            log.info("{}{}", "垛位保存或发车,查询基础钢坯类型配置信息为空!", JSON.toJSONString(loadingParams));
+        List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = loadingParams.getStackingAndLoadingVehiclesList();
+        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())
+                .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);
+            billetHotsend.setAmountTotal(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); // 堆垛总支数
+            }
+//            billetHotsend.setAmountTotal(billetHotsend.getAmountTotal() + stackingAndLoadingVehiclesList.size()); //总支数
+            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);
+        }
+        // 获取所有的坯号集合
+        List<String> billetNosList = stackingAndLoadingVehiclesList.stream().map(StackingAndLoadingVehicles::getBilletNos)
+                .flatMap(billetNos -> {
+                    if (billetNos!= null) {
+                        return java.util.stream.Stream.of(billetNos.split(","));
+                    } else {
+                        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);
         }
-        List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesListParam = loadingParams.getStackingAndLoadingVehiclesList();
         StorageBill storageBill = loadingParams.getStorageBill();
-        // 1 保存或更新 钢坯热送基础信息 billet_hotsend
+        // 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(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);
+        });
+        stackingUpLogService.saveBatch(stackingUpLogList);
+        //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 ->{
+            if ("stacking_and_loading_vehicles".equals(loadingParams.getBelongTable())){
+                x.setBelongTable("stacking_and_loading_vehicles");
+            }
+            x.setUpdateTime(new Date());
+            x.setBhtcId(loadingParams.getBilletHotsendTypeConfigId());
+        });
+        billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
+    }
+
+    @Override
+    public void stackDepartHandle(LoadingParams loadingParams) {
+        // 根据billetHotsendTypeConfigId 查询基础垛位信息
+        BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(loadingParams.getBilletHotsendTypeConfigId());
+        List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = loadingParams.getStackingAndLoadingVehiclesList();
         BilletHotsend billetHotsend = new BilletHotsend();
+        //1 新保存 钢坯热送基础信息
         BeanUtils.copyProperties(loadingParams.getBilletHotsend(), billetHotsend);
-        billetHotsend.setCreateDate(new Date());
-        if ("stacking_and_loading_vehicles".equals(loadingParams.getBelongTable()) && "1".equals(billetHotsendTypeConfig.getBelongTable())){
-            billetHotsend.setStackNum(stackingAndLoadingVehiclesListParam.size() * 4); // 堆垛总支数
+//		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;
         }
-//        billetHotsend.setAmountTotal(stackingAndLoadingVehiclesListParam.size());// 总支数
-        if (billetHotsend.getIsUpd()){
+        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); // 堆垛总支数
+            }
             LambdaUpdateWrapper<BilletHotsend> updateWrapper = new LambdaUpdateWrapper<>();
-            updateWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo()).eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo());
+            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);
         }
-        // 2 先查询堆垛公共容器中的信息,在批量移除 堆垛公共容器中的记录 stacking_and_loading_vehicles
-        List<String> ids = stackingAndLoadingVehiclesListParam.stream().map(StackingAndLoadingVehicles::getId).collect(Collectors.toList());
-        List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = baseMapper.selectBatchIds(ids);
-        if (oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)){
-            log.info("{}{}", "垛位保存或发车,堆垛容器信息信息为空!", JSON.toJSONString(loadingParams));
-            return;
+        // 获取所有的坯号集合
+        List<String> billetNosList = stackingAndLoadingVehiclesList.stream().map(StackingAndLoadingVehicles::getBilletNos)
+                .flatMap(billetNos -> {
+                    if (billetNos!= null) {
+                        return java.util.stream.Stream.of(billetNos.split(","));
+                    } else {
+                        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);
         }
-        baseMapper.deleteBatchIds(stackingAndLoadingVehiclesList.stream().map(StackingAndLoadingVehicles::getId).collect(Collectors.toList()));
+        StorageBill storageBill = loadingParams.getStorageBill();
         // 3 保存 下垛日志    stacking_down_log
         List<StackingDownLog> stackingDownLogList = new ArrayList<>();
-        stackingAndLoadingVehiclesListParam.forEach(x ->{
+        stackingAndLoadingVehiclesList.forEach(x ->{
             StackingDownLog stackingDownLog = new StackingDownLog();
             BeanUtils.copyProperties(x, stackingDownLog);
             stackingDownLog.setBilletNo(x.getBilletNos());
@@ -526,167 +657,46 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         });
         stackingDownLogService.saveBatch(stackingDownLogList);
 
-        List<String> billetNos = new ArrayList<>();
-        // 4 根据所属表 保存对应的棒线和对象信息,明细信息 roll_club_two、roll_club_two_details、roll_club_three、roll_club_three_details、roll_out_shipp、roll_out_shipp_details
-        if ("roll_club_two".equals(loadingParams.getBelongTable())){
-            // 保存棒一信息
-            RollClubTwo rollClubTwo = new RollClubTwo();
-            BeanUtils.copyProperties(billetHotsend, rollClubTwo);
-            rollClubTwo.setAmountTotal(stackingAndLoadingVehiclesListParam.size());// 总支数
-            rollClubTwo.setSize(stackingAndLoadingVehiclesListParam.stream().findFirst().orElse(null).getSize()); //定尺
-//			rollClubTwo.setBlankOutput();// 出坯量
-//			rollClubTwo.setDecideWeight();// 定重
-            rollClubTwoService.save(rollClubTwo);
-            // 保存棒二明细信息
-            List<RollClubTwoDetails> rollClubTwoDetailsList = new ArrayList<>();
-            stackingAndLoadingVehiclesListParam.forEach(x ->{
-                RollClubTwoDetails rollClubTwoDetails = new RollClubTwoDetails();
-                BeanUtils.copyProperties(x, rollClubTwoDetails);
-                rollClubTwoDetails.setBilletNo(x.getBilletNos());// 坯号
-                rollClubTwoDetails.setStackStorey(x.getLayer()); // 堆垛层号(1-20)
-                rollClubTwoDetails.setStackNum(x.getAddress());// 堆垛编号(1-9)
-                rollClubTwoDetails.setStorageBillId(storageBill.getId()); // 装运单ID
-//                rollClubTwoDetails.setStartNum() // 起始根数
-//                rollClubTwoDetails.setEndNumStack(); // 堆垛结束跟
-                billetNos.add(x.getBilletNos());
-                rollClubTwoDetailsList.add(rollClubTwoDetails);
-            });
-            rollClubTwoDetailsService.saveBatch(rollClubTwoDetailsList);
-        }
+        // 4 删除垛位容器中的信息
+        baseMapper.deleteById(stackingAndLoadingVehicles);
 
-        if ("roll_club_three".equals(loadingParams.getBelongTable())){
-            // 保存棒三信息
-            RollClubThree rollClubThree = new RollClubThree();
-            BeanUtils.copyProperties(billetHotsend, rollClubThree);
-            rollClubThree.setAmountTotal(stackingAndLoadingVehiclesListParam.size());// 总支数
-            rollClubThree.setSize(stackingAndLoadingVehiclesListParam.stream().findFirst().orElse(null).getSize()); //定尺
-//			rollClubThree.setBlankOutput();// 出坯量
-//			rollClubThree.setDecideWeight();// 定重
-            rollClubThreeService.save(rollClubThree);
-            // 保存棒三明细信息
-            List<RollClubThreeDetails> rollClubThreeDetailsList = new ArrayList<>();
-            stackingAndLoadingVehiclesListParam.forEach(x ->{
-                RollClubThreeDetails rollClubThreeDetails = new RollClubThreeDetails();
-                BeanUtils.copyProperties(x, rollClubThreeDetails);
-                rollClubThreeDetails.setBilletNo(x.getBilletNos());// 坯号
-                rollClubThreeDetails.setStackStorey(x.getLayer()); // 堆垛层号(1-20)
-                rollClubThreeDetails.setStackNum(x.getAddress());// 堆垛编号(1-9)
-                rollClubThreeDetails.setStorageBillId(storageBill.getId()); // 装运单ID
-//                rollClubThreeDetails.setStartNum() // 起始根数
-//                rollClubThreeDetails.setEndNumStack(); // 堆垛结束跟
-                billetNos.add(x.getBilletNos());
-                rollClubThreeDetailsList.add(rollClubThreeDetails);
-            });
-            rollClubThreeDetailsService.saveBatch(rollClubThreeDetailsList);
-        }
-        /**
-         * 保存上若信息
-         */
-        if ("roll_out_shipp".equals(loadingParams.getBelongTable())){
-            RollOutShipp rollOutShipp = new RollOutShipp();
-            BeanUtils.copyProperties(billetHotsend, rollOutShipp);
-            rollOutShipp.setAmountTotal(stackingAndLoadingVehiclesListParam.size());// 总支数
-            rollOutShipp.setSize(stackingAndLoadingVehiclesListParam.stream().findFirst().orElse(null).getSize()); //定尺
-//			rollOutShipp.setBlankOutput();// 出坯量
-//			rollOutShipp.setDecideWeight();// 定重
-            rollOutShippService.save(rollOutShipp);
-            // 保存高线明细信息
-            List<RollOutShippDetails> rollOutShippDetailsList = new ArrayList<>();
-            stackingAndLoadingVehiclesListParam.forEach(x ->{
-                RollOutShippDetails rollOutShippDetails = new RollOutShippDetails();
-                BeanUtils.copyProperties(x, rollOutShippDetails);
-                rollOutShippDetails.setBilletNo(x.getBilletNos());// 坯号
-                rollOutShippDetails.setStackStorey(x.getLayer()); // 堆垛层号(1-20)
-                rollOutShippDetails.setStackNum(x.getAddress());// 堆垛编号(1-9)
-                rollOutShippDetails.setStorageBillId(storageBill.getId()); // 装运单ID
-                billetNos.add(x.getBilletNos());
-                rollOutShippDetailsList.add(rollOutShippDetails);
-            });
-            rollOutShippDetailsService.saveBatch(rollOutShippDetailsList);
-        }
         //5 查询并批量更新钢坯基础信息 belongTable
-        LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<BilletBasicInfo>()
+        LambdaQueryWrapper<BilletBasicInfo> queryWrapperBB = new LambdaQueryWrapper<BilletBasicInfo>()
                 .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
                 .eq(BilletBasicInfo::getHeatNo, billetHotsend.getHeatNo())
-                .in(BilletBasicInfo::getBilletNo, billetNos);
-        List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
+                .in(BilletBasicInfo::getBilletNo, billetNosList);
+        List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperBB);
         billetBasicInfoList.forEach(x ->{
-            if ("roll_club_one".equals(loadingParams.getBelongTable())){
-                x.setBelongTable("roll_club_one");
-            }else if ("roll_club_two".equals(loadingParams.getBelongTable())){
-                x.setBelongTable("roll_club_two");
-            }else if ("roll_club_three".equals(loadingParams.getBelongTable())){
-                x.setBelongTable("roll_club_three");
-            }else if ("roll_height".equals(loadingParams.getBelongTable())){
-                x.setBelongTable("roll_height");
-            }else if ("roll_out_shipp".equals(loadingParams.getBelongTable())){
-                x.setBelongTable("roll_out_shipp");
+            if ("stacking_and_loading_vehicles".equals(loadingParams.getBelongTable())){
+                x.setBelongTable("stacking_and_loading_vehicles");
             }
             x.setUpdateTime(new Date());
             x.setBhtcId(loadingParams.getBilletHotsendTypeConfigId());
         });
         billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
-        /**
-         * IsUpd为false代表页面保存
-         */
-        if (!billetHotsend.getIsUpd() && oConvertUtils.isNotEmpty(storageBill)){
-            // 6 更新装运单 storage_bill 《IsUpd为false代表页面保存:不操作装运单和储运车信息》
+        // 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() + 1);// 本车车次
-            storageBill.setUpdateTime(new Date());
+            storageBill.setCarNum(storageBill.getCarNum() == 0 ? 0 : storageBill.getCarNum() + 1);// 本车车次
             storageBillService.updateById(storageBill);
             // 7 发车后,新增钢坯堆垛储运信息,生成储运单 storage_car_log
             StorageCarLog storageCarLog = new StorageCarLog();
             BeanUtils.copyProperties(storageBill, storageCarLog);
-            List<String> sizeList = new ArrayList<>();
-            List<String> heatNoList = new ArrayList<>();
-            long count = 0l;
-            //根据铸机号、钢坯转运单ID查询定尺信息
-            if ("roll_club_two".equals(loadingParams.getBelongTable())){
-                LambdaQueryWrapper<RollClubTwoDetails> queryWrapperRCT = new LambdaQueryWrapper();
-                queryWrapperRCT.eq(RollClubTwoDetails::getCcmNo, storageBill.getCcmNo()).eq(RollClubTwoDetails::getStorageBillId, storageBill.getId());
-                List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapperRCT);
-                sizeList = rollClubTwoDetailsList.stream().map(RollClubTwoDetails::getSize).distinct()
-                        .collect(Collectors.toList());
-                heatNoList = rollClubTwoDetailsList.stream().map(RollClubTwoDetails::getHeatNo).distinct()
-                        .collect(Collectors.toList());
-                if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
-                    count = rollClubTwoDetailsList.stream().count();
-                }
-            }
-            if ("roll_club_three".equals(loadingParams.getBelongTable())){
-                LambdaQueryWrapper<RollClubThreeDetails> queryWrapperCTS = new LambdaQueryWrapper();
-                queryWrapperCTS.eq(RollClubThreeDetails::getCcmNo, storageBill.getCcmNo()).eq(RollClubThreeDetails::getStorageBillId, storageBill.getId());
-                List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapperCTS);
-                sizeList = rollClubThreeDetailsList.stream().map(RollClubThreeDetails::getSize).distinct()
-                        .collect(Collectors.toList());
-                heatNoList = rollClubThreeDetailsList.stream().map(RollClubThreeDetails::getHeatNo).distinct()
-                        .collect(Collectors.toList());
-                if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)){
-                    count = rollClubThreeDetailsList.stream().count();
-                }
-            }
-            if ("roll_out_shipp".equals(loadingParams.getBelongTable())){
-                LambdaQueryWrapper<RollOutShippDetails> queryWrapperROS = new LambdaQueryWrapper();
-                queryWrapperROS.eq(RollOutShippDetails::getCcmNo, storageBill.getCcmNo()).eq(RollOutShippDetails::getStorageBillId, storageBill.getId());
-                List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapperROS);
-                sizeList = rollOutShippDetailsList.stream().map(RollOutShippDetails::getSize).distinct()
-                        .collect(Collectors.toList());
-                heatNoList = rollOutShippDetailsList.stream().map(RollOutShippDetails::getHeatNo).distinct()
-                        .collect(Collectors.toList());
-                if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)){
-                    count = rollOutShippDetailsList.stream().count();
-                }
-            }
             storageCarLog.setDestination(billetHotsendTypeConfig.getTypeName());// 目的地
-            storageCarLog.setCarNm(storageCarLog.getCarNm());// 车号
-//			storageCarLog.setFixedWeight();// 定重
-            storageCarLog.setOutCarNum(storageCarLog.getOutCarNum()); // 出车号
+            storageCarLog.setCarNm(String.valueOf(storageBill.getCarNum()));// 车号
+            storageCarLog.setOutCarNum(storageBill.getLicensePlate()); // 出车号
             storageCarLog.setTypeConfigId(billetHotsendTypeConfig.getId()); // 钢坯配置类型ID
-            storageCarLog.setHeatNo(String.join(",", heatNoList));
-            storageCarLog.setSize(String.join(",", sizeList));// 定尺
-            storageCarLog.setAmount(String.valueOf(count));// 支数
-            storageCarLog.setDataTime(new Date());
+            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);
         }
     }

+ 1 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageCarLog/entity/StorageCarLog.java

@@ -110,7 +110,7 @@ public class StorageCarLog implements Serializable {
 	/**支数*/
 	@Excel(name = "支数", width = 15)
     @ApiModelProperty(value = "支数")
-    private String amount;
+    private Integer amount;
 
     @Excel(name = "钢坯配置类型ID", width = 15)
     @ApiModelProperty(value = "钢坯配置类型ID")