Commit 579c077f authored by lilongyang's avatar lilongyang

1、区域查询按照区域进行like查询

parent ceda0a63
......@@ -8,7 +8,6 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
......@@ -17,6 +16,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ObjectUtils;
......@@ -153,6 +153,7 @@ public class TDBigScreenAnalyseController extends BaseController {
LambdaQueryWrapper<FanHealthIndex> wrapper = new LambdaQueryWrapper<FanHealthIndex>();
wrapper.orderByDesc(FanHealthIndex::getTs);
wrapper.last("limit 1");
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
if (CharSequenceUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
if ("FDZ".equals(stationBasic.getStationType())) {
......@@ -175,10 +176,16 @@ public class TDBigScreenAnalyseController extends BaseController {
}
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
if (CharSequenceUtil.isNotEmpty(areaCode)) {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "片区");
wrapper.like(FanHealthIndex::getArea, "%" + areaCode + "%");
} else {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "全域");
}
FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper);
stringBigDecimalHashMap.put("value",BigDecimal.valueOf( fanHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP));
stringBigDecimalHashMap.put("value", BigDecimal.valueOf(fanHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP));
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
......@@ -269,6 +276,91 @@ public class TDBigScreenAnalyseController extends BaseController {
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 折线图", notes = "场站设备健康状态指数与趋势 - 折线图")
@GetMapping(value = "/getHealthListInfoByMinute")
public ResponseModel<Map<String, Object>> getHealthListInfoByMinute(@RequestParam(required = false) String areaCode,
@RequestParam(required = false) String stationCode, @RequestParam(required = false) String area,
@RequestParam(required = false) String station, @RequestParam(required = false) String analysisType,
@RequestParam(required = false) Date startTime, @RequestParam(required = false) Date endTime) {
if (StrUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
stationCode = stationBasic.getFanGatewayId();
} else if (StrUtil.isNotEmpty(station)) {
// 由于命名不统一
StationBasic stationBasic = stationBasicMapper.selectOne(new LambdaQueryWrapper<StationBasic>()
.eq(StationBasic::getStationName, station.substring(0, station.length() - 1) + '场').or()
.eq(StationBasic::getStationName, station.substring(0, station.length() - 1) + '站'));
stationCode = stationBasic.getFanGatewayId();
}
if (StrUtil.isNotEmpty(areaCode)) {
areaCode = "%" + areaCode + "%";
} else if (StrUtil.isNotEmpty(area)) {
areaCode = "%" + area + "%";
}
String finalStationCode = stationCode;
String finalAreaCode = areaCode;
List<String> valueList;
List<String> dateList;
List<Map<String, Object>> arrayList = new ArrayList<>();
HashMap<String, Object> resultMap = new HashMap<>();
HashMap<String, Object> stringStringHashMap = new HashMap<>();
LambdaQueryWrapper<FanHealthIndex> wrapper = new LambdaQueryWrapper<FanHealthIndex>();
wrapper.orderByDesc(FanHealthIndex::getTs);
wrapper.last("limit 15");
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
if (CharSequenceUtil.isNotEmpty(finalStationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(finalStationCode);
if ("FDZ".equals(stationBasic.getStationType())) {
stationCode = stationBasic.getFanGatewayId();
wrapper.eq(FanHealthIndex::getAnalysisObjType, "场站");
wrapper.eq(FanHealthIndex::getGatewayId, stationCode);
List<FanHealthIndex> fanHealthIndexList = fanHealthIndexMapper.selectList(wrapper);
valueList = fanHealthIndexList.stream().map(t -> String.valueOf(BigDecimal.valueOf(t.getHealthIndex())
.setScale(1, BigDecimal.ROUND_HALF_UP))).collect(Collectors.toList());
dateList = fanHealthIndexList.stream().map(t -> t.getRecDate()).collect(Collectors.toList());
} else {
LambdaQueryWrapper<PvHealthIndex> pvwrapper = new LambdaQueryWrapper<PvHealthIndex>();
pvwrapper.eq(PvHealthIndex::getAnalysisObjType, "场站");
pvwrapper.eq(PvHealthIndex::getGatewayId, stationCode);
pvwrapper.orderByDesc(PvHealthIndex::getTs);
pvwrapper.last("limit 15");
List<PvHealthIndex> pvHealthIndexList = pvHealthIndexMapper.selectList(pvwrapper);
valueList = pvHealthIndexList.stream().map(t -> String.valueOf(BigDecimal.valueOf(t.getHealthIndex())
.setScale(1, BigDecimal.ROUND_HALF_UP))).collect(Collectors.toList());
dateList = pvHealthIndexList.stream().map(t -> t.getRecDate()).collect(Collectors.toList());
}
stringStringHashMap.put("data", valueList);
arrayList.add(stringStringHashMap);
resultMap.put("axisData", dateList);
resultMap.put("seriesData", arrayList);
return ResponseHelper.buildResponse(resultMap);
}
if (CharSequenceUtil.isNotEmpty(finalAreaCode)) {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "片区");
wrapper.like(FanHealthIndex::getArea, finalAreaCode);
} else {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "全域");
}
List<FanHealthIndex> fanHealthIndexList = fanHealthIndexMapper.selectList(wrapper);
valueList = fanHealthIndexList.stream().map(t -> String.valueOf(BigDecimal.valueOf(t.getHealthIndex())
.setScale(1, BigDecimal.ROUND_HALF_UP))).collect(Collectors.toList());
dateList = fanHealthIndexList.stream().map(t -> t.getRecDate()).collect(Collectors.toList());
stringStringHashMap.put("data", valueList);
arrayList.add(stringStringHashMap);
resultMap.put("axisData", dateList);
resultMap.put("seriesData", arrayList);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "全域各片区设备预警情况(条) ", notes = "全域各片区设备预警情况(条) ")
@GetMapping(value = "/getAllEquipAlarmInfo")
......@@ -352,19 +444,7 @@ public class TDBigScreenAnalyseController extends BaseController {
List<String> list = new ArrayList<>();
// FeignClientResult<List<CompanyModel>> listFeignClientResult = Privilege.companyClient.queryAgencyList("AREA");
//
// List<CompanyModel> companyModels = new ArrayList<>();
//
// if (!ObjectUtils.isEmpty(listFeignClientResult)) {
// if (listFeignClientResult.getStatus() == 200) {
// companyModels = listFeignClientResult.getResult();
// } else {
// throw new RuntimeException(listFeignClientResult.getMessage());
// }
// }
// list = companyModels.stream().map(CompanyModel::getCompanyName).collect(Collectors.toList());
//
list = Arrays.asList("华北区域", "东北区域", "华东区域", "华南区域", "西南区域", "西北区域", "华中区域");
......@@ -375,6 +455,66 @@ public class TDBigScreenAnalyseController extends BaseController {
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "片区、场站设备健康状态指数 ", notes = "片区、场站设备健康状态指数 ")
@GetMapping(value = "/getHealthInfoByMinute")
public ResponseModel<Map<String, Object>> getHealthInfoByMinute(@RequestParam(required = false) String areaCode) {
LambdaQueryWrapper<FanHealthIndex> wrapper = new LambdaQueryWrapper<FanHealthIndex>();
wrapper.orderByDesc(FanHealthIndex::getTs);
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
if (CharSequenceUtil.isNotEmpty(areaCode)) {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "场站");
wrapper.like(FanHealthIndex::getArea, "%" + areaCode + "%");
}else{
wrapper.eq(FanHealthIndex::getAnalysisObjType, "片区");
}
List<Object> seriesData = new ArrayList<>();
List<String> axisData = new ArrayList<>();
List<FanHealthIndex> fanHealthIndexList = fanHealthIndexMapper.selectList(wrapper);
Map<String, Object> resultMap = new HashMap<>();
if (CharSequenceUtil.isNotEmpty(areaCode)) {
Map<String, Map<String, List<FanHealthIndex>>> groupedData = fanHealthIndexList.stream()
.collect(Collectors.groupingBy(FanHealthIndex::getArea, Collectors.groupingBy(FanHealthIndex::getStation)));
Map<String, Map<String, FanHealthIndex>> latestData = groupedData.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
e -> e.getValue().values().stream()
.map(list -> list.stream()
.max(Comparator.comparing(FanHealthIndex::getTs))
.get())
.collect(Collectors.toMap(FanHealthIndex::getStation, Function.identity()))
));
List<Object> finalSeriesData = new ArrayList<>();
List<String> finalAxisData = new ArrayList<>();
latestData.values().forEach(s -> {
s.forEach((k,v) -> {
finalSeriesData.add(v.getHealthIndex());
finalAxisData.add(v.getStation());
});
});
seriesData.addAll(finalSeriesData);
axisData.addAll(finalAxisData);
}else{
Map<String, List<FanHealthIndex>> groupedData = fanHealthIndexList.stream()
.collect(Collectors.groupingBy(FanHealthIndex::getArea));
Map<String, FanHealthIndex> latestData = groupedData.values().stream().map(list -> list.stream()
.max(Comparator.comparing(FanHealthIndex::getTs))
.get())
.collect(Collectors.toMap(FanHealthIndex::getArea, Function.identity()));
seriesData = latestData.values().stream().map(t -> String.valueOf(BigDecimal.valueOf(t.getHealthIndex())
.setScale(1, BigDecimal.ROUND_HALF_UP))).collect(Collectors.toList());
axisData = latestData.values().stream().map(t -> t.getArea()).collect(Collectors.toList());
}
resultMap.put("axisData", axisData);
resultMap.put("seriesData", seriesData);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "全域各场站设备实时预警处置信息", notes = "全域各场站设备实时预警处置信息")
@GetMapping(value = "/getEquipWarningInfoByPage")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment