Browse Source

#消息代码同步

zhongwei
yang_shj 1 year ago
parent
commit
28c3776f99
  1. 4
      hzims-biz-common/pom.xml
  2. 32
      hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/constant/TicketProcessConstant.java
  3. 61
      hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/Condition.java
  4. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java
  5. 8
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java
  6. 66
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/BusinessMessageDTO.java
  7. 15
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java
  8. 10
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java
  9. 33
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatResponseVo.java
  10. 33
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatResponseVo.java
  11. 28
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeResponseVo.java
  12. 4
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeVo.java
  13. 6
      hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java
  14. 20
      hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageController.java
  15. 2
      hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java
  16. 14
      hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java
  17. 49
      hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
  18. 8
      hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java
  19. 34
      hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml
  20. 14
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java
  21. 106
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
  22. 79
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java
  23. 1
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java
  24. 46
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java

4
hzims-biz-common/pom.xml

@ -22,6 +22,10 @@
<artifactId>blade-core-auto</artifactId> <artifactId>blade-core-auto</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-common</artifactId>
</dependency>
<!--Json 工具 Start--> <!--Json 工具 Start-->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>

32
hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/constant/TicketProcessConstant.java

@ -1,32 +0,0 @@
package com.hnac.hzims.common.logs.constant;
/**
* 开票常量类
*
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/4/8 10:53
*/
public class TicketProcessConstant {
/**
* 第一种工作票的key
*/
public static final String FIRST_TICKET_KEY = "networking";
/**
* 操作票
*/
public static final String OPERATION_TICKET_KEY = "moreActionBankDirect";
/**
* 水力机械工作票
*/
public static final String MACHINERY_TICKET_KEY = "machinery";
/**
* 日常维护
*/
public static final String MAINTENANCE_KEY = "maintenance";
}

61
hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/Condition.java

@ -32,6 +32,67 @@ public class Condition extends org.springblade.core.mp.support.Condition {
return c; return c;
} }
public static <T> LambdaQueryWrapper<T> getQueryWrapper(Class<T> clazz, Object query) {
QueryWrapper qw = new QueryWrapper();
qw.setEntityClass(clazz);
Class queryClass = query.getClass();
List<Field> fieldList = new ArrayList<>();
while (null != queryClass){
fieldList.addAll(Arrays.asList(queryClass.getDeclaredFields()));
queryClass = queryClass.getSuperclass();
}
for(Field field:fieldList){
field.setAccessible(true);
QueryField queryField = field.getAnnotation(QueryField.class);
if(queryField==null) {
continue;
}
Object value;
try {
value = field.get(query);
} catch (Exception e) {
throw new ServiceException("获取属性性出错");
}
if(value==null) {
continue;
}
List list = null;
if(value instanceof List){
list = (List)value;
if(list.size()==0) {
continue;
}
}
String condition = queryField.condition();
if(Func.isBlank(condition)) {
continue;
}
String fileName = camel2under(field.getName());
if(SqlCondition.EQUAL.equals(condition)) {
qw.eq(fileName, value);
}else if(SqlCondition.LIKE.equals(condition)){
qw.like(fileName,value);
}else if(SqlCondition.LIKE_LEFT.equals(condition)){
qw.likeLeft(fileName,value);
}else if(SqlCondition.LIKE_RIGHT.equals(condition)){
qw.likeRight(fileName,value);
}else if(SqlCondition.NOT_IN.equals(condition)){
String columnName = queryField.columnName();
if(Func.isBlank(columnName)) {
throw new ServiceException("查询不包含条件时需要指定列名");
}
qw.notIn(camel2under(columnName),list);
}else if(SqlCondition.IN.equals(condition)){
String columnName = queryField.columnName();
if(Func.isBlank(columnName)) {
throw new ServiceException("查询包含条件时需要指定列名");
}
qw.in(camel2under(columnName),list);
}
}
return qw.lambda();
}
/** /**
* 支持配置化的模糊查询 * 支持配置化的模糊查询
* @param entity 数据库返回的对象实体 * @param entity 数据库返回的对象实体

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java

@ -12,7 +12,7 @@ public interface AbnormalAlarmConstant {
List<Long> LONG_TYPE_LIST = Arrays.asList(3L,2L,5L,10L,13L,14L); List<Long> LONG_TYPE_LIST = Arrays.asList(3L,2L,5L,10L,13L,14L);
List<String> SEND_MESSSAGE_TYPE_LIST = Arrays.asList("2","13","14"); List<String> SEND_MESSSAGE_TYPE_LIST = Arrays.asList("3","13","14");
String LEVEL_TYPE_LIST = "3,2,5,10,13,14"; String LEVEL_TYPE_LIST = "3,2,5,10,13,14";

8
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java

@ -1,7 +1,6 @@
package com.hnac.hzims.message; package com.hnac.hzims.message;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -53,8 +52,15 @@ public class MessageConstants {
DUTY("duty","值班消息"), DUTY("duty","值班消息"),
SAFE("safe","安全消息"), SAFE("safe","安全消息"),
ACCESS("access","检修消息"), ACCESS("access","检修消息"),
BUSINESS("business","事务消息"),
TICKETMESSAGE("ticket-message","工作票消息"), TICKETMESSAGE("ticket-message","工作票消息"),
OPERATIONTICKETMESSAGE("operation-ticket-message","操作票消息"), OPERATIONTICKETMESSAGE("operation-ticket-message","操作票消息"),
ROUTINEMAINTENANCE("operation-maintenance-message","日常维护消息"),
OPERATIONDEFECTMESSAGE("operation-defect-message","消缺消息"),
OVERHAUL_PLAN("overhaul-plan","检修计划"),
OVERHAUL_TASK("overhaul-task","检修任务"),
; ;
@Getter @Getter
private String key; private String key;

66
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/BusinessMessageDTO.java

@ -0,0 +1,66 @@
package com.hnac.hzims.message.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* @ClassName BusinessMessageDTO
* @description:
* @author: hx
* @create: 2023-06-15 19:10
* @Version 4.0
**/
@Data
@ApiModel("事务消息")
@EqualsAndHashCode
public class BusinessMessageDTO implements Serializable {
@ApiModelProperty(value = "机构ID",required = true)
@NotNull(message = "机构ID不能为空")
private Long deptId;
@ApiModelProperty("机构名称")
private String deptName;
@ApiModelProperty(value = "业务关键字",required = true)
@NotNull(message = "业务关键字不能为空")
private String businessKey;
@ApiModelProperty(value = "业务分类。系统通知:system,事务消息:business,日常提醒:dailyRemind,巡检消息:inspect",required = true)
@NotNull(message = "业务分类不能为空")
private String businessClassify;
@ApiModelProperty("业务任务ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long taskId;
@NotNull
@ApiModelProperty(value = "内容")
private String content;
@NotNull
@ApiModelProperty(value = "主题")
private String subject;
@NotNull
@ApiModelProperty(value = "推送用户")
private String userIds;
@ApiModelProperty(value = "创建用户")
private Long createUser;
@ApiModelProperty(value = "租户ID")
private String tenantId;
}

15
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java

@ -1,10 +1,7 @@
package com.hnac.hzims.message.fegin; package com.hnac.hzims.message.fegin;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.dto.*;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@ -29,6 +26,7 @@ public interface IMessageClient {
String SEND_MESSAGE = API_PREFIX + "/sendMessage"; String SEND_MESSAGE = API_PREFIX + "/sendMessage";
String GET_TEMPLATE_BY_ID = API_PREFIX + "/getMsgTemplateById"; String GET_TEMPLATE_BY_ID = API_PREFIX + "/getMsgTemplateById";
String PLAN_SEND_MESSAGE = API_PREFIX + "/planSendMessage"; String PLAN_SEND_MESSAGE = API_PREFIX + "/planSendMessage";
String SEND_APP_AND_WS_MSG = API_PREFIX + "/sendAppAndWsMsgByUsers";
/** /**
* 推送消息短信 * 推送消息短信
@ -54,4 +52,13 @@ public interface IMessageClient {
**/ **/
@PostMapping(PLAN_SEND_MESSAGE) @PostMapping(PLAN_SEND_MESSAGE)
R<PlanMsgRecordDto> planSendMessage(@RequestBody PlanMsgRecordDto request); R<PlanMsgRecordDto> planSendMessage(@RequestBody PlanMsgRecordDto request);
/**
* 发送多人APPWEB消息
* @Author hx
* @param request
* @return
*/
@PostMapping(value = SEND_APP_AND_WS_MSG,consumes = "application/json; charset=UTF-8")
R<Boolean> sendAppAndWsMsgByUsers(@RequestBody BusinessMessageDTO request);
} }

10
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java

