| | |
| | | import java.text.ParseException; |
| | | |
| | | @RestController |
| | | @Api(tags = "电源实时告警") |
| | | @RequestMapping("poweralarm") |
| | | @Api(tags = "电源告警") |
| | | @RequestMapping("powerAlarm") |
| | | public class PowerAlarmController { |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private PowerAlarmHistoryService hisService; |
| | | |
| | | @ApiOperation("在用电源实时推送告警信息") |
| | | /*@ApiOperation("在用电源实时推送告警信息") |
| | | @GetMapping("getResPowerAlm") |
| | | public Response getResPowerAlm(@RequestParam(required = false) int pinfId){ |
| | | Response res=service.getResPowerAlm(pinfId); |
| | | return res; |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | @ApiOperation("查询电源告警") |
| | | @GetMapping("getPowerAlarm") |
| | | public Response getPowerAlarm(@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.getPowerAlarm(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 pinfId,@RequestParam String startTime,@RequestParam String endTime |
| | | @ApiOperation("查询历史-分页") |
| | | @GetMapping("getHisPage") |
| | | public Response getHisPage(@RequestParam(required = false) Integer almLevel,@RequestParam String startTime,@RequestParam String endTime |
| | | , @RequestParam int pageNum, @RequestParam int pageSize) throws ParseException, InterruptedException { |
| | | Response res=hisService.getHisAlarm(pinfId,startTime,endTime,pageNum,pageSize); |
| | | Response res=hisService.getHisPage(almLevel,startTime,endTime,pageNum,pageSize); |
| | | return res; |
| | | } |
| | | } |
| | |
| | | |
| | | public interface PowerAlarmMapper extends CustomMapper<PowerAlarm>{ |
| | | //查询电源告警 |
| | | List<PowerAlarm> getPowerAlarm(int almLevel, Date startTime, Date endTime); |
| | | List<PowerAlarm> getList(Integer almLevel, Date startTime, Date endTime); |
| | | |
| | | //在用电源实时推送告警信息 |
| | | List<PowerAlarm> getResPowerAlm(int pinfId); |
| | |
| | | private SubTablePageInfoUtil util; |
| | | |
| | | //查询电源历史时间告警 |
| | | public Response getHisAlarm(int pinfId, String startTime, String endTime, int pageNum, int pageSize) throws ParseException { |
| | | public Response getHisPage(Integer almLevel, String startTime, String endTime, int pageNum, int pageSize) throws ParseException { |
| | | PowerAlarmHistory his=new PowerAlarmHistory(); |
| | | his.setPowerId(pinfId); |
| | | his.setAlmLevel(almLevel); |
| | | PageInfo pageInfo=util.getPageInfo(pageNum,pageSize, ThreadLocalUtil.parse(startTime,1),ThreadLocalUtil.parse(endTime,1) |
| | | ,"db_power_alarm","power_alarm_history",his); |
| | | return new Response().setII(1,pageInfo.getList()!=null,pageInfo,"查询电源历史时间告警"); |
| | | return new Response().setII(1,pageInfo.getList()!=null,pageInfo,"查询历史-分页"); |
| | | } |
| | | } |
| | |
| | | return new Response().setII(1,list!=null,list,"在用电源实时推送告警信息"); |
| | | } |
| | | //查询电源告警 |
| | | public Response getPowerAlarm(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<PowerAlarm> list=mapper.getPowerAlarm(almLevel, ThreadLocalUtil.parse(startTime,1),ThreadLocalUtil.parse(endTime,1)); |
| | | List<PowerAlarm> 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); |
| | |
| | | if(battAlarmHistory.getAlmEndTime()!=null){ |
| | | sql+=" and alm_start_time <='"+ThreadLocalUtil.format(battAlarmHistory.getAlmEndTime(),1)+"' "; |
| | | } |
| | | sql+=" ORDER BY alm_start_time asc limit "+ battAlarmHistory.getLimitStart()+","+ battAlarmHistory.getLimitEnd()+" "; |
| | | sql+=" ORDER BY alm_start_time desc limit "+ battAlarmHistory.getLimitStart()+","+ battAlarmHistory.getLimitEnd()+" "; |
| | | List<BattAlarmHistory> list=sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | |
| | | //电源告警历史实时计算每张表查询总数 |
| | | public int getPowerHisCount(PowerAlarmHistory powerAlarmHistory) { |
| | | String sql="SELECT count(*) as number FROM db_power_alarm."+ powerAlarmHistory.getRecordYear()+" history " + |
| | | " where history.power_id="+ powerAlarmHistory.getPowerId() ; |
| | | " where 1=1"; |
| | | if(powerAlarmHistory.getAlmLevel()!=null){ |
| | | sql+= " and history.alm_level="+ powerAlarmHistory.getAlmLevel(); |
| | | } |
| | | if(powerAlarmHistory.getAlmStartTime()!=null){ |
| | | sql+=" and alm_start_time >='"+ ThreadLocalUtil.format(powerAlarmHistory.getAlmStartTime(),1)+"' "; |
| | | } |
| | |
| | | //电源告警历史实时 |
| | | public List<PowerAlarmHistory> getPowerHisList(PowerAlarmHistory powerAlarmHistory) { |
| | | String sql="SELECT * FROM db_power_alarm."+ powerAlarmHistory.getRecordYear()+" history " + |
| | | " where history.power_id="+ powerAlarmHistory.getPowerId() ; |
| | | " where 1=1"; |
| | | if(powerAlarmHistory.getAlmLevel()!=null){ |
| | | sql+= " and history.alm_level="+ powerAlarmHistory.getAlmLevel(); |
| | | } |
| | | if(powerAlarmHistory.getAlmStartTime()!=null){ |
| | | sql+=" and alm_start_time >='"+ ThreadLocalUtil.format(powerAlarmHistory.getAlmStartTime(),1)+"' "; |
| | | } |
| | | if(powerAlarmHistory.getAlmEndTime()!=null){ |
| | | sql+=" and alm_start_time <='"+ThreadLocalUtil.format(powerAlarmHistory.getAlmEndTime(),1)+"' "; |
| | | } |
| | | sql+=" ORDER BY alm_start_time asc limit "+ powerAlarmHistory.getLimitStart()+","+ powerAlarmHistory.getLimitEnd()+" "; |
| | | sql+=" ORDER BY alm_start_time desc limit "+ powerAlarmHistory.getLimitStart()+","+ powerAlarmHistory.getLimitEnd()+" "; |
| | | List<PowerAlarmHistory> list=sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.whyc.mapper.PowerAlarmMapper"> |
| | | |
| | | <select id="getPowerAlarm" resultType="com.whyc.pojo.db_power_alarm.PowerAlarm"> |
| | | <select id="getList" resultType="com.whyc.pojo.db_power_alarm.PowerAlarm"> |
| | | select power_alarm.*,power_inf.power_name from db_power_alarm.power_alarm,db_batt.power_inf |
| | | <where> |
| | | power_alarm.power_id=power_inf.power_id |