diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/entity/PlanEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/entity/PlanEntity.java
index 2382a03..ed78383 100644
--- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/entity/PlanEntity.java
+++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/entity/PlanEntity.java
@@ -3,6 +3,8 @@ package com.hnac.hzinfo.inspect.plan.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jdk.nashorn.internal.ir.annotations.Ignore;
@@ -195,4 +197,8 @@ public class PlanEntity extends TenantEntity {
@ApiModelProperty(value = "值班id")
private Long dutyId;
+ @ApiModelProperty(value = "消息模板ID")
+ @JsonSerialize(nullsUsing = NullSerializer.class)
+ private Long messageTemplateId;
+
}
diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java
index f3ce072..83c4274 100644
--- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java
+++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java
@@ -3,6 +3,8 @@ package com.hnac.hzinfo.inspect.task.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -165,5 +167,8 @@ public class TaskEntity extends TenantEntity {
@ApiModelProperty(value = "值班id")
private Long dutyId;
+ @ApiModelProperty(value = "消息模板ID")
+ @JsonSerialize(nullsUsing = NullSerializer.class)
+ private Long messageTemplateId;
}
diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java
index 611fab7..d2e233d 100644
--- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java
+++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java
@@ -59,9 +59,13 @@ public class PlanMsgRecordDto implements Serializable {
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long createUser;
+ @ApiModelProperty("阿里云短信模板参数")
+ private String smsParam;
+
@ApiModelProperty("消息推送耳机")
@NotNull
private String content;
+
@ApiModelProperty("租户ID")
private String tenantId;
diff --git a/hzims-service/inspect/pom.xml b/hzims-service/inspect/pom.xml
index 7376582..9ac3564 100644
--- a/hzims-service/inspect/pom.xml
+++ b/hzims-service/inspect/pom.xml
@@ -134,7 +134,11 @@
blade-starter-oss-minio
${bladex.project.version}
-
+
+ com.hnac.hzims
+ message-api
+ ${hzims.project.version}
+
diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java
index 247bc93..c41efa0 100644
--- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java
+++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/plan/controller/PlanController.java
@@ -137,7 +137,7 @@ public class PlanController extends BladeController {
@ApiImplicitParam(name="status",value="0:待审核-->1:已审核-->2:派发中-->3:暂停-->4:结束-->5审核不通过-->6待提交")
})
public R modifyPlanStatus(@RequestParam(value = "id") @ApiParam(value = "主键ID",required = true) Long id,
- @RequestParam @DictInvalid(dictKey = PlanContants.PLAN_STATUS) Integer status) {
+ @RequestParam Integer status) {
return R.status(planService.modifyPlanStatus(id, status));
}
diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java
new file mode 100644
index 0000000..3a7b5bb
--- /dev/null
+++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java
@@ -0,0 +1,126 @@
+package com.hnac.hzinfo.inspect.task.aspect;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.google.common.collect.Lists;
+import com.hnac.hzims.message.dto.PlanMsgRecordDto;
+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.TaskUserEntity;
+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 lombok.AllArgsConstructor;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.utils.CollectionUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ObjectUtil;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName TaskGenerateAspect
+ * @description: 消息生成后业务操作
+ * @author: hx
+ * @create: 2023-04-17 11:21
+ * @Version 4.0
+ **/
+@Aspect
+@Component
+@RequiredArgsConstructor
+@Slf4j
+public class TaskGenerateAspect {
+
+ private final IMessageClient messageClient;
+ private final ITaskService taskService;
+ private final ITaskUserService taskUserService;
+
+ /**
+ * 巡检任务开始前发送短信信息阿里云模板
+ **/
+ @Value("${hzims.inspect.task.templateCode.taskBegin}")
+ private String taskBeginTemplateCode;
+
+ /**
+ * 巡检任务结束前发送短信信息阿里云模板
+ **/
+ @Value("${hzims.inspect.task.templateCode.taskEnd}")
+ private String taskEndTemplateCode;
+
+ @Pointcut("execution(* com.hnac.hzinfo.inspect.task.job.service.ITaskJobService.sendTask(..))")
+ public void taskSaveCut() {
+ }
+
+ @AfterReturning(value = "taskSaveCut()")
+ private void saveTask(JoinPoint joinPoint) {
+ Object[] args = joinPoint.getArgs();
+ new Thread(() -> {
+ if(ObjectUtil.isNotEmpty(args[0]) && args[0] instanceof PlanEntity) {
+ PlanEntity plan = (PlanEntity) args[0];
+ List list = taskService.list(
+ Wrappers.lambdaQuery().eq(TaskEntity::getPlanId,plan.getId())
+ );
+ if(CollectionUtil.isNotEmpty(list)) {
+ list.forEach(this::pushMessageByTask);
+ }
+ TaskEntity task = JSONObject.parseObject(JSON.toJSONString(args[0]),TaskEntity.class);
+ this.pushMessageByTask(task);
+ }
+ },"巡检任务消息推送").start();
+ }
+
+ /**
+ * 根据巡检任务生成消息推送记录
+ * @param taskEntity 巡检任务
+ */
+ private void pushMessageByTask(TaskEntity taskEntity) {
+ PlanMsgRecordDto recordDto = new PlanMsgRecordDto();
+ recordDto.setDeptId(taskEntity.getCreateDept());
+ recordDto.setTemplateId(taskEntity.getMessageTemplateId());
+ recordDto.setTaskId(taskEntity.getId());
+ if(Func.isEmpty(AuthUtil.getUserId())) {
+ recordDto.setTenantId(taskEntity.getTenantId());
+ }
+ // 获取巡检任务的消息推送人
+ LambdaQueryWrapper eq = Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId, taskEntity.getId());
+ List taskUserList = taskUserService.list(eq);
+ if(CollectionUtil.isNotEmpty(taskUserList)) {
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ taskUserList.stream().map(TaskUserEntity::getUserId).filter(Func::isNotEmpty).forEach(userId -> {
+ recordDto.setReceiver(userId);
+ recordDto.setCreateUser(userId);
+ Map smsMap = new HashMap<>(2);
+ // 消息开始前提醒
+ recordDto.setResourceCode(taskBeginTemplateCode);
+ smsMap.put("one",taskEntity.getPlanName());
+ smsMap.put("two",df.format(taskEntity.getPlanStartTime()));
+ recordDto.setPlanTime(taskEntity.getPlanStartTime());
+ recordDto.setSmsParam(JSON.toJSONString(smsMap));
+ recordDto.setContent("任务“"+ taskEntity.getPlanName() + "”的计划执行时间是:" + df.format(taskEntity.getPlanStartTime())+ " —— " + df.format(taskEntity.getPlanEndTime()));
+ messageClient.planSendMessage(recordDto);
+ // 消息结束前提醒
+/* smsMap.put("two",df.format(taskEntity.getPlanEndTime()));
+ recordDto.setPlanTime(taskEntity.getPlanEndTime());
+ recordDto.setSmsParam(JSON.toJSONString(smsMap));
+ messageClient.planSendMessage(recordDto);*/
+ });
+ }
+ }
+}
diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java
index 501bef5..b256697 100644
--- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/job/service/TaskJobService.java
+++ b/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.task.TaskContants;
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.service.ITaskObjectProjectContentService;
import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectService;
@@ -89,6 +90,9 @@ public class TaskJobService {
@Autowired
private IDutyMainClient dutyMainClient;
+ @Autowired
+ private TaskGenerateAspect taskGenerateAspect;
+
private final String dateSplit = "_";
/**
@@ -401,6 +405,7 @@ public class TaskJobService {
task.setCreateUser(plan.getCreateUser());
task.setCreateDept(plan.getCreateDept());
task.setAutoVideo(plan.getAutoVideo());
+ task.setMessageTemplateId(plan.getMessageTemplateId());
task.setMethod(plan.getMethod());
task.setEndRemindFlag(true);
task.setStartRemindFlag(true);
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
index 5869b26..bf43821 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
@@ -101,6 +101,7 @@ public class MessageClient extends BladeController implements IMessageClient{
entity.setPusherName(UserCache.getUser(request.getReceiver()).getName());
entity.setAccount(request.getReceiver().toString());
entity.setContent(request.getContent());
+ entity.setSmsParam(request.getSmsParam());
if(Func.isNotEmpty(request.getTenantId())) {
entity.setTenantId(request.getTenantId());
}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
index 82fc76d..db349be 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
@@ -84,6 +84,9 @@ public class MessagePushSchedule {
MessagePushRecordEntity request = records.get(0);
// 完善推送内容
request.setContent(this.getPushContent(type,records));
+ if(MessageConstants.SMS_PUSH.equals(type)) {
+ request.setSmsParam(request.getContent());
+ }
request.setMessageId(IdWorker.getId());
Boolean flag = service.send(request);
if(!flag) {
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java
index 488d385..65ccdf0 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java
@@ -51,7 +51,7 @@ public class SmsMessageServiceImpl implements IMessageService {
R response = smsClient.sendMessage(
Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId(),
request.getResourceCode(),
- request.getContent(),
+ request.getSmsParam(),
this.getAccountByPusher(Long.parseLong(request.getPusher()),request.getType())
);
Assert.isTrue(response.isSuccess(),() -> {
diff --git a/hzims-service/operational/src/main/resources/db/1.0.1.sql b/hzims-service/operational/src/main/resources/db/1.0.1.sql
index 0ab54ec..1beb842 100644
--- a/hzims-service/operational/src/main/resources/db/1.0.1.sql
+++ b/hzims-service/operational/src/main/resources/db/1.0.1.sql
@@ -3,4 +3,10 @@ alter table hzims_oper_maintenance_library add COLUMN `MESSAGE_TEMPLATE_ID` bigi
-- 日常维护计划添加消息模板ID
alter table hzims_oper_maintenance_plan add COLUMN `MESSAGE_TEMPLATE_ID` bigint(20) comment '消息推送模板ID';
-- 日常维护任务添加消息模板ID
-alter table hzims_oper_maintenance_task add COLUMN `MESSAGE_TEMPLATE_ID` bigint(20) comment '消息推送模板ID';
\ No newline at end of file
+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 '设备编码';
\ No newline at end of file