Browse Source

# 修改建站是有相同编码时保存失败的bug

# 消息推送定时任务推送规则修改
# 巡检任务消息推送成功标识位修改
zhongwei
haungxing 2 years ago
parent
commit
e974e79ebf
  1. 6
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/plan/vo/PlanVO.java
  2. 4
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java
  3. 14
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java
  4. 2
      hzims-service/inspect/src/main/resources/db/1.0.0.sql
  5. 6
      hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
  6. 2
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
  7. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

6
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; package com.hnac.hzinfo.inspect.plan.vo;
import com.fasterxml.jackson.annotation.JsonFormat; 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 com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -184,4 +186,8 @@ public class PlanVO extends TenantEntity implements Serializable {
/** hzims add end **/ /** hzims add end **/
@ApiModelProperty(value = "消息模板ID")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long messageTemplateId;
} }

4
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) @JsonSerialize(nullsUsing = NullSerializer.class)
private Long messageTemplateId; private Long messageTemplateId;
@ApiModelProperty(value = "消息推送状态")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Boolean pushStatus;
} }

14
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]; PlanEntity plan = (PlanEntity) args[0];
List<TaskEntity> list = taskService.list( List<TaskEntity> list = taskService.list(
Wrappers.<TaskEntity>lambdaQuery().eq(TaskEntity::getPlanId,plan.getId()) Wrappers.<TaskEntity>lambdaQuery().eq(TaskEntity::getPlanId,plan.getId())
.isNull(TaskEntity::getPushStatus)
); );
if(CollectionUtil.isNotEmpty(list)) { 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); TaskEntity task = JSONObject.parseObject(JSON.toJSONString(args[0]),TaskEntity.class);
this.pushMessageByTask(task); this.pushMessageByTask(task);
} }
@ -91,6 +97,7 @@ public class TaskGenerateAspect {
* @param taskEntity 巡检任务 * @param taskEntity 巡检任务
*/ */
private void pushMessageByTask(TaskEntity taskEntity) { private void pushMessageByTask(TaskEntity taskEntity) {
log.info("======================进入消息推送======================");
PlanMsgRecordDto recordDto = new PlanMsgRecordDto(); PlanMsgRecordDto recordDto = new PlanMsgRecordDto();
recordDto.setDeptId(taskEntity.getCreateDept()); recordDto.setDeptId(taskEntity.getCreateDept());
recordDto.setTemplateId(taskEntity.getMessageTemplateId()); recordDto.setTemplateId(taskEntity.getMessageTemplateId());
@ -114,12 +121,13 @@ public class TaskGenerateAspect {
recordDto.setPlanTime(taskEntity.getPlanStartTime()); recordDto.setPlanTime(taskEntity.getPlanStartTime());
recordDto.setSmsParam(JSON.toJSONString(smsMap)); recordDto.setSmsParam(JSON.toJSONString(smsMap));
recordDto.setContent("任务“"+ taskEntity.getPlanName() + "”的计划执行时间是:" + df.format(taskEntity.getPlanStartTime())+ " —— " + df.format(taskEntity.getPlanEndTime())); recordDto.setContent("任务“"+ taskEntity.getPlanName() + "”的计划执行时间是:" + df.format(taskEntity.getPlanStartTime())+ " —— " + df.format(taskEntity.getPlanEndTime()));
log.info("巡检任务开始,推送对象:{}",JSON.toJSONString(recordDto));
messageClient.planSendMessage(recordDto); messageClient.planSendMessage(recordDto);
// 消息结束前提醒 // 消息结束前提醒
/* smsMap.put("two",df.format(taskEntity.getPlanEndTime())); smsMap.put("two",df.format(taskEntity.getPlanEndTime()));
recordDto.setPlanTime(taskEntity.getPlanEndTime()); recordDto.setPlanTime(taskEntity.getPlanEndTime());
recordDto.setSmsParam(JSON.toJSONString(smsMap)); recordDto.setSmsParam(JSON.toJSONString(smsMap));
messageClient.planSendMessage(recordDto);*/ messageClient.planSendMessage(recordDto);
}); });
} }
} }

