Browse Source

fix: 解决任务月度查询逾期状态异常的问题

zhongwei
liwen 8 months ago
parent
commit
b49f336dc1
  1. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/constants/RedisKeyConstants.java
  2. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java
  3. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/constants/RedisKeyConstants.java

@ -11,8 +11,8 @@ import org.springframework.stereotype.Component;
@Data
public class RedisKeyConstants {
public static String MAINTENANCE_TASK_DELAY_LIST = "hzims:operation:maintenance:end:delay:tasks";
public static String REMIND_TASK_END_LIST = "hzims:operation:maintenance:end:delay:tasks";
public static String MAINTENANCE_TASK_DELAY_LIST = "hzims:operation:maintenance:delay:tasks";
public static String REMIND_TASK_END_LIST = "hzims:operation:maintenance:end:tasks";
/**根据realId获取实时数据**/
@Value("${hzims.operation.realIdKey}")

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java

@ -1,6 +1,5 @@
package com.hnac.hzims.operational.maintenance.scheduled;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.google.common.collect.Lists;
import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.message.MessageConstants;
@ -17,7 +16,6 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.data.redis.core.RedisTemplate;
@ -31,6 +29,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import static com.hnac.hzims.operational.maintenance.constants.ScheduledConstant.REMIND_MAINTENANCE_BECOME_TASK;
@Component
@Slf4j
@AllArgsConstructor
@ -56,7 +55,7 @@ public class MaintenanceTaskRemindHandler {
else if(Lists.newArrayList("待领用","待执行").contains(taskEntity.getFlowTaskName())) {
XxlJobLogger.log("开始执行id为{}的任务", Optional.ofNullable(operMaintenanceTaskEntity.getId()).orElse(0L));
//日常维护任务到期消息提醒,提醒对象:执行人、项目经理角色 取出
//this.sendMessage(taskEntity);
this.sendMessage(taskEntity);
redisTemplate.opsForZSet().remove(RedisKeyConstants.MAINTENANCE_TASK_DELAY_LIST,operMaintenanceTaskEntity);
}
});

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java

@ -61,10 +61,12 @@ public class MaintenanceTaskSchedule {
@XxlJob(GENERATE_MAINTENANCE_TASK_SCHEDULE)
public ReturnT<String> execute(String param) throws Exception {
Date startDate = StringUtil.isNotBlank(param) ? DateUtil.parse(param, DateUtil.PATTERN_DATE) : DateUtil.parse(DateUtil.formatDate(DateUtil.now()), DateUtil.PATTERN_DATE);
Date endDate = DateUtil.parse(DateUtil.formatDate(DateUtil.plusDays(startDate, 1)), DateUtil.PATTERN_DATE);
LambdaQueryWrapper<OperMaintenancePlanEntity> planQW = Wrappers.<OperMaintenancePlanEntity>lambdaQuery().isNull(OperMaintenancePlanEntity::getCreateTaskTime)
.ge(OperMaintenancePlanEntity::getDisposeTime, startDate).lt(OperMaintenancePlanEntity::getDisposeTime, endDate);
String startDate = DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATE) + " 00:00:00";
String endDate = DateUtil.format(DateUtil.plusDays(DateUtil.now(), 1), DateUtil.PATTERN_DATE) + " 00:00:00";
LambdaQueryWrapper<OperMaintenancePlanEntity> planQW = Wrappers.<OperMaintenancePlanEntity>lambdaQuery()
.isNull(OperMaintenancePlanEntity::getCreateTaskTime)
.ge(OperMaintenancePlanEntity::getDisposeTime, startDate)
.lt(OperMaintenancePlanEntity::getDisposeTime, endDate);
List<OperMaintenancePlanEntity> planList = planService.list(planQW);
XxlJobLogger.log("日常维护任务生成开始!计划ID为:"+planList.stream().map(OperMaintenancePlanEntity::getId).map(String::valueOf).collect(Collectors.joining(",")));
//分页插入日常维护计划

Loading…
Cancel
Save