소스 검색

炉号变更04

qiangxuan 2 일 전
부모
커밋
09584ce691

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

@@ -2113,7 +2113,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 					commonBilletRollClubTwoHandle(rollClubTwoList, changeHeatVo, shift, shiftGroup);
 				}
 				List<BilletBasicInfo> rollClubThreeList = originalBilletBasicInfoLists.stream()
-						.filter(item -> "roll_club_three".equals(item.getBelongTable())) // 筛选 belong_table 等于 "roll_club_one" 的记录
+						.filter(item -> "roll_club_three".equals(item.getBelongTable())) // 筛选 belong_table 等于 "roll_club_three" 的记录
 						.collect(Collectors.toList());
 				if (rollClubThreeList.size() > 0){
 					//公共方法  处理钢坯实绩、炉次实绩、炉次传递单
@@ -2122,7 +2122,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 					commonBilletRollClubThreeHandle(rollClubThreeList, changeHeatVo, shift, shiftGroup);
 				}
 				List<BilletBasicInfo> rollOutShippList = originalBilletBasicInfoLists.stream()
-						.filter(item -> "roll_out_shipp".equals(item.getBelongTable())) // 筛选 belong_table 等于 "roll_club_one" 的记录
+						.filter(item -> "roll_out_shipp".equals(item.getBelongTable())) // 筛选 belong_table 等于 "roll_out_shipp" 的记录
 						.collect(Collectors.toList());
 				if (rollOutShippList.size() > 0){
 					//公共方法  处理钢坯实绩、炉次实绩、炉次传递单
@@ -2131,7 +2131,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 					commonBilletRollOutShippHandle(rollOutShippList, changeHeatVo, shift, shiftGroup);
 				}
 				List<BilletBasicInfo> rollDeputyCrossList = originalBilletBasicInfoLists.stream()
-						.filter(item -> "roll_deputy_cross".equals(item.getBelongTable())) // 筛选 belong_table 等于 "roll_club_one" 的记录
+						.filter(item -> "roll_deputy_cross".equals(item.getBelongTable())) // 筛选 belong_table 等于 "roll_deputy_cross" 的记录
 						.collect(Collectors.toList());
 				if (rollDeputyCrossList.size() > 0){
 					//公共方法  处理钢坯实绩、炉次实绩、炉次传递单
@@ -2140,7 +2140,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 					commonBilletRollDeputyCrossHandle(rollDeputyCrossList, changeHeatVo, shift, shiftGroup);
 				}
 				List<BilletBasicInfo> stackingList = originalBilletBasicInfoLists.stream()
