|
@@ -18,7 +18,10 @@ import org.jeecg.common.util.oConvertUtils;
|
|
import org.jeecg.modules.actualControl.heatsActuals.service.IHeatsActualsService;
|
|
import org.jeecg.modules.actualControl.heatsActuals.service.IHeatsActualsService;
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
|
|
|
|
+import org.jeecg.modules.billet.billetHotsendChangeShift.util.ScheduleUtils;
|
|
import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
|
|
import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
|
|
|
|
+import org.jeecg.modules.billet.storageBill.entity.ShiftEnum;
|
|
|
|
+import org.jeecg.modules.billet.storageBill.entity.ShiftGroupEnum;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -30,9 +33,8 @@ import java.time.LocalDateTime;
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
import java.time.YearMonth;
|
|
import java.time.YearMonth;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 钢坯交班记录
|
|
* @Description: 钢坯交班记录
|
|
@@ -237,4 +239,99 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
|
|
|
return Result.OK(pageList);
|
|
return Result.OK(pageList);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 每天 08:00:00 执行的定时任务
|
|
|
|
+// @Scheduled(cron = "0 0 8 * * ?")
|
|
|
|
+ public void executeDayShiftTask() {
|
|
|
|
+ log.info("自动化定时交班——白班:08:00:00开始执行!");
|
|
|
|
+ performShiftChange("白班");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 每天 16:00:00 执行的定时任务
|
|
|
|
+// @Scheduled(cron = "0 0 16 * * ?")
|
|
|
|
+ public void executeMiddleShiftTask() {
|
|
|
|
+ log.info("自动定时交班——中班:16:00:00开始执行!");
|
|
|
|
+ performShiftChange("中班");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 每天 00:00:00 执行的定时任务
|
|
|
|
+// @Scheduled(cron = "0 0 0 * * ?")
|
|
|
|
+ public void executeNeightShiftTask() {
|
|
|
|
+ log.info("自动化定时交班——白班:08:00:00开始执行!");
|
|
|
|
+ performShiftChange("夜班");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="自动化交班测试", notes="自动化交班测试")
|
|
|
|
+ @GetMapping(value = "/autoByCcmNo")
|
|
|
|
+ public Result<List<BilletHotsendChangeShift>> autoByCcmNo() {
|
|
|
|
+ performShiftChange("白班");
|
|
|
|
+ List<BilletHotsendChangeShift> list = billetHotsendChangeShiftService.list().stream()
|
|
|
|
+ .sorted(Comparator.comparing(BilletHotsendChangeShift::getCreateTime).reversed())
|
|
|
|
+ .limit(2)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ return Result.OK(list);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 自动化交班
|
|
|
|
+ * @author: jeecg-boot
|
|
|
|
+ * @param shiftName
|
|
|
|
+ */
|
|
|
|
+ private void performShiftChange(String shiftName) {
|
|
|
|
+
|
|
|
|
+ String keyShiftGroupfive = String.format("class:shift:group:%s", "5");
|
|
|
|
+ String keyShiftfive = String.format("class:shift:%s", "5");
|
|
|
|
+
|
|
|
|
+ String fiveShiftGroup = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroupfive));
|
|
|
|
+ String fiveShift = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftfive));
|
|
|
|
+
|
|
|
|
+ String keyShiftGroupsix = String.format("class:shift:group:%s", "6");
|
|
|
|
+ String keyShiftsix = String.format("class:shift:%s", "6");
|
|
|
|
+
|
|
|
|
+ String sixShiftGroup = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroupsix));
|
|
|
|
+ String sixShift = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftsix));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 5.6号机的班组和班别是否相等
|
|
|
|
+ if (!Objects.equals(sixShiftGroup, fiveShiftGroup) || !Objects.equals(sixShift, fiveShift)) {
|
|
|
|
+ log.info("缓存中5.6号机的当班班组信息不一致,执行交班定时任务失败! {}", new Date());
|
|
|
|
+ log.info("5号机班组值:{},6号机班组值:{}", fiveShiftGroup, sixShiftGroup);
|
|
|
|
+ log.info("5号机班别值:{},6号机班别值:{}", fiveShift, sixShift);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String currentShiftGroupName = ShiftGroupEnum.fromCode(sixShiftGroup).name();
|
|
|
|
+ String currentShiftName = ShiftEnum.fromCode(sixShift).name().replace("班", "");
|
|
|
|
+
|
|
|
|
+ String[] result = ScheduleUtils.getNextShiftInfo(currentShiftGroupName, currentShiftName);
|
|
|
|
+ if (result.length < 4 || result[2] == null || result[3] == null) {
|
|
|
|
+ log.info("根据排班表未匹配出下一个班次信息,自动化交班失败! {}", new Date());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ log.info("下一个班次信息:{}——{}", result[0], result[1]);
|
|
|
|
+ log.info("下一个班次信息:{}——{}", result[3], result[2]);
|
|
|
|
+
|
|
|
|
+ // 查询当天的交班记录
|
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapperCS = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapperCS.between(BilletHotsendChangeShift::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
|
|
|
|
+ List<BilletHotsendChangeShift> billetHotsendChangeShiftList = billetHotsendChangeShiftService.list(queryWrapperCS);
|
|
|
|
+
|
|
|
|
+ String nextShift = String.join(",", result[3], result[2]);
|
|
|
|
+
|
|
|
|
+ if (oConvertUtils.listIsNotEmpty(billetHotsendChangeShiftList)) {
|
|
|
|
+ boolean exists = billetHotsendChangeShiftList.stream()
|
|
|
|
+ .map(x -> String.join(",", x.getShift(), x.getShiftGroup()))
|
|
|
|
+ .anyMatch(s -> s.equals(nextShift));
|
|
|
|
+ if (exists) {
|
|
|
|
+ log.info("自动化当天不能重复交班! {}", new Date());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShiftVo = new BilletHotsendChangeShift();
|
|
|
|
+ billetHotsendChangeShiftVo.setShiftGroup(result[2]);
|
|
|
|
+ billetHotsendChangeShiftVo.setShift(result[3]);
|
|
|
|
+ JSONObject jsonObject = billetHotsendChangeShiftService.autoChangeShiftHandle(billetHotsendChangeShiftVo);
|
|
|
|
+ log.info("自动化{}交班成功! {} 结果值:{}", shiftName, new Date(), jsonObject);
|
|
|
|
+ }
|
|
}
|
|
}
|