Commit ac9a3783 by 胡懿

修复iotdb session连接错误的问题

parent 8d027b10
......@@ -12,6 +12,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.security.PermitAll;
import java.util.Date;
import java.util.List;
......@@ -23,6 +24,7 @@ public class DeviceLogInfoController {
@Autowired
private IotDbConfig iotDbConfig;
@PermitAll
@PostMapping("/saveDeviceLogInfo")
@Operation(summary = "外部性请求保存日志")
public CommonResult<String> saveDeviceLogInfo(@RequestBody DeviceLogInfo deviceLogInfo) {
......@@ -33,6 +35,8 @@ public class DeviceLogInfoController {
rabbitTemplate.convertAndSend("my_boot_topic_exchange", "devicelog.save", deviceLogInfoStr);
return CommonResult.success("保存成功");
}
@PermitAll
@PostMapping("/saveDeviceLogInfoList")
@Operation(summary = "外部性请求保存日志")
public CommonResult<String> saveDeviceLogInfoList(@RequestBody List<DeviceLogInfo> deviceLogInfoList) {
......
......@@ -12,6 +12,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.security.PermitAll;
import java.util.Date;
import java.util.List;
......@@ -28,6 +29,11 @@ public class WebLogInfoController {
@Operation(summary = "初始化数据库")
public CommonResult<String> initIotDBDatabase() {
MyIotDbUtils.createDatabase(iotDbConfig);
MyIotDbUtils.createWebLogInfoTimeseries(iotDbConfig);
MyIotDbUtils.createIllegalLogTimeseries(iotDbConfig);
FileIotDbUtil.createFileLogInfoTimeseries(iotDbConfig);
SpecialPeopleIotDbUtils.createSpeLogInfoTimeseries(iotDbConfig);
JarDecLogIotDbUtil.createJarDecLogInfoTimeseries(iotDbConfig);
return CommonResult.success("初始化成功");
}
......@@ -65,6 +71,7 @@ public class WebLogInfoController {
return CommonResult.success("初始化成功");
}
@PermitAll
@PostMapping("/saveWebLogInfo")
@Operation(summary = "外部性请求保存日志")
public CommonResult<String> saveWebLogInfo(@RequestBody WebLogInfo webLogInfo) {
......
......@@ -22,13 +22,12 @@ import java.util.List;
* 重要文件访问日志
*/
public class FileIotDbUtil {
private static SessionPool sessionPool;
public static void createFileLogInfoTimeseries(IotDbConfig iotDbConfig) {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -61,7 +60,7 @@ public class FileIotDbUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -119,7 +118,7 @@ public class FileIotDbUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -175,7 +174,7 @@ public class FileIotDbUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -183,7 +182,7 @@ public class FileIotDbUtil {
.maxSize(3)
.build();
int offsetNum = (fileDecLogInfo.getPageNum() - 1) * fileDecLogInfo.getPageSize() + 1;
int offsetNum = (fileDecLogInfo.getPageNum() - 1) * fileDecLogInfo.getPageSize();
int limitNum = fileDecLogInfo.getPageSize();
StringBuffer sb = new StringBuffer();
sb.append("select userId, username, sysAbbre, content, privateKey, clientIp, fileName, fileId from root.myDecFileLogInfo.decFileLog");
......
......@@ -18,7 +18,6 @@ import java.util.Random;
public class IotDBUtil {
private static SessionPool sessionPool;
public static void main(String[] args) {
select();
......@@ -30,7 +29,7 @@ public class IotDBUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("192.168.19.128:6667");
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user("root")
......@@ -53,7 +52,7 @@ public class IotDBUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("192.168.19.128:6667");
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user("root")
......@@ -99,7 +98,7 @@ public class IotDBUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("192.168.19.128:6667");
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user("root")
......@@ -124,7 +123,7 @@ public class IotDBUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("192.168.19.128:6667");
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user("root")
......@@ -158,7 +157,7 @@ public class IotDBUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("192.168.19.128:6667");
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user("root")
......@@ -211,7 +210,7 @@ public class IotDBUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("192.168.19.128:6667");
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user("root")
......@@ -263,7 +262,7 @@ public class IotDBUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add("192.168.19.128:6667");
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user("root")
......
......@@ -18,13 +18,11 @@ import java.util.List;
public class JarDecLogIotDbUtil {
private static SessionPool sessionPool;
public static void createJarDecLogInfoTimeseries(IotDbConfig iotDbConfig) {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -57,7 +55,7 @@ public class JarDecLogIotDbUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -111,7 +109,7 @@ public class JarDecLogIotDbUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -167,7 +165,7 @@ public class JarDecLogIotDbUtil {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -175,7 +173,7 @@ public class JarDecLogIotDbUtil {
.maxSize(3)
.build();
int offsetNum = (jarDecLogInfo.getPageNum() - 1) * jarDecLogInfo.getPageSize() + 1;
int offsetNum = (jarDecLogInfo.getPageNum() - 1) * jarDecLogInfo.getPageSize();
int limitNum = jarDecLogInfo.getPageSize();
StringBuffer sb = new StringBuffer();
sb.append("select userId, username, sysAbbre, content, privateKey, clientIp, type from root.myDecFileLogInfo.jarDecLog");
......
......@@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.List;
public class MyIotDbUtils {
private static SessionPool sessionPool;
// 创建数据库
public static void createDatabase(IotDbConfig iotDbConfig) {
......@@ -26,7 +25,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -47,7 +46,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -77,7 +76,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -112,7 +111,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -167,7 +166,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -223,7 +222,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -296,7 +295,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -304,7 +303,7 @@ public class MyIotDbUtils {
.maxSize(3)
.build();
int offsetNum = (webLogInfoVo.getPageNum() - 1) * webLogInfoVo.getPageSize() + 1;
int offsetNum = (webLogInfoVo.getPageNum() - 1) * webLogInfoVo.getPageSize();
int limitNum = webLogInfoVo.getPageSize();
StringBuffer sb = new StringBuffer();
sb.append("select userId, username, sysAbbre, url, accessed, type, clientIp, remark from root.myWebLogInfo.tableTwo");
......@@ -399,7 +398,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -478,7 +477,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -486,7 +485,7 @@ public class MyIotDbUtils {
.maxSize(3)
.build();
int offsetNum = (webLogInfoVo.getPageNum() - 1) * webLogInfoVo.getPageSize() + 1;
int offsetNum = (webLogInfoVo.getPageNum() - 1) * webLogInfoVo.getPageSize();
int limitNum = webLogInfoVo.getPageSize();
StringBuffer sb = new StringBuffer();
sb.append("select userId, username, sysAbbre, url, accessed, type, clientIp, remark, illType from root.myWebLogInfo.tableThree");
......@@ -591,7 +590,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -624,7 +623,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -662,7 +661,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -745,7 +744,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -826,7 +825,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -891,7 +890,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -899,7 +898,7 @@ public class MyIotDbUtils {
.maxSize(3)
.build();
int offsetNum = (deviceLogInfo.getPageNum() - 1) * deviceLogInfo.getPageSize() + 1;
int offsetNum = (deviceLogInfo.getPageNum() - 1) * deviceLogInfo.getPageSize();
int limitNum = deviceLogInfo.getPageSize();
StringBuffer sb = new StringBuffer();
sb.append("select roleId, roleName, userId, username, deviceId, deviceName, deviceTypeId, deviceTypeName, accessed, type, clientIp, remark from root.myDeviceLogInfo.tableOne");
......@@ -998,7 +997,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -1063,7 +1062,7 @@ public class MyIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -1071,7 +1070,7 @@ public class MyIotDbUtils {
.maxSize(3)
.build();
int offsetNum = (deviceIllLogInfo.getPageNum() - 1) * deviceIllLogInfo.getPageSize() + 1;
int offsetNum = (deviceIllLogInfo.getPageNum() - 1) * deviceIllLogInfo.getPageSize();
int limitNum = deviceIllLogInfo.getPageSize();
StringBuffer sb = new StringBuffer();
sb.append("select roleId, roleName, userId, username, deviceId, deviceName, deviceTypeId, deviceTypeName, accessed, illType, clientIp, remark from root.myDeviceLogInfo.tableTwo");
......
......@@ -20,13 +20,12 @@ import java.util.List;
* 重点、特殊人群解密日志揭露
*/
public class SpecialPeopleIotDbUtils {
private static SessionPool sessionPool;
public static void createSpeLogInfoTimeseries(IotDbConfig iotDbConfig) {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -58,7 +57,7 @@ public class SpecialPeopleIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -109,7 +108,7 @@ public class SpecialPeopleIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -165,7 +164,7 @@ public class SpecialPeopleIotDbUtils {
try {
List<String> nodeUrls = new ArrayList<>();
nodeUrls.add(iotDbConfig.getIp() + ":" + iotDbConfig.getPort());
sessionPool =
SessionPool sessionPool =
new SessionPool.Builder()
.nodeUrls(nodeUrls)
.user(iotDbConfig.getUsername())
......@@ -173,7 +172,7 @@ public class SpecialPeopleIotDbUtils {
.maxSize(3)
.build();
int offsetNum = (spePeoLogInfo.getPageNum() - 1) * spePeoLogInfo.getPageSize() + 1;
int offsetNum = (spePeoLogInfo.getPageNum() - 1) * spePeoLogInfo.getPageSize();
int limitNum = spePeoLogInfo.getPageSize();
StringBuffer sb = new StringBuffer();
sb.append("select userId, username, sysAbbre, content, privateKey, clientIp from root.myDecFileLogInfo.speLog");
......
......@@ -4512,7 +4512,7 @@ COMMENT ON TABLE yudao_demo01_contact IS '示例联系人表';
-- ----------------------------
-- @formatter:off
BEGIN;
INSERT INTO yudao_demo01_contact (id, name, sex, birthday, description, avatar, creator, create_time, updater, update_time, deleted, tenant_id) VALUES (1, '土豆', 2, '2023-11-07 00:00:00', '<p>天蚕土豆!呀</p>', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/46f8fa1a37db3f3960d8910ff2fe3962ab3b2db87cf2f8ccb4dc8145b8bdf237.jpeg', '1', '2023-11-15 23:34:30', '1', '2023-11-15 23:47:39', '0', 1);
INSERT INTO yudao_demo01_contact (id, name, sex, birthday, description, avatar, creator, create_time, updater, update_time, deleted, tenant_id) VALUES (1, 'aaa', 2, '2023-11-07 00:00:00', '<p>aaa</p>', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/46f8fa1a37db3f3960d8910ff2fe3962ab3b2db87cf2f8ccb4dc8145b8bdf237.jpeg', '1', '2023-11-15 23:34:30', '1', '2023-11-15 23:47:39', '0', 1);
COMMIT;
-- @formatter:on
......
......@@ -189,6 +189,18 @@ public class AuthController {
return success(authService.socialLogin(reqVO));
}
// =======================================对接平台====================================================
@PostMapping("/ptLogin")
@PermitAll
@Operation(summary = "使用账号密码登录平台")
......
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