Commit 5567c659 authored by tangwei's avatar tangwei

解决冲突

parents 1d10d20d 258f14c8
......@@ -30,6 +30,7 @@ import org.typroject.tyboot.core.foundation.context.SpringContextHelper;
import java.io.*;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -69,6 +70,9 @@ public class ClientHandler<path> implements Runnable {
}
private String upload2Maas(InputStream inputStream, String hostAndPort) throws IOException {
InputStream intercept = intercept(inputStream);
AmosRequestContext robotAuthentication = SpringContextHelper.getBean(AmosRequestContext.class);
if (Objects.nonNull(robotAuthentication)) {
String token = robotAuthentication.getToken();
......@@ -93,16 +97,16 @@ public class ClientHandler<path> implements Runnable {
}
};
params.add("file", resource);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, getHeader(token,product,appKey,hostAndPort,true));
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, getHeader(token, product, appKey, hostAndPort, true));
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> responseEntity = restTemplate.exchange(uploadUrl, HttpMethod.POST, requestEntity, String.class);
String body = responseEntity.getBody();
JSONObject jsonObject = JSONObject.parseObject(body);
String result = jsonObject.getString("result");
String path = jsonObject.getString("path");
if (jsonObject.getString("status").equals("200")){
log.info("路径:"+path+"/"+result);
}else {
if (jsonObject.getString("status").equals("200")) {
log.info("路径:" + path + "/" + result);
} else {
throw new RuntimeException("返回状态码错误");
}
......@@ -152,14 +156,14 @@ public class ClientHandler<path> implements Runnable {
return null;
}
private HttpHeaders getHeader(String token,String product,String appKey,String hostAndPort,Boolean isUpload){
private HttpHeaders getHeader(String token, String product, String appKey, String hostAndPort, Boolean isUpload) {
HttpHeaders header = new HttpHeaders();
header.add(Constant.TOKEN, token);
header.add(Constant.PRODUCT, product);
header.add(Constant.APPKEY, appKey);
if (isUpload){
if (isUpload) {
header.setContentType(MediaType.MULTIPART_FORM_DATA);
}else {
} else {
header.setContentType(MediaType.APPLICATION_JSON);
}
return header;
......@@ -169,6 +173,58 @@ public class ClientHandler<path> implements Runnable {
requestInfoToSocketServer();
}
//截取文件流
public static InputStream intercept(InputStream is) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "/n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String string1 = sb.toString();
int startFilePath = string1.indexOf("##STATITLE##");
int endFilePath = string1.indexOf("##ENDTITLE##");
int startFile = string1.indexOf("##STAFILE##");
int endFile = string1.indexOf("##ENDFILE##");
if (startFilePath < 0) {
log.info("不存在文件名开始标志");
return null;
}
if (endFilePath < 0) {
log.info("不存在文件名结束标志");
return null;
}
if (startFile < 0) {
log.info("不存在文件开始标志");
return null;
}
if (endFile < 0) {
log.info("不存在文件结束标志");
return null;
}
String filePath = string1.substring(startFilePath, endFilePath).substring("##STATITLE##".length());
log.info("文件名:" + filePath);
String file = string1.substring(startFile, endFile).substring("##STAFILE##".length());
log.info("文件:" + file);
InputStream fileInputStream = new ByteArrayInputStream(file.getBytes());
return fileInputStream;
}
private static void requestInfoToSocketServer() {
try {
Socket socket = new Socket("127.0.0.1", 7777);
......
package com.yeejoin.amos.boot.module.cas.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.module.cas.api.entity.IdxBizXnzs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Value;
import java.util.List;
import java.sql.*;
import java.util.*;
public interface IdxBizSyncService extends IService<IdxBizXnzs> {
// 多个查询(分页)
List selectAllPageQuery(String tableName, Map params, int current, int size);
String getSql(String tableName, Map params, int current, int size);
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.cas.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.module.cas.api.service.IdxBizSyncService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@RestController
@Api(tags = "Api")
@RequestMapping(value = "/idx-biz-sync", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class IdxBizSyncController {
@Autowired
private IdxBizSyncService idxBizSyncService;
@TycloudOperation(ApiLevel = UserType.AGENCY ,needAuth = false)
@RequestMapping(value = "/page/{tableName}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
@ResponseBody
public List listPage(@PathVariable String tableName,
@RequestParam(value = "current",defaultValue = "1") int current,
@RequestParam(value = "size",defaultValue = "10") int size,
@RequestBody Map params) throws Exception{
List list = idxBizSyncService.selectAllPageQuery(tableName, params, current, size);
return list;
}
}
package com.yeejoin.amos.boot.module.cas.service.impl;
import com.yeejoin.amos.boot.module.cas.api.dto.IdxBizXnzsDto;
import com.yeejoin.amos.boot.module.cas.api.entity.IdxBizXnzs;
import com.yeejoin.amos.boot.module.cas.api.mapper.IdxBizXnzsMapper;
import com.yeejoin.amos.boot.module.cas.api.service.IIdxBizXnzsService;
import com.yeejoin.amos.boot.module.cas.api.service.IdxBizSyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@Service
public class IdxBizSyncServiceImpl extends BaseService<IdxBizXnzsDto, IdxBizXnzs, IdxBizXnzsMapper> implements IdxBizSyncService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public List selectAllPageQuery(String tableName, Map params, int current, int size) {
List<Map<String, Object>> list = jdbcTemplate.queryForList(getSql(tableName, params, current, size));
return list;
}
@Override
public String getSql(String tableName, Map params, int current, int size) {
String sql = "select * from " + tableName;
sql += " where ";
Iterator<Map.Entry<String, Object>> it = params.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
sql = sql + entry.getKey() + " = " + "'" + entry.getValue() + "'" + " AND ";
}
sql += "1 = 1 ";
sql += " limit " + (current - 1) * size + "," + size;
return sql;
}
}
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.10.210:3306/amos_idx_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.url=jdbc:mysql://39.98.45.134:3306/amos_idx?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8&useSSL=false&autoReconnect=true&zeroDateTimeBehavior=CONVERT_TO_NULL
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
......
......@@ -58,7 +58,7 @@ public class AmosJxiopAnalyseApplication {
@Autowired
private EmqKeeper emqKeeper;
//本地是否执行健康指数算法开关
@Value("${openHealth:true}")
@Value("${openHealth:false}")
Boolean openHealth;
@Autowired
private SyncESDataToTdengineMqttListener syncESDataToTdengineMqttListener;
......@@ -79,7 +79,7 @@ public class AmosJxiopAnalyseApplication {
@Bean
public void initMqtt() throws Exception {
if (!openHealth) {
if (openHealth) {
//订阅固化周期性数据成功的消息
emqKeeper.subscript("sync_esdata_to_tdengine_notice", 1, syncESDataToTdengineMqttListener);
}
......
......@@ -112,6 +112,14 @@ public class CommonConstans {
}
};
public static final HashMap<String, String> waringPeriodTowaringCycle = new HashMap<String, String>() {
{
put("按时刻", "分钟");
put("按小时", "小时");
put("按天", "天");
}
};
public static final HashMap<String, String> waringPeriodDateFormate = new HashMap<String, String>() {
{
......
......@@ -22,9 +22,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author system_generator
......@@ -47,7 +45,7 @@ public class AnalyseController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "工况测点区间划分-风机", notes = "工况测点区间划分-风机")
@GetMapping(value = "/getFanConditionVariablesByTime")
public ResponseModel<String> getFanConditionVariablesByTime(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime) ){
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime)) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
......@@ -55,23 +53,25 @@ public class AnalyseController extends BaseController {
}
return ResponseHelper.buildResponse(commonServiceImpl.getFanConditionVariablesByTimeThread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "工况测点区间划分-光伏", notes = "工况测点区间划分-光伏")
@GetMapping(value = "/getPvConditionVariablesByTime")
public ResponseModel<String> getPvConditionVariablesByTime(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime) ){
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
}
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime)) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
}
return ResponseHelper.buildResponse(commonServiceImpl.getPvConditionVariablesByTimeThread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "相关性分析-风机", notes = "相关性分析-风机")
@GetMapping(value = "/getFanConditionVariablesByTimeAnalyse")
public ResponseModel<String> getFanConditionVariablesByTimeAnalyse(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime) ){
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime)) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
......@@ -93,10 +93,10 @@ public class AnalyseController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "相关性分析 - 光伏 - 新", notes = "相关性分析 - 光伏 - 新")
@GetMapping(value = "/getPvConditionVariablesByTimeAnalyseNew")
public ResponseModel<String> getPvConditionVariablesByTimeAnalyseNew(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) throws InterruptedException {
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime) ){
startTime = DateUtils.convertDateToString(DateUtil.beginOfYear(new Date()), DateUtils.DATE_TIME_PATTERN);
endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()), DateUtils.DATE_TIME_PATTERN);
public ResponseModel<String> getPvConditionVariablesByTimeAnalyseNew(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) throws InterruptedException {
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime)) {
startTime = DateUtils.convertDateToString(DateUtil.beginOfYear(new Date()), DateUtils.DATE_TIME_PATTERN);
endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()), DateUtils.DATE_TIME_PATTERN);
}
commonServiceImpl.chuliPv(startTime, endTime);
return ResponseHelper.buildResponse(commonServiceImpl.getPvConditionVariablesByTimeAnalyseThread(startTime, endTime));
......@@ -107,7 +107,7 @@ public class AnalyseController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "相关性分析-风机", notes = "相关性分析-风机")
@GetMapping(value = "/getPvConditionVariablesByTimeAnalyse")
public ResponseModel<String> getPvConditionVariablesByTimeAnalyse(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime) ){
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime)) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
......@@ -115,11 +115,12 @@ public class AnalyseController extends BaseController {
}
return ResponseHelper.buildResponse(commonServiceImpl.getPvConditionVariablesByTimeAnalyseThread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "中心值计算-风机", notes = "中心值计算-风机")
@GetMapping(value = "/getFanConditionVariablesByTimeAnalyse1")
public ResponseModel<String> getFanConditionVariablesByTimeAnalyse1(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime) ){
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime)) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
......@@ -127,11 +128,12 @@ public class AnalyseController extends BaseController {
}
return ResponseHelper.buildResponse(commonServiceImpl.getFanConditionVariablesByTimeAnalyse1Thread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "中心值计算-光伏", notes = "中心值计算-光伏")
@GetMapping(value = "/getPvConditionVariablesByTimeAnalyse1")
public ResponseModel<String> getPvConditionVariablesByTimeAnalyse1(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime) ){
if (StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime)) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
......@@ -174,7 +176,7 @@ public class AnalyseController extends BaseController {
if (StringUtils.isEmpty(endTime)) {
endTime = DateUtils.convertDateToString(DateUtils.dateAddHours(new Date(), -8), DateUtils.DATE_TIME_PATTERN);
}
return ResponseHelper.buildResponse(commonServiceImpl.getInfluxdbDataByConditon(stationType,pointId,startTime, endTime)) ;
return ResponseHelper.buildResponse(commonServiceImpl.getInfluxdbDataByConditon(stationType, pointId, startTime, endTime));
}
......@@ -189,16 +191,16 @@ public class AnalyseController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "post", value = "获取influxdb数据", notes = "获取influxdb数据")
@PostMapping(value = "/getInfluxdbDataByConditon")
public ResponseModel<Map<String, Object>> getDataByConditon(@RequestParam String stationType, @RequestParam(required = false) String pointId, @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,@RequestBody Map<String,Object> map ) {
if ("FD".equals(stationType)){
public ResponseModel<Map<String, Object>> getDataByConditon(@RequestParam String stationType, @RequestParam(required = false) String pointId, @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestBody Map<String, Object> map) {
if ("FD".equals(stationType)) {
LambdaQueryWrapper<IdxBizFanHealthIndex> indexLambdaQueryWrapper = new LambdaQueryWrapper<>();
indexLambdaQueryWrapper.eq(IdxBizFanHealthIndex::getStation,map.get("STATION"));
indexLambdaQueryWrapper.eq(IdxBizFanHealthIndex::getEquipmentName,map.get("EQUIPNAME"));
indexLambdaQueryWrapper.eq(IdxBizFanHealthIndex::getPointName,map.get("EQUIPINDEX")).last("limit 1");
LambdaQueryWrapper<IdxBizFanHealthIndex> indexLambdaQueryWrapper = new LambdaQueryWrapper<>();
indexLambdaQueryWrapper.eq(IdxBizFanHealthIndex::getStation, map.get("STATION"));
indexLambdaQueryWrapper.eq(IdxBizFanHealthIndex::getEquipmentName, map.get("EQUIPNAME"));
indexLambdaQueryWrapper.eq(IdxBizFanHealthIndex::getPointName, map.get("EQUIPINDEX")).last("limit 1");
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = idxBizFanHealthIndexMapper.selectList(indexLambdaQueryWrapper);
if (CollectionUtils.isNotEmpty(idxBizFanHealthIndices)){
if (CollectionUtils.isNotEmpty(idxBizFanHealthIndices)) {
pointId = idxBizFanHealthIndices.get(0).getIndexAddress();
}
}
......@@ -232,18 +234,35 @@ public class AnalyseController extends BaseController {
if (StringUtils.isEmpty(endTime)) {
endTime = DateUtils.convertDateToString(DateUtils.dateAddHours(new Date(), -8), DateUtils.DATE_TIME_PATTERN);
}
return ResponseHelper.buildResponse(commonServiceImpl.getInfluxdbDataByConditon(stationType,pointId,startTime, endTime)) ;
return ResponseHelper.buildResponse(commonServiceImpl.getInfluxdbDataByConditon(stationType, pointId, startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "预警详情信息-风机", notes = "预警详情信息-风机")
@GetMapping(value = "/getAlramInfoDetailOfFan")
public ResponseModel<Map<String, Object>> getAlramInfoDetailOfFan(@RequestParam(required = true) String id){
return ResponseHelper.buildResponse(iAlarmInfoDetailService.getAlramInfoDetailOfFan(id));
@ApiOperation(httpMethod = "GET", value = "预警详情信息", notes = "预警详情信息")
@GetMapping(value = "/getAlramInfoDetail")
public ResponseModel<Map<String, Object>> getAlramInfoDetailOfFan(@RequestParam(required = true) String id, @RequestParam(required = true) String type) {
if ("FAN".equals(type)) {
return ResponseHelper.buildResponse(iAlarmInfoDetailService.getAlramInfoDetailOfFan(id));
} else {
return ResponseHelper.buildResponse(iAlarmInfoDetailService.getAlramInfoDetailOfPv(id));
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "预警详情信息-光伏", notes = "预警详情信息-光伏")
@GetMapping(value = "/getAlramInfoDetailOfPv")
public ResponseModel<Map<String, Object>> getAlramInfoDetailOfPv(@RequestParam(required = true) String id){
return ResponseHelper.buildResponse(iAlarmInfoDetailService.getAlramInfoDetailOfPv(id));
@GetMapping(value = "/queryIndexByArae")
public ResponseModel<Map<String, Object>> queryIndexByArae(String ARAE, String ANALYSISTYPE, String startTimeTop, String endTimeTop) {
List<Map<String, Object>> maps = idxBizFanHealthIndexMapper.queryIndexByArae(ARAE, ANALYSISTYPE, startTimeTop, endTimeTop);
List<String> axisData = new ArrayList<>();
List<String> seriesData = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
for (Map<String, Object> obj : maps) {
axisData.add(obj.get("HEALTHINDEX").toString());
seriesData.add(obj.get("ANALYSISTIME").toString());
}
map.put("axisData", axisData);
map.put("seriesData", seriesData);
return ResponseHelper.buildResponse(map);
}
}
......@@ -16,10 +16,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -162,20 +159,20 @@ public class KafkaAnalyseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全景诊断回溯")
@GetMapping("/getFullViewRecall")
public ResponseModel<List<FullViewRecallInfoDTO>> getFullViewRecall() {
List<Map<String, Object>> stationIndexInfo = idxBizFanHealthIndexMapper.getStationIndexInfo();
public ResponseModel<List<FullViewRecallInfoDTO>> getFullViewRecall(@RequestParam(required = false, value = "analysisType") String analysisType) {
List<Map<String, Object>> stationIndexInfo = idxBizFanHealthIndexMapper.getStationIndexInfoByParam(analysisType);
Map<String, Double> stationHealthIndexMap = stationIndexInfo.stream().collect(Collectors.toMap(t -> t.get("station").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> equipmentIndexInfo = idxBizFanHealthIndexMapper.getEquipmentIndexInfo();
List<Map<String, Object>> equipmentIndexInfo = idxBizFanHealthIndexMapper.getEquipmentIndexInfoByParam(analysisType);
Map<String, Double> equipmentIndexInfoMap = equipmentIndexInfo.stream().collect(Collectors.toMap(t -> t.get("equipmentName").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> subSystemIndexInfo = idxBizFanHealthIndexMapper.getSubSystemIndexInfo();
List<Map<String, Object>> subSystemIndexInfo = idxBizFanHealthIndexMapper.getSubSystemIndexInfoByParam(analysisType);
Map<String, Double> subSystemIndexInfoMap = subSystemIndexInfo.stream().collect(Collectors.toMap(t -> t.get("subSystem").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> pointNameIndexInfo = idxBizFanHealthIndexMapper.getPointNameIndexInfo();
List<Map<String, Object>> pointNameIndexInfo = idxBizFanHealthIndexMapper.getPointNameIndexInfoByParam(analysisType);
Map<String, Double> pointNameIndexInfoMap = pointNameIndexInfo.stream().collect(Collectors.toMap(t -> t.get("gatewayIndexAddress").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
......@@ -193,7 +190,7 @@ public class KafkaAnalyseController {
int stationInt = 1;
int equipmentInt = 1;
int subSystemInt = 1;
Double healthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfo(null, null).doubleValue();
Double healthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfoByParam(null, null, analysisType).doubleValue();
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
......@@ -211,14 +208,14 @@ public class KafkaAnalyseController {
allMapDto.setScore(healthScoreInfo);
allMapDto.setIsRoot(true);
allMapDto.setCategory("category");
allMapDto.setChildList(new ArrayList<>());
allMapDto.setChildren(new ArrayList<>());
allMapDto.setParentKey("0");
for (Map.Entry<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> areaMap : resultMap.entrySet()) {
Double areaLowScore = null;
Double areaHighScore = null;
Double areaHealthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfo(areaMap.getKey(), null).doubleValue();
Double areaHealthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfoByParam(areaMap.getKey(), null, analysisType).doubleValue();
LambdaQueryWrapper<IdxBizFanHealthLevel> areaQuery = new LambdaQueryWrapper<>();
areaQuery.isNull(IdxBizFanHealthLevel::getStatus);
......@@ -233,7 +230,7 @@ public class KafkaAnalyseController {
areaMapDto.setStatus(areaIdxBizFanHealthLevel.getHealthLevel());
areaMapDto.setScore(areaHealthScoreInfo);
areaMapDto.setParentKey(allMapDto.getKey());
allMapDto.getChildList().add(areaMapDto);
allMapDto.getChildren().add(areaMapDto);
areaInt++;
List<FullViewRecallInfoDTO> areaMapList = new ArrayList<>();
for (Map.Entry<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>> stationMap : areaMap.getValue().entrySet()) {
......@@ -276,7 +273,7 @@ public class KafkaAnalyseController {
}
}
stationDto.setParentKey(areaMapDto.getKey());
areaMapDto.getChildList().add(stationDto);
areaMapDto.getChildren().add(stationDto);
stationInt++;
for (Map.Entry<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>> equipmentMap : stationMap.getValue().entrySet()) {
......@@ -301,7 +298,7 @@ public class KafkaAnalyseController {
equipmentMapDto.setStatus(levelInfo.getHealthLevel());
equipmentMapDto.setScore(equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0));
equipmentMapDto.setParentKey(stationDto.getKey());
stationDto.getChildList().add(equipmentMapDto);
stationDto.getChildren().add(equipmentMapDto);
equipmentInt++;
for (Map.Entry<String, Map<String, List<FullViewRecallDataDTO>>> subSystemMap : equipmentMap.getValue().entrySet()) {
FullViewRecallInfoDTO subSystemMapDto = new FullViewRecallInfoDTO();
......@@ -315,7 +312,7 @@ public class KafkaAnalyseController {
subSystemMapDto.setScore(subSystemIndexInfoMap.getOrDefault(subSystemMap.getKey(), 100.0));
subSystemMapDto.setParentKey(equipmentMapDto.getKey());
equipmentMapDto.getChildList().add(subSystemMapDto);
equipmentMapDto.getChildren().add(subSystemMapDto);
subSystemInt++;
for (Map.Entry<String, List<FullViewRecallDataDTO>> pointNameMap : subSystemMap.getValue().entrySet()) {
FullViewRecallInfoDTO pointNameMapDto = new FullViewRecallInfoDTO();
......@@ -331,7 +328,7 @@ public class KafkaAnalyseController {
pointNameMapDto.setScore(pointNameIndexInfoMap.getOrDefault(fullViewRecallDataDTO.getStation() + "_" + fullViewRecallDataDTO.getIndexAddress(), 100.0));
pointNameMapDto.setParentKey(subSystemMapDto.getKey());
subSystemMapDto.getChildList().add(pointNameMapDto);
subSystemMapDto.getChildren().add(pointNameMapDto);
pointNameInt++;
}
......@@ -355,8 +352,9 @@ public class KafkaAnalyseController {
String stationType = "风电站";
List<IdxBizFanHealthLevel> collect = healthLevelInfoList.stream().filter(item -> item.getAnalysisObjType().contains(station)).collect(Collectors.toList());
for (IdxBizFanHealthLevel item : collect) {
if (!item.getAnalysisObjType().contains("子系统")) {
if (item.getAnalysisObjType().contains("子阵")) {
stationType = "光伏站";
break;
}
}
for (IdxBizFanHealthLevel item : collect) {
......
......@@ -13,11 +13,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
......@@ -46,11 +48,11 @@ public class TestController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET", value = "test2", notes = "test1")
@GetMapping("/test2")
public void test2 () {
public void test2 (@RequestParam(value = "startTime") String startTime, @Param("recDate") String recDate) {
// List<FanHealthIndex> infoListByGroupByCD = fanHealthIndexMapper.getInfoListByGroupByCdFan(startTime, recDate);
// commonService.healthWarningMinuteByFJ();
commonService.healthWarningMinuteByFan();
// commonService.healthWarningMinuteByPv();
// return infoListByGroupByCD;
}
@Autowired
......@@ -64,7 +66,6 @@ public class TestController extends BaseController {
@PostMapping("/saveTest")
public void saveTest () {
tdengineTimeService.insertHourData();
// QueryWrapper<FanHealthIndex> fanHealthIndexQueryWrapper = new QueryWrapper<>();
// List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.selectList(fanHealthIndexQueryWrapper);
//
......
......@@ -15,6 +15,6 @@ public class FullViewRecallInfoDTO {
private String status = "";
private Boolean isRoot = false;
private String category = "";
private List<FullViewRecallInfoDTO> childList = new ArrayList<>();
private List<FullViewRecallInfoDTO> children = new ArrayList<>();
private String parentKey;
}
......@@ -25,6 +25,8 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
BigDecimal getHealthScoreInfoByStation(@Param("stationCode") String stationCode, @Param("tableName") String tableName);
BigDecimal getHealthScoreInfoByParam(@Param("areaCode") String areaCode, @Param("stationCode") String stationCode, @Param("analysisType") String analysisType);
List<Map<String, Object>> getHealthListInfo(@Param("areaCode") String areaCode, @Param("stationCode") String stationCode);
......@@ -99,6 +101,15 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
List<Map<String, Object>> getPointNameIndexInfo();
List<Map<String, Object>> getStationIndexInfoByParam(@Param("analysisType") String analysisType);
List<Map<String, Object>> getEquipmentIndexInfoByParam(@Param("analysisType") String analysisType);
List<Map<String, Object>> getSubSystemIndexInfoByParam(@Param("analysisType") String analysisType);
List<Map<String, Object>> getPointNameIndexInfoByParam(@Param("analysisType") String analysisType);
List<IdxBizFanHealthLevel> getHealthLevelInfoList();
......@@ -132,4 +143,6 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
@Param("recDate") String recDate);
int getIsWarningByPointId(@Param("indexAddress") String indexAddress, @Param("fanGatewayId") String fanGatewayId, @Param("tableName") String tableName);
List<Map<String,Object>> queryIndexByArae(String ARAE, String ANALYSISTYPE,String startTimeTop,String endTimeTop);
}
......@@ -47,8 +47,11 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
public Map<String, Object> getAlramInfoDetailOfFan(String id) {
Map<String, Object> result = new HashMap<>();
IdxBizFanWarningRecord idxBizFanWarningRecord = idxBizFanWarningRecordMapper.selectById(id);
//获取告警信息
result.put("warningInfo", getFanAlarmInfoMap(idxBizFanWarningRecord));
// -----------预警趋势
//获取工况组合来源
result.put("sourceInfo", getSourceInfoMapFan(idxBizFanWarningRecord));
// 获取预警趋势
HashMap<String, Object> alarmTrendAndAlarmAbnormalityListResult = getFanAlarmTrendAndAlarmAbnormalityList(idxBizFanWarningRecord);
result.put("alarmTrend", alarmTrendAndAlarmAbnormalityListResult.get("alarmTrend"));
result.put("alarmAbnormalityList", alarmTrendAndAlarmAbnormalityListResult.get("alarmAbnormalityList"));
......@@ -60,64 +63,20 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
.eq("ANALYSIS_POINT_ID", idxBizFanWarningRecord.getAnalysisPointId()));
IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue = new IdxBizFanPointVarCentralValue();
if (idxBizFanPointVarCentralValueList.size() <= 0) {
result.put("healthPointInfo", new HashMap<>());
result.put("currentValue", new HashMap<>());
result.put("trainValue", new HashMap<>());
return result;
}
idxBizFanPointVarCentralValue = idxBizFanPointVarCentralValueList.get(0);
handlerIdxBizFanPointVarCentralValue(idxBizFanPointVarCentralValueList);
//健康指数来源测点信息
HashMap<String, String> healthPointInfoMap = new HashMap<>();
healthPointInfoMap.put("analysisPointName", idxBizFanPointVarCentralValue.getAnalysisPointName());
healthPointInfoMap.put("processPoint1Name", idxBizFanPointVarCentralValue.getProcessPoint1Name());
healthPointInfoMap.put("processPoint2Name", idxBizFanPointVarCentralValue.getProcessPoint2Name());
healthPointInfoMap.put("processPoint3Name", idxBizFanPointVarCentralValue.getProcessPoint3Name());
result.put("healthPointInfo", healthPointInfoMap);
List<IdxBizFanPointProcessVariableClassification> idxBizFanPointProcessVariableClassificationList = idxBizFanPointProcessVariableClassificationMapper
.selectList(new QueryWrapper<IdxBizFanPointProcessVariableClassification>()
.in("SEQUENCE_NBR", Arrays.asList(idxBizFanPointVarCentralValue.getAnalysisPointId(), idxBizFanPointVarCentralValue.getProcessPoint1Id(), idxBizFanPointVarCentralValue.getProcessPoint2Id(), idxBizFanPointVarCentralValue.getProcessPoint3Id())));
String addresss = idxBizFanPointProcessVariableClassificationList.stream()
.map(idxBizFanPointProcessVariableClassification -> "'" + idxBizFanPointProcessVariableClassification.getIndexAddress() + "'")
.collect(Collectors.joining(","));
Map<String, String> idAddressMap = idxBizFanPointProcessVariableClassificationList.stream()
.collect(Collectors.toMap(IdxBizFanPointProcessVariableClassification::getSequenceNbr, IdxBizFanPointProcessVariableClassification::getIndexAddress));
//查询固化数据---------------------
List<IndicatorData> indicatorDataList = indicatorDataMapper.selectDataByGatewayIdAndAddressForAlarmInfoDetail(idxBizFanPointProcessVariableClassificationList.get(0).getGatewayId(), addresss, startTime, endTime);
Map<String, Double> indicatorDataListMap = new HashMap<>(indicatorDataList.size());
TreeSet<String> timesindicatorDataList = new TreeSet<>();
indicatorDataList.forEach(indicatorData -> {
String time = DateUtil.format(indicatorData.getCreatedTime(), DatePattern.NORM_DATETIME_MINUTE_PATTERN) + ":00";
indicatorDataListMap.put(time + "_" + indicatorData.getAddress(), Double.valueOf(indicatorData.getValueF()));
timesindicatorDataList.add(time);
});
result.put("healthPointInfo", getHealthPointInfoFan(idxBizFanPointVarCentralValue));
HashMap<String, Object> currentValueAndTrainValueMap = getCurrentValueAndTrainValueInfoFan(idxBizFanPointVarCentralValue, startTime, endTime, idxBizFanPointVarCentralValueList);
//当前值
List<HashMap<String, String>> currentValue = new ArrayList<>();
result.put("currentValue", currentValueAndTrainValueMap.get("currentValue"));
//训练值
List<HashMap<String, String>> trainValue = new ArrayList<>();
String analyseValueAddress = idAddressMap.get(idxBizFanPointVarCentralValue.getAnalysisPointId());
String process1Address = idAddressMap.get(idxBizFanPointVarCentralValue.getProcessPoint1Id());
String process2Address = idAddressMap.get(idxBizFanPointVarCentralValue.getProcessPoint2Id());
String process3Address = idAddressMap.get(idxBizFanPointVarCentralValue.getProcessPoint3Id());
timesindicatorDataList.forEach(
s -> {
HashMap<String, String> currentValueMap = new HashMap<>();
currentValueMap.put("time", s);
Double analyseValue = indicatorDataListMap.get(s + "_" + analyseValueAddress);
Double processValue1 = indicatorDataListMap.get(s + "_" + process1Address);
Double processValue2 = indicatorDataListMap.get(s + "_" + process2Address);
Double processValue3 = indicatorDataListMap.get(s + "_" + process3Address);
currentValueMap.put("analyseValue", String.valueOf(analyseValue));
currentValueMap.put("processValue1", String.valueOf(processValue1));
currentValueMap.put("processValue2", String.valueOf(processValue2));
currentValueMap.put("processValue3", String.valueOf(processValue3));
HashMap<String, String> trainValueMap = getWorkingConditionCombinationIntervalFan(processValue1, processValue2, processValue3, idxBizFanPointVarCentralValueList);
trainValueMap.put("time", s);
currentValue.add(currentValueMap);
trainValue.add(trainValueMap);
}
);
result.put("currentValue", currentValue);
result.put("trainValue", trainValue);
//---------------工况组合来源
result.put("sourceInfo", getSourceInfoMapFan(idxBizFanWarningRecord));
result.put("trainValue", currentValueAndTrainValueMap.get("trainValue"));
return result;
}
......@@ -125,7 +84,10 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
public Map<String, Object> getAlramInfoDetailOfPv(String id) {
Map<String, Object> result = new HashMap<>();
IdxBizPvWarningRecord idxBizPvWarningRecord = idxBizPvWarningRecordMapper.selectById(id);
//告警信息
result.put("warningInfo", getPvAlarmInfoMap(idxBizPvWarningRecord));
//---------------工况组合来源
result.put("sourceInfo", getSourceInfoMapPv(idxBizPvWarningRecord));
// -----------预警趋势
HashMap<String, Object> alarmTrendAndAlarmAbnormalityListResult = getPvAlarmTrendAndAlarmAbnormalityList(idxBizPvWarningRecord);
result.put("alarmTrend", alarmTrendAndAlarmAbnormalityListResult.get("alarmTrend"));
......@@ -138,67 +100,28 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
.eq("ANALYSIS_POINT_ID", idxBizPvWarningRecord.getAnalysisPointId()));
IdxBizPvPointVarCentralValue idxBizPvPointVarCentralValue = new IdxBizPvPointVarCentralValue();
if (idxBizPvPointVarCentralValueList.size() <= 0) {
result.put("healthPointInfo", new HashMap<>());
result.put("currentValue", new HashMap<>());
result.put("trainValue", new HashMap<>());
return result;
}
idxBizPvPointVarCentralValue = idxBizPvPointVarCentralValueList.get(0);
handlerIdxBizPvPointVarCentralValue(idxBizPvPointVarCentralValueList);
//健康指数来源测点信息
HashMap<String, String> healthPointInfoMap = new HashMap<>();
healthPointInfoMap.put("analysisPointName", idxBizPvPointVarCentralValue.getAnalysisPointIdName());
healthPointInfoMap.put("processPoint1Name", idxBizPvPointVarCentralValue.getProcessPoint1IdName());
healthPointInfoMap.put("processPoint2Name", idxBizPvPointVarCentralValue.getProcessPoint2IdName());
healthPointInfoMap.put("processPoint3Name", idxBizPvPointVarCentralValue.getProcessPoint3IdName());
result.put("healthPointInfo", healthPointInfoMap);
List<IdxBizPvPointProcessVariableClassification> idxBizPvPointProcessVariableClassificationList = idxBizPvPointProcessVariableClassificationMapper
.selectList(new QueryWrapper<IdxBizPvPointProcessVariableClassification>()
.in("SEQUENCE_NBR", Arrays.asList(idxBizPvPointVarCentralValue.getAnalysisPointId(), idxBizPvPointVarCentralValue.getProcessPoint1Id(), idxBizPvPointVarCentralValue.getProcessPoint2Id(), idxBizPvPointVarCentralValue.getProcessPoint3Id())));
String addresss = idxBizPvPointProcessVariableClassificationList.stream()
.map(idxBizFanPointProcessVariableClassification -> "'" + idxBizFanPointProcessVariableClassification.getIndexAddress() + "'")
.collect(Collectors.joining(","));
Map<String, String> idAddressMap = idxBizPvPointProcessVariableClassificationList.stream()
.collect(Collectors.toMap(IdxBizPvPointProcessVariableClassification::getSequenceNbr, IdxBizPvPointProcessVariableClassification::getIndexAddress));
//查询固化数据---------------------
List<IndicatorData> indicatorDataList = indicatorDataMapper.selectDataByGatewayIdAndAddressForAlarmInfoDetail(idxBizPvPointProcessVariableClassificationList.get(0).getGatewayId(), addresss, startTime, endTime);
Map<String, Double> indicatorDataListMap = new HashMap<>(indicatorDataList.size());
TreeSet<String> timesindicatorDataList = new TreeSet<>();
indicatorDataList.forEach(indicatorData -> {
String time = DateUtil.format(indicatorData.getCreatedTime(), DatePattern.NORM_DATETIME_MINUTE_PATTERN) + ":00";
indicatorDataListMap.put(time + "_" + indicatorData.getAddress(), Double.valueOf(indicatorData.getValueF()));
timesindicatorDataList.add(time);
});
result.put("healthPointInfo", getHealthPointInfoPv(idxBizPvPointVarCentralValue));
HashMap<String, Object> currentValueAndTrainValueMap = getCurrentValueAndTrainValueInfoPv(idxBizPvPointVarCentralValue, startTime, endTime, idxBizPvPointVarCentralValueList);
//当前值
List<HashMap<String, String>> currentValue = new ArrayList<>();
result.put("currentValue", currentValueAndTrainValueMap.get("currentValue"));
//训练值
List<HashMap<String, String>> trainValue = new ArrayList<>();
String analyseValueAddress = idAddressMap.get(idxBizPvPointVarCentralValue.getAnalysisPointId());
String process1Address = idAddressMap.get(idxBizPvPointVarCentralValue.getProcessPoint1Id());
String process2Address = idAddressMap.get(idxBizPvPointVarCentralValue.getProcessPoint2Id());
String process3Address = idAddressMap.get(idxBizPvPointVarCentralValue.getProcessPoint3Id());
timesindicatorDataList.forEach(
s -> {
HashMap<String, String> currentValueMap = new HashMap<>();
currentValueMap.put("time", s);
Double analyseValue = indicatorDataListMap.get(s + "_" + analyseValueAddress);
Double processValue1 = indicatorDataListMap.get(s + "_" + process1Address);
Double processValue2 = indicatorDataListMap.get(s + "_" + process2Address);
Double processValue3 = indicatorDataListMap.get(s + "_" + process3Address);
currentValueMap.put("analyseValue", String.valueOf(analyseValue));
currentValueMap.put("processValue1", String.valueOf(processValue1));
currentValueMap.put("processValue2", String.valueOf(processValue2));
currentValueMap.put("processValue3", String.valueOf(processValue3));
HashMap<String, String> trainValueMap = getWorkingConditionCombinationIntervalPv(processValue1, processValue2, processValue3, idxBizPvPointVarCentralValueList);
trainValueMap.put("time", s);
currentValue.add(currentValueMap);
trainValue.add(trainValueMap);
}
);
result.put("currentValue", currentValue);
result.put("trainValue", trainValue);
//---------------工况组合来源
result.put("sourceInfo", getSourceInfoMapPv(idxBizPvWarningRecord));
result.put("trainValue", currentValueAndTrainValueMap.get("trainValue"));
return result;
}
// 获取风机告警信息
/**
* 获取告风机警信息
* @param idxBizFanWarningRecord
* @return 告警信息
*/
public HashMap<String, String> getFanAlarmInfoMap(IdxBizFanWarningRecord idxBizFanWarningRecord) {
HashMap<String, String> alarmInfoMap = new HashMap<>();
......@@ -214,7 +137,12 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
alarmInfoMap.put("waringRule", idxBizFanWarningRecord.getCONTENT());
return alarmInfoMap;
}
// 获取光伏告警信息
/**
* 获取光伏告警信息
* @param idxBizPvWarningRecord
* @return 告警信息
*/
public HashMap<String, String> getPvAlarmInfoMap(IdxBizPvWarningRecord idxBizPvWarningRecord) {
HashMap<String, String> alarmInfoMap = new HashMap<>();
......@@ -230,89 +158,151 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
alarmInfoMap.put("waringRule", idxBizPvWarningRecord.getCONTENT());
return alarmInfoMap;
}
// 获取风机趋势图与异常度
/**
* 获取风机趋势数据、异常度数据、开始时间、结束时间
* @param idxBizFanWarningRecord
* @return
*/
public HashMap<String, Object> getFanAlarmTrendAndAlarmAbnormalityList(IdxBizFanWarningRecord idxBizFanWarningRecord) {
HashMap<String, Object> result = new HashMap<>();
HashMap<String, List<String>> alarmTrendMap = new HashMap<>();
HashMap<String, Object> alarmTrendMap = new HashMap<>();
HashMap<String,Object> maxValueAndWaringCycle = getWaringCycleAndMaxValueByWaring(idxBizFanWarningRecord.getWarningPeriod(),idxBizFanWarningRecord.getCONTENT(),idxBizFanWarningRecord.getPointName());
List<HashMap<String, String>> alarmAbnormalityList = new ArrayList<>();
Long analysisDate = idxBizFanWarningRecord.getRecDate().getTime() + 1000 * 60;
List<IdxBizFanHealthIndex> idxBizFanHealthIndexList = idxBizFanHealthIndexMapper.selectList(new QueryWrapper<IdxBizFanHealthIndex>()
.eq("GATEWAY_ID", idxBizFanWarningRecord.getGatewayId())
.eq("INDEX_ADDRESS", idxBizFanWarningRecord.getIndexAddress())
.le("ANALYSIS_TIME", DateUtil.formatDateTime(new Date(analysisDate)))
.eq("ANALYSIS_TYPE", idxBizFanWarningRecord.getWarningPeriod())
.le("ANALYSIS_TIME", DateUtil.offsetMinute(idxBizFanWarningRecord.getRecDate(), 1))
.orderByDesc("ANALYSIS_TIME")
.last("limit 30"));
List<String> xDatas = new ArrayList<>();
List<String> yDatas = new ArrayList<>();
List<Double> yDatas = new ArrayList<>();
String startTime = "";
String endTime = "";
for (int i = idxBizFanHealthIndexList.size() - 1; i >= 0; i--) {
int idxBizFanHealthIndexListSize = idxBizFanHealthIndexList.size();
for (int i = idxBizFanHealthIndexListSize - 1; i >= 0; i--) {
HashMap<String, String> alarmAbnormalityItem = new HashMap<>();
IdxBizFanHealthIndex idxBizFanHealthIndex = idxBizFanHealthIndexList.get(i);
xDatas.add(idxBizFanHealthIndex.getANALYSISTIME());
yDatas.add(String.valueOf(idxBizFanHealthIndex.getHealthIndex()));
yDatas.add(idxBizFanHealthIndex.getHealthIndex());
alarmAbnormalityItem.put("sort", String.valueOf(i));
alarmAbnormalityItem.put("time", idxBizFanHealthIndex.getANALYSISTIME());
alarmAbnormalityItem.put("abnormal", String.valueOf(idxBizFanHealthIndex.getANOMALY()));
alarmAbnormalityItem.put("abnormal", String.valueOf(idxBizFanHealthIndex.getANOMALY()).replace("null","0.0"));
alarmAbnormalityItem.put("healthValue", String.valueOf(idxBizFanHealthIndex.getHealthIndex()));
if (i == 0) {
endTime = idxBizFanHealthIndex.getANALYSISTIME();
if (idxBizFanHealthIndexListSize >= 3) {
if (i == 0) {
endTime = handlerDateStr(idxBizFanHealthIndex.getANALYSISTIME(), -8, 5);
}
if (i == 2) {
startTime = handlerDateStr(idxBizFanHealthIndex.getANALYSISTIME(), -8, -5);
}
}
if (idxBizFanHealthIndexListSize == 2) {
if (i == 0) {
endTime = handlerDateStr(idxBizFanHealthIndex.getANALYSISTIME(), -8, 5);
}
if (i == 1) {
startTime = handlerDateStr(idxBizFanHealthIndex.getANALYSISTIME(), -8, -5);
}
}
if (i == 2) {
startTime = idxBizFanHealthIndex.getANALYSISTIME();
if (idxBizFanHealthIndexListSize == 1) {
if (i == 0) {
endTime = handlerDateStr(idxBizFanHealthIndex.getANALYSISTIME(), -8, 5);
startTime = handlerDateStr(idxBizFanHealthIndex.getANALYSISTIME(), -8, -5);
}
}
alarmAbnormalityList.add(alarmAbnormalityItem);
}
alarmTrendMap.put("xDatas", xDatas);
alarmTrendMap.put("yDatas", yDatas);
alarmTrendMap.put("maxValue", maxValueAndWaringCycle.get("maxValue"));
alarmTrendMap.put("warningCycle", maxValueAndWaringCycle.get("warningCycle"));
result.put("alarmTrend", alarmTrendMap);
// 异常度 alarmAbnormality
result.put("alarmAbnormalityList", alarmAbnormalityList.subList(alarmAbnormalityList.size() - 3, alarmAbnormalityList.size()));
int alarmAbnormalitySize = idxBizFanHealthIndexListSize >= 3 ? 3 : idxBizFanHealthIndexListSize;
alarmAbnormalityList=alarmAbnormalityList.subList(alarmAbnormalityList.size() - alarmAbnormalitySize, alarmAbnormalityList.size());
alarmAbnormalityList.sort(Comparator.comparingInt(o->Integer.parseInt(o.get("sort"))));
result.put("alarmAbnormalityList", alarmAbnormalityList);
result.put("startTime", startTime);
result.put("endTime", endTime);
return result;
}
// 获取光伏趋势图与异常度
/**
* 获取光伏趋势数据、异常度数据、开始时间、结束时间
* @param idxBizPvWarningRecord
* @return
*/
public HashMap<String, Object> getPvAlarmTrendAndAlarmAbnormalityList(IdxBizPvWarningRecord idxBizPvWarningRecord) {
HashMap<String, Object> result = new HashMap<>();
HashMap<String, List<String>> alarmTrendMap = new HashMap<>();
HashMap<String, Object> alarmTrendMap = new HashMap<>();
HashMap<String,Object> maxValueAndWaringCycle = getWaringCycleAndMaxValueByWaring(idxBizPvWarningRecord.getWarningPeriod(),idxBizPvWarningRecord.getCONTENT(),idxBizPvWarningRecord.getPointName());
List<HashMap<String, String>> alarmAbnormalityList = new ArrayList<>();
Long analysisDate = idxBizPvWarningRecord.getRecDate().getTime() + 1000 * 60;
List<IdxBizPvHealthIndex> idxBizPvHealthIndexList = idxBizPvHealthIndexMapper.selectList(new QueryWrapper<IdxBizPvHealthIndex>()
.eq("GATEWAY_ID", idxBizPvWarningRecord.getGatewayId())
.eq("INDEX_ADDRESS", idxBizPvWarningRecord.getIndexAddress())
.le("ANALYSIS_TIME", DateUtil.formatDateTime(new Date(analysisDate)))
.eq("ANALYSIS_TYPE", idxBizPvWarningRecord.getWarningPeriod())
.le("ANALYSIS_TIME", DateUtil.offsetMinute(idxBizPvWarningRecord.getRecDate(), 1))
.orderByDesc("ANALYSIS_TIME")
.last("limit 30"));
List<String> xDatas = new ArrayList<>();
List<String> yDatas = new ArrayList<>();
List<Double> yDatas = new ArrayList<>();
String startTime = "";
String endTime = "";
int idxBizPvHealthIndexListSize = idxBizPvHealthIndexList.size();
for (int i = idxBizPvHealthIndexList.size() - 1; i >= 0; i--) {
HashMap<String, String> alarmAbnormalityItem = new HashMap<>();
IdxBizPvHealthIndex idxBizPvHealthIndex = idxBizPvHealthIndexList.get(i);
xDatas.add(idxBizPvHealthIndex.getANALYSISTIME());
yDatas.add(String.valueOf(idxBizPvHealthIndex.getHealthIndex()));
yDatas.add(idxBizPvHealthIndex.getHealthIndex());
alarmAbnormalityItem.put("sort", String.valueOf(i));
alarmAbnormalityItem.put("time", idxBizPvHealthIndex.getANALYSISTIME());
alarmAbnormalityItem.put("abnormal", String.valueOf(idxBizPvHealthIndex.getANOMALY()));
alarmAbnormalityItem.put("abnormal", String.valueOf(idxBizPvHealthIndex.getANOMALY()).replace("null","0.0"));
alarmAbnormalityItem.put("healthValue", String.valueOf(idxBizPvHealthIndex.getHealthIndex()));
if (i == 0) {
endTime = idxBizPvHealthIndex.getANALYSISTIME();
if (idxBizPvHealthIndexListSize >= 3) {
if (i == 0) {
endTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, 5);
}
if (i == 2) {
startTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, -5);
}
}
if (idxBizPvHealthIndexListSize == 2) {
if (i == 0) {
endTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, 5);
}
if (i == 1) {
startTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, -5);
}
}
if (i == 2) {
startTime = idxBizPvHealthIndex.getANALYSISTIME();
if (idxBizPvHealthIndexListSize == 1) {
if (i == 0) {
endTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, 5);
startTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, -5);
}
}
alarmAbnormalityList.add(alarmAbnormalityItem);
}
alarmTrendMap.put("xDatas", xDatas);
alarmTrendMap.put("yDatas", yDatas);
alarmTrendMap.put("maxValue", maxValueAndWaringCycle.get("maxValue"));
alarmTrendMap.put("warningCycle", maxValueAndWaringCycle.get("warningCycle"));
result.put("alarmTrend", alarmTrendMap);
// 异常度 alarmAbnormality
result.put("alarmAbnormalityList", alarmAbnormalityList.subList(alarmAbnormalityList.size() - 3, alarmAbnormalityList.size()));
int alarmAbnormalitySize = idxBizPvHealthIndexListSize >= 3 ? 3 : idxBizPvHealthIndexListSize;
alarmAbnormalityList=alarmAbnormalityList.subList(alarmAbnormalityList.size() - alarmAbnormalitySize, alarmAbnormalityList.size());
alarmAbnormalityList.sort(Comparator.comparingInt(o->Integer.parseInt(o.get("sort"))));
result.put("alarmAbnormalityList", alarmAbnormalityList);
result.put("startTime", startTime);
result.put("endTime", endTime);
return result;
}
//处理风机-相关性区间
/**
* 处理风机中心值区间值为空的情况
* @param idxBizFanPointVarCentralValueList
*/
public void handlerIdxBizFanPointVarCentralValue(List<IdxBizFanPointVarCentralValue> idxBizFanPointVarCentralValueList) {
idxBizFanPointVarCentralValueList.forEach(idxBizFanPointVarCentralValue1 -> {
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue1.getProcess1Min())) {
......@@ -335,7 +325,11 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
}
});
}
//处理光伏-相关性区间
/**
* 处理光伏中心值区间值为空的情况
* @param idxBizPvPointVarCentralValueList
*/
public void handlerIdxBizPvPointVarCentralValue(List<IdxBizPvPointVarCentralValue> idxBizPvPointVarCentralValueList) {
idxBizPvPointVarCentralValueList.forEach(idxBizPvPointVarCentralValue1 -> {
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue1.getProcess1Min())) {
......@@ -359,7 +353,14 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
});
}
//根据工况变量值获取分析变量的中心值、标准值、以及工况组合区间值-风机
/**
* 根据工况变量值获取工况变量训练值、工况组合区间等-风机
* @param processPoint1Value
* @param processPoint2Value
* @param processPoint3Value
* @param idxBizFanPointVarCentralValueList
* @return
*/
public HashMap<String, String> getWorkingConditionCombinationIntervalFan(Double processPoint1Value, Double processPoint2Value, Double processPoint3Value, List<IdxBizFanPointVarCentralValue> idxBizFanPointVarCentralValueList) {
HashMap<String, String> result = new HashMap<>();
IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue = idxBizFanPointVarCentralValueList
......@@ -372,11 +373,19 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
result.put("analysisCenterValue", String.valueOf(idxBizFanPointVarCentralValue.getAnalysisCenterValue()));
result.put("analysisStdDev", String.valueOf(idxBizFanPointVarCentralValue.getAnalysisStdDev()));
result.put("WorkingConditionCombinationInterval", (idxBizFanPointVarCentralValue.getProcess1Min() + ":" + idxBizFanPointVarCentralValue.getProcess1Max() + "," + idxBizFanPointVarCentralValue.getProcess2Min() + ":" + idxBizFanPointVarCentralValue.getPorcess2Max() + "," + idxBizFanPointVarCentralValue.getProcess3Min() + ":" + idxBizFanPointVarCentralValue.getProcess3Max()).
result.put("WorkingConditionCombinationInterval", ( "[ ["+idxBizFanPointVarCentralValue.getProcess1Min() + ":" + idxBizFanPointVarCentralValue.getProcess1Max() + "] , [" + idxBizFanPointVarCentralValue.getProcess2Min() + ":" + idxBizFanPointVarCentralValue.getPorcess2Max() + "] , [" + idxBizFanPointVarCentralValue.getProcess3Min() + ":" + idxBizFanPointVarCentralValue.getProcess3Max()+" ] ]").
replace("Infinity", "∞"));
return result;
}
//根据工况变量值获取分析变量的中心值、标准值、以及工况组合区间值-光伏
/**
* 根据工况变量值获取工况变量训练值、工况组合区间等-光伏
* @param processPoint1Value
* @param processPoint2Value
* @param processPoint3Value
* @param idxBizPvPointVarCentralValueList
* @return
*/
public HashMap<String, String> getWorkingConditionCombinationIntervalPv(Double processPoint1Value, Double processPoint2Value, Double processPoint3Value, List<IdxBizPvPointVarCentralValue> idxBizPvPointVarCentralValueList) {
HashMap<String, String> result = new HashMap<>();
IdxBizPvPointVarCentralValue idxBizPvPointVarCentralValue = idxBizPvPointVarCentralValueList
......@@ -389,11 +398,16 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
result.put("analysisCenterValue", String.valueOf(idxBizPvPointVarCentralValue.getAnalysisCenterValue()));
result.put("analysisStdDev", String.valueOf(idxBizPvPointVarCentralValue.getAnalysisStdDev()));
result.put("WorkingConditionCombinationInterval", (idxBizPvPointVarCentralValue.getProcess1Min() + ":" + idxBizPvPointVarCentralValue.getProcess1Max() + "," + idxBizPvPointVarCentralValue.getProcess2Min() + ":" + idxBizPvPointVarCentralValue.getProcess2Max() + "," + idxBizPvPointVarCentralValue.getProcess3Min() + ":" + idxBizPvPointVarCentralValue.getProcess3Max()).
result.put("WorkingConditionCombinationInterval", ("[ ["+ idxBizPvPointVarCentralValue.getProcess1Min() + ":" + idxBizPvPointVarCentralValue.getProcess1Max() + "] , [" + idxBizPvPointVarCentralValue.getProcess2Min() + ":" + idxBizPvPointVarCentralValue.getProcess2Max() + "] , [" + idxBizPvPointVarCentralValue.getProcess3Min() + ":" + idxBizPvPointVarCentralValue.getProcess3Max()+" ] ]").
replace("Infinity", "∞"));
return result;
}
//获取sourceInfoMap-风机
/**
* 获取风机的分析变量与工况变量的笛卡尔积
* @param idxBizFanWarningRecord
* @return
*/
public HashMap<String, Object> getSourceInfoMapFan(IdxBizFanWarningRecord idxBizFanWarningRecord) {
List<IdxBizFanPointVarCorrelation> idxBizFanPointVarCorrelationList = idxBizFanPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>().eq("EQUIPMENT_NAME", idxBizFanWarningRecord.getEquipmentName()));
......@@ -415,7 +429,11 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
return sourceInfoMap;
}
//获取sourceInfoMap-光伏
/**
* 获取光伏的分析变量与工况变量的笛卡尔积
* @param idxBizPvWarningRecord
* @return
*/
public HashMap<String, Object> getSourceInfoMapPv(IdxBizPvWarningRecord idxBizPvWarningRecord) {
List<IdxBizPvPointVarCorrelation> idxBizPvPointVarCorrelationList = idxBizPvPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>().eq("EQUIPMENT_NAME", idxBizPvWarningRecord.getEquipmentName()));
......@@ -437,4 +455,189 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
return sourceInfoMap;
}
/**
* 获取风机的分析变量与工况变量的名称
* @param idxBizFanPointVarCentralValue
* @return
*/
public HashMap<String, String> getHealthPointInfoFan(IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue) {
HashMap<String, String> result = new HashMap<>();
result.put("analysisPointName", idxBizFanPointVarCentralValue.getAnalysisPointName());
result.put("processPoint1Name", idxBizFanPointVarCentralValue.getProcessPoint1Name());
result.put("processPoint2Name", idxBizFanPointVarCentralValue.getProcessPoint2Name());
result.put("processPoint3Name", idxBizFanPointVarCentralValue.getProcessPoint3Name());
return result;
}
/**
* 获取光伏的分析变量与工况变量的名称
* @param idxBizPvPointVarCentralValue
* @return
*/
public HashMap<String, String> getHealthPointInfoPv(IdxBizPvPointVarCentralValue idxBizPvPointVarCentralValue) {
HashMap<String, String> result = new HashMap<>();
result.put("analysisPointName", idxBizPvPointVarCentralValue.getAnalysisPointIdName());
result.put("processPoint1Name", idxBizPvPointVarCentralValue.getProcessPoint1IdName());
result.put("processPoint2Name", idxBizPvPointVarCentralValue.getProcessPoint2IdName());
result.put("processPoint3Name", idxBizPvPointVarCentralValue.getProcessPoint3IdName());
return result;
}
/**
* 获取风机的当前值与训练值
* @param idxBizFanPointVarCentralValue
* @param startTime
* @param endTime
* @param idxBizFanPointVarCentralValueList
* @return
*/
public HashMap<String, Object> getCurrentValueAndTrainValueInfoFan(IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue, String startTime, String endTime, List<IdxBizFanPointVarCentralValue> idxBizFanPointVarCentralValueList) {
HashMap<String, Object> result = new HashMap<>();
List<IdxBizFanPointProcessVariableClassification> idxBizFanPointProcessVariableClassificationList = idxBizFanPointProcessVariableClassificationMapper
.selectList(new QueryWrapper<IdxBizFanPointProcessVariableClassification>()
.in("SEQUENCE_NBR", Arrays.asList(idxBizFanPointVarCentralValue.getAnalysisPointId(), idxBizFanPointVarCentralValue.getProcessPoint1Id(), idxBizFanPointVarCentralValue.getProcessPoint2Id(), idxBizFanPointVarCentralValue.getProcessPoint3Id())));
String addresss = idxBizFanPointProcessVariableClassificationList.stream()
.map(idxBizFanPointProcessVariableClassification -> "'" + idxBizFanPointProcessVariableClassification.getIndexAddress() + "'")
.collect(Collectors.joining(","));
Map<String, String> idAddressMap = idxBizFanPointProcessVariableClassificationList.stream()
.collect(Collectors.toMap(IdxBizFanPointProcessVariableClassification::getSequenceNbr, IdxBizFanPointProcessVariableClassification::getIndexAddress));
//查询固化数据---------------------
List<IndicatorData> indicatorDataList = indicatorDataMapper.selectDataByGatewayIdAndAddressForAlarmInfoDetail(idxBizFanPointProcessVariableClassificationList.get(0).getGatewayId(), addresss, startTime, endTime);
Map<String, Double> indicatorDataListMap = new HashMap<>(indicatorDataList.size());
TreeSet<String> timesindicatorDataList = new TreeSet<>();
indicatorDataList.forEach(indicatorData -> {
String time = DateUtil.format(indicatorData.getCreatedTime(), DatePattern.NORM_DATETIME_MINUTE_PATTERN) + ":00";
indicatorDataListMap.put(time + "_" + indicatorData.getAddress(), Double.valueOf(indicatorData.getValueF()));
timesindicatorDataList.add(time);
});
//当前值
List<HashMap<String, String>> currentValue = new ArrayList<>();
//训练值
List<HashMap<String, String>> trainValue = new ArrayList<>();
String analyseValueAddress = idAddressMap.get(idxBizFanPointVarCentralValue.getAnalysisPointId());
String process1Address = idAddressMap.get(idxBizFanPointVarCentralValue.getProcessPoint1Id());
String process2Address = idAddressMap.get(idxBizFanPointVarCentralValue.getProcessPoint2Id());
String process3Address = idAddressMap.get(idxBizFanPointVarCentralValue.getProcessPoint3Id());
List<String> timesindicatorDataListSorted = timesindicatorDataList.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
timesindicatorDataListSorted.forEach(
s -> {
HashMap<String, String> currentValueMap = new HashMap<>();
currentValueMap.put("time", s);
Double analyseValue = indicatorDataListMap.get(s + "_" + analyseValueAddress);
Double processValue1 = indicatorDataListMap.get(s + "_" + process1Address);
Double processValue2 = indicatorDataListMap.get(s + "_" + process2Address);
Double processValue3 = indicatorDataListMap.get(s + "_" + process3Address);
currentValueMap.put("analyseValue", String.valueOf(analyseValue));
currentValueMap.put("processValue1", String.valueOf(processValue1));
currentValueMap.put("processValue2", String.valueOf(processValue2));
currentValueMap.put("processValue3", String.valueOf(processValue3));
HashMap<String, String> trainValueMap = getWorkingConditionCombinationIntervalFan(processValue1, processValue2, processValue3, idxBizFanPointVarCentralValueList);
trainValueMap.put("time", s);
currentValue.add(currentValueMap);
trainValue.add(trainValueMap);
}
);
result.put("currentValue", currentValue);
result.put("trainValue", trainValue);
return result;
}
/**
* 获取光伏的当前值与训练值
* @param idxBizPvPointVarCentralValue
* @param startTime
* @param endTime
* @param idxBizPvPointVarCentralValueList
* @return
*/
public HashMap<String, Object> getCurrentValueAndTrainValueInfoPv(IdxBizPvPointVarCentralValue idxBizPvPointVarCentralValue, String startTime, String endTime, List<IdxBizPvPointVarCentralValue> idxBizPvPointVarCentralValueList) {
HashMap<String, Object> result = new HashMap<>();
List<IdxBizPvPointProcessVariableClassification> idxBizPvPointProcessVariableClassificationList = idxBizPvPointProcessVariableClassificationMapper
.selectList(new QueryWrapper<IdxBizPvPointProcessVariableClassification>()
.in("SEQUENCE_NBR", Arrays.asList(idxBizPvPointVarCentralValue.getAnalysisPointId(), idxBizPvPointVarCentralValue.getProcessPoint1Id(), idxBizPvPointVarCentralValue.getProcessPoint2Id(), idxBizPvPointVarCentralValue.getProcessPoint3Id())));
String addresss = idxBizPvPointProcessVariableClassificationList.stream()
.map(idxBizFanPointProcessVariableClassification -> "'" + idxBizFanPointProcessVariableClassification.getIndexAddress() + "'")
.collect(Collectors.joining(","));
Map<String, String> idAddressMap = idxBizPvPointProcessVariableClassificationList.stream()
.collect(Collectors.toMap(IdxBizPvPointProcessVariableClassification::getSequenceNbr, IdxBizPvPointProcessVariableClassification::getIndexAddress));
//查询固化数据---------------------
List<IndicatorData> indicatorDataList = indicatorDataMapper.selectDataByGatewayIdAndAddressForAlarmInfoDetail(idxBizPvPointProcessVariableClassificationList.get(0).getGatewayId(), addresss, startTime, endTime);
Map<String, Double> indicatorDataListMap = new HashMap<>(indicatorDataList.size());
TreeSet<String> timesindicatorDataList = new TreeSet<>();
indicatorDataList.forEach(indicatorData -> {
String time = DateUtil.format(indicatorData.getCreatedTime(), DatePattern.NORM_DATETIME_MINUTE_PATTERN) + ":00";
indicatorDataListMap.put(time + "_" + indicatorData.getAddress(), Double.valueOf(indicatorData.getValueF()));
timesindicatorDataList.add(time);
});
//当前值
List<HashMap<String, String>> currentValue = new ArrayList<>();
//训练值
List<HashMap<String, String>> trainValue = new ArrayList<>();
String analyseValueAddress = idAddressMap.get(idxBizPvPointVarCentralValue.getAnalysisPointId());
String process1Address = idAddressMap.get(idxBizPvPointVarCentralValue.getProcessPoint1Id());
String process2Address = idAddressMap.get(idxBizPvPointVarCentralValue.getProcessPoint2Id());
String process3Address = idAddressMap.get(idxBizPvPointVarCentralValue.getProcessPoint3Id());
List<String> timesindicatorDataListSorted = timesindicatorDataList.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
timesindicatorDataListSorted.forEach(
s -> {
HashMap<String, String> currentValueMap = new HashMap<>();
currentValueMap.put("time", s);
Double analyseValue = indicatorDataListMap.get(s + "_" + analyseValueAddress);
Double processValue1 = indicatorDataListMap.get(s + "_" + process1Address);
Double processValue2 = indicatorDataListMap.get(s + "_" + process2Address);
Double processValue3 = indicatorDataListMap.get(s + "_" + process3Address);
currentValueMap.put("analyseValue", String.valueOf(analyseValue));
currentValueMap.put("processValue1", String.valueOf(processValue1));
currentValueMap.put("processValue2", String.valueOf(processValue2));
currentValueMap.put("processValue3", String.valueOf(processValue3));
HashMap<String, String> trainValueMap = getWorkingConditionCombinationIntervalPv(processValue1, processValue2, processValue3, idxBizPvPointVarCentralValueList);
trainValueMap.put("time", s);
currentValue.add(currentValueMap);
trainValue.add(trainValueMap);
}
);
result.put("currentValue", currentValue);
result.put("trainValue", trainValue);
return result;
}
/**
* 将字符时间进行小时、分钟偏移后返回格式化后的数据-主要用于查询固化值
* @param dateStr
* @param offsetHour
* @param offsetMinutes
* @return
*/
public String handlerDateStr(String dateStr, Integer offsetHour, Integer offsetMinutes) {
Date date = DateUtil.parse(dateStr);
date = DateUtil.offsetHour(date, offsetHour);
date = DateUtil.offsetMinute(date, offsetMinutes);
return DateUtil.format(date, DatePattern.NORM_DATETIME_PATTERN);
}
/**
* 根据预预警类型获取预警周期与预警值
* @return
*/
public HashMap<String,Object> getWaringCycleAndMaxValueByWaring(String warningPeriod,String warningContenct,String pointName){
HashMap<String,Object> result = new HashMap<>();
warningContenct=warningContenct.replace(pointName+"连续","");
String spiltStr =CommonConstans.waringPeriodTowaringCycle.get(warningPeriod);
String [] strings= warningContenct.split(spiltStr);
Double maxValue=0.0;
Integer warningCycle=0;
if(strings.length == 2){
if (spiltStr.equals("分钟")){
warningCycle = Integer.valueOf(strings[0])/10;
}else {
warningCycle=Integer.valueOf(strings[0]);
}
if(strings[1].contains("<")){
maxValue = Double.valueOf(strings[1].split("<")[1]);
}
}
result.put("maxValue",maxValue);
result.put("warningCycle",warningCycle);
return result;
}
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.excel.EasyExcel;
......@@ -151,6 +152,10 @@ public class CommonServiceImpl {
@Autowired
private PvHealthIndexMapper pvHealthIndexMapper;
@Autowired
private TdengineTimeServiceImpl tdengineTimeService;
/**
* @return
* @deprecated 获取工况变量列表风机
......@@ -1281,9 +1286,7 @@ public class CommonServiceImpl {
queryBuilder.should(QueryBuilders.wildcardQuery(key, shouldQuerCondtion.get(key)));
}
}
Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder)
.build();
Query query = new NativeSearchQueryBuilder().withQuery(queryBuilder).build();
query.setTrackTotalHits(true);
SearchHits search = elasticsearchTemplate.search(query, tClass);
if (search.hasSearchHits()) {
......@@ -1447,14 +1450,18 @@ public class CommonServiceImpl {
}
// @Scheduled(cron = "0 0/10 * * * ?")
@Async("async")
// @Scheduled(cron = "0 0/10 * * * ?")
// @Async("async")
public void healthWarningMinuteByFan() {
if (!openHealth) {
return;
}
Date time = new Date();
String format = DateUtil.format(time, DatePattern.NORM_DATETIME_PATTERN);
time = DateUtil.offsetMinute(time,-DateUtil.minute(time)%10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
logger.info("风机---------------------健康指数时间----" + time);
Calendar calendar = Calendar.getInstance();
List<IdxBizFanPointProcessVariableClassificationDto> data = idxBizFanPointProcessVariableClassificationMapper.getInfluxDBData();
Map<String, List<IdxBizFanPointProcessVariableClassificationDto>> maps = data.stream().collect(Collectors.groupingBy(IdxBizFanPointProcessVariableClassificationDto::getGatewayId));
......@@ -1505,11 +1512,16 @@ public class CommonServiceImpl {
// // TODO: handle exception
// }
// }
Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream().collect(Collectors.toMap(indicatorData -> indicatorData.getAddress() +"_"+ indicatorData.getGatewayId(), IndicatorData::getValueF));
Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream().collect(Collectors.toMap(indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(), IndicatorData::getValueF));
//将测点id与值处理成map
HashMap<String, Double> idxBizFanPointProcessVariableClassificationDtoIdValueMap = new HashMap<>();
for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
Double currentValue = Double.valueOf(indicatorDataListAllMap.get(datum.getIndexAddress() + "_" + datum.getGatewayId()));
if (!ObjectUtils.isEmpty(currentValue)) {
datum.setCurrentValue(currentValue);
idxBizFanPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), currentValue);
} else {
idxBizFanPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), 0.0);
}
// for (ESEquipments equipment : equipments) {
// if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) {
......@@ -1538,31 +1550,53 @@ public class CommonServiceImpl {
List<String> ProcessPoint2Id = new ArrayList<>();
List<String> ProcessPoint3Id = new ArrayList<>();
List<String> analysisVariableIds = new ArrayList<>();
idxBizUhefs.forEach(idxBizFanPointVarCentralValue -> {
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess1Min())) {
idxBizFanPointVarCentralValue.setProcess1Min(Double.NEGATIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess2Min())) {
idxBizFanPointVarCentralValue.setProcess2Min(Double.NEGATIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess3Min())) {
idxBizFanPointVarCentralValue.setProcess3Min(Double.NEGATIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess1Max())) {
idxBizFanPointVarCentralValue.setProcess1Max(Double.POSITIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getPorcess2Max())) {
idxBizFanPointVarCentralValue.setPorcess2Max(Double.POSITIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess3Max())) {
idxBizFanPointVarCentralValue.setProcess3Max(Double.POSITIVE_INFINITY);
}
});
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() == null ? 0.0 : datum.getCurrentValue();
}
if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) {
value2 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
}
if (idxBizUhef.getProcessPoint3Id().equals(datum.getSequenceNbr())) {
value3 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
}
if (idxBizUhef.getAnalysisPointId().equals(datum.getSequenceNbr())) {
value4 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
}
}
if ((null == idxBizUhef.getProcess1Min() || idxBizUhef.getProcess1Min() <= value1) && (null == idxBizUhef.getProcess1Max() || value1 <= idxBizUhef.getProcess1Max())
&& (null == idxBizUhef.getProcess2Min() || idxBizUhef.getProcess2Min() <= value2) && (null == idxBizUhef.getPorcess2Max() || value2 <= idxBizUhef.getPorcess2Max())
&& (null == idxBizUhef.getProcess3Min() || idxBizUhef.getProcess3Min() <= value3) && (null == idxBizUhef.getProcess3Max() || value3 <= idxBizUhef.getProcess3Max())) {
// for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
// if (idxBizUhef.getProcessPoint1Id().equals(datum.getSequenceNbr())) {
// value1 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// }
// if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) {
// value2 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// }
// if (idxBizUhef.getProcessPoint3Id().equals(datum.getSequenceNbr())) {
// value3 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// }
// if (idxBizUhef.getAnalysisPointId().equals(datum.getSequenceNbr())) {
// value4 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// }
// }
value1 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint1Id());
value2 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint2Id());
value3 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint3Id());
value4 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getAnalysisPointId());
if (
idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max()
&& idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getPorcess2Max()
&& idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()) {
if (!analysisVariableIdList.contains(idxBizUhef.getAnalysisPointId())) {
analysisVariableList.add(value4);
analysisVariable.add(value4);
......@@ -1594,16 +1628,7 @@ public class CommonServiceImpl {
requestMap.put("analysisVariableId", analysisVariableIdList);
Table healthData = Table.create("healthData");
healthData.addColumns(DoubleColumn.create("analysisVariable", analysisVariable),
DoubleColumn.create("stdDev", stdDev),
DoubleColumn.create("centerValue", centerValue),
StringColumn.create("ProcessPoint1Id", ProcessPoint1Id),
DoubleColumn.create("ProcessPoint1", ProcessPoint1),
StringColumn.create("ProcessPoint2Id", ProcessPoint2Id),
DoubleColumn.create("ProcessPoint2", ProcessPoint2),
StringColumn.create("ProcessPoint3Id", ProcessPoint3Id),
DoubleColumn.create("ProcessPoint3", ProcessPoint3),
StringColumn.create("analysisVariableId", analysisVariableIds));
healthData.addColumns(DoubleColumn.create("analysisVariable", analysisVariable), DoubleColumn.create("stdDev", stdDev), DoubleColumn.create("centerValue", centerValue), StringColumn.create("ProcessPoint1Id", ProcessPoint1Id), DoubleColumn.create("ProcessPoint1", ProcessPoint1), StringColumn.create("ProcessPoint2Id", ProcessPoint2Id), DoubleColumn.create("ProcessPoint2", ProcessPoint2), StringColumn.create("ProcessPoint3Id", ProcessPoint3Id), DoubleColumn.create("ProcessPoint3", ProcessPoint3), StringColumn.create("analysisVariableId", analysisVariableIds));
logger.info("------------------------------------------开始调用健康指数计算算法开始----------------------------------------");
String response = HttpUtil.createPost(baseUrlZSFX).body(JSON.toJSONString(requestMap)).execute().body();
......@@ -1617,8 +1642,7 @@ public class CommonServiceImpl {
List<Double> scoreValue = JSONObject.parseArray(scoreValueArray.toJSONString(), Double.class);
List<Double> indexValue = JSONObject.parseArray(indexValueArray.toJSONString(), Double.class);
// Table resultTable = Table.create("healthData");
healthData.addColumns(StringColumn.create("analysisVariableIdResult", jsonArrayToStringList),
DoubleColumn.create("indexValue", indexValue), DoubleColumn.create("scoreValue", scoreValue));
healthData.addColumns(StringColumn.create("analysisVariableIdResult", jsonArrayToStringList), DoubleColumn.create("indexValue", indexValue), DoubleColumn.create("scoreValue", scoreValue));
System.out.println(healthData.print());
try {
healthData.write().csv(new Date().getTime() + "fj.csv");
......@@ -1631,7 +1655,6 @@ public class CommonServiceImpl {
queryWrapper.in(IdxBizFanPointProcessVariableClassification::getSequenceNbr, jsonArrayToStringList);
List<IdxBizFanPointProcessVariableClassification> list = idxBizFanPointProcessVariableClassificationMapper.selectList(queryWrapper);
List<IdxBizFanHealthIndex> idxBizFanHealthIndexs = new ArrayList<>();
Set<String> stations = list.stream().map(IdxBizFanPointProcessVariableClassification::getStation).collect(Collectors.toSet());
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
......@@ -1652,8 +1675,7 @@ public class CommonServiceImpl {
idxBizFanHealthIndex.setWeigth(1.0);
//获取健康指数对应等级
for (IdxBizFanHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit()
&& indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit() && indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
idxBizFanHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
}
......@@ -1685,7 +1707,9 @@ public class CommonServiceImpl {
}
}
idxBizFanHealthIndexService.saveBatch(idxBizFanHealthIndexs);
fanHealthIndexMapper.saveBatchHealthIndexList(fanHealthIndices1, "fan_health_index_moment");
// 按时刻相关数据插入TDEngine 【异步】
insertFanDataTDEngine(fanHealthIndices1, format);
}
try {
......@@ -1702,15 +1726,45 @@ public class CommonServiceImpl {
}
/**
* 风电按时刻相关数据插入
* @param fanHealthIndices
*/
@Async
public void insertFanDataTDEngine(ArrayList<FanHealthIndex> fanHealthIndices, String recDate) {
// 按时刻 - 测点插入
ArrayList<FanHealthIndex> newList = new ArrayList<>();
for (int i = 0; i < fanHealthIndices.size(); i++) {
//分批次处理
newList.add(fanHealthIndices.get(i));//循环将数据填入载体list
if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
fanHealthIndexMapper.saveBatchHealthIndexList(newList, "fan_health_index_moment");
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
// 按时刻 子系统、设备、场站、区域 插入数据
try {
tdengineTimeService.insertMomentData(recDate);
} catch (ParseException e) {
e.printStackTrace();
}
}
// @Scheduled(cron = "0 0/10 * * * ?")
@Async("async")
// @Async("async")
public void healthWarningMinuteByPv() {
if (!openHealth) {
return;
}
Calendar calendar = Calendar.getInstance();
Date time = new Date();
String format = DateUtil.format(time, DatePattern.NORM_DATETIME_PATTERN);
time = DateUtil.offsetMinute(time,-DateUtil.minute(time)%10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
logger.info("光伏---------------------健康指数时间----" + time);
List<IdxBizPvPointProcessVariableClassificationDto> data = idxBizPvPointProcessVariableClassificationMapper.getInfluxDBData();
Map<String, List<IdxBizPvPointProcessVariableClassificationDto>> maps = data.stream().collect(Collectors.groupingBy(IdxBizPvPointProcessVariableClassificationDto::getGatewayId));
// BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
......@@ -1743,13 +1797,17 @@ public class CommonServiceImpl {
// } catch (Exception e) {
// // TODO: handle exception
// }
Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream().collect(Collectors.toMap(indicatorData -> indicatorData.getAddress() +"_"+indicatorData.getGatewayId(), IndicatorData::getValueF));
Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream().collect(Collectors.toMap(indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(), IndicatorData::getValueF));
HashMap<String, Double> idxBizPvPointProcessVariableClassificationDtoIdValueMap = new HashMap<>();
for (IdxBizPvPointProcessVariableClassificationDto datum : data) {
// for (ESEquipments equipment : equipments) {
// if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) {
Double currentValue = Double.valueOf(indicatorDataListAllMap.get(datum.getIndexAddress() + "_" + datum.getGatewayId()));
if (!ObjectUtils.isEmpty(currentValue)) {
datum.setCurrentValue(currentValue);
idxBizPvPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(),currentValue);
}else {
idxBizPvPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(),0.0);
}
// }
// }
......@@ -1774,29 +1832,50 @@ public class CommonServiceImpl {
List<String> ProcessPoint2Id = new ArrayList<>();
List<String> ProcessPoint3Id = new ArrayList<>();
List<String> analysisVariableIds = new ArrayList<>();
idxBizUhefs.forEach(idxBizPvPointVarCentralValue -> {
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess1Min())) {
idxBizPvPointVarCentralValue.setProcess1Min(Double.NEGATIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess2Min())) {
idxBizPvPointVarCentralValue.setProcess2Min(Double.NEGATIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess3Min())) {
idxBizPvPointVarCentralValue.setProcess3Min(Double.NEGATIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess1Max())) {
idxBizPvPointVarCentralValue.setProcess1Max(Double.POSITIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess2Max())) {
idxBizPvPointVarCentralValue.setProcess2Max(Double.POSITIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess3Max())) {
idxBizPvPointVarCentralValue.setProcess3Max(Double.POSITIVE_INFINITY);
}
});
for (IdxBizPvPointVarCentralValue idxBizUhef : idxBizUhefs) {
double value1 = 0.00;
double value2 = 0.00;
double value3 = 0.00;
double value4 = 0.00;
for (IdxBizPvPointProcessVariableClassificationDto 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();
}
}
if ((null == idxBizUhef.getProcess1Min() || idxBizUhef.getProcess1Min() <= value1) && (null == idxBizUhef.getProcess1Max() || value1 <= idxBizUhef.getProcess1Max())
&& (null == idxBizUhef.getProcess2Min() || idxBizUhef.getProcess2Min() <= value2) && (null == idxBizUhef.getProcess2Max() || value2 <= idxBizUhef.getProcess2Max())
&& (null == idxBizUhef.getProcess3Min() || idxBizUhef.getProcess3Min() <= value3) && (null == idxBizUhef.getProcess3Max() || value3 <= idxBizUhef.getProcess3Max())) {
// for (IdxBizPvPointProcessVariableClassificationDto 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();
// }
// }
value1 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint1Id());
value2 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint2Id());
value3 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint3Id());
value4 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getAnalysisPointId());
if ( idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max() && idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getProcess2Max() && idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()) {
if (!analysisVariableIdList.contains(idxBizUhef.getAnalysisPointId())) {
analysisVariableList.add(value4);
analysisVariable.add(value4);
......@@ -1828,16 +1907,7 @@ public class CommonServiceImpl {
requestMap.put("analysisVariableId", analysisVariableIdList);
Table healthData = Table.create("healthData");
healthData.addColumns(DoubleColumn.create("analysisVariable", analysisVariable),
DoubleColumn.create("stdDev", stdDev),
DoubleColumn.create("centerValue", centerValue),
StringColumn.create("ProcessPoint1Id", ProcessPoint1Id),
DoubleColumn.create("ProcessPoint1", ProcessPoint1),
StringColumn.create("ProcessPoint2Id", ProcessPoint2Id),
DoubleColumn.create("ProcessPoint2", ProcessPoint2),
StringColumn.create("ProcessPoint3Id", ProcessPoint3Id),
DoubleColumn.create("ProcessPoint3", ProcessPoint3),
StringColumn.create("analysisVariableId", analysisVariableIds));
healthData.addColumns(DoubleColumn.create("analysisVariable", analysisVariable), DoubleColumn.create("stdDev", stdDev), DoubleColumn.create("centerValue", centerValue), StringColumn.create("ProcessPoint1Id", ProcessPoint1Id), DoubleColumn.create("ProcessPoint1", ProcessPoint1), StringColumn.create("ProcessPoint2Id", ProcessPoint2Id), DoubleColumn.create("ProcessPoint2", ProcessPoint2), StringColumn.create("ProcessPoint3Id", ProcessPoint3Id), DoubleColumn.create("ProcessPoint3", ProcessPoint3), StringColumn.create("analysisVariableId", analysisVariableIds));
logger.info("------------------------------------------开始调用健康指数计算算法开始----------------------------------------");
String response = HttpUtil.createPost(baseUrlZSFX).body(JSON.toJSONString(requestMap)).execute().body();
JSONObject jsonObject = JSON.parseObject(response);
......@@ -1849,8 +1919,7 @@ public class CommonServiceImpl {
List<Double> scoreValue = JSONObject.parseArray(scoreValueArray.toJSONString(), Double.class);
List<Double> indexValue = JSONObject.parseArray(indexValueArray.toJSONString(), Double.class);
// Table resultTable = Table.create("healthData");
healthData.addColumns(StringColumn.create("analysisVariableIdResult", jsonArrayToStringList),
DoubleColumn.create("indexValue", indexValue), DoubleColumn.create("scoreValue", scoreValue));
healthData.addColumns(StringColumn.create("analysisVariableIdResult", jsonArrayToStringList), DoubleColumn.create("indexValue", indexValue), DoubleColumn.create("scoreValue", scoreValue));
System.out.println(healthData.print());
try {
healthData.write().csv(new Date().getTime() + "gf.csv");
......@@ -1887,8 +1956,7 @@ public class CommonServiceImpl {
//获取健康指数对应等级
for (IdxBizPvHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit()
&& indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit() && indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
idxBizPvHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
}
......@@ -1913,7 +1981,8 @@ public class CommonServiceImpl {
}
}
idxBizPvHealthIndexService.saveBatch(idxBizPvHealthIndexs);
pvHealthIndexMapper.saveBatchHealthIndexList(fanHealthIndices1, "pv_health_index_moment");
//按时刻 - 相关数据插入
insertPvDataTDEngine(fanHealthIndices1, format);
}
try {
logger.info("--------------------response: " + response);
......@@ -1925,4 +1994,31 @@ public class CommonServiceImpl {
}
/**
* 光伏按时刻相关数据插入
* @param pvHealthIndices
*/
@Async
public void insertPvDataTDEngine(ArrayList<PvHealthIndex> pvHealthIndices, String recDate) {
// 按时刻 - 测点插入
ArrayList<PvHealthIndex> newList = new ArrayList<>();
for (int i = 0; i < pvHealthIndices.size(); i++) {
//分批次处理
newList.add(pvHealthIndices.get(i));//循环将数据填入载体list
if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
pvHealthIndexMapper.saveBatchHealthIndexList(newList, "pv_health_index_moment");
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
// 按时刻 设备、子阵、场站、区域 插入数据
try {
tdengineTimeService.insertMomentDataPv(recDate);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
......@@ -119,7 +119,8 @@ public class HealthStatusIndicatorServiceImpl {
if (!openHealth){
return;
}
// Calendar calendar = Calendar.getInstance();
log.info("光伏---------------------预警时间----"+time);
// 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");
......@@ -555,6 +556,7 @@ public class HealthStatusIndicatorServiceImpl {
return;
}
// Calendar calendar = Calendar.getInstance();
log.info("风机---------------------预警时间----"+time);
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@Service
@EnableScheduling
public class TdengineTimeServiceImpl {
@Autowired
private FanHealthIndexMapper fanHealthIndexMapper;
@Autowired
private PvHealthIndexMapper pvHealthIndexMapper;
@Autowired
private IdxBizFanHealthLevelMapper idxBizFanHealthLevelMapper;
@Autowired
private IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper;
/**
* 风电 - 按时刻生成子系统、设备、场站、区域 数据
*/
public void insertMomentData(String recDate) throws ParseException {
//s 489分钟 为 8小时 + 19分钟
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -489), DateUtils.DATE_TIME_PATTERN);
// 子系统
List<IdxBizFanHealthLevel> levelListZxt = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "子系统").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexMapper.getInfoListByGroupByZxtFan(startTime, "fan_health_index_moment", "测点");
saveBatchFan(fanHealthIndicesZxt, "fan_health_index_moment", recDate, "按时刻", levelListZxt);
// 设备
List<IdxBizFanHealthLevel> levelListSb = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesSb = fanHealthIndexMapper.getInfoListByGroupBySbFan(startTime, "fan_health_index_moment", "子系统");
saveBatchFan(fanHealthIndicesSb, "fan_health_index_moment", recDate, "按时刻", levelListSb);
// 场站
List<IdxBizFanHealthLevel> levelListCz = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesCz = fanHealthIndexMapper.getInfoListByGroupByCzFan(startTime, "fan_health_index_moment", "设备");
saveBatchFan(fanHealthIndicesCz, "fan_health_index_moment", recDate, "按时刻", levelListCz);
// 区域
List<IdxBizFanHealthLevel> levelListQy = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesQy = fanHealthIndexMapper.getInfoListByGroupByQyFan(startTime, "fan_health_index_moment", "场站");
saveBatchFan(fanHealthIndicesQy, "fan_health_index_moment", recDate, "按时刻", levelListQy);
}
/**
* 风电 - 按小时生成测点、子系统、设备、场站、区域 数据
*/
@Scheduled(cron = "0 0 0/1 * * ? ")
public void insertHourData() throws ParseException {
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd HH:00:00");
// 8小时 + 59分钟
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -541), DateUtils.DATE_TIME_PATTERN);
// 测点
List<IdxBizFanHealthLevel> levelList = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.getInfoListByGroupByCdFan(startTime, "fan_health_index_moment", "测点");
saveBatchFan(fanHealthIndices, "fan_health_index_hour", recDate, "按小时", levelList);
// 子系统
List<IdxBizFanHealthLevel> levelListZxt = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "子系统").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexMapper.getInfoListByGroupByZxtFan(startTime, "fan_health_index_moment", "测点");
saveBatchFan(fanHealthIndicesZxt, "fan_health_index_hour", recDate, "按小时", levelListZxt);
// 设备
List<IdxBizFanHealthLevel> levelListSb = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesSb = fanHealthIndexMapper.getInfoListByGroupBySbFan(startTime, "fan_health_index_moment", "子系统");
saveBatchFan(fanHealthIndicesSb, "fan_health_index_hour", recDate, "按小时", levelListSb);
// 场站
List<IdxBizFanHealthLevel> levelListCz = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesCz = fanHealthIndexMapper.getInfoListByGroupByCzFan(startTime, "fan_health_index_moment", "设备");
saveBatchFan(fanHealthIndicesCz, "fan_health_index_hour", recDate, "按小时", levelListCz);
// 区域
List<IdxBizFanHealthLevel> levelListQy = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesQy = fanHealthIndexMapper.getInfoListByGroupByQyFan(startTime, "fan_health_index_moment", "场站");
saveBatchFan(fanHealthIndicesQy, "fan_health_index_hour", recDate, "按小时", levelListQy);
}
/**
* 风电 - 按天生成测点、子系统、设备、场站、区域 数据
*/
@Scheduled(cron = "0 0 0 1/1 * ? ")
public void insertDayData() throws ParseException {
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00");
String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN);
List<IdxBizFanHealthLevel> levelList = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.getInfoListByGroupByCdFan(startTime, "fan_health_index_hour", "测点");
saveBatchFan(fanHealthIndices, "fan_health_index_day", recDate, "按天", levelList);
// 子系统
List<IdxBizFanHealthLevel> levelListZxt = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "子系统").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesZxt = fanHealthIndexMapper.getInfoListByGroupByZxtFan(startTime, "fan_health_index_hour", "测点");
saveBatchFan(fanHealthIndicesZxt, "fan_health_index_day", recDate, "按天", levelListZxt);
// 设备
List<IdxBizFanHealthLevel> levelListSb = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesSb = fanHealthIndexMapper.getInfoListByGroupBySbFan(startTime, "fan_health_index_hour", "子系统");
saveBatchFan(fanHealthIndicesSb, "fan_health_index_day", recDate, "按天", levelListSb);
// 场站
List<IdxBizFanHealthLevel> levelListCz = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesCz = fanHealthIndexMapper.getInfoListByGroupByCzFan(startTime, "fan_health_index_hour", "设备");
saveBatchFan(fanHealthIndicesCz, "fan_health_index_day", recDate, "按天", levelListCz);
// 区域
List<IdxBizFanHealthLevel> levelListQy = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesQy = fanHealthIndexMapper.getInfoListByGroupByQyFan(startTime, "fan_health_index_hour", "场站");
saveBatchFan(fanHealthIndicesQy, "fan_health_index_day", recDate, "按天", levelListQy);
}
private String getHealthLevelByScore(List<IdxBizFanHealthLevel> levelList, Double healthIndex) {
String levelDesc = "安全";
for (IdxBizFanHealthLevel item : levelList) {
if (item.getGroupUpperLimit() >= healthIndex && item.getGroupLowerLimit() < healthIndex) {
levelDesc = item.getHealthLevel();
break;
}
}
return levelDesc;
}
private void saveBatchFan(List<FanHealthIndex> fanHealthIndices,
String tableName,
String recDate,
String analysisType,
List<IdxBizFanHealthLevel> levelList) {
ArrayList<FanHealthIndex> newList = new ArrayList<>();
for (int i = 0; i < fanHealthIndices.size(); i++) {
FanHealthIndex fanHealthIndex = fanHealthIndices.get(i);
fanHealthIndex.setRecDate(recDate);
fanHealthIndex.setAnalysisTime(recDate);
fanHealthIndex.setAnalysisType(analysisType);
fanHealthIndex.setHealthLevel(getHealthLevelByScore(levelList, fanHealthIndex.getHealthIndex()));
//分批次处理
newList.add(fanHealthIndex);//循环将数据填入载体list
if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
fanHealthIndexMapper.saveBatchHealthIndexList(newList, tableName);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
}
/**
* 光伏 - 按时刻生成设备、子阵、场站和片区数据
*/
public void insertMomentDataPv(String recDate) throws ParseException {
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -489), DateUtils.DATE_TIME_PATTERN);
// 设备
List<IdxBizPvHealthLevel> levelListSb = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesSb = pvHealthIndexMapper.getInfoListByGroupBySbPv(startTime, "pv_health_index_moment", "测点");
saveBatchPv(fanHealthIndicesSb, "pv_health_index_moment", recDate, "按时刻", levelListSb);
// 子阵
List<IdxBizPvHealthLevel> levelListZz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "子阵").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesZz = pvHealthIndexMapper.getInfoListByGroupByZzPv(startTime, "pv_health_index_moment", "设备");
saveBatchPv(fanHealthIndicesZz, "pv_health_index_moment", recDate, "按时刻", levelListZz);
// 场站
List<IdxBizPvHealthLevel> levelListCz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesCz = pvHealthIndexMapper.getInfoListByGroupByCzPv(startTime, "pv_health_index_moment", "子阵");
saveBatchPv(fanHealthIndicesCz, "pv_health_index_moment", recDate, "按时刻", levelListCz);
// 片区
List<IdxBizPvHealthLevel> levelListQy = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesQy = pvHealthIndexMapper.getInfoListByGroupByQyPv(startTime, "pv_health_index_moment", "场站");
saveBatchPv(fanHealthIndicesQy, "pv_health_index_moment", recDate, "按时刻", levelListQy);
}
/**
* 光伏 - 按小时生成 测点、设备、子阵、场站和片区数据
*/
@Scheduled(cron = "0 0 0/1 * * ? ")
public void insertHourDataPv() throws ParseException {
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd HH:00:00");
// 8小时 + 59分钟
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -541), DateUtils.DATE_TIME_PATTERN);
// 测点
List<IdxBizPvHealthLevel> levelList = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
List<PvHealthIndex> fanHealthIndices = pvHealthIndexMapper.getInfoListByGroupByCdPv(startTime, "pv_health_index_moment", "测点");
saveBatchPv(fanHealthIndices, "pv_health_index_hour", recDate, "按小时", levelList);
// 设备
List<IdxBizPvHealthLevel> levelListSb = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesSb = pvHealthIndexMapper.getInfoListByGroupBySbPv(startTime, "pv_health_index_moment", "测点");
saveBatchPv(fanHealthIndicesSb, "pv_health_index_hour", recDate, "按小时", levelListSb);
// 子阵
List<IdxBizPvHealthLevel> levelListZz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "子阵").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesZz = pvHealthIndexMapper.getInfoListByGroupByZzPv(startTime, "pv_health_index_moment", "设备");
saveBatchPv(fanHealthIndicesZz, "pv_health_index_hour", recDate, "按小时", levelListZz);
// 场站
List<IdxBizPvHealthLevel> levelListCz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesCz = pvHealthIndexMapper.getInfoListByGroupByCzPv(startTime, "pv_health_index_moment", "子阵");
saveBatchPv(fanHealthIndicesCz, "pv_health_index_hour", recDate, "按小时", levelListCz);
// 片区
List<IdxBizPvHealthLevel> levelListQy = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesQy = pvHealthIndexMapper.getInfoListByGroupByQyPv(startTime, "pv_health_index_moment", "场站");
saveBatchPv(fanHealthIndicesQy, "pv_health_index_hour", recDate, "按小时", levelListQy);
}
/**
* 光伏 - 按天生成 测点、设备、子阵、场站和片区数据
*/
@Scheduled(cron = "0 0 0 1/1 * ? ")
public void insertDayDataPv() throws ParseException {
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00");
List<IdxBizPvHealthLevel> levelList = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN);
List<PvHealthIndex> fanHealthIndices = pvHealthIndexMapper.getInfoListByGroupByCdPv(startTime, "pv_health_index_hour", "测点");
saveBatchPv(fanHealthIndices, "pv_health_index_day", recDate, "按天", levelList);
// 设备
List<IdxBizPvHealthLevel> levelListSb = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesSb = pvHealthIndexMapper.getInfoListByGroupBySbPv(startTime, "pv_health_index_hour", "测点");
saveBatchPv(fanHealthIndicesSb, "pv_health_index_hour", recDate, "按天", levelListSb);
// 子阵
List<IdxBizPvHealthLevel> levelListZz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "子阵").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesZz = pvHealthIndexMapper.getInfoListByGroupByZzPv(startTime, "pv_health_index_hour", "设备");
saveBatchPv(fanHealthIndicesZz, "pv_health_index_hour", recDate, "按天", levelListZz);
// 场站
List<IdxBizPvHealthLevel> levelListCz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesCz = pvHealthIndexMapper.getInfoListByGroupByCzPv(startTime, "pv_health_index_hour", "子阵");
saveBatchPv(fanHealthIndicesCz, "pv_health_index_hour", recDate, "按天", levelListCz);
// 片区
List<IdxBizPvHealthLevel> levelListQy = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesQy = pvHealthIndexMapper.getInfoListByGroupByQyPv(startTime, "pv_health_index_hour", "场站");
saveBatchPv(fanHealthIndicesQy, "pv_health_index_hour", recDate, "按天", levelListQy);
}
private String getHealthLevelByScorePv(List<IdxBizPvHealthLevel> levelList, Double healthIndex) {
String levelDesc = "安全";
for (IdxBizPvHealthLevel item : levelList) {
if (item.getGroupUpperLimit() >= healthIndex && item.getGroupLowerLimit() < healthIndex) {
levelDesc = item.getHealthLevel();
break;
}
}
return levelDesc;
}
private void saveBatchPv(List<PvHealthIndex> pvHealthIndices,
String tableName,
String recDate,
String analysisType,
List<IdxBizPvHealthLevel> levelList) {
ArrayList<PvHealthIndex> newList = new ArrayList<>();
for (int i = 0; i < pvHealthIndices.size(); i++) {
PvHealthIndex item = pvHealthIndices.get(i);
item.setRecDate(recDate);
item.setAnalysisTime(recDate);
item.setAnalysisType(analysisType);
item.setHealthLevel(getHealthLevelByScorePv(levelList, item.getHealthIndex()));
//分批次处理
newList.add(item);//循环将数据填入载体list
if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
pvHealthIndexMapper.saveBatchHealthIndexList(newList, tableName);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time AS analysisTime, station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status FROM analysis_data.fan_health_index_day WHERE analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null'> AND area = #{area} </if> " +
"<if test='indexAddress!= null'> AND index_address = #{indexAddress} </if> " +
"<if test='pointName!= null'>AND point_name = #{pointName} </if> " +
"<if test='station!= null'>AND station = #{station} </if>" +
"<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" +
"<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>")
List<FanHealthIndexDay> selectData(@Param("healthLevel")String healthLevel,@Param("area")String area,@Param("equipmentName")String equipmentName,@Param("subSystem")String subSystem,@Param("analysisType")String analysisType,@Param("analysisObjType")String analysisObjType,@Param("station")String station,@Param("pointName")String pointName, @Param("indexAddress")String indexAddress,@Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexHour;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface FanHealthIndexHourMapper extends BaseMapper<FanHealthIndexHour> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time AS analysisTime, station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status FROM analysis_data.fan_health_index_hour WHERE analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null'> AND area = #{area} </if> " +
"<if test='indexAddress!= null'> AND index_address = #{indexAddress} </if> " +
"<if test='pointName!= null'>AND point_name = #{pointName} </if> " +
"<if test='station!= null'>AND station = #{station} </if>" +
"<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" +
"<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>")
List<FanHealthIndexDay> selectData(@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subSystem")String subSystem, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
}
......@@ -3,11 +3,63 @@ package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time AS analysisTime, station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status FROM analysis_data.fan_health_index_data WHERE analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null'> AND area = #{area} </if> " +
"<if test='indexAddress!= null'> AND index_address = #{indexAddress} </if> " +
"<if test='pointName!= null'>AND point_name = #{pointName} </if> " +
"<if test='station!= null'>AND station = #{station} </if>" +
"<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" +
"<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>")
List<FanHealthIndexDay> selectData(@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subSystem")String subSystem, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
int saveBatchHealthIndexList(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName);
/**
* 测点
*
* @return
*/
List<FanHealthIndex> getInfoListByGroupByCdFan(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
/**
* 子系统
*/
List<FanHealthIndex> getInfoListByGroupByZxtFan(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
/**
* 设备
*/
List<FanHealthIndex> getInfoListByGroupBySbFan(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
/**
* 场站
*/
List<FanHealthIndex> getInfoListByGroupByCzFan(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
/**
* 区域
*/
List<FanHealthIndex> getInfoListByGroupByQyFan(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexMoment;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface FanHealthIndexMomentMapper extends BaseMapper<FanHealthIndexMoment> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time AS analysisTime, station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status FROM analysis_data.fan_health_index_moment WHERE analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null'> AND area = #{area} </if> " +
"<if test='indexAddress!= null'> AND index_address = #{indexAddress} </if> " +
"<if test='pointName!= null'>AND point_name = #{pointName} </if> " +
"<if test='station!= null'>AND station = #{station} </if>" +
"<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" +
"<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>")
List<FanHealthIndexDay> selectData (@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subSystem")String subSystem, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface PvHealthIndexDayMapper extends BaseMapper<PvHealthIndexDay> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"FROM analysis_data.pv_health_index_day WHERE and analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null '> AND area = #{area} </if> " +
"<if test='indexAddress!= null '> AND index_address = #{indexAddress} </if> " +
"<if test='pointName!= null '>AND point_name = #{pointName} </if> " +
"<if test='station!= null'>AND station = #{station} </if>" +
"<if test='healthLevel!= null '>AND health_level = #{healthLevel} </if>" +
"<if test='subarray!= null'>AND subarray = #{subarray} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>")
List<PvHealthIndexDay> selectData(@Param("station")String station,@Param("analysisType")String analysisType,@Param("indexAddress")String indexAddress,@Param("healthLevel")String healthLevel,@Param("area")String area,@Param("analysisObjType")String analysisObjType, @Param("subarray")String subarray, @Param("pointName")String pointName,@Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop, @Param("equipmentName")String equipmentName);
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexHour;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface PvHealthIndexHourMapper extends BaseMapper<PvHealthIndexHour> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"FROM analysis_data.pv_health_index_hour WHERE and analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null '> AND area = #{area} </if> " +
"<if test='indexAddress!= null '> AND index_address = #{indexAddress} </if> " +
"<if test='pointName!= null '>AND point_name = #{pointName} </if> " +
"<if test='station!= null'>AND station = #{station} </if>" +
"<if test='healthLevel!= null '>AND health_level = #{healthLevel} </if>" +
"<if test='subarray!= null'>AND subarray = #{subarray} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>")
List<FanHealthIndexDay> selectData (@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subSystem")String subSystem, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
}
......@@ -3,13 +3,49 @@ package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"FROM analysis_data.pv_health_index_data WHERE and analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null '> AND area = #{area} </if> " +
"<if test='indexAddress!= null '> AND index_address = #{indexAddress} </if> " +
"<if test='pointName!= null '>AND point_name = #{pointName} </if> " +
"<if test='station!= null'>AND station = #{station} </if>" +
"<if test='healthLevel!= null '>AND health_level = #{healthLevel} </if>" +
"<if test='subarray!= null'>AND subarray = #{subarray} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>")
List<FanHealthIndexDay> selectData (@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subSystem")String subSystem, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
int saveBatchHealthIndexList(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName);
List<PvHealthIndex> getInfoListByGroupByCdPv(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
List<PvHealthIndex> getInfoListByGroupBySbPv(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
List<PvHealthIndex> getInfoListByGroupByZzPv(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
List<PvHealthIndex> getInfoListByGroupByCzPv(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
List<PvHealthIndex> getInfoListByGroupByQyPv(@Param("startTime") String startTime,
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexMoment;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface PvHealthIndexMomentMapper extends BaseMapper<PvHealthIndexMoment> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"FROM analysis_data.pv_health_index_moment WHERE and analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null '> AND area = #{area} </if> " +
"<if test='indexAddress!= null '> AND index_address = #{indexAddress} </if> " +
"<if test='pointName!= null '>AND point_name = #{pointName} </if> " +
"<if test='station!= null'>AND station = #{station} </if>" +
"<if test='healthLevel!= null '>AND health_level = #{healthLevel} </if>" +
"<if test='subarray!= null'>AND subarray = #{subarray} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>")
List<FanHealthIndexDay> selectData(@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subSystem")String subSystem, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
public interface PvWaringRecordMapper extends BaseMapper<PvWarningRecord> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName(value = "", autoResultMap = true)
public class FanWarningRecord {
private Long ts;
private String recDate;
private String disposotionState;
private String healthIndex;
private String analysisPointId;
private String warningName;
private String arae;
private String station;
private String subSystem;
private String number;
private String gatewayId;
private String indexAddress;
private String equipmentName;
private String content;
private String pointName;
private String healthLevel;
private String disposotionDate;
private String kks;
private String warningPeriod;
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName(value = "", autoResultMap = true)
public class PvWarningRecord {
private Long ts;
private String recDate;
private String disposotionState;
private String healthIndexSeq;
private String analysisPointId;
private String warningName;
private String arae;
private String station;
private String subarray;
private String manufacturer;
private String deviceType;
private String gatewayId;
private String indexAddress;
private String equipmentName;
private String content;
private String pointName;
private String healthLevel;
private String disposotionDate;
private String kks;
private String warningPeriod;
}
......@@ -53,6 +53,77 @@
) a
</select>
<select id="getHealthScoreInfoByParam" resultType="java.math.BigDecimal">
SELECT
CEILING(avg( a.avgHealthIndex )) AS healthIndex
FROM
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM
idx_biz_fan_health_index
<where>
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
<if test="areaCode != null and areaCode != ''">
AND ARAE like concat('%', #{areaCode}, '%')
AND ANALYSIS_OBJ_TYPE = '片区'
</if>
<if test="stationCode != null and stationCode != ''">
AND GATEWAY_ID = #{stationCode}
AND ANALYSIS_OBJ_TYPE = '场站'
</if>
<if test="(stationCode == null or stationCode == '') and (areaCode == null or areaCode == '')">
AND ANALYSIS_OBJ_TYPE = '片区'
</if>
</where>
UNION ALL
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM
idx_biz_pv_health_index
<where>
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
<if test="areaCode != null and areaCode != ''">
AND ARAE like concat('%', #{areaCode}, '%')
AND ANALYSIS_OBJ_TYPE = '片区'
</if>
<if test="stationCode != null and stationCode != ''">
AND GATEWAY_ID = #{stationCode}
AND ANALYSIS_OBJ_TYPE = '场站'
</if>
<if test="(stationCode == null or stationCode == '') and (areaCode == null or areaCode == '')">
AND ANALYSIS_OBJ_TYPE = '片区'
</if>
</where>
)
) a
</select>
<select id="getHealthScoreInfoByStation" resultType="java.math.BigDecimal">
SELECT
......@@ -678,12 +749,13 @@
SELECT a.*,
row_number() over ( ORDER BY pointName ) AS id
FROM (
SELECT ARAE AS area,
(SELECT ARAE AS area,
STATION AS station,
EQUIPMENT_NAME AS equipmentName,
SUB_SYSTEM AS subSystem,
POINT_NAME AS pointName,
INDEX_ADDRESS AS indexAddress
INDEX_ADDRESS AS indexAddress,
KKS
FROM idx_biz_fan_point_process_variable_classification
WHERE TAG_CODE = '分析变量'
AND ARAE is not null
......@@ -692,13 +764,15 @@
AND SUB_SYSTEM is not null
AND POINT_NAME is not null
AND INDEX_ADDRESS is not null
)
UNION ALL
SELECT ARAE AS area,
(SELECT ARAE AS area,
STATION AS station,
SUBARRAY AS equipmentName,
EQUIPMENT_NAME AS subSystem,
POINT_NAME AS pointName,
INDEX_ADDRESS AS indexAddress
INDEX_ADDRESS AS indexAddress,
KKS
FROM idx_biz_pv_point_process_variable_classification
WHERE TAG_CODE = '分析变量'
AND ARAE is not null
......@@ -707,7 +781,9 @@
AND EQUIPMENT_NAME is not null
AND POINT_NAME is not null
AND INDEX_ADDRESS is not null
)
) a
ORDER BY a.station ASC, a.equipmentName ASC, a.equipmentName asc, a.subSystem asc
</select>
<select id="getStationIndexInfo" resultType="java.util.Map">
......@@ -1284,4 +1360,262 @@
AND GATEWAY_ID = #{fanGatewayId}
and DISPOSOTION_STATE = '未处置'
</select>
<select id="getStationIndexInfoByParam" resultType="java.util.Map">
SELECT a.STATION AS station,
ROUND(avg(a.avgHealthIndex), 2) AS healthIndex
FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
STATION AS STATION
FROM idx_biz_fan_health_index
<where>
ANALYSIS_OBJ_TYPE = '场站'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY STATION
UNION ALL
(
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
STATION AS STATION
FROM idx_biz_pv_health_index
<where>
ANALYSIS_OBJ_TYPE = '场站'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY STATION
)
) a
GROUP BY a.STATION
</select>
<select id="getEquipmentIndexInfoByParam" resultType="java.util.Map">
SELECT a.equipmentName AS equipmentName,
ROUND(avg(a.avgHealthIndex), 2) AS healthIndex
FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
EQUIPMENT_NAME AS equipmentName
FROM idx_biz_fan_health_index
<where>
ANALYSIS_OBJ_TYPE = '设备'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY EQUIPMENT_NAME
UNION ALL
(
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
SUBARRAY AS equipmentName
FROM idx_biz_pv_health_index
<where>
ANALYSIS_OBJ_TYPE = '子阵'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY SUBARRAY
)
) a
where equipmentName is not null
and equipmentName != ''
GROUP BY
a.equipmentName
</select>
<select id="getSubSystemIndexInfoByParam" resultType="java.util.Map">
SELECT a.subSystem AS subSystem,
ROUND(avg(a.avgHealthIndex), 2) AS healthIndex
FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
SUB_SYSTEM AS subSystem
FROM idx_biz_fan_health_index
<where>
ANALYSIS_OBJ_TYPE = '子系统'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY SUB_SYSTEM
UNION ALL
(
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
EQUIPMENT_NAME AS subSystem
FROM idx_biz_pv_health_index
<where>
ANALYSIS_OBJ_TYPE = '设备'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY EQUIPMENT_NAME
)
) a
where subSystem is not null
and subSystem != ''
GROUP BY
a.subSystem
</select>
<select id="getPointNameIndexInfoByParam" resultType="java.util.Map">
SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex,
concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress
FROM idx_biz_fan_health_index
<where>
ANALYSIS_OBJ_TYPE = '测点'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY INDEX_ADDRESS
UNION ALL
(
SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex,
concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress
FROM idx_biz_pv_health_index
<where>
ANALYSIS_OBJ_TYPE = '测点'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY INDEX_ADDRESS
)
</select>
<select id="queryIndexByArae" resultType="map">
SELECT
CAST(AVG(b.HEALTH_INDEX) as SIGNED) HEALTHINDEX,
b.REC_DATE,
b.ANALYSIS_TIME as ANALYSISTIME
FROM
(
SELECT
ANALYSIS_TIME,
REC_DATE,
HEALTH_INDEX
FROM
`idx_biz_fan_health_index`
<where>
<if test = 'startTimeTop != null and startTimeTop != ""' >
AND REC_DATE >= #{startTimeTop}
</if>
<if test = 'endTimeTop != null and endTimeTop != ""' >
<![CDATA[ AND REC_DATE <= #{endTimeTop}]]>
</if>
<if test = 'ARAE != null and ARAE != ""' >
AND ARAE = #{ARAE}
</if>
<if test = 'ANALYSISTYPE != null and ANALYSISTYPE != ""' >
AND ANALYSIS_TYPE = #{ANALYSISTYPE}
</if>
</where>
UNION ALL
SELECT
ANALYSIS_TIME,
REC_DATE,
HEALTH_INDEX
FROM
`idx_biz_PV_health_index`
<where>
<if test = ' startTimeTop != null and startTimeTop != ""' >
AND REC_DATE >= #{startTimeTop}
</if>
<if test = 'endTimeTop != null and endTimeTop != ""' >
<![CDATA[ AND REC_DATE <= #{endTimeTop}]]>
</if>
<if test = 'ARAE != null and ARAE != ""' >
AND ARAE = #{ARAE}
</if>
<if test = 'ANALYSISTYPE != null and ANALYSISTYPE !=""' >
AND ANALYSIS_TYPE = #{ANALYSISTYPE}
</if>
</where>
)b
GROUP BY REC_DATE
</select>
</mapper>
......@@ -4,12 +4,12 @@
<insert id="saveBatchHealthIndexList">
insert into
${tableName}
using fan_health_index_data TAGS ('按时刻')
values
<foreach collection="list" separator="," item="item" index="index">
${tableName}
using fan_health_index_data TAGS (#{item.analysisType})
values
(
now + #{index}a,
now,
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
......@@ -32,4 +32,124 @@
)
</foreach>
</insert>
<select id="getInfoListByGroupByCdFan" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex">
select
index_address,
gateway_id ,
station,
analysis_obj_type,
analysis_obj_seq,
weight,
area,
sub_system,
number,
equipment_name,
avg(anomaly) as anomaly,
point_name,
kks,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
index_address,
station,
analysis_obj_type,
analysis_obj_seq,
weight,
area,
sub_system,
number,
equipment_name,
point_name,
kks
</select>
<select id="getInfoListByGroupByZxtFan" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex">
select
gateway_id ,
station,
'子系统' as analysis_obj_type,
area,
sub_system,
equipment_name,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area,
sub_system,
equipment_name
</select>
<select id="getInfoListByGroupBySbFan" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex">
select
gateway_id ,
station,
'设备' as analysis_obj_type,
area,
number,
equipment_name,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area,
number,
equipment_name
</select>
<select id="getInfoListByGroupByCzFan" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex">
select
gateway_id,
station,
'场站' as analysis_obj_type,
area,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area
</select>
<select id="getInfoListByGroupByQyFan" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex">
select
'片区' as analysis_obj_type,
area,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
analysis_obj_type,
area
</select>
</mapper>
<?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">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper">
</mapper>
......@@ -2,35 +2,188 @@
<!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.tdMapper2.PvHealthIndexMapper">
<insert id="saveBatchHealthIndexList">
insert into
<foreach collection="list" separator="," item="item" index="index">
${tableName}
using pv_health_index_data TAGS (#{item.analysisType})
<!--<insert id="saveBatchHealthIndexList">-->
<!-- insert into-->
<!-- <foreach collection="list" separator=" " item="item" index="index">-->
<!-- ${tableName}-->
<!-- using pv_health_index_data TAGS (#{item.analysisType})-->
<!-- values-->
<!-- (-->
<!-- now,-->
<!-- #{item.recDate, jdbcType=VARCHAR},-->
<!-- #{item.analysisObjType, jdbcType=VARCHAR},-->
<!-- #{item.analysisObjSeq, jdbcType=VARCHAR},-->
<!-- #{item.weight, jdbcType=FLOAT},-->
<!-- #{item.healthIndex, jdbcType=FLOAT},-->
<!-- #{item.healthLevel, jdbcType=VARCHAR},-->
<!-- #{item.analysisStartTime, jdbcType=VARCHAR},-->
<!-- #{item.analysisEndTime, jdbcType=VARCHAR},-->
<!-- #{item.area, jdbcType=VARCHAR},-->
<!-- #{item.station, jdbcType=VARCHAR},-->
<!-- #{item.subarray, jdbcType=VARCHAR},-->
<!-- #{item.manufacturer, jdbcType=VARCHAR},-->
<!-- #{item.deviceType, jdbcType=VARCHAR},-->
<!-- #{item.equipmentName, jdbcType=VARCHAR},-->
<!-- #{item.gatewayId, jdbcType=VARCHAR},-->
<!-- #{item.indexAddress, jdbcType=VARCHAR},-->
<!-- #{item.anomaly, jdbcType=FLOAT},-->
<!-- #{item.pointName, jdbcType=VARCHAR},-->
<!-- #{item.analysisTime, jdbcType=VARCHAR},-->
<!-- #{item.kks, jdbcType=VARCHAR},-->
<!-- )-->
<!-- </foreach>-->
<!-- </insert>-->
<insert id="saveBatchHealthIndexList">
insert into ${tableName}
using pv_health_index_data TAGS ('按时刻')
values
(
now,
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subarray, jdbcType=VARCHAR},
#{item.manufacturer, jdbcType=VARCHAR},
#{item.deviceType, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR},
)
</foreach>
<foreach collection="list" separator="," item="item" index="index">
(
now,
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subarray, jdbcType=VARCHAR},
#{item.manufacturer, jdbcType=VARCHAR},
#{item.deviceType, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR}
)
</foreach>
</insert>
<select id="getInfoListByGroupByCdPv" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex">
select
index_address,
gateway_id ,
station,
'测点' as analysis_obj_type,
analysis_obj_seq,
weight,
area,
subarray,
manufacturer,
equipment_name,
avg(anomaly) as anomaly,
point_name,
device_type,
kks,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
index_address,
station,
analysis_obj_type,
analysis_obj_seq,
weight,
area,
subarray,
manufacturer,
equipment_name,
point_name,
device_type,
kks
</select>
<select id="getInfoListByGroupBySbPv" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex">
select
gateway_id ,
station,
'设备' as analysis_obj_type,
area,
subarray,
equipment_name,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area,
subarray,
equipment_name
</select>
<select id="getInfoListByGroupByZzPv" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex">
select
gateway_id ,
station,
'子阵' as analysis_obj_type,
area,
subarray,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area,
subarray
</select>
<select id="getInfoListByGroupByCzPv" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex">
select
gateway_id ,
station,
'场站' as analysis_obj_type,
area,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area
</select>
<select id="getInfoListByGroupByQyPv" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex">
select
'片区' as analysis_obj_type,
area,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
analysis_obj_type,
area
</select>
</mapper>
<?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">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper">
</mapper>
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