Commit b0928098 authored by 高建强's avatar 高建强

item:稳压泵指标统计细化重构提交

parent ebe0d4ea
......@@ -27,6 +27,7 @@ public class DateUtils {
public static final String MINUTE_ONLY_PATTERN = "mm";
public static final String HOUR_ONLY_PATTERN = "HH";
public static final String MONTH_DAY_HOUR_PATTERN = "MM-dd HH";
public static final String MONTH_DAY_HOUR_MINUTE_PATTERN = "MM-dd HH:mm";
public static final String DATE_PATTERN_NUM = "yyyyMMdd";
public static final String CHN_DATE_PATTERN_YEAR = "yyyy年";
public static final String CHN_DATE_PATTERN_MONTH = "MM月";
......@@ -933,7 +934,7 @@ public class DateUtils {
* @param pattern 时间格式
* @return 秒数
*/
public static Long getDurationSecconds(String startTime, String endTime, String pattern) {
public static Long getDurationSeconds(String startTime, String endTime, String pattern) {
final LocalDateTime start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).getSeconds();
......@@ -947,7 +948,7 @@ public class DateUtils {
* @param pattern 时间格式
* @return 秒数
*/
public static Long getDurationSecconds(Date startTime, Date endTime, String pattern) {
public static Long getDurationSeconds(Date startTime, Date endTime, String pattern) {
final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
final LocalDateTime start = LocalDateTime.parse(sdf.format(startTime), DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(sdf.format(endTime), DateTimeFormatter.ofPattern(pattern));
......
......@@ -8,11 +8,11 @@ package com.yeejoin.equipmanage.common.enums;
public enum PressurePumpAnalysisEnum {
PRESSURE_PUMP_FAULT("1", "1", "稳压泵是否故障", "无", ""),
PRESSURE_PUMP_INTERVAL("2", "2", "最近一次启停间隔", "", "分钟"),
PRESSURE_PUMP_DURATION("3", "3", "最近一次启动时长", "", "分钟"),
PRESSURE_PUMP_HALF("4", "4", "半小时启动", "", "次"),
PRESSURE_PUMP_TWO("5", "5", "2小时启动", "", "次"),
PRESSURE_PUMP_PIPE("6", "6", "管网压力", "", "");
PRESSURE_PUMP_INTERVAL("2", "2", "最近一次启停间隔", "0", "分钟"),
PRESSURE_PUMP_DURATION("3", "3", "最近一次启动时长", "0", "分钟"),
PRESSURE_PUMP_HALF("4", "4", "半小时启动", "0", "次"),
PRESSURE_PUMP_TWO("5", "5", "2小时启动", "0", "次"),
PRESSURE_PUMP_PIPE("6", "6", "管网压力", "正常", "");
private final String key;
private final String code;
......
......@@ -19,6 +19,8 @@ public enum PressurePumpRelateEnum {
PRESSURE_PUMP_START_BEFORE_MINUTE("-5", "稳压泵启泵前分钟数"),
PIPE_PRESSURE_NORMAL_STATUS("正常", "稳压泵管网压力正常状态"),
PIPE_PRESSURE_ABNORMAL_STATUS("异常", "稳压泵管网压力异常状态"),
START("1", "稳压泵启动"),
STOP("0", "稳压泵停止"),
UN_CLEAN_TIME("false", "未消除");
private final String value;
......
......@@ -7,9 +7,6 @@ import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
......@@ -27,7 +24,6 @@ public class DateUtils {
public static final String YEAR_PATTERN = "yyyy";
public static final String MINUTE_ONLY_PATTERN = "mm";
public static final String HOUR_ONLY_PATTERN = "HH";
public static final String MONTH_DAY_HOUR_PATTERN = "MM-dd HH";
public static final String DATE_TIME_T_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static final String[] TWENTY_FOUR = new String[]{" 00:00:00"," 01:00:00"," 02:00:00",
" 03:00:00"," 04:00:00"," 05:00:00"," 06:00:00"," 07:00:00"," 08:00:00"," 09:00:00"," 10:00:00"," 11:00:00"," 12:00:00"," 13:00:00",
......@@ -92,18 +88,6 @@ public class DateUtils {
}
/**
* 将字符换转换为日期
* @param date
* @param pattern
* @return
* @throws ParseException
*/
public static Date convertStrToDate(String date, String pattern) throws ParseException {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
return formatter.parse(date);
}
/**
* 获取当前时间任意
* @return
*/
......@@ -1031,118 +1015,6 @@ public class DateUtils {
return now;
}
public static List<String> getTimeStrListByStartAndEnd(String startTime, String endTime, String pattern) {
try {
List<String> list = new ArrayList<>();
Date startDate = convertStrToDate(startTime, DATE_TIME_PATTERN);
Date endDate = convertStrToDate(endTime, DATE_TIME_PATTERN);
list.add(convertDateToString(startDate, pattern));
Date date = startDate;
while (true) {
if (MONTH_DAY_HOUR_PATTERN.equals(pattern)) {
date = dateAddMinutes(date, 60);
} else {
date = dateAddMinutes(date, 1);
}
if (dateCompare(endDate, date) == 1) {
list.add(convertDateToString(date, pattern));
} else {
break;
}
}
return list;
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
/**
* 获取两个时间段之间的秒数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 秒数
*/
public static Long getDurationSecconds(String startTime, String endTime, String pattern) {
final LocalDateTime start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).getSeconds();
}
/**
* 获取两个时间段之间的秒数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 秒数
*/
public static Long getDurationSecconds(Date startTime, Date endTime, String pattern) {
final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
final LocalDateTime start = LocalDateTime.parse(sdf.format(startTime), DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(sdf.format(endTime), DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).getSeconds();
}
/**
* 获取两个时间段之间的分钟数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 分钟数
*/
public static Long getDurationMinutes(String startTime, String endTime, String pattern) {
final LocalDateTime start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).toMinutes();
}
/**
* 获取两个时间段之间的分钟数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 分钟数
*/
public static Long getDurationMinutes(Date startTime, Date endTime, String pattern) {
final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
final LocalDateTime start = LocalDateTime.parse(sdf.format(startTime), DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(sdf.format(endTime), DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).toMinutes();
}
/**
* 获取两个时间段之间的小时数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 小时
*/
public static Long getDurationHours(String startTime, String endTime, String pattern) {
final LocalDateTime start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).toHours();
}
/**
* 获取两个时间段之间的小时数
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param pattern 时间格式
* @return 小时
*/
public static Long getDurationHours(Date startTime, Date endTime, String pattern) {
final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
final LocalDateTime start = LocalDateTime.parse(sdf.format(startTime), DateTimeFormatter.ofPattern(pattern));
final LocalDateTime end = LocalDateTime.parse(sdf.format(endTime), DateTimeFormatter.ofPattern(pattern));
return Duration.between(start, end).toHours();
}
public static Date getBeginDayOfWeek() {
Date date = new Date();
if (date == null) {
......
......@@ -325,8 +325,8 @@ public class SupervisionConfigureController extends AbstractBaseController {
twoHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), two, nowStrLong, prefix, suffix, pressurePumpStart);
fourHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), four, nowStrLong, prefix, suffix, pressurePumpStart);
oneHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), one, nowStrLong, prefix, suffix, pressurePumpStart);
start = iotFeign.topSingleField(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "true", pressurePumpStart);
stop = iotFeign.topSingleField(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "false", pressurePumpStart);
start = iotFeign.topSingleField("1", prefix, suffix, "true", pressurePumpStart);
stop = iotFeign.topSingleField("1", prefix, suffix, "false", pressurePumpStart);
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -53,9 +53,6 @@ public interface IotFeign {
@RequestMapping(value = "v1/livedata/common/top/single-field", method = RequestMethod.GET, consumes = "application/json")
ResponseModel topSingleField(
@RequestHeader("appKey") String appKey,
@RequestHeader("product") String product,
@RequestHeader("token") String token,
@RequestParam(value = "top") String top,
@RequestParam(value = "productKey") String productKey,
@RequestParam( required = false, value = "deviceName") String deviceName,
......
......@@ -15,17 +15,20 @@ public interface IPressurePumpService {
/**
* redis缓存物联采集数据,内部读取JSON配置指定有效期
* @param message
*
* @param iotDatalist
* @param topic
*/
void saveDataToRedis(List<IotDataVO> iotDatalist);
void saveDataToRedis(List<IotDataVO> iotDatalist, String topic);
/**
* 根据key,模糊查询所有的redis缓存数据
* @param key
* 根据nameKey,模糊查询所有的redis缓存数据
* @param infoCode
* @param nameKey
* @param iotCode
* @return
*/
List<IotDataVO> getDataToRedis(String key);
List<IotDataVO> getDataToRedis(String infoCode, String nameKey, String iotCode);
/**
* 获取指标配置JSON信息集合
......@@ -37,7 +40,7 @@ public interface IPressurePumpService {
* 获取所有稳压泵最近一次启停间隔,min
* @return
*/
long getAllPressurePumpStartStopInterval(List<IotDataVO> redisDataList, String nowStrLong, String bizOrgCode);
long getAllPressurePumpStartStopInterval(List<IotDataVO> redisDataList, List<Map<String, String>> iotDataList, String nowStrLong, String bizOrgCode);
/**
* 获取稳压泵一定时间内启动频率或次数
......@@ -50,21 +53,60 @@ public interface IPressurePumpService {
/**
* 获取稳压泵最近一次启停时长,min
*
* @param redisDataList
* @param iotDataList
* @param nowStrLong
* @param bizOrgCode
* @return
*/
long getAllPressurePumpStartStopDuration(List<IotDataVO> redisDataList, String nowStrLong, String bizOrgCode);
long getAllPressurePumpStartStopDuration(List<IotDataVO> redisDataList, List<Map<String, String>> iotDataList, String nowStrLong, String bizOrgCode);
/**
* 获取稳压泵指定启泵前 minutes 分钟,管网压力差绝对值
*
* @param redisDataList
* @param redisDataPipeList
* @param iotDataList
* @param iotDataPipeList
* @param nowStrLong
* @param minutes
* @return
*/
double getAllPressurePumpPipePressureDiff(List<IotDataVO> redisDataList, List<IotDataVO> redisDataPipeList, String nowStrLong, String minutes);
double getAllPressurePumpPipePressureDiff(List<IotDataVO> redisDataList, List<IotDataVO> redisDataPipeList, List<Map<String, String>> iotDataList, List<Map<String, String>> iotDataPipeList, String nowStrLong, String minutes);
/**
* 根据指标,获取物联top数据,influxdb
* @param top
* @param productKey
* @param deviceName
* @param key
* @param fieldKey
* @return
*/
List<Map<String, String>> getIotTopSingleField(String top, String productKey, String deviceName, String key, String fieldKey);
/**
* 根据时间范围,获取redis指定指标或指定指标设备的缓存数据
* @param infoCode
* @param nameKey
* @param iotCode
* @param startDate
* @param endDate
* @return
*/
List<IotDataVO> getDataToRedisByDateBetween(String infoCode, String nameKey, String iotCode, Date startDate, Date endDate);
/**
* 根据时间范围获取iot物联数据集合
* @param startTime
* @param endTime
* @param prefix
* @param suffix
* @param o
* @param pressurePumpStart
* @return
*/
List<Map<String, String>> getIotCommonListData(String startTime, String endTime, String prefix, String suffix, String key, String fieldKey);
}
......@@ -317,7 +317,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
}
// redis缓存指定指标、指定时长物联数据
pressurePumpService.saveDataToRedis(iotDatalist);
pressurePumpService.saveDataToRedis(iotDatalist, topic);
if (!StringUtils.isEmpty(traceId)) {
String finalTraceId = traceId;
......
......@@ -4,6 +4,7 @@
"code": "PressurePump",
"nameKey": "FHS_PressurePump_Start,FHS_PipePressureDetector_PipePressure",
"expire": 14400,
"equipmentCode": "92010800KAL44"
"equipmentCode": "92010800KAL44",
"top": "100"
}
]
\ No newline at end of file
......@@ -1728,7 +1728,8 @@
wes.value_label valueLabel,
wes.realtime_iot_es_index_id realtimeIotSpecificIndexId,
wes.realtime_iot_index_update_date realtiemIotIndexUpdateDate,
wes.realtime_iot_index_id realtimeIotIndexId
wes.realtime_iot_index_id realtimeIotIndexId,
wes.iot_code iotCode
FROM
wl_equipment_specific wes
<where>
......
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