|
@@ -18,7 +18,8 @@ import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.actualControl.heatsActuals.service.IHeatsActualsService;
|
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
|
|
|
import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
|
|
|
-import org.jeecg.modules.billet.billetHotsendChangeShift.util.ScheduleRecord;
|
|
|
+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.storageBill.entity.ShiftEnum;
|
|
|
import org.jeecg.modules.billet.storageBill.entity.ShiftGroupEnum;
|
|
@@ -34,7 +35,6 @@ import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.YearMonth;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -288,7 +288,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
redisTemplate.opsForValue().set(nextshiftIdKey, nextId);
|
|
|
return Result.OK("设置交班索引i为:" + nextId);
|
|
|
}
|
|
|
-// performShiftChange(null);
|
|
|
+ performShiftChange(null);
|
|
|
return Result.OK(null);
|
|
|
}
|
|
|
/**
|
|
@@ -304,116 +304,55 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
String sixShiftGroup = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroupsix));
|
|
|
String sixShift = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftsix));
|
|
|
|
|
|
-
|
|
|
String currentShiftGroupName = ShiftGroupEnum.fromCode(sixShiftGroup).name();
|
|
|
String currentShiftName = ShiftEnum.fromCode(sixShift).name().replace("班", "");
|
|
|
|
|
|
String nextshiftIdKey = String.format("class:nextshift:Id:%s", "5-6");
|
|
|
- String nextCacheId = oConvertUtils.getString(redisTemplate.opsForValue().get(nextshiftIdKey));
|
|
|
+ String currentCacheId = oConvertUtils.getString(redisTemplate.opsForValue().get(nextshiftIdKey));
|
|
|
+
|
|
|
+ log.info(DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()) + " 当前班次信息值:" + sixShift+ ","+ sixShiftGroup);
|
|
|
+ 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 nextShiftInfo = ScheduleUtils.findNextShift(data, Integer.valueOf(currentCacheId), currentShiftGroupName, currentShiftName);
|
|
|
+ if (nextShiftInfo == null){
|
|
|
+ log.info("{}{}", "获取到下个班组信息为空!", new Date() + "自动化交班失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ String nextShiftGroupName = nextShiftInfo.getShiftgroup();
|
|
|
|
|
|
- String nextShiftGroupName = "";
|
|
|
- String nextShiftName = "";
|
|
|
- int nextShiftGroupVal = 0;
|
|
|
- int nextShiftVal = 0;
|
|
|
-
|
|
|
-
|
|
|
- List<ScheduleRecord> scheduleRecordListAll = new ArrayList<>();
|
|
|
- // 将数据添加到列表中
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(1, "丙", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(2, "甲", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(3, "乙", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(4, "丙", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(5, "甲", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(6, "乙", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(7, "丙", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(8, "甲", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(9, "乙", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(10, "丙", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(11, "甲", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(12, "乙", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(13, "丁", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(14, "丙", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(15, "甲", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(16, "丁", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(17, "丙", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(18, "甲", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(19, "丁", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(20, "丙", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(21, "甲", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(22, "丁", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(23, "丙", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(24, "甲", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(25, "乙", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(26, "丁", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(27, "丙", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(28, "乙", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(29, "丁", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(30, "丙", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(31, "乙", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(32, "丁", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(33, "丙", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(34, "乙", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(35, "丁", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(36, "丙", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(37, "甲", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(38, "乙", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(39, "丁", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(40, "甲", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(41, "乙", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(42, "丁", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(43, "甲", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(44, "乙", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(45, "丁", "中"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(46, "甲", "夜"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(47, "乙", "白"));
|
|
|
- scheduleRecordListAll.add(new ScheduleRecord(48, "丁", "中"));
|
|
|
-
|
|
|
- if (oConvertUtils.isEmpty(nextCacheId)) {
|
|
|
- for (ScheduleRecord scheduleRecord : scheduleRecordListAll) {
|
|
|
- if (currentShiftGroupName.equals(scheduleRecord.getShiftGroup()) && currentShiftName.equals(scheduleRecord.getShift())) {
|
|
|
- nextShiftGroupName = scheduleRecord.getShiftGroup();
|
|
|
- nextShiftName = scheduleRecord.getShift();
|
|
|
- nextShiftGroupVal = scheduleRecord.getShiftGroupValue();
|
|
|
- nextShiftVal = scheduleRecord.getShiftValue();
|
|
|
- redisTemplate.opsForValue().set(nextshiftIdKey, scheduleRecord.getId() + 1);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- for (ScheduleRecord scheduleRecord : scheduleRecordListAll) {
|
|
|
- if (scheduleRecord.getId() == Integer.parseInt(nextCacheId)) {
|
|
|
-
|
|
|
- nextShiftName = scheduleRecord.getShift();
|
|
|
- nextShiftGroupName = scheduleRecord.getShiftGroup();
|
|
|
-
|
|
|
- nextShiftGroupVal = scheduleRecord.getShiftGroupValue();
|
|
|
- nextShiftVal = scheduleRecord.getShiftValue();
|
|
|
-
|
|
|
- if (Integer.parseInt(nextCacheId) == 48){
|
|
|
- redisTemplate.opsForValue().set(nextshiftIdKey, 1);
|
|
|
- }else {
|
|
|
- redisTemplate.opsForValue().set(nextshiftIdKey, scheduleRecord.getId() + 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- log.info(new Date() + "下一个班次名::" + nextCacheId + ","+nextShiftGroupName+ ","+ nextShiftName);
|
|
|
- log.info("下一个班次值::" + nextShiftGroupVal+ ","+ nextShiftVal);
|
|
|
+ String nextShiftName = nextShiftInfo.getShift();
|
|
|
+
|
|
|
+ int nextUniqueShiftId = nextShiftInfo.getId();
|
|
|
+
|
|
|
+ String finalNextShiftGroupVal = ShiftGroupEnum.getCodeByName(nextShiftName);
|
|
|
+
|
|
|
+ String finalNextShiftVal = ShiftEnum.getCodeByName(nextShiftGroupName + "班");;
|
|
|
+
|
|
|
+ redisTemplate.opsForValue().set(nextshiftIdKey, nextUniqueShiftId);
|
|
|
+
|
|
|
+ log.info(DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()) + " 下一个班次信息值:" + finalNextShiftVal + ","+ finalNextShiftGroupVal);
|
|
|
+ log.info(DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()) + " 下一个班次信息名:" + nextUniqueShiftId + "," + nextShiftGroupName + ","+ nextShiftName);
|
|
|
|
|
|
- String finalNextShiftGroupVal = String.valueOf(nextShiftGroupVal);
|
|
|
- String finalNextShiftVal = String.valueOf(nextShiftVal);
|
|
|
// 查询当天的交班记录
|
|
|
LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapperCS = new LambdaQueryWrapper<>();
|
|
|
queryWrapperCS.between(BilletHotsendChangeShift::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
|
|
|
List<BilletHotsendChangeShift> billetHotsendChangeShiftList = billetHotsendChangeShiftService.list(queryWrapperCS);
|
|
|
|
|
|
- String nextShift = String.join(",", finalNextShiftVal, finalNextShiftGroupVal);
|
|
|
+ String nextShiftAndShiftGroupInfo = String.join(",", finalNextShiftVal, finalNextShiftGroupVal);
|
|
|
|
|
|
if (oConvertUtils.listIsNotEmpty(billetHotsendChangeShiftList)) {
|
|
|
boolean exists = billetHotsendChangeShiftList.stream()
|
|
|
.map(x -> String.join(",", x.getShift(), x.getShiftGroup()))
|
|
|
- .anyMatch(s -> s.equals(nextShift));
|
|
|
+ .anyMatch(s -> s.equals(nextShiftAndShiftGroupInfo));
|
|
|
if (exists) {
|
|
|
log.info("自动交班,当天不能重复交班! {}", new Date());
|
|
|
// 自动交班失败,交班ID索引值回滚,保证交班顺序
|
|
@@ -428,14 +367,14 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
billetHotsendChangeShiftVo.setShiftGroup(finalNextShiftGroupVal);
|
|
|
billetHotsendChangeShiftVo.setShift(finalNextShiftVal);
|
|
|
JSONObject jsonObject = billetHotsendChangeShiftService.autoChangeShiftHandle(billetHotsendChangeShiftVo);
|
|
|
- log.info("自动化{}交班成功!{} 结果值:{}", shiftName, new Date(), jsonObject);
|
|
|
+ log.info("自动化{}交班成功!{} 结果值:{}", shiftName, DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()), jsonObject);
|
|
|
}
|
|
|
|
|
|
-// @Scheduled(cron = "0 38 17 * * ?")
|
|
|
+ @Scheduled(cron = "0 40 10 * * ?")
|
|
|
public void executeNeightShiftTask1() {
|
|
|
log.info("设置索引iD");
|
|
|
String nextshiftIdKey = String.format("class:nextshift:Id:%s", "5-6");
|
|
|
- redisTemplate.opsForValue().set(nextshiftIdKey, 22);
|
|
|
+ redisTemplate.opsForValue().set(nextshiftIdKey, 26);
|
|
|
}
|
|
|
|
|
|
// @Scheduled(cron = "0 * * * * ?")
|