whyclxw
2025-05-08 4c0f551e508bce3e853737a57a7cb09c0fbbb56f
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.whyc.dto.Response;
import com.whyc.mapper.AlarmDetailMapper;
import com.whyc.pojo.AlarmDetail;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
@Service
public class AlarmDetailService {
 
    @Autowired(required = false)
    private AlarmDetailMapper mapper;
 
    //根据almId查询告警详情
    public Response getDetailByAlmId(String almId, int highorlow) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.like("alm_id", almId);
        wrapper.eq("highorlow", highorlow);
        wrapper.orderByAsc("id");
        List list = mapper.selectList(wrapper);
        return new Response().setII(1, list.size() > 0, list, "告警详情");
    }
 
    //根据almId添加告警详情
    public Response addDetailByAlmId(List<AlarmDetail> list) {
        int flag = mapper.insertBatchSomeColumn(list);
        return new Response().set(1, flag, "批量添加详情");
    }
 
    //根据主键id编辑告警详情
    @Transactional
    public Response updateDetailById(List<AlarmDetail> list) {
        if (list != null && list.size() > 0) {
            for (AlarmDetail ad : list) {
                UpdateWrapper wrapper = new UpdateWrapper();
                wrapper.set("alm_reason", ad.getAlmReason());
                wrapper.set("alm_advice", ad.getAlmAdvice());
                wrapper.set("alm_type", ad.getAlmType());
                wrapper.set("highorlow", ad.getHighorlow());
                wrapper.eq("id", ad.getId());
                mapper.update((AlarmDetail) ActionUtil.objeNull, wrapper);
            }
        }
        return new Response().set(1, true);
    }
 
    //根据主键id移除告警详情
    public Response deleteDetailById(List<Integer> list) {
        int flag = mapper.deleteDetailById(list);
        return new Response().set(1, flag > 0, "移除告警详情");
    }
 
    //根据告警来源查询告警详情
    public Response searchDetailByType(int almType) {
        List<AlarmDetail> list = mapper.searchDetailByType(almType);
        return new Response().setII(1, list.size() > 0, list, "告警详情");
    }
}