From 53cc3c85e35b400b3de3f859f673ae8337a19f67 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Tue, 13 Aug 2024 16:15:59 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E7=99=BB=E5=BD=95=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...OracleMonitorStatusToMysqlServiceImpl.java | 91 ++++--- .../java/com/njcn/InfluxDataApplication.java | 2 +- .../java/com/njcn/influx/config/Security.java | 19 ++ .../njcn/influx/job/OracleToInfluxDBJob.java | 8 +- .../src/main/resources/application.yml | 7 + .../src/main/resources/application_hb.yml | 3 + .../src/main/resources/application_sjzx.yml | 2 + .../src/main/resources/static/base.js | 243 ++++++++++++++++++ .../src/main/resources/static/index.html | 78 +++--- .../oracle/mapper/mapping/LineTimeMapper.xml | 2 +- 10 files changed, 372 insertions(+), 83 deletions(-) create mode 100644 influx-data/influx-target/src/main/java/com/njcn/influx/config/Security.java create mode 100644 influx-data/influx-target/src/main/resources/static/base.js diff --git a/influx-data/influx-source/src/main/java/com/njcn/influx/service/impl/OracleMonitorStatusToMysqlServiceImpl.java b/influx-data/influx-source/src/main/java/com/njcn/influx/service/impl/OracleMonitorStatusToMysqlServiceImpl.java index 8cdad72..6da4dc5 100644 --- a/influx-data/influx-source/src/main/java/com/njcn/influx/service/impl/OracleMonitorStatusToMysqlServiceImpl.java +++ b/influx-data/influx-source/src/main/java/com/njcn/influx/service/impl/OracleMonitorStatusToMysqlServiceImpl.java @@ -11,6 +11,7 @@ import com.njcn.influx.mapper.PqDeviceMapper; import com.njcn.influx.mapper.RmpEventDetailPOMapper; import com.njcn.influx.service.*; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.time.LocalDateTime; @@ -29,6 +30,9 @@ import java.util.stream.Collectors; @Service public class OracleMonitorStatusToMysqlServiceImpl implements OracleMonitorStatusToMysqlService { + @Value("${business.type}") + private Integer systemType; + private final RmpEventDetailPOMapper rmpEventDetailPOMapper; private final IPqDeviceBakService pqDeviceBakService; private final PqDeviceMapper pqDeviceMapper; @@ -54,48 +58,53 @@ public class OracleMonitorStatusToMysqlServiceImpl implements OracleMonitorStatu Map oracleDevMysql = list.stream().collect(Collectors.toMap(PqDeviceBak::getDevId, PqDeviceBak::getId)); List pqDevices = pqDeviceMapper.selectList(null); //pq的设备表更改通信状态 - List tempList = new ArrayList<>(); - pqDevices.stream().forEach(temp->{ - String id =""; - if (!IdMappingCache.DevIdMapping.containsKey(temp.getDevIndex()+"")){ - return; - }else { - id=IdMappingCache.DevIdMapping.get(temp.getDevIndex()+""); - } - pqDeviceMysqlService.update(new LambdaUpdateWrapper() - .set(PqDeviceMysql::getRunFlag,temp.getDevFlag()) - .set(PqDeviceMysql::getComFlag,temp.getStatus()) - .set(PqDeviceMysql::getUpdateTime,temp.getUpdateTime()) - .eq(PqDeviceMysql::getId,id)); - - }); - - Map> oracleDevMap = pqDevices.stream().collect(Collectors.groupingBy(PqDevice::getDevFlag - , Collectors.mapping(PqDevice::getDevIndex, Collectors.toList()))); - oracleDevMap.forEach((key, value) -> { - List info = new ArrayList<>(); - for (Long aLong : value) { - if (oracleDevMysql.containsKey(aLong)) { - info.add(oracleDevMysql.get(aLong)); + if(systemType == 0){ + List tempList = new ArrayList<>(); + pqDevices.stream().forEach(temp->{ + String id =""; + if (!IdMappingCache.DevIdMapping.containsKey(temp.getDevIndex()+"")){ + return; + }else { + id=IdMappingCache.DevIdMapping.get(temp.getDevIndex()+""); } - } - String devStatus = devStatusId(key, devDicList); - String monitorStatus = monitorStatusId(key, monitorDicList); - if (StrUtil.isNotBlank(devStatus) && CollUtil.isNotEmpty(info)) { - //修改终端状态 - pmsTerminalService.update(new LambdaUpdateWrapper() - .set(PmsTerminal::getTerminalState, devStatusId(key, devDicList)) - .in(PmsTerminal::getId, info) - ); - } - if (StrUtil.isNotBlank(monitorStatus) && CollUtil.isNotEmpty(info)) { - //修改监测点状态 - pmsMonitorService.update(new LambdaUpdateWrapper() - .set(PmsMonitor::getMonitorState, monitorStatusId(key, monitorDicList)) - .in(PmsMonitor::getTerminalId, info) - ); - } - }); + pqDeviceMysqlService.update(new LambdaUpdateWrapper() + .set(PqDeviceMysql::getRunFlag,temp.getDevFlag()) + .set(PqDeviceMysql::getComFlag,temp.getStatus()) + .set(PqDeviceMysql::getUpdateTime,temp.getUpdateTime()) + .eq(PqDeviceMysql::getId,id)); + + }); + }else { + Map> oracleDevMap = pqDevices.stream().collect(Collectors.groupingBy(PqDevice::getDevFlag + , Collectors.mapping(PqDevice::getDevIndex, Collectors.toList()))); + oracleDevMap.forEach((key, value) -> { + List info = new ArrayList<>(); + for (Long aLong : value) { + if (oracleDevMysql.containsKey(aLong)) { + info.add(oracleDevMysql.get(aLong)); + } + } + String devStatus = devStatusId(key, devDicList); + String monitorStatus = monitorStatusId(key, monitorDicList); + if (StrUtil.isNotBlank(devStatus) && CollUtil.isNotEmpty(info)) { + //修改终端状态 + pmsTerminalService.update(new LambdaUpdateWrapper() + .set(PmsTerminal::getTerminalState, devStatusId(key, devDicList)) + .in(PmsTerminal::getId, info) + ); + } + if (StrUtil.isNotBlank(monitorStatus) && CollUtil.isNotEmpty(info)) { + //修改监测点状态 + pmsMonitorService.update(new LambdaUpdateWrapper() + .set(PmsMonitor::getMonitorState, monitorStatusId(key, monitorDicList)) + .in(PmsMonitor::getTerminalId, info) + ); + } + }); + } + + + } diff --git a/influx-data/influx-target/src/main/java/com/njcn/InfluxDataApplication.java b/influx-data/influx-target/src/main/java/com/njcn/InfluxDataApplication.java index 389e269..91ef85c 100644 --- a/influx-data/influx-target/src/main/java/com/njcn/InfluxDataApplication.java +++ b/influx-data/influx-target/src/main/java/com/njcn/InfluxDataApplication.java @@ -19,7 +19,7 @@ import org.springframework.scheduling.annotation.EnableAsync; @EnableAsync @DependsOn("proxyMapperRegister") @MapperScan("com.njcn.**.mapper") -@SpringBootApplication(scanBasePackages = "com.njcn", exclude = {SecurityAutoConfiguration.class, SecurityFilterAutoConfiguration.class}) +@SpringBootApplication(scanBasePackages = "com.njcn") public class InfluxDataApplication { public static void main(String[] args) { diff --git a/influx-data/influx-target/src/main/java/com/njcn/influx/config/Security.java b/influx-data/influx-target/src/main/java/com/njcn/influx/config/Security.java new file mode 100644 index 0000000..ae7f91b --- /dev/null +++ b/influx-data/influx-target/src/main/java/com/njcn/influx/config/Security.java @@ -0,0 +1,19 @@ +package com.njcn.influx.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +@EnableWebSecurity +public class Security extends WebSecurityConfigurerAdapter { + + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.formLogin().and().authorizeRequests().anyRequest().authenticated().and().csrf().disable(); + } + + +} diff --git a/influx-data/influx-target/src/main/java/com/njcn/influx/job/OracleToInfluxDBJob.java b/influx-data/influx-target/src/main/java/com/njcn/influx/job/OracleToInfluxDBJob.java index 15e9d04..97b65d1 100644 --- a/influx-data/influx-target/src/main/java/com/njcn/influx/job/OracleToInfluxDBJob.java +++ b/influx-data/influx-target/src/main/java/com/njcn/influx/job/OracleToInfluxDBJob.java @@ -48,14 +48,14 @@ public class OracleToInfluxDBJob { //每小时03分钟时执行上一个小时的数据同步 //河北这边比较特殊, - @Scheduled(cron="0 40 * * * ?") + @Scheduled(cron="0 15 * * * ?") public void executeHours() { DataAsynParam dataAsynParam = new DataAsynParam(); // 获取当前时间 LocalDateTime now = LocalDateTime.now(); // 减去一个小时 - LocalDateTime oneHourAgo = now.minusHours(1); + LocalDateTime oneHourAgo = now.minusHours(2); // 将分钟和秒设置为0 LocalDateTime result = oneHourAgo.truncatedTo(ChronoUnit.HOURS); @@ -116,8 +116,8 @@ public class OracleToInfluxDBJob { * 每天同步台账监测点部分信息 仅数据中心使用 * @date 2024/3/5 */ - @Scheduled(cron="0 30 0 * * ?") + /* @Scheduled(cron="0 30 0 * * ?") public void synLedgerMonitor() { oracleMonitorStatusToMysqlService.monitorTimeSync(); - } + }*/ } diff --git a/influx-data/influx-target/src/main/resources/application.yml b/influx-data/influx-target/src/main/resources/application.yml index cd781c3..2a5b2fe 100644 --- a/influx-data/influx-target/src/main/resources/application.yml +++ b/influx-data/influx-target/src/main/resources/application.yml @@ -2,8 +2,15 @@ business: #分片次数,一定为24的约数,1 2 3 4 6 8 12 24 slice: 4 + # 0.pq 1.pms + type: 0 server: port: 8090 + #springsecurity默认过期时间30m + servlet: + session: + timeout: 1440m + spring: security: user: diff --git a/influx-data/influx-target/src/main/resources/application_hb.yml b/influx-data/influx-target/src/main/resources/application_hb.yml index aa3c01a..057a2ab 100644 --- a/influx-data/influx-target/src/main/resources/application_hb.yml +++ b/influx-data/influx-target/src/main/resources/application_hb.yml @@ -2,6 +2,9 @@ business: #分片次数,一定为24的约数,1 2 3 4 6 8 12 24 slice: 4 + # 0.pq 1.pms + type: 1 + server: port: 8090 spring: diff --git a/influx-data/influx-target/src/main/resources/application_sjzx.yml b/influx-data/influx-target/src/main/resources/application_sjzx.yml index 001a645..e04c7dc 100644 --- a/influx-data/influx-target/src/main/resources/application_sjzx.yml +++ b/influx-data/influx-target/src/main/resources/application_sjzx.yml @@ -2,6 +2,8 @@ business: #分片次数,一定为24的约数,1 2 3 4 6 8 12 24 slice: 4 + # 0.pq 1.pms + type: 0 server: port: 8090 spring: diff --git a/influx-data/influx-target/src/main/resources/static/base.js b/influx-data/influx-target/src/main/resources/static/base.js new file mode 100644 index 0000000..7db43d0 --- /dev/null +++ b/influx-data/influx-target/src/main/resources/static/base.js @@ -0,0 +1,243 @@ +/** + * Created by SLICE_30_K on 2017/5/22. + * + * 支持一般Base64的编码和解码 + * 支持符合RFC_4648标准中"URL and Filename Safe Alphabet"的URL安全Base64编解码 + * 支持中文字符的编解码(Unicode编码) + */ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(factory); + } + else { + // Global (browser) + window.BASE64 = factory(); + } +}(this, function () { + var BASE64_MAPPING = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/' + ]; + var URLSAFE_BASE64_MAPPING = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '-', '_' + ]; + + var _toBinary = function (ascii) { + var binary = []; + while (ascii > 0) { + var b = ascii % 2; + ascii = Math.floor(ascii / 2); + binary.push(b); + } + binary.reverse(); + return binary; + }; + + var _toDecimal = function (binary) { + var dec = 0; + var p = 0; + for (var i = binary.length - 1; i >= 0; --i) { + var b = binary[i]; + if (b == 1) { + dec += Math.pow(2, p); + } + ++p; + } + return dec; + }; + + var _toUTF8Binary = function (c, binaryArray) { + var mustLen = (8 - (c + 1)) + ((c - 1) * 6); + var fatLen = binaryArray.length; + var diff = mustLen - fatLen; + while (--diff >= 0) { + binaryArray.unshift(0); + } + var binary = []; + var _c = c; + while (--_c >= 0) { + binary.push(1); + } + binary.push(0); + var i = 0, len = 8 - (c + 1); + for (; i < len; ++i) { + binary.push(binaryArray[i]); + } + + for (var j = 0; j < c - 1; ++j) { + binary.push(1); + binary.push(0); + var sum = 6; + while (--sum >= 0) { + binary.push(binaryArray[i++]); + } + } + return binary; + }; + + var _toBinaryArray = function (str) { + var binaryArray = []; + for (var i = 0, len = str.length; i < len; ++i) { + var unicode = str.charCodeAt(i); + var _tmpBinary = _toBinary(unicode); + if (unicode < 0x80) { + var _tmpdiff = 8 - _tmpBinary.length; + while (--_tmpdiff >= 0) { + _tmpBinary.unshift(0); + } + binaryArray = binaryArray.concat(_tmpBinary); + } else if (unicode >= 0x80 && unicode <= 0x7FF) { + binaryArray = binaryArray.concat(_toUTF8Binary(2, _tmpBinary)); + } else if (unicode >= 0x800 && unicode <= 0xFFFF) {//UTF-8 3byte + binaryArray = binaryArray.concat(_toUTF8Binary(3, _tmpBinary)); + } else if (unicode >= 0x10000 && unicode <= 0x1FFFFF) {//UTF-8 4byte + binaryArray = binaryArray.concat(_toUTF8Binary(4, _tmpBinary)); + } else if (unicode >= 0x200000 && unicode <= 0x3FFFFFF) {//UTF-8 5byte + binaryArray = binaryArray.concat(_toUTF8Binary(5, _tmpBinary)); + } else if (unicode >= 4000000 && unicode <= 0x7FFFFFFF) {//UTF-8 6byte + binaryArray = binaryArray.concat(_toUTF8Binary(6, _tmpBinary)); + } + } + return binaryArray; + }; + + var _toUnicodeStr = function (binaryArray) { + var unicode; + var unicodeBinary = []; + var str = ""; + for (var i = 0, len = binaryArray.length; i < len;) { + if (binaryArray[i] == 0) { + unicode = _toDecimal(binaryArray.slice(i, i + 8)); + str += String.fromCharCode(unicode); + i += 8; + } else { + var sum = 0; + while (i < len) { + if (binaryArray[i] == 1) { + ++sum; + } else { + break; + } + ++i; + } + unicodeBinary = unicodeBinary.concat(binaryArray.slice(i + 1, i + 8 - sum)); + i += 8 - sum; + while (sum > 1) { + unicodeBinary = unicodeBinary.concat(binaryArray.slice(i + 2, i + 8)); + i += 8; + --sum; + } + unicode = _toDecimal(unicodeBinary); + str += String.fromCharCode(unicode); + unicodeBinary = []; + } + } + return str; + }; + + var _encode = function (str, url_safe) { + var base64_Index = []; + var binaryArray = _toBinaryArray(str); + var dictionary = url_safe ? URLSAFE_BASE64_MAPPING : BASE64_MAPPING; + + var extra_Zero_Count = 0; + for (var i = 0, len = binaryArray.length; i < len; i += 6) { + var diff = (i + 6) - len; + if (diff == 2) { + extra_Zero_Count = 2; + } else if (diff == 4) { + extra_Zero_Count = 4; + } + var _tmpExtra_Zero_Count = extra_Zero_Count; + while (--_tmpExtra_Zero_Count >= 0) { + binaryArray.push(0); + } + base64_Index.push(_toDecimal(binaryArray.slice(i, i + 6))); + } + + var base64 = ''; + for (var i = 0, len = base64_Index.length; i < len; ++i) { + base64 += dictionary[base64_Index[i]]; + } + + for (var i = 0, len = extra_Zero_Count / 2; i < len; ++i) { + base64 += '='; + } + return base64; + }; + + var _decode = function (_base64Str, url_safe) { + var _len = _base64Str.length; + var extra_Zero_Count = 0; + var dictionary = url_safe ? URLSAFE_BASE64_MAPPING : BASE64_MAPPING; + + if (_base64Str.charAt(_len - 1) == '=') { + if (_base64Str.charAt(_len - 2) == '=') {//两个等号说明补了4个0 + extra_Zero_Count = 4; + _base64Str = _base64Str.substring(0, _len - 2); + } else {//一个等号说明补了2个0 + extra_Zero_Count = 2; + _base64Str = _base64Str.substring(0, _len - 1); + } + } + + var binaryArray = []; + for (var i = 0, len = _base64Str.length; i < len; ++i) { + var c = _base64Str.charAt(i); + for (var j = 0, size = dictionary.length; j < size; ++j) { + if (c == dictionary[j]) { + var _tmp = _toBinary(j); + /*不足6位的补0*/ + var _tmpLen = _tmp.length; + if (6 - _tmpLen > 0) { + for (var k = 6 - _tmpLen; k > 0; --k) { + _tmp.unshift(0); + } + } + binaryArray = binaryArray.concat(_tmp); + break; + } + } + } + if (extra_Zero_Count > 0) { + binaryArray = binaryArray.slice(0, binaryArray.length - extra_Zero_Count); + } + var str = _toUnicodeStr(binaryArray); + return str; + }; + + var __BASE64 = { + encode: function (str) { + return _encode(str, false); + }, + decode: function (base64Str) { + return _decode(base64Str, false); + }, + urlsafe_encode: function (str) { + return _encode(str, true); + }, + urlsafe_decode: function (base64Str) { + return _decode(base64Str, true); + } + }; + + return __BASE64; +})); \ No newline at end of file diff --git a/influx-data/influx-target/src/main/resources/static/index.html b/influx-data/influx-target/src/main/resources/static/index.html index cf66f00..5d97a22 100644 --- a/influx-data/influx-target/src/main/resources/static/index.html +++ b/influx-data/influx-target/src/main/resources/static/index.html @@ -8,6 +8,7 @@ +
@@ -126,7 +127,7 @@