Commit 18fd86a2 authored by lilongyang's avatar lilongyang

Merge branch 'developer' of http://36.40.66.175:5000/moa/jxdj_zx/amos-boot-zx-biz into developer

parents 81180fa3 1e5178ba
......@@ -8,6 +8,7 @@ import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
......@@ -664,13 +665,6 @@ public class DateUtils {
/*System.out.println(dateFormat(maxDateOfMonth(dateParse("2016-02", "yyyy-MM")), null));
System.out.println(dateFormat(minDateOfMonth(dateParse("2016-03-31", null)), null));*/
// System.out.println(dateFormat(new Date(), CHN_DATE_PATTERN_YEAR));
// System.out.println(dateFormat(new Date(), CHN_DATE_PATTERN_MONTH));
// System.out.println(getWeekOfYear(new Date()));
// System.out.println(getQuarterStr(getMonth(dateParse("2021-5-11", null))));
// System.out.println(getWeekBeginDate(dateParse("2021-10-11", null)));
// System.out.println(getWeekEndDate(dateParse("2021-10-11", null)));
System.out.println(secondsToTimeStr(3600));
List<String> beforeCurrentMonth = getBeforeCurrentMonth(3, true);
System.out.println(beforeCurrentMonth);
......@@ -688,6 +682,53 @@ public class DateUtils {
return name;
}
//获取当前时间下一整时分点 例如 传入17:18 返回 17:20
public static String getNextWholeMinute(String currentTimeString) {
// 定义日期时间字符串的格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 将字符串转换为 LocalDateTime
LocalDateTime currentTime = LocalDateTime.parse(currentTimeString, formatter);
int currentMinute = currentTime.getMinute();
int seconds = currentTime.getSecond();
int nanos = currentTime.getNano();
// 如果当前分钟已经是整时分点,则加上 60 分钟
if (currentMinute % 10 == 0 && seconds == 0 && nanos == 0) {
return currentTimeString;
}
// 否则计算下一个整时分点
LocalDateTime localDateTime = currentTime.withSecond(0).withNano(0).plusMinutes(10 - currentMinute % 10);
return localDateTime.format(formatter);
}
//获取当前时间下一整时分点 例如 传入17:18 返回 17:20
public static String getBeforeWholeMinute(String currentTimeString) {
// 定义日期时间字符串的格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 将字符串转换为 LocalDateTime
LocalDateTime currentTime = LocalDateTime.parse(currentTimeString, formatter);
int currentMinute = currentTime.getMinute();
int seconds = currentTime.getSecond();
int nanos = currentTime.getNano();
// 如果当前分钟已经是整时分点,则加上 60 分钟
if (currentMinute % 10 == 0 && seconds == 0 && nanos == 0) {
return currentTimeString;
}
// 否则计算下一个整时分点
LocalDateTime localDateTime = currentTime.withSecond(0).withNano(0).minusMinutes(currentMinute % 10);
return localDateTime.format(formatter);
}
/**
* 获取某月的日期List
*
......
......@@ -61,6 +61,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
......@@ -176,6 +177,7 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
*/
@Scheduled (cron = "${dataRequestScheduled.tanYin}")
@Override
public void customerInfoList() {
try {
String startDate = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
......@@ -221,6 +223,7 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
@Scheduled (cron = "${dataRequestScheduled.tanYin}")
@Async
@Override
@PostConstruct
public void stationList() {
long ts = System.currentTimeMillis();
log.info("-------碳银同步电站开始: {} ------- ", ts);
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import static com.yeejoin.amos.boot.biz.common.utils.DateUtils.DATE_TIME_PATTERN;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
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.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -43,36 +12,21 @@ 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.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto;
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.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.IdxBizFanHealthIndexLatest;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRuleSet;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndexLatest;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexLatestMapper;
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.IdxBizPvHealthIndexLatestMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*;
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;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexDayMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper;
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.tdMapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
......@@ -82,16 +36,38 @@ import com.yeejoin.amos.boot.module.jxiop.biz.utils.TimeRangeUtil;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.yeejoin.amos.boot.biz.common.utils.DateUtils.DATE_TIME_PATTERN;
@RestController
@Api(tags = "智能分析 - 大屏API")
@RequestMapping(value = "/bigScreenAnalyse")
public class TDBigScreenAnalyseController extends BaseController {
public class TDBigScreenAnalyseController extends BaseController implements ApplicationRunner {
public final DecimalFormat df = new DecimalFormat("0.0");
@Autowired
......@@ -134,7 +110,8 @@ public class TDBigScreenAnalyseController extends BaseController {
private IdxBizPvWarningRuleSetServiceImpl idxBizPvWarningRuleSetService;
@Autowired
private PvHealthIndexDayMapper pvHealthIndexDayMapper;
@Autowired
private RedisUtils redisUtils;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 仪表盘", notes = "场站设备健康状态指数与趋势 - 仪表盘")
@GetMapping(value = "/getHealthScoreInfo")
......@@ -785,6 +762,10 @@ public class TDBigScreenAnalyseController extends BaseController {
@GetMapping("/getFanInfoByPage")
public ResponseModel<Page<Map<String, Object>>> getFanInfoByPage(
@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(fanInfoByPage(stationId));
}
private Page<Map<String, Object>> fanInfoByPage(String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
List<Map<String, Object>> equipmentList = idxBizFanHealthIndexMapper
.getFanInfoByPage(stationBasic.getFanGatewayId());
......@@ -827,7 +808,7 @@ public class TDBigScreenAnalyseController extends BaseController {
mapPage.setTotal(equipmentList.size());
mapPage.setCurrent(1);
mapPage.setRecords(equipmentList);
return ResponseHelper.buildResponse(mapPage);
return mapPage;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -836,7 +817,10 @@ public class TDBigScreenAnalyseController extends BaseController {
public ResponseModel<Map<String, Object>> getSubSystemInfo(
@RequestParam(value = "equipmentName", required = false) String equipmentName,
@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(subSystemInfo(equipmentName,stationId));
}
private Map<String, Object> subSystemInfo(String equipmentName, String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getSubSystemInfo(equipmentName,
......@@ -856,7 +840,7 @@ public class TDBigScreenAnalyseController extends BaseController {
});
resultMap.put("axisData", axisData);
resultMap.put("seriesData", seriesData);
return ResponseHelper.buildResponse(resultMap);
return resultMap;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -866,7 +850,10 @@ public class TDBigScreenAnalyseController extends BaseController {
@RequestParam(value = "subSystem", required = false) String subSystem,
@RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "equipmentName", required = false) String equipmentName) {
return ResponseHelper.buildResponse(subSystemPointInfo(subSystem,stationId,equipmentName));
}
private Page<Map<String, Object>> subSystemPointInfo(String subSystem, String stationId, String equipmentName) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
equipmentName = StrUtil.isNotEmpty(equipmentName) ? "%" + equipmentName + "风机%" : equipmentName;
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getHealthInfoBySubSystem(subSystem,
......@@ -918,7 +905,7 @@ public class TDBigScreenAnalyseController extends BaseController {
mapPage.setTotal(pointNameList.size());
mapPage.setCurrent(1);
mapPage.setRecords(pointNameList);
return ResponseHelper.buildResponse(mapPage);
return mapPage;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -926,6 +913,11 @@ public class TDBigScreenAnalyseController extends BaseController {
@GetMapping("/getPvInfoByPage")
public ResponseModel<Page<Map<String, Object>>> getPvInfoByPage(
@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(pvInfoByPage(stationId));
}
private Page<Map<String, Object>> pvInfoByPage(String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
List<Map<String, Object>> equipmentList = idxBizFanHealthIndexMapper
.getPvInfoByPage(stationBasic.getFanGatewayId());
......@@ -958,7 +950,7 @@ public class TDBigScreenAnalyseController extends BaseController {
mapPage.setTotal(equipmentList.size());
mapPage.setCurrent(1);
mapPage.setRecords(equipmentList);
return ResponseHelper.buildResponse(mapPage);
return mapPage;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -968,6 +960,10 @@ public class TDBigScreenAnalyseController extends BaseController {
@RequestParam(value = "subarray", required = false) String subarray,
@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(pvSubSystemInfo(subarray,stationId));
}
private Map<String, Object> pvSubSystemInfo(String subarray, String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvSubSystemInfo(subarray,
......@@ -987,7 +983,7 @@ public class TDBigScreenAnalyseController extends BaseController {
});
resultMap.put("axisData", axisData);
resultMap.put("seriesData", seriesData);
return ResponseHelper.buildResponse(resultMap);
return resultMap;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -996,7 +992,10 @@ public class TDBigScreenAnalyseController extends BaseController {
public ResponseModel<Page<Map<String, Object>>> getPvSubSystemPointInfo(
@RequestParam(value = "equipmentName", required = false) String equipmentName,
@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(pvSubSystemPointInfo(equipmentName,stationId));
}
private Page<Map<String, Object>> pvSubSystemPointInfo(String equipmentName,String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvHealthInfoBySubSystem(equipmentName,
stationBasic.getFanGatewayId());
......@@ -1044,7 +1043,7 @@ public class TDBigScreenAnalyseController extends BaseController {
mapPage.setTotal(pointNameList.size());
mapPage.setCurrent(1);
mapPage.setRecords(pointNameList);
return ResponseHelper.buildResponse(mapPage);
return mapPage;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......@@ -1862,4 +1861,70 @@ public class TDBigScreenAnalyseController extends BaseController {
return permissions;
}
@Override
public void run(ApplicationArguments args) throws Exception {
initStationFirstSelect();
}
/**
* 初始化场站第一个选中
*/
@Scheduled(cron = "0 */3 * * * ?")
public void initStationFirstSelect() {
List<StationBasicDto> stationBasicDtos = stationBasicMapper.getStationBasicList();
if(CollectionUtil.isNotEmpty(stationBasicDtos)){
JSONArray resultArray=new JSONArray();
for (StationBasicDto stationBasicDto : stationBasicDtos) {
JSONObject jsonObject=new JSONObject();
Long stationBasicId = stationBasicDto.getSequenceNbr();
jsonObject.put("stationBasicId",stationBasicId);
//此处获取大屏场站的状态3个图的第一个值 场站、子系统状态指数、子系统各变量健康状态指数
if("FDZ".equals(stationBasicDto.getStationType())){
Page<Map<String, Object>> fanInfoByPage = fanInfoByPage(String.valueOf(stationBasicId));
List<Map<String, Object>> records = fanInfoByPage.getRecords();
if(CollectionUtil.isNotEmpty(records)){
Map<String, Object> fanInfoMap = records.get(0);
String equipmentNameSimple = (String)fanInfoMap.get("equipmentNameSimple");
jsonObject.put("equipmentNameDefault",equipmentNameSimple);
Map<String, Object> subSystemInfo = subSystemInfo(equipmentNameSimple, String.valueOf(stationBasicId));
List axisData = (List)subSystemInfo.get("axisData");
if(CollectionUtil.isNotEmpty(axisData)){
String subSystemDefault = (String) axisData.get(0);
jsonObject.put("subSystemDefault",subSystemDefault);
Page<Map<String, Object>> subSystemPointInfo = subSystemPointInfo(subSystemDefault, String.valueOf(stationBasicId), equipmentNameSimple);
List<Map<String, Object>> subSystemPointInfoList = subSystemPointInfo.getRecords();
if(CollectionUtil.isNotEmpty(subSystemPointInfoList)){
Map<String, Object> stringObjectMap = subSystemPointInfoList.get(0);
String indexAddressDefault = (String)stringObjectMap.get("indexAddress");
jsonObject.put("indexAddressDefault",indexAddressDefault);
}
}
}
}else {
Page<Map<String, Object>> pvInfoByPage = pvInfoByPage(String.valueOf(stationBasicId));
List<Map<String, Object>> records = pvInfoByPage.getRecords();
if(CollectionUtil.isNotEmpty(records)){
Map<String, Object> pvInfoMap = records.get(0);
String subarray = (String)pvInfoMap.get("subarray");
jsonObject.put("equipmentNameDefault",subarray);
Map<String, Object> subSystemInfo = pvSubSystemInfo(subarray, String.valueOf(stationBasicId));
List axisData = (List)subSystemInfo.get("axisData");
if(CollectionUtil.isNotEmpty(axisData)){
String subSystemDefault = (String) axisData.get(0);
jsonObject.put("subSystemDefault",subSystemDefault);
Page<Map<String, Object>> subSystemPointInfo = pvSubSystemPointInfo(subSystemDefault, String.valueOf(stationBasicId));
List<Map<String, Object>> subSystemPointInfoList = subSystemPointInfo.getRecords();
if(CollectionUtil.isNotEmpty(subSystemPointInfoList)){
Map<String, Object> stringObjectMap = subSystemPointInfoList.get(0);
String indexAddressDefault = (String)stringObjectMap.get("indexAddress");
jsonObject.put("indexAddressDefault",indexAddressDefault);
}
}
}
}
resultArray.add(jsonObject);
}
redisUtils.set("STATION_FIRST_SELECT",resultArray);
}
}
}
......@@ -100,48 +100,46 @@ public class TdInfoQueryController extends BaseController {
}
dto.setOrgCode(orgCode);
Date currentDate = new Date();
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) {
Date date = DateUtils.dateParse(startDate + " 00:00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, 0), DATE_TIME_PATTERN));
long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_day", startDate, "Asc ");
dto.setStartDateTs(startTs);
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
Date date = DateUtils.dateParse(startDate + ":00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -9), DATE_TIME_PATTERN));
long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_hour", startDate + ":00:00", "Asc ");
dto.setStartDateTs(startTs);
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
StringBuilder newStartDate = new StringBuilder(startDate);
int number = 0;
if((newStartDate.charAt(15) - '0') > 0) {
number = 9;
}
newStartDate.replace(15, 16, number+"");
Date startDateDate = DateUtils.dateParse(newStartDate + ":00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(startDateDate, -8), DATE_TIME_PATTERN));
String nextWholeMinute = DateUtils.getNextWholeMinute(dto.getStartDate()+":00");
long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_moment", nextWholeMinute, "Asc ");
dto.setStartDateTs(startTs);
} else {
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN));
long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_data", startDate+" 00:00:00", "Asc ");
dto.setStartDateTs(startTs);
}
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) {
Date endDateDate = DateUtils.dateParse(endDate + " 23:59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, 24), DATE_TIME_PATTERN));
}else
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
Date endDateDate = DateUtils.dateParse(endDate + ":59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -9), DATE_TIME_PATTERN));
} else
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
StringBuilder newEndDate = new StringBuilder(endDate);
newEndDate.replace(15, 16, "9");
Date endDateDate = DateUtils.dateParse(newEndDate + ":59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
long endTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_day", endDate, "desc ");
dto.setEndDateTs(endTs);
dto.setTableName("fan_health_index_day");
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
long endTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_hour", endDate + ":00:00", "desc ");
dto.setEndDateTs(endTs);
dto.setTableName("fan_health_index_hour");
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
String nextWholeMinute = DateUtils.getBeforeWholeMinute(endDate+":00");
long endTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_moment", nextWholeMinute, "desc ");
dto.setEndDateTs(endTs);
dto.setTableName("fan_health_index_moment");
} else {
Date endDateDate = DateUtils.dateParse(endDate, "yyyy-MM-dd HH:mm:ss");
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
long endTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_data", endDate+" 00:00:00", "desc ");
dto.setEndDateTs(endTs);
dto.setTableName("fan_health_index_data");
}
}
Page<FanHealthIndex> resultPage = new Page<>(dto.getCurrent(), dto.getSize());
......@@ -213,23 +211,18 @@ public class TdInfoQueryController extends BaseController {
String startDate = dto.getStartDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) {
Date date = DateUtils.dateParse(startDate + " 00:00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, 0), DATE_TIME_PATTERN));
long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_day", startDate, "Asc ");
dto.setStartDateTs(startTs);
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
Date date = DateUtils.dateParse(startDate + ":00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -9), DATE_TIME_PATTERN));
long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_hour", startDate + ":00:00", "Asc ");
dto.setStartDateTs(startTs);
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
StringBuilder newStartDate = new StringBuilder(startDate);
int number = 0;
if((newStartDate.charAt(15) - '0') > 0) {
number = 9;
}
newStartDate.replace(15, 16, number+"");
Date startDateDate = DateUtils.dateParse(newStartDate + ":00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(startDateDate, -8), DATE_TIME_PATTERN));
String nextWholeMinute = DateUtils.getNextWholeMinute(dto.getStartDate()+":00");
long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_moment", nextWholeMinute, "Asc ");
dto.setStartDateTs(startTs);
} else {
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN));
long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_data", startDate+" 00:00:00", "Asc ");
dto.setStartDateTs(startTs);
}
......@@ -237,25 +230,24 @@ public class TdInfoQueryController extends BaseController {
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) {
Date endDateDate = DateUtils.dateParse(endDate + " 23:59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, 24), DATE_TIME_PATTERN));
}else
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
Date endDateDate = DateUtils.dateParse(endDate + ":59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -9), DATE_TIME_PATTERN));
} else
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
StringBuilder newEndDate = new StringBuilder(endDate);
newEndDate.replace(15, 16, "9");
Date endDateDate = DateUtils.dateParse(newEndDate + ":59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
long endTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_day", endDate, "desc ");
dto.setEndDateTs(endTs);
dto.setTableName("pv_health_index_day");
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
long endTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_hour", endDate + ":00:00", "desc ");
dto.setEndDateTs(endTs);
dto.setTableName("pv_health_index_hour");
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
String nextWholeMinute = DateUtils.getBeforeWholeMinute(endDate);
long endTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_moment", nextWholeMinute, "desc ");
dto.setEndDateTs(endTs);
dto.setTableName("pv_health_index_moment");
} else {
Date endDateDate = DateUtils.dateParse(endDate, "yyyy-MM-dd HH:mm:ss");
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
long endTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_data", endDate+" 00:00:00", "desc ");
dto.setEndDateTs(endTs);
dto.setTableName("pv_health_index_data");
}
}
if (CharSequenceUtil.isNotEmpty(dto.getSortsString())) {
ObjectMapper objectMapper = new ObjectMapper();
......
......@@ -47,4 +47,7 @@ public class FanHealthIndexDto implements Serializable {
private String orgCode;
private List<String> gatewayIds;
private String warningPeriod;
private String tableName;
private Long startDateTs;
private Long endDateTs;
}
......@@ -46,5 +46,8 @@ public class PvHealthIndexDto {
private String sortOne;
private String sortsString;
private String orgCode;
private String tableName;
private Long startDateTs;
private Long endDateTs;
private List<String> gatewayIds;
}
......@@ -2999,6 +2999,7 @@ public class CommonServiceImpl {
if (500 == newList.size() || i == pvHealthIndices.size() - 1) { // 载体list达到要求,进行批量操作
// 调用批量插入
pvHealthIndexMapper.saveBatchHealthIndexList(newList, "pv_health_index_moment", analysisType);
// pvHealthIndexMapper.saveBatchHealthIndexListNew(newList, "pv_health_index_moment_new", analysisType);
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfoPv(newList);
newList.clear();// 每次批量操作后,清空载体list,等待下次的数据填入
}
......
......@@ -19,6 +19,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
......@@ -107,7 +108,9 @@ public class TdengineTimeServiceImpl {
idxFanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", WarningPeriodEnum.HOUR.getName());
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd HH:00:00");
// 8小时 + 59分钟
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -541), DateUtils.DATE_TIME_PATTERN);
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -539), DateUtils.DATE_TIME_PATTERN);
log.debug("开始时间为----------------------{}",startTime);
log.debug("整点存库时间为----------------------{}",recDate);
// // 测点
// List<IdxBizFanHealthLevel> levelList = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
// List<FanHealthIndex> fanHealthIndices = fanHealthIndexService.getInfoListByGroupByCdFan(startTime, "fan_health_index_moment", "测点");
......@@ -115,6 +118,7 @@ public class TdengineTimeServiceImpl {
// 测点
List<IdxBizFanHealthLevel> levelList = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
List<FanHealthIndex> healthIndices = fanHealthIndexMapper.getInfoListByGroupByCdFan(startTime, "fan_health_index_moment", "测点");
log.debug("风电小时测点数据为----------------------{}",healthIndices);
saveBatchFan(healthIndices, "fan_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), levelList);
// 子系统
List<IdxBizFanHealthLevel> levelListZxt = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "子系统").last("limit 4"));
......@@ -137,19 +141,24 @@ public class TdengineTimeServiceImpl {
// 测点
List<IdxBizPvHealthLevel> pvlevelList = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoListByGroupByCdPv(startTime, "pv_health_index_moment", "测点");
log.debug("光伏小时测点数据为----------------------{}",pvHealthIndices);
saveBatchPv(pvHealthIndices, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvlevelList);
// saveBatchPvNew(pvHealthIndices, "pv_health_index_hour_new", recDate, WarningPeriodEnum.HOUR.getName(), pvlevelList);
// 设备
List<IdxBizPvHealthLevel> pvLevelListSb = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesSb = pvHealthIndexService.getInfoListByGroupBySbPv(startTime, "pv_health_index_hour", "测点");
saveBatchPv(pvHealthIndicesSb, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListSb);
// saveBatchPvNew(pvHealthIndicesSb, "pv_health_index_hour_new", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListSb);
// 子阵
List<IdxBizPvHealthLevel> pvLevelListZz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "子阵").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesZz = pvHealthIndexService.getInfoListByGroupByZzPv(startTime, "pv_health_index_hour", "设备");
saveBatchPv(pvHealthIndicesZz, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListZz);
// saveBatchPvNew(pvHealthIndicesZz, "pv_health_index_hour_new", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListZz);
// 场站
List<IdxBizPvHealthLevel> pvLevelListCz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesCz = pvHealthIndexService.getInfoListByGroupByCzPv(startTime, "pv_health_index_hour", "子阵");
saveBatchPv(pvHealthIndicesCz, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListCz);
// saveBatchPvNew(pvHealthIndicesCz, "pv_health_index_hour_new", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListCz);
// 区域
List<HealthIndexDTO> healthIndexQyDTOS = fanHealthIndexService.getInfoListByGroupByQy(startTime,"fan_health_index_hour", "pv_health_index_hour","场站");
......@@ -160,6 +169,7 @@ public class TdengineTimeServiceImpl {
List<IdxBizPvHealthLevel> pvLevelListQy = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQy = healthIndexQyDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQy, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListQy);
// saveBatchPvNew(pvHealthIndicesQy, "pv_health_index_hour_new", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListQy);
// 全域【所有 / 全国】
List<HealthIndexDTO> healthIndexQgDTOS = fanHealthIndexService.getInfoListByGroupByQg(startTime, "fan_health_index_hour", "pv_health_index_hour", "片区");
......@@ -170,6 +180,7 @@ public class TdengineTimeServiceImpl {
List<IdxBizPvHealthLevel> pvLevelListQg = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "全域").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQg, "pv_health_index_hour", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListQg);
// saveBatchPvNew(pvHealthIndicesQg, "pv_health_index_hour_new", recDate, WarningPeriodEnum.HOUR.getName(), pvLevelListQg);
//预警生成
healthStatusIndicatorServiceImpl.healthWarningHour();
......@@ -218,18 +229,22 @@ public class TdengineTimeServiceImpl {
List<IdxBizPvHealthLevel> pvlevelList = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoListByGroupByCdPv(startTime, "pv_health_index_hour", "测点");
saveBatchPv(pvHealthIndices, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvlevelList);
// saveBatchPvNew(pvHealthIndices, "pv_health_index_day_new", recDate, WarningPeriodEnum.DAY.getName(), pvlevelList);
// 设备
List<IdxBizPvHealthLevel> pvLevelListSb = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesSb = pvHealthIndexService.getInfoListByGroupBySbPv(startTime, "pv_health_index_day", "测点");
saveBatchPv(pvHealthIndicesSb, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListSb);
// saveBatchPvNew(pvHealthIndicesSb, "pv_health_index_day_new", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListSb);
// 子阵
List<IdxBizPvHealthLevel> pvLevelListZz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "子阵").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesZz = pvHealthIndexService.getInfoListByGroupByZzPv(startTime, "pv_health_index_day", "设备");
saveBatchPv(pvHealthIndicesZz, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListZz);
// saveBatchPvNew(pvHealthIndicesZz, "pv_health_index_day_new", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListZz);
// 场站
List<IdxBizPvHealthLevel> pvLevelListCz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesCz = pvHealthIndexService.getInfoListByGroupByCzPv(startTime, "pv_health_index_day", "子阵");
saveBatchPv(pvHealthIndicesCz, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListCz);
// saveBatchPvNew(pvHealthIndicesCz, "pv_health_index_day_new", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListCz);
// 区域
List<HealthIndexDTO> healthIndexQyDTOS = fanHealthIndexService.getInfoListByGroupByQy(startTime,"fan_health_index_day", "pv_health_index_day","场站");
......@@ -240,6 +255,7 @@ public class TdengineTimeServiceImpl {
List<IdxBizPvHealthLevel> pvLevelListQy = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQy = healthIndexQyDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQy, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQy);
// saveBatchPvNew(pvHealthIndicesQy, "pv_health_index_day_new", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQy);
// 全域【所有 / 全国】
List<HealthIndexDTO> healthIndexQgDTOS = fanHealthIndexService.getInfoListByGroupByQg(startTime, "fan_health_index_day", "pv_health_index_day", "片区");
......@@ -250,6 +266,7 @@ public class TdengineTimeServiceImpl {
List<IdxBizPvHealthLevel> pvLevelListQg = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "全域").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQg, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQg);
// saveBatchPvNew(pvHealthIndicesQg, "pv_health_index_day_new", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQg);
//预警生成
healthStatusIndicatorServiceImpl.healthWarningDay();
......@@ -297,6 +314,29 @@ public class TdengineTimeServiceImpl {
}
}
@Async
private void saveBatchFanNew(List<FanHealthIndex> fanHealthIndices,
String tableName,
String recDate,
String analysisType,
List<IdxBizFanHealthLevel> levelList) {
ArrayList<FanHealthIndex> newList = new ArrayList<>();
for (int i = 0; i < fanHealthIndices.size(); i++) {
FanHealthIndex fanHealthIndex = fanHealthIndices.get(i);
fanHealthIndex.setRecDate(recDate);
fanHealthIndex.setAnalysisTime(recDate);
fanHealthIndex.setAnalysisType(analysisType);
fanHealthIndex.setHealthLevel(getHealthLevelByScore(levelList, fanHealthIndex.getHealthIndex()));
//分批次处理
newList.add(fanHealthIndex);//循环将数据填入载体list
if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
fanHealthIndexMapper.saveBatchHealthIndexListNew(newList, tableName, analysisType);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
}
/**
* 光伏 - 按时刻生成设备、子阵、场站和片区数据
*/
......@@ -306,14 +346,17 @@ public class TdengineTimeServiceImpl {
List<IdxBizPvHealthLevel> levelListSb = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesSb = pvHealthIndexService.getInfoListByGroupBySbPv(startTime, "pv_health_index_moment", "测点");
saveBatchPv(fanHealthIndicesSb, "pv_health_index_moment", recDate, WarningPeriodEnum.MINUTES.getName(), levelListSb);
// saveBatchPvNew(fanHealthIndicesSb, "pv_health_index_moment_new", recDate, WarningPeriodEnum.MINUTES.getName(), levelListSb);
// 子阵
List<IdxBizPvHealthLevel> levelListZz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "子阵").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesZz = pvHealthIndexService.getInfoListByGroupByZzPv(startTime, "pv_health_index_moment", "设备");
saveBatchPv(fanHealthIndicesZz, "pv_health_index_moment", recDate, WarningPeriodEnum.MINUTES.getName(), levelListZz);
// saveBatchPvNew(fanHealthIndicesZz, "pv_health_index_moment_new", recDate, WarningPeriodEnum.MINUTES.getName(), levelListZz);
// 场站
List<IdxBizPvHealthLevel> levelListCz = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站").last("limit 4"));
List<PvHealthIndex> fanHealthIndicesCz = pvHealthIndexService.getInfoListByGroupByCzPv(startTime, "pv_health_index_moment", "子阵");
saveBatchPv(fanHealthIndicesCz, "pv_health_index_moment", recDate, WarningPeriodEnum.MINUTES.getName(), levelListCz);
// saveBatchPvNew(fanHealthIndicesCz, "pv_health_index_moment_new", recDate, WarningPeriodEnum.MINUTES.getName(), levelListCz);
// // 片区
// List<IdxBizPvHealthLevel> levelListQy = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
// List<PvHealthIndex> fanHealthIndicesQy = pvHealthIndexService.getInfoListByGroupByQyPv(startTime, "pv_health_index_moment", "场站");
......@@ -443,7 +486,28 @@ public class TdengineTimeServiceImpl {
}
}
}
@Async
private void saveBatchPvNew(List<PvHealthIndex> pvHealthIndices,
String tableName,
String recDate,
String analysisType,
List<IdxBizPvHealthLevel> levelList) {
ArrayList<PvHealthIndex> newList = new ArrayList<>();
for (int i = 0; i < pvHealthIndices.size(); i++) {
PvHealthIndex item = pvHealthIndices.get(i);
item.setRecDate(recDate);
item.setAnalysisTime(recDate);
item.setAnalysisType(analysisType);
item.setHealthLevel(getHealthLevelByScorePv(levelList, item.getHealthIndex()));
//分批次处理
newList.add(item);//循环将数据填入载体list
if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
pvHealthIndexMapper.saveBatchHealthIndexListNew(newList, tableName, analysisType);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
}
public void insertMomentDataTest(String startTime) {
//s 489分钟 为 8小时 + 19分钟
......@@ -512,6 +576,7 @@ public class TdengineTimeServiceImpl {
List<IdxBizPvHealthLevel> pvLevelListQy = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "片区").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQy = healthIndexQyDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQy, "pv_health_index_moment", recDate, WarningPeriodEnum.MINUTES.getName(), pvLevelListQy);
// saveBatchPvNew(pvHealthIndicesQy, "pv_health_index_moment_new", recDate, WarningPeriodEnum.MINUTES.getName(), pvLevelListQy);
// 全域【所有 / 全国】
List<HealthIndexDTO> healthIndexQgDTOS = fanHealthIndexService.getInfoListByGroupByQg(startTime, "fan_health_index_moment", "pv_health_index_moment", "片区");
......@@ -522,6 +587,7 @@ public class TdengineTimeServiceImpl {
List<IdxBizPvHealthLevel> pvLevelListQg = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "全域").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQg, "pv_health_index_moment", recDate, WarningPeriodEnum.MINUTES.getName(), pvLevelListQg);
// saveBatchPvNew(pvHealthIndicesQg, "pv_health_index_moment_new", recDate, WarningPeriodEnum.MINUTES.getName(), pvLevelListQg);
}
public void insertMomentDataAllTest(String startTime) throws ParseException {
......@@ -552,5 +618,7 @@ public class TdengineTimeServiceImpl {
List<IdxBizPvHealthLevel> pvLevelListQg = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "全域").last("limit 4"));
List<PvHealthIndex> pvHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toPvHealthIndex(o)).collect(Collectors.toList());
saveBatchPv(pvHealthIndicesQg, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQg);
// saveBatchPvNew(pvHealthIndicesQg, "pv_health_index_day_new", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQg);
}
}
......@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -107,4 +108,5 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
@Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType);
int saveBatchHealthIndexListNew(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName, @Param("analysisType") String analysisType);
}
......@@ -30,6 +30,7 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
List<PvHealthIndex> selectData (@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subarray")String subarray, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
int saveBatchHealthIndexList(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName, @Param("analysisType") String analysisType);
int saveBatchHealthIndexListNew(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName, @Param("analysisType") String analysisType);
// int saveBatchHealthIndexLatestInfo(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName);
......@@ -61,6 +62,8 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
List<PvHealthIndex> getInfoByPage(@Param("dto") PvHealthIndexDto dto);
long getTsByRecDate(@Param("tableName")String tableName,@Param("recDate")String recDate,@Param("sort")String sort);
Integer getInfoByPageTotal(@Param("dto") PvHealthIndexDto dto);
List<PvHealthIndex> getInfoList(@Param("startTime") String startTime,
......
......@@ -554,4 +554,36 @@
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
</select>
<insert id="saveBatchHealthIndexListNew" >
insert into
${tableName}
using fan_health_index_data_new TAGS (#{analysisType})
values
<foreach collection="list" separator="," item="item" index="index">
(
now,
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subSystem, jdbcType=VARCHAR},
#{item.number, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR},
#{item.orgCode, jdbcType=VARCHAR}
)
</foreach>
</insert>
</mapper>
......@@ -199,12 +199,12 @@
</select>
<select id="getInfoByPage" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex">
SELECT * FROM pv_health_index_data
SELECT * FROM ${dto.tableName}
<where>
<if test="dto.analysisObjType!= null and dto.analysisObjType!= ''">analysis_obj_type = #{dto.analysisObjType}</if>
<if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if>
<if test="dto.endDate!= null and dto.endDate!= ''"> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
<if test="dto.endDateTs!= null and dto.endDateTs!= ''"> and ts &lt;= #{dto.endDateTs} </if>
<if test="dto.startDateTs!= null and dto.startDateTs!= ''"> and ts &gt;= #{dto.startDateTs} </if>
<if test="dto.area!= null and dto.area!= ''"> AND area = #{dto.area} </if>
<if test="dto.subarray!= null and dto.subarray!= ''"> AND subarray = #{dto.subarray} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
......@@ -226,13 +226,18 @@
limit #{dto.current}, #{dto.size}
</select>
<select id="getTsByRecDate" resultType="long">
SELECT ts FROM analysis_data.${tableName}
where rec_date = #{recDate} order by ts ${sort} limit 1 ;
</select>
<select id="getInfoByPageTotal" resultType="java.lang.Integer">
SELECT count(1) FROM pv_health_index_data
<where>
<if test="dto.analysisObjType!= null and dto.analysisObjType!= ''">analysis_obj_type = #{dto.analysisObjType}</if>
<if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if>
<if test="dto.endDate!= null and dto.endDate!= ''"> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
<if test="dto.endDateTs!= null and dto.endDateTs!= ''"> and ts &lt;= #{dto.endDateTs} </if>
<if test="dto.startDateTs!= null and dto.startDateTs!= ''"> and ts &gt;= #{dto.startDateTs} </if>
<if test="dto.area!= null and dto.area!= ''"> AND area = #{dto.area} </if>
<if test="dto.subarray!= null and dto.subarray!= ''"> AND subarray = #{dto.subarray} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
......@@ -318,4 +323,35 @@
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
</select>
<insert id="saveBatchHealthIndexListNew">
insert into analysis_data.${tableName}
using analysis_data.pv_health_index_data_new TAGS (#{analysisType},#{recDate})
values
<foreach collection="list" separator="," item="item" index="index">
(
now,
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subarray, jdbcType=VARCHAR},
#{item.manufacturer, jdbcType=VARCHAR},
#{item.deviceType, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.orgCode, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR}
)
</foreach>
</insert>
</mapper>
......@@ -56,4 +56,10 @@ public class StationInfoDto {
@ApiModelProperty(value = "风险等级")
private String riskLevel;
@ApiModelProperty(value = "系统名称默认值")
private String equipmentNameDefault;
@ApiModelProperty(value = "设备状态默认值")
private String subSystemDefault;
@ApiModelProperty(value = "变量状态默认值")
private String indexAddressDefault;
}
......@@ -72,5 +72,6 @@ public interface StationBasicMapper extends BaseMapper<StationBasic> {
StationBasicDto getStationInfoByCode(@Param("stationCode")String stationCode);
List<StationBasicDto> getStationsByAreaCode(@Param("areaCode")String stationCode);
List<StationBasicDto> getStationBasicList();
}
......@@ -213,4 +213,12 @@
is_delete = 0
ORDER BY sequence_nbr ASC
</select>
<select id="getStationBasicList" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto">
SELECT
sequence_nbr AS sequenceNbr,
station_type stationType
FROM
station_basic
</select>
</mapper>
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationCoordinateDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationInfoDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationRecordInfo;
......@@ -63,6 +65,8 @@ public class StationBasicServiceImpl extends BaseService<StationBasicDto, Statio
@Autowired
MapRegionServiceImpl mapRegionServiceImpl;
private final String CZLX = "CZLX";
@Autowired
private RedisUtils redisUtils;
/**
* 分页查询
......@@ -279,6 +283,7 @@ public class StationBasicServiceImpl extends BaseService<StationBasicDto, Statio
}
public List<StationInfoDto> getStationList(String areaCode, String type) {
JSONArray stationSelectDefault =(JSONArray)redisUtils.get("STATION_FIRST_SELECT");
// 场站信息列表 地图接口返回使用
List<StationInfoDto> stationInfoDtoList = new LinkedList<>();
//场站信息列表
......@@ -338,6 +343,19 @@ public class StationBasicServiceImpl extends BaseService<StationBasicDto, Statio
stationInfoDto.setTitlePos(doubleList);
stationInfoDto.setIndicatorData(indicatorList);
stationInfoDto.setRiskLevel(stationRecordInfo.getRiskLevel());
//添加默认场站选中的值
if(!CollectionUtils.isEmpty(stationSelectDefault)){
for (Object o : stationSelectDefault) {
if(o instanceof JSONObject){
JSONObject jsonObject=(JSONObject) o;
if(stationRecordInfo.getStationId().equals(jsonObject.getLong("stationBasicId"))){
stationInfoDto.setEquipmentNameDefault(jsonObject.getString("equipmentNameDefault"));
stationInfoDto.setSubSystemDefault(jsonObject.getString("subSystemDefault"));
stationInfoDto.setIndexAddressDefault(jsonObject.getString("indexAddressDefault"));
}
}
}
}
stationInfoDtoList.add(stationInfoDto);
});
......
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