...
This commit is contained in:
parent
5792878b82
commit
1aaeee1bfd
|
@ -162,19 +162,19 @@ public class WaterPointController {
|
|||
if (StringUtils.isEmpty(water_point_id)) {
|
||||
return Result.error("未提供积水点id");
|
||||
}
|
||||
String sql = String.format("SELECT DISTINCT\n" +
|
||||
"\tYEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) `year`,\n" +
|
||||
"\tMONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) `month`,\n" +
|
||||
"\tDAY ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) `day` \n" +
|
||||
"FROM\n" +
|
||||
"\twater_point_sensor \n" +
|
||||
"WHERE\n" +
|
||||
"\twater_point_sensor.water_point_id = '%s' \n" +
|
||||
"\tAND water_point_sensor.updated_date != '0.00' \n" +
|
||||
"ORDER BY\n" +
|
||||
"\t`year` DESC,\n" +
|
||||
"\t`month` DESC,\n" +
|
||||
"\t`day` DESC;", water_point_id);
|
||||
String sql = String.format("SELECT DISTINCT " +
|
||||
"YEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) `year`," +
|
||||
"MONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) `month`," +
|
||||
"DAY ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) `day` " +
|
||||
" FROM " +
|
||||
"water_point_sensor " +
|
||||
" WHERE " +
|
||||
"water_point_sensor.water_point_id = '%s' " +
|
||||
"AND water_point_sensor.updated_date != '0.00'" +
|
||||
" ORDER BY " +
|
||||
"`year` DESC," +
|
||||
"`month` DESC," +
|
||||
"`day` DESC;", water_point_id);
|
||||
return Result.success(jdbcTemplate.queryForList(sql));
|
||||
}
|
||||
|
||||
|
@ -197,28 +197,26 @@ public class WaterPointController {
|
|||
if (StringUtils.isEmpty(year) || StringUtils.isEmpty(month) || StringUtils.isEmpty(day)) {
|
||||
return Result.error("未提供日期");
|
||||
}
|
||||
String sql = String.format("SELECT\n" +
|
||||
"\tupdated_date AS depth,\n" +
|
||||
"\tYEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) AS `year`,\n" +
|
||||
"\tMONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) AS `month`,\n" +
|
||||
"\tDAY ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) AS `day`,\n" +
|
||||
"\tHOUR (\n" +
|
||||
"\tSTR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' )) AS `hour`,\n" +
|
||||
"\tMINUTE (\n" +
|
||||
"\tSTR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' )) AS `minute` \n" +
|
||||
"FROM\n" +
|
||||
"\twater_point_sensor \n" +
|
||||
"WHERE\n" +
|
||||
"\twater_point_sensor.water_point_id = '%s' \n" +
|
||||
"\tAND YEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) = %s \n" +
|
||||
"\tAND MONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) = %s \n" +
|
||||
"\tAND DAY ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) = %s \n" +
|
||||
"ORDER BY\n" +
|
||||
"\t`year` DESC,\n" +
|
||||
"\t`month` DESC,\n" +
|
||||
"\t`day` DESC,\n" +
|
||||
"\t`hour`,\n" +
|
||||
"\t`minute`;", water_point_id, year, month, day);
|
||||
String sql = String.format("SELECT " +
|
||||
"updated_date AS depth," +
|
||||
"YEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) AS `year`," +
|
||||
"MONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) AS `month`," +
|
||||
"DAY ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) AS `day`," +
|
||||
"HOUR ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' )) AS `hour`," +
|
||||
"MINUTE ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' )) AS `minute`" +
|
||||
" FROM " +
|
||||
" water_point_sensor " +
|
||||
" WHERE " +
|
||||
"water_point_sensor.water_point_id = '%s' " +
|
||||
"AND YEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) = %s " +
|
||||
"AND MONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) = %s " +
|
||||
"AND DAY ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) = %s " +
|
||||
" ORDER BY " +
|
||||
"`year` DESC," +
|
||||
"`month` DESC," +
|
||||
"`day` DESC," +
|
||||
"`hour`," +
|
||||
"`minute`;", water_point_id, year, month, day);
|
||||
return Result.success(jdbcTemplate.queryForList(sql));
|
||||
}
|
||||
|
||||
|
@ -239,25 +237,25 @@ public class WaterPointController {
|
|||
if (StringUtils.isEmpty(year) || StringUtils.isEmpty(month)) {
|
||||
return Result.error("未提供日期");
|
||||
}
|
||||
String sql = String.format("SELECT\n" +
|
||||
"\tMAX( updated_date ) AS depth,\n" +
|
||||
"\tYEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) AS `year`,\n" +
|
||||
"\tMONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) AS `month`,\n" +
|
||||
"\tDAY ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) AS `day` \n" +
|
||||
"FROM\n" +
|
||||
"\twater_point_sensor \n" +
|
||||
"WHERE\n" +
|
||||
"\twater_point_sensor.water_point_id = '%s' \n" +
|
||||
"\tAND YEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) = %s \n" +
|
||||
"\tAND MONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%Y-%m-%d %H:%i:%s' ) ) = %s \n" +
|
||||
"GROUP BY\n" +
|
||||
"\t`year`,\n" +
|
||||
"\t`month`,\n" +
|
||||
"\t`day` \n" +
|
||||
"ORDER BY\n" +
|
||||
"\t`year` DESC,\n" +
|
||||
"\t`month` DESC,\n" +
|
||||
"\t`day` DESC;", water_point_id, year, month);
|
||||
String sql = String.format("SELECT " +
|
||||
"MAX( updated_date ) AS depth," +
|
||||
"YEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) AS `year`," +
|
||||
"MONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) AS `month`," +
|
||||
"DAY ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) AS `day` " +
|
||||
" FROM " +
|
||||
"water_point_sensor " +
|
||||
" WHERE " +
|
||||
"water_point_sensor.water_point_id = '%s' " +
|
||||
"AND YEAR ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) = %s " +
|
||||
"AND MONTH ( STR_TO_DATE( water_point_sensor.water_point_area, '%%Y-%%m-%%d %%H:%%i:%%s' ) ) = %s " +
|
||||
" GROUP BY " +
|
||||
"`year`," +
|
||||
"`month`," +
|
||||
"`day` " +
|
||||
" ORDER BY " +
|
||||
"`year` DESC," +
|
||||
"`month` DESC," +
|
||||
"`day` DESC;", water_point_id, year, month);
|
||||
return Result.success(jdbcTemplate.queryForList(sql));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue