Commit cb47ecc3 authored by suhuiguang's avatar suhuiguang

1.ccs 物联监控

parent a4d959a9
...@@ -821,6 +821,13 @@ public class DateUtils { ...@@ -821,6 +821,13 @@ public class DateUtils {
return getDate(calendar.getTime()); return getDate(calendar.getTime());
} }
public static Date getBeginDateOfMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
return calendar.getTime();
}
/** /**
* 将秒数转换为时分秒格式 * 将秒数转换为时分秒格式
* *
......
...@@ -45,10 +45,10 @@ public class FireEquipmentSignalLogDto extends BaseDto { ...@@ -45,10 +45,10 @@ public class FireEquipmentSignalLogDto extends BaseDto {
private String fireBuildingMrid; private String fireBuildingMrid;
@ApiModelProperty(value = "报警类型:alarm_type_fire(火灾报警)/alarm_type_trouble(故障告警)") @ApiModelProperty(value = "报警类型:alarm_type_fire(火灾报警)/alarm_type_trouble(故障告警)")
private String alarmType; private String signalType;
@ApiModelProperty(value = "报警类型名称") @ApiModelProperty(value = "报警类型名称")
private String alarmTypeName; private String signalTypeName;
@ApiModelProperty(value = "确认状态:0-未确认 1-已确认") @ApiModelProperty(value = "确认状态:0-未确认 1-已确认")
private String confirmState; private String confirmState;
......
...@@ -16,7 +16,7 @@ import java.util.Date; ...@@ -16,7 +16,7 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@ApiModel(value = "FireAlarmDayStatisticsDto", description = "换流站告警日统计") @ApiModel(value = "FireAlarmDayStatisticsDto", description = "换流站告警日统计")
public class FireAlarmDayStatisticsDto extends BaseDto { public class FireSignalDayStatisticsDto extends BaseDto {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -30,13 +30,17 @@ public class FireAlarmDayStatisticsDto extends BaseDto { ...@@ -30,13 +30,17 @@ public class FireAlarmDayStatisticsDto extends BaseDto {
@ApiModelProperty(value = "统计日期") @ApiModelProperty(value = "统计日期")
private Date collectDate; private Date collectDate;
@ApiModelProperty(value = "报警次数") @ApiModelProperty(value = "上报次数")
private Integer alarmTimes; private Integer reportTimes;
@ApiModelProperty(value = "告警类型") @ApiModelProperty(value = "信号类型")
private String alarmType; private String signalType;
@ApiModelProperty(value = "信号类型名称")
private String signalTypeName;
@ApiModelProperty(value = "是否为告警信号数据")
private Boolean isAlarm;
@ApiModelProperty(value = "告警类型名称")
private String alarmTypeName;
} }
...@@ -9,7 +9,7 @@ import lombok.experimental.Accessors; ...@@ -9,7 +9,7 @@ import lombok.experimental.Accessors;
import java.util.Date; import java.util.Date;
/** /**
* 换流站告警日统计 * 设备信号类型上报次数日统计
* *
* @author system_generator * @author system_generator
* @date 2021-11-09 * @date 2021-11-09
...@@ -17,8 +17,8 @@ import java.util.Date; ...@@ -17,8 +17,8 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("asf_fire_alarm_day_statistics") @TableName("asf_fire_signal_day_statistics")
public class FireAlarmDayStatistics extends BaseEntity { public class FireSignalDayStatistics extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -43,19 +43,25 @@ public class FireAlarmDayStatistics extends BaseEntity { ...@@ -43,19 +43,25 @@ public class FireAlarmDayStatistics extends BaseEntity {
/** /**
* 报警次数 * 报警次数
*/ */
@TableField("alarm_times") @TableField("report_times")
private Integer alarmTimes; private Integer reportTimes;
/** /**
* 告警类型 * 信号类型
*/ */
@TableField("alarm_type") @TableField("signal_type")
private String alarmType; private String signalType;
/** /**
* 告警类型名称 * 信号类型名称
*/ */
@TableField("alarm_type_name") @TableField("signal_type_name")
private String alarmTypeName; private String signalTypeName;
/**
* 是否为告警信号数据
*/
private Boolean isAlarm;
} }
package com.yeejoin.amos.boot.module.ccs.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import javax.ws.rs.GET;
/**
* @author DELL
*/
@AllArgsConstructor
@Getter
public enum SignalTypeOfAlarm {
/**
* 特殊统计信号类型枚举
*/
FAULT_ALARM("faultAlarm","故障告警"),
FIRE_ALARM("fireAlarm","火灾告警"),
SHIELD_ALARM("shieldAlarm","屏蔽"),
OIL_LEAK_ALARM("oilLeakAlarm","漏油"),
ALARM("alarm","告警");
private String code;
private String name;
}
package com.yeejoin.amos.boot.module.ccs.api.mapper; package com.yeejoin.amos.boot.module.ccs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.ccs.api.entity.FireAlarmDayStatistics; import com.yeejoin.amos.boot.module.ccs.api.entity.FireSignalDayStatistics;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
* @author system_generator * @author system_generator
* @date 2021-11-09 * @date 2021-11-09
*/ */
public interface FireAlarmDayStatisticsMapper extends BaseMapper<FireAlarmDayStatistics> { public interface FireSignalDayStatisticsMapper extends BaseMapper<FireSignalDayStatistics> {
/** /**
* 告警次数-折线图使用 * 告警次数-折线图使用
...@@ -22,5 +22,5 @@ public interface FireAlarmDayStatisticsMapper extends BaseMapper<FireAlarmDaySta ...@@ -22,5 +22,5 @@ public interface FireAlarmDayStatisticsMapper extends BaseMapper<FireAlarmDaySta
* @param endDate 结束日期 * @param endDate 结束日期
* @return List<String> * @return List<String>
*/ */
List<String> queryAlarmTimesTrend(@Param("stationCode") String stationCode, @Param("beginDate") String beginDate, @Param("endDate") String endDate); List<String> queryAlarmTimesTrend(@Param("stationCode") String stationCode, @Param("beginDate") String beginDate, @Param("endDate") String endDate,@Param("signalType") String signalType);
} }
...@@ -3,8 +3,10 @@ package com.yeejoin.amos.boot.module.ccs.api.mapper; ...@@ -3,8 +3,10 @@ package com.yeejoin.amos.boot.module.ccs.api.mapper;
import com.yeejoin.amos.boot.module.ccs.api.dto.FireStationInfoDto; import com.yeejoin.amos.boot.module.ccs.api.dto.FireStationInfoDto;
import com.yeejoin.amos.boot.module.ccs.api.entity.FireStationInfo; import com.yeejoin.amos.boot.module.ccs.api.entity.FireStationInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 站端信息表 Mapper 接口 * 站端信息表 Mapper 接口
...@@ -24,7 +26,10 @@ public interface FireStationInfoMapper extends BaseMapper<FireStationInfo> { ...@@ -24,7 +26,10 @@ public interface FireStationInfoMapper extends BaseMapper<FireStationInfo> {
/** /**
* 换流站装备信息 * 换流站装备信息
* @param stationCode * @param stationCode
* @param stationName
* @return * @return
*/ */
List<FireStationInfoDto> queryStationEquipInfo(String stationCode); List<Map<String, Object>> queryStationEquipInfo(@Param("stationCode") String stationCode, @Param("stationName") String stationName);
List<Map<String, Object>> lastYearAlarmCount();
} }
package com.yeejoin.amos.boot.module.ccs.api.service;
/**
* 换流站告警日统计接口类
*
* @author system_generator
* @date 2021-11-09
*/
public interface IFireAlarmDayStatisticsService {
}
package com.yeejoin.amos.boot.module.ccs.api.service; package com.yeejoin.amos.boot.module.ccs.api.service;
import com.yeejoin.amos.boot.module.ccs.api.dto.FireStationInfoDto;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -27,9 +25,10 @@ public interface IFireEquipmentService { ...@@ -27,9 +25,10 @@ public interface IFireEquipmentService {
* 站端物联设备 * 站端物联设备
* *
* @param stationCode 换流站code * @param stationCode 换流站code
* @param stationName
* @return List<FireStationInfoDto> * @return List<FireStationInfoDto>
*/ */
List<FireStationInfoDto> stationEquipmentInfo(String stationCode); List<Map<String, Object>> stationEquipmentInfo(String stationCode, String stationName);
/** /**
* 故障设备汇总 * 故障设备汇总
......
package com.yeejoin.amos.boot.module.ccs.api.service;
import java.text.ParseException;
import java.util.Map;
/**
* 换流站告警日统计接口类
*
* @author system_generator
* @date 2021-11-09
*/
public interface IFireSignalDayStatisticsService {
/**
* 警情信息
*
* @return Map<String, Object>
*/
Map<String, Object> selectForAlarmCount() throws ParseException;
/**
* 警情变化趋势
*
* @param beginData 开始日期
* @param endData 接受日期
* @return Map<String, Object>
*/
Map<String, Object> selectForAlarmTrend(String beginData, String endData);
/**
* 警情类型占比
* @param beginData 开始日期
* @param endData 结束日期
* @return Map<String, Object>
*/
Map<String, Object> todayAlarmPercent(String beginData, String endData);
}
...@@ -23,4 +23,10 @@ public interface IStatisticsService { ...@@ -23,4 +23,10 @@ public interface IStatisticsService {
* @return Map<String, Object> * @return Map<String, Object>
*/ */
Map<String, Object> alarmAndDangerTrend(String stationCode, String beginDate, String endDate); Map<String, Object> alarmAndDangerTrend(String stationCode, String beginDate, String endDate);
/**
* 近一年警情统计
* @return List<Map<String, Object>>
*/
List<Map<String, Object>> lastYearAlarmCount();
} }
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
a.id, a.id,
a.fire_equipment_name, a.fire_equipment_name,
a.fire_equipment_index_name, a.fire_equipment_index_name,
a.alarm_type, a.signal_type,
a.alarm_type_name, a.signal_type_name,
a.create_date, a.create_date,
s.name as station_name, s.name as station_name,
a.station_code, a.station_code,
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
where where
a.station_code = s.code a.station_code = s.code
and s.status = false and s.status = false
and a.is_alarm = true
<if test="stationCode != null and stationCode != ''"> <if test="stationCode != null and stationCode != ''">
and a.station_code = #{stationCode} and a.station_code = #{stationCode}
</if> </if>
...@@ -55,7 +54,7 @@ ...@@ -55,7 +54,7 @@
distinct(ai.fire_equipment_mrid) as mrid distinct(ai.fire_equipment_mrid) as mrid
FROM `asf_fire_equipment_signal_log` ai FROM `asf_fire_equipment_signal_log` ai
where where
ai.alarm_date =#{alarmDate} ai.signal_report_date =#{alarmDate}
and ai.is_alarm = true and ai.is_alarm = true
<if test="stationCode != null and stationCode != ''"> <if test="stationCode != null and stationCode != ''">
and ai.station_code =#{stationCode} and ai.station_code =#{stationCode}
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
FROM FROM
`asf_fire_equipment_signal_log` a `asf_fire_equipment_signal_log` a
where where
year(a.alarm_date) = YEAR(#{currentDate}) year(a.signal_report_date) = YEAR(#{currentDate})
and a.signal_type = 'fault' and a.signal_type = 'faultAlarm'
group by a.equipment_definition_name group by a.equipment_definition_name
ORDER BY total desc ORDER BY total desc
<if test="top != null and top != ''"> <if test="top != null and top != ''">
......
<?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.ccs.api.mapper.FireAlarmDayStatisticsMapper"> <mapper namespace="com.yeejoin.amos.boot.module.ccs.api.mapper.FireSignalDayStatisticsMapper">
<select id="queryAlarmTimesTrend" resultType="java.lang.String"> <select id="queryAlarmTimesTrend" resultType="java.lang.String">
select select
(SELECT (SELECT
IFNULL(sum(s.alarm_times),0) IFNULL(sum(s.report_times),0)
FROM `asf_fire_alarm_day_statistics` s FROM `asf_fire_signal_day_statistics` s
<where> <where>
<if test="stationCode != null and stationCode != ''"> <if test="stationCode != null and stationCode != ''">
s.station_code = #{stationCode} and s.station_code = #{stationCode}
</if> </if>
s.collect_date = t.date <if test="signalType != null and signalType != ''">
and s.signal_type = #{signalType}
</if>
and s.collect_date = t.date
and s.is_alarm = true
</where> </where>
) as times ) as times
from from
......
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
resultType="com.yeejoin.amos.boot.module.ccs.api.dto.FireStationInfoDto"> resultType="com.yeejoin.amos.boot.module.ccs.api.dto.FireStationInfoDto">
SELECT SELECT
i.*, i.*,
IFNULL((SELECT sum(s.alarm_times) from asf_fire_alarm_day_statistics s where s.collect_date = CURRENT_DATE and s.station_code = i.`code`),0) as todayAlarmTimes, IFNULL((SELECT sum(s.report_times) from asf_fire_signal_day_statistics s where s.collect_date = CURRENT_DATE and
IFNULL((SELECT count(1) from asf_fire_latent_danger d where d.deal_state = 1 and d.station_code = i.`code`),0) as existDangerNumber s.station_code = i.`code`),0) as todayAlarmTimes,
IFNULL((SELECT count(1) from asf_fire_latent_danger d where d.deal_state = 1 and d.station_code = i.`code`),0)
as existDangerNumber
FROM FROM
`asf_fire_station_info` i `asf_fire_station_info` i
where i.status = false where i.status = false
...@@ -16,19 +18,42 @@ ...@@ -16,19 +18,42 @@
</if> </if>
</select> </select>
<select id="queryStationEquipInfo" <select id="queryStationEquipInfo"
resultType="com.yeejoin.amos.boot.module.ccs.api.dto.FireStationInfoDto"> resultType="java.util.Map">
SELECT SELECT
si.id, si.id,
si.code, si.code,
si.`name`, si.`name`,
(select count(1) from ast_fire_equipment e where e.station_code = si.code and e.is_iot = true) as iotEquipmentNumber, (select count(1) from ast_fire_equipment e where e.station_code = si.code and e.is_iot = true) as
(select count(DISTINCT(1)) from asf_fire_equipment_signal_log l where l.station_code = si.code and l.alarm_date =CURRENT_DATE and l.is_alarm = true) as todayAlarmEquipmentNumber iotEquipmentNumber,
(select count(DISTINCT(1)) from asf_fire_equipment_signal_log l where l.station_code = si.code and
l.signal_report_date =CURRENT_DATE and l.is_alarm = true) as todayAlarmEquipmentNumber
FROM `asf_fire_station_info` si FROM `asf_fire_station_info` si
<where> <where>
<if test="stationCode != null and stationCode != ''"> <if test="stationCode != null and stationCode != ''">
si.code = #{stationCode} si.code = #{stationCode}
</if> </if>
<if test="stationName != null and stationName != ''">
si.name like concat('%', #{stationName},'%')
</if>
</where> </where>
order by iotEquipmentNumber desc order by iotEquipmentNumber desc
</select> </select>
<select id="lastYearAlarmCount" resultType="java.util.Map">
SELECT
s.code,
s.name,
(select
count(DISTINCT(l.fire_equipment_mrid))
from asf_fire_equipment_signal_log l
where l.is_alarm =true and
l.signal_report_date >= DATE_sub(CURDATE(),INTERVAL 1 year)
and l.signal_report_date <![CDATA[ <= ]]> CURDATE() and l.station_code = s.code) as alarmEquipNumber,
ifnull((SELECT sum(ds.report_times) from asf_fire_signal_day_statistics ds
where ds.is_alarm =true and
ds.collect_date >= DATE_sub(CURDATE(),INTERVAL 1 year)
and ds.collect_date <![CDATA[ <= ]]> CURDATE()
and ds.station_code = s.code),0) as alarmTimes
FROM
`asf_fire_station_info` s
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.ccs.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.ccs.api.dto.FireAlarmDayStatisticsDto;
import com.yeejoin.amos.boot.module.ccs.biz.service.impl.FireAlarmDayStatisticsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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 java.util.List;
/**
* 换流站告警日统计
*
* @author system_generator
* @date 2021-11-09
*/
@RestController
@Api(tags = "换流站告警日统计Api")
@RequestMapping(value = "/fire-alarm-day-statistics")
public class FireAlarmDayStatisticsController extends BaseController {
@Autowired
FireAlarmDayStatisticsServiceImpl fireAlarmDayStatisticsServiceImpl;
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "换流站告警日统计列表全部数据查询", notes = "换流站告警日统计列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<FireAlarmDayStatisticsDto>> selectForList() {
return ResponseHelper.buildResponse(fireAlarmDayStatisticsServiceImpl.queryForFireAlarmDayStatisticsList());
}
}
...@@ -55,8 +55,9 @@ public class FireEquipmentController extends BaseController { ...@@ -55,8 +55,9 @@ public class FireEquipmentController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "站端物联设备", notes = "站端物联设备") @ApiOperation(httpMethod = "GET", value = "站端物联设备", notes = "站端物联设备")
@GetMapping(value = "/station/info") @GetMapping(value = "/station/info")
public ResponseModel stationEquipmentInfo( public ResponseModel stationEquipmentInfo(
@ApiParam(value = "换流站编号") @RequestParam(required = false) String stationCode) { @ApiParam(value = "换流站编号") @RequestParam(required = false) String stationCode,
return ResponseHelper.buildResponse(iFireEquipmentService.stationEquipmentInfo(stationCode)); @ApiParam(value = "换流站名称") @RequestParam(required = false) String stationName) {
return ResponseHelper.buildResponse(iFireEquipmentService.stationEquipmentInfo(stationCode,stationName));
} }
......
package com.yeejoin.amos.boot.module.ccs.biz.controller; package com.yeejoin.amos.boot.module.ccs.biz.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List; import com.yeejoin.amos.boot.module.ccs.api.dto.FireEquipmentSignalDto;
import com.yeejoin.amos.boot.module.ccs.biz.service.impl.FireEquipmentSignalServiceImpl; import com.yeejoin.amos.boot.module.ccs.biz.service.impl.FireEquipmentSignalServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import io.swagger.annotations.Api;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.module.ccs.api.dto.FireEquipmentSignalDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType; 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 java.util.List;
/** /**
* 设备报警信息表 * 设备报警信息表
...@@ -24,77 +23,20 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType; ...@@ -24,77 +23,20 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
* @date 2021-11-09 * @date 2021-11-09
*/ */
@RestController @RestController
@Api(tags = "设备报警信息表Api") @Api(tags = "设备信号信息表Api")
@RequestMapping(value = "/fire-equipment-alarm") @RequestMapping(value = "/fire-equipment-signal")
public class FireEquipmentSignalController extends BaseController { public class FireEquipmentSignalController extends BaseController {
@Autowired @Autowired
FireEquipmentSignalServiceImpl fireEquipmentSignalServiceImpl; FireEquipmentSignalServiceImpl fireEquipmentSignalServiceImpl;
/** /**
* 新增设备报警信息表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增设备报警信息表", notes = "新增设备报警信息表")
public ResponseModel<FireEquipmentSignalDto> save(@RequestBody FireEquipmentSignalDto model) {
model = fireEquipmentSignalServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除设备报警信息表", notes = "根据sequenceNbr删除设备报警信息表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
return ResponseHelper.buildResponse(fireEquipmentSignalServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个设备报警信息表", notes = "根据sequenceNbr查询单个设备报警信息表")
public ResponseModel<FireEquipmentSignalDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(fireEquipmentSignalServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "设备报警信息表分页查询", notes = "设备报警信息表分页查询")
public ResponseModel<Page<FireEquipmentSignalDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size) {
Page<FireEquipmentSignalDto> page = new Page<FireEquipmentSignalDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(fireEquipmentSignalServiceImpl.queryForFireEquipmentAlarmPage(page));
}
/**
* 列表全部数据查询 * 列表全部数据查询
* *
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "设备报警信息表列表全部数据查询", notes = "设备报警信息表列表全部数据查询") @ApiOperation(httpMethod = "GET", value = "设备报警信息表列表全部数据查询", notes = "设备报警信息表列表全部数据查询")
@GetMapping(value = "/list") @GetMapping(value = "/list")
public ResponseModel<List<FireEquipmentSignalDto>> selectForList() { public ResponseModel<List<FireEquipmentSignalDto>> selectForList() {
return ResponseHelper.buildResponse(fireEquipmentSignalServiceImpl.queryForFireEquipmentAlarmList()); return ResponseHelper.buildResponse(fireEquipmentSignalServiceImpl.queryForFireEquipmentAlarmList());
......
...@@ -26,8 +26,8 @@ import java.util.List; ...@@ -26,8 +26,8 @@ import java.util.List;
* @date 2021-11-09 * @date 2021-11-09
*/ */
@RestController @RestController
@Api(tags = "设备报警信息日志表Api") @Api(tags = "设备信号信息日志表Api")
@RequestMapping(value = "/fire-equipment-alarm-log") @RequestMapping(value = "/fire-equipment-signal-log")
public class FireEquipmentSignalLogController extends BaseController { public class FireEquipmentSignalLogController extends BaseController {
@Autowired @Autowired
......
package com.yeejoin.amos.boot.module.ccs.biz.controller;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.ccs.biz.service.impl.FireSignalDayStatisticsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
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 java.text.ParseException;
/**
* 换流站告警日统计
*
* @author system_generator
* @date 2021-11-09
*/
@RestController
@Api(tags = "换流站告警日统计Api")
@RequestMapping(value = "/fire-signal-day-statistics")
public class FireSignalDayStatisticsController extends BaseController {
@Autowired
FireSignalDayStatisticsServiceImpl fireSignalDayStatisticsServiceImpl;
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "警情信息统计", notes = "警情信息统计")
@GetMapping(value = "/alarm/count")
public ResponseModel selectForAlarmCount() throws ParseException {
return ResponseHelper.buildResponse(fireSignalDayStatisticsServiceImpl.selectForAlarmCount());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "警情变化趋势", notes = "警情变化趋势")
@GetMapping(value = "/alarm/trend")
public ResponseModel selectForAlarmTrend(
@ApiParam(value = "开始日期:yyyy-MM-dd", required = true) @RequestParam String beginData,
@ApiParam(value = "结束日期:yyyy-MM-dd", required = true) @RequestParam String endData) {
return ResponseHelper.buildResponse(fireSignalDayStatisticsServiceImpl.selectForAlarmTrend(beginData, endData));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "警情类型占比", notes = "警情类型占比")
@GetMapping(value = "/alarm/percent")
public ResponseModel todayAlarmPercent(
@ApiParam(value = "开始日期:yyyy-MM-dd", required = true) @RequestParam String beginData,
@ApiParam(value = "结束日期:yyyy-MM-dd", required = true) @RequestParam String endData) {
return ResponseHelper.buildResponse(fireSignalDayStatisticsServiceImpl.todayAlarmPercent(beginData, endData));
}
}
...@@ -46,5 +46,12 @@ public class StatisticsController { ...@@ -46,5 +46,12 @@ public class StatisticsController {
return ResponseHelper.buildResponse(iStatisticsService.alarmAndDangerTrend(stationCode, beginDate, endDate)); return ResponseHelper.buildResponse(iStatisticsService.alarmAndDangerTrend(stationCode, beginDate, endDate));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "近一年警情统计", notes = "近一年警情统计")
@GetMapping(value = "/station/lastYearAlarm")
public ResponseModel lastYearAlarmCount() {
return ResponseHelper.buildResponse(iStatisticsService.lastYearAlarmCount());
}
} }
package com.yeejoin.amos.boot.module.ccs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.ccs.api.dto.FireAlarmDayStatisticsDto;
import com.yeejoin.amos.boot.module.ccs.api.entity.FireAlarmDayStatistics;
import com.yeejoin.amos.boot.module.ccs.api.mapper.FireAlarmDayStatisticsMapper;
import com.yeejoin.amos.boot.module.ccs.api.service.IFireAlarmDayStatisticsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List;
/**
* 换流站告警日统计服务实现类
*
* @author system_generator
* @date 2021-11-09
*/
@Service
public class FireAlarmDayStatisticsServiceImpl extends BaseService<FireAlarmDayStatisticsDto, FireAlarmDayStatistics, FireAlarmDayStatisticsMapper> implements IFireAlarmDayStatisticsService {
/**
* 列表查询 示例
*/
public List<FireAlarmDayStatisticsDto> queryForFireAlarmDayStatisticsList() {
return this.queryForList("", false);
}
public int alarmTimesCount(String stationCode, String beginDate, String endDate) {
LambdaQueryWrapper<FireAlarmDayStatistics> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(stationCode), FireAlarmDayStatistics::getStationCode, stationCode);
wrapper.ge(FireAlarmDayStatistics::getCollectDate, beginDate);
wrapper.le(FireAlarmDayStatistics::getCollectDate, endDate);
List<FireAlarmDayStatistics> list = this.list(wrapper);
return list.stream().mapToInt(FireAlarmDayStatistics::getAlarmTimes).sum();
}
public List<String> alarmTimesTrend(String stationCode, String beginDate, String endDate) {
return this.baseMapper.queryAlarmTimesTrend(stationCode, beginDate, endDate);
}
}
\ No newline at end of file
...@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.ccs.biz.service.impl; ...@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.ccs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.ccs.api.dto.FireEquipmentDto; import com.yeejoin.amos.boot.module.ccs.api.dto.FireEquipmentDto;
import com.yeejoin.amos.boot.module.ccs.api.dto.FireStationInfoDto;
import com.yeejoin.amos.boot.module.ccs.api.entity.FireEquipment; import com.yeejoin.amos.boot.module.ccs.api.entity.FireEquipment;
import com.yeejoin.amos.boot.module.ccs.api.mapper.FireEquipmentSignalLogMapper; import com.yeejoin.amos.boot.module.ccs.api.mapper.FireEquipmentSignalLogMapper;
import com.yeejoin.amos.boot.module.ccs.api.mapper.FireEquipmentSignalMapper; import com.yeejoin.amos.boot.module.ccs.api.mapper.FireEquipmentSignalMapper;
...@@ -51,8 +50,8 @@ public class FireEquipmentServiceImpl extends BaseService<FireEquipmentDto, Fire ...@@ -51,8 +50,8 @@ public class FireEquipmentServiceImpl extends BaseService<FireEquipmentDto, Fire
} }
@Override @Override
public List<FireStationInfoDto> stationEquipmentInfo(String stationCode) { public List<Map<String, Object>> stationEquipmentInfo(String stationCode, String stationName) {
return stationInfoMapper.queryStationEquipInfo(stationCode); return stationInfoMapper.queryStationEquipInfo(stationCode,stationName);
} }
@Override @Override
......
package com.yeejoin.amos.boot.module.ccs.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.ccs.api.dto.FireSignalDayStatisticsDto;
import com.yeejoin.amos.boot.module.ccs.api.entity.FireSignalDayStatistics;
import com.yeejoin.amos.boot.module.ccs.api.enums.SignalTypeOfAlarm;
import com.yeejoin.amos.boot.module.ccs.api.mapper.FireSignalDayStatisticsMapper;
import com.yeejoin.amos.boot.module.ccs.api.service.IFireSignalDayStatisticsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.text.ParseException;
import java.util.*;
/**
* 换流站告警日统计服务实现类
*
* @author system_generator
* @date 2021-11-09
*/
@Service
public class FireSignalDayStatisticsServiceImpl extends BaseService<FireSignalDayStatisticsDto, FireSignalDayStatistics, FireSignalDayStatisticsMapper> implements IFireSignalDayStatisticsService {
public int alarmTimesCount(String stationCode, String beginDate, String endDate) {
LambdaQueryWrapper<FireSignalDayStatistics> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(stationCode), FireSignalDayStatistics::getStationCode, stationCode);
wrapper.ge(FireSignalDayStatistics::getCollectDate, beginDate);
wrapper.le(FireSignalDayStatistics::getCollectDate, endDate);
wrapper.eq(FireSignalDayStatistics::getIsAlarm, true);
List<FireSignalDayStatistics> list = this.list(wrapper);
return list.stream().mapToInt(FireSignalDayStatistics::getReportTimes).sum();
}
public List<String> alarmTimesTrend(String stationCode, String beginDate, String endDate) {
return this.baseMapper.queryAlarmTimesTrend(stationCode, beginDate, endDate, null);
}
@Override
public Map<String, Object> selectForAlarmCount() throws ParseException {
//TODO 统计告警类型的指标信息
//今天
String today = DateUtils.dateFormat(new Date(), DateUtils.DATE_PATTERN);
//昨天
Date yesterday = DateUtils.dateAdd(new Date(), 1, false);
String yesterdayStr = DateUtils.dateFormat(yesterday, DateUtils.DATE_PATTERN);
//本周开始日期
Date weekBegin = DateUtils.beginDateOfWeek(new Date());
//本月开始日期
Date monthBegin = DateUtils.getBeginDateOfMonth(new Date());
//今日告警数量
int todayAlarmTimes = this.alarmTimesCount(null, today, today);
//昨日警情数量
int yesterdayAlarmTimes = this.alarmTimesCount(null, yesterdayStr, yesterdayStr);
//本周警情数目
int weekAlarmTimes = this.alarmTimesCount(null, DateUtils.dateFormat(weekBegin, DateUtils.DATE_PATTERN), today);
//本月警情数目
int monthAlarmTimes = this.alarmTimesCount(null, DateUtils.dateFormat(monthBegin, DateUtils.DATE_PATTERN), today);
Map<String, Object> result = new HashMap<>(8);
result.put("todayAlarmTimes", todayAlarmTimes);
result.put("yesterdayAlarmTimes", yesterdayAlarmTimes);
result.put("weekAlarmTimes", weekAlarmTimes);
result.put("monthAlarmTimes", monthAlarmTimes);
return result;
}
@Override
public Map<String, Object> selectForAlarmTrend(String beginData, String endData) {
//故障告警
List<String> faultAlarm = this.baseMapper.queryAlarmTimesTrend(null, beginData, endData, SignalTypeOfAlarm.FAULT_ALARM.getCode());
//火灾告警
List<String> fireAlarm = this.baseMapper.queryAlarmTimesTrend(null, beginData, endData, SignalTypeOfAlarm.FIRE_ALARM.getCode());
//屏蔽
List<String> shieldAlarm = this.baseMapper.queryAlarmTimesTrend(null, beginData, endData, SignalTypeOfAlarm.SHIELD_ALARM.getCode());
//漏油
List<String> oilAlarm = this.baseMapper.queryAlarmTimesTrend(null, beginData, endData, SignalTypeOfAlarm.OIL_LEAK_ALARM.getCode());
//告警
List<String> alarm = this.baseMapper.queryAlarmTimesTrend(null, beginData, endData, SignalTypeOfAlarm.ALARM.getCode());
Map<String, Object> result = new LinkedHashMap<>(8);
result.put("faultAlarm", faultAlarm);
result.put("fireAlarm", fireAlarm);
result.put("shieldAlarm", shieldAlarm);
result.put("oilLeakAlarm", oilAlarm);
result.put("alarm", alarm);
return result;
}
@Override
public Map<String, Object> todayAlarmPercent(String beginData, String endData) {
Map<String, Object> re = new LinkedHashMap<>(8);
//故障告警
re.put("faultAlarm", this.signalReportTimesCount(beginData, endData, SignalTypeOfAlarm.FAULT_ALARM.getCode()));
//火灾告警
re.put("fireAlarm", this.signalReportTimesCount(beginData, endData, SignalTypeOfAlarm.FIRE_ALARM.getCode()));
//屏蔽
re.put("shieldAlarm", this.signalReportTimesCount(beginData, endData, SignalTypeOfAlarm.SHIELD_ALARM.getCode()));
//漏油
re.put("oilLeakAlarm", this.signalReportTimesCount(beginData, endData, SignalTypeOfAlarm.OIL_LEAK_ALARM.getCode()));
//告警
re.put("alarm", this.signalReportTimesCount(beginData, endData, SignalTypeOfAlarm.ALARM.getCode()));
return re;
}
private int signalReportTimesCount(String beginDate, String endDate, String signalType) {
LambdaQueryWrapper<FireSignalDayStatistics> wrapper = new LambdaQueryWrapper<>();
wrapper.ge(FireSignalDayStatistics::getCollectDate, beginDate);
wrapper.le(FireSignalDayStatistics::getCollectDate, endDate);
wrapper.eq(FireSignalDayStatistics::getSignalType, signalType);
List<FireSignalDayStatistics> list = this.list(wrapper);
return list.stream().mapToInt(FireSignalDayStatistics::getReportTimes).sum();
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.ccs.biz.service.impl; package com.yeejoin.amos.boot.module.ccs.biz.service.impl;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.ccs.api.mapper.FireStationInfoMapper;
import com.yeejoin.amos.boot.module.ccs.api.service.IStatisticsService; import com.yeejoin.amos.boot.module.ccs.api.service.IStatisticsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,11 +19,14 @@ import java.util.Map; ...@@ -18,11 +19,14 @@ import java.util.Map;
public class StatisticsServiceImpl implements IStatisticsService { public class StatisticsServiceImpl implements IStatisticsService {
@Autowired @Autowired
FireAlarmDayStatisticsServiceImpl fireAlarmDayStatisticsService; FireSignalDayStatisticsServiceImpl fireAlarmDayStatisticsService;
@Autowired @Autowired
FireDangerDayStatisticsServiceImpl fireDangerDayStatisticsService; FireDangerDayStatisticsServiceImpl fireDangerDayStatisticsService;
@Autowired
FireStationInfoMapper fireStationInfoMapper;
@Override @Override
public Map<String, Object> alarmAndDangerNumCount(String stationCode) throws ParseException { public Map<String, Object> alarmAndDangerNumCount(String stationCode) throws ParseException {
...@@ -55,4 +59,9 @@ public class StatisticsServiceImpl implements IStatisticsService { ...@@ -55,4 +59,9 @@ public class StatisticsServiceImpl implements IStatisticsService {
result.put("dangerTrend", dangerTrend); result.put("dangerTrend", dangerTrend);
return result; return result;
} }
@Override
public List<Map<String, Object>> lastYearAlarmCount() {
return fireStationInfoMapper.lastYearAlarmCount();
}
} }
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