Commit fd28cd1e authored by wujiang's avatar wujiang

修改查询问题

parent 0a20427e
...@@ -198,17 +198,17 @@ public class TdInfoQueryController extends BaseController { ...@@ -198,17 +198,17 @@ public class TdInfoQueryController extends BaseController {
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) { if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate(); String startDate = dto.getStartDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) { if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) {
Long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_day", startDate, "Asc "); Long startTs = pvHealthIndexMapper.getTsByRecDateGT("fan_health_index_day", startDate, "Asc ");
dto.setStartDateTs(startTs); dto.setStartDateTs(startTs);
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) { }else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
Long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_hour", startDate + ":00:00", "Asc "); Long startTs = pvHealthIndexMapper.getTsByRecDateGT("fan_health_index_hour", startDate + ":00:00", "Asc ");
dto.setStartDateTs(startTs); dto.setStartDateTs(startTs);
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) { } else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
String nextWholeMinute = DateUtils.getNextWholeMinute(dto.getStartDate()+":00"); String nextWholeMinute = DateUtils.getNextWholeMinute(dto.getStartDate()+":00");
Long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_moment", nextWholeMinute, "Asc "); Long startTs = pvHealthIndexMapper.getTsByRecDateGT("fan_health_index_moment", nextWholeMinute, "Asc ");
dto.setStartDateTs(startTs); dto.setStartDateTs(startTs);
} else { } else {
Long startTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_data", startDate+" 00:00:00", "Asc "); Long startTs = pvHealthIndexMapper.getTsByRecDateGT("fan_health_index_data", startDate+" 00:00:00", "Asc ");
dto.setStartDateTs(startTs); dto.setStartDateTs(startTs);
} }
} }
...@@ -221,20 +221,20 @@ public class TdInfoQueryController extends BaseController { ...@@ -221,20 +221,20 @@ public class TdInfoQueryController extends BaseController {
endDate= formatter.format(date); endDate= formatter.format(date);
} }
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) { if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) {
Long endTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_day", endDate, "desc "); Long endTs = pvHealthIndexMapper.getTsByRecDateLT("fan_health_index_day", endDate, "desc ");
dto.setEndDateTs(endTs); dto.setEndDateTs(endTs);
dto.setTableName("fan_health_index_day"); dto.setTableName("fan_health_index_day");
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) { }else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
Long endTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_hour", endDate + ":00:00", "desc "); Long endTs = pvHealthIndexMapper.getTsByRecDateLT("fan_health_index_hour", endDate + ":00:00", "desc ");
dto.setEndDateTs(endTs); dto.setEndDateTs(endTs);
dto.setTableName("fan_health_index_hour"); dto.setTableName("fan_health_index_hour");
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) { } else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
String nextWholeMinute = DateUtils.getBeforeWholeMinute(endDate+":00"); String nextWholeMinute = DateUtils.getBeforeWholeMinute(endDate+":00");
Long endTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_moment", nextWholeMinute, "desc "); Long endTs = pvHealthIndexMapper.getTsByRecDateLT("fan_health_index_moment", nextWholeMinute, "desc ");
dto.setEndDateTs(endTs); dto.setEndDateTs(endTs);
dto.setTableName("fan_health_index_moment"); dto.setTableName("fan_health_index_moment");
} else { } else {
Long endTs = pvHealthIndexMapper.getTsByRecDate("fan_health_index_data", endDate+" 00:00:00", "desc "); Long endTs = pvHealthIndexMapper.getTsByRecDateLT("fan_health_index_data", endDate+" 00:00:00", "desc ");
dto.setEndDateTs(endTs); dto.setEndDateTs(endTs);
dto.setTableName("fan_health_index_data"); dto.setTableName("fan_health_index_data");
} }
...@@ -320,17 +320,17 @@ public class TdInfoQueryController extends BaseController { ...@@ -320,17 +320,17 @@ public class TdInfoQueryController extends BaseController {
String startDate = dto.getStartDate(); String startDate = dto.getStartDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) { if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) {
Long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_day", startDate, "Asc "); Long startTs = pvHealthIndexMapper.getTsByRecDateGT("pv_health_index_day", startDate, "Asc ");
dto.setStartDateTs(startTs); dto.setStartDateTs(startTs);
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) { }else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
Long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_hour", startDate + ":00:00", "Asc "); Long startTs = pvHealthIndexMapper.getTsByRecDateGT("pv_health_index_hour", startDate + ":00:00", "Asc ");
dto.setStartDateTs(startTs); dto.setStartDateTs(startTs);
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) { } else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
String nextWholeMinute = DateUtils.getNextWholeMinute(dto.getStartDate()+":00"); String nextWholeMinute = DateUtils.getNextWholeMinute(dto.getStartDate()+":00");
Long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_moment", nextWholeMinute, "Asc "); Long startTs = pvHealthIndexMapper.getTsByRecDateGT("pv_health_index_moment", nextWholeMinute, "Asc ");
dto.setStartDateTs(startTs); dto.setStartDateTs(startTs);
} else { } else {
Long startTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_data", startDate+" 00:00:00", "Asc "); Long startTs = pvHealthIndexMapper.getTsByRecDateGT("pv_health_index_data", startDate+" 00:00:00", "Asc ");
dto.setStartDateTs(startTs); dto.setStartDateTs(startTs);
} }
} }
...@@ -338,25 +338,25 @@ public class TdInfoQueryController extends BaseController { ...@@ -338,25 +338,25 @@ public class TdInfoQueryController extends BaseController {
String dateNowShortStr = DateUtils.getDateNowShortStr(); String dateNowShortStr = DateUtils.getDateNowShortStr();
String endDate = dto.getEndDate(); String endDate = dto.getEndDate();
if (dateNowShortStr.equals(endDate)){ if (dateNowShortStr.equals(endDate)){
Date date = DateUtils.dateAddDays(null, -1); Date date = DateUtils.dateAddDays(null, 0);
SimpleDateFormat formatter = new SimpleDateFormat(DateUtils.DATE_PATTERN); SimpleDateFormat formatter = new SimpleDateFormat(DateUtils.DATE_PATTERN);
endDate= formatter.format(date); endDate= formatter.format(date);
} }
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) { if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) {
Long endTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_day", endDate, "desc "); Long endTs = pvHealthIndexMapper.getTsByRecDateLT("pv_health_index_day", endDate, "desc ");
dto.setEndDateTs(endTs); dto.setEndDateTs(endTs);
dto.setTableName("pv_health_index_day"); dto.setTableName("pv_health_index_day");
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) { }else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
Long endTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_hour", endDate + ":00:00", "desc "); Long endTs = pvHealthIndexMapper.getTsByRecDateLT("pv_health_index_hour", endDate + ":00:00", "desc ");
dto.setEndDateTs(endTs); dto.setEndDateTs(endTs);
dto.setTableName("pv_health_index_hour"); dto.setTableName("pv_health_index_hour");
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) { } else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
String nextWholeMinute = DateUtils.getBeforeWholeMinute(endDate+":00"); String nextWholeMinute = DateUtils.getBeforeWholeMinute(endDate+":00");
Long endTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_moment", nextWholeMinute, "desc "); Long endTs = pvHealthIndexMapper.getTsByRecDateLT("pv_health_index_moment", nextWholeMinute, "desc ");
dto.setEndDateTs(endTs); dto.setEndDateTs(endTs);
dto.setTableName("pv_health_index_moment"); dto.setTableName("pv_health_index_moment");
} else { } else {
Long endTs = pvHealthIndexMapper.getTsByRecDate("pv_health_index_data", endDate+" 00:00:00", "desc "); Long endTs = pvHealthIndexMapper.getTsByRecDateLT("pv_health_index_data", endDate+" 00:00:00", "desc ");
dto.setEndDateTs(endTs); dto.setEndDateTs(endTs);
dto.setTableName("pv_health_index_data"); dto.setTableName("pv_health_index_data");
} }
......
...@@ -62,7 +62,9 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> { ...@@ -62,7 +62,9 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
List<PvHealthIndex> getInfoByPage(@Param("dto") PvHealthIndexDto dto); List<PvHealthIndex> getInfoByPage(@Param("dto") PvHealthIndexDto dto);
Long getTsByRecDate(@Param("tableName")String tableName,@Param("recDate")String recDate,@Param("sort")String sort); Long getTsByRecDateGT(@Param("tableName")String tableName,@Param("recDate")String recDate,@Param("sort")String sort);
Long getTsByRecDateLT(@Param("tableName")String tableName,@Param("recDate")String recDate,@Param("sort")String sort);
Integer getInfoByPageTotal(@Param("dto") PvHealthIndexDto dto); Integer getInfoByPageTotal(@Param("dto") PvHealthIndexDto dto);
......
...@@ -228,9 +228,14 @@ ...@@ -228,9 +228,14 @@
limit #{dto.current}, #{dto.size} limit #{dto.current}, #{dto.size}
</select> </select>
<select id="getTsByRecDate" resultType="long"> <select id="getTsByRecDateGT" resultType="long">
SELECT ts FROM analysis_data.${tableName} SELECT ts FROM analysis_data.${tableName}
where rec_date = #{recDate} order by ts ${sort} limit 1 ; where rec_date &gt;= #{recDate} order by ts ${sort} limit 1 ;
</select>
<select id="getTsByRecDateLT" resultType="long">
SELECT ts FROM analysis_data.${tableName}
where rec_date &lt;= #{recDate} order by ts ${sort} limit 1 ;
</select> </select>
<select id="getInfoByPageTotal" resultType="java.lang.Integer"> <select id="getInfoByPageTotal" resultType="java.lang.Integer">
......
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