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

设备token验证添加

parent f84acfe5
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<parent> <parent>
<groupId>com.mortals.xhx</groupId> <groupId>com.mortals.xhx</groupId>
<artifactId>device-platform</artifactId> <artifactId>device-new-platform</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>
......
...@@ -77,54 +77,6 @@ INSERT INTO `mortals_xhx_menu` VALUES (9106, '任务信息', '/task/list', 91, 6 ...@@ -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 (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, '系统管理员'); 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 -- Table structure for mortals_xhx_oper_log
...@@ -277,14 +229,6 @@ CREATE TABLE `mortals_xhx_site` ( ...@@ -277,14 +229,6 @@ CREATE TABLE `mortals_xhx_site` (
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '站点信息表' ROW_FORMAT = Dynamic; ) 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 -- Table structure for mortals_xhx_table_index
-- ---------------------------- -- ----------------------------
......
-- ---------------------------- -- ----------------------------
-- 设备表 -- 设备表
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `mortals_stp_device`; DROP TABLE IF EXISTS `mortals_xhx_device`;
CREATE TABLE mortals_stp_device( CREATE TABLE mortals_xhx_device(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`deviceName` varchar(20) NOT NULL COMMENT '设备名称', `deviceName` varchar(20) NOT NULL COMMENT '设备名称',
`deviceCode` varchar(256) COMMENT '设备编码', `deviceCode` varchar(256) COMMENT '设备编码',
...@@ -16,6 +16,7 @@ CREATE TABLE mortals_stp_device( ...@@ -16,6 +16,7 @@ CREATE TABLE mortals_stp_device(
`deviceFirmname` varchar(20) COMMENT '设备生产厂商名称', `deviceFirmname` varchar(20) COMMENT '设备生产厂商名称',
`deviceOnlineStatus` tinyint(2) NOT NULL COMMENT '在线状态 (0.离线,1.在线)', `deviceOnlineStatus` tinyint(2) NOT NULL COMMENT '在线状态 (0.离线,1.在线)',
`status` 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 '备注', `deviceRemark` varchar(256) COMMENT '备注',
`onlineTime` datetime COMMENT '最近上线时间', `onlineTime` datetime COMMENT '最近上线时间',
`offlineTime` datetime COMMENT '最近离线时间', `offlineTime` datetime COMMENT '最近离线时间',
...@@ -25,11 +26,12 @@ CREATE TABLE mortals_stp_device( ...@@ -25,11 +26,12 @@ CREATE TABLE mortals_stp_device(
`updateTime` datetime COMMENT '更新时间', `updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备';
-- ---------------------------- -- ----------------------------
-- 设备生产厂商表 -- 设备生产厂商表
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `mortals_stp_firm`; DROP TABLE IF EXISTS `mortals_xhx_firm`;
CREATE TABLE mortals_stp_firm( CREATE TABLE mortals_xhx_firm(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`firmName` varchar(128) NOT NULL COMMENT '设备生产厂商名称', `firmName` varchar(128) NOT NULL COMMENT '设备生产厂商名称',
`firmCode` varchar(128) COMMENT '设备生产商编码', `firmCode` varchar(128) COMMENT '设备生产商编码',
...@@ -40,6 +42,8 @@ CREATE TABLE mortals_stp_firm( ...@@ -40,6 +42,8 @@ CREATE TABLE mortals_stp_firm(
`updateTime` datetime COMMENT '更新时间', `updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备生产厂商'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备生产厂商';
-- ---------------------------- -- ----------------------------
-- 设备日志表 -- 设备日志表
-- ---------------------------- -- ----------------------------
...@@ -56,6 +60,7 @@ PRIMARY KEY (`id`) ...@@ -56,6 +60,7 @@ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备日志'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备日志';
-- ---------------------------- -- ----------------------------
-- 设备菜单 SQL -- 设备菜单 SQL
-- ---------------------------- -- ----------------------------
...@@ -66,27 +71,6 @@ INSERT INTO `mortals_xhx_menu` VALUES (null, '设备', '/device/list', 0, 1, 1, ...@@ -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/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); 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 -- 设备参数 SQL
...@@ -107,16 +91,23 @@ INSERT INTO `mortals_xhx_param` VALUES (null, '在线状态 ', 'Device', 'device ...@@ -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', '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', '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', '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_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_param` VALUES (null, '日志类型,', 'DeviceLog', 'logType', '1', '下发服务', 1, 4, 0, 'logType', NULL, NULL, NULL); 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 @@ ...@@ -10,7 +10,7 @@
<parent> <parent>
<groupId>com.mortals.xhx</groupId> <groupId>com.mortals.xhx</groupId>
<artifactId>device-platform</artifactId> <artifactId>device-new-platform</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>
...@@ -55,6 +55,14 @@ ...@@ -55,6 +55,14 @@
<artifactId>spring-data-redis</artifactId> <artifactId>spring-data-redis</artifactId>
</dependency> </dependency>
<!--Token生成与解析-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <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; ...@@ -10,10 +10,14 @@ import java.io.Serializable;
@Data @Data
public class DeviceReq implements Serializable { public class DeviceReq implements Serializable {
/**
* 行为
*/
private String action; private String action;
/**
private String devicenum; * 设备编码(暂定mac地址)
*/
private String deviceNum;
private String ip; 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; ...@@ -2,21 +2,22 @@ package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; 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.message.SendToAllRequest;
import com.mortals.xhx.base.framework.ws.util.WebSocketUtil; import com.mortals.xhx.base.framework.ws.util.WebSocketUtil;
import com.mortals.xhx.busiz.req.DeviceReq; import com.mortals.xhx.busiz.req.DeviceReq;
import com.mortals.xhx.busiz.rsp.ApiResp; import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum; import com.mortals.xhx.busiz.rsp.DeviceResp;
import com.mortals.xhx.common.code.DeviceOnlineStatusEnum; 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.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.service.DeviceLogService; import com.mortals.xhx.module.device.service.DeviceLogService;
import com.mortals.xhx.module.device.service.DeviceService; import com.mortals.xhx.module.device.service.DeviceService;
import lombok.extern.apachecommons.CommonsLog; import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -38,26 +39,31 @@ public class DeviceApiController { ...@@ -38,26 +39,31 @@ public class DeviceApiController {
@Autowired @Autowired
private DeviceService deviceService; private DeviceService deviceService;
@Autowired
private DeviceTokenService deviceTokenService;
/** /**
* 设备数据上报 * 设备激活
* *
* @param req * @param req
* @return * @return
*/ */
@PostMapping("upload") @PostMapping("active")
public String upload(DeviceReq req) { public String active(@RequestBody DeviceReq req) {
log.info("【设备数据上报】【请求体】--> " + JSONObject.toJSONString(req)); log.info("【设备激活】【请求体】--> " + JSONObject.toJSONString(req));
ApiResp rsp = new ApiResp<>(); ApiResp<DeviceResp> rsp = new ApiResp<>();
rsp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue()); rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
DeviceResp deviceResp = new DeviceResp();
try { try {
//根据设备编码查询设备 //根据设备编码查询设备是否存在,如果存在判断是否已经激活
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDevicenum()); DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceNum());
boolean bool = false;
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
if (deviceEntity.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.离线.getValue()) { //判断设备是否已经激活,如果已激活返回token信息
bool = true; if (deviceEntity.getActive() == ActiveEnum.已激活.getValue() && deviceEntity.getStatus() == StatusEnum.启用.getValue()) {
String token = deviceTokenService.createToken(deviceEntity);
deviceResp.setToken(token);
} }
deviceEntity.setOnlineTime(new Date()); deviceEntity.setOnlineTime(new Date());
deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue()); deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue());
...@@ -66,25 +72,11 @@ public class DeviceApiController { ...@@ -66,25 +72,11 @@ public class DeviceApiController {
deviceEntity.setSiteNum(req.getSitenum()); deviceEntity.setSiteNum(req.getSitenum());
deviceEntity.setCenternum(req.getCenternum()); deviceEntity.setCenternum(req.getCenternum());
deviceService.update(deviceEntity); 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 { } else {
//新增设备 //新增设备
deviceEntity = new DeviceEntity(); deviceEntity = new DeviceEntity();
deviceEntity.initAttrValue(); deviceEntity.initAttrValue();
deviceEntity.setDeviceCode(req.getDevicenum()); deviceEntity.setDeviceCode(req.getDeviceNum());
deviceEntity.setOnlineTime(new Date()); deviceEntity.setOnlineTime(new Date());
deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue()); deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue());
deviceEntity.setIp(req.getIp()); deviceEntity.setIp(req.getIp());
...@@ -95,17 +87,41 @@ public class DeviceApiController { ...@@ -95,17 +87,41 @@ public class DeviceApiController {
deviceEntity.setCreateTime(new Date()); deviceEntity.setCreateTime(new Date());
deviceService.save(deviceEntity); deviceService.save(deviceEntity);
DeviceLogEntity deviceLogEntity = new DeviceLogEntity(); rsp.setMsg("当前设备未激活,激活后再上线。");
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);
WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(JSON.toJSONString(deviceEntity))); 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) { } catch (Exception e) {
log.error("接收数据失败", e); log.error("接收数据失败", e);
rsp.setCode(ApiRespCodeEnum.FAILED.getValue()); rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
...@@ -113,7 +129,7 @@ public class DeviceApiController { ...@@ -113,7 +129,7 @@ public class DeviceApiController {
return JSON.toJSONString(rsp); return JSON.toJSONString(rsp);
} }
log.info("响应【设备数据上报】【响应体】--> " + JSONObject.toJSONString(rsp)); log.debug("响应【设备数据上报】【响应体】--> " + JSONObject.toJSONString(rsp));
return JSON.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 { ...@@ -9,6 +9,9 @@ public enum ApiRespCodeEnum {
SUCCESS(1, "接收成功"), SUCCESS(1, "接收成功"),
/** 执行失败 */ /** 执行失败 */
FAILED(2,"执行失败"), FAILED(2,"执行失败"),
/** token认证失败 */
TOKEN_FAILED(3,"token认证失败"),
; ;
private final Integer value; private final Integer value;
......
...@@ -17,9 +17,46 @@ public final class Constant { ...@@ -17,9 +17,46 @@ public final class Constant {
*/ */
public static final String HTTP = "http://"; 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 */ /** 基础代码版本 Z-BASE.MANAGER-S1.0.0 */
public final static String BASEMANAGER_VERSION = "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"; public final static String PARAM_SERVER_HTTP_URL = "server_http_url";
} }
...@@ -8,11 +8,11 @@ import com.mortals.framework.annotation.Excel; ...@@ -8,11 +8,11 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.vo.DeviceVo; import com.mortals.xhx.module.device.model.vo.DeviceVo;
/** /**
* 设备实体对象 * 设备实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-03-09 * @date 2022-04-11
*/ */
public class DeviceEntity extends DeviceVo { public class DeviceEntity extends DeviceVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -67,6 +67,10 @@ public class DeviceEntity extends DeviceVo { ...@@ -67,6 +67,10 @@ public class DeviceEntity extends DeviceVo {
* 启用状态 (0.停止,1.启用) * 启用状态 (0.停止,1.启用)
*/ */
private Integer status; private Integer status;
/**
* 激活状态 (0.未激活,1.已激活)
*/
private Integer active;
/** /**
* 备注 * 备注
*/ */
...@@ -251,6 +255,20 @@ public class DeviceEntity extends DeviceVo { ...@@ -251,6 +255,20 @@ public class DeviceEntity extends DeviceVo {
public void setStatus(Integer status){ public void setStatus(Integer status){
this.status = status; this.status = status;
} }
/**
* 获取 激活状态 (0.未激活,1.已激活)
* @return Integer
*/
public Integer getActive(){
return active;
}
/**
* 设置 激活状态 (0.未激活,1.已激活)
* @param active
*/
public void setActive(Integer active){
this.active = active;
}
/** /**
* 获取 备注 * 获取 备注
* @return String * @return String
...@@ -327,6 +345,7 @@ public class DeviceEntity extends DeviceVo { ...@@ -327,6 +345,7 @@ public class DeviceEntity extends DeviceVo {
sb.append(",deviceFirmname:").append(getDeviceFirmname()); sb.append(",deviceFirmname:").append(getDeviceFirmname());
sb.append(",deviceOnlineStatus:").append(getDeviceOnlineStatus()); sb.append(",deviceOnlineStatus:").append(getDeviceOnlineStatus());
sb.append(",status:").append(getStatus()); sb.append(",status:").append(getStatus());
sb.append(",active:").append(getActive());
sb.append(",deviceRemark:").append(getDeviceRemark()); sb.append(",deviceRemark:").append(getDeviceRemark());
sb.append(",onlineTime:").append(getOnlineTime()); sb.append(",onlineTime:").append(getOnlineTime());
sb.append(",offlineTime:").append(getOfflineTime()); sb.append(",offlineTime:").append(getOfflineTime());
...@@ -359,6 +378,8 @@ public class DeviceEntity extends DeviceVo { ...@@ -359,6 +378,8 @@ public class DeviceEntity extends DeviceVo {
this.status = 0; this.status = 0;
this.active = 0;
this.deviceRemark = ""; this.deviceRemark = "";
this.onlineTime = null; this.onlineTime = null;
......
...@@ -4,11 +4,11 @@ import java.util.Date; ...@@ -4,11 +4,11 @@ import java.util.Date;
import java.util.List; import java.util.List;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
/** /**
* 设备查询对象 * 设备查询对象
* *
* @author zxfei * @author zxfei
* @date 2022-03-09 * @date 2022-04-11
*/ */
public class DeviceQuery extends DeviceEntity { public class DeviceQuery extends DeviceEntity {
/** 开始 主键ID,主键,自增长 */ /** 开始 主键ID,主键,自增长 */
private Long idStart; private Long idStart;
...@@ -94,6 +94,18 @@ public class DeviceQuery extends DeviceEntity { ...@@ -94,6 +94,18 @@ public class DeviceQuery extends DeviceEntity {
/** 启用状态 (0.停止,1.启用)列表 */ /** 启用状态 (0.停止,1.启用)列表 */
private List <Integer> statusList; private List <Integer> statusList;
/** 开始 激活状态 (0.未激活,1.已激活) */
private Integer activeStart;
/** 结束 激活状态 (0.未激活,1.已激活) */
private Integer activeEnd;
/** 增加 激活状态 (0.未激活,1.已激活) */
private Integer activeIncrement;
/** 激活状态 (0.未激活,1.已激活)列表 */
private List <Integer> activeList;
/** 备注 */ /** 备注 */
private List<String> deviceRemarkList; private List<String> deviceRemarkList;
...@@ -593,6 +605,70 @@ public class DeviceQuery extends DeviceEntity { ...@@ -593,6 +605,70 @@ public class DeviceQuery extends DeviceEntity {
this.statusList = statusList; this.statusList = statusList;
} }
/**
* 获取 开始 激活状态 (0.未激活,1.已激活)
* @return activeStart
*/
public Integer getActiveStart(){
return this.activeStart;
}
/**
* 设置 开始 激活状态 (0.未激活,1.已激活)
* @param activeStart
*/
public void setActiveStart(Integer activeStart){
this.activeStart = activeStart;
}
/**
* 获取 结束 激活状态 (0.未激活,1.已激活)
* @return $activeEnd
*/
public Integer getActiveEnd(){
return this.activeEnd;
}
/**
* 设置 结束 激活状态 (0.未激活,1.已激活)
* @param activeEnd
*/
public void setActiveEnd(Integer activeEnd){
this.activeEnd = activeEnd;
}
/**
* 获取 增加 激活状态 (0.未激活,1.已激活)
* @return activeIncrement
*/
public Integer getActiveIncrement(){
return this.activeIncrement;
}
/**
* 设置 增加 激活状态 (0.未激活,1.已激活)
* @param activeIncrement
*/
public void setActiveIncrement(Integer activeIncrement){
this.activeIncrement = activeIncrement;
}
/**
* 获取 激活状态 (0.未激活,1.已激活)
* @return activeList
*/
public List<Integer> getActiveList(){
return this.activeList;
}
/**
* 设置 激活状态 (0.未激活,1.已激活)
* @param activeList
*/
public void setActiveList(List<Integer> activeList){
this.activeList = activeList;
}
/** /**
* 获取 备注 * 获取 备注
* @return deviceRemarkList * @return deviceRemarkList
...@@ -1241,6 +1317,51 @@ public class DeviceQuery extends DeviceEntity { ...@@ -1241,6 +1317,51 @@ public class DeviceQuery extends DeviceEntity {
return this; return this;
} }
/**
* 设置 激活状态 (0.未激活,1.已激活)
* @param active
*/
public DeviceQuery active(Integer active){
setActive(active);
return this;
}
/**
* 设置 开始 激活状态 (0.未激活,1.已激活)
* @param activeStart
*/
public DeviceQuery activeStart(Integer activeStart){
this.activeStart = activeStart;
return this;
}
/**
* 设置 结束 激活状态 (0.未激活,1.已激活)
* @param activeEnd
*/
public DeviceQuery activeEnd(Integer activeEnd){
this.activeEnd = activeEnd;
return this;
}
/**
* 设置 增加 激活状态 (0.未激活,1.已激活)
* @param activeIncrement
*/
public DeviceQuery activeIncrement(Integer activeIncrement){
this.activeIncrement = activeIncrement;
return this;
}
/**
* 设置 激活状态 (0.未激活,1.已激活)
* @param activeList
*/
public DeviceQuery activeList(List<Integer> activeList){
this.activeList = activeList;
return this;
}
/** /**
* 设置 备注 * 设置 备注
......
package com.mortals.xhx.module.device.model.vo; package com.mortals.xhx.module.device.model.vo;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
import lombok.Data; import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* 设备视图对象 * 设备视图对象
* *
* @author zxfei * @author zxfei
* @date 2022-03-09 * @date 2022-03-09
*/ */
@Data @Data
public class DeviceVo extends BaseEntityLong { 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; package com.mortals.xhx.module.device.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService; import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
import java.util.List;
/** /**
* DeviceService * DeviceService
* *
...@@ -11,4 +16,11 @@ import com.mortals.xhx.module.device.model.DeviceEntity; ...@@ -11,4 +16,11 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
*/ */
public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ 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; 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 org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.xhx.module.device.dao.DeviceDao; import com.mortals.xhx.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService; 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 * DeviceService
* 设备 service实现 * 设备 service实现
* *
* @author zxfei * @author zxfei
* @date 2022-03-09 * @date 2022-03-09
*/ */
@Service("deviceService") @Service("deviceService")
public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, DeviceEntity, Long> implements DeviceService { public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, DeviceEntity, Long> implements DeviceService {
@Autowired
private TbCoreQueueProducerProvider producerProvider;
@Override @Override
protected String getExtKey(DeviceEntity data) { protected String getExtKey(DeviceEntity data) {
return data.getDeviceCode(); 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; ...@@ -3,6 +3,7 @@ package com.mortals.xhx.module.device.web;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol; import com.mortals.framework.model.OrderCol;
import com.mortals.xhx.base.system.param.service.ParamService; 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.DeviceOnlineStatusEnum;
import com.mortals.xhx.common.code.DeviceTypeEnum; import com.mortals.xhx.common.code.DeviceTypeEnum;
import com.mortals.xhx.module.firm.model.FirmQuery; import com.mortals.xhx.module.firm.model.FirmQuery;
...@@ -70,14 +71,15 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic ...@@ -70,14 +71,15 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
this.addDict(model, "deviceType", deviceTypeMap); this.addDict(model, "deviceType", deviceTypeMap);
this.addDict(model, "deviceOnlineStatus", paramService.getParamBySecondOrganize("Device", "deviceOnlineStatus")); this.addDict(model, "deviceOnlineStatus", paramService.getParamBySecondOrganize("Device", "deviceOnlineStatus"));
this.addDict(model, "status", paramService.getParamBySecondOrganize("Device", "status")); 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()))); 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("onlineCount", collect.get(true));
model.put("offlineCount", collect.get(false)); model.put("offlineCount", collect.get(false));
//离线设备 按类型分组 //离线设备 按类型分组
if (collect.get(false) > 0) { 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); model.put("offlineDeviceType", collectTwo);
} }
super.init(request, response, form, model, context); super.init(request, response, form, model, context);
......
...@@ -7,11 +7,11 @@ import com.mortals.framework.annotation.Excel; ...@@ -7,11 +7,11 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.firm.model.vo.FirmVo; import com.mortals.xhx.module.firm.model.vo.FirmVo;
/** /**
* 设备生产厂商实体对象 * 设备生产厂商实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-03-09 * @date 2022-04-11
*/ */
public class FirmEntity extends FirmVo { public class FirmEntity extends FirmVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -3,11 +3,11 @@ package com.mortals.xhx.module.firm.model; ...@@ -3,11 +3,11 @@ package com.mortals.xhx.module.firm.model;
import java.util.List; import java.util.List;
import com.mortals.xhx.module.firm.model.FirmEntity; import com.mortals.xhx.module.firm.model.FirmEntity;
/** /**
* 设备生产厂商查询对象 * 设备生产厂商查询对象
* *
* @author zxfei * @author zxfei
* @date 2022-03-09 * @date 2022-04-11
*/ */
public class FirmQuery extends FirmEntity { public class FirmQuery extends FirmEntity {
/** 开始 主键ID,主键,自增长 */ /** 开始 主键ID,主键,自增长 */
private Long idStart; private Long idStart;
......
...@@ -95,3 +95,12 @@ queue: ...@@ -95,3 +95,12 @@ queue:
handshake_timeout: 10000 handshake_timeout: 10000
queue-properties: queue-properties:
core: x-max-length-bytes:1048576000;x-message-ttl:604800000 core: x-max-length-bytes:1048576000;x-message-ttl:604800000
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcd1234
# 令牌有效期(默认60分钟)
expireTime: 60
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd"> "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.device.dao.ibatis.DeviceLogDaoImpl"> <mapper namespace="com.mortals.xhx.module.device.dao.ibatis.DeviceLogDaoImpl">
<!-- 字段和属性映射 --> <!-- 字段和属性映射 -->
<resultMap type="DeviceLogEntity" id="DeviceLogEntity-Map"> <resultMap type="DeviceLogEntity" id="DeviceLogEntity-Map">
<id property="id" column="id" /> <id property="id" column="id" />
<id property="deviceId" column="deviceId" /> <result property="deviceId" column="deviceId" />
<result property="deviceNum" column="deviceNum" /> <result property="deviceNum" column="deviceNum" />
<result property="deviceName" column="deviceName" /> <result property="deviceName" column="deviceName" />
<result property="logType" column="logType" /> <result property="logType" column="logType" />
...@@ -20,25 +20,25 @@ ...@@ -20,25 +20,25 @@
<sql id="_columns"> <sql id="_columns">
<trim suffixOverrides="," suffix=""> <trim suffixOverrides="," suffix="">
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))">
a.id as id, a.id,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceId') or colPickMode == 1 and data.containsKey('deviceId')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceId') or colPickMode == 1 and data.containsKey('deviceId')))">
a.deviceId as deviceId, a.deviceId,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceNum') or colPickMode == 1 and data.containsKey('deviceNum')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceNum') or colPickMode == 1 and data.containsKey('deviceNum')))">
a.deviceNum as deviceNum, a.deviceNum,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceName') or colPickMode == 1 and data.containsKey('deviceName')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceName') or colPickMode == 1 and data.containsKey('deviceName')))">
a.deviceName as deviceName, a.deviceName,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('logType') or colPickMode == 1 and data.containsKey('logType')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('logType') or colPickMode == 1 and data.containsKey('logType')))">
a.logType as logType, a.logType,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('content') or colPickMode == 1 and data.containsKey('content')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('content') or colPickMode == 1 and data.containsKey('content')))">
a.content as content, a.content,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))">
a.createTime as createTime, a.createTime,
</if> </if>
</trim> </trim>
</sql> </sql>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd"> "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.device.dao.ibatis.DeviceDaoImpl"> <mapper namespace="com.mortals.xhx.module.device.dao.ibatis.DeviceDaoImpl">
<!-- 字段和属性映射 --> <!-- 字段和属性映射 -->
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<result property="deviceFirmname" column="deviceFirmname" /> <result property="deviceFirmname" column="deviceFirmname" />
<result property="deviceOnlineStatus" column="deviceOnlineStatus" /> <result property="deviceOnlineStatus" column="deviceOnlineStatus" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="active" column="active" />
<result property="deviceRemark" column="deviceRemark" /> <result property="deviceRemark" column="deviceRemark" />
<result property="onlineTime" column="onlineTime" /> <result property="onlineTime" column="onlineTime" />
<result property="offlineTime" column="offlineTime" /> <result property="offlineTime" column="offlineTime" />
...@@ -33,89 +34,92 @@ ...@@ -33,89 +34,92 @@
<sql id="_columns"> <sql id="_columns">
<trim suffixOverrides="," suffix=""> <trim suffixOverrides="," suffix="">
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))">
a.id as id, a.id,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceName') or colPickMode == 1 and data.containsKey('deviceName')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceName') or colPickMode == 1 and data.containsKey('deviceName')))">
a.deviceName as deviceName, a.deviceName,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceCode') or colPickMode == 1 and data.containsKey('deviceCode')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceCode') or colPickMode == 1 and data.containsKey('deviceCode')))">
a.deviceCode as deviceCode, a.deviceCode,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceType') or colPickMode == 1 and data.containsKey('deviceType')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceType') or colPickMode == 1 and data.containsKey('deviceType')))">
a.deviceType as deviceType, a.deviceType,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceMac') or colPickMode == 1 and data.containsKey('deviceMac')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceMac') or colPickMode == 1 and data.containsKey('deviceMac')))">
a.deviceMac as deviceMac, a.deviceMac,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('ip') or colPickMode == 1 and data.containsKey('ip')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('ip') or colPickMode == 1 and data.containsKey('ip')))">
a.ip as ip, a.ip,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('centernum') or colPickMode == 1 and data.containsKey('centernum')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('centernum') or colPickMode == 1 and data.containsKey('centernum')))">
a.centernum as centernum, a.centernum,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('port') or colPickMode == 1 and data.containsKey('port')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('port') or colPickMode == 1 and data.containsKey('port')))">
a.port as port, a.port,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('siteNum') or colPickMode == 1 and data.containsKey('siteNum')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('siteNum') or colPickMode == 1 and data.containsKey('siteNum')))">
a.siteNum as siteNum, a.siteNum,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceFirmId') or colPickMode == 1 and data.containsKey('deviceFirmId')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceFirmId') or colPickMode == 1 and data.containsKey('deviceFirmId')))">
a.deviceFirmId as deviceFirmId, a.deviceFirmId,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceFirmname') or colPickMode == 1 and data.containsKey('deviceFirmname')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceFirmname') or colPickMode == 1 and data.containsKey('deviceFirmname')))">
a.deviceFirmname as deviceFirmname, a.deviceFirmname,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceOnlineStatus') or colPickMode == 1 and data.containsKey('deviceOnlineStatus')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceOnlineStatus') or colPickMode == 1 and data.containsKey('deviceOnlineStatus')))">
a.deviceOnlineStatus as deviceOnlineStatus, a.deviceOnlineStatus,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('status') or colPickMode == 1 and data.containsKey('status')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('status') or colPickMode == 1 and data.containsKey('status')))">
a.status as status, a.status,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('active') or colPickMode == 1 and data.containsKey('active')))">
a.active,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceRemark') or colPickMode == 1 and data.containsKey('deviceRemark')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceRemark') or colPickMode == 1 and data.containsKey('deviceRemark')))">
a.deviceRemark as deviceRemark, a.deviceRemark,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('onlineTime') or colPickMode == 1 and data.containsKey('onlineTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('onlineTime') or colPickMode == 1 and data.containsKey('onlineTime')))">
a.onlineTime as onlineTime, a.onlineTime,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('offlineTime') or colPickMode == 1 and data.containsKey('offlineTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('offlineTime') or colPickMode == 1 and data.containsKey('offlineTime')))">
a.offlineTime as offlineTime, a.offlineTime,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createUserId') or colPickMode == 1 and data.containsKey('createUserId')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createUserId') or colPickMode == 1 and data.containsKey('createUserId')))">
a.createUserId as createUserId, a.createUserId,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))">
a.createTime as createTime, a.createTime,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateUserId') or colPickMode == 1 and data.containsKey('updateUserId')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateUserId') or colPickMode == 1 and data.containsKey('updateUserId')))">
a.updateUserId as updateUserId, a.updateUserId,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
a.updateTime as updateTime, a.updateTime,
</if> </if>
</trim> </trim>
</sql> </sql>
<!-- 新增 区分主键自增加还是业务插入 --> <!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="DeviceEntity" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="DeviceEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_stp_device insert into mortals_xhx_device
(deviceName,deviceCode,deviceType,deviceMac,ip,centernum,port,siteNum,deviceFirmId,deviceFirmname,deviceOnlineStatus,status,deviceRemark,onlineTime,offlineTime,createUserId,createTime,updateUserId,updateTime) (deviceName,deviceCode,deviceType,deviceMac,ip,centernum,port,siteNum,deviceFirmId,deviceFirmname,deviceOnlineStatus,status,active,deviceRemark,onlineTime,offlineTime,createUserId,createTime,updateUserId,updateTime)
VALUES VALUES
(#{deviceName},#{deviceCode},#{deviceType},#{deviceMac},#{ip},#{centernum},#{port},#{siteNum},#{deviceFirmId},#{deviceFirmname},#{deviceOnlineStatus},#{status},#{deviceRemark},#{onlineTime},#{offlineTime},#{createUserId},#{createTime},#{updateUserId},#{updateTime}) (#{deviceName},#{deviceCode},#{deviceType},#{deviceMac},#{ip},#{centernum},#{port},#{siteNum},#{deviceFirmId},#{deviceFirmname},#{deviceOnlineStatus},#{status},#{active},#{deviceRemark},#{onlineTime},#{offlineTime},#{createUserId},#{createTime},#{updateUserId},#{updateTime})
</insert> </insert>
<!-- 批量新增 --> <!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto"> <insert id="insertBatch" parameterType="paramDto">
insert into mortals_stp_device insert into mortals_xhx_device
(deviceName,deviceCode,deviceType,deviceMac,ip,centernum,port,siteNum,deviceFirmId,deviceFirmname,deviceOnlineStatus,status,deviceRemark,onlineTime,offlineTime,createUserId,createTime,updateUserId,updateTime) (deviceName,deviceCode,deviceType,deviceMac,ip,centernum,port,siteNum,deviceFirmId,deviceFirmname,deviceOnlineStatus,status,active,deviceRemark,onlineTime,offlineTime,createUserId,createTime,updateUserId,updateTime)
VALUES VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," > <foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.deviceName},#{item.deviceCode},#{item.deviceType},#{item.deviceMac},#{item.ip},#{item.centernum},#{item.port},#{item.siteNum},#{item.deviceFirmId},#{item.deviceFirmname},#{item.deviceOnlineStatus},#{item.status},#{item.deviceRemark},#{item.onlineTime},#{item.offlineTime},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime}) (#{item.deviceName},#{item.deviceCode},#{item.deviceType},#{item.deviceMac},#{item.ip},#{item.centernum},#{item.port},#{item.siteNum},#{item.deviceFirmId},#{item.deviceFirmname},#{item.deviceOnlineStatus},#{item.status},#{item.active},#{item.deviceRemark},#{item.onlineTime},#{item.offlineTime},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime})
</foreach> </foreach>
</insert> </insert>
<!-- 根据ParamDto更新 --> <!-- 根据ParamDto更新 -->
<update id="update" parameterType="paramDto"> <update id="update" parameterType="paramDto">
update mortals_stp_device as a update mortals_xhx_device as a
set set
<trim suffixOverrides="," suffix=""> <trim suffixOverrides="," suffix="">
<if test="(colPickMode==0 and data.containsKey('deviceName')) or (colPickMode==1 and !data.containsKey('deviceName'))"> <if test="(colPickMode==0 and data.containsKey('deviceName')) or (colPickMode==1 and !data.containsKey('deviceName'))">
...@@ -166,6 +170,12 @@ ...@@ -166,6 +170,12 @@
<if test="(colPickMode==0 and data.containsKey('statusIncrement')) or (colPickMode==1 and !data.containsKey('statusIncrement'))"> <if test="(colPickMode==0 and data.containsKey('statusIncrement')) or (colPickMode==1 and !data.containsKey('statusIncrement'))">
a.status=ifnull(a.status,0) + #{data.statusIncrement}, a.status=ifnull(a.status,0) + #{data.statusIncrement},
</if> </if>
<if test="(colPickMode==0 and data.containsKey('active')) or (colPickMode==1 and !data.containsKey('active'))">
a.active=#{data.active},
</if>
<if test="(colPickMode==0 and data.containsKey('activeIncrement')) or (colPickMode==1 and !data.containsKey('activeIncrement'))">
a.active=ifnull(a.active,0) + #{data.activeIncrement},
</if>
<if test="(colPickMode==0 and data.containsKey('deviceRemark')) or (colPickMode==1 and !data.containsKey('deviceRemark'))"> <if test="(colPickMode==0 and data.containsKey('deviceRemark')) or (colPickMode==1 and !data.containsKey('deviceRemark'))">
a.deviceRemark=#{data.deviceRemark}, a.deviceRemark=#{data.deviceRemark},
</if> </if>
...@@ -203,7 +213,7 @@ ...@@ -203,7 +213,7 @@
</update> </update>
<!-- 批量更新 --> <!-- 批量更新 -->
<update id="updateBatch" parameterType="paramDto"> <update id="updateBatch" parameterType="paramDto">
update mortals_stp_device as a update mortals_xhx_device as a
<trim prefix="set" suffixOverrides=","> <trim prefix="set" suffixOverrides=",">
<trim prefix="deviceName=(case" suffix="ELSE deviceName end),"> <trim prefix="deviceName=(case" suffix="ELSE deviceName end),">
<foreach collection="data.dataList" item="item" index="index" separator="" > <foreach collection="data.dataList" item="item" index="index" separator="" >
...@@ -309,6 +319,18 @@ ...@@ -309,6 +319,18 @@
</choose> </choose>
</foreach> </foreach>
</trim> </trim>
<trim prefix="active=(case" suffix="ELSE active end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
<when test="(colPickMode==0 and item.containsKey('active')) or (colPickMode==1 and !item.containsKey('active'))">
when a.id=#{item.id} then #{item.active}
</when>
<when test="(colPickMode==0 and item.containsKey('activeIncrement')) or (colPickMode==1 and !item.containsKey('activeIncrement'))">
when a.id=#{item.id} then ifnull(a.active,0) + #{item.activeIncrement}
</when>
</choose>
</foreach>
</trim>
<trim prefix="deviceRemark=(case" suffix="ELSE deviceRemark end),"> <trim prefix="deviceRemark=(case" suffix="ELSE deviceRemark end),">
<foreach collection="data.dataList" item="item" index="index" separator="" > <foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('deviceRemark')) or (colPickMode==1 and !item.containsKey('deviceRemark'))"> <if test="(colPickMode==0 and item.containsKey('deviceRemark')) or (colPickMode==1 and !item.containsKey('deviceRemark'))">
...@@ -377,23 +399,23 @@ ...@@ -377,23 +399,23 @@
<!-- 根据主健查询 --> <!-- 根据主健查询 -->
<select id="getByKey" parameterType="paramDto" resultMap="DeviceEntity-Map"> <select id="getByKey" parameterType="paramDto" resultMap="DeviceEntity-Map">
select <include refid="_columns"/> select <include refid="_columns"/>
from mortals_stp_device as a from mortals_xhx_device as a
where a.id=#{condition.id} where a.id=#{condition.id}
</select> </select>
<!-- 根据主健删除 --> <!-- 根据主健删除 -->
<delete id="deleteByKey" parameterType="paramDto"> <delete id="deleteByKey" parameterType="paramDto">
delete a.* from mortals_stp_device as a where a.id=#{condition.id} delete a.* from mortals_xhx_device as a where a.id=#{condition.id}
</delete> </delete>
<!-- 根据主健删除一批,针对单一主健有效 --> <!-- 根据主健删除一批,针对单一主健有效 -->
<delete id="deleteByKeys"> <delete id="deleteByKeys">
delete from mortals_stp_device where id in delete from mortals_xhx_device where id in
<foreach collection="array" item="item" index="index" open="(" separator="," close=")"> <foreach collection="array" item="item" index="index" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</delete> </delete>
<!-- 根据paramDto删除一批 --> <!-- 根据paramDto删除一批 -->
<delete id="deleteByMap" parameterType="paramDto"> <delete id="deleteByMap" parameterType="paramDto">
delete a.* from mortals_stp_device as a delete a.* from mortals_xhx_device as a
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
<trim prefixOverrides="and" prefix=""> <trim prefixOverrides="and" prefix="">
...@@ -404,7 +426,7 @@ ...@@ -404,7 +426,7 @@
<!-- 获取列表 --> <!-- 获取列表 -->
<select id="getList" parameterType="paramDto" resultMap="DeviceEntity-Map"> <select id="getList" parameterType="paramDto" resultMap="DeviceEntity-Map">
select <include refid="_columns"/> select <include refid="_columns"/>
from mortals_stp_device as a from mortals_xhx_device as a
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
<trim prefixOverrides="and" prefix=""> <trim prefixOverrides="and" prefix="">
...@@ -419,7 +441,7 @@ ...@@ -419,7 +441,7 @@
<!-- 获取 --> <!-- 获取 -->
<select id="getListCount" parameterType="paramDto" resultType="int"> <select id="getListCount" parameterType="paramDto" resultType="int">
select count(1) select count(1)
from mortals_stp_device as a from mortals_xhx_device as a
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
<trim prefixOverrides="and" prefix=""> <trim prefixOverrides="and" prefix="">
...@@ -694,6 +716,27 @@ ...@@ -694,6 +716,27 @@
${_conditionType_} a.status <![CDATA[ <= ]]> #{${_conditionParam_}.statusEnd} ${_conditionType_} a.status <![CDATA[ <= ]]> #{${_conditionParam_}.statusEnd}
</if> </if>
<if test="conditionParamRef.containsKey('active')">
<if test="conditionParamRef.active != null ">
${_conditionType_} a.active = #{${_conditionParam_}.active}
</if>
<if test="conditionParamRef.active == null">
${_conditionType_} a.active is null
</if>
</if>
<if test="conditionParamRef.containsKey('activeList')">
${_conditionType_} a.active in
<foreach collection="conditionParamRef.activeList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('activeStart') and conditionParamRef.activeStart != null">
${_conditionType_} a.active <![CDATA[ >= ]]> #{${_conditionParam_}.activeStart}
</if>
<if test="conditionParamRef.containsKey('activeEnd') and conditionParamRef.activeEnd != null">
${_conditionType_} a.active <![CDATA[ <= ]]> #{${_conditionParam_}.activeEnd}
</if>
<if test="conditionParamRef.containsKey('deviceRemark')"> <if test="conditionParamRef.containsKey('deviceRemark')">
<if test="conditionParamRef.deviceRemark != null and conditionParamRef.deviceRemark != ''"> <if test="conditionParamRef.deviceRemark != null and conditionParamRef.deviceRemark != ''">
...@@ -889,6 +932,11 @@ ...@@ -889,6 +932,11 @@
<if test='orderCol.status != null and "DESC".equalsIgnoreCase(orderCol.status)'>DESC</if> <if test='orderCol.status != null and "DESC".equalsIgnoreCase(orderCol.status)'>DESC</if>
, ,
</if> </if>
<if test="orderCol.containsKey('active')">
a.active
<if test='orderCol.active != null and "DESC".equalsIgnoreCase(orderCol.active)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('deviceRemark')"> <if test="orderCol.containsKey('deviceRemark')">
a.deviceRemark a.deviceRemark
<if test='orderCol.deviceRemark != null and "DESC".equalsIgnoreCase(orderCol.deviceRemark)'>DESC</if> <if test='orderCol.deviceRemark != null and "DESC".equalsIgnoreCase(orderCol.deviceRemark)'>DESC</if>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd"> "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.firm.dao.ibatis.FirmDaoImpl"> <mapper namespace="com.mortals.xhx.module.firm.dao.ibatis.FirmDaoImpl">
<!-- 字段和属性映射 --> <!-- 字段和属性映射 -->
...@@ -21,34 +21,34 @@ ...@@ -21,34 +21,34 @@
<sql id="_columns"> <sql id="_columns">
<trim suffixOverrides="," suffix=""> <trim suffixOverrides="," suffix="">
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))">
a.id as id, a.id,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('firmName') or colPickMode == 1 and data.containsKey('firmName')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('firmName') or colPickMode == 1 and data.containsKey('firmName')))">
a.firmName as firmName, a.firmName,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('firmCode') or colPickMode == 1 and data.containsKey('firmCode')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('firmCode') or colPickMode == 1 and data.containsKey('firmCode')))">
a.firmCode as firmCode, a.firmCode,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('firmRemark') or colPickMode == 1 and data.containsKey('firmRemark')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('firmRemark') or colPickMode == 1 and data.containsKey('firmRemark')))">
a.firmRemark as firmRemark, a.firmRemark,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createUserId') or colPickMode == 1 and data.containsKey('createUserId')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createUserId') or colPickMode == 1 and data.containsKey('createUserId')))">
a.createUserId as createUserId, a.createUserId,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))">
a.createTime as createTime, a.createTime,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateUserId') or colPickMode == 1 and data.containsKey('updateUserId')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateUserId') or colPickMode == 1 and data.containsKey('updateUserId')))">
a.updateUserId as updateUserId, a.updateUserId,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
a.updateTime as updateTime, a.updateTime,
</if> </if>
</trim> </trim>
</sql> </sql>
<!-- 新增 区分主键自增加还是业务插入 --> <!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="FirmEntity" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="FirmEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_stp_firm insert into mortals_xhx_firm
(firmName,firmCode,firmRemark,createUserId,createTime,updateUserId,updateTime) (firmName,firmCode,firmRemark,createUserId,createTime,updateUserId,updateTime)
VALUES VALUES
(#{firmName},#{firmCode},#{firmRemark},#{createUserId},#{createTime},#{updateUserId},#{updateTime}) (#{firmName},#{firmCode},#{firmRemark},#{createUserId},#{createTime},#{updateUserId},#{updateTime})
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<!-- 批量新增 --> <!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto"> <insert id="insertBatch" parameterType="paramDto">
insert into mortals_stp_firm insert into mortals_xhx_firm
(firmName,firmCode,firmRemark,createUserId,createTime,updateUserId,updateTime) (firmName,firmCode,firmRemark,createUserId,createTime,updateUserId,updateTime)
VALUES VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," > <foreach collection="data.dataList" item="item" index="index" separator="," >
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<!-- 根据ParamDto更新 --> <!-- 根据ParamDto更新 -->
<update id="update" parameterType="paramDto"> <update id="update" parameterType="paramDto">
update mortals_stp_firm as a update mortals_xhx_firm as a
set set
<trim suffixOverrides="," suffix=""> <trim suffixOverrides="," suffix="">
<if test="(colPickMode==0 and data.containsKey('firmName')) or (colPickMode==1 and !data.containsKey('firmName'))"> <if test="(colPickMode==0 and data.containsKey('firmName')) or (colPickMode==1 and !data.containsKey('firmName'))">
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
</update> </update>
<!-- 批量更新 --> <!-- 批量更新 -->
<update id="updateBatch" parameterType="paramDto"> <update id="updateBatch" parameterType="paramDto">
update mortals_stp_firm as a update mortals_xhx_firm as a
<trim prefix="set" suffixOverrides=","> <trim prefix="set" suffixOverrides=",">
<trim prefix="firmName=(case" suffix="ELSE firmName end),"> <trim prefix="firmName=(case" suffix="ELSE firmName end),">
<foreach collection="data.dataList" item="item" index="index" separator="" > <foreach collection="data.dataList" item="item" index="index" separator="" >
...@@ -177,23 +177,23 @@ ...@@ -177,23 +177,23 @@
<!-- 根据主健查询 --> <!-- 根据主健查询 -->
<select id="getByKey" parameterType="paramDto" resultMap="FirmEntity-Map"> <select id="getByKey" parameterType="paramDto" resultMap="FirmEntity-Map">
select <include refid="_columns"/> select <include refid="_columns"/>
from mortals_stp_firm as a from mortals_xhx_firm as a
where a.id=#{condition.id} where a.id=#{condition.id}
</select> </select>
<!-- 根据主健删除 --> <!-- 根据主健删除 -->
<delete id="deleteByKey" parameterType="paramDto"> <delete id="deleteByKey" parameterType="paramDto">
delete a.* from mortals_stp_firm as a where a.id=#{condition.id} delete a.* from mortals_xhx_firm as a where a.id=#{condition.id}
</delete> </delete>
<!-- 根据主健删除一批,针对单一主健有效 --> <!-- 根据主健删除一批,针对单一主健有效 -->
<delete id="deleteByKeys"> <delete id="deleteByKeys">
delete from mortals_stp_firm where id in delete from mortals_xhx_firm where id in
<foreach collection="array" item="item" index="index" open="(" separator="," close=")"> <foreach collection="array" item="item" index="index" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</delete> </delete>
<!-- 根据paramDto删除一批 --> <!-- 根据paramDto删除一批 -->
<delete id="deleteByMap" parameterType="paramDto"> <delete id="deleteByMap" parameterType="paramDto">
delete a.* from mortals_stp_firm as a delete a.* from mortals_xhx_firm as a
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
<trim prefixOverrides="and" prefix=""> <trim prefixOverrides="and" prefix="">
...@@ -204,7 +204,7 @@ ...@@ -204,7 +204,7 @@
<!-- 获取列表 --> <!-- 获取列表 -->
<select id="getList" parameterType="paramDto" resultMap="FirmEntity-Map"> <select id="getList" parameterType="paramDto" resultMap="FirmEntity-Map">
select <include refid="_columns"/> select <include refid="_columns"/>
from mortals_stp_firm as a from mortals_xhx_firm as a
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
<trim prefixOverrides="and" prefix=""> <trim prefixOverrides="and" prefix="">
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
<!-- 获取 --> <!-- 获取 -->
<select id="getListCount" parameterType="paramDto" resultType="int"> <select id="getListCount" parameterType="paramDto" resultType="int">
select count(1) select count(1)
from mortals_stp_firm as a from mortals_xhx_firm as a
<trim suffixOverrides="where" suffix=""> <trim suffixOverrides="where" suffix="">
where where
<trim prefixOverrides="and" prefix=""> <trim prefixOverrides="and" prefix="">
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<version>1.1.5-SNAPSHOT</version> <version>1.1.5-SNAPSHOT</version>
</parent> </parent>
<groupId>com.mortals.xhx</groupId> <groupId>com.mortals.xhx</groupId>
<artifactId>device-platform</artifactId> <artifactId>device-new-platform</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
...@@ -30,17 +30,17 @@ ...@@ -30,17 +30,17 @@
</activation> </activation>
<properties> <properties>
<profiles.active>develop</profiles.active> <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.queue.type>rabbitmq</profiles.queue.type>
<profiles.datasource.uri> <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.username>root</profiles.datasource.username>
<profiles.datasource.password>12345678</profiles.datasource.password> <profiles.datasource.password>12345678</profiles.datasource.password>
<profiles.redis.uri>127.0.0.1</profiles.redis.uri> <profiles.redis.uri>127.0.0.1</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port> <profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username> <profiles.redis.username></profiles.redis.username>
<profiles.redis.password></profiles.redis.password> <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.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.queue.type>rabbitmq</profiles.queue.type> <profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host> <profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
...@@ -59,17 +59,17 @@ ...@@ -59,17 +59,17 @@
<id>test</id> <id>test</id>
<properties> <properties>
<profiles.active>test</profiles.active> <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.queue.type>rabbitmq</profiles.queue.type>
<profiles.datasource.uri> <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.username>root</profiles.datasource.username>
<profiles.datasource.password>nacos@2020</profiles.datasource.password> <profiles.datasource.password>nacos@2020</profiles.datasource.password>
<profiles.redis.uri>192.168.0.252</profiles.redis.uri> <profiles.redis.uri>192.168.0.252</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port> <profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username> <profiles.redis.username></profiles.redis.username>
<profiles.redis.password>hotel@2020</profiles.redis.password> <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.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host> <profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port> <profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
...@@ -87,17 +87,17 @@ ...@@ -87,17 +87,17 @@
<id>product</id> <id>product</id>
<properties> <properties>
<profiles.active>product</profiles.active> <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.queue.type>rabbitmq</profiles.queue.type>
<profiles.datasource.uri> <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.username>root</profiles.datasource.username>
<profiles.datasource.password>root123</profiles.datasource.password> <profiles.datasource.password>root123</profiles.datasource.password>
<profiles.redis.uri>192.168.0.26</profiles.redis.uri> <profiles.redis.uri>192.168.0.26</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port> <profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username> <profiles.redis.username></profiles.redis.username>
<profiles.redis.password></profiles.redis.password> <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.kafka.brokers>192.168.0.26:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.26</profiles.rabbitmq.host> <profiles.rabbitmq.host>192.168.0.26</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port> <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