|
@@ -4256,6 +4256,8 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
|
lenzhaChongpai(chongpaiStartDate, chongpaiEndDate, apsScheduleConfigDo, currentUser);
|
|
|
//退火重排
|
|
|
tuihuoChongpai(chongpaiStartDate, chongpaiEndDate, apsScheduleConfigDo, currentUser);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e);
|
|
|
} finally {
|
|
|
//锁定所有 未锁定的 作业和作业明细
|
|
|
apsProcessOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>()
|
|
@@ -4436,60 +4438,67 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
|
|
|
}
|
|
|
|
|
|
private String doRestartSchedule(String tenantId) {
|
|
|
- //即将排程日期
|
|
|
- DateTime nowDate = DateUtil.date();
|
|
|
- String time1 = DateUtil.format(nowDate, "yyyy-MM-dd 00:00:00");
|
|
|
- String time2 = DateUtil.format(nowDate, "yyyy-MM-dd 04:00:00");
|
|
|
- String time3 = DateUtil.format(nowDate, "yyyy-MM-dd 19:00:00");
|
|
|
- String time4 = DateUtil.format(nowDate, "yyyy-MM-dd 23:59:59");
|
|
|
- String now = DateUtil.format(nowDate, "yyyy-MM-dd HH:mm:ss");
|
|
|
//如果当前时间在0-12点,重排今天12点-明天12点
|
|
|
//如果当前时间在12-24点,重排明天12点-后天12点
|
|
|
String needScheduleStartDate = "";
|
|
|
String needScheduleEndDate = "";
|
|
|
- if (now.compareTo(time1) >= 0 && now.compareTo(time2) < 0) {
|
|
|
- needScheduleStartDate = DateUtil.format(nowDate, "yyyy-MM-dd 12:00:00");
|
|
|
- needScheduleEndDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd 12:00:00");
|
|
|
- } else if (now.compareTo(time3) >= 0 && now.compareTo(time4) <= 0) {
|
|
|
- needScheduleStartDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd 12:00:00");
|
|
|
- needScheduleEndDate = DateUtil.format(DateUtil.offsetDay(nowDate, 2), "yyyy-MM-dd 12:00:00");
|
|
|
- } else {
|
|
|
- log.info("{}不在调度时间段中,不调度排程", tenantId);
|
|
|
- return "notNeedWait";
|
|
|
- }
|
|
|
- //查询日志判断是否已调度排程成功
|
|
|
- int count = apsScheduleLogService.count(new LambdaQueryWrapper<ApsScheduleLogDo>()
|
|
|
- .eq(ApsScheduleLogDo::getTenantid, tenantId)
|
|
|
- .eq(ApsScheduleLogDo::getScheduletype, "调度排程")
|
|
|
- .eq(ApsScheduleLogDo::getSucess, "是")
|
|
|
- .eq(ApsScheduleLogDo::getSchedulestarttime, needScheduleStartDate)
|
|
|
- .eq(ApsScheduleLogDo::getScheduleendtime, needScheduleEndDate));
|
|
|
- if (count > 0) {
|
|
|
- log.info("{}已调度排程,无需排程", tenantId);
|
|
|
- return "notNeedWait";
|
|
|
- }
|
|
|
-
|
|
|
SysUserVo currentUser = new SysUserVo();
|
|
|
- currentUser.setId("8672bf72ab274bec83052868ae336b38");
|
|
|
- currentUser.setName("管理员");
|
|
|
- List<SysOrganizationVo> organizationVoList = new LinkedList<>();
|
|
|
- SysOrganizationDo org = sysOrganizationService.getById(tenantId);
|
|
|
- SysOrganizationVo sysOrganizationVo = BeanUtil.toBean(org, SysOrganizationVo.class);
|
|
|
- organizationVoList.add(sysOrganizationVo);
|
|
|
- currentUser.setOrganizationDoList(organizationVoList);
|
|
|
- CXCommonUtils.getCurrentUserFactoryId(currentUser);
|
|
|
-
|
|
|
- // 按照所属工厂加锁
|
|
|
- RLock rLock = redissonClient.getLock(tenantId);
|
|
|
- boolean isLocked = rLock.isLocked();
|
|
|
- // 锁是否被占用
|
|
|
- if (isLocked) {
|
|
|
- return "needWait";
|
|
|
+ try {
|
|
|
+ //即将排程日期
|
|
|
+ DateTime nowDate = DateUtil.date();
|
|
|
+ String time1 = DateUtil.format(nowDate, "yyyy-MM-dd 00:00:00");
|
|
|
+ String time2 = DateUtil.format(nowDate, "yyyy-MM-dd 04:00:00");
|
|
|
+ String time3 = DateUtil.format(nowDate, "yyyy-MM-dd 19:00:00");
|
|
|
+ String time4 = DateUtil.format(nowDate, "yyyy-MM-dd 23:59:59");
|
|
|
+ String now = DateUtil.format(nowDate, "yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ if (now.compareTo(time1) >= 0 && now.compareTo(time2) < 0) {
|
|
|
+ needScheduleStartDate = DateUtil.format(nowDate, "yyyy-MM-dd 12:00:00");
|
|
|
+ needScheduleEndDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd 12:00:00");
|
|
|
+ } else if (now.compareTo(time3) >= 0 && now.compareTo(time4) <= 0) {
|
|
|
+ needScheduleStartDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd 12:00:00");
|
|
|
+ needScheduleEndDate = DateUtil.format(DateUtil.offsetDay(nowDate, 2), "yyyy-MM-dd 12:00:00");
|
|
|
+ } else {
|
|
|
+ log.info("{}不在调度时间段中,不调度排程", tenantId);
|
|
|
+ return "notNeedWait";
|
|
|
+ }
|
|
|
+ //查询日志判断是否已调度排程成功
|
|
|
+ int count = apsScheduleLogService.count(new LambdaQueryWrapper<ApsScheduleLogDo>()
|
|
|
+ .eq(ApsScheduleLogDo::getTenantid, tenantId)
|
|
|
+ .eq(ApsScheduleLogDo::getScheduletype, "调度排程")
|
|
|
+ .eq(ApsScheduleLogDo::getSucess, "是")
|
|
|
+ .eq(ApsScheduleLogDo::getSchedulestarttime, needScheduleStartDate)
|
|
|
+ .eq(ApsScheduleLogDo::getScheduleendtime, needScheduleEndDate));
|
|
|
+ if (count > 0) {
|
|
|
+ log.info("{}已调度排程,无需排程", tenantId);
|
|
|
+ return "notNeedWait";
|
|
|
+ }
|
|
|
+
|
|
|
+ currentUser.setId("8672bf72ab274bec83052868ae336b38");
|
|
|
+ currentUser.setName("管理员");
|
|
|
+ List<SysOrganizationVo> organizationVoList = new LinkedList<>();
|
|
|
+ SysOrganizationDo org = sysOrganizationService.getById(tenantId);
|
|
|
+ SysOrganizationVo sysOrganizationVo = BeanUtil.toBean(org, SysOrganizationVo.class);
|
|
|
+ organizationVoList.add(sysOrganizationVo);
|
|
|
+ currentUser.setOrganizationDoList(organizationVoList);
|
|
|
+ CXCommonUtils.getCurrentUserFactoryId(currentUser);
|
|
|
+
|
|
|
+ // 按照所属工厂加锁
|
|
|
+ RLock rLock = redissonClient.getLock(tenantId);
|
|
|
+ boolean isLocked = rLock.isLocked();
|
|
|
+ // 锁是否被占用
|
|
|
+ if (isLocked) {
|
|
|
+ return "needWait";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e);
|
|
|
+ return "notNeedWait";
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
apsScheduleRestart(null, needScheduleStartDate, needScheduleEndDate, currentUser);
|
|
|
} catch (Exception e) {
|
|
|
+ log.error(e);
|
|
|
return "success";
|
|
|
}
|
|
|
return "success";
|