Commit 5bcfe4478969edd3f56e64144c53957bb274bb06
1 parent
fa1826ca
bsth_c_arrival_info_'year'表查询sql优化
Showing
1 changed file
with
25 additions
and
25 deletions
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| @@ -152,17 +152,17 @@ public class ReportServiceImpl implements ReportService{ | @@ -152,17 +152,17 @@ public class ReportServiceImpl implements ReportService{ | ||
| 152 | PreparedStatement ps = null; | 152 | PreparedStatement ps = null; |
| 153 | ResultSet rs = null; | 153 | ResultSet rs = null; |
| 154 | String year=date.substring(0,4); | 154 | String year=date.substring(0,4); |
| 155 | - String sql = "select * from bsth_c_arrival_info_"+year+" where device_id=? AND line_id=? " | ||
| 156 | - + " AND weeks_year>=? AND weeks_year<=? AND ts >= ? AND ts <=? order by ts"; | 155 | + String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year in (?, ?) AND line_id=? " |
| 156 | + + " AND ts >= ? AND ts <=? AND device_id=? order by ts"; | ||
| 157 | try{ | 157 | try{ |
| 158 | conn = DBUtils_MS.getConnection(); | 158 | conn = DBUtils_MS.getConnection(); |
| 159 | ps = conn.prepareStatement(sql); | 159 | ps = conn.prepareStatement(sql); |
| 160 | - ps.setString(1, sbbb); | ||
| 161 | - ps.setString(2,line); | ||
| 162 | - ps.setInt(3, weeks_year); | ||
| 163 | - ps.setInt(4, weeks_year_next); | ||
| 164 | - ps.setLong(5, date1); | ||
| 165 | - ps.setLong(6, date2); | 160 | + ps.setInt(1, weeks_year); |
| 161 | + ps.setInt(2, weeks_year_next); | ||
| 162 | + ps.setString(3,line); | ||
| 163 | + ps.setLong(4, date1); | ||
| 164 | + ps.setLong(5, date2); | ||
| 165 | + ps.setString(6, sbbb); | ||
| 166 | rs = ps.executeQuery(); | 166 | rs = ps.executeQuery(); |
| 167 | 167 | ||
| 168 | list = resultSet2Set(rs); | 168 | list = resultSet2Set(rs); |
| @@ -2219,16 +2219,16 @@ public class ReportServiceImpl implements ReportService{ | @@ -2219,16 +2219,16 @@ public class ReportServiceImpl implements ReportService{ | ||
| 2219 | PreparedStatement ps = null; | 2219 | PreparedStatement ps = null; |
| 2220 | ResultSet rs = null; | 2220 | ResultSet rs = null; |
| 2221 | String year=date.substring(0,4); | 2221 | String year=date.substring(0,4); |
| 2222 | - String sql = "select * from bsth_c_arrival_info_"+year+" where line_id=? AND weeks_year=? " | ||
| 2223 | - + " AND ts >= ? AND ts <=? AND up_down=? order by device_id,ts"; | 2222 | + String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year=? AND line_id=? " |
| 2223 | + + " AND up_down=? AND ts >= ? AND ts <=? order by device_id,ts"; | ||
| 2224 | try{ | 2224 | try{ |
| 2225 | conn = DBUtils_MS.getConnection(); | 2225 | conn = DBUtils_MS.getConnection(); |
| 2226 | ps = conn.prepareStatement(sql); | 2226 | ps = conn.prepareStatement(sql); |
| 2227 | - ps.setString(1, line); | ||
| 2228 | - ps.setInt(2, weeks_year1); | ||
| 2229 | - ps.setLong(3, date1); | ||
| 2230 | - ps.setLong(4, date2); | ||
| 2231 | - ps.setInt(5, zd); | 2227 | + ps.setInt(1, weeks_year1); |
| 2228 | + ps.setString(2, line); | ||
| 2229 | + ps.setInt(3, zd); | ||
| 2230 | + ps.setLong(4, date1); | ||
| 2231 | + ps.setLong(5, date2); | ||
| 2232 | rs = ps.executeQuery(); | 2232 | rs = ps.executeQuery(); |
| 2233 | 2233 | ||
| 2234 | list = resultSet2Set(rs); | 2234 | list = resultSet2Set(rs); |
| @@ -2269,16 +2269,16 @@ public class ReportServiceImpl implements ReportService{ | @@ -2269,16 +2269,16 @@ public class ReportServiceImpl implements ReportService{ | ||
| 2269 | PreparedStatement ps = null; | 2269 | PreparedStatement ps = null; |
| 2270 | ResultSet rs = null; | 2270 | ResultSet rs = null; |
| 2271 | String year=date.substring(0,4); | 2271 | String year=date.substring(0,4); |
| 2272 | - String sql = "select * from bsth_c_arrival_info_"+year+" where line_id=? AND weeks_year=? " | ||
| 2273 | - + " AND ts >= ? AND ts <=? AND up_down=? order by device_id,ts"; | 2272 | + String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year=? AND line_id=? " |
| 2273 | + + " AND up_down=? AND ts >= ? AND ts <=? order by device_id,ts"; | ||
| 2274 | try{ | 2274 | try{ |
| 2275 | conn = DBUtils_MS.getConnection(); | 2275 | conn = DBUtils_MS.getConnection(); |
| 2276 | ps = conn.prepareStatement(sql); | 2276 | ps = conn.prepareStatement(sql); |
| 2277 | - ps.setString(1, line); | ||
| 2278 | - ps.setInt(2, weeks_year1); | ||
| 2279 | - ps.setLong(3, date1); | ||
| 2280 | - ps.setLong(4, date2); | ||
| 2281 | - ps.setInt(5, zd); | 2277 | + ps.setInt(1, weeks_year1); |
| 2278 | + ps.setString(2, line); | ||
| 2279 | + ps.setInt(3, zd); | ||
| 2280 | + ps.setLong(4, date1); | ||
| 2281 | + ps.setLong(5, date2); | ||
| 2282 | rs = ps.executeQuery(); | 2282 | rs = ps.executeQuery(); |
| 2283 | 2283 | ||
| 2284 | list = resultSet2Set(rs); | 2284 | list = resultSet2Set(rs); |
| @@ -3880,12 +3880,12 @@ public class ReportServiceImpl implements ReportService{ | @@ -3880,12 +3880,12 @@ public class ReportServiceImpl implements ReportService{ | ||
| 3880 | PreparedStatement ps = null; | 3880 | PreparedStatement ps = null; |
| 3881 | ResultSet rs = null; | 3881 | ResultSet rs = null; |
| 3882 | String year=date.substring(0,4); | 3882 | String year=date.substring(0,4); |
| 3883 | - String sql = "select * from bsth_c_arrival_info_"+year+" where line_id=? AND weeks_year=? AND ts > ? AND ts <=? order by ts"; | 3883 | + String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year=? AND line_id=? AND ts > ? AND ts <=? order by ts"; |
| 3884 | try{ | 3884 | try{ |
| 3885 | conn = DBUtils_MS.getConnection(); | 3885 | conn = DBUtils_MS.getConnection(); |
| 3886 | ps = conn.prepareStatement(sql); | 3886 | ps = conn.prepareStatement(sql); |
| 3887 | - ps.setString(1,line); | ||
| 3888 | - ps.setInt(2, weeks_year); | 3887 | + ps.setInt(1, weeks_year); |
| 3888 | + ps.setString(2,line); | ||
| 3889 | ps.setLong(3, date1); | 3889 | ps.setLong(3, date1); |
| 3890 | ps.setLong(4, date2); | 3890 | ps.setLong(4, date2); |
| 3891 | rs = ps.executeQuery(); | 3891 | rs = ps.executeQuery(); |