fix:Analysis log搜索
This commit is contained in:
parent
ebf432cf9c
commit
ecac7a9240
|
@ -8,17 +8,22 @@ import java.util.List;
|
|||
@Data
|
||||
public class AnalysisLogDto extends AlarmAnalysisLog {
|
||||
|
||||
private String name;
|
||||
private String stationCode;
|
||||
|
||||
private String source;
|
||||
private List<NuclideInfo> nuclideList;
|
||||
|
||||
/* 以下属性作废 */
|
||||
// TODO del
|
||||
|
||||
private String name; // 规则名称
|
||||
|
||||
private String source; // 当前规则关注的数据源(逗号分隔)
|
||||
|
||||
private List<String> sourceList;
|
||||
|
||||
private String stations;
|
||||
private String stations; // 当前规则关注的台站(逗号分隔)
|
||||
|
||||
private List<String> stationList;
|
||||
|
||||
private String nuclides;
|
||||
|
||||
private List<NuclideInfo> nuclideList;
|
||||
private String nuclides; // 当前规则关注的核素(逗号分隔)
|
||||
}
|
||||
|
|
|
@ -35,4 +35,6 @@ public interface SystemClient {
|
|||
@GetMapping("/gardsStations/getCodesMap")
|
||||
Map<String,String> stationCodesMap(@RequestParam Collection<String> stationIds);
|
||||
|
||||
@GetMapping("/gardsStations/stationCodesMap")
|
||||
Map<String,String> stationCodesMap();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
@ -10,6 +12,5 @@ import org.jeecg.modules.base.entity.postgre.AlarmAnalysisLog;
|
|||
|
||||
@Mapper
|
||||
public interface AlarmAnalysisLogMapper extends BaseMapper<AlarmAnalysisLog> {
|
||||
|
||||
List<AnalysisLogDto> findPage(String startDate,String endDate);
|
||||
Page<AnalysisLogDto> findPage(Page<AnalysisLogDto> page, Map<String, Object> params);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.mapper.AlarmAnalysisLogMapper">
|
||||
|
||||
<select id="findPage" resultType="org.jeecg.modules.base.dto.AnalysisLogDto">
|
||||
<!--<select id="findPage" resultType="org.jeecg.modules.base.dto.AnalysisLogDto">
|
||||
SELECT
|
||||
l.*,
|
||||
r.name,
|
||||
|
@ -21,5 +21,32 @@
|
|||
</if>
|
||||
</where>
|
||||
ORDER BY l.alarm_start_date DESC
|
||||
</select>-->
|
||||
<select id="findPage" resultType="org.jeecg.modules.base.dto.AnalysisLogDto">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
alarm_analysis_log
|
||||
<where>
|
||||
<if test="params.source != null and params.source.size() > 0">
|
||||
datasource IN
|
||||
<foreach collection="params.source" index="index" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.stations != null and params.stations.size() > 0">
|
||||
AND station_id IN
|
||||
<foreach collection="params.stations" index="index" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params.startDate != null and params.startDate != ''">
|
||||
AND alarm_start_date >= #{params.startDate}
|
||||
</if>
|
||||
<if test="params.endDate != null and params.endDate != ''">
|
||||
AND alarm_start_date <= #{params.endDate}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY alarm_start_date DESC
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
|
@ -34,6 +36,7 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AlarmAnalysisLogServiceImpl extends ServiceImpl<AlarmAnalysisLogMapper, AlarmAnalysisLog> implements IAlarmAnalysisLogService {
|
||||
|
||||
@Autowired
|
||||
|
@ -44,72 +47,44 @@ public class AlarmAnalysisLogServiceImpl extends ServiceImpl<AlarmAnalysisLogMap
|
|||
String startDate = analysisLogVo.getStartDate();
|
||||
String endDate = analysisLogVo.getEndDate();
|
||||
if (StrUtil.isNotBlank(startDate))
|
||||
startDate += DateConstant.TIME_START;
|
||||
analysisLogVo.setStartDate(startDate + DateConstant.TIME_START);
|
||||
if (StrUtil.isNotBlank(endDate))
|
||||
endDate += DateConstant.TIME_END;
|
||||
List<AnalysisLogDto> result = baseMapper.findPage(startDate, endDate);
|
||||
List<String> source = analysisLogVo.getSource();
|
||||
List<String> stations = analysisLogVo.getStations();
|
||||
List<String> nuclides = analysisLogVo.getNuclides();
|
||||
String comma = SymbolConstant.COMMA;
|
||||
// 条件过滤
|
||||
if (CollUtil.isNotEmpty(source)){
|
||||
result = result.stream().filter(item -> {
|
||||
List<String> sourceIds = ListUtil
|
||||
.toList(item.getSource().split(comma));
|
||||
return CollUtil.containsAny(sourceIds,source);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(stations)){
|
||||
result = result.stream().filter(item -> {
|
||||
List<String> stationIds = ListUtil
|
||||
.toList(item.getStations().split(comma));
|
||||
return CollUtil.containsAny(stationIds,stations);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(nuclides)){
|
||||
result = result.stream().filter(item -> {
|
||||
List<String> nuclideList = ListUtil
|
||||
.toList(item.getNuclides().split(comma));
|
||||
return CollUtil.containsAny(nuclideList,nuclides);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
analysisLogVo.setEndDate(endDate + DateConstant.TIME_END);
|
||||
Map<String, Object> params = BeanUtil.beanToMap(analysisLogVo);
|
||||
Integer pageNo = analysisLogVo.getPageNo();
|
||||
Integer pageSize = analysisLogVo.getPageSize();
|
||||
Page<AnalysisLogDto> page = new Page<>(pageNo, pageSize);
|
||||
page = baseMapper.findPage(page, params);
|
||||
List<AnalysisLogDto> records = page.getRecords();
|
||||
|
||||
// 数据字典
|
||||
List<DictModel> sourceDict = systemClient.getItems(DictConstant.ANALYSE_SOURCE);
|
||||
// 封装Source和Station
|
||||
for (AnalysisLogDto logDto : result) {
|
||||
Map<String, String> sourceMap = sourceDict.stream().collect(Collectors
|
||||
.toMap(DictModel::getValue, DictModel::getText));
|
||||
Map<String, String> stationCodesMap = systemClient.stationCodesMap();
|
||||
for (AnalysisLogDto logDto : records) {
|
||||
// 数据源
|
||||
String sources = logDto.getSource();
|
||||
List<String> sourceList = getShow(sourceDict, sources);
|
||||
logDto.setSourceList(sourceList);
|
||||
String datasource = logDto.getDatasource();
|
||||
logDto.setDatasource(sourceMap.getOrDefault(datasource, "--"));
|
||||
// TODO del
|
||||
logDto.setSourceList(ListUtil.toList(sourceMap.getOrDefault(datasource, "--")));
|
||||
// 台站
|
||||
String stationIds = logDto.getStations();
|
||||
if (StrUtil.isNotBlank(stationIds)){
|
||||
List<String> stationList = systemClient.stationCodes(stationIds);
|
||||
logDto.setStationList(stationList);
|
||||
}
|
||||
String stationId = logDto.getStationId();
|
||||
logDto.setStationCode(stationCodesMap.getOrDefault(stationId, "--"));
|
||||
// TODO del
|
||||
logDto.setStationList(ListUtil.toList(stationCodesMap.getOrDefault(stationId, "--")));
|
||||
// 将nuclide的json串转换为对象集合
|
||||
String nuclideInfo = logDto.getNuclideInfo();
|
||||
if (StrUtil.isNotBlank(nuclideInfo)){
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
List<NuclideInfo> nuclideInfos = mapper.readValue(nuclideInfo,
|
||||
new TypeReference<List<NuclideInfo>>() {
|
||||
});
|
||||
List<NuclideInfo> nuclideInfos = mapper.readValue(nuclideInfo, new TypeReference<List<NuclideInfo>>() {});
|
||||
logDto.setNuclideList(nuclideInfos);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
log.error("nuclideInfo解析异常: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 封装分页
|
||||
Integer pageNo = analysisLogVo.getPageNo();
|
||||
Integer pageSize = analysisLogVo.getPageSize();
|
||||
int total = result.size();
|
||||
List<AnalysisLogDto> records = PageUtil.page(pageNo, pageSize, result);
|
||||
Page<AnalysisLogDto> page = new Page<>(pageNo,pageSize,total);
|
||||
page.setRecords(records);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
@ -251,7 +226,7 @@ public class AlarmAnalysisLogServiceImpl extends ServiceImpl<AlarmAnalysisLogMap
|
|||
return result;
|
||||
}
|
||||
|
||||
private List<String> getShow(List<DictModel> dictModels,String dict){
|
||||
/*private List<String> getShow(List<DictModel> dictModels,String dict){
|
||||
List<String> show = new ArrayList<>();
|
||||
if (StrUtil.isBlank(dict))
|
||||
return null;
|
||||
|
@ -262,7 +237,7 @@ public class AlarmAnalysisLogServiceImpl extends ServiceImpl<AlarmAnalysisLogMap
|
|||
show.add(dictMap.get(key));
|
||||
}
|
||||
return show;
|
||||
}
|
||||
}*/
|
||||
|
||||
private List<AlarmAnalysisLog> getLogs(String startDate,String endDate){
|
||||
startDate += DateConstant.TIME_START;
|
||||
|
|
|
@ -106,4 +106,10 @@ public class GardsStationsController {
|
|||
public Map<String,String> getCodesMap(@RequestParam Collection<String> stationIds){
|
||||
return gardsStationsService.getCodeMap(stationIds);
|
||||
}
|
||||
|
||||
@GetMapping("stationCodesMap")
|
||||
@ApiOperation(value = "获取台站CodeMap", notes = "获取台站CodeMap")
|
||||
public Map<String,String> getCodesMap(){
|
||||
return gardsStationsService.getCodeMap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,4 +66,6 @@ public interface IGardsStationsService extends IService<GardsStations> {
|
|||
List<String> getCodeByIds(String stationIds);
|
||||
|
||||
Map<String,String> getCodeMap(Collection<String> stationIds);
|
||||
|
||||
Map<String,String> getCodeMap();
|
||||
}
|
||||
|
|
|
@ -230,4 +230,17 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCodeMap() {
|
||||
String key = RedisConstant.STATION_CODE_MAP;
|
||||
if (redisUtil.hasKey(key))
|
||||
return (Map<String, String>) redisUtil.get(key);
|
||||
List<GardsStations> gardsStations = list();
|
||||
Map<String, String> stationCodeMap = gardsStations.stream().collect(Collectors.toMap(
|
||||
station -> String.valueOf(station.getStationId()),
|
||||
GardsStations::getStationCode));
|
||||
redisUtil.set(key, stationCodeMap);
|
||||
return stationCodeMap;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user