collect = sysLogToList.stream().map(item -> {
+ SysLog sysLog = new SysLog();
+ BeanUtils.copyProperties(item, sysLog);
+ return sysLog;
+ }).collect(Collectors.toList());
+ //添加到数据库
+ boolean save = sysLogService.saveBatch(collect);
+ if (save) {
+ log.info("操作日志新增成功 ~~~");
+ return;
+ }
+ log.info("操作日志新增失败 ~~~");
+ throw new IllegalArgumentException("操作日志新增失败");
+ }
+}
+
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java
new file mode 100644
index 0000000..09bde87
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java
@@ -0,0 +1,70 @@
+package com.hnac.hzims.middle.systemlog.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ *
+ * 操作日志统计数据
+ *
+ *
+ * @author dfy
+ * @since 2023-04-08
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("hzims_statistics")
+public class Statistics implements Serializable {
+
+ private static final long serialVersionUID=1L;
+
+ /**
+ * 编号
+ */
+ @TableField("id")
+ private Long id;
+
+ /**
+ * 统计日期
+ */
+ @TableField("date_calculated")
+ private String dateCalculated;
+
+ /**
+ * 操作模块统计
+ */
+ @TableField("title_num")
+ private Integer titleNum;
+
+ /**
+ * 功能模块统计
+ */
+ @TableField("module_name_num")
+ private Integer moduleNameNum;
+
+ /**
+ * 请求路径统计
+ */
+ @TableField("path_num")
+ private Integer pathNum;
+
+ /**
+ * 创建时间
+ */
+ @TableField("create_time")
+ private LocalDateTime createTime;
+
+ /**
+ * 更新时间
+ */
+ @TableField("update_time")
+ private LocalDateTime updateTime;
+
+
+}
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java
new file mode 100644
index 0000000..210acca
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/SysLog.java
@@ -0,0 +1,199 @@
+package com.hnac.hzims.middle.systemlog.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.time.LocalDateTime;
+import java.sql.Blob;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ *
+ *
+ *
+ *
+ * @author dfy
+ * @since 2023-04-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("hzims_sys_log")
+public class SysLog implements Serializable {
+
+ private static final long serialVersionUID=1L;
+
+ /**
+ * 操作日志编号
+ */
+ @TableField("id")
+ private Long id;
+
+
+ /**
+ * 功能模块
+ */
+ @TableField("module_name")
+ private String moduleName;
+
+ /**
+ * 租户ID
+ */
+ @TableField("tenant_id")
+ private String tenantId;
+
+ /**
+ * 服务器ip
+ */
+ @TableField("server_ip")
+ private String serverIp;
+
+ /**
+ * 服务器地址
+ */
+ @TableField("server_host")
+ private String serverHost;
+
+ /**
+ * 服务名称
+ */
+ @TableField("server_name")
+ private String serverName;
+
+ /**
+ * 环境
+ */
+ @TableField("env")
+ private String env;
+
+ /**
+ * 操作人Id
+ */
+ @TableField("operation_user_id")
+ private Long operationUserId;
+
+ /**
+ * 操作人名称
+ */
+ @TableField("operation_user_name")
+ private String operationUserName;
+
+ /**
+ * 请求路径 (操作地址)
+ */
+ @TableField("path")
+ private String path;
+
+ /**
+ * 用户代理
+ */
+ @TableField("user_agent")
+ private String userAgent;
+
+ /**
+ * 操作方式
+ */
+ @TableField("method")
+ private String method;
+
+ /**
+ * 方法类
+ */
+ @TableField("method_class")
+ private String methodClass;
+
+ /**
+ * 方法名
+ */
+ @TableField("method_name")
+ private String methodName;
+
+ /**
+ * 方法执行时间 消耗时间 毫秒
+ */
+ @TableField("cost_time")
+ private String costTime;
+
+ /**
+ * 方法入参
+ */
+ @TableField("parameter")
+ private String parameter;
+
+ /**
+ * 操作方法
+ */
+ @TableField("title")
+ private String title;
+
+ /**
+ * 方法描述
+ */
+ @TableField("action")
+ private String action;
+
+ /**
+ * 系统类型
+ */
+ @TableField("operator_type")
+ private String operatorType;
+
+ /**
+ * 操作人类别
+ */
+ @TableField("business_type")
+ private String businessType;
+
+ /**
+ * 返回结果
+ */
+ @TableField("json_result")
+ private String jsonResult;
+
+ /**
+ * 请求的Ip
+ */
+ @TableField("local_ip")
+ private String localIp;
+
+ /**
+ * 错误消息
+ */
+ @TableField("error_msg")
+ private String errorMsg;
+
+ /**
+ * 操作时间
+ */
+ @TableField("operation_time")
+ private LocalDateTime operationTime;
+
+ /**
+ * 操作状态(0 正常 1 异常)
+ */
+ @TableField("status")
+ private Integer status;
+
+ /**
+ * 创建时间
+ */
+ @TableField("create_time")
+ private LocalDateTime createTime;
+
+ /**
+ * 更新时间
+ */
+ @TableField("update_time")
+ private LocalDateTime updateTime;
+
+ /**
+ * 逻辑删除 (0 可用 1 删除)
+ */
+ @TableField("is_deleted")
+ private Integer isDeleted;
+
+
+
+}
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.java
new file mode 100644
index 0000000..53166f0
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.java
@@ -0,0 +1,16 @@
+package com.hnac.hzims.middle.systemlog.mapper;
+
+import com.hnac.hzims.middle.systemlog.entity.Statistics;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ *
+ * 操作日志统计数据 Mapper 接口
+ *
+ *
+ * @author dfy
+ * @since 2023-04-08
+ */
+public interface StatisticsMapper extends BaseMapper {
+
+}
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.java
new file mode 100644
index 0000000..009f3a1
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.java
@@ -0,0 +1,16 @@
+package com.hnac.hzims.middle.systemlog.mapper;
+
+import com.hnac.hzims.middle.systemlog.entity.SysLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ *
+ * Mapper 接口
+ *
+ *
+ * @author dfy
+ * @since 2023-04-04
+ */
+public interface SysLogMapper extends BaseMapper {
+
+}
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml
new file mode 100644
index 0000000..093a8d3
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java
new file mode 100644
index 0000000..a04f72c
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java
@@ -0,0 +1,20 @@
+package com.hnac.hzims.middle.systemlog.service;
+
+import com.hnac.hzims.middle.systemlog.entity.Statistics;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *
+ * 操作日志统计数据 服务类
+ *
+ *
+ * @author dfy
+ * @since 2023-04-08
+ */
+public interface StatisticsService extends IService {
+
+ /**
+ * 保存统计的数据
+ */
+ void saveCountStatistics();
+}
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java
new file mode 100644
index 0000000..e409a1e
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java
@@ -0,0 +1,16 @@
+package com.hnac.hzims.middle.systemlog.service;
+
+import com.hnac.hzims.middle.systemlog.entity.SysLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *
+ * 服务类
+ *
+ *
+ * @author dfy
+ * @since 2023-04-04
+ */
+public interface SysLogService extends IService {
+
+}
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java
new file mode 100644
index 0000000..b1f5c97
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java
@@ -0,0 +1,34 @@
+package com.hnac.hzims.middle.systemlog.service.impl;
+
+import com.hnac.hzims.middle.systemlog.entity.Statistics;
+import com.hnac.hzims.middle.systemlog.mapper.StatisticsMapper;
+import com.hnac.hzims.middle.systemlog.service.StatisticsService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.hnac.hzims.middle.systemlog.service.SysLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ *
+ * 操作日志统计数据 服务实现类
+ *
+ *
+ * @author dfy
+ * @since 2023-04-08
+ */
+@Service
+public class StatisticsServiceImpl extends ServiceImpl implements StatisticsService {
+
+ @Autowired
+ private SysLogService sysLogService;
+
+
+ /**
+ * 保存统计的数据
+ */
+ @Override
+ public void saveCountStatistics() {
+ //1. 保存操作模块的数据
+
+ }
+}
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java
new file mode 100644
index 0000000..a889cce
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java
@@ -0,0 +1,20 @@
+package com.hnac.hzims.middle.systemlog.service.impl;
+
+import com.hnac.hzims.middle.systemlog.entity.SysLog;
+import com.hnac.hzims.middle.systemlog.mapper.SysLogMapper;
+import com.hnac.hzims.middle.systemlog.service.SysLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ *
+ * 服务实现类
+ *
+ *
+ * @author dfy
+ * @since 2023-04-04
+ */
+@Service
+public class SysLogServiceImpl extends ServiceImpl implements SysLogService {
+
+}
diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java
new file mode 100644
index 0000000..99a09d0
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java
@@ -0,0 +1,31 @@
+package com.hnac.hzims.middle.systemlog.task;
+
+import com.hnac.hzims.middle.systemlog.service.StatisticsService;
+import com.hnac.hzims.middle.systemlog.service.SysLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.TimerTask;
+
+/**
+ * @Author WL
+ * @Version v1.0
+ * @Serial 1.0
+ * @Date 2023/4/8 14:13
+ */
+@Component
+public class SyslogTimerTask extends TimerTask {
+
+
+ @Autowired
+ private StatisticsService statisticsService;
+
+ /**
+ * The action to be performed by this timer task.
+ */
+ @Override
+ public void run() {
+ //保存统计的数据
+ statisticsService.saveCountStatistics();
+ }
+}
diff --git a/hzims-service/hzims-middle/src/main/resources/application.yml b/hzims-service/hzims-middle/src/main/resources/application.yml
new file mode 100644
index 0000000..6e69e09
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/resources/application.yml
@@ -0,0 +1,38 @@
+#服务器端口
+server:
+ port: 8400
+
+#数据源配置
+spring:
+ #排除DruidDataSourceAutoConfigure
+ autoconfigure:
+ exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+ datasource:
+ url: jdbc:mysql://192.168.1.20:3576/dev_hzims_middle?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
+ username: root
+ password: 123
+
+
+#mybatis-plus配置
+mybatis-plus:
+ mapper-locations:
+ - classpath:com/hnac/hzims/**/mapper/*Mapper.xml
+ - classpath:/mapper/*Mapper.xml
+ #实体扫描,多个package用逗号或者分号分隔
+ typeAliasesPackage: com.hnac.hzims.**.entity
+
+#swagger扫描路径配置
+swagger:
+ base-packages:
+ - org.springbalde
+ - com.hnac
+
+blade:
+ data-scope:
+ enabled: false
+ lock:
+ enabled: true
+ address: redis://192.168.1.20:3577
+ password: 1qaz2WSX@redis
+ database: 0
+ ssl: false
diff --git a/hzims-service/hzims-middle/src/main/resources/bootstrap.yml b/hzims-service/hzims-middle/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..0abf99a
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/resources/bootstrap.yml
@@ -0,0 +1,7 @@
+spring:
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 175.6.40.67:10042
+
+
diff --git a/hzims-service/hzims-middle/src/main/resources/mapper/SysLogMapper.xml b/hzims-service/hzims-middle/src/main/resources/mapper/SysLogMapper.xml
new file mode 100644
index 0000000..698fb08
--- /dev/null
+++ b/hzims-service/hzims-middle/src/main/resources/mapper/SysLogMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/hzims-service/hzims-middle/src/test/java/com/hnac/hzims/middle/MiddleApplicationTests.java b/hzims-service/hzims-middle/src/test/java/com/hnac/hzims/middle/MiddleApplicationTests.java
new file mode 100644
index 0000000..ad2db3e
--- /dev/null
+++ b/hzims-service/hzims-middle/src/test/java/com/hnac/hzims/middle/MiddleApplicationTests.java
@@ -0,0 +1,15 @@
+package com.hnac.hzims.middle;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class MiddleApplicationTests {
+
+ @Test
+ void contextLoads() {
+
+ System.out.println("1");
+ }
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/config/MessageFactory.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/config/MessageFactory.java
new file mode 100644
index 0000000..898685e
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/config/MessageFactory.java
@@ -0,0 +1,34 @@
+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;
+ }
+ }
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java
new file mode 100644
index 0000000..a1f3fa8
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java
@@ -0,0 +1,60 @@
+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 save(@RequestBody MessagePushRecordEntity request) {
+ return R.status(messagePushRecordService.save(request));
+ }
+
+ @PostMapping("/update")
+ @ApiOperation("更新消息推送记录")
+ @ApiOperationSupport(order = 2)
+ public R update(@RequestBody MessagePushRecordEntity request) {
+ return R.status(messagePushRecordService.updateById(request));
+ }
+
+ @GetMapping("/list")
+ @ApiOperation("查询消息推送记录列表")
+ @ApiOperationSupport(order = 3)
+ public R> list(MessagePushRecordEntity request) {
+ return R.data(messagePushRecordService.list(request));
+ }
+
+ @GetMapping("/listPage")
+ @ApiOperation("分页查询消息推送记录列表")
+ @ApiOperationSupport(order = 4)
+ public R> listPage(MessagePushRecordEntity request, Query query) {
+ return R.data(messagePushRecordService.listPage(request,query));
+ }
+
+ @GetMapping("/send/{id}")
+ @ApiOperation("推送消息记录")
+ @ApiOperationSupport(order = 4)
+ public R send(@PathVariable @ApiParam("消息记录ID") Long id) {
+ return R.data(messagePushRecordService.send(id));
+ }
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageTemplateController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageTemplateController.java
new file mode 100644
index 0000000..9e22aad
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageTemplateController.java
@@ -0,0 +1,66 @@
+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 save(@RequestBody MessageTemplateEntity request) {
+ return R.status(messageTemplateService.save(request));
+ }
+
+ @GetMapping("/list")
+ @ApiOperation("查询列表")
+ @ApiOperationSupport(order = 2)
+ public R> list(MessageTemplateEntity request) {
+ return R.data(messageTemplateService.list(request));
+ }
+
+ @GetMapping("/listPage")
+ @ApiOperation("分页查询")
+ @ApiOperationSupport(order = 3)
+ public R> listPage(MessageTemplateEntity request, Query query) {
+ return R.data(messageTemplateService.listPage(request,query));
+ }
+
+ @DeleteMapping("/delete/{ids}")
+ @ApiOperation("删除消息模板")
+ @ApiOperationSupport(order = 4)
+ public R delete(@PathVariable String ids) {
+ return R.status(messageTemplateService.deleteLogic(Func.toLongList(",",ids)));
+ }
+
+ @PutMapping("/update")
+ @ApiOperation("修改消息模板")
+ @ApiOperationSupport(order = 5)
+ public R update(@RequestBody MessageTemplateEntity request) {
+ Assert.isTrue(Func.isNotEmpty(request.getId()),() -> {
+ throw new ServiceException("消息模板编辑时传入ID不能为空");
+ });
+ return R.status(messageTemplateService.updateById(request));
+ }
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java
new file mode 100644
index 0000000..1c43025
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java
@@ -0,0 +1,78 @@
+package com.hnac.hzims.message.controller.web;
+
+import com.hnac.hzims.message.service.IMessagePushRecordService;
+import com.hnac.hzims.message.vo.msgpushrecord.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import java.util.List;
+
+/**
+ * 消息统计页面
+ * @Author dfy
+ * @Version v1.0
+ * @Serial 1.0
+ * @Date 2023/4/7 8:41
+ */
+@Slf4j
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/message/statistics")
+public class MessageStatisticsController {
+
+
+ private final IMessagePushRecordService messagePushRecordService;
+
+
+ /**
+ * 短信推送统计
+ * @return
+ */
+ @GetMapping("/smsPushStat")
+ public R smsPushStat(MessagePushRecordEntityVo vo) {
+ log.info("短信推送统计");
+ List messagePushRecordVos = messagePushRecordService.smsPushStat(vo);
+ log.info("短信推送统计 返回的数据: {}",messagePushRecordVos);
+ return R.data(messagePushRecordVos);
+ }
+
+
+
+ /**
+ * 业务类型统计
+ */
+ @GetMapping("/businessTypeStat")
+ public R businessTypeStat(MessagePushRecordEntityVo vo) {
+ log.info("业务类型统计");
+ List messagePushRecordVos = messagePushRecordService.businessTypeStat(vo);
+ log.info("业务类型统计 返回的数据: {}",messagePushRecordVos);
+ return R.data(messagePushRecordVos);
+ }
+
+
+ /**
+ * 人员发送统计
+ */
+ @GetMapping("/userPushStat")
+ public R userPushStat(MessagePushRecordEntityVo vo) {
+ log.info("人员发送统计");
+ List messagePushRecordVos = messagePushRecordService.userPushStat(vo);
+ log.info("人员发送统计 返回的数据: {}",messagePushRecordVos);
+ return R.data(messagePushRecordVos);
+ }
+
+
+ /**
+ * 推送成功失败统计
+ */
+ @GetMapping("/pushStat")
+ public R pushStat(MessagePushRecordEntityVo vo) {
+ List messagePushRecordVos = messagePushRecordService.pushStat(vo);
+ log.info("推送成功失败统计 返回的数据: {}",messagePushRecordVos);
+ return R.data(messagePushRecordVos);
+ }
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
index 352e2f9..3a04b61 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
import com.hnac.hzims.message.MessageConstants;
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.service.IMessagePushRecordService;
import com.hnac.hzims.message.service.IMessageService;
import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl;
import lombok.AllArgsConstructor;
@@ -23,6 +25,8 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class MessageClient extends BladeController implements IMessageClient{
+ private final IMessagePushRecordService recordService;
+
@Override
@PostMapping(SEND_SMS_MESSAGE)
public R sendSmsMessage(@RequestBody SmsPushDto pushDto) {
@@ -30,4 +34,10 @@ public class MessageClient extends BladeController implements IMessageClient{
return messageService.send(pushDto);
}
+ @Override
+ @PostMapping(SEND_MESSAGE)
+ public R sendMessage(@RequestBody MessagePushRecordEntity request) {
+ return R.status(recordService.saveAndSend(request));
+ }
+
}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java
new file mode 100644
index 0000000..de23097
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java
@@ -0,0 +1,39 @@
+package com.hnac.hzims.message.mapper;
+
+import com.hnac.hzims.message.entity.MessagePushRecordEntity;
+import com.hnac.hzims.message.vo.msgpushrecord.*;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
+
+import java.util.List;
+
+public interface MessagePushRecordMapper extends UserDataScopeBaseMapper {
+
+ /**
+ * 根据type统计数量
+ * @return
+ */
+ List smsPushStat(@Param("vo") MessagePushRecordEntityVo vo);
+
+
+ /**
+ * 业务类型统计
+ * @return
+ */
+ List businessTypeStat(@Param("vo") MessagePushRecordEntityVo vo);
+
+
+ /**
+ * 人员发送统计
+ * @return
+ */
+ List userPushStat(@Param("vo") MessagePushRecordEntityVo vo);
+
+
+ /**
+ * 推送成功失败统计
+ * @return
+ */
+ List pushStat(@Param("vo") MessagePushRecordEntityVo vo);
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml
new file mode 100644
index 0000000..9ae9935
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessageTemplateMapper.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessageTemplateMapper.java
new file mode 100644
index 0000000..edd01b0
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessageTemplateMapper.java
@@ -0,0 +1,8 @@
+package com.hnac.hzims.message.mapper;
+
+import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
+import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
+
+public interface MessageTemplateMapper extends UserDataScopeBaseMapper {
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
index a5f0b53..30565d2 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
@@ -1,135 +1,120 @@
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.query.LambdaQueryWrapper;
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.constants.RedisKeyConstants;
-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.hnac.hzims.message.MessageConstants;
+import com.hnac.hzims.message.config.MessageFactory;
+import com.hnac.hzims.message.entity.MessagePushRecordEntity;
+import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
+import com.hnac.hzims.message.service.IMessagePushRecordService;
+import com.hnac.hzims.message.service.IMessageService;
+import com.hnac.hzims.message.service.IMessageTemplateService;
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.AllArgsConstructor;
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.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.data.redis.core.RedisTemplate;
+import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Component;
-import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
-import java.time.ZoneOffset;
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
-import static com.hnac.hzims.message.constants.XxlJobConstants.*;
+import static com.hnac.hzims.message.constants.XxlJobConstants.PUSH_MESSAGE_BY_NOTICE;
+import static com.hnac.hzims.message.constants.XxlJobConstants.PUSH_SMS_MESSAGE_BY_NOTICE;
/**
- * 消息中心定时推送任务调度
- * @author hx
- */
+ * @ClassName MessagePushSchedule
+ * @description: 消息推送
+ * @author: hx
+ * @create: 2023-04-04 14:31
+ * @Version 4.0
+ **/
@Component
+@AllArgsConstructor
@Slf4j
public class MessagePushSchedule {
- @Autowired
- private ISmsConfigService smsConfigService;
- @Autowired
- private IPushMessageService pushMessageService;
- @Autowired
- @Qualifier("smsPushService")
- private IPushService pushService;
+ private final IMessageTemplateService templateService;
+ private final IMessagePushRecordService recordService;
- public static final String MESSAGE_ID = "messageId";
-
- /**
- * 消息推送根据推送人分时段推送任务调度
- * @param params 暂不支持参数参入执行调度任务
- * @return
- */
- @XxlJob(PUSH_SMS_MESSAGE_BY_NOTICE)
+ @XxlJob(PUSH_MESSAGE_BY_NOTICE)
public ReturnT pushSmsMessageByNotice(String params) {
- List 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 pushMessageList = pushMessageService.list(pushMessageDTO);
- XxlJobLogger.log("开始推送短信,推送条数为:"+pushMessageList.size());
- // 获取推送消息内容体 根据用户拆分出多条短信推送
- List splitSmsList = this.transform(pushMessageList);
- if(CollectionUtil.isEmpty(splitSmsList)) {
+ // 获取消息模板
+ List templateList = templateService.list();
+ LocalDateTime now = LocalDateTime.now();
+ templateList.forEach(template -> {
+ LocalDateTime endTime = DateUtil.plus(LocalDateTime.now(), template.getConcentratedDuration(), template.getConcentratedTimeUnit());
+ endTime = DateUtil.plus(endTime, template.getAdvanceDuration(), template.getAdvanceTimeUnit());
+ LambdaQueryWrapper lqw = Wrappers.lambdaQuery()
+ .eq(MessagePushRecordEntity::getStatus, MessageConstants.NOT_PUSH)
+ .eq(MessagePushRecordEntity::getTemplateId,template.getId())
+ .ge(MessagePushRecordEntity::getPlanTime, now)
+ .le(MessagePushRecordEntity::getPlanTime, endTime);
+ List list = recordService.list(lqw);
+ if(CollectionUtil.isEmpty(list) || list.size() == 0) {
return;
}
- this.push(splitSmsList,smsConfigEntity);
-
+ this.sendMessage(list);
});
return ReturnT.SUCCESS;
}
- /**
- * 推送短信
- * @param splitSmsList 短信内容
- * @param configEntity 短信配置
- */
- private void push(List splitSmsList,SmsConfigEntity configEntity) {
- Map> 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 smsPushDtoList = JSONArray.parseArray(JSON.toJSONString(messages), SmsPushDto.class);
- SmsPushDto templatePush = smsPushDtoList.get(0);
- Map 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 pushLU = Wrappers.lambdaUpdate()
- .set(PushMessageEntity::getIsPush, true)
- .in(PushMessageEntity::getId, messageIds.split(","));
- pushMessageService.update(pushLU);
- R pushResult = pushService.send(templatePush);
- LambdaUpdateWrapper successLU = Wrappers.lambdaUpdate();
- if(pushResult.isSuccess()) {
- successLU.set(PushMessageEntity::getIsSuccess,true);
- }
- else {
- successLU.set(PushMessageEntity::getIsSuccess,false);
+ /** @Author hx
+ * @Description 消息集中推送
+ * @Date 2023/4/4 15:31
+ * @Param [list] 消息推送记录
+ * @return void
+ **/
+ private void sendMessage(List list) {
+ Map> collect = list.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getAccount));
+ String type = list.get(0).getType();
+ IMessageService service = MessageFactory.getMessageSend(type);
+ collect.forEach((account,records) -> {
+ MessagePushRecordEntity request = records.get(0);
+ // 完善推送内容
+ request.setContent(this.getPushContent(type,records));
+ Boolean flag = service.send(request);
+ if(!flag) {
+ return;
}
- successLU.in(PushMessageEntity::getId, messageIds.split(","));
- pushMessageService.update(successLU);
+ List ids = records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList());
+ // 更新消息推送状态
+ LambdaUpdateWrapper lwq = Wrappers.lambdaUpdate()
+ .set(MessagePushRecordEntity::getStatus, flag ? MessageConstants.PUSH_SUCCESS : MessageConstants.PUSH_FAILED)
+ .set(MessagePushRecordEntity::getPushTime,LocalDateTime.now())
+ .in(MessagePushRecordEntity::getId, ids);
+ recordService.update(lwq);
});
}
- /**
- * 获取推送消息内容体 根据用户拆分出多条短信推送
- * @param pushMessageList
- * @return
- */
- private List transform(List 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());
+ /** @Author hx
+ * @Description 获取群推送内容
+ * @Date 2023/4/4 16:06
+ * @Param [type, list]
+ * @return java.lang.String
+ **/
+ private String getPushContent(String type,List list) {
+ if(MessageConstants.APP_NAME.equals(type)) {
+ return list.stream().map(MessagePushRecordEntity::getContent).collect(Collectors.joining("\r\n"));
+ }
+ else if(MessageConstants.SMS_PUSH.equals(type)) {
+ Map params = new HashMap<>();
+ list.stream().map(MessagePushRecordEntity::getContent).forEachOrdered(record -> {
+ JSONObject param = JSONObject.parseObject(record);
+ param.forEach((k,v) -> {
+ params.put(k, params.containsKey(k) && Func.isNotEmpty(params.get(k)) ? params.get(k) + "," + v : (String) v);
+ });
+ });
+ return JSON.toJSONString(params);
+ }
+ return null;
}
-
}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushScheduleOld.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushScheduleOld.java
new file mode 100644
index 0000000..00862dc
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushScheduleOld.java
@@ -0,0 +1,130 @@
+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 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 pushMessageList = pushMessageService.list(pushMessageDTO);
+ XxlJobLogger.log("开始推送短信,推送条数为:"+pushMessageList.size());
+ // 获取推送消息内容体 根据用户拆分出多条短信推送
+ List splitSmsList = this.transform(pushMessageList);
+ if(CollectionUtil.isEmpty(splitSmsList)) {
+ return;
+ }
+ this.push(splitSmsList,smsConfigEntity);
+
+ });
+ return ReturnT.SUCCESS;
+ }
+
+ /**
+ * 推送短信
+ * @param splitSmsList 短信内容
+ * @param configEntity 短信配置
+ */
+ private void push(List splitSmsList,SmsConfigEntity configEntity) {
+ Map> 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 smsPushDtoList = JSONArray.parseArray(JSON.toJSONString(messages), SmsPushDto.class);
+ SmsPushDto templatePush = smsPushDtoList.get(0);
+ Map 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 pushLU = Wrappers.lambdaUpdate()
+ .set(PushMessageEntity::getIsPush, true)
+ .in(PushMessageEntity::getId, messageIds.split(","));
+ pushMessageService.update(pushLU);
+ R pushResult = pushService.send(templatePush);
+ LambdaUpdateWrapper 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 transform(List 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());
+ }
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java
new file mode 100644
index 0000000..b978230
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java
@@ -0,0 +1,74 @@
+package com.hnac.hzims.message.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.hnac.hzims.message.entity.MessagePushRecordEntity;
+import com.hnac.hzims.message.vo.msgpushrecord.*;
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.core.mp.support.Query;
+
+import java.util.List;
+
+public interface IMessagePushRecordService extends BaseService {
+
+ /**
+ * 查询消息推送记录列表
+ * @param request 查询条件
+ * @return 消息记录列表
+ */
+ List list(MessagePushRecordEntity request);
+
+ /**
+ * 分页查询消息推送记录列表
+ * @param request 查询条件
+ * @param query 分页
+ * @return 消息记录列表
+ */
+ IPage listPage(MessagePushRecordEntity request, Query query);
+
+ /** @Author hx
+ * @Description 根据ID发送短信
+ * @Date 2023/4/4 17:37
+ * @Param ids 消息记录ID
+ * @return
+ **/
+ Boolean send(Long id);
+
+ /** @Author hx
+ * @Description 保存并推送消息
+ * @Date 2023/4/6 20:14
+ * @Param request 消息推送记录
+ * @return
+ **/
+ Boolean saveAndSend(MessagePushRecordEntity request);
+
+
+ /**
+ * 短信推送统计
+ */
+ List smsPushStat(MessagePushRecordEntityVo vo);
+
+
+ /**
+ * 业务类型统计
+ * @return
+ */
+ List businessTypeStat(MessagePushRecordEntityVo vo);
+
+
+ /**
+ * 人员发送统计
+ * @return
+ */
+ List userPushStat(MessagePushRecordEntityVo vo);
+
+
+ /**
+ * 推送成功失败统计
+ * @return
+ */
+ List pushStat(MessagePushRecordEntityVo vo);
+
+
+
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java
index c0f9574..fbb4ae0 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java
@@ -2,6 +2,7 @@ package com.hnac.hzims.message.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.message.dto.PushDto;
+import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import org.springblade.core.tool.api.R;
/**
@@ -16,4 +17,6 @@ public interface IMessageService {
*/
R send(T pushObject);
+ Boolean send(MessagePushRecordEntity request);
+
}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageTemplateService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageTemplateService.java
new file mode 100644
index 0000000..14fb453
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageTemplateService.java
@@ -0,0 +1,28 @@
+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 {
+
+ /**
+ * 查询消息模板列表
+ * @param req 查询条件
+ * @return 消息模板列表
+ */
+ List list(MessageTemplateEntity req);
+
+
+ /**
+ * 分页查询消息
+ * @param req 查询条件
+ * @param query 分页条件
+ * @return 消息模板分页查询结果
+ */
+ IPage listPage(MessageTemplateEntity req, Query query);
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java
index 1181a69..03051ba 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MailMessageServiceImpl.java
@@ -3,6 +3,7 @@ package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.dto.MailPushDto;
import com.hnac.hzims.message.dto.PushDto;
@@ -75,4 +76,9 @@ public class MailMessageServiceImpl implements IMessageService {
return R.success("发送成功!");
}
+ @Override
+ public Boolean send(MessagePushRecordEntity request) {
+ return null;
+ }
+
}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
new file mode 100644
index 0000000..c7d1e44
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
@@ -0,0 +1,257 @@
+package com.hnac.hzims.message.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.hnac.hzims.message.MessageConstants;
+import com.hnac.hzims.message.config.MessageFactory;
+import com.hnac.hzims.message.entity.MessagePushRecordEntity;
+import com.hnac.hzims.message.enums.PushStatEnum;
+import com.hnac.hzims.message.mapper.MessagePushRecordMapper;
+import com.hnac.hzims.message.service.IMessagePushRecordService;
+import com.hnac.hzims.message.service.IMessageService;
+import com.hnac.hzims.message.vo.msgpushrecord.*;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.core.log.exception.ServiceException;
+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 org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
+
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+@AllArgsConstructor
+@Slf4j
+public class MessagePushRecordServiceImpl extends BaseServiceImpl implements IMessagePushRecordService {
+
+ @Override
+ public List list(MessagePushRecordEntity request) {
+ return this.list(this.getQueryWrapper(request));
+ }
+
+ @Override
+ public IPage listPage(MessagePushRecordEntity request, Query query) {
+ return this.page(Condition.getPage(query), this.getQueryWrapper(request));
+ }
+
+ @Override
+ public Boolean send(Long id) {
+ MessagePushRecordEntity record = this.getById(id);
+ IMessageService messageSend = MessageFactory.getMessageSend(record.getType());
+ Boolean result = messageSend.send(record);
+ Assert.isTrue(result , ()-> {
+ throw new ServiceException("发送消息失败!");
+ });
+ // 更新推送状态以及推送时间
+ LambdaUpdateWrapper luw = Wrappers.lambdaUpdate()
+ .set(MessagePushRecordEntity::getPushTime, LocalDateTime.now())
+ .set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS)
+ .eq(MessagePushRecordEntity::getId, id);
+ return this.update(luw);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public Boolean saveAndSend(MessagePushRecordEntity request) {
+ if(Func.isEmpty(request.getPlanTime())) {
+ request.setPlanTime(LocalDateTime.now());
+ }
+ if(this.save(request) && Func.isNotEmpty(request.getId())) {
+ return this.send(request.getId());
+ }
+ return false;
+ }
+
+ /**
+ * 获取 QueryWrapper
+ * @param request 查询条件
+ * @return QueryWrapper
+ */
+ private LambdaQueryWrapper getQueryWrapper(MessagePushRecordEntity request) {
+ LambdaQueryWrapper lambda = Condition.getQueryWrapper(request).lambda();
+ if(Func.isNotEmpty(request.getStartTime())) {
+ lambda.ge(MessagePushRecordEntity::getPushTime,request.getStartTime());
+ }
+ if(Func.isNotEmpty(request.getEndTime())) {
+ lambda.le(MessagePushRecordEntity::getPushTime,request.getEndTime());
+ }
+ lambda.orderByDesc(MessagePushRecordEntity::getPushTime);
+ return lambda;
+ }
+ /**
+ * 短信推送统计
+ */
+ @Override
+ public List smsPushStat(MessagePushRecordEntityVo vo) {
+ //根据type统计数量
+ List messagePushRecordVos = baseMapper.smsPushStat(vo);
+ messagePushRecordVos.forEach(item -> {
+ YearMonth strMonth = item.getStrMonth();
+ // 字符串转localDate 获取月份
+ item.setMonth(strMonth.getMonthValue());
+ item.setYear(strMonth.getYear());
+ });
+
+ //按类型分组
+ Map> collect =
+ messagePushRecordVos.stream().collect(Collectors.groupingBy(MessagePushRecordVo::getType));
+
+ List messagePushRecordTypeVos = new ArrayList<>();
+ //封装数据
+ collect.forEach((key, value) -> {
+ MessagePushRecordTypeVo messagePushRecordTypeVo = new MessagePushRecordTypeVo();
+ messagePushRecordTypeVo.setType(key);
+ messagePushRecordTypeVo.setMessagePushRecordList(value);
+ messagePushRecordTypeVos.add(messagePushRecordTypeVo);
+ });
+ return messagePushRecordTypeVos;
+ }
+
+ /**
+ * 业务类型统计
+ *
+ * @return
+ */
+ @Override
+ public List businessTypeStat(MessagePushRecordEntityVo vo) {
+ List businessTypeStatVos = baseMapper.businessTypeStat(vo);
+ businessTypeStatVos.forEach(item -> {
+ String businessClassifyByName = this.getBusinessClassifyByName(item.getBusinessClassify());
+ item.setBusinessClassifyName(businessClassifyByName);
+ });
+ return businessTypeStatVos;
+ }
+
+ /**
+ * 人员发送统计
+ *
+ * @return
+ */
+ @Override
+ public List userPushStat(MessagePushRecordEntityVo vo) {
+ List userPushStatTypeVos = baseMapper.userPushStat(vo);
+ //添加业务类型名称
+ userPushStatTypeVos.forEach(item -> {
+ List pushStatList = item.getPushStatList();
+ pushStatList.forEach(pushStat -> {
+ String businessClassify = pushStat.getBusinessClassify();
+ String businessTypeName = this.getBusinessClassifyByName(businessClassify);
+ pushStat.setBusinessClassifyName(businessTypeName);
+ });
+
+ });
+ return userPushStatTypeVos;
+ }
+
+ /**
+ * 推送成功失败统计
+ *
+ * @return
+ */
+ @Override
+ public List pushStat(MessagePushRecordEntityVo vo) {
+ List pushStatTypeVos = baseMapper.pushStat(vo);
+ pushStatTypeVos.forEach(item -> {
+ //业务类型名称
+ String businessClassify = item.getBusinessClassify();
+ String businessTypeName = this.getBusinessClassifyByName(businessClassify);
+ item.setBusinessClassifyName(businessTypeName);
+ List pushStatList = item.getPushStatList();
+ pushStatList.forEach(pushStat -> {
+ Integer status = pushStat.getStatus();
+ //状态名称
+ String name = this.getStatusByName(status);
+ pushStat.setStatusName(name);
+ //业务类型名称
+ String businessClassifyPushStat = pushStat.getBusinessClassify();
+ String businessTypeNamePushStat = this.getBusinessClassifyByName(businessClassifyPushStat);
+ pushStat.setBusinessClassifyName(businessTypeNamePushStat);
+ });
+ });
+ return pushStatTypeVos;
+ }
+
+
+ /**
+ * 状态 ===> 状态名称
+ *
+ * @param key 状态
+ */
+ private String getStatusByName(Integer key) {
+ String value = null;
+ switch (key) {
+ case 0:
+ value = PushStatEnum.UNPUSHED.getValue();
+ break;
+ case 1:
+ value = PushStatEnum.SUCCESS.getValue();
+ break;
+ case 2:
+ value = PushStatEnum.FAIL.getValue();
+ break;
+ case 3:
+ value = PushStatEnum.CONFIRMED.getValue();
+ break;
+ case 4:
+ log.error("状态异常,没有这状态");
+ break;
+ }
+ return value;
+ }
+
+
+ /**
+ * 业务分类 ===> 业务分类名称
+ *
+ * @param key 状态
+ */
+ private String getBusinessClassifyByName(String key) {
+ key = key == null ? "" : key;
+ String value = null;
+ switch (key) {
+ case "system":
+ value = "系统通知";
+ break;
+ case "business":
+ value = "事务消息";
+ break;
+ case "dailyRemind":
+ value = "日常提醒";
+ break;
+ case "inspect":
+ value = "巡检消息";
+ break;
+ case "":
+ log.error("状态业务分类,没有这状态");
+ break;
+ }
+ return value;
+ }
+
+
+ /**
+ * 现在的月份减去3个 按当前时间推12个月
+ */
+ private int getCurrentMonth(String strMonth) {
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
+ //获取年月
+ YearMonth yearMonth = YearMonth.parse(strMonth, dateTimeFormatter);
+ //减去3个月
+ //YearMonth month = yearMonth.minusMonths(3);
+ return yearMonth.getMonthValue();
+ }
+
+
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessageTemplateServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessageTemplateServiceImpl.java
new file mode 100644
index 0000000..2012749
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessageTemplateServiceImpl.java
@@ -0,0 +1,48 @@
+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 com.hnac.hzims.message.wrapper.MessageTemplateWrapper;
+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.CollectionUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@AllArgsConstructor
+@Slf4j
+public class MessageTemplateServiceImpl extends BaseServiceImpl implements IMessageTemplateService {
+ @Override
+ public List list(MessageTemplateEntity req) {
+ List record = this.list(this.getQueryWrapper(req));
+ return MessageTemplateWrapper.build().listVO(record);
+ }
+
+ @Override
+ public IPage listPage(MessageTemplateEntity req, Query query) {
+ IPage page = this.page(Condition.getPage(query), this.getQueryWrapper(req));
+ return page.setRecords(MessageTemplateWrapper.build().listVO(page.getRecords()));
+ }
+
+ /**
+ * 根据查询条件获取消息模板QueryWrapper
+ * @param req 查询条件
+ * @return 消息模板QueryWrapper
+ */
+ private LambdaQueryWrapper getQueryWrapper(MessageTemplateEntity req) {
+ LambdaQueryWrapper lambda = Condition.getQueryWrapper(req).lambda();
+ if(Func.isNotEmpty(req.getStatus())) {
+ lambda.eq(MessageTemplateEntity::getStatus,req.getStatus());
+ }
+ return lambda;
+ }
+}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java
index 24c6107..6f19844 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java
@@ -2,23 +2,32 @@ package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
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.dto.AppPushDto;
import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.service.IMessageService;
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.PushInfo;
import com.hnac.hzinfo.core.push.model.PushPlatform;
+import com.hnac.hzinfo.core.push.model.PushResponse;
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.tool.api.R;
+import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.resource.feign.IPushClient;
import org.springblade.resource.vo.PushInfoVO;
import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReference;
@@ -30,6 +39,7 @@ import java.util.concurrent.atomic.AtomicReference;
public class PushMessageServiceImpl implements IMessageService {
private final IPushClient pushClient;
+ private final BladeLogger logger;
@Override
@SaveLog(type = MessageConstants.APP_NAME)
@@ -73,4 +83,38 @@ public class PushMessageServiceImpl implements IMessageService {
});
return R.success("推送成功");
}
+
+ @Override
+ public Boolean send(MessagePushRecordEntity request) {
+ PushInfoVO pushInfoVO = new PushInfoVO();
+ pushInfoVO.setTenantId(Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId());
+ ArrayList platformTypes = Lists.newArrayList(PlatformType.Android, PlatformType.IOS);
+ platformTypes.forEach(platformType -> {
+ PushPlatform platform = PushPlatform.newBuilder().addPlatformType(platformType).build();
+ R 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;
+ }
}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java
index 2f1bc0f..b614eb6 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java
@@ -2,7 +2,9 @@ package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.google.api.client.util.Value;
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.dto.PushDto;
import com.hnac.hzims.message.dto.SmsPushDto;
@@ -10,11 +12,13 @@ import com.hnac.hzims.message.service.IMessageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.resource.feign.ISmsClient;
import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
/**
* @author hx
@@ -41,4 +45,18 @@ public class SmsMessageServiceImpl implements IMessageService {
}
return response;
}
+
+ @Override
+ public Boolean send(MessagePushRecordEntity request) {
+ R 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();
+ }
}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java
index b71b4ce..9b9ddfb 100644
--- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java
@@ -3,6 +3,7 @@ package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.dto.PushDto;
import com.hnac.hzims.message.dto.WsPushDto;
@@ -83,4 +84,9 @@ public class WebsocketServiceImpl implements IMessageService {
}
return R.success("推送成功");
}
+
+ @Override
+ public Boolean send(MessagePushRecordEntity request) {
+ return null;
+ }
}
diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/wrapper/MessageTemplateWrapper.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/wrapper/MessageTemplateWrapper.java
new file mode 100644
index 0000000..31ba882
--- /dev/null
+++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/wrapper/MessageTemplateWrapper.java
@@ -0,0 +1,30 @@
+package com.hnac.hzims.message.wrapper;
+
+import com.hnac.hzims.message.entity.config.MessageTemplateEntity;
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.system.cache.DictCache;
+import org.springblade.system.user.cache.UserCache;
+import org.springblade.system.user.entity.User;
+
+import java.util.Optional;
+
+/**
+ * @ClassName MessageTemplateWrapper
+ * @description:
+ * @author: hx
+ * @create: 2023-04-06 17:30
+ * @Version 4.0
+ **/
+public class MessageTemplateWrapper extends BaseEntityWrapper {
+
+ public static MessageTemplateWrapper build() {
+ return new MessageTemplateWrapper();
+ }
+
+ @Override
+ public MessageTemplateEntity entityVO(MessageTemplateEntity entity) {
+ User user = UserCache.getUser(entity.getCreateUser());
+ entity.setCreatorName(Optional.ofNullable(user).map(User::getName).orElse(entity.getCreateUser().toString()));
+ return entity;
+ }
+}
diff --git a/hzims-service/message/src/main/resources/application.yml b/hzims-service/message/src/main/resources/application.yml
index 14c8d05..3a53591 100644
--- a/hzims-service/message/src/main/resources/application.yml
+++ b/hzims-service/message/src/main/resources/application.yml
@@ -7,6 +7,8 @@ mybatis-plus:
mapper-locations: classpath:com/hnac/hzims/**/mapper/*Mapper.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.hnac.hzims.**.entity
+ configuration:
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#swagger扫描路径配置
swagger:
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java
index c8fea79..31b720e 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java
@@ -2,6 +2,9 @@ package com.hnac.hzims.operational.access.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
+import com.hnac.hzims.common.logs.enums.BusinessType;
+import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.access.dto.OperAccessLibraryDTO;
import com.hnac.hzims.operational.access.dto.OperAccessLibraryListDTO;
import com.hnac.hzims.operational.access.service.IOperAccessLibraryService;
@@ -82,6 +85,8 @@ public class OperAccessLibraryController extends BladeController {
@GetMapping("/list")
@ApiOperationSupport(order = 50)
@ApiOperation(value = "分页 查询参数:emCode,gradeCode")
+ @OperationAnnotation(title = "检修库",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,
+ action = "分页 查询参数:emCode,gradeCode")
public R> list(OperAccessLibraryListDTO req, Query query) {
return service.list(req, query);
}
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessPlanController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessPlanController.java
index f998393..a92e633 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessPlanController.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessPlanController.java
@@ -3,6 +3,9 @@ package com.hnac.hzims.operational.access.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.invalid.ObjectRequiredInvalid;
+import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
+import com.hnac.hzims.common.logs.enums.BusinessType;
+import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.OperationalConstants;
import com.hnac.hzims.operational.access.dto.OperAccessPlanDTO;
import com.hnac.hzims.operational.access.dto.OperAccessPlanFlowDTO;
@@ -121,6 +124,9 @@ public class OperAccessPlanController extends BladeController {
@ApiLog
@GetMapping("/list")
@ApiOperationSupport(order = 50)
+ @OperationAnnotation(moduleName = "检修管理",title = "检修计划",operatorType = OperatorType.MOBILE,businessType =
+ BusinessType.GENCODE,
+ action = "分页 查询参数:code,name,gradeCode,manager,techLead,handleStatus,status")
@ApiOperation(value = "分页 查询参数:code,name,gradeCode,manager,techLead,handleStatus,status")
public R> list(OperAccessPlanListDTO req, Query query) {
return service.list(req, query);
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessStatisticsController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessStatisticsController.java
index 002ba80..930002b 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessStatisticsController.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessStatisticsController.java
@@ -2,6 +2,9 @@ package com.hnac.hzims.operational.access.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
+import com.hnac.hzims.common.logs.enums.BusinessType;
+import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO;
import com.hnac.hzims.operational.access.service.IOperAccessStatisticsService;
import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO;
@@ -81,6 +84,8 @@ public class OperAccessStatisticsController extends BladeController {
@GetMapping("/list")
@ApiOperationSupport(order = 50)
@ApiOperation(value = "分页 查询参数:pid,taskId,manager")
+ @OperationAnnotation(title = "检修记录",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,
+ action = "分页 查询参数:pid,taskId,manager")
public R> list(OperAccessStatisticsDTO req, Query query) {
return service.list(req, Condition.getPage(query));
}
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java
index 71f93cb..f3ae298 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java
@@ -2,6 +2,9 @@ package com.hnac.hzims.operational.access.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
+import com.hnac.hzims.common.logs.enums.BusinessType;
+import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO;
import com.hnac.hzims.operational.access.dto.OperAccessTaskFlowDTO;
import com.hnac.hzims.operational.access.service.IOperAccessTaskService;
@@ -80,6 +83,8 @@ public class OperAccessTaskController extends BladeController {
@ApiLog
@GetMapping("/list")
@ApiOperationSupport(order = 50)
+ @OperationAnnotation(title = "我的检修任务",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,
+ action = "分页 查询参数:name,code,handler,status,planId,planCode")
@ApiOperation(value = "分页 查询参数:name,code,handler,status,planId,planCode")
public R> list(OperAccessTaskDTO req, Query query) {
return service.list(req, query);
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/StAlamRecordController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/StAlamRecordController.java
index e0017ae..9fe6026 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/StAlamRecordController.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/StAlamRecordController.java
@@ -4,6 +4,9 @@ package com.hnac.hzims.operational.config.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
+import com.hnac.hzims.common.logs.enums.BusinessType;
+import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity;
import com.hnac.hzims.operational.config.service.StAlamRecordService;
import com.hnac.hzims.operational.config.vo.FaultVo;
@@ -47,7 +50,8 @@ public class StAlamRecordController {
*
*
*/
-
+ @OperationAnnotation(moduleName = "集中监控",title = "集中监控", operatorType = OperatorType.MOBILE,
+ businessType = BusinessType.GENCODE,action = "获取当天的告警列表")
@ApiOperation("获取当天的告警列表")
@RequestMapping(value = "/getDaySoeList", method = {RequestMethod.GET, RequestMethod.POST})
public R getDaySoeList(@ApiParam(value = "时间 yyyy-MM-dd HH:mm:ss") @RequestParam(required = false) String date,
@@ -61,7 +65,8 @@ public class StAlamRecordController {
}
return stAlamRecordService.getDaySoeList(AuthUtil.getUser(), date, type,current,size,code);
}
-
+ @OperationAnnotation(moduleName = "集中监控",title = "集中监控", operatorType = OperatorType.MOBILE,
+ businessType = BusinessType.GENCODE,action = "获取故障列表数据")
@ApiOperation("获取故障列表数据")
@RequestMapping(value = "/getFaultList", method = {RequestMethod.GET, RequestMethod.POST})
public R> getFaultList(@ApiParam(value = "站点编码") @RequestParam(required = false) String code) {
@@ -75,6 +80,8 @@ public class StAlamRecordController {
@GetMapping("/listPage")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入vo")
+ @OperationAnnotation(title = "系统预警处理", operatorType = OperatorType.MOBILE,
+ businessType = BusinessType.GENCODE,action = "分页查询")
public R> list(StAlarmRecordVo vo, Query query) {
return R.data(stAlamRecordService.doPageList(Condition.getPage(query), vo));
}
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java
index 65eb6ba..d075403 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java
@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.invalid.DictInvalid;
import com.hnac.hzims.common.invalid.ObjectRequiredInvalid;
+import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
+import com.hnac.hzims.common.logs.enums.BusinessType;
+import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.defect.entity.OperDefectEntity;
import com.hnac.hzims.operational.defect.service.IOperDefectService;
import com.hnac.hzims.operational.defect.vo.OperDefectVO;
@@ -62,6 +65,9 @@ public class OperDefectController extends BladeController {
@ApiOperation(value = "分页", notes = "传入defect")
@ApiImplicitParams({
})
+ @OperationAnnotation(moduleName = "缺陷管理",
+ title = "缺陷库",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action
+ = "分页")
public R> list(OperDefectEntity defect, Query query) {
LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperDefectEntity(), defect);
if (defect.getActStartTime() != null) {
@@ -150,6 +156,8 @@ public class OperDefectController extends BladeController {
@GetMapping("/getDefectStatistics")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "获取缺陷的统计月报", notes = " month 格式:2021-01")
+ @OperationAnnotation(moduleName = "缺陷管理",title = "缺陷月报表",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,
+ action = "获取缺陷的统计月报")
public R