qiangxuan 6 kuukautta sitten
vanhempi
sitoutus
e24830897d

+ 20 - 27
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/controller/BilletHotsendChangeShiftController.java

@@ -24,7 +24,6 @@ import org.springframework.web.servlet.ModelAndView;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.Arrays;
-import java.util.Calendar;
 import java.util.Date;
 
 /**
@@ -81,37 +80,31 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 	@PostMapping(value = "/add")
 	public Result<String> add(@RequestBody BilletHotsendChangeShift billetHotsendChangeShiftVo) {
 
-		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
-		// 获取当天开始时间 00:00:00
-		Calendar startCalendar = Calendar.getInstance();
-		startCalendar.setTime(new Date());
-		startCalendar.set(Calendar.HOUR_OF_DAY, 0);
-		startCalendar.set(Calendar.MINUTE, 0);
-		startCalendar.set(Calendar.SECOND, 0);
-		Date startOfDay = startCalendar.getTime();
-		// 获取当天结束时间 23:59:59
-		Calendar endCalendar = Calendar.getInstance();
-		endCalendar.setTime(new Date());
-		endCalendar.set(Calendar.HOUR_OF_DAY, 23);
-		endCalendar.set(Calendar.MINUTE, 59);
-		endCalendar.set(Calendar.SECOND, 59);
-		Date endOfDay = endCalendar.getTime();
-		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, billetHotsendChangeShiftVo.getCcmNo())
-				.eq(BilletHotsendChangeShift::getShiftGroup, billetHotsendChangeShiftVo.getShiftGroup())
-				.eq(BilletHotsendChangeShift::getShift, billetHotsendChangeShiftVo.getShift())
-				.between(BilletHotsendChangeShift::getCreateTime, startOfDay, endOfDay);
-		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
-		if (billetHotsendChangeShift != null){
-			return Result.OK("交班记录已存在,请检查班组或班别!");
-		}
-		billetHotsendChangeShiftVo.setCreateTime(new Date());
-		billetHotsendChangeShiftVo.setId(String.valueOf(IdWorker.getId()));
-		billetHotsendChangeShiftService.save(billetHotsendChangeShiftVo);
+		// 生成新的交班记录
 		String keyShiftGroup = String.format("class:shift:group:%s", billetHotsendChangeShiftVo.getCcmNo());
 		String keyShift = String.format("class:shift:%s", billetHotsendChangeShiftVo.getCcmNo());
 		redisTemplate.opsForValue().set(keyShiftGroup, billetHotsendChangeShiftVo.getShiftGroup());
 		redisTemplate.opsForValue().set(keyShift, billetHotsendChangeShiftVo.getShift());
+
+		// 初始化并保存入库
+		BilletHotsendChangeShift billetHotsendChangeShift1 = new BilletHotsendChangeShift();
+		billetHotsendChangeShift1.setId(String.valueOf(IdWorker.getId()));
+		billetHotsendChangeShift1.setCcmNo(billetHotsendChangeShiftVo.getCcmNo());
+		billetHotsendChangeShift1.setShift(billetHotsendChangeShiftVo.getShift());
+		billetHotsendChangeShift1.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
+		billetHotsendChangeShift1.setHotfeignAmount(0);// 当前热装支数
+		billetHotsendChangeShift1.setProductAmount(0);//当前生产支数
+		billetHotsendChangeShift1.setHotsendAmount(0);// 当前热送支数
+		billetHotsendChangeShift1.setStackAmount(0);//当前起垛支数
+		billetHotsendChangeShift1.setOutCarNum(0);//车次
+		billetHotsendChangeShift1.setShiftSum(0);//当班总数
+		billetHotsendChangeShift1.setShiftProduct(0d); // 当班总重
+		billetHotsendChangeShift1.setWasteAmount(0);// 当前废品支数
+		billetHotsendChangeShift1.setCreateTime(new Date());
+		billetHotsendChangeShiftService.save(billetHotsendChangeShift1);
+
 		operateLogService.add(billetHotsendChangeShiftVo,null, BilletHotsendChangeShift.class);
+
 		return Result.OK("交班成功!");
 	}
 	

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

@@ -91,7 +91,7 @@ public class BilletHotsendChangeShift implements Serializable {
 	/**当班总重*/
 	@Excel(name = "当班总重", width = 15)
     @ApiModelProperty(value = "当班总重")
-    private Integer shiftProduct;
+    private Double shiftProduct;
 	/**当班总数*/
 	@Excel(name = "当班总数", width = 15)
     @ApiModelProperty(value = "当班总数")

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

