Commit dc8b78e75085e8694a069d41ab2d091cfd92399a
1 parent
6b1128b3
1.加入计划配车信息
Showing
1 changed file
with
51 additions
and
3 deletions
src/main/java/com/bsth/server_rs/dks/DksRestService.java
| ... | ... | @@ -140,6 +140,47 @@ public class DksRestService { |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | + * 计划配车数 | |
| 144 | + * @param month | |
| 145 | + */ | |
| 146 | + @GET | |
| 147 | + @Path("/bus/plan/{month}") | |
| 148 | + public List<BusVo> busPlan(@PathParam("month") String month) { | |
| 149 | + List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 150 | + List<BusVo> result = new ArrayList<>(); | |
| 151 | + String oldLineCode = ""; | |
| 152 | + BusVo vo = null; | |
| 153 | + int max = 0; | |
| 154 | + for (int i = 0, len = configs.size();i < len;i++) { | |
| 155 | + LineServiceConfig config = configs.get(i); | |
| 156 | + if (i == 0) { | |
| 157 | + oldLineCode = config.getLineCode(); | |
| 158 | + vo = new BusVo(); | |
| 159 | + vo.setLineName(config.getLineName()); | |
| 160 | + vo.setMonth(month); | |
| 161 | + vo.setBusFirstCount(config.getCarCount()); | |
| 162 | + } else if (!oldLineCode.equals(config.getLineCode())) { | |
| 163 | + oldLineCode = config.getLineCode(); | |
| 164 | + vo.setBusMaxCount(max); | |
| 165 | + result.add(vo); | |
| 166 | + max = 0; | |
| 167 | + vo = new BusVo(); | |
| 168 | + vo.setLineName(config.getLineName()); | |
| 169 | + vo.setMonth(month); | |
| 170 | + vo.setBusFirstCount(config.getCarCount()); | |
| 171 | + } | |
| 172 | + max = Math.max(max, config.getCarCount()); | |
| 173 | + if (i == len - 1) { | |
| 174 | + vo.setBusMaxCount(max); | |
| 175 | + result.add(vo); | |
| 176 | + } | |
| 177 | + vo.setBusLastCount(config.getCarCount()); | |
| 178 | + } | |
| 179 | + | |
| 180 | + return result; | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 143 | 184 | * 实际配车数 |
| 144 | 185 | * @param month |
| 145 | 186 | */ |
| ... | ... | @@ -226,12 +267,12 @@ public class DksRestService { |
| 226 | 267 | // 记录实际线路司售配档情况 |
| 227 | 268 | List<SchedulePlanInfo> schedulePlanInfos = schedulePlanInfoRepository.findByDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(dateTime.toString("yyyy-MM-dd")).toDate()); |
| 228 | 269 | Set<String> lineCodes = new HashSet<>(); |
| 229 | - Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(); | |
| 270 | + Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>(); | |
| 230 | 271 | final List<LineServiceConfig> objects = new ArrayList<>(); |
| 231 | 272 | for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { |
| 232 | 273 | String lineCode = schedulePlanInfo.getXlBm(); |
| 233 | 274 | lineCodes.add(lineCode); |
| 234 | - Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode); | |
| 275 | + Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode); | |
| 235 | 276 | if (conductors == null) { |
| 236 | 277 | conductors = new HashSet<>(); |
| 237 | 278 | line2conductors.put(lineCode, conductors); |
| ... | ... | @@ -240,10 +281,15 @@ public class DksRestService { |
| 240 | 281 | drivers = new HashSet<>(); |
| 241 | 282 | line2drivers.put(lineCode, drivers); |
| 242 | 283 | } |
| 284 | + if (cars == null) { | |
| 285 | + cars = new HashSet<>(); | |
| 286 | + line2cars.put(lineCode, cars); | |
| 287 | + } | |
| 243 | 288 | if (!StringUtils.isEmpty(schedulePlanInfo.getsGh())) { |
| 244 | 289 | conductors.add(schedulePlanInfo.getsGh()); |
| 245 | 290 | } |
| 246 | 291 | drivers.add(schedulePlanInfo.getjGh()); |
| 292 | + cars.add(schedulePlanInfo.getClZbh()); | |
| 247 | 293 | } |
| 248 | 294 | for (String lineCode : lineCodes) { |
| 249 | 295 | LineServiceConfig object = new LineServiceConfig(); |
| ... | ... | @@ -253,6 +299,7 @@ public class DksRestService { |
| 253 | 299 | object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); |
| 254 | 300 | object.setConductorCount(line2conductors.get(lineCode).size()); |
| 255 | 301 | object.setDriverCount(line2drivers.get(lineCode).size()); |
| 302 | + object.setCarCount(line2cars.get(lineCode).size()); | |
| 256 | 303 | |
| 257 | 304 | objects.add(object); |
| 258 | 305 | } |
| ... | ... | @@ -265,7 +312,7 @@ public class DksRestService { |
| 265 | 312 | |
| 266 | 313 | try { |
| 267 | 314 | jdbcTemplate.update("delete from control_interface.bsth_t_plan where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); |
| 268 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_plan (line_code, line_name, schedule_date, conductor_count, driver_count) values (?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 315 | + jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_plan (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 269 | 316 | @Override |
| 270 | 317 | public void setValues(PreparedStatement ps, int i) throws SQLException { |
| 271 | 318 | LineServiceConfig object = objects.get(i); |
| ... | ... | @@ -274,6 +321,7 @@ public class DksRestService { |
| 274 | 321 | ps.setString(3, object.getScheduleDate()); |
| 275 | 322 | ps.setInt(4, object.getConductorCount()); |
| 276 | 323 | ps.setInt(5, object.getDriverCount()); |
| 324 | + ps.setInt(6, object.getCarCount()); | |
| 277 | 325 | } |
| 278 | 326 | |
| 279 | 327 | @Override | ... | ... |