@ -1,9 +1,6 @@
package com.hnac.hzims.message.fegin; package com.hnac.hzims.message.fegin;
import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.dto.*;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@ -34,4 +31,9 @@ public class MessageClientFallback implements IMessageClient {
public R<PlanMsgRecordDto> planSendMessage(PlanMsgRecordDto request) { public R<PlanMsgRecordDto> planSendMessage(PlanMsgRecordDto request) {
return R.fail("调用失败!"); return R.fail("调用失败!");
} }
@Override
public R<Boolean> sendAppAndWsMsgByUsers(BusinessMessageDTO request) {
return R.fail("调用失败!");
}
} }

33
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatResponseVo.java

@ -0,0 +1,33 @@
package com.hnac.hzims.message.vo.msgpushrecord;
import lombok.Data;
import java.util.List;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/6/29 14:18
*/
@Data
public class PushStatResponseVo {
/**
* 推送人名称
*/
private String pusherName;
/**
* 业务分类
*/
private String businessClassify;
/**
* 业务分类名称
*/
private String businessClassifyName;
/**
* 统计数量
*/
private Integer count;
}

33
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatResponseVo.java

@ -0,0 +1,33 @@
package com.hnac.hzims.message.vo.msgpushrecord;
import lombok.Data;
import javax.sound.sampled.Port;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/6/29 13:58
*/
@Data
public class UserPushStatResponseVo {
/**
* 业务分类
*/
private String businessClassify;
/**
* 业务分类名称
*/
private String businessClassifyName;
/**
* 封装map
*/
private Map<String,Integer> params;
}

28
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeResponseVo.java

@ -0,0 +1,28 @@
package com.hnac.hzims.message.vo.msgpushrecord;
import lombok.Data;
import java.util.List;
import java.util.Set;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/6/29 13:46
*/
@Data
public class UserPushStatTypeResponseVo {
/**
* 封装人员信息
*/
private List<String> userNames;
/**
* 封装业务分类对象
*/
private List<UserPushStatResponseVo> userPushStatResponseVos;
}

4
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeVo.java

@ -22,4 +22,8 @@ public class UserPushStatTypeVo {
* 推送业务分类数组 * 推送业务分类数组
*/ */
private List<UserPushStatVo> pushStatList; private List<UserPushStatVo> pushStatList;
} }

6
hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java

@ -18,9 +18,13 @@ public class ThreadPoolConfig {
@Bean @Bean
public ExecutorService logExecutorService() { public ExecutorService logExecutorService() {
return new ThreadPoolExecutor(1, 1, return new ThreadPoolExecutor(2, 5,
0L, TimeUnit.MILLISECONDS, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>()); new LinkedBlockingQueue<Runnable>());
} }
@Bean
public ExecutorService appMessagePushExecutor() {
return new ThreadPoolExecutor(2, 5, 5L, TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
}
} }

20
hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageController.java

@ -7,6 +7,7 @@ import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.dto.WsPushDto; import com.hnac.hzims.message.dto.WsPushDto;
import com.hnac.hzims.message.fegin.IPushMsgClient; import com.hnac.hzims.message.fegin.IPushMsgClient;
import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.service.IMessageService;
import com.hnac.hzims.message.service.IPushMessageService;
import com.hnac.hzims.message.service.impl.MailMessageServiceImpl; import com.hnac.hzims.message.service.impl.MailMessageServiceImpl;
import com.hnac.hzims.message.service.impl.PushMessageServiceImpl; import com.hnac.hzims.message.service.impl.PushMessageServiceImpl;
import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl; import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl;
@ -14,16 +15,16 @@ import com.hnac.hzims.message.service.impl.WebsocketServiceImpl;
import com.hnac.hzims.message.utils.HtmlModule; import com.hnac.hzims.message.utils.HtmlModule;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.SpringUtil;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -79,4 +80,15 @@ public class MessageController extends BladeController {
IMessageService messageService = SpringUtil.getBean(WebsocketServiceImpl.class); IMessageService messageService = SpringUtil.getBean(WebsocketServiceImpl.class);
return messageService.send(wsPushDto); return messageService.send(wsPushDto);
} }
@GetMapping("/sendByUsers")
@ApiOperation("发送APP消息(多人)")
@ApiOperationSupport(order=5)
public R sendByUsers(@ApiParam("消息主题") String subject,
@ApiParam("消息内容") String content,
@ApiParam("用户ID列表") String userIds,
@ApiParam("租户ID") String tenantId) throws Exception {
PushMessageServiceImpl messageService = SpringUtil.getBean(PushMessageServiceImpl.class);
return R.status(messageService.sendByUsers(subject,content, Func.toStrList(",",userIds),tenantId));
}
} }

2
hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java

