czt
2024-07-13 b030109e665301e7edd6ad0fe5c832ee10fe39b4
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
package com.ld.igds.warn.view;
 
import com.bstek.bdf2.core.model.DefaultUser;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.provider.Page;
import com.ld.igds.constant.NoticeType;
import com.ld.igds.constant.WarnLevel;
import com.ld.igds.constant.WarnStatus;
import com.ld.igds.constant.WarnType;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.models.MWarnConf;
import com.ld.igds.models.MWarnInfo;
import com.ld.igds.sys.service.SysUserService;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.warn.data.WarnData;
import com.ld.igds.warn.service.CoreWarnService;
import com.ld.igds.warn.service.HWarnService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 警报管理
 * 
 * @author:
 *
 */
@Component
public class WarnPR {
 
    @Autowired
    private HWarnService hWarnService;
    @Autowired
    private CoreWarnService coreWarnService;
    @Autowired
    private SysUserService sysUserService;
 
    /**
     * 警告类型
     *
     * ${dorado.getDataProvider("warnPR#triggerWarnType").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerWarnType() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
        for (WarnType w:WarnType.values()) {
            list.add(new DicTrigger(w.getCode(), w.getMsg()));
        }
        //list.add(new DicTrigger(WarnType.TYPE_01.getCode(), "警告"));
        //list.add(new DicTrigger(WarnType.TYPE_02.getCode(), "预警"));
        //list.add(new DicTrigger(WarnType.TYPE_01.getCode(), "通知"));
 
        return list;
    }
 
    /**
     * 警告等级
     *
     * ${dorado.getDataProvider("warnPR#triggerWarnLevel").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerWarnLevel() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
        for (WarnLevel w:WarnLevel.values()) {
            list.add(new DicTrigger(w.getCode(), w.getMsg()));
        }
        //list.add(new DicTrigger(WarnLevel.LEVEL_01.getCode(), "一级警告"));
       // list.add(new DicTrigger(WarnLevel.LEVEL_02.getCode(), "二级警告"));
       // list.add(new DicTrigger(WarnLevel.LEVEL_03.getCode(), "三级警告"));
 
        return list;
    }
 
    /**
     * 警告状态
     *
     * ${dorado.getDataProvider("warnPR#triggerWarnStatus").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerWarnStatus() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
 
        list.add(new DicTrigger(WarnStatus.STATUS_10.getCode(), "未处理"));
        list.add(new DicTrigger(WarnStatus.STATUS_20.getCode(), "延迟处理"));
        list.add(new DicTrigger(WarnStatus.STATUS_30.getCode(), "已处理"));
        list.add(new DicTrigger(WarnStatus.STATUS_40.getCode(), "忽略"));
 
        return list;
    }
 
 
    /**
     * warnPR#listWarn
     * @param param
     * @return
     */
    @DataProvider
    public void listWarn(Page<MWarnInfo> page, Map<String,Object> param) throws Exception {
 
        if(null == param){
            param = new HashMap<>();
        }
 
        hWarnService.listWarnInfo(page, param);
    }
 
    /**
     * warnPR#saveWarn
     *
     * @param data
     */
    @DataResolver
    public void saveWarn(MWarnInfo data){
        hWarnService.saveWarnInfo(data);
    }
 
 
    /**
     * warnPR#updateWarnStatus
     * @param data
     */
    @DataResolver
    public String updateWarnStatus(MWarnInfo data) throws Exception {
        hWarnService.updateWarnStatus(data);
        return null;
    }
 
    /**
     * warnPR#delWarn
     * @param data
     * @return
     */
    @Expose
    public String delWarn(MWarnInfo data){
        return hWarnService.delWarnInfo(data);
    }
 
 
    /**
     * warnPR#testWarn 警告测试
     */
    @Expose
    public String testWarn(WarnData data) {
        if(data == null || StringUtils.isEmpty(data.getPhone())){
            return "手机号不能为空!";
        }
        return coreWarnService.noticeTestWarn(data.getPhone(),data.getType(),data.getLevel(), data.getBizType());
    }
 
 
    //----------------------------------警告配置-------------------------------------//
 
 
    /**
     * 警告通知方式
     *
     * ${dorado.getDataProvider("warnPR#triggerNoticeType").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerNoticeType() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
 
        list.add(new DicTrigger(NoticeType.NONE.getCode(), NoticeType.NONE.getName()));
        list.add(new DicTrigger(NoticeType.SMS.getCode(), NoticeType.SMS.getName()));
        list.add(new DicTrigger(NoticeType.EMAIL.getCode(), NoticeType.EMAIL.getName()));
        list.add(new DicTrigger(NoticeType.VOICE.getCode(), NoticeType.VOICE.getName()));
        list.add(new DicTrigger(NoticeType.WECHAT.getCode(), NoticeType.WECHAT.getName()));
 
        return list;
    }
 
    /**
     * warnPR#getConf
     * @param deptId
     * @return
     */
    @DataProvider
    public MWarnConf getConf(String deptId){
        if(StringUtils.isEmpty(deptId)){
            deptId = ContextUtil.subDeptId(null);
        }
        MWarnConf result = hWarnService.getConf(deptId);
        if(null == result){
            result = new MWarnConf();
            result.setStart(0);
            result.setEnd(24);
            result.setDeptId(deptId);
        }
        return result;
    }
 
    /**
     * warnPR#updateConf
     * @param data
     */
    @DataResolver
    public void updateConf(MWarnConf data){
        hWarnService.updateConf(data);
    }
 
    /**
     * warnPR#loadUserByParam
     * 根据关键字查询,可能是用户账号,或者中文名
     *
     * @param
     * @return
     */
    @DataProvider
    public List<DefaultUser> loadUserByParam(Map<String, Object> param) {
 
        if(null == param){
            param = new HashMap<String, Object>();
        }
        return sysUserService.loadUsers(param);
    }
}