admin
2024-02-20 435bc751b10bf5868182219bc4c0851ab7674cd7
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
package com.ruoyi.aibrain.service.impl;
 
import java.util.*;
 
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.aibrain.mapper.AiAlarmInfoMapper;
import com.ruoyi.aibrain.domain.AiAlarmInfo;
import com.ruoyi.aibrain.service.IAiAlarmInfoService;
 
/**
 * 报警信息管理Service业务层处理
 *
 * @author wf
 * @date 2023-03-08
 */
@Service
public class AiAlarmInfoServiceImpl implements IAiAlarmInfoService
{
    @Autowired
    private AiAlarmInfoMapper aiAlarmInfoMapper;
 
    /**
     * 查询报警信息管理
     *
     * @param id 报警信息管理主键
     * @return 报警信息管理
     */
    @Override
    public AiAlarmInfo selectAiAlarmInfoById(Long id)
    {
        return aiAlarmInfoMapper.selectAiAlarmInfoById(id);
    }
 
    /**
     * 查询报警信息管理列表
     *
     * @param aiAlarmInfo 报警信息管理
     * @return 报警信息管理
     */
    @Override
    public List<AiAlarmInfo> selectAiAlarmInfoList(AiAlarmInfo aiAlarmInfo)
    {
        return aiAlarmInfoMapper.selectAiAlarmInfoList(aiAlarmInfo);
    }
 
    /**
     * 新增报警信息管理
     *
     * @param aiAlarmInfo 报警信息管理
     * @return 结果
     */
    @Override
    public int insertAiAlarmInfo(AiAlarmInfo aiAlarmInfo)
    {
        return aiAlarmInfoMapper.insertAiAlarmInfo(aiAlarmInfo);
    }
 
    /**
     * 修改报警信息管理
     *
     * @param aiAlarmInfo 报警信息管理
     * @return 结果
     */
    @Override
    public int updateAiAlarmInfo(AiAlarmInfo aiAlarmInfo)
    {
        return aiAlarmInfoMapper.updateAiAlarmInfo(aiAlarmInfo);
    }
 
    /**
     * 批量删除报警信息管理
     *
     * @param ids 需要删除的报警信息管理主键
     * @return 结果
     */
    @Override
    public int deleteAiAlarmInfoByIds(Long[] ids)
    {
        return aiAlarmInfoMapper.deleteAiAlarmInfoByIds(ids);
    }
 
    /**
     * 删除报警信息管理信息
     *
     * @param id 报警信息管理主键
     * @return 结果
     */
    @Override
    public int deleteAiAlarmInfoById(Long id)
    {
        return aiAlarmInfoMapper.deleteAiAlarmInfoById(id);
    }
 
    /**
     * 三违报警统计
     *
     * @param aiAlarmInfo 报警信息管理
     * @return 结果
     */
    @Override
    public int countSanWeiAlarm(AiAlarmInfo aiAlarmInfo) {
        return aiAlarmInfoMapper.countSanWeiAlarm(aiAlarmInfo);
    }
 
    /**
     * 隐患报警统计
     *
     * @param aiAlarmInfo 报警信息管理
     * @return 结果
     */
    @Override
    public int countYinHuanAlarm(AiAlarmInfo aiAlarmInfo) {
        return aiAlarmInfoMapper.countYinHuanAlarm(aiAlarmInfo);
    }
 
    /**
     * 智能识别仪报警统计
     *
     * @param aiAlarmInfo 报警信息管理
     * @return 结果
     */
    @Override
    public int countAllAlarm(AiAlarmInfo aiAlarmInfo) {
        return aiAlarmInfoMapper.countAllAlarm(aiAlarmInfo);
    }
 
    /**
     * 报警信息分析统计
     * @param aiAlarmInfo 报警信息管理
     * @return 结果
     */
    @Override
    public Map<String, Object> countAlarmByTimeAndType(AiAlarmInfo aiAlarmInfo) {
        Map<String, Object> result = new HashMap<>();
        List<Map<String,Object>> personResult = new ArrayList<>();
        List<Map<String,Object>> thingResult = new ArrayList<>();
        List<Map<String,Object>> ambientResult = new ArrayList<>();
        aiAlarmInfo.setSmallClass("1");
        List<Map<String,Object>> persons = aiAlarmInfoMapper.countAlarmByTimeAndType(aiAlarmInfo);//人员
        aiAlarmInfo.setSmallClass("3");
        List<Map<String,Object>> things = aiAlarmInfoMapper.countAlarmByTimeAndType(aiAlarmInfo);//异物
        aiAlarmInfo.setSmallClass("2");
        List<Map<String,Object>> ambients = aiAlarmInfoMapper.countAlarmByTimeAndType(aiAlarmInfo);//环境
 
        for (int i = aiAlarmInfo.getDays(); i >= 0; i--) {
            String days = DateUtils.getDateTime(new Date(),i);
            Map<String,Object> per = new HashMap<>();
            per.put("days",days);
            Map<String,Object> thi = new HashMap<>();
            thi.put("days",days);
            Map<String,Object> amb = new HashMap<>();
            amb.put("days",days);
            for (Map<String,Object> person : persons){
                if (days.equals(person.get("days").toString())){
                    per.put("value",person.get("count"));
                    break;
                }
            }
            if (!per.containsKey("value")){
                per.put("value",0);
            }
            personResult.add(per);
            for (Map<String,Object> thing : things){
                if (days.equals(thing.get("days").toString())){
                    thi.put("value",thing.get("count"));
                    break;
                }
            }
            if (!thi.containsKey("value")){
                thi.put("value",0);
            }
            thingResult.add(thi);
            for (Map<String,Object> ambient : ambients){
                if (days.equals(ambient.get("days").toString())){
                    amb.put("value",ambient.get("count"));
                    break;
                }
            }
            if (!amb.containsKey("value")){
                amb.put("value",0);
            }
            ambientResult.add(amb);
        }
        result.put("person",personResult);
        result.put("thing",thingResult);
        result.put("ambient",ambientResult);
        return result;
    }
 
    /**
     * 年度报警统计
     * @return 结果
     */
    @Override
    public int countAlarmInYear() {
        return aiAlarmInfoMapper.countAlarmInYear();
    }
 
    /**
     * 月度报警统计
     * @return 结果
     */
    @Override
    public int countAlarmInMonth() {
        return aiAlarmInfoMapper.countAlarmInMonth();
    }
 
    /**
     * 本年区域报警Top排序
     * @return 结果
     */
    @Override
    public List<Map<String, Object>> selectCountAlarmByRegion() {
        return aiAlarmInfoMapper.selectCountAlarmByRegion();
    }
 
    /**
     * 本年报警类型统计
     * @return 结果
     */
    @Override
    public List<Map<String, Object>> selectCountAlarmBySmall() {
        return aiAlarmInfoMapper.selectCountAlarmBySmall();
    }
 
    /**
     * 实时报警:未处理的最新十条
     * @return 结果
     */
    @Override
    public List<AiAlarmInfo> selectAlarmInfoNew() {
        return aiAlarmInfoMapper.selectAlarmInfoNew();
    }
 
    /**
     * 根据报警参数查询最新日期的报警
     * @return 结果
     */
    @Override
    public AiAlarmInfo selectAlarmInfo(AiAlarmInfo aiAlarmInfo) {
        return aiAlarmInfoMapper.selectAlarmInfo(aiAlarmInfo);
    }
}