Эх сурвалжийг харах

Merge branch 'master' of 123.57.213.14:guoqiang.duan/zgzt-bus-java

guoqiang 6 сар өмнө
parent
commit
b6bded94f3

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

@@ -314,7 +314,6 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(billetHotsendDetailsVo.getBilletHotsendTypeConfigId());
 		List<RollClubCommon> rollClubCommonList = billetHotsendDetailsVo.getRollClubCommonList();
 		BilletHotsend billetHotsend = new BilletHotsend();
-
 		// 新保存 钢坯热送基础信息
 		BeanUtils.copyProperties(billetHotsendDetailsVo.getBilletHotsend(), billetHotsend);
 		billetHotsend.setCreateDate(new Date());
@@ -323,22 +322,24 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		queryWrapperHA.eq(HeatsActuals::getCasterCode, billetHotsend.getCcmNo()).eq(HeatsActuals::getHeatsCode, billetHotsend.getHeatNo());
 		HeatsActuals heatsActuals = heatsActualsService.getOne(queryWrapperHA);
 		LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
-		if (oConvertUtils.isEmpty(heatsActuals)){
+		if (heatsActuals != null){
 			queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
 					.eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-					.eq(BilletHotsend::getShift, billetHotsend.getShift())
-					.eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
+					.eq(BilletHotsend::getShift, heatsActuals.getShift())
+					.eq(BilletHotsend::getShiftGroup, heatsActuals.getShiftGroup());
+			billetHotsend.setShift(heatsActuals.getShift());
+			billetHotsend.setShiftGroup(heatsActuals.getShiftGroup());
 		}else {
 			queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
 					.eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-					.eq(BilletHotsend::getShift, heatsActuals.getShift())
-					.eq(BilletHotsend::getShiftGroup, heatsActuals.getShiftGroup());
+					.eq(BilletHotsend::getShift, billetHotsend.getShift())
+					.eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
 		}
 		BilletHotsend check = baseMapper.selectOne(queryWrapper);
 		if (oConvertUtils.isNotEmpty(check) && oConvertUtils.listIsEmpty(rollClubCommonList)){
 			return;
 		}
-		if (oConvertUtils.isEmpty(check)){
+		if (oConvertUtils.isEmpty(check) && oConvertUtils.listIsEmpty(rollClubCommonList)){
 			billetHotsend.setRollclubtwoNum(0);
 			billetHotsend.setRollcluboneNum(0);
 			billetHotsend.setRolloutshippNum(0);
@@ -352,24 +353,48 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			return;
 		}else {
 			if ("roll_club_one".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRollcluboneNum(oConvertUtils.isEmpty(check.getRollcluboneNum()) ? rollClubCommonList.size() : check.getRollcluboneNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRollcluboneNum())){
+					billetHotsend.setRollcluboneNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRollcluboneNum(check.getRollcluboneNum() + rollClubCommonList.size());
+				}
 			}else if ("roll_club_two".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRollclubtwoNum(oConvertUtils.isEmpty(check.getRollclubtwoNum()) ? rollClubCommonList.size() : check.getRollclubtwoNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRollclubtwoNum())){
+					billetHotsend.setRollclubtwoNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRollclubtwoNum(check.getRollclubtwoNum() + rollClubCommonList.size());
+				}
 			}else if ("roll_club_three".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRollclubthreeNum(oConvertUtils.isEmpty(check.getRollclubthreeNum()) ? rollClubCommonList.size() : check.getRollclubthreeNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRollclubthreeNum())){
+					billetHotsend.setRollclubthreeNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRollclubthreeNum(check.getRollclubthreeNum() + rollClubCommonList.size());
+				}
 			}else if ("roll_height".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRollheightNum(oConvertUtils.isEmpty(check.getRollheightNum()) ? rollClubCommonList.size() : check.getRollheightNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRollheightNum())){
+					billetHotsend.setRollheightNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRollheightNum(check.getRollheightNum() + rollClubCommonList.size());
+				}
 			}else if ("roll_out_shipp".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRolloutshippNum(oConvertUtils.isEmpty(check.getRolloutshippNum()) ? rollClubCommonList.size() : check.getRolloutshippNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRolloutshippNum())){
+					billetHotsend.setRolloutshippNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRolloutshippNum(check.getRolloutshippNum() + rollClubCommonList.size());
+				}
+			}
+			if (oConvertUtils.isNotEmpty(check)){
+				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());
+				baseMapper.update(billetHotsend,  updateWrapper);
+			}else {
+				billetHotsend.setAmountTotal(0);
+				billetHotsend.setStackNum(0);
+				baseMapper.insert(billetHotsend);
 			}
