Ver código fonte

手动交班逻辑调整

qiangxuan 5 dias atrás
pai
commit
60e9ed253e

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

@@ -156,26 +156,9 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 	@RequiresPermissions("billetHotsendChangeShift:billet_hotsend_change_shift:add")
 	@PostMapping(value = "/add")
 	public Result<String> add(@RequestBody BilletHotsendChangeShift billetHotsendChangeShiftVo) {
-		// 通过铸机号查询最新的一条记录
-//		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapperCS = new LambdaQueryWrapper<>();
-//		queryWrapperCS.eq(BilletHotsendChangeShift::getCcmNo, billetHotsendChangeShiftVo.getCcmNo())
-//				.isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
-//				.orderByDesc(BilletHotsendChangeShift::getCreateTime)
-//				.last("limit 1");
-//		BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapperCS, false);
-//		if (billetHotsendChangeShift.getShift().equals(billetHotsendChangeShiftVo.getShift()) && billetHotsendChangeShift.getShiftGroup().equals(billetHotsendChangeShiftVo.getShiftGroup())){
-//			return Result.error("该班别已交班,请勿重复交班!");
-//		}
-//
-//		// B端手动交班下发mqtt
-//		if ("5".equals(billetHotsendChangeShiftVo.getCcmNo())){
-//			billetHotsendChangeShiftService.fiveChangeShiftHandle(billetHotsendChangeShiftVo);
-//		}else if ("6".equals(billetHotsendChangeShiftVo.getCcmNo())){
-//			billetHotsendChangeShiftService.sixChangeShiftHandle(billetHotsendChangeShiftVo);
-//		}
 		JSONObject jsonObject = billetHotsendChangeShiftService.billetHotsendChangeShiftHandle(billetHotsendChangeShiftVo);
 		if (jsonObject.containsKey("fail")){
-			return Result.OK((String) jsonObject.get("fail"));
+			return Result.error((String) jsonObject.get("fail"));
 		}
 		return Result.OK("交班成功!");
 	}

+ 7 - 39
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/service/impl/BilletHotsendChangeShiftServiceImpl.java

@@ -14,12 +14,10 @@ import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendCha
 import org.jeecg.modules.billet.billetHotsendChangeShift.mapper.BilletHotsendChangeShiftMapper;
 import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
 import org.jeecg.modules.billet.billetHotsendChangeShift.util.ScheduleUtils;
-import org.jeecg.modules.billet.billetHotsendChangeShift.util.ShiftInfo;
 import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
 import org.jeecg.modules.billet.shiftConfiguration.entity.ShiftConfiguration;
 import org.jeecg.modules.billet.shiftConfiguration.service.IShiftConfigurationService;
 import org.jeecg.modules.billet.storageBill.entity.ShiftEnum;
-import org.jeecg.modules.billet.storageBill.entity.ShiftGroupEnum;
 import org.jeecg.modules.connConfig.mapper.ConfigMqttMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -76,7 +74,6 @@ public class BilletHotsendChangeShiftServiceImpl extends ServiceImpl<BilletHotse
             return result;
         }
 
-        String nextshiftIdKey = String.format("class:nextshift:Id:%s", ccmNo);
         String keyShiftGroup = String.format("class:shift:group:%s", ccmNo);
         String keyShift = String.format("class:shift:%s", ccmNo);
 
@@ -91,54 +88,27 @@ public class BilletHotsendChangeShiftServiceImpl extends ServiceImpl<BilletHotse
         String currentShiftGroup = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroup));
         String currentShift = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShift));
 
-        String currentShiftGroupName = ShiftGroupEnum.fromCode(currentShiftGroup).name();
-        String currentShiftName = ShiftEnum.fromCode(currentShift).name().replace("班", "");
-
-        String currentShiftIdKey = String.format("class:nextshift:Id:%s", ccmNo);
-        String currentCacheId = oConvertUtils.getString(redisTemplate.opsForValue().get(currentShiftIdKey));
-
         log.info(DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()) + " 交班当前班次信息值:" + currentShift+ ","+ currentShiftGroup);
