Commit 071eca35 authored by tangwei's avatar tangwei

解决冲突

parents 27d14c2d dc74bac8
...@@ -66,7 +66,7 @@ public class AnalyseController extends BaseController { ...@@ -66,7 +66,7 @@ public class AnalyseController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "获取influxdb数据", notes = "获取influxdb数据") @ApiOperation(httpMethod = "GET", value = "获取influxdb数据", notes = "获取influxdb数据")
@GetMapping(value = "/getInfluxdbDataByConditon") @GetMapping(value = "/getInfluxdbDataByConditon")
public ResponseModel<List<Map<String, Object>>> getInfluxdbDataByConditon(@RequestParam String stationType, @RequestParam String pointId, @RequestParam String startTime, @RequestParam String endTime) { public ResponseModel<Map<String, Object>> getInfluxdbDataByConditon(@RequestParam String stationType, @RequestParam String pointId, @RequestParam String startTime, @RequestParam String endTime) {
return ResponseHelper.buildResponse(commonServiceImpl.getInfluxdbDataByConditon(stationType,pointId,startTime, endTime)) ; return ResponseHelper.buildResponse(commonServiceImpl.getInfluxdbDataByConditon(stationType,pointId,startTime, endTime)) ;
} }
} }
...@@ -9,6 +9,7 @@ import lombok.Data; ...@@ -9,6 +9,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
/** /**
* *
...@@ -30,7 +31,7 @@ public class IdxBizFanPointProcessVariableClassificationDto { ...@@ -30,7 +31,7 @@ public class IdxBizFanPointProcessVariableClassificationDto {
private String record; private String record;
@TableField("REC_DATE") @TableField("REC_DATE")
private LocalDateTime recDate; private Date recDate;
@TableField("REC_USER_ID") @TableField("REC_USER_ID")
private String recUserId; private String recUserId;
...@@ -93,7 +94,7 @@ public class IdxBizFanPointProcessVariableClassificationDto { ...@@ -93,7 +94,7 @@ public class IdxBizFanPointProcessVariableClassificationDto {
private String pointName; private String pointName;
@TableField("GATEWAY_ID") @TableField("GATEWAY_ID")
private Long gatewayId; private String gatewayId;
@ApiModelProperty(value = "点表地址") @ApiModelProperty(value = "点表地址")
@TableField("INDEX_ADDRESS") @TableField("INDEX_ADDRESS")
...@@ -103,4 +104,12 @@ public class IdxBizFanPointProcessVariableClassificationDto { ...@@ -103,4 +104,12 @@ public class IdxBizFanPointProcessVariableClassificationDto {
@TableField("KKS") @TableField("KKS")
private String kks; private String kks;
private Double currentValue;
private String pointOneId;
private String pointTwoId;
private String pointThreeId;
private String analysVariableId;
} }
...@@ -114,4 +114,7 @@ public class IdxBizFanPointVarCentralValueDto { ...@@ -114,4 +114,7 @@ public class IdxBizFanPointVarCentralValueDto {
@TableField("PROCESS_POINT2_ID") @TableField("PROCESS_POINT2_ID")
private Double processPoint2Id; private Double processPoint2Id;
@ApiModelProperty(value = "预警内容")
@TableField("CONTENT")
private String CONTENT;
} }
...@@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; ...@@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
/** /**
* *
...@@ -39,7 +40,7 @@ public class IdxBizFanPointVarCentralValue{ ...@@ -39,7 +40,7 @@ public class IdxBizFanPointVarCentralValue{
* *
*/ */
@TableField("REC_DATE") @TableField("REC_DATE")
private LocalDateTime recDate; private Date recDate;
/** /**
* *
...@@ -81,7 +82,7 @@ public class IdxBizFanPointVarCentralValue{ ...@@ -81,7 +82,7 @@ public class IdxBizFanPointVarCentralValue{
* *
*/ */
@TableField("ANALYSIS_POINT_ID") @TableField("ANALYSIS_POINT_ID")
private Integer analysisPointId; private String analysisPointId;
/** /**
* 片区 * 片区
...@@ -171,6 +172,6 @@ public class IdxBizFanPointVarCentralValue{ ...@@ -171,6 +172,6 @@ public class IdxBizFanPointVarCentralValue{
* 工况变量2ID * 工况变量2ID
*/ */
@TableField("PROCESS_POINT2_ID") @TableField("PROCESS_POINT2_ID")
private Double processPoint2Id; private String processPoint2Id;
} }
...@@ -125,4 +125,9 @@ public class IdxBizFanWarningRecord{ ...@@ -125,4 +125,9 @@ public class IdxBizFanWarningRecord{
@TableField("EQUIPMENT_NAME") @TableField("EQUIPMENT_NAME")
private String equipmentName; private String equipmentName;
/**
* 预警内容
* */
@TableField("CONTENT")
private String CONTENT;
} }
package com.yeejoin.amos.boot.module.jxiop.biz.mapper2; package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointProcessVariableClassification; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointProcessVariableClassification;
import java.util.List; import java.util.List;
...@@ -12,7 +13,7 @@ import java.util.List; ...@@ -12,7 +13,7 @@ import java.util.List;
* @date 2023-08-15 * @date 2023-08-15
*/ */
public interface IdxBizFanPointProcessVariableClassificationMapper extends BaseMapper<IdxBizFanPointProcessVariableClassification> { public interface IdxBizFanPointProcessVariableClassificationMapper extends BaseMapper<IdxBizFanPointProcessVariableClassification> {
List<IdxBizFanPointProcessVariableClassification> getInfluxDBData(); List<IdxBizFanPointProcessVariableClassificationDto> getInfluxDBData();
List<String> gateWayIdListFan(); List<String> gateWayIdListFan();
} }
...@@ -2,18 +2,30 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; ...@@ -2,18 +2,30 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.*; import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil; import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -23,31 +35,45 @@ import java.util.stream.Collectors; ...@@ -23,31 +35,45 @@ import java.util.stream.Collectors;
public class CommonServiceImpl { public class CommonServiceImpl {
//utc时间格式 //utc时间格式
public static final String FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'"; public static final String FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
public static final String FORMAT_DEFAULT = "yyyy-MM-dd HH:mm:ss";
private static final Logger logger = LoggerFactory.getLogger(CommonServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(CommonServiceImpl.class);
//-----------------调用算法时间间隔---------------- //-----------------调用算法时间间隔----------------
@Value("${sleep.time:10}") @Value("${sleep.time:10}")
Integer sleepTime; Integer sleepTime;
@Value("${sleep.time:30}")
Integer zxzsleepTime;
@Value("${base.url:http://36.40.66.175:30009/maas/maas/processes/api/}") @Value("${base.url:http://36.40.66.175:30009/maas/maas/processes/api/}")
String baseUrl; String baseUrl;
//----------------工况变量工况变量划分请求属性配置------------------------ //----------------工况变量工况变量划分请求属性配置------------------------
@Value("${gkblhf.url:e884fccf-b7ac-4fa4-bdb7-a5b6ff7319ec}") @Value("${gkblhffan.url:3d0acca8-a6aa-4791-8dc3-9f8d3137556a}")
String gkqjhfurl; String gkqjhfurlfan;
@Value("${gkblhfpv.url:e884fccf-b7ac-4fa4-bdb7-a5b6ff7319ec}")
String gkqjhfurlpv;
@Value("${gkblhf.key:input 1}") @Value("${gkblhf.key:input 1}")
String gkqjhfkey; String gkqjhfkey;
//----------------工况变量相关性计算请求属性配置------------------------ //----------------工况变量相关性计算请求属性配置------------------------
@Value("${gkxgxfx.url:f5457bfe-0780-418d-9287-c4f31d3fb4c7}") @Value("${gkxgxfxfan.url:b5797e0a-d456-44d3-9f21-9528e5321b74}")
String gkxgxfxurl; String gkxgxfxurlfan;
@Value("${gkxgxfxpv.url:f5457bfe-0780-418d-9287-c4f31d3fb4c7}")
String gkxgxfxurlpv;
@Value("${gkxgxfx.key:input 1}") @Value("${gkxgxfx.key:input 1}")
String gkxgxfxkey; String gkxgxfxkey;
//----------------工况变量中心值计算相关请求属性配置------------------------ //----------------工况变量中心值计算相关请求属性配置------------------------
@Value("${gkzxzjs.url:ee855fc0-cb37-4b11-96c6-e61e195436bc}") @Value("${gkzxzjsfan.url:2ad85cd3-aede-4936-b3bb-029bf2598c49}")
String gkzxzjsurl; String gkzxzjsurlfan;
@Value("${gkzxzjspv.url:5c9fc897-a9f2-4563-8d7b-8cf60c6a663f}")
String gkzxzjsurlpv;
@Value("${gkzxzjs.key:input 1}") @Value("${gkzxzjs.key:input 1}")
String gkzxzjskey1; String gkzxzjskey1;
@Value("${gkzxzjs.key:input 2}") @Value("${gkzxzjs.key:input 2}")
String gkzxzjskey2; String gkzxzjskey2;
//----------------健康指数值计算相关请求属性配置------------------------
@Value("${jkzsjs.url:d6c175af-50e2-4ea9-9006-f091cdfe203e}")
String jkzsjsurl;
// {"tableName": "idx_biz_fan_point_process_variable_classification"} 风机工况变量划分 // {"tableName": "idx_biz_fan_point_process_variable_classification"} 风机工况变量划分
// {"tableName": "idx_biz_pv_point_process_variable_classification"} 光伏工况变量画分 // {"tableName": "idx_biz_pv_point_process_variable_classification"} 光伏工况变量画分
// {"tableName": "idx_biz_fan_point_var_correlation"} 风机相关性 // {"tableName": "idx_biz_fan_point_var_correlation"} 风机相关性
...@@ -63,6 +89,13 @@ public class CommonServiceImpl { ...@@ -63,6 +89,13 @@ public class CommonServiceImpl {
@Autowired @Autowired
private InfluxdbUtil influxdbUtil; private InfluxdbUtil influxdbUtil;
@Autowired
private ElasticsearchRestTemplate elasticsearchTemplate;
@Autowired
IdxBizFanPointVarCentralValueMapper idxBizFanPointVarCentralValueMapper;
/** /**
* @return * @return
...@@ -136,7 +169,7 @@ public class CommonServiceImpl { ...@@ -136,7 +169,7 @@ public class CommonServiceImpl {
logger.info("------------------------------------------风机::开始调用工况变量区间划分算法----------------------------------------"); logger.info("------------------------------------------风机::开始调用工况变量区间划分算法----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkqjhfkey, params); realParams.put(gkqjhfkey, params);
String reponse = HttpUtil.createPost(baseUrl + gkqjhfurl).body(JSON.toJSONString(realParams)).execute().body(); String reponse = HttpUtil.createPost(baseUrl + gkqjhfurlfan).body(JSON.toJSONString(realParams)).execute().body();
try { try {
logger.info(reponse); logger.info(reponse);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
...@@ -167,7 +200,7 @@ public class CommonServiceImpl { ...@@ -167,7 +200,7 @@ public class CommonServiceImpl {
logger.info("------------------------------------------光伏::开始调用工况变量区间划分算法----------------------------------------"); logger.info("------------------------------------------光伏::开始调用工况变量区间划分算法----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkqjhfkey, params); realParams.put(gkqjhfkey, params);
String reponse = HttpUtil.createPost(baseUrl + gkqjhfurl).body(JSON.toJSONString(realParams)).execute().body(); String reponse = HttpUtil.createPost(baseUrl + gkqjhfurlpv).body(JSON.toJSONString(realParams)).execute().body();
try { try {
logger.info(reponse); logger.info(reponse);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
...@@ -270,7 +303,7 @@ public class CommonServiceImpl { ...@@ -270,7 +303,7 @@ public class CommonServiceImpl {
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkxgxfxkey, requestParams); realParams.put(gkxgxfxkey, requestParams);
logger.info("------------------------------风机相关性------------分析变量与工况变量相关性分析算参数---------------------------------------" + JSON.toJSONString(realParams)); logger.info("------------------------------风机相关性------------分析变量与工况变量相关性分析算参数---------------------------------------" + JSON.toJSONString(realParams));
String repsonse = HttpUtil.createPost(baseUrl + gkxgxfxurl).body(JSON.toJSONString(realParams)).execute().body(); String repsonse = HttpUtil.createPost(baseUrl + gkxgxfxurlfan).body(JSON.toJSONString(realParams)).execute().body();
try { try {
logger.info("response-------------" + repsonse); logger.info("response-------------" + repsonse);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
...@@ -315,7 +348,7 @@ public class CommonServiceImpl { ...@@ -315,7 +348,7 @@ public class CommonServiceImpl {
logger.info("---------------------------------光伏相关性---------分析变量与工况变量相关性分析算法开始----------------------------------------"); logger.info("---------------------------------光伏相关性---------分析变量与工况变量相关性分析算法开始----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkxgxfxkey, requestParams); realParams.put(gkxgxfxkey, requestParams);
String repsonse = HttpUtil.createPost(baseUrl + gkxgxfxurl).body(JSON.toJSONString(realParams)).execute().body(); String repsonse = HttpUtil.createPost(baseUrl + gkxgxfxurlpv).body(JSON.toJSONString(realParams)).execute().body();
try { try {
logger.info("response----光伏相关性---------" + repsonse); logger.info("response----光伏相关性---------" + repsonse);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
...@@ -388,7 +421,7 @@ public class CommonServiceImpl { ...@@ -388,7 +421,7 @@ public class CommonServiceImpl {
returnList.forEach((k) -> { returnList.forEach((k) -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("analysisVariable", Double.parseDouble(k.get("value").toString())); map.put("analysisVariable", Double.parseDouble(k.get("value").toString()));
map.put("analysisVariableId", Long.parseLong(IdxBizFanPointProcessVariableClassification.getSequenceNbr())); map.put("analysisVariableId", (IdxBizFanPointProcessVariableClassification.getSequenceNbr().toString()));
params.add(map); params.add(map);
}); });
logger.info("--------------------------------------风机中心值------开始查询influxdb--------------------------------"); logger.info("--------------------------------------风机中心值------开始查询influxdb--------------------------------");
...@@ -399,37 +432,37 @@ public class CommonServiceImpl { ...@@ -399,37 +432,37 @@ public class CommonServiceImpl {
String sql1 = String.format("select value from %s where address='%s' ", tableName, list.get(1).getProcessIndexAddress()); String sql1 = String.format("select value from %s where address='%s' ", tableName, list.get(1).getProcessIndexAddress());
String sql2 = String.format("select value from %s where address='%s' ", tableName, list.get(2).getProcessIndexAddress()); String sql2 = String.format("select value from %s where address='%s' ", tableName, list.get(2).getProcessIndexAddress());
List<HashMap<String, Object>> values = new ArrayList<>(); List<HashMap<String, Object>> values = new ArrayList<>();
List<String> processPointIds = list.stream().map(IdxBizFanPointVarCorrelation -> IdxBizFanPointVarCorrelation.getProcessPointId().toString()).collect(Collectors.toList()); List<String> processPointIds = list.stream().map(idxBizFanPointVarCorrelation -> idxBizFanPointVarCorrelation.getProcessPointId().toString()).collect(Collectors.toList());
List<IdxBizFanPointProcessVariableClassification> idxBizFanPointProcessVariableClassificationList = idxBizFanPointProcessVariableClassificationMapper.selectList(new QueryWrapper<IdxBizFanPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds)); List<IdxBizFanPointProcessVariableClassification> idxBizFanPointProcessVariableClassificationList = idxBizFanPointProcessVariableClassificationMapper.selectList(new QueryWrapper<IdxBizFanPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds));
//区间值1 //区间值1
HashMap<String, Object> value1 = new HashMap<>(); HashMap<String, Object> value1 = new HashMap<>();
value1.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue1())?0.0:idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue1()); value1.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue1()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue1());
value1.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue1())?0.0:idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue1()); value1.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue1()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue1());
value1.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue1())?0.0:idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue1()); value1.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue1()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue1());
values.add(value1); values.add(value1);
//区间值2 //区间值2
HashMap<String, Object> value2 = new HashMap<>(); HashMap<String, Object> value2 = new HashMap<>();
value2.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue2())?0.0:idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue2()); value2.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue2()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue2());
value2.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue2())?0.0:idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue2()); value2.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue2()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue2());
value2.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue2())?0.0:idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue2()); value2.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue2()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue2());
values.add(value2); values.add(value2);
//区间值3 //区间值3
HashMap<String, Object> value3 = new HashMap<>(); HashMap<String, Object> value3 = new HashMap<>();
value3.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue3())?0.0:idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue3()); value3.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue3()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue3());
value3.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue3())?0.0:idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue3()); value3.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue3()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue3());
value3.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue3())?0.0:idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue3()); value3.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue3()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue3());
values.add(value3); values.add(value3);
//区间值4 //区间值4
HashMap<String, Object> value4 = new HashMap<>(); HashMap<String, Object> value4 = new HashMap<>();
value4.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue4())?0.0:idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue4()); value4.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue4()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue4());
value4.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue4())?0.0:idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue4()); value4.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue4()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue4());
value4.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue4())?0.0:idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue4()); value4.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue4()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue4());
values.add(value4); values.add(value4);
//区间值5 //区间值5
HashMap<String, Object> value5 = new HashMap<>(); HashMap<String, Object> value5 = new HashMap<>();
value5.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue5())?0.0:idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue5()); value5.put("processVariable1", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue5()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(2).getIntervalValue5());
value5.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue5())?0.0:idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue5()); value5.put("processVariable2", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue5()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(1).getIntervalValue5());
value5.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue5())?0.0:idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue5()); value5.put("processVariable3", ObjectUtils.isEmpty(idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue5()) ? 0.0 : idxBizFanPointProcessVariableClassificationList.get(0).getIntervalValue5());
values.add(value5); values.add(value5);
List<Map<String, Object>> returnList0 = influxdbUtil.query(sql); List<Map<String, Object>> returnList0 = influxdbUtil.query(sql);
List<Map<String, Object>> maxList = returnList0; List<Map<String, Object>> maxList = returnList0;
...@@ -458,34 +491,33 @@ public class CommonServiceImpl { ...@@ -458,34 +491,33 @@ public class CommonServiceImpl {
map3 = returnList2.get(returnList2.size() - 1); map3 = returnList2.get(returnList2.size() - 1);
} }
map.put("processVariable1", Double.parseDouble(map1.get("value").toString())); map.put("processVariable1", Double.parseDouble(map1.get("value").toString()));
map.put("processVariable1Id", Long.parseLong(list.get(0).getProcessPointId().toString())); map.put("processVariable1Id", list.get(0).getProcessPointId().toString());
map.put("processVariable2", Double.parseDouble(map2.get("value").toString())); map.put("processVariable2", Double.parseDouble(map2.get("value").toString()));
map.put("processVariable2Id", Long.parseLong(list.get(1).getProcessPointId().toString())); map.put("processVariable2Id", list.get(1).getProcessPointId().toString());
map.put("processVariable3", Double.parseDouble(map3.get("value").toString())); map.put("processVariable3", Double.parseDouble(map3.get("value").toString()));
map.put("processVariable3Id", Long.parseLong(list.get(2).getProcessPointId().toString())); map.put("processVariable3Id", list.get(2).getProcessPointId().toString());
params1.add(map); params1.add(map);
if (params.size() >= params1.size()) { }
requestParams = megreMapList1(params, params1); if (params.size() >= params1.size()) {
} else { requestParams = megreMapList1(params, params1);
requestParams = megreMapList1(params1, params); } else {
} requestParams = megreMapList1(params1, params);
if (!requestParams.isEmpty()) { }
logger.info("---------------------------------风机中心值---------开始调用中心值计算算法开始----------------------------------------"); if (!requestParams.isEmpty()) {
HashMap<String, Object> realParams = new HashMap<>(); logger.info("---------------------------------风机中心值---------开始调用中心值计算算法开始----------------------------------------");
realParams.put(gkzxzjskey1, requestParams); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkzxzjskey2, values); realParams.put(gkzxzjskey1, values);
logger.info("------------------------------风机中心值------请求参数---------------------------------------" + JSON.toJSONString(realParams)); realParams.put(gkzxzjskey2, requestParams);
String response = HttpUtil.createPost(baseUrl + gkzxzjsurl).body(JSON.toJSONString(realParams)).execute().body(); logger.info("------------------------------风机中心值------请求参数---------------------------------------" + JSON.toJSONString(realParams));
try { String response = HttpUtil.createPost(baseUrl + gkzxzjsurlfan).body(JSON.toJSONString(realParams)).execute().body();
logger.info("------------------风机中心值--repsonse: " + response); try {
TimeUnit.SECONDS.sleep(sleepTime); logger.info("------------------风机中心值--repsonse: " + response);
logger.info("-----------------------------------风机中心值-------调用中心值计算算法结束----------------------------------------"); TimeUnit.SECONDS.sleep(zxzsleepTime);
} catch (InterruptedException e) { logger.info("-----------------------------------风机中心值-------调用中心值计算算法结束----------------------------------------");
throw new RuntimeException(e); } catch (InterruptedException e) {
} throw new RuntimeException(e);
} }
} }
} }
//中心值参数组装-光伏 //中心值参数组装-光伏
...@@ -511,33 +543,33 @@ public class CommonServiceImpl { ...@@ -511,33 +543,33 @@ public class CommonServiceImpl {
List<IdxBizPvPointProcessVariableClassification> idxBizPvPointProcessVariableClassificationList = idxBizPvPointProcessVariableClassificationMapper.selectList(new QueryWrapper<IdxBizPvPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds)); List<IdxBizPvPointProcessVariableClassification> idxBizPvPointProcessVariableClassificationList = idxBizPvPointProcessVariableClassificationMapper.selectList(new QueryWrapper<IdxBizPvPointProcessVariableClassification>().in("SEQUENCE_NBR", processPointIds));
//区间值1 //区间值1
HashMap<String, Object> value1 = new HashMap<>(); HashMap<String, Object> value1 = new HashMap<>();
value1.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue1())?0.0:idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue1()); value1.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue1()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue1());
value1.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue1())?0.0:idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue1()); value1.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue1()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue1());
value1.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue1())?0.0:idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue1()); value1.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue1()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue1());
values.add(value1); values.add(value1);
//区间值2 //区间值2
HashMap<String, Object> value2 = new HashMap<>(); HashMap<String, Object> value2 = new HashMap<>();
value2.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue2())?0.0:idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue2()); value2.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue2()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue2());
value2.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue2())?0.0:idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue2()); value2.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue2()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue2());
value2.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue2())?0.0:idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue2()); value2.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue2()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue2());
values.add(value2); values.add(value2);
//区间值3 //区间值3
HashMap<String, Object> value3 = new HashMap<>(); HashMap<String, Object> value3 = new HashMap<>();
value3.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue3())?0.0:idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue3()); value3.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue3()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue3());
value3.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue3())?0.0:idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue3()); value3.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue3()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue3());
value3.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue3())?0.0:idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue3()); value3.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue3()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue3());
values.add(value3); values.add(value3);
//区间值4 //区间值4
HashMap<String, Object> value4 = new HashMap<>(); HashMap<String, Object> value4 = new HashMap<>();
value4.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue4())?0.0:idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue4()); value4.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue4()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue4());
value4.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue4())?0.0:idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue4()); value4.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue4()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue4());
value4.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue4())?0.0:idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue4()); value4.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue4()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue4());
values.add(value4); values.add(value4);
//区间值5 //区间值5
HashMap<String, Object> value5 = new HashMap<>(); HashMap<String, Object> value5 = new HashMap<>();
value5.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue5())?0.0:idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue5()); value5.put("processVariable1", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue5()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(2).getIntervalValue5());
value5.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue5())?0.0:idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue5()); value5.put("processVariable2", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue5()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(1).getIntervalValue5());
value5.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue5())?0.0:idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue5()); value5.put("processVariable3", ObjectUtils.isEmpty(idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue5()) ? 0.0 : idxBizPvPointProcessVariableClassificationList.get(0).getIntervalValue5());
values.add(value5); values.add(value5);
List<Map<String, Object>> returnList0 = influxdbUtil.query(sql); List<Map<String, Object>> returnList0 = influxdbUtil.query(sql);
List<Map<String, Object>> maxList = returnList0; List<Map<String, Object>> maxList = returnList0;
...@@ -572,27 +604,28 @@ public class CommonServiceImpl { ...@@ -572,27 +604,28 @@ public class CommonServiceImpl {
map.put("processVariable3", Double.parseDouble(map3.get("value").toString())); map.put("processVariable3", Double.parseDouble(map3.get("value").toString()));
map.put("processVariable3Id", Long.parseLong(list.get(2).getProcessPointId().toString())); map.put("processVariable3Id", Long.parseLong(list.get(2).getProcessPointId().toString()));
params1.add(map); params1.add(map);
if (params.size() >= params1.size()) { }
requestParams = megreMapList1(params, params1); if (params.size() >= params1.size()) {
} else { requestParams = megreMapList1(params, params1);
requestParams = megreMapList1(params1, params); } else {
} requestParams = megreMapList1(params1, params);
if (!requestParams.isEmpty()) { }
logger.info("-------------------------------------光伏中心值-----开始调用中心值计算算法----------------------------------------"); if (!requestParams.isEmpty()) {
HashMap<String, Object> realParams = new HashMap<>(); logger.info("-------------------------------------光伏中心值-----开始调用中心值计算算法----------------------------------------");
realParams.put(gkzxzjskey1, requestParams); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkzxzjskey2, values); realParams.put(gkzxzjskey1, values);
String response = HttpUtil.createPost(baseUrl + gkzxzjsurl).body(JSON.toJSONString(realParams)).execute().body(); realParams.put(gkzxzjskey2, requestParams);
try { String response = HttpUtil.createPost(baseUrl + gkzxzjsurlpv).body(JSON.toJSONString(realParams)).execute().body();
logger.info("-------------光伏中心值-------repsonse: " + response); try {
TimeUnit.SECONDS.sleep(sleepTime); logger.info("-------------光伏中心值-------repsonse: " + response);
logger.info("-----------------------------------光伏中心值-------调用中心值计算算法结束----------------------------------------"); TimeUnit.SECONDS.sleep(sleepTime);
} catch (InterruptedException e) { logger.info("-----------------------------------光伏中心值-------调用中心值计算算法结束----------------------------------------");
throw new RuntimeException(e); } catch (InterruptedException e) {
} throw new RuntimeException(e);
} }
} }
} }
public List<Map<String, Object>> megreMapList1(List<Map<String, Object>> longList, List<Map<String, Object>> shortList) { public List<Map<String, Object>> megreMapList1(List<Map<String, Object>> longList, List<Map<String, Object>> shortList) {
...@@ -622,20 +655,128 @@ public class CommonServiceImpl { ...@@ -622,20 +655,128 @@ public class CommonServiceImpl {
return resultList; return resultList;
} }
public List<Map<String, Object>> getInfluxdbDataByConditon(String stationType, String pointId, String startTime, String endTime) { public Map<String, Object> getInfluxdbDataByConditon(String stationType, String pointId, String startTime, String endTime) {
HashMap<String,Object> resultLast =new HashMap();
String sql = ""; String sql = "";
if ("FD".equals(stationType)) { if ("FD".equals(stationType)) {
IdxBizFanPointProcessVariableClassification idxBizFanPointProcessVariableClassification = idxBizFanPointProcessVariableClassificationMapper.selectById(pointId); IdxBizFanPointProcessVariableClassification idxBizFanPointProcessVariableClassification = idxBizFanPointProcessVariableClassificationMapper.selectOne(new QueryWrapper<IdxBizFanPointProcessVariableClassification>().eq("SEQUENCE_NBR",pointId));
sql = String.format("select * from iot_data_%s where address ='%s' and time > '%s' and time < '%s' ;", idxBizFanPointProcessVariableClassification.getGatewayId(), idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime); sql = String.format("select * from iot_data_%s where address ='%s' and time > '%s' and time < '%s' ;", idxBizFanPointProcessVariableClassification.getGatewayId(), idxBizFanPointProcessVariableClassification.getIndexAddress(), getUtcTimeString(startTime), getUtcTimeString(endTime));
} else { } else {
IdxBizPvPointProcessVariableClassification idxBizPvPointProcessVariableClassification = idxBizPvPointProcessVariableClassificationMapper.selectById(pointId); IdxBizPvPointProcessVariableClassification idxBizPvPointProcessVariableClassification = idxBizPvPointProcessVariableClassificationMapper.selectOne(new QueryWrapper<IdxBizPvPointProcessVariableClassification>().eq("SEQUENCE_NBR",pointId));
sql = String.format("select * from iot_data_%s where address ='%s' and time > '%s' and time < '%s' ;", idxBizPvPointProcessVariableClassification.getGatewayId(), idxBizPvPointProcessVariableClassification.getIndexAddress(), startTime, endTime); sql = String.format("select * from iot_data_%s where address ='%s' and time > '%s' and time < '%s' ;", idxBizPvPointProcessVariableClassification.getGatewayId(), idxBizPvPointProcessVariableClassification.getIndexAddress(), getUtcTimeString(startTime), getUtcTimeString(endTime));
} }
return influxdbUtil.query(sql); List<Map<String,Object>> reuslt = influxdbUtil.query(sql);
List<String> seriesData_valuse=new ArrayList<>();
List<String> axisData_valuse=new ArrayList<>();
reuslt.forEach(item->{
seriesData_valuse.add(item.get("value").toString());
axisData_valuse.add(item.get("time").toString());
});
resultLast.put("seriesData",seriesData_valuse);
resultLast.put("axisData",axisData_valuse);
return resultLast;
} }
public String getUtcTimeString(String timeStr) { public String getUtcTimeString(String timeStr) {
SimpleDateFormat dateFormat = new SimpleDateFormat(FORMAT_UTC); SimpleDateFormat dateFormatUTC = new SimpleDateFormat(FORMAT_UTC);
return dateFormat.format(timeStr); SimpleDateFormat dateFormatDefault = new SimpleDateFormat(FORMAT_DEFAULT);
Date time1 = null;
try {
time1 = dateFormatDefault.parse(timeStr);
} catch (ParseException e) {
logger.info("输入的时间格式错误");
}
String s = dateFormatUTC.format(time1);
return s;
}
@Scheduled(cron = "0 0/10 * * * ?")
private void healthWarningMinute() {
List<IdxBizFanPointProcessVariableClassificationDto> data = idxBizFanPointProcessVariableClassificationMapper.getInfluxDBData();
Map<String, List<IdxBizFanPointProcessVariableClassificationDto>> maps = data.stream().collect(Collectors.groupingBy(IdxBizFanPointProcessVariableClassificationDto::getGatewayId));
BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
List<QueryBuilder> should = boolMustAll.should();
for (String s : maps.keySet()) {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
List<String> address = maps.get(s).stream().map(IdxBizFanPointProcessVariableClassificationDto::getIndexAddress).collect(Collectors.toList());
boolQueryBuilder.must(QueryBuilders.termsQuery("address.keyword", address)).must(QueryBuilders.matchQuery("gatewayId.keyword", s));
should.add(boolQueryBuilder);
}
// 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
//过滤条件
.withQuery(boolMustAll);
List<ESEquipments> equipments = new LinkedList<>();
long totle = 0;
try {
SearchHits<ESEquipments> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESEquipments.class);
for (SearchHit searchHit : searchHits.getSearchHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
ESEquipments eSAlertCalled = JSONObject.toJavaObject(jsonObject, ESEquipments.class);
equipments.add(eSAlertCalled);
}
totle = searchHits.getTotalHits();
} catch (Exception e) {
// TODO: handle exception
}
for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
for (ESEquipments equipment : equipments) {
if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())){
datum.setCurrentValue(equipment.getValueDouble());
}
}
}
LambdaQueryWrapper<IdxBizFanPointVarCentralValue> wrapper = new LambdaQueryWrapper<>();
List<IdxBizFanPointVarCentralValue> idxBizUhefs = idxBizFanPointVarCentralValueMapper.selectList(wrapper);
List< Map<String, Object>> datas = new ArrayList<>();
Map<String, Map<String, Object>> resultMap = new HashMap<>();
for (IdxBizFanPointVarCentralValue idxBizUhef : idxBizUhefs) {
double value1 = 0.00;
double value2 = 0.00;
double value3 = 0.00;
double value4 = 0.00;
for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
if (idxBizUhef.getProcessPoint1Id().equals(datum.getSequenceNbr())){
value1 = datum.getCurrentValue();
}
if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) {
value2 = datum.getCurrentValue();
}
if (idxBizUhef.getProcessPoint3Id().equals(datum.getSequenceNbr())) {
value3 = datum.getCurrentValue();
}
if (idxBizUhef.getAnalysisPointId().equals(datum.getSequenceNbr())) {
value4 = datum.getCurrentValue();
}
}
Map<String, Object> map = new HashMap<>();
if (idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max() &&
idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getPorcess2Max() &&
idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()){
map.put("analysVariable",value4);
map.put("stdDev",idxBizUhef.getAnalysisStdDev());
map.put("centerValue",idxBizUhef.getAnalysisCenterValue());
map.put("analysVariableId",idxBizUhef.getAnalysisPointId());
resultMap.put(idxBizUhef.getAnalysisPointId(),map);
}
}
Collection<Map<String, Object>> values = resultMap.values();
if (!values.isEmpty()) {
logger.info("------------------------------------------开始调用健康指数计算算法开始----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkzxzjskey1, values);
String response = HttpUtil.createPost(baseUrl + jkzsjsurl).body(JSON.toJSONString(realParams)).execute().body();
try {
logger.info("--------------------repsonse: "+response);
logger.info("------------------------------------------调用健康指数计算算法结束----------------------------------------");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} }
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizUhefDto; import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizUxfvDto; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPldo;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizUhef;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizUxfv;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPldoMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizUhefMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizUxfvMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class HealthStatusIndicatorServiceImpl { public class HealthStatusIndicatorServiceImpl {
@Autowired @Value("${healthValue_Warn}")
private IdxBizUhefMapper idxBizUhefMapper; Double healthValueWarn;
@Autowired @Value("${healthValue_Risk}")
private IdxBizUxfvMapper idxBizUxfvMapper; Double healthValueRisk;
@Autowired @Value("${healthValue_Notice}")
private IdxBizPldoMapper idxBizPldoMapper; Double healthValueNotice;
@Autowired
private InfluxDButils influxDButils;
@Autowired
private ElasticsearchRestTemplate elasticsearchTemplate;
@Scheduled(cron = "0/10 * * * * ? ") @Value("${healthValue_DayCount}")
private void mother() { long healthValueDayCount;
List<IdxBizUxfvDto> data = idxBizUxfvMapper.getInfluxDBData(); @Value("${healthValue_HourCount}")
long healthValueHourCount;
@Value("${healthValue_MinCount}")
long healthValueMinCount;
Map<String, List<IdxBizUxfvDto>> maps = data.stream().collect(Collectors.groupingBy(IdxBizUxfvDto::getGatewayId)); @Autowired
BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery(); private RedisUtils redisUtils;
@Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
List<QueryBuilder> should = boolMustAll.should(); @Autowired
for (String s : maps.keySet()) { IdxBizFanWarningRecordMapper idxBizFanWarningRecordMapper;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
List<String> address = maps.get(s).stream().map(IdxBizUxfvDto::getIndexAddress).collect(Collectors.toList()); /***
boolQueryBuilder.must(QueryBuilders.termsQuery("address.keyword", address)).must(QueryBuilders.matchQuery("gatewayId.keyword", s)); * 每一小时获取一次最大粒度内的指数异常数据
should.add(boolQueryBuilder); * 判断一小时内数据是否符合预警规则 符合则报警并在redis中缓存 同一级别的预警记录下次不生成
} *
*/
@Scheduled(cron = "0 0 */1 * * ?")
private void healthWarningMinute() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LambdaQueryWrapper<IdxBizFanHealthIndex> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizFanHealthIndex::getAnalysisType,"按时刻");
wrapper.le(IdxBizFanHealthIndex::getHealthIndex,healthValueNotice);
wrapper.ge(IdxBizFanHealthIndex::getRecDate,df.format(calendar.getTime()));
wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate);
List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper);
Map<Integer, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress)));
for (Integer gateWayId : gateWayMaps.keySet()) {
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) {
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address);
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(IdxBizFanHealthIndex::getHealthIndex).collect(Collectors.toList());
long riskNum = healthIndex.stream().filter(e -> e <= healthValueRisk).count();
long warnNum = healthIndex.stream().filter(e -> e <= healthValueWarn).count();
long noticeNum = healthIndex.stream().filter(e -> e <= healthValueNotice).count();
String level = "";
String content = "";
String num = "";
content = healthValueMinCount + "分钟";
if (riskNum >= healthValueMinCount && !redisUtils.hasKey(gateWayId+"_"+address+"_health_risk_minute")){
redisUtils.set(gateWayId+"_"+address+"_health_risk_minute","risk");
level ="危险";
num = ""+healthValueRisk;
}else if (warnNum >= healthValueMinCount && !redisUtils.hasKey(gateWayId+"_"+address+"_health_warn_minute") ){
redisUtils.set(gateWayId+"_"+address+"_health_warn_minute","warn");
level ="警告";
num = ""+healthValueWarn;
}else if (noticeNum >= healthValueMinCount && !redisUtils.hasKey(gateWayId+"_"+address+"_health_notice_minute")){
redisUtils.set(gateWayId+"_"+address+"_health_notice_minute","notice");
level ="注意";
num = ""+healthValueNotice;
}
// 创建查询构造器 if (!level.equals("")){
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder() IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord();
//过滤条件 idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord());
.withQuery(boolMustAll); idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae());
List<ESEquipments> equipments = new LinkedList<>(); idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation());
long totle = 0; idxBizFanWarningRecord.setSubSystem(idxBizFanHealthIndices.get(0).getSubSystem());
try { idxBizFanWarningRecord.setGatewayId(gateWayId);
SearchHits<ESEquipments> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESEquipments.class); idxBizFanWarningRecord.setIndexAddress(address);
idxBizFanWarningRecord.setEquipmentName(idxBizFanHealthIndices.get(0).getEquipmentName());
for (SearchHit searchHit : searchHits.getSearchHits()) { idxBizFanWarningRecord.setAnalysisPointId(idxBizFanHealthIndices.get(0).getAnalysisObjSeq());
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent()); idxBizFanWarningRecord.setDisposotionState("未处置");
ESEquipments eSAlertCalled = JSONObject.toJavaObject(jsonObject, ESEquipments.class); idxBizFanWarningRecord.setStatus("0");
equipments.add(eSAlertCalled); idxBizFanWarningRecord.setWarningName(level);
idxBizFanWarningRecord.setCONTENT("连续"+content+"健康指数<"+num );
}
} }
totle = searchHits.getTotalHits();
} catch (Exception e) {
// TODO: handle exception
} }
}
/***
* 每五小时获取一次最大粒度内的指数异常数据
* 判断五小时内数据是否符合预警规则 符合则报警并在redis中缓存 同一级别的预警记录下次不生成
*
*/
@Scheduled(cron = "0 0 */5 * * ?")
private void healthWarningHour() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LambdaQueryWrapper<IdxBizFanHealthIndex> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizFanHealthIndex::getAnalysisType,"按小时");
wrapper.le(IdxBizFanHealthIndex::getHealthIndex,healthValueNotice);
wrapper.ge(IdxBizFanHealthIndex::getRecDate,df.format(calendar.getTime()));
wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate);
List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper);
Map<Integer, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress)));
for (Integer gateWayId : gateWayMaps.keySet()) {
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) {
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address);
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(IdxBizFanHealthIndex::getHealthIndex).collect(Collectors.toList());
long riskNum = healthIndex.stream().filter(e -> e <= healthValueRisk).count();
long warnNum = healthIndex.stream().filter(e -> e <= healthValueWarn).count();
long noticeNum = healthIndex.stream().filter(e -> e <= healthValueNotice).count();
String level = "";
String content = "";
String num = "";
content = healthValueHourCount + "小时";
if (riskNum >= healthValueHourCount && !redisUtils.hasKey(gateWayId+"_"+address+"_health_risk_hour")){
redisUtils.set(gateWayId+"_"+address+"_health_risk_hour","risk");
level ="危险";
num = ""+healthValueRisk;
}else if (warnNum >= healthValueHourCount && !redisUtils.hasKey(gateWayId+"_"+address+"_health_risk_hour") ){
redisUtils.set(gateWayId+"_"+address+"_health_warn_hour","warn");
level ="警告";
num = ""+healthValueWarn;
}else if (noticeNum >= healthValueHourCount && !redisUtils.hasKey(gateWayId+"_"+address+"_health_notice_hour")){
redisUtils.set(gateWayId+"_"+address+"_health_notice_hour","notice");
level ="注意";
num = ""+healthValueNotice;
for (IdxBizUxfvDto datum : data) {
for (ESEquipments equipment : equipments) {
if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())){
datum.setCurrentValue(equipment.getValueDouble());
} }
}
}
LambdaQueryWrapper<IdxBizUhef> wrapper = new LambdaQueryWrapper<>(); if (!level.equals("")){
List<IdxBizUhef> idxBizUhefs = idxBizUhefMapper.selectList(wrapper); IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord();
List< Map<String, Object>> datas = new ArrayList<>(); idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord());
for (IdxBizUhef idxBizUhef : idxBizUhefs) { idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae());
double value1 = 0.00; idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation());
double value2 = 0.00; idxBizFanWarningRecord.setSubSystem(idxBizFanHealthIndices.get(0).getSubSystem());
double value3 = 0.00; idxBizFanWarningRecord.setGatewayId(gateWayId);
double value4 = 0.00; idxBizFanWarningRecord.setIndexAddress(address);
idxBizFanWarningRecord.setEquipmentName(idxBizFanHealthIndices.get(0).getEquipmentName());
for (IdxBizUxfvDto datum : data) { idxBizFanWarningRecord.setAnalysisPointId(idxBizFanHealthIndices.get(0).getAnalysisObjSeq());
if (idxBizUhef.getPointOneId().equals(datum.getSequenceNbr())){ idxBizFanWarningRecord.setDisposotionState("未处置");
value1 = datum.getCurrentValue(); idxBizFanWarningRecord.setStatus("0");
} idxBizFanWarningRecord.setWarningName(level);
if (idxBizUhef.getPointTwoId().equals(datum.getSequenceNbr())) { idxBizFanWarningRecord.setCONTENT("连续"+content+"健康指数<"+num );
value2 = datum.getCurrentValue();
}
if (idxBizUhef.getPointThreeId().equals(datum.getSequenceNbr())) {
value3 = datum.getCurrentValue();
} }
if (idxBizUhef.getAnalysisPointId().equals(datum.getSequenceNbr())) {
value4 = datum.getCurrentValue();
}
} }
if (idxBizUhef.getProcess1Min() < value1 && value1 < idxBizUhef.getProcess1Max() && }
idxBizUhef.getProcess2Min() < value2 && value2 < idxBizUhef.getProcess2Max() && }
idxBizUhef.getProcess3Min() < value3 && value3 < idxBizUhef.getProcess3Max()){
Map<String, Object> map = new HashMap<>();
map.put("analysVariable",value4);
map.put("stdDev",idxBizUhef.getAnalysisStdDev());
map.put("centerValue",idxBizUhef.getAnalysisCenterValue());
map.put("analysVariableId",idxBizUhef.getAnalysisPointId());
datas.add(map);
//算法接口 获取健康指数
double healthExponent = 0.00;
LambdaQueryWrapper<IdxBizPldo> healthQerry = new LambdaQueryWrapper<>();
healthQerry.ge(IdxBizPldo::getGroupLowerLimit,healthExponent);
healthQerry.le(IdxBizPldo::getGroupUpperLimit,healthExponent);
healthQerry.eq(IdxBizPldo::getAnalysisObjType,"设备");
IdxBizPldo idxBizPldo = idxBizPldoMapper.selectOne(healthQerry);
IdxBizFanHealthIndex idxBizFanHealthIndex = new IdxBizFanHealthIndex(); /***
* 每三天取一次最大粒度内的指数异常数据
* 判断三天内数据是否符合预警规则 符合则报警并在redis中缓存 同一级别的预警记录下次不生成
*
*/
@Scheduled(cron = "0 0 0 */3 * ? ")
private void healthWarningDay() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LambdaQueryWrapper<IdxBizFanHealthIndex> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizFanHealthIndex::getAnalysisType,"按天");
wrapper.le(IdxBizFanHealthIndex::getHealthIndex,healthValueNotice);
wrapper.ge(IdxBizFanHealthIndex::getRecDate,df.format(calendar.getTime()));
wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate);
List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper);
Map<Integer, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress)));
for (Integer gateWayId : gateWayMaps.keySet()) {
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) {
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address);
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(IdxBizFanHealthIndex::getHealthIndex).collect(Collectors.toList());
long riskNum = healthIndex.stream().filter(e -> e <= healthValueRisk).count();
long warnNum = healthIndex.stream().filter(e -> e <= healthValueWarn).count();
long noticeNum = healthIndex.stream().filter(e -> e <= healthValueNotice).count();
String level = "";
String content = "";
String num = "";
content = healthValueDayCount + "天";
if (riskNum >= healthValueDayCount && !redisUtils.hasKey(gateWayId+"_"+address+"_health_risk_day")){
redisUtils.set(gateWayId+"_"+address+"_health_risk_day","risk");
level ="危险";
num = ""+healthValueRisk;
}else if (warnNum >= healthValueDayCount && !redisUtils.hasKey(gateWayId+"_"+address+"_health_warn_day") ){
redisUtils.set(gateWayId+"_"+address+"_health_warn_day","warn");
level ="警告";
num = ""+healthValueWarn;
}else if (noticeNum >= healthValueDayCount && !redisUtils.hasKey(gateWayId+"_"+address+"_health_notice_day")){
redisUtils.set(gateWayId+"_"+address+"_health_notice_day","notice");
level ="注意";
num = ""+healthValueNotice;
}
if (!level.equals("")){
IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord();
idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord());
idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae());
idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation());
idxBizFanWarningRecord.setSubSystem(idxBizFanHealthIndices.get(0).getSubSystem());
idxBizFanWarningRecord.setGatewayId(gateWayId);
idxBizFanWarningRecord.setIndexAddress(address);
idxBizFanWarningRecord.setEquipmentName(idxBizFanHealthIndices.get(0).getEquipmentName());
idxBizFanWarningRecord.setAnalysisPointId(idxBizFanHealthIndices.get(0).getAnalysisObjSeq());
idxBizFanWarningRecord.setDisposotionState("未处置");
idxBizFanWarningRecord.setStatus("0");
idxBizFanWarningRecord.setWarningName(level);
idxBizFanWarningRecord.setCONTENT("连续"+content+"健康指数<"+num );
idxBizFanWarningRecordMapper.insert(idxBizFanWarningRecord);
}
} }
} }
// TODO: data
} }
} }
...@@ -80,3 +80,11 @@ spring.elasticsearch.rest.connection-timeout=30000 ...@@ -80,3 +80,11 @@ spring.elasticsearch.rest.connection-timeout=30000
spring.elasticsearch.rest.username=elastic spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=123456 spring.elasticsearch.rest.password=123456
spring.elasticsearch.rest.read-timeout=30000 spring.elasticsearch.rest.read-timeout=30000
healthValue_Warn=39
healthValue_Risk=59
healthValue_Notice=79
healthValue_DayCount=3
healthValue_HourCount=6
healthValue_MinCount=5
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointProcessVariableClassificationMapper"> <mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointProcessVariableClassificationMapper">
<select id="getInfluxDBData" resultType="com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointProcessVariableClassification"> <select id="getInfluxDBData" resultType="com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto">
SELECT b.*, SELECT b.*,
ibfpvcv.PROCESS_POINT1_ID as pointOneId, ibfpvcv.PROCESS_POINT1_ID as pointOneId,
ibfpvcv.PROCESS_POINT2_ID as pointTwoId, ibfpvcv.PROCESS_POINT2_ID as pointTwoId,
ibfpvcv.PROCESS_POINT3_ID as pointThreeId, ibfpvcv.PROCESS_POINT3_ID as pointThreeId,
ibfpvcv.ANALYSIS_POINT_ID as pointId ibfpvcv.ANALYSIS_POINT_ID as pointId
FROM ( FROM (
SELECT * SELECT *
FROM idx_biz_uxfv uxfv FROM idx_biz_fan_point_process_variable_classification uxfv
WHERE uxfv.SEQUENCE_NBR IN ( WHERE uxfv.SEQUENCE_NBR IN (
SELECT PROCESS_POINT1_ID SELECT PROCESS_POINT1_ID
FROM `idx_biz_fan_point_var_central_value` FROM `idx_biz_fan_point_var_central_value`
WHERE ANALYSIS_POINT_ID IS NOT NULL WHERE ANALYSIS_POINT_ID IS NOT NULL
GROUP BY ANALYSIS_POINT_ID, GROUP BY ANALYSIS_POINT_ID,
PROCESS_POINT1_ID, PROCESS_POINT1_ID,
PROCESS_POINT3_ID, PROCESS_POINT3_ID,
PROCESS_POINT2_ID PROCESS_POINT2_ID
UNION ALL UNION ALL
SELECT PROCESS_POINT2_ID SELECT PROCESS_POINT2_ID
FROM `idx_biz_fan_point_var_central_value` FROM `idx_biz_fan_point_var_central_value`
WHERE ANALYSIS_POINT_ID IS NOT NULL WHERE ANALYSIS_POINT_ID IS NOT NULL
GROUP BY ANALYSIS_POINT_ID, GROUP BY ANALYSIS_POINT_ID,
PROCESS_POINT1_ID, PROCESS_POINT1_ID,
PROCESS_POINT3_ID, PROCESS_POINT3_ID,
PROCESS_POINT2_ID PROCESS_POINT2_ID
UNION ALL UNION ALL
SELECT PROCESS_POINT3_ID SELECT PROCESS_POINT3_ID
FROM `idx_biz_fan_point_var_central_value` FROM `idx_biz_fan_point_var_central_value`
WHERE ANALYSIS_POINT_ID IS NOT NULL WHERE ANALYSIS_POINT_ID IS NOT NULL
GROUP BY ANALYSIS_POINT_ID, GROUP BY ANALYSIS_POINT_ID,
PROCESS_POINT1_ID, PROCESS_POINT1_ID,
PROCESS_POINT3_ID, PROCESS_POINT3_ID,
PROCESS_POINT2_ID PROCESS_POINT2_ID
UNION ALL UNION ALL
SELECT ANALYSIS_POINT_ID SELECT ANALYSIS_POINT_ID
FROM `idx_biz_fan_point_var_central_value` FROM `idx_biz_fan_point_var_central_value`
WHERE ANALYSIS_POINT_ID IS NOT NULL WHERE ANALYSIS_POINT_ID IS NOT NULL
GROUP BY ANALYSIS_POINT_ID, GROUP BY ANALYSIS_POINT_ID,
PROCESS_POINT1_ID, PROCESS_POINT1_ID,
PROCESS_POINT3_ID, PROCESS_POINT3_ID,
PROCESS_POINT2_ID PROCESS_POINT2_ID
)) AS b, )) AS b,
idx_biz_fan_point_var_central_value ibfpvcv idx_biz_fan_point_var_central_value ibfpvcv
WHERE b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT1_ID WHERE b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT1_ID
OR b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT2_ID OR b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT2_ID
OR b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT3_ID OR b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT3_ID
OR b.SEQUENCE_NBR = ibfpvcv.ANALYSIS_POINT_ID
GROUP BY b.SEQUENCE_NBR GROUP BY b.SEQUENCE_NBR
</select> </select>
......
...@@ -629,7 +629,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -629,7 +629,7 @@ public class MonitorFanIdxController extends BaseController {
String num = monitorFanIndicator.getFJCount(gatewayId); String num = monitorFanIndicator.getFJCount(gatewayId);
columnMap.put("逆变器台数",num); columnMap.put("逆变器台数",num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber()); Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber());
columnMap.put("装机容量",capacityl); columnMap.put("装机容量",String.format("%.2f",capacityl));
String json = null; String json = null;
try { try {
......
...@@ -89,6 +89,9 @@ public class CommonServiceImpl { ...@@ -89,6 +89,9 @@ public class CommonServiceImpl {
String sql = "SELECT * FROM indicators_"+gatewayId+" where equipmentIndexName='"+indicator+"'"; String sql = "SELECT * FROM indicators_"+gatewayId+" where equipmentIndexName='"+indicator+"'";
Double avageValue = 0.0; Double avageValue = 0.0;
List<Map<String,Object>> mapList = influxdbUtil.query(sql); List<Map<String,Object>> mapList = influxdbUtil.query(sql);
if (mapList.size() < 1){
return avageValue;
}
avageValue =mapList.stream().filter(stringObjectMap -> !ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l->Double.parseDouble((String) l.get("value"))).average().getAsDouble(); avageValue =mapList.stream().filter(stringObjectMap -> !ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l->Double.parseDouble((String) l.get("value"))).average().getAsDouble();
return Double.valueOf(String.format("%.2f",avageValue)); return Double.valueOf(String.format("%.2f",avageValue));
} }
......
[ [
{ {
"titie": "装机容量", "title": "装机容量",
"title1": "装机容量(MW)", "title1": "装机容量(MW)",
"url": "upload/jxiop/amos_studio/2F378EF430F788CA71E876359B46C4E.png" "url": "upload/jxiop/amos_studio/2F378EF430F788CA71E876359B46C4E.png"
}, },
{ {
"titie": "日发电量", "title": "日发电量",
"title1": "日发电量(万kWh)", "title1": "日发电量(万kWh)",
"url": "upload/jxiop/amos_studio/E07C6C41715033585F69934AF08A3431.png" "url": "upload/jxiop/amos_studio/E07C6C41715033585F69934AF08A3431.png"
}, },
{ {
"titie": "风机台数", "title": "风机台数",
"title1": "风机台数(台)", "title1": "风机台数(台)",
"action": "*.replace(\".0\",\"\")", "action": "*.replace(\".0\",\"\")",
"url": "upload/jxiop/amos_studio/EA3572E1BD31DC1E7D8DA162F09ECB.png" "url": "upload/jxiop/amos_studio/EA3572E1BD31DC1E7D8DA162F09ECB.png"
}, },
{ {
"titie": "月发电量", "title": "月发电量",
"title1": "月发电量(万kWh)", "title1": "月发电量(万kWh)",
"url": "upload/jxiop/amos_studio/6CE2792ABEEAE816CB798649A6796.png" "url": "upload/jxiop/amos_studio/6CE2792ABEEAE816CB798649A6796.png"
}, },
{ {
"titie": "瞬时风速", "title": "瞬时风速",
"title1": "平均风速(m/s)", "title1": "平均风速(m/s)",
"url": "upload/jxiop/amos_studio/3B66742AAB2FEB0F5CEC10DA50156F.png" "url": "upload/jxiop/amos_studio/3B66742AAB2FEB0F5CEC10DA50156F.png"
}, },
{ {
"titie": "年发电量", "title": "年发电量",
"title1": "年发电量(万kWh)", "title1": "年发电量(万kWh)",
"url": "upload/jxiop/amos_studio/12D321E29727689B334E3E625383EB7C.png" "url": "upload/jxiop/amos_studio/12D321E29727689B334E3E625383EB7C.png"
}, },
{ {
"titie": "有功功率", "title": "有功功率",
"title1": "有功功率(MW)", "title1": "有功功率(MW)",
"action": "String.format(\"%.2f\",Double.parseDouble(*)/1000)", "action": "String.format(\"%.2f\",Double.parseDouble(*)/1000)",
"url": "upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png" "url": "upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png"
}, },
{ {
"titie": "日利用小时", "title": "日利用小时",
"title1": "日利用小时", "title1": "日利用小时",
"action":"String.format(\"%.2f\",Double.parseDouble(columnMap.get(\"*\").toString())/ (Double.parseDouble(columnMap.get(\"-\").toString())*1000))", "action":"String.format(\"%.2f\",Double.parseDouble(columnMap.get(\"*\").toString())/ (Double.parseDouble(columnMap.get(\"-\").toString())*1000))",
"url": "upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png" "url": "upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png"
}, },
{ {
"titie": "上网电量", "title": "上网电量",
"title1": "上网电量(万kWh)", "title1": "上网电量(万kWh)",
"url": "upload/jxiop/amos_studio/1660C5DDA22ACFADC89A60DEDB82FA39.png" "url": "upload/jxiop/amos_studio/1660C5DDA22ACFADC89A60DEDB82FA39.png"
} }
......
[ [
{ {
"titie": "逆变器台数", "title": "逆变器台数",
"title1": "逆变器台数(台)", "title1": "逆变器台数(台)",
"action": "*.replace(\".0\",\"\")", "action": "*.replace(\".0\",\"\")",
"url": "upload/jxiop/amos_studio/EA3572E1BD31DC1E7D8DA162F09ECB.png" "url": "upload/jxiop/amos_studio/EA3572E1BD31DC1E7D8DA162F09ECB.png"
}, },
{ {
"titie": "装机容量", "title": "装机容量",
"title1": "装机容量(MW)", "title1": "装机容量(MW)",
"url": "upload/jxiop/amos_studio/2F378EF430F788CA71E876359B46C4E.png" "url": "upload/jxiop/amos_studio/2F378EF430F788CA71E876359B46C4E.png"
}, },
{ {
"titie": "有功功率", "title": "有功功率",
"title1": "有功功率(MW)", "title1": "有功功率(MW)",
"action": "String.format(\"%.2f\",Double.parseDouble(*)/1000)", "action": "String.format(\"%.2f\",Double.parseDouble(*)/1000)",
"url": "upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png" "url": "upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
{ {
"url": "upload/jxiop/amos_studio/F9A5F9E6EB7C825CA869063E817E281.png", "url": "upload/jxiop/amos_studio/F9A5F9E6EB7C825CA869063E817E281.png",
"title1": "综合效率(%)", "title1": "综合效率(%)",
"title2": "综合效率" "title": "综合效率"
}, },
{ {
"url": "upload/jxiop/amos_studio/DD1CE8BAF5A7C3AC5E6E2C0D46C3EEC.png", "url": "upload/jxiop/amos_studio/DD1CE8BAF5A7C3AC5E6E2C0D46C3EEC.png",
...@@ -29,30 +29,30 @@ ...@@ -29,30 +29,30 @@
{ {
"url": "upload/jxiop/amos_studio/22639FDFF29B20B681DF55F1252876B3.png", "url": "upload/jxiop/amos_studio/22639FDFF29B20B681DF55F1252876B3.png",
"title1": "总辐射日累计(Mb/㎡)", "title1": "总辐射日累计(Mb/㎡)",
"title2": "总辐射累计" "title": "总辐射累计"
}, },
{ {
"titie": "日发电量", "title": "日发电量",
"title1": "日发电量(万kWh)", "title1": "日发电量(万kWh)",
"url": "upload/jxiop/amos_studio/E07C6C41715033585F69934AF08A3431.png" "url": "upload/jxiop/amos_studio/E07C6C41715033585F69934AF08A3431.png"
}, },
{ {
"titie": "月发电量", "title": "月发电量",
"title1": "月发电量(万kWh)", "title1": "月发电量(万kWh)",
"url": "upload/jxiop/amos_studio/6CE2792ABEEAE816CB798649A6796.png" "url": "upload/jxiop/amos_studio/6CE2792ABEEAE816CB798649A6796.png"
}, },
{ {
"titie": "年发电量", "title": "年发电量",
"title1": "年发电量(万kWh)", "title1": "年发电量(万kWh)",
"url": "upload/jxiop/amos_studio/12D321E29727689B334E3E625383EB7C.png" "url": "upload/jxiop/amos_studio/12D321E29727689B334E3E625383EB7C.png"
}, },
{ {
"titie": "上网电量", "title": "上网电量",
"title1": "上网电量(万kWh)", "title1": "上网电量(万kWh)",
"url": "upload/jxiop/amos_studio/1660C5DDA22ACFADC89A60DEDB82FA39.png" "url": "upload/jxiop/amos_studio/1660C5DDA22ACFADC89A60DEDB82FA39.png"
}, },
{ {
"titie": "年利用小时", "title": "年利用小时",
"title1": "年利用小时", "title1": "年利用小时",
"action":"String.format(\"%.2f\",Double.parseDouble(columnMap.get(\"*\").toString())/ (Double.parseDouble(columnMap.get(\"-\").toString())*1000))", "action":"String.format(\"%.2f\",Double.parseDouble(columnMap.get(\"*\").toString())/ (Double.parseDouble(columnMap.get(\"-\").toString())*1000))",
"url": "upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png" "url": "upload/jxiop/amos_studio/C46B483E51ACAC137CBEB5156F6F377.png"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment