diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/vo/PlanVO.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/vo/PlanVO.java index f2dee4b..d12668a 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/vo/PlanVO.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/vo/PlanVO.java @@ -4,6 +4,8 @@ package com.hnac.hzinfo.inspect.plan.vo; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import com.google.common.collect.Lists; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -184,4 +186,8 @@ public class PlanVO extends TenantEntity implements Serializable { /** hzims add end **/ + @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 83c4274..6743e12 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 @@ -171,4 +171,8 @@ public class TaskEntity extends TenantEntity { @JsonSerialize(nullsUsing = NullSerializer.class) private Long messageTemplateId; + @ApiModelProperty(value = "消息推送状态") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Boolean pushStatus; + } 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 index 3a7b5bb..d437893 100644 --- 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 @@ -76,10 +76,16 @@ public class TaskGenerateAspect { PlanEntity plan = (PlanEntity) args[0]; List list = taskService.list( Wrappers.lambdaQuery().eq(TaskEntity::getPlanId,plan.getId()) + .isNull(TaskEntity::getPushStatus) ); if(CollectionUtil.isNotEmpty(list)) { - list.forEach(this::pushMessageByTask); + list.forEach(task -> { + this.pushMessageByTask(task); + task.setPushStatus(true); + taskService.updateById(task); + }); } + TaskEntity task = JSONObject.parseObject(JSON.toJSONString(args[0]),TaskEntity.class); this.pushMessageByTask(task); } @@ -91,6 +97,7 @@ public class TaskGenerateAspect { * @param taskEntity 巡检任务 */ private void pushMessageByTask(TaskEntity taskEntity) { + log.info("======================进入消息推送======================"); PlanMsgRecordDto recordDto = new PlanMsgRecordDto(); recordDto.setDeptId(taskEntity.getCreateDept()); recordDto.setTemplateId(taskEntity.getMessageTemplateId()); @@ -114,12 +121,13 @@ public class TaskGenerateAspect { recordDto.setPlanTime(taskEntity.getPlanStartTime()); recordDto.setSmsParam(JSON.toJSONString(smsMap)); recordDto.setContent("任务“"+ taskEntity.getPlanName() + "”的计划执行时间是:" + df.format(taskEntity.getPlanStartTime())+ " —— " + df.format(taskEntity.getPlanEndTime())); + log.info("巡检任务开始,推送对象:{}",JSON.toJSONString(recordDto)); messageClient.planSendMessage(recordDto); // 消息结束前提醒 -/* smsMap.put("two",df.format(taskEntity.getPlanEndTime())); + smsMap.put("two",df.format(taskEntity.getPlanEndTime())); recordDto.setPlanTime(taskEntity.getPlanEndTime()); recordDto.setSmsParam(JSON.toJSONString(smsMap)); - messageClient.planSendMessage(recordDto);*/ + messageClient.planSendMessage(recordDto); }); } } diff --git a/hzims-service/inspect/src/main/resources/db/1.0.0.sql b/hzims-service/inspect/src/main/resources/db/1.0.0.sql index 9053136..9747c3a 100644 --- a/hzims-service/inspect/src/main/resources/db/1.0.0.sql +++ b/hzims-service/inspect/src/main/resources/db/1.0.0.sql @@ -1,4 +1,6 @@ -- 巡检计划添加消息模板字段 alter table `hz_st_re_plan` add column `message_template_id` bigint(20) comment '消息模板ID'; -- 巡检任务添加消息模板字段 -alter table `hz_st_ex_task` add column `message_template_id` bigint(20) comment '消息模板ID'; \ No newline at end of file +alter table `hz_st_ex_task` add column `message_template_id` bigint(20) comment '消息模板ID'; + +alter table hz_st_ex_task add COLUMN `push_status` bigint(1) default null comment '推送状态'; \ No newline at end of file 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 97357e2..7c63987 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 @@ -77,28 +77,30 @@ public class MessagePushSchedule { * @return void **/ private void sendMessage(List list) { - Map> collect = list.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getAccount)); - String type = list.get(0).getType(); - IMessageService service = MessageFactory.getMessageSend(type); - collect.forEach((account,records) -> { - 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) { - return; - } - List ids = records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList()); - // 更新消息推送状态 - LambdaUpdateWrapper lwq = Wrappers.lambdaUpdate() - .set(MessagePushRecordEntity::getStatus, flag ? MessageConstants.PUSH_SUCCESS : MessageConstants.PUSH_FAILED) - .set(MessagePushRecordEntity::getPushTime,LocalDateTime.now()) - .in(MessagePushRecordEntity::getId, ids); - recordService.update(lwq); + Map> typeGroup = list.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getType)); + typeGroup.forEach((type,typeList) -> { + Map> collect = typeList.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getAccount)); + IMessageService service = MessageFactory.getMessageSend(type); + collect.forEach((account,records) -> { + 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) { + return; + } + List ids = records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList()); + // 更新消息推送状态 + LambdaUpdateWrapper lwq = Wrappers.lambdaUpdate() + .set(MessagePushRecordEntity::getStatus, flag ? MessageConstants.PUSH_SUCCESS : MessageConstants.PUSH_FAILED) + .set(MessagePushRecordEntity::getPushTime,LocalDateTime.now()) + .in(MessagePushRecordEntity::getId, ids); + recordService.update(lwq); + }); }); } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java index 9237990..437cacc 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java @@ -95,10 +95,10 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl platformTypes = Lists.newArrayList(PlatformType.Android, PlatformType.IOS); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 3322ece..85ee6c1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -71,10 +71,6 @@ public class StationServiceImpl extends BaseServiceImpl { - throw new ServiceException("创建/修改机构失败!"); - }); LambdaQueryWrapper lwq; if (Func.isEmpty(req.getId())) { lwq = Wrappers.lambdaQuery() @@ -88,6 +84,10 @@ public class StationServiceImpl extends BaseServiceImpl { throw new ServiceException("该站点名/编码已有对应记录,请找到相应记录做修改处理"); }); + // 新建站点的所属机构 + Assert.isTrue(this.buildDept(req), () -> { + throw new ServiceException("创建/修改机构失败!"); + }); Optional sort = Optional.ofNullable(this.getStationMaxOrder()); req.setSort(sort.isPresent() ? sort.get() + 1 : 1); Assert.isTrue(this.saveOrUpdate(req), () -> {