Browse Source

# 消息模块

# 巡检模块变更为HZIMS子模块
zhongwei
haungxing 2 years ago
parent
commit
a7485570fe
  1. 10
      hzims-service-api/inspect-api/pom.xml
  2. 8
      hzims-service-api/message-api/pom.xml
  3. 69
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java
  4. 2
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/config/ConfigEntity.java
  5. 51
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/config/MessageTemplateEntity.java
  6. 8
      hzims-service-api/pom.xml
  7. 15
      hzims-service/equipment/pom.xml
  8. 11
      hzims-service/inspect/pom.xml
  9. 34
      hzims-service/message/src/main/java/com/hnac/hzims/message/config/MessageFactory.java
  10. 60
      hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java
  11. 66
      hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageTemplateController.java
  12. 8
      hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java
  13. 179
      hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
  14. 130
      hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushScheduleOld.java
  15. 35
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java
  16. 3
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java
  17. 28
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageTemplateService.java
  18. 6
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java
  19. 55
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
  20. 44
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessageTemplateServiceImpl.java
  21. 44
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java
  22. 18
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java
  23. 6
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java
  24. 3
      hzims-service/pom.xml
  25. 12
      hzims-service/safeproduct/pom.xml
  26. 15
      hzims-service/ticket/pom.xml
  27. 11
      pom.xml

10
hzims-service-api/inspect-api/pom.xml

