Commit 13077bd1 authored by wujiang's avatar wujiang

提交全域接口

parent d2d4a00b
......@@ -6,17 +6,23 @@ import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.*;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -33,12 +39,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibm.icu.math.BigDecimal;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.feign.RiskWarningFeign;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallInfoDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
......@@ -50,6 +57,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWarningRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRuleSetServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRuleSetServiceImpl;
......@@ -59,6 +67,12 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexDayMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.TimeRangeUtil;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
......@@ -132,37 +146,58 @@ public class TDBigScreenAnalyseController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 仪表盘-10分钟", notes = "场站设备健康状态指数与趋势 - 仪表盘-10分钟")
@GetMapping(value = "/getHealthScoreInfoByMinute")
public ResponseModel<Map<String, Object>> getHealthScoreInfoByMinute(@RequestParam(required = false) String areaCode,
@RequestParam(required = false) String stationCode,
@RequestParam (required = false) String tableName) {
public ResponseModel<Map<String, Object>> getHealthScoreInfoByMinute(
@RequestParam(required = false) String areaCode, @RequestParam(required = false) String stationCode,
@RequestParam(required = false) String tableName) {
HashMap<String, Object> stringBigDecimalHashMap = new HashMap<>();
LambdaQueryWrapper<FanHealthIndex> wrapper = new LambdaQueryWrapper<FanHealthIndex>();
wrapper.orderByDesc(FanHealthIndex::getTs);
wrapper.last("limit 1");
if (CharSequenceUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
if ("FDZ".equals(stationBasic.getStationType())) {
stationCode = stationBasic.getFanGatewayId();
stringBigDecimalHashMap.put("value", idxBizFanHealthIndexMapper.getHealthScoreInfoByStationByMinute(stationCode, tableName));
wrapper.eq(FanHealthIndex::getAnalysisObjType, "场站");
wrapper.eq(FanHealthIndex::getGatewayId, stationCode);
FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper);
stringBigDecimalHashMap.put("value",
BigDecimal.valueOf(fanHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP));
} else {
LambdaQueryWrapper<PvHealthIndex> pvwrapper = new LambdaQueryWrapper<PvHealthIndex>();
pvwrapper.eq(PvHealthIndex::getAnalysisObjType, "场站");
pvwrapper.eq(PvHealthIndex::getGatewayId, stationCode);
pvwrapper.orderByDesc(PvHealthIndex::getTs);
pvwrapper.last("limit 1");
PvHealthIndex pvHealthIndex = pvHealthIndexMapper.selectOne(pvwrapper);
stringBigDecimalHashMap.put("value",
BigDecimal.valueOf(pvHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP));
}
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
stringBigDecimalHashMap.put("value",
idxBizFanHealthIndexMapper.getHealthScoreInfoByLatest(areaCode, stationCode));
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
wrapper.eq(FanHealthIndex::getAnalysisObjType, "全域");
FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper);
stringBigDecimalHashMap.put("value",BigDecimal.valueOf( fanHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP));
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 折线图", notes = "场站设备健康状态指数与趋势 - 折线图")
@GetMapping(value = "/getHealthListInfo")
public ResponseModel<Map<String, Object>> getHealthListInfo(@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) {
@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)+'站'));
.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)) {
......@@ -172,26 +207,26 @@ public class TDBigScreenAnalyseController extends BaseController {
}
HashMap<String, Object> resultMap = new HashMap<>();
//List<Map<String, String>> dateInfoBy15 = new ArrayList<>();
List<String> dateList=new ArrayList<>();
// List<Map<String, String>> dateInfoBy15 = new ArrayList<>();
List<String> dateList = new ArrayList<>();
if (startTime != null && endTime != null) {
if (WarningPeriodEnum.DAY.getName().equals(analysisType)) {
//dateInfoBy15 = idxBizFanHealthIndexMapper.getDateInfo(startTime, endTime);
dateList=TimeRangeUtil.getDateInfo(startTime, endTime);
// dateInfoBy15 = idxBizFanHealthIndexMapper.getDateInfo(startTime, endTime);
dateList = TimeRangeUtil.getDateInfo(startTime, endTime);
} else if (WarningPeriodEnum.HOUR.getName().equals(analysisType)) {
//dateInfoBy15 = idxBizFanHealthIndexMapper.getHourInfo(startTime, endTime);
dateList=TimeRangeUtil.getHourInfo(startTime, endTime);
// dateInfoBy15 = idxBizFanHealthIndexMapper.getHourInfo(startTime, endTime);
dateList = TimeRangeUtil.getHourInfo(startTime, endTime);
} else if (WarningPeriodEnum.MINUTES.getName().equals(analysisType)) {
//dateInfoBy15 = idxBizFanHealthIndexMapper.getMomentInfo(startTime, endTime);
dateList=TimeRangeUtil.getMomentInfo(startTime, endTime);
// dateInfoBy15 = idxBizFanHealthIndexMapper.getMomentInfo(startTime, endTime);
dateList = TimeRangeUtil.getMomentInfo(startTime, endTime);
}
} else {
//dateInfoBy15 = idxBizFanHealthIndexMapper.getDateInfoBy15();
dateList=TimeRangeUtil.getDateInfoBy15();
dateList = TimeRangeUtil.getDateInfoBy15();
}
List<String> valueList = new ArrayList<>();
String finalStationCode = stationCode;
// List<String> dateList = dateInfoBy15.stream().map(i -> i.get("date")).collect(Collectors.toList());
// List<String> dateList = dateInfoBy15.stream().map(i ->
// i.get("date")).collect(Collectors.toList());
String finalAreaCode = areaCode;
if ((WarningPeriodEnum.DAY.getName().equals(analysisType))) {
List<String> fullDateList = dateList.stream().map(s -> {
......@@ -202,8 +237,7 @@ public class TDBigScreenAnalyseController extends BaseController {
Map<String, Object> map = healthListInfo.stream().collect(Collectors
.toMap(i -> String.valueOf(i.get("recdate")), i -> i.get("healthindex"), (key1, key2) -> key2));
for (String date : dateList) {
String value = map.get(date) != null ? String.valueOf(map.get(date))
: "100";
String value = map.get(date) != null ? String.valueOf(map.get(date)) : "100";
valueList.add(String.valueOf(Math.round(Double.valueOf(value) * 10.0) / 10.0));
}
} else if (WarningPeriodEnum.HOUR.getName().equals(analysisType)) {
......@@ -364,8 +398,8 @@ public class TDBigScreenAnalyseController extends BaseController {
}
Integer count = fanWaringRecordMapper.getEquipWarningInfoByPageCount(arae, station, stationType, warningName,
stationId, startDate, endDate);
//前端存在分页bug 此处限制分页后筛选导致页面超出问题
if (count > 0 && current > (count/10 + 1)){
// 前端存在分页bug 此处限制分页后筛选导致页面超出问题
if (count > 0 && current > (count / 10 + 1)) {
current = 1;
}
// List<IdxBizFanWarningRecord> idxBizFanWarningRecordIPage =
......@@ -850,12 +884,12 @@ public class TDBigScreenAnalyseController extends BaseController {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String nameByIndexAddress = idxBizFanHealthIndexMapper.getPointNameByIndexAddress(indexAddress, tableName,
stationBasic.getFanGatewayId());
int num = 0 ;
if (StringUtils.isNotEmpty(tableName2)){
num = idxBizFanHealthIndexMapper.getIsWarningByPointId(indexAddress, stationBasic.getFanGatewayId(), tableName2);
int num = 0;
if (StringUtils.isNotEmpty(tableName2)) {
num = idxBizFanHealthIndexMapper.getIsWarningByPointId(indexAddress, stationBasic.getFanGatewayId(),
tableName2);
}
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("text", nameByIndexAddress);
resultMap.put("warningNum", num);
......@@ -1576,16 +1610,15 @@ public class TDBigScreenAnalyseController extends BaseController {
ArrayList<FanWarningRecord> newList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
//分批次处理
newList.add(list.get(i));//循环将数据填入载体list
if (500 == newList.size() || i == list.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
// 分批次处理
newList.add(list.get(i));// 循环将数据填入载体list
if (500 == newList.size() || i == list.size() - 1) { // 载体list达到要求,进行批量操作
// 调用批量插入
fanWaringRecordMapper.saveBatchWarningRecords(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
newList.clear();// 每次批量操作后,清空载体list,等待下次的数据填入
}
}
List<PvWarningRecord> list2 = pvWaringRecordMapper.selectList(null);
list2.forEach(item -> {
if ("未处置".equals(item.getDisposotionState())) {
......@@ -1597,12 +1630,12 @@ public class TDBigScreenAnalyseController extends BaseController {
ArrayList<PvWarningRecord> newList2 = new ArrayList<>();
for (int i = 0; i < list2.size(); i++) {
//分批次处理
newList2.add(list2.get(i));//循环将数据填入载体list
if (500 == newList2.size() || i == list2.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
// 分批次处理
newList2.add(list2.get(i));// 循环将数据填入载体list
if (500 == newList2.size() || i == list2.size() - 1) { // 载体list达到要求,进行批量操作
// 调用批量插入
pvWaringRecordMapper.saveBatchWarningRecords(newList2);
newList2.clear();//每次批量操作后,清空载体list,等待下次的数据填入
newList2.clear();// 每次批量操作后,清空载体list,等待下次的数据填入
}
}
......
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