zhitong.yu
7 天以前 7fc9c42987a13c1d8d2159591a5803e70518827f
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.hxzk.gps.controller.Warning;
 
import cn.dev33.satoken.annotation.SaCheckLogin;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxzk.gps.controller.Warning.dto.TableSearchResult.TableSearchResult;
import com.hxzk.gps.entity.Person.TbPerson;
import com.hxzk.gps.entity.Warning.TbWarning;
import com.hxzk.gps.mapper.Warning.TbWarningMapper;
import com.hxzk.gps.result.ListDataResult;
import com.hxzk.gps.result.ResultTable;
 
import com.hxzk.gps.result.table;
import com.hxzk.gps.service.Company.TbCompanyService;
import com.hxzk.gps.service.Person.TbPersonService;
import com.hxzk.gps.service.Warning.TbWarningService;
import com.hxzk.gps.util.GetUser.UserInfoUtil;
import com.hxzk.gps.util.MessageUtils.MessageUtils;
import com.hxzk.gps.util.Result.ReturnMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author YuZhiTong
 * @since 2025-05-23
 */
@RestController
@RequestMapping("/Warning")
@Api("告警管理")
public class TbWarningController {
    @Autowired
    TbWarningService warningService;
 
    @Autowired
    TbWarningMapper warningMapper;
 
    @Autowired
    TbPersonService personService;
 
    @Autowired
    TbCompanyService companyService;
 
    @SaCheckLogin
    @ApiOperation(value = "平台告警列表接口", notes = "该接口提供了平台告警列表的信息查询功能")
    @PostMapping("FindWarningInfo")
    public ResultTable FindWarningInfo(@RequestBody TableSearchResult TableSearchResult){
        return warningService.FindWarningInfo(TableSearchResult);
    }
 
    @SaCheckLogin
    @ApiOperation(value = "平台公司未处理告警列表接口", notes = "该接口提供了平台公司未处理告警列表的信息查询功能")
    @PostMapping("FindWarningUntreated")
    public ResultTable FindWarningUntreated(@RequestBody TableSearchResult TableSearchResult){
        return warningService.FindWarningUntreated(TableSearchResult);
    }
 
    @SaCheckLogin
    @ApiOperation(value = "告警全部处理接口", notes = "该接口提供了平台告警全部处理功能")
    @PostMapping("AllHandle")
    public ReturnMessage AllHandle(){
        return warningService.AllHandle();
    }
 
    @SaCheckLogin
    @ApiOperation(value = "告警处理接口", notes = "该接口提供了平台告警处理功能")
    @PostMapping("Handle")
    public ReturnMessage Handle(@RequestBody TbWarning warning){
        return warningService.Handle(warning);
    }
 
 
    @SaCheckLogin
    @ApiOperation(value = "平台统计分析告警接口", notes = "该接口提供了平台统计分析告警功能")
    @PostMapping("FindWarningAll")
    public List<TbWarning> FindWarningAll(){
        return warningMapper.FindWarningAll(UserInfoUtil.getUserCompany());
    }
    @SaCheckLogin
    @ApiOperation(value = "平台根据告警类型查询接口", notes = "该接口提供了平台根据告警类型查询功能")
    @PostMapping("FindWarningInfoType")
    public ResultTable FindWarningInfoType(@RequestBody TableSearchResult TableSearchResult){
        QueryWrapper queryWrapper = new QueryWrapper<>();
        PageHelper.startPage(TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize());
        PageInfo<TbPerson> infoNoPerson = new PageInfo<>();
        List<Long> list = companyService.getChildCompanyIds(UserInfoUtil.getUserCompanyId());
        switch (TableSearchResult.getWarning().getType()){
            case "SOS报警":
                PageInfo<TbWarning> infoNoWarningSOS = new PageInfo<>(warningMapper.FindWarningInfoType(list,"SOS"));
                table<TbWarning> infoWarningSOS = new table<>(infoNoWarningSOS.getList(),TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize(),infoNoPerson.getTotal());
                return ListDataResult.resultTableSuccess(infoWarningSOS, MessageUtils.getMessage("Success"));
            case "聚集报警":
                PageInfo<TbWarning> infoNoWarningJuJi = new PageInfo<>(warningMapper.FindWarningInfoType(list,"聚集告警"));
                table<TbWarning> infoWarningJuJi = new table<>(infoNoWarningJuJi.getList(),TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize(),infoNoPerson.getTotal());
                return ListDataResult.resultTableSuccess(infoWarningJuJi, MessageUtils.getMessage("Success"));
            case "越界报警":
                PageInfo<TbWarning> infoNoWarningChuQu = new PageInfo<>(warningMapper.FindWarningInfoType(list,"出去告警"));
                table<TbWarning> infoWarningChuQu = new table<>(infoNoWarningChuQu.getList(),TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize(),infoNoPerson.getTotal());
                return ListDataResult.resultTableSuccess(infoWarningChuQu, MessageUtils.getMessage("Success"));
 
            case "进入报警":
                PageInfo<TbWarning> infoNoWarningJinRu = new PageInfo<>(warningMapper.FindWarningInfoType(list,"进入告警"));
                table<TbWarning> infoWarningJinRu = new table<>(infoNoWarningJinRu.getList(),TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize(),infoNoPerson.getTotal());
                return ListDataResult.resultTableSuccess(infoWarningJinRu, MessageUtils.getMessage("Success"));
 
            case "离线人员":
                queryWrapper.eq("p_online","0");
                queryWrapper.in("companyid", list);
                infoNoPerson = new PageInfo<>(personService.getBaseMapper().selectList(queryWrapper));
                table<TbPerson> infoPersons = new table<>(infoNoPerson.getList(),TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize(),infoNoPerson.getTotal());
                return ListDataResult.resultTableSuccess(infoPersons, MessageUtils.getMessage("Success"));
            case "在线人员":
                queryWrapper.eq("p_online","1");
                queryWrapper.in("companyid", list);
                infoNoPerson = new PageInfo<>(personService.getBaseMapper().selectList(queryWrapper));
                table<TbPerson> achortable = new table<>(infoNoPerson.getList(),TableSearchResult.getTableList().getPageNum(),TableSearchResult.getTableList().getPageSize(),infoNoPerson.getTotal());
                return ListDataResult.resultTableSuccess(achortable, MessageUtils.getMessage("Success"));
        }
        return null;
    }
}