-			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());;
-			baseMapper.update(billetHotsend,  updateWrapper);
-			billetHotsend.setId(check.getId());
-			operateLogService.add(billetHotsend,null,BilletHotsend.class);
 		}
 		List<String> billetNos = new ArrayList<>();
 		StorageBill storageBill = billetHotsendDetailsVo.getStorageBill();
@@ -642,52 +667,84 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		// 新保存 钢坯热送基础信息
 		BeanUtils.copyProperties(billetHotsendDetailsVo.getBilletHotsend(), billetHotsend);
 		billetHotsend.setCreateDate(new Date());
-		//	billetHotsend.setAmountTotal(rollClubCommonList.size()); //总支数
+//		billetHotsend.setAmountTotal(rollClubCommonList.size()); //总支数
 		LambdaQueryWrapper<HeatsActuals> queryWrapperHA = new LambdaQueryWrapper();
 		queryWrapperHA.eq(HeatsActuals::getCasterCode, billetHotsend.getCcmNo()).eq(HeatsActuals::getHeatsCode, billetHotsend.getHeatNo());
 		HeatsActuals heatsActuals = heatsActualsService.getOne(queryWrapperHA);
 		LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
-		if (oConvertUtils.isEmpty(heatsActuals)){
+		if (heatsActuals != null){
 			queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
 					.eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-					.eq(BilletHotsend::getShift, billetHotsend.getShift())
-					.eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
+					.eq(BilletHotsend::getShift, heatsActuals.getShift())
+					.eq(BilletHotsend::getShiftGroup, heatsActuals.getShiftGroup());
+			billetHotsend.setShift(heatsActuals.getShift());
+			billetHotsend.setShiftGroup(heatsActuals.getShiftGroup());
 		}else {
 			queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
 					.eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-					.eq(BilletHotsend::getShift, heatsActuals.getShift())
-					.eq(BilletHotsend::getShiftGroup, heatsActuals.getShiftGroup());
+					.eq(BilletHotsend::getShift, billetHotsend.getShift())
+					.eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
 		}
 		BilletHotsend check = baseMapper.selectOne(queryWrapper);
+		if (oConvertUtils.isNotEmpty(check) && oConvertUtils.listIsEmpty(rollClubCommonList)){
+			return;
+		}
 		if (oConvertUtils.isEmpty(check) && oConvertUtils.listIsEmpty(rollClubCommonList)){
 			billetHotsend.setRollclubtwoNum(0);
 			billetHotsend.setRollcluboneNum(0);
 			billetHotsend.setRolloutshippNum(0);
 			billetHotsend.setRollheightNum(0);
 			billetHotsend.setRollclubthreeNum(0);
+			billetHotsend.setAmountTotal(0);
+			billetHotsend.setStackNum(0);
 			baseMapper.insert(billetHotsend);
-			billetHotsend.setId(check.getId());
-			operateLogService.add(billetHotsend,null, BilletHotsend.class);
+			billetHotsend.setId(billetHotsend.getId());
+			operateLogService.add(billetHotsend,null,BilletHotsend.class);
+			return;
 		}else {
 			if ("roll_club_one".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRollcluboneNum(oConvertUtils.isEmpty(check.getRollcluboneNum()) ? rollClubCommonList.size() : check.getRollcluboneNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRollcluboneNum())){
+					billetHotsend.setRollcluboneNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRollcluboneNum(check.getRollcluboneNum() + rollClubCommonList.size());
+				}
 			}else if ("roll_club_two".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRollclubtwoNum(oConvertUtils.isEmpty(check.getRollclubtwoNum()) ? rollClubCommonList.size() : check.getRollclubtwoNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRollclubtwoNum())){
+					billetHotsend.setRollclubtwoNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRollclubtwoNum(check.getRollclubtwoNum() + rollClubCommonList.size());
+				}
 			}else if ("roll_club_three".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRollclubthreeNum(oConvertUtils.isEmpty(check.getRollclubthreeNum()) ? rollClubCommonList.size() : check.getRollclubthreeNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRollclubthreeNum())){
+					billetHotsend.setRollclubthreeNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRollclubthreeNum(check.getRollclubthreeNum() + rollClubCommonList.size());
+				}
 			}else if ("roll_height".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRollheightNum(oConvertUtils.isEmpty(check.getRollheightNum()) ? rollClubCommonList.size() : check.getRollheightNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRollheightNum())){
+					billetHotsend.setRollheightNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRollheightNum(check.getRollheightNum() + rollClubCommonList.size());
+				}
 			}else if ("roll_out_shipp".equals(billetHotsendDetailsVo.getBelongTable()) && "0".equals(billetHotsendTypeConfig.getBelongType().toString())){
-				billetHotsend.setRolloutshippNum(oConvertUtils.isEmpty(check.getRolloutshippNum()) ? rollClubCommonList.size() : check.getRolloutshippNum() + rollClubCommonList.size());
+				if (oConvertUtils.isEmpty(check) || oConvertUtils.isEmpty(check.getRolloutshippNum())){
+					billetHotsend.setRolloutshippNum(rollClubCommonList.size());
+				}else {
+					billetHotsend.setRolloutshippNum(check.getRolloutshippNum() + rollClubCommonList.size());
+				}
+			}
+			if (oConvertUtils.isNotEmpty(check)){
+				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());
+				baseMapper.update(billetHotsend,  updateWrapper);
+			}else {
+				billetHotsend.setAmountTotal(0);
+				billetHotsend.setStackNum(0);
+				baseMapper.insert(billetHotsend);
 			}
-			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());;
-			baseMapper.update(billetHotsend,  updateWrapper);
-			billetHotsend.setId(check.getId());
-			operateLogService.add(billetHotsend,null,BilletHotsend.class);
 		}
 		StorageBill storageBill = billetHotsendDetailsVo.getStorageBill();
 		List<String> billetNos = new ArrayList<>();
@@ -697,8 +754,6 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			RollClubOne rollClubOne = new RollClubOne();
 			BeanUtils.copyProperties(billetHotsend, rollClubOne);
 			rollClubOne.setSize(rollClubCommonList.stream().findFirst().orElse(null).getSize()); //定尺
-//			rollClubOne.setBlankOutput();// 出坯量
-//			rollClubOne.setDecideWeight();// 定重
 			LambdaQueryWrapper<RollClubOne> queryWrapper1 = new LambdaQueryWrapper<>();
 			queryWrapper1.eq(RollClubOne::getCcmNo, billetHotsend.getCcmNo())
 					.eq(RollClubOne::getHeatNo, billetHotsend.getHeatNo())

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

@@ -1,6 +1,5 @@
 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;
@@ -12,7 +11,6 @@ import org.jeecg.modules.actualControl.billetActual.billetActual.service.IBillet
 import org.jeecg.modules.actualControl.heatsActuals.entity.HeatsActuals;
 import org.jeecg.modules.actualControl.heatsActuals.service.IHeatsActualsService;
 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.service.IBilletHotsendBaseService;
 import org.jeecg.modules.billet.billetHotsend.service.IRulerDefaultConfigService;
@@ -459,38 +457,42 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(loadingParams.getBilletHotsendTypeConfigId());
         List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = loadingParams.getStackingAndLoadingVehiclesList();
         BilletHotsend billetHotsend = new BilletHotsend();
-        //1 新保存 钢坯热送基础信息
         BeanUtils.copyProperties(loadingParams.getBilletHotsend(), billetHotsend);
-        LambdaQueryWrapper<HeatsActuals> queryWrapperHA = new LambdaQueryWrapper();
-        queryWrapperHA.eq(HeatsActuals::getCasterCode, billetHotsend.getCcmNo()).eq(HeatsActuals::getHeatsCode, billetHotsend.getHeatNo());
-        HeatsActuals heatsActuals = heatsActualsService.getOne(queryWrapperHA);
-        LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
-        if (oConvertUtils.isEmpty(heatsActuals)){
-            queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
-                    .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-                    .eq(BilletHotsend::getShift, billetHotsend.getShift())
-                    .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
-        }else {
-            queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
-                    .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-                    .eq(BilletHotsend::getShift, heatsActuals.getShift())
-                    .eq(BilletHotsend::getShiftGroup, heatsActuals.getShiftGroup());
+        String cacheShint = loadingParams.getBilletHotsend().getShift();
+        String cacheShintGroup = loadingParams.getBilletHotsend().getShiftGroup();
+        //1 新保存 钢坯热送基础信息
+        HeatsActuals heatsActuals = heatsActualsService.getOne(new LambdaQueryWrapper<HeatsActuals>().eq(HeatsActuals::getCasterCode, billetHotsend.getCcmNo()).eq(HeatsActuals::getHeatsCode, billetHotsend.getHeatNo()));
+        if (heatsActuals != null) {
+            cacheShint = heatsActuals.getShift();
+            cacheShintGroup = heatsActuals.getShiftGroup();
         }
-        BilletHotsend idExistBh = billetHotsendBaseService.getOne(queryWrapper);
-        if (oConvertUtils.isEmpty(idExistBh)){
-            log.info("{}{}", "钢坯热送基础信息不存在,垛位装车失败!", JSON.toJSONString(loadingParams));
+        if (oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)){
             return;
-        }else {
-            int result = Integer.compare(idExistBh.getStackNum(), stackingAndLoadingVehiclesList.size() * 4);
-            billetHotsend.setStackNum(result > 0 ? idExistBh.getStackNum() - stackingAndLoadingVehiclesList.size() * 4 : 0);
+        }
+        LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
+                .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
+                .eq(BilletHotsend::getShift, cacheShint)
+                .eq(BilletHotsend::getShiftGroup, cacheShintGroup);
+        BilletHotsend idExistBh = billetHotsendBaseService.getOne(queryWrapper);
+        if (oConvertUtils.isNotEmpty(idExistBh)){
+            // 钢坯热送基础信息存在,但是钢坯信息不存在 直接返回
+            billetHotsend.setStackNum(idExistBh.getStackNum() - 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());;
+                    .eq(BilletHotsend::getShift, cacheShint)
+                    .eq(BilletHotsend::getShiftGroup, cacheShintGroup)
+                    .set(BilletHotsend::getStackNum, billetHotsend.getStackNum())
+                    .set(BilletHotsend::getShift, cacheShint)
+                    .set(BilletHotsend::getShiftGroup, cacheShintGroup);
             billetHotsendBaseService.update(billetHotsend, updateWrapper);
-            billetHotsend.setId(idExistBh.getId());
-            operateLogService.add(billetHotsend,null, BilletHotsend.class);
+        } else {
+            // 钢坯热送基础信息不存在,但是钢坯信息不存在 保存钢坯热送基础信息
+            billetHotsend.setStackNum(stackingAndLoadingVehiclesList.size() * 4);
+            billetHotsend.setShiftGroup(cacheShintGroup);
+            billetHotsend.setShift(cacheShint);
+            billetHotsendBaseService.save(billetHotsend);
         }
         // 根据铸机号、位置、层数、类型配置ID更新 初始化容器中的垛位信息
         stackingAndLoadingVehiclesList.forEach(x ->{
@@ -508,7 +510,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             BeanUtils.copyProperties(x, stackingAndLoadingVehicles);
             stackingAndLoadingVehiclesMapper.update(stackingAndLoadingVehicles, updateWrapper);
         });
-
+        String finalCacheShint1 = cacheShint;
+        String finalCacheShintGroup1 = cacheShintGroup;
         // 3 保存 下垛日志    stacking_up_log
         List<StackingDownLog> stackingDownLogList = new ArrayList<>();
         stackingAndLoadingVehiclesList.forEach(x ->{
@@ -520,6 +523,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             stackingDownLog.setStackStorey(x.getLayer());// 堆垛层号(1-20)
             stackingDownLog.setStackNum(x.getAddress());// 堆垛编号(1-9)
             stackingDownLog.setStackAddr(billetHotsendTypeConfig.getTypeName());
+            stackingDownLog.setShift(finalCacheShint1);
+            stackingDownLog.setShiftGroup(finalCacheShintGroup1);
 //            stackingUpLog.setFromStackingId(stackingAndLoadingVehicles.getId());
             stackingDownLogList.add(stackingDownLog);
         });
@@ -558,41 +563,44 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(loadingParams.getBilletHotsendTypeConfigId());
         List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = loadingParams.getStackingAndLoadingVehiclesList();
         BilletHotsend billetHotsend = new BilletHotsend();
-        //1 新保存 钢坯热送基础信息
         BeanUtils.copyProperties(loadingParams.getBilletHotsend(), billetHotsend);
-        LambdaQueryWrapper<HeatsActuals> queryWrapperHA = new LambdaQueryWrapper();
-        queryWrapperHA.eq(HeatsActuals::getCasterCode, billetHotsend.getCcmNo()).eq(HeatsActuals::getHeatsCode, billetHotsend.getHeatNo());
-        HeatsActuals heatsActuals = heatsActualsService.getOne(queryWrapperHA);
-        LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
-        if (oConvertUtils.isEmpty(heatsActuals)){
-            queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
-                    .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-                    .eq(BilletHotsend::getShift, billetHotsend.getShift())
-                    .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
-        }else {
-            queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
-                    .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-                    .eq(BilletHotsend::getShift, heatsActuals.getShift())
-                    .eq(BilletHotsend::getShiftGroup, heatsActuals.getShiftGroup());
+        String cacheShint = loadingParams.getBilletHotsend().getShift();
+        String cacheShintGroup = loadingParams.getBilletHotsend().getShiftGroup();
+        //1 新保存 钢坯热送基础信息
+        HeatsActuals heatsActuals = heatsActualsService.getOne(new LambdaQueryWrapper<HeatsActuals>().eq(HeatsActuals::getCasterCode, billetHotsend.getCcmNo()).eq(HeatsActuals::getHeatsCode, billetHotsend.getHeatNo()));
+        if (heatsActuals != null) {
+            cacheShint = heatsActuals.getShift();
+            cacheShintGroup = heatsActuals.getShiftGroup();
         }
-        BilletHotsend idExistBh = billetHotsendBaseService.getOne(queryWrapper);
-        if (oConvertUtils.isEmpty(idExistBh)){
-            log.info("{}{}", "钢坯热送基础信息不存在,垛位发车失败!", JSON.toJSONString(loadingParams));
+        if (oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)){
             return;
-        } else {
-            int result = Integer.compare(idExistBh.getStackNum(), stackingAndLoadingVehiclesList.size() * 4);
-            billetHotsend.setStackNum(result > 0 ? idExistBh.getStackNum() - stackingAndLoadingVehiclesList.size() * 4 : 0);// 垛位总支数
+        }
+        LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
+                .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
+                .eq(BilletHotsend::getShift, cacheShint)
+                .eq(BilletHotsend::getShiftGroup, cacheShintGroup);
+        BilletHotsend idExistBh = billetHotsendBaseService.getOne(queryWrapper);
+        if (oConvertUtils.isNotEmpty(idExistBh)){
+            // 钢坯热送基础信息存在,但是钢坯信息不存在 直接返回
+            billetHotsend.setStackNum(idExistBh.getStackNum() - 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());;
+                    .eq(BilletHotsend::getShift, cacheShint)
+                    .eq(BilletHotsend::getShiftGroup, cacheShintGroup)
+                    .set(BilletHotsend::getStackNum, billetHotsend.getStackNum())
+                    .set(BilletHotsend::getShift, cacheShint)
+                    .set(BilletHotsend::getShiftGroup, cacheShintGroup);
             billetHotsendBaseService.update(billetHotsend, updateWrapper);
-            billetHotsend.setId(idExistBh.getId());
-            operateLogService.add(billetHotsend,null, BilletHotsend.class);
+        } else {
+            // 钢坯热送基础信息不存在,但是钢坯信息不存在 保存钢坯热送基础信息
+            billetHotsend.setStackNum(stackingAndLoadingVehiclesList.size() * 4);
+            billetHotsend.setShiftGroup(cacheShintGroup);
+            billetHotsend.setShift(cacheShint);
+            billetHotsendBaseService.save(billetHotsend);
         }
-
-        // 3 发车后,动态更新容器中的垛位信息 初始化
+        // 2 发车后,动态更新容器中的垛位信息 初始化
         stackingAndLoadingVehiclesList.forEach(x ->{
             LambdaUpdateWrapper<StackingAndLoadingVehicles> updateWrapper = new LambdaUpdateWrapper();
             updateWrapper.eq(StackingAndLoadingVehicles::getId, x.getId())
@@ -610,6 +618,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         });
 
         // 4 保存 下垛日志    stacking_down_log
+        String finalCacheShint1 = cacheShint;
+        String finalCacheShintGroup1 = cacheShintGroup;
         List<StackingDownLog> stackingDownLogList = new ArrayList<>();
         stackingAndLoadingVehiclesList.forEach(x ->{
             StackingDownLog stackingDownLog = new StackingDownLog();
@@ -619,6 +629,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             stackingDownLog.setStorageBillId(loadingParams.getStorageBill().getId());// 装运单ID
             stackingDownLog.setStackStorey(x.getLayer());
             stackingDownLog.setStackNum(x.getAddress());
+            stackingDownLog.setShift(finalCacheShint1);
+            stackingDownLog.setShiftGroup(finalCacheShintGroup1);
             stackingDownLogList.add(stackingDownLog);
         });
         stackingDownLogService.saveBatch(stackingDownLogList);
@@ -647,8 +659,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         StorageBill storageBill = loadingParams.getStorageBill();
         LambdaQueryWrapper<StorageBill> queryWrapperSB = new LambdaQueryWrapper<>();
         queryWrapperSB.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
-                     .eq(StorageBill::getShift, storageBill.getShift())
-                   .eq(StorageBill::getShiftGroup, storageBill.getShiftGroup())
+                     .eq(StorageBill::getShift, finalCacheShint1)
+                   .eq(StorageBill::getShiftGroup, finalCacheShintGroup1)
                     .eq(StorageBill::getLicensePlate, storageBill.getLicensePlate());
         List<StorageBill> storageBillList = storageBillService.list(queryWrapperSB);
         storageBill.setCarNum(oConvertUtils.listIsEmpty(storageBillList) ? 0 : storageBillList.size() + 1);// 本车车次
@@ -670,10 +682,10 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         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());
+                .eq(StackingUpLog::getShift, finalCacheShint1)
+                .eq(StackingUpLog::getShiftGroup, finalCacheShintGroup1);
         List<StackingUpLog> stackingUpLogList = stackingUpLogService.list(queryWrapperSU);
-        storageCarLog.setAmount(storageBill.getAmountTotal());// 支数
+        storageCarLog.setAmount(stackingUpLogList.size());// 支数
         storageCarLogService.save(storageCarLog);
     }
 
