Commit a9095a7f authored by caotao's avatar caotao

分析模块需求变更

parent 06bbd582
......@@ -618,26 +618,45 @@ private FanHealthIndexMapper fanHealthIndexMapper;
@ApiOperation(value = "光伏 该装备下各指标预警 - 风站中间 下方列表")
@GetMapping("/getPvSubSystemPointInfo")
public ResponseModel<Page<Map<String, Object>>> getPvSubSystemPointInfo(@RequestParam(value = "equipmentName", required = false) String equipmentName,
@RequestParam(value = "stationId", required = false) String stationId) throws UnsupportedEncodingException {
equipmentName = java.net.URLDecoder.decode(equipmentName,"UTF-8");
@RequestParam(value = "stationId", required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvHealthInfoBySubSystem(equipmentName, stationBasic.getFanGatewayId());
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvWarningInfoBySubSystem(equipmentName, stationBasic.getFanGatewayId());
Map<Object, String> equipmentHealthIndexMap = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("pointName"), t -> t.get("warningName").toString()));
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvHealthInfoBySubSystem(equipmentName, stationBasic.getFanGatewayId());
Map<Object, Double> equipmentHealthIndexMap = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("pointName"), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> pointNameList = idxBizFanHealthIndexMapper.getPvPointNameListBySumSystem(stationBasic.getFanGatewayId(), equipmentName);
pointNameList.forEach(item -> {
String equipmentHealthScore = equipmentHealthIndexMap.getOrDefault(item.get("pointName"), "安全");
Double equipmentHealthScore = equipmentHealthIndexMap.getOrDefault(item.get("pointName"), 100.0);
if (100.0 == equipmentHealthScore) {
item.put("warningName", "安全");
item.put("status", "安全");
} else {
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizFanHealthLevel::getStatus, stationBasic.getStationName());
query.le(IdxBizFanHealthLevel::getGroupLowerLimit, equipmentHealthScore);
query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, equipmentHealthScore);
IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query);
if (ObjectUtils.isEmpty(idxBizFanHealthLevel)) {
item.put("warningName", "安全");
item.put("status", "安全");
} else {
item.put("warningName", idxBizFanHealthLevel.getHealthLevel());
item.put("status", idxBizFanHealthLevel.getHealthLevel());
}
}
int sort = 4;
if ("注意".equals(equipmentHealthScore)) {
if ("注意".equals(item.get("warningName"))) {
sort = 3;
} else if ("警告".equals(equipmentHealthScore)) {
} else if ("警告".equals(item.get("warningName"))) {
sort = 2;
} else if ("危险".equals(equipmentHealthScore)) {
} else if ("危险".equals(item.get("warningName"))) {
sort = 1;
}
item.put("sort", sort);
item.put("warningName", equipmentHealthScore);
item.put("status", equipmentHealthScore);
item.put("healthIndex", equipmentHealthScore);
});
pointNameList.sort(Comparator.comparing(o -> o.get("sort").toString()));
Page<Map<String, Object>> mapPage = new Page<>();
......@@ -645,6 +664,7 @@ private FanHealthIndexMapper fanHealthIndexMapper;
mapPage.setTotal(pointNameList.size());
mapPage.setCurrent(1);
mapPage.setRecords(pointNameList);
return ResponseHelper.buildResponse(mapPage);
}
......
......@@ -18,7 +18,8 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.*;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -58,14 +59,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRuleSetServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRuleSetServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexDayMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
......@@ -719,31 +712,46 @@ public class TDBigScreenAnalyseController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "光伏 该装备下各指标预警 - 风站中间 下方列表")
@GetMapping("/getPvSubSystemPointInfo")
public ResponseModel<Page<Map<String, Object>>> getPvSubSystemPointInfo(
@RequestParam(value = "equipmentName", required = false) String equipmentName,
@RequestParam(value = "stationId", required = false) String stationId) throws UnsupportedEncodingException {
equipmentName = java.net.URLDecoder.decode(equipmentName, "UTF-8");
public ResponseModel<Page<Map<String, Object>>> getPvSubSystemPointInfo(@RequestParam(value = "equipmentName", required = false) String equipmentName,
@RequestParam(value = "stationId", required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvHealthInfoBySubSystem(equipmentName, stationBasic.getFanGatewayId());
List<Map<String, Object>> healthListInfo = fanHealthIndexMapper.getPvWarningInfoBySubSystemTd(equipmentName,
stationBasic.getFanGatewayId());
Map<Object, String> equipmentHealthIndexMap = healthListInfo.stream()
.collect(Collectors.toMap(t -> t.get("pointname"), t -> t.get("warningname").toString()));
List<Map<String, Object>> pointNameList = idxBizFanHealthIndexMapper
.getPvPointNameListBySumSystem(stationBasic.getFanGatewayId(), equipmentName);
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvHealthInfoBySubSystem(equipmentName, stationBasic.getFanGatewayId());
Map<Object, Double> equipmentHealthIndexMap = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("pointName"), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> pointNameList = idxBizFanHealthIndexMapper.getPvPointNameListBySumSystem(stationBasic.getFanGatewayId(), equipmentName);
pointNameList.forEach(item -> {
String equipmentHealthScore = equipmentHealthIndexMap.getOrDefault(item.get("pointName"), "安全");
Double equipmentHealthScore = equipmentHealthIndexMap.getOrDefault(item.get("pointName"), 100.0);
if (100.0 == equipmentHealthScore) {
item.put("warningName", "安全");
item.put("status", "安全");
} else {
LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizPvHealthLevel::getStatus, item.get("station"));
query.le(IdxBizPvHealthLevel::getGroupLowerLimit, equipmentHealthScore);
query.ge(IdxBizPvHealthLevel::getGroupUpperLimit, equipmentHealthScore);
IdxBizPvHealthLevel idxBizFanHealthLevel = idxBizPvHealthLevelMapper.selectOne(query);
if (ObjectUtils.isEmpty(idxBizFanHealthLevel)) {
item.put("warningName", "安全");
item.put("status", "安全");
} else {
item.put("warningName", idxBizFanHealthLevel.getHealthLevel());
item.put("status", idxBizFanHealthLevel.getHealthLevel());
}
}
int sort = 4;
if ("注意".equals(equipmentHealthScore)) {
if ("注意".equals(item.get("warningName"))) {
sort = 3;
} else if ("警告".equals(equipmentHealthScore)) {
} else if ("警告".equals(item.get("warningName"))) {
sort = 2;
} else if ("危险".equals(equipmentHealthScore)) {
} else if ("危险".equals(item.get("warningName"))) {
sort = 1;
}
item.put("sort", sort);
item.put("warningName", equipmentHealthScore);
item.put("status", equipmentHealthScore);
item.put("healthIndex", equipmentHealthScore);
});
pointNameList.sort(Comparator.comparing(o -> o.get("sort").toString()));
Page<Map<String, Object>> mapPage = new Page<>();
......@@ -1311,6 +1319,49 @@ public class TDBigScreenAnalyseController extends BaseController {
return ResponseHelper.buildResponse(resultMap);
}
@Autowired
private PvHealthIndexDayMapper pvHealthIndexDayMapper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风站/光伏 右下实时趋势")
@GetMapping("/getTrendInfoByAddressBy1118Pv")
public ResponseModel<Map<String, Object>> getTrendInfoByAddressBy1118Pv(@RequestParam(value = "indexAddress", required = false) String indexAddress,
@RequestParam(value = "stationId", required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(DateUtils.dateAddDays(new Date(), - 15));
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
LambdaQueryWrapper<PvHealthIndexDay> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(PvHealthIndexDay::getIndexAddress, indexAddress);
lambdaQueryWrapper.eq(PvHealthIndexDay::getGatewayId, stationBasic.getFanGatewayId());
lambdaQueryWrapper.eq(PvHealthIndexDay::getAnalysisObjType, "测点");
lambdaQueryWrapper.le(PvHealthIndexDay::getRecDate, endTime);
lambdaQueryWrapper.ge(PvHealthIndexDay::getRecDate, startTime);
List<PvHealthIndexDay> fanHealthIndexDayList = pvHealthIndexDayMapper.selectList(lambdaQueryWrapper);
// List<IndicatorData> indicatorData = indicatorDataMapper.selectDataByAddressAndtime(indexAddress, startTime, endTime, stationBasic.getFanGatewayId());
HashMap<String, Object> resultMap = new HashMap<>();
List<String> time = new ArrayList<>();
List<Object> valueList = new ArrayList<>();
fanHealthIndexDayList.forEach(item -> {
time.add(item.getRecDate().substring(0, 10));
String format = df.format(item.getHealthIndex());
valueList.add(format);
});
List<Map<String, Object>> arrayList = new ArrayList<>();
HashMap<String, Object> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("data", valueList);
arrayList.add(stringStringHashMap);
resultMap.put("axisData", time);
resultMap.put("seriesData", arrayList);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风站/光伏 右下诊断分析")
@GetMapping("/getRiskHandleByVarDescBy1118")
......@@ -1361,4 +1412,56 @@ public class TDBigScreenAnalyseController extends BaseController {
return ResponseHelper.buildResponse(stringStringHashMap);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风站/光伏 右下诊断分析")
@GetMapping("/getRiskHandleByVarDescBy1118Pv")
public ResponseModel<Map<String, String>> getRiskHandleByVarDescBy1118Pv(
@RequestParam(value = "varDesc", required = false) String varDesc,
@RequestParam(value = "tableName", required = true) String tableName,
@RequestParam(value = "stationId") String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
Map<String, Object> healthIndexMap = idxBizFanHealthIndexMapper.getHealthIndexByIndexAddressPv(stationBasic.getFanGatewayId(), varDesc);
if (ObjectUtils.isEmpty(healthIndexMap)) {
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("content", "正常运行");
return ResponseHelper.buildResponse(stringStringHashMap);
}
LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizPvHealthLevel::getStatus, healthIndexMap.get("station"));
query.le(IdxBizPvHealthLevel::getGroupLowerLimit, healthIndexMap.get("healthIndex"));
query.ge(IdxBizPvHealthLevel::getGroupUpperLimit, healthIndexMap.get("healthIndex"));
IdxBizPvHealthLevel idxBizFanHealthLevel = idxBizPvHealthLevelMapper.selectOne(query);
if (ObjectUtils.isNotEmpty(idxBizFanHealthLevel) && "安全".equals(idxBizFanHealthLevel.getHealthLevel())) {
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("content", "正常运行");
return ResponseHelper.buildResponse(stringStringHashMap);
}
varDesc = idxBizFanHealthIndexMapper.getPointNameByIndexAddress(varDesc, tableName,
stationBasic.getFanGatewayId());
FeignClientResult<List<String>> sevenEntityMcb = null;
try {
sevenEntityMcb = riskWarningFeign.getRiskHandleByVarDesc(varDesc);
} catch (Exception e) {
e.printStackTrace();
}
if (ObjectUtils.isEmpty(sevenEntityMcb) || sevenEntityMcb.getStatus() != 200) {
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("content", "正常运行");
return ResponseHelper.buildResponse(stringStringHashMap);
}
StringBuilder resultString = new StringBuilder();
List<String> result = sevenEntityMcb.getResult();
for (String s : result) {
resultString.append(s);
}
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("content", resultString.toString());
return ResponseHelper.buildResponse(stringStringHashMap);
}
}
......@@ -162,4 +162,6 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
String endTimeTop);
Map<String, Object> getHealthIndexByIndexAddress(@Param("gatewayId") String gatewayId, @Param("indexAddress") String indexAddress);
Map<String, Object> getHealthIndexByIndexAddressPv(@Param("gatewayId") String gatewayId, @Param("indexAddress") String indexAddress);
}
......@@ -644,14 +644,13 @@
</select>
<select id="getPvHealthInfoBySubSystem" resultType="java.util.Map">
SELECT
IFNULL( ROUND(avg( HEALTH_INDEX ), 2), 0 ) AS healthIndex,
IFNULL(HEALTH_INDEX, 100) AS healthIndex,
POINT_NAME AS pointName
FROM
idx_biz_pv_health_index
pv_health_index_latest_data
<where>
ANALYSIS_OBJ_TYPE = '测点'
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE
AND POINT_NAME IS NOT NULL
AND POINT_NAME != ''
<if test="equipmentName != null and equipmentName != ''">
......@@ -1643,5 +1642,18 @@
and GATEWAY_ID = #{gatewayId}
and ANALYSIS_OBJ_TYPE = '测点'
and ANALYSIS_TYPE = '按天'
limit 1
</select>
<select id="getHealthIndexByIndexAddressPv" resultType="java.util.Map">
select ROUND(ifnull(HEALTH_INDEX, 100.0), 1) as healthIndex,
STATION as station
from pv_health_index_latest_data
where
INDEX_ADDRESS = #{indexAddress}
and GATEWAY_ID = #{gatewayId}
and ANALYSIS_OBJ_TYPE = '测点'
and ANALYSIS_TYPE = '按天'
limit 1
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment