whyclxw
2024-12-12 2e9d51ac8b7835f2b002eb686f23304da4c3559e
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
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.dto.Response;
import com.whyc.mapper.PowerAlarmMapper;
import com.whyc.pojo.db_alarm.BattAlarm;
import com.whyc.pojo.db_power_alarm.PowerAlarm;
import com.whyc.util.ActionUtil;
import com.whyc.util.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
public class PowerAlarmService {
 
    @Autowired(required = false)
    private PowerAlarmMapper mapper;
 
    /*
     在用电源实时推送告警信息
     **/
    public Response getResPowerAlm(int pinfId) {
        List<PowerAlarm> list=mapper.getResPowerAlm(pinfId);
        return new Response().setII(1,list!=null,list,"在用电源实时推送告警信息");
    }
    //查询电源告警
    public Response getPowerAlarm(int 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));
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"查询电源告警");
    }
    //确认告警
    public Response confirmAlarm(int num) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("num",num);
        wrapper.set("alm_confirm",1);
        int flag=mapper.update((PowerAlarm) ActionUtil.objeNull,wrapper);
        return new Response().set(1,flag>0);
    }
    //取消告警
    public Response cancleAlarm(int num) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("num",num);
        wrapper.set("alm_confirm",0);
        int flag=mapper.update((PowerAlarm) ActionUtil.objeNull,wrapper);
        return new Response().set(1,flag>0);
    }
}