|
|
@ -1,9 +1,14 @@ |
|
|
|
package com.hnac.hzims.operational.maintenance.scheduled; |
|
|
|
package com.hnac.hzims.operational.maintenance.scheduled; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzims.equipment.feign.IEmInfoClient; |
|
|
|
import com.hnac.hzims.equipment.feign.IEmInfoClient; |
|
|
|
|
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
|
|
|
|
import com.hnac.hzims.message.dto.MessagePushRecordDto; |
|
|
|
|
|
|
|
import com.hnac.hzims.message.entity.config.MessageTemplateEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.message.fegin.IMessageClient; |
|
|
|
import com.hnac.hzims.message.req.PushExtrasReq; |
|
|
|
import com.hnac.hzims.message.req.PushExtrasReq; |
|
|
|
import com.hnac.hzims.operational.access.constants.AccessConstants; |
|
|
|
import com.hnac.hzims.operational.access.constants.AccessConstants; |
|
|
|
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; |
|
|
|
import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; |
|
|
@ -20,10 +25,13 @@ import lombok.AllArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
|
|
|
import org.springblade.core.log.logger.BladeLogger; |
|
|
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
import org.springblade.flow.core.feign.IFlowClient; |
|
|
|
import org.springblade.flow.core.feign.IFlowClient; |
|
|
|
import org.springblade.flow.core.utils.FlowUtil; |
|
|
|
import org.springblade.flow.core.utils.FlowUtil; |
|
|
|
import org.springblade.flow.core.utils.TaskUtil; |
|
|
|
import org.springblade.flow.core.utils.TaskUtil; |
|
|
|
|
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
@ -53,7 +61,8 @@ public class MaintenanceTaskCreateTask { |
|
|
|
private final IOperMaintenanceTaskService taskService; |
|
|
|
private final IOperMaintenanceTaskService taskService; |
|
|
|
private final IImsDutyMainService mainService; |
|
|
|
private final IImsDutyMainService mainService; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final IEmInfoClient emInfoClient; |
|
|
|
private final IMessageClient messageClient; |
|
|
|
|
|
|
|
private final BladeLogger logger; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.task.templateCode.maintenance.taskDispose}") |
|
|
|
@Value("${hzims.operation.task.templateCode.maintenance.taskDispose}") |
|
|
|
private String maintenanceTaskKey; |
|
|
|
private String maintenanceTaskKey; |
|
|
@ -149,15 +158,13 @@ public class MaintenanceTaskCreateTask { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
taskService.save(taskEntity); |
|
|
|
taskService.save(taskEntity); |
|
|
|
//计算任务计划结束时间 存入redis
|
|
|
|
|
|
|
|
redisTemplate.opsForZSet().add(maintenanceTaskKey,taskEntity,disposeTime.toEpochSecond(ZoneOffset.of("+8"))); |
|
|
|
|
|
|
|
redisTemplate.opsForZSet().add(REMIND_TASK_END_LIST,taskEntity,taskEntity.getPlanEndTime().toEpochSecond(ZoneOffset.of("+8"))); |
|
|
|
|
|
|
|
//生成工作流实例
|
|
|
|
//生成工作流实例
|
|
|
|
String processInstanceId = this.startProcessInstance(planEntity.getProcDefId(), taskEntity); |
|
|
|
String processInstanceId = this.startProcessInstance(planEntity.getProcDefId(), taskEntity); |
|
|
|
taskEntity.setProcessInstanceId(processInstanceId); |
|
|
|
taskEntity.setProcessInstanceId(processInstanceId); |
|
|
|
taskService.updateById(taskEntity); |
|
|
|
taskService.updateById(taskEntity); |
|
|
|
planEntity.setCreateTaskTime(DateUtil.now()); |
|
|
|
planEntity.setCreateTaskTime(DateUtil.now()); |
|
|
|
planMapper.updateById(planEntity); |
|
|
|
planMapper.updateById(planEntity); |
|
|
|
|
|
|
|
this.pushTaskMessage(taskEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -180,4 +187,33 @@ public class MaintenanceTaskCreateTask { |
|
|
|
.getData() |
|
|
|
.getData() |
|
|
|
.getProcessInstanceId(); |
|
|
|
.getProcessInstanceId(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @Author hx |
|
|
|
|
|
|
|
* @Description 推送日常维护任务消息 |
|
|
|
|
|
|
|
* @Date 2023/4/12 18:39 |
|
|
|
|
|
|
|
* @Param [taskEntity] 日常维护任务 |
|
|
|
|
|
|
|
* @return void |
|
|
|
|
|
|
|
**/ |
|
|
|
|
|
|
|
private void pushTaskMessage(OperMaintenanceTaskEntity taskEntity) { |
|
|
|
|
|
|
|
XxlJobLogger.log("开始保存{}的日常维护消息推送记录",taskEntity.getDisposer()); |
|
|
|
|
|
|
|
R<MessageTemplateEntity> templateR = messageClient.getMsgTemplateById(taskEntity.getMessageTemplateId()); |
|
|
|
|
|
|
|
if(templateR.isSuccess() && ObjectUtil.isNotEmpty(templateR.getData())) { |
|
|
|
|
|
|
|
Func.toLongList("",taskEntity.getDisposer()).forEach(userId -> { |
|
|
|
|
|
|
|
MessagePushRecordDto recordDto = BeanUtil.copy(templateR.getData(),MessagePushRecordDto.class); |
|
|
|
|
|
|
|
recordDto.setTypes(Arrays.asList(Func.split(recordDto.getType(),","))); |
|
|
|
|
|
|
|
recordDto.setDeptId(taskEntity.getCreateDept()); |
|
|
|
|
|
|
|
recordDto.setCreateUser(taskEntity.getCreateUser()); |
|
|
|
|
|
|
|
recordDto.setCreateDept(taskEntity.getCreateDept()); |
|
|
|
|
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
|
|
|
|
|
recordDto.setPlanTime(LocalDateTime.ofInstant(taskEntity.getDisposeTime().toInstant(),zoneId)); |
|
|
|
|
|
|
|
recordDto.setPushType(MessageConstants.PLAN); |
|
|
|
|
|
|
|
recordDto.setPusher(userId.toString()); |
|
|
|
|
|
|
|
recordDto.setPusherName(UserCache.getUser(userId).getName()); |
|
|
|
|
|
|
|
recordDto.setAccount(recordDto.getPusher()); |
|
|
|
|
|
|
|
recordDto.setContent("距离任务执行时间已不满一小时,请及时处理"); |
|
|
|
|
|
|
|
XxlJobLogger.log("推送内容体为:{}", JSON.toJSONString(taskEntity.getDisposer())); |
|
|
|
|
|
|
|
messageClient.sendMessage(recordDto); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|