DataInitializer.java
1.46 KB
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
package cn.com.glsx.kafka.init;
import cn.com.glsx.kafka.service.EshieldAlarmService;
import cn.com.glsx.stdinterface.dto.AlarmWarnAlarmTypeDTO;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
/**
* 初始化警情中心
*
* @author yangll
*/
@Slf4j
@Component
@Order(Ordered.HIGHEST_PRECEDENCE + 1)
public class DataInitializer implements CommandLineRunner {
@Autowired
private EshieldAlarmService eshieldAlarmService;
/**
* 初始化用户数据
**/
public static HashMap<String, Integer> cacheAlarmType = new HashMap<>();
@Override
public void run(String... strings) {
initAlarmType();
}
public void initAlarmType() {
List<AlarmWarnAlarmTypeDTO> alarmTypeList = eshieldAlarmService.getAllAlarmType();
if (CollectionUtil.isEmpty(alarmTypeList)) {
log.info("alarmTypeList is null");
return;
}
log.info("alarmTypeList===" + JSONUtil.toJsonStr(alarmTypeList));
for (AlarmWarnAlarmTypeDTO eat : alarmTypeList) {
cacheAlarmType.put(eat.getTypeDesc(), eat.getAlarmType());
}
}
}