|
@@ -50,6 +50,9 @@ public class AlarmRecordWrapper {
|
|
@Autowired
|
|
@Autowired
|
|
AlarmRecordServiceImpl alarmRecordService;
|
|
AlarmRecordServiceImpl alarmRecordService;
|
|
|
|
|
|
|
|
+ // 因经常查询报警类型,将报警类型放入内存缓存中
|
|
|
|
+ Map<String, SimpleObjVO> alarmItemMap = new HashMap<>();
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取报警类型编码和名称的映射
|
|
* 获取报警类型编码和名称的映射
|
|
*
|
|
*
|
|
@@ -60,20 +63,35 @@ public class AlarmRecordWrapper {
|
|
* @version V1.0 2021/9/20 4:31 下午
|
|
* @version V1.0 2021/9/20 4:31 下午
|
|
*/
|
|
*/
|
|
public Map<String, SimpleObjVO> getAlarmItemMap(List<String> itemCodes) throws Exception {
|
|
public Map<String, SimpleObjVO> getAlarmItemMap(List<String> itemCodes) throws Exception {
|
|
- Map<String, SimpleObjVO> alarmItemMap = new HashMap<>();
|
|
|
|
- QueryAlarmItemDTO queryAlarmItemDTO = new QueryAlarmItemDTO();
|
|
|
|
- queryAlarmItemDTO.setCode(itemCodes);
|
|
|
|
- DmpResult<List<AlarmItem>> alarmItemsResult = alarmItemService.query(queryAlarmItemDTO);
|
|
|
|
- List<AlarmItem> alarmItems = alarmItemsResult.getData();
|
|
|
|
- if (CollectionUtils.isEmpty(alarmItems)) {
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(itemCodes)) {
|
|
|
|
+ return new HashMap<>();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ Map<String, SimpleObjVO> resultMap = new HashMap<>();
|
|
|
|
+ List<String> unCachedItemCodes = new ArrayList<>();
|
|
|
|
+ for (String itemCode : itemCodes) {
|
|
|
|
+ if (alarmItemMap.containsKey(itemCode)) {
|
|
|
|
+ resultMap.put(itemCode, alarmItemMap.get(itemCode));
|
|
|
|
+ } else {
|
|
|
|
+ unCachedItemCodes.add(itemCode);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- alarmItemMap.putAll(alarmItems.stream().collect(Collectors.toMap(
|
|
|
|
- AlarmItem::getId,
|
|
|
|
- alarmItem -> new SimpleObjVO(alarmItem.getId(), alarmItem.getName()),
|
|
|
|
- (k1, k2) -> k1
|
|
|
|
- )));
|
|
|
|
- return alarmItemMap;
|
|
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(unCachedItemCodes)) {
|
|
|
|
+ QueryAlarmItemDTO queryAlarmItemDTO = new QueryAlarmItemDTO();
|
|
|
|
+ queryAlarmItemDTO.setCode(unCachedItemCodes);
|
|
|
|
+ DmpResult<List<AlarmItem>> alarmItemsResult = alarmItemService.query(queryAlarmItemDTO);
|
|
|
|
+ List<AlarmItem> alarmItems = alarmItemsResult.getData();
|
|
|
|
+ Map<String, SimpleObjVO> unCachedItems = alarmItems.stream().collect(Collectors.toMap(
|
|
|
|
+ AlarmItem::getCode,
|
|
|
|
+ alarmItem -> new SimpleObjVO(alarmItem.getId(), alarmItem.getName()),
|
|
|
|
+ (k1, k2) -> k1
|
|
|
|
+ ));
|
|
|
|
+ alarmItemMap.putAll(unCachedItems);
|
|
|
|
+ resultMap.putAll(unCachedItems);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return resultMap;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|