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; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils; 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 com.yeejoin.amos.boot.module.jxiop.biz.listener.SyncESDataToTdengineMqttListener;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -62,6 +63,8 @@ public class AmosJxiopAnalyseApplication { ...@@ -62,6 +63,8 @@ public class AmosJxiopAnalyseApplication {
Boolean openHealth; Boolean openHealth;
@Autowired @Autowired
private SyncESDataToTdengineMqttListener syncESDataToTdengineMqttListener; private SyncESDataToTdengineMqttListener syncESDataToTdengineMqttListener;
@Autowired
private SyncDasSuccessMqttListener syncDasSuccessMqttListener;
private static final Logger logger = LoggerFactory.getLogger(AmosJxiopAnalyseApplication.class); private static final Logger logger = LoggerFactory.getLogger(AmosJxiopAnalyseApplication.class);
...@@ -82,6 +85,8 @@ public class AmosJxiopAnalyseApplication { ...@@ -82,6 +85,8 @@ public class AmosJxiopAnalyseApplication {
if (openHealth) { if (openHealth) {
//订阅固化周期性数据成功的消息 //订阅固化周期性数据成功的消息
emqKeeper.subscript("sync_esdata_to_tdengine_notice", 1, syncESDataToTdengineMqttListener); 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; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; 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.IdxBizFanPointVarCorrelationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelation;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanPointVarCorrelationServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanPointVarCorrelationServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -15,6 +19,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -15,6 +19,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
...@@ -112,4 +117,32 @@ public class IdxBizFanPointVarCorrelationController extends BaseController { ...@@ -112,4 +117,32 @@ public class IdxBizFanPointVarCorrelationController extends BaseController {
public ResponseModel<List<IdxBizFanPointVarCorrelationDto>> selectForList() { public ResponseModel<List<IdxBizFanPointVarCorrelationDto>> selectForList() {
return ResponseHelper.buildResponse(idxBizFanPointVarCorrelationServiceImpl.queryForIdxBizFanPointVarCorrelationList()); 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; ...@@ -2,7 +2,11 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; 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.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 com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvPointVarCorrelationServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -15,6 +19,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -15,6 +19,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
...@@ -112,4 +117,32 @@ public class IdxBizPvPointVarCorrelationController extends BaseController { ...@@ -112,4 +117,32 @@ public class IdxBizPvPointVarCorrelationController extends BaseController {
public ResponseModel<List<IdxBizPvPointVarCorrelationDto>> selectForList() { public ResponseModel<List<IdxBizPvPointVarCorrelationDto>> selectForList() {
return ResponseHelper.buildResponse(idxBizPvPointVarCorrelationServiceImpl.queryForIdxBizPvPointVarCorrelationList()); 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; ...@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
...@@ -86,4 +87,6 @@ public class IdxBizFanPointVarCorrelationDto { ...@@ -86,4 +87,6 @@ public class IdxBizFanPointVarCorrelationDto {
@TableField("EQUIPMENT_NAME") @TableField("EQUIPMENT_NAME")
private String equipmentName; private String equipmentName;
@TableField(exist = false)
private List<String> processPointIds;
} }
...@@ -149,4 +149,9 @@ public class IdxBizFanPointVarCorrelation{ ...@@ -149,4 +149,9 @@ public class IdxBizFanPointVarCorrelation{
*/ */
@TableField("PROCESS_POINT_NAME") @TableField("PROCESS_POINT_NAME")
private String processPointName; private String processPointName;
/**
* 匹配工况变量
*/
@TableField("MATCH_PROCESS_PONIT")
private String matchProcessPoint;
} }
...@@ -12,8 +12,6 @@ import java.time.LocalDateTime; ...@@ -12,8 +12,6 @@ import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
/** /**
*
*
* @author system_generator * @author system_generator
* @date 2023-08-15 * @date 2023-08-15
*/ */
...@@ -21,7 +19,7 @@ import java.util.Date; ...@@ -21,7 +19,7 @@ import java.util.Date;
@Accessors(chain = true) @Accessors(chain = true)
@TableName("idx_biz_fan_warning_rule_set") @TableName("idx_biz_fan_warning_rule_set")
public class IdxBizFanWarningRuleSet{ public class IdxBizFanWarningRuleSet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -124,4 +122,6 @@ public class IdxBizFanWarningRuleSet{ ...@@ -124,4 +122,6 @@ public class IdxBizFanWarningRuleSet{
@TableField("POINT_NAME") @TableField("POINT_NAME")
private String pointName; private String pointName;
@TableField("GATEWAY_ID")
private String gatewayId;
} }
...@@ -151,4 +151,7 @@ public class IdxBizPvPointVarCorrelation{ ...@@ -151,4 +151,7 @@ public class IdxBizPvPointVarCorrelation{
*/ */
@TableField("PROCESS_POINT_NAME") @TableField("PROCESS_POINT_NAME")
private String processPointName; private String processPointName;
@TableField("MATCH_PROCESS_POINT")
private String matchProcessPoint;
} }
...@@ -133,4 +133,11 @@ public class IdxBizPvWarningRuleSet{ ...@@ -133,4 +133,11 @@ public class IdxBizPvWarningRuleSet{
*/ */
@TableField("POINT_NAME") @TableField("POINT_NAME")
private String pointName; 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; ...@@ -16,6 +16,7 @@ import java.util.Map;
*/ */
public interface IdxBizFanPointProcessVariableClassificationMapper extends BaseMapper<IdxBizFanPointProcessVariableClassification> { public interface IdxBizFanPointProcessVariableClassificationMapper extends BaseMapper<IdxBizFanPointProcessVariableClassification> {
List<IdxBizFanPointProcessVariableClassificationDto> getInfluxDBData(); List<IdxBizFanPointProcessVariableClassificationDto> getInfluxDBData();
List<IdxBizFanPointProcessVariableClassificationDto> getInfluxDBDataByGatewayId(String gatewayId);
List<Map<String,Object>> selectParams(String tableName,String column,String isFx); List<Map<String,Object>> selectParams(String tableName,String column,String isFx);
......
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jxiop.biz.mapper2; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelation; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelation;
import java.util.List;
/** /**
* Mapper 接口 * Mapper 接口
* *
...@@ -10,5 +12,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelatio ...@@ -10,5 +12,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointVarCorrelatio
* @date 2023-08-15 * @date 2023-08-15
*/ */
public interface IdxBizFanPointVarCorrelationMapper extends BaseMapper<IdxBizFanPointVarCorrelation> { 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 ...@@ -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分钟'") @Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按10分钟'")
Integer getMaxWaringCycleOfMinutes(); 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 = '按小时'") @Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按小时'")
Integer getMaxWaringCycleOfHour(); Integer getMaxWaringCycleOfHour();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按天'") @Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按天'")
......
...@@ -17,5 +17,6 @@ public interface IdxBizPvPointProcessVariableClassificationMapper extends BaseMa ...@@ -17,5 +17,6 @@ public interface IdxBizPvPointProcessVariableClassificationMapper extends BaseMa
List<String> gateWayIdListPv(); List<String> gateWayIdListPv();
List<IdxBizPvPointProcessVariableClassificationDto> getInfluxDBData(); List<IdxBizPvPointProcessVariableClassificationDto> getInfluxDBData();
List<IdxBizPvPointProcessVariableClassificationDto> getInfluxDBDataByGatewayId(String gatewayId);
} }
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jxiop.biz.mapper2; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointVarCorrelation; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointVarCorrelation;
import java.util.List;
/** /**
* Mapper 接口 * Mapper 接口
* *
...@@ -11,4 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointVarCorrelation ...@@ -11,4 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointVarCorrelation
*/ */
public interface IdxBizPvPointVarCorrelationMapper extends BaseMapper<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 ...@@ -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分钟'") @Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按10分钟'")
Integer getMaxWaringCycleOfMinutes(); 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 = '按小时'") @Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按小时'")
Integer getMaxWaringCycleOfHour(); Integer getMaxWaringCycleOfHour();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按天'") @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; ...@@ -3,20 +3,14 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil; 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.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; 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.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.SmartAnalyseEnum; import com.yeejoin.amos.boot.module.jxiop.biz.Enum.SmartAnalyseEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum; import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum;
...@@ -30,13 +24,11 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper; ...@@ -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.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import javafx.scene.control.Tab;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.joda.time.DateTimeUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -48,22 +40,16 @@ import org.springframework.data.elasticsearch.core.SearchHit; ...@@ -48,22 +40,16 @@ import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; 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.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil;
import tech.tablesaw.api.DoubleColumn; import tech.tablesaw.api.DoubleColumn;
import tech.tablesaw.api.StringColumn; import tech.tablesaw.api.StringColumn;
import tech.tablesaw.api.Table; import tech.tablesaw.api.Table;
import java.io.File;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -84,7 +70,8 @@ public class CommonServiceImpl { ...@@ -84,7 +70,8 @@ public class CommonServiceImpl {
*/ */
private static final BlockingQueue<IdxBizPvPointProcessVariableClassification> fifoPv = new LinkedBlockingQueue<>( private static final BlockingQueue<IdxBizPvPointProcessVariableClassification> fifoPv = new LinkedBlockingQueue<>(
5000); 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}") @Value("${sleep.time:10}")
Integer sleepTime; Integer sleepTime;
...@@ -156,21 +143,15 @@ public class CommonServiceImpl { ...@@ -156,21 +143,15 @@ public class CommonServiceImpl {
private IndicatorDataMapper indicatorDataMapper; private IndicatorDataMapper indicatorDataMapper;
@Autowired @Autowired
private ElasticsearchRestTemplate elasticsearchTemplate; private ElasticsearchRestTemplate elasticsearchTemplate;
@Autowired @Autowired
private FanHealthIndexMapper fanHealthIndexMapper; private FanHealthIndexMapper fanHealthIndexMapper;
@Autowired @Autowired
private IdxBizPvHealthIndexMapper idxFanHealthIndexMapper; private IdxBizPvHealthIndexMapper idxFanHealthIndexMapper;
@Autowired @Autowired
private PvHealthIndexMapper pvHealthIndexMapper; private PvHealthIndexMapper pvHealthIndexMapper;
@Autowired @Autowired
private TdengineTimeServiceImpl tdengineTimeService; private TdengineTimeServiceImpl tdengineTimeService;
public final DecimalFormat df = new DecimalFormat("#.00");
/** /**
* @return * @return
* @deprecated 获取工况变量列表风机 * @deprecated 获取工况变量列表风机
...@@ -314,7 +295,6 @@ public class CommonServiceImpl { ...@@ -314,7 +295,6 @@ public class CommonServiceImpl {
idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime, tableName); idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime, tableName);
// List<Map<String, Object>> returnList = influxdbUtil.query(sql); // List<Map<String, Object>> returnList = influxdbUtil.query(sql);
returnList.forEach((k) -> { returnList.forEach((k) -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -329,8 +309,7 @@ public class CommonServiceImpl { ...@@ -329,8 +309,7 @@ public class CommonServiceImpl {
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkqjhfkey, params); realParams.put(gkqjhfkey, params);
logger.info("------------------------------------------调用地址:" + baseUrl + gkqjhfurlfan); logger.info("------------------------------------------调用地址:" + baseUrl + gkqjhfurlfan);
logger.info("------------------------------------------调用参数:" logger.info("------------------------------------------调用参数:" + JSON.toJSONString(JSON.toJSONString(realParams)));
+ JSON.toJSONString(JSON.toJSONString(realParams)));
String response = HttpUtil.createPost(baseUrl + gkqjhfurlfan).body(JSON.toJSONString(realParams)) String response = HttpUtil.createPost(baseUrl + gkqjhfurlfan).body(JSON.toJSONString(realParams))
.execute().body(); .execute().body();
if (response.contains("\"status\":200") && response.contains("rows") && response.contains("rows")) { if (response.contains("\"status\":200") && response.contains("rows") && response.contains("rows")) {
...@@ -622,14 +601,12 @@ public class CommonServiceImpl { ...@@ -622,14 +601,12 @@ public class CommonServiceImpl {
idxBizFanPointVarCorrelation idxBizFanPointVarCorrelation
.setCorrelationCoefficient(values.getDoubleValue("correlation_coefficient")); .setCorrelationCoefficient(values.getDoubleValue("correlation_coefficient"));
idxBizFanPointVarCorrelationMapper.updateById(idxBizFanPointVarCorrelation); idxBizFanPointVarCorrelationMapper.updateById(idxBizFanPointVarCorrelation);
logger.info( logger.info("------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------");
"------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------");
} }
try { try {
logger.info("response-------------" + response); logger.info("response-------------" + response);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
logger.info( logger.info("----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------");
"----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------");
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
...@@ -768,8 +745,8 @@ public class CommonServiceImpl { ...@@ -768,8 +745,8 @@ public class CommonServiceImpl {
IdxBizFanPointProcessVariableClassification.getGatewayId()) IdxBizFanPointProcessVariableClassification.getGatewayId())
.eq("ANALYSIS_POINT_ID", .eq("ANALYSIS_POINT_ID",
IdxBizFanPointProcessVariableClassification.getSequenceNbr()) IdxBizFanPointProcessVariableClassification.getSequenceNbr())
.eq("MATCH","匹配")); .eq("MATCH_PROCESS_POINT", "匹配"));
if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() !=3 ){ if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() != 3) {
gongkuangList = idxBizFanPointVarCorrelationMapper gongkuangList = idxBizFanPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>() .selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID", .eq("ANALYSIS_GATEWAY_ID",
...@@ -821,8 +798,8 @@ public class CommonServiceImpl { ...@@ -821,8 +798,8 @@ public class CommonServiceImpl {
idxBizPvPointProcessVariableClassification.getGatewayId()) idxBizPvPointProcessVariableClassification.getGatewayId())
.eq("ANALYSIS_POINT_ID", .eq("ANALYSIS_POINT_ID",
idxBizPvPointProcessVariableClassification.getSequenceNbr()) idxBizPvPointProcessVariableClassification.getSequenceNbr())
.eq("MATCH","匹配")); .eq("MATCH_PROCESS_POINT", "匹配"));
if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() != 3){ if (CollectionUtil.isEmpty(gongkuangList) || gongkuangList.size() != 3) {
gongkuangList = idxBizPvPointVarCorrelationMapper gongkuangList = idxBizPvPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>() .selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>()
.eq("ANALYSIS_GATEWAY_ID", .eq("ANALYSIS_GATEWAY_ID",
...@@ -2148,63 +2125,35 @@ public class CommonServiceImpl { ...@@ -2148,63 +2125,35 @@ public class CommonServiceImpl {
} }
/** public void healthWarningMinuteByFan(String gatewayId) {
* 风电按时刻相关数据插入
*
* @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) { if (!openHealth) {
return; return;
} }
// Calendar calendar = Calendar.getInstance();
Date time = new Date(); Date time = new Date();
time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10); time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00"); time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
logger.info("光伏---------------------健康指数时间----" + time); logger.info("风机---------------------健康指数时间----" + time);
List<IdxBizPvPointProcessVariableClassificationDto> data = idxBizPvPointProcessVariableClassificationMapper // Calendar calendar = Calendar.getInstance();
.getInfluxDBData(); List<IdxBizFanPointProcessVariableClassificationDto> data = idxBizFanPointProcessVariableClassificationMapper
Map<String, List<IdxBizPvPointProcessVariableClassificationDto>> maps = data.stream() .getInfluxDBDataByGatewayId(gatewayId);
.collect(Collectors.groupingBy(IdxBizPvPointProcessVariableClassificationDto::getGatewayId)); // Map<String, List<IdxBizFanPointProcessVariableClassificationDto>> maps = data.stream()
// .collect(Collectors.groupingBy(IdxBizFanPointProcessVariableClassificationDto::getGatewayId));
// BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery(); // BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
// List<QueryBuilder> should = boolMustAll.should(); // List<QueryBuilder> should = boolMustAll.should();
List<IndicatorData> indicatorDataListAll = new LinkedList<>(); // List<IndicatorData> indicatorDataListAll = new LinkedList<>();
for (String s : maps.keySet()) { // for (String s : maps.keySet()) {
// BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); // BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
// String addressids = maps.get(s).stream().map(idxBizPvPointProcessVariableClassificationDto -> "\'" + idxBizPvPointProcessVariableClassificationDto.getIndexAddress() + "\'").collect(Collectors.joining(",")); // List<String> address = maps.get(s).stream().map(IdxBizFanPointProcessVariableClassificationDto::getIndexAddress).collect(Collectors.toList());
List<IndicatorData> indicatorDataList = indicatorDataMapper.selectDataByGatewayIdAndAddress(s); // boolQueryBuilder.must(QueryBuilders.termsQuery("address.keyword", address)).must(QueryBuilders.matchQuery("gatewayId.keyword", 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); // 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() // NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// //过滤条件 // //过滤条件
// .withQuery(boolMustAll); // .withQuery(boolMustAll);
...@@ -2222,27 +2171,48 @@ public class CommonServiceImpl { ...@@ -2222,27 +2171,48 @@ public class CommonServiceImpl {
// } catch (Exception e) { // } catch (Exception e) {
// // TODO: handle exception // // 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() Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(), indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(),
IndicatorData::getValueF)); IndicatorData::getValueF));
HashMap<String, Double> idxBizPvPointProcessVariableClassificationDtoIdValueMap = new HashMap<>(); // 将测点id与值处理成map
for (IdxBizPvPointProcessVariableClassificationDto datum : data) { HashMap<String, Double> idxBizFanPointProcessVariableClassificationDtoIdValueMap = new HashMap<>();
// for (ESEquipments equipment : equipments) { log.info("indicatorDataListAllMap" + JSONObject.toJSONString(indicatorDataListAllMap));
// if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) { log.info("data" + JSONObject.toJSONString(data));
for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
Double currentValue = Double Double currentValue = Double
.valueOf(indicatorDataListAllMap.get(datum.getIndexAddress() + "_" + datum.getGatewayId())); .valueOf(indicatorDataListAllMap.get(datum.getIndexAddress() + "_" + datum.getGatewayId()));
if (!ObjectUtils.isEmpty(currentValue)) { if (!ObjectUtils.isEmpty(currentValue)) {
datum.setCurrentValue(currentValue); datum.setCurrentValue(currentValue);
idxBizPvPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), currentValue); idxBizFanPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), currentValue);
} else { } 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<>(); HashMap<String, Object> requestMap = new HashMap<>();
ArrayList<Object> analysisVariableList = new ArrayList<>(); ArrayList<Object> analysisVariableList = new ArrayList<>();
ArrayList<Object> stdDevList = new ArrayList<>(); ArrayList<Object> stdDevList = new ArrayList<>();
...@@ -2261,51 +2231,51 @@ public class CommonServiceImpl { ...@@ -2261,51 +2231,51 @@ public class CommonServiceImpl {
List<String> ProcessPoint2Id = new ArrayList<>(); List<String> ProcessPoint2Id = new ArrayList<>();
List<String> ProcessPoint3Id = new ArrayList<>(); List<String> ProcessPoint3Id = new ArrayList<>();
List<String> analysisVariableIds = new ArrayList<>(); List<String> analysisVariableIds = new ArrayList<>();
idxBizUhefs.forEach(idxBizPvPointVarCentralValue -> { idxBizUhefs.forEach(idxBizFanPointVarCentralValue -> {
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess1Min())) { if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess1Min())) {
idxBizPvPointVarCentralValue.setProcess1Min(Double.NEGATIVE_INFINITY); idxBizFanPointVarCentralValue.setProcess1Min(Double.NEGATIVE_INFINITY);
} }
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess2Min())) { if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess2Min())) {
idxBizPvPointVarCentralValue.setProcess2Min(Double.NEGATIVE_INFINITY); idxBizFanPointVarCentralValue.setProcess2Min(Double.NEGATIVE_INFINITY);
} }
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess3Min())) { if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess3Min())) {
idxBizPvPointVarCentralValue.setProcess3Min(Double.NEGATIVE_INFINITY); idxBizFanPointVarCentralValue.setProcess3Min(Double.NEGATIVE_INFINITY);
} }
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess1Max())) { if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess1Max())) {
idxBizPvPointVarCentralValue.setProcess1Max(Double.POSITIVE_INFINITY); idxBizFanPointVarCentralValue.setProcess1Max(Double.POSITIVE_INFINITY);
} }
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess2Max())) { if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getPorcess2Max())) {
idxBizPvPointVarCentralValue.setProcess2Max(Double.POSITIVE_INFINITY); idxBizFanPointVarCentralValue.setPorcess2Max(Double.POSITIVE_INFINITY);
} }
if (ObjectUtils.isEmpty(idxBizPvPointVarCentralValue.getProcess3Max())) { if (ObjectUtils.isEmpty(idxBizFanPointVarCentralValue.getProcess3Max())) {
idxBizPvPointVarCentralValue.setProcess3Max(Double.POSITIVE_INFINITY); idxBizFanPointVarCentralValue.setProcess3Max(Double.POSITIVE_INFINITY);
} }
}); });
for (IdxBizPvPointVarCentralValue idxBizUhef : idxBizUhefs) { for (IdxBizFanPointVarCentralValue idxBizUhef : idxBizUhefs) {
double value1 = 0.00; double value1 = 0.00;
double value2 = 0.00; double value2 = 0.00;
double value3 = 0.00; double value3 = 0.00;
double value4 = 0.00; double value4 = 0.00;
// for (IdxBizPvPointProcessVariableClassificationDto datum : data) { // for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
// if (idxBizUhef.getProcessPoint1Id().equals(datum.getSequenceNbr())) { // if (idxBizUhef.getProcessPoint1Id().equals(datum.getSequenceNbr())) {
// value1 = datum.getCurrentValue(); // value1 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// } // }
// if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) { // if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) {
// value2 = datum.getCurrentValue(); // value2 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// } // }
// if (idxBizUhef.getProcessPoint3Id().equals(datum.getSequenceNbr())) { // if (idxBizUhef.getProcessPoint3Id().equals(datum.getSequenceNbr())) {
// value3 = datum.getCurrentValue(); // value3 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// } // }
// if (idxBizUhef.getAnalysisPointId().equals(datum.getSequenceNbr())) { // if (idxBizUhef.getAnalysisPointId().equals(datum.getSequenceNbr())) {
// value4 = datum.getCurrentValue(); // value4 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// } // }
// } // }
value1 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint1Id()); value1 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint1Id());
value2 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint2Id()); value2 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint2Id());
value3 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint3Id()); value3 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint3Id());
value4 = idxBizPvPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getAnalysisPointId()); value4 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getAnalysisPointId());
if (idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max() 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()) { && idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()) {
if (!analysisVariableIdList.contains(idxBizUhef.getAnalysisPointId())) { if (!analysisVariableIdList.contains(idxBizUhef.getAnalysisPointId())) {
analysisVariableList.add(value4); analysisVariableList.add(value4);
...@@ -2328,10 +2298,10 @@ public class CommonServiceImpl { ...@@ -2328,10 +2298,10 @@ public class CommonServiceImpl {
analysisVariableIdList.add(idxBizUhef.getAnalysisPointId()); analysisVariableIdList.add(idxBizUhef.getAnalysisPointId());
analysisVariableId.add(idxBizUhef.getAnalysisPointId()); analysisVariableId.add(idxBizUhef.getAnalysisPointId());
} }
} }
} }
requestMap.put("analysisVariable", analysisVariableList); requestMap.put("analysisVariable", analysisVariableList);
requestMap.put("stdDev", stdDevList); requestMap.put("stdDev", stdDevList);
requestMap.put("centerValue", centerValueList); requestMap.put("centerValue", centerValueList);
...@@ -2348,10 +2318,11 @@ public class CommonServiceImpl { ...@@ -2348,10 +2318,11 @@ public class CommonServiceImpl {
DoubleColumn.create("ProcessPoint3", ProcessPoint3), DoubleColumn.create("ProcessPoint3", ProcessPoint3),
StringColumn.create("analysisVariableId", analysisVariableIds)); StringColumn.create("analysisVariableId", analysisVariableIds));
logger.info( logger.info(
"------------------------------------------开始调用光伏健康指数计算算法开始----------------------------------------"); "------------------------------------------开始调用风机健康指数计算算法开始----------------------------------------");
logger.info("------------------------------------------调用地址:" + baseUrlZSFX); logger.info("------------------------------------------调用地址:" + baseUrlZSFX);
// logger.info("------------------------------------------调用参数:"+JSON.toJSONString(requestMap)); // logger.info("------------------------------------------调用参数:"+JSON.toJSONString(requestMap));
String response = HttpUtil.createPost(baseUrlZSFX).body(JSON.toJSONString(requestMap)).execute().body(); String response = HttpUtil.createPost(baseUrlZSFX).body(JSON.toJSONString(requestMap)).execute().body();
JSONObject jsonObject = JSON.parseObject(response); JSONObject jsonObject = JSON.parseObject(response);
if (jsonObject.containsKey("indexValue")) { if (jsonObject.containsKey("indexValue")) {
JSONArray indexValueArray = jsonObject.getJSONArray("indexValue"); JSONArray indexValueArray = jsonObject.getJSONArray("indexValue");
...@@ -2366,82 +2337,651 @@ public class CommonServiceImpl { ...@@ -2366,82 +2337,651 @@ public class CommonServiceImpl {
DoubleColumn.create("indexValue", indexValue), DoubleColumn.create("scoreValue", scoreValue)); DoubleColumn.create("indexValue", indexValue), DoubleColumn.create("scoreValue", scoreValue));
System.out.println(healthData.print()); System.out.println(healthData.print());
try { try {
healthData.write().csv(new Date().getTime() + "gf.csv"); healthData.write().csv(new Date().getTime() + "fj.csv");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
LambdaQueryWrapper<IdxBizPvPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanPointProcessVariableClassification> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(IdxBizPvPointProcessVariableClassification::getSequenceNbr, jsonArrayToStringList); queryWrapper.in(IdxBizFanPointProcessVariableClassification::getSequenceNbr, jsonArrayToStringList);
List<IdxBizPvPointProcessVariableClassification> list = idxBizPvPointProcessVariableClassificationMapper List<IdxBizFanPointProcessVariableClassification> list = idxBizFanPointProcessVariableClassificationMapper
.selectList(queryWrapper); .selectList(queryWrapper);
List<IdxBizFanHealthIndex> idxBizFanHealthIndexs = new ArrayList<>();
Set<String> stations = list.stream().map(IdxBizPvPointProcessVariableClassification::getStation) Set<String> stations = list.stream().map(IdxBizFanPointProcessVariableClassification::getStation)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点"); query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点");
query.in(IdxBizPvHealthLevel::getStatus, stations); query.in(IdxBizFanHealthLevel::getStatus, stations);
List<IdxBizPvHealthLevel> idxBizFanHealthLevels = idxBizPvHealthLevelMapper.selectList(query); List<IdxBizFanHealthLevel> idxBizFanHealthLevels = idxBizFanHealthLevelMapper.selectList(query);
ArrayList<FanHealthIndex> fanHealthIndices1 = new ArrayList<>();
List<IdxBizPvHealthIndex> idxBizPvHealthIndexs = new ArrayList<>(); for (IdxBizFanPointProcessVariableClassification obj : list) {
ArrayList<PvHealthIndex> fanHealthIndices1 = new ArrayList<>();
for (IdxBizPvPointProcessVariableClassification obj : list) {
for (int i = 0; i < analysisVariableIdArray.size(); i++) { for (int i = 0; i < analysisVariableIdArray.size(); i++) {
if (analysisVariableIdArray.get(i).toString().equals(obj.getSequenceNbr())) { if (analysisVariableIdArray.get(i).toString().equals(obj.getSequenceNbr())) {
IdxBizPvHealthIndex idxBizPvHealthIndex = new IdxBizPvHealthIndex(); IdxBizFanHealthIndex idxBizFanHealthIndex = new IdxBizFanHealthIndex();
BeanUtils.copyProperties(obj, idxBizPvHealthIndex, "sequenceNbr"); BeanUtils.copyProperties(obj, idxBizFanHealthIndex, "sequenceNbr");
// idxBizPvHealthIndex.setSequenceNbr(null);
// 2023年10月30日10点05分 移除原来的判断 无论是否小于0都取绝对值 // 2023年10月30日10点05分 移除原来的判断 无论是否小于0都取绝对值
idxBizPvHealthIndex.setHealthIndex(Math.abs(indexValueArray.getDoubleValue(i))); idxBizFanHealthIndex.setHealthIndex(Math.abs(indexValueArray.getDoubleValue(i)));
idxBizPvHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr()); idxBizFanHealthIndex.setAnalysisObjSeq(obj.getSequenceNbr());
idxBizPvHealthIndex.setRecDate(time); idxBizFanHealthIndex.setRecDate(time);
idxBizPvHealthIndex.setWeigth(1.0); // idxBizFanHealthIndex.setSequenceNbr(null);
idxBizFanHealthIndex.setWeigth(1.0);
// 获取健康指数对应等级 // 获取健康指数对应等级
for (IdxBizFanHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) {
for (IdxBizPvHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit() if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit()
&& indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) { && indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
idxBizPvHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel()); idxBizFanHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
} }
} }
idxBizPvHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName()); idxBizFanHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName());
idxBizPvHealthIndex.setAnalysisObjType("测点"); idxBizFanHealthIndex.setAnalysisObjType("测点");
idxBizPvHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i)); if (ObjectUtils.isEmpty(scoreValueArray.getDoubleValue(i))) {
idxBizPvHealthIndex.setANALYSISTIME(DateUtils.getDateNowString()); System.out.println(JSON.toJSONString(requestMap));
idxBizPvHealthIndexs.add(idxBizPvHealthIndex); idxBizFanHealthIndex.setANOMALY(0.0);
PvHealthIndex pvHealthIndex = new PvHealthIndex();
BeanUtil.copyProperties(idxBizPvHealthIndex, pvHealthIndex); } else {
pvHealthIndex.setWeight(idxBizPvHealthIndex.getWeigth()); idxBizFanHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i));
pvHealthIndex.setAnomaly(idxBizPvHealthIndex.getANOMALY());
pvHealthIndex.setRecDate(DateUtil.now()); }
pvHealthIndex.setArea(idxBizPvHealthIndex.getArae()); idxBizFanHealthIndex.setANALYSISTIME(DateUtils.getDateNowString());
pvHealthIndex.setAnalysisTime(DateUtil.now()); idxBizFanHealthIndexs.add(idxBizFanHealthIndex);
pvHealthIndex.setHealthLevel(idxBizPvHealthIndex.getHealthLevel()); FanHealthIndex fanHealthIndex = new FanHealthIndex();
pvHealthIndex.setKks(idxBizPvHealthIndex.getKks()); BeanUtil.copyProperties(idxBizFanHealthIndex, fanHealthIndex);
pvHealthIndex.setRecDate(format); fanHealthIndex.setWeight(idxBizFanHealthIndex.getWeigth());
pvHealthIndex.setOrgCode(obj.getOrgCode()); fanHealthIndex.setAnomaly(idxBizFanHealthIndex.getANOMALY());
fanHealthIndices1.add(pvHealthIndex); 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); // idxBizFanHealthIndexService.saveBatch(idxBizFanHealthIndexs);
// 按时刻 - 相关数据插入 // 按时刻相关数据插入TDEngine 【异步】
insertPvDataTDEngine(fanHealthIndices1, format, WarningPeriodEnum.MINUTES.getName()); insertFanDataTDEngine(fanHealthIndices1, format, WarningPeriodEnum.MINUTES.getName());
} }
try { try {
// logger.info("--------------------response: " + response); logger.info("--------------------response: " + response);
logger.info( 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); throw new RuntimeException(e);
} }
// healthStatusIndicatorService.healthWarningMinuteGF(calendar, time); // healthStatusIndicatorService.healthWarningMinuteGF(calendar, time);
healthStatusIndicatorService.healthWarningMinuteGF(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; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointVarCorrelationDto; 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.entity.IdxBizFanPointVarCorrelation;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointVarCorrelationMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointVarCorrelationMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizFanPointVarCorrelationService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizFanPointVarCorrelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 服务实现类 * 服务实现类
...@@ -18,6 +25,9 @@ import java.util.List; ...@@ -18,6 +25,9 @@ import java.util.List;
*/ */
@Service @Service
public class IdxBizFanPointVarCorrelationServiceImpl extends BaseService<IdxBizFanPointVarCorrelationDto, IdxBizFanPointVarCorrelation, IdxBizFanPointVarCorrelationMapper> implements IIdxBizFanPointVarCorrelationService { public class IdxBizFanPointVarCorrelationServiceImpl extends BaseService<IdxBizFanPointVarCorrelationDto, IdxBizFanPointVarCorrelation, IdxBizFanPointVarCorrelationMapper> implements IIdxBizFanPointVarCorrelationService {
@Autowired
private IdxBizFanPointVarCorrelationMapper idxBizFanPointVarCorrelationMapper;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -31,4 +41,47 @@ public class IdxBizFanPointVarCorrelationServiceImpl extends BaseService<IdxBizF ...@@ -31,4 +41,47 @@ public class IdxBizFanPointVarCorrelationServiceImpl extends BaseService<IdxBizF
public List<IdxBizFanPointVarCorrelationDto> queryForIdxBizFanPointVarCorrelationList() { public List<IdxBizFanPointVarCorrelationDto> queryForIdxBizFanPointVarCorrelationList() {
return this.queryForList("" , false); 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; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvPointVarCorrelationDto; 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.entity.IdxBizPvPointVarCorrelation;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvPointVarCorrelationMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvPointVarCorrelationMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizPvPointVarCorrelationService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizPvPointVarCorrelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 服务实现类 * 服务实现类
...@@ -18,6 +26,8 @@ import java.util.List; ...@@ -18,6 +26,8 @@ import java.util.List;
*/ */
@Service @Service
public class IdxBizPvPointVarCorrelationServiceImpl extends BaseService<IdxBizPvPointVarCorrelationDto,IdxBizPvPointVarCorrelation,IdxBizPvPointVarCorrelationMapper> implements IIdxBizPvPointVarCorrelationService { public class IdxBizPvPointVarCorrelationServiceImpl extends BaseService<IdxBizPvPointVarCorrelationDto,IdxBizPvPointVarCorrelation,IdxBizPvPointVarCorrelationMapper> implements IIdxBizPvPointVarCorrelationService {
@Autowired
private IdxBizPvPointVarCorrelationMapper idxBizPvPointVarCorrelationMapper;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -31,4 +41,49 @@ public class IdxBizPvPointVarCorrelationServiceImpl extends BaseService<IdxBizPv ...@@ -31,4 +41,49 @@ public class IdxBizPvPointVarCorrelationServiceImpl extends BaseService<IdxBizPv
public List<IdxBizPvPointVarCorrelationDto> queryForIdxBizPvPointVarCorrelationList() { public List<IdxBizPvPointVarCorrelationDto> queryForIdxBizPvPointVarCorrelationList() {
return this.queryForList("" , false); 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> { ...@@ -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}") @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); 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}") @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); List<IndicatorData> selectDataByGatewayIdAndAddressForAlarmInfoDetail(@Param("gatewayId") String gatewayId,@Param("addresses") String addresses,@Param("startTime") String startTime, @Param("endTime") String endTime);
......
...@@ -83,7 +83,89 @@ ...@@ -83,7 +83,89 @@
GROUP BY GROUP BY
b.SEQUENCE_NBR b.SEQUENCE_NBR
</select> </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 id="gateWayIdListFan" resultType="java.lang.String">
select GATEWAY_ID from idx_biz_fan_point_process_variable_classification group by GATEWAY_ID; select GATEWAY_ID from idx_biz_fan_point_process_variable_classification group by GATEWAY_ID;
</select> </select>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointVarCorrelationMapper"> <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> </mapper>
...@@ -88,4 +88,89 @@ ...@@ -88,4 +88,89 @@
GROUP BY GROUP BY
b.SEQUENCE_NBR b.SEQUENCE_NBR
</select> </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> </mapper>
...@@ -2,4 +2,23 @@ ...@@ -2,4 +2,23 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvPointVarCorrelationMapper"> <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> </mapper>
...@@ -4,11 +4,13 @@ import lombok.Data; ...@@ -4,11 +4,13 @@ import lombok.Data;
@Data @Data
public class BuDunGenDto { public class BuDunGenDto {
private Double day; private String station_name;
private Double month; private Double actual_installed_capacity;
private Double year; private Double day;
private Double month_complete; private Double month;
private Double year_complete; private Double year;
private Double year_hour_number; private Double month_complete;
private Double cumulative; private Double year_complete;
private Double year_hour_number;
private Double cumulative;
} }
...@@ -246,10 +246,11 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -246,10 +246,11 @@ public class MonitorServiceImpl implements MonitorService {
@Override @Override
public Map<String, Object> gettimedateqyyfd(String areaName) { 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)); MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("name", areaName));
if (!areaName.contains(Constants.areaChinese)) { 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); List<BundunCompleteDto> bundunCompleteDtoList = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BundunCompleteDto.class);
......
...@@ -39,7 +39,7 @@ public class CoreCommonServiceImpl implements CoreCommonService { ...@@ -39,7 +39,7 @@ public class CoreCommonServiceImpl implements CoreCommonService {
}); });
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
return result; return new ArrayList<>();
} }
return result; return result;
} }
......
...@@ -361,14 +361,14 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -361,14 +361,14 @@ public class MonitorServiceImpl implements MonitorService {
AtomicReference<Double> fdzannualPower = new AtomicReference<>(0.0); AtomicReference<Double> fdzannualPower = new AtomicReference<>(0.0);
AtomicReference<Double> gfzannualPower = new AtomicReference<>(0.0); AtomicReference<Double> gfzannualPower = new AtomicReference<>(0.0);
List<CoreValuesDto> coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null); 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); List<BuDunStationDetailInfo> buDunStationDetailInfos = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BuDunStationDetailInfo.class);
if (buDunStationDetailInfos.size() > 0) { if (buDunStationDetailInfos.size() > 0) {
buDunStationDetailInfos.forEach(buDunStationDetailInfo -> { buDunStationDetailInfos.forEach(buDunStationDetailInfo -> {
CompletionOfPowerIndicatorsDto completionOfPowerIndicatorsDto = new CompletionOfPowerIndicatorsDto(); CompletionOfPowerIndicatorsDto completionOfPowerIndicatorsDto = new CompletionOfPowerIndicatorsDto();
completionOfPowerIndicatorsDto.setStationName(buDunStationDetailInfo.getStation_name()); completionOfPowerIndicatorsDto.setStationName(buDunStationDetailInfo.getStation_name());
completionOfPowerIndicatorsDto.setInstallCapactity(String.valueOf(buDunStationDetailInfo.getActual_installed_capacity())); 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.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, buDunStationDetailInfo.getDay()));
completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, buDunStationDetailInfo.getMonth())); completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, buDunStationDetailInfo.getMonth()));
completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, buDunStationDetailInfo.getYear())); completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, buDunStationDetailInfo.getYear()));
...@@ -487,7 +487,7 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -487,7 +487,7 @@ public class MonitorServiceImpl implements MonitorService {
String requestUrl = Constants.BASE_URL + "?" + Constants.get_area_item_url; String requestUrl = Constants.BASE_URL + "?" + Constants.get_area_item_url;
if (!ObjectUtils.isEmpty(areaName)) { if (!ObjectUtils.isEmpty(areaName)) {
if (!areaName.contains(Constants.areaChinese)) { if (!areaName.contains(Constants.areaChinese)) {
areaName = Constants.areaChinese; areaName =areaName+ Constants.areaChinese;
} }
requestUrl = requestUrl + "&areaName=" + areaName; requestUrl = requestUrl + "&areaName=" + areaName;
} }
...@@ -579,7 +579,7 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -579,7 +579,7 @@ public class MonitorServiceImpl implements MonitorService {
List<HashMap<String, String>> mapList = new ArrayList<>(); List<HashMap<String, String>> mapList = new ArrayList<>();
String requestUrl = Constants.BASE_URL + "?" + Constants.get_month_top_url + "&topValue=5"; String requestUrl = Constants.BASE_URL + "?" + Constants.get_month_top_url + "&topValue=5";
if (!ObjectUtils.isEmpty(areaName)) { if (!ObjectUtils.isEmpty(areaName)) {
if (areaName.contains(Constants.areaChinese)) { if (!areaName.contains(Constants.areaChinese)) {
areaName = areaName + Constants.areaChinese; areaName = areaName + Constants.areaChinese;
} }
requestUrl = requestUrl + "&areaName=" + areaName; requestUrl = requestUrl + "&areaName=" + areaName;
...@@ -646,7 +646,7 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -646,7 +646,7 @@ public class MonitorServiceImpl implements MonitorService {
List<StationBasic> gfdzlist = new ArrayList<>(); List<StationBasic> gfdzlist = new ArrayList<>();
String requestUrl = Constants.BASE_URL + "?" + Constants.get_hours_num_top + "&topValue=3&tabValue=" + tabValue; String requestUrl = Constants.BASE_URL + "?" + Constants.get_hours_num_top + "&topValue=3&tabValue=" + tabValue;
if (!ObjectUtils.isEmpty(areaName)) { if (!ObjectUtils.isEmpty(areaName)) {
if (areaName.contains(Constants.areaChinese)) { if (!areaName.contains(Constants.areaChinese)) {
areaName = areaName + Constants.areaChinese; areaName = areaName + Constants.areaChinese;
} }
requestUrl = requestUrl + "&areaName=" + areaName; 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