@@ -682,46 +694,47 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         // 根据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<HeatsActuals> queryWrapperHA = new LambdaQueryWrapper();
-        queryWrapperHA.eq(HeatsActuals::getCasterCode, billetHotsend.getCcmNo()).eq(HeatsActuals::getHeatsCode, billetHotsend.getHeatNo());
-        HeatsActuals heatsActuals = heatsActualsService.getOne(queryWrapperHA);
-        LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
-        if (oConvertUtils.isEmpty(heatsActuals)){
-            queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
-                    .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-                    .eq(BilletHotsend::getShift, billetHotsend.getShift())
-                    .eq(BilletHotsend::getShiftGroup, billetHotsend.getShiftGroup());
-        }else {
-            queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
-                    .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
-                    .eq(BilletHotsend::getShift, heatsActuals.getShift())
-                    .eq(BilletHotsend::getShiftGroup, heatsActuals.getShiftGroup());
+        String cacheShint = loadingParams.getBilletHotsend().getShift();
+        String cacheShintGroup = loadingParams.getBilletHotsend().getShiftGroup();
+        //1 新保存 钢坯热送基础信息
+        HeatsActuals heatsActuals = heatsActualsService.getOne(new LambdaQueryWrapper<HeatsActuals>().eq(HeatsActuals::getCasterCode, billetHotsend.getCcmNo()).eq(HeatsActuals::getHeatsCode, billetHotsend.getHeatNo()));
+        if (heatsActuals != null) {
+            cacheShint = heatsActuals.getShift();
+            cacheShintGroup = heatsActuals.getShiftGroup();
         }
-        BilletHotsend idExistBh = billetHotsendBaseService.getOne(queryWrapper);
-        if (oConvertUtils.isNotEmpty(idExistBh) && oConvertUtils.listIsEmpty(rollClubCommonList)){
+        if (oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)){
             return;
         }
-        if (oConvertUtils.isEmpty(idExistBh) && oConvertUtils.listIsEmpty(rollClubCommonList)){
-            billetHotsend.setStackNum(0);
-            billetHotsend.setAmountTotal(0);
-            billetHotsendBaseService.save(billetHotsend);
-            return;
-        }else {
+        LambdaQueryWrapper<BilletHotsend> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(BilletHotsend::getCcmNo, billetHotsend.getCcmNo())
+                .eq(BilletHotsend::getHeatNo, billetHotsend.getHeatNo())
+                .eq(BilletHotsend::getShift, cacheShint)
+                .eq(BilletHotsend::getShiftGroup, cacheShintGroup);
+        BilletHotsend idExistBh = billetHotsendBaseService.getOne(queryWrapper);
+        if (oConvertUtils.isNotEmpty(idExistBh)){
+            // 钢坯热送基础信息存在,但是钢坯信息不存在 直接返回
             billetHotsend.setStackNum(idExistBh.getStackNum() + stackingAndLoadingVehiclesList.size() * 4); // 堆垛总支数
-//            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());;
+                    .eq(BilletHotsend::getShift, cacheShint)
+                    .eq(BilletHotsend::getShiftGroup, cacheShintGroup)
+                    .set(BilletHotsend::getStackNum, billetHotsend.getStackNum())
+                    .set(BilletHotsend::getShift, cacheShint)
+                    .set(BilletHotsend::getShiftGroup, cacheShintGroup);
             billetHotsendBaseService.update(billetHotsend, updateWrapper);
+        } else {
+            // 钢坯热送基础信息不存在,但是钢坯信息不存在 保存钢坯热送基础信息
+            billetHotsend.setStackNum(stackingAndLoadingVehiclesList.size() * 4);
+            billetHotsend.setShiftGroup(cacheShintGroup);
+            billetHotsend.setShift(cacheShint);
+            billetHotsendBaseService.save(billetHotsend);
         }
-
         // 2 发车后,动态更新容器中的垛位信息 初始化
+        String finalCacheShint1 = cacheShint;
+        String finalCacheShintGroup1 = cacheShintGroup;
         stackingAndLoadingVehiclesList.forEach(x ->{
             LambdaUpdateWrapper<StackingAndLoadingVehicles> queryWrapperSA = new LambdaUpdateWrapper<>();
             queryWrapperSA.eq(StackingAndLoadingVehicles::getCcmNo, x.getCcmNo())
@@ -730,6 +743,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                     .eq(StackingAndLoadingVehicles::getTypeConfigId, loadingParams.getBilletHotsendTypeConfigId());;
             StackingAndLoadingVehicles stackingAndLoadingVehicles = createInitializedVehicle();
             BeanUtils.copyProperties(x, stackingAndLoadingVehicles);
+            stackingAndLoadingVehicles.setShift(finalCacheShint1);
+            stackingAndLoadingVehicles.setShiftGroup(finalCacheShintGroup1);
             stackingAndLoadingVehicles.setCreateDate(new Date());
             baseMapper.update(stackingAndLoadingVehicles, queryWrapperSA);
         });
@@ -744,6 +759,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             stackingUpLog.setAmount(4); // 支数
             stackingUpLog.setLayer(x.getLayer());// 堆垛层号(1-20)
             stackingUpLog.setAddress(x.getAddress());// 堆垛编号(1-9)
+            stackingUpLog.setShift(finalCacheShint1);
+            stackingUpLog.setShiftGroup(finalCacheShintGroup1);
             stackingUpLog.setStackAddr(billetHotsendTypeConfig.getTypeName());
             stackingUpLogList.add(stackingUpLog);
         });
@@ -769,7 +786,6 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             x.setBhtcId(loadingParams.getBilletHotsendTypeConfigId());
         });
         billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
-
     }
 
 

+ 11 - 9
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/controller/StorageBillController.java

@@ -95,24 +95,26 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 	 @PostMapping(value = "/add")
 	 public Result<String> add(@RequestBody StorageBill storageBill) {
 
-		 //
+		 String keyShiftGroup = String.format("class:shift:group:%s", storageBill.getCcmNo());
+		 String keyShift = String.format("class:shift:%s", storageBill.getCcmNo());
+		 String text1 = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroup));
+		 String text2 = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShift));
+
 		 LambdaQueryWrapper<StorageBill> queryWrapper = new LambdaQueryWrapper<>();
 		 queryWrapper.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
-				 	 .eq(StorageBill::getLicensePlate, storageBill.getLicensePlate())
-				     .isNull(StorageBill::getOutTime);
+				 .eq(StorageBill::getLicensePlate, storageBill.getLicensePlate())
+				 .eq(StorageBill::getShiftGroup, text1)
+				 .eq(StorageBill::getShift, text2)
+				 .isNull(StorageBill::getOutTime);
 		 StorageBill isStorageBill = storageBillService.getOne(queryWrapper);
-		 if (oConvertUtils.isNotEmpty(isStorageBill)){
-			 return Result.OK("该车存在未发车车辆,新增钢坯装运单失败!");
+		 if (oConvertUtils.isNotEmpty(isStorageBill)) {
+			 return Result.OK("存在未发车车辆,新增钢坯装运单失败!");
 		 }
 		 storageBill.setCarAllNum(oConvertUtils.listIsEmpty(storageBillService.list()) ? 0 : storageBillService.list().size() + 1);// 车次总序号
 		 storageBill.setDateTime(new Date());// 日期
 		 storageBill.setArrivalTime(new Date());// 到达时间
 		 storageBill.setCarNum(0);
 		 storageBill.setAmountTotal(oConvertUtils.isEmpty(storageBill.getAmountTotal()) ? 0 : storageBill.getAmountTotal());
-		 String keyShiftGroup = String.format("class:shift:group:%s", storageBill.getCcmNo());
-		 String keyShift = String.format("class:shift:%s", storageBill.getCcmNo());
-		 String text1 = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroup));
-		 String text2 = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShift));
 		 storageBill.setShiftGroup(text1);
 		 storageBill.setShift(text2);
 		 storageBillService.save(storageBill);