feat:send message
This commit is contained in:
parent
6da18a25e6
commit
d9e89f5606
|
@ -79,6 +79,8 @@ public interface CommonConstant {
|
|||
public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:";
|
||||
/** 登录用户Token令牌缓存KEY前缀 */
|
||||
String PREFIX_USER_TOKEN = "prefix_user_token:";
|
||||
/** APP端记录登陆用户Token令牌缓存KEY */
|
||||
String PREFIX_USER_TOKEN_APP = "prefix_user_token_app:";
|
||||
// /** Token缓存时间:3600秒即一小时 */
|
||||
// int TOKEN_EXPIRE_TIME = 3600;
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ public interface ServiceNameConstants {
|
|||
/**
|
||||
* 微服务名:系统管理模块
|
||||
*/
|
||||
String SERVICE_SYSTEM = "jeecg-system";
|
||||
String SERVICE_SYSTEM = "armd-system";
|
||||
/**
|
||||
* 微服务名: demo模块
|
||||
*/
|
||||
String SERVICE_DEMO = "jeecg-demo";
|
||||
String SERVICE_DEMO = "armd-demo";
|
||||
/**
|
||||
* 微服务名: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;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -19,8 +19,8 @@ public interface SystemClient {
|
|||
@RequestMapping("/sys/user/findUserMap")
|
||||
Map<String, SysUser> findUserMap();
|
||||
|
||||
@GetMapping("/sys/sendMessage/send")
|
||||
void sendMessage(@RequestParam MessageDTO messageDTO,
|
||||
@PostMapping("/sys/sendMessage/send")
|
||||
void sendMessage(@RequestBody MessageDTO messageDTO,
|
||||
@RequestParam String groupId,
|
||||
@RequestParam String notific);
|
||||
|
||||
|
@ -39,4 +39,9 @@ public interface SystemClient {
|
|||
|
||||
@GetMapping("/gardsStations/stationCodesMap")
|
||||
Map<String,String> stationCodesMap();
|
||||
|
||||
@PostMapping("/sys/appMessage/pushMessageToSingle")
|
||||
void pushMessageToSingle(@RequestBody MessageDTO messageDTO, @RequestParam String groupId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -198,8 +198,12 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
logService.saveLog(logInfo);
|
||||
// 发送报警信息
|
||||
String groupId = info.getGroupId();
|
||||
if (StrUtil.isNotBlank(groupId))
|
||||
systemClient.sendMessage(new MessageDTO(), groupId, ALL.getValue());
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
messageDTO.setTitle("Nuclied Warn Info").setContent(alarmInfo.toString());
|
||||
if (StrUtil.isNotBlank(groupId)) {
|
||||
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 qsSaveScac = savePath + StringPool.SLASH + qsScacPath;
|
||||
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.getVLc(), "Lc", rootPath + qsSaveLc);
|
||||
GammaReportUtil.writeFile(fileAnlyse.getVScac(), "Scac", rootPath + qsSaveScac);
|
||||
|
|
|
@ -81,6 +81,7 @@ public class DataReceivingStatusManager {
|
|||
String cacheTime = (String) redisUtil.get("maxCacheTime");
|
||||
//从redis中获取台站信息
|
||||
Map<String, GardsStations> stationInfoMap = (HashMap<String, GardsStations>) redisUtil.get("stationInfoMap");
|
||||
// List<Integer> stationIds = stationInfoMap.keySet().stream().collect(Collectors.toList());
|
||||
List<String> stationIds = new LinkedList<>();
|
||||
for (Map.Entry<String, GardsStations> stationInfo:stationInfoMap.entrySet()) {
|
||||
GardsStations infoValue = stationInfo.getValue();
|
||||
|
|
|
@ -55,6 +55,24 @@
|
|||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-module-beta-gamma-analyser</artifactId>
|
||||
</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>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>getui-nexus</id>
|
||||
<url>https://mvn.getui.com/nexus/content/repositories/releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</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);
|
||||
}
|
||||
|
||||
}
|
|
@ -18,8 +18,8 @@ public class SendMessageController {
|
|||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
@GetMapping("send")
|
||||
public void sendMessage(@RequestParam MessageDTO messageDTO,
|
||||
@PostMapping("send")
|
||||
public void sendMessage(@RequestBody MessageDTO messageDTO,
|
||||
@RequestParam String groupId,
|
||||
@RequestParam String notific){
|
||||
sendMessage.send(messageDTO, groupId, notific);
|
||||
|
|
|
@ -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,37 @@
|
|||
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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@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)) {
|
||||
userClientId = userClientId.stream().distinct().collect(Collectors.toList());
|
||||
//调用app推送方法
|
||||
pushAppUtil.pushToList(messageDTO, userClientId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@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)) {
|
||||
userClientId = userClientId.stream().distinct().collect(Collectors.toList());
|
||||
//调用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/category", "WORK");
|
||||
//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.MonitorSystem;
|
||||
import org.jeecg.modules.message.SendMessage;
|
||||
import org.jeecg.modules.message.util.PushAppUtil;
|
||||
|
||||
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||
@Getter
|
||||
|
@ -24,6 +25,8 @@ public abstract class Monitor {
|
|||
|
||||
private AbnormalAlarmClient alarmClient;
|
||||
|
||||
private PushAppUtil pushAppUtil;
|
||||
|
||||
/*
|
||||
* 规则首次触发报警后,设置该规则的沉默周期(如果有)
|
||||
*/
|
||||
|
@ -40,6 +43,7 @@ public abstract class Monitor {
|
|||
redisStreamUtil = SpringContextUtils.getBean(RedisStreamUtil.class);
|
||||
alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
|
||||
monitorSystem = SpringContextUtils.getBean(MonitorSystem.class);
|
||||
pushAppUtil = SpringContextUtils.getBean(PushAppUtil.class);
|
||||
}
|
||||
|
||||
protected void destroy() {
|
||||
|
|
|
@ -116,6 +116,7 @@ public class DatabaseJob extends Monitor implements Job{
|
|||
String groupId = alarmRule.getContactId();
|
||||
String notific = alarmRule.getNotification();
|
||||
getSendMessage().send(messageDTO, groupId, notific);
|
||||
getPushAppUtil().pushToSingle(messageDTO, groupId);
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Database预警规则: {}解析失败,失败原因: {}", operator, e.getMessage());
|
||||
|
|
|
@ -107,6 +107,7 @@ public class EmailJob extends Monitor implements Job{
|
|||
String groupId = alarmRule.getContactId();
|
||||
String notific = alarmRule.getNotification();
|
||||
getSendMessage().send(messageDTO, groupId, notific);
|
||||
getPushAppUtil().pushToSingle(messageDTO, groupId);
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Email预警规则: {}解析失败,失败原因: {}", operator, e.getMessage());
|
||||
|
|
|
@ -122,6 +122,7 @@ public class ServerJob extends Monitor implements Job {
|
|||
String groupId = alarmRule.getContactId();
|
||||
String notific = alarmRule.getNotification();
|
||||
getSendMessage().send(messageDTO, groupId, notific);
|
||||
getPushAppUtil().pushToSingle(messageDTO, groupId);
|
||||
}
|
||||
}catch (FeignException.Unauthorized e){
|
||||
ManageUtil.refreshToken();
|
||||
|
|
|
@ -612,12 +612,22 @@ public class LoginController {
|
|||
|
||||
//6. 生成token
|
||||
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.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 信息
|
||||
obj.put("token", token);
|
||||
|
||||
result.setResult(obj);
|
||||
result.setSuccess(true);
|
||||
result.setCode(200);
|
||||
|
@ -625,6 +635,30 @@ public class LoginController {
|
|||
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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -24,10 +24,11 @@ public class RadionuclideController {
|
|||
|
||||
@GetMapping("findAutoPage")
|
||||
@ApiOperation(value = "分页查询自动处理结果", notes = "分页查询自动处理结果")
|
||||
public Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds, String qualifie,
|
||||
public Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds,
|
||||
String qualifie, String sampleType,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")Date startTime,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
|
||||
return autoService.findAutoPage(queryRequest, stationIds, qualifie, startTime, endTime);
|
||||
return autoService.findAutoPage(queryRequest, stationIds, qualifie, sampleType,startTime, endTime);
|
||||
}
|
||||
|
||||
@GetMapping("findReviewedPage")
|
||||
|
|
|
@ -8,11 +8,12 @@ import org.jeecg.modules.entity.GardsSampleDataWeb;
|
|||
import org.jeecg.modules.entity.vo.SpectrumFileRecord;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface GardsSampleDataWebMapper extends BaseMapper<GardsSampleDataWeb> {
|
||||
|
||||
Page<GardsSampleDataWeb> findAutoPage(String startDate, String endDate, List<Integer> stationIdList, String qualifie, Page<GardsSampleDataWeb> page);
|
||||
Page<GardsSampleDataWeb> findAutoPage(String startDate, String endDate, List<Integer> stationIdList, String qualifie, String sampleType, Page<GardsSampleDataWeb> page);
|
||||
|
||||
Page<GardsSampleDataWeb> findReviewedPage(String startDate, String endDate, List<Integer> stationIdList, String qualifie, Page<GardsSampleDataWeb> page);
|
||||
|
||||
|
|
|
@ -42,6 +42,9 @@
|
|||
<if test = "qualifie != null and qualifie != ''">
|
||||
AND sam.SPECTRAL_QUALIFIE = #{qualifie}
|
||||
</if>
|
||||
<if test = "sampleType != null and sampleType != ''">
|
||||
AND sam.SAMPLE_TYPE = #{sampleType}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sam.ACQUISITION_START DESC
|
||||
</select>
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.Date;
|
|||
|
||||
public interface IAutoService extends IService<GardsAnalyses> {
|
||||
|
||||
Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds, String qualifie, Date startTime, Date endTime);
|
||||
Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds, String qualifie, String sampleType,Date startTime, Date endTime);
|
||||
|
||||
GardsAnalyses getOne(Integer sampleId);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class AutoServiceImpl extends ServiceImpl<GardsAnalysesAutoMapper, GardsA
|
|||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds, String qualifie, Date startTime, Date endTime) {
|
||||
public Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds, String qualifie, String sampleType, Date startTime, Date endTime) {
|
||||
Result result = new Result();
|
||||
//获取redis中缓存的台站信息
|
||||
Map<String, String> stationMap = (Map<String, String>)redisUtil.get("stationMap");
|
||||
|
@ -66,7 +66,7 @@ public class AutoServiceImpl extends ServiceImpl<GardsAnalysesAutoMapper, GardsA
|
|||
stationIdList = Arrays.asList(stationIds);
|
||||
}
|
||||
Page<GardsSampleDataWeb> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
||||
Page<GardsSampleDataWeb> sampleDataPage = gardsSampleDataWebMapper.findAutoPage(startDate, endDate, stationIdList, qualifie, page);
|
||||
Page<GardsSampleDataWeb> sampleDataPage = gardsSampleDataWebMapper.findAutoPage(startDate, endDate, stationIdList, qualifie, sampleType, page);
|
||||
sampleDataPage.getRecords().forEach(item->{
|
||||
item.setSiteDetCode(StringUtils.trim(item.getSiteDetCode()));
|
||||
if (stationMap.containsKey(item.getStationId().toString()) && CollectionUtils.isNotEmpty(stationMap)){
|
||||
|
|
Loading…
Reference in New Issue
Block a user