| | |
| | | |
| | | @RestController |
| | | @Api(tags = "电池实时告警") |
| | | @RequestMapping("battalarm") |
| | | @RequestMapping("battAlarm") |
| | | public class BattAlarmController { |
| | | @Autowired |
| | | private BattAlarmService service; |
| | |
| | | @Autowired |
| | | private BattAlarmHisService hisService; |
| | | |
| | | @ApiOperation("在用电池组实时推送告警信息") |
| | | /*@ApiOperation("在用电池组实时推送告警信息") |
| | | @GetMapping("getResBattAlm") |
| | | public Response getResBattAlm(@RequestParam(required = false) int binfId){ |
| | | Response res=service.getResBattAlm(binfId); |
| | | public Response getResBattAlm(@RequestParam(required = false) int battGroupId){ |
| | | Response res=service.getResBattAlm(battGroupId); |
| | | return res; |
| | | } |
| | | }*/ |
| | | |
| | | @ApiOperation("查询电池告警") |
| | | @GetMapping("getBattAlarm") |
| | | public Response getBattAlarm(@RequestParam(required = false) int almLevel,@RequestParam String startTime,@RequestParam String endTime |
| | | @ApiOperation("查询告警-分页") |
| | | @GetMapping("getPage") |
| | | public Response getPage(@RequestParam(required = false) Integer almLevel,@RequestParam String startTime,@RequestParam String endTime |
| | | ,@RequestParam int pageNum,@RequestParam int pageSize){ |
| | | Response res=service.getBattAlarm(almLevel,startTime,endTime,pageNum,pageSize); |
| | | return res; |
| | | return service.getPage(almLevel,startTime,endTime,pageNum,pageSize); |
| | | } |
| | | |
| | | @ApiOperation("确认告警") |
| | | @GetMapping("confirmAlarm") |
| | | public Response confirmAlarm(@RequestParam int num){ |
| | | Response res=service.confirmAlarm(num); |
| | | return res; |
| | | return service.confirmAlarm(num); |
| | | } |
| | | @ApiOperation("取消告警") |
| | | @GetMapping("cancleAlarm") |
| | | public Response cancleAlarm(@RequestParam int num){ |
| | | Response res=service.cancleAlarm(num); |
| | | return res; |
| | | @ApiOperation("告警确认取消") |
| | | @GetMapping("cancelAlarm") |
| | | public Response cancelAlarm(@RequestParam int num){ |
| | | return service.cancelAlarm(num); |
| | | } |
| | | |
| | | @ApiOperation("查询电池组历史时间告警") |
| | | @GetMapping("getHisAlarm") |
| | | public Response getHisAlarm(@RequestParam int binfId,@RequestParam String startTime,@RequestParam String endTime |
| | | @ApiOperation("查询电池告警历史-分页") |
| | | @GetMapping("getHistoryPage") |
| | | public Response getHistoryPage(@RequestParam(required = false) Integer almLevel,@RequestParam String startTime,@RequestParam String endTime |
| | | , @RequestParam int pageNum, @RequestParam int pageSize) throws ParseException, InterruptedException { |
| | | Response res=hisService.getHisAlarm(binfId,startTime,endTime,pageNum,pageSize); |
| | | return res; |
| | | return hisService.getHistoryPage(almLevel,startTime,endTime,pageNum,pageSize); |
| | | } |
| | | } |
| | |
| | | |
| | | public interface BattAlarmMapper extends CustomMapper<BattAlarm>{ |
| | | //查询电池告警 |
| | | List<BattAlarm> getBattAlarm(int almLevel, Date startTime, Date endTime); |
| | | List<BattAlarm> getList(Integer almLevel, Date startTime, Date endTime); |
| | | //在用电池组实时推送告警信息 |
| | | List<BattAlarm> getResBattAlm(int binfId); |
| | | List<BattAlarm> getResBattAlm(int battGroupId); |
| | | //查询电池告警(2024。4.15修改) |
| | | List<BattAlarm> getAlm2(Integer battGroupId); |
| | | } |
| | |
| | | |
| | | @TableField("binf_id") |
| | | @ApiModelProperty("电池组id") |
| | | private Integer binfId; |
| | | private Integer battGroupId; |
| | | |
| | | @TableField("alm_start_time") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty("电池组名称") |
| | | private String binfName; |
| | | private String battGroupName; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty("电源名称") |
| | | private String powerName; |
| | | } |
| | |
| | | |
| | | @TableField("binf_id") |
| | | @ApiModelProperty("电池组id") |
| | | private Integer binfId; |
| | | private Integer battGroupId; |
| | | |
| | | @TableField("alm_start_time") |
| | | @ApiModelProperty("告警开始时间") |
| | |
| | | private SubTablePageInfoUtil util; |
| | | |
| | | //查询电池组历史时间告警 |
| | | public Response getHisAlarm(int binfId, String startTime, String endTime,int pageNum,int pageSize)throws ParseException, InterruptedException { |
| | | public Response getHistoryPage(Integer almLevel, String startTime, String endTime,int pageNum,int pageSize)throws ParseException, InterruptedException { |
| | | BattAlarmHistory his=new BattAlarmHistory(); |
| | | his.setBinfId(binfId); |
| | | his.setAlmLevel(almLevel); |
| | | PageInfo pageInfo=util.getPageInfo(pageNum,pageSize, ThreadLocalUtil.parse(startTime,1),ThreadLocalUtil.parse(endTime,1) |
| | | ,"db_alarm","batt_alarm_history",his); |
| | | return new Response().setII(1,pageInfo.getList()!=null,pageInfo,"查询电池组历史时间告警"); |
| | | return new Response().setII(1,pageInfo.getList()!=null,pageInfo,"查询电池告警历史-分页"); |
| | | } |
| | | } |
| | |
| | | /* |
| | | 在用电池组实时推送告警信息 |
| | | **/ |
| | | public Response getResBattAlm(int binfId) { |
| | | List<BattAlarm> list=mapper.getResBattAlm(binfId); |
| | | public Response getResBattAlm(int battGroupId) { |
| | | List<BattAlarm> list=mapper.getResBattAlm(battGroupId); |
| | | return new Response().setII(1,list!=null,list,"在用电池组实时推送告警信息"); |
| | | } |
| | | //查询电池告警 |
| | | public Response getBattAlarm(int almLevel, String startTime, String endTime ,int pageNum, int pageSize) { |
| | | public Response getPage(Integer almLevel, String startTime, String endTime ,int pageNum, int pageSize) { |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<BattAlarm> list=mapper.getBattAlarm(almLevel, ThreadLocalUtil.parse(startTime,1),ThreadLocalUtil.parse(endTime,1)); |
| | | List<BattAlarm> list=mapper.getList(almLevel, ThreadLocalUtil.parse(startTime,1),ThreadLocalUtil.parse(endTime,1)); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list!=null,pageInfo,"查询电池告警"); |
| | | return new Response().setII(1,list!=null,pageInfo,"查询分页"); |
| | | } |
| | | //确认告警 |
| | | public Response confirmAlarm(int num) { |
| | |
| | | return new Response().set(1,flag>0); |
| | | } |
| | | //取消告警 |
| | | public Response cancleAlarm(int num) { |
| | | public Response cancelAlarm(int num) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("num",num); |
| | | wrapper.set("alm_confirm",0); |
| | |
| | | //电池告警历史实时计算每张表查询总数 |
| | | public int getBattHisCount(BattAlarmHistory battAlarmHistory) { |
| | | String sql="SELECT count(*) as number FROM db_alarm."+ battAlarmHistory.getRecordYear()+" history " + |
| | | " where history.binf_id="+ battAlarmHistory.getBinfId() ; |
| | | " where 1=1" ; |
| | | if (battAlarmHistory.getAlmLevel()!=null){ |
| | | sql+=" and history.alm_level="+ battAlarmHistory.getAlmLevel(); |
| | | } |
| | | if(battAlarmHistory.getAlmStartTime()!=null){ |
| | | sql+=" and alm_start_time >='"+ ThreadLocalUtil.format(battAlarmHistory.getAlmStartTime(),1)+"' "; |
| | | } |
| | |
| | | //电池告警历史实时 |
| | | public List<BattAlarmHistory> getBattHisList(BattAlarmHistory battAlarmHistory) { |
| | | String sql="SELECT * FROM db_alarm."+ battAlarmHistory.getRecordYear()+" history " + |
| | | " where history.binf_id="+ battAlarmHistory.getBinfId() ; |
| | | " where 1=1"; |
| | | if(battAlarmHistory.getAlmLevel()!=null){ |
| | | sql+=" and history.alm_level="+ battAlarmHistory.getAlmLevel(); |
| | | } |
| | | if(battAlarmHistory.getAlmStartTime()!=null){ |
| | | sql+=" and alm_start_time >='"+ ThreadLocalUtil.format(battAlarmHistory.getAlmStartTime(),1)+"' "; |
| | | } |
| | |
| | | while (rs.next()){ |
| | | BattAlarmHistory data=new BattAlarmHistory(); |
| | | data.setNum(rs.getInt("num")); |
| | | data.setBinfId(rs.getInt("binf_id")); |
| | | data.setBattGroupId(rs.getInt("binf_id")); |
| | | data.setAlmStartTime(rs.getTimestamp("alm_start_time")); |
| | | data.setAlmEndTime(rs.getTimestamp("alm_end_time")); |
| | | data.setMonNum(rs.getInt("mon_num")); |
| | |
| | | @Autowired |
| | | private UserInfService userInfService; |
| | | |
| | | //按年月分表 |
| | | /**按年份表分页查询*/ |
| | | public PageInfo<Object> getPageInfo(int pageNum,int pageSize, |
| | | Date startTime,Date endTime, |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.whyc.mapper.BattAlarmMapper"> |
| | | |
| | | <select id="getBattAlarm" resultType="com.whyc.pojo.db_alarm.BattAlarm"> |
| | | select batt_alarm.*,power_inf.binf_name from db_alarm.batt_alarm,db_batt.power_inf |
| | | <select id="getList" resultType="com.whyc.pojo.db_alarm.BattAlarm"> |
| | | select batt_alarm.*,batt_alarm.binf_id as battGroupId,power_inf.binf_name as battGroupName,power_inf.power_name from db_alarm.batt_alarm,db_batt.power_inf |
| | | <where> |
| | | batt_alarm.binf_id=power_inf.binf_id |
| | | and batt_alarm.alm_start_time>=#{startTime} |
| | |
| | | select batt_alarm.*,power_inf.binf_name from db_alarm.batt_alarm,db_batt.power_inf |
| | | <where> |
| | | batt_alarm.binf_id=power_inf.binf_id |
| | | and batt_alarm.binf_id=#{binfId} |
| | | and batt_alarm.binf_id=#{battGroupId} |
| | | order by batt_alarm.alm_start_time desc |
| | | </where> |
| | | </select> |