whycxzp
2025-05-26 ed735ec485585cc26bb0a3cfefae320d2eaa2b9e
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.constant.DevAlmEnum;
import com.whyc.dto.DevA200AlarmDto;
import com.whyc.dto.Response;
import com.whyc.mapper.DevLithiumAlarmDataMapper;
import com.whyc.pojo.db_alarm.DevLithiumAlarmData;
import com.whyc.pojo.db_user.UserInf;
import com.whyc.util.ActionUtil;
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.Date;
import java.util.List;
import java.util.Map;
 
@Service
public class DevLithiumAlarmDataService {
 
    @Autowired(required = false)
    private DevLithiumAlarmDataMapper mapper;
 
    @Autowired(required = false)
    private SubTablePageInfoUtil service;
 
    @Autowired(required = false)
    private UserInfService uerInfService;
 
    //获取设备告警信息
    public Response getPage(int uid, DevA200AlarmDto dto) {
        PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
        dto.setUid(uid);
        List<DevLithiumAlarmData> list=mapper.getDevAlmInf(dto);
        for (DevLithiumAlarmData data:list) {
            UserInf uinf=uerInfService.getUinfByUId(data.getConfirmedUid());
            data.setConfirmedUname(uinf!=null?uinf.getUname():"");
            int almId=data.getAlmId();
            data.setAlmName(DevAlmEnum.getValue(almId));
        }
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,null);
    }
    //获取历史告警
    public Response getPage(DevA200AlarmDto dto) throws ParseException {
        UserInf uinf= ActionUtil.getUser();
        dto.setUid(uinf.getUid());
        if(dto.getStartTime()==null){
            dto.setStartTime(ThreadLocalUtil.parse("2024-01-01 00:00:00",1));
        }
        if(dto.getEndTime()==null){
            dto.setEndTime(new Date());
        }
        PageInfo pageInfo=service.getPageInfo(dto.getPageNum(),dto.getPageSize(),dto.getStartTime(),dto.getEndTime()
                ,"db_alarm", "tb_devalarm_data", dto);
        return new Response().setII(1,pageInfo!=null,pageInfo,null);
    }
   //确认实时告警
    public Response confirm(int num) {
        UserInf uinf= ActionUtil.getUser();
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.set("alm_is_confirmed",1);
        wrapper.set("confirmed_uid",uinf.getUid());
        wrapper.set("confirmed_time",new Date());
        wrapper.eq("num",num);
        int flag=mapper.update((DevLithiumAlarmData) ActionUtil.objeNull,wrapper);
        return new Response().set(1,flag>0,null);
    }
    //获取所有的告警类型
    public Response getAllAlmName() {
        Map<Integer,String> map=DevAlmEnum.getOpInfo();
        return new Response().setII(1,true,map,null);
    }
    //弹窗告警
    public Response getPopup(Integer uid) {
        List<DevLithiumAlarmData> list=mapper.getPopup(uid);
        for (DevLithiumAlarmData data:list) {
            int almId=data.getAlmId();
            data.setAlmName(DevAlmEnum.getValue(almId));
        }
        return new Response().setII(1,list!=null,list,null);
    }
}