@ -102,8 +102,6 @@ public class MessagePushRecordController extends BladeController {
@GetMapping("/getPersonalUnreadMessage") @GetMapping("/getPersonalUnreadMessage")
@ApiOperation("获取当前登录人待办消息") @ApiOperation("获取当前登录人待办消息")
@ApiOperationSupport(order = 8) @ApiOperationSupport(order = 8)
@OperationAnnotation(moduleName = "视频集中监控", title = "视频集中监控", action = "获取当前登录人待办消息",
operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE)
public R<List<UnreadMessageVO>> getPersonalUnreadMessage() { public R<List<UnreadMessageVO>> getPersonalUnreadMessage() {
List<UnreadMessageVO> personalUnreadMessage = messagePushRecordService.getPersonalUnreadMessage(); List<UnreadMessageVO> personalUnreadMessage = messagePushRecordService.getPersonalUnreadMessage();
return R.data(personalUnreadMessage); return R.data(personalUnreadMessage);

14
hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java

@ -56,10 +56,22 @@ public class MessageStatisticsController {
/** /**
* 人员发送统计 * 人员发送统计
*/ */
@GetMapping("/userPushStatWithMessgae")
public R userPushStatWithMessgae(MessagePushRecordEntityVo vo) {
log.info("人员发送统计");
List<UserPushStatTypeVo> messagePushRecordVos = messagePushRecordService.userPushStat(vo);
log.info("人员发送统计 返回的数据: {}",messagePushRecordVos);
return R.data(messagePushRecordVos);
}
/**
* 新人员发送统计
*/
@GetMapping("/userPushStat") @GetMapping("/userPushStat")
public R userPushStat(MessagePushRecordEntityVo vo) { public R userPushStat(MessagePushRecordEntityVo vo) {
log.info("人员发送统计"); log.info("人员发送统计");
List<UserPushStatTypeVo> messagePushRecordVos = messagePushRecordService.userPushStat(vo); UserPushStatTypeResponseVo messagePushRecordVos = messagePushRecordService.newUserPushStat(vo);
log.info("人员发送统计 返回的数据: {}",messagePushRecordVos); log.info("人员发送统计 返回的数据: {}",messagePushRecordVos);
return R.data(messagePushRecordVos); return R.data(messagePushRecordVos);
} }

49
hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java

@ -2,28 +2,26 @@ package com.hnac.hzims.message.fegin;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.dto.*;
import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import com.hnac.hzims.message.service.IMessagePushRecordService; import com.hnac.hzims.message.service.IMessagePushRecordService;
import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.service.IMessageService;
import com.hnac.hzims.message.service.IMessageTemplateService; import com.hnac.hzims.message.service.IMessageTemplateService;
import com.hnac.hzims.message.service.impl.PushMessageServiceImpl;
import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl; import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl;
import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -33,7 +31,9 @@ import javax.validation.Valid;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* @author hx * @author hx
@ -115,4 +115,37 @@ public class MessageClient extends BladeController implements IMessageClient{
return R.success("推送成功!"); return R.success("推送成功!");
} }
@Override
@PostMapping(value = SEND_APP_AND_WS_MSG , produces="application/json; charset=UTF-8")
public R<Boolean> sendAppAndWsMsgByUsers(@RequestBody BusinessMessageDTO request) {
// 保存消息记录
List<MessagePushRecordEntity> pushRecords = Func.toLongList(request.getUserIds()).stream().flatMap(userId -> {
long messageId = IdWorker.getId();
return Lists.newArrayList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH).stream().map(messageType -> {
MessagePushRecordEntity record = BeanUtil.copy(request, MessagePushRecordEntity.class);
record.setMessageId(messageId);
record.setPusher(userId.toString());
record.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null));
record.setPushType(MessageConstants.IMMEDIATELY);
record.setAccount(userId.toString());
record.setPlanTime(LocalDateTime.now());
record.setType(messageType);
record.setCreateDept(record.getDeptId());
return record;
});
}).collect(Collectors.toList());
boolean saveResult = recordService.saveBatch(pushRecords);
if(saveResult) {
List<MessagePushRecordEntity> appRecords = pushRecords.stream().filter(record -> MessageConstants.APP_PUSH.equals(record.getType())).collect(Collectors.toList());
// 推送消息 - app
Boolean appFlag = recordService.sendAppMsgByUsers(request, appRecords);
// 推送消息 - web
Boolean wsFlag = recordService.sendWsMsgByUsers(CollectionUtils.subtract(pushRecords, appRecords).stream().collect(Collectors.toList()));
return R.data(appFlag && wsFlag);
}
else {
return R.data(false);
}
}
} }

