新增推送通知基础配置类MyApiHelper
新增推送通知工具类PushAppUtil 增加在线,离线推送消息相关方法 消息推送根据报警规则组id,获取绑定用户id,根据用户id查询绑定的客户端id推送消息 新增表绑定用户以及客户端信息 app登陆增加新的redisKey存储当前用户名对应的token信息,在别处登陆时清除上一个登陆token退出用户登陆 新增接口用户在app端登陆时,新增或修改当前用户id绑定的客户端id 定时任务增加推送通知工具类声明 分析结果消费者代码增加推送通知工具类
This commit is contained in:
parent
9107cdf13e
commit
9e8935c9d4
|
@ -79,6 +79,8 @@ public interface CommonConstant {
|
||||||
public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:";
|
public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:";
|
||||||
/** 登录用户Token令牌缓存KEY前缀 */
|
/** 登录用户Token令牌缓存KEY前缀 */
|
||||||
String PREFIX_USER_TOKEN = "prefix_user_token:";
|
String PREFIX_USER_TOKEN = "prefix_user_token:";
|
||||||
|
/** APP端记录登陆用户Token令牌缓存KEY */
|
||||||
|
String PREFIX_USER_TOKEN_APP = "prefix_user_token_app:";
|
||||||
// /** Token缓存时间:3600秒即一小时 */
|
// /** Token缓存时间:3600秒即一小时 */
|
||||||
// int TOKEN_EXPIRE_TIME = 3600;
|
// int TOKEN_EXPIRE_TIME = 3600;
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,11 @@ public interface ServiceNameConstants {
|
||||||
/**
|
/**
|
||||||
* 微服务名:系统管理模块
|
* 微服务名:系统管理模块
|
||||||
*/
|
*/
|
||||||
String SERVICE_SYSTEM = "jeecg-system";
|
String SERVICE_SYSTEM = "armd-system";
|
||||||
/**
|
/**
|
||||||
* 微服务名: demo模块
|
* 微服务名: demo模块
|
||||||
*/
|
*/
|
||||||
String SERVICE_DEMO = "jeecg-demo";
|
String SERVICE_DEMO = "armd-demo";
|
||||||
/**
|
/**
|
||||||
* 微服务名:online在线模块
|
* 微服务名:online在线模块
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package org.jeecg.modules.base.entity.postgre;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("sys_user_client")
|
||||||
|
public class SysUserClient implements Serializable {
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@TableField(value = "user_id")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@TableField(value = "client_id")
|
||||||
|
private String clientId;
|
||||||
|
|
||||||
|
@TableField(value = "create_by")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@TableField(value = "create_time")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@TableField(value = "update_by")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
@TableField(value = "update_time")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -39,4 +39,9 @@ public interface SystemClient {
|
||||||
|
|
||||||
@GetMapping("/gardsStations/stationCodesMap")
|
@GetMapping("/gardsStations/stationCodesMap")
|
||||||
Map<String,String> stationCodesMap();
|
Map<String,String> stationCodesMap();
|
||||||
|
|
||||||
|
@PostMapping("/sys/appMessage/pushMessageToSingle")
|
||||||
|
void pushMessageToSingle(@RequestBody MessageDTO messageDTO, @RequestParam String groupId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,8 +200,10 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
||||||
String groupId = info.getGroupId();
|
String groupId = info.getGroupId();
|
||||||
MessageDTO messageDTO = new MessageDTO();
|
MessageDTO messageDTO = new MessageDTO();
|
||||||
messageDTO.setTitle("Nuclied Warn Info").setContent(alarmInfo.toString());
|
messageDTO.setTitle("Nuclied Warn Info").setContent(alarmInfo.toString());
|
||||||
if (StrUtil.isNotBlank(groupId))
|
if (StrUtil.isNotBlank(groupId)) {
|
||||||
systemClient.sendMessage(messageDTO, groupId, ALL.getValue());
|
systemClient.sendMessage(messageDTO, groupId, ALL.getValue());
|
||||||
|
systemClient.pushMessageToSingle(messageDTO, groupId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3246,6 +3246,12 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
||||||
String qsSaveLc = savePath + StringPool.SLASH + qsLcPath;
|
String qsSaveLc = savePath + StringPool.SLASH + qsLcPath;
|
||||||
String qsSaveScac = savePath + StringPool.SLASH + qsScacPath;
|
String qsSaveScac = savePath + StringPool.SLASH + qsScacPath;
|
||||||
if((type.equals(MiddleDataType.Auto.getType())) || (type.equals(MiddleDataType.InterAction.getType()) && flag.equalsIgnoreCase("save")) ) {
|
if((type.equals(MiddleDataType.Auto.getType())) || (type.equals(MiddleDataType.InterAction.getType()) && flag.equalsIgnoreCase("save")) ) {
|
||||||
|
//判断生成baseline,lc,scac文件的目录是否存在 如果不存在则创建目录
|
||||||
|
String fileSavePath = rootPath + qsSaveBaseLine.substring(0, qsSaveBaseLine.lastIndexOf(StringPool.SLASH));
|
||||||
|
File fileSave = new File(fileSavePath);
|
||||||
|
if (!fileSave.exists()) {
|
||||||
|
fileSave.mkdirs();
|
||||||
|
}
|
||||||
GammaReportUtil.writeFile(fileAnlyse.getBaseCtrls(), rootPath + qsSaveBaseLine);
|
GammaReportUtil.writeFile(fileAnlyse.getBaseCtrls(), rootPath + qsSaveBaseLine);
|
||||||
GammaReportUtil.writeFile(fileAnlyse.getVLc(), "Lc", rootPath + qsSaveLc);
|
GammaReportUtil.writeFile(fileAnlyse.getVLc(), "Lc", rootPath + qsSaveLc);
|
||||||
GammaReportUtil.writeFile(fileAnlyse.getVScac(), "Scac", rootPath + qsSaveScac);
|
GammaReportUtil.writeFile(fileAnlyse.getVScac(), "Scac", rootPath + qsSaveScac);
|
||||||
|
|
|
@ -55,6 +55,24 @@
|
||||||
<groupId>org.jeecgframework.boot</groupId>
|
<groupId>org.jeecgframework.boot</groupId>
|
||||||
<artifactId>jeecg-module-beta-gamma-analyser</artifactId>
|
<artifactId>jeecg-module-beta-gamma-analyser</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- app端推送SDK -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.getui.push</groupId>
|
||||||
|
<artifactId>restful-sdk</artifactId>
|
||||||
|
<version>1.0.0.7</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.gexin.platform</groupId>
|
||||||
|
<artifactId>gexin-rp-sdk-http</artifactId>
|
||||||
|
<version>4.1.2.3</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>getui-nexus</id>
|
||||||
|
<url>https://mvn.getui.com/nexus/content/repositories/releases/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package org.jeecg.config.init;
|
||||||
|
|
||||||
|
import com.getui.push.v2.sdk.ApiHelper;
|
||||||
|
import com.getui.push.v2.sdk.GtApiConfiguration;
|
||||||
|
import com.getui.push.v2.sdk.api.PushApi;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "getui.app")
|
||||||
|
public class MyApiHelper {
|
||||||
|
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
private String appKey;
|
||||||
|
|
||||||
|
private String appSecret;
|
||||||
|
|
||||||
|
private String masterSecret;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个推接口实例化
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean(name = "onlyPushApi")
|
||||||
|
public PushApi pushApi() {
|
||||||
|
GtApiConfiguration apiConfiguration = new GtApiConfiguration();
|
||||||
|
//填写应用配置,参数在“Uni Push”下的“应用配置”页面中获取
|
||||||
|
apiConfiguration.setAppId(appId);
|
||||||
|
apiConfiguration.setAppKey(appKey);
|
||||||
|
apiConfiguration.setMasterSecret(masterSecret);
|
||||||
|
//实例化ApiHelper对象,用于创建接口对象
|
||||||
|
ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
|
||||||
|
//创建对象,建议复用。目前有PushApi、StatisticApi、UserApi
|
||||||
|
PushApi pushApi = apiHelper.creatApi(PushApi.class);
|
||||||
|
return pushApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.jeecg.modules.message.controller;
|
||||||
|
|
||||||
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||||
|
import org.jeecg.modules.message.service.IAppMessageService;
|
||||||
|
import org.jeecg.modules.message.util.PushAppUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("sys/appMessage")
|
||||||
|
public class SendAppMessageController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAppMessageService appMessageService;
|
||||||
|
|
||||||
|
@PostMapping("pushMessageToSingle")
|
||||||
|
public void pushMessageToSingle(@RequestBody MessageDTO messageDTO, @RequestParam String groupId) {
|
||||||
|
appMessageService.sendToSingle(messageDTO, groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.jeecg.modules.message.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface AppMessageMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分组id获取关联的用户id
|
||||||
|
* @param groupId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<String> findGroupUserIds(@Param(value = "groupId") String groupId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户关联的客户端id
|
||||||
|
* @param userIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<String> findUserClientId(@Param(value = "userIds") List<String> userIds);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.jeecg.modules.message.mapper.AppMessageMapper">
|
||||||
|
|
||||||
|
<select id="findGroupUserIds" resultType="java.lang.String">
|
||||||
|
SELECT user_id FROM alarm_contact_group_member WHERE group_id = #{groupId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="findUserClientId" resultType="java.lang.String">
|
||||||
|
SELECT
|
||||||
|
client_id
|
||||||
|
FROM
|
||||||
|
sys_user_client
|
||||||
|
<where>
|
||||||
|
user_id in
|
||||||
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.jeecg.modules.message.service;
|
||||||
|
|
||||||
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||||
|
|
||||||
|
public interface IAppMessageService {
|
||||||
|
|
||||||
|
void sendToSingle(MessageDTO messageDTO, String groupId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.jeecg.modules.message.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||||
|
import org.jeecg.modules.message.mapper.AppMessageMapper;
|
||||||
|
import org.jeecg.modules.message.service.IAppMessageService;
|
||||||
|
import org.jeecg.modules.message.util.PushAppUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AppMessageServiceImpl implements IAppMessageService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PushAppUtil pushAppUtil;
|
||||||
|
@Autowired
|
||||||
|
private AppMessageMapper appMessageMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendToSingle(MessageDTO messageDTO, String groupId) {
|
||||||
|
//根据分组id查询出关联的用户id
|
||||||
|
List<String> groupUserIds = appMessageMapper.findGroupUserIds(groupId);
|
||||||
|
if (CollectionUtils.isNotEmpty(groupUserIds)) {
|
||||||
|
//根据用户id查询出用户关联的app客户端id
|
||||||
|
List<String> userClientId = appMessageMapper.findUserClientId(groupUserIds);
|
||||||
|
if (CollectionUtils.isNotEmpty(userClientId)) {
|
||||||
|
//调用app推送方法
|
||||||
|
pushAppUtil.pushToList(messageDTO, userClientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,146 @@
|
||||||
|
package org.jeecg.modules.message.util;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.getui.push.v2.sdk.api.PushApi;
|
||||||
|
import com.getui.push.v2.sdk.common.ApiResult;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.Audience;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.AudienceDTO;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.Settings;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.message.PushChannel;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.message.PushDTO;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.message.PushMessage;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.message.android.AndroidDTO;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.message.android.GTNotification;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.message.android.ThirdNotification;
|
||||||
|
import com.getui.push.v2.sdk.dto.req.message.android.Ups;
|
||||||
|
import com.getui.push.v2.sdk.dto.res.TaskIdDTO;
|
||||||
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||||
|
import org.jeecg.modules.message.mapper.AppMessageMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PushAppUtil {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AppMessageMapper appMessageMapper;
|
||||||
|
@Resource(name = "onlyPushApi")
|
||||||
|
private PushApi pushApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据groupId,查询给个人
|
||||||
|
* @param messageDTO
|
||||||
|
* @param groupId
|
||||||
|
*/
|
||||||
|
public void pushToSingle(MessageDTO messageDTO, String groupId) {
|
||||||
|
//根据分组id查询出关联的用户id
|
||||||
|
List<String> groupUserIds = appMessageMapper.findGroupUserIds(groupId);
|
||||||
|
if (CollectionUtils.isNotEmpty(groupUserIds)) {
|
||||||
|
//根据用户id查询出用户关联的app客户端id
|
||||||
|
List<String> userClientId = appMessageMapper.findUserClientId(groupUserIds);
|
||||||
|
if (CollectionUtils.isNotEmpty(userClientId)) {
|
||||||
|
//调用app推送方法
|
||||||
|
pushToList(messageDTO, userClientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pushToList(MessageDTO messageDTO, List<String> clientIds) {
|
||||||
|
//批量发送
|
||||||
|
AudienceDTO audienceDTO = new AudienceDTO();
|
||||||
|
|
||||||
|
PushDTO<Audience> pushDTO = buildPushDTO(messageDTO.getTitle(), messageDTO.getContent());
|
||||||
|
//创建消息
|
||||||
|
ApiResult<TaskIdDTO> createApiResult = pushApi.createMsg(pushDTO);
|
||||||
|
if (! createApiResult.isSuccess()) {
|
||||||
|
System.out.println("推送:创建消息失败"+createApiResult.getMsg());
|
||||||
|
}
|
||||||
|
// 设置接收人信息
|
||||||
|
Audience audience = new Audience();
|
||||||
|
pushDTO.setAudience(audience);
|
||||||
|
audience.setCid(clientIds);
|
||||||
|
|
||||||
|
audienceDTO.setAudience(audience);
|
||||||
|
audienceDTO.setTaskid(createApiResult.getData().getTaskId());
|
||||||
|
audienceDTO.setAsync(true);
|
||||||
|
|
||||||
|
ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushListByCid(audienceDTO);
|
||||||
|
if (apiResult.isSuccess()) {
|
||||||
|
// success
|
||||||
|
System.out.println(apiResult.getMsg());
|
||||||
|
} else {
|
||||||
|
// failed
|
||||||
|
System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建推送消息
|
||||||
|
* @param title
|
||||||
|
* @param content
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private PushDTO<Audience> buildPushDTO(String title, String content) {
|
||||||
|
PushDTO<Audience> pushDTO = new PushDTO<>();
|
||||||
|
// 设置推送参数
|
||||||
|
pushDTO.setRequestId(System.currentTimeMillis() + "");
|
||||||
|
pushDTO.setGroupName("test-group");
|
||||||
|
|
||||||
|
//配置推送条件
|
||||||
|
Settings settings = new Settings();
|
||||||
|
pushDTO.setSettings(settings);
|
||||||
|
//消息有效期,走厂商消息需要设置该值
|
||||||
|
settings.setTtl(3600000);
|
||||||
|
|
||||||
|
//安卓在线通道走个推推送时的消息体(在线通道不支持ios)
|
||||||
|
PushMessage pushMessage = new PushMessage();
|
||||||
|
pushDTO.setPushMessage(pushMessage);
|
||||||
|
//通知消息
|
||||||
|
GTNotification notification = new GTNotification();
|
||||||
|
pushMessage.setNotification(notification);
|
||||||
|
notification.setTitle(title);
|
||||||
|
notification.setBody(content);
|
||||||
|
notification.setClickType("intent");
|
||||||
|
notification.setIntent("intent://io.dcloud.unipush/?#Intent;scheme=unipush;launchFlags=0x4000000;component=com.analysissystem/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=测试标题;S.content=测试内容;S.payload=test;end");
|
||||||
|
//透传消息 此格式的透传消息由 unipush 做了特殊处理,会自动展示通知栏。开发者也可自定义其它格式,在客户端自己处理。
|
||||||
|
// pushMessage.setTransmission(" {title:\"个推通道透传消息标题\",content:\"个推通道透传消息内容\",payload:\"自定义数据\"}");
|
||||||
|
|
||||||
|
//设置离线推送时的消息体
|
||||||
|
PushChannel pushChannel = new PushChannel();
|
||||||
|
|
||||||
|
//安卓离线厂商通道推送的消息体
|
||||||
|
AndroidDTO androidDTO = new AndroidDTO();
|
||||||
|
Ups ups = new Ups();
|
||||||
|
//通知消息
|
||||||
|
ThirdNotification thirdNotification = new ThirdNotification();
|
||||||
|
ups.setNotification(thirdNotification);
|
||||||
|
thirdNotification.setTitle(title);
|
||||||
|
thirdNotification.setBody(content);
|
||||||
|
thirdNotification.setClickType("intent");
|
||||||
|
thirdNotification.setIntent("intent://io.dcloud.unipush/?#Intent;scheme=unipush;launchFlags=0x4000000;component=com.analysissystem/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=测试标题;S.content=测试内容;S.payload=test;end");
|
||||||
|
//透传消息
|
||||||
|
// ups.setTransmission(" {title:\"安卓离线厂商通道透传消息标题\",content:\"安卓离线厂商通道透传消息内容\",payload:\"自定义数据\"}");
|
||||||
|
//华为手机配置厂商参数
|
||||||
|
ups.addOption("HW", "/message/android/notification/badge/add_num", 1);
|
||||||
|
ups.addOption("HW", "/message/android/notification/importance", "HIGH");
|
||||||
|
ups.addOption("HW", "/message/android/ttl", "86400s");
|
||||||
|
//OPPO手机配置厂商参数
|
||||||
|
ups.addOption("OP", "/off_line", true);
|
||||||
|
ups.addOption("OP", "/show_ttl", 86400);
|
||||||
|
//VIVO手机配置厂商参数
|
||||||
|
ups.addOption("VV", "/notifyType", 4);
|
||||||
|
ups.addOption("VV", "/timeToLive", 86400);
|
||||||
|
|
||||||
|
androidDTO.setUps(ups);
|
||||||
|
pushChannel.setAndroid(androidDTO);
|
||||||
|
|
||||||
|
pushDTO.setPushChannel(pushChannel);
|
||||||
|
return pushDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import org.jeecg.common.util.SpringContextUtils;
|
||||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||||
import org.jeecg.modules.feignclient.MonitorSystem;
|
import org.jeecg.modules.feignclient.MonitorSystem;
|
||||||
import org.jeecg.modules.message.SendMessage;
|
import org.jeecg.modules.message.SendMessage;
|
||||||
|
import org.jeecg.modules.message.util.PushAppUtil;
|
||||||
|
|
||||||
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -24,6 +25,8 @@ public abstract class Monitor {
|
||||||
|
|
||||||
private AbnormalAlarmClient alarmClient;
|
private AbnormalAlarmClient alarmClient;
|
||||||
|
|
||||||
|
private PushAppUtil pushAppUtil;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 规则首次触发报警后,设置该规则的沉默周期(如果有)
|
* 规则首次触发报警后,设置该规则的沉默周期(如果有)
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +43,7 @@ public abstract class Monitor {
|
||||||
redisStreamUtil = SpringContextUtils.getBean(RedisStreamUtil.class);
|
redisStreamUtil = SpringContextUtils.getBean(RedisStreamUtil.class);
|
||||||
alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
|
alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
|
||||||
monitorSystem = SpringContextUtils.getBean(MonitorSystem.class);
|
monitorSystem = SpringContextUtils.getBean(MonitorSystem.class);
|
||||||
|
pushAppUtil = SpringContextUtils.getBean(PushAppUtil.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void destroy() {
|
protected void destroy() {
|
||||||
|
|
|
@ -116,6 +116,7 @@ public class DatabaseJob extends Monitor implements Job{
|
||||||
String groupId = alarmRule.getContactId();
|
String groupId = alarmRule.getContactId();
|
||||||
String notific = alarmRule.getNotification();
|
String notific = alarmRule.getNotification();
|
||||||
getSendMessage().send(messageDTO, groupId, notific);
|
getSendMessage().send(messageDTO, groupId, notific);
|
||||||
|
getPushAppUtil().pushToSingle(messageDTO, groupId);
|
||||||
}
|
}
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
log.error("Database预警规则: {}解析失败,失败原因: {}", operator, e.getMessage());
|
log.error("Database预警规则: {}解析失败,失败原因: {}", operator, e.getMessage());
|
||||||
|
|
|
@ -107,6 +107,7 @@ public class EmailJob extends Monitor implements Job{
|
||||||
String groupId = alarmRule.getContactId();
|
String groupId = alarmRule.getContactId();
|
||||||
String notific = alarmRule.getNotification();
|
String notific = alarmRule.getNotification();
|
||||||
getSendMessage().send(messageDTO, groupId, notific);
|
getSendMessage().send(messageDTO, groupId, notific);
|
||||||
|
getPushAppUtil().pushToSingle(messageDTO, groupId);
|
||||||
}
|
}
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
log.error("Email预警规则: {}解析失败,失败原因: {}", operator, e.getMessage());
|
log.error("Email预警规则: {}解析失败,失败原因: {}", operator, e.getMessage());
|
||||||
|
|
|
@ -122,6 +122,7 @@ public class ServerJob extends Monitor implements Job {
|
||||||
String groupId = alarmRule.getContactId();
|
String groupId = alarmRule.getContactId();
|
||||||
String notific = alarmRule.getNotification();
|
String notific = alarmRule.getNotification();
|
||||||
getSendMessage().send(messageDTO, groupId, notific);
|
getSendMessage().send(messageDTO, groupId, notific);
|
||||||
|
getPushAppUtil().pushToSingle(messageDTO, groupId);
|
||||||
}
|
}
|
||||||
}catch (FeignException.Unauthorized e){
|
}catch (FeignException.Unauthorized e){
|
||||||
ManageUtil.refreshToken();
|
ManageUtil.refreshToken();
|
||||||
|
|
|
@ -612,12 +612,22 @@ public class LoginController {
|
||||||
|
|
||||||
//6. 生成token
|
//6. 生成token
|
||||||
String token = JwtUtil.sign(username, syspassword);
|
String token = JwtUtil.sign(username, syspassword);
|
||||||
|
//判断是否存在当前token如果存在 销毁当前token重新生成token信息
|
||||||
|
if ( redisUtil.hasKey(CommonConstant.PREFIX_USER_TOKEN_APP+username) ) {
|
||||||
|
//获取存储的app端token
|
||||||
|
String usedToken = (String) redisUtil.get(CommonConstant.PREFIX_USER_TOKEN_APP+username);
|
||||||
|
logOutApp(usedToken);
|
||||||
|
}
|
||||||
|
|
||||||
// 设置超时时间
|
// 设置超时时间
|
||||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
|
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
|
||||||
|
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN_APP+username, token);
|
||||||
|
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN_APP+username, JwtUtil.EXPIRE_TIME*2 / 1000);
|
||||||
|
|
||||||
//token 信息
|
//token 信息
|
||||||
obj.put("token", token);
|
obj.put("token", token);
|
||||||
|
|
||||||
result.setResult(obj);
|
result.setResult(obj);
|
||||||
result.setSuccess(true);
|
result.setSuccess(true);
|
||||||
result.setCode(200);
|
result.setCode(200);
|
||||||
|
@ -625,6 +635,30 @@ public class LoginController {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logOutApp(String token) {
|
||||||
|
//通过token获取用户名
|
||||||
|
String username = JwtUtil.getUsername(token);
|
||||||
|
//根据用户名查询用户信息
|
||||||
|
LoginUser sysUser = sysBaseApi.getUserByName(username);
|
||||||
|
//用户信息不为空
|
||||||
|
if(sysUser!=null) {
|
||||||
|
//update-begin--Author:wangshuai Date:20200714 for:登出日志没有记录人员
|
||||||
|
baseCommonService.addLog("用户名: "+sysUser.getRealname()+",退出成功[移动端]!", CommonConstant.LOG_TYPE_1, null,sysUser);
|
||||||
|
//update-end--Author:wangshuai Date:20200714 for:登出日志没有记录人员
|
||||||
|
log.info(" 用户名: "+sysUser.getRealname()+",退出成功[移动端]! ");
|
||||||
|
//清空用户登录Token缓存
|
||||||
|
redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token);
|
||||||
|
//清空用户登陆app端Token缓存
|
||||||
|
redisUtil.del(CommonConstant.PREFIX_USER_TOKEN_APP+username);
|
||||||
|
//清空用户登录Shiro权限缓存
|
||||||
|
redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId());
|
||||||
|
//清空用户的缓存信息(包括部门信息),例如sys:cache:user::<username>
|
||||||
|
redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername()));
|
||||||
|
//调用shiro的logout
|
||||||
|
SecurityUtils.getSubject().logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图形验证码
|
* 图形验证码
|
||||||
* @param sysLoginModel
|
* @param sysLoginModel
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.jeecg.modules.system.controller;
|
||||||
|
|
||||||
|
import org.jeecg.modules.base.entity.postgre.SysUserClient;
|
||||||
|
import org.jeecg.modules.system.service.ISysUserClientService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/userClient")
|
||||||
|
public class SysUserClientController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserClientService userClientService;
|
||||||
|
|
||||||
|
@PostMapping("saveOrUpdateClient")
|
||||||
|
public void saveOrUpdateClient(@RequestBody SysUserClient sysUserClient) {
|
||||||
|
userClientService.saveOrUpdateClient(sysUserClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.jeecg.modules.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.jeecg.modules.base.entity.postgre.SysUserClient;
|
||||||
|
|
||||||
|
public interface SysUserClientMapper extends BaseMapper<SysUserClient> {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.jeecg.modules.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.modules.base.entity.postgre.SysUserClient;
|
||||||
|
|
||||||
|
public interface ISysUserClientService extends IService<SysUserClient> {
|
||||||
|
|
||||||
|
void saveOrUpdateClient(SysUserClient sysUserClient);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.jeecg.modules.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.jeecg.modules.base.entity.postgre.SysUserClient;
|
||||||
|
import org.jeecg.modules.system.mapper.SysUserClientMapper;
|
||||||
|
import org.jeecg.modules.system.service.ISysUserClientService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service("sysUserClientService")
|
||||||
|
public class SysUserClientServiceImpl extends ServiceImpl<SysUserClientMapper, SysUserClient> implements ISysUserClientService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveOrUpdateClient(SysUserClient userClient) {
|
||||||
|
//根据用户id查询cid
|
||||||
|
LambdaQueryWrapper<SysUserClient> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysUserClient::getUserId, userClient.getUserId());
|
||||||
|
SysUserClient sysUserClient = this.baseMapper.selectOne(queryWrapper);
|
||||||
|
//判断用户关联的客户端id是否为空
|
||||||
|
if (Objects.nonNull(sysUserClient)) {
|
||||||
|
sysUserClient.setClientId(userClient.getClientId());
|
||||||
|
this.baseMapper.updateById(sysUserClient);
|
||||||
|
} else {//如果用户关联的客户端id为空 说明当前用户没有关联的客户端id
|
||||||
|
userClient.setId(IdWorker.getIdStr());
|
||||||
|
this.baseMapper.insert(userClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user