Commit 1e5178ba authored by wujiang's avatar wujiang

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

# Conflicts: # amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/TdengineTimeServiceImpl.java
parents bd0b5024 c47d6e3d
......@@ -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 cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.biz.Enum.SmartAnalyseEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO;
......@@ -172,7 +174,11 @@ public class KafkaAnalyseController {
List<String> addressInfo = idxBizFanHealthIndexMapper.getAddressInfo();
String join = String.join(",", addressInfo);
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, "1668801435891929089");
String startTime = DateUtils.convertDateToString(DateUtil.offsetDay(new Date(), -1),
DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()),
DateUtils.DATE_TIME_PATTERN);
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, "1668801435891929089",startTime,endTime);
return ResponseHelper.buildResponse(indicatorData);
}
......
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")
......@@ -552,13 +529,13 @@ public class TDBigScreenAnalyseController extends BaseController {
// pvWrapper.eq(PvHealthIndex::getAnalysisTime, pvHealthIndex.getAnalysisTime());
// pvWrapper.last("limit 10");
// List<PvHealthIndex> pvHealthIndexList = pvHealthIndexMapper.selectList(pvWrapper);
LambdaQueryWrapper<IdxBizFanHealthIndexLatest> wrapperl = new LambdaQueryWrapper<IdxBizFanHealthIndexLatest>();
wrapperl.eq(IdxBizFanHealthIndexLatest::getAnalysisType, "按10分钟");
wrapperl.eq(IdxBizFanHealthIndexLatest::getAnalysisObjType, "场站");
wrapperl.eq(IdxBizFanHealthIndexLatest::getArae, areaCode+"区域");
List<IdxBizFanHealthIndexLatest> fanHealthIndexList=idxBizFanHealthIndexLatestMapper.selectList(wrapperl);
LambdaQueryWrapper<IdxBizPvHealthIndexLatest> wrapperp = new LambdaQueryWrapper<IdxBizPvHealthIndexLatest>();
wrapperp.eq(IdxBizPvHealthIndexLatest::getAnalysisType, "按10分钟");
wrapperp.eq(IdxBizPvHealthIndexLatest::getAnalysisObjType, "场站");
......@@ -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,43 +100,47 @@ 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) {
dto.setStartDate(startDate);
}else {
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
startDate = startDate + ":00:00";
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
startDate = startDate + ":00";
}
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(date, DATE_TIME_PATTERN);
dto.setStartDate(startDateString);
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) {
long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_day", startDate, "Asc ");
dto.setStartDateTs(startTs);
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
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) {
String nextWholeMinute = DateUtils.getNextWholeMinute(dto.getStartDate()+":00");
long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_moment", nextWholeMinute, "Asc ");
dto.setStartDateTs(startTs);
} else {
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) {
dto.setEndDate(endDate);
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 {
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
endDate = endDate + ":00:00";
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
endDate = endDate + ":00";
}
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(endDateDate, DATE_TIME_PATTERN);
dto.setEndDate(endDateString);
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());
dto.setCurrent((dto.getCurrent() - 1) * dto.getSize());
......@@ -203,45 +207,47 @@ 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) {
dto.setStartDate(startDate);
}else {
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
startDate = startDate + ":00:00";
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
startDate = startDate + ":00";
}
long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_day", startDate, "Asc ");
dto.setStartDateTs(startTs);
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
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) {
String nextWholeMinute = DateUtils.getNextWholeMinute(dto.getStartDate()+":00");
long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_moment", nextWholeMinute, "Asc ");
dto.setStartDateTs(startTs);
} else {
long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_data", startDate+" 00:00:00", "Asc ");
dto.setStartDateTs(startTs);
}
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(date, DATE_TIME_PATTERN);
dto.setStartDate(startDateString);
}
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) {
dto.setEndDate(endDate);
}else {
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
endDate = endDate + ":00:00";
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
endDate = endDate + ":00";
}
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(endDateDate, DATE_TIME_PATTERN);
dto.setEndDate(endDateString);
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 {
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();
......@@ -291,42 +297,26 @@ public class TdInfoQueryController extends BaseController {
}
dto.setOrgCode(orgCode);
Date currentDate = new Date();
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate();
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按天") && startDate.length() == 10) {
startDate = startDate + " 00:00:00";
}
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按小时") && startDate.length() == 13) {
startDate = startDate + ":00:00";
}
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按10分钟") && startDate.length() == 16) {
startDate = startDate + ":00";
if(startDate.length() == 10) {
Date date = DateUtils.dateParse(startDate + " 00:00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN));
} else {
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN));
}
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN);
dto.setStartDate(startDateString);
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按天") && endDate.length() == 10) {
endDate = endDate + " 00:00:00";
}
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按小时") && endDate.length() == 13) {
endDate = endDate + ":00:00";
}
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按10分钟") && endDate.length() == 16) {
endDate = endDate + ":00";
if(endDate.length() == 10) {
Date endDateDate = DateUtils.dateParse(endDate + " 23:59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
} else {
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
}
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN);
dto.setEndDate(endDateString);
}
if (CharSequenceUtil.isNotEmpty(dto.getSortsString())) {
ObjectMapper objectMapper = new ObjectMapper();
......@@ -375,41 +365,29 @@ public class TdInfoQueryController extends BaseController {
}
dto.setOrgCode(orgCode);
Date currentDate = new Date();
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate();
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按天") && startDate.length() == 10) {
startDate = startDate + " 00:00:00";
}
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按小时") && startDate.length() == 13) {
startDate = startDate + ":00:00";
}
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按10分钟") && startDate.length() == 16) {
startDate = startDate + ":00";
if(startDate.length() == 10) {
Date date = DateUtils.dateParse(startDate + " 00:00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN));
} else {
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN));
}
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN);
dto.setStartDate(startDateString);
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按天") && endDate.length() == 10) {
endDate = endDate + " 00:00:00";
}
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按小时") && endDate.length() == 13) {
endDate = endDate + ":00:00";
}
if(dto.getWarningPeriod() != null && dto.getWarningPeriod().equals("按10分钟") && endDate.length() == 16) {
endDate = endDate + ":00";
if(endDate.length() == 10) {
Date endDateDate = DateUtils.dateParse(endDate + " 23:59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
} else {
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
}
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN);
dto.setEndDate(endDateString);
}
if (CharSequenceUtil.isNotEmpty(dto.getSortsString())) {
ObjectMapper objectMapper = new ObjectMapper();
try {
......
......@@ -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;
}
......@@ -43,7 +43,7 @@ import static com.yeejoin.amos.boot.module.jxiop.biz.kafka.Constant.*;
* @create 2022/11/1 10:06
**/
@Slf4j
//@Service
@Service
public class KafkaConsumerService {
@Autowired
......@@ -478,9 +478,13 @@ public class KafkaConsumerService {
private void buildZXZExecData(List<ConsumerRecord<String, String>> consumerRecords,
Map<String, Set<String>> gatewayPoints,
Map<String, List<IdxBizFanPointProcessVariableClassification>> zxzIds, String xgxPvConsumer) {
String startTime = DateUtils.convertDateToString(DateUtil.offsetDay(new Date(), -1),
DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()),
DateUtils.DATE_TIME_PATTERN);
for (String gatewayId : gatewayPoints.keySet()) {
String join = String.join(",", gatewayPoints.get(gatewayId));
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId);
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId,startTime,endTime);
JsonReadOptions options = JsonReadOptions.builderFromString(JSON.toJSONString(indicatorData))
.columnTypes(new Function<String, ColumnType>() {
......@@ -499,9 +503,13 @@ public class KafkaConsumerService {
private void buildExecData(List<ConsumerRecord<String, String>> consumerRecords,
Map<String, Set<String>> gatewayPoints, String xgxPvConsumer) {
String startTime = DateUtils.convertDateToString(DateUtil.offsetDay(new Date(), -1),
DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()),
DateUtils.DATE_TIME_PATTERN);
for (String gatewayId : gatewayPoints.keySet()) {
String join = String.join(",", gatewayPoints.get(gatewayId));
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId);
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId,startTime,endTime);
JsonReadOptions options = JsonReadOptions.builderFromString(JSON.toJSONString(indicatorData))
.columnTypes(new Function<String, ColumnType>() {
......@@ -816,9 +824,13 @@ public class KafkaConsumerService {
private void buildZXZPvExecData(List<ConsumerRecord<String, String>> consumerRecords,
Map<String, Set<String>> gatewayPoints,
Map<String, List<IdxBizPvPointProcessVariableClassification>> zxzIds, String xgxPvConsumer) {
String startTime = DateUtils.convertDateToString(DateUtil.offsetDay(new Date(), -1),
DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(DateUtils.getCurrentDayEndTime(new Date()),
DateUtils.DATE_TIME_PATTERN);
for (String gatewayId : gatewayPoints.keySet()) {
String join = String.join(",", gatewayPoints.get(gatewayId));
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId);
List<IndicatorData> indicatorData = indicatorDataMapper.selectByAddresses(join, gatewayId,startTime,endTime);
JsonReadOptions options = JsonReadOptions.builderFromString(JSON.toJSONString(indicatorData))
.columnTypes(new Function<String, ColumnType>() {
......
......@@ -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,等待下次的数据填入
}
......
......@@ -112,7 +112,7 @@ public class IdxBizFanHealthIndexServiceImpl extends BaseService<IdxBizFanHealth
endTime = endTime.concat(" 23:59:59");
} else if (startTime.length() == 13) {
startTime = startTime.concat(":00:00");
endTime = endTime.concat(":59:59");
endTime = endTime.concat(":50:59");
} else if (startTime.length() == 16) {
startTime = startTime.concat(":00");
endTime = endTime.concat(":59");
......
......@@ -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 {
......@@ -543,17 +609,16 @@ public class TdengineTimeServiceImpl {
recOriginalDate = DateUtil.offsetDay(recOriginalDate, -1);
String recDate = DateUtil.format(recOriginalDate, "yyyy-MM-dd");
String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN);
// 全域【所有 / 全国】
List<HealthIndexDTO> healthIndexQgDTOS = fanHealthIndexService.getInfoListByGroupByQg(startTime, "fan_health_index_day", "pv_health_index_day", "片区");
List<HealthIndexDTO> healthIndexQgDTOS = fanHealthIndexService.getInfoListByGroupByQg(startTime, "fan_health_index_day", "fan_health_index_day", "片区");
List<IdxBizFanHealthLevel> levelListQg = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "全域").last("limit 4"));
List<FanHealthIndex> fanHealthIndicesQg = healthIndexQgDTOS.stream().map(o -> fanHealthIndexService.toFanHealthIndex(o)).collect(Collectors.toList());
// saveBatchFan(fanHealthIndicesQg, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelListQg);
saveBatchFan(fanHealthIndicesQg, "fan_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), levelListQg);
// 全域【所有 / 全国】
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);
saveBatchPv(pvHealthIndicesQg, "pv_health_index_day", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQg);
// saveBatchPvNew(pvHealthIndicesQg, "pv_health_index_day_new", recDate, WarningPeriodEnum.DAY.getName(), pvLevelListQg);
}
}
......@@ -89,7 +89,7 @@ public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> {
);
@Select("<script>"+
"SELECT distinct d.`health_index` AS healthIndex,d.rec_date as recDate, d.`health_index` AS `value`, d.anomaly, substr(d.analysis_time,1,10) as analysisTime,d.station,d.equipment_name AS equipmentName, d.point_name as pointName, ( CASE d.HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"SELECT distinct d.`health_index` AS healthIndex,d.ts,d.rec_date as recDate, d.`health_index` AS `value`, d.anomaly, substr(d.analysis_time,1,10) as analysisTime,d.station,d.equipment_name AS equipmentName, d.point_name as pointName, ( CASE d.HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
" FROM analysis_data.fan_health_index_day d" +
" INNER JOIN (SELECT last(ts) as maxTs " +
"<if test='area!= null '> ,area </if> " +
......
......@@ -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);
}
......@@ -111,7 +111,7 @@ public interface PvHealthIndexDayMapper extends BaseMapper<PvHealthIndexDay> {
@Select("<script>"+
"SELECT distinct d.`health_index` AS healthIndex,d.rec_date as recDate, d.`health_index` AS `value`, d.anomaly, substr(d.analysis_time,1,10) as analysisTime,d.station,d.equipment_name AS equipmentName, d.point_name as pointName, d.index_address as indexAddress, ( CASE d.HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"SELECT distinct d.`health_index` AS healthIndex,d.ts,d.rec_date as recDate, d.`health_index` AS `value`, d.anomaly, substr(d.analysis_time,1,10) as analysisTime,d.station,d.equipment_name AS equipmentName, d.point_name as pointName, d.index_address as indexAddress, ( CASE d.HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
" FROM analysis_data.pv_health_index_day d" +
" INNER JOIN (SELECT last(ts) as maxTs " +
"<if test='area!= null '> ,area </if> " +
......
......@@ -82,7 +82,7 @@ public interface PvHealthIndexHourMapper extends BaseMapper<PvHealthIndexHour> {
@Select("<script>"+
"SELECT distinct d.`health_index` AS healthIndex,d.rec_date as recDate, d.`health_index` AS `value`, d.anomaly, substr(d.analysis_time,1,10) as analysisTime,d.station,d.equipment_name AS equipmentName, d.point_name as pointName, d.index_address as indexAddress, ( CASE d.HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"SELECT distinct d.`health_index` AS healthIndex,d.ts,d.rec_date as recDate, d.`health_index` AS `value`, d.anomaly, substr(d.analysis_time,1,10) as analysisTime,d.station,d.equipment_name AS equipmentName, d.point_name as pointName, d.index_address as indexAddress, ( CASE d.HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
" FROM analysis_data.pv_health_index_hour d" +
" INNER JOIN (SELECT last(ts) as maxTs " +
"<if test='area!= null '> ,area </if> " +
......
......@@ -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,
......
......@@ -79,7 +79,7 @@ public interface PvHealthIndexMomentMapper extends BaseMapper<PvHealthIndexMomen
@Param("orgCode") String orgCode);
@Select("<script>"+
"SELECT distinct d.`health_index` AS healthIndex,d.rec_date as recDate, d.`health_index` AS `value`, d.anomaly, substr(d.analysis_time,1,10) as analysisTime,d.station,d.equipment_name AS equipmentName, d.point_name as pointName, d.index_address as indexAddress, ( CASE d.HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"SELECT distinct d.`health_index` AS healthIndex,d.ts,d.rec_date as recDate, d.`health_index` AS `value`, d.anomaly, substr(d.analysis_time,1,10) as analysisTime,d.station,d.equipment_name AS equipmentName, d.point_name as pointName, d.index_address as indexAddress, ( CASE d.HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
" FROM analysis_data.pv_health_index_moment d" +
" INNER JOIN (SELECT last(ts) as maxTs " +
"<if test='area!= null '> ,area </if> " +
......
......@@ -34,8 +34,8 @@ public interface IndicatorDataMapper extends BaseMapper<IndicatorData> {
List<IndicatorData> selectDataById (@Param("id")String id);
@Select("select `id`, `value` from iot_data.indicator_data where `address` in (${addresses}) and gateway_id = #{gatewayId}")
List<IndicatorData> selectByAddresses(@Param("addresses") String addresses, @Param("gatewayId") String gatewayId);
@Select("select `id`, `value` from iot_data.indicator_data where `address` in (${addresses}) and gateway_id = #{gatewayId} and ts >= #{startTime} and ts <= #{endTime}")
List<IndicatorData> selectByAddresses(@Param("addresses") String addresses, @Param("gatewayId") String gatewayId,@Param("startTime") String startTime, @Param("endTime")String endTime);
/**
* 根据测点名称查询测点值信息
......
......@@ -26,14 +26,15 @@ spring.db6.datasource.password=Yeejoin@2020
spring.db6.datasource.driver-class-name=com.kingbase8.Driver
## eureka properties:
eureka.instance.hostname=10.20.1.160
eureka.instance.hostname=47.92.234.253
eureka.client.serviceUrl.defaultZone=http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/
## redis properties:
spring.redis.database=1
spring.redis.host=10.20.0.169
spring.redis.host=10.20.1.210
spring.redis.port=6379
spring.redis.password=yeejoin@2020
openHealth=false
spring.cache.type=GENERIC
j2cache.open-spring-cache=true
j2cache.cache-clean-mode=passive
......@@ -78,13 +79,13 @@ emqx.client-password=public
tdengine-server:
driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
jdbc-url: jdbc:TAOS-RS://10.20.0.169:6041/iot_data_1?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
jdbc-url: jdbc:TAOS-RS://10.20.0.203:6041/iot_data_1?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
username: root
password: taosdata
#spring.db3.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db3.datasource.url=jdbc:TAOS-RS://10.20.0.169:6041/iot_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
spring.db3.datasource.url=jdbc:TAOS-RS://10.20.0.203:6041/iot_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
spring.db3.datasource.username=root
spring.db3.datasource.password=taosdata
spring.db3.datasource.driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
......@@ -92,7 +93,7 @@ spring.db3.datasource.driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
# ����ר��td���ݿ� analyse_data
#spring.db4.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db4.datasource.url=jdbc:TAOS-RS://10.20.0.169:6041/analysis_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
spring.db4.datasource.url=jdbc:TAOS-RS://10.20.0.203:6041/analysis_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
spring.db4.datasource.username=root
spring.db4.datasource.password=taosdata
spring.db4.datasource.driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
......@@ -149,7 +150,7 @@ amos.secret.key=qaz
#eureka.instance.ip-address=172.16.3.122
spring.activemq.broker-url=tcp://10.20.0.169:61616
spring.activemq.broker-url=tcp://10.20.1.210:61616
spring.activemq.user=admin
spring.activemq.password=admin
spring.jms.pub-sub-domain=false
......@@ -165,16 +166,16 @@ pictureUrl=upload/jxiop/syz/
#kafka
spring.kafka.bootstrap-servers=10.20.0.169:9092
spring.kafka.bootstrap-servers=10.20.0.223:9092,10.20.0.133:9200
spring.kafka.producer.retries=1
spring.kafka.producer.bootstrap-servers=10.20.0.169:9092
spring.kafka.producer.bootstrap-servers=10.20.0.223:9092,10.20.0.133:9200
spring.kafka.producer.batch-size=16384
spring.kafka.producer.buffer-memory=33554432
spring.kafka.producer.acks=1
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.consumer.group-id=consumerGroup
spring.kafka.consumer.bootstrap-servers=10.20.0.169:9092
spring.kafka.consumer.bootstrap-servers=10.20.0.223:9092,10.20.0.133:9200
spring.kafka.consumer.enable-auto-commit=false
spring.kafka.consumer.auto-offset-reset=earliest
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
......@@ -182,21 +183,22 @@ spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.S
spring.kafka.listener.ack-mode=manual_immediate
spring.kafka.listener.type=batch
#һ����ȡ���� && �߳�����
spring.kafka.consumer.max-poll-records=30
#spring.kafka.consumer.fetch-max-wait= 10000
spring.kafka.consumer.max-poll-records=50
spring.kafka.consumer.fetch-max-wait= 10000
#��ǰʱ����ǰƫ������ ����ʷƫ������
last.month.num = 12
#����� �㷨����
base.url.XGX=http://139.9.171.247:8052/intelligent-analysis/correlation
base.url.XGX=http://10.20.1.29:8052/intelligent-analysis/correlation
#�������� �㷨���õ�ַ
base.url.GKHF=http://139.9.171.247:8052/intelligent-analysis/working-condition-division
base.url.GKHF=http://10.20.1.29:8052/intelligent-analysis/working-condition-division
#����� �㷨����
base.url.ZXZ=http://139.9.171.247:8052/intelligent-analysis/central-value
base.url.ZXZ=http://10.20.1.29:8052/intelligent-analysis/central-value
#ָ���������㷨����
base.url.zsfx:http://139.9.171.247:8052/intelligent-analysis/index-analysis
base.url.zsfx:http://10.20.1.29:8052/intelligent-analysis/index-analysis
forecast.url=
logic=
\ No newline at end of file
analyse.cycle.offset=5
logic=false
\ No newline at end of file
......@@ -2,7 +2,7 @@ spring.application.name=AMOS-JXIOP-ANALYSE-CZ
server.servlet.context-path=/jxiop-analyse
server.port=33400
server.uri-encoding=UTF-8
spring.profiles.active=dev1
spring.profiles.active=kingbase8
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
logging.config=classpath:logback-${spring.profiles.active}.xml
......@@ -75,7 +75,7 @@ station.section=10
gl.sum.column=日发电量,月发电量,年发电量
gl.avg.column=有功功率,日利用小时,瞬时风速
spring.elasticsearch.rest.uris=http://10.20.0.169:9200
spring.elasticsearch.rest.uris=http://10.20.0.223:9200
spring.elasticsearch.rest.connection-timeout=30000
spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=Yeejoin@2020
......
......@@ -171,8 +171,8 @@
<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 rec_date &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and rec_date &gt;= #{dto.startDate} </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.area!= null and dto.area!= ''"> AND area = #{dto.area} </if>
<if test="dto.number!= null and dto.number!= ''"> AND `number` = #{dto.number} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
......@@ -200,8 +200,8 @@
<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 rec_date &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and rec_date &gt;= #{dto.startDate} </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.area!= null and dto.area!= ''"> AND area = #{dto.area} </if>
<if test="dto.number!= null and dto.number!= ''"> AND `number` = #{dto.number} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
......@@ -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 rec_date &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and rec_date &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 rec_date &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and rec_date &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>
......@@ -241,7 +246,7 @@
<if test="dto.equipmentName!= null and dto.equipmentName!= ''">AND equipment_name = #{dto.equipmentName}
</if>
<if test="dto.orgCode != null and dto.orgCode != ''">
and org_code like #{dto.orgCode}
and org_code like #{dto.orgCode}
</if>
</where>
......@@ -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);
});
......
......@@ -26,21 +26,7 @@
FROM
sjgl_zsj_zsbtz
WHERE
FSB IN (
SELECT
DBID
FROM
sjgl_zsj_zsbtz
WHERE
MACHGENRE = (
SELECT
DATAID
FROM
tpri_dmp_databook
WHERE
MACHGENRE = #{DATAID} and WERKS = #{WERKS}
)
)
MACHGENRE = #{DATAID} and WERKS = #{WERKS}
</select>
<select id="getStationInfoMapByStationGFWerks" resultType="map">
......
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