qiangxuan 2 semanas atrás
pai
commit
b0e82a48d6

+ 32 - 18
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetOriginalProductRecord/controller/BilletOriginalProductRecordController.java

@@ -3,7 +3,6 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -32,7 +31,6 @@ import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsend;
 import org.jeecg.modules.billet.billetHotsend.service.IBilletHotsendBaseService;
 import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
 import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
-import org.jeecg.modules.billet.billetHotsendConfig.entity.BilletHotsendTypeConfig;
 import org.jeecg.modules.billet.billetOriginalProductRecord.dto.LengthCountQueryDTO;
 import org.jeecg.modules.billet.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
 import org.jeecg.modules.billet.billetOriginalProductRecord.service.IBilletOriginalProductRecordService;
@@ -336,7 +334,6 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 						 positionLog.append(p.getLayer()).append(".").append(p.getAddress()).append(" → "));
 				 log.info(positionLog.substring(0, positionLog.length() - 4)); // 移除最后的" → "
 			 }
-
 			 if (availablePositions.isEmpty()) {
 				 log.info("无法计算出可用位置,起垛失败!heatNo={}", heatNo);
 				 return;
@@ -425,20 +422,32 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 	 public Result<String> addStorageBillHandle(@RequestParam(name="ccmNo",required = false) String ccmNo,
 												@RequestParam(name="positionNum",required = true) Integer positionNum,
 												@RequestParam(name="licensePlate",required = true) String licensePlate) {
+		 // 参数验证
+		 if (positionNum == 2 && StringUtils.isEmpty(ccmNo)) {
+			 return Result.error("车位2铸机号不能为空!");
+		 }
+
 		 StorageBill storageBill = new StorageBill();
 		 storageBill.setId(String.valueOf(IdWorker.getId()));
-		 storageBill.setPositionNum(positionNum);
-		 storageBill.setLicensePlate(licensePlate);
-	 	 if (positionNum == 1){
-			  storageBill.setCcmNo("5");
-		 }else if (positionNum == 2){
-			  storageBill.setCcmNo(ccmNo);
-		 }else if (positionNum == 3 || positionNum == 4){
-			  storageBill.setCcmNo("6");
+		 // 确定最终的ccmNo
+		 String finalCcmNo;
+		 if (positionNum == 1) {
+			 finalCcmNo = "5";
+		 } else if (positionNum == 2) {
+			 finalCcmNo = ccmNo;
+		 } else if (positionNum == 3 || positionNum == 4) {
+			 finalCcmNo = "6";
+		 } else {
+			 return Result.error("无效的车位号!");
 		 }
+		 storageBill.setCcmNo(finalCcmNo);
 		 // 从 Redis 获取班次信息
 		 String shiftGroup = getShiftInfo(storageBill.getCcmNo(), "class:shift:group:%s");
 		 String shift = getShiftInfo(storageBill.getCcmNo(), "class:shift:%s");
+		 // 空值检查
+		 if (shiftGroup == null || shift == null) {
+			 return Result.error("班组、班别不存在,创建失败!");
+		 }
 		 // 判断车牌号是否存在未发车的装运单信息
 		 LambdaQueryWrapper<StorageBill> queryWrapper = new LambdaQueryWrapper<>();
 		 queryWrapper.eq(StorageBill::getLicensePlate, licensePlate)
@@ -448,20 +457,20 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		 StorageBill isStorageBill = storageBillService.getOne(queryWrapper);
 		 if (oConvertUtils.isNotEmpty(isStorageBill)) {
 			 log.info("推钢室查询到存在未发车车辆,车牌号为:{},新增钢坯装运单失败!", storageBill.getLicensePlate());
-			 return Result.error("该车存在未发车信息,操作失败!");
+			 return Result.error("该车存在未发车信息,创建失败!");
 		 }
 		 // 判断车位是否存在未发车车辆(2025/3.3,半自动化逻辑,等自动化发车车位发车完善后,在添加此段逻辑)
 		 List<StorageBill> storageBillList = storageBillService.list(new LambdaQueryWrapper<StorageBill>()
-				 .eq(StorageBill::getPositionNum, storageBill.getPositionNum())
+				 .eq(StorageBill::getPositionNum, positionNum)
 				 .isNull(StorageBill::getOutTime));
 		 if (oConvertUtils.listIsNotEmpty(storageBillList)){
 			 log.info("{}{}", "推钢室该车位存在未发车信息,新增钢坯装运单失败!", JSON.toJSON(storageBillList));
-			 return Result.error("该车位存在未发车信息,操作失败!");
+			 return Result.error("该车位存在未发车信息,创建失败!");
 		 }
 
 		 // 根据铸机号、班组、班别,创建时间倒序 只返回一条,查询储运配置信息
 		 LambdaQueryWrapper<ShiftConfiguration> queryWrapper1 = new LambdaQueryWrapper<>();
-		 queryWrapper1.eq(ShiftConfiguration::getCcmNo, ccmNo)
+		 queryWrapper1.eq(ShiftConfiguration::getCcmNo, storageBill.getCcmNo())
 				 .eq(ShiftConfiguration::getShiftGroup, shiftGroup)
 				 .eq(ShiftConfiguration::getShift, shift)
 				 .orderByDesc(ShiftConfiguration::getCreateTime)
@@ -479,7 +488,8 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		 storageBill.setArrivalTime(new Date());// 到达时间
 		 // 更新交班记录 通过铸机号、班组、班别去查询交班记录并初始化 出车号
 		 updateBilletHotsendChangeShift(storageBill.getCcmNo(), shiftGroup, shift);
-
+		 storageBill.setPositionNum(positionNum);
+		 storageBill.setLicensePlate(licensePlate);
 		 storageBill.setAmountTotal(0);
 		 storageBill.setPanelAmountTotal(0);
 		 storageBill.setShiftGroup(shiftGroup);
@@ -492,7 +502,7 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		 storageBill.setBtype("0");
 		 storageBillService.save(storageBill);
 
-		 return Result.OK("操作成功!");
+		 return Result.OK("创建成功!");
 	 }
 	
 	/**
@@ -600,6 +610,10 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		 }else {
 			 billetHotsendChangeShift = billetHotsendChangeShiftService.getById(changeShiftId);
 		 }
+		 if (billetHotsendChangeShift == null) {
+			 log.error("未查询到有效的交班记录,无法继续处理");
+			 return Result.error("未找到对应的交班信息,原始生产记录获取失败!");
+		 }
 		 //1、 获取当班浇筑炉次详细信息
 		 List<HeatsActualsInfo> heatsActualsInfoList = queryCurrentHeatsActualsInfo(ccmNo, billetHotsendChangeShift.getShift(), billetHotsendChangeShift.getShiftGroup(), billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime(), queryType);
 		 log.info("原始生产记录,当班浇筑炉次数据信息: " + JSON.toJSON(heatsActualsInfoList));
@@ -2352,7 +2366,7 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 				 .last("limit 1");
 		 BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
 		 if (oConvertUtils.isEmpty(billetHotsendChangeShift)) {
-			 log.info("手动创建装运单交班记录不存在,车次数维护失败:{}", ccmNo+shiftGroup+shift);
+			 log.info("推钢室界面创建装运单交班记录不存在,车次数维护失败:{}", ccmNo+shiftGroup+shift);
 			 return;
 		 }
 		 billetHotsendChangeShift.setOutCarNum(billetHotsendChangeShift.getOutCarNum() + 1);