@@ -545,6 +545,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollClubTwoDetails.setLicensePlate(loadingParams.getStorageBill().getLicensePlate());
                 rollClubTwoDetails.setCreateTime(new Date());
                 rollClubTwoDetails.setUpdateTime(new Date());
+                rollClubTwoDetails.setId(String.valueOf(IdWorker.getId()));
                 addRollClubTwoDetailsList.add(rollClubTwoDetails);
             }else if ("roll_club_three".equals(loadingParams.getDestinationTable())){
                 RollClubThreeDetails rollClubThreeDetails = new RollClubThreeDetails();
@@ -556,6 +557,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollClubThreeDetails.setLicensePlate(loadingParams.getStorageBill().getLicensePlate());
                 rollClubThreeDetails.setCreateTime(new Date());
                 rollClubThreeDetails.setUpdateTime(new Date());
+                rollClubThreeDetails.setId(String.valueOf(IdWorker.getId()));
                 addRollClubThreeDetailsList.add(rollClubThreeDetails);
             }else if ("roll_out_shipp".equals(loadingParams.getDestinationTable())){
                 RollOutShippDetails rollOutShippDetails = new RollOutShippDetails();
@@ -565,6 +567,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollOutShippDetails.setStackStorey(x.getLayer());
                 rollOutShippDetails.setStackNum(x.getAddress());
                 rollOutShippDetails.setLicensePlate(loadingParams.getStorageBill().getLicensePlate());
+                rollOutShippDetails.setId(String.valueOf(IdWorker.getId()));
                 rollOutShippDetails.setCreateTime(new Date());
                 rollOutShippDetails.setUpdateTime(new Date());
                 addRollOutShippDetailsList.add(rollOutShippDetails);
@@ -678,6 +681,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollClubTwoDetails.setStackStorey(x.getLayer());
                 rollClubTwoDetails.setStackNum(x.getAddress());
                 rollClubTwoDetails.setLicensePlate(storageBill.getLicensePlate());
+                rollClubTwoDetails.setId(String.valueOf(IdWorker.getId()));
                 rollClubTwoDetails.setCreateTime(new Date());
                 rollClubTwoDetails.setUpdateTime(new Date());
                 addRollClubTwoDetailsList.add(rollClubTwoDetails);
@@ -691,6 +695,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollClubThreeDetails.setLicensePlate(storageBill.getLicensePlate());
                 rollClubThreeDetails.setCreateTime(new Date());
                 rollClubThreeDetails.setUpdateTime(new Date());
+                rollClubThreeDetails.setId(String.valueOf(IdWorker.getId()));
                 addRollClubThreeDetailsList.add(rollClubThreeDetails);
             }else if ("roll_out_shipp".equals(loadingParams.getDestinationTable())){
                 RollOutShippDetails rollOutShippDetails = new RollOutShippDetails();
@@ -702,6 +707,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollOutShippDetails.setLicensePlate(storageBill.getLicensePlate());
                 rollOutShippDetails.setCreateTime(new Date());
                 rollOutShippDetails.setUpdateTime(new Date());
+                rollOutShippDetails.setId(String.valueOf(IdWorker.getId()));
                 addRollOutShippDetailsList.add(rollOutShippDetails);
             }
         });

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

@@ -106,56 +106,62 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 	 @ApiOperation(value="钢坯装运单-添加", notes="钢坯装运单-添加")
 	 @PostMapping(value = "/add")
 	 public Result<String> add(@RequestBody StorageBill storageBill) {
+		 try {
+			 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));
 
-		 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())
+					 .eq(StorageBill::getShiftGroup, text1)
+					 .eq(StorageBill::getShift, text2)
+					 .isNull(StorageBill::getOutTime);
+			 StorageBill isStorageBill = storageBillService.getOne(queryWrapper);
+			 if (oConvertUtils.isNotEmpty(isStorageBill)) {
+				 log.info("查询到存在未发车车辆,车牌号为:{},新增钢坯装运单失败!", storageBill.getLicensePlate());
+				 return Result.OK("存在未发车车辆,新增钢坯装运单失败!");
+			 }
+			 storageBill.setCarAllNum(oConvertUtils.listIsEmpty(storageBillService.list()) ? 0 : storageBillService.list().size() + 1);// 车次总序号
+			 storageBill.setArrivalTime(new Date());// 到达时间
 