@ -3,9 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>hzims-service-api</artifactId> <artifactId>BladeX</artifactId>
<groupId>com.hnac.hzims</groupId> <groupId>org.springblade</groupId>
<version>4.0.0-SNAPSHOT</version> <version>2.7.6.RELEASE</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -15,17 +15,19 @@
<properties> <properties>
<!-- <bladex.project.version>2.7.6.RELEASE</bladex.project.version>--> <bladex.project.version>2.7.6.RELEASE</bladex.project.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-starter-mybatis</artifactId> <artifactId>blade-starter-mybatis</artifactId>
<version>${bladex.project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-starter-tenant</artifactId> <artifactId>blade-starter-tenant</artifactId>
<version>${bladex.project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>

8
hzims-service-api/message-api/pom.xml

@ -16,9 +16,9 @@
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-resource-api</artifactId> <artifactId>blade-resource-api</artifactId>
</dependency> </dependency>
<!-- <dependency>--> <dependency>
<!-- <groupId>com.hnac.hzims</groupId>--> <groupId>com.hnac.hzims</groupId>
<!-- <artifactId>hzims-biz-common</artifactId>--> <artifactId>hzims-biz-common</artifactId>
<!-- </dependency>--> </dependency>
</dependencies> </dependencies>
</project> </project>

69
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java

@ -1,69 +0,0 @@
package com.hnac.hzims.message.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
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 java.time.LocalDateTime;
@Data
@ApiModel(value = "消息推送记录",description = "消息推送记录")
@TableName("hzims_message_push_record")
@EqualsAndHashCode
public class MessagePushRecordEntity extends MessageTemplateEntity {
@ApiModelProperty("业务任务ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long taskId;
@ApiModelProperty("消息模板ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long templateId;
@ApiModelProperty("资源编码")
@QueryField(condition = SqlCondition.EQUAL)
private String resourceCode;
@ApiModelProperty(value = "推送人")
@QueryField(condition = SqlCondition.LIKE)
private String pusher;
@ApiModelProperty(value = "推送账号:手机号,邮箱")
private String account;
@ApiModelProperty(value = "推送人名称")
@QueryField(condition = SqlCondition.LIKE)
private String pusherName;
@ApiModelProperty(value = "内容")
private String content;
@ApiModelProperty(value = "计划推送时间")
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime planTime;
@ApiModelProperty(value = "实际推送时间")
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime pushTime;
@ApiModelProperty(value = "响应时间")
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime respondTime;
@ApiModelProperty(value = "响应说明")
private String respondRemark;
}

2
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/config/ConfigEntity.java

@ -1,5 +1,6 @@
package com.hnac.hzims.message.entity.config; package com.hnac.hzims.message.entity.config;
import com.hnac.hzims.common.invalid.DictInvalid;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -24,6 +25,7 @@ public class ConfigEntity extends TenantEntity implements Serializable {
@ApiModelProperty(value = "业务分类。系统通知:system,事务消息:business,日常提醒:dailyRemind,巡检消息:inspect",required = true) @ApiModelProperty(value = "业务分类。系统通知:system,事务消息:business,日常提醒:dailyRemind,巡检消息:inspect",required = true)
@NotNull(message = "业务分类不能为空") @NotNull(message = "业务分类不能为空")
@DictInvalid(dictKey = "businessClassify")
@QueryField(condition = SqlCondition.EQUAL) @QueryField(condition = SqlCondition.EQUAL)
private String businessClassify; private String businessClassify;

51
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/config/MessageTemplateEntity.java

@ -0,0 +1,51 @@
package com.hnac.hzims.message.entity.config;
import io.swagger.annotations.ApiModelProperty;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import javax.validation.constraints.NotNull;
/**
* @ClassName MessageTemplateEntity
* @description:
* @author: hx
* @create: 2023-04-06 14:55
* @Version 4.0
**/
public class MessageTemplateEntity {
@ApiModelProperty(value = "消息类型")
@NotNull(message = "消息类型不能为空")
@QueryField(condition = SqlCondition.EQUAL)
private String type;
@ApiModelProperty(value = "业务分类。系统通知:system,事务消息:business,日常提醒:dailyRemind,巡检消息:inspect",required = true)
@NotNull(message = "业务分类不能为空")
@QueryField(condition = SqlCondition.EQUAL)
private String businessClassify;
@ApiModelProperty(value = "业务关键字",required = true)
@NotNull(message = "业务关键字不能为空")
@QueryField(condition = SqlCondition.LIKE)
private String businessKey;
@ApiModelProperty(value = "主题",required = true)
@NotNull(message = "主题不能为空")
@QueryField(condition = SqlCondition.LIKE)
private String subject;
@ApiModelProperty(value = "集中推送时长")
private Integer concentratedDuration;
@ApiModelProperty(value = "集中推送单位")
private String concentratedTimeUnit;
@ApiModelProperty(value = "提前推送时长")
private Integer advanceDuration;
@ApiModelProperty(value = "提前推送单位")
@QueryField(condition = SqlCondition.EQUAL)
private String advanceTimeUnit;
}

8
hzims-service-api/pom.xml

@ -21,7 +21,7 @@
<module>equipment-api</module> <module>equipment-api</module>
<module>safeproduct-api</module> <module>safeproduct-api</module>
<module>hzims-operational-api</module> <module>hzims-operational-api</module>
<module>inspect-api</module> <!-- <module>inspect-api</module>-->
<module>message-api</module> <module>message-api</module>
<module>ticket-api</module> <module>ticket-api</module>
<module>weather-api</module> <module>weather-api</module>
@ -32,12 +32,6 @@
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-starter-mybatis</artifactId> <artifactId>blade-starter-mybatis</artifactId>
<exclusions>
<exclusion>
<artifactId>lettuce-core</artifactId>
<groupId>io.lettuce</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>

15
hzims-service/equipment/pom.xml

@ -24,11 +24,11 @@
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-starter-oss-all</artifactId> <artifactId>blade-starter-oss-all</artifactId>
</dependency> </dependency>
<!-- <dependency>--> <dependency>
<!-- <groupId>com.hnac.hzims</groupId>--> <groupId>com.hnac.hzims</groupId>
<!-- <artifactId>spare-api</artifactId>--> <artifactId>spare-api</artifactId>
<!-- <version>${hzims.project.version}</version>--> <version>${hzims.project.version}</version>
<!-- </dependency>--> </dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId> <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
@ -94,10 +94,7 @@
<artifactId>hzims-operational-api</artifactId> <artifactId>hzims-operational-api</artifactId>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

11
hzims-service/inspect/pom.xml

@ -4,18 +4,19 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>hzims-service</artifactId> <artifactId>BladeX</artifactId>
<groupId>com.hnac.hzims</groupId> <groupId>org.springblade</groupId>
<version>4.0.0-SNAPSHOT</version> <version>2.7.6.RELEASE</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.hnac.hzinfo.inspect</groupId> <groupId>com.hnac.hzinfo.inspect</groupId>
<artifactId>hzinfo-inspect</artifactId> <artifactId>hzinfo-inspect</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<!-- <bladex.project.version>2.7.6.RELEASE</bladex.project.version>--> <bladex.project.version>2.7.6.RELEASE</bladex.project.version>
<bladex.system.version>4.5.6.RELEASE</bladex.system.version> <bladex.system.version>4.5.6.RELEASE</bladex.system.version>
<hzims.project.version>4.0.0-SNAPSHOT</hzims.project.version> <hzims.project.version>4.0.0-SNAPSHOT</hzims.project.version>
<docker.plugin.version>1.4.13</docker.plugin.version> <docker.plugin.version>1.4.13</docker.plugin.version>
@ -111,7 +112,7 @@
<dependency> <dependency>
<groupId>com.hnac.hzinfo</groupId> <groupId>com.hnac.hzinfo</groupId>
<artifactId>inspect-api</artifactId> <artifactId>inspect-api</artifactId>
<version>${hzims.project.version}</version> <version>${bladex.project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.hikvision.ga</groupId> <groupId>com.hikvision.ga</groupId>

34
hzims-service/message/src/main/java/com/hnac/hzims/message/config/MessageFactory.java

@ -1,34 +0,0 @@
package com.hnac.hzims.message.config;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.service.IMessageService;
import org.springblade.core.tool.utils.SpringUtil;
public class MessageFactory {
/** @Author hx
* @Description 获取方法类型
* @Date 2023/4/4 14:22
* @Param [messageType] 消息类型
* @return com.hnac.hzims.message.service.IMessageService
**/
public static IMessageService getMessageSend(String messageType) {
if(MessageConstants.APP_PUSH.equals(messageType)) {
return SpringUtil.getBean("pushMessageService");
}
else if(MessageConstants.SMS_PUSH.equals(messageType)) {
return SpringUtil.getBean("smsMessageService");
}
else if(MessageConstants.MAIL_PUSH.equals(messageType)) {
return SpringUtil.getBean("mailMessageService");
}
else if(MessageConstants.WS_PUSH.equals(messageType)) {
return SpringUtil.getBean("websocketService");
}
else {
return null;
}
}
}

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

@ -1,60 +0,0 @@
package com.hnac.hzims.message.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.service.IMessagePushRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/message/record")
@Api(value = "消息推送记录",tags = "消息推送记录")
@AllArgsConstructor
public class MessagePushRecordController extends BladeController {
private final IMessagePushRecordService messagePushRecordService;
@PostMapping("/save")
@ApiOperation("保存消息推送")
@ApiOperationSupport(order = 1)
public R<Boolean> save(@RequestBody MessagePushRecordEntity request) {
return R.status(messagePushRecordService.save(request));
}
@PostMapping("/update")
@ApiOperation("更新消息推送记录")
@ApiOperationSupport(order = 2)
public R<Boolean> update(@RequestBody MessagePushRecordEntity request) {
return R.status(messagePushRecordService.updateById(request));
}
@GetMapping("/list")
@ApiOperation("查询消息推送记录列表")
@ApiOperationSupport(order = 3)
public R<List<MessagePushRecordEntity>> list(MessagePushRecordEntity request) {
return R.data(messagePushRecordService.list(request));
}
@GetMapping("/listPage")
@ApiOperation("分页查询消息推送记录列表")
@ApiOperationSupport(order = 4)
public R<IPage<MessagePushRecordEntity>> listPage(MessagePushRecordEntity request, Query query) {
return R.data(messagePushRecordService.listPage(request,query));
}
@GetMapping("/send/{id}")
@ApiOperation("推送消息记录")
@ApiOperationSupport(order = 4)
public R<Boolean> send(@PathVariable @ApiParam("消息记录ID") String id) {
return R.data(messagePushRecordService.send(id));
}
}

66
hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageTemplateController.java

@ -1,66 +0,0 @@
package com.hnac.hzims.message.controller;
import com.aliyun.oss.ServiceException;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import com.hnac.hzims.message.service.IMessageTemplateService;
import groovy.util.logging.Slf4j;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@AllArgsConstructor
@RequestMapping("/message/template")
@Api(value = "消息模板管理",tags = "消息模板管理")
public class MessageTemplateController extends BladeController {
private final IMessageTemplateService messageTemplateService;
@PostMapping("/save")
@ApiOperation("保存消息模板")
@ApiOperationSupport(order = 1)
public R<Boolean> save(@RequestBody MessageTemplateEntity request) {
return R.status(messageTemplateService.save(request));
}
@GetMapping("/list")
@ApiOperation("查询列表")
@ApiOperationSupport(order = 2)
public R<List<MessageTemplateEntity>> list(MessageTemplateEntity request) {
return R.data(messageTemplateService.list(request));
}
@GetMapping("/listPage")
@ApiOperation("分页查询")
@ApiOperationSupport(order = 3)
public R<IPage<MessageTemplateEntity>> listPage(MessageTemplateEntity request, Query query) {
return R.data(messageTemplateService.listPage(request,query));
}
@DeleteMapping("/delete/{ids}")
@ApiOperation("删除消息模板")
@ApiOperationSupport(order = 4)
public R<Boolean> delete(@PathVariable String ids) {
return R.status(messageTemplateService.deleteLogic(Func.toLongList(",",ids)));
}
@PutMapping("/update")
@ApiOperation("修改消息模板")
@ApiOperationSupport(order = 5)
public R<Boolean> update(@RequestBody MessageTemplateEntity request) {
Assert.isTrue(Func.isNotEmpty(request.getId()),() -> {
throw new ServiceException("消息模板编辑时传入ID不能为空");
});
return R.status(messageTemplateService.updateById(request));
}
}

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

@ -1,8 +0,0 @@
package com.hnac.hzims.message.mapper;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
public interface MessagePushRecordMapper extends UserDataScopeBaseMapper<MessagePushRecordEntity> {
}

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

@ -1,112 +1,135 @@
package com.hnac.hzims.message.schedule; package com.hnac.hzims.message.schedule;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.common.utils.DateUtil;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.configure.service.ISmsConfigService;
import com.hnac.hzims.message.config.MessageFactory; import com.hnac.hzims.message.constants.RedisKeyConstants;
import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.dto.PushMessageDTO;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.service.IMessagePushRecordService; import com.hnac.hzims.message.entity.PushMessageEntity;
import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.entity.config.SmsConfigEntity;
import com.hnac.hzims.message.service.IMessageTemplateService; import com.hnac.hzims.message.push.service.IPushService;
import com.hnac.hzims.message.service.IPushMessageService;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor; import com.xxl.job.core.log.XxlJobLogger;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap; import java.time.ZoneOffset;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.hnac.hzims.message.constants.XxlJobConstants.PUSH_MESSAGE_BY_NOTICE; import static com.hnac.hzims.message.constants.XxlJobConstants.*;
import static com.hnac.hzims.message.constants.XxlJobConstants.PUSH_SMS_MESSAGE_BY_NOTICE;
/** /**
* @ClassName MessagePushSchedule * 消息中心定时推送任务调度
* @description: 消息推送 * @author hx
* @author: hx */
* @create: 2023-04-04 14:31
* @Version 4.0
**/
@Component @Component
@AllArgsConstructor
@Slf4j @Slf4j
public class MessagePushSchedule { public class MessagePushSchedule {
private final IMessageTemplateService templateService; @Autowired
private final IMessagePushRecordService recordService; private ISmsConfigService smsConfigService;
@Autowired
private IPushMessageService pushMessageService;
@Autowired
@Qualifier("smsPushService")
private IPushService pushService;
@XxlJob(PUSH_MESSAGE_BY_NOTICE) public static final String MESSAGE_ID = "messageId";
/**
* 消息推送根据推送人分时段推送任务调度
* @param params 暂不支持参数参入执行调度任务
* @return
*/
@XxlJob(PUSH_SMS_MESSAGE_BY_NOTICE)
public ReturnT pushSmsMessageByNotice(String params) { public ReturnT pushSmsMessageByNotice(String params) {
// 获取消息模板 List<SmsConfigEntity> list = smsConfigService.list();
List<MessageTemplateEntity> templateList = templateService.list(); list.stream().filter(e -> Func.isNotEmpty(e.getDuration()) && Func.isNotEmpty(e.getTimeUnit())).forEach(smsConfigEntity -> {
LocalDateTime now = LocalDateTime.now(); //查询出规定时段内的短信数量统一发送
templateList.forEach(template -> { // 获取配置的时间范围内的消息
LocalDateTime endTime = DateUtil.plus(LocalDateTime.now(), template.getConcentratedDuration(), template.getConcentratedTimeUnit()); LocalDateTime endTime = DateUtil.plus(LocalDateTime.now(), smsConfigEntity.getDuration(), smsConfigEntity.getTimeUnit());
endTime = DateUtil.plus(endTime, template.getAdvanceDuration(), template.getAdvanceTimeUnit()); PushMessageDTO pushMessageDTO = new PushMessageDTO();
LambdaQueryWrapper<MessagePushRecordEntity> lqw = Wrappers.<MessagePushRecordEntity>lambdaQuery() pushMessageDTO.setStartTime(LocalDateTime.now());
.eq(MessagePushRecordEntity::getStatus, MessageConstants.NOT_PUSH) pushMessageDTO.setEndTime(endTime);
.ge(MessagePushRecordEntity::getPlanTime, now) pushMessageDTO.setBusinessKey(smsConfigEntity.getBusinessKey());
.le(MessagePushRecordEntity::getPlanTime, endTime); pushMessageDTO.setIsPush(false);
List<MessagePushRecordEntity> list = recordService.list(lqw); List<PushMessageEntity> pushMessageList = pushMessageService.list(pushMessageDTO);
this.sendMessage(list); XxlJobLogger.log("开始推送短信,推送条数为:"+pushMessageList.size());
}); // 获取推送消息内容体 根据用户拆分出多条短信推送
return ReturnT.SUCCESS; List<JSONObject> splitSmsList = this.transform(pushMessageList);
if(CollectionUtil.isEmpty(splitSmsList)) {
return;
} }
this.push(splitSmsList,smsConfigEntity);
/** @Author hx
* @Description 消息集中推送
* @Date 2023/4/4 15:31
* @Param [list] 消息推送记录
* @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));
Boolean flag = service.send(request);
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);
}); });
return ReturnT.SUCCESS;
} }
/** @Author hx /**
* @Description 获取群推送内容 * 推送短信
* @Date 2023/4/4 16:06 * @param splitSmsList 短信内容
* @Param [type, list] * @param configEntity 短信配置
* @return java.lang.String */
**/ private void push(List<JSONObject> splitSmsList,SmsConfigEntity configEntity) {
private String getPushContent(String type,List<MessagePushRecordEntity> list) { Map<String, List<JSONObject>> phoneMap = splitSmsList.stream().collect(Collectors.groupingBy(sms -> sms.getString("phones")));
if(MessageConstants.APP_NAME.equals(type)) { phoneMap.forEach((phone,messages) -> {
return list.stream().map(MessagePushRecordEntity::getContent).collect(Collectors.joining("\r\n")); String messageIds = messages.stream().map(message -> message.getString(MESSAGE_ID)).collect(Collectors.joining(","));
} List<SmsPushDto> smsPushDtoList = JSONArray.parseArray(JSON.toJSONString(messages), SmsPushDto.class);
else if(MessageConstants.SMS_PUSH.equals(type)) { SmsPushDto templatePush = smsPushDtoList.get(0);
Map<String,String> params = new HashMap<>(); Map<String,String> params = new HashMap<>();
list.stream().map(MessagePushRecordEntity::getContent).forEachOrdered(record -> { Arrays.stream(configEntity.getContentVariables().split(",")).forEachOrdered(contentVariable ->{
JSONObject param = JSONObject.parseObject(record); String value = smsPushDtoList.stream().map(SmsPushDto::getParams)
param.forEach((k,v) -> { .map(pm -> MapUtil.getStr(pm,contentVariable)).collect(Collectors.joining(","));
params.put(k, params.containsKey(k) && Func.isNotEmpty(params.get(k)) ? params.get(k) + "," + v : (String) v); params.put(contentVariable,value);
}); });
templatePush.setParams(params);
XxlJobLogger.log(">>>>>>>>>>开始推送消息,推送内容为:"+JSONObject.toJSONString(templatePush)+"<<<<<<<<<<");
LambdaUpdateWrapper<PushMessageEntity> pushLU = Wrappers.<PushMessageEntity>lambdaUpdate()
.set(PushMessageEntity::getIsPush, true)
.in(PushMessageEntity::getId, messageIds.split(","));
pushMessageService.update(pushLU);
R pushResult = pushService.send(templatePush);
LambdaUpdateWrapper<PushMessageEntity> successLU = Wrappers.lambdaUpdate();
if(pushResult.isSuccess()) {
successLU.set(PushMessageEntity::getIsSuccess,true);
}
else {
successLU.set(PushMessageEntity::getIsSuccess,false);
}
successLU.in(PushMessageEntity::getId, messageIds.split(","));
pushMessageService.update(successLU);
}); });
return JSON.toJSONString(params);
} }
return null;
/**
* 获取推送消息内容体 根据用户拆分出多条短信推送
* @param pushMessageList
* @return
*/
private List<JSONObject> transform(List<PushMessageEntity> pushMessageList) {
return pushMessageList.stream().map(m -> {
JSONObject object = JSONObject.parseObject(m.getMessageContent());
object.put(MESSAGE_ID,m.getId());
return object;
}).filter(object -> Func.isNotEmpty(object.getString("phones"))).collect(Collectors.toList());
} }
} }

130
hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushScheduleOld.java

@ -1,130 +0,0 @@
package com.hnac.hzims.message.schedule;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.utils.DateUtil;
import com.hnac.hzims.message.configure.service.ISmsConfigService;
import com.hnac.hzims.message.dto.PushMessageDTO;
import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.entity.PushMessageEntity;
import com.hnac.hzims.message.entity.config.SmsConfigEntity;
import com.hnac.hzims.message.push.service.IPushService;
import com.hnac.hzims.message.service.IPushMessageService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static com.hnac.hzims.message.constants.XxlJobConstants.*;
/**
* 消息中心定时推送任务调度
* @author hx
*/
@Component
@Slf4j
public class MessagePushScheduleOld {
@Autowired
private ISmsConfigService smsConfigService;
@Autowired
private IPushMessageService pushMessageService;
@Autowired
@Qualifier("smsPushService")
private IPushService pushService;
public static final String MESSAGE_ID = "messageId";
/**
* 消息推送根据推送人分时段推送任务调度
* @param params 暂不支持参数参入执行调度任务
* @return
*/
@XxlJob(PUSH_SMS_MESSAGE_BY_NOTICE)
public ReturnT pushSmsMessageByNotice(String params) {
List<SmsConfigEntity> list = smsConfigService.list();
list.stream().filter(e -> Func.isNotEmpty(e.getDuration()) && Func.isNotEmpty(e.getTimeUnit())).forEach(smsConfigEntity -> {
//查询出规定时段内的短信数量统一发送
// 获取配置的时间范围内的消息
LocalDateTime endTime = DateUtil.plus(LocalDateTime.now(), smsConfigEntity.getDuration(), smsConfigEntity.getTimeUnit());
PushMessageDTO pushMessageDTO = new PushMessageDTO();
pushMessageDTO.setStartTime(LocalDateTime.now());
pushMessageDTO.setEndTime(endTime);
pushMessageDTO.setBusinessKey(smsConfigEntity.getBusinessKey());
pushMessageDTO.setIsPush(false);
List<PushMessageEntity> pushMessageList = pushMessageService.list(pushMessageDTO);
XxlJobLogger.log("开始推送短信,推送条数为:"+pushMessageList.size());
// 获取推送消息内容体 根据用户拆分出多条短信推送
List<JSONObject> splitSmsList = this.transform(pushMessageList);
if(CollectionUtil.isEmpty(splitSmsList)) {
return;
}
this.push(splitSmsList,smsConfigEntity);
});
return ReturnT.SUCCESS;
}
/**
* 推送短信
* @param splitSmsList 短信内容
* @param configEntity 短信配置
*/
private void push(List<JSONObject> splitSmsList,SmsConfigEntity configEntity) {
Map<String, List<JSONObject>> phoneMap = splitSmsList.stream().collect(Collectors.groupingBy(sms -> sms.getString("phones")));
phoneMap.forEach((phone,messages) -> {
String messageIds = messages.stream().map(message -> message.getString(MESSAGE_ID)).collect(Collectors.joining(","));
List<SmsPushDto> smsPushDtoList = JSONArray.parseArray(JSON.toJSONString(messages), SmsPushDto.class);
SmsPushDto templatePush = smsPushDtoList.get(0);
Map<String,String> params = new HashMap<>();
Arrays.stream(configEntity.getContentVariables().split(",")).forEachOrdered(contentVariable ->{
String value = smsPushDtoList.stream().map(SmsPushDto::getParams)
.map(pm -> MapUtil.getStr(pm,contentVariable)).collect(Collectors.joining(","));
params.put(contentVariable,value);
});
templatePush.setParams(params);
XxlJobLogger.log(">>>>>>>>>>开始推送消息,推送内容为:"+JSONObject.toJSONString(templatePush)+"<<<<<<<<<<");
LambdaUpdateWrapper<PushMessageEntity> pushLU = Wrappers.<PushMessageEntity>lambdaUpdate()
.set(PushMessageEntity::getIsPush, true)
.in(PushMessageEntity::getId, messageIds.split(","));
pushMessageService.update(pushLU);
R pushResult = pushService.send(templatePush);
LambdaUpdateWrapper<PushMessageEntity> successLU = Wrappers.lambdaUpdate();
if(pushResult.isSuccess()) {
successLU.set(PushMessageEntity::getIsSuccess,true);
}
else {
successLU.set(PushMessageEntity::getIsSuccess,false);
}
successLU.in(PushMessageEntity::getId, messageIds.split(","));
pushMessageService.update(successLU);
});
}
/**
* 获取推送消息内容体 根据用户拆分出多条短信推送
* @param pushMessageList
* @return
*/
private List<JSONObject> transform(List<PushMessageEntity> pushMessageList) {
return pushMessageList.stream().map(m -> {
JSONObject object = JSONObject.parseObject(m.getMessageContent());
object.put(MESSAGE_ID,m.getId());
return object;
}).filter(object -> Func.isNotEmpty(object.getString("phones"))).collect(Collectors.toList());
}
}

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

@ -1,35 +0,0 @@
package com.hnac.hzims.message.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
import java.util.List;
public interface IMessagePushRecordService extends BaseService<MessagePushRecordEntity> {
/**
* 查询消息推送记录列表
* @param request 查询条件
* @return 消息记录列表
*/
List<MessagePushRecordEntity> list(MessagePushRecordEntity request);
/**
* 分页查询消息推送记录列表
* @param request 查询条件
* @param query 分页
* @return 消息记录列表
*/
IPage<MessagePushRecordEntity> listPage(MessagePushRecordEntity request, Query query);
/** @Author hx
* @Description 根据ID发送短信
* @Date 2023/4/4 17:37
* @Param ids 消息记录ID
* @return
**/
Boolean send(String id);
}

3
hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java

@ -2,7 +2,6 @@ package com.hnac.hzims.message.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.message.dto.PushDto; import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
/** /**
@ -17,6 +16,4 @@ public interface IMessageService {
*/ */
<T extends PushDto> R<String> send(T pushObject); <T extends PushDto> R<String> send(T pushObject);
Boolean send(MessagePushRecordEntity request);
} }

28
hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageTemplateService.java

@ -1,28 +0,0 @@
package com.hnac.hzims.message.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
import java.util.List;
public interface IMessageTemplateService extends BaseService<MessageTemplateEntity> {
/**
* 查询消息模板列表
* @param req 查询条件
* @return 消息模板列表
*/
List<MessageTemplateEntity> list(MessageTemplateEntity req);
/**
* 分页查询消息
* @param req 查询条件
* @param query 分页条件
* @return 消息模板分页查询结果
*/
IPage<MessageTemplateEntity> listPage(MessageTemplateEntity req, Query query);
}

6
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java

@ -3,7 +3,6 @@ package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.log.aspect.SaveLog; import com.hnac.hzims.message.log.aspect.SaveLog;
import com.hnac.hzims.message.dto.MailPushDto; import com.hnac.hzims.message.dto.MailPushDto;
import com.hnac.hzims.message.dto.PushDto; import com.hnac.hzims.message.dto.PushDto;
@ -76,9 +75,4 @@ public class MailMessageServiceImpl implements IMessageService {
return R.success("发送成功!"); return R.success("发送成功!");
} }
@Override
public Boolean send(MessagePushRecordEntity request) {
return null;
}
} }

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

@ -1,55 +0,0 @@
package com.hnac.hzims.message.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.message.config.MessageFactory;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.mapper.MessagePushRecordMapper;
import com.hnac.hzims.message.service.IMessagePushRecordService;
import com.hnac.hzims.message.service.IMessageService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@AllArgsConstructor
@Slf4j
public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRecordMapper, MessagePushRecordEntity> implements IMessagePushRecordService {
@Override
public List<MessagePushRecordEntity> list(MessagePushRecordEntity request) {
return this.list(this.getQueryWrapper(request));
}
@Override
public IPage<MessagePushRecordEntity> listPage(MessagePushRecordEntity request, Query query) {
return this.page(Condition.getPage(query),this.getQueryWrapper(request));
}
@Override
public Boolean send(String id) {
MessagePushRecordEntity record = this.getById(id);
IMessageService messageSend = MessageFactory.getMessageSend(record.getType());
return messageSend.send(record);
}
/**
* 获取 QueryWrapper
* @param request 查询条件
* @return QueryWrapper
*/
private LambdaQueryWrapper<MessagePushRecordEntity> getQueryWrapper(MessagePushRecordEntity request) {
LambdaQueryWrapper<MessagePushRecordEntity> lambda = Condition.getQueryWrapper(request).lambda();
if(Func.isNotEmpty(request.getStatus())) {
lambda.eq(MessagePushRecordEntity::getStatus,request.getStatus());
}
return lambda;
}
}

44
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessageTemplateServiceImpl.java

@ -1,44 +0,0 @@
package com.hnac.hzims.message.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
import com.hnac.hzims.message.mapper.MessageTemplateMapper;
import com.hnac.hzims.message.service.IMessageTemplateService;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@AllArgsConstructor
@Slf4j
public class MessageTemplateServiceImpl extends BaseServiceImpl<MessageTemplateMapper, MessageTemplateEntity> implements IMessageTemplateService {
@Override
public List<MessageTemplateEntity> list(MessageTemplateEntity req) {
return this.list(this.getQueryWrapper(req));
}
@Override
public IPage<MessageTemplateEntity> listPage(MessageTemplateEntity req, Query query) {
return this.page(Condition.getPage(query) , this.getQueryWrapper(req));
}
/**
* 根据查询条件获取消息模板QueryWrapper
* @param req 查询条件
* @return 消息模板QueryWrapper
*/
private LambdaQueryWrapper<MessageTemplateEntity> getQueryWrapper(MessageTemplateEntity req) {
LambdaQueryWrapper<MessageTemplateEntity> lambda = Condition.getQueryWrapper(req).lambda();
if(Func.isNotEmpty(req.getStatus())) {
lambda.eq(MessageTemplateEntity::getStatus,req.getStatus());
}
return lambda;
}
}

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

@ -2,32 +2,23 @@ package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.log.aspect.SaveLog; import com.hnac.hzims.message.log.aspect.SaveLog;
import com.hnac.hzims.message.dto.AppPushDto; import com.hnac.hzims.message.dto.AppPushDto;
import com.hnac.hzims.message.dto.PushDto; import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.service.IMessageService;
import com.hnac.hzinfo.core.push.enums.PlatformType; import com.hnac.hzinfo.core.push.enums.PlatformType;
import com.hnac.hzinfo.core.push.enums.PushAudienceType;
import com.hnac.hzinfo.core.push.model.PushAudience; import com.hnac.hzinfo.core.push.model.PushAudience;
import com.hnac.hzinfo.core.push.model.PushInfo; import com.hnac.hzinfo.core.push.model.PushInfo;
import com.hnac.hzinfo.core.push.model.PushPlatform; import com.hnac.hzinfo.core.push.model.PushPlatform;
import com.hnac.hzinfo.core.push.model.PushResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
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.Func;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.resource.feign.IPushClient; import org.springblade.resource.feign.IPushClient;
import org.springblade.resource.vo.PushInfoVO; import org.springblade.resource.vo.PushInfoVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -39,7 +30,6 @@ import java.util.concurrent.atomic.AtomicReference;
public class PushMessageServiceImpl implements IMessageService { public class PushMessageServiceImpl implements IMessageService {
private final IPushClient pushClient; private final IPushClient pushClient;
private final BladeLogger logger;
@Override @Override
@SaveLog(type = MessageConstants.APP_NAME) @SaveLog(type = MessageConstants.APP_NAME)
@ -83,38 +73,4 @@ public class PushMessageServiceImpl implements IMessageService {
}); });
return R.success("推送成功"); return R.success("推送成功");
} }
@Override
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);
platformTypes.forEach(platformType -> {
PushPlatform platform = PushPlatform.newBuilder().addPlatformType(platformType).build();
R<PushResponse> response;
// 安卓推送
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);
pushInfoVO.setPushInfo(pushInfo);
response = pushClient.tenantPush(pushInfoVO);
}
// IOS推送
else if(PlatformType.IOS.equals(platformType)) {
PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, Lists.newArrayList(request.getPusher())).build();
PushInfo pushInfo = new PushInfo("ops-push-ios", request.getSubject(), request.getContent(),
"", null, platform, pushAudience);
pushInfoVO.setPushInfo(pushInfo);
response = pushClient.tenantPush(pushInfoVO);
} else {
response = null;
}
Assert.isTrue(ObjectUtil.isNotEmpty(response) && response.isSuccess(),() -> {
logger.error("hzims-message:PushMessageServiceImpl:send", "请求参数为:"+JSON.toJSONString(pushInfoVO)+"错误信息为:"+response.getMsg());
throw new ServiceException(response.getMsg());
});
});
return true;
}
} }

