whyclxw
2025-02-17 70f6a8d6b295e8149e209b9ca9add886c57a4e11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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,"查询锁告警的历史状态");
    }
}