-		 LambdaQueryWrapper<StorageBill> queryWrapper = new LambdaQueryWrapper<>();
-		 queryWrapper.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
-				 .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("存在未发车车辆,新增钢坯装运单失败!");
-		 }
-		 storageBill.setCarAllNum(oConvertUtils.listIsEmpty(storageBillService.list()) ? 0 : storageBillService.list().size() + 1);// 车次总序号
-		 storageBill.setArrivalTime(new Date());// 到达时间
-
-		 LambdaQueryWrapper<StorageBill> queryWrapper1 = new LambdaQueryWrapper<>();
-		 queryWrapper1.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
-				 .eq(StorageBill::getLicensePlate, storageBill.getLicensePlate())
-				 .eq(StorageBill::getShiftGroup, text1)
-				 .eq(StorageBill::getShift, text2).between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
+			 LambdaQueryWrapper<StorageBill> queryWrapper1 = new LambdaQueryWrapper<>();
+			 queryWrapper1.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
+					 .eq(StorageBill::getLicensePlate, storageBill.getLicensePlate())
+					 .eq(StorageBill::getShiftGroup, text1)
+					 .eq(StorageBill::getShift, text2).between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
 
-		 LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
-		 queryWrapper2.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
-				 .eq(StorageBill::getShiftGroup, text1)
-				 .eq(StorageBill::getShift, text2).between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
-		 List<StorageBill> storageBillList = storageBillService.list(queryWrapper1);
-		 storageBill.setCarNum(storageBillList.size() + 1);
-		 storageBill.setCarAllNum(storageBillService.list(queryWrapper2).size() + 1);
+			 LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
+			 queryWrapper2.eq(StorageBill::getCcmNo, storageBill.getCcmNo())
+					 .eq(StorageBill::getShiftGroup, text1)
+					 .eq(StorageBill::getShift, text2).between(StorageBill::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
+			 List<StorageBill> storageBillList = storageBillService.list(queryWrapper1);
+			 storageBill.setCarNum(storageBillList.size() + 1);
+			 storageBill.setCarAllNum(storageBillService.list(queryWrapper2).size() + 1);
 
-		 // 通过铸机号、班组、班别去查询交班记录并初始化 车次
-		 LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper3 = new LambdaQueryWrapper<>();
-		 queryWrapper3.eq(BilletHotsendChangeShift::getCcmNo, storageBill.getCcmNo())
-				 .eq(BilletHotsendChangeShift::getShiftGroup, text1)
-				 .eq(BilletHotsendChangeShift::getShift, text2).between(BilletHotsendChangeShift::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
-		 BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper3);
-		 if (oConvertUtils.isNotEmpty(billetHotsendChangeShift)){
-			 billetHotsendChangeShift.setOutCarNum(billetHotsendChangeShift.getOutCarNum() + 1);
-			 billetHotsendChangeShift.setUpdateTime(new Date());
-			 billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
+			 // 通过铸机号、班组、班别去查询交班记录并初始化 车次
+			 LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper3 = new LambdaQueryWrapper<>();
+			 queryWrapper3.eq(BilletHotsendChangeShift::getCcmNo, storageBill.getCcmNo())
+					 .eq(BilletHotsendChangeShift::getShiftGroup, text1)
+					 .eq(BilletHotsendChangeShift::getShift, text2).between(BilletHotsendChangeShift::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
+			 BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper3);
+			 if (oConvertUtils.isNotEmpty(billetHotsendChangeShift)){
+				 billetHotsendChangeShift.setOutCarNum(billetHotsendChangeShift.getOutCarNum() + 1);
+				 billetHotsendChangeShift.setUpdateTime(new Date());
+				 billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
+			 }
+			 storageBill.setAmountTotal(0);
+			 storageBill.setShiftGroup(text1);
+			 storageBill.setShift(text2);
+			 storageBillService.save(storageBill);
+			 operateLogService.add(storageBill,null,StorageBill.class);
+			 return Result.OK("钢坯装运单添加成功!");
+		 } catch (Exception e) {
+			 // 记录异常日志
+			 log.error("添加钢坯装运单时发生异常", e);
+			 return Result.error("系统错误,请稍后再试!");
 		 }
-		 storageBill.setAmountTotal(0);
-		 storageBill.setShiftGroup(text1);
-		 storageBill.setShift(text2);
-		 storageBillService.save(storageBill);
-		 operateLogService.add(storageBill,null,StorageBill.class);
-		 return Result.OK("添加成功!");
 	 }
 	
 	/**