Commit 5e8bb0dd authored by wujiang's avatar wujiang

Merge branch 'developer' of http://36.40.66.175:5000/moa/amos-boot-biz into developer

parents 019ac91c 55fd3d3d
......@@ -3,6 +3,7 @@ package com.yeejoin.amos;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.listener.SyncDasSuccessMqttListener;
import com.yeejoin.amos.boot.module.jxiop.biz.listener.SyncESDataToTdengineMqttListener;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
......@@ -62,6 +63,8 @@ public class AmosJxiopAnalyseApplication {
Boolean openHealth;
@Autowired
private SyncESDataToTdengineMqttListener syncESDataToTdengineMqttListener;
@Autowired
private SyncDasSuccessMqttListener syncDasSuccessMqttListener;
private static final Logger logger = LoggerFactory.getLogger(AmosJxiopAnalyseApplication.class);
......@@ -82,6 +85,8 @@ public class AmosJxiopAnalyseApplication {
if (openHealth) {
//订阅固化周期性数据成功的消息
emqKeeper.subscript("sync_esdata_to_tdengine_notice", 1, syncESDataToTdengineMqttListener);
//订阅业务固化同步数据成功消息
emqKeeper.subscript("sync_iotdata_to_tdengine_notice", 1, syncDasSuccessMqttListener);
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointVarCorrelationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelation;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanPointVarCorrelationServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -15,6 +19,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
*
......@@ -112,4 +117,32 @@ public class IdxBizFanPointVarCorrelationController extends BaseController {
public ResponseModel<List<IdxBizFanPointVarCorrelationDto>> selectForList() {
return ResponseHelper.buildResponse(idxBizFanPointVarCorrelationServiceImpl.queryForIdxBizFanPointVarCorrelationList());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "查询当前点位所选择的工况变量", notes = "查询当前点位所选择的工况变量")
@GetMapping(value = "/getCurrentChoosePoint")
public ResponseModel<Map<String,Object>> getCurrentChoosePoint(String gatewayId,String analysePointId) {
return ResponseHelper.buildResponse(idxBizFanPointVarCorrelationServiceImpl.getCurrentChoosePoint(gatewayId,analysePointId));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "查询当前点位所选择的工况变量", notes = "查询当前点位所选择的工况变量")
@PostMapping(value = "/updatePointChoose")
public ResponseModel updatePointChoose(@RequestBody IdxBizFanPointVarCorrelationDto dto) {
idxBizFanPointVarCorrelationServiceImpl.updatePointChoose(dto.getAnalysisGatewayId(),dto.getAnalysisPointId(),dto.getProcessPointIds());
return CommonResponseUtil.success();
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "查询当前点位的工况变量", notes = "查询当前点位的工况变量")
@GetMapping(value = "/getPointProcess")
public ResponseModel<Map<String,Object>> getPointProcess(String gatewayId, String analysePointId) {
return ResponseHelper.buildResponse(idxBizFanPointVarCorrelationServiceImpl.getPointProcess(gatewayId,analysePointId));
}
}
......@@ -2,7 +2,11 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointVarCorrelationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvPointVarCorrelationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelation;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointVarCorrelation;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvPointVarCorrelationServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -15,6 +19,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
*
......@@ -112,4 +117,32 @@ public class IdxBizPvPointVarCorrelationController extends BaseController {
public ResponseModel<List<IdxBizPvPointVarCorrelationDto>> selectForList() {
return ResponseHelper.buildResponse(idxBizPvPointVarCorrelationServiceImpl.queryForIdxBizPvPointVarCorrelationList());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "查询当前点位所选择的工况变量", notes = "查询当前点位所选择的工况变量")
@GetMapping(value = "/getCurrentChoosePoint")
public ResponseModel<Map<String,Object>> getCurrentChoosePoint(String gatewayId, String analysePointId) {
return ResponseHelper.buildResponse(idxBizPvPointVarCorrelationServiceImpl.getCurrentChoosePoint(gatewayId,analysePointId));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "查询当前点位所选择的工况变量", notes = "查询当前点位所选择的工况变量")
@PostMapping(value = "/updatePointChoose")
public ResponseModel updatePointChoose(@RequestBody IdxBizFanPointVarCorrelationDto dto) {
idxBizPvPointVarCorrelationServiceImpl.updatePointChoose(dto.getAnalysisGatewayId(),dto.getAnalysisPointId(),dto.getProcessPointIds());
return CommonResponseUtil.success();
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "查询当前点位的工况变量", notes = "查询当前点位的工况变量")
@GetMapping(value = "/getPointProcess")
public ResponseModel<Map<String,Object>> getPointProcess(String gatewayId, String analysePointId) {
return ResponseHelper.buildResponse(idxBizPvPointVarCorrelationServiceImpl.getPointProcess(gatewayId,analysePointId));
}
}
......@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
......@@ -86,4 +87,6 @@ public class IdxBizFanPointVarCorrelationDto {
@TableField("EQUIPMENT_NAME")
private String equipmentName;
@TableField(exist = false)
private List<String> processPointIds;
}
......@@ -149,4 +149,9 @@ public class IdxBizFanPointVarCorrelation{
*/
@TableField("PROCESS_POINT_NAME")
private String processPointName;
/**
* 匹配工况变量
*/
@TableField("MATCH_PROCESS_PONIT")
private String matchProcessPoint;
}
......@@ -12,8 +12,6 @@ import java.time.LocalDateTime;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2023-08-15
*/
......@@ -21,7 +19,7 @@ import java.util.Date;
@Accessors(chain = true)
@TableName("idx_biz_fan_warning_rule_set")
public class IdxBizFanWarningRuleSet{
public class IdxBizFanWarningRuleSet {
private static final long serialVersionUID = 1L;
......@@ -124,4 +122,6 @@ public class IdxBizFanWarningRuleSet{
@TableField("POINT_NAME")
private String pointName;
@TableField("GATEWAY_ID")
private String gatewayId;
}
......@@ -151,4 +151,7 @@ public class IdxBizPvPointVarCorrelation{
*/
@TableField("PROCESS_POINT_NAME")
private String processPointName;
@TableField("MATCH_PROCESS_POINT")
private String matchProcessPoint;
}
......@@ -133,4 +133,11 @@ public class IdxBizPvWarningRuleSet{
*/
@TableField("POINT_NAME")
private String pointName;
/**
* 分析变量
*/
@TableField("GATEWAY_ID")
private String gatewayId;
}
package com.yeejoin.amos.boot.module.jxiop.biz.listener;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqxListener;
/**
* @author Administrator
*/
@Component
@Slf4j
public class SyncDasSuccessMqttListener extends EmqxListener {
@Autowired
CommonServiceImpl commonServiceImpl;
@Override
public void processMessage(String topic, MqttMessage mqttMessage) {
log.info(topic + "收到数据同步成功,开始计算健康指数!");
byte[] payload = mqttMessage.getPayload();
String str = new String(payload);
String msg = JSON.parse(str).toString();
JSONObject jsonObject = JSONObject.parseObject(msg);
String flag = jsonObject.get("sync_flag").toString();
String gatewayId = jsonObject.get("gatewayId").toString();
if ("success".equals(flag)&&jsonObject.containsKey("gatewayId")){
//开始异步计算光伏的健康指数算法
new Thread(()->{
//调用光伏的健康指数算法
commonServiceImpl.healthWarningMinuteByPv(gatewayId);
}).start();
//开始异步计算风机的健康指数算法
new Thread(()->{
//调用风机的健康指数算法
commonServiceImpl.healthWarningMinuteByFan(gatewayId);
}).start();
}
}
}
......@@ -16,6 +16,7 @@ import java.util.Map;
*/
public interface IdxBizFanPointProcessVariableClassificationMapper extends BaseMapper<IdxBizFanPointProcessVariableClassification> {
List<IdxBizFanPointProcessVariableClassificationDto> getInfluxDBData();
List<IdxBizFanPointProcessVariableClassificationDto> getInfluxDBDataByGatewayId(String gatewayId);
List<Map<String,Object>> selectParams(String tableName,String column,String isFx);
......
......@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelation;
import java.util.List;
/**
* Mapper 接口
*
......@@ -10,5 +12,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelatio
* @date 2023-08-15
*/
public interface IdxBizFanPointVarCorrelationMapper extends BaseMapper<IdxBizFanPointVarCorrelation> {
void updatePointChoose(String gatewayId, Long analysePointId, List<String> processPointIds);
}
......@@ -21,6 +21,9 @@ public interface IdxBizFanWarningRuleSetMapper extends BaseMapper<IdxBizFanWarni
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按10分钟'")
Integer getMaxWaringCycleOfMinutes();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按10分钟' and GATEWAY_ID = #{gatewayId}")
Integer getMaxWaringCycleOfMinutesByGatewayId(String gatewayId);
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按小时'")
Integer getMaxWaringCycleOfHour();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按天'")
......
......@@ -17,5 +17,6 @@ public interface IdxBizPvPointProcessVariableClassificationMapper extends BaseMa
List<String> gateWayIdListPv();
List<IdxBizPvPointProcessVariableClassificationDto> getInfluxDBData();
List<IdxBizPvPointProcessVariableClassificationDto> getInfluxDBDataByGatewayId(String gatewayId);
}
......@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointVarCorrelation;
import java.util.List;
/**
* Mapper 接口
*
......@@ -11,4 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointVarCorrelation
*/
public interface IdxBizPvPointVarCorrelationMapper extends BaseMapper<IdxBizPvPointVarCorrelation> {
void updatePointChoose(String gatewayId, Long analysePointId, List<String> processPointIds);
}
......@@ -16,6 +16,8 @@ public interface IdxBizPvWarningRuleSetMapper extends BaseMapper<IdxBizPvWarning
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按10分钟'")
Integer getMaxWaringCycleOfMinutes();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按10分钟' and GATEWAY_ID = #{gateWayId}")
Integer getMaxWaringCycleOfMinutesByGatewayId(String gateWayId);
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按小时'")
Integer getMaxWaringCycleOfHour();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按天'")
......
......@@ -3,20 +3,14 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
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;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.SmartAnalyseEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum;
......@@ -30,13 +24,11 @@ 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 com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import javafx.scene.control.Tab;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.joda.time.DateTimeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
......@@ -48,22 +40,16 @@ import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil;
import tech.tablesaw.api.DoubleColumn;
import tech.tablesaw.api.StringColumn;
import tech.tablesaw.api.Table;
import java.io.File;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
......@@ -84,7 +70,8 @@ public class CommonServiceImpl {
*/
private static final BlockingQueue<IdxBizPvPointProcessVariableClassification> fifoPv = new LinkedBlockingQueue<>(
5000);
private static int threadNumber = Runtime.getRuntime().availableProcessors() * 2;
private static final int threadNumber = Runtime.getRuntime().availableProcessors() * 2;
public final DecimalFormat df = new DecimalFormat("#.00");
// -----------------调用算法时间间隔----------------
@Value("${sleep.time:10}")
Integer sleepTime;
......@@ -156,21 +143,15 @@ public class CommonServiceImpl {
private IndicatorDataMapper indicatorDataMapper;
@Autowired
private ElasticsearchRestTemplate elasticsearchTemplate;
@Autowired
private FanHealthIndexMapper fanHealthIndexMapper;
@Autowired
private IdxBizPvHealthIndexMapper idxFanHealthIndexMapper;
@Autowired
private PvHealthIndexMapper pvHealthIndexMapper;
@Autowired
private TdengineTimeServiceImpl tdengineTimeService;
public final DecimalFormat df = new DecimalFormat("#.00");
/**
* @return
* @deprecated 获取工况变量列表风机
......@@ -314,7 +295,6 @@ public class CommonServiceImpl {
idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime, tableName);
// List<Map<String, Object>> returnList = influxdbUtil.query(sql);
returnList.forEach((k) -> {
Map<String, Object> map = new HashMap<>();
......@@ -329,8 +309,7 @@ public class CommonServiceImpl {
HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkqjhfkey, params);
logger.info("------------------------------------------调用地址:" + baseUrl + gkqjhfurlfan);
logger.info("------------------------------------------调用参数:"
+ JSON.toJSONString(JSON.toJSONString(realParams)));
logger.info("------------------------------------------调用参数:" + JSON.toJSONString(JSON.toJSONString(realParams)));
String response = HttpUtil.createPost(baseUrl + gkqjhfurlfan).body(JSON.toJSONString(realParams))
.execute().body();
if (response.contains("\"status\":200") && response.contains("rows") && response.contains("rows")) {
......@@ -622,14 +601,12 @@ public class CommonServiceImpl {
idxBizFanPointVarCorrelation
.setCorrelationCoefficient(values.getDoubleValue("correlation_coefficient"));
idxBizFanPointVarCorrelationMapper.updateById(idxBizFanPointVarCorrelation);
logger.info(
"------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------");
logger.info("------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------");
}
try {
logger.info("response-------------" + response);
TimeUnit.SECONDS.sleep(sleepTime);
logger.info(
"----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------");
logger.info("----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
......@@ -768,8 +745,8 @@ public class CommonServiceImpl {
IdxBizFanPointProcessVariableClassification.getGatewayId())
.eq("ANALYSIS_POINT_ID",
IdxBizFanPointProcessVariableClassification.getSequenceNbr())
.eq("MATCH","匹配"));
if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() !=3 ){
.eq("MATCH_PROCESS_POINT", "匹配"));
if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() != 3) {
gongkuangList = idxBizFanPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID",
......@@ -821,8 +798,8 @@ public class CommonServiceImpl {
idxBizPvPointProcessVariableClassification.getGatewayId())
.eq("ANALYSIS_POINT_ID",
idxBizPvPointProcessVariableClassification.getSequenceNbr())
.eq("MATCH","匹配"));
if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() != 3){
.eq("MATCH_PROCESS_POINT", "匹配"));
if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() != 3) {
gongkuangList = idxBizPvPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID",
......@@ -2148,63 +2125,35 @@ public class CommonServiceImpl {
}
/**
* 风电按时刻相关数据插入
*
* @param fanHealthIndices
*/
@Async
public void insertFanDataTDEngine(ArrayList<FanHealthIndex> fanHealthIndices, String recDate, String analysisType) {
idxFanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", analysisType);
// 按时刻 - 测点插入
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", analysisType);
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList);
newList.clear();// 每次批量操作后,清空载体list,等待下次的数据填入
}
}
// 按时刻 子系统、设备、场站、区域 插入数据
try {
tdengineTimeService.insertMomentData(recDate);
} catch (ParseException e) {
e.printStackTrace();
}
}
public void healthWarningMinuteByFan(String gatewayId) {
// @Scheduled(cron = "0 0/10 * * * ?")
// @Async("async")
public void healthWarningMinuteByPv() {
if (!openHealth) {
return;
}
// Calendar calendar = Calendar.getInstance();
Date time = new Date();
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));
logger.info("风机---------------------健康指数时间----" + time);
// Calendar calendar = Calendar.getInstance();
List<IdxBizFanPointProcessVariableClassificationDto> data = idxBizFanPointProcessVariableClassificationMapper
.getInfluxDBDataByGatewayId(gatewayId);
// Map<String, List<IdxBizFanPointProcessVariableClassificationDto>> maps = data.stream()
// .collect(Collectors.groupingBy(IdxBizFanPointProcessVariableClassificationDto::getGatewayId));
// BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
// List<QueryBuilder> should = boolMustAll.should();
List<IndicatorData> indicatorDataListAll = new LinkedList<>();
for (String s : maps.keySet()) {
// List<IndicatorData> indicatorDataListAll = new LinkedList<>();
// for (String s : maps.keySet()) {
// BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
// String addressids = maps.get(s).stream().map(idxBizPvPointProcessVariableClassificationDto -> "\'" + idxBizPvPointProcessVariableClassificationDto.getIndexAddress() + "\'").collect(Collectors.joining(","));
List<IndicatorData> indicatorDataList = indicatorDataMapper.selectDataByGatewayIdAndAddress(s);
indicatorDataListAll.addAll(indicatorDataList);
// List<String> address = maps.get(s).stream().map(IdxBizPvPointProcessVariableClassificationDto::getIndexAddress).collect(Collectors.toList());
// boolQueryBuilder.must(QueryBuilders.termsQuery("address.keyword", address)).must(QueryBuilders.termsQuery("gatewayId.keyword", s));
// List<String> address = maps.get(s).stream().map(IdxBizFanPointProcessVariableClassificationDto::getIndexAddress).collect(Collectors.toList());
// boolQueryBuilder.must(QueryBuilders.termsQuery("address.keyword", address)).must(QueryBuilders.matchQuery("gatewayId.keyword", s));
// should.add(boolQueryBuilder);
}
// 创建查询构造器
// String addressids = maps.get(s).stream().map(idxBizFanPointProcessVariableClassificationDto -> "\'" + idxBizFanPointProcessVariableClassificationDto.getIndexAddress() + "\'").collect(Collectors.joining(","));
List<IndicatorData> indicatorDataListAll = indicatorDataMapper.selectDataByGatewayId(gatewayId);
// indicatorDataListAll.addAll(indicatorDataList);
// }
// // 创建查询构造器
// NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// //过滤条件
// .withQuery(boolMustAll);
......@@ -2222,27 +2171,48 @@ public class CommonServiceImpl {
// } catch (Exception e) {
// // TODO: handle exception
// }
//
//
// while (totle == 0) {
// try {
// SearchHits<ESEquipments> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESEquipments.class);
//
// for (SearchHit searchHit : searchHits.getSearchHits()) {
// JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
// ESEquipments eSAlertCalled = JSONObject.toJavaObject(jsonObject, ESEquipments.class);
// equipments.add(eSAlertCalled);
// }
// totle = searchHits.getTotalHits();
// } catch (Exception e) {
// // TODO: handle exception
// }
// }
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())) {
// 将测点id与值处理成map
HashMap<String, Double> idxBizFanPointProcessVariableClassificationDtoIdValueMap = new HashMap<>();
log.info("indicatorDataListAllMap" + JSONObject.toJSONString(indicatorDataListAllMap));
log.info("data" + JSONObject.toJSONString(data));
for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
Double currentValue = Double
.valueOf(indicatorDataListAllMap.get(datum.getIndexAddress() + "_" + datum.getGatewayId()));
if (!ObjectUtils.isEmpty(currentValue)) {
datum.setCurrentValue(currentValue);
idxBizPvPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), currentValue);
idxBizFanPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), currentValue);
} else {
idxBizPvPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), 0.0);
idxBizFanPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), 0.0);
}
// for (ESEquipments equipment : equipments) {
// if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) {
// datum.setCurrentValue(equipment.getValueF());
// }
// }
}
LambdaQueryWrapper<IdxBizPvPointVarCentralValue> wrapper = new LambdaQueryWrapper<>();
List<IdxBizPvPointVarCentralValue> idxBizUhefs = idxBizPvPointVarCentralValueMapper.selectList(wrapper);
LambdaQueryWrapper<IdxBizFanPointVarCentralValue> wrapper = new LambdaQueryWrapper<>();
List<IdxBizFanPointVarCentralValue> idxBizUhefs = idxBizFanPointVarCentralValueMapper.selectList(wrapper);
HashMap<String, Object> requestMap = new HashMap<>();
ArrayList<Object> analysisVariableList = new ArrayList<>();
ArrayList<Object> stdDevList = new ArrayList<>();
......@@ -2261,51 +2231,51 @@ 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);
idxBizUhefs.forEach(idxBizFanPointVarCentralValue -> {
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess1Min())) {
idxBizFanPointVarCentralValue.setProcess1Min(Double.NEGATIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess2Min())) {
idxBizPvPointVarCentralValue.setProcess2Min(Double.NEGATIVE_INFINITY);
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess2Min())) {
idxBizFanPointVarCentralValue.setProcess2Min(Double.NEGATIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess3Min())) {
idxBizPvPointVarCentralValue.setProcess3Min(Double.NEGATIVE_INFINITY);
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess3Min())) {
idxBizFanPointVarCentralValue.setProcess3Min(Double.NEGATIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess1Max())) {
idxBizPvPointVarCentralValue.setProcess1Max(Double.POSITIVE_INFINITY);
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess1Max())) {
idxBizFanPointVarCentralValue.setProcess1Max(Double.POSITIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess2Max())) {
idxBizPvPointVarCentralValue.setProcess2Max(Double.POSITIVE_INFINITY);
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getPorcess2Max())) {
idxBizFanPointVarCentralValue.setPorcess2Max(Double.POSITIVE_INFINITY);
}
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess3Max())) {
idxBizPvPointVarCentralValue.setProcess3Max(Double.POSITIVE_INFINITY);
if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess3Max())) {
idxBizFanPointVarCentralValue.setProcess3Max(Double.POSITIVE_INFINITY);
}
});
for (IdxBizPvPointVarCentralValue idxBizUhef : idxBizUhefs) {
for (IdxBizFanPointVarCentralValue idxBizUhef : idxBizUhefs) {
double value1 = 0.00;
double value2 = 0.00;
double value3 = 0.00;
double value4 = 0.00;
// for (IdxBizPvPointProcessVariableClassificationDto datum : data) {
// for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
// if (idxBizUhef.getProcessPoint1Id().equals(datum.getSequenceNbr())) {
// value1 = datum.getCurrentValue();
// value1 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// }
// if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) {
// value2 = datum.getCurrentValue();
// value2 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// }
// if (idxBizUhef.getProcessPoint3Id().equals(datum.getSequenceNbr())) {
// value3 = datum.getCurrentValue();
// value3 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// }
// if (idxBizUhef.getAnalysisPointId().equals(datum.getSequenceNbr())) {
// value4 = datum.getCurrentValue();
// value4 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// }
// }
value1 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint1Id());
value2 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint2Id());
value3 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint3Id());
value4 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getAnalysisPointId());
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.getProcess2Max()
&& idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getPorcess2Max()
&& idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()) {
if (!analysisVariableIdList.contains(idxBizUhef.getAnalysisPointId())) {
analysisVariableList.add(value4);
......@@ -2328,10 +2298,10 @@ public class CommonServiceImpl {
analysisVariableIdList.add(idxBizUhef.getAnalysisPointId());
analysisVariableId.add(idxBizUhef.getAnalysisPointId());
}
}
}
requestMap.put("analysisVariable", analysisVariableList);
requestMap.put("stdDev", stdDevList);
requestMap.put("centerValue", centerValueList);
......@@ -2348,10 +2318,11 @@ public class CommonServiceImpl {
DoubleColumn.create("ProcessPoint3", ProcessPoint3),
StringColumn.create("analysisVariableId", analysisVariableIds));
logger.info(
"------------------------------------------开始调用光伏健康指数计算算法开始----------------------------------------");
"------------------------------------------开始调用风机健康指数计算算法开始----------------------------------------");
logger.info("------------------------------------------调用地址:" + baseUrlZSFX);
// logger.info("------------------------------------------调用参数:"+JSON.toJSONString(requestMap));
String response = HttpUtil.createPost(baseUrlZSFX).body(JSON.toJSONString(requestMap)).execute().body();
JSONObject jsonObject = JSON.parseObject(response);
if (jsonObject.containsKey("indexValue")) {
JSONArray indexValueArray = jsonObject.getJSONArray("indexValue");
......@@ -2366,82 +2337,651 @@ public class CommonServiceImpl {
DoubleColumn.create("indexValue", indexValue), DoubleColumn.create("scoreValue", scoreValue));
System.out.println(healthData.print());
try {
healthData.write().csv(new Date().getTime() + "gf.csv");
healthData.write().csv(new Date().getTime() + "fj.csv");
} catch (Exception e) {
e.printStackTrace();
}
LambdaQueryWrapper<IdxBizPvPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(IdxBizPvPointProcessVariableClassification::getSequenceNbr, jsonArrayToStringList);
List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationMapper
LambdaQueryWrapper<IdxBizFanPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(IdxBizFanPointProcessVariableClassification::getSequenceNbr, jsonArrayToStringList);
List<IdxBizFanPointProcessVariableClassification> list = idxBizFanPointProcessVariableClassificationMapper
.selectList(queryWrapper);
Set<String> stations = list.stream().map(IdxBizPvPointProcessVariableClassification::getStation)
List<IdxBizFanHealthIndex> idxBizFanHealthIndexs = new ArrayList<>();
Set<String> stations = list.stream().map(IdxBizFanPointProcessVariableClassification::getStation)
.collect(Collectors.toSet());
LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点");
query.in(IdxBizPvHealthLevel::getStatus, stations);
List<IdxBizPvHealthLevel> idxBizFanHealthLevels = idxBizPvHealthLevelMapper.selectList(query);
List<IdxBizPvHealthIndex> idxBizPvHealthIndexs = new ArrayList<>();
ArrayList<PvHealthIndex> fanHealthIndices1 = new ArrayList<>();
for (IdxBizPvPointProcessVariableClassification obj : list) {
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点");
query.in(IdxBizFanHealthLevel::getStatus, stations);
List<IdxBizFanHealthLevel> idxBizFanHealthLevels = idxBizFanHealthLevelMapper.selectList(query);
ArrayList<FanHealthIndex> fanHealthIndices1 = new ArrayList<>();
for (IdxBizFanPointProcessVariableClassification obj : list) {
for (int i = 0; i < analysisVariableIdArray.size(); i++) {
if (analysisVariableIdArray.get(i).toString().equals(obj.getSequenceNbr())) {
IdxBizPvHealthIndex idxBizPvHealthIndex = new IdxBizPvHealthIndex();
BeanUtils.copyProperties(obj, idxBizPvHealthIndex, "sequenceNbr");
// idxBizPvHealthIndex.setSequenceNbr(null);
IdxBizFanHealthIndex idxBizFanHealthIndex = new IdxBizFanHealthIndex();
BeanUtils.copyProperties(obj, idxBizFanHealthIndex, "sequenceNbr");
// 2023年10月30日10点05分 移除原来的判断 无论是否小于0都取绝对值
idxBizPvHealthIndex.setHealthIndex(Math.abs(indexValueArray.getDoubleValue(i)));
idxBizPvHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr());
idxBizPvHealthIndex.setRecDate(time);
idxBizPvHealthIndex.setWeigth(1.0);
idxBizFanHealthIndex.setHealthIndex(Math.abs(indexValueArray.getDoubleValue(i)));
idxBizFanHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr());
idxBizFanHealthIndex.setRecDate(time);
// idxBizFanHealthIndex.setSequenceNbr(null);
idxBizFanHealthIndex.setWeigth(1.0);
// 获取健康指数对应等级
for (IdxBizPvHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) {
for (IdxBizFanHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit()
&& indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
idxBizPvHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
idxBizFanHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
}
}
idxBizPvHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName());
idxBizPvHealthIndex.setAnalysisObjType("测点");
idxBizPvHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i));
idxBizPvHealthIndex.setANALYSISTIME(DateUtils.getDateNowString());
idxBizPvHealthIndexs.add(idxBizPvHealthIndex);
PvHealthIndex pvHealthIndex = new PvHealthIndex();
BeanUtil.copyProperties(idxBizPvHealthIndex, pvHealthIndex);
pvHealthIndex.setWeight(idxBizPvHealthIndex.getWeigth());
pvHealthIndex.setAnomaly(idxBizPvHealthIndex.getANOMALY());
pvHealthIndex.setRecDate(DateUtil.now());
pvHealthIndex.setArea(idxBizPvHealthIndex.getArae());
pvHealthIndex.setAnalysisTime(DateUtil.now());
pvHealthIndex.setHealthLevel(idxBizPvHealthIndex.getHealthLevel());
pvHealthIndex.setKks(idxBizPvHealthIndex.getKks());
pvHealthIndex.setRecDate(format);
pvHealthIndex.setOrgCode(obj.getOrgCode());
fanHealthIndices1.add(pvHealthIndex);
idxBizFanHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName());
idxBizFanHealthIndex.setAnalysisObjType("测点");
if (ObjectUtils.isEmpty(scoreValueArray.getDoubleValue(i))) {
System.out.println(JSON.toJSONString(requestMap));
idxBizFanHealthIndex.setANOMALY(0.0);
} else {
idxBizFanHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i));
}
idxBizFanHealthIndex.setANALYSISTIME(DateUtils.getDateNowString());
idxBizFanHealthIndexs.add(idxBizFanHealthIndex);
FanHealthIndex fanHealthIndex = new FanHealthIndex();
BeanUtil.copyProperties(idxBizFanHealthIndex, fanHealthIndex);
fanHealthIndex.setWeight(idxBizFanHealthIndex.getWeigth());
fanHealthIndex.setAnomaly(idxBizFanHealthIndex.getANOMALY());
fanHealthIndex.setRecDate(DateUtil.now());
fanHealthIndex.setArea(idxBizFanHealthIndex.getArae());
fanHealthIndex.setAnalysisTime(DateUtil.now());
fanHealthIndex.setHealthLevel(fanHealthIndex.getHealthLevel());
fanHealthIndex.setKks(idxBizFanHealthIndex.getKks());
fanHealthIndex.setRecDate(format);
fanHealthIndex.setOrgCode(obj.getOrgCode());
fanHealthIndices1.add(fanHealthIndex);
}
}
}
// idxBizPvHealthIndexService.saveBatch(idxBizPvHealthIndexs);
// 按时刻 - 相关数据插入
insertPvDataTDEngine(fanHealthIndices1, format, WarningPeriodEnum.MINUTES.getName());
// idxBizFanHealthIndexService.saveBatch(idxBizFanHealthIndexs);
// 按时刻相关数据插入TDEngine 【异步】
insertFanDataTDEngine(fanHealthIndices1, format, WarningPeriodEnum.MINUTES.getName());
}
try {
// logger.info("--------------------response: " + response);
logger.info("--------------------response: " + response);
logger.info(
"------------------------------------------调用光伏健康指数计算算法结束----------------------------------------");
} catch (Exception e) {
"------------------------------------------调用风机健康指数计算算法结束----------------------------------------");
logger.info("------------------------------------------开始计算预警----------------------------------------");
// healthStatusIndicatorService.healthWarningMinute(calendar, time);
// ++++++++++
healthStatusIndicatorService.healthWarningMinute(time,gatewayId);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 风电按时刻相关数据插入
*
* @param fanHealthIndices
*/
@Async
public void insertFanDataTDEngine(ArrayList<FanHealthIndex> fanHealthIndices, String recDate, String analysisType) {
idxFanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", analysisType);
// 按时刻 - 测点插入
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", analysisType);
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList);
newList.clear();// 每次批量操作后,清空载体list,等待下次的数据填入
}
}
// 按时刻 子系统、设备、场站、区域 插入数据
try {
tdengineTimeService.insertMomentData(recDate);
} catch (ParseException e) {
e.printStackTrace();
}
}
// @Scheduled(cron = "0 0/10 * * * ?")
// @Async("async")
public void healthWarningMinuteByPv() {
if (!openHealth) {
return;
}
// Calendar calendar = Calendar.getInstance();
Date time = new Date();
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();
// List<QueryBuilder> should = boolMustAll.should();
List<IndicatorData> indicatorDataListAll = new LinkedList<>();
for (String s : maps.keySet()) {
// BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
// String addressids = maps.get(s).stream().map(idxBizPvPointProcessVariableClassificationDto -> "\'" + idxBizPvPointProcessVariableClassificationDto.getIndexAddress() + "\'").collect(Collectors.joining(","));
List<IndicatorData> indicatorDataList = indicatorDataMapper.selectDataByGatewayIdAndAddress(s);
indicatorDataListAll.addAll(indicatorDataList);
// List<String> address = maps.get(s).stream().map(IdxBizPvPointProcessVariableClassificationDto::getIndexAddress).collect(Collectors.toList());
// boolQueryBuilder.must(QueryBuilders.termsQuery("address.keyword", address)).must(QueryBuilders.termsQuery("gatewayId.keyword", s));
// should.add(boolQueryBuilder);
}
// 创建查询构造器
// NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// //过滤条件
// .withQuery(boolMustAll);
// List<ESEquipments> equipments = new LinkedList<>();
// long totle = 0;
// try {
// SearchHits<ESEquipments> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESEquipments.class);
//
// for (SearchHit searchHit : searchHits.getSearchHits()) {
// JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
// ESEquipments eSAlertCalled = JSONObject.toJavaObject(jsonObject, ESEquipments.class);
// equipments.add(eSAlertCalled);
// }
// totle = searchHits.getTotalHits();
// } catch (Exception e) {
// // TODO: handle exception
// }
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);
}
// }
// }
}
LambdaQueryWrapper<IdxBizPvPointVarCentralValue> wrapper = new LambdaQueryWrapper<>();
List<IdxBizPvPointVarCentralValue> idxBizUhefs = idxBizPvPointVarCentralValueMapper.selectList(wrapper);
HashMap<String, Object> requestMap = new HashMap<>();
ArrayList<Object> analysisVariableList = new ArrayList<>();
ArrayList<Object> stdDevList = new ArrayList<>();
ArrayList<Object> centerValueList = new ArrayList<>();
ArrayList<Object> analysisVariableIdList = new ArrayList<>();
List<Double> analysisVariable = new ArrayList<>();
List<Double> stdDev = new ArrayList<>();
List<Double> centerValue = new ArrayList<>();
List<String> analysisVariableId = new ArrayList<>();
List<Double> ProcessPoint1 = new ArrayList<>();
List<Double> ProcessPoint2 = new ArrayList<>();
List<Double> ProcessPoint3 = new ArrayList<>();
List<String> ProcessPoint1Id = new ArrayList<>();
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();
// }
// }
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);
ProcessPoint1Id.add(idxBizUhef.getProcessPoint1Id());
ProcessPoint2Id.add(idxBizUhef.getProcessPoint2Id());
ProcessPoint3Id.add(idxBizUhef.getProcessPoint3Id());
analysisVariableIds.add(idxBizUhef.getAnalysisPointId());
ProcessPoint1.add(value1);
ProcessPoint2.add(value2);
ProcessPoint3.add(value3);
stdDevList.add(idxBizUhef.getAnalysisStdDev());
stdDev.add(idxBizUhef.getAnalysisStdDev());
centerValueList.add(idxBizUhef.getAnalysisCenterValue());
centerValue.add(idxBizUhef.getAnalysisCenterValue());
analysisVariableIdList.add(idxBizUhef.getAnalysisPointId());
analysisVariableId.add(idxBizUhef.getAnalysisPointId());
}
}
}
requestMap.put("analysisVariable", analysisVariableList);
requestMap.put("stdDev", stdDevList);
requestMap.put("centerValue", centerValueList);
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));
logger.info(
"------------------------------------------开始调用光伏健康指数计算算法开始----------------------------------------");
logger.info("------------------------------------------调用地址:" + baseUrlZSFX);
// logger.info("------------------------------------------调用参数:"+JSON.toJSONString(requestMap));
String response = HttpUtil.createPost(baseUrlZSFX).body(JSON.toJSONString(requestMap)).execute().body();
JSONObject jsonObject = JSON.parseObject(response);
if (jsonObject.containsKey("indexValue")) {
JSONArray indexValueArray = jsonObject.getJSONArray("indexValue");
JSONArray scoreValueArray = jsonObject.getJSONArray("scoreValue");
JSONArray analysisVariableIdArray = jsonObject.getJSONArray("analysisVariableId");
List<String> jsonArrayToStringList = JSONObject.parseArray(analysisVariableIdArray.toJSONString(),
String.class);
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));
System.out.println(healthData.print());
try {
healthData.write().csv(new Date().getTime() + "gf.csv");
} catch (Exception e) {
e.printStackTrace();
}
LambdaQueryWrapper<IdxBizPvPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(IdxBizPvPointProcessVariableClassification::getSequenceNbr, jsonArrayToStringList);
List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationMapper
.selectList(queryWrapper);
Set<String> stations = list.stream().map(IdxBizPvPointProcessVariableClassification::getStation)
.collect(Collectors.toSet());
LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点");
query.in(IdxBizPvHealthLevel::getStatus, stations);
List<IdxBizPvHealthLevel> idxBizFanHealthLevels = idxBizPvHealthLevelMapper.selectList(query);
List<IdxBizPvHealthIndex> idxBizPvHealthIndexs = new ArrayList<>();
ArrayList<PvHealthIndex> fanHealthIndices1 = new ArrayList<>();
for (IdxBizPvPointProcessVariableClassification obj : list) {
for (int i = 0; i < analysisVariableIdArray.size(); i++) {
if (analysisVariableIdArray.get(i).toString().equals(obj.getSequenceNbr())) {
IdxBizPvHealthIndex idxBizPvHealthIndex = new IdxBizPvHealthIndex();
BeanUtils.copyProperties(obj, idxBizPvHealthIndex, "sequenceNbr");
// idxBizPvHealthIndex.setSequenceNbr(null);
// 2023年10月30日10点05分 移除原来的判断 无论是否小于0都取绝对值
idxBizPvHealthIndex.setHealthIndex(Math.abs(indexValueArray.getDoubleValue(i)));
idxBizPvHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr());
idxBizPvHealthIndex.setRecDate(time);
idxBizPvHealthIndex.setWeigth(1.0);
// 获取健康指数对应等级
for (IdxBizPvHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit()
&& indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
idxBizPvHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
}
}
idxBizPvHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName());
idxBizPvHealthIndex.setAnalysisObjType("测点");
idxBizPvHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i));
idxBizPvHealthIndex.setANALYSISTIME(DateUtils.getDateNowString());
idxBizPvHealthIndexs.add(idxBizPvHealthIndex);
PvHealthIndex pvHealthIndex = new PvHealthIndex();
BeanUtil.copyProperties(idxBizPvHealthIndex, pvHealthIndex);
pvHealthIndex.setWeight(idxBizPvHealthIndex.getWeigth());
pvHealthIndex.setAnomaly(idxBizPvHealthIndex.getANOMALY());
pvHealthIndex.setRecDate(DateUtil.now());
pvHealthIndex.setArea(idxBizPvHealthIndex.getArae());
pvHealthIndex.setAnalysisTime(DateUtil.now());
pvHealthIndex.setHealthLevel(idxBizPvHealthIndex.getHealthLevel());
pvHealthIndex.setKks(idxBizPvHealthIndex.getKks());
pvHealthIndex.setRecDate(format);
pvHealthIndex.setOrgCode(obj.getOrgCode());
fanHealthIndices1.add(pvHealthIndex);
}
}
}
// idxBizPvHealthIndexService.saveBatch(idxBizPvHealthIndexs);
// 按时刻 - 相关数据插入
insertPvDataTDEngine(fanHealthIndices1, format, WarningPeriodEnum.MINUTES.getName());
}
try {
// logger.info("--------------------response: " + response);
logger.info(
"------------------------------------------调用光伏健康指数计算算法结束----------------------------------------");
} catch (Exception e) {
throw new RuntimeException(e);
}
// healthStatusIndicatorService.healthWarningMinuteGF(calendar, time);
healthStatusIndicatorService.healthWarningMinuteGF(time);
}
public void healthWarningMinuteByPv(String gatewayId) {
if (!openHealth) {
return;
}
// Calendar calendar = Calendar.getInstance();
Date time = new Date();
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
.getInfluxDBDataByGatewayId(gatewayId);
// Map<String, List<IdxBizPvPointProcessVariableClassificationDto>> maps = data.stream()
// .collect(Collectors.groupingBy(IdxBizPvPointProcessVariableClassificationDto::getGatewayId));
// BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
// List<QueryBuilder> should = boolMustAll.should();
// List<IndicatorData> indicatorDataListAll = new LinkedList<>();
// for (String s : maps.keySet()) {
// BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
// String addressids = maps.get(s).stream().map(idxBizPvPointProcessVariableClassificationDto -> "\'" + idxBizPvPointProcessVariableClassificationDto.getIndexAddress() + "\'").collect(Collectors.joining(","));
List<IndicatorData> indicatorDataListAll = indicatorDataMapper.selectDataByGatewayId(gatewayId);
// indicatorDataListAll.addAll(indicatorDataList);
// List<String> address = maps.get(s).stream().map(IdxBizPvPointProcessVariableClassificationDto::getIndexAddress).collect(Collectors.toList());
// boolQueryBuilder.must(QueryBuilders.termsQuery("address.keyword", address)).must(QueryBuilders.termsQuery("gatewayId.keyword", s));
// should.add(boolQueryBuilder);
// }
// 创建查询构造器
// NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// //过滤条件
// .withQuery(boolMustAll);
// List<ESEquipments> equipments = new LinkedList<>();
// long totle = 0;
// try {
// SearchHits<ESEquipments> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESEquipments.class);
//
// for (SearchHit searchHit : searchHits.getSearchHits()) {
// JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
// ESEquipments eSAlertCalled = JSONObject.toJavaObject(jsonObject, ESEquipments.class);
// equipments.add(eSAlertCalled);
// }
// totle = searchHits.getTotalHits();
// } catch (Exception e) {
// // TODO: handle exception
// }
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);
}
// }
// }
}
LambdaQueryWrapper<IdxBizPvPointVarCentralValue> wrapper = new LambdaQueryWrapper<>();
List<IdxBizPvPointVarCentralValue> idxBizUhefs = idxBizPvPointVarCentralValueMapper.selectList(wrapper);
HashMap<String, Object> requestMap = new HashMap<>();
ArrayList<Object> analysisVariableList = new ArrayList<>();
ArrayList<Object> stdDevList = new ArrayList<>();
ArrayList<Object> centerValueList = new ArrayList<>();
ArrayList<Object> analysisVariableIdList = new ArrayList<>();
List<Double> analysisVariable = new ArrayList<>();
List<Double> stdDev = new ArrayList<>();
List<Double> centerValue = new ArrayList<>();
List<String> analysisVariableId = new ArrayList<>();
List<Double> ProcessPoint1 = new ArrayList<>();
List<Double> ProcessPoint2 = new ArrayList<>();
List<Double> ProcessPoint3 = new ArrayList<>();
List<String> ProcessPoint1Id = new ArrayList<>();
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();
// }
// }
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);
ProcessPoint1Id.add(idxBizUhef.getProcessPoint1Id());
ProcessPoint2Id.add(idxBizUhef.getProcessPoint2Id());
ProcessPoint3Id.add(idxBizUhef.getProcessPoint3Id());
analysisVariableIds.add(idxBizUhef.getAnalysisPointId());
ProcessPoint1.add(value1);
ProcessPoint2.add(value2);
ProcessPoint3.add(value3);
stdDevList.add(idxBizUhef.getAnalysisStdDev());
stdDev.add(idxBizUhef.getAnalysisStdDev());
centerValueList.add(idxBizUhef.getAnalysisCenterValue());
centerValue.add(idxBizUhef.getAnalysisCenterValue());
analysisVariableIdList.add(idxBizUhef.getAnalysisPointId());
analysisVariableId.add(idxBizUhef.getAnalysisPointId());
}
}
}
requestMap.put("analysisVariable", analysisVariableList);
requestMap.put("stdDev", stdDevList);
requestMap.put("centerValue", centerValueList);
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));
logger.info(
"------------------------------------------开始调用光伏健康指数计算算法开始----------------------------------------");
logger.info("------------------------------------------调用地址:" + baseUrlZSFX);
// logger.info("------------------------------------------调用参数:"+JSON.toJSONString(requestMap));
String response = HttpUtil.createPost(baseUrlZSFX).body(JSON.toJSONString(requestMap)).execute().body();
JSONObject jsonObject = JSON.parseObject(response);
if (jsonObject.containsKey("indexValue")) {
JSONArray indexValueArray = jsonObject.getJSONArray("indexValue");
JSONArray scoreValueArray = jsonObject.getJSONArray("scoreValue");
JSONArray analysisVariableIdArray = jsonObject.getJSONArray("analysisVariableId");
List<String> jsonArrayToStringList = JSONObject.parseArray(analysisVariableIdArray.toJSONString(),
String.class);
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));
System.out.println(healthData.print());
try {
healthData.write().csv(new Date().getTime() + "gf.csv");
} catch (Exception e) {
e.printStackTrace();
}
LambdaQueryWrapper<IdxBizPvPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(IdxBizPvPointProcessVariableClassification::getSequenceNbr, jsonArrayToStringList);
List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationMapper
.selectList(queryWrapper);
Set<String> stations = list.stream().map(IdxBizPvPointProcessVariableClassification::getStation)
.collect(Collectors.toSet());
LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点");
query.in(IdxBizPvHealthLevel::getStatus, stations);
List<IdxBizPvHealthLevel> idxBizFanHealthLevels = idxBizPvHealthLevelMapper.selectList(query);
List<IdxBizPvHealthIndex> idxBizPvHealthIndexs = new ArrayList<>();
ArrayList<PvHealthIndex> fanHealthIndices1 = new ArrayList<>();
for (IdxBizPvPointProcessVariableClassification obj : list) {
for (int i = 0; i < analysisVariableIdArray.size(); i++) {
if (analysisVariableIdArray.get(i).toString().equals(obj.getSequenceNbr())) {
IdxBizPvHealthIndex idxBizPvHealthIndex = new IdxBizPvHealthIndex();
BeanUtils.copyProperties(obj, idxBizPvHealthIndex, "sequenceNbr");
// idxBizPvHealthIndex.setSequenceNbr(null);
// 2023年10月30日10点05分 移除原来的判断 无论是否小于0都取绝对值
idxBizPvHealthIndex.setHealthIndex(Math.abs(indexValueArray.getDoubleValue(i)));
idxBizPvHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr());
idxBizPvHealthIndex.setRecDate(time);
idxBizPvHealthIndex.setWeigth(1.0);
// 获取健康指数对应等级
for (IdxBizPvHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit()
&& indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
idxBizPvHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
}
}
idxBizPvHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName());
idxBizPvHealthIndex.setAnalysisObjType("测点");
idxBizPvHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i));
idxBizPvHealthIndex.setANALYSISTIME(DateUtils.getDateNowString());
idxBizPvHealthIndexs.add(idxBizPvHealthIndex);
PvHealthIndex pvHealthIndex = new PvHealthIndex();
BeanUtil.copyProperties(idxBizPvHealthIndex, pvHealthIndex);
pvHealthIndex.setWeight(idxBizPvHealthIndex.getWeigth());
pvHealthIndex.setAnomaly(idxBizPvHealthIndex.getANOMALY());
pvHealthIndex.setRecDate(DateUtil.now());
pvHealthIndex.setArea(idxBizPvHealthIndex.getArae());
pvHealthIndex.setAnalysisTime(DateUtil.now());
pvHealthIndex.setHealthLevel(idxBizPvHealthIndex.getHealthLevel());
pvHealthIndex.setKks(idxBizPvHealthIndex.getKks());
pvHealthIndex.setRecDate(format);
pvHealthIndex.setOrgCode(obj.getOrgCode());
fanHealthIndices1.add(pvHealthIndex);
}
}
}
// idxBizPvHealthIndexService.saveBatch(idxBizPvHealthIndexs);
// 按时刻 - 相关数据插入
insertPvDataTDEngine(fanHealthIndices1, format, WarningPeriodEnum.MINUTES.getName());
}
try {
// logger.info("--------------------response: " + response);
logger.info(
"------------------------------------------调用光伏健康指数计算算法结束----------------------------------------");
} catch (Exception e) {
throw new RuntimeException(e);
}
// healthStatusIndicatorService.healthWarningMinuteGF(calendar, time);
healthStatusIndicatorService.healthWarningMinuteGF(time,gatewayId);
}
/**
* 光伏按时刻相关数据插入
*
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapBuilder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointVarCorrelationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelation;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointVarCorrelationMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizFanPointVarCorrelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 服务实现类
......@@ -18,6 +25,9 @@ import java.util.List;
*/
@Service
public class IdxBizFanPointVarCorrelationServiceImpl extends BaseService<IdxBizFanPointVarCorrelationDto, IdxBizFanPointVarCorrelation, IdxBizFanPointVarCorrelationMapper> implements IIdxBizFanPointVarCorrelationService {
@Autowired
private IdxBizFanPointVarCorrelationMapper idxBizFanPointVarCorrelationMapper;
/**
* 分页查询
*/
......@@ -31,4 +41,47 @@ public class IdxBizFanPointVarCorrelationServiceImpl extends BaseService<IdxBizF
public List<IdxBizFanPointVarCorrelationDto> queryForIdxBizFanPointVarCorrelationList() {
return this.queryForList("" , false);
}
public Map<String,Object> getCurrentChoosePoint(String gatewayId, String analysePointId) {
List<IdxBizFanPointVarCorrelation> gongkuangList;
gongkuangList = idxBizFanPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID",
gatewayId)
.eq("ANALYSIS_POINT_ID",
analysePointId)
.eq("MATCH_PROCESS_PONIT","匹配"));
if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() !=3 ){
gongkuangList = idxBizFanPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID",
gatewayId)
.eq("ANALYSIS_POINT_ID",
analysePointId)
.orderByDesc("CORRELATION_COEFFICIENT").last("limit 0,3"));
}
List<Long> collect = gongkuangList.stream().map(IdxBizFanPointVarCorrelation::getProcessPointId).collect(Collectors.toList());
return MapBuilder.<String,Object>create().put("processPointIds",collect).build();
}
public void updatePointChoose(String gatewayId, Long analysePointId, List<String> processPointIds) {
this.getBaseMapper().updatePointChoose(gatewayId,analysePointId,null);
this.getBaseMapper().updatePointChoose(gatewayId,analysePointId,processPointIds);
}
public Map<String,Object> getPointProcess(String gatewayId, String analysePointId) {
List<IdxBizFanPointVarCorrelation> gongkuangList = idxBizFanPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID",
gatewayId)
.eq("ANALYSIS_POINT_ID",
analysePointId));
return MapBuilder.<String,Object>create().put("processPointIds",gongkuangList).build();
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapBuilder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvPointVarCorrelationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointVarCorrelation;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvPointVarCorrelationMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizPvPointVarCorrelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 服务实现类
......@@ -18,6 +26,8 @@ import java.util.List;
*/
@Service
public class IdxBizPvPointVarCorrelationServiceImpl extends BaseService<IdxBizPvPointVarCorrelationDto,IdxBizPvPointVarCorrelation,IdxBizPvPointVarCorrelationMapper> implements IIdxBizPvPointVarCorrelationService {
@Autowired
private IdxBizPvPointVarCorrelationMapper idxBizPvPointVarCorrelationMapper;
/**
* 分页查询
*/
......@@ -31,4 +41,49 @@ public class IdxBizPvPointVarCorrelationServiceImpl extends BaseService<IdxBizPv
public List<IdxBizPvPointVarCorrelationDto> queryForIdxBizPvPointVarCorrelationList() {
return this.queryForList("" , false);
}
public Map<String,Object> getCurrentChoosePoint(String gatewayId, String analysePointId) {
List<IdxBizPvPointVarCorrelation> gongkuangList;
gongkuangList = idxBizPvPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID",
gatewayId)
.eq("ANALYSIS_POINT_ID",
analysePointId)
.eq("MATCH_PROCESS_POINT","匹配"));
if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() !=3 ){
gongkuangList = idxBizPvPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID",
gatewayId)
.eq("ANALYSIS_POINT_ID",
analysePointId)
.orderByDesc("CORRELATION_COEFFICIENT").last("limit 0,3"));
}
List<String> collect = gongkuangList.stream().map(IdxBizPvPointVarCorrelation::getProcessPointId).collect(Collectors.toList());
return MapBuilder.<String,Object>create().put("processPointIds",collect).build();
}
public void updatePointChoose(String gatewayId, Long analysePointId, List<String> processPointIds) {
this.getBaseMapper().updatePointChoose(gatewayId,analysePointId,null);
this.getBaseMapper().updatePointChoose(gatewayId,analysePointId,processPointIds);
}
public Map<String,Object> getPointProcess(String gatewayId, String analysePointId) {
List<IdxBizPvPointVarCorrelation> gongkuangList = idxBizPvPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID",
gatewayId)
.eq("ANALYSIS_POINT_ID",
analysePointId));
return MapBuilder.<String,Object>create().put("processPointIds",gongkuangList).build();
}
}
\ No newline at end of file
......@@ -53,6 +53,8 @@ public interface IndicatorDataMapper extends BaseMapper<IndicatorData> {
@Select("select `value`,`value_f`, address, gateway_id from iot_data.indicator_data where ts > NOW()-10m and gateway_id = #{gatewayId}")
List<IndicatorData> selectDataByGatewayIdAndAddress(@Param("gatewayId") String gatewayId);
@Select("select `value`,`value_f`, address, gateway_id from analysis_data.indicator_data where ts > NOW()-10m and gateway_id = #{gatewayId} and point_type = 'SENSOR'")
List<IndicatorData> selectDataByGatewayId(@Param("gatewayId") String gatewayId);
@Select("select created_time,`value`,`value_f`, address, gateway_id from iot_data.indicator_data where gateway_id = #{gatewayId} and `address` in ( ${addresses} ) and ts >= #{startTime} and ts <= #{endTime}")
List<IndicatorData> selectDataByGatewayIdAndAddressForAlarmInfoDetail(@Param("gatewayId") String gatewayId,@Param("addresses") String addresses,@Param("startTime") String startTime, @Param("endTime") String endTime);
......
......@@ -83,7 +83,89 @@
GROUP BY
b.SEQUENCE_NBR
</select>
<select id="getInfluxDBDataByGatewayId" resultType="com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto">
SELECT
b.*,
ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
ibfpvcv.ANALYSIS_POINT_ID AS pointId
FROM
(
SELECT
*
FROM
idx_biz_fan_point_process_variable_classification uxfv
WHERE
uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT1_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
) AS b,
idx_biz_fan_point_var_central_value ibfpvcv
WHERE
b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT1_ID
GROUP BY
b.SEQUENCE_NBR UNION ALL
SELECT
b.*,
ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
ibfpvcv.ANALYSIS_POINT_ID AS pointId
FROM
(
SELECT
*
FROM
idx_biz_fan_point_process_variable_classification uxfv
WHERE
uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT2_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
) AS b,
idx_biz_fan_point_var_central_value ibfpvcv
WHERE
b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT2_ID
GROUP BY
b.SEQUENCE_NBR UNION ALL
SELECT
b.*,
ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
ibfpvcv.ANALYSIS_POINT_ID AS pointId
FROM
(
SELECT
*
FROM
idx_biz_fan_point_process_variable_classification uxfv
WHERE
uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT3_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
) AS b,
idx_biz_fan_point_var_central_value ibfpvcv
WHERE
b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT3_ID
GROUP BY
b.SEQUENCE_NBR UNION ALL
SELECT
b.*,
ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
ibfpvcv.ANALYSIS_POINT_ID AS pointId
FROM
(
SELECT
*
FROM
idx_biz_fan_point_process_variable_classification uxfv
WHERE
uxfv.SEQUENCE_NBR IN ( SELECT ANALYSIS_POINT_ID FROM `idx_biz_fan_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
) AS b,
idx_biz_fan_point_var_central_value ibfpvcv
WHERE
b.SEQUENCE_NBR = ibfpvcv.ANALYSIS_POINT_ID
and b.GATEWAY_ID = #{gatewayId}
GROUP BY
b.SEQUENCE_NBR
</select>
<select id="gateWayIdListFan" resultType="java.lang.String">
select GATEWAY_ID from idx_biz_fan_point_process_variable_classification group by GATEWAY_ID;
</select>
......
<?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.mapper2.IdxBizFanPointVarCorrelationMapper">
<update id="updatePointChoose">
update idx_biz_fan_point_var_correlation
<set>
<if test="processPointIds == null || processPointIds.size() == 0">
MATCH_PROCESS_PONIT = null
</if>
<if test="processPointIds != null and processPointIds.size() > 0">
MATCH_PROCESS_PONIT = '匹配'
</if>
</set>
WHERE ANALYSIS_GATEWAY_ID = #{gatewayId}
and ANALYSIS_POINT_ID = #{analysePointId}
<if test="processPointIds != null and processPointIds.size() > 0">
and PROCESS_POINT_ID in
<foreach collection="processPointIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</update>
</mapper>
......@@ -88,4 +88,89 @@
GROUP BY
b.SEQUENCE_NBR
</select>
<select id="getInfluxDBDataByGatewayId" resultType="com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvPointProcessVariableClassificationDto">
SELECT
b.*,
ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
ibfpvcv.ANALYSIS_POINT_ID AS pointId
FROM
(
SELECT
*
FROM
idx_biz_pv_point_process_variable_classification uxfv
WHERE
uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT1_ID FROM `idx_biz_pv_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
) AS b,
idx_biz_pv_point_var_central_value ibfpvcv
WHERE
b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT1_ID
GROUP BY
b.SEQUENCE_NBR UNION ALL
SELECT
b.*,
ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
ibfpvcv.ANALYSIS_POINT_ID AS pointId
FROM
(
SELECT
*
FROM
idx_biz_pv_point_process_variable_classification uxfv
WHERE
uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT2_ID FROM `idx_biz_pv_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
) AS b,
idx_biz_pv_point_var_central_value ibfpvcv
WHERE
b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT2_ID
GROUP BY
b.SEQUENCE_NBR UNION ALL
SELECT
b.*,
ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
ibfpvcv.ANALYSIS_POINT_ID AS pointId
FROM
(
SELECT
*
FROM
idx_biz_pv_point_process_variable_classification uxfv
WHERE
uxfv.SEQUENCE_NBR IN ( SELECT PROCESS_POINT3_ID FROM `idx_biz_pv_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
) AS b,
idx_biz_pv_point_var_central_value ibfpvcv
WHERE
b.SEQUENCE_NBR = ibfpvcv.PROCESS_POINT3_ID
GROUP BY
b.SEQUENCE_NBR UNION ALL
SELECT
b.*,
ibfpvcv.PROCESS_POINT1_ID AS pointOneId,
ibfpvcv.PROCESS_POINT2_ID AS pointTwoId,
ibfpvcv.PROCESS_POINT3_ID AS pointThreeId,
ibfpvcv.ANALYSIS_POINT_ID AS pointId
FROM
(
SELECT
*
FROM
idx_biz_pv_point_process_variable_classification uxfv
WHERE
uxfv.SEQUENCE_NBR IN ( SELECT ANALYSIS_POINT_ID FROM `idx_biz_pv_point_var_central_value` WHERE ANALYSIS_POINT_ID IS NOT NULL GROUP BY ANALYSIS_POINT_ID, PROCESS_POINT1_ID, PROCESS_POINT3_ID, PROCESS_POINT2_ID )
) AS b,
idx_biz_pv_point_var_central_value ibfpvcv
WHERE
b.SEQUENCE_NBR = ibfpvcv.ANALYSIS_POINT_ID
and b.GATEWAY_ID = #{gatewayId}
GROUP BY
b.SEQUENCE_NBR
</select>
</mapper>
......@@ -2,4 +2,23 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvPointVarCorrelationMapper">
<update id="updatePointChoose">
update idx_biz_pv_point_var_correlation
<set>
<if test="processPointIds == null || processPointIds.size() == 0">
MATCH_PROCESS_PONIT = null
</if>
<if test="processPointIds != null and processPointIds.size() > 0">
MATCH_PROCESS_PONIT = '匹配'
</if>
</set>
WHERE ANALYSIS_GATEWAY_ID = #{gatewayId}
and ANALYSIS_POINT_ID = #{analysePointId}
<if test="processPointIds != null and processPointIds.size() > 0">
and PROCESS_POINT_ID in
<foreach collection="processPointIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</update>
</mapper>
......@@ -4,11 +4,13 @@ import lombok.Data;
@Data
public class BuDunGenDto {
private Double day;
private Double month;
private Double year;
private Double month_complete;
private Double year_complete;
private Double year_hour_number;
private Double cumulative;
private String station_name;
private Double actual_installed_capacity;
private Double day;
private Double month;
private Double year;
private Double month_complete;
private Double year_complete;
private Double year_hour_number;
private Double cumulative;
}
......@@ -246,10 +246,11 @@ public class MonitorServiceImpl implements MonitorService {
@Override
public Map<String, Object> gettimedateqyyfd(String areaName) {
String requestUrl = Constants.BASE_URL + "?" + Constants.get_generated_quota_trend + "&areaName=" + areaName;
String requestUrl = Constants.BASE_URL + "?" + Constants.get_generated_quota_trend ;
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("name", areaName));
if (!areaName.contains(Constants.areaChinese)) {
areaName = Constants.areaChinese;
areaName =areaName+ Constants.areaChinese;
requestUrl =requestUrl+ "&areaName=" + areaName;
}
List<BundunCompleteDto> bundunCompleteDtoList = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BundunCompleteDto.class);
......
......@@ -39,7 +39,7 @@ public class CoreCommonServiceImpl implements CoreCommonService {
});
}catch (Exception e){
e.printStackTrace();
return result;
return new ArrayList<>();
}
return result;
}
......
......@@ -361,14 +361,14 @@ public class MonitorServiceImpl implements MonitorService {
AtomicReference<Double> fdzannualPower = new AtomicReference<>(0.0);
AtomicReference<Double> gfzannualPower = new AtomicReference<>(0.0);
List<CoreValuesDto> coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null);
String requestUrl = Constants.BASE_URL + "?" + Constants.get_province_station_item + "&provinceName" + provinceName;
String requestUrl = Constants.BASE_URL + "?" + Constants.get_province_station_item + "&provinceName=" + provinceName;
List<BuDunStationDetailInfo> buDunStationDetailInfos = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BuDunStationDetailInfo.class);
if (buDunStationDetailInfos.size() > 0) {
buDunStationDetailInfos.forEach(buDunStationDetailInfo -> {
CompletionOfPowerIndicatorsDto completionOfPowerIndicatorsDto = new CompletionOfPowerIndicatorsDto();
completionOfPowerIndicatorsDto.setStationName(buDunStationDetailInfo.getStation_name());
completionOfPowerIndicatorsDto.setInstallCapactity(String.valueOf(buDunStationDetailInfo.getActual_installed_capacity()));
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, buDunStationDetailInfo.getWind_as_irradiance()));
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(!ObjectUtils.isEmpty(buDunStationDetailInfo.getWind_as_irradiance())?String.format(CommonConstans.Twodecimalplaces, buDunStationDetailInfo.getWind_as_irradiance()):"--");
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, buDunStationDetailInfo.getDay()));
completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, buDunStationDetailInfo.getMonth()));
completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, buDunStationDetailInfo.getYear()));
......@@ -487,7 +487,7 @@ public class MonitorServiceImpl implements MonitorService {
String requestUrl = Constants.BASE_URL + "?" + Constants.get_area_item_url;
if (!ObjectUtils.isEmpty(areaName)) {
if (!areaName.contains(Constants.areaChinese)) {
areaName = Constants.areaChinese;
areaName =areaName+ Constants.areaChinese;
}
requestUrl = requestUrl + "&areaName=" + areaName;
}
......@@ -579,7 +579,7 @@ public class MonitorServiceImpl implements MonitorService {
List<HashMap<String, String>> mapList = new ArrayList<>();
String requestUrl = Constants.BASE_URL + "?" + Constants.get_month_top_url + "&topValue=5";
if (!ObjectUtils.isEmpty(areaName)) {
if (areaName.contains(Constants.areaChinese)) {
if (!areaName.contains(Constants.areaChinese)) {
areaName = areaName + Constants.areaChinese;
}
requestUrl = requestUrl + "&areaName=" + areaName;
......@@ -646,7 +646,7 @@ public class MonitorServiceImpl implements MonitorService {
List<StationBasic> gfdzlist = new ArrayList<>();
String requestUrl = Constants.BASE_URL + "?" + Constants.get_hours_num_top + "&topValue=3&tabValue=" + tabValue;
if (!ObjectUtils.isEmpty(areaName)) {
if (areaName.contains(Constants.areaChinese)) {
if (!areaName.contains(Constants.areaChinese)) {
areaName = areaName + Constants.areaChinese;
}
requestUrl = requestUrl + "&areaName=" + areaName;
......
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