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

装运单发车逻辑优化

qiangxuan 2 сар өмнө
parent
commit
f102945c5b

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

@@ -267,24 +267,41 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 	@ApiOperation(value="钢坯装运单-发车", notes="钢坯装运单-发车")
 	@PostMapping(value = "/startCar")
 	public Result<String> startCar(@RequestBody StorageBill storageBill) {
+
+		// 检查 storageBill 是否为 null
+		if (storageBill == null || storageBill.getId() == null) {
+			return Result.OK("传入的装运单信息为空,发车失败!");
+		}
+
+		// 获取装运单信息
 		StorageBill isStorageBill = storageBillService.getById(storageBill.getId());
+		if (isStorageBill == null) {
+			return Result.OK("未找到对应的装运单信息,发车失败!");
+		}
+
+		// 检查是否已发车
 		if (oConvertUtils.isNotEmpty(isStorageBill.getOutTime())) {
 			return Result.OK("该车已发车,请勿重复发车!");
 		}
+
+		// 检查车牌是否一致
 		if (!storageBill.getLicensePlate().equals(isStorageBill.getLicensePlate())) {
 			return Result.OK("车牌不一致,发车失败!");
 		}
-		storageBill.setOutTime(new Date());
-		storageBill.setUpdateTime(new Date());
+
+		// 设置发车时间和更新时间
+		isStorageBill.setOutTime(new Date());
+		isStorageBill.setUpdateTime(new Date());
+
 		// 判断装运单,是否有装运信息,装运总支数为0时,手动发车失败
-		if (storageBill.getAmountTotal() == 0 || isStorageBill.getAmountTotal() == null) {
-			log.info("{}{}","钢坯装运信息为空!", JSON.toJSON(isStorageBill));
-			storageBillService.updateById(storageBill);
+		if (isStorageBill.getAmountTotal() == null || isStorageBill.getAmountTotal() == 0) {
+			log.info("钢坯装运信息为空!{}", JSON.toJSON(isStorageBill));
+			storageBillService.updateById(isStorageBill);
 			return Result.OK("钢坯装运单-发车成功!");
 		}
-		storageBillService.updateById(storageBill);
+
 		// 添加编辑日志
-		operateLogService.add(isStorageBill,storageBill,StorageBill.class);
+		operateLogService.add(isStorageBill, storageBill, StorageBill.class);
 		// 7 发车后,新增钢坯堆垛储运信息,生成储运单 storage_car_log
 		StorageCarLog storageCarLog = new StorageCarLog();
 		BeanUtils.copyProperties(storageBill, storageCarLog);