Commit 0ae077cf authored by caotao's avatar caotao

工况区间划分、分析变量与工况变量相关性、中心值相关代码提交

parent 7545a034
......@@ -20,44 +20,29 @@ import java.util.List;
* @date 2023-08-11
*/
@RestController
@Api(tags = "工况测点测试")
@Api(tags = "工况测点Controller")
@RequestMapping(value = "/test")
public class TestController extends BaseController {
@Autowired
CommonServiceImpl commonServiceImpl;
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "列表全部数据查询-风电", notes = "列表全部数据查询")
@GetMapping(value = "/listfan")
public ResponseModel<List<IdxBizC80c>> selectForListFan() {
return ResponseHelper.buildResponse(commonServiceImpl.getAllFanstationTestPoint().subList(0, 20));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "列表全部数据查询-光伏", notes = "列表全部数据查询")
@GetMapping(value = "/listpv")
public ResponseModel<List<IdxBizHjev>> selectForListPV() {
return ResponseHelper.buildResponse(commonServiceImpl.getAllPVstationTestPoint().subList(0, 20));
@ApiOperation(httpMethod = "GET", value = "工况测点区间划分", notes = "工况测点区间划分")
@GetMapping(value = "/getConditionVariablesByTime")
public void getConditionVariablesByTime(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getConditionVariablesByTime(startTime, endTime);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "test", notes = "列表全部数据查询")
@GetMapping(value = "/test")
public void selectForListTest() {
commonServiceImpl.getIdxBizUxfvList();
@ApiOperation(httpMethod = "GET", value = "相关性分析", notes = "相关性分析")
@GetMapping(value = "/getConditionVariablesByTimeAnalyse")
public void getConditionVariablesByTimeAnalyse(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getConditionVariablesByTimeAnalyse(startTime, endTime);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "test", notes = "列表全部数据查询")
@GetMapping(value = "/getDateByTime")
public void getDateByTime(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getConditionVariablesByTime(startTime, endTime);
@ApiOperation(httpMethod = "GET", value = "中心值计算", notes = "中心值计算")
@GetMapping(value = "/getConditionVariablesByTimeAnalyse1")
public void getConditionVariablesByTimeAnalyse1(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getConditionVariablesByTimeAnalyse1(startTime, endTime);
}
}
......@@ -4,6 +4,7 @@ import cn.hutool.http.HttpUtil;
import cn.hutool.log.LogFactory;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType;
import com.yeejoin.amos.AmosJxiopAnalyseApplication;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizC80c;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizHjev;
......@@ -26,10 +27,30 @@ import java.util.stream.Collectors;
@Service
public class CommonServiceImpl {
private static final Logger logger = LoggerFactory.getLogger(CommonServiceImpl.class);
//-----------------调用算法时间间隔----------------
@Value("${sleep.time:10}")
Integer sleepTime;
@Value("${gkbl.url:http://36.40.66.175:30009/maas/api/901b4627-4fb0-4527-ab2d-f6ea936c9b9d}")
String gkblurl;
@Value("${base.url:http://36.40.66.175:30009/maas/maas/processes/api/}")
String baseUrl;
//----------------工况变量工况变量划分请求属性配置------------------------
@Value("${gkblhf.url:901b4627-4fb0-4527-ab2d-f6ea936c9b9d}")
String gkqjhfurl;
@Value("${gkblhf.key:input 1}")
String gkqjhfkey;
//----------------工况变量相关性计算请求属性配置------------------------
@Value("${gkxgxfx.url:1bf5548d-aac1-4b43-bdb4-45ba8ea048a8}")
String gkxgxfxurl;
@Value("${gkxgxfx.key:input 1}")
String gkxgxfxkey;
//----------------工况变量中心值计算相关请求属性配置------------------------
@Value("${gkzxzjs.url:d01c690d-fcb7-44b4-8622-7187fb2cb0fd}")
String gkzxzjsurl;
@Value("${gkzxzjs.key:input 1}")
String gkzxzjskey1;
@Value("${gkzxzjs.key:input 2}")
String gkzxzjskey2;
// idx_biz_hjev 光伏监测变量
// idx_biz_c80c 风电监测变量 (根据设备、系统、型号查分析和工况测点)
// idx_biz_3yud 光伏工况变量划分
......@@ -107,23 +128,26 @@ public class CommonServiceImpl {
//遍历查询数据并调用并计算
public void foreachHandlerConditionVariab(String tableName, List<IdxBizUxfv> list, String startTime, String endTime) {
list.forEach(idxBizUxfv -> {
logger.info("--------------------------------------------开始查询--------------------------------");
List<Map<String, String>> params = new ArrayList<>();
logger.info("--------------------------------------------开始查询influxdb--------------------------------");
List<Map<String, Object>> params = new ArrayList<>();
// String sql = String.format("select value from %s where address='%s' and where time >= '%s' and where time <= '%s' ", tableName, idxBizUxfv.getIndexAddress(), startTime, endTime);
String sql = String.format("select value from %s where address='%s' ", tableName, idxBizUxfv.getIndexAddress());
List<Map<String, Object>> returnList = influxdbUtil.query(sql);
returnList.forEach((k) -> {
Map<String, String> map = new HashMap<>();
map.put("processVariable", k.get("value").toString());
map.put("processVariableId", idxBizUxfv.getSequenceNbr());
Map<String, Object> map = new HashMap<>();
map.put("processVariable", Double.parseDouble(k.get("value").toString()));
map.put("processVariableId", Long.parseLong(idxBizUxfv.getSequenceNbr()));
params.add(map);
});
if (!params.isEmpty()) {
logger.info("------------------------------------------开始调用工况变量算法----------------------------------------");
HttpUtil.createPost(gkblurl).body(JSON.toJSONString(params)).execute().body();
logger.info("------------------------------------------开始调用工况变量区间划分算法----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkqjhfkey, params);
String reponse = HttpUtil.createPost(baseUrl + gkqjhfurl).body(JSON.toJSONString(realParams)).execute().body();
try {
logger.info(reponse);
TimeUnit.SECONDS.sleep(sleepTime);
logger.info("------------------------------------------调用工况变量算法结束----------------------------------------");
logger.info("------------------------------------------调用工况变量区间划分算法结束----------------------------------------");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
......@@ -158,25 +182,25 @@ public class CommonServiceImpl {
public void foreachHandlerConditionVariabAnalyse(String tableName, List<IdxBizC80c> list, String startTime, String endTime, IdxBizUxfv idxBizUxfv) {
String sql1 = String.format("select value from %s where address='%s' ", tableName, idxBizUxfv.getIndexAddress());
List<Map<String, Object>> returnList = influxdbUtil.query(sql1);
List<Map<String, String>> params = new ArrayList<>();
List<Map<String, Object>> params = new ArrayList<>();
returnList.forEach((k) -> {
Map<String, String> map = new HashMap<>();
map.put("analysisVariable", k.get("value").toString());
map.put("analysisVariableId", idxBizUxfv.getSequenceNbr());
Map<String, Object> map = new HashMap<>();
map.put("analysisVariable", Double.parseDouble(k.get("value").toString()));
map.put("analysisVariableId", Long.parseLong(idxBizUxfv.getSequenceNbr()));
params.add(map);
});
final List<Map<String, String>> tempParams = params;
final List<Map<String, Object>> tempParams = params;
list.forEach(idxBizC80c -> {
logger.info("--------------------------------------------开始查询--------------------------------");
List<Map<String, String>> params1 = new ArrayList<>();
List<Map<String, String>> requestParams = new ArrayList<>();
logger.info("--------------------------------------------开始查询influxdb--------------------------------");
List<Map<String, Object>> params1 = new ArrayList<>();
List<Map<String, Object>> requestParams = new ArrayList<>();
// String sql = String.format("select value from %s where address='%s' and where time >= '%s' and where time <= '%s' ", tableName, idxBizUxfv.getIndexAddress(), startTime, endTime);
String sql = String.format("select value from %s where address='%s' ", tableName, idxBizC80c.getProcessIndexAddress());
List<Map<String, Object>> returnList1 = influxdbUtil.query(sql);
returnList.forEach((k) -> {
Map<String, String> map = new HashMap<>();
map.put("processVariable", k.get("value").toString());
map.put("processVariableId", idxBizC80c.getProcessPointId().toString());
Map<String, Object> map = new HashMap<>();
map.put("processVariable", Double.parseDouble(k.get("value").toString()));
map.put("processVariableId", Long.parseLong(idxBizC80c.getProcessPointId().toString()));
params1.add(map);
});
if (tempParams.size() >= params1.size()) {
......@@ -185,11 +209,14 @@ public class CommonServiceImpl {
requestParams = megreMapList(params1, tempParams);
}
if (!requestParams.isEmpty()) {
logger.info("------------------------------------------开始调用工况变量算法----------------------------------------");
HttpUtil.createPost(gkblurl).body(JSON.toJSONString(requestParams)).execute().body();
logger.info("------------------------------------------分析变量与工况变量相关性分析算法开始----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkxgxfxkey, requestParams);
String repsonse = HttpUtil.createPost(baseUrl + gkxgxfxurl).body(JSON.toJSONString(realParams)).execute().body();
try {
logger.info("response-------------" + repsonse);
TimeUnit.SECONDS.sleep(sleepTime);
logger.info("------------------------------------------调用工况变量算法结束----------------------------------------");
logger.info("------------------------------------------分析变量与工况变量相关性分析算法结束----------------------------------------");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
......@@ -197,23 +224,24 @@ public class CommonServiceImpl {
});
}
public List<Map<String, String>> megreMapList(List<Map<String, String>> longList, List<Map<String, String>> shortList) {
List<Map<String, String>> resultList = new ArrayList<>();
public List<Map<String, Object>> megreMapList(List<Map<String, Object>> longList, List<Map<String, Object>> shortList) {
List<Map<String, Object>> resultList = new ArrayList<>();
for (int i = 0; i < longList.size(); i++) {
Map<String, String> map = longList.get(i);
Map<String, String> mapOfShortList = null;
if (i < mapOfShortList.size() - 1) {
Map<String, Object> map = longList.get(i);
Map<String, Object> mapOfShortList = null;
if (i < shortList.size() - 1) {
mapOfShortList = shortList.get(i);
} else {
mapOfShortList = shortList.get(shortList.size() - 1);
}
if (map.containsKey("processVariable")) {
if (!map.containsKey("processVariable")) {
map.put("processVariable", mapOfShortList.get("processVariable"));
map.put("processVariableId", mapOfShortList.get("processVariableId"));
} else {
map.put("analysisVariable", mapOfShortList.get("analysisVariable"));
map.put("analysisVariableId", mapOfShortList.get("analysisVariableId"));
}
resultList.add(map);
}
return resultList;
}
......@@ -224,7 +252,7 @@ public class CommonServiceImpl {
List<IdxBizUxfv> list = IdxBizUxfvHashMap.get(s);
list.forEach(idxBizUxfv -> {
List<IdxBizC80c> gongkuangList = idxBizC80cMapper.selectList(new QueryWrapper<IdxBizC80c>().eq("ANALYSIS_GATEWAY_ID", idxBizUxfv.getGatewayId()).eq("ANALYSIS_POINT_ID", idxBizUxfv.getSequenceNbr()).orderByDesc("CORRELATION_COEFFICIENT").last("limit 0,3"));
foreachHandlerConditionVariabAnalyse(s, gongkuangList, startTime, endTime, idxBizUxfv);
foreachHandlerConditionVariabAnalyse1(s, gongkuangList, startTime, endTime, idxBizUxfv);
});
});
}
......@@ -232,22 +260,54 @@ public class CommonServiceImpl {
public void foreachHandlerConditionVariabAnalyse1(String tableName, List<IdxBizC80c> list, String startTime, String endTime, IdxBizUxfv idxBizUxfv) {
String sql0 = String.format("select value from %s where address='%s' ", tableName, idxBizUxfv.getIndexAddress());
List<Map<String, Object>> returnList = influxdbUtil.query(sql0);
List<Map<String, String>> params = new ArrayList<>();
List<Map<String, Object>> params = new ArrayList<>();
returnList.forEach((k) -> {
Map<String, String> map = new HashMap<>();
map.put("analysisVariable", k.get("value").toString());
map.put("analysisVariableId", idxBizUxfv.getSequenceNbr());
Map<String, Object> map = new HashMap<>();
map.put("analysisVariable", Double.parseDouble(k.get("value").toString()));
map.put("analysisVariableId", Long.parseLong(idxBizUxfv.getSequenceNbr()));
params.add(map);
});
final List<Map<String, String>> tempParams = params;
logger.info("--------------------------------------------开始查询--------------------------------");
List<Map<String, String>> params1 = new ArrayList<>();
List<Map<String, String>> requestParams = new ArrayList<>();
final List<Map<String, Object>> tempParams = params;
logger.info("--------------------------------------------开始查询influxdb--------------------------------");
List<Map<String, Object>> params1 = new ArrayList<>();
List<Map<String, Object>> requestParams = new ArrayList<>();
// String sql = String.format("select value from %s where address='%s' and where time >= '%s' and where time <= '%s' ", tableName, idxBizUxfv.getIndexAddress(), startTime, endTime);
String sql = String.format("select value from %s where address='%s' ", tableName, list.get(0).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());
List<HashMap<String, Object>> values = new ArrayList<>();
List<String> processPointIds = list.stream().map(idxBizC80c -> idxBizC80c.getProcessPointId().toString()).collect(Collectors.toList());
List<IdxBizUxfv> idxBizUxfvList = idxBizUxfvMapper.selectList(new QueryWrapper<IdxBizUxfv>().in("SEQUENCE_NBR", processPointIds));
//区间值1
HashMap<String, Object> value1 = new HashMap<>();
value1.put("processVariable1", idxBizUxfvList.get(2).getIntervalValue1());
value1.put("processVariable2", idxBizUxfvList.get(1).getIntervalValue1());
value1.put("processVariable3", idxBizUxfvList.get(0).getIntervalValue1());
values.add(value1);
//区间值2
HashMap<String, Object> value2 = new HashMap<>();
value2.put("processVariable1", idxBizUxfvList.get(2).getIntervalValue2());
value2.put("processVariable2", idxBizUxfvList.get(1).getIntervalValue2());
value2.put("processVariable3", idxBizUxfvList.get(0).getIntervalValue2());
values.add(value2);
//区间值3
HashMap<String, Object> value3 = new HashMap<>();
value3.put("processVariable1", idxBizUxfvList.get(2).getIntervalValue3());
value3.put("processVariable2", idxBizUxfvList.get(1).getIntervalValue3());
value3.put("processVariable3", idxBizUxfvList.get(0).getIntervalValue3());
values.add(value3);
//区间值4
HashMap<String, Object> value4 = new HashMap<>();
value4.put("processVariable1", idxBizUxfvList.get(2).getIntervalValue4());
value4.put("processVariable2", idxBizUxfvList.get(1).getIntervalValue4());
value4.put("processVariable3", idxBizUxfvList.get(0).getIntervalValue4());
values.add(value4);
//区间值5
HashMap<String, Object> value5 = new HashMap<>();
value5.put("processVariable1", idxBizUxfvList.get(2).getIntervalValue5());
value5.put("processVariable2", idxBizUxfvList.get(1).getIntervalValue5());
value5.put("processVariable3", idxBizUxfvList.get(0).getIntervalValue5());
values.add(value5);
List<Map<String, Object>> returnList0 = influxdbUtil.query(sql);
List<Map<String, Object>> maxList = returnList0;
List<Map<String, Object>> returnList1 = influxdbUtil.query(sql);
......@@ -255,7 +315,7 @@ public class CommonServiceImpl {
List<Map<String, Object>> returnList2 = influxdbUtil.query(sql);
maxList = maxList.size() > returnList2.size() ? maxList : returnList2;
for (int j = 0; j < maxList.size(); j++) {
Map<String, String> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
Map<String, Object> map1 = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>();
......@@ -274,12 +334,12 @@ public class CommonServiceImpl {
} else {
map3 = returnList2.get(returnList2.size() - 1);
}
map.put("processVariable1", map1.get("value").toString());
map.put("processVariable1Id", list.get(0).getProcessPointId().toString());
map.put("processVariable2", map2.get("value").toString());
map.put("processVariable2Id", list.get(1).getProcessPointId().toString());
map.put("processVariable3", map3.get("value").toString());
map.put("processVariable3Id", list.get(2).getProcessPointId().toString());
map.put("processVariable1", Double.parseDouble(map1.get("value").toString()));
map.put("processVariable1Id", Long.parseLong(list.get(0).getProcessPointId().toString()));
map.put("processVariable2", Double.parseDouble(map2.get("value").toString()));
map.put("processVariable2Id", Long.parseLong(list.get(1).getProcessPointId().toString()));
map.put("processVariable3", Double.parseDouble(map3.get("value").toString()));
map.put("processVariable3Id", Long.parseLong(list.get(2).getProcessPointId().toString()));
params1.add(map);
if (tempParams.size() >= params1.size()) {
requestParams = megreMapList1(tempParams, params1);
......@@ -287,11 +347,15 @@ public class CommonServiceImpl {
requestParams = megreMapList1(params1, tempParams);
}
if (!requestParams.isEmpty()) {
logger.info("------------------------------------------开始调用工况变量算法----------------------------------------");
HttpUtil.createPost(gkblurl).body(JSON.toJSONString(requestParams)).execute().body();
logger.info("------------------------------------------开始调用中心值计算算法开始----------------------------------------");
HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkzxzjskey1, requestParams);
realParams.put(gkzxzjskey2, values);
String response = HttpUtil.createPost(baseUrl + gkzxzjsurl).body(JSON.toJSONString(realParams)).execute().body();
try {
logger.info("--------------------repsonse: "+response);
TimeUnit.SECONDS.sleep(sleepTime);
logger.info("------------------------------------------调用工况变量算法结束----------------------------------------");
logger.info("------------------------------------------调用中心值计算算法结束----------------------------------------");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
......@@ -300,17 +364,17 @@ public class CommonServiceImpl {
}
public List<Map<String, String>> megreMapList1(List<Map<String, String>> longList, List<Map<String, String>> shortList) {
List<Map<String, String>> resultList = new ArrayList<>();
public List<Map<String, Object>> megreMapList1(List<Map<String, Object>> longList, List<Map<String, Object>> shortList) {
List<Map<String, Object>> resultList = new ArrayList<>();
for (int i = 0; i < longList.size(); i++) {
Map<String, String> map = longList.get(i);
Map<String, String> mapOfShortList = null;
if (i < mapOfShortList.size() - 1) {
Map<String, Object> map = longList.get(i);
Map<String, Object> mapOfShortList = null;
if (i < shortList.size() - 1) {
mapOfShortList = shortList.get(i);
} else {
mapOfShortList = shortList.get(shortList.size() - 1);
}
if (map.containsKey("processVariable1")) {
if (!map.containsKey("processVariable1")) {
map.put("processVariable1", mapOfShortList.get("processVariable1"));
map.put("processVariable1Id", mapOfShortList.get("processVariable1Id"));
map.put("processVariable2", mapOfShortList.get("processVariable2"));
......@@ -321,7 +385,14 @@ public class CommonServiceImpl {
map.put("analysisVariable", mapOfShortList.get("analysisVariable"));
map.put("analysisVariableId", mapOfShortList.get("analysisVariableId"));
}
resultList.add(map);
}
return resultList;
}
public List<Map<String, Object>> getInfluxdbDataByConditon() {
String sql = "select * from %s";
List<Map<String, Object>> result = influxdbUtil.query(sql);
return result;
}
}
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