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. 46
      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. 2
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java
  8. 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;
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;
}

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)
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];
List<TaskEntity> list = taskService.list(
Wrappers.<TaskEntity>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);
});
}
}

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_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 '推送状态';

46
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<MessagePushRecordEntity> list) {
Map<String, List<MessagePushRecordEntity>> 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<Long> ids = records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList());
// 更新消息推送状态
LambdaUpdateWrapper<MessagePushRecordEntity> lwq = Wrappers.<MessagePushRecordEntity>lambdaUpdate()
.set(MessagePushRecordEntity::getStatus, flag ? MessageConstants.PUSH_SUCCESS : MessageConstants.PUSH_FAILED)
.set(MessagePushRecordEntity::getPushTime,LocalDateTime.now())
.in(MessagePushRecordEntity::getId, ids);
recordService.update(lwq);
Map<String, List<MessagePushRecordEntity>> typeGroup = list.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getType));
typeGroup.forEach((type,typeList) -> {
Map<String, List<MessagePushRecordEntity>> 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<Long> ids = records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList());
// 更新消息推送状态
LambdaUpdateWrapper<MessagePushRecordEntity> lwq = Wrappers.<MessagePushRecordEntity>lambdaUpdate()
.set(MessagePushRecordEntity::getStatus, flag ? MessageConstants.PUSH_SUCCESS : MessageConstants.PUSH_FAILED)
.set(MessagePushRecordEntity::getPushTime,LocalDateTime.now())
.in(MessagePushRecordEntity::getId, ids);
recordService.update(lwq);
});
});
}

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)
public Boolean saveAndSend(MessagePushRecordEntity request) {
LocalDateTime now = LocalDateTime.now();
request.setStatus(MessageConstants.NOT_PUSH);
if (MessageConstants.IMMEDIATELY.equals(request.getPushType())) {
request.setPlanTime(now);
request.setPushTime(now);
request.setStatus(MessageConstants.NOT_PUSH);
// 立即推送消息
if (this.save(request) && Func.isNotEmpty(request.getId())) {
return this.send(request.getId());

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

@ -85,7 +85,7 @@ public class PushMessageServiceImpl implements IMessageService {
}
@Override
public boolean send(MessagePushRecordEntity request) {
public boolean send(MessagePushRecordEntity request) {
PushInfoVO pushInfoVO = new PushInfoVO();
pushInfoVO.setTenantId(Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId());
ArrayList<PlatformType> platformTypes = Lists.newArrayList(PlatformType.Android, PlatformType.IOS);

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

Loading…
Cancel
Save