18
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java

@ -2,9 +2,7 @@ package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.api.client.util.Value;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.log.aspect.SaveLog; import com.hnac.hzims.message.log.aspect.SaveLog;
import com.hnac.hzims.message.dto.PushDto; import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.dto.SmsPushDto; import com.hnac.hzims.message.dto.SmsPushDto;
@ -12,13 +10,11 @@ import com.hnac.hzims.message.service.IMessageService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
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.secure.utils.AuthUtil;
import org.springblade.core.sms.model.SmsResponse; import org.springblade.core.sms.model.SmsResponse;
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.Func;
import org.springblade.resource.feign.ISmsClient; import org.springblade.resource.feign.ISmsClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
/** /**
* @author hx * @author hx
@ -45,18 +41,4 @@ public class SmsMessageServiceImpl implements IMessageService {
} }
return response; return response;
} }
@Override
public Boolean send(MessagePushRecordEntity request) {
R<SmsResponse> response = smsClient.sendMessage(
Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId(),
request.getResourceCode(),
request.getContent(),
request.getAccount()
);
Assert.isTrue(response.isSuccess(),() -> {
throw new ServiceException(response.getMsg());
});
return response.getData().isSuccess();
}
} }

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

@ -3,7 +3,6 @@ package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.log.aspect.SaveLog; import com.hnac.hzims.message.log.aspect.SaveLog;
import com.hnac.hzims.message.dto.PushDto; import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.dto.WsPushDto; import com.hnac.hzims.message.dto.WsPushDto;
@ -84,9 +83,4 @@ public class WebsocketServiceImpl implements IMessageService {
} }
return R.success("推送成功"); return R.success("推送成功");
} }
@Override
public Boolean send(MessagePushRecordEntity request) {
return null;
}
} }

3
hzims-service/pom.xml

@ -22,11 +22,10 @@
<module>equipment</module> <module>equipment</module>
<module>safeproduct</module> <module>safeproduct</module>
<module>operational</module> <module>operational</module>
<module>inspect</module> <!-- <module>inspect</module>-->
<module>message</module> <module>message</module>
<module>ticket</module> <module>ticket</module>
<module>weather</module> <module>weather</module>
<module>middle</module>
</modules> </modules>
<dependencies> <dependencies>

12
hzims-service/safeproduct/pom.xml

@ -30,11 +30,11 @@
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-starter-oss-all</artifactId> <artifactId>blade-starter-oss-all</artifactId>
</dependency> </dependency>
<!-- <dependency>--> <dependency>
<!-- <groupId>com.hnac.hzims</groupId>--> <groupId>com.hnac.hzims</groupId>
<!-- <artifactId>spare-api</artifactId>--> <artifactId>spare-api</artifactId>
<!-- <version>${hzims.project.version}</version>--> <version>${hzims.project.version}</version>
<!-- </dependency>--> </dependency>
<dependency> <dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>
<artifactId>safeproduct-api</artifactId> <artifactId>safeproduct-api</artifactId>
@ -133,7 +133,7 @@
<dependency> <dependency>
<groupId>com.hnac.hzinfo</groupId> <groupId>com.hnac.hzinfo</groupId>
<artifactId>inspect-api</artifactId> <artifactId>inspect-api</artifactId>
<version>${hzims.project.version}</version> <version>2.7.6.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>

15
hzims-service/ticket/pom.xml

@ -54,11 +54,14 @@
</dependency> </dependency>
<!--excel转换为pdf 通过https://repo.e-iceblue.cn/repository/maven-public/下载jar包--> <!--excel转换为pdf 通过https://repo.e-iceblue.cn/repository/maven-public/下载jar包-->
<dependency> <dependency>
<groupId>e-iceblue</groupId> <groupId>e-iceblue </groupId>
<artifactId>spire.xls.free</artifactId> <artifactId>spire.xls.free</artifactId>
<version>3.9.1</version> <version>3.9.1</version>
</dependency> </dependency>
<!--easypoi-->
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
@ -80,14 +83,18 @@
<artifactId>easypoi-web</artifactId> <artifactId>easypoi-web</artifactId>
<version>${easypoi.version}</version> <version>${easypoi.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId> <artifactId>hutool-core</artifactId>
<version>5.7.16</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-starter-http</artifactId> <artifactId>blade-starter-http</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-collections</groupId> <groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId> <artifactId>commons-collections</artifactId>
@ -95,12 +102,6 @@
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-core-boot</artifactId> <artifactId>blade-core-boot</artifactId>
<exclusions>
<exclusion>
<artifactId>lettuce-core</artifactId>
<groupId>io.lettuce</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>

11
pom.xml

@ -13,12 +13,14 @@
<bladex.project.snapshot.version>4.5.8-SNAPSHOT</bladex.project.snapshot.version> <bladex.project.snapshot.version>4.5.8-SNAPSHOT</bladex.project.snapshot.version>
<!-- 4.5.8-SNAPSHOT--> <!-- 4.5.8-SNAPSHOT-->
<hzims.project.version>4.0.0-SNAPSHOT</hzims.project.version> <hzims.project.version>4.0.0-SNAPSHOT</hzims.project.version>
<bladex.projet.common.version>4.5.8-SNAPSHOT</bladex.projet.common.version> <bladex.projet.common.version>4.5.6.RELEASE</bladex.projet.common.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><java.version>1.8</java.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><java.version>1.8</java.version>
<maven.plugin.version>3.8.1</maven.plugin.version> <maven.plugin.version>3.8.1</maven.plugin.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<hzinfo.data.version>4.6.1-SNAPSHOT</hzinfo.data.version> <hzinfo.data.version>4.6.1-SNAPSHOT</hzinfo.data.version>
<!-- <hzinfo.data.api.version>4.5.3-SNAPSHOT</hzinfo.data.api.version>-->
<!-- <hzinfo.data.sdk.version>4.5.4-RELEASE</hzinfo.data.sdk.version>-->
<flowable.version>6.4.2</flowable.version> <flowable.version>6.4.2</flowable.version>
<dubbo.version>2.7.5</dubbo.version> <dubbo.version>2.7.5</dubbo.version>
@ -121,8 +123,7 @@
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-flow-api</artifactId> <artifactId>blade-flow-api</artifactId>
<!-- <version>${bladex.project.version}</version>--> <version>${bladex.project.version}</version>
<version>4.5.8-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
@ -156,11 +157,11 @@
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>
<version>${spring.boot.version}</version> <version>${spring.boot.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.hnac.hzinfo</groupId> <groupId>com.hnac.hzinfo</groupId>
<artifactId>inspect-api</artifactId> <artifactId>inspect-api</artifactId>
<!-- <version>2.7.6.RELEASE</version>--> <version>2.7.6.RELEASE</version>
<version>${hzims.project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>

Loading…
Cancel
Save