Commit dc8b78e75085e8694a069d41ab2d091cfd92399a

Authored by 王通
1 parent 6b1128b3

1.加入计划配车信息

src/main/java/com/bsth/server_rs/dks/DksRestService.java
@@ -140,6 +140,47 @@ public class DksRestService { @@ -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 * @param month 185 * @param month
145 */ 186 */
@@ -226,12 +267,12 @@ public class DksRestService { @@ -226,12 +267,12 @@ public class DksRestService {
226 // 记录实际线路司售配档情况 267 // 记录实际线路司售配档情况
227 List<SchedulePlanInfo> schedulePlanInfos = schedulePlanInfoRepository.findByDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(dateTime.toString("yyyy-MM-dd")).toDate()); 268 List<SchedulePlanInfo> schedulePlanInfos = schedulePlanInfoRepository.findByDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(dateTime.toString("yyyy-MM-dd")).toDate());
228 Set<String> lineCodes = new HashSet<>(); 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 final List<LineServiceConfig> objects = new ArrayList<>(); 271 final List<LineServiceConfig> objects = new ArrayList<>();
231 for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { 272 for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) {
232 String lineCode = schedulePlanInfo.getXlBm(); 273 String lineCode = schedulePlanInfo.getXlBm();
233 lineCodes.add(lineCode); 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 if (conductors == null) { 276 if (conductors == null) {
236 conductors = new HashSet<>(); 277 conductors = new HashSet<>();
237 line2conductors.put(lineCode, conductors); 278 line2conductors.put(lineCode, conductors);
@@ -240,10 +281,15 @@ public class DksRestService { @@ -240,10 +281,15 @@ public class DksRestService {
240 drivers = new HashSet<>(); 281 drivers = new HashSet<>();
241 line2drivers.put(lineCode, drivers); 282 line2drivers.put(lineCode, drivers);
242 } 283 }
  284 + if (cars == null) {
  285 + cars = new HashSet<>();
  286 + line2cars.put(lineCode, cars);
  287 + }
243 if (!StringUtils.isEmpty(schedulePlanInfo.getsGh())) { 288 if (!StringUtils.isEmpty(schedulePlanInfo.getsGh())) {
244 conductors.add(schedulePlanInfo.getsGh()); 289 conductors.add(schedulePlanInfo.getsGh());
245 } 290 }
246 drivers.add(schedulePlanInfo.getjGh()); 291 drivers.add(schedulePlanInfo.getjGh());
  292 + cars.add(schedulePlanInfo.getClZbh());
247 } 293 }
248 for (String lineCode : lineCodes) { 294 for (String lineCode : lineCodes) {
249 LineServiceConfig object = new LineServiceConfig(); 295 LineServiceConfig object = new LineServiceConfig();
@@ -253,6 +299,7 @@ public class DksRestService { @@ -253,6 +299,7 @@ public class DksRestService {
253 object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); 299 object.setScheduleDate(dateTime.toString("yyyy-MM-dd"));
254 object.setConductorCount(line2conductors.get(lineCode).size()); 300 object.setConductorCount(line2conductors.get(lineCode).size());
255 object.setDriverCount(line2drivers.get(lineCode).size()); 301 object.setDriverCount(line2drivers.get(lineCode).size());
  302 + object.setCarCount(line2cars.get(lineCode).size());
256 303
257 objects.add(object); 304 objects.add(object);
258 } 305 }
@@ -265,7 +312,7 @@ public class DksRestService { @@ -265,7 +312,7 @@ public class DksRestService {
265 312
266 try { 313 try {
267 jdbcTemplate.update("delete from control_interface.bsth_t_plan where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); 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 @Override 316 @Override
270 public void setValues(PreparedStatement ps, int i) throws SQLException { 317 public void setValues(PreparedStatement ps, int i) throws SQLException {
271 LineServiceConfig object = objects.get(i); 318 LineServiceConfig object = objects.get(i);
@@ -274,6 +321,7 @@ public class DksRestService { @@ -274,6 +321,7 @@ public class DksRestService {
274 ps.setString(3, object.getScheduleDate()); 321 ps.setString(3, object.getScheduleDate());
275 ps.setInt(4, object.getConductorCount()); 322 ps.setInt(4, object.getConductorCount());
276 ps.setInt(5, object.getDriverCount()); 323 ps.setInt(5, object.getDriverCount());
  324 + ps.setInt(6, object.getCarCount());
277 } 325 }
278 326
279 @Override 327 @Override