| | |
| | | private LockAlarmHisService service; |
| | | @ApiOperation("查询锁告警的历史状态") |
| | | @GetMapping("getLockAlmHis") |
| | | public Response getLockAlmHis(@RequestParam Integer lockId,@RequestParam Integer almId, @RequestParam String startTime, @RequestParam String endTime |
| | | public Response getLockAlmHis(@RequestParam Integer areaId,@RequestParam Integer almId, @RequestParam String startTime, @RequestParam String endTime |
| | | , @RequestParam int pageNum, @RequestParam int pageSize) throws ParseException, InterruptedException { |
| | | Response res=service.getLockAlmHis(lockId,almId,startTime,endTime,pageNum,pageSize); |
| | | Response res=service.getLockAlmHis(areaId,almId,startTime,endTime,pageNum,pageSize); |
| | | return res; |
| | | } |
| | | } |
| | |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2025-02-05 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | @ApiModel(value="LockAlarmHis对象", description="2025年电子锁具历史告警表") |
| | | public class LockAlarmHis implements Serializable { |
| | | |
| | |
| | | |
| | | @TableField(exist = false) |
| | | private LockInf linf; |
| | | |
| | | @TableField(exist = false) |
| | | private List<Integer> lids; |
| | | |
| | | } |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.LockInfMapper; |
| | | import com.whyc.pojo.db_area.LockInf; |
| | | import com.whyc.pojo.db_lock_alarm.LockAlarmHis; |
| | | import com.whyc.pojo.db_lock_his.LockHis; |
| | | import com.whyc.util.SubTablePageInfoUtil; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class LockAlarmHisService { |
| | | @Autowired |
| | | private SubTablePageInfoUtil util; |
| | | |
| | | @Autowired |
| | | private AreaInfService areaInfService; |
| | | |
| | | @Autowired(required = false) |
| | | private LockInfMapper lockInfMapper; |
| | | |
| | | |
| | | //查询锁告警的历史状态 |
| | | public Response getLockAlmHis(Integer lockId, Integer almId,String startTime, String endTime, int pageNum, int pageSize) throws ParseException { |
| | | public Response getLockAlmHis(Integer areaId, Integer almId,String startTime, String endTime, int pageNum, int pageSize) throws ParseException { |
| | | LockAlarmHis his=new LockAlarmHis(); |
| | | his.setLockId(lockId); |
| | | if(areaId!=null){ |
| | | List<Integer> areaList=new ArrayList(); |
| | | areaList.add(areaId); |
| | | areaInfService.getAllAreaId(areaId,areaList); |
| | | //根据区域查询所有的锁 |
| | | if(areaList!=null){ |
| | | QueryWrapper wrapper1=new QueryWrapper(); |
| | | wrapper1.in("area_id",areaList); |
| | | List<LockInf> lockInfList=lockInfMapper.selectList(wrapper1); |
| | | List<Integer> lockIdList = lockInfList.stream() |
| | | .map(LockInf::getLockId) // 提取id值 |
| | | .collect(Collectors.toList()); // 转换为列表*/ |
| | | his.setLids(lockIdList); |
| | | } |
| | | } |
| | | his.setAlmId(almId); |
| | | PageInfo pageInfo=util.getPageInfo(pageNum,pageSize, ThreadLocalUtil.parse(startTime,1),ThreadLocalUtil.parse(endTime,1) |
| | | ,"db_lock_alarm","tb_lock_alarm",his); |
| | |
| | | //锁的告警历史记录总数 |
| | | public int getLockAlmHisCount(LockAlarmHis his) { |
| | | String sql="SELECT count(*) as number FROM db_lock_alarm."+ his.getRecordYear()+" history " + |
| | | " where history.lock_id="+ his.getLockId() ; |
| | | " where 1=1 "; |
| | | if(his.getLids()!=null&&his.getLids().size()>0){ |
| | | List<Integer> lids=his.getLids(); |
| | | sql+=" and history.lock_id in ("; |
| | | for (int i=0;i<lids.size();i++) { |
| | | if(i==lids.size()-1){ |
| | | sql=sql+lids.get(i)+") "; |
| | | }else{ |
| | | sql=sql+lids.get(i)+","; |
| | | } |
| | | } |
| | | } |
| | | if(his.getStartTime()!=null){ |
| | | sql+=" and alm_start_time >='"+ ThreadLocalUtil.format(his.getStartTime(),1)+"' "; |
| | | } |
| | |
| | | //锁的告警历史记录 |
| | | public List<LockAlarmHis> getLockAlmHisList(LockAlarmHis his) { |
| | | String sql="SELECT * FROM db_lock_alarm."+ his.getRecordYear()+" history " + |
| | | " where history.lock_id="+ his.getLockId() ; |
| | | " where 1=1 " ; |
| | | if(his.getLids()!=null&&his.getLids().size()>0){ |
| | | List<Integer> lids=his.getLids(); |
| | | sql+=" and history.lock_id in ("; |
| | | for (int i=0;i<lids.size();i++) { |
| | | if(i==lids.size()-1){ |
| | | sql=sql+lids.get(i)+") "; |
| | | }else{ |
| | | sql=sql+lids.get(i)+","; |
| | | } |
| | | } |
| | | } |
| | | if(his.getStartTime()!=null){ |
| | | sql+=" and alm_start_time >='"+ ThreadLocalUtil.format(his.getStartTime(),1)+"' "; |
| | | } |