Commit 53a350d8 authored by 赵啸非's avatar 赵啸非

设备token验证添加

parent f84acfe5
......@@ -14,7 +14,7 @@
<parent>
<groupId>com.mortals.xhx</groupId>
<artifactId>device-platform</artifactId>
<artifactId>device-new-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
......
......@@ -77,54 +77,6 @@ INSERT INTO `mortals_xhx_menu` VALUES (9106, '任务信息', '/task/list', 91, 6
INSERT INTO `mortals_xhx_menu` VALUES (9107, '操作日志', '/oper/log/list', 91, 70, 1, 0, 0, NULL, NULL, NULL, NULL, 0, 0, 3, NULL, NULL, NULL);
INSERT INTO `mortals_xhx_menu` VALUES (9133, '站点管理', '/site/list', 91, NULL, 1, 0, 1, NULL, 'view', NULL, NULL, 0, 0, 3, '2021-11-03 21:51:48', 1, '系统管理员');
-- ----------------------------
-- Table structure for mortals_xhx_one_site
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_one_site`;
CREATE TABLE `mortals_xhx_one_site` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键,自增长',
`site_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点名称',
`is_site` tinyint(2) NULL DEFAULT NULL COMMENT '是否是站点 1是 0是展示数据',
`iid` bigint(20) NULL DEFAULT NULL COMMENT '标识ID',
`p_id` bigint(20) NULL DEFAULT NULL COMMENT '父级id',
`region_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '区域编号',
`site_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点编号',
`pro_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '省编码',
`area_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '区编码',
`city_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '市编码',
`site_ip` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点服务器ip',
`site_port` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点服务器端口',
`site_one_code_mac` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点一码通mac地址',
`longitude` decimal(10, 6) NULL DEFAULT NULL COMMENT '经度',
`latitude` decimal(10, 6) NULL DEFAULT NULL COMMENT '纬度',
`haveSonArea` char(5) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '是否有下级',
`site_tel` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '中心联系电话',
`detail_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '中心详细地址',
`site_remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '中心介绍',
`am_work_start_time` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '上午上班开始时间',
`am_work_end_time` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '上午上班结束时间',
`pm_work_start_time` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '下午上班开始时间',
`pm_work_end_time` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '下午上班结束时间',
`average_time` bigint(20) NULL DEFAULT NULL COMMENT '平均等待时间,后期删除,单位毫秒',
`waiting_number` int(5) NULL DEFAULT NULL COMMENT '等待人数,后期删除',
`workday1` tinyint(1) NULL DEFAULT NULL COMMENT '周一 1上班 0不上',
`workday2` tinyint(1) NULL DEFAULT NULL COMMENT '周二 1上班 0不上',
`workday3` tinyint(1) NULL DEFAULT NULL COMMENT '周三 1上班 0不上',
`workday4` tinyint(1) NULL DEFAULT NULL COMMENT '周四 1上班 0不上',
`workday5` tinyint(1) NULL DEFAULT NULL COMMENT '周五 1上班 0不上',
`workday6` tinyint(1) NULL DEFAULT NULL COMMENT '周六 1上班 0不上',
`workday7` tinyint(1) NULL DEFAULT NULL COMMENT '周日 1上班 0不上',
`lv` tinyint(4) NULL DEFAULT NULL COMMENT '楼层',
`building` tinyint(4) NULL DEFAULT NULL COMMENT '楼栋',
`deleted` tinyint(1) NULL DEFAULT 0 COMMENT '删除状态 0未删除 1已删除',
`createUserId` bigint(20) NULL DEFAULT NULL COMMENT '创建人id',
`createUserName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人名称',
`createTime` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`updateUserId` bigint(20) NULL DEFAULT NULL COMMENT '修改人',
`updateUserName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人名称',
`updateTime` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '站点表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for mortals_xhx_oper_log
......@@ -277,14 +229,6 @@ CREATE TABLE `mortals_xhx_site` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '站点信息表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of mortals_xhx_site
-- ----------------------------
INSERT INTO `mortals_xhx_site` VALUES (5, '测试站点1', 0, '', '12313', '13281114856', '123123', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '12313', '213132123', 0, 1, '2021-09-27 13:53:53', 'admin', '2021-09-27 11:34:20', 'admin');
INSERT INTO `mortals_xhx_site` VALUES (6, '测试站点1-1', 10, ',10', '啊啊啊', '13908095770', 'asd', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'adadf', 'dsaasdf', 0, 1, '2021-09-27 12:04:31', 'admin', '2021-09-27 11:35:11', 'admin');
INSERT INTO `mortals_xhx_site` VALUES (7, '测试站点1-2', 5, ',5', '达到', '13808095771', '111', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '对对对', '222', 0, 1, '2021-09-27 12:04:31', 'admin', '2021-09-27 11:36:19', 'admin');
INSERT INTO `mortals_xhx_site` VALUES (10, '测试站点2', 0, '', '2222', '13808095774', '22', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '111', '333', 0, 1, '2021-09-27 12:04:31', 'admin', '2021-09-27 12:03:50', 'admin');
-- ----------------------------
-- Table structure for mortals_xhx_table_index
-- ----------------------------
......
-- ----------------------------
-- 设备表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_stp_device`;
CREATE TABLE mortals_stp_device(
DROP TABLE IF EXISTS `mortals_xhx_device`;
CREATE TABLE mortals_xhx_device(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`deviceName` varchar(20) NOT NULL COMMENT '设备名称',
`deviceCode` varchar(256) COMMENT '设备编码',
......@@ -16,6 +16,7 @@ CREATE TABLE mortals_stp_device(
`deviceFirmname` varchar(20) COMMENT '设备生产厂商名称',
`deviceOnlineStatus` tinyint(2) NOT NULL COMMENT '在线状态 (0.离线,1.在线)',
`status` tinyint(2) NOT NULL COMMENT '启用状态 (0.停止,1.启用)',
`active` tinyint(2) NOT NULL COMMENT '激活状态 (0.未激活,1.已激活)',
`deviceRemark` varchar(256) COMMENT '备注',
`onlineTime` datetime COMMENT '最近上线时间',
`offlineTime` datetime COMMENT '最近离线时间',
......@@ -25,11 +26,12 @@ CREATE TABLE mortals_stp_device(
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备';
-- ----------------------------
-- 设备生产厂商表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_stp_firm`;
CREATE TABLE mortals_stp_firm(
DROP TABLE IF EXISTS `mortals_xhx_firm`;
CREATE TABLE mortals_xhx_firm(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`firmName` varchar(128) NOT NULL COMMENT '设备生产厂商名称',
`firmCode` varchar(128) COMMENT '设备生产商编码',
......@@ -40,6 +42,8 @@ CREATE TABLE mortals_stp_firm(
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备生产厂商';
-- ----------------------------
-- 设备日志表
-- ----------------------------
......@@ -56,6 +60,7 @@ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备日志';
-- ----------------------------
-- 设备菜单 SQL
-- ----------------------------
......@@ -66,27 +71,6 @@ INSERT INTO `mortals_xhx_menu` VALUES (null, '设备', '/device/list', 0, 1, 1,
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备-菜单管理-查看', '/device/list,/device/view,/device/info,/device/export,/device/exportExcel,/device/downloadTemplate,/device/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备-菜单管理-维护', '/device/add,/device/edit,/device/delete,/device/logicDelete,/device/save,/device/importData', 3, 0, NULL, NULL, NULL, 0);
-- ----------------------------
-- 设备生产厂商菜单 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_menu` VALUES (null, '设备生产厂商', '/firm/list', 0, 1, 1, 0, 0,'',NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL);
-- ----------------------------
-- 设备生产厂商资源路径 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备生产厂商-菜单管理-查看', '/firm/list,/firm/view,/firm/info,/firm/export,/firm/exportExcel,/firm/downloadTemplate,/firm/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备生产厂商-菜单管理-维护', '/firm/add,/firm/edit,/firm/delete,/firm/logicDelete,/firm/save,/firm/importData', 3, 0, NULL, NULL, NULL, 0);
-- ----------------------------
-- 设备日志菜单 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_menu` VALUES (null, '设备日志', '/device/log/list', 0, 1, 1, 0, 0,'',NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL);
-- ----------------------------
-- 设备日志资源路径 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备日志-菜单管理-查看', '/device/log/list,/device/log/view,/device/log/info,/device/log/export,/device/log/exportExcel,/device/log/downloadTemplate,/device/log/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备日志-菜单管理-维护', '/device/log/add,/device/log/edit,/device/log/delete,/device/log/logicDelete,/device/log/save,/device/log/importData', 3, 0, NULL, NULL, NULL, 0);
-- ----------------------------
-- 设备参数 SQL
......@@ -107,16 +91,23 @@ INSERT INTO `mortals_xhx_param` VALUES (null, '在线状态 ', 'Device', 'device
INSERT INTO `mortals_xhx_param` VALUES (null, '在线状态 ', 'Device', 'deviceOnlineStatus', '1', '在线', 1, 4, 0, 'deviceOnlineStatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '启用状态 ', 'Device', 'status', '0', '停止', 1, 4, 0, 'status', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '启用状态 ', 'Device', 'status', '1', '启用', 1, 4, 0, 'status', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '激活状态 ', 'Device', 'active', '0', '未激活', 1, 4, 0, 'active', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '激活状态 ', 'Device', 'active', '1', '已激活', 1, 4, 0, 'active', NULL, NULL, NULL);
-- ----------------------------
-- 设备生产厂商参数 SQL
-- 设备生产厂商菜单 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_menu` VALUES (null, '设备生产厂商', '/firm/list', 0, 1, 1, 0, 0,'',NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL);
-- ----------------------------
-- 设备日志参数 SQL
-- 设备生产厂商资源路径 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_param` VALUES (null, '日志类型,', 'DeviceLog', 'logType', '0', '上报事件', 1, 4, 0, 'logType', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '日志类型,', 'DeviceLog', 'logType', '1', '下发服务', 1, 4, 0, 'logType', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备生产厂商-菜单管理-查看', '/firm/list,/firm/view,/firm/info,/firm/export,/firm/exportExcel,/firm/downloadTemplate,/firm/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备生产厂商-菜单管理-维护', '/firm/add,/firm/edit,/firm/delete,/firm/logicDelete,/firm/save,/firm/importData', 3, 0, NULL, NULL, NULL, 0);
......@@ -10,7 +10,7 @@
<parent>
<groupId>com.mortals.xhx</groupId>
<artifactId>device-platform</artifactId>
<artifactId>device-new-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
......@@ -55,6 +55,14 @@
<artifactId>spring-data-redis</artifactId>
</dependency>
<!--Token生成与解析-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
......
package com.mortals.xhx.base;
import java.lang.annotation.*;
/**
* 设备验证
*
* @author zxfei
*
*/
@Inherited
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DeviceAuth {
}
......@@ -10,10 +10,14 @@ import java.io.Serializable;
@Data
public class DeviceReq implements Serializable {
/**
* 行为
*/
private String action;
private String devicenum;
/**
* 设备编码(暂定mac地址)
*/
private String deviceNum;
private String ip;
......
package com.mortals.xhx.busiz.rsp;
import lombok.Data;
import java.io.Serializable;
@Data
public class DeviceResp implements Serializable {
/**
* token
*/
private String token;
}
package com.mortals.xhx.busiz.security;
import cn.hutool.core.util.IdUtil;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.device.model.DeviceEntity;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
/**
* token验证处理
*
* @author zxfei
*/
@Component
public class DeviceTokenService {
// 令牌自定义标识
@Value("${token.header}")
private String header;
// 令牌秘钥
@Value("${token.secret}")
private String secret;
// 令牌有效期(默认30分钟)
@Value("${token.expireTime}")
private int expireTime;
protected static final long MILLIS_SECOND = 1000;
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L;
@Autowired
private ICacheService cacheService;
/**
* 获取设备信息
*
* @return 设备信息
*/
public DeviceEntity getLoginDevice(HttpServletRequest request) {
// 获取请求携带的令牌
String token = getToken(request);
if (StringUtils.isNotEmpty(token)) {
Claims claims = parseToken(token);
String uuid = (String) claims.get(Constant.LOGIN_DEVICE_KEY);
String deviceKey = getTokenKey(uuid);
DeviceEntity device = cacheService.get(deviceKey, DeviceEntity.class);
return device;
}
return null;
}
/**
* 设置设备信息
*/
public void setDevice(DeviceEntity device) {
if (StringUtils.isNotNull(device) && StringUtils.isNotEmpty(device.getToken())) {
refreshToken(device);
}
}
/**
* 删除用户身份信息
*/
public void delDevice(String token) {
if (StringUtils.isNotEmpty(token)) {
String deviceKey = getTokenKey(token);
cacheService.del(deviceKey);
}
}
/**
* 创建令牌
*
* @param device 设备信息
* @return 令牌
*/
public String createToken(DeviceEntity device) {
String token = IdUtil.fastUUID();
device.setToken(token);
refreshToken(device);
Map<String, Object> claims = new HashMap<>();
claims.put(Constant.LOGIN_DEVICE_KEY, token);
return createToken(claims);
}
/**
* 验证令牌有效期,相差不足20分钟,自动刷新缓存
*
* @param device
* @return 令牌
*/
public void verifyToken(DeviceEntity device) {
long expireTime = device.getExpireTime();
long currentTime = System.currentTimeMillis();
if (expireTime - currentTime <= MILLIS_MINUTE_TEN) {
refreshToken(device);
}
}
/**
* 刷新令牌有效期
*
* @param device 信息
*/
public void refreshToken(DeviceEntity device) {
device.setLoginTime(System.currentTimeMillis());
device.setExpireTime(device.getLoginTime() + expireTime * MILLIS_MINUTE);
// 根据uuid将device缓存
String deviceKey = getTokenKey(device.getToken());
//设置有效时间 单位秒
cacheService.setnx(deviceKey, device, expireTime * MILLIS_MINUTE * MILLIS_SECOND);
}
/**
* 从数据声明生成令牌
*
* @param claims 数据声明
* @return 令牌
*/
private String createToken(Map<String, Object> claims) {
String token = Jwts.builder()
.setClaims(claims)
.signWith(SignatureAlgorithm.HS512, secret).compact();
return token;
}
/**
* 从令牌中获取数据声明
*
* @param token 令牌
* @return 数据声明
*/
private Claims parseToken(String token) {
return Jwts.parser()
.setSigningKey(secret)
.parseClaimsJws(token)
.getBody();
}
/**
* 从令牌中获取设备编号
*
* @param token 令牌
* @return 用户名
*/
public String getDeviceNumFromToken(String token) {
Claims claims = parseToken(token);
return claims.getSubject();
}
/**
* 获取请求token
*
* @param request
* @return token
*/
private String getToken(HttpServletRequest request) {
String token = request.getHeader(header);
if (StringUtils.isNotEmpty(token) && token.startsWith(Constant.TOKEN_PREFIX)) {
token = token.replace(Constant.TOKEN_PREFIX, "");
}
return token;
}
private String getTokenKey(String uuid) {
return Constant.LOGIN_TOKEN_KEY + uuid;
}
}
package com.mortals.xhx.busiz.security;
import com.mortals.framework.common.HttpStatus;
import com.mortals.framework.exception.AppException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
* 安全服务工具类
*
* @author zxfei
*/
public class SecurityUtils {
/**
* 获取Authentication
*/
public static Authentication getAuthentication() {
return SecurityContextHolder.getContext().getAuthentication();
}
/**
* 生成BCryptPasswordEncoder密码
*
* @param password 密码
* @return 加密字符串
*/
public static String encryptPassword(String password) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
return passwordEncoder.encode(password);
}
/**
* 判断密码是否相同
*
* @param rawPassword 真实密码
* @param encodedPassword 加密后字符
* @return 结果
*/
public static boolean matchesPassword(String rawPassword, String encodedPassword) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
return passwordEncoder.matches(rawPassword, encodedPassword);
}
/**
* 是否为管理员
*
* @param userId 用户ID
* @return 结果
*/
public static boolean isAdmin(Long userId) {
return userId != null && 1L == userId;
}
}
package com.mortals.xhx.busiz.security.filter;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.interceptor.BaseInterceptor;
import com.mortals.xhx.base.DeviceAuth;
import com.mortals.xhx.busiz.security.SecurityUtils;
import com.mortals.xhx.busiz.security.DeviceTokenService;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.module.device.model.DeviceEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
/**
* 设备上报验证
*
* @author: zxfei
* @date: 2022/4/11 15:50
*/
@Component
public class DeviceSubmitInterceptor extends BaseInterceptor {
@Autowired
private DeviceTokenService deviceTokenService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
DeviceAuth annotation = method.getAnnotation(DeviceAuth.class);
if (annotation != null) {
//校验
if (this.verifyDevice(request)) {
JSONObject ret = new JSONObject();
ret.put("code", ApiRespCodeEnum.TOKEN_FAILED.getValue());
ret.put("msg", ApiRespCodeEnum.TOKEN_FAILED.getLabel());
super.writeJsonResponse(response, 200, JSONObject.toJSONString(ret));
return false;
}
}
return true;
} else {
return super.preHandle(request, response, handler);
}
}
public boolean verifyDevice(HttpServletRequest request) {
DeviceEntity device = deviceTokenService.getLoginDevice(request);
if (StringUtils.isNotNull(device) && StringUtils.isNull(SecurityUtils.getAuthentication())) {
deviceTokenService.verifyToken(device);
return true;
}
return false;
}
}
package com.mortals.xhx.busiz.security.filter;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.busiz.security.SecurityUtils;
import com.mortals.xhx.busiz.security.DeviceTokenService;
import com.mortals.xhx.module.device.model.DeviceEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* token过滤器 验证token有效性
*
* @author ruoyi
*/
//@Component
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
@Autowired
private DeviceTokenService deviceTokenService;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
DeviceEntity device = deviceTokenService.getLoginDevice(request);
if (StringUtils.isNotNull(device) && StringUtils.isNull(SecurityUtils.getAuthentication())) {
deviceTokenService.verifyToken(device);
// UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities());
// authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
// SecurityContextHolder.getContext().setAuthentication(authenticationToken);
}
chain.doFilter(request, response);
}
}
......@@ -2,21 +2,22 @@ package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import com.mortals.xhx.base.DeviceAuth;
import com.mortals.xhx.base.framework.ws.message.SendToAllRequest;
import com.mortals.xhx.base.framework.ws.util.WebSocketUtil;
import com.mortals.xhx.busiz.req.DeviceReq;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.code.DeviceOnlineStatusEnum;
import com.mortals.xhx.busiz.rsp.DeviceResp;
import com.mortals.xhx.busiz.security.DeviceTokenService;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.service.DeviceLogService;
import com.mortals.xhx.module.device.service.DeviceService;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
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;
......@@ -38,26 +39,31 @@ public class DeviceApiController {
@Autowired
private DeviceService deviceService;
@Autowired
private DeviceTokenService deviceTokenService;
/**
* 设备数据上报
* 设备激活
*
* @param req
* @return
*/
@PostMapping("upload")
public String upload(DeviceReq req) {
log.info("【设备数据上报】【请求体】--> " + JSONObject.toJSONString(req));
ApiResp rsp = new ApiResp<>();
rsp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
@PostMapping("active")
public String active(@RequestBody DeviceReq req) {
log.info("【设备激活】【请求体】--> " + JSONObject.toJSONString(req));
ApiResp<DeviceResp> rsp = new ApiResp<>();
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
DeviceResp deviceResp = new DeviceResp();
try {
//根据设备编码查询设备
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDevicenum());
boolean bool = false;
//根据设备编码查询设备是否存在,如果存在判断是否已经激活
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceNum());
if (!ObjectUtils.isEmpty(deviceEntity)) {
if (deviceEntity.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.离线.getValue()) {
bool = true;
//判断设备是否已经激活,如果已激活返回token信息
if (deviceEntity.getActive() == ActiveEnum.已激活.getValue() && deviceEntity.getStatus() == StatusEnum.启用.getValue()) {
String token = deviceTokenService.createToken(deviceEntity);
deviceResp.setToken(token);
}
deviceEntity.setOnlineTime(new Date());
deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue());
......@@ -66,25 +72,11 @@ public class DeviceApiController {
deviceEntity.setSiteNum(req.getSitenum());
deviceEntity.setCenternum(req.getCenternum());
deviceService.update(deviceEntity);
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceNum(deviceEntity.getDeviceCode());
deviceLogEntity.setContent(JSONObject.toJSONString(req));
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity);
if (bool) {
WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(JSON.toJSONString(deviceEntity)));
}
} else {
//新增设备
deviceEntity = new DeviceEntity();
deviceEntity.initAttrValue();
deviceEntity.setDeviceCode(req.getDevicenum());
deviceEntity.setDeviceCode(req.getDeviceNum());
deviceEntity.setOnlineTime(new Date());
deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue());
deviceEntity.setIp(req.getIp());
......@@ -95,17 +87,41 @@ public class DeviceApiController {
deviceEntity.setCreateTime(new Date());
deviceService.save(deviceEntity);
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceNum(deviceEntity.getDeviceCode());
deviceLogEntity.setContent(JSONObject.toJSONString(req));
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity);
rsp.setMsg("当前设备未激活,激活后再上线。");
WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(JSON.toJSONString(deviceEntity)));
}
rsp.setData(deviceResp);
} catch (Exception e) {
log.error("接收数据失败", e);
rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
rsp.setMsg(e.getMessage());
return JSON.toJSONString(rsp);
}
log.info("响应【设备激活】【响应体】--> " + JSONObject.toJSONString(rsp));
return JSON.toJSONString(rsp);
}
/**
* 设备数据上报
*
* @param req
* @return
*/
@PostMapping("upload")
@DeviceAuth
public String upload(@RequestBody DeviceReq req) {
log.debug("【设备数据上报】【请求体】--> " + JSONObject.toJSONString(req));
ApiResp<String> rsp = new ApiResp<>();
rsp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
try {
//根据设备编码查询设备
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceNum());
if (!ObjectUtils.isEmpty(deviceEntity)) {
//将上报信息转发到mq中
deviceService.sendDeviceMessage(deviceEntity.getId(), JSON.toJSONString(req), null);
}
} catch (Exception e) {
log.error("接收数据失败", e);
rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
......@@ -113,7 +129,7 @@ public class DeviceApiController {
return JSON.toJSONString(rsp);
}
log.info("响应【设备数据上报】【响应体】--> " + JSONObject.toJSONString(rsp));
log.debug("响应【设备数据上报】【响应体】--> " + JSONObject.toJSONString(rsp));
return JSON.toJSONString(rsp);
}
......
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 激活状态 (0.未激活,1.已激活)枚举类
*
* @author zxfei
*/
public enum ActiveEnum {
未激活(0, "未激活"),
已激活(1, "已激活");
private Integer value;
private String desc;
ActiveEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static ActiveEnum getByValue(Integer value) {
for (ActiveEnum activeEnum : ActiveEnum.values()) {
if (activeEnum.getValue() == value) {
return activeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (ActiveEnum item : ActiveEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
......@@ -9,6 +9,9 @@ public enum ApiRespCodeEnum {
SUCCESS(1, "接收成功"),
/** 执行失败 */
FAILED(2,"执行失败"),
/** token认证失败 */
TOKEN_FAILED(3,"token认证失败"),
;
private final Integer value;
......
......@@ -17,9 +17,46 @@ public final class Constant {
*/
public static final String HTTP = "http://";
/**
* 上行消息topic
*/
public static final String UPLOAD_TOPIC = "upload:";
/**
* 下行消息topic
*/
public static final String DOWN_TOPIC = "down:";
/**
* 验证码有效期(分钟)
*/
public static final Integer CAPTCHA_EXPIRATION = 2;
/**
* 登录设备 redis key
*/
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
/**
* 令牌
*/
public static final String TOKEN = "token";
/**
* 令牌前缀
*/
public static final String TOKEN_PREFIX = "Bearer ";
/**
* 令牌前缀
*/
public static final String LOGIN_DEVICE_KEY = "login_device_key";
/** 基础代码版本 Z-BASE.MANAGER-S1.0.0 */
public final static String BASEMANAGER_VERSION = "Z-BASE.MANAGER-S1.0.0";
public final static String PARAM_SERVER_HTTP_URL = "server_http_url";
}
package com.mortals.xhx.module.device.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.DeviceEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 设备视图对象
*
* @author zxfei
* @date 2022-03-09
*/
* 设备视图对象
*
* @author zxfei
* @date 2022-03-09
*/
@Data
public class DeviceVo extends BaseEntityLong {
/**
* 设备唯一标识
*/
private String token;
/**
* 登录时间
*/
private Long loginTime;
/**
* 过期时间
*/
private Long expireTime;
}
\ No newline at end of file
package com.mortals.xhx.module.device.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.module.device.model.DeviceEntity;
import java.util.List;
/**
* DeviceService
*
......@@ -11,4 +16,11 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
*/
public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
ApiResp<String> sendDeviceMessage(Long deviceId, String message , Context context);
ApiResp<String> sendDeviceMessage(List<Long> deviceIds, String message , Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.device.service.impl;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.queue.*;
import com.mortals.xhx.queue.provider.TbCoreQueueProducerProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.xhx.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* DeviceService
* 设备 service实现
*
* @author zxfei
* @date 2022-03-09
*/
* DeviceService
* 设备 service实现
*
* @author zxfei
* @date 2022-03-09
*/
@Service("deviceService")
public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, DeviceEntity, Long> implements DeviceService {
@Autowired
private TbCoreQueueProducerProvider producerProvider;
@Override
protected String getExtKey(DeviceEntity data) {
return data.getDeviceCode();
}
@Override
public ApiResp<String> sendDeviceMessage(Long deviceId, String message, Context context) {
ApiResp<String> resp = new ApiResp<>();
resp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
resp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
//发送消息
send(message, context, resp, deviceId);
return resp;
}
@Override
public ApiResp<String> sendDeviceMessage(List<Long> deviceIds, String message, Context context) {
ApiResp<String> resp = new ApiResp<>();
resp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
resp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
for (Long deviceId : deviceIds) {
send(message, context, resp, deviceId);
}
return resp;
}
private void send(String message, Context context, ApiResp<String> resp, Long deviceId) {
DeviceEntity deviceEntity = this.get(deviceId, context);
if (!ObjectUtils.isEmpty(deviceEntity)) {
TbQueueProducer<TbQueueMsg> producer = producerProvider.getTbCoreMsgProducer();
TopicPartitionInfo info = TopicPartitionInfo.builder().topic(Constant.UPLOAD_TOPIC+deviceEntity.getDeviceMac()).build();
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.CLIENTID, "device".getBytes());
Map<String, Object> headers = new HashMap<>();
headers.put(MessageHeader.TIMESTAMP, DateUtils.getCurrStrDateTime().getBytes());
TbQueueMsg queueMsg = new DefaultTbQueueMsg(UUID.randomUUID(), message == null ? "".getBytes() : message.getBytes(), header);
producer.send(info, queueMsg, new TbQueueCallback() {
@Override
public void onSuccess(TbQueueMsgMetadata metadata) {
log.debug("消息投递成功,设备通道编码:" + deviceEntity.getDeviceMac());
}
@Override
public void onFailure(Throwable t) {
}
});
} else {
log.error(String.format("设备Id查询不到设备,deviceId:%s", deviceId));
resp.setCode(ApiRespCodeEnum.FAILED.getValue());
resp.setMsg(String.format("设备Id查询不到设备,deviceId:%s", deviceId));
}
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.mortals.xhx.module.device.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.ActiveEnum;
import com.mortals.xhx.common.code.DeviceOnlineStatusEnum;
import com.mortals.xhx.common.code.DeviceTypeEnum;
import com.mortals.xhx.module.firm.model.FirmQuery;
......@@ -70,14 +71,15 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
this.addDict(model, "deviceType", deviceTypeMap);
this.addDict(model, "deviceOnlineStatus", paramService.getParamBySecondOrganize("Device", "deviceOnlineStatus"));
this.addDict(model, "status", paramService.getParamBySecondOrganize("Device", "status"));
this.addDict(model, "active", paramService.getParamBySecondOrganize("Device", "active"));
this.addDict(model, "deviceFirmId", firmService.find(new FirmQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getFirmName())));
Map<Boolean, Long> collect = this.service.find(new DeviceQuery()).stream().collect(Collectors.partitioningBy(item -> (item.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.在线.getValue()), Collectors.counting()));
Map<Boolean, Long> collect = this.service.find(new DeviceQuery().active(ActiveEnum.已激活.getValue())).stream().collect(Collectors.partitioningBy(item -> (item.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.在线.getValue()), Collectors.counting()));
model.put("onlineCount", collect.get(true));
model.put("offlineCount", collect.get(false));
//离线设备 按类型分组
if (collect.get(false) > 0) {
Map<String, Long> collectTwo = this.service.find(new DeviceQuery().deviceOnlineStatus(DeviceOnlineStatusEnum.离线.getValue())).stream().collect(Collectors.groupingBy(x -> deviceTypeMap.get(x.getDeviceType().toString()), Collectors.counting()));
Map<String, Long> collectTwo = this.service.find(new DeviceQuery().deviceOnlineStatus(DeviceOnlineStatusEnum.离线.getValue()).active(ActiveEnum.已激活.getValue())).stream().collect(Collectors.groupingBy(x -> deviceTypeMap.get(x.getDeviceType().toString()), Collectors.counting()));
model.put("offlineDeviceType", collectTwo);
}
super.init(request, response, form, model, context);
......
......@@ -7,71 +7,71 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.firm.model.vo.FirmVo;
/**
* 设备生产厂商实体对象
*
* @author zxfei
* @date 2022-03-09
*/
* 设备生产厂商实体对象
*
* @author zxfei
* @date 2022-04-11
*/
public class FirmEntity extends FirmVo {
private static final long serialVersionUID = 1L;
/**
* 设备生产厂商名称
*/
* 设备生产厂商名称
*/
@Excel(name = "设备生产厂商名称")
private String firmName;
/**
* 设备生产商编码
*/
* 设备生产商编码
*/
private String firmCode;
/**
* 备注
*/
* 备注
*/
private String firmRemark;
public FirmEntity(){}
/**
* 获取 设备生产厂商名称
* @return String
*/
* 获取 设备生产厂商名称
* @return String
*/
public String getFirmName(){
return firmName;
}
/**
* 设置 设备生产厂商名称
* @param firmName
*/
* 设置 设备生产厂商名称
* @param firmName
*/
public void setFirmName(String firmName){
this.firmName = firmName;
}
/**
* 获取 设备生产商编码
* @return String
*/
* 获取 设备生产商编码
* @return String
*/
public String getFirmCode(){
return firmCode;
}
/**
* 设置 设备生产商编码
* @param firmCode
*/
* 设置 设备生产商编码
* @param firmCode
*/
public void setFirmCode(String firmCode){
this.firmCode = firmCode;
}
/**
* 获取 备注
* @return String
*/
* 获取 备注
* @return String
*/
public String getFirmRemark(){
return firmRemark;
}
/**
* 设置 备注
* @param firmRemark
*/
* 设置 备注
* @param firmRemark
*/
public void setFirmRemark(String firmRemark){
this.firmRemark = firmRemark;
}
......@@ -81,7 +81,7 @@ public class FirmEntity extends FirmVo {
@Override
public int hashCode() {
return this.getId().hashCode();
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
......@@ -89,7 +89,7 @@ public class FirmEntity extends FirmVo {
if (obj instanceof FirmEntity) {
FirmEntity tmp = (FirmEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
return true;
}
}
return false;
......@@ -105,10 +105,10 @@ public class FirmEntity extends FirmVo {
public void initAttrValue(){
this.firmName = "";
this.firmName = "";
this.firmCode = "";
this.firmCode = "";
this.firmRemark = "";
this.firmRemark = "";
}
}
\ No newline at end of file
......@@ -95,3 +95,12 @@ queue:
handshake_timeout: 10000
queue-properties:
core: x-max-length-bytes:1048576000;x-message-ttl:604800000
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcd1234
# 令牌有效期(默认60分钟)
expireTime: 60
......@@ -9,7 +9,7 @@
<version>1.1.5-SNAPSHOT</version>
</parent>
<groupId>com.mortals.xhx</groupId>
<artifactId>device-platform</artifactId>
<artifactId>device-new-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
......@@ -30,17 +30,17 @@
</activation>
<properties>
<profiles.active>develop</profiles.active>
<profiles.server.port>18221</profiles.server.port>
<profiles.server.port>18222</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://localhost:3306/device-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<![CDATA[jdbc:mysql://localhost:3306/device-new-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>12345678</profiles.datasource.password>
<profiles.redis.uri>127.0.0.1</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password></profiles.redis.password>
<profiles.redis.database>6</profiles.redis.database>
<profiles.redis.database>7</profiles.redis.database>
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
......@@ -59,17 +59,17 @@
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
<profiles.server.port>18221</profiles.server.port>
<profiles.server.port>18222</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.98:3306/device-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.98:3306/device-new-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>nacos@2020</profiles.datasource.password>
<profiles.redis.uri>192.168.0.252</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password>hotel@2020</profiles.redis.password>
<profiles.redis.database>2</profiles.redis.database>
<profiles.redis.database>7</profiles.redis.database>
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
......@@ -87,17 +87,17 @@
<id>product</id>
<properties>
<profiles.active>product</profiles.active>
<profiles.server.port>18221</profiles.server.port>
<profiles.server.port>18222</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.26:8183/device-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.26:8183/device-new-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>root123</profiles.datasource.password>
<profiles.redis.uri>192.168.0.26</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password></profiles.redis.password>
<profiles.redis.database>2</profiles.redis.database>
<profiles.redis.database>7</profiles.redis.database>
<profiles.kafka.brokers>192.168.0.26:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.26</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment