Commit 311e47c6 authored by 高建强's avatar 高建强

item:新增系统近一周告警趋势图接口

parent 74235268
package com.yeejoin.equipmanage.common.vo;
import lombok.Data;
@Data
public class EquipAlarmLineVo {
private String date;
private String indexName;
private String indexKey;
private Integer total;
private Integer index;
}
......@@ -74,4 +74,26 @@ public class ConfigureController extends AbstractBaseController {
return CommonResponseUtil.success(equipmentSpecificAlarmService.equipStatusCount(hashMap));
}
@RequestMapping(value = "/equipAlarmLine", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "系统近一周告警趋势图", produces = "application/json;charset=UTF-8", notes = "系统近一周告警趋势图")
public ResponseModel equipStatusCount(@RequestParam(required = false) String systemCode, @RequestParam(required = false) String indexKeys) {
HashMap<String, Object> hashMap = new HashMap<>();
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
String bizOrgCode = personIdentity.getBizOrgCode();
if (StringUtils.isNotBlank(bizOrgCode)) {
hashMap.put("bizOrgCode", bizOrgCode);
}
}
if (StringUtils.isNotBlank(systemCode)) {
hashMap.put("systemCode", systemCode);
}
if (StringUtils.isNotBlank(indexKeys)) {
hashMap.put("indexKeys", indexKeys.split(","));
}
return CommonResponseUtil.success(equipmentSpecificAlarmService.equipAlarmLine(hashMap));
}
}
......@@ -10,6 +10,7 @@ import com.yeejoin.equipmanage.common.entity.dto.AlarmDTO;
import com.yeejoin.equipmanage.common.entity.dto.EquipSpecificAlarmDTO;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentIotAlarmVO;
import com.yeejoin.equipmanage.common.utils.CommonPageInfoParam;
import com.yeejoin.equipmanage.common.vo.EquipAlarmLineVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -199,4 +200,11 @@ public interface EquipmentSpecificAlarmMapper extends BaseMapper<EquipmentSpecif
int selectCountByIotCode(@Param("iotCode") String iotCode, @Param("indexKey") String indexKey, @Param("indexValue") String indexValue);
List<Map<String, Object>> equipStatusCount(HashMap<String, Object> hashMap);
/**
* 近一周告警趋势
* @param hashMap
* @return
*/
List<EquipAlarmLineVo> equipAlarmLine(HashMap<String, Object> hashMap);
}
......@@ -85,4 +85,6 @@ public interface IEquipmentSpecificAlarmService extends IService<EquipmentSpecif
List<EquipmentSpecificAlarm> getEquipListBySpecific(Boolean status, Long equipmentSpecificId);
LinkedList<Map<String, Object>> equipStatusCount(HashMap<String, Object> hashMap);
Map<String, Object> equipAlarmLine(HashMap<java.lang.String,java.lang.Object> hashMap);
}
......@@ -23,6 +23,7 @@ import com.yeejoin.equipmanage.common.vo.*;
import com.yeejoin.equipmanage.fegin.JcsFeign;
import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.service.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageImpl;
......@@ -42,6 +43,7 @@ import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author DELL
......@@ -98,8 +100,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
if (0 == list.size()) {
throw new RuntimeException("导出数据列表无数据!");
}
ExcelUtil.createTemplate(response, "设备告警信息", "设备告警信息", equipmentDownloads, EquipmentAlarmDownloadVO.class, null,
false);
ExcelUtil.createTemplate(response, "设备告警信息", "设备告警信息", equipmentDownloads, EquipmentAlarmDownloadVO.class, null, false);
}
......@@ -126,8 +127,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
alarmDownloadVO.setHandleType("");
} else {
String handleType = ConfirmAlamEnum.getTypeByCode(String.valueOf(alarm.get("handleType")));
alarmDownloadVO.setHandleType(StringUtil.isNotEmpty(handleType)
? handleType : signalClassifyService.getTypeNameByCode(String.valueOf(alarm.get("handleType"))).getTypeName());
alarmDownloadVO.setHandleType(StringUtil.isNotEmpty(handleType) ? handleType : signalClassifyService.getTypeNameByCode(String.valueOf(alarm.get("handleType"))).getTypeName());
}
alarmDownloadVO.setResolveResult(StringUtil.isNotEmpty(alarm.get("resolveResult")) ? alarm.get("resolveResult").toString() : "");
alarmDownloadVO.setConfirmDate(StringUtil.isNotEmpty(alarm.get("confirmDate")) ? alarm.get("confirmDate").toString().replace("T", " ") : "");
......@@ -158,8 +158,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
alarmDownloadVO.setHandleType("");
} else {
String handleType = ConfirmAlamEnum.getTypeByCode(String.valueOf(alarm.get("handleType")));
alarmDownloadVO.setHandleType(StringUtil.isNotEmpty(handleType)
? handleType : signalClassifyService.getTypeNameByCode(String.valueOf(alarm.get("handleType"))).getTypeName());
alarmDownloadVO.setHandleType(StringUtil.isNotEmpty(handleType) ? handleType : signalClassifyService.getTypeNameByCode(String.valueOf(alarm.get("handleType"))).getTypeName());
}
alarmDownloadVO.setResolveResult(StringUtil.isNotEmpty(alarm.get("resolveResult")) ? alarm.get("resolveResult").toString() : "");
alarmDownloadVO.setConfirmDate(StringUtil.isNotEmpty(alarm.get("confirmDate")) ? alarm.get("confirmDate").toString().replace("T", " ") : "");
......@@ -189,8 +188,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
x.put("handleType", null);
} else {
String handleType = ConfirmAlamEnum.getTypeByCode(String.valueOf(x.get("handleType")));
x.put("handleType", StringUtil.isNotEmpty(handleType)
? handleType : signalClassifyService.getTypeNameByCode(String.valueOf(x.get("handleType"))).getTypeName());
x.put("handleType", StringUtil.isNotEmpty(handleType) ? handleType : signalClassifyService.getTypeNameByCode(String.valueOf(x.get("handleType"))).getTypeName());
}
// 冗余统一跑马灯显示字段取值
x.put("equipmentSpecificIndexName", x.get("fireEquipmentSpecificIndexName"));
......@@ -262,8 +260,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
dataVO.setHandleStatus(StringUtil.toString(x.get("handleStatus")));
dataVO.setStatus(StringUtil.toString(x.get("status")));
Object type = x.get("type");
if (AlarmTypeEnum.HZGJ.getCode().equals(type) || AlarmTypeEnum.GZGJ.getCode().equals(type)
|| AlarmTypeEnum.PB.getCode().equals(type)) {
if (AlarmTypeEnum.HZGJ.getCode().equals(type) || AlarmTypeEnum.GZGJ.getCode().equals(type) || AlarmTypeEnum.PB.getCode().equals(type)) {
dataVO.setAlarmType(AlarmTypeEnum.getTypeByCode(String.valueOf(type)));
}
dataVO.setAlarmContent(String.valueOf(x.get("alamContent")));
......@@ -649,8 +646,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
}
@Override
public List<EquipmentSpecificAlarm> getEquipListBySpecific(Boolean status,
Long equipmentSpecificId) {
public List<EquipmentSpecificAlarm> getEquipListBySpecific(Boolean status, Long equipmentSpecificId) {
return equipmentSpecificAlarmMapper.getEquipListBySpecific(status, equipmentSpecificId);
}
......@@ -668,4 +664,43 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
return linkedList;
}
@Override
public Map<String, Object> equipAlarmLine(HashMap<String, Object> hashMap) {
Map<String, Object> resultMap = new HashMap<>();
List<EquipAlarmLineVo> list = equipmentSpecificAlarmMapper.equipAlarmLine(hashMap);
if (!CollectionUtils.isEmpty(list)) {
LinkedHashSet<String> xAxis = new LinkedHashSet<>();
LinkedHashMap<String, Object> yAxis = new LinkedHashMap<>();
// 取出所有非空indexName
Set<Object> indexKNameSet = list.stream().map(EquipAlarmLineVo::getIndexName).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
Map<String, List<EquipAlarmLineVo>> dateCollect = list.stream().collect(Collectors.groupingBy(EquipAlarmLineVo::getDate));
// 迭代器倒序遍历map
ListIterator<Map.Entry<String, List<EquipAlarmLineVo>>> i = new ArrayList<Map.Entry<String, List<EquipAlarmLineVo>>>(dateCollect.entrySet()).listIterator(dateCollect.size());
while (i.hasPrevious()) {
LinkedList<Object> yData = new LinkedList<>();
Map.Entry<String, List<EquipAlarmLineVo>> entry = i.previous();
String key = entry.getKey();
List<EquipAlarmLineVo> value = entry.getValue();
for (EquipAlarmLineVo vo : value) {
String indexName = vo.getIndexName();
if (indexKNameSet.contains(indexName)) {
yData.add(vo.getTotal());
} else {
yData.add(0);
}
}
yAxis.put(key, yData);
xAxis.add(key);
}
resultMap.put("legend", indexKNameSet);
resultMap.put("xAxis", xAxis);
resultMap.put("yAxis", yAxis);
}
return resultMap;
}
}
......@@ -1173,4 +1173,71 @@
</if>
</where>
</select>
<select id="equipAlarmLine" parameterType="java.util.HashMap" resultType="com.yeejoin.equipmanage.common.vo.EquipAlarmLineVo">
SELECT
s.`index`,
s.date,
IFNULL(s1.equipment_specific_index_name,'') AS indexName,
IFNULL(s1.equipment_specific_index_key,'') AS `indexKey`,
IFNULL(s1.`total`,0) AS total
FROM
(
SELECT
( @s := @s + 1 ) + 1 AS `index`,
DATE( DATE_SUB( CURRENT_DATE, INTERVAL @s DAY ) ) AS date
FROM
mysql.help_topic,
( SELECT @s := - 1 ) temp
WHERE
@s &lt; 6
) s
LEFT JOIN (
SELECT
t.equipment_specific_index_name,
t.equipment_specific_index_key,
t.`total`,
t.date
FROM
(
SELECT
wlesa.equipment_specific_id,
wlesa.equipment_specific_index_name,
wlesa.equipment_specific_index_key,
COUNT( DISTINCT wlesa.equipment_specific_id ) AS `total`,
LEFT ( wlesa.create_date, 10 ) AS date
FROM
`wl_equipment_specific_alarm_log` `wlesa`
LEFT JOIN `wl_equipment_specific` `wles` ON `wlesa`.`equipment_specific_id` = `wles`.`id`
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, wles.system_id )
<where>
DATE_SUB( CURDATE( ), INTERVAL 7 DAY ) &lt;= date( wlesa.create_date )
AND wlesa.equipment_specific_index_value = 'true'
<if test="systemCode != null and systemCode != ''">
AND fs.code = #{systemCode}
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wles.biz_org_code like concat (#{bizOrgCode},'%')
</if>
<if test="indexKeys != null and indexKeys.length >0">
AND wlesa.equipment_specific_index_key IN
<foreach collection="indexKeys" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
GROUP BY
wlesa.equipment_specific_id,
wlesa.equipment_specific_index_key,
LEFT ( wlesa.create_date, 10 )
) t
GROUP BY
t.equipment_specific_index_key,
t.date
) s1 ON s.date = s1.date
GROUP BY
s.date,
s1.equipment_specific_index_key
ORDER BY
s.date
</select>
</mapper>
\ No newline at end of file
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