Commit 9736b415 authored by chenzhao's avatar chenzhao

风电健康指数查询优化

parent ac0daddf
......@@ -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
*
......
......@@ -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;
}
......@@ -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>
......@@ -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>
......@@ -320,13 +325,12 @@
</select>
<insert id="saveBatchHealthIndexListNew">
insert into ${tableName}
using pv_health_index_data_new TAGS (#{analysisType})
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.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
......@@ -344,9 +348,9 @@
#{item.indexAddress, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.orgCode, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR},
#{item.orgCode, jdbcType=VARCHAR}
#{item.kks, jdbcType=VARCHAR}
)
</foreach>
</insert>
......
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