Commit cfd3c83e authored by zhangsen's avatar zhangsen

修改 td

parent a61072d4
...@@ -51,6 +51,8 @@ import java.text.SimpleDateFormat; ...@@ -51,6 +51,8 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.yeejoin.amos.boot.biz.common.utils.DateUtils.DATE_TIME_PATTERN;
@RestController @RestController
@Api(tags = "智能分析 - 大屏API") @Api(tags = "智能分析 - 大屏API")
@RequestMapping(value = "/tdBigScreenAnalyse") @RequestMapping(value = "/tdBigScreenAnalyse")
...@@ -111,7 +113,7 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -111,7 +113,7 @@ public class TDBigScreenAnalyseController extends BaseController {
stringBigDecimalHashMap.put("value", Integer.valueOf(idxBizFanHealthIndexMapper.getHealthScoreInfoByStation(stationCode, tableName).toString().replace(".0", ""))); stringBigDecimalHashMap.put("value", Integer.valueOf(idxBizFanHealthIndexMapper.getHealthScoreInfoByStation(stationCode, tableName).toString().replace(".0", "")));
return ResponseHelper.buildResponse(stringBigDecimalHashMap); return ResponseHelper.buildResponse(stringBigDecimalHashMap);
} }
stringBigDecimalHashMap.put("value", Integer.valueOf(idxBizFanHealthIndexMapper.getHealthScoreInfo(areaCode, stationCode).toString().replace(".0", ""))); stringBigDecimalHashMap.put("value", Integer.valueOf(idxBizFanHealthIndexMapper.getHealthScoreInfoByLatest(areaCode, stationCode).toString().replace(".0", "")));
return ResponseHelper.buildResponse(stringBigDecimalHashMap); return ResponseHelper.buildResponse(stringBigDecimalHashMap);
} }
...@@ -354,11 +356,11 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -354,11 +356,11 @@ public class TDBigScreenAnalyseController extends BaseController {
@ApiOperation(value = "场站预警信息统计图 - 雷达图", httpMethod = "GET") @ApiOperation(value = "场站预警信息统计图 - 雷达图", httpMethod = "GET")
@GetMapping("/equipWarningRadarMap") @GetMapping("/equipWarningRadarMap")
public ResponseModel<Map<String, Object>> assessIndexRadarMap(@RequestParam(required = false, value = "stationCode") String stationCode) { public ResponseModel<Map<String, Object>> assessIndexRadarMap(@RequestParam(required = false, value = "stationCode") String stationCode) {
if (StrUtil.isNotEmpty(stationCode)) { if (CharSequenceUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode); StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
stationCode = stationBasic.getFanGatewayId(); stationCode = stationBasic.getFanGatewayId();
} }
List<Map<String, Object>> list = idxBizFanHealthIndexMapper.equipWarningRadarMap(stationCode); List<Map<String, Object>> list = idxBizFanHealthIndexMapper.equipWarningRadarMapByTd(stationCode);
Map<String, Integer> warningNumMap = list.stream().collect(Collectors.toMap(t -> t.get("warningName").toString(), t -> Integer.parseInt(t.get("num").toString()))); Map<String, Integer> warningNumMap = list.stream().collect(Collectors.toMap(t -> t.get("warningName").toString(), t -> Integer.parseInt(t.get("num").toString())));
List<String> warningList = Arrays.asList("危险", "注意", "警告"); List<String> warningList = Arrays.asList("危险", "注意", "警告");
List<Integer> data = new ArrayList<>(); List<Integer> data = new ArrayList<>();
...@@ -532,7 +534,7 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -532,7 +534,7 @@ public class TDBigScreenAnalyseController extends BaseController {
subSystem = java.net.URLDecoder.decode(subSystem,"UTF-8"); subSystem = java.net.URLDecoder.decode(subSystem,"UTF-8");
StationBasic stationBasic = stationBasicMapper.selectById(stationId); StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getHealthInfoBySubSystem(subSystem, stationBasic.getFanGatewayId()); // List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getHealthInfoBySubSystem(subSystem, stationBasic.getFanGatewayId());
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getWarningInfoBySubSystem(subSystem, stationBasic.getFanGatewayId()); List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getWarningInfoBySubSystemTd(subSystem, stationBasic.getFanGatewayId());
Map<Object, String> equipmentHealthIndexMap = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("pointName"), t -> t.get("warningName").toString())); Map<Object, String> equipmentHealthIndexMap = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("pointName"), t -> t.get("warningName").toString()));
List<Map<String, Object>> pointNameList = idxBizFanHealthIndexMapper.getPointNameListBySumSystem(stationBasic.getFanGatewayId(), subSystem); List<Map<String, Object>> pointNameList = idxBizFanHealthIndexMapper.getPointNameListBySumSystem(stationBasic.getFanGatewayId(), subSystem);
pointNameList.forEach(item -> { pointNameList.forEach(item -> {
...@@ -669,13 +671,16 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -669,13 +671,16 @@ public class TDBigScreenAnalyseController extends BaseController {
public ResponseModel<Map<String, Object>> getTrendInfoByAddress(@RequestParam(value = "indexAddress", required = false) String indexAddress, public ResponseModel<Map<String, Object>> getTrendInfoByAddress(@RequestParam(value = "indexAddress", required = false) String indexAddress,
@RequestParam(value = "stationId", required = false) String stationId, @RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "tableName", required = false) String tableName, @RequestParam(value = "tableName", required = false) String tableName,
@RequestParam(value = "tableName2", required = false) String tableName2) { @RequestParam(value = "tableName2", required = false) String tableName2) throws ParseException {
StationBasic stationBasic = stationBasicMapper.selectById(stationId); StationBasic stationBasic = stationBasicMapper.selectById(stationId);
List<Map<String, Object>> resultListData = new ArrayList<>(); List<Map<String, Object>> resultListData = new ArrayList<>();
String recDate = idxBizFanHealthIndexMapper.getRecDateByIndexAddress(stationBasic.getFanGatewayId(), indexAddress, tableName); String recDate = idxBizFanHealthIndexMapper.getRecDateByIndexAddressTs(stationBasic.getFanGatewayId(), indexAddress, tableName);
if (CharSequenceUtil.isNotEmpty(recDate)) { if (CharSequenceUtil.isNotEmpty(recDate)) {
resultListData = idxBizFanHealthIndexMapper.getInfoListByTableName(stationBasic.getFanGatewayId(), indexAddress, tableName2, recDate); Date date = DateUtils.dateParse(recDate, DATE_TIME_PATTERN);
String datejian8 = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN);
String datejian20 = DateUtils.dateFormat(DateUtils.dateAddHours(date, -20), DATE_TIME_PATTERN);
resultListData = idxBizFanHealthIndexMapper.getInfoListByTableNameTs(stationBasic.getFanGatewayId(), indexAddress, tableName2, datejian8, datejian20);
} }
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
List<String> time = new ArrayList<>(); List<String> time = new ArrayList<>();
...@@ -683,7 +688,7 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -683,7 +688,7 @@ public class TDBigScreenAnalyseController extends BaseController {
resultListData.forEach(item -> { resultListData.forEach(item -> {
String date = ""; String date = "";
try { try {
date = DateUtils.convertDateToString(DateUtils.dateParse(item.get("REC_DATE").toString(), DateUtils.DATE_TIME_PATTERN), "MM-dd HH:mm:ss"); date = DateUtils.convertDateToString(DateUtils.dateParse(item.get("rec_date").toString(), DateUtils.DATE_TIME_PATTERN), "MM-dd HH:mm:ss");
} catch (ParseException e) { } catch (ParseException e) {
} }
time.add(date); time.add(date);
......
...@@ -22,6 +22,7 @@ import java.util.Map; ...@@ -22,6 +22,7 @@ import java.util.Map;
public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIndex> { public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIndex> {
BigDecimal getHealthScoreInfo(@Param("areaCode") String areaCode, @Param("stationCode") String stationCode); BigDecimal getHealthScoreInfo(@Param("areaCode") String areaCode, @Param("stationCode") String stationCode);
BigDecimal getHealthScoreInfoByLatest(@Param("areaCode") String areaCode, @Param("stationCode") String stationCode);
BigDecimal getHealthScoreInfoByStation(@Param("stationCode") String stationCode, @Param("tableName") String tableName); BigDecimal getHealthScoreInfoByStation(@Param("stationCode") String stationCode, @Param("tableName") String tableName);
...@@ -41,6 +42,8 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn ...@@ -41,6 +42,8 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
List<Map<String, Object>> equipWarningRadarMap(@Param("stationCode") String stationCode); List<Map<String, Object>> equipWarningRadarMap(@Param("stationCode") String stationCode);
List<Map<String, Object>> equipWarningRadarMapByTd(@Param("stationCode") String stationCode);
List<Map<String, Object>> getAllEquipAlarmInfoAnalysisByStationType(@Param("tableName") String tableName, List<Map<String, Object>> getAllEquipAlarmInfoAnalysisByStationType(@Param("tableName") String tableName,
@Param("areaCode") String areaCode, @Param("areaCode") String areaCode,
@Param("stationType") String stationType); @Param("stationType") String stationType);
...@@ -62,6 +65,7 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn ...@@ -62,6 +65,7 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
List<Map<String, Object>> getWarningInfoBySubSystem(@Param("subSystem") String subSystem, @Param("gatewayId") String gatewayId); List<Map<String, Object>> getWarningInfoBySubSystem(@Param("subSystem") String subSystem, @Param("gatewayId") String gatewayId);
List<Map<String, Object>> getWarningInfoBySubSystemTd(@Param("subSystem") String subSystem, @Param("gatewayId") String gatewayId);
...@@ -137,11 +141,20 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn ...@@ -137,11 +141,20 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
String getRecDateByIndexAddress(@Param("fanGatewayId") String fanGatewayId, @Param("indexAddress") String indexAddress, @Param("tableName") String tableName); String getRecDateByIndexAddress(@Param("fanGatewayId") String fanGatewayId, @Param("indexAddress") String indexAddress, @Param("tableName") String tableName);
String getRecDateByIndexAddressTs(@Param("fanGatewayId") String fanGatewayId, @Param("indexAddress") String indexAddress, @Param("tableName") String tableName);
List<Map<String, Object>> getInfoListByTableName(@Param("fanGatewayId") String fanGatewayId, List<Map<String, Object>> getInfoListByTableName(@Param("fanGatewayId") String fanGatewayId,
@Param("indexAddress") String indexAddress, @Param("indexAddress") String indexAddress,
@Param("tableName") String tableName, @Param("tableName") String tableName,
@Param("recDate") String recDate); @Param("recDate") String recDate);
List<Map<String, Object>> getInfoListByTableNameTs(@Param("fanGatewayId") String fanGatewayId,
@Param("indexAddress") String indexAddress,
@Param("tableName") String tableName,
@Param("recDate") String recDate,
@Param("date12") String date12);
int getIsWarningByPointId(@Param("indexAddress") String indexAddress, @Param("fanGatewayId") String fanGatewayId, @Param("tableName") String tableName); int getIsWarningByPointId(@Param("indexAddress") String indexAddress, @Param("fanGatewayId") String fanGatewayId, @Param("tableName") String tableName);
List<Map<String,Object>> queryIndexByArae(String ARAE, String ANALYSISTYPE,String startTimeTop,String endTimeTop); List<Map<String,Object>> queryIndexByArae(String ARAE, String ANALYSISTYPE,String startTimeTop,String endTimeTop);
......
...@@ -458,7 +458,7 @@ ...@@ -458,7 +458,7 @@
CEILING(IFNULL( HEALTH_INDEX, 100 )) AS healthIndex, CEILING(IFNULL( HEALTH_INDEX, 100 )) AS healthIndex,
SUB_SYSTEM AS subSystem SUB_SYSTEM AS subSystem
FROM FROM
idx_biz_fan_health_index fan_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '子系统' ANALYSIS_OBJ_TYPE = '子系统'
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
...@@ -497,7 +497,7 @@ ...@@ -497,7 +497,7 @@
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex, IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex,
EQUIPMENT_NAME as equipmentName EQUIPMENT_NAME as equipmentName
FROM FROM
idx_biz_fan_health_index fan_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '设备' ANALYSIS_OBJ_TYPE = '设备'
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
...@@ -1616,6 +1616,139 @@ ...@@ -1616,6 +1616,139 @@
GROUP BY REC_DATE GROUP BY REC_DATE
</select> </select>
<select id="getHealthScoreInfoByLatest" resultType="java.math.BigDecimal">
SELECT
CEILING(avg( a.avgHealthIndex )) AS healthIndex
FROM
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM
fan_health_index_latest_data
<where>
ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE
<if test="areaCode != null and areaCode != ''">
AND ARAE like concat('%', #{areaCode}, '%')
AND ANALYSIS_OBJ_TYPE = '片区'
</if>
<if test="stationCode != null and stationCode != ''">
AND GATEWAY_ID = #{stationCode}
AND ANALYSIS_OBJ_TYPE = '场站'
</if>
<if test="(stationCode == null or stationCode == '') and (areaCode == null or areaCode == '')">
AND ANALYSIS_OBJ_TYPE = '片区'
</if>
</where>
UNION ALL
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM
pv_health_index_latest_data
<where>
ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE
<if test="areaCode != null and areaCode != ''">
AND ARAE like concat('%', #{areaCode}, '%')
AND ANALYSIS_OBJ_TYPE = '片区'
</if>
<if test="stationCode != null and stationCode != ''">
AND GATEWAY_ID = #{stationCode}
AND ANALYSIS_OBJ_TYPE = '场站'
</if>
<if test="(stationCode == null or stationCode == '') and (areaCode == null or areaCode == '')">
AND ANALYSIS_OBJ_TYPE = '片区'
</if>
</where>
)
) a
</select>
<select id="equipWarningRadarMapByTd" resultType="java.util.Map">
select
a.warningName,
count(1) as num
from
(
select
warning_name as warningName
from
analysis_data.fan_warning_record
<where>
((disposotion_state = '未处置')
or (disposotion_state = '已处置'
and ts > now - 3d - 8h))
<if test="stationCode != null and stationCode != ''">
and gateway_id = #{stationCode}
</if>
</where>
union all
(select
warning_name as warningName
from
analysis_data.pv_warning_record
<where>((disposotion_state = '未处置')
or (
disposotion_state = '已处置'
and ts > now - 3d - 8h ))
<if test="stationCode != null and stationCode != ''">
and gateway_id = #{stationCode}
</if>
</where>)
) a
group by
a.warningName
</select>
<select id="getWarningInfoBySubSystemTd" resultType="java.util.Map">
SELECT
point_name as pointName,
warning_name as warningName,
last(ts)
FROM
fan_warning_record
<where>
disposotion_state = '未处置'
<if test="subSystem != null and subSystem != ''">
AND sub_system = #{subSystem}
</if>
<if test="gatewayId != null and gatewayId != ''">
AND gateway_id = #{gatewayId}
</if>
</where>
group by point_name
</select>
<select id="getRecDateByIndexAddressTs" resultType="java.lang.String">
SELECT
rec_date
FROM
${tableName}
WHERE
index_address = #{indexAddress}
AND disposotion_state = '未处置'
and gateway_id = #{fanGatewayId}
ORDER BY
ts DESC
LIMIT 1
</select>
<select id="getInfoListByTableNameTs" resultType="java.util.Map">
SELECT
*,
CEIL(health_index) as healthIndex
FROM
${tableName}
WHERE
#{recDate} >= ts
AND ts >= #{date12}
AND analysis_type = '按时刻'
AND index_address = #{indexAddress}
AND gateway_id = #{fanGatewayId}
</select>
</mapper> </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