-						.filter(item -> "stacking_and_loading_vehicles".equals(item.getBelongTable())) // 筛选 belong_table 等于 "roll_club_one" 的记录
+						.filter(item -> "stacking_and_loading_vehicles".equals(item.getBelongTable())) // 筛选 belong_table 等于 "stacking_and_loading_vehicles" 的记录
 						.collect(Collectors.toList());
 				if (stackingList.size() > 0){
 					//公共方法  处理钢坯实绩、炉次实绩、炉次传递单
@@ -2172,10 +2172,18 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		if (originalRollClubOne == null) {
 			throw new RuntimeException("原棒一主表为空,操作失败!");
 		}
-		originalRollClubOne.setAmountTotal(originalRollClubOne.getAmountTotal() - changeHeatVo.getNumber());
-		originalRollClubOne.setBlankOutput(originalRollClubOne.getBlankOutput() - changeTotalWeight);
-		rollClubOneService.updateById(originalRollClubOne);
+		// 获取当前值
+		Integer currentAmount = originalRollClubOne.getAmountTotal();
+		Double currentOutput = originalRollClubOne.getBlankOutput();
+
+		// 计算新值(确保不小于 0)
+		int newAmount = Math.max(0, currentAmount - changeHeatVo.getNumber());
+		double newOutput = Math.max(0, currentOutput - changeTotalWeight);
 
+		// 设置新值并更新
+		originalRollClubOne.setAmountTotal(newAmount);
+		originalRollClubOne.setBlankOutput(newOutput);
+		rollClubOneService.updateById(originalRollClubOne);
 		RollClubOne changeRollClubOne = getRollClubOne(changeHeatVo.getChangeHeatNo(), changeHeatVo.getCcmNo(), shift, shiftGroup);
 		if (changeRollClubOne == null) {
 			throw new RuntimeException("变更棒一主表为空,操作失败!");
@@ -2216,8 +2224,17 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		if (originalRollClubTwo == null) {
 			throw new RuntimeException("原棒二主表为空,操作失败!");
 		}
-		originalRollClubTwo.setAmountTotal(originalRollClubTwo.getAmountTotal() - changeHeatVo.getNumber());
-		originalRollClubTwo.setBlankOutput(originalRollClubTwo.getBlankOutput() - changeTotalWeight);
+		// 获取当前值
+		Integer currentAmount = originalRollClubTwo.getAmountTotal();
+		Double currentOutput = originalRollClubTwo.getBlankOutput();
+
+		// 计算新值(确保不小于 0)
+		int newAmount = Math.max(0, currentAmount - changeHeatVo.getNumber());
+		double newOutput = Math.max(0, currentOutput - changeTotalWeight);
+
+		// 设置新值并更新
+		originalRollClubTwo.setAmountTotal(newAmount);
+		originalRollClubTwo.setBlankOutput(newOutput);
 		rollClubTwoService.updateById(originalRollClubTwo);
 
 		RollClubTwo changeRollClubTwo = getRollClubTwo(changeHeatVo.getChangeHeatNo(), changeHeatVo.getCcmNo(), shift, shiftGroup);
@@ -2258,8 +2275,17 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		if (originalRollClubThree == null) {
 			throw new RuntimeException("原棒三主表为空,操作失败!");
 		}
-		originalRollClubThree.setAmountTotal(originalRollClubThree.getAmountTotal() - changeHeatVo.getNumber());
-		originalRollClubThree.setBlankOutput(originalRollClubThree.getBlankOutput() - changeTotalWeight);
+		// 获取当前值
+		Integer currentAmount = originalRollClubThree.getAmountTotal();
+		Double currentOutput = originalRollClubThree.getBlankOutput();
+
+		// 计算新值(确保不小于 0)
+		int newAmount = Math.max(0, currentAmount - changeHeatVo.getNumber());
+		double newOutput = Math.max(0, currentOutput - changeTotalWeight);
+
+		// 设置新值并更新
+		originalRollClubThree.setAmountTotal(newAmount);
+		originalRollClubThree.setBlankOutput(newOutput);
 		rollClubThreeService.updateById(originalRollClubThree);
 
 		RollClubThree changeRollClubThree = getRollClubThree(changeHeatVo.getChangeHeatNo(), changeHeatVo.getCcmNo(), shift, shiftGroup);
@@ -2299,8 +2325,17 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		if (originalRollOutShipp == null) {
 			throw new RuntimeException("原上若主表为空,操作失败!");
 		}
-		originalRollOutShipp.setAmountTotal(originalRollOutShipp.getAmountTotal() - changeHeatVo.getNumber());
-		originalRollOutShipp.setBlankOutput(originalRollOutShipp.getBlankOutput() - changeTotalWeight);
+		// 获取当前值
+		Integer currentAmount = originalRollOutShipp.getAmountTotal();
+		Double currentOutput = originalRollOutShipp.getBlankOutput();
+
+		// 计算新值(确保不小于 0)
+		int newAmount = Math.max(0, currentAmount - changeHeatVo.getNumber());
+		double newOutput = Math.max(0, currentOutput - changeTotalWeight);
+
+		// 设置新值并更新
+		originalRollOutShipp.setAmountTotal(newAmount);
+		originalRollOutShipp.setBlankOutput(newOutput);
 		rollOutShippService.updateById(originalRollOutShipp);
 
 		RollOutShipp changeRollOutShipp = getRollOutShipp(changeHeatVo.getChangeHeatNo(), changeHeatVo.getCcmNo(), shift, shiftGroup);
@@ -2341,8 +2376,17 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		if (originalRollDeputyCross == null) {
 			throw new RuntimeException("原付跨主表为空,操作失败!");
 		}
-		originalRollDeputyCross.setAmountTotal(originalRollDeputyCross.getAmountTotal() - changeHeatVo.getNumber());
-		originalRollDeputyCross.setBlankOutput(originalRollDeputyCross.getBlankOutput() - changeTotalWeight);
+		// 获取当前值
+		Integer currentAmount = originalRollDeputyCross.getAmountTotal();
+		Double currentOutput = originalRollDeputyCross.getBlankOutput();
+
+		// 计算新值(确保不小于 0)
+		int newAmount = Math.max(0, currentAmount - changeHeatVo.getNumber());
+		double newOutput = Math.max(0, currentOutput - changeTotalWeight);
+
+		// 设置新值并更新
+		originalRollDeputyCross.setAmountTotal(newAmount);
+		originalRollDeputyCross.setBlankOutput(newOutput);
 		rollDeputyCrossService.updateById(originalRollDeputyCross);
 
 		RollDeputyCross changeRollDeputyCross = getRollDeputyCross(changeHeatVo.getChangeHeatNo(), changeHeatVo.getCcmNo(), shift, shiftGroup);
@@ -2393,7 +2437,8 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			queryWrapper.eq(StackingAndLoadingVehicles::getCcmNo, changeHeatVo.getCcmNo());
 			queryWrapper.eq(StackingAndLoadingVehicles::getShift, shift);
 			queryWrapper.eq(StackingAndLoadingVehicles::getShiftGroup, shiftGroup);
-			queryWrapper.like(StackingAndLoadingVehicles::getBilletNos, x).last("limit 1");
+			queryWrapper.apply("FIND_IN_SET({0}, billet_nos) > 0", x);
+			queryWrapper.last("LIMIT 1");
 			StackingAndLoadingVehicles stackingAndLoadingVehicles = stackingAndLoadingVehiclesMapper.selectOne(queryWrapper);
 			if (stackingAndLoadingVehicles != null){
 				stackingAndLoadingVehicles.setHeatNo(changeHeatVo.getChangeHeatNo());
@@ -2428,11 +2473,17 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		if (originalHeatsActuals == null) {
 			throw new RuntimeException("原炉次实绩为空,操作失败!");
 		}
-		// 更新炉次实绩数量和对应的重量
-		if (originalHeatsActuals.getBilletSum() != 0){
-			originalHeatsActuals.setBilletSum(originalHeatsActuals.getBilletSum() - changeHeatVo.getNumber());
-		}
-		originalHeatsActuals.setBlankOutput(originalHeatsActuals.getBlankOutput() - changeTotalWeight);
+		// 获取当前值  更新炉次实绩数量和对应的重量
+		Integer currentBilletSum = originalHeatsActuals.getBilletSum();
+		Double currentOutput = originalHeatsActuals.getBlankOutput();
+
+		// 计算新值(确保不小于 0)
+		int newBilletSum = (currentBilletSum != 0) ? Math.max(0, currentBilletSum - changeHeatVo.getNumber()) : 0;
+		double newOutput = Math.max(0, currentOutput - changeTotalWeight);
+
+		// 设置新值并更新
+		originalHeatsActuals.setBilletSum(newBilletSum);
+		originalHeatsActuals.setBlankOutput(newOutput);
 		heatsActualsService.updateById(originalHeatsActuals);
 
 		// 变更炉次实绩处理 处理变更炉次实绩(增加钢坯)
@@ -2452,21 +2503,44 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		if (originalBilletHotsend == null){
 			throw new RuntimeException("原炉次传递单为空,操作失败!");
 		}
-		if (type == 1){
-			originalBilletHotsend.setRollcluboneNum(originalBilletHotsend.getRollcluboneNum() - changeHeatVo.getNumber());
-		}else if (type == 2){
-			originalBilletHotsend.setRollclubtwoNum(originalBilletHotsend.getRollclubtwoNum() - changeHeatVo.getNumber());
-		}else if (type == 3){
-			originalBilletHotsend.setRollclubthreeNum(originalBilletHotsend.getRollclubthreeNum() - changeHeatVo.getNumber());
-		}else if (type == 4){
-			originalBilletHotsend.setRolloutshippNum(originalBilletHotsend.getRolloutshippNum() - changeHeatVo.getNumber());
-		}else if (type == 5){
-			originalBilletHotsend.setRollDeputyCrossNum(originalBilletHotsend.getRollDeputyCrossNum() - changeHeatVo.getNumber());
-		}else if (type == 6){
-			originalBilletHotsend.setStackNum(originalBilletHotsend.getStackNum() - changeHeatVo.getNumber() / 4);
-		}
-		originalBilletHotsend.setAmountTotal(originalBilletHotsend.getAmountTotal() - changeHeatVo.getNumber());
-		originalBilletHotsend.setBlankOutput(originalBilletHotsend.getBlankOutput() - changeTotalWeight);
+		// 根据不同类型更新相应字段,确保不出现负数
+		if (type == 1) {
+			Integer currentNum = originalBilletHotsend.getRollcluboneNum();
+			int newNum = Math.max(0, currentNum - changeHeatVo.getNumber());
+			originalBilletHotsend.setRollcluboneNum(newNum);
+		} else if (type == 2) {
+			Integer currentNum = originalBilletHotsend.getRollclubtwoNum();
+			int newNum = Math.max(0, currentNum - changeHeatVo.getNumber());
+			originalBilletHotsend.setRollclubtwoNum(newNum);
+		} else if (type == 3) {
+			Integer currentNum = originalBilletHotsend.getRollclubthreeNum();
+			int newNum = Math.max(0, currentNum - changeHeatVo.getNumber());
+			originalBilletHotsend.setRollclubthreeNum(newNum);
+		} else if (type == 4) {
+			Integer currentNum = originalBilletHotsend.getRolloutshippNum();
+			int newNum = Math.max(0, currentNum - changeHeatVo.getNumber());
+			originalBilletHotsend.setRolloutshippNum(newNum);
+		} else if (type == 5) {
+			Integer currentNum = originalBilletHotsend.getRollDeputyCrossNum();
+			int newNum = Math.max(0, currentNum - changeHeatVo.getNumber());
+			originalBilletHotsend.setRollDeputyCrossNum(newNum);
+		} else if (type == 6) {
+			Integer currentNum = originalBilletHotsend.getStackNum();
+			// 注意:这里除以4,如果changeHeatVo.getNumber()不是4的倍数,可能需要特殊处理
+			int newNum = Math.max(0, currentNum - changeHeatVo.getNumber() / 4);
+			originalBilletHotsend.setStackNum(newNum);
+		}
+		// 获取当前值
+		Integer currentAmount1 = originalBilletHotsend.getAmountTotal();
+		Double currentOutput1 = originalBilletHotsend.getBlankOutput();
+
+		// 计算新值(确保不小于 0)
+		int newAmount1 = Math.max(0, currentAmount1 - changeHeatVo.getNumber());
+		double newOutput1 = Math.max(0, currentOutput1 - changeTotalWeight);
+
+		//炉次传递单 设置新值并更新
+		originalBilletHotsend.setAmountTotal(newAmount1);
+		originalBilletHotsend.setBlankOutput(newOutput1);
 		baseMapper.updateById(originalBilletHotsend);
 
 		// 变更的炉次传递单,增加数量和重量