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 com.whyc.util.ThreadLocalUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
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 areaId, String almIds,String startTime, String endTime, int pageNum, int pageSize) throws ParseException {
|
LockAlarmHis his=new LockAlarmHis();
|
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.setAlmIds(almIds);
|
PageInfo pageInfo=util.getPageInfo(pageNum,pageSize, ThreadLocalUtil.parse(startTime,1),ThreadLocalUtil.parse(endTime,1)
|
,"db_lock_alarm","tb_lock_alarm",his);
|
return new Response().setII(1,pageInfo.getList()!=null,pageInfo,"查询锁告警的历史状态");
|
}
|
}
|