8
hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java

@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List; import java.util.List;
import java.util.Set;
public interface MessagePushRecordMapper extends UserDataScopeBaseMapper<MessagePushRecordEntity> { public interface MessagePushRecordMapper extends UserDataScopeBaseMapper<MessagePushRecordEntity> {
@ -43,4 +44,11 @@ public interface MessagePushRecordMapper extends UserDataScopeBaseMapper<Message
*/ */
List<Integer> selectByStatus(); List<Integer> selectByStatus();
/**
* 新人员发送统计
* @param vo
* @return
*/
List<PushStatResponseVo> selectUserPushStat(@Param("vo") MessagePushRecordEntityVo vo);
} }

34
hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml

@ -14,6 +14,7 @@
</resultMap> </resultMap>
<!-- 根据type统计数量--> <!-- 根据type统计数量-->
<select id="smsPushStat" resultType="com.hnac.hzims.message.vo.msgpushrecord.MessagePushRecordVo"> <select id="smsPushStat" resultType="com.hnac.hzims.message.vo.msgpushrecord.MessagePushRecordVo">
select count(1) power, select count(1) power,
@ -27,6 +28,7 @@
and and
DEPT_ID = #{vo.stationCode} DEPT_ID = #{vo.stationCode}
</if> </if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where> </where>
group by strMonth, TYPE group by strMonth, TYPE
</select> </select>
@ -50,6 +52,7 @@
and and
type = #{vo.type} type = #{vo.type}
</if> </if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where> </where>
group by businessClassify group by businessClassify
</select> </select>
@ -74,6 +77,7 @@
and and
type = #{vo.type} type = #{vo.type}
</if> </if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where> </where>
group by businessClassify, pusherName group by businessClassify, pusherName
</select> </select>
@ -107,6 +111,7 @@
and and
type = #{vo.type} type = #{vo.type}
</if> </if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where> </where>
group by businessClassify,status group by businessClassify,status
</select> </select>
@ -116,4 +121,33 @@
from hzims_message_push_record from hzims_message_push_record
group by STATUS group by STATUS
</select> </select>
<select id="selectUserPushStat" resultType="com.hnac.hzims.message.vo.msgpushrecord.PushStatResponseVo">
select PUSHER_NAME pusherName,
BUSINESS_CLASSIFY businessClassify,
count(1) count
from hzims_message_push_record
<where>
IS_DELETED = 0
<if test="vo.stationCode != null and vo.stationCode != ''">
and
DEPT_ID = #{vo.stationCode}
</if>
<if test="vo.yearMonth != null">
and
date_format(PLAN_TIME, '%Y-%m') = #{vo.yearMonth}
</if>
<if test="vo.type != null and vo.type != ''">
and
type = #{vo.type}
</if>
and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null)
</where>
group by businessClassify,pusherName
</select>
</mapper> </mapper>

14
hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java

@ -1,11 +1,14 @@
package com.hnac.hzims.message.service; package com.hnac.hzims.message.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.vo.UnreadMessageVO; import com.hnac.hzims.message.vo.UnreadMessageVO;
import com.hnac.hzims.message.vo.msgpushrecord.*; import com.hnac.hzims.message.vo.msgpushrecord.*;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
@ -84,4 +87,15 @@ public interface IMessagePushRecordService extends BaseService<MessagePushRecord
**/ **/
List<UnreadMessageVO> getPersonalAppUnreadMessage(); List<UnreadMessageVO> getPersonalAppUnreadMessage();
Boolean sendAppMsgByUsers(BusinessMessageDTO request,List<MessagePushRecordEntity> records);
Boolean sendWsMsgByUsers(List<MessagePushRecordEntity> request);
/**
* 新人员发送统计
* @param vo
* @return
*/
UserPushStatTypeResponseVo newUserPushStat(MessagePushRecordEntityVo vo);
} }

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

