Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f54ce5ae3c | |||
|
|
3a589962a5 | ||
|
|
e54df08dca | ||
| 055c762415 | |||
|
|
cdbb4fe428 | ||
|
|
d972bbef80 | ||
| 1d664fee19 | |||
| eb10a16799 | |||
| 6e85a72b7d | |||
| 59b56a39dc | |||
| da387cc39d | |||
|
|
9d4215afb5 | ||
| 35e3d098a9 | |||
| 61bbbed153 | |||
| 0fe103d01e | |||
| d64b15a8e6 | |||
| 3ed732affd | |||
| 128925a5d6 | |||
| 311b2844ba | |||
| 7dc2cde6ed | |||
|
|
8b1074c172 | ||
|
|
67ad03ddbe | ||
| 24e937e331 | |||
| 89ece63f2e | |||
| 1e79bbdcb0 | |||
| ec051827ac | |||
| 6fa63a7f3e | |||
| a9aa0785da | |||
| 23e7288609 | |||
|
|
a573c17886 | ||
| be8edfd4cf | |||
| 30b4f03f6b | |||
|
|
ee41b0a554 | ||
| 458b2347ed | |||
|
|
c1bfc2347f | ||
| eba02ffcf3 | |||
| 2921145336 | |||
|
|
9de6981cd5 | ||
| fb58b13c91 | |||
|
|
e12e5d90c8 | ||
|
|
075205d4b9 | ||
| 1af8fcc72f | |||
|
|
6ec0ef54e9 | ||
| fd23719a41 | |||
| 306200791a | |||
| e6a1874abf | |||
|
|
8502421b91 | ||
|
|
50cd5d3895 |
10
pom.xml
10
pom.xml
@@ -43,16 +43,20 @@
|
|||||||
<!-- <middle.server.url>10.95.53.49</middle.server.url>-->
|
<!-- <middle.server.url>10.95.53.49</middle.server.url>-->
|
||||||
<middle.server.url>192.168.1.22</middle.server.url>
|
<middle.server.url>192.168.1.22</middle.server.url>
|
||||||
<!--微服务模块发布地址-->
|
<!--微服务模块发布地址-->
|
||||||
<service.server.url>127.0.0.1</service.server.url>
|
<service.server.url>192.168.1.127</service.server.url>
|
||||||
<!--docker仓库地址-->
|
<!--docker仓库地址-->
|
||||||
<docker.server.url>192.168.1.22</docker.server.url>
|
<docker.server.url>192.168.1.22</docker.server.url>
|
||||||
<!--nacos的ip:port-->
|
<!--nacos的ip:port-->
|
||||||
<nacos.url>${middle.server.url}:18848</nacos.url>
|
<nacos.url>${middle.server.url}:18848</nacos.url>
|
||||||
|
<!--nacos开启鉴权后的用户名-->
|
||||||
|
<nacos.username>nacos</nacos.username>
|
||||||
|
<!--nacos的ip:port-->
|
||||||
|
<nacos.password>nacos</nacos.password>
|
||||||
<!--服务器发布内容为空-->
|
<!--服务器发布内容为空-->
|
||||||
<!-- <nacos.namespace></nacos.namespace>-->
|
<!-- <nacos.namespace></nacos.namespace>-->
|
||||||
<!-- <nacos.namespace>1dd11af6-e668-41fd-a663-02a05705304d</nacos.namespace>-->
|
<!-- <nacos.namespace>1dd11af6-e668-41fd-a663-02a05705304d</nacos.namespace>-->
|
||||||
<!-- <nacos.namespace>fd74182b-1fce-4dba-afa7-2623b0376205</nacos.namespace>-->
|
<!-- <nacos.namespace>fd74182b-1fce-4dba-afa7-2623b0376205</nacos.namespace>-->
|
||||||
<nacos.namespace>910d0d69-2254-481b-b9f7-7ecf9cb881b0</nacos.namespace>
|
<nacos.namespace>ddcae5af-ac35-4fc4-9804-962de94dfc61</nacos.namespace>
|
||||||
<!-- sentinel:port-->
|
<!-- sentinel:port-->
|
||||||
<sentinel.url>${middle.server.url}:8080</sentinel.url>
|
<sentinel.url>${middle.server.url}:8080</sentinel.url>
|
||||||
<!--网关地址,主要用于配置swagger中认证token-->
|
<!--网关地址,主要用于配置swagger中认证token-->
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.njcn.advance.mapper.carrycapacity.CarryCapacityUserPOMapper;
|
|||||||
import com.njcn.advance.pojo.carrycapacity.param.CarryCapacityUserParam;
|
import com.njcn.advance.pojo.carrycapacity.param.CarryCapacityUserParam;
|
||||||
import com.njcn.advance.pojo.carrycapacity.po.CarryCapacityUserPO;
|
import com.njcn.advance.pojo.carrycapacity.po.CarryCapacityUserPO;
|
||||||
import com.njcn.advance.service.carrycapacity.CarryCapacityUserPOService;
|
import com.njcn.advance.service.carrycapacity.CarryCapacityUserPOService;
|
||||||
|
import com.njcn.common.pojo.constant.LogInfo;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.user.api.UserFeignClient;
|
import com.njcn.user.api.UserFeignClient;
|
||||||
import com.njcn.user.pojo.vo.UserVO;
|
import com.njcn.user.pojo.vo.UserVO;
|
||||||
@@ -77,7 +78,7 @@ public class CarryCapacityUserPOServiceImpl extends ServiceImpl<CarryCapacityUse
|
|||||||
page.getRecords().stream().forEach(temp->{
|
page.getRecords().stream().forEach(temp->{
|
||||||
UserVO user = userFeignClient.getUserById(temp.getCreateBy()).getData();
|
UserVO user = userFeignClient.getUserById(temp.getCreateBy()).getData();
|
||||||
|
|
||||||
temp.setCreateBy(user.getName());
|
temp.setCreateBy(Objects.isNull(user)? LogInfo.UNKNOWN_USER:user.getName());
|
||||||
});
|
});
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import com.njcn.influx.deprecated.InfluxDBPublicParam;
|
|||||||
import com.njcn.influx.imapper.DataHarmPowerPMapper;
|
import com.njcn.influx.imapper.DataHarmPowerPMapper;
|
||||||
import com.njcn.influx.imapper.DataHarmPowerQMapper;
|
import com.njcn.influx.imapper.DataHarmPowerQMapper;
|
||||||
import com.njcn.influx.imapper.DataVMapper;
|
import com.njcn.influx.imapper.DataVMapper;
|
||||||
import com.njcn.influx.imapper.IDataIMapper;
|
import com.njcn.influx.imapper.DataIMapper;
|
||||||
import com.njcn.influx.pojo.bo.CarryCapcityData;
|
import com.njcn.influx.pojo.bo.CarryCapcityData;
|
||||||
import com.njcn.influx.pojo.po.DataI;
|
import com.njcn.influx.pojo.po.DataI;
|
||||||
import com.njcn.oss.constant.OssPath;
|
import com.njcn.oss.constant.OssPath;
|
||||||
@@ -74,14 +74,14 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
private final DataHarmPowerQMapper dataHarmPowerQMapper;
|
private final DataHarmPowerQMapper dataHarmPowerQMapper;
|
||||||
private final DataHarmPowerPMapper dataHarmPowerPMapper;
|
private final DataHarmPowerPMapper dataHarmPowerPMapper;
|
||||||
private final DataVMapper dataVMapper;
|
private final DataVMapper dataVMapper;
|
||||||
private final IDataIMapper dataIMapper;
|
private final DataIMapper dataIMapper;
|
||||||
|
|
||||||
private final CarryCapacityStrategyPOService carryCapacityStrategyPOService;
|
private final CarryCapacityStrategyPOService carryCapacityStrategyPOService;
|
||||||
private final CarryCapacityDataPOService carryCapacityDataPOService;
|
private final CarryCapacityDataPOService carryCapacityDataPOService;
|
||||||
private final RedisUtil redisUtil;
|
private final RedisUtil redisUtil;
|
||||||
private final CarryCapacityResultPOService carryCapacityResultPOService;
|
private final CarryCapacityResultPOService carryCapacityResultPOService;
|
||||||
private final CarryCapacityUserPOService carryCapacityUserPOService;
|
private final CarryCapacityUserPOService carryCapacityUserPOService;
|
||||||
private static final double DEFAULTVALUE=3141.5926;
|
private static final double DEFAULTVALUE=3.1415926;
|
||||||
|
|
||||||
private final FileStorageUtil fileStorageUtil;
|
private final FileStorageUtil fileStorageUtil;
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
缺失布置3.1415926,后边更具3.1415926个数来判断数据完整性,及进行数据补充*/
|
缺失布置3.1415926,后边更具3.1415926个数来判断数据完整性,及进行数据补充*/
|
||||||
//有功功率
|
//有功功率
|
||||||
String SqlP1 = "select mean(p)*1000 as value from data_harmpower_p where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
String SqlP1 = "select mean(p)*1000 as value from data_harmpower_p where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||||
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||||
dataHarmPowerPList = dataHarmPowerPMapper.getSqlResult(SqlP1);
|
dataHarmPowerPList = dataHarmPowerPMapper.getSqlResult(SqlP1);
|
||||||
|
|
||||||
//数据校验
|
//数据校验
|
||||||
@@ -172,7 +172,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
|
|
||||||
//无功功率
|
//无功功率
|
||||||
String SqlQ1 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
String SqlQ1 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||||
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||||
dataHarmPowerQList = dataHarmPowerQMapper.getSqlResult(SqlQ1);
|
dataHarmPowerQList = dataHarmPowerQMapper.getSqlResult(SqlQ1);
|
||||||
//数据缺失填补
|
//数据缺失填补
|
||||||
//数据校验
|
//数据校验
|
||||||
@@ -201,7 +201,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
, formatter) + " 23:59:00";
|
, formatter) + " 23:59:00";
|
||||||
|
|
||||||
String SqlP2 = "select mean(p)*1000 as value from data_harmpower_p where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
String SqlP2 = "select mean(p)*1000 as value from data_harmpower_p where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||||
dataHarmPowerP2List = dataHarmPowerPMapper.getSqlResult(SqlP2);
|
dataHarmPowerP2List = dataHarmPowerPMapper.getSqlResult(SqlP2);
|
||||||
//数据校验
|
//数据校验
|
||||||
if(CollectionUtil.isEmpty(dataHarmPowerP2List)){
|
if(CollectionUtil.isEmpty(dataHarmPowerP2List)){
|
||||||
@@ -220,7 +220,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
|
|
||||||
//无功功率
|
//无功功率
|
||||||
String SqlQ2 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
String SqlQ2 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||||
dataHarmPowerQ2List = dataHarmPowerQMapper.getSqlResult(SqlQ2);
|
dataHarmPowerQ2List = dataHarmPowerQMapper.getSqlResult(SqlQ2);
|
||||||
//数据校验
|
//数据校验
|
||||||
//数据校验
|
//数据校验
|
||||||
@@ -240,7 +240,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
|
|
||||||
//电压
|
//电压
|
||||||
String SqlU2 = "select mean(rms)*1000 as value from data_v where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
String SqlU2 = "select mean(rms)*1000 as value from data_v where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||||
dataHarmPowerU2List = dataVMapper.getSqlResult(SqlU2);
|
dataHarmPowerU2List = dataVMapper.getSqlResult(SqlU2);
|
||||||
//数据校验
|
//数据校验
|
||||||
//数据校验
|
//数据校验
|
||||||
@@ -325,7 +325,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
if(CollectionUtil.isEmpty(dataHarmPowerQList)){
|
if(CollectionUtil.isEmpty(dataHarmPowerQList)){
|
||||||
//无功功率
|
//无功功率
|
||||||
String SqlQ1 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
String SqlQ1 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||||
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||||
dataHarmPowerQList = dataHarmPowerQMapper.getSqlResult(SqlQ1);
|
dataHarmPowerQList = dataHarmPowerQMapper.getSqlResult(SqlQ1);
|
||||||
if(CollectionUtil.isEmpty(dataHarmPowerQList)){
|
if(CollectionUtil.isEmpty(dataHarmPowerQList)){
|
||||||
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
|
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
|
||||||
@@ -796,7 +796,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
, formatter) + " 23:59:00";
|
, formatter) + " 23:59:00";
|
||||||
|
|
||||||
String SqlP2 = "select mean(p)*1000 as value from data_harmpower_p where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
String SqlP2 = "select mean(p)*1000 as value from data_harmpower_p where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||||
dataHarmPowerP2List = dataHarmPowerPMapper.getSqlResult(SqlP2);
|
dataHarmPowerP2List = dataHarmPowerPMapper.getSqlResult(SqlP2);
|
||||||
//数据校验
|
//数据校验
|
||||||
if(CollectionUtil.isEmpty(dataHarmPowerP2List)){
|
if(CollectionUtil.isEmpty(dataHarmPowerP2List)){
|
||||||
@@ -818,14 +818,14 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
|
|
||||||
//无功功率
|
//无功功率
|
||||||
String SqlQ2 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
String SqlQ2 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||||
dataHarmPowerQ2List = dataHarmPowerQMapper.getSqlResult(SqlQ2);
|
dataHarmPowerQ2List = dataHarmPowerQMapper.getSqlResult(SqlQ2);
|
||||||
//数据校验
|
//数据校验
|
||||||
//数据缺失填补
|
//数据缺失填补
|
||||||
linearInterpolation(dataHarmPowerQ2List);
|
linearInterpolation(dataHarmPowerQ2List);
|
||||||
//电压
|
//电压
|
||||||
String SqlU2 = "select mean(rms)*1000 as value from data_v where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
String SqlU2 = "select mean(rms)*1000 as value from data_v where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||||
dataHarmPowerU2List = dataVMapper.getSqlResult(SqlU2);
|
dataHarmPowerU2List = dataVMapper.getSqlResult(SqlU2);
|
||||||
//数据校验
|
//数据校验
|
||||||
|
|
||||||
@@ -1163,24 +1163,31 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
*/
|
*/
|
||||||
public static void linearInterpolation(List<CarryCapcityData> data) {
|
public static void linearInterpolation(List<CarryCapcityData> data) {
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
|
||||||
if (data.get(i).getValue() == DEFAULTVALUE ||Objects.isNull(data.get(i).getValue())) {
|
|
||||||
|
data.stream().collect(Collectors.groupingBy(CarryCapcityData::getPhaseType)).forEach((k,v)->{
|
||||||
|
|
||||||
|
for (int i = 0; i < v.size(); i++) {
|
||||||
|
if (v.get(i).getValue() == DEFAULTVALUE ||Objects.isNull(v.get(i).getValue())) {
|
||||||
int prevIndex = i - 1;
|
int prevIndex = i - 1;
|
||||||
int nextIndex = i + 1;
|
int nextIndex = i + 1;
|
||||||
while (prevIndex >= 0 && (data.get(prevIndex).getValue() == DEFAULTVALUE|| Objects.isNull(data.get(prevIndex).getValue()))) {
|
while (prevIndex >= 0 && (v.get(prevIndex).getValue() == DEFAULTVALUE|| Objects.isNull(v.get(prevIndex).getValue()))) {
|
||||||
prevIndex--;
|
prevIndex--;
|
||||||
}
|
}
|
||||||
while (nextIndex < data.size() && (data.get(nextIndex).getValue() == DEFAULTVALUE|| Objects.isNull(data.get(nextIndex).getValue()))) {
|
while (nextIndex < v.size() && (v.get(nextIndex).getValue() == DEFAULTVALUE|| Objects.isNull(v.get(nextIndex).getValue()))) {
|
||||||
nextIndex++;
|
nextIndex++;
|
||||||
}
|
}
|
||||||
if (prevIndex >= 0 && nextIndex < data.size()) {
|
if (prevIndex >= 0 && nextIndex < v.size()) {
|
||||||
double slope = (data.get(nextIndex).getValue() - data.get(prevIndex).getValue()) / (nextIndex - prevIndex);
|
double slope = (v.get(nextIndex).getValue() - v.get(prevIndex).getValue()) / (nextIndex - prevIndex);
|
||||||
data.get(i).setValue(data.get(prevIndex).getValue() + slope * (i - prevIndex));
|
v.get(i).setValue(v.get(prevIndex).getValue() + slope * (i - prevIndex));
|
||||||
} else {
|
} else {
|
||||||
data.get(i).setValue(DEFAULTVALUE);
|
v.get(i).setValue(DEFAULTVALUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -1192,72 +1199,76 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
|||||||
*/
|
*/
|
||||||
public static void linearInterpolationI(List<DataI> data) {
|
public static void linearInterpolationI(List<DataI> data) {
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
data.stream().collect(Collectors.groupingBy(DataI::getPhaseType)).forEach((k,v)->{
|
||||||
if (data.get(i).getI2() == DEFAULTVALUE||Objects.isNull(data.get(i).getI2())) {
|
for (int i = 0; i < v.size(); i++) {
|
||||||
|
if (v.get(i).getI2() == DEFAULTVALUE||Objects.isNull(v.get(i).getI2())) {
|
||||||
int prevIndex = i - 1;
|
int prevIndex = i - 1;
|
||||||
int nextIndex = i + 1;
|
int nextIndex = i + 1;
|
||||||
while (prevIndex >= 0 && (data.get(prevIndex).getI2() == DEFAULTVALUE||Objects.isNull(data.get(prevIndex).getI2()))) {
|
while (prevIndex >= 0 && (v.get(prevIndex).getI2() == DEFAULTVALUE||Objects.isNull(v.get(prevIndex).getI2()))) {
|
||||||
prevIndex--;
|
prevIndex--;
|
||||||
}
|
}
|
||||||
while (nextIndex < data.size() && (data.get(nextIndex).getI2() == DEFAULTVALUE||Objects.isNull(data.get(nextIndex).getI2()))) {
|
while (nextIndex < v.size() && (v.get(nextIndex).getI2() == DEFAULTVALUE||Objects.isNull(v.get(nextIndex).getI2()))) {
|
||||||
nextIndex++;
|
nextIndex++;
|
||||||
}
|
}
|
||||||
if (prevIndex >= 0 && nextIndex < data.size()) {
|
if (prevIndex >= 0 && nextIndex < v.size()) {
|
||||||
double slope = (data.get(nextIndex).getI2() - data.get(prevIndex).getI2()) / (nextIndex - prevIndex);
|
double slope = (v.get(nextIndex).getI2() - v.get(prevIndex).getI2()) / (nextIndex - prevIndex);
|
||||||
data.get(i).setI2(data.get(prevIndex).getI2() + slope * (i - prevIndex));
|
v.get(i).setI2(v.get(prevIndex).getI2() + slope * (i - prevIndex));
|
||||||
data.get(i).setI3(data.get(prevIndex).getI3() + slope * (i - prevIndex));
|
v.get(i).setI3(v.get(prevIndex).getI3() + slope * (i - prevIndex));
|
||||||
data.get(i).setI4(data.get(prevIndex).getI4() + slope * (i - prevIndex));
|
v.get(i).setI4(v.get(prevIndex).getI4() + slope * (i - prevIndex));
|
||||||
data.get(i).setI5(data.get(prevIndex).getI5() + slope * (i - prevIndex));
|
v.get(i).setI5(v.get(prevIndex).getI5() + slope * (i - prevIndex));
|
||||||
data.get(i).setI6(data.get(prevIndex).getI6() + slope * (i - prevIndex));
|
v.get(i).setI6(v.get(prevIndex).getI6() + slope * (i - prevIndex));
|
||||||
data.get(i).setI7(data.get(prevIndex).getI7() + slope * (i - prevIndex));
|
v.get(i).setI7(v.get(prevIndex).getI7() + slope * (i - prevIndex));
|
||||||
data.get(i).setI8(data.get(prevIndex).getI8() + slope * (i - prevIndex));
|
v.get(i).setI8(v.get(prevIndex).getI8() + slope * (i - prevIndex));
|
||||||
data.get(i).setI9(data.get(prevIndex).getI9() + slope * (i - prevIndex));
|
v.get(i).setI9(v.get(prevIndex).getI9() + slope * (i - prevIndex));
|
||||||
data.get(i).setI10(data.get(prevIndex).getI10() + slope * (i - prevIndex));
|
v.get(i).setI10(v.get(prevIndex).getI10() + slope * (i - prevIndex));
|
||||||
data.get(i).setI11(data.get(prevIndex).getI11() + slope * (i - prevIndex));
|
v.get(i).setI11(v.get(prevIndex).getI11() + slope * (i - prevIndex));
|
||||||
data.get(i).setI12(data.get(prevIndex).getI12() + slope * (i - prevIndex));
|
v.get(i).setI12(v.get(prevIndex).getI12() + slope * (i - prevIndex));
|
||||||
data.get(i).setI13(data.get(prevIndex).getI13() + slope * (i - prevIndex));
|
v.get(i).setI13(v.get(prevIndex).getI13() + slope * (i - prevIndex));
|
||||||
data.get(i).setI14(data.get(prevIndex).getI14() + slope * (i - prevIndex));
|
v.get(i).setI14(v.get(prevIndex).getI14() + slope * (i - prevIndex));
|
||||||
data.get(i).setI15(data.get(prevIndex).getI15() + slope * (i - prevIndex));
|
v.get(i).setI15(v.get(prevIndex).getI15() + slope * (i - prevIndex));
|
||||||
data.get(i).setI16(data.get(prevIndex).getI16() + slope * (i - prevIndex));
|
v.get(i).setI16(v.get(prevIndex).getI16() + slope * (i - prevIndex));
|
||||||
data.get(i).setI17(data.get(prevIndex).getI17() + slope * (i - prevIndex));
|
v.get(i).setI17(v.get(prevIndex).getI17() + slope * (i - prevIndex));
|
||||||
data.get(i).setI18(data.get(prevIndex).getI18() + slope * (i - prevIndex));
|
v.get(i).setI18(v.get(prevIndex).getI18() + slope * (i - prevIndex));
|
||||||
data.get(i).setI19(data.get(prevIndex).getI19() + slope * (i - prevIndex));
|
v.get(i).setI19(v.get(prevIndex).getI19() + slope * (i - prevIndex));
|
||||||
data.get(i).setI20(data.get(prevIndex).getI20() + slope * (i - prevIndex));
|
v.get(i).setI20(v.get(prevIndex).getI20() + slope * (i - prevIndex));
|
||||||
data.get(i).setI21(data.get(prevIndex).getI21() + slope * (i - prevIndex));
|
v.get(i).setI21(v.get(prevIndex).getI21() + slope * (i - prevIndex));
|
||||||
data.get(i).setI22(data.get(prevIndex).getI22() + slope * (i - prevIndex));
|
v.get(i).setI22(v.get(prevIndex).getI22() + slope * (i - prevIndex));
|
||||||
data.get(i).setI23(data.get(prevIndex).getI23() + slope * (i - prevIndex));
|
v.get(i).setI23(v.get(prevIndex).getI23() + slope * (i - prevIndex));
|
||||||
data.get(i).setI24(data.get(prevIndex).getI24() + slope * (i - prevIndex));
|
v.get(i).setI24(v.get(prevIndex).getI24() + slope * (i - prevIndex));
|
||||||
data.get(i).setI25(data.get(prevIndex).getI25() + slope * (i - prevIndex));
|
v.get(i).setI25(v.get(prevIndex).getI25() + slope * (i - prevIndex));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
data.get(i).setI2(DEFAULTVALUE);
|
v.get(i).setI2(DEFAULTVALUE);
|
||||||
data.get(i).setI3(DEFAULTVALUE);
|
v.get(i).setI3(DEFAULTVALUE);
|
||||||
data.get(i).setI4(DEFAULTVALUE);
|
v.get(i).setI4(DEFAULTVALUE);
|
||||||
data.get(i).setI5(DEFAULTVALUE);
|
v.get(i).setI5(DEFAULTVALUE);
|
||||||
data.get(i).setI6(DEFAULTVALUE);
|
v.get(i).setI6(DEFAULTVALUE);
|
||||||
data.get(i).setI7(DEFAULTVALUE);
|
v.get(i).setI7(DEFAULTVALUE);
|
||||||
data.get(i).setI8(DEFAULTVALUE);
|
v.get(i).setI8(DEFAULTVALUE);
|
||||||
data.get(i).setI9(DEFAULTVALUE);
|
v.get(i).setI9(DEFAULTVALUE);
|
||||||
data.get(i).setI10(DEFAULTVALUE);
|
v.get(i).setI10(DEFAULTVALUE);
|
||||||
data.get(i).setI11(DEFAULTVALUE);
|
v.get(i).setI11(DEFAULTVALUE);
|
||||||
data.get(i).setI12(DEFAULTVALUE);
|
v.get(i).setI12(DEFAULTVALUE);
|
||||||
data.get(i).setI13(DEFAULTVALUE);
|
v.get(i).setI13(DEFAULTVALUE);
|
||||||
data.get(i).setI14(DEFAULTVALUE);
|
v.get(i).setI14(DEFAULTVALUE);
|
||||||
data.get(i).setI15(DEFAULTVALUE);
|
v.get(i).setI15(DEFAULTVALUE);
|
||||||
data.get(i).setI16(DEFAULTVALUE);
|
v.get(i).setI16(DEFAULTVALUE);
|
||||||
data.get(i).setI17(DEFAULTVALUE);
|
v.get(i).setI17(DEFAULTVALUE);
|
||||||
data.get(i).setI18(DEFAULTVALUE);
|
v.get(i).setI18(DEFAULTVALUE);
|
||||||
data.get(i).setI19(DEFAULTVALUE);
|
v.get(i).setI19(DEFAULTVALUE);
|
||||||
data.get(i).setI20(DEFAULTVALUE);
|
v.get(i).setI20(DEFAULTVALUE);
|
||||||
data.get(i).setI21(DEFAULTVALUE);
|
v.get(i).setI21(DEFAULTVALUE);
|
||||||
data.get(i).setI22(DEFAULTVALUE);
|
v.get(i).setI22(DEFAULTVALUE);
|
||||||
data.get(i).setI23(DEFAULTVALUE);
|
v.get(i).setI23(DEFAULTVALUE);
|
||||||
data.get(i).setI24(DEFAULTVALUE);
|
v.get(i).setI24(DEFAULTVALUE);
|
||||||
data.get(i).setI25(DEFAULTVALUE);
|
v.get(i).setI25(DEFAULTVALUE);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ public class ResponsibilityAlgorithm {
|
|||||||
//EK计算,用于后续计算FK(不含背景的用户责任指标)、HK(包含背景的用户责任指标)
|
//EK计算,用于后续计算FK(不含背景的用户责任指标)、HK(包含背景的用户责任指标)
|
||||||
//float **EKarr = (float **)malloc(TL * sizeof(float *));//先申请P个指针型字节的空间
|
//float **EKarr = (float **)malloc(TL * sizeof(float *));//先申请P个指针型字节的空间
|
||||||
//for (int i = 0; i < TL; i++)
|
//for (int i = 0; i < TL; i++)
|
||||||
//EKarr[i] = (float *)malloc(TL * sizeof(float));
|
//EKarr[i] = (float *)malloc(TL * Float.SIZE / Byte.SIZE);
|
||||||
|
|
||||||
float[][] EKarr;
|
float[][] EKarr;
|
||||||
EKarr = dyEKCom(simCor, Pdata, width, P, TL);
|
EKarr = dyEKCom(simCor, Pdata, width, P, TL);
|
||||||
@@ -303,7 +303,7 @@ public class ResponsibilityAlgorithm {
|
|||||||
//不含背景的用户谐波责任指标
|
//不含背景的用户谐波责任指标
|
||||||
//float **FKarr = (float **)malloc(TL * sizeof(float *));//先申请P个指针型字节的空间
|
//float **FKarr = (float **)malloc(TL * sizeof(float *));//先申请P个指针型字节的空间
|
||||||
//for (int i = 0; i < TL; i++)
|
//for (int i = 0; i < TL; i++)
|
||||||
//FKarr[i] = (float *)malloc(TL * sizeof(float));
|
//FKarr[i] = (float *)malloc(TL * Float.SIZE / Byte.SIZE);
|
||||||
float[][] FKarr;
|
float[][] FKarr;
|
||||||
FKarr = DyFKCom(EKdata, width, P, TL);
|
FKarr = DyFKCom(EKdata, width, P, TL);
|
||||||
RealMatrix FKdata = MatrixUtils.createRealMatrix(slcorlength, P);
|
RealMatrix FKdata = MatrixUtils.createRealMatrix(slcorlength, P);
|
||||||
@@ -316,7 +316,7 @@ public class ResponsibilityAlgorithm {
|
|||||||
//包含背景的谐波责任指标
|
//包含背景的谐波责任指标
|
||||||
//float **HKarr = (float **)malloc(TL * sizeof(float *));//先申请P个指针型字节的空间
|
//float **HKarr = (float **)malloc(TL * sizeof(float *));//先申请P个指针型字节的空间
|
||||||
//for (int i = 0; i < TL; i++)
|
//for (int i = 0; i < TL; i++)
|
||||||
//HKarr[i] = (float *)malloc(TL * sizeof(float));
|
//HKarr[i] = (float *)malloc(TL * Float.SIZE / Byte.SIZE);
|
||||||
float[][] HKarr;
|
float[][] HKarr;
|
||||||
HKarr = DyHKCom(bjCore, EKdata, width, P, TL);
|
HKarr = DyHKCom(bjCore, EKdata, width, P, TL);
|
||||||
RealMatrix HKdata = MatrixUtils.createRealMatrix(slcorlength, (P + 1));
|
RealMatrix HKdata = MatrixUtils.createRealMatrix(slcorlength, (P + 1));
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
package com.njcn.auth.controller;
|
package com.njcn.auth.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
import com.nimbusds.jose.jwk.JWKSet;
|
import com.nimbusds.jose.jwk.JWKSet;
|
||||||
import com.nimbusds.jose.jwk.RSAKey;
|
import com.nimbusds.jose.jwk.RSAKey;
|
||||||
import com.njcn.auth.service.UserTokenService;
|
import com.njcn.auth.service.UserTokenService;
|
||||||
|
import com.njcn.auth.utils.AuthPubUtil;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.constant.OperateType;
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||||
import com.njcn.common.pojo.dto.UserTokenInfo;
|
import com.njcn.common.pojo.dto.UserTokenInfo;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
import com.njcn.common.utils.sm.DesUtils;
|
import com.njcn.common.utils.sm.DesUtils;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
|
import com.njcn.user.api.PassWordRuleFeugnClient;
|
||||||
import com.njcn.user.api.UserFeignClient;
|
import com.njcn.user.api.UserFeignClient;
|
||||||
|
import com.njcn.user.enums.UserResponseEnum;
|
||||||
|
import com.njcn.user.pojo.po.UserStrategy;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import com.njcn.web.utils.RequestUtil;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import com.njcn.web.utils.RestTemplateUtil;
|
import com.njcn.web.utils.RestTemplateUtil;
|
||||||
@@ -39,6 +46,7 @@ import java.security.interfaces.RSAPublicKey;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
@@ -59,11 +67,13 @@ public class AuthController extends BaseController {
|
|||||||
|
|
||||||
private final UserFeignClient userFeignClient;
|
private final UserFeignClient userFeignClient;
|
||||||
|
|
||||||
|
private final PassWordRuleFeugnClient passWordRuleFeugnClient;
|
||||||
|
|
||||||
private final UserTokenService userTokenService;
|
private final UserTokenService userTokenService;
|
||||||
|
|
||||||
|
|
||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.AUTHENTICATE)
|
@OperateInfo(info = LogEnum.SYSTEM_SERIOUS, operateType = OperateType.AUTHENTICATE)
|
||||||
@ApiOperation("登录认证")
|
@ApiOperation("登录认证")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = SecurityConstants.GRANT_TYPE, defaultValue = "password", value = "授权模式", required = true),
|
@ApiImplicitParam(name = SecurityConstants.GRANT_TYPE, defaultValue = "password", value = "授权模式", required = true),
|
||||||
@@ -80,6 +90,8 @@ public class AuthController extends BaseController {
|
|||||||
public Object postAccessToken(@ApiIgnore Principal principal, @RequestParam @ApiIgnore Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
|
public Object postAccessToken(@ApiIgnore Principal principal, @RequestParam @ApiIgnore Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
|
||||||
String methodDescribe = getMethodDescribe("postAccessToken");
|
String methodDescribe = getMethodDescribe("postAccessToken");
|
||||||
String username = parameters.get(SecurityConstants.USERNAME);
|
String username = parameters.get(SecurityConstants.USERNAME);
|
||||||
|
|
||||||
|
|
||||||
String grantType = parameters.get(SecurityConstants.GRANT_TYPE);
|
String grantType = parameters.get(SecurityConstants.GRANT_TYPE);
|
||||||
if (grantType.equalsIgnoreCase(SecurityConstants.GRANT_CAPTCHA) || grantType.equalsIgnoreCase(SecurityConstants.REFRESH_TOKEN_KEY)) {
|
if (grantType.equalsIgnoreCase(SecurityConstants.GRANT_CAPTCHA) || grantType.equalsIgnoreCase(SecurityConstants.REFRESH_TOKEN_KEY)) {
|
||||||
username = DesUtils.aesDecrypt(username);
|
username = DesUtils.aesDecrypt(username);
|
||||||
@@ -87,6 +99,28 @@ public class AuthController extends BaseController {
|
|||||||
//短信方式登录,将手机号赋值为用户名
|
//短信方式登录,将手机号赋值为用户名
|
||||||
username = parameters.get(SecurityConstants.PHONE);
|
username = parameters.get(SecurityConstants.PHONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//判断当前登录是否超过最大并发数
|
||||||
|
UserStrategy data = passWordRuleFeugnClient.getUserStrategy().getData();
|
||||||
|
String onlineUserKey = SecurityConstants.TOKEN_ONLINE_PREFIX;
|
||||||
|
List<UserTokenInfo> onLineUser = (List<UserTokenInfo>) redisUtil.getLikeListAllValues(onlineUserKey);
|
||||||
|
if(CollectionUtil.isNotEmpty(onLineUser)){
|
||||||
|
String finalUsername = username;
|
||||||
|
onLineUser = onLineUser.stream().filter(item->{
|
||||||
|
JSONObject jsonObject = AuthPubUtil.getLoginByToken(item.getRefreshToken());
|
||||||
|
String login = jsonObject.getStr(SecurityConstants.USER_NAME_KEY);
|
||||||
|
long exp = Long.parseLong(jsonObject.getStr(SecurityConstants.JWT_EXP));
|
||||||
|
long now = Calendar.getInstance().getTimeInMillis()/1000;
|
||||||
|
return (exp > now) && !login.equals(finalUsername);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer maxNum = data.getMaxNum();
|
||||||
|
if((CollectionUtil.isNotEmpty(onLineUser)?onLineUser.size():0)>=maxNum){
|
||||||
|
throw new BusinessException(UserResponseEnum.LOGIN_USER_OVERLIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (grantType.equalsIgnoreCase(SecurityConstants.REFRESH_TOKEN_KEY)) {
|
if (grantType.equalsIgnoreCase(SecurityConstants.REFRESH_TOKEN_KEY)) {
|
||||||
//如果是刷新token,需要去黑名单校验
|
//如果是刷新token,需要去黑名单校验
|
||||||
userTokenService.judgeRefreshToken(parameters.get(SecurityConstants.REFRESH_TOKEN_KEY));
|
userTokenService.judgeRefreshToken(parameters.get(SecurityConstants.REFRESH_TOKEN_KEY));
|
||||||
@@ -106,6 +140,7 @@ public class AuthController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_SERIOUS, operateType = OperateType.LOGOUT)
|
||||||
@ApiOperation("用户登出系统")
|
@ApiOperation("用户登出系统")
|
||||||
@DeleteMapping("/logout")
|
@DeleteMapping("/logout")
|
||||||
public HttpResult<Object> logout() {
|
public HttpResult<Object> logout() {
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ public class UserTokenService {
|
|||||||
redisUtil.saveByKeyWithExpire(onlineUserKey, userTokenInfo, refreshLifeTime.plusMinutes(5L).toEpochSecond(ZoneOffset.of("+8")) - LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
|
redisUtil.saveByKeyWithExpire(onlineUserKey, userTokenInfo, refreshLifeTime.plusMinutes(5L).toEpochSecond(ZoneOffset.of("+8")) - LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
|
||||||
|
|
||||||
//记录成功登录后的信息
|
//记录成功登录后的信息
|
||||||
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, nickName, ip, "登录认证", OperateType.AUTHENTICATE, 1, "", 0, 1, generalInfo.getMicroServiceName(), userIndex,LocalDateTime.now());
|
//LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, nickName, ip, "登录认证", OperateType.AUTHENTICATE, 1, "", 0, 1, generalInfo.getMicroServiceName(), userIndex,LocalDateTime.now());
|
||||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
//publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.njcn.auth.utils;
|
package com.njcn.auth.utils;
|
||||||
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import okhttp3.*;
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.nimbusds.jose.JWSObject;
|
||||||
|
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -28,4 +31,13 @@ public class AuthPubUtil {
|
|||||||
return String.join("", textList);
|
return String.join("", textList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public static JSONObject getLoginByToken(String token){
|
||||||
|
JWSObject jwsObject = JWSObject.parse(token);
|
||||||
|
String payload = jwsObject.getPayload().toString();
|
||||||
|
JSONObject jsonObject = JSONUtil.parseObj(payload);
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 不通过流程任务的 Request VO")
|
@Schema(description = "管理后台 - 不通过流程任务的 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@@ -21,4 +22,9 @@ public class BpmTaskRejectParam {
|
|||||||
@NotBlank(message = "审批意见不能为空")
|
@NotBlank(message = "审批意见不能为空")
|
||||||
private String reason;
|
private String reason;
|
||||||
|
|
||||||
|
@ApiModelProperty("抄送的用户编号数组")
|
||||||
|
private Collection<String> copyUserIds;
|
||||||
|
|
||||||
|
@ApiModelProperty("变量实例(动态表单)")
|
||||||
|
private Map<String, Object> variables;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.njcn.bpm.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.bpm.pojo.dto.BpmInstanceInfo;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统筹流程实例的公共方案
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2024年06月12日 18:14
|
||||||
|
*/
|
||||||
|
public interface IBpmReasonService<T> extends IService<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据业务id实时更新当前业务流程状态
|
||||||
|
* @param businessId 实际业务id
|
||||||
|
* @param status 流程实例当前状态,具体参考BpmTaskStatusEnum枚举
|
||||||
|
*/
|
||||||
|
void updateProcessStatus(String businessId,String reason, Integer status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据业务id获取历史审批id以及该任务的重要信息
|
||||||
|
* @param businessId 业务流程id
|
||||||
|
*/
|
||||||
|
BpmInstanceInfo getInstanceInfo(String businessId);
|
||||||
|
}
|
||||||
@@ -35,6 +35,12 @@ public class BpmProcessInstanceStatusEvent extends ApplicationEvent {
|
|||||||
*/
|
*/
|
||||||
private String businessKey;
|
private String businessKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核消息
|
||||||
|
* 例如说,请假
|
||||||
|
*/
|
||||||
|
private String reason;
|
||||||
|
|
||||||
public BpmProcessInstanceStatusEvent(Object source) {
|
public BpmProcessInstanceStatusEvent(Object source) {
|
||||||
super(source);
|
super(source);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class BpmSupervisionStatusListener implements ApplicationListener<BpmPro
|
|||||||
* @param event 事件
|
* @param event 事件
|
||||||
*/
|
*/
|
||||||
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
||||||
businessCommonFeignClient.updateProcessStatus(event.getProcessDefinitionKey(),event.getBusinessKey(), event.getStatus());
|
businessCommonFeignClient.updateProcessStatus(event.getProcessDefinitionKey(),event.getBusinessKey(),event.getReason(), event.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
|
|||||||
import com.njcn.bpm.pojo.dto.PageResult;
|
import com.njcn.bpm.pojo.dto.PageResult;
|
||||||
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
||||||
import com.njcn.bpm.pojo.param.instance.BpmProcessInstancePageParam;
|
import com.njcn.bpm.pojo.param.instance.BpmProcessInstancePageParam;
|
||||||
|
import com.njcn.bpm.pojo.param.task.BpmTaskRejectParam;
|
||||||
|
import org.flowable.engine.TaskService;
|
||||||
import org.flowable.engine.delegate.event.FlowableCancelledEvent;
|
import org.flowable.engine.delegate.event.FlowableCancelledEvent;
|
||||||
import org.flowable.engine.history.HistoricProcessInstance;
|
import org.flowable.engine.history.HistoricProcessInstance;
|
||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
@@ -146,6 +148,13 @@ public interface IBpmProcessInstanceService {
|
|||||||
*/
|
*/
|
||||||
void updateProcessInstanceReject(String id, String reason);
|
void updateProcessInstanceReject(String id, String reason);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新 ProcessInstance 拓展记录为不通过
|
||||||
|
*
|
||||||
|
* @param id 流程编号
|
||||||
|
* @param reason 理由。例如说,审批不通过时,需要传递该值
|
||||||
|
*/
|
||||||
|
void updateProcessInstanceFromReject(String id, String reason, TaskService taskService, BpmTaskRejectParam bpmTaskRejectParam);
|
||||||
/**
|
/**
|
||||||
* 用于测试过程删除流程,正式环境慎用
|
* 用于测试过程删除流程,正式环境慎用
|
||||||
* @author cdf
|
* @author cdf
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.bpm.service.task.impl;
|
package com.njcn.bpm.service.task.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@@ -13,6 +14,7 @@ import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
|
|||||||
import com.njcn.bpm.pojo.dto.PageResult;
|
import com.njcn.bpm.pojo.dto.PageResult;
|
||||||
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
||||||
import com.njcn.bpm.pojo.param.instance.BpmProcessInstancePageParam;
|
import com.njcn.bpm.pojo.param.instance.BpmProcessInstancePageParam;
|
||||||
|
import com.njcn.bpm.pojo.param.task.BpmTaskRejectParam;
|
||||||
import com.njcn.bpm.service.IBpmProcessDefinitionService;
|
import com.njcn.bpm.service.IBpmProcessDefinitionService;
|
||||||
import com.njcn.bpm.service.task.IBpmProcessInstanceService;
|
import com.njcn.bpm.service.task.IBpmProcessInstanceService;
|
||||||
import com.njcn.bpm.strategy.BpmTaskCandidateStartUserSelectStrategy;
|
import com.njcn.bpm.strategy.BpmTaskCandidateStartUserSelectStrategy;
|
||||||
@@ -30,6 +32,7 @@ import org.flowable.bpmn.model.UserTask;
|
|||||||
import org.flowable.common.engine.impl.identity.Authentication;
|
import org.flowable.common.engine.impl.identity.Authentication;
|
||||||
import org.flowable.engine.HistoryService;
|
import org.flowable.engine.HistoryService;
|
||||||
import org.flowable.engine.RuntimeService;
|
import org.flowable.engine.RuntimeService;
|
||||||
|
import org.flowable.engine.TaskService;
|
||||||
import org.flowable.engine.delegate.event.FlowableCancelledEvent;
|
import org.flowable.engine.delegate.event.FlowableCancelledEvent;
|
||||||
import org.flowable.engine.history.HistoricProcessInstance;
|
import org.flowable.engine.history.HistoricProcessInstance;
|
||||||
import org.flowable.engine.repository.ProcessDefinition;
|
import org.flowable.engine.repository.ProcessDefinition;
|
||||||
@@ -72,7 +75,7 @@ public class BpmProcessInstanceServiceImpl implements IBpmProcessInstanceService
|
|||||||
@Resource
|
@Resource
|
||||||
private IBpmProcessDefinitionService processDefinitionService;
|
private IBpmProcessDefinitionService processDefinitionService;
|
||||||
|
|
||||||
// @Resource
|
// @Resource
|
||||||
// private BpmMessageService messageService;
|
// private BpmMessageService messageService;
|
||||||
//
|
//
|
||||||
@Resource
|
@Resource
|
||||||
@@ -90,7 +93,6 @@ public class BpmProcessInstanceServiceImpl implements IBpmProcessInstanceService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProcessInstance> getProcessInstances(Set<String> ids) {
|
public List<ProcessInstance> getProcessInstances(Set<String> ids) {
|
||||||
return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list();
|
return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list();
|
||||||
@@ -285,18 +287,30 @@ public class BpmProcessInstanceServiceImpl implements IBpmProcessInstanceService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateProcessInstanceWhenApprove(ProcessInstance instance) {
|
public void updateProcessInstanceWhenApprove(ProcessInstance instance) {
|
||||||
|
//判断传入参数是否是,不通过信息不通过则需要更新流程信息为不通过
|
||||||
|
Integer processInstanceStatus = BpmProcessInstanceStatusEnum.APPROVE.getStatus();
|
||||||
|
Map<String, Object> processVariables = instance.getProcessVariables();
|
||||||
|
if (processVariables.containsKey(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS)) {
|
||||||
|
Integer stata =Integer.valueOf(processVariables.get(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS).toString());
|
||||||
|
if (BpmProcessInstanceStatusEnum.REJECT.getStatus()==stata) {
|
||||||
|
processInstanceStatus = BpmProcessInstanceStatusEnum.REJECT.getStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
// 1. 更新流程实例 status
|
// 1. 更新流程实例 status
|
||||||
runtimeService.setVariable(instance.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS,
|
runtimeService.setVariable(instance.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS,
|
||||||
BpmProcessInstanceStatusEnum.APPROVE.getStatus());
|
processInstanceStatus);
|
||||||
|
|
||||||
// 2. 发送流程被【通过】的消息
|
// 2. 发送流程被【通过】的消息
|
||||||
// messageService.sendMessageWhenProcessInstanceApprove(BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceApproveMessage(instance));
|
// messageService.sendMessageWhenProcessInstanceApprove(BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceApproveMessage(instance));
|
||||||
|
|
||||||
// 3. 发送流程实例的状态事件
|
// 3. 发送流程实例的状态事件
|
||||||
// 注意:此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance
|
// 注意:此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance
|
||||||
|
// 在审核不通过时,会触该信息,设置在审核通过时,才发送
|
||||||
|
if(BpmProcessInstanceStatusEnum.APPROVE.getStatus()==processInstanceStatus){
|
||||||
HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId());
|
HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId());
|
||||||
processInstanceEventPublisher.sendProcessInstanceResultEvent(
|
processInstanceEventPublisher.sendProcessInstanceResultEvent(
|
||||||
BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, BpmProcessInstanceStatusEnum.APPROVE.getStatus()));
|
BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, processInstanceStatus));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -314,7 +328,31 @@ public class BpmProcessInstanceServiceImpl implements IBpmProcessInstanceService
|
|||||||
|
|
||||||
// 4. 发送流程实例的状态事件
|
// 4. 发送流程实例的状态事件
|
||||||
processInstanceEventPublisher.sendProcessInstanceResultEvent(
|
processInstanceEventPublisher.sendProcessInstanceResultEvent(
|
||||||
BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, BpmProcessInstanceStatusEnum.REJECT.getStatus()));
|
BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, reason, BpmProcessInstanceStatusEnum.REJECT.getStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateProcessInstanceFromReject(String id, String reason, TaskService taskService, BpmTaskRejectParam bpmTaskRejectParam) {
|
||||||
|
// 1. 更新流程实例 status
|
||||||
|
runtimeService.setVariable(id, BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, BpmProcessInstanceStatusEnum.REJECT.getStatus());
|
||||||
|
|
||||||
|
// 2. 删除流程实例,以实现驳回任务时,取消整个审批流程
|
||||||
|
ProcessInstance processInstance = getProcessInstance(id);
|
||||||
|
// 3.3 调用 BPM complete 去完成任务
|
||||||
|
// 其中,variables 是存储动态表单到 local 任务级别。过滤一下,避免 ProcessInstance 系统级的变量被占用
|
||||||
|
if (CollectionUtil.isNotEmpty(bpmTaskRejectParam.getVariables())) {
|
||||||
|
Map<String, Object> variables = FlowableUtils.filterTaskFormVariable(bpmTaskRejectParam.getVariables());
|
||||||
|
taskService.complete(bpmTaskRejectParam.getId(), variables, true);
|
||||||
|
} else {
|
||||||
|
taskService.complete(bpmTaskRejectParam.getId());
|
||||||
|
}
|
||||||
|
//这是删除所有信息,
|
||||||
|
// deleteProcessInstance(id, StrUtil.format(BpmDeleteReasonEnum.REJECT_TASK.format(reason)));
|
||||||
|
// 4. 发送流程实例的状态事件
|
||||||
|
processInstanceEventPublisher.sendProcessInstanceResultEvent(
|
||||||
|
BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, reason, BpmProcessInstanceStatusEnum.REJECT.getStatus()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteProcessInstance(String id, String reason) {
|
public void deleteProcessInstance(String id, String reason) {
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ public class BpmTaskServiceImpl implements IBpmTaskService {
|
|||||||
BpmCommentTypeEnum.REJECT.formatComment(bpmTaskRejectParam.getReason()));
|
BpmCommentTypeEnum.REJECT.formatComment(bpmTaskRejectParam.getReason()));
|
||||||
|
|
||||||
// 3. 更新流程实例,审批不通过!
|
// 3. 更新流程实例,审批不通过!
|
||||||
processInstanceService.updateProcessInstanceReject(instance.getProcessInstanceId(), bpmTaskRejectParam.getReason());
|
processInstanceService.updateProcessInstanceFromReject(instance.getProcessInstanceId(), bpmTaskRejectParam.getReason(), taskService, bpmTaskRejectParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -105,12 +105,13 @@ public interface BpmProcessInstanceConvert {
|
|||||||
return bpmProcessInstanceStatusEvent;
|
return bpmProcessInstanceStatusEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
default BpmProcessInstanceStatusEvent buildProcessInstanceStatusEvent(Object source, ProcessInstance instance, Integer status) {
|
default BpmProcessInstanceStatusEvent buildProcessInstanceStatusEvent(Object source, ProcessInstance instance,String reason, Integer status) {
|
||||||
BpmProcessInstanceStatusEvent bpmProcessInstanceStatusEvent = new BpmProcessInstanceStatusEvent(source);
|
BpmProcessInstanceStatusEvent bpmProcessInstanceStatusEvent = new BpmProcessInstanceStatusEvent(source);
|
||||||
bpmProcessInstanceStatusEvent.setId(instance.getId());
|
bpmProcessInstanceStatusEvent.setId(instance.getId());
|
||||||
bpmProcessInstanceStatusEvent.setStatus(status);
|
bpmProcessInstanceStatusEvent.setStatus(status);
|
||||||
bpmProcessInstanceStatusEvent.setProcessDefinitionKey(instance.getProcessDefinitionKey());
|
bpmProcessInstanceStatusEvent.setProcessDefinitionKey(instance.getProcessDefinitionKey());
|
||||||
bpmProcessInstanceStatusEvent.setBusinessKey(instance.getBusinessKey());
|
bpmProcessInstanceStatusEvent.setBusinessKey(instance.getBusinessKey());
|
||||||
|
bpmProcessInstanceStatusEvent.setReason(reason);
|
||||||
return bpmProcessInstanceStatusEvent;
|
return bpmProcessInstanceStatusEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,18 +21,17 @@ public class GenerateCode {
|
|||||||
|
|
||||||
private static final String TARGET_DIR = "D://code";
|
private static final String TARGET_DIR = "D://code";
|
||||||
|
|
||||||
private static final String DB_URL = "jdbc:mysql://192.168.1.24:13306/pqsinfo_jb";
|
private static final String DB_URL = "jdbc:mysql://127.0.0.1:3306/pqsinfo";
|
||||||
// private static final String DB_URL = "jdbc:oracle:thin:@192.168.1.170:1521:pqsbase";
|
// private static final String DB_URL = "jdbc:oracle:thin:@192.168.1.170:1521:pqsbase";
|
||||||
|
|
||||||
private static final String USERNAME = "root";
|
private static final String USERNAME = "root";
|
||||||
|
|
||||||
private static final String PASSWORD = "njcnpqs";
|
private static final String PASSWORD = "123456";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
List<Module> modules = Stream.of(
|
List<Module> modules = Stream.of(
|
||||||
new Module("hongawen", "com.njcn.supervision", "survey", Stream.of(
|
new Module("xy", "com.njcn.supervision", "survey", Stream.of(
|
||||||
"supervision_survey_plan",
|
"supervision_line_warning"
|
||||||
"supervision_survey_test"
|
|
||||||
).collect(Collectors.toList()), "supervision_")
|
).collect(Collectors.toList()), "supervision_")
|
||||||
).collect(Collectors.toList());
|
).collect(Collectors.toList());
|
||||||
generateJavaFile(modules);
|
generateJavaFile(modules);
|
||||||
|
|||||||
@@ -103,12 +103,18 @@ public enum CommonResponseEnum {
|
|||||||
|
|
||||||
ADVANCE_RESPONSE_ENUM("A00105", "终端响应枚举类型"),
|
ADVANCE_RESPONSE_ENUM("A00105", "终端响应枚举类型"),
|
||||||
|
|
||||||
|
DYNAMIC_RESPONSE_ENUM("A00002", "动态枚举内容"),
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
private final String message;
|
private String message;
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
CommonResponseEnum(String code, String message) {
|
CommonResponseEnum(String code, String message) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class DataTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
InfluxDbUtils influxDBUtil = new InfluxDbUtils("admin", "123456", "http://192.168.1.18:8086", "pqsbase_sjzx", "");
|
InfluxDbUtils influxDBUtil = new InfluxDbUtils("root", "123456", "http://127.0.0.1:8086", "pqsadmin_jb", "");
|
||||||
|
|
||||||
insert(influxDBUtil);
|
insert(influxDBUtil);
|
||||||
}
|
}
|
||||||
@@ -72,16 +72,88 @@ public class DataTest {
|
|||||||
|
|
||||||
//单条数据插入
|
//单条数据插入
|
||||||
public static void insert(InfluxDbUtils influxDBUtil) {
|
public static void insert(InfluxDbUtils influxDBUtil) {
|
||||||
|
|
||||||
|
// Map<String, String> tags = new HashMap<>();
|
||||||
|
// long time = Long.parseLong("1719921600000");
|
||||||
|
// tags.put("line_id", "82a9bad93e784c37135db4589794e6b0");
|
||||||
|
// tags.put("phasic_type", "A");
|
||||||
|
// tags.put("value_type","CP95");
|
||||||
|
// tags.put("quality_flag","0");
|
||||||
|
//
|
||||||
|
// Map<String, Object> fields = new HashMap<>();
|
||||||
|
// fields.put("i_2",0);
|
||||||
|
// fields.put("i_3",0);
|
||||||
|
// fields.put("i_4",0);
|
||||||
|
// fields.put("i_5",6.02);
|
||||||
|
// fields.put("i_6",0);
|
||||||
|
// fields.put("i_7",0);
|
||||||
|
// fields.put("i_8",0);
|
||||||
|
// fields.put("i_9",0);
|
||||||
|
// fields.put("i_10",0);
|
||||||
|
// fields.put("i_11",0);
|
||||||
|
// fields.put("i_12",0);
|
||||||
|
// fields.put("i_13",0);
|
||||||
|
// fields.put("i_14",0);
|
||||||
|
// fields.put("i_15",3.25);
|
||||||
|
// fields.put("i_16",0);
|
||||||
|
// fields.put("i_17",0);
|
||||||
|
// fields.put("i_18",0);
|
||||||
|
// fields.put("i_19",0);
|
||||||
|
// fields.put("i_20",0);
|
||||||
|
// fields.put("i_21",0);
|
||||||
|
// fields.put("i_22",0);
|
||||||
|
// fields.put("i_23",0);
|
||||||
|
// fields.put("i_24",3.52);
|
||||||
|
// fields.put("i_25",0);
|
||||||
|
// influxDBUtil.insert("data_i", tags, fields, time, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
Map<String, String> tags = new HashMap<>();
|
Map<String, String> tags = new HashMap<>();
|
||||||
long time = Long.parseLong("1675958400000");
|
long time = Long.parseLong("1719842400000");
|
||||||
tags.put("dev_id", "57d121d45a26f3cc1d7b6ba541f895c0");
|
tags.put("line_id", "ebdf6cbc275c5d7ed8104fcb3792fb0a");
|
||||||
|
tags.put("phasic_type", "A");
|
||||||
|
tags.put("value_type","CP95");
|
||||||
|
tags.put("quality_flag","0");
|
||||||
|
|
||||||
Map<String, Object> fields = new HashMap<>();
|
Map<String, Object> fields = new HashMap<>();
|
||||||
|
fields.put("v_1",10.0);
|
||||||
|
fields.put("v_2",0);
|
||||||
|
fields.put("v_3",0);
|
||||||
|
fields.put("v_4",0);
|
||||||
|
fields.put("v_5",6.02);
|
||||||
|
fields.put("v_6",0);
|
||||||
|
fields.put("v_7",0);
|
||||||
|
fields.put("v_8",0);
|
||||||
|
fields.put("v_9",0);
|
||||||
|
fields.put("v_10",0);
|
||||||
|
fields.put("v_11",0);
|
||||||
|
fields.put("v_12",0);
|
||||||
|
fields.put("v_13",0);
|
||||||
|
fields.put("v_14",0);
|
||||||
|
fields.put("v_15",3.25);
|
||||||
|
fields.put("v_16",0);
|
||||||
|
fields.put("v_17",0);
|
||||||
|
fields.put("v_18",0);
|
||||||
|
fields.put("v_19",0);
|
||||||
|
fields.put("v_20",0);
|
||||||
|
fields.put("v_21",0);
|
||||||
|
fields.put("v_22",0);
|
||||||
|
fields.put("v_23",0);
|
||||||
|
fields.put("v_24",3.52);
|
||||||
|
fields.put("v_25",0);
|
||||||
|
influxDBUtil.insert("data_inharm_v", tags, fields, time, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Map<String, String> tags = new HashMap<>();
|
||||||
|
// long time = Long.parseLong("1675958400000");
|
||||||
|
// tags.put("dev_id", "57d121d45a26f3cc1d7b6ba541f895c0");
|
||||||
|
// Map<String, Object> fields = new HashMap<>();
|
||||||
// fields.put("due",1440);
|
// fields.put("due",1440);
|
||||||
// fields.put("real",1200);
|
// fields.put("real",1200);
|
||||||
fields.put("online_min", 0);
|
// fields.put("online_min", 0);
|
||||||
fields.put("offline_min", 1440);
|
// fields.put("offline_min", 1440);
|
||||||
fields.put("online_rate", 0.0000);
|
// fields.put("online_rate", 0.0000);
|
||||||
influxDBUtil.insert("pqs_onlinerate", tags, fields, time, TimeUnit.MILLISECONDS);
|
// influxDBUtil.insert("pqs_onlinerate", tags, fields, time, TimeUnit.MILLISECONDS);
|
||||||
// long time = Long.parseLong("1655135328135");
|
// long time = Long.parseLong("1655135328135");
|
||||||
// Map<String, String> tags = new HashMap<>();
|
// Map<String, String> tags = new HashMap<>();
|
||||||
// // tags.put("line_id", "127fad1dcb0077ac2979141b8473a5e4");
|
// // tags.put("line_id", "127fad1dcb0077ac2979141b8473a5e4");
|
||||||
|
|||||||
@@ -51,7 +51,13 @@ public class FeignConfig {
|
|||||||
//对结果进行转换
|
//对结果进行转换
|
||||||
HttpResult<Object> result = PubUtils.json2obj(bodyStr, type);
|
HttpResult<Object> result = PubUtils.json2obj(bodyStr, type);
|
||||||
//如果返回错误,且为内部错误,则直接抛出异常
|
//如果返回错误,且为内部错误,则直接抛出异常
|
||||||
CommonResponseEnum commonResponseEnum = EnumUtils.getCommonResponseEnumByCode(result.getCode());
|
CommonResponseEnum commonResponseEnum;
|
||||||
|
if(result.getCode().equals(CommonResponseEnum.DYNAMIC_RESPONSE_ENUM.getCode())){
|
||||||
|
commonResponseEnum = CommonResponseEnum.DYNAMIC_RESPONSE_ENUM;
|
||||||
|
commonResponseEnum.setMessage(result.getMessage());
|
||||||
|
}else{
|
||||||
|
commonResponseEnum = EnumUtils.getCommonResponseEnumByCode(result.getCode());
|
||||||
|
}
|
||||||
switch (commonResponseEnum) {
|
switch (commonResponseEnum) {
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -84,10 +84,12 @@ public class LogServiceImpl implements ILogService {
|
|||||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
//推送审计消息功能
|
//推送审计消息功能
|
||||||
if(severity!=0){
|
if(severity!=0){
|
||||||
|
if(!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)){
|
||||||
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
//发送邮箱功能
|
//发送邮箱功能
|
||||||
if(severity==2&&logInfoDTO.getResult()==0){
|
if(severity==2&&logInfoDTO.getResult()==0){
|
||||||
publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
//publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//如果存在设备日志注解,则记录设备日志
|
//如果存在设备日志注解,则记录设备日志
|
||||||
@@ -167,10 +169,12 @@ public class LogServiceImpl implements ILogService {
|
|||||||
private void auditPush(Integer severity, LogInfoDTO logInfoDTO) {
|
private void auditPush(Integer severity, LogInfoDTO logInfoDTO) {
|
||||||
//推送审计消息功能
|
//推送审计消息功能
|
||||||
if(severity !=0){
|
if(severity !=0){
|
||||||
|
if(!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) {
|
||||||
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
//发送邮箱功能
|
//发送邮箱功能
|
||||||
if(severity ==2&& logInfoDTO.getResult()==0){
|
if (severity == 2 && logInfoDTO.getResult() == 0) {
|
||||||
publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
//publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.njcn.device.biz.pojo.dto;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,6 +31,16 @@ public class SubGetBase implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String voltageLevel;
|
private String voltageLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经度
|
||||||
|
*/
|
||||||
|
private BigDecimal lng;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 纬度
|
||||||
|
*/
|
||||||
|
private BigDecimal lat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门
|
* 部门
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.njcn.device.pq.api;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.device.pq.api.fallback.DeviceFeignClientFallbackFactory;
|
||||||
|
import com.njcn.device.pq.api.fallback.LineFeignClientFallbackFactory;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@FeignClient(
|
||||||
|
value = ServerInfo.DEVICE,
|
||||||
|
path = "/dev",
|
||||||
|
fallbackFactory = DeviceFeignClientFallbackFactory.class,
|
||||||
|
contextId = "dev")
|
||||||
|
public interface DeviceFeignClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 技术监督修改装置定检时间
|
||||||
|
*
|
||||||
|
* @param devId 监测点id
|
||||||
|
* @param thisTimeCheck 起始时间
|
||||||
|
* @param nextTimeCheck 结束时间
|
||||||
|
* @return 终端状态信息
|
||||||
|
*/
|
||||||
|
@PostMapping("/updateDevCheckTime")
|
||||||
|
@ApiOperation("技术监督修改装置定检时间")
|
||||||
|
HttpResult<String> updateDevCheckTime(@RequestParam("devId") String devId,
|
||||||
|
@RequestParam("thisTimeCheck") String thisTimeCheck,
|
||||||
|
@RequestParam("nextTimeCheck") String nextTimeCheck);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -353,4 +353,12 @@ public interface LineFeignClient {
|
|||||||
|
|
||||||
@PostMapping("/getReportLineInfo")
|
@PostMapping("/getReportLineInfo")
|
||||||
HttpResult<List<ReportLineInfoVo>> getReportLineInfo(@RequestBody List<String> ids);
|
HttpResult<List<ReportLineInfoVo>> getReportLineInfo(@RequestBody List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据监测点名称和电网侧变电站名称模糊搜索
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/getByName")
|
||||||
|
HttpResult<List<LineDetail>> getByName(@RequestParam("name") String name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import com.njcn.device.pq.pojo.param.SyncTerminalParam;
|
|||||||
import com.njcn.device.pq.pojo.po.Line;
|
import com.njcn.device.pq.pojo.po.Line;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
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.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -31,11 +33,23 @@ public interface TerminalBaseClient {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/getSubstationById")
|
@PostMapping("/getSubstationById")
|
||||||
HttpResult<List<Line>> getSubstationById(@RequestBody List<String> list);
|
HttpResult<List<Line>> getSubstationById(@RequestBody List<String> list);
|
||||||
/*
|
|
||||||
冀北技术监督台账同步
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 冀北技术监督台账同步
|
||||||
|
*/
|
||||||
@ApiOperation("终端/母线/监测点同步操作")
|
@ApiOperation("终端/母线/监测点同步操作")
|
||||||
@PostMapping("terminalSync")
|
@PostMapping("terminalSync")
|
||||||
HttpResult<String> terminalSync( @RequestBody SyncTerminalParam syncTerminalParam);
|
HttpResult<String> terminalSync( @RequestBody SyncTerminalParam syncTerminalParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点和装置同步成运行状态
|
||||||
|
*/
|
||||||
|
@GetMapping("/terminalSyncRunFly")
|
||||||
|
HttpResult<Boolean> terminalSyncRunFly(@RequestParam("lineId") String lineId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点信息删除
|
||||||
|
*/
|
||||||
|
@GetMapping("/terminalSyncDeleteFly")
|
||||||
|
HttpResult<Boolean> terminalSyncDeleteFly(@RequestParam("lineId") String lineId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.njcn.device.pq.api.fallback;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.device.biz.utils.DeviceEnumUtil;
|
||||||
|
import com.njcn.device.pq.api.DeviceFeignClient;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class DeviceFeignClientFallbackFactory implements FallbackFactory<DeviceFeignClient> {
|
||||||
|
@Override
|
||||||
|
public DeviceFeignClient create(Throwable throwable) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if (throwable.getCause() instanceof BusinessException) {
|
||||||
|
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||||
|
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new DeviceFeignClient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<String> updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "技术监督修改装置定检时间", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -281,6 +281,12 @@ public class LineFeignClientFallbackFactory implements FallbackFactory<LineFeign
|
|||||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点id获取预告警单基础信息: ", throwable.toString());
|
log.error("{}异常,降级处理,异常为:{}", "根据监测点id获取预告警单基础信息: ", throwable.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<List<LineDetail>> getByName(String name) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "根据监测点名称和电网侧变电站名称模糊搜索: ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,18 @@ public class TerminalBaseClientFallbackFactory implements FallbackFactory<Termin
|
|||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> terminalSyncRunFly(String lineId) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "监测点和装置同步成运行状态", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> terminalSyncDeleteFly(String lineId) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "监测点信息删除", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,15 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class LineDataQualityDTO {
|
public class LineDataQualityDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点id
|
||||||
|
*/
|
||||||
private String lineId;
|
private String lineId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点名称
|
||||||
|
*/
|
||||||
|
private String lineName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线率
|
* 在线率
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class DevDetail {
|
|||||||
private Integer comFlag;
|
private Integer comFlag;
|
||||||
|
|
||||||
@ApiModelProperty("定检时间")
|
@ApiModelProperty("定检时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
private LocalDate nextTimeCheck;
|
private LocalDate nextTimeCheck;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,4 +50,7 @@ public class ReportLineInfoVo implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty("超标天数")
|
@ApiModelProperty("超标天数")
|
||||||
private Integer overDays;
|
private Integer overDays;
|
||||||
|
|
||||||
|
@ApiModelProperty("电网标志(0-电网侧;1-非电网侧)")
|
||||||
|
private Integer powerFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,4 +167,13 @@ public class DeviceController extends BaseController {
|
|||||||
Console.log("string payload : {}", payload);
|
Console.log("string payload : {}", payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@PostMapping("/updateDevCheckTime")
|
||||||
|
@ApiOperation("技术监督修改装置定检时间")
|
||||||
|
public HttpResult<String> updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck) {
|
||||||
|
String methodDescribe = getMethodDescribe("updateDevCheckTime");
|
||||||
|
iDeviceService.updateDevCheckTime(devId,thisTimeCheck,nextTimeCheck);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -509,7 +509,6 @@ public class LineController extends BaseController {
|
|||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("根据装置部门和模糊搜索获取装置详情")
|
@ApiOperation("根据装置部门和模糊搜索获取装置详情")
|
||||||
@ApiImplicitParam(name = "id", value = "装置id", required = true)
|
|
||||||
@PostMapping("/getDeptDeviceDetailData")
|
@PostMapping("/getDeptDeviceDetailData")
|
||||||
HttpResult<List<LineDetailVO.Detail>> getDeptDeviceDetailData(@RequestBody DataParam param){
|
HttpResult<List<LineDetailVO.Detail>> getDeptDeviceDetailData(@RequestBody DataParam param){
|
||||||
String methodDescribe = getMethodDescribe("getDeptDeviceDetailData");
|
String methodDescribe = getMethodDescribe("getDeptDeviceDetailData");
|
||||||
@@ -534,4 +533,13 @@ public class LineController extends BaseController {
|
|||||||
List<ReportLineInfoVo> result = lineService.getReportLineInfo(ids);
|
List<ReportLineInfoVo> result = lineService.getReportLineInfo(ids);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@ApiOperation("根据监测点名称和电网侧变电站名称模糊搜索")
|
||||||
|
@PostMapping("/getByName")
|
||||||
|
HttpResult<List<LineDetail>> getByName(@RequestParam("name") String name){
|
||||||
|
String methodDescribe = getMethodDescribe("getByName");
|
||||||
|
List<LineDetail> list = lineService.getByName(name);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
import com.njcn.device.biz.enums.DeviceResponseEnum;
|
import com.njcn.device.biz.enums.DeviceResponseEnum;
|
||||||
import com.njcn.device.pq.mapper.LineDetailMapper;
|
|
||||||
import com.njcn.device.pq.mapper.LineMapper;
|
|
||||||
import com.njcn.device.pq.mapper.OverlimitMapper;
|
|
||||||
import com.njcn.device.pq.mapper.VoltageMapper;
|
|
||||||
import com.njcn.device.pq.pojo.bo.DeviceType;
|
import com.njcn.device.pq.pojo.bo.DeviceType;
|
||||||
import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
|
import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
|
||||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||||
@@ -27,7 +23,6 @@ import com.njcn.device.pq.pojo.vo.TerminalVO;
|
|||||||
import com.njcn.device.pq.service.TerminalBaseService;
|
import com.njcn.device.pq.service.TerminalBaseService;
|
||||||
import com.njcn.device.pq.service.impl.GeneralDeviceService;
|
import com.njcn.device.pq.service.impl.GeneralDeviceService;
|
||||||
import com.njcn.poi.util.PoiUtil;
|
import com.njcn.poi.util.PoiUtil;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -60,23 +55,6 @@ import java.util.stream.Stream;
|
|||||||
public class TerminalBaseController extends BaseController {
|
public class TerminalBaseController extends BaseController {
|
||||||
|
|
||||||
private final TerminalBaseService terminalBaseService;
|
private final TerminalBaseService terminalBaseService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final LineDetailMapper lineDetailMapper;
|
|
||||||
|
|
||||||
|
|
||||||
private final OverlimitMapper overlimitMapper;
|
|
||||||
|
|
||||||
|
|
||||||
private final DicDataFeignClient dicDataFeignClient;
|
|
||||||
|
|
||||||
|
|
||||||
private final LineMapper lineMapper;
|
|
||||||
|
|
||||||
|
|
||||||
private final VoltageMapper voltageMapper;
|
|
||||||
|
|
||||||
private final GeneralDeviceService generalDeviceService;
|
private final GeneralDeviceService generalDeviceService;
|
||||||
|
|
||||||
|
|
||||||
@@ -143,17 +121,34 @@ public class TerminalBaseController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("终端/母线/监测点同步操作")
|
@ApiOperation("变电站/终端/母线/监测点同步操作")
|
||||||
@OperateInfo(operateType = OperateType.ADD, info = LogEnum.BUSINESS_MEDIUM)
|
@OperateInfo(operateType = OperateType.ADD, info = LogEnum.BUSINESS_MEDIUM)
|
||||||
@PostMapping("terminalSync")
|
@PostMapping("terminalSync")
|
||||||
public HttpResult<String> terminalSync(@Valid @RequestBody SyncTerminalParam syncTerminalParam) {
|
public HttpResult<String> terminalSync(@Valid @RequestBody SyncTerminalParam syncTerminalParam) {
|
||||||
String methodDescribe = getMethodDescribe("terminalSync");
|
String methodDescribe = getMethodDescribe("terminalSync");
|
||||||
|
String substation = terminalBaseService.terminalSync(syncTerminalParam);
|
||||||
String subtation = terminalBaseService.terminalSync(syncTerminalParam);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, substation, methodDescribe);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, subtation, methodDescribe);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation("监测点和装置同步成运行状态")
|
||||||
|
@OperateInfo(operateType = OperateType.ADD, info = LogEnum.BUSINESS_MEDIUM)
|
||||||
|
@GetMapping("/terminalSyncRunFly")
|
||||||
|
public HttpResult<Boolean> terminalSyncRunFly(@RequestParam("lineId") String lineId) {
|
||||||
|
String methodDescribe = getMethodDescribe("terminalSyncRunFly");
|
||||||
|
Boolean b = terminalBaseService.terminalSyncRunFly(lineId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("监测点信息删除")
|
||||||
|
@OperateInfo(operateType = OperateType.ADD, info = LogEnum.BUSINESS_MEDIUM)
|
||||||
|
@GetMapping("/terminalSyncDeleteFly")
|
||||||
|
public HttpResult<Boolean> terminalSyncDeleteFly(@RequestParam("lineId") String lineId) {
|
||||||
|
String methodDescribe = getMethodDescribe("terminalSyncDeleteFly");
|
||||||
|
Boolean b = terminalBaseService.terminalSyncDeleteFly(lineId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 终端修改操作
|
* 终端修改操作
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -555,4 +555,9 @@ public interface LineMapper extends BaseMapper<Line> {
|
|||||||
List<LineDetailVO.noDataLineInfo> getNoDataLine(@Param("time")String time);
|
List<LineDetailVO.noDataLineInfo> getNoDataLine(@Param("time")String time);
|
||||||
|
|
||||||
List<ReportLineInfoVo> getReportLineInfo(@Param("ids")List<String> ids);
|
List<ReportLineInfoVo> getReportLineInfo(@Param("ids")List<String> ids);
|
||||||
|
|
||||||
|
List<Line> getSubByCondition(@Param("subIds") List<String> subIds, @Param("scale") List<SimpleDTO> scale);
|
||||||
|
|
||||||
|
List<LineDetail> selectByName(@Param("name") String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,8 @@
|
|||||||
device.com_flag comFlag,
|
device.com_flag comFlag,
|
||||||
1 as lineType,
|
1 as lineType,
|
||||||
0 as type,
|
0 as type,
|
||||||
lineDetail.monitor_flag as isUpToGrid
|
lineDetail.monitor_flag as isUpToGrid,
|
||||||
|
point.name pointName
|
||||||
</if>
|
</if>
|
||||||
<!--母线-->
|
<!--母线-->
|
||||||
<if test="type == 2">
|
<if test="type == 2">
|
||||||
@@ -97,11 +98,11 @@
|
|||||||
<select id="orgSubStationInfoGet" resultType="com.njcn.device.biz.pojo.dto.TerminalGetBase$Extend">
|
<select id="orgSubStationInfoGet" resultType="com.njcn.device.biz.pojo.dto.TerminalGetBase$Extend">
|
||||||
select
|
select
|
||||||
DISTINCT
|
DISTINCT
|
||||||
|
point.id lineId,
|
||||||
pq_dept_line.id unitId,
|
pq_dept_line.id unitId,
|
||||||
substation.id ledgerId,
|
substation.id ledgerId,
|
||||||
substation.name subName,
|
substation.name subName,
|
||||||
sub.Scale voltageLevel,
|
sub.Scale voltageLevel,
|
||||||
point.id lineId,
|
|
||||||
lineDetail.Monitor_Flag as monitorFlag
|
lineDetail.Monitor_Flag as monitorFlag
|
||||||
from pq_dept_line pq_dept_line
|
from pq_dept_line pq_dept_line
|
||||||
inner join pq_line point on pq_dept_line.line_id = point.id
|
inner join pq_line point on pq_dept_line.line_id = point.id
|
||||||
@@ -155,7 +156,9 @@
|
|||||||
substation.id id,
|
substation.id id,
|
||||||
substation.name name,
|
substation.name name,
|
||||||
pq_dept_line.id orgId,
|
pq_dept_line.id orgId,
|
||||||
sub.Scale voltageLevel
|
sub.Scale voltageLevel,
|
||||||
|
sub.lng lng,
|
||||||
|
sub.lat lat
|
||||||
from pq_dept_line pq_dept_line
|
from pq_dept_line pq_dept_line
|
||||||
inner join pq_line point on pq_dept_line.line_id = point.id
|
inner join pq_line point on pq_dept_line.line_id = point.id
|
||||||
inner join pq_line_detail lineDetail on point.id = lineDetail.id
|
inner join pq_line_detail lineDetail on point.id = lineDetail.id
|
||||||
|
|||||||
@@ -268,7 +268,8 @@
|
|||||||
pq_line t1 ,
|
pq_line t1 ,
|
||||||
pq_line_detail t2
|
pq_line_detail t2
|
||||||
where
|
where
|
||||||
t1.id = t2.id
|
t1.state = 1
|
||||||
|
and t1.id = t2.id
|
||||||
and
|
and
|
||||||
t1.id in
|
t1.id in
|
||||||
<foreach collection="ids" separator="," open="(" close=")" item="item">
|
<foreach collection="ids" separator="," open="(" close=")" item="item">
|
||||||
@@ -1701,7 +1702,8 @@
|
|||||||
pd.IP ip,
|
pd.IP ip,
|
||||||
pld.Short_Capacity shortCapacity,
|
pld.Short_Capacity shortCapacity,
|
||||||
pld.Dev_Capacity devCapacity,
|
pld.Dev_Capacity devCapacity,
|
||||||
pld.Deal_Capacity dealCapacity
|
pld.Deal_Capacity dealCapacity,
|
||||||
|
pld.Power_Flag powerFlag
|
||||||
from
|
from
|
||||||
pq_line pl
|
pq_line pl
|
||||||
left join pq_line_detail pld on pl.Id = pld.Id
|
left join pq_line_detail pld on pl.Id = pld.Id
|
||||||
@@ -1713,12 +1715,47 @@
|
|||||||
left join pq_voltage pv on pv.Id = pl2.Id
|
left join pq_voltage pv on pv.Id = pl2.Id
|
||||||
left join pq_device pd on pl3.Id = pd.Id
|
left join pq_device pd on pl3.Id = pd.Id
|
||||||
left join sys_dict_data sdd on pv.`Scale` = sdd.Id
|
left join sys_dict_data sdd on pv.`Scale` = sdd.Id
|
||||||
where
|
<where>
|
||||||
<if test="ids!=null and ids.size() > 0">
|
<if test="ids!=null and ids.size() > 0">
|
||||||
pl.Id IN
|
pl.Id IN
|
||||||
<foreach collection="ids" item="item" open="(" close=")" separator=",">
|
<foreach collection="ids" item="item" open="(" close=")" separator=",">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
<select id="getSubByCondition" resultType="com.njcn.device.pq.pojo.po.Line">
|
||||||
|
select
|
||||||
|
t1.*
|
||||||
|
from
|
||||||
|
pq_line t1 ,
|
||||||
|
pq_substation t2
|
||||||
|
where
|
||||||
|
t1.id = t2.id
|
||||||
|
and
|
||||||
|
t1.id in
|
||||||
|
<foreach collection="subIds" separator="," open="(" close=")" item="item">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
<if test="scale!=null and scale.size()!=0">
|
||||||
|
AND t2.scale in
|
||||||
|
<foreach collection="scale" open="(" close=")" item="item" separator=",">
|
||||||
|
#{item.id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<select id="selectByName" resultType="com.njcn.device.pq.pojo.po.LineDetail">
|
||||||
|
select
|
||||||
|
t2.*
|
||||||
|
from
|
||||||
|
pq_line t1 ,
|
||||||
|
pq_line_detail t2
|
||||||
|
<where>
|
||||||
|
t1.id = t2.id
|
||||||
|
<if test="name!=null and name!=''">
|
||||||
|
AND (t1.name like CONCAT('%', #{name}, '%') or t2.Power_Substation_Name like CONCAT('%', #{name}, '%'))
|
||||||
|
</if>
|
||||||
|
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -125,4 +125,12 @@ public interface IDeviceService extends IService<Device> {
|
|||||||
* @Date: 2023/8/17 9:24
|
* @Date: 2023/8/17 9:24
|
||||||
*/
|
*/
|
||||||
String restartDev(List<String> devList);
|
String restartDev(List<String> devList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param devId 装置id
|
||||||
|
* @param thisTimeCheck 本次定检时间
|
||||||
|
* @param nextTimeCheck 下次定检时间
|
||||||
|
* @Description: 技术监督修改装置定检时间
|
||||||
|
*/
|
||||||
|
void updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.njcn.device.pq.pojo.param.PqsParam;
|
|||||||
import com.njcn.device.pq.pojo.param.TerminalMainQueryParam;
|
import com.njcn.device.pq.pojo.param.TerminalMainQueryParam;
|
||||||
import com.njcn.device.pq.pojo.po.Line;
|
import com.njcn.device.pq.pojo.po.Line;
|
||||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||||
|
import com.njcn.device.pq.pojo.po.LineDetail;
|
||||||
import com.njcn.device.pq.pojo.po.TopMsgPO;
|
import com.njcn.device.pq.pojo.po.TopMsgPO;
|
||||||
import com.njcn.device.pq.pojo.vo.*;
|
import com.njcn.device.pq.pojo.vo.*;
|
||||||
import com.njcn.web.pojo.param.BaseParam;
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
@@ -224,4 +225,6 @@ public interface LineService extends IService<Line> {
|
|||||||
List<LineDetailVO.noDataLineInfo> getNoDataLine();
|
List<LineDetailVO.noDataLineInfo> getNoDataLine();
|
||||||
|
|
||||||
List<ReportLineInfoVo> getReportLineInfo(List<String> ids);
|
List<ReportLineInfoVo> getReportLineInfo(List<String> ids);
|
||||||
|
|
||||||
|
List<LineDetail> getByName(String name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,14 @@ public interface TerminalBaseService {
|
|||||||
*/
|
*/
|
||||||
List<Line> getVoltageByCondition(List<String> voltageIds, List<SimpleDTO> scale);
|
List<Line> getVoltageByCondition(List<String> voltageIds, List<SimpleDTO> scale);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询变电站信息
|
||||||
|
*
|
||||||
|
* @param subIds 变电站索引
|
||||||
|
* @param scale 电压等级
|
||||||
|
*/
|
||||||
|
List<Line> getSubByCondition(List<String> subIds, List<SimpleDTO> scale);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据指定电压等级查询母线id
|
* 根据指定电压等级查询母线id
|
||||||
*
|
*
|
||||||
@@ -243,4 +251,18 @@ public interface TerminalBaseService {
|
|||||||
* @Date: 2024/5/29
|
* @Date: 2024/5/29
|
||||||
*/
|
*/
|
||||||
String terminalSync(SyncTerminalParam syncTerminalParam);
|
String terminalSync(SyncTerminalParam syncTerminalParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点和装置同步成运行状态
|
||||||
|
* @param lineId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Boolean terminalSyncRunFly(String lineId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测数据删除
|
||||||
|
* @param lineId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Boolean terminalSyncDeleteFly(String lineId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.device.pq.mapper.DevVersionMapper;
|
import com.njcn.device.pq.mapper.DevVersionMapper;
|
||||||
import com.njcn.device.pq.mapper.DeviceMapper;
|
import com.njcn.device.pq.mapper.DeviceMapper;
|
||||||
@@ -397,5 +398,14 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
return "命令发送成功";
|
return "命令发送成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck) {
|
||||||
|
LambdaUpdateWrapper<Device> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(Device::getId, devId)
|
||||||
|
.set(Device::getThisTimeCheck, thisTimeCheck)
|
||||||
|
.set(Device::getNextTimeCheck, nextTimeCheck);
|
||||||
|
this.update(updateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -417,25 +417,22 @@ public class GeneralDeviceService {
|
|||||||
return generalDeviceDTO;
|
return generalDeviceDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
//筛选出终端id,理论上监测点的pids中第五个id为终端id
|
//1.筛选出母线id,理论上监测点的pids中第六个id为母线id 联查: pq_line t1 ,pq_voltage t2
|
||||||
List<String> devIds = lines.stream().map(line -> {
|
List<String> voltageIds=lines.stream().map(Line::getPid).collect(Collectors.toList());
|
||||||
String[] idsArray = line.getPids().split(",");
|
|
||||||
return idsArray[4];
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
// 再根据终端条件筛选合法终端信息 联查:pq_line t1,pq_device t2
|
|
||||||
List<Line> devices = terminalBaseService.getDeviceByCondition(devIds,
|
|
||||||
deviceType,
|
|
||||||
deviceInfoParam.getManufacturer());
|
|
||||||
//筛选出母线id,理论上监测点的pids中第六个id为母线id 联查: pq_line t1 ,pq_voltage t2
|
|
||||||
List<String> voltageIds = lines.stream().map(line -> {
|
|
||||||
String[] idsArray = line.getPids().split(",");
|
|
||||||
return idsArray[5];
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
//再根据电压等级筛选合法母线信息
|
//再根据电压等级筛选合法母线信息
|
||||||
List<Line> voltages = terminalBaseService.getVoltageByCondition(voltageIds,
|
List<Line> voltages = terminalBaseService.getVoltageByCondition(voltageIds, deviceInfoParam.getScale());
|
||||||
deviceInfoParam.getScale());
|
|
||||||
|
//2.筛选出终端id,理论上监测点的pids中第五个id为终端id
|
||||||
|
List<String> devIds=voltages.stream().map(Line::getPid).collect(Collectors.toList());
|
||||||
|
// 再根据终端条件筛选合法终端信息 联查:pq_line t1,pq_device t2
|
||||||
|
List<Line> devices = terminalBaseService.getDeviceByCondition(devIds, deviceType, deviceInfoParam.getManufacturer());
|
||||||
|
|
||||||
|
//3.筛选出变电站id,理论上监测点的pids中第四个id为变电站id 联查: pq_line t1 ,pq_substation t2
|
||||||
|
List<String> subIds=devices.stream().map(Line::getPid).collect(Collectors.toList());
|
||||||
|
List<Line> sub = terminalBaseService.getSubByCondition(subIds, deviceInfoParam.getScale());
|
||||||
|
|
||||||
//筛选最终的数据
|
//筛选最终的数据
|
||||||
dealDeviceData(generalDeviceDTO, lines, devices, voltages);
|
dealDeviceData(generalDeviceDTO, lines, devices, voltages, sub);
|
||||||
return generalDeviceDTO;
|
return generalDeviceDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,15 +444,18 @@ public class GeneralDeviceService {
|
|||||||
* @param devices 筛选后的终端信息
|
* @param devices 筛选后的终端信息
|
||||||
* @param voltages 筛选后的母线信息
|
* @param voltages 筛选后的母线信息
|
||||||
*/
|
*/
|
||||||
private void dealDeviceData(GeneralDeviceDTO generalDeviceDTO, List<Line> lines, List<Line> devices, List<Line> voltages) {
|
private void dealDeviceData(GeneralDeviceDTO generalDeviceDTO, List<Line> lines, List<Line> devices, List<Line> voltages, List<Line> sub) {
|
||||||
List<String> gdIndexes = new ArrayList<>(), subIndexes = new ArrayList<>(), deviceIndexes = new ArrayList<>(), voltageIndexes = new ArrayList<>(), lineIndexes = new ArrayList<>();
|
List<String> gdIndexes = new ArrayList<>(), subIndexes = new ArrayList<>(), deviceIndexes = new ArrayList<>(), voltageIndexes = new ArrayList<>(), lineIndexes = new ArrayList<>();
|
||||||
List<String> devIds = devices.stream().map(Line::getId).distinct().collect(Collectors.toList());
|
List<String> devIds = devices.stream().map(Line::getId).distinct().collect(Collectors.toList());
|
||||||
List<String> volIds = voltages.stream().map(Line::getId).distinct().collect(Collectors.toList());
|
List<String> volIds = voltages.stream().map(Line::getId).distinct().collect(Collectors.toList());
|
||||||
|
List<String> subIds = sub.stream().map(Line::getId).distinct().collect(Collectors.toList());
|
||||||
for (Line line : lines) {
|
for (Line line : lines) {
|
||||||
String[] idsArray = line.getPids().split(",");
|
String[] idsArray = line.getPids().split(",");
|
||||||
//监测点同时满足条件筛选后的终端、母线信息,才是最终的结果
|
//监测点同时满足条件筛选后的终端、母线信息,才是最终的结果
|
||||||
if (devIds.contains(idsArray[LineBaseEnum.DEVICE_LEVEL.getCode()]) &&
|
if (devIds.contains(idsArray[LineBaseEnum.DEVICE_LEVEL.getCode()]) &&
|
||||||
volIds.contains(idsArray[LineBaseEnum.SUB_V_LEVEL.getCode()])) {
|
volIds.contains(idsArray[LineBaseEnum.SUB_V_LEVEL.getCode()])&&
|
||||||
|
subIds.contains(idsArray[LineBaseEnum.SUB_LEVEL.getCode()])
|
||||||
|
) {
|
||||||
gdIndexes.add(idsArray[LineBaseEnum.GD_LEVEL.getCode()]);
|
gdIndexes.add(idsArray[LineBaseEnum.GD_LEVEL.getCode()]);
|
||||||
subIndexes.add(idsArray[LineBaseEnum.SUB_LEVEL.getCode()]);
|
subIndexes.add(idsArray[LineBaseEnum.SUB_LEVEL.getCode()]);
|
||||||
deviceIndexes.add(idsArray[LineBaseEnum.DEVICE_LEVEL.getCode()]);
|
deviceIndexes.add(idsArray[LineBaseEnum.DEVICE_LEVEL.getCode()]);
|
||||||
|
|||||||
@@ -296,12 +296,14 @@ public class GridDiagramServiceImpl implements GridDiagramService {
|
|||||||
//根据步进单位获取起始日期时间和结束日期时间的时间区间集合
|
//根据步进单位获取起始日期时间和结束日期时间的时间区间集合
|
||||||
List<DateTime> dateTimes = DateUtil.rangeToList(parse, DateUtil.parse(param.getSearchEndTime()), dateField);
|
List<DateTime> dateTimes = DateUtil.rangeToList(parse, DateUtil.parse(param.getSearchEndTime()), dateField);
|
||||||
List<Date> times;
|
List<Date> times;
|
||||||
|
//终端分布趋势
|
||||||
if (4 == type) {
|
if (4 == type) {
|
||||||
List<String> devIDs = generalDeviceDTOList.stream().flatMap(x -> x.getDeviceIndexes().stream()).distinct().collect(Collectors.toList());
|
List<String> devIDs = generalDeviceDTOList.stream().flatMap(x -> x.getDeviceIndexes().stream()).distinct().collect(Collectors.toList());
|
||||||
List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>().select(Device::getLoginTime).in(CollUtil.isNotEmpty(devIDs), Device::getId, devIDs).eq(Device::getRunFlag, 0));
|
List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>().select(Device::getLoginTime).in(CollUtil.isNotEmpty(devIDs), Device::getId, devIDs).eq(Device::getRunFlag, 0));
|
||||||
times = list.stream().map(x -> Date.from(x.getLoginTime().atStartOfDay(ZoneId.systemDefault()).toInstant())).collect(Collectors.toList());
|
times = list.stream().map(x -> Date.from(x.getLoginTime().atStartOfDay(ZoneId.systemDefault()).toInstant())).collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
List<String> ids;
|
List<String> ids;
|
||||||
|
//监测点分布趋势
|
||||||
if (type == 3) {
|
if (type == 3) {
|
||||||
ids = generalDeviceDTOList.stream().flatMap(x -> x.getSubIndexes().stream()).distinct().collect(Collectors.toList());
|
ids = generalDeviceDTOList.stream().flatMap(x -> x.getSubIndexes().stream()).distinct().collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -694,6 +694,11 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
|||||||
return this.baseMapper.getReportLineInfo(ids);
|
return this.baseMapper.getReportLineInfo(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LineDetail> getByName(String name) {
|
||||||
|
return this.baseMapper.selectByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Overlimit> getOverLimitByList(PollutionParamDTO pollutionParamDTO) {
|
public List<Overlimit> getOverLimitByList(PollutionParamDTO pollutionParamDTO) {
|
||||||
return overlimitMapper.selectBatchIds(pollutionParamDTO.getLineList());
|
return overlimitMapper.selectBatchIds(pollutionParamDTO.getLineList());
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public class RStatIntegrityDServiceImpl extends ServiceImpl<RStatIntegrityDMappe
|
|||||||
for(Line item : lineList){
|
for(Line item : lineList){
|
||||||
LineDataQualityDTO lineDataQualityDTO = new LineDataQualityDTO();
|
LineDataQualityDTO lineDataQualityDTO = new LineDataQualityDTO();
|
||||||
lineDataQualityDTO.setLineId(item.getId());
|
lineDataQualityDTO.setLineId(item.getId());
|
||||||
|
lineDataQualityDTO.setLineName(item.getName());
|
||||||
if(onlineMap.containsKey(item.getPid())){
|
if(onlineMap.containsKey(item.getPid())){
|
||||||
lineDataQualityDTO.setOnlineRate(Double.valueOf(onlineMap.get(item.getPid()).getOnlineRate()));
|
lineDataQualityDTO.setOnlineRate(Double.valueOf(onlineMap.get(item.getPid()).getOnlineRate()));
|
||||||
}else {
|
}else {
|
||||||
@@ -95,6 +96,7 @@ public class RStatIntegrityDServiceImpl extends ServiceImpl<RStatIntegrityDMappe
|
|||||||
}else {
|
}else {
|
||||||
lineDataQualityDTO.setIntegrityRate(0.00);
|
lineDataQualityDTO.setIntegrityRate(0.00);
|
||||||
}
|
}
|
||||||
|
result.add(lineDataQualityDTO);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,15 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|||||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.text.StrBuilder;
|
import cn.hutool.core.text.StrBuilder;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.common.config.GeneralInfo;
|
import com.njcn.common.config.GeneralInfo;
|
||||||
import com.njcn.common.pojo.dto.SimpleDTO;
|
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||||
@@ -21,6 +24,8 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
import com.njcn.device.biz.enums.DeviceResponseEnum;
|
import com.njcn.device.biz.enums.DeviceResponseEnum;
|
||||||
|
import com.njcn.device.biz.enums.RunFlagEnum;
|
||||||
|
import com.njcn.device.biz.pojo.dto.LineDTO;
|
||||||
import com.njcn.device.biz.pojo.po.DeviceBak;
|
import com.njcn.device.biz.pojo.po.DeviceBak;
|
||||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||||
import com.njcn.device.biz.utils.COverlimitUtil;
|
import com.njcn.device.biz.utils.COverlimitUtil;
|
||||||
@@ -108,9 +113,6 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|||||||
|
|
||||||
private final FileStorageUtil fileStorageUtil;
|
private final FileStorageUtil fileStorageUtil;
|
||||||
|
|
||||||
private final GeneralInfo generalInfo;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 终端新增操作
|
* 终端新增操作
|
||||||
*
|
*
|
||||||
@@ -1489,6 +1491,11 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|||||||
return this.baseMapper.getVoltageByCondition(voltageIds, scale);
|
return this.baseMapper.getVoltageByCondition(voltageIds, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Line> getSubByCondition(List<String> subIds, List<SimpleDTO> scale) {
|
||||||
|
return this.baseMapper.getSubByCondition(subIds, scale);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getVoltageIdByScale(List<String> voltageIds, String scale) {
|
public List<String> getVoltageIdByScale(List<String> voltageIds, String scale) {
|
||||||
return this.baseMapper.getVoltageIdByScale(voltageIds, scale);
|
return this.baseMapper.getVoltageIdByScale(voltageIds, scale);
|
||||||
@@ -1882,13 +1889,13 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|||||||
Device deviceDetail = new Device();
|
Device deviceDetail = new Device();
|
||||||
BeanUtils.copyProperties(deviceParam, deviceDetail);
|
BeanUtils.copyProperties(deviceParam, deviceDetail);
|
||||||
deviceDetail.setId(device.getId());
|
deviceDetail.setId(device.getId());
|
||||||
deviceDetail.setRunFlag(0);
|
deviceDetail.setRunFlag(3);
|
||||||
deviceDetail.setCallFlag(0);
|
deviceDetail.setCallFlag(0);
|
||||||
deviceDetail.setComFlag(0);
|
deviceDetail.setComFlag(0);
|
||||||
deviceDetail.setCheckFlag(1);
|
deviceDetail.setCheckFlag(1);
|
||||||
deviceDetail.setThisTimeCheck(PubUtils.localDateFormat(deviceParam.getThisTimeCheck()));
|
deviceDetail.setThisTimeCheck(PubUtils.localDateFormat(deviceParam.getThisTimeCheck()));
|
||||||
deviceDetail.setNextTimeCheck(PubUtils.localDateFormat(deviceParam.getNextTimeCheck()));
|
deviceDetail.setNextTimeCheck(PubUtils.localDateFormat(deviceParam.getNextTimeCheck()));
|
||||||
deviceDetail.setLoginTime(PubUtils.localDateFormat(deviceParam.getNextTimeCheck()));
|
deviceDetail.setLoginTime(PubUtils.localDateFormat(deviceParam.getLoginTime()));
|
||||||
deviceDetail.setUpdateTime(LocalDateTime.now());
|
deviceDetail.setUpdateTime(LocalDateTime.now());
|
||||||
|
|
||||||
//处理装置识别码秘钥
|
//处理装置识别码秘钥
|
||||||
@@ -1947,7 +1954,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|||||||
LineDetail lineDetail = new LineDetail();
|
LineDetail lineDetail = new LineDetail();
|
||||||
BeanUtils.copyProperties(lineParam, lineDetail);
|
BeanUtils.copyProperties(lineParam, lineDetail);
|
||||||
lineDetail.setId(line.getId());
|
lineDetail.setId(line.getId());
|
||||||
lineDetail.setRunFlag(0);
|
lineDetail.setRunFlag(3);
|
||||||
//判断国网监测点id
|
//判断国网监测点id
|
||||||
if (StrUtil.isNotBlank(lineDetail.getMonitorId())) {
|
if (StrUtil.isNotBlank(lineDetail.getMonitorId())) {
|
||||||
lineDetail.setMonitorFlag(1);
|
lineDetail.setMonitorFlag(1);
|
||||||
@@ -1987,6 +1994,40 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|||||||
return subIndex;
|
return subIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Boolean terminalSyncRunFly(String lineId) {
|
||||||
|
LineDTO lineDTO = this.baseMapper.selectLineDetail(lineId);
|
||||||
|
if(ObjectUtil.isNotNull(lineDTO)){
|
||||||
|
lineDetailMapper.update(null,new LambdaUpdateWrapper<LineDetail>()
|
||||||
|
.set(LineDetail::getRunFlag, 0)
|
||||||
|
.eq(LineDetail::getId, lineDTO.getLineId())
|
||||||
|
);
|
||||||
|
|
||||||
|
deviceMapper.update(null,new LambdaUpdateWrapper<Device>()
|
||||||
|
.set(Device::getRunFlag, 0)
|
||||||
|
.eq(Device::getId, lineDTO.getDevId())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Boolean terminalSyncDeleteFly(String lineId) {
|
||||||
|
LineDTO lineDTO = this.baseMapper.selectLineDetail(lineId);
|
||||||
|
if(ObjectUtil.isNotNull(lineDTO)){
|
||||||
|
//删除监测点详细信息
|
||||||
|
lineDetailMapper.updateLineRunFlag(lineDTO.getLineId(), RunFlagEnum.QUIT.getStatus());
|
||||||
|
//todo 删除监测点信息
|
||||||
|
this.removeById(lineDTO.getLineId());
|
||||||
|
//todo 删除部门监测点关系
|
||||||
|
deptLineMapper.delete(new LambdaQueryWrapper<DeptLine>()
|
||||||
|
.eq(DeptLine::getLineId, lineDTO.getLineId()));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private String saveTerminalInfo(List<OracleTerminalExcel> oracleTerminalExcels, List<OverLimitExcel> overLimitExcels) {
|
private String saveTerminalInfo(List<OracleTerminalExcel> oracleTerminalExcels, List<OverLimitExcel> overLimitExcels) {
|
||||||
List<OracleTerminalExcel.OracleTerminalExcelMsg> oracleTerminalExcelMsg = new ArrayList<>();
|
List<OracleTerminalExcel.OracleTerminalExcelMsg> oracleTerminalExcelMsg = new ArrayList<>();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.njcn.energy.pojo.api;
|
|||||||
|
|
||||||
import com.njcn.common.pojo.constant.ServerInfo;
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.energy.pojo.api.fallback.EleAirStrategyFallbackFactory;
|
||||||
import com.njcn.energy.pojo.api.fallback.EleOnlineRateFallbackFactory;
|
import com.njcn.energy.pojo.api.fallback.EleOnlineRateFallbackFactory;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -14,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
* @author cdf
|
* @author cdf
|
||||||
* @date 2022/4/22
|
* @date 2022/4/22
|
||||||
*/
|
*/
|
||||||
@FeignClient(value = ServerInfo.ENERGY,path = "/air",fallbackFactory = EleOnlineRateFallbackFactory.class)
|
@FeignClient(value = ServerInfo.ENERGY,path = "/air",fallbackFactory = EleAirStrategyFallbackFactory.class)
|
||||||
public interface EleAirStrategyFeignClient {
|
public interface EleAirStrategyFeignClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,6 +24,6 @@ public interface EleAirStrategyFeignClient {
|
|||||||
* @date 2022/4/22
|
* @date 2022/4/22
|
||||||
*/
|
*/
|
||||||
@GetMapping("dealAirStrategyId")
|
@GetMapping("dealAirStrategyId")
|
||||||
HttpResult<Boolean> dealAirStrategyId(@RequestParam("id") String id,@RequestParam("operation") String operation);
|
HttpResult<Boolean> dealAirStrategyId(@RequestParam("operation") String operation);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.njcn.energy.pojo.api;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.energy.pojo.api.fallback.EleOnlineRateFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pqs
|
||||||
|
*
|
||||||
|
* @author cdf
|
||||||
|
* @date 2022/4/22
|
||||||
|
*/
|
||||||
|
@FeignClient(value = ServerInfo.ENERGY,path = "/energyJob",fallbackFactory = EleOnlineRateFallbackFactory.class)
|
||||||
|
public interface EnergyStatisticFeignClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取策略下的监测点
|
||||||
|
* @author cdf
|
||||||
|
* @date 2022/4/22
|
||||||
|
*/
|
||||||
|
@GetMapping("electricCalJob")
|
||||||
|
HttpResult<Boolean> electricCalJob();
|
||||||
|
|
||||||
|
@GetMapping("eleOnlineRateJob")
|
||||||
|
HttpResult<Boolean> eleOnlineRateJobHandler();
|
||||||
|
|
||||||
|
@GetMapping("eleIntegrityJob")
|
||||||
|
HttpResult<Boolean> eleIntegrityJobHandler();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ public class EleAirStrategyFallbackFactory implements FallbackFactory<EleAirStra
|
|||||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
return new EleAirStrategyFeignClient() {
|
return new EleAirStrategyFeignClient() {
|
||||||
@Override
|
@Override
|
||||||
public HttpResult<Boolean> dealAirStrategyId(String id,String operation) {
|
public HttpResult<Boolean> dealAirStrategyId(String operation) {
|
||||||
log.error("{}异常,降级处理,异常为:{}","空调控制策略数据",cause.toString());
|
log.error("{}异常,降级处理,异常为:{}","空调控制策略数据",cause.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.njcn.energy.pojo.api.fallback;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.energy.pojo.api.EleAirStrategyFeignClient;
|
||||||
|
import com.njcn.energy.pojo.api.EnergyStatisticFeignClient;
|
||||||
|
import com.njcn.energy.pojo.utils.EnergyEnumUtil;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/4/20 15:09
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class EnergyStatisticFallbackFactory implements FallbackFactory<EnergyStatisticFeignClient> {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnergyStatisticFeignClient create(Throwable cause) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if(cause.getCause() instanceof BusinessException){
|
||||||
|
BusinessException businessException = (BusinessException) cause.getCause();
|
||||||
|
exceptionEnum = EnergyEnumUtil.getExceptionEnum(businessException.getResult());
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new EnergyStatisticFeignClient() {
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> electricCalJob() {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","调度统计电量增量",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> eleOnlineRateJobHandler() {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","用能终端在线率数据",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> eleIntegrityJobHandler() {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","用能数据完整性数据",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package com.njcn.energy.pojo.dto;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/4/13 16:57
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class HarmonicDTO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private Integer real;
|
||||||
|
|
||||||
|
private Integer due;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
|
||||||
import com.njcn.common.pojo.constant.PatternRegex;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import com.njcn.energy.pojo.param.LineParam;
|
|
||||||
import com.njcn.web.constant.ValidMessage;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.Pattern;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.energy.pojo.dto;
|
package com.njcn.energy.pojo.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@@ -36,11 +36,9 @@ public class AirStrategyParam{
|
|||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@ApiModelProperty(name = "开始时间",required = true)
|
@ApiModelProperty(name = "开始时间",required = true)
|
||||||
@NotBlank(message = "开始时间不可为空")
|
|
||||||
private String startTime;
|
private String startTime;
|
||||||
|
|
||||||
@ApiModelProperty(name = "开始时间",required = true)
|
@ApiModelProperty(name = "结束时间",required = true)
|
||||||
@NotBlank(message = "开始时间不可为空")
|
|
||||||
private String endTime;
|
private String endTime;
|
||||||
|
|
||||||
@ApiModelProperty(name = "空调模式",required = true)
|
@ApiModelProperty(name = "空调模式",required = true)
|
||||||
|
|||||||
@@ -33,11 +33,7 @@
|
|||||||
<artifactId>system-api</artifactId>
|
<artifactId>system-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.njcn</groupId>
|
|
||||||
<artifactId>job-api</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>common-web</artifactId>
|
<artifactId>common-web</artifactId>
|
||||||
@@ -66,11 +62,7 @@
|
|||||||
<version>13.0</version>
|
<version>13.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.njcn</groupId>
|
|
||||||
<artifactId>job-api</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -201,8 +201,8 @@ public class EleAirStrategyController extends BaseController {
|
|||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
@GetMapping("/dealAirStrategyId")
|
@GetMapping("/dealAirStrategyId")
|
||||||
@ApiOperation("根据策略定时开启关闭空调")
|
@ApiOperation("根据策略定时开启关闭空调")
|
||||||
public void dealAirStrategyId(@RequestParam("id")String id,@RequestParam("operation")String operation) {
|
public void dealAirStrategyId(@RequestParam("operation")String operation) {
|
||||||
eleAirStrategyService.dealAirStrategyId(id, operation);
|
eleAirStrategyService.dealAirStrategyId(operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,342 @@
|
|||||||
|
package com.njcn.energy.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.njcn.energy.pojo.api.EleIntegrityFeignClient;
|
||||||
|
import com.njcn.energy.pojo.api.EleOnlineRateFeignClient;
|
||||||
|
import com.njcn.energy.pojo.dto.HarmonicDTO;
|
||||||
|
import com.njcn.energy.pojo.dto.OnlineRateDTO;
|
||||||
|
import com.njcn.influx.config.InfluxDbConfig;
|
||||||
|
import com.njcn.influx.utils.InfluxDbUtils;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.influxdb.InfluxDB;
|
||||||
|
import org.influxdb.dto.BatchPoints;
|
||||||
|
import org.influxdb.dto.Point;
|
||||||
|
import org.influxdb.dto.QueryResult;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "用能系统数据调度")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("energyJob")
|
||||||
|
public class StatisticDataRunController {
|
||||||
|
|
||||||
|
private final Integer POWER_DATA_DUE = 96;
|
||||||
|
|
||||||
|
private final Integer AIR_DATA_DUE = 288;
|
||||||
|
|
||||||
|
private final InfluxDbUtils influxDbUtils;
|
||||||
|
|
||||||
|
private final InfluxDbConfig influxDbConfig;
|
||||||
|
|
||||||
|
private final EleOnlineRateFeignClient eleOnlineRateFeignClient;
|
||||||
|
|
||||||
|
private final EleIntegrityFeignClient eleIntegrityFeignClient;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度统计电量增量
|
||||||
|
*/
|
||||||
|
@GetMapping("electricCalJob")
|
||||||
|
@Async("asyncExecutor")
|
||||||
|
public void electricCalJob() {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
|
||||||
|
startTime.add(Calendar.MINUTE, -40);
|
||||||
|
String start = sdf.format(startTime.getTime());
|
||||||
|
|
||||||
|
Calendar endTime = Calendar.getInstance();
|
||||||
|
//endTime.add(Calendar.DAY_OF_MONTH,-8);
|
||||||
|
String end = sdf.format(endTime.getTime());
|
||||||
|
|
||||||
|
String sql = "select * from power_data where time > '" + start + "' and time < '" + end + "' order by time";
|
||||||
|
List<Map<String, Object>> list = influxDbUtils.getResult(sql);
|
||||||
|
|
||||||
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
|
Map lineTemMap = new HashMap<>();
|
||||||
|
List<Map<String, Object>> insertObj = new ArrayList<>();
|
||||||
|
list.stream().collect(Collectors.groupingBy((item) -> item.get("LineId"), Collectors.toList())).forEach(lineTemMap::put);
|
||||||
|
lineTemMap.forEach((lineId, mapList) -> {
|
||||||
|
List<Map<String, Object>> tmpList = (List) mapList;
|
||||||
|
if (CollectionUtil.isNotEmpty(tmpList)) {
|
||||||
|
for (int i = 0; i < tmpList.size(); i++) {
|
||||||
|
if (i != 0) {
|
||||||
|
Map<String, Object> mapEnd = tmpList.get(i);
|
||||||
|
Map<String, Object> mapStart = tmpList.get(i - 1);
|
||||||
|
Long endT = (Long) mapEnd.get("time") + 28800;
|
||||||
|
Long startT = (Long) mapStart.get("time") + 28800;
|
||||||
|
if (endT > startT) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (endT - startT == 60 * 15) {
|
||||||
|
for (Map.Entry<String, Object> entry : tmpList.get(i).entrySet()) {
|
||||||
|
if (entry.getKey().equals("Phase") || entry.getKey().equals("LineId") || entry.getKey().equals("Stat_Method")) {
|
||||||
|
map.put(entry.getKey(), entry.getValue());
|
||||||
|
} else if (entry.getKey().equals("time")) {
|
||||||
|
map.put(entry.getKey(), endT);
|
||||||
|
} else {
|
||||||
|
//定义 float最大值
|
||||||
|
Float endThis = Float.parseFloat(entry.getValue().toString());
|
||||||
|
Float startThis = Float.parseFloat(mapStart.get(entry.getKey()).toString());
|
||||||
|
if (-1000000f == endThis || -1000000f == startThis) {
|
||||||
|
map.put(entry.getKey(), -1000000f);
|
||||||
|
} else {
|
||||||
|
map.put(entry.getKey(), endThis - startThis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
insertObj.add(map);
|
||||||
|
} else {
|
||||||
|
//缺少数据处理
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error("时间起始顺序错误!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (CollectionUtil.isNotEmpty(insertObj)) {
|
||||||
|
BatchPoints batchPoints = BatchPoints.database(influxDbConfig.getDatabase()).build();
|
||||||
|
for (Map<String, Object> it : insertObj) {
|
||||||
|
Point.Builder point = Point.measurement("power_data_add");
|
||||||
|
it.forEach((key, val) -> {
|
||||||
|
if (key.equals("LineId")) {
|
||||||
|
point.tag(key, val.toString());
|
||||||
|
} else if (key.equals("time")) {
|
||||||
|
point.time((Long) val, TimeUnit.SECONDS);
|
||||||
|
} else if (key.equals("Phase") || key.equals("Stat_Method")) {
|
||||||
|
point.addField(key, val.toString());
|
||||||
|
} else {
|
||||||
|
point.addField(key, (Float) val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Point p = point.build();
|
||||||
|
batchPoints.point(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
influxDbUtils.batchInsert(batchPoints, TimeUnit.SECONDS);
|
||||||
|
HashMap<String, Map<String, Object>> hashMap = new HashMap<>();
|
||||||
|
for (int j = 0; j < insertObj.size(); j++) {
|
||||||
|
hashMap.put(insertObj.get(j).get("LineId").toString(), insertObj.get(j));
|
||||||
|
}
|
||||||
|
hashMap.forEach((key, val) -> {
|
||||||
|
Long t = (Long) val.get("time") * 1000;
|
||||||
|
String tt = Instant.ofEpochMilli((Long) val.get("time") * 1000).toString();
|
||||||
|
String sqlQs = "delete from power_data_add_Real where time< '" + tt + "' and LineId ='" + key + "'";
|
||||||
|
influxDbUtils.deleteMeasurementData(sqlQs);
|
||||||
|
Map<String, Object> filedss = new HashMap<>();
|
||||||
|
Map<String, String> tagss = new HashMap<>();
|
||||||
|
val.forEach((keytem, valtem) -> {
|
||||||
|
if (keytem.equals("time")) {
|
||||||
|
|
||||||
|
} else if (keytem.equals("LineId")) {
|
||||||
|
tagss.put(keytem, valtem.toString());
|
||||||
|
} else {
|
||||||
|
filedss.put(keytem, valtem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
influxDbUtils.insert("power_data_add_Real", tagss, filedss, t, TimeUnit.MILLISECONDS);
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error(start + "——————" + end + "influxdb数据库power_data表数据为空,请联系管理员排查");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用能终端在线率数据
|
||||||
|
* -------------------------------------------------start-----------------------------------------------------------
|
||||||
|
*/
|
||||||
|
@GetMapping("eleOnlineRateJob")
|
||||||
|
public void eleOnlineRateJobHandler() {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)-1, 0, 0, 0);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
Calendar calendar2 = Calendar.getInstance();
|
||||||
|
calendar2.set(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DAY_OF_MONTH)-1, 23, 59, 59);
|
||||||
|
calendar2.set(Calendar.MILLISECOND, 0);
|
||||||
|
String startTime = format.format(calendar.getTime());
|
||||||
|
String endTime = format.format(calendar2.getTime());
|
||||||
|
List<OnlineRateDTO> list = eleOnlineRateFeignClient.getDeviceTime(startTime,endTime).getData();
|
||||||
|
createOnlineMeasurement(list,calendar.getTimeInMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成用能终端在线率表
|
||||||
|
*/
|
||||||
|
private void createOnlineMeasurement(List<OnlineRateDTO> list, long time){
|
||||||
|
List<String> records = new ArrayList<String>();
|
||||||
|
list.forEach(item->{
|
||||||
|
Map<String, String> tags = new HashMap<>();
|
||||||
|
Map<String, Object> fields = new HashMap<>();
|
||||||
|
tags.put("device_id",item.getDeviceId());
|
||||||
|
fields.put("online_rate",item.getOnlineRate());
|
||||||
|
Point point = influxDbUtils.pointBuilder("ele_online_rate", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||||
|
BatchPoints batchPoints = BatchPoints.database(influxDbConfig.getDatabase()).tag("device_id", item.getDeviceId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||||
|
batchPoints.point(point);
|
||||||
|
records.add(batchPoints.lineProtocol());
|
||||||
|
});
|
||||||
|
influxDbUtils.batchInsert(influxDbConfig.getDatabase(),"", InfluxDB.ConsistencyLevel.ALL, records);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -------------------------------------------------end-------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用能数据完整性数据
|
||||||
|
* -------------------------------------------------start-----------------------------------------------------------
|
||||||
|
*/
|
||||||
|
@GetMapping("eleIntegrityJob")
|
||||||
|
public void eleIntegrityJobHandler() {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)-1, 0, 0, 0);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
Calendar calendar2 = Calendar.getInstance();
|
||||||
|
calendar2.set(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DAY_OF_MONTH)-1, 23, 59, 59);
|
||||||
|
calendar2.set(Calendar.MILLISECOND, 0);
|
||||||
|
String startTime = format.format(calendar.getTime());
|
||||||
|
String endTime = format.format(calendar2.getTime());
|
||||||
|
|
||||||
|
List<HarmonicDTO> powerData = getPowerData(startTime,endTime);
|
||||||
|
if(!CollectionUtils.isEmpty(powerData)){
|
||||||
|
createMeasurement(powerData,calendar.getTimeInMillis());
|
||||||
|
} else {
|
||||||
|
List<HarmonicDTO> result = new ArrayList<>();
|
||||||
|
//查询当前网关下所有监测点id
|
||||||
|
List<String> lineList = eleIntegrityFeignClient.getPowerLineId().getData();
|
||||||
|
lineList.forEach(item->{
|
||||||
|
HarmonicDTO harmonicDTO = new HarmonicDTO();
|
||||||
|
harmonicDTO.setId(item);
|
||||||
|
harmonicDTO.setReal(0);
|
||||||
|
harmonicDTO.setDue(96);
|
||||||
|
result.add(harmonicDTO);
|
||||||
|
});
|
||||||
|
createMeasurement(result,calendar.getTimeInMillis());
|
||||||
|
}
|
||||||
|
List<HarmonicDTO> airData = getAirData(startTime,endTime);
|
||||||
|
if(!CollectionUtils.isEmpty(airData)){
|
||||||
|
powerData = new ArrayList<>(airData);
|
||||||
|
createMeasurement(powerData,calendar.getTimeInMillis());
|
||||||
|
} else {
|
||||||
|
List<HarmonicDTO> result = new ArrayList<>();
|
||||||
|
//查询当前网关下所有监测点id
|
||||||
|
List<String> lineList = eleIntegrityFeignClient.getAirLineId().getData();
|
||||||
|
lineList.forEach(item->{
|
||||||
|
HarmonicDTO harmonicDTO = new HarmonicDTO();
|
||||||
|
harmonicDTO.setId(item);
|
||||||
|
harmonicDTO.setReal(0);
|
||||||
|
harmonicDTO.setDue(288);
|
||||||
|
result.add(harmonicDTO);
|
||||||
|
});
|
||||||
|
createMeasurement(result,calendar.getTimeInMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成power_data数据
|
||||||
|
*/
|
||||||
|
private List<HarmonicDTO> getPowerData(String startTime, String endTime){
|
||||||
|
List<HarmonicDTO> list = new ArrayList<>();
|
||||||
|
String sql = "SELECT count(FundWattHr) FROM power_data where time >= '"+startTime+"' and time <= '"+endTime+"' group by LineId";
|
||||||
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
|
//处理结果集
|
||||||
|
List<QueryResult.Series> seriesList = sqlResult.getResults().get(0).getSeries();
|
||||||
|
if (!CollectionUtils.isEmpty(seriesList)){
|
||||||
|
seriesList.forEach(po -> {
|
||||||
|
HarmonicDTO harmonicDTO = new HarmonicDTO();
|
||||||
|
String lineId = po.getTags().get("LineId");
|
||||||
|
List<List<Object>> countList = po.getValues();
|
||||||
|
for (List<Object> value : countList) {
|
||||||
|
//当日实际数据
|
||||||
|
Integer count = new BigDecimal(value.get(1).toString()).intValue();
|
||||||
|
harmonicDTO.setId(lineId);
|
||||||
|
harmonicDTO.setReal(count);
|
||||||
|
harmonicDTO.setDue(POWER_DATA_DUE);
|
||||||
|
}
|
||||||
|
list.add(harmonicDTO);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成air_data数据
|
||||||
|
*/
|
||||||
|
private List<HarmonicDTO> getAirData(String startTime, String endTime){
|
||||||
|
List<HarmonicDTO> list = new ArrayList<>();
|
||||||
|
String sql = "SELECT count(ACInMode),count(ACOutMode) FROM air_data where time >='"+startTime+"' and time <= '"+endTime+"' group by LineId";
|
||||||
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
|
//处理结果集
|
||||||
|
List<QueryResult.Series> seriesList = sqlResult.getResults().get(0).getSeries();
|
||||||
|
if (!CollectionUtils.isEmpty(seriesList)){
|
||||||
|
seriesList.forEach(po -> {
|
||||||
|
HarmonicDTO harmonicDTO = new HarmonicDTO();
|
||||||
|
String lineId = po.getTags().get("LineId");
|
||||||
|
List<List<Object>> countList = po.getValues();
|
||||||
|
for (List<Object> value : countList) {
|
||||||
|
//当日实际数据
|
||||||
|
if (!Objects.isNull(value.get(1))){
|
||||||
|
harmonicDTO.setReal(new BigDecimal(value.get(1).toString()).intValue());
|
||||||
|
} else {
|
||||||
|
harmonicDTO.setReal(new BigDecimal(value.get(2).toString()).intValue());
|
||||||
|
}
|
||||||
|
harmonicDTO.setId(lineId);
|
||||||
|
harmonicDTO.setDue(AIR_DATA_DUE);
|
||||||
|
}
|
||||||
|
list.add(harmonicDTO);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成用能数据完整性表
|
||||||
|
*/
|
||||||
|
private void createMeasurement(List<HarmonicDTO> list, long time){
|
||||||
|
List<String> records = new ArrayList<String>();
|
||||||
|
list.forEach(item->{
|
||||||
|
Map<String, String> tags = new HashMap<>();
|
||||||
|
Map<String, Object> fields = new HashMap<>();
|
||||||
|
tags.put("line_id",item.getId());
|
||||||
|
fields.put("real",item.getReal());
|
||||||
|
fields.put("due",item.getDue());
|
||||||
|
Point point = influxDbUtils.pointBuilder("ele_integrity", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||||
|
BatchPoints batchPoints = BatchPoints.database(influxDbConfig.getDatabase()).tag("line_id", item.getId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||||
|
batchPoints.point(point);
|
||||||
|
records.add(batchPoints.lineProtocol());
|
||||||
|
});
|
||||||
|
influxDbUtils.batchInsert(influxDbConfig.getDatabase(),"", InfluxDB.ConsistencyLevel.ALL, records);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -------------------------------------------------end-------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -1,39 +1,27 @@
|
|||||||
package com.njcn.energy.handler;
|
package com.njcn.energy.handler;
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||||
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
||||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
import com.njcn.energy.pojo.constant.ApiParam;
|
import com.njcn.energy.pojo.constant.ApiParam;
|
||||||
import com.njcn.energy.pojo.dto.AirStrategyDTO;
|
|
||||||
import com.njcn.energy.pojo.dto.DeviceOperateDTO;
|
import com.njcn.energy.pojo.dto.DeviceOperateDTO;
|
||||||
import com.njcn.energy.pojo.dto.RegisterDTO;
|
import com.njcn.energy.pojo.dto.RegisterDTO;
|
||||||
import com.njcn.energy.pojo.enums.EnergyResponseEnum;
|
import com.njcn.energy.pojo.enums.EnergyResponseEnum;
|
||||||
import com.njcn.energy.pojo.po.AirStrategy;
|
|
||||||
import com.njcn.energy.pojo.po.EleLogs;
|
import com.njcn.energy.pojo.po.EleLogs;
|
||||||
import com.njcn.energy.service.IEleLogsService;
|
import com.njcn.energy.service.IEleLogsService;
|
||||||
import com.njcn.energy.service.IModelService;
|
import com.njcn.energy.service.IModelService;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import io.swagger.models.auth.In;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.json.JSON;
|
|
||||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
@@ -54,139 +42,134 @@ public class MqttMessageHandler {
|
|||||||
private final IEleLogsService eleLogsService;
|
private final IEleLogsService eleLogsService;
|
||||||
|
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * 设备注册
|
* 设备注册
|
||||||
// */
|
*/
|
||||||
// @MqttSubscribe(value = "/device/register",qos = 1)
|
@MqttSubscribe(value = "/device/register",qos = 1)
|
||||||
// public void register(String topic, MqttMessage message, @Payload String payload) {
|
public void register(String topic, MqttMessage message, @Payload String payload) {
|
||||||
// String result = modelService.deviceRegister(new String(message.getPayload(), StandardCharsets.UTF_8));
|
String result = modelService.deviceRegister(new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||||
// publisher.send("/platform/register",result,1,false);
|
publisher.send("/platform/register",result,1,false);
|
||||||
// EleLogs eleLogs = new EleLogs();
|
EleLogs eleLogs = new EleLogs();
|
||||||
// eleLogs.setType(1);
|
eleLogs.setType(1);
|
||||||
// //设备取消注册,需要通知平台
|
//设备取消注册,需要通知平台
|
||||||
|
Gson gson = new Gson();
|
||||||
|
RegisterDTO.RegisterRequest registerDTO = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), RegisterDTO.RegisterRequest.class);
|
||||||
|
RegisterDTO.RegisterResponse response = gson.fromJson(result, RegisterDTO.RegisterResponse.class);
|
||||||
|
if (registerDTO.getParam().getType() == 0){
|
||||||
|
eleLogs.setType(0);
|
||||||
|
if (response.getCode() == 200 && response.getParam().getRes() == 1){
|
||||||
|
DeviceOperateDTO deviceOperateDTO = new DeviceOperateDTO();
|
||||||
|
deviceOperateDTO.setNdid(registerDTO.getParam().getNDid());
|
||||||
|
deviceOperateDTO.setDid(response.getParam().getDid());
|
||||||
|
deviceOperateDTO.setTime(Long.toString(System.currentTimeMillis()/1000));
|
||||||
|
deviceOperateDTO.setMessage("装置取消注册");
|
||||||
|
deviceOperateDTO.setType("003");
|
||||||
|
publisher.send("/device/platform",gson.toJson(deviceOperateDTO),1,false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//将日志存库
|
||||||
|
eleLogs.setNdid(registerDTO.getParam().getNDid());
|
||||||
|
eleLogs.setReqTime(LocalDateTime.ofEpochSecond(Long.parseLong(registerDTO.getTimestamp()), 0, ZoneOffset.ofHours(8)));
|
||||||
|
eleLogs.setInfo(response.getMsg());
|
||||||
|
eleLogs.setCreateTime(LocalDateTime.now());
|
||||||
|
eleLogsService.addLogs(eleLogs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备接入
|
||||||
|
*/
|
||||||
|
@MqttSubscribe(value = "/device/pltreq/{version}/{edgeId}",qos = 1)
|
||||||
|
public void access(String topic, MqttMessage message, @NamedValue("edgeId") String edgeId,@NamedValue("version") String version, @Payload String payload) throws InterruptedException {
|
||||||
|
String result = modelService.deviceAccess(new String(message.getPayload(), StandardCharsets.UTF_8),edgeId);
|
||||||
|
Gson gson = new Gson();
|
||||||
|
RegisterDTO.RegisterRequest registerDTO = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), RegisterDTO.RegisterRequest.class);
|
||||||
|
RegisterDTO.RegisterResponse response = gson.fromJson(result, RegisterDTO.RegisterResponse.class);
|
||||||
|
//设备接入成功,需要通知平台
|
||||||
|
if (response.getCode() == 200 && Objects.equals(response.getType(), ApiParam.REP_LINKUP)){
|
||||||
|
DeviceOperateDTO deviceOperateDTO = new DeviceOperateDTO();
|
||||||
|
deviceOperateDTO.setNdid(edgeId);
|
||||||
|
deviceOperateDTO.setDid(registerDTO.getParam().getDid());
|
||||||
|
deviceOperateDTO.setTime(Long.toString(System.currentTimeMillis()/1000));
|
||||||
|
deviceOperateDTO.setMessage("装置上线");
|
||||||
|
deviceOperateDTO.setType("004");
|
||||||
|
publisher.send("/device/platform",gson.toJson(deviceOperateDTO),1,false);
|
||||||
|
deviceOperateDTO.setMessage("主题更新");
|
||||||
|
deviceOperateDTO.setType("002");
|
||||||
|
publisher.send("/device/operate",gson.toJson(deviceOperateDTO),1,false);
|
||||||
|
}
|
||||||
|
//有装置异常需要主动下线,需要通知平台
|
||||||
|
if (response.getCode() == 300 && Objects.equals(response.getType(), ApiParam.REP_HEARTBEAT)){
|
||||||
|
DeviceOperateDTO deviceOperateDTO = new DeviceOperateDTO();
|
||||||
|
deviceOperateDTO.setNdid(edgeId);
|
||||||
|
deviceOperateDTO.setDid(registerDTO.getParam().getDid());
|
||||||
|
deviceOperateDTO.setTime(Long.toString(System.currentTimeMillis()/1000));
|
||||||
|
deviceOperateDTO.setMessage("装置下线");
|
||||||
|
deviceOperateDTO.setType("005");
|
||||||
|
publisher.send("/device/platform",gson.toJson(deviceOperateDTO),1,false);
|
||||||
|
response.setCode(Integer.parseInt(EnergyResponseEnum.SUCCESS.getCode()));
|
||||||
|
result = gson.toJson(response);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 如果心跳超过3分钟,下线当前网关所有装置,需要通知平台,记录数据库掉线时间
|
||||||
|
* 使用redis的过期时间做处理
|
||||||
|
*/
|
||||||
|
redisUtil.saveByKeyWithExpire("MQTT:" + edgeId,registerDTO.getTimestamp(),180L);
|
||||||
|
redisUtil.saveByKeyWithExpire(edgeId,registerDTO.getTimestamp(),200L);
|
||||||
|
//将日志存库
|
||||||
|
if (!Objects.equals(response.getType(), ApiParam.REP_HEARTBEAT)){
|
||||||
|
EleLogs eleLogs = new EleLogs();
|
||||||
|
eleLogs.setType(2);
|
||||||
|
eleLogs.setNdid(edgeId);
|
||||||
|
eleLogs.setReqTime(LocalDateTime.ofEpochSecond(Long.parseLong(registerDTO.getTimestamp()), 0, ZoneOffset.ofHours(8)));
|
||||||
|
eleLogs.setInfo(response.getMsg());
|
||||||
|
eleLogs.setCreateTime(LocalDateTime.now());
|
||||||
|
eleLogsService.addLogs(eleLogs);
|
||||||
|
}
|
||||||
|
//回复装置信息
|
||||||
|
publisher.send("/device/pltrep/"+version+"/" + edgeId,result,1,false);
|
||||||
|
|
||||||
|
// 询问模板数据 暂时线下传递模板数据
|
||||||
// Gson gson = new Gson();
|
// Gson gson = new Gson();
|
||||||
// RegisterDTO.RegisterRequest registerDTO = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), RegisterDTO.RegisterRequest.class);
|
// AccessDTO.AccessResponse response = gson.fromJson(result,AccessDTO.AccessResponse.class);
|
||||||
// RegisterDTO.RegisterResponse response = gson.fromJson(result, RegisterDTO.RegisterResponse.class);
|
// if (response.getCode() == Integer.parseInt(EnergyResponseEnum.NO_MODEL_FIND.getCode())){
|
||||||
// if (registerDTO.getParam().getType() == 0){
|
// AskDataDTO.AskDataRequest askDataDTO = new AskDataDTO.AskDataRequest();
|
||||||
// eleLogs.setType(0);
|
// askDataDTO.setTimestamp(Long.toString(System.currentTimeMillis()/1000));
|
||||||
// if (response.getCode() == 200 && response.getParam().getRes() == 1){
|
// askDataDTO.setLevel(0);
|
||||||
// DeviceOperateDTO deviceOperateDTO = new DeviceOperateDTO();
|
// askDataDTO.setType(ApiParam.CMD_DEV_DATA);
|
||||||
// deviceOperateDTO.setNdid(registerDTO.getParam().getNDid());
|
// AskDataParamDTO askDataParamDTO = new AskDataParamDTO();
|
||||||
// deviceOperateDTO.setDid(response.getParam().getDid());
|
// askDataParamDTO.setDataType(DataType.TEMPLATE);
|
||||||
// deviceOperateDTO.setTime(Long.toString(System.currentTimeMillis()/1000));
|
// askDataParamDTO.setOperate(ModelState.READ);
|
||||||
// deviceOperateDTO.setMessage("装置取消注册");
|
// askDataParamDTO.setStartTime(Long.toString(System.currentTimeMillis()/1000));
|
||||||
// deviceOperateDTO.setType("003");
|
// askDataDTO.setParam(askDataParamDTO);
|
||||||
// publisher.send("/device/platform",gson.toJson(deviceOperateDTO),1,false);
|
// publisher.send("/platform/command/v1/" + edgeId,gson.toJson(askDataDTO),1,false);
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// //将日志存库
|
|
||||||
// eleLogs.setNdid(registerDTO.getParam().getNDid());
|
|
||||||
// eleLogs.setReqTime(LocalDateTime.ofEpochSecond(Long.parseLong(registerDTO.getTimestamp()), 0, ZoneOffset.ofHours(8)));
|
|
||||||
// eleLogs.setInfo(response.getMsg());
|
|
||||||
// eleLogs.setCreateTime(LocalDateTime.now());
|
|
||||||
// eleLogsService.addLogs(eleLogs);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 设备接入
|
|
||||||
// */
|
|
||||||
// @MqttSubscribe(value = "/device/pltreq/{version}/{edgeId}",qos = 1)
|
|
||||||
// public void access(String topic, MqttMessage message, @NamedValue("edgeId") String edgeId,@NamedValue("version") String version, @Payload String payload) throws InterruptedException {
|
|
||||||
// String result = modelService.deviceAccess(new String(message.getPayload(), StandardCharsets.UTF_8),edgeId);
|
|
||||||
// Gson gson = new Gson();
|
|
||||||
// RegisterDTO.RegisterRequest registerDTO = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), RegisterDTO.RegisterRequest.class);
|
|
||||||
// RegisterDTO.RegisterResponse response = gson.fromJson(result, RegisterDTO.RegisterResponse.class);
|
|
||||||
// //设备接入成功,需要通知平台
|
|
||||||
// if (response.getCode() == 200 && Objects.equals(response.getType(), ApiParam.REP_LINKUP)){
|
|
||||||
// DeviceOperateDTO deviceOperateDTO = new DeviceOperateDTO();
|
|
||||||
// deviceOperateDTO.setNdid(edgeId);
|
|
||||||
// deviceOperateDTO.setDid(registerDTO.getParam().getDid());
|
|
||||||
// deviceOperateDTO.setTime(Long.toString(System.currentTimeMillis()/1000));
|
|
||||||
// deviceOperateDTO.setMessage("装置上线");
|
|
||||||
// deviceOperateDTO.setType("004");
|
|
||||||
// publisher.send("/device/platform",gson.toJson(deviceOperateDTO),1,false);
|
|
||||||
// deviceOperateDTO.setMessage("主题更新");
|
|
||||||
// deviceOperateDTO.setType("002");
|
|
||||||
// publisher.send("/device/operate",gson.toJson(deviceOperateDTO),1,false);
|
|
||||||
// }
|
|
||||||
// //有装置异常需要主动下线,需要通知平台
|
|
||||||
// if (response.getCode() == 300 && Objects.equals(response.getType(), ApiParam.REP_HEARTBEAT)){
|
|
||||||
// DeviceOperateDTO deviceOperateDTO = new DeviceOperateDTO();
|
|
||||||
// deviceOperateDTO.setNdid(edgeId);
|
|
||||||
// deviceOperateDTO.setDid(registerDTO.getParam().getDid());
|
|
||||||
// deviceOperateDTO.setTime(Long.toString(System.currentTimeMillis()/1000));
|
|
||||||
// deviceOperateDTO.setMessage("装置下线");
|
|
||||||
// deviceOperateDTO.setType("005");
|
|
||||||
// publisher.send("/device/platform",gson.toJson(deviceOperateDTO),1,false);
|
|
||||||
// response.setCode(Integer.parseInt(EnergyResponseEnum.SUCCESS.getCode()));
|
|
||||||
// result = gson.toJson(response);
|
|
||||||
// }
|
|
||||||
// /**
|
|
||||||
// * 如果心跳超过3分钟,下线当前网关所有装置,需要通知平台,记录数据库掉线时间
|
|
||||||
// * 使用redis的过期时间做处理
|
|
||||||
// */
|
|
||||||
// redisUtil.saveByKeyWithExpire("MQTT:" + edgeId,registerDTO.getTimestamp(),180L);
|
|
||||||
// redisUtil.saveByKeyWithExpire(edgeId,registerDTO.getTimestamp(),200L);
|
|
||||||
// //将日志存库
|
|
||||||
// if (!Objects.equals(response.getType(), ApiParam.REP_HEARTBEAT)){
|
|
||||||
// EleLogs eleLogs = new EleLogs();
|
|
||||||
// eleLogs.setType(2);
|
|
||||||
// eleLogs.setNdid(edgeId);
|
|
||||||
// eleLogs.setReqTime(LocalDateTime.ofEpochSecond(Long.parseLong(registerDTO.getTimestamp()), 0, ZoneOffset.ofHours(8)));
|
|
||||||
// eleLogs.setInfo(response.getMsg());
|
|
||||||
// eleLogs.setCreateTime(LocalDateTime.now());
|
|
||||||
// eleLogsService.addLogs(eleLogs);
|
|
||||||
// }
|
|
||||||
// //回复装置信息
|
|
||||||
// publisher.send("/device/pltrep/"+version+"/" + edgeId,result,1,false);
|
|
||||||
//
|
|
||||||
//// 询问模板数据 暂时线下传递模板数据
|
|
||||||
//// Gson gson = new Gson();
|
|
||||||
//// AccessDTO.AccessResponse response = gson.fromJson(result,AccessDTO.AccessResponse.class);
|
|
||||||
//// if (response.getCode() == Integer.parseInt(EnergyResponseEnum.NO_MODEL_FIND.getCode())){
|
|
||||||
//// AskDataDTO.AskDataRequest askDataDTO = new AskDataDTO.AskDataRequest();
|
|
||||||
//// askDataDTO.setTimestamp(Long.toString(System.currentTimeMillis()/1000));
|
|
||||||
//// askDataDTO.setLevel(0);
|
|
||||||
//// askDataDTO.setType(ApiParam.CMD_DEV_DATA);
|
|
||||||
//// AskDataParamDTO askDataParamDTO = new AskDataParamDTO();
|
|
||||||
//// askDataParamDTO.setDataType(DataType.TEMPLATE);
|
|
||||||
//// askDataParamDTO.setOperate(ModelState.READ);
|
|
||||||
//// askDataParamDTO.setStartTime(Long.toString(System.currentTimeMillis()/1000));
|
|
||||||
//// askDataDTO.setParam(askDataParamDTO);
|
|
||||||
//// publisher.send("/platform/command/v1/" + edgeId,gson.toJson(askDataDTO),1,false);
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 获取模板信息
|
|
||||||
// */
|
|
||||||
// @MqttSubscribe(value = "/platform/reply/{version}/{edgeId}",qos = 1)
|
|
||||||
// public void replyTemplate(String topic, MqttMessage message, @NamedValue("edgeId") String edgeId, @Payload String payload) {
|
|
||||||
// String result = modelService.deviceData(new String(message.getPayload(), StandardCharsets.UTF_8));
|
|
||||||
// //模板发生变更通知其他云服务
|
|
||||||
// Gson gson = new Gson();
|
|
||||||
// RegisterDTO.RegisterResponse response = gson.fromJson(result, RegisterDTO.RegisterResponse.class);
|
|
||||||
// if (Objects.equals(response.getCode(),200)){
|
|
||||||
// DeviceOperateDTO deviceOperateDTO = new DeviceOperateDTO();
|
|
||||||
// deviceOperateDTO.setTime(Long.toString(System.currentTimeMillis()));
|
|
||||||
// deviceOperateDTO.setMessage("模板更新");
|
|
||||||
// deviceOperateDTO.setType("001");
|
|
||||||
// publisher.send("/device/operate",gson.toJson(deviceOperateDTO),1,false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 获取网关订阅的主题
|
|
||||||
// */
|
|
||||||
// @MqttSubscribe(value = "/device/topic/{edgeId}",qos = 1)
|
|
||||||
// public void subscribeTopic(String topic, MqttMessage message, @NamedValue("edgeId") String edgeId, @Payload String payload) {
|
|
||||||
// modelService.subscribeTopic(new String(message.getPayload(), StandardCharsets.UTF_8),edgeId);
|
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模板信息
|
||||||
|
*/
|
||||||
|
@MqttSubscribe(value = "/platform/reply/{version}/{edgeId}",qos = 1)
|
||||||
|
public void replyTemplate(String topic, MqttMessage message, @NamedValue("edgeId") String edgeId, @Payload String payload) {
|
||||||
|
String result = modelService.deviceData(new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||||
|
//模板发生变更通知其他云服务
|
||||||
|
Gson gson = new Gson();
|
||||||
|
RegisterDTO.RegisterResponse response = gson.fromJson(result, RegisterDTO.RegisterResponse.class);
|
||||||
|
if (Objects.equals(response.getCode(),200)){
|
||||||
|
DeviceOperateDTO deviceOperateDTO = new DeviceOperateDTO();
|
||||||
|
deviceOperateDTO.setTime(Long.toString(System.currentTimeMillis()));
|
||||||
|
deviceOperateDTO.setMessage("模板更新");
|
||||||
|
deviceOperateDTO.setType("001");
|
||||||
|
publisher.send("/device/operate",gson.toJson(deviceOperateDTO),1,false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取网关订阅的主题
|
||||||
|
*/
|
||||||
|
@MqttSubscribe(value = "/device/topic/{edgeId}",qos = 1)
|
||||||
|
public void subscribeTopic(String topic, MqttMessage message, @NamedValue("edgeId") String edgeId, @Payload String payload) {
|
||||||
|
modelService.subscribeTopic(new String(message.getPayload(), StandardCharsets.UTF_8),edgeId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public interface EleAirStrategyService extends IService<AirStrategy> {
|
|||||||
* @author cdf
|
* @author cdf
|
||||||
* @date 2022/4/22
|
* @date 2022/4/22
|
||||||
*/
|
*/
|
||||||
void dealAirStrategyId(String id,String operation);
|
void dealAirStrategyId(String operation);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.db.constant.DbConstant;
|
import com.njcn.db.constant.DbConstant;
|
||||||
import com.njcn.energy.handler.MqttMessageHandler;
|
|
||||||
import com.njcn.energy.mapper.AirStrategyMapper;
|
import com.njcn.energy.mapper.AirStrategyMapper;
|
||||||
import com.njcn.energy.mapper.LogicDeviceLineMapper;
|
import com.njcn.energy.mapper.LogicDeviceLineMapper;
|
||||||
import com.njcn.energy.pojo.dto.AirStrategyDTO;
|
import com.njcn.energy.pojo.dto.AirStrategyDTO;
|
||||||
@@ -33,11 +32,11 @@ import com.njcn.energy.pojo.vo.AirStrategyVO;
|
|||||||
import com.njcn.energy.service.EleAirStrategyService;
|
import com.njcn.energy.service.EleAirStrategyService;
|
||||||
import com.njcn.energy.service.IEleSetService;
|
import com.njcn.energy.service.IEleSetService;
|
||||||
import com.njcn.influx.utils.InfluxDbUtils;
|
import com.njcn.influx.utils.InfluxDbUtils;
|
||||||
import com.njcn.job.api.JobFeignClient;
|
//import com.njcn.job.api.JobFeignClient;
|
||||||
import com.njcn.job.model.XxlJobInfo;
|
//import com.njcn.job.model.XxlJobInfo;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
import com.njcn.web.utils.RequestUtil;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
//import com.xxl.job.core.biz.model.ReturnT;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||||
import org.influxdb.dto.QueryResult;
|
import org.influxdb.dto.QueryResult;
|
||||||
@@ -67,7 +66,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
|
|
||||||
private final IEleSetService iEleSetService;
|
private final IEleSetService iEleSetService;
|
||||||
|
|
||||||
private final JobFeignClient jobFeignClient;
|
//private final JobFeignClient jobFeignClient;
|
||||||
|
|
||||||
private final LogicDeviceLineMapper logicDeviceLineMapper;
|
private final LogicDeviceLineMapper logicDeviceLineMapper;
|
||||||
|
|
||||||
@@ -75,7 +74,6 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
|
|
||||||
private final AirStrategyMapper airStrategyMapper;
|
private final AirStrategyMapper airStrategyMapper;
|
||||||
|
|
||||||
private final MqttMessageHandler mqttMessageHandler;
|
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
private final InfluxDbUtils influxDbUtils;
|
||||||
|
|
||||||
@@ -160,7 +158,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
String cronOn = "" + startTime.getSecond() + CharUtil.SPACE + startTime.getMinute() + CharUtil.SPACE + startTime.getHour() + CharUtil.SPACE + startTime.getDayOfMonth() + CharUtil.SPACE + startTime.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTime.getYear();
|
String cronOn = "" + startTime.getSecond() + CharUtil.SPACE + startTime.getMinute() + CharUtil.SPACE + startTime.getHour() + CharUtil.SPACE + startTime.getDayOfMonth() + CharUtil.SPACE + startTime.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTime.getYear();
|
||||||
String paramOn = "open" + StrUtil.C_COMMA + airStrategy.getId();
|
String paramOn = "open" + StrUtil.C_COMMA + airStrategy.getId();
|
||||||
|
|
||||||
XxlJobInfo xxlJobInfo = assScheduling("测试定时开空调",cronOn,paramOn);
|
/* XxlJobInfo xxlJobInfo = assScheduling("测试定时开空调",cronOn,paramOn);
|
||||||
HttpResult<String> result = jobFeignClient.addJob(xxlJobInfo);
|
HttpResult<String> result = jobFeignClient.addJob(xxlJobInfo);
|
||||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||||
@@ -178,7 +176,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
}
|
}
|
||||||
|
|
||||||
String ids = result.getData() + StrUtil.COMMA + result2.getData();
|
String ids = result.getData() + StrUtil.COMMA + result2.getData();
|
||||||
airStrategy.setXxlId(ids);
|
airStrategy.setXxlId(ids);*/
|
||||||
this.updateById(airStrategy);
|
this.updateById(airStrategy);
|
||||||
} else if(airStrategyParam.getType() == 1) {
|
} else if(airStrategyParam.getType() == 1) {
|
||||||
|
|
||||||
@@ -196,7 +194,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
* 添加开机调度任务
|
* 添加开机调度任务
|
||||||
*/
|
*/
|
||||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||||
String startTime = airStrategyOnOff.getStartTime();
|
/* String startTime = airStrategyOnOff.getStartTime();
|
||||||
String[] temTime = startTime.split(":");
|
String[] temTime = startTime.split(":");
|
||||||
String cron = "0" + CharUtil.SPACE + temTime[1] + CharUtil.SPACE + temTime[0] + CharUtil.SPACE + "* * ?";
|
String cron = "0" + CharUtil.SPACE + temTime[1] + CharUtil.SPACE + temTime[0] + CharUtil.SPACE + "* * ?";
|
||||||
String param = "close" + StrUtil.C_COMMA + airStrategyOnOff.getId();
|
String param = "close" + StrUtil.C_COMMA + airStrategyOnOff.getId();
|
||||||
@@ -205,7 +203,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||||
}
|
}
|
||||||
airStrategyOnOff.setXxlId(result.getData());
|
airStrategyOnOff.setXxlId(result.getData());*/
|
||||||
this.updateById(airStrategyOnOff);
|
this.updateById(airStrategyOnOff);
|
||||||
} else if(airStrategyParam.getType() == 2) {
|
} else if(airStrategyParam.getType() == 2) {
|
||||||
//开机策略
|
//开机策略
|
||||||
@@ -219,7 +217,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
/*
|
/*
|
||||||
* 添加开机调度任务
|
* 添加开机调度任务
|
||||||
*/
|
*/
|
||||||
String startTime = airStrategyOnOff.getStartTime();
|
/* String startTime = airStrategyOnOff.getStartTime();
|
||||||
String[] temTime = startTime.split(":");
|
String[] temTime = startTime.split(":");
|
||||||
String cron = "0" + CharUtil.SPACE + temTime[1] + CharUtil.SPACE + temTime[0] + CharUtil.SPACE + "* * ?";
|
String cron = "0" + CharUtil.SPACE + temTime[1] + CharUtil.SPACE + temTime[0] + CharUtil.SPACE + "* * ?";
|
||||||
String param = "open" + StrUtil.C_COMMA + airStrategyOnOff.getId();
|
String param = "open" + StrUtil.C_COMMA + airStrategyOnOff.getId();
|
||||||
@@ -228,7 +226,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||||
}
|
}
|
||||||
airStrategyOnOff.setXxlId(result.getData());
|
airStrategyOnOff.setXxlId(result.getData());*/
|
||||||
this.updateById(airStrategyOnOff);
|
this.updateById(airStrategyOnOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,6 +248,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*组装调度任务*/
|
/*组装调度任务*/
|
||||||
|
/*
|
||||||
private XxlJobInfo assScheduling(String desc,String confTime,String param){
|
private XxlJobInfo assScheduling(String desc,String confTime,String param){
|
||||||
XxlJobInfo xxlJobInfo = new XxlJobInfo();
|
XxlJobInfo xxlJobInfo = new XxlJobInfo();
|
||||||
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
||||||
@@ -270,6 +269,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
xxlJobInfo.setGlueRemark("GLUE代码初始化");
|
xxlJobInfo.setGlueRemark("GLUE代码初始化");
|
||||||
return xxlJobInfo;
|
return xxlJobInfo;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -295,7 +295,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
});
|
});
|
||||||
iEleSetService.saveBatch(list);
|
iEleSetService.saveBatch(list);
|
||||||
|
|
||||||
|
/*
|
||||||
String[] jobIds = airStrategyRes.getXxlId().split(StrUtil.COMMA);
|
String[] jobIds = airStrategyRes.getXxlId().split(StrUtil.COMMA);
|
||||||
if(updateParam.getType() == 0) {
|
if(updateParam.getType() == 0) {
|
||||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||||
@@ -343,7 +343,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
if (result.getCode().equals(String.valueOf(ReturnT.FAIL_CODE))) {
|
||||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,14 +368,14 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
lambdaQueryWrapper.eq(AirSet::getId, id);
|
lambdaQueryWrapper.eq(AirSet::getId, id);
|
||||||
iEleSetService.remove(lambdaQueryWrapper);
|
iEleSetService.remove(lambdaQueryWrapper);
|
||||||
|
|
||||||
String[] arr = airStrategy.getXxlId().split(StrUtil.COMMA);
|
/* String[] arr = airStrategy.getXxlId().split(StrUtil.COMMA);
|
||||||
|
|
||||||
for (String xxlId : arr) {
|
for (String xxlId : arr) {
|
||||||
HttpResult<String> result = jobFeignClient.removeJob(Integer.parseInt(xxlId));
|
HttpResult<String> result = jobFeignClient.removeJob(Integer.parseInt(xxlId));
|
||||||
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
||||||
throw new BusinessException(EnergyResponseEnum.TASK_DEL_ERROR);
|
throw new BusinessException(EnergyResponseEnum.TASK_DEL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -391,13 +391,13 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
if (airStrategy.getStatus() != 1) {
|
if (airStrategy.getStatus() != 1) {
|
||||||
throw new BusinessException(EnergyResponseEnum.TASK_NO_RUN);
|
throw new BusinessException(EnergyResponseEnum.TASK_NO_RUN);
|
||||||
}
|
}
|
||||||
String[] arr = airStrategy.getXxlId().split(StrUtil.COMMA);
|
/* String[] arr = airStrategy.getXxlId().split(StrUtil.COMMA);
|
||||||
for (String xxlId : arr) {
|
for (String xxlId : arr) {
|
||||||
HttpResult<String> result = jobFeignClient.stopJob(Integer.parseInt(xxlId));
|
HttpResult<String> result = jobFeignClient.stopJob(Integer.parseInt(xxlId));
|
||||||
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
||||||
throw new BusinessException(EnergyResponseEnum.TASK_STOP_ERROR);
|
throw new BusinessException(EnergyResponseEnum.TASK_STOP_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
this.lambdaUpdate()
|
this.lambdaUpdate()
|
||||||
.set(AirStrategy::getStatus, 4)
|
.set(AirStrategy::getStatus, 4)
|
||||||
@@ -432,21 +432,21 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
String[] ids = airStrategy.getXxlId().split(StrUtil.COMMA);
|
String[] ids = airStrategy.getXxlId().split(StrUtil.COMMA);
|
||||||
if (airStrategy.getStatus() == 0) {
|
if (airStrategy.getStatus() == 0) {
|
||||||
//可以启动
|
//可以启动
|
||||||
for (String xxlId : ids) {
|
/* for (String xxlId : ids) {
|
||||||
HttpResult<String> result = jobFeignClient.startTask(Integer.parseInt(xxlId));
|
HttpResult<String> result = jobFeignClient.startTask(Integer.parseInt(xxlId));
|
||||||
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
||||||
throw new BusinessException(EnergyResponseEnum.TASK_RUNING);
|
throw new BusinessException(EnergyResponseEnum.TASK_RUNING);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
this.lambdaUpdate().set(AirStrategy::getStatus, 1).eq(AirStrategy::getId, id).update();
|
this.lambdaUpdate().set(AirStrategy::getStatus, 1).eq(AirStrategy::getId, id).update();
|
||||||
} else if (airStrategy.getStatus() == 1) {
|
} else if (airStrategy.getStatus() == 1) {
|
||||||
//已经执行中
|
//已经执行中
|
||||||
for (String xxlId : ids) {
|
/* for (String xxlId : ids) {
|
||||||
HttpResult<String> result = jobFeignClient.stopJob(Integer.parseInt(xxlId));
|
HttpResult<String> result = jobFeignClient.stopJob(Integer.parseInt(xxlId));
|
||||||
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
||||||
throw new BusinessException(EnergyResponseEnum.TASK_DEL_ERROR);
|
throw new BusinessException(EnergyResponseEnum.TASK_DEL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
this.lambdaUpdate().set(AirStrategy::getStatus, 0).eq(AirStrategy::getId, id).update();
|
this.lambdaUpdate().set(AirStrategy::getStatus, 0).eq(AirStrategy::getId, id).update();
|
||||||
} else {
|
} else {
|
||||||
//已经完成
|
//已经完成
|
||||||
@@ -457,16 +457,16 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealAirStrategyId(String id, String operation) {
|
public void dealAirStrategyId(String operation) {
|
||||||
try {
|
try {
|
||||||
AirStrategy airStrategy = this.getById(id);
|
AirStrategy airStrategy = this.list(new LambdaQueryWrapper<>()).get(0);
|
||||||
if (Objects.isNull(airStrategy)) {
|
if (Objects.isNull(airStrategy)) {
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LambdaQueryWrapper<AirSet> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AirSet> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(AirSet::getId, id);
|
lambdaQueryWrapper.eq(AirSet::getId, airStrategy.getId());
|
||||||
List<AirSet> list = iEleSetService.list(lambdaQueryWrapper);
|
List<AirSet> list = iEleSetService.list(lambdaQueryWrapper);
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
List<String> lineIds = list.stream().map(AirSet::getLineId).collect(Collectors.toList());
|
List<String> lineIds = list.stream().map(AirSet::getLineId).collect(Collectors.toList());
|
||||||
@@ -527,13 +527,10 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
publisher.send(topic, json, 1, false);
|
publisher.send(topic, json, 1, false);
|
||||||
|
|
||||||
|
|
||||||
//mqttMessageHandler.setMqttParam(0,topic,json);
|
|
||||||
this.mqttSendCount = 0;
|
this.mqttSendCount = 0;
|
||||||
this.mqttJsonMsg = json;
|
this.mqttJsonMsg = json;
|
||||||
this.mqttSendTopic = topic;
|
this.mqttSendTopic = topic;
|
||||||
flag = true;
|
|
||||||
|
|
||||||
Thread.sleep(3000);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -558,9 +555,11 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
this.mqttSendCount = 0;
|
this.mqttSendCount = 0;
|
||||||
this.mqttJsonMsg = json;
|
this.mqttJsonMsg = json;
|
||||||
this.mqttSendTopic = topic;
|
this.mqttSendTopic = topic;
|
||||||
flag = true;
|
|
||||||
Thread.sleep(3000);
|
System.out.println("发送关空调控制"+LocalDateTime.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Thread.sleep(8000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("close".equals(operation) && airStrategy.getType() == 0) {
|
if ("close".equals(operation) && airStrategy.getType() == 0) {
|
||||||
@@ -581,33 +580,28 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Boolean flag = false;
|
|
||||||
private Integer mqttSendCount = 0;
|
private Integer mqttSendCount = 0;
|
||||||
private String mqttJsonMsg;
|
private String mqttJsonMsg;
|
||||||
private String mqttSendTopic;
|
private String mqttSendTopic;
|
||||||
|
|
||||||
@MqttSubscribe(value = "/platform/devack/#", qos = 1)
|
@MqttSubscribe(value = "/platform/devack/#", qos = 1)
|
||||||
public void airOperation(String topic, MqttMessage message, @Payload String payload) {
|
public void airOperation(String topic, MqttMessage message, @Payload String payload) {
|
||||||
|
System.out.println("收到网关反馈控制"+LocalDateTime.now());
|
||||||
System.out.println(message.toString());
|
System.out.println(message.toString());
|
||||||
JSONObject jsonObject = new JSONObject(message.toString());
|
JSONObject jsonObject = new JSONObject(message.toString());
|
||||||
String str = jsonObject.getStr("userId");
|
String str = jsonObject.getStr("userId");
|
||||||
|
|
||||||
if (str.equals(clientId)) {
|
if (str.equals(clientId)) {
|
||||||
|
|
||||||
if (!jsonObject.getStr("code").equals("200")) {
|
if (!jsonObject.getStr("code").equals("200")) {
|
||||||
mqttSendCount++;
|
mqttSendCount++;
|
||||||
if (mqttSendCount < 3) {
|
if (mqttSendCount < 3) {
|
||||||
System.out.println("进入错误重发++++++");
|
System.out.println("进入错误重发++++++");
|
||||||
System.out.println("错误重发详情" + mqttJsonMsg);
|
System.out.println("错误重发详情" + mqttJsonMsg);
|
||||||
publisher.send(mqttSendTopic, mqttJsonMsg, 1, false);
|
publisher.send(mqttSendTopic, mqttJsonMsg, 1, false);
|
||||||
} else {
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.njcn.energy.pojo.vo.LoadStatisticVO;
|
|||||||
import com.njcn.energy.pojo.vo.LoadTendencyVO;
|
import com.njcn.energy.pojo.vo.LoadTendencyVO;
|
||||||
import com.njcn.energy.service.HighAnalyticService;
|
import com.njcn.energy.service.HighAnalyticService;
|
||||||
import com.njcn.influx.utils.InfluxDbUtils;
|
import com.njcn.influx.utils.InfluxDbUtils;
|
||||||
import com.njcn.job.api.JobFeignClient;
|
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.system.enums.DicDataTypeEnum;
|
import com.njcn.system.enums.DicDataTypeEnum;
|
||||||
import com.njcn.system.enums.SystemResponseEnum;
|
import com.njcn.system.enums.SystemResponseEnum;
|
||||||
@@ -59,7 +58,6 @@ public class HighAnalyticServiceImpl implements HighAnalyticService {
|
|||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
private final InfluxDbUtils influxDbUtils;
|
||||||
|
|
||||||
private final JobFeignClient jobFeignClient;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ public class LogicDeviceLineServiceImpl extends ServiceImpl<LogicDeviceLineMappe
|
|||||||
stringBuilderMax.append(listData.get(j).getName()).append(", ");
|
stringBuilderMax.append(listData.get(j).getName()).append(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stringBuilderMax.append("from ").append(tableName + "_Real").append(" where").append(" LineId='" + lineId + "'").append(" order by time").append(InfluxDBPublicParam.TIME_ZONE);
|
stringBuilderMax.append("from ").append(tableName + "_Real").append(" where").append(" LineId='" + lineId + "'").append(" order by time");
|
||||||
List<Map<String, Object>> list = influxDbUtils.getResult(stringBuilderMax.toString(), "");
|
List<Map<String, Object>> list = influxDbUtils.getResult(stringBuilderMax.toString(), "");
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
for(int i=0;i<list.size();i++){
|
for(int i=0;i<list.size();i++){
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.njcn.event.pojo.param.EventCountParam;
|
|||||||
import com.njcn.event.pojo.po.EventDetail;
|
import com.njcn.event.pojo.po.EventDetail;
|
||||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||||
import com.njcn.event.pojo.vo.GeneralVO;
|
import com.njcn.event.pojo.vo.GeneralVO;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
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.RequestBody;
|
||||||
@@ -69,4 +70,10 @@ public interface EventDetailFeignClient {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/getAppEventDetailLtAmplitude")
|
@PostMapping("/getAppEventDetailLtAmplitude")
|
||||||
HttpResult<List<RmpEventDetailPO>> getAppEventDetailLtAmplitude(@RequestBody EventCountParam param);
|
HttpResult<List<RmpEventDetailPO>> getAppEventDetailLtAmplitude(@RequestBody EventCountParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据监测点id集合和统计类型,查询暂态信息
|
||||||
|
*/
|
||||||
|
@PostMapping("/getEventDetailByEventType")
|
||||||
|
HttpResult<List<RmpEventDetailPO>> getEventDetailByEventType(@RequestBody EventCountParam param);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,12 @@ public class EventDetailFeignClientFallbackFactory implements FallbackFactory<Ev
|
|||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<List<RmpEventDetailPO>> getEventDetailByEventType(EventCountParam param) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合和统计类型,查询暂态信息", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,8 @@ public class EventCountParam implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty(name="endTime",value="统计截止日期(yyyy-MM-dd)")
|
@ApiModelProperty(name="endTime",value="统计截止日期(yyyy-MM-dd)")
|
||||||
private String endTime;
|
private String endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(name="eventType",value="统计类型")
|
||||||
|
private List<String> eventType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,6 +177,24 @@ public class EventDetailController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, count, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, count, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据监测点id集合和统计类型,查询暂态信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getEventDetailByEventType")
|
||||||
|
@ApiOperation("根据监测点id集合和统计类型,查询暂态信息")
|
||||||
|
public HttpResult<List<RmpEventDetailPO>> getEventDetailByEventType(@RequestBody EventCountParam param) {
|
||||||
|
String methodDescribe = getMethodDescribe("getAppEventDetailLtAmplitude");
|
||||||
|
List<RmpEventDetailPO> list = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||||
|
.in(CollUtil.isNotEmpty(param.getIds()), RmpEventDetailPO::getLineId, param.getIds())
|
||||||
|
.in(CollUtil.isNotEmpty(param.getEventType()), RmpEventDetailPO::getEventType, param.getEventType())
|
||||||
|
.ge(StrUtil.isNotBlank(param.getStartTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
|
||||||
|
.le(StrUtil.isNotBlank(param.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
|
||||||
|
);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据监测点id集合,统计时间范围内特征增幅小于0.9的暂态信息(灿能云)
|
* 根据监测点id集合,统计时间范围内特征增幅小于0.9的暂态信息(灿能云)
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@@ -3,10 +3,17 @@ package com.njcn.gateway.config;
|
|||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
|
||||||
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
|
import com.njcn.common.pojo.constant.LogInfo;
|
||||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||||
|
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||||
|
import com.njcn.common.utils.PubUtils;
|
||||||
import com.njcn.gateway.enums.GateWayEnum;
|
import com.njcn.gateway.enums.GateWayEnum;
|
||||||
import com.njcn.gateway.security.AuthorizationManager;
|
import com.njcn.gateway.security.AuthorizationManager;
|
||||||
import com.njcn.gateway.utils.ResponseUtils;
|
import com.njcn.gateway.utils.ResponseUtils;
|
||||||
|
import com.njcn.gateway.utils.WebFluxRequestUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -14,6 +21,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
||||||
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
|
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
|
||||||
import org.springframework.security.config.web.server.ServerHttpSecurity;
|
import org.springframework.security.config.web.server.ServerHttpSecurity;
|
||||||
@@ -30,6 +38,8 @@ import java.io.InputStream;
|
|||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
@@ -44,6 +54,8 @@ public class ResourceServerConfig {
|
|||||||
|
|
||||||
private final WhiteListConfig whiteListConfig;
|
private final WhiteListConfig whiteListConfig;
|
||||||
|
|
||||||
|
private final MqttPublisher publisher;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
|
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
|
||||||
|
|
||||||
@@ -75,7 +87,31 @@ public class ResourceServerConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
ServerAccessDeniedHandler accessDeniedHandler() {
|
ServerAccessDeniedHandler accessDeniedHandler() {
|
||||||
return (exchange, denied) -> Mono.defer(() -> Mono.just(exchange.getResponse()))
|
return (exchange, denied) -> Mono.defer(() -> Mono.just(exchange.getResponse()))
|
||||||
.flatMap(response -> ResponseUtils.writeErrorInfo(response, GateWayEnum.NO_AUTHORIZATION));
|
.flatMap(response -> {
|
||||||
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
|
JSONObject jsonObject = WebFluxRequestUtil.getJwtPayload(request);
|
||||||
|
String loginName = jsonObject.get("user_name").toString();
|
||||||
|
String userName = jsonObject.get("nickname").toString();
|
||||||
|
String userIndex = jsonObject.get("userIndex").toString();
|
||||||
|
String ip = WebFluxRequestUtil.getRealIp(request);
|
||||||
|
LogInfoDTO logInfoDTO = new LogInfoDTO(
|
||||||
|
loginName,
|
||||||
|
userName,
|
||||||
|
ip,
|
||||||
|
"越权访问",
|
||||||
|
"越权访问",
|
||||||
|
0,
|
||||||
|
"当前用户无该接口访问权限:"+request.getPath().toString(),
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
"",
|
||||||
|
userIndex,
|
||||||
|
LocalDateTime.now()
|
||||||
|
);
|
||||||
|
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
|
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
|
return ResponseUtils.writeErrorInfo(response, GateWayEnum.NO_AUTHORIZATION);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +120,30 @@ public class ResourceServerConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
ServerAuthenticationEntryPoint authenticationEntryPoint() {
|
ServerAuthenticationEntryPoint authenticationEntryPoint() {
|
||||||
return (exchange, e) -> Mono.defer(() -> Mono.just(exchange.getResponse()))
|
return (exchange, e) -> Mono.defer(() -> Mono.just(exchange.getResponse()))
|
||||||
.flatMap(response -> ResponseUtils.writeErrorInfo(response, GateWayEnum.ACCESS_TOKEN_EXPIRE_JWT));
|
.flatMap(response -> {
|
||||||
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
|
JSONObject jsonObject = WebFluxRequestUtil.getJwtPayload(request);
|
||||||
|
if(Objects.isNull(jsonObject)){
|
||||||
|
String ip = WebFluxRequestUtil.getRealIp(request);
|
||||||
|
LogInfoDTO logInfoDTO = new LogInfoDTO(
|
||||||
|
ip,
|
||||||
|
ip,
|
||||||
|
ip,
|
||||||
|
"越权访问",
|
||||||
|
"越权访问",
|
||||||
|
0,
|
||||||
|
"异常token访问:"+request.getPath().toString(),
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
"",
|
||||||
|
ip,
|
||||||
|
LocalDateTime.now()
|
||||||
|
);
|
||||||
|
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
|
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||||
|
}
|
||||||
|
return ResponseUtils.writeErrorInfo(response, GateWayEnum.ACCESS_TOKEN_EXPIRE_JWT);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user