2
hzims-service/inspect/src/main/resources/db/1.0.0.sql

@ -2,3 +2,5 @@
alter table `hz_st_re_plan` add column `message_template_id` bigint(20) comment '消息模板ID'; 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'; 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 '推送状态';

6
hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java

@ -77,8 +77,9 @@ public class MessagePushSchedule {
* @return void * @return void
**/ **/
private void sendMessage(List<MessagePushRecordEntity> list) { private void sendMessage(List<MessagePushRecordEntity> list) {
Map<String, List<MessagePushRecordEntity>> collect = list.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getAccount)); Map<String, List<MessagePushRecordEntity>> typeGroup = list.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getType));
String type = list.get(0).getType(); typeGroup.forEach((type,typeList) -> {
Map<String, List<MessagePushRecordEntity>> collect = typeList.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getAccount));
IMessageService service = MessageFactory.getMessageSend(type); IMessageService service = MessageFactory.getMessageSend(type);
collect.forEach((account,records) -> { collect.forEach((account,records) -> {
MessagePushRecordEntity request = records.get(0); MessagePushRecordEntity request = records.get(0);
@ -100,6 +101,7 @@ public class MessagePushSchedule {
.in(MessagePushRecordEntity::getId, ids); .in(MessagePushRecordEntity::getId, ids);
recordService.update(lwq); recordService.update(lwq);
}); });
});
} }
/** @Author hx /** @Author hx

2
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java

@ -95,10 +95,10 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean saveAndSend(MessagePushRecordEntity request) { public Boolean saveAndSend(MessagePushRecordEntity request) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
request.setStatus(MessageConstants.NOT_PUSH);
if (MessageConstants.IMMEDIATELY.equals(request.getPushType())) { if (MessageConstants.IMMEDIATELY.equals(request.getPushType())) {
request.setPlanTime(now); request.setPlanTime(now);
request.setPushTime(now); request.setPushTime(now);
request.setStatus(MessageConstants.NOT_PUSH);
// 立即推送消息 // 立即推送消息
if (this.save(request) && Func.isNotEmpty(request.getId())) { if (this.save(request) && Func.isNotEmpty(request.getId())) {
return this.send(request.getId()); return this.send(request.getId());

8
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -71,10 +71,6 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
@Override @Override
public void buildStation(StationEntity req) { public void buildStation(StationEntity req) {
// 新建站点的所属机构
Assert.isTrue(this.buildDept(req), () -> {
throw new ServiceException("创建/修改机构失败!");
});
LambdaQueryWrapper lwq; LambdaQueryWrapper lwq;
if (Func.isEmpty(req.getId())) { if (Func.isEmpty(req.getId())) {
lwq = Wrappers.<StationEntity>lambdaQuery() lwq = Wrappers.<StationEntity>lambdaQuery()
@ -88,6 +84,10 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
Assert.isTrue(CollectionUtil.isEmpty(list), () -> { Assert.isTrue(CollectionUtil.isEmpty(list), () -> {
throw new ServiceException("该站点名/编码已有对应记录,请找到相应记录做修改处理"); throw new ServiceException("该站点名/编码已有对应记录,请找到相应记录做修改处理");
}); });
// 新建站点的所属机构
Assert.isTrue(this.buildDept(req), () -> {
throw new ServiceException("创建/修改机构失败!");
});
Optional<Integer> sort = Optional.ofNullable(this.getStationMaxOrder()); Optional<Integer> sort = Optional.ofNullable(this.getStationMaxOrder());
req.setSort(sort.isPresent() ? sort.get() + 1 : 1); req.setSort(sort.isPresent() ? sort.get() + 1 : 1);
Assert.isTrue(this.saveOrUpdate(req), () -> { Assert.isTrue(this.saveOrUpdate(req), () -> {

Loading…
Cancel
Save