@ -14,6 +14,7 @@ import com.google.common.collect.Lists;
import com.hnac.hzims.common.utils.CacheUtil; import com.hnac.hzims.common.utils.CacheUtil;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.config.MessageFactory; import com.hnac.hzims.message.config.MessageFactory;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.enums.PushStatEnum; import com.hnac.hzims.message.enums.PushStatEnum;
import com.hnac.hzims.message.mapper.MessagePushRecordMapper; import com.hnac.hzims.message.mapper.MessagePushRecordMapper;
@ -22,29 +23,25 @@ import com.hnac.hzims.message.service.IMessagePushRecordService;
import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.service.IMessageService;
import com.hnac.hzims.message.vo.UnreadMessageVO; import com.hnac.hzims.message.vo.UnreadMessageVO;
import com.hnac.hzims.message.vo.msgpushrecord.*; import com.hnac.hzims.message.vo.msgpushrecord.*;
import io.minio.messages.Item;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition; import com.hnac.hzims.common.utils.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.system.cache.DictCache; import org.springblade.system.cache.DictCache;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.validation.Valid; import javax.validation.Valid;
import java.time.LocalDate; import java.time.*;
import java.time.LocalDateTime;
import java.time.Year;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -118,13 +115,14 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
* @return QueryWrapper * @return QueryWrapper
*/ */
private LambdaQueryWrapper<MessagePushRecordEntity> getQueryWrapper(MessagePushRecordEntity request) { private LambdaQueryWrapper<MessagePushRecordEntity> getQueryWrapper(MessagePushRecordEntity request) {
LambdaQueryWrapper<MessagePushRecordEntity> lambda = Condition.getQueryWrapper(request).lambda(); LambdaQueryWrapper<MessagePushRecordEntity> lambda = Condition.getQueryWrapper(MessagePushRecordEntity.class,request);
if (Func.isNotEmpty(request.getStartTime())) { if(Func.isNotEmpty(request.getStartTime())) {
lambda.ge(MessagePushRecordEntity::getPushTime, request.getStartTime()); lambda.ge(MessagePushRecordEntity::getPushTime, LocalDateTime.of(request.getStartTime(), LocalTime.MIN));
} }
if (Func.isNotEmpty(request.getEndTime())) { if(Func.isNotEmpty(request.getEndTime())) {
lambda.le(MessagePushRecordEntity::getPushTime, request.getEndTime()); lambda.le(MessagePushRecordEntity::getPushTime, LocalDateTime.of(request.getEndTime(), LocalTime.MAX));
} }
lambda.eq(Func.isNotEmpty(request.getStatus()),MessagePushRecordEntity::getStatus,request.getStatus());
lambda.orderByDesc(MessagePushRecordEntity::getPushTime); lambda.orderByDesc(MessagePushRecordEntity::getPushTime);
return lambda; return lambda;
} }
@ -234,11 +232,55 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
String businessTypeName = this.getBusinessClassifyByName(businessClassify); String businessTypeName = this.getBusinessClassifyByName(businessClassify);
pushStat.setBusinessClassifyName(businessTypeName); pushStat.setBusinessClassifyName(businessTypeName);
}); });
}); });
return userPushStatTypeVos; return userPushStatTypeVos;
} }
/**
* 新人员发送统计
*
* @param vo
* @return
*/
@Override
public UserPushStatTypeResponseVo newUserPushStat(MessagePushRecordEntityVo vo) {
UserPushStatTypeResponseVo pushStatList = new UserPushStatTypeResponseVo();
List<UserPushStatResponseVo> results = new ArrayList<>();
List<PushStatResponseVo> pushStat = baseMapper.selectUserPushStat(vo);
List<String> list = pushStat.stream().map(item -> item.getPusherName()).distinct().collect(Collectors.toList());
pushStatList.setUserNames(list);
//封装业务分类对象
Map<String, List<PushStatResponseVo>> collect = pushStat.stream().collect(Collectors.groupingBy(PushStatResponseVo::getBusinessClassify));
//
for (Map.Entry<String, List<PushStatResponseVo>> entry : collect.entrySet()) {
List<String> arrayList = Lists.newArrayList(list);
UserPushStatResponseVo userPushStatTypeResponseVo = new UserPushStatResponseVo();
//存储key
userPushStatTypeResponseVo.setBusinessClassify(entry.getKey());
userPushStatTypeResponseVo.setBusinessClassifyName(this.getBusinessClassifyByName(entry.getKey()));
TreeMap<String, Integer> treeMap = new TreeMap<>();
//存储业务分类
List<PushStatResponseVo> pushStatResponseVos = entry.getValue();
for (PushStatResponseVo pushStatResponseVo : pushStatResponseVos) {
if (arrayList.contains(pushStatResponseVo.getPusherName())){
arrayList.remove(pushStatResponseVo.getPusherName());
}
treeMap.put(pushStatResponseVo.getPusherName(),pushStatResponseVo.getCount());
}
//如果不存在设为0
for (String name : arrayList) {
treeMap.put(name,0);
}
userPushStatTypeResponseVo.setParams(treeMap);
results.add(userPushStatTypeResponseVo);
}
pushStatList.setUserPushStatResponseVos(results);
return pushStatList;
}
/** /**
* 推送成功失败统计 * 推送成功失败统计
* *
@ -321,6 +363,40 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@Override
public Boolean sendAppMsgByUsers(BusinessMessageDTO request, List<MessagePushRecordEntity> records) {
PushMessageServiceImpl service = SpringUtil.getBean(PushMessageServiceImpl.class);
try {
boolean sendFlag = service.sendByUsers(request.getSubject(), request.getContent(), Arrays.asList(request.getUserIds().split(",")), request.getTenantId());
if (sendFlag) {
return this.update(Wrappers.<MessagePushRecordEntity>lambdaUpdate()
.set(MessagePushRecordEntity::getPushTime, LocalDateTime.now())
.set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS)
.in(MessagePushRecordEntity::getId, records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList()))
);
}
return false;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
@Override
public Boolean sendWsMsgByUsers(List<MessagePushRecordEntity> request) {
WebsocketServiceImpl service = SpringUtil.getBean(WebsocketServiceImpl.class);
request.forEach(record -> {
boolean sendFlag = service.send(record);
if (sendFlag) {
this.update(Wrappers.<MessagePushRecordEntity>lambdaUpdate()
.set(MessagePushRecordEntity::getPushTime, LocalDateTime.now())
.set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS)
.in(MessagePushRecordEntity::getId, record.getId())
);
}
});
return true;
}
/** /**
* 状态 ===> 状态名称 * 状态 ===> 状态名称

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

@ -29,6 +29,9 @@ import org.springframework.util.Assert;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
/** /**
@ -40,6 +43,7 @@ public class PushMessageServiceImpl implements IMessageService {
private final IPushClient pushClient; private final IPushClient pushClient;
private final BladeLogger logger; private final BladeLogger logger;
private final ExecutorService appMessagePushExecutor;
@Override @Override
@SaveLog(type = MessageConstants.APP_NAME) @SaveLog(type = MessageConstants.APP_NAME)
@ -85,36 +89,51 @@ public class PushMessageServiceImpl implements IMessageService {
} }
@Override @Override
public boolean send(MessagePushRecordEntity request) { public boolean send(MessagePushRecordEntity request) {
PushInfoVO pushInfoVO = new PushInfoVO(); String tenantId = Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId();
pushInfoVO.setTenantId(Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId()); try {
ArrayList<PlatformType> platformTypes = Lists.newArrayList(PlatformType.Android, PlatformType.IOS); return this.sendByUsers(request.getSubject(), request.getContent(), Func.toStrList(",",request.getPusher()),tenantId);
platformTypes.forEach(platformType -> { }
PushPlatform platform = PushPlatform.newBuilder().addPlatformType(platformType).build(); catch (Exception e) {
R<PushResponse> response; throw new ServiceException(e.getMessage());
// 安卓推送 }
if(PlatformType.Android.equals(platformType)) { }
PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, Lists.newArrayList(request.getPusher())).build();
PushInfo pushInfo = new PushInfo("ops-push-android", request.getSubject(), request.getContent(), /**
"", null, platform, pushAudience); * 发送APP消息(多人)
pushInfoVO.setPushInfo(pushInfo); * @param subject 消息主题
response = pushClient.tenantPush(pushInfoVO); * @param content 消息内容
} * @param userIds 用户ID列表
// IOS推送 * @param tenantId 租户ID
else if(PlatformType.IOS.equals(platformType)) { * @return
PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, Lists.newArrayList(request.getPusher())).build(); */
PushInfo pushInfo = new PushInfo("ops-push-ios", request.getSubject(), request.getContent(), public boolean sendByUsers(String subject, String content, List<String> userIds,String tenantId) throws Exception {
"", null, platform, pushAudience); // 安卓推送
pushInfoVO.setPushInfo(pushInfo); FutureTask<Boolean> androidPush = new FutureTask<>(() -> {
response = pushClient.tenantPush(pushInfoVO); PushInfoVO pushInfoVO = new PushInfoVO();
} else { PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.Android).build();
response = null; PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build();
} PushInfo pushInfo = new PushInfo("ops-push-android", subject, content,"", null, pushPlatform, pushAudience);
Assert.isTrue(ObjectUtil.isNotEmpty(response) && response.isSuccess(),() -> { pushInfoVO.setPushInfo(pushInfo);
logger.error("hzims-message:PushMessageServiceImpl:send", "请求参数为:"+JSON.toJSONString(pushInfoVO)+"错误信息为:"+response.getMsg()); pushInfoVO.setTenantId(tenantId);
throw new ServiceException(response.getMsg()); R<PushResponse> pushResult = pushClient.tenantPush(pushInfoVO);
}); return pushResult.isSuccess();
}); });
return true; appMessagePushExecutor.submit(new Thread(androidPush,"安卓推送"));
// IOS推送
FutureTask<Boolean> iosPush = new FutureTask<>(() -> {
PushInfoVO pushInfoVO = new PushInfoVO();
PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.IOS).build();
PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build();
PushInfo pushInfo = new PushInfo("ops-push-ios", subject, content,"", null, pushPlatform, pushAudience);
pushInfoVO.setPushInfo(pushInfo);
pushInfoVO.setTenantId(tenantId);
R<PushResponse> pushResult = pushClient.tenantPush(pushInfoVO);
return pushResult.isSuccess();
});
appMessagePushExecutor.submit(new Thread(iosPush,"ios推送"));
return androidPush.get() && iosPush.get();
} }
} }

