Browse Source

# 巡检任务生成消息推送修改

zhongwei
haungxing 2 years ago
parent
commit
00f4926e66
  1. 39
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java
  2. 5
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java
  3. 6
      hzims-service/operational/src/main/resources/db/1.0.1.sql

39
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java

@ -8,9 +8,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.message.dto.PlanMsgRecordDto; import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzinfo.inspect.plan.entity.PlanEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import com.hnac.hzinfo.inspect.task.entity.TaskEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity; import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity;
import com.hnac.hzinfo.inspect.task.job.service.TaskRemindManager; import com.hnac.hzinfo.inspect.task.job.service.TaskRemindManager;
import com.hnac.hzinfo.inspect.task.service.ITaskService;
import com.hnac.hzinfo.inspect.task.service.ITaskUserService; import com.hnac.hzinfo.inspect.task.service.ITaskUserService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -47,6 +49,7 @@ import java.util.Map;
public class TaskGenerateAspect { public class TaskGenerateAspect {
private final IMessageClient messageClient; private final IMessageClient messageClient;
private final ITaskService taskService;
private final ITaskUserService taskUserService; private final ITaskUserService taskUserService;
/** /**
@ -61,38 +64,26 @@ public class TaskGenerateAspect {
@Value("${hzims.inspect.task.templateCode.taskEnd}") @Value("${hzims.inspect.task.templateCode.taskEnd}")
private String taskEndTemplateCode; private String taskEndTemplateCode;
@Pointcut("execution(* com.hnac.hzinfo.inspect.task.service.ITaskService.save(..))") @Pointcut("execution(* com.hnac.hzinfo.inspect.task.job.service.ITaskJobService.sendTask(..))")
public void taskSaveCut() { public void taskSaveCut() {
} }
@Pointcut("execution(* com.hnac.hzinfo.inspect.task.service.ITaskService.saveBatch(..))") @AfterReturning(value = "taskSaveCut()")
public void taskSaveCutBatch() { private void saveTask(JoinPoint joinPoint) {
}
@AfterReturning(value = "taskSaveCut()",returning = "result")
private void saveTask(JoinPoint joinPoint,boolean result) throws Throwable {
if(result) {
Object[] args = joinPoint.getArgs(); Object[] args = joinPoint.getArgs();
new Thread(() -> { new Thread(() -> {
if(ObjectUtil.isNotEmpty(args[0]) && args[0] instanceof TaskEntity) { if(ObjectUtil.isNotEmpty(args[0]) && args[0] instanceof PlanEntity) {
PlanEntity plan = (PlanEntity) args[0];
List<TaskEntity> list = taskService.list(
Wrappers.<TaskEntity>lambdaQuery().eq(TaskEntity::getPlanId,plan.getId())
);
if(CollectionUtil.isNotEmpty(list)) {
list.forEach(this::pushMessageByTask);
}
TaskEntity task = JSONObject.parseObject(JSON.toJSONString(args[0]),TaskEntity.class); TaskEntity task = JSONObject.parseObject(JSON.toJSONString(args[0]),TaskEntity.class);
this.pushMessageByTask(task); this.pushMessageByTask(task);
} }
},"巡检任务消息推送"); },"巡检任务消息推送").start();
}
}
@AfterReturning(value = "taskSaveCutBatch()",returning = "result")
private void saveTaskBatch(JoinPoint joinPoint,boolean result) throws Throwable {
if(result) {
Object[] args = joinPoint.getArgs();
new Thread(() -> {
if(args.length == 1) {
List<TaskEntity> taskList = JSONArray.parseArray(JSON.toJSONString(args[0]),TaskEntity.class);
taskList.forEach(this::pushMessageByTask);
}
},"巡检任务消息批量推送").start();
}
} }
/** /**

5
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java

@ -18,6 +18,7 @@ import com.hnac.hzinfo.inspect.plan.entity.*;
import com.hnac.hzinfo.inspect.plan.service.*; import com.hnac.hzinfo.inspect.plan.service.*;
import com.hnac.hzinfo.inspect.task.TaskContants; import com.hnac.hzinfo.inspect.task.TaskContants;
import com.hnac.hzinfo.inspect.task.TaskContants.ClaimStatusEnum; import com.hnac.hzinfo.inspect.task.TaskContants.ClaimStatusEnum;
import com.hnac.hzinfo.inspect.task.aspect.TaskGenerateAspect;
import com.hnac.hzinfo.inspect.task.entity.*; import com.hnac.hzinfo.inspect.task.entity.*;
import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService;
import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectService; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectService;
@ -89,6 +90,9 @@ public class TaskJobService {
@Autowired @Autowired
private IDutyMainClient dutyMainClient; private IDutyMainClient dutyMainClient;
@Autowired
private TaskGenerateAspect taskGenerateAspect;
private final String dateSplit = "_"; private final String dateSplit = "_";
/** /**
@ -401,6 +405,7 @@ public class TaskJobService {
task.setCreateUser(plan.getCreateUser()); task.setCreateUser(plan.getCreateUser());
task.setCreateDept(plan.getCreateDept()); task.setCreateDept(plan.getCreateDept());
task.setAutoVideo(plan.getAutoVideo()); task.setAutoVideo(plan.getAutoVideo());
task.setMessageTemplateId(plan.getMessageTemplateId());
task.setMethod(plan.getMethod()); task.setMethod(plan.getMethod());
task.setEndRemindFlag(true); task.setEndRemindFlag(true);
task.setStartRemindFlag(true); task.setStartRemindFlag(true);

6
hzims-service/operational/src/main/resources/db/1.0.1.sql

@ -4,3 +4,9 @@ alter table hzims_oper_maintenance_library add COLUMN `MESSAGE_TEMPLATE_ID` bigi
alter table hzims_oper_maintenance_plan add COLUMN `MESSAGE_TEMPLATE_ID` bigint(20) comment '消息推送模板ID'; alter table hzims_oper_maintenance_plan add COLUMN `MESSAGE_TEMPLATE_ID` bigint(20) comment '消息推送模板ID';
-- 日常维护任务添加消息模板ID -- 日常维护任务添加消息模板ID
alter table hzims_oper_maintenance_task add COLUMN `MESSAGE_TEMPLATE_ID` bigint(20) comment '消息推送模板ID'; alter table hzims_oper_maintenance_task add COLUMN `MESSAGE_TEMPLATE_ID` bigint(20) comment '消息推送模板ID';
-- 日常维护库设备库编码长度修改
alter table hzims_oper_maintenance_library MODIFY COLUMN `em_code` VARCHAR(50) comment '设备编码';
-- 日常维护库设备计划编码长度修改
alter table hzims_oper_maintenance_plan MODIFY COLUMN `em_code` VARCHAR(50) comment '设备编码';
-- 日常维护库设备任务编码长度修改
alter table hzims_oper_maintenance_task MODIFY COLUMN `em_code` VARCHAR(50) comment '设备编码';
Loading…
Cancel
Save