-        log.info(DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()) + " 交班当前班次信息名:" + currentCacheId + "," + currentShiftName+ ","+ currentShiftGroupName);
-
-        String[] data = {
-                "1 丙", "2 甲", "3 乙", "4 丙", "5 甲", "6 乙", "7 丙", "8 甲", "9 乙", "10 丙",
-                "11 甲", "12 乙", "13 丁", "14 丙", "15 甲", "16 丁", "17 丙", "18 甲", "19 丁", "20 丙",
-                "21 甲", "22 丁", "23 丙", "24 甲", "25 乙", "26 丁", "27 丙", "28 乙", "29 丁", "30 丙",
-                "31 乙", "32 丁", "33 丙", "34 乙", "35 丁", "36 丙", "37 甲", "38 乙", "39 丁", "40 甲",
-                "41 乙", "42 丁", "43 甲", "44 乙", "45 丁", "46 甲", "47 乙", "48 丁"
-        };
-
-        ShiftInfo nextShiftGroupInfo = ScheduleUtils.findNextShift(data, Integer.valueOf(currentCacheId), currentShiftGroupName);
-        if (nextShiftGroupInfo == null){
-            log.info("{}{}", ccmNo + ">>>>>>获取下个班组信息为空,交班失败!", DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()));
-            return result;
-        }
+
         // 班别名(白中夜)
         String nextShiftName  = "";
         // 验证23:00 到01:00 之间
-        if (ScheduleUtils.isBetweenTime(new Date(), "07:30", "08:30")) {
+        if (ScheduleUtils.isBetweenTime(new Date(), "07:40", "08:30")) {
             nextShiftName = "白";
-        } else if (ScheduleUtils.isBetweenTime(new Date(), "15:30", "16:30")) {
+        } else if (ScheduleUtils.isBetweenTime(new Date(), "14:40", "16:30")) {
             nextShiftName = "中";
-        } else if (ScheduleUtils.isBetweenTime(new Date(), "23:30", "00:30")) {
+        } else if (ScheduleUtils.isBetweenTime(new Date(), "23:40", "00:30")) {
             nextShiftName = "夜";
         }else {
             log.info("{}{}", ccmNo + "未在交班范围内,交班失败!,", DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()));
-            result.put("fail","未在交班时间范围内,交班失败!");
+            result.put("fail","未在交班时间范围内,交班操作失败!");
             return result;
         }
-        // 班组名(甲乙丙丁)
-        String nextShiftGroupName =  nextShiftGroupInfo.getShift();
         // 班组值
-        String finalNextShiftGroupVal = ShiftGroupEnum.getCodeByName(nextShiftGroupName);
+        String finalNextShiftGroupVal = billetHotsendChangeShiftVo.getShiftGroup();
         // 班别值
         String finalNextShiftVal = ShiftEnum.getCodeByName(nextShiftName + "班");
 
-        int nextUniqueShiftId = nextShiftGroupInfo.getId();
-
-        log.info(DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()) + " 手动交班下一个班次缓存值:" + finalNextShiftVal + ","+ finalNextShiftGroupVal);
-        log.info(DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()) + " 手动交班下一个班次信息名:" + nextUniqueShiftId + "," + nextShiftGroupName + ","+ nextShiftName);
-
         // 设置键并设置过期时间
         redisTemplate.opsForValue().set(autoChangeShiftLimitKey,"executed", EXPIRE_TIME, EXPIRE_TIME_UNIT);
 
@@ -146,7 +116,6 @@ public class BilletHotsendChangeShiftServiceImpl extends ServiceImpl<BilletHotse
             // 先更新班组班别缓存
             redisTemplate.opsForValue().set(keyShiftGroup, finalNextShiftGroupVal);
             redisTemplate.opsForValue().set(keyShift, finalNextShiftVal);
-            redisTemplate.opsForValue().set(currentShiftIdKey, nextUniqueShiftId);
 
             // 获取当前班组班别
             BilletHotsendChangeShift billetHotsendChangeShift = baseMapper.selectOne(new LambdaQueryWrapper<BilletHotsendChangeShift>()
@@ -213,12 +182,11 @@ public class BilletHotsendChangeShiftServiceImpl extends ServiceImpl<BilletHotse
                 log.info("{}{}", ccmNo + "交班生成储运配置:", JSON.toJSON(newShiftConfiguration));
             }
             operateLogService.add(billetHotsendChangeShift1, null, BilletHotsendChangeShift.class);
-            result.put("success", "手动交班成功!");
+            result.put("success", "交班成功!");
         } catch (Exception e) {
             log.error("交班出现异常", e);
             redisTemplate.opsForValue().set(keyShiftGroup, oldShiftGroup);
             redisTemplate.opsForValue().set(keyShift, oldShift);
-            redisTemplate.opsForValue().set(nextshiftIdKey, currentCacheId);
             result.put("fail", "交班异常!");
         }
         return result;