1
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java

@ -23,6 +23,7 @@ import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.WebSocketSession;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**

46
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java

@ -1,16 +1,15 @@
package com.hnac.hzims.operational.alert.service.impl; package com.hnac.hzims.operational.alert.service.impl;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant;
import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity; import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity;
import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity;
import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity;
import com.hnac.hzims.operational.alert.mapper.AbnormalAlarmMapper; import com.hnac.hzims.operational.alert.mapper.AbnormalAlarmMapper;
import com.hnac.hzims.operational.alert.service.AbnormalAlarmService; import com.hnac.hzims.operational.alert.service.AbnormalAlarmService;
import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService; import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.ISoeClient;
@ -18,7 +17,6 @@ import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation;
import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
@ -27,13 +25,13 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.function.Function; import java.util.function.Function;
@ -203,34 +201,46 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
if(CollectionUtil.isEmpty(depts)){ if(CollectionUtil.isEmpty(depts)){
return; return;
} }
// 获取站点用户 List<User> users = this.parentAuthUser(depts.get(0));
R<List<User>> result = userClient.userListByDeptId(depts.get(0)); if(CollectionUtil.isEmpty(users)){
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return; return;
} }
MessagePushRecordDto message = new MessagePushRecordDto(); BusinessMessageDTO message = new BusinessMessageDTO();
message.setDeptId(depts.get(0));
message.setBusinessClassify("warning"); message.setBusinessClassify("warning");
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey());
message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription());
message.setTaskId(entity.getId()); message.setTaskId(entity.getId());
message.setTenantId("200000"); message.setTenantId("200000");
message.setContent(entity.getSoeExplain()); message.setContent(entity.getSoeExplain());
message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
message.setPushType(MessageConstants.IMMEDIATELY);
message.setDeptId(depts.get(0));
message.setCreateDept(depts.get(0));
R<String> deptName = sysClient.getDeptName(depts.get(0)); R<String> deptName = sysClient.getDeptName(depts.get(0));
if (deptName.isSuccess()) { if (deptName.isSuccess()) {
message.setDeptName(deptName.getData()); message.setDeptName(deptName.getData());
} }
User admin = userClient.userByAccount("200000", "admin").getData(); User admin = userClient.userByAccount("200000", "admin").getData();
message.setCreateUser(admin.getId()); message.setCreateUser(admin.getId());
result.getData().forEach(user->{ messageClient.sendAppAndWsMsgByUsers(message);
message.setPusher(String.valueOf(user.getId()));
message.setPusherName(user.getName());
message.setAccount(String.valueOf(user.getId()));
messageClient.sendMessage(message);
});
}); });
} }
/**
* 获取本级机构或者上级机构用户
* @param deptId
* @return
*/
private List<User> parentAuthUser(Long deptId) {
List<User> users = new ArrayList<>();
R<List<User>> selfs = userClient.userListByDeptId(deptId);
if(selfs.isSuccess() && CollectionUtil.isNotEmpty(selfs.getData())){
users.addAll(selfs.getData());
}
R<Dept> dept = sysClient.getDept(deptId);
if(dept.isSuccess() && ObjectUtil.isNotEmpty(dept.getData())){
R<List<User>> parents = userClient.userListByDeptId(deptId);
if(parents.isSuccess() && CollectionUtil.isNotEmpty(parents.getData())){
users.addAll(parents.getData().stream().filter(o->!users.stream().map(User::getId).collect(Collectors.toList()).contains(o.getId())).collect(Collectors.toList()));
}
}
return users;
}
} }

Loading…
Cancel
Save