Commit 1a0b59bf authored by litengwei's avatar litengwei

任务 24814 设备告警列表导出接口

parent bbbe8331
......@@ -82,6 +82,6 @@
FROM
asf_fire_equipment_signal_log
WHERE
FIND_IN_SET(#{mrid,jdbcType=VARCHAR}, system_mrids)
_IN_SET(#{mrid,jdbcType=VARCHAR}, system_mrids)
</select>
</mapper>
package com.yeejoin.equipmanage.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.equipmanage.common.entity.Alarm;
import com.yeejoin.equipmanage.common.utils.NameUtils;
import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.service.IAlarmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import liquibase.pro.packaged.O;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
......@@ -34,6 +44,9 @@ public class AlarmController {
@Autowired
IAlarmService iAlarmService;
@Autowired
RedisUtils redisUtils;
/**
* 新增
*
......@@ -136,13 +149,39 @@ public class AlarmController {
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.GET)
@PersonIdentify
@RequestMapping(value = "/totalAlarmNum", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "修改", notes = "修改")
public ResponseModel<Map<String, Object>> updateByIdAlarm(String bizOrgCode, String systemId) {
ResponseModel responseModel = new ResponseModel();
// responseModel.setResult();
@ApiOperation(httpMethod = "GET", value = "设备平台告警数量统计,按系统", notes = "设备平台告警数量统计,按系统")
public ResponseModel<Object> totalAlarmNum(String bizOrgCode, String systemId) {
if(StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
bizOrgCode = reginParams.getPersonIdentity().getBizOrgCode();
}
return ResponseHelper.buildResponse(iAlarmService.totalNum(bizOrgCode, systemId));
}
return iAlarmService.updateById(alarm);
/**
* 设备告警信息导出
*
* @return
*/
@RequestMapping(value = "/downList", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "告警信息导出", notes = "告警信息导出")
public void downList(HttpServletResponse response, @RequestParam(required = false) List<String> types,
@RequestParam(required = false) List<String> emergencyLevels,
@RequestParam(required = false) String name,
@RequestParam(required = false) Integer cleanStatus,
@RequestParam(required = false) Integer handleStatus,
@RequestParam(required = false) String bizOrgCode,
@RequestParam(required = false) String systemCode,
@RequestParam(required = false) String createDate,
@RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate ) {
iAlarmService.downList(response,bizOrgCode, systemCode, types, emergencyLevels, name, cleanStatus, handleStatus, createDate, startDate, endDate);
}
}
package com.yeejoin.equipmanage.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class AlarmExportDto {
@ExcelProperty(value = "设备名称", index = 0)
private String equipmentSpecificName;
@ExcelProperty(value = "类型", index = 1)
private String type;
@ExcelProperty(value = "等级", index = 2)
private String emergencyLevelDescribe;
@ExcelProperty(value = "消除状态", index = 3)
private String cleanStatus;
@ExcelProperty(value = "时间", index = 4)
private String createDate;
@ExcelProperty(value = "所在位置", index = 5)
private String location;
@ExcelProperty(value = "告警确认", index = 6)
private String handleStatus;
}
......@@ -2,6 +2,10 @@ package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.equipmanage.common.entity.Alarm;
import liquibase.pro.packaged.S;
import java.util.List;
import java.util.Map;
/**
* Mapper 接口
......@@ -11,4 +15,5 @@ import com.yeejoin.equipmanage.common.entity.Alarm;
*/
public interface AlarmMapper extends BaseMapper<Alarm> {
List<Map<String,String>> totalNum(String bizOrgCode, String systemId);
}
......@@ -109,6 +109,8 @@ public interface EmergencyMapper extends BaseMapper{
*/
Page<Map<String, Object>> alarmList(@Param("page") Page<Map<String, Object>> page, @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode, @Param("types") List<String> types, @Param("emergencyLevels") List<String> emergencyLevels, @Param("name") String name, @Param("cleanStatus") Integer cleanStatus, @Param("handleStatus") Integer handleStatus , @Param("createDate") String createDate , @Param("startDate") String startDate , @Param("endDate") String endDate);
List<Map<String, Object>> alarmListNoPage( @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode, @Param("types") List<String> types, @Param("emergencyLevels") List<String> emergencyLevels, @Param("name") String name, @Param("cleanStatus") Integer cleanStatus, @Param("handleStatus") Integer handleStatus , @Param("createDate") String createDate , @Param("startDate") String startDate , @Param("endDate") String endDate);
IPage<EquipTypeImgAmountVO> getEmergencyEquipList(@Param("page") IPage page, @Param("equipTypeAmountPage") EquipTypeAmountPageDTO equipTypeAmountPage, @Param("list") List<String> list);
List<Map<String, Object >> getEquipStatistic(@Param("bizOrgCode") String bizOrgCode, @Param("equipCodeKey") String equipCodeKey);
......
package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.equipmanage.common.entity.Alarm;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 服务类
*
......@@ -11,4 +16,7 @@ import com.yeejoin.equipmanage.common.entity.Alarm;
*/
public interface IAlarmService extends IService<Alarm> {
List<Map<String,String>> totalNum(String bizOrgCode, String systemId);
void downList(HttpServletResponse response, String bizOrgCode, String systemCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus, String createDate, String startDate, String endDate);
}
package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.equipmanage.common.entity.Alarm;
import com.yeejoin.equipmanage.common.vo.EquipmentAlarmDownloadVO;
import com.yeejoin.equipmanage.dto.AlarmExportDto;
import com.yeejoin.equipmanage.mapper.AlarmMapper;
import com.yeejoin.equipmanage.mapper.EmergencyMapper;
import com.yeejoin.equipmanage.service.IAlarmService;
import liquibase.pro.packaged.L;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 服务实现类
*
......@@ -15,4 +29,30 @@ import org.springframework.stereotype.Service;
@Service
public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements IAlarmService {
@Autowired
AlarmMapper alarmMapper;
@Autowired
EmergencyMapper emergencyMapper;
@Override
public void downList(HttpServletResponse response, String bizOrgCode, String systemCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus, String createDate, String startDate, String endDate) {
List<Map<String, Object>> list = emergencyMapper.alarmListNoPage(bizOrgCode, systemCode, types, emergencyLevels, name, cleanStatus, handleStatus, createDate, startDate, endDate);
List<AlarmExportDto> alarmExportDtoList = new ArrayList<>();
if(list.size() > 0) {
for (Map m :list
) {
String s = JSONObject.toJSONString(m);
AlarmExportDto dto = JSONObject.parseObject(s, AlarmExportDto.class);
alarmExportDtoList.add(dto);
}
ExcelUtil.createTemplate(response, "设备告警信息", "设备告警信息", alarmExportDtoList, AlarmExportDto.class, null, false);
}
}
@Override
public List<Map<String,String>> totalNum(String bizOrgCode, String systemId) {
return alarmMapper.totalNum(bizOrgCode, systemId);
}
}
......@@ -2,4 +2,35 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.equipmanage.mapper.AlarmMapper">
<select id="totalNum" resultType="java.util.Map">
SELECT count(*) num, 'qlgj' as code from wl_equipment_specific_alarm_log a
where a.biz_org_code = #{bizOrgCode}
<if test="systemId != null and systemId !=''">
and FIND_IN_SET(#{systemId},a.system_ids)
</if>
UNION ALL
SELECT count(*) num, 'wfggj' as code from wl_equipment_specific_alarm_log a where a.`status` = 1
and a.biz_org_code = #{bizOrgCode}
<if test="systemId != null and systemId !=''">
and FIND_IN_SET(#{systemId},a.system_ids)
</if>
UNION ALL
SELECT count(*) num, 'hzgj' as code from wl_equipment_specific_alarm_log a where a.`type` = 'FIREALARM'
and a.biz_org_code = #{bizOrgCode}
<if test="systemId != null and systemId !=''">
and FIND_IN_SET(#{systemId},a.system_ids)
</if>
UNION ALL
SELECT count(*) num, 'gzgj' as code from wl_equipment_specific_alarm_log a where a.`type` = 'BREAKDOWN'
and a.biz_org_code = #{bizOrgCode}
<if test="systemId != null and systemId !=''">
and FIND_IN_SET(#{systemId},a.system_ids)
</if>
UNION ALL
SELECT count(*) num, 'pbgj' as code from wl_equipment_specific_alarm_log a where a.`type` = 'SHIELD'
and a.biz_org_code = #{bizOrgCode}
<if test="systemId != null and systemId !=''">
and FIND_IN_SET(#{systemId},a.system_ids)
</if>
</select>
</mapper>
......@@ -1492,6 +1492,86 @@
wlesal.create_date DESC
</select>
<select id="alarmListNoPage" resultType="java.util.Map">
SELECT
wlesal.id,
concat(wlesal.equipment_specific_name, wlesal.equipment_specific_index_name) AS alamContent,
IF (wlesal.confirm_type IS NULL, '未确认', '已确认') handleStatus,
IF (wlesal.clean_time IS NOT NULL, '已消除', '未消除' ) cleanStatus,
wlesal.equipment_index_id AS fireEquipmentIndexId,
wlesal.equipment_specific_code AS code,
wlesal.equipment_specific_index_key AS fireEquipmentSpecificIndexKey,
wlesal.equipment_specific_index_name AS fireEquipmentSpecificIndexName,
CASE wlesal.equipment_specific_index_value
WHEN 'true' THEN '是'
WHEN 'false' THEN '否'
ELSE wlesal.equipment_specific_index_value
END AS fireEquipmentPointValue,
wlesal.type AS typeCode,
(
SELECT
type_name
FROM
wl_signal_classify sc
WHERE
sc.type_code = wlesal.type
LIMIT 1
) AS type,
wlesal.equipment_specific_name AS equipmentSpecificName,
wlesal.location,
date_format(wlesal.create_date, '%Y-%m-%d %H:%i:%s') createDate,
wlesal.emergency_level_describe AS emergencyLevelDescribe,
fs.name AS systemName
FROM
wl_equipment_specific_alarm_log wlesal
LEFT JOIN wl_equipment_specific wes ON wes.id = wlesal.equipment_specific_id
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, wlesal.system_ids )
<where>
<if test="bizOrgCode != null and bizOrgCode != ''">
and wlesal.biz_org_code like concat(#{bizOrgCode},'%')
</if>
<if test='createDate != null and createDate == "1"'>
AND wlesal.create_date LIKE CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d' ), '%' )
</if>
<if test='startDate != null and startDate == ""'>
AND wlesal.create_date >= DATE_FORMAT( ${startDate}, '%Y-%m-%d %H:%i:%s' )
</if>
<if test='endDate != null and endDate == ""'>
AND DATE_FORMAT( ${endDate}, '%Y-%m-%d %H:%i:%s' ) >= wlesal.create_date
</if>
<if test="systemCode != null and systemCode != ''">
and fs.code = #{systemCode}
</if>
<if test="name != null and name != ''">
and wlesal.equipment_specific_name like concat('%', #{name},'%')
</if>
<if test="cleanStatus != null and cleanStatus != '' and cleanStatus == 2">
and wlesal.clean_time IS NULL
</if>
<if test="cleanStatus != null and cleanStatus != '' and cleanStatus == 1">
and wlesal.clean_time IS NOT NULL
</if>
<if test="handleStatus != null and handleStatus != '' and handleStatus == 2">
and wlesal.confirm_type IS NULL
</if>
<if test="handleStatus != null and handleStatus != '' and handleStatus == 1">
and wlesal.confirm_type IS NOT NULL
</if>
<if test="types != null">
<foreach collection="types" index="index" item="item" open="and (" separator=" OR " close=")">
wlesal.type = #{item}
</foreach>
</if>
<if test="emergencyLevels != null">
<foreach collection="emergencyLevels" index="index" item="item" open="and (" separator=" OR " close=")">
wlesal.emergency_level = #{item}
</foreach>
</if>
</where>
ORDER BY
wlesal.create_date DESC
</select>
<select id="getEmergencyMaterials" resultType="java.util.Map">
SELECT
*
......
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