Commit dc74bac8 authored by caotao's avatar caotao

1.更新算法id、调整从influxdb获取数据接口

parent a35b4bb4
...@@ -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)) ;
} }
} }
...@@ -15,7 +15,6 @@ import org.elasticsearch.index.query.QueryBuilder; ...@@ -15,7 +15,6 @@ import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; 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.ElasticsearchRestTemplate;
...@@ -26,6 +25,7 @@ import org.springframework.scheduling.annotation.Scheduled; ...@@ -26,6 +25,7 @@ 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;
...@@ -35,25 +35,34 @@ import java.util.stream.Collectors; ...@@ -35,25 +35,34 @@ 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;
...@@ -160,7 +169,7 @@ public class CommonServiceImpl { ...@@ -160,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);
...@@ -191,7 +200,7 @@ public class CommonServiceImpl { ...@@ -191,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);
...@@ -294,7 +303,7 @@ public class CommonServiceImpl { ...@@ -294,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);
...@@ -339,7 +348,7 @@ public class CommonServiceImpl { ...@@ -339,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);
...@@ -412,7 +421,7 @@ public class CommonServiceImpl { ...@@ -412,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--------------------------------");
...@@ -423,37 +432,37 @@ public class CommonServiceImpl { ...@@ -423,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;
...@@ -482,12 +491,13 @@ public class CommonServiceImpl { ...@@ -482,12 +491,13 @@ 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()) { if (params.size() >= params1.size()) {
requestParams = megreMapList1(params, params1); requestParams = megreMapList1(params, params1);
} else { } else {
...@@ -496,13 +506,13 @@ public class CommonServiceImpl { ...@@ -496,13 +506,13 @@ public class CommonServiceImpl {
if (!requestParams.isEmpty()) { if (!requestParams.isEmpty()) {
logger.info("---------------------------------风机中心值---------开始调用中心值计算算法开始----------------------------------------"); logger.info("---------------------------------风机中心值---------开始调用中心值计算算法开始----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkzxzjskey1, requestParams); realParams.put(gkzxzjskey1, values);
realParams.put(gkzxzjskey2, values); realParams.put(gkzxzjskey2, requestParams);
logger.info("------------------------------风机中心值------请求参数---------------------------------------" + JSON.toJSONString(realParams)); logger.info("------------------------------风机中心值------请求参数---------------------------------------" + JSON.toJSONString(realParams));
String response = HttpUtil.createPost(baseUrl + gkzxzjsurl).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + gkzxzjsurlfan).body(JSON.toJSONString(realParams)).execute().body();
try { try {
logger.info("------------------风机中心值--repsonse: " + response); logger.info("------------------风机中心值--repsonse: " + response);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(zxzsleepTime);
logger.info("-----------------------------------风机中心值-------调用中心值计算算法结束----------------------------------------"); logger.info("-----------------------------------风机中心值-------调用中心值计算算法结束----------------------------------------");
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -510,8 +520,6 @@ public class CommonServiceImpl { ...@@ -510,8 +520,6 @@ public class CommonServiceImpl {
} }
} }
}
//中心值参数组装-光伏 //中心值参数组装-光伏
public void foreachHandlerConditionVariabAnalyse1Pv(String tableName, List<IdxBizPvPointVarCorrelation> list, String startTime, String endTime, IdxBizPvPointProcessVariableClassification idxBizPvPointProcessVariableClassification) { public void foreachHandlerConditionVariabAnalyse1Pv(String tableName, List<IdxBizPvPointVarCorrelation> list, String startTime, String endTime, IdxBizPvPointProcessVariableClassification idxBizPvPointProcessVariableClassification) {
String sql0 = String.format("select value from %s where address='%s' ", tableName, idxBizPvPointProcessVariableClassification.getIndexAddress()); String sql0 = String.format("select value from %s where address='%s' ", tableName, idxBizPvPointProcessVariableClassification.getIndexAddress());
...@@ -535,33 +543,33 @@ public class CommonServiceImpl { ...@@ -535,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;
...@@ -596,6 +604,7 @@ public class CommonServiceImpl { ...@@ -596,6 +604,7 @@ 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()) { if (params.size() >= params1.size()) {
requestParams = megreMapList1(params, params1); requestParams = megreMapList1(params, params1);
} else { } else {
...@@ -604,9 +613,9 @@ public class CommonServiceImpl { ...@@ -604,9 +613,9 @@ public class CommonServiceImpl {
if (!requestParams.isEmpty()) { if (!requestParams.isEmpty()) {
logger.info("-------------------------------------光伏中心值-----开始调用中心值计算算法----------------------------------------"); logger.info("-------------------------------------光伏中心值-----开始调用中心值计算算法----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkzxzjskey1, requestParams); realParams.put(gkzxzjskey1, values);
realParams.put(gkzxzjskey2, values); realParams.put(gkzxzjskey2, requestParams);
String response = HttpUtil.createPost(baseUrl + gkzxzjsurl).body(JSON.toJSONString(realParams)).execute().body(); String response = HttpUtil.createPost(baseUrl + gkzxzjsurlpv).body(JSON.toJSONString(realParams)).execute().body();
try { try {
logger.info("-------------光伏中心值-------repsonse: " + response); logger.info("-------------光伏中心值-------repsonse: " + response);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
...@@ -615,7 +624,7 @@ public class CommonServiceImpl { ...@@ -615,7 +624,7 @@ public class CommonServiceImpl {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
}
} }
...@@ -646,21 +655,39 @@ public class CommonServiceImpl { ...@@ -646,21 +655,39 @@ 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 * * * ?") @Scheduled(cron = "0 0/10 * * * ?")
......
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