Commit 0176c846f1b43d970cc8b49f9e6a2c5079b2770c

Authored by mcy123
1 parent 954bca51

mcy

src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -18,13 +18,16 @@ import com.bsth.entity.Personnel; @@ -18,13 +18,16 @@ import com.bsth.entity.Personnel;
18 import com.bsth.entity.realcontrol.ChildTaskPlan; 18 import com.bsth.entity.realcontrol.ChildTaskPlan;
19 import com.bsth.entity.realcontrol.LineConfig; 19 import com.bsth.entity.realcontrol.LineConfig;
20 import com.bsth.entity.realcontrol.ScheduleRealInfo; 20 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  21 +import com.bsth.entity.realcontrol.SvgAttribute;
21 import com.bsth.entity.schedule.CarConfigInfo; 22 import com.bsth.entity.schedule.CarConfigInfo;
22 import com.bsth.entity.schedule.EmployeeConfigInfo; 23 import com.bsth.entity.schedule.EmployeeConfigInfo;
23 import com.bsth.entity.schedule.GuideboardInfo; 24 import com.bsth.entity.schedule.GuideboardInfo;
  25 +import com.bsth.entity.sys.DutyEmployee;
24 import com.bsth.entity.sys.SysUser; 26 import com.bsth.entity.sys.SysUser;
25 import com.bsth.repository.LineRepository; 27 import com.bsth.repository.LineRepository;
26 import com.bsth.repository.realcontrol.ChildTaskPlanRepository; 28 import com.bsth.repository.realcontrol.ChildTaskPlanRepository;
27 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; 29 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  30 +import com.bsth.repository.realcontrol.SvgAttributeRepository;
28 import com.bsth.repository.schedule.CarConfigInfoRepository; 31 import com.bsth.repository.schedule.CarConfigInfoRepository;
29 import com.bsth.repository.schedule.EmployeeConfigInfoRepository; 32 import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
30 import com.bsth.repository.schedule.GuideboardInfoRepository; 33 import com.bsth.repository.schedule.GuideboardInfoRepository;
@@ -32,12 +35,15 @@ import com.bsth.security.util.SecurityUtils; @@ -32,12 +35,15 @@ import com.bsth.security.util.SecurityUtils;
32 import com.bsth.service.SectionRouteService; 35 import com.bsth.service.SectionRouteService;
33 import com.bsth.service.impl.BaseServiceImpl; 36 import com.bsth.service.impl.BaseServiceImpl;
34 import com.bsth.service.realcontrol.ScheduleRealInfoService; 37 import com.bsth.service.realcontrol.ScheduleRealInfoService;
  38 +import com.bsth.service.sys.DutyEmployeeService;
35 import com.bsth.util.*; 39 import com.bsth.util.*;
36 import com.bsth.websocket.handler.SendUtils; 40 import com.bsth.websocket.handler.SendUtils;
37 import com.google.common.base.Splitter; 41 import com.google.common.base.Splitter;
38 import com.google.common.collect.ArrayListMultimap; 42 import com.google.common.collect.ArrayListMultimap;
  43 +import com.google.common.collect.BiMap;
39 import com.google.common.collect.Lists; 44 import com.google.common.collect.Lists;
40 import com.google.common.collect.Multimap; 45 import com.google.common.collect.Multimap;
  46 +import org.apache.commons.lang3.StringEscapeUtils;
41 import org.apache.commons.lang3.StringUtils; 47 import org.apache.commons.lang3.StringUtils;
42 import org.joda.time.format.DateTimeFormat; 48 import org.joda.time.format.DateTimeFormat;
43 import org.joda.time.format.DateTimeFormatter; 49 import org.joda.time.format.DateTimeFormatter;
@@ -53,429 +59,390 @@ import java.util.*; @@ -53,429 +59,390 @@ import java.util.*;
53 59
54 @Service 60 @Service
55 public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long> 61 public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long>
56 - implements ScheduleRealInfoService { 62 + implements ScheduleRealInfoService {
57 63
58 - @Autowired  
59 - ScheduleRealInfoRepository scheduleRealInfoRepository; 64 + @Autowired
  65 + ScheduleRealInfoRepository scheduleRealInfoRepository;
60 66
61 - @Autowired  
62 - EmployeeConfigInfoRepository employeeConfigInfoRepository; 67 + @Autowired
  68 + EmployeeConfigInfoRepository employeeConfigInfoRepository;
63 69
64 - @Autowired  
65 - CarConfigInfoRepository carConfigInfoRepository;  
66 -  
67 - @Autowired  
68 - SectionRouteService sectionRouteService;  
69 -  
70 - /*@Autowired  
71 - BorrowCenter borrowCenter;*/  
72 -  
73 - @Autowired  
74 - LineRepository lineRepository;  
75 -  
76 - @Autowired  
77 - GuideboardInfoRepository guideboardInfoRepository;  
78 -  
79 - @Autowired  
80 - ChildTaskPlanRepository cTaskPlanRepository;  
81 -  
82 - @Autowired  
83 - SendUtils sendUtils;  
84 -  
85 - @Autowired  
86 - DayOfSchedule dayOfSchedule;  
87 -  
88 - @Autowired  
89 - SchAttrCalculator schAttrCalculator;  
90 -  
91 - @Autowired  
92 - LineConfigData lineConfigData;  
93 -  
94 - Logger logger = LoggerFactory.getLogger(this.getClass());  
95 -  
96 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
97 - sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"), sdfShort = new SimpleDateFormat("HH:mm"),  
98 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
99 -  
100 - @Override  
101 - public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) {  
102 - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines));  
103 -  
104 - Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create();  
105 -  
106 - for (String lineCode : lineList) {  
107 - mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode));  
108 - }  
109 - return mMap.asMap();  
110 - }  
111 -  
112 - private final static long DAY_TIME = 1000 * 60 * 60 * 24L;  
113 - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");  
114 - @Override  
115 - public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj/*, String nbbm,String jsy,String spy*/) {  
116 - Map<String, Object> map = new HashMap<>();  
117 - try {  
118 -  
119 - ScheduleRealInfo schedule = dayOfSchedule.get(id);  
120 -  
121 -  
122 - LineConfig config = lineConfigData.get(schedule.getXlBm());  
123 - //小于线路开始运营时间,则默认跨过24点  
124 - if(dfsj.compareTo(config.getStartOpt()) < 0){  
125 - schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME));  
126 - }  
127 - else {  
128 - schedule.setRealExecDate(schedule.getScheduleDateStr());  
129 - }  
130 -  
131 - schedule.setDfsjAll(dfsj);  
132 - schedule.addRemarks(remarks);  
133 -  
134 - List<ScheduleRealInfo> ts = new ArrayList<>();  
135 - ts.add(schedule);  
136 - //调整终点时间和下一个班次的应到时间  
137 - schedule.calcEndTime();  
138 - ScheduleRealInfo nextSch = dayOfSchedule.next(schedule);  
139 - if(null != nextSch){  
140 - nextSch.setQdzArrDateJH(schedule.getZdsj());  
141 - ts.add(nextSch);  
142 - }  
143 -  
144 - // 持久化到数据库  
145 - dayOfSchedule.save(schedule);  
146 -  
147 - map.put("status", ResponseCode.SUCCESS);  
148 - map.put("ts", ts);  
149 - } catch (Exception e) {  
150 - logger.error("", e);  
151 - map.put("status", ResponseCode.ERROR);  
152 - }  
153 - return map;  
154 - }  
155 -  
156 - @Override  
157 - public Map<String, Object> destroy(String idsStr, /*int spaceAdjust, */String remarks, String reason/*, int spaceNum*/) {  
158 -  
159 - Map<String, Object> map = new HashMap<>();  
160 - List<ScheduleRealInfo> rsList = new ArrayList<>();  
161 - map.put("ts", rsList);  
162 - try {  
163 - List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr));  
164 -  
165 - ScheduleRealInfo schedule = null;  
166 - for (String id : idList) {  
167 - schedule = dayOfSchedule.get(Long.parseLong(id));  
168 - if(schedule.isDestroy()){  
169 - map.put("status", ResponseCode.ERROR);  
170 - map.put("msg", "不必要的重复烂班!");  
171 - return map;  
172 - }  
173 -  
174 - schedule.setAdjustExps(reason);  
175 - schedule.destroy();  
176 - schedule.addRemarks(remarks);  
177 -  
178 - dayOfSchedule.save(schedule);  
179 - rsList.add(schedule);  
180 - }  
181 -  
182 - map.put("status", ResponseCode.SUCCESS);  
183 - } catch (Exception e) {  
184 - logger.error("", e);  
185 - map.put("status", ResponseCode.ERROR);  
186 - }  
187 - return map;  
188 - }  
189 -  
190 - // 线路id获取驾驶员  
191 - @Override  
192 - public List<Map<String, String>> findDriverByLine(String lineCode) {  
193 - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);  
194 -  
195 - List<Map<String, String>> rsList = new ArrayList<>();  
196 - Map<String, String> map = null;  
197 - Personnel driver = null;  
198 - String code = null;  
199 -  
200 - for (EmployeeConfigInfo employee : list) {  
201 - driver = employee.getJsy();  
202 - if (driver != null) {  
203 - map = new HashMap<>();  
204 - code = driver.getJobCode();  
205 - map.put("id", code + "/" + driver.getPersonnelName());  
206 - map.put("text", code + "/" + driver.getPersonnelName());  
207 - rsList.add(map);  
208 - }  
209 - }  
210 - return rsList;  
211 - }  
212 -  
213 - // 线路id获取售票员  
214 - @Override  
215 - public List<Map<String, String>> findConductorByLine(String lineCode) {  
216 - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);  
217 -  
218 - List<Map<String, String>> rsList = new ArrayList<>();  
219 - Map<String, String> map = null;  
220 - Personnel conductor = null;  
221 - String code = null;  
222 -  
223 - for (EmployeeConfigInfo employee : list) {  
224 - conductor = employee.getSpy();  
225 - if (conductor != null) {  
226 - code = conductor.getJobCode();  
227 - map = new HashMap<>();  
228 - map.put("id", code + "/" + conductor.getPersonnelName());  
229 - map.put("text", code + "/" + conductor.getPersonnelName());  
230 - rsList.add(map);  
231 - }  
232 - }  
233 - return rsList;  
234 - }  
235 -  
236 - @Override  
237 - public List<Map<String, String>> findCarByLine(String lineCode) {  
238 -  
239 - List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode);  
240 -  
241 - List<Map<String, String>> rsList = new ArrayList<>();  
242 - Map<String, String> map = null;  
243 - Cars car = null;  
244 - String code = null;  
245 -  
246 - for (CarConfigInfo cci : list) {  
247 - car = cci.getCl();  
248 - if (car != null) {  
249 - code = car.getInsideCode();  
250 - map = new HashMap<>();  
251 - map.put("id", code);  
252 - map.put("text", code);  
253 - rsList.add(map);  
254 - }  
255 - }  
256 - return rsList;  
257 - }  
258 -  
259 -  
260 - /**  
261 - * 临加班次  
262 - */  
263 - @Override  
264 - public Map<String, Object> save(ScheduleRealInfo t) {  
265 - Map<String, Object> rs = new HashMap<>();  
266 - try{  
267 - SysUser user = SecurityUtils.getCurrentUser();  
268 - String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm());  
269 -  
270 - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd")  
271 - ,sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");  
272 -  
273 - if(StringUtils.isEmpty(t.getjGh())){  
274 - rs.put("status", ResponseCode.ERROR);  
275 - rs.put("msg", "驾驶员工号不能为空!");  
276 - return rs;  
277 - }  
278 - //截取工号  
279 - if(t.getjGh().indexOf("-") != -1){  
280 - t.setjGh(t.getjGh().split("-")[1]);  
281 - }  
282 -  
283 - t.setScheduleDateStr(schDate);  
284 - t.setScheduleDate(sdfyyyyMMdd.parse(schDate));  
285 - t.setRealExecDate(schDate);  
286 - t.setCreateBy(user);  
287 - t.setSflj(true);  
288 - t.setLate(false);  
289 - t.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + t.getZdsj()).getTime());  
290 -  
291 -  
292 - //班次历时  
293 - t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60);  
294 -  
295 - //起终点名称  
296 - t.setQdzName(BasicData.stationCode2NameMap.get(t.getQdzCode()));  
297 - t.setZdzName(BasicData.stationCode2NameMap.get(t.getZdzCode()));  
298 -  
299 - //计算班次实际时间  
300 - schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t);  
301 - if(t.getZdsjT() < t.getFcsjT()){  
302 - rs.put("status", ResponseCode.ERROR);  
303 - rs.put("msg", "起终点时间异常!");  
304 - return rs;  
305 - }  
306 -  
307 - //实时入库  
308 - super.save(t);  
309 -  
310 - // 加入缓存  
311 - dayOfSchedule.put(t);  
312 -  
313 - //更新起点应到时间  
314 - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(t.getClZbh());  
315 -  
316 -  
317 - rs.put("ts", ts);  
318 - rs.put("t", t);  
319 - }catch(Exception e){  
320 - logger.error("", e);  
321 - rs.put("status", ResponseCode.ERROR);  
322 - }  
323 - return rs;  
324 - }  
325 -  
326 - @Override  
327 - public Map<String, Object> delete(Long id) {  
328 - Map<String, Object> rs = new HashMap<>();  
329 - rs.put("status", ResponseCode.ERROR);  
330 -  
331 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
332 - if(sch == null){  
333 - rs.put("msg", "无效的id号");  
334 - return rs;  
335 - }  
336 -  
337 - if(!sch.isSflj()){  
338 - rs.put("msg", "你只能删除临加班次");  
339 - return rs;  
340 - }  
341 -  
342 - dayOfSchedule.delete(sch);  
343 - //ScheduleRealInfo sch = dayOfSchedule.delete(id);  
344 - //数据库删除  
345 - rs = super.delete(id);  
346 - //更新起点应到时间  
347 - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch.getClZbh());  
348 - rs.put("ts", ts);  
349 - rs.put("delete", sch);  
350 -  
351 - return rs;  
352 - }  
353 -  
354 - @Override  
355 - public List<Map<String, String>> sreachVehic(String nbbm) {  
356 - // 转大写  
357 - nbbm = nbbm.toUpperCase();  
358 -  
359 - List<Map<String, String>> list = new ArrayList<>();  
360 - Map<String, String> map;  
361 - Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();  
362 -  
363 - Line line;  
364 - for (String k : allSet) {  
365 - if (k.indexOf(nbbm) != -1) {  
366 - // 所属线路  
367 - map = new HashMap<>();  
368 - line = BasicData.nbbm2LineMap.get(k);  
369 - map.put("id", k);  
370 - map.put("text", k);  
371 - if (null != line) {  
372 - map.put("lineName", line.getName());  
373 - map.put("lineCode", line.getLineCode());  
374 - }  
375 -  
376 - list.add(map);  
377 - }  
378 -  
379 - if (list.size() > 20)  
380 - break;  
381 - }  
382 - return list;  
383 - }  
384 -  
385 -/* @Override  
386 - public Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) {  
387 - // 班次  
388 - ScheduleRealInfo schedule = dayOfSchedule.get(id);  
389 - int upDown = Integer.parseInt(schedule.getXlDir());  
390 -  
391 - String rq = sdfMonth.format(new Date());  
392 - // 换车  
393 - if (!StringUtils.isBlank(nbbm)) {  
394 - adjustCar(schedule, nbbm);  
395 - }  
396 -  
397 - List<String> tempArray;  
398 - // 换驾驶员  
399 - if (!StringUtils.isBlank(jsy)) {  
400 - tempArray = Splitter.on("/").splitToList(jsy);  
401 - adjustDriver(schedule, tempArray.get(0), tempArray.get(1));  
402 - }  
403 -  
404 - // 换售票员  
405 - if (!StringUtils.isBlank(spy)) {  
406 - tempArray = Splitter.on("/").splitToList(spy);  
407 - adjustConductor(schedule, tempArray.get(0), tempArray.get(1));  
408 - }  
409 -  
410 - if(borrowLine != null && borrowTimeStr != null){  
411 - try {  
412 - //跨线路借车  
413 - Long t = sdfMinute.parse(rq + " " + borrowTimeStr).getTime();  
414 - //borrowCenter.put(nbbm, borrowLine, 0, t, upDown);  
415 - } catch (ParseException e) {  
416 - e.printStackTrace();  
417 - }  
418 - }  
419 -  
420 - if(revertLine != null && revertTimeStr != null){  
421 - //定时还车  
422 - try {  
423 - Long t = sdfMinute.parse(rq + " " + revertTimeStr).getTime();  
424 - //还车的时候不用切走向  
425 - //borrowCenter.put(nbbm, revertLine, 1, t, -1);  
426 - } catch (ParseException e) {  
427 - e.printStackTrace();  
428 - }  
429 - }  
430 -  
431 - scheduleRealInfoRepository.save(schedule);  
432 - //ScheduleBuffer.persistentList.add(schedule);  
433 -  
434 - Map<String, Object> map = new HashMap<>();  
435 - map.put("status", 200);  
436 - map.put("t", schedule);  
437 - return map;  
438 - }*/  
439 -  
440 - @Override  
441 - public void adjustCar(ScheduleRealInfo schedule, String car) {  
442 - schedule.setClZbh(car);  
443 - } 70 + @Autowired
  71 + CarConfigInfoRepository carConfigInfoRepository;
444 72
445 - @Override  
446 - public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) {  
447 - if(driver.indexOf("-") != -1)  
448 - driver = driver.split("-")[1];  
449 - schedule.setjGh(driver);  
450 - schedule.setjName(driverName);  
451 - } 73 + @Autowired
  74 + SectionRouteService sectionRouteService;
452 75
453 - @Override  
454 - public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) {  
455 - if(conductor.indexOf("-") != -1)  
456 - conductor = conductor.split("-")[1];  
457 - schedule.setsGh(conductor);  
458 - schedule.setsName(conductorName);  
459 - } 76 + /*@Autowired
  77 + BorrowCenter borrowCenter;*/
460 78
461 - @Override  
462 - public List<ScheduleRealInfo> queryUserInfo(String line, String date,String state) {  
463 - if(state.equals("2")){  
464 - return scheduleRealInfoRepository.queryUserInfo2(line, date);  
465 - }else{  
466 - return scheduleRealInfoRepository.queryUserInfo3(line, date);  
467 - }  
468 -  
469 - }  
470 - /**  
471 - *  
472 - */  
473 - @Override  
474 - public List<ScheduleRealInfo> exportWaybill(String jName, String clZbh, String lpName,String date) { 79 + @Autowired
  80 + LineRepository lineRepository;
  81 +
  82 + @Autowired
  83 + GuideboardInfoRepository guideboardInfoRepository;
  84 +
  85 + @Autowired
  86 + ChildTaskPlanRepository cTaskPlanRepository;
  87 +
  88 + @Autowired
  89 + SendUtils sendUtils;
  90 +
  91 + @Autowired
  92 + DayOfSchedule dayOfSchedule;
  93 +
  94 + @Autowired
  95 + SchAttrCalculator schAttrCalculator;
  96 +
  97 + @Autowired
  98 + LineConfigData lineConfigData;
  99 +
  100 + @Autowired
  101 + DutyEmployeeService dutyEmployeeService;
  102 +
  103 + Logger logger = LoggerFactory.getLogger(this.getClass());
  104 +
  105 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  106 + sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"), sdfShort = new SimpleDateFormat("HH:mm"),
  107 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  108 +
  109 + @Override
  110 + public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) {
  111 + List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines));
  112 +
  113 + Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create();
  114 +
  115 + for (String lineCode : lineList) {
  116 + mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode));
  117 + }
  118 + return mMap.asMap();
  119 + }
  120 +
  121 + private final static long DAY_TIME = 1000 * 60 * 60 * 24L;
  122 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  123 +
  124 + @Override
  125 + public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType) {
  126 + Map<String, Object> map = new HashMap<>();
  127 + try {
  128 +
  129 + ScheduleRealInfo schedule = dayOfSchedule.get(id);
  130 +
  131 +
  132 + LineConfig config = lineConfigData.get(schedule.getXlBm());
  133 + //小于线路开始运营时间,则默认跨过24点
  134 + if (dfsj.compareTo(config.getStartOpt()) < 0) {
  135 + schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME));
  136 + } else {
  137 + schedule.setRealExecDate(schedule.getScheduleDateStr());
  138 + }
  139 +
  140 + schedule.setDfsjAll(dfsj);
  141 + schedule.addRemarks(remarks);
  142 +
  143 + List<ScheduleRealInfo> ts = new ArrayList<>();
  144 + ts.add(schedule);
  145 + //调整终点时间和下一个班次的应到时间
  146 + schedule.calcEndTime();
  147 + ScheduleRealInfo nextSch = dayOfSchedule.next(schedule);
  148 + if (null != nextSch) {
  149 + nextSch.setQdzArrDateJH(schedule.getZdsj());
  150 + ts.add(nextSch);
  151 + }
  152 +
  153 + //调整班次类型
  154 + if(StringUtils.isNotEmpty(bcType)){
  155 + schedule.setBcType(bcType);
  156 + }
  157 +
  158 + // 持久化到数据库
  159 + dayOfSchedule.save(schedule);
  160 +
  161 + map.put("status", ResponseCode.SUCCESS);
  162 + map.put("ts", ts);
  163 + } catch (Exception e) {
  164 + logger.error("", e);
  165 + map.put("status", ResponseCode.ERROR);
  166 + }
  167 + return map;
  168 + }
  169 +
  170 + @Override
  171 + public Map<String, Object> destroy(String idsStr, /*int spaceAdjust, */String remarks, String reason/*, int spaceNum*/) {
  172 +
  173 + Map<String, Object> map = new HashMap<>();
  174 + List<ScheduleRealInfo> rsList = new ArrayList<>();
  175 + map.put("ts", rsList);
  176 + try {
  177 + List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr));
  178 +
  179 + ScheduleRealInfo schedule = null;
  180 + for (String id : idList) {
  181 + schedule = dayOfSchedule.get(Long.parseLong(id));
  182 + if (schedule.isDestroy()) {
  183 + map.put("status", ResponseCode.ERROR);
  184 + map.put("msg", "不必要的重复烂班!");
  185 + return map;
  186 + }
  187 +
  188 + schedule.setAdjustExps(reason);
  189 + schedule.destroy();
  190 + schedule.addRemarks(remarks);
  191 +
  192 + dayOfSchedule.save(schedule);
  193 + rsList.add(schedule);
  194 + }
  195 +
  196 + map.put("status", ResponseCode.SUCCESS);
  197 + } catch (Exception e) {
  198 + logger.error("", e);
  199 + map.put("status", ResponseCode.ERROR);
  200 + }
  201 + return map;
  202 + }
  203 +
  204 + // 线路id获取驾驶员
  205 + @Override
  206 + public List<Map<String, String>> findDriverByLine(String lineCode) {
  207 + List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
  208 +
  209 + List<Map<String, String>> rsList = new ArrayList<>();
  210 + Map<String, String> map = null;
  211 + Personnel driver = null;
  212 + String code = null;
  213 +
  214 + for (EmployeeConfigInfo employee : list) {
  215 + driver = employee.getJsy();
  216 + if (driver != null) {
  217 + map = new HashMap<>();
  218 + code = driver.getJobCode();
  219 + map.put("id", code + "/" + driver.getPersonnelName());
  220 + map.put("text", code + "/" + driver.getPersonnelName());
  221 + rsList.add(map);
  222 + }
  223 + }
  224 + return rsList;
  225 + }
  226 +
  227 + // 线路id获取售票员
  228 + @Override
  229 + public List<Map<String, String>> findConductorByLine(String lineCode) {
  230 + List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
  231 +
  232 + List<Map<String, String>> rsList = new ArrayList<>();
  233 + Map<String, String> map = null;
  234 + Personnel conductor = null;
  235 + String code = null;
  236 +
  237 + for (EmployeeConfigInfo employee : list) {
  238 + conductor = employee.getSpy();
  239 + if (conductor != null) {
  240 + code = conductor.getJobCode();
  241 + map = new HashMap<>();
  242 + map.put("id", code + "/" + conductor.getPersonnelName());
  243 + map.put("text", code + "/" + conductor.getPersonnelName());
  244 + rsList.add(map);
  245 + }
  246 + }
  247 + return rsList;
  248 + }
  249 +
  250 + @Override
  251 + public List<Map<String, String>> findCarByLine(String lineCode) {
  252 +
  253 + List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode);
  254 +
  255 + List<Map<String, String>> rsList = new ArrayList<>();
  256 + Map<String, String> map = null;
  257 + Cars car = null;
  258 + String code = null;
  259 +
  260 + for (CarConfigInfo cci : list) {
  261 + car = cci.getCl();
  262 + if (car != null) {
  263 + code = car.getInsideCode();
  264 + map = new HashMap<>();
  265 + map.put("id", code);
  266 + map.put("text", code);
  267 + rsList.add(map);
  268 + }
  269 + }
  270 + return rsList;
  271 + }
  272 +
  273 +
  274 + /**
  275 + * 临加班次
  276 + */
  277 + @Override
  278 + public Map<String, Object> save(ScheduleRealInfo t) {
  279 + Map<String, Object> rs = new HashMap<>();
  280 + try {
  281 + if (BasicData.deviceId2NbbmMap.inverse().get(t.getClZbh()) == null) {
  282 + rs.put("msg", "车辆 " + t.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");
  283 + rs.put("status", ResponseCode.ERROR);
  284 + return rs;
  285 + }
  286 +
  287 + SysUser user = SecurityUtils.getCurrentUser();
  288 + String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm());
  289 +
  290 + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");
  291 +
  292 + if (StringUtils.isEmpty(t.getjGh())) {
  293 + rs.put("status", ResponseCode.ERROR);
  294 + rs.put("msg", "驾驶员工号不能为空!");
  295 + return rs;
  296 + }
  297 + //截取工号
  298 + if (t.getjGh().indexOf("-") != -1) {
  299 + t.setjGh(t.getjGh().split("-")[1]);
  300 + }
  301 +
  302 + t.setScheduleDateStr(schDate);
  303 + t.setScheduleDate(sdfyyyyMMdd.parse(schDate));
  304 + t.setRealExecDate(schDate);
  305 + t.setCreateBy(user);
  306 + t.setSflj(true);
  307 + t.setLate(false);
  308 + t.setDfsj(t.getFcsj());
  309 + t.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + t.getZdsj()).getTime());
  310 +
  311 +
  312 + //班次历时
  313 + t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60);
  314 +
  315 + //起终点名称
  316 + String prefix = t.getXlBm() + "_" + t.getXlDir() + "_";
  317 + t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix));
  318 + t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix));
  319 +
  320 + //计算班次实际时间
  321 + schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t);
  322 + if (t.getZdsjT() < t.getFcsjT()) {
  323 + rs.put("status", ResponseCode.ERROR);
  324 + rs.put("msg", "起终点时间异常!");
  325 + return rs;
  326 + }
  327 +
  328 + //实时入库
  329 + super.save(t);
  330 +
  331 + // 加入缓存
  332 + dayOfSchedule.put(t);
  333 +
  334 + //更新起点应到时间
  335 + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(t.getClZbh());
  336 +
  337 +
  338 + rs.put("ts", ts);
  339 + rs.put("t", t);
  340 + } catch (Exception e) {
  341 + logger.error("", e);
  342 + rs.put("status", ResponseCode.ERROR);
  343 + }
  344 + return rs;
  345 + }
  346 +
  347 + @Override
  348 + public Map<String, Object> delete(Long id) {
  349 + Map<String, Object> rs = new HashMap<>();
  350 + rs.put("status", ResponseCode.ERROR);
  351 +
  352 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  353 + if (sch == null) {
  354 + rs.put("msg", "无效的id号");
  355 + return rs;
  356 + }
  357 +
  358 + if (!sch.isSflj()) {
  359 + rs.put("msg", "你只能删除临加班次");
  360 + return rs;
  361 + }
  362 +
  363 + dayOfSchedule.delete(sch);
  364 + //ScheduleRealInfo sch = dayOfSchedule.delete(id);
  365 + //数据库删除
  366 + rs = super.delete(id);
  367 + //更新起点应到时间
  368 + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch.getClZbh());
  369 + rs.put("ts", ts);
  370 + rs.put("delete", sch);
  371 +
  372 + return rs;
  373 + }
  374 +
  375 + @Override
  376 + public List<Map<String, String>> sreachVehic(String nbbm) {
  377 + // 转大写
  378 + nbbm = nbbm.toUpperCase();
  379 +
  380 + List<Map<String, String>> list = new ArrayList<>();
  381 + Map<String, String> map;
  382 + Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();
  383 +
  384 + Line line;
  385 + for (String k : allSet) {
  386 + if (k.indexOf(nbbm) != -1) {
  387 + // 所属线路
  388 + map = new HashMap<>();
  389 + line = BasicData.nbbm2LineMap.get(k);
  390 + map.put("id", k);
  391 + map.put("text", k);
  392 + if (null != line) {
  393 + map.put("lineName", line.getName());
  394 + map.put("lineCode", line.getLineCode());
  395 + }
  396 +
  397 + list.add(map);
  398 + }
  399 +
  400 + if (list.size() > 20)
  401 + break;
  402 + }
  403 + return list;
  404 + }
  405 +
  406 + @Override
  407 + public void adjustCar(ScheduleRealInfo schedule, String car) {
  408 + schedule.setClZbh(car);
  409 + }
  410 +
  411 + @Override
  412 + public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) {
  413 + if (driver.indexOf("-") != -1)
  414 + driver = driver.split("-")[1];
  415 + schedule.setjGh(driver);
  416 + schedule.setjName(driverName);
  417 + }
  418 +
  419 + @Override
  420 + public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) {
  421 + if (conductor.indexOf("-") != -1)
  422 + conductor = conductor.split("-")[1];
  423 + schedule.setsGh(conductor);
  424 + schedule.setsName(conductorName);
  425 + }
  426 +
  427 + @Override
  428 + public List<ScheduleRealInfo> queryUserInfo(String line, String date, String state) {
  429 + if (state.equals("2")) {
  430 + return scheduleRealInfoRepository.queryUserInfo2(line, date);
  431 + } else {
  432 + return scheduleRealInfoRepository.queryUserInfo3(line, date);
  433 + }
  434 +
  435 + }
  436 +
  437 + /**
  438 + *
  439 + */
  440 + @Override
  441 + public List<ScheduleRealInfo> exportWaybill(String jName, String clZbh, String lpName,String date,String line) {
475 ReportUtils ee = new ReportUtils(); 442 ReportUtils ee = new ReportUtils();
476 ReportRelatedUtils rru = new ReportRelatedUtils(); 443 ReportRelatedUtils rru = new ReportRelatedUtils();
477 List<Iterator<?>> list = new ArrayList<Iterator<?>>(); 444 List<Iterator<?>> list = new ArrayList<Iterator<?>>();
478 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName,date); 445 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName,date,line);
479 List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>(); 446 List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
480 447
481 DecimalFormat format = new DecimalFormat("0.00"); 448 DecimalFormat format = new DecimalFormat("0.00");
@@ -496,7 +463,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -496,7 +463,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
496 //计划班次,烂班班次,增加班次 463 //计划班次,烂班班次,增加班次
497 tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc(); 464 tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
498 if(scheduleRealInfo.isSflj()){ 465 if(scheduleRealInfo.isSflj()){
499 - addMileage += tempJhlc;  
500 ljbc++; 466 ljbc++;
501 }else{ 467 }else{
502 jhlc += tempJhlc; 468 jhlc += tempJhlc;
@@ -510,7 +476,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -510,7 +476,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
510 //计算营运里程,空驶里程 476 //计算营运里程,空驶里程
511 if(childTaskPlans.isEmpty()){ 477 if(childTaskPlans.isEmpty()){
512 if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") 478 if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
513 - || scheduleRealInfo.getBcType().equals("venting")){ 479 + ){
514 ksgl += tempJhlc; 480 ksgl += tempJhlc;
515 }else{ 481 }else{
516 yygl += tempJhlc; 482 yygl += tempJhlc;
@@ -520,8 +486,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -520,8 +486,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
520 while(it.hasNext()){ 486 while(it.hasNext()){
521 ChildTaskPlan childTaskPlan = it.next(); 487 ChildTaskPlan childTaskPlan = it.next();
522 if(childTaskPlan.getMileageType().equals("empty")){ 488 if(childTaskPlan.getMileageType().equals("empty")){
  489 + if(scheduleRealInfo.isSflj()){
  490 + addMileage += tempJhlc;
  491 + }
523 ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); 492 ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
524 }else{ 493 }else{
  494 + if(scheduleRealInfo.isSflj()){
  495 + addMileage += tempJhlc;
  496 + }
525 yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); 497 yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
526 } 498 }
527 } 499 }
@@ -570,83 +542,141 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -570,83 +542,141 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
570 542
571 list.add(listMap.iterator()); 543 list.add(listMap.iterator());
572 ee.excelReplace(list, new Object[] { scheduleRealInfos.get(0),map }, path+"mould\\waybill_minhang.xls", 544 ee.excelReplace(list, new Object[] { scheduleRealInfos.get(0),map }, path+"mould\\waybill_minhang.xls",
573 - path+"export\\" + jName + ".xls"); 545 + path+"export\\" + date+"-"+jName+"-"+clZbh+"-"+lpName+"-行车路单.xls");
574 return scheduleRealInfos; 546 return scheduleRealInfos;
575 } 547 }
576 548
577 - @Override  
578 - public List<Map<String, Object>> dailyInfo(String line, String date,String type) {  
579 - DecimalFormat format = new DecimalFormat("0.00");  
580 - ReportUtils ee = new ReportUtils();  
581 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
582 - List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date);  
583 -  
584 - double totalZGL = 0,totalKSGL=0,totalYH=0;  
585 - int totalBCS=0;  
586 - for(int i = 0;i < list.size();i++){  
587 - String zgl = format.format(Double.parseDouble(list.get(i).get("zgl")==null?"0":list.get(i).get("zgl").toString()));  
588 - String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl")==null?"0":list.get(i).get("ksgl").toString()));  
589 - if(type.equals("export")){  
590 - totalZGL += Double.parseDouble(zgl);  
591 - totalKSGL += Double.parseDouble(ksgl);  
592 - totalBCS += Integer.parseInt(list.get(i).get("bcs").toString());  
593 - }  
594 - list.get(i).put("zgl", zgl);  
595 - list.get(i).put("ksgl", ksgl);  
596 - }  
597 - if(type.equals("export")){  
598 - Map<String,Object> map = new HashMap<String, Object>();  
599 - map.put("line", line);  
600 - map.put("date", date);  
601 - map.put("totalZGL", totalZGL);  
602 - map.put("totalKSGL", totalKSGL);  
603 - map.put("totalYH", totalYH);  
604 - map.put("totalBCS", totalBCS);  
605 -  
606 - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";  
607 -  
608 - listI.add(list.iterator());  
609 - try {  
610 - ee.excelReplace(listI, new Object[] { map }, path+"mould\\daily.xls",  
611 - path+"export\\班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");  
612 - } catch (ParseException e) {  
613 - e.printStackTrace();  
614 - }  
615 - }  
616 - return list;  
617 - }  
618 -  
619 - @Override  
620 - public List<Object[]> historyMessage(String line, String date, String code) {  
621 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
622 - long d= 0;  
623 - long t=0;  
624 - if(date.length()>0){  
625 - try {  
626 - d=sdf.parse(date+" 00:00:00").getTime();  
627 - t=sdf.parse(date+" 23:59:59").getTime();  
628 - } catch (ParseException e) {  
629 - // TODO Auto-generated catch block  
630 - e.printStackTrace();  
631 - }  
632 -  
633 - }  
634 -  
635 - List<Object[]> list = scheduleRealInfoRepository.historyMessage(line,d,t, code);  
636 - for(Object[] obj:list){  
637 - if(obj != null){  
638 - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));  
639 - obj[4] = BasicData.lineCode2NameMap.get(line);  
640 - }  
641 - }  
642 - return list;  
643 - }  
644 -  
645 - @Override  
646 - public Map<Integer, Integer> trustStatus(String lineStr) {  
647 - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr));  
648 -  
649 - Map<Integer, Integer> map = new HashMap<>(); 549 + @Override
  550 + public List<Map<String, Object>> dailyInfo(String line, String date, String type) {
  551 + DecimalFormat format = new DecimalFormat("0.00");
  552 + ReportUtils ee = new ReportUtils();
  553 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  554 + List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date);
  555 +
  556 + double totalZGL = 0, totalKSGL = 0, totalYH = 0;
  557 + int totalBCS = 0;
  558 + for (int i = 0; i < list.size(); i++) {
  559 + String zgl = format.format(Double.parseDouble(list.get(i).get("zgl") == null ? "0" : list.get(i).get("zgl").toString()));
  560 + String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl") == null ? "0" : list.get(i).get("ksgl").toString()));
  561 + if (type.equals("export")) {
  562 + totalZGL += Double.parseDouble(zgl);
  563 + totalKSGL += Double.parseDouble(ksgl);
  564 + totalBCS += Integer.parseInt(list.get(i).get("bcs").toString());
  565 + }
  566 + list.get(i).put("zgl", zgl);
  567 + list.get(i).put("ksgl", ksgl);
  568 + }
  569 + if (type.equals("export")) {
  570 + Map<String, Object> map = new HashMap<String, Object>();
  571 + map.put("line", line);
  572 + map.put("date", date);
  573 + map.put("totalZGL", totalZGL);
  574 + map.put("totalKSGL", totalKSGL);
  575 + map.put("totalYH", totalYH);
  576 + map.put("totalBCS", totalBCS);
  577 +
  578 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  579 +
  580 + listI.add(list.iterator());
  581 + try {
  582 + ee.excelReplace(listI, new Object[]{map}, path + "mould\\daily.xls",
  583 + path + "export\\班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  584 + } catch (ParseException e) {
  585 + e.printStackTrace();
  586 + }
  587 + }
  588 + return list;
  589 + }
  590 +
  591 + @Override
  592 + public List<Object[]> historyMessage(String line, String date, String code, String type) {
  593 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  594 + long d = 0;
  595 + long t = 0;
  596 + if (date.length() > 0) {
  597 + try {
  598 + d = sdf.parse(date + " 00:00:00").getTime();
  599 + t = sdf.parse(date + " 23:59:59").getTime();
  600 + } catch (ParseException e) {
  601 + // TODO Auto-generated catch block
  602 + e.printStackTrace();
  603 + }
  604 +
  605 + }
  606 +
  607 + List<Object[]> list = scheduleRealInfoRepository.historyMessage(line, d, t, code);
  608 + for (Object[] obj : list) {
  609 + if (obj != null) {
  610 + obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));
  611 + obj[4] = BasicData.lineCode2NameMap.get(line);
  612 + }
  613 + }
  614 +
  615 + if (type != null && type.length() != 0 && type.equals("export")) {
  616 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  617 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  618 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  619 + Map<String, Object> m = new HashMap<String, Object>();
  620 + ReportUtils ee = new ReportUtils();
  621 + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
  622 + for (int i = 0; i < list.size(); i++) {
  623 + Map<String, Object> map = new HashMap<String, Object>();
  624 + Object[] obj = list.get(i);
  625 + map.put("num", i + 1);
  626 + map.put("line", obj[4]);
  627 + map.put("clZbh", obj[0]);
  628 + map.put("sender", obj[1]);
  629 + map.put("date", obj[3]);
  630 + map.put("text", obj[2]);
  631 + newList.add(map);
  632 + }
  633 + try {
  634 + listI.add(newList.iterator());
  635 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  636 + ee.excelReplace(listI, new Object[]{m}, path + "mould\\historyMessage.xls",
  637 + path + "export\\调度历史消息" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  638 + } catch (Exception e) {
  639 + // TODO: handle exception
  640 + e.printStackTrace();
  641 + }
  642 + }
  643 +
  644 + if (type != null && type.length() != 0 && type.equals("export_msg")) {
  645 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  646 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  647 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  648 + Map<String, Object> m = new HashMap<String, Object>();
  649 + ReportUtils ee = new ReportUtils();
  650 + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
  651 + for (int i = 0; i < list.size(); i++) {
  652 + Map<String, Object> map = new HashMap<String, Object>();
  653 + Object[] obj = list.get(i);
  654 + map.put("num", i + 1);
  655 + map.put("line", obj[4]);
  656 + map.put("clZbh", obj[0]);
  657 + map.put("sender", obj[1]);
  658 + map.put("date", obj[3]);
  659 + map.put("text", obj[2]);
  660 + newList.add(map);
  661 + }
  662 + try {
  663 + listI.add(newList.iterator());
  664 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  665 + ee.excelReplace(listI, new Object[]{m}, path + "mould\\message.xls",
  666 + path + "export\\调度消息分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  667 + } catch (Exception e) {
  668 + // TODO: handle exception
  669 + e.printStackTrace();
  670 + }
  671 + }
  672 + return list;
  673 + }
  674 +
  675 + @Override
  676 + public Map<Integer, Integer> trustStatus(String lineStr) {
  677 + List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr));
  678 +
  679 + Map<Integer, Integer> map = new HashMap<>();
650 /*Integer code; 680 /*Integer code;
651 for (String lineCode : lineList) { 681 for (String lineCode : lineList) {
652 code = Integer.parseInt(lineCode); 682 code = Integer.parseInt(lineCode);
@@ -655,485 +685,1584 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -655,485 +685,1584 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
655 685
656 map.put(code, ScheduleBuffer.trustMap.get(code)); 686 map.put(code, ScheduleBuffer.trustMap.get(code));
657 }*/ 687 }*/
658 - return map;  
659 - }  
660 -  
661 - @Override  
662 - public Map<String, Object> realOutAdjust(Long id, String fcsjActual, String remarks) {  
663 - Map<String, Object> rs = new HashMap<>();  
664 - List<ScheduleRealInfo> ts = new ArrayList<>();  
665 - try {  
666 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
667 -  
668 - LineConfig config = lineConfigData.get(sch.getXlBm());  
669 - //小于线路开始运营时间,则默认跨过24点  
670 - if(fcsjActual.compareTo(config.getStartOpt()) < 0){  
671 - sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME)); 688 + return map;
  689 + }
  690 +
  691 + @Override
  692 + public Map<String, Object> realOutAdjust(Long id, String fcsjActual, String remarks) {
  693 + Map<String, Object> rs = new HashMap<>();
  694 + List<ScheduleRealInfo> ts = new ArrayList<>();
  695 + try {
  696 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  697 +
  698 + LineConfig config = lineConfigData.get(sch.getXlBm());
  699 + //小于线路开始运营时间,则默认跨过24点
  700 + if (fcsjActual.compareTo(config.getStartOpt()) < 0) {
  701 + sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME));
  702 + } else {
  703 + sch.setRealExecDate(sch.getScheduleDateStr());
  704 + }
  705 +
  706 + sch.setFcsjActualAll(fcsjActual);
  707 + sch.addRemarks(remarks);
  708 + sch.calcStatus();
  709 +
  710 + dayOfSchedule.save(sch);
  711 + //scheduleRealInfoRepository.save(sch);
  712 +
  713 + ts.add(sch);
  714 +
  715 + rs.put("status", ResponseCode.SUCCESS);
  716 + rs.put("ts", ts);
  717 +
  718 + //通知页面刷新
  719 + sendUtils.refreshSch(ts);
  720 + } catch (Exception e) {
  721 + logger.error("", e);
  722 + rs.put("status", ResponseCode.ERROR);
  723 + }
  724 +
  725 + return rs;
  726 + }
  727 +
  728 + @Override
  729 + public Map<String, Object> revokeDestroy(Long id) {
  730 + Map<String, Object> rs = new HashMap<>();
  731 + try {
  732 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  733 + if (sch.getStatus() != -1) {
  734 + rs.put("status", ResponseCode.ERROR);
  735 + rs.put("msg", "未烂班,无法撤销!");
  736 + } else {
  737 + sch.setStatus(0);
  738 + rs.put("status", ResponseCode.SUCCESS);
  739 + rs.put("t", sch);
  740 +
  741 + }
  742 + } catch (Exception e) {
  743 + logger.error("", e);
  744 + rs.put("status", ResponseCode.ERROR);
  745 + }
  746 + return rs;
  747 + }
  748 +
  749 + @Override
  750 + public Map<String, Object> revokeRealOutgo(Long id) {
  751 + Map<String, Object> rs = new HashMap<>();
  752 + List<ScheduleRealInfo> ts = new ArrayList<>();
  753 +
  754 + try {
  755 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  756 + if (sch.getFcsjActual() == null) {
  757 + rs.put("status", ResponseCode.ERROR);
  758 + rs.put("msg", "无实发时间,无法撤销!");
  759 + } else {
  760 + //将对应的到离站数据标记为不可信
  761 + List<ArrivalEntity> list = ArrivalData_GPS.findByNbbm(sch.getClZbh());
  762 + for (ArrivalEntity arr : list) {
  763 + if (arr.getInOut() == 1
  764 + && arr.getUpDown() == Integer.parseInt(sch.getXlDir())
  765 + && arr.getStopNo().equals(sch.getQdzCode())
  766 + && Math.abs(arr.getTs() - sch.getFcsjActualTime()) < 1000 * 60) {
  767 + arr.setEnable(false);
  768 + break;
  769 + }
  770 + }
  771 +
  772 + sch.clearFcsjActual();
  773 + rs.put("status", ResponseCode.SUCCESS);
  774 +
  775 + ts.add(sch);
  776 + rs.put("ts", ts);
  777 +
  778 + }
  779 + } catch (Exception e) {
  780 + logger.error("", e);
  781 + rs.put("status", ResponseCode.ERROR);
  782 + }
  783 + return rs;
  784 + }
  785 +
  786 + @Override
  787 + public Map<String, Object> spaceAdjust(Long[] ids, Integer space) {
  788 +
  789 + List<ScheduleRealInfo> list = new ArrayList<>(), updateList = new ArrayList<>();
  790 + Map<String, Object> rs = new HashMap<>();
  791 + try {
  792 + ScheduleRealInfo sch, next;
  793 + for (Long id : ids) {
  794 + sch = dayOfSchedule.get(id);
  795 + if (null != sch)
  796 + list.add(sch);
  797 + }
  798 +
  799 + int size = list.size();
  800 + if (size == 0) {
  801 + rs.put("status", ResponseCode.ERROR);
  802 + } else {
  803 + // 按发车时间排序
  804 + Collections.sort(list, new ScheduleComparator.FCSJ());
  805 +
  806 + // 以第一个实际发车/待发时间为起点,调整间隔
  807 + sch = list.get(0);
  808 + Long st = sch.getFcsjActualTime() == null ? sch.getDfsjT() : sch.getFcsjActualTime(), plus = space * 60 * 1000L;
  809 +
  810 + for (int i = 1; i < size; i++) {
  811 + st += plus;
  812 + sch = list.get(i);
  813 + sch.setDfsjAll(st);
  814 + //重新计算终点时间
  815 + sch.calcEndTime();
  816 +
  817 + dayOfSchedule.save(sch);
  818 +
  819 + updateList.add(sch);
  820 + next = dayOfSchedule.next(sch);
  821 + if (next.getQdzName().equals(sch.getZdzName())) {
  822 + next.setQdzArrDateJH(sch.getZdsj());
  823 + updateList.add(next);
  824 + }
  825 + }
  826 +
  827 +
  828 + rs.put("status", ResponseCode.SUCCESS);
  829 + rs.put("ts", updateList);
  830 + }
  831 +
  832 + } catch (Exception e) {
  833 + logger.error("", e);
  834 + rs.put("status", ResponseCode.ERROR);
  835 + }
  836 + return rs;
  837 + }
  838 +
  839 + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
  840 +
  841 + @Override
  842 + public Map<String, Object> schInfoFineTune(Map<String, String> map) {
  843 + Map<String, Object> rs = new HashMap<>();
  844 + List<ScheduleRealInfo> ts = new ArrayList<>();
  845 + try {
  846 + Long id = Long.parseLong(map.get("id"));
  847 + //班次类型
  848 + //String bcType = map.get("bcType");
  849 + //车辆自编号
  850 + //String clZbh = map.get("clZbh");
  851 + //计划发车时间
  852 + //String fcsj = map.get("fcsj");
  853 + //实际发车时间
  854 + String fcsjActual = map.get("fcsjActual");
  855 + //实际终点时间
  856 + String zdsjActual = map.get("zdsjActual");
  857 + //备注
  858 + String remarks = map.get("remarks");
  859 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  860 + if (null != sch) {
  861 + if (StringUtils.isNotBlank(fcsjActual)) {
  862 + LineConfig config = lineConfigData.get(sch.getXlBm());
  863 + long t = 0L;
  864 + //小于线路开始运营时间,则默认跨过24点
  865 + if (fcsjActual.compareTo(config.getStartOpt()) < 0)
  866 + t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual);
  867 + else
  868 + t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual);
  869 +
  870 + //调整实发
  871 + if (!fcsjActual.equals(sch.getFcsjActual()))
  872 + sch.setFcsjActualAll(t);
  873 + } else {
  874 + //撤销实发
  875 + if (sch.getFcsjActual() != null)
  876 + revokeRealOutgo(sch.getId());
  877 + }
  878 + //实达时间
  879 + if (StringUtils.isNotBlank(zdsjActual)) {
  880 + if (!zdsjActual.equals(sch.getZdsjActual())) {
  881 + //调整实达
  882 + sch.setZdsjActualAll(zdsjActual);
  883 + //下一班次起点到达时间
  884 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  885 + if (null != next) {
  886 + next.setQdzArrDateSJ(zdsjActual);
  887 + ts.add(next);
  888 + }
  889 +
  890 + //重新计算车辆执行班次
  891 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
  892 + }
  893 + } else {
  894 + //清除实达时间
  895 + sch.clearZdsjActual();
  896 + //清除下一班次起点到达时间
  897 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  898 + if (null != next) {
  899 + next.setQdzArrDateSJ(null);
  900 + ts.add(next);
  901 + }
  902 + }
  903 + sch.setRemarks(remarks);
  904 +
  905 + try {
  906 + //烂班
  907 + if(map.get("status") != null
  908 + && Integer.parseInt(map.get("status").toString()) == -1){
  909 + destroy(sch.getId() + "", "", map.get("adjustExps").toString());
  910 + }
  911 + } catch (NumberFormatException e) {
  912 + logger.error("", e);
  913 + }
  914 + }
  915 +
  916 + String bcType = map.get("bcType");
  917 + if(StringUtils.isNotEmpty(bcType)){
  918 + sch.setBcType(bcType);
  919 + }
  920 + //班次状态
  921 + sch.calcStatus();
  922 + dayOfSchedule.save(sch);
  923 + //页面需要更新的班次信息
  924 + ts.add(sch);
  925 +
  926 + rs.put("status", ResponseCode.SUCCESS);
  927 + rs.put("ts", ts);
  928 + } catch (Exception e) {
  929 + logger.error("", e);
  930 + rs.put("status", ResponseCode.ERROR);
  931 + }
  932 + return rs;
  933 + }
  934 +
  935 + @Override
  936 + public Map<String, Object> outgoAdjustAll(String params) {
  937 + Map<String, Object> rs = new HashMap<>();
  938 + try {
  939 + JSONArray jsonArray = JSONArray.parseArray(params);
  940 +
  941 + ScheduleRealInfo schedule = null;
  942 + JSONObject jsonObj;
  943 + String dfsj;
  944 + for (int i = 0; i < jsonArray.size(); i++) {
  945 + jsonObj = jsonArray.getJSONObject(i);
  946 + dfsj = jsonObj.getString("t");
  947 + schedule = dayOfSchedule.get(jsonObj.getLong("id"));
  948 + //设置待发时间
  949 + schedule.setDfsjAll(dfsj);
  950 +
  951 + dayOfSchedule.save(schedule);
  952 + }
  953 +
  954 + rs.put("status", ResponseCode.SUCCESS);
  955 + //将更新的最后一个班次返回
  956 + rs.put("t", schedule);
  957 + } catch (Exception e) {
  958 + logger.error("", e);
  959 + rs.put("status", ResponseCode.ERROR);
  960 + }
  961 + return rs;
  962 + }
  963 +
  964 + @Override
  965 + public Map<String, Object> findRouteByLine(String lineCode) {
  966 + Map<String, Object> map = new HashMap<>();
  967 + //上行
  968 + Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode);
  969 + map.put("line.id_eq", lineId);
  970 + map.put("directions_eq", 0);
  971 + List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map);
  972 +
  973 + //下行
  974 + map.put("directions_eq", 1);
  975 + List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map);
  976 +
  977 + Map<String, Object> rs = new HashMap<>();
  978 +
  979 + String upVectors = "", vec;
  980 + //拼接上行路段
  981 + for (Map<String, Object> temp : upList) {
  982 + vec = temp.get("sectionBsectionVector").toString();
  983 + upVectors += vec.subSequence(11, vec.length() - 2) + " ";
  984 + }
  985 +
  986 + //拼接下行路段
  987 + String downVectors = "";
  988 + for (Map<String, Object> temp : downList) {//LINESTRING(
  989 + vec = temp.get("sectionBsectionVector").toString();
  990 + downVectors += vec.subSequence(11, vec.length() - 2) + " ";
  991 + }
  992 +
  993 +
  994 + rs.put("up", upVectors);
  995 + //上行gcj
  996 + rs.put("up_gcj", BdToGcjString(upVectors));
  997 + rs.put("down", downVectors);
  998 + //下行gcj
  999 + rs.put("down_gcj", BdToGcjString(downVectors));
  1000 + rs.put("lineId", lineId);
  1001 +
  1002 + return rs;
  1003 + }
  1004 +
  1005 + /**
  1006 + * @param @param bdStr
  1007 + * @throws
  1008 + * @Title: BdToGcjString
  1009 + * @Description: TODO(将百度路由字符串 转 成GCJ 字符串)
  1010 + */
  1011 + public String BdToGcjString(String bdStr) {
  1012 + String[] array = bdStr.split(","), subArray;
  1013 + if (array.length == 0 || bdStr.length() < 2)
  1014 + return "";
  1015 +
  1016 + String gcjStr = "";
  1017 + TransGPS.Location location;
  1018 + for (String crd : array) {
  1019 + subArray = crd.split(" ");
  1020 + if (subArray.length != 2)
  1021 + continue;
  1022 + location = TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1])));
  1023 +
  1024 + gcjStr += location.getLng() + " " + location.getLat() + ",";
  1025 + }
  1026 +
  1027 + return gcjStr.substring(0, gcjStr.length() - 1);
  1028 + }
  1029 +
  1030 + public List<Map<String, String>> findLine(String line) {
  1031 + List<Line> listLine = lineRepository.findLine("%" + line + "%");
  1032 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  1033 + Map<String, String> map;
  1034 + for (Line temp : listLine) {
  1035 + if (temp != null) {
  1036 + String xlName = temp.getName();
  1037 + if (xlName.indexOf(line) != -1) {
  1038 + map = new HashMap<String, String>();
  1039 + map.put("id", temp.getLineCode());
  1040 + map.put("text", xlName);
  1041 + list.add(map);
  1042 + }
  1043 + }
  1044 + }
  1045 + return list;
  1046 + }
  1047 +
  1048 + public List<Map<String, String>> findLpName(String lpName) {
  1049 + List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%" + lpName + "%");
  1050 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  1051 + Map<String, String> map;
  1052 + for (GuideboardInfo temp : listLpName) {
  1053 + if (temp != null) {
  1054 + String lp = temp.getLpName();
  1055 + if (lp.indexOf(lpName) != -1) {
  1056 + map = new HashMap<String, String>();
  1057 + map.put("id", lp);
  1058 + map.put("text", lp);
  1059 + list.add(map);
  1060 + }
  1061 + }
  1062 + }
  1063 + return list;
  1064 + }
  1065 +
  1066 + @Override
  1067 + public Map<String, Object> findKMBC2(String jName, String clZbh, String date) {
  1068 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date);
  1069 +
  1070 + DecimalFormat format = new DecimalFormat("0.00");
  1071 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  1072 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  1073 + int jhbc = 0, cjbc = 0, ljbc = 0;
  1074 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;
  1075 + float addMileage = 0l, remMileage = 0l;
  1076 + String j_Name = "";
  1077 + Map<String, Object> map = new HashMap<String, Object>();
  1078 + for (ScheduleRealInfo scheduleRealInfo : list) {
  1079 + if (scheduleRealInfo != null) {
  1080 + j_Name = scheduleRealInfo.getjName();
  1081 + //计划里程(主任务过滤掉临加班次),
  1082 + //烂班里程(主任务烂班),
  1083 + //临加里程(主任务临加),
  1084 + //计划班次,烂班班次,增加班次
  1085 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1086 + if (scheduleRealInfo.isSflj()) {
  1087 + addMileage += tempJhlc;
  1088 + ljbc++;
  1089 + } else {
  1090 + jhlc += tempJhlc;
  1091 + jhbc++;
  1092 + if (scheduleRealInfo.getStatus() == -1) {
  1093 + remMileage += tempJhlc;
  1094 + cjbc++;
  1095 + }
  1096 + }
  1097 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1098 + //计算营运里程,空驶里程
  1099 + if (childTaskPlans.isEmpty()) {
  1100 + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  1101 + || scheduleRealInfo.getBcType().equals("venting")) {
  1102 + ksgl += tempJhlc;
  1103 + } else {
  1104 + yygl += tempJhlc;
  1105 + }
  1106 + } else {
  1107 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1108 + while (it.hasNext()) {
  1109 + ChildTaskPlan childTaskPlan = it.next();
  1110 + if (childTaskPlan.getMileageType().equals("empty")) {
  1111 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1112 + } else {
  1113 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1114 + }
  1115 + }
  1116 + }
  1117 + }
  1118 + }
  1119 + map.put("j_name", j_Name);
  1120 + map.put("jhlc", format.format(jhlc));
  1121 + map.put("remMileage", format.format(remMileage));
  1122 + map.put("addMileage", format.format(addMileage));
  1123 + map.put("yygl", format.format(yygl));
  1124 + map.put("ksgl", format.format(ksgl));
  1125 + map.put("realMileage", format.format(yygl + ksgl));
  1126 + map.put("jhbc", jhbc);
  1127 + map.put("cjbc", cjbc);
  1128 + map.put("ljbc", ljbc);
  1129 + map.put("sjbc", jhbc - cjbc + ljbc);
  1130 + return map;
  1131 + }
  1132 +
  1133 +
  1134 +
  1135 + @Override
  1136 + public Map<String, Object> findKMBC(String jName, String clZbh,
  1137 + String lpName, String date,String line) {
  1138 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date,line);
  1139 + DecimalFormat format = new DecimalFormat("0.00");
  1140 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  1141 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  1142 + int jhbc = 0, cjbc = 0, ljbc = 0;
  1143 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0;
  1144 + float addMileage = 0l, remMileage = 0l;
  1145 + Map<String, Object> map = new HashMap<String, Object>();
  1146 + for (ScheduleRealInfo scheduleRealInfo : list) {
  1147 + if (scheduleRealInfo != null) {
  1148 + //计划里程(主任务过滤掉临加班次),
  1149 + //烂班里程(主任务烂班),
  1150 + //临加里程(主任务临加),
  1151 + //计划班次,烂班班次,增加班次
  1152 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1153 + if (scheduleRealInfo.isSflj()) {
  1154 + addMileage += tempJhlc;
  1155 + ljbc++;
  1156 + } else {
  1157 + if (!(scheduleRealInfo.getBcType().equals("in")
  1158 + || scheduleRealInfo.getBcType().equals("out"))) {
  1159 + jhbc++;
  1160 + jhlc += tempJhlc;
  1161 + }
  1162 +
  1163 + if (scheduleRealInfo.getStatus() == -1) {
  1164 + remMileage += tempJhlc;
  1165 + cjbc++;
  1166 + }
  1167 + }
  1168 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1169 + //计算营运里程,空驶里程
  1170 + if (childTaskPlans.isEmpty()) {
  1171 + if (scheduleRealInfo.getBcType().equals("in") ||
  1172 + scheduleRealInfo.getBcType().equals("out")) {
  1173 + jcclc += tempJhlc;
  1174 + }
  1175 + //主任务 放空班次属于营运
  1176 +// else if(scheduleRealInfo.getBcType().equals("venting")){
  1177 +// ksgl += tempJhlc;
  1178 +// }
  1179 + else {
  1180 + if (scheduleRealInfo.getStatus() != -1) {
  1181 + yygl += tempJhlc;
  1182 + }
  1183 + }
  1184 + } else {
  1185 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1186 + while (it.hasNext()) {
  1187 + ChildTaskPlan childTaskPlan = it.next();
  1188 + if (childTaskPlan.getMileageType().equals("empty")) {
  1189 + if (childTaskPlan.isDestroy()) {
  1190 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1191 + } else {
  1192 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1193 + }
  1194 + } else {
  1195 + if (childTaskPlan.isDestroy()) {
  1196 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1197 +// cjbc++;
  1198 + } else {
  1199 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1200 + }
  1201 + }
  1202 + }
  1203 + }
  1204 + }
  1205 + }
  1206 + map.put("jhlc", format.format(jhlc));
  1207 + map.put("remMileage", format.format(remMileage));
  1208 + map.put("addMileage", format.format(addMileage));
  1209 + map.put("yygl", format.format(yygl));
  1210 + map.put("ksgl", format.format(ksgl));
  1211 + map.put("realMileage", format.format(yygl + ksgl + jcclc));
  1212 + map.put("jhbc", jhbc);
  1213 + map.put("cjbc", cjbc);
  1214 + map.put("ljbc", ljbc);
  1215 + map.put("sjbc", jhbc - cjbc + ljbc);
  1216 + map.put("jcclc", jcclc);
  1217 + map.put("zkslc", format.format(ksgl + jcclc));
  1218 + return map;
  1219 + }
  1220 +
  1221 +
  1222 + @Override
  1223 + public List<Map<String, Object>> account(String line, String date,
  1224 + String code, String xlName, String type) {
  1225 + List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code);
  1226 + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
  1227 + Map<String, Object> map;
  1228 + int i = 1;
  1229 + for (Object[] obj : lsitObj) {
  1230 + if (obj != null) {
  1231 + map = new HashMap<String, Object>();
  1232 + map.put("num", i++);
  1233 + map.put("xlName", xlName);
  1234 + map.put("clZbh", obj[3]);
  1235 + map.put("company", obj[0]);
  1236 + map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1] + "")).toUpperCase());
  1237 + map.put("requestTime", obj[2]);
  1238 + listMap.add(map);
  1239 + }
  1240 + }
  1241 +
  1242 + if (type != null && type.length() != 0 && type.equals("export")) {
  1243 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  1244 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  1245 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1246 + Map<String, Object> m = new HashMap<String, Object>();
  1247 + ReportUtils ee = new ReportUtils();
  1248 + Map<String, Object> typeMap = new HashMap<String, Object>();
  1249 + typeMap.put("0xA1", "请求恢复运营");
  1250 + typeMap.put("0xA2", "申请调档");
  1251 + typeMap.put("0xA3", "出场请求");
  1252 + typeMap.put("0xA5", "进场请求");
  1253 + typeMap.put("0xA7", "加油请求");
  1254 + typeMap.put("0x50", "车辆故障");
  1255 + typeMap.put("0x70", "路阻报告");
  1256 + typeMap.put("0x60", "事故报告");
  1257 + typeMap.put("0x11", "扣证纠纷");
  1258 + typeMap.put("0x12", "报警");
  1259 + for (Map<String, Object> map1 : listMap) {
  1260 + map1.put("requestText", typeMap.get(map1.get("requestType")));
  1261 + }
  1262 + try {
  1263 + listI.add(listMap.iterator());
  1264 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  1265 + ee.excelReplace(listI, new Object[]{m}, path + "mould\\account.xls",
  1266 + path + "export\\驾驶员请求台账" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  1267 + } catch (Exception e) {
  1268 + // TODO: handle exception
  1269 + e.printStackTrace();
  1270 + }
  1271 + }
  1272 +
  1273 + return listMap;
  1274 + }
  1275 +
  1276 + @Override
  1277 + public List<ScheduleRealInfo> correctForm(String line, String startDate,
  1278 + String endDate, String lpName, String code, String type) {
  1279 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.correctForm(line, startDate, endDate, lpName, code);
  1280 +
  1281 + if (type != null && type.length() != 0 && type.equals("export")) {
  1282 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  1283 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  1284 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1285 + Map<String, Object> m = new HashMap<String, Object>();
  1286 + ReportUtils ee = new ReportUtils();
  1287 + m.put("dates", startDate + " 至 " + endDate);
  1288 + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
  1289 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1290 + for (ScheduleRealInfo schedule : list) {
  1291 + Map<String, Object> tempMap = new HashMap<String, Object>();
  1292 + tempMap.put("xlName", schedule.getXlName() != null ? schedule.getXlName() : "");
  1293 + tempMap.put("lpName", schedule.getLpName() != null ? schedule.getLpName() : "");
  1294 + tempMap.put("clZbh", schedule.getClZbh() != null ? schedule.getClZbh() : "");
  1295 + tempMap.put("jName", schedule.getjName() != null ? schedule.getjName() : "");
  1296 + tempMap.put("sName", schedule.getsName() != null ? schedule.getsName() : "");
  1297 + tempMap.put("fcsj", schedule.getFcsj() != null ? schedule.getFcsj() : "");
  1298 + tempMap.put("fcsjActual", schedule.getFcsjActual() != null ? schedule.getFcsjActual() : "");
  1299 + tempMap.put("zdsj", schedule.getZdsj() != null ? schedule.getZdsj() : "");
  1300 + tempMap.put("zdsjActual", schedule.getZdsjActual() != null ? schedule.getZdsjActual() : "");
  1301 + if (schedule.getUpdateBy() != null) {
  1302 + if (schedule.getUpdateBy().getName() != null)
  1303 + tempMap.put("userName", schedule.getUpdateBy().getName());
  1304 + else
  1305 + tempMap.put("userName", "");
  1306 + } else {
  1307 + tempMap.put("userName", "");
  1308 + }
  1309 + if (schedule.getUpdateDate() != null) {
  1310 + tempMap.put("updateDate", sdf.format(schedule.getUpdateDate()));
  1311 + } else {
  1312 + tempMap.put("updateDate", "");
  1313 + }
  1314 + tempMap.put("remarks", schedule.getRemarks() != null ? schedule.getRemarks() : "");
  1315 + tempList.add(tempMap);
  1316 + }
  1317 + try {
  1318 + listI.add(tempList.iterator());
  1319 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  1320 + ee.excelReplace(listI, new Object[]{m}, path + "mould\\correctForm.xls",
  1321 + path + "export\\修正报表" + sdfSimple.format(sdfMonth.parse(startDate)) + "-" + sdfSimple.format(sdfMonth.parse(endDate)) + ".xls");
  1322 + } catch (Exception e) {
  1323 + // TODO: handle exception
  1324 + e.printStackTrace();
  1325 + }
  1326 + Map<String, Object> map = tempList.get(tempList.size() - 1);
  1327 + System.out.println("tempMap:" + map);
  1328 + }
  1329 +
  1330 + return list;
  1331 + }
  1332 +
  1333 + @Override
  1334 + public List<ScheduleRealInfo> queryListWaybill(String jName, String clZbh,
  1335 + String lpName, String date,String line) {
  1336 + List<ScheduleRealInfo> list = null;
  1337 + list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date,line);
  1338 + for (int i = 0; i < list.size(); i++) {
  1339 + ScheduleRealInfo s = list.get(i);
  1340 + String remarks = "";
  1341 + if (s.getRemarks() != null) {
  1342 + remarks += s.getRemarks();
  1343 + }
  1344 + Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
  1345 + if (!childTaskPlans.isEmpty()) {
  1346 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1347 + while (it.hasNext()) {
  1348 + ChildTaskPlan c = it.next();
  1349 + if (c.getRemarks() != null && c.getRemarks().length() > 0) {
  1350 + remarks += c.getRemarks();
  1351 + }
  1352 +
  1353 + }
  1354 + }
  1355 + s.setRemarks(remarks);
  1356 + }
  1357 +
  1358 + return list;
  1359 + }
  1360 +
  1361 + @Override
  1362 + public Map<String, Object> removeChildTask(Long taskId) {
  1363 + Map<String, Object> rs = new HashMap<>();
  1364 + ChildTaskPlan chTask = cTaskPlanRepository.findOne(taskId);
  1365 +
  1366 + ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId());
  1367 + try {
  1368 +
  1369 + sch.getcTasks().remove(chTask);
  1370 + scheduleRealInfoRepository.save(sch);
  1371 + rs.put("status", ResponseCode.SUCCESS);
  1372 + } catch (Exception e) {
  1373 + logger.error("", e);
  1374 + rs.put("status", ResponseCode.ERROR);
  1375 + }
  1376 + return rs;
  1377 + }
  1378 +
  1379 + @Override
  1380 + public List<Map<String, Object>> statisticsDaily(String line, String date,
  1381 + String xlName, String type) {
  1382 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1383 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  1384 + DecimalFormat format = new DecimalFormat("0.00");
  1385 + double jhlc = 0, tempJhlc = 0, childMileage = 0;
  1386 + float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f, ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_other = 0f, ljgl = 0f;
  1387 + //班次
  1388 + int sj_0 = 6 * 60 + 31, sj_1 = 8 * 60 + 30, sj_2 = 16 * 60 + 1, sj_3 = 18 * 60;
  1389 + int jhbc = 0, jhbc_m = 0, jhbc_a = 0;
  1390 + int sjbc = 0, sjbc_m = 0, sjbc_a = 0;
  1391 + int ljbc = 0, ljbc_m = 0, ljbc_a = 0;
  1392 + int fzbc = 0, fzbc_m = 0, fzbc_a = 0;
  1393 + int dtbc = 0, dtbc_m = 0, dtbc_a = 0;
  1394 + int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0;
  1395 + Map<String, Object> map = new HashMap<String, Object>();
  1396 + for (ScheduleRealInfo scheduleRealInfo : list) {
  1397 + if (scheduleRealInfo != null) {
  1398 +
  1399 + if (!(scheduleRealInfo.getBcType().equals("in")
  1400 + || scheduleRealInfo.getBcType().equals("out"))) {
  1401 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1402 + //计算实际里程,少驶里程,计划里程=实际里程+少驶里程
  1403 + if (childTaskPlans.isEmpty()) {
  1404 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1405 + //临加公里
  1406 + if (scheduleRealInfo.isSflj()) {
  1407 + ljgl += tempJhlc;
  1408 + } else {
  1409 + jhlc += tempJhlc;
  1410 + }
  1411 + if (scheduleRealInfo.getStatus() == 2) {
  1412 + sjgl += tempJhlc;
  1413 + } else if (scheduleRealInfo.getStatus() == -1) {
  1414 + ssgl += tempJhlc;
  1415 + if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("路阻") != -1) {
  1416 + ssgl_lz += tempJhlc;
  1417 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("吊慢") != -1) {
  1418 + ssgl_dm += tempJhlc;
  1419 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("故障") != -1) {
  1420 + ssgl_gz += tempJhlc;
  1421 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("纠纷") != -1) {
  1422 + ssgl_jf += tempJhlc;
  1423 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("肇事") != -1) {
  1424 + ssgl_zs += tempJhlc;
  1425 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("缺人") != -1) {
  1426 + ssgl_qr += tempJhlc;
  1427 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("缺车") != -1) {
  1428 + ssgl_qc += tempJhlc;
  1429 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("客稀") != -1) {
  1430 + ssgl_kx += tempJhlc;
  1431 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("气候") != -1) {
  1432 + ssgl_qh += tempJhlc;
  1433 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("援外") != -1) {
  1434 + ssgl_yw += tempJhlc;
  1435 + } else {
  1436 + ssgl_other += tempJhlc;
  1437 + }
  1438 + }
  1439 + } else {
  1440 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1441 + while (it.hasNext()) {
  1442 + ChildTaskPlan childTaskPlan = it.next();
  1443 + childMileage = childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1444 + jhlc += childMileage;
  1445 + if (childTaskPlan.isDestroy()) {
  1446 + ssgl += childMileage;
  1447 + if (childTaskPlan.getDestroyReason().equals("路阻")) {
  1448 + ssgl_lz += childTaskPlan.getMileage();
  1449 + } else if (childTaskPlan.getDestroyReason().equals("吊慢")) {
  1450 + ssgl_dm += childTaskPlan.getMileage();
  1451 + } else if (childTaskPlan.getDestroyReason().equals("故障")) {
  1452 + ssgl_gz += childTaskPlan.getMileage();
  1453 + } else if (childTaskPlan.getDestroyReason().equals("纠纷")) {
  1454 + ssgl_jf += childTaskPlan.getMileage();
  1455 + } else if (childTaskPlan.getDestroyReason().equals("肇事")) {
  1456 + ssgl_zs += childTaskPlan.getMileage();
  1457 + } else if (childTaskPlan.getDestroyReason().equals("缺人")) {
  1458 + ssgl_qr += childTaskPlan.getMileage();
  1459 + } else if (childTaskPlan.getDestroyReason().equals("缺车")) {
  1460 + ssgl_qc += childTaskPlan.getMileage();
  1461 + } else if (childTaskPlan.getDestroyReason().equals("客稀")) {
  1462 + ssgl_kx += childTaskPlan.getMileage();
  1463 + } else if (childTaskPlan.getDestroyReason().equals("气候")) {
  1464 + ssgl_qh += childTaskPlan.getMileage();
  1465 + } else if (childTaskPlan.getDestroyReason().equals("援外")) {
  1466 + ssgl_yw += childTaskPlan.getMileage();
  1467 + } else {
  1468 + ssgl_other += childTaskPlan.getMileage();
  1469 + }
  1470 + } else {
  1471 + sjgl += childMileage;
  1472 + }
  1473 + }
  1474 + }
  1475 +
  1476 + //班次
  1477 + jhbc++;
  1478 + String[] fcsj = scheduleRealInfo.getFcsj().split(":");
  1479 + String[] fcsjActual = (scheduleRealInfo.getFcsjActual() == null ? "0:00" : scheduleRealInfo.getFcsjActual()).split(":");
  1480 + if ((Integer.parseInt(fcsj[0]) * 60 + Integer.parseInt(fcsj[1])) > sj_0 && (Integer.parseInt(fcsj[0]) * 60 + Integer.parseInt(fcsj[1])) < sj_1) {
  1481 + jhbc_m++;
  1482 + } else if ((Integer.parseInt(fcsj[0]) * 60 + Integer.parseInt(fcsj[1])) > sj_2 && (Integer.parseInt(fcsj[0]) * 60 + Integer.parseInt(fcsj[1])) < sj_3) {
  1483 + jhbc_a++;
  1484 + }
  1485 + if (scheduleRealInfo.getStatus() == 2) {
  1486 + sjbc++;
  1487 + if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_1) {
  1488 + sjbc_m++;
  1489 + } else if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_3) {
  1490 + sjbc_a++;
  1491 + }
  1492 + }
  1493 + if (scheduleRealInfo.isSflj()) {
  1494 + ljbc++;
  1495 + if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_1) {
  1496 + ljbc_m++;
  1497 + } else if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_3) {
  1498 + ljbc_a++;
  1499 + }
  1500 + }
  1501 + if (scheduleRealInfo.getBcType().equals("venting")) {
  1502 + fzbc++;
  1503 + if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_1) {
  1504 + fzbc_m++;
  1505 + } else if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_3) {
  1506 + fzbc_a++;
  1507 + }
  1508 + }
  1509 + }
  1510 + }
  1511 + }
  1512 + map.put("xlName", xlName);
  1513 + map.put("jhlc", format.format(jhlc));
  1514 + map.put("sjgl", format.format(sjgl));
  1515 + map.put("ssgl", format.format(ssgl));
  1516 + map.put("ssgl_lz", ssgl_lz == 0 ? 0 : format.format(ssgl_lz));
  1517 + map.put("ssgl_dm", ssgl_dm == 0 ? 0 : format.format(ssgl_dm));
  1518 + map.put("ssgl_gz", ssgl_gz == 0 ? 0 : format.format(ssgl_gz));
  1519 + map.put("ssgl_jf", ssgl_jf == 0 ? 0 : format.format(ssgl_jf));
  1520 + map.put("ssgl_zs", ssgl_zs == 0 ? 0 : format.format(ssgl_zs));
  1521 + map.put("ssgl_qr", ssgl_qr == 0 ? 0 : format.format(ssgl_qr));
  1522 + map.put("ssgl_qc", ssgl_qc == 0 ? 0 : format.format(ssgl_qc));
  1523 + map.put("ssgl_kx", ssgl_kx == 0 ? 0 : format.format(ssgl_kx));
  1524 + map.put("ssgl_qh", ssgl_qh == 0 ? 0 : format.format(ssgl_qh));
  1525 + map.put("ssgl_yw", ssgl_yw == 0 ? 0 : format.format(ssgl_yw));
  1526 + map.put("ssgl_other", ssgl_other == 0 ? 0 : format.format(ssgl_other));
  1527 + map.put("ljgl", ljgl == 0 ? 0 : format.format(ljgl));
  1528 + map.put("jhbc", jhbc);
  1529 + map.put("jhbc_m", jhbc_m);
  1530 + map.put("jhbc_a", jhbc_a);
  1531 + map.put("sjbc", sjbc);
  1532 + map.put("sjbc_m", sjbc_m);
  1533 + map.put("sjbc_a", sjbc_a);
  1534 + map.put("ljbc", ljbc);
  1535 + map.put("ljbc_m", ljbc_m);
  1536 + map.put("ljbc_a", ljbc_a);
  1537 + map.put("fzbc", fzbc);
  1538 + map.put("fzbc_m", fzbc_m);
  1539 + map.put("fzbc_a", fzbc_a);
  1540 + map.put("dtbc", dtbc);
  1541 + map.put("dtbc_m", dtbc_m);
  1542 + map.put("dtbc_a", dtbc_a);
  1543 + map.put("djg", djg);
  1544 + map.put("djg_m", djg_m);
  1545 + map.put("djg_a", djg_a);
  1546 + map.put("djg_time", djg_time);
  1547 + lMap.add(map);
  1548 +
  1549 + if(type != null && type.length() != 0 && type.equals("export")){
  1550 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  1551 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  1552 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1553 + Map<String,Object> m = new HashMap<String, Object>();
  1554 + ReportUtils ee = new ReportUtils();
  1555 + try {
  1556 + listI.add(lMap.iterator());
  1557 + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
  1558 + ee.excelReplace(listI, new Object[] { m }, path+"mould\\statisticsDaily_.xls",
  1559 + path+"export\\统计日报" + sdfSimple.format(sdfMonth.parse(date))+".xls");
  1560 + } catch (Exception e) {
  1561 + // TODO: handle exception
  1562 + e.printStackTrace();
672 } 1563 }
673 - else {  
674 - sch.setRealExecDate(sch.getScheduleDateStr()); 1564 + }
  1565 +
  1566 + return lMap;
  1567 + }
  1568 +
  1569 + @Override
  1570 + public Map<String, Object> scheduleDaily(String line, String date) {
  1571 + Map<String, String> tempMap = null;
  1572 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1573 + Map<String, Object> map = new HashMap<String, Object>();
  1574 + Double jhlc = 0.00;
  1575 + Float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f, ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_other = 0f, ljgl = 0f;
  1576 + int jhbc = 0;
  1577 + for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) {
  1578 + if (scheduleRealInfo != null) {
  1579 + //计算里程(包括子任务)
  1580 + jhlc += scheduleRealInfo.getJhlc();
  1581 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1582 + if (!childTaskPlans.isEmpty()) {
  1583 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1584 + while (it.hasNext()) {
  1585 + ChildTaskPlan childTaskPlan = it.next();
  1586 + //是否烂班,烂班就是少驶
  1587 + if (!childTaskPlan.isDestroy()) {
  1588 + sjgl += childTaskPlan.getMileage();
  1589 + } else {
  1590 + ssgl += childTaskPlan.getMileage();
  1591 + if (childTaskPlan.getDestroyReason().equals("路阻")) {
  1592 + ssgl_lz += childTaskPlan.getMileage();
  1593 + } else if (childTaskPlan.getDestroyReason().equals("吊慢")) {
  1594 + ssgl_dm += childTaskPlan.getMileage();
  1595 + } else if (childTaskPlan.getDestroyReason().equals("故障")) {
  1596 + ssgl_gz += childTaskPlan.getMileage();
  1597 + } else if (childTaskPlan.getDestroyReason().equals("纠纷")) {
  1598 + ssgl_jf += childTaskPlan.getMileage();
  1599 + } else if (childTaskPlan.getDestroyReason().equals("肇事")) {
  1600 + ssgl_zs += childTaskPlan.getMileage();
  1601 + } else if (childTaskPlan.getDestroyReason().equals("缺人")) {
  1602 + ssgl_qr += childTaskPlan.getMileage();
  1603 + } else if (childTaskPlan.getDestroyReason().equals("缺车")) {
  1604 + ssgl_qc += childTaskPlan.getMileage();
  1605 + } else if (childTaskPlan.getDestroyReason().equals("客稀")) {
  1606 + ssgl_kx += childTaskPlan.getMileage();
  1607 + } else if (childTaskPlan.getDestroyReason().equals("气候")) {
  1608 + ssgl_qh += childTaskPlan.getMileage();
  1609 + } else if (childTaskPlan.getDestroyReason().equals("援外")) {
  1610 + ssgl_yw += childTaskPlan.getMileage();
  1611 + } else {
  1612 + ssgl_other += childTaskPlan.getMileage();
  1613 + }
  1614 + }
  1615 + //临加公里
  1616 + if (childTaskPlan.getType1().equals("临加")) {
  1617 + ljgl += childTaskPlan.getMileage();
  1618 + }
  1619 + }
  1620 + }
  1621 + //班次
  1622 + scheduleRealInfo.getFcsjT();
  1623 + scheduleRealInfo.getFcsjActualTime();
  1624 + }
  1625 + }
  1626 + map.put("jhlc", jhlc);
  1627 + map.put("sjgl", sjgl);
  1628 + map.put("ssgl", ssgl);
  1629 + map.put("ssgl_lz", ssgl_lz);
  1630 + map.put("ssgl_dm", ssgl_dm);
  1631 + map.put("ssgl_gz", ssgl_gz);
  1632 + map.put("ssgl_jf", ssgl_jf);
  1633 + map.put("ssgl_zs", ssgl_zs);
  1634 + map.put("ssgl_qr", ssgl_qr);
  1635 + map.put("ssgl_qc", ssgl_qc);
  1636 + map.put("ssgl_kx", ssgl_kx);
  1637 + map.put("ssgl_qh", ssgl_qh);
  1638 + map.put("ssgl_yw", ssgl_yw);
  1639 + map.put("ssgl_other", ssgl_other);
  1640 + map.put("ljgl", ljgl);
  1641 +
  1642 + map.put("jhbc", scheduleRealInfos.size());
  1643 + return null;
  1644 + }
  1645 +
  1646 + @Override
  1647 + public int countByLineCodeAndDate(String xlBm, String schDate) {
  1648 + return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate);
  1649 + }
  1650 +
  1651 + @Override
  1652 + public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) {
  1653 + return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate);
  1654 + }
  1655 +
  1656 + @Override
  1657 + public void deleteByLineCodeAndDate(String xlBm, String schDate) {
  1658 + scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate);
  1659 + }
  1660 +
  1661 + @Override
  1662 + public Long getMaxId() {
  1663 + return scheduleRealInfoRepository.getMaxId();
  1664 + }
  1665 +
  1666 + @Override
  1667 + public List<ScheduleRealInfo> realScheduleList(String line, String date) {
  1668 + /*List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.queryUserInfo(line, date);
  1669 + List<ScheduleRealInfo> listTotal = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1670 + for(ScheduleRealInfo info:listInfo){
  1671 + for(ScheduleRealInfo total:listTotal){
  1672 + if(info.getjGh().equals(total.getjGh()) && info.getLpName().equals(total.getLpName()) && info.getClZbh().equals(total.getClZbh())){
  1673 +
  1674 + }
675 } 1675 }
  1676 + }*/
  1677 + return scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1678 + }
676 1679
677 - sch.setFcsjActualAll(fcsjActual);  
678 - sch.addRemarks(remarks);  
679 - sch.calcStatus();  
680 -  
681 - dayOfSchedule.save(sch);  
682 - //scheduleRealInfoRepository.save(sch);  
683 -  
684 - ts.add(sch);  
685 1680
686 - rs.put("status", ResponseCode.SUCCESS);  
687 - rs.put("ts", ts); 1681 + public List<Map<String, Object>> yesterdayDataList(String line, String date) {
  1682 + //前一天日期
  1683 +// String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1));
  1684 +// String date = "2016-09-20";
  1685 + List<Map<String, Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date);
  1686 +// List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1687 + for (int x = 0; x < yesterdayDataList.size(); x++) {
  1688 + String jName = yesterdayDataList.get(x).get("jGh").toString();
  1689 + String clZbh = yesterdayDataList.get(x).get("clZbh").toString();
  1690 + List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date);
  1691 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0;
  1692 + float addMileage = 0l, remMileage = 0l;
  1693 + Map<String, Object> map = new HashMap<String, Object>();
  1694 + boolean fage = true;
  1695 + for (ScheduleRealInfo scheduleRealInfo : lists) {
  1696 + if (fage) {
  1697 + //根据线路代码获取公司
  1698 + Line li = lineRepository.findByLineCode(scheduleRealInfo.getXlBm());
  1699 + yesterdayDataList.get(x).put("company", li.getCompany());
  1700 + yesterdayDataList.get(x).put("bCompany", li.getBrancheCompany());
  1701 + fage = false;
  1702 + }
  1703 + if (scheduleRealInfo != null) {
  1704 + //计划里程(主任务过滤掉临加班次),
  1705 + //烂班里程(主任务烂班),
  1706 + //临加里程(主任务临加),
  1707 + //计划班次,烂班班次,增加班次
  1708 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1709 + if (scheduleRealInfo.isSflj()) {
  1710 + addMileage += tempJhlc;
  1711 + } else {
  1712 + if (!(scheduleRealInfo.getBcType().equals("in")
  1713 + || scheduleRealInfo.getBcType().equals("out"))) {
  1714 + jhlc += tempJhlc;
  1715 + }
  1716 +
  1717 + if (scheduleRealInfo.getStatus() == -1) {
  1718 + remMileage += tempJhlc;
  1719 + }
  1720 + }
  1721 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1722 + //计算营运里程,空驶里程
  1723 + if (childTaskPlans.isEmpty()) {
  1724 + if (scheduleRealInfo.getBcType().equals("in") ||
  1725 + scheduleRealInfo.getBcType().equals("out")) {
  1726 + jcclc += tempJhlc;
  1727 + }
  1728 + //主任务 放空班次属于营运
  1729 +// else if(scheduleRealInfo.getBcType().equals("venting")){
  1730 +// ksgl += tempJhlc;
  1731 +// }
  1732 + else {
  1733 + if (scheduleRealInfo.getStatus() != -1) {
  1734 + yygl += tempJhlc;
  1735 + }
  1736 + }
  1737 + } else {
  1738 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1739 + while (it.hasNext()) {
  1740 + ChildTaskPlan childTaskPlan = it.next();
  1741 + if (childTaskPlan.getMileageType().equals("empty")) {
  1742 + if (childTaskPlan.isDestroy()) {
  1743 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1744 + } else {
  1745 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1746 + }
  1747 + } else {
  1748 + if (childTaskPlan.isDestroy()) {
  1749 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1750 + } else {
  1751 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1752 + }
  1753 + }
  1754 + }
  1755 + }
  1756 + }
  1757 + }
  1758 +
  1759 + yesterdayDataList.get(x).put("totalKilometers", yygl + ksgl + jcclc);
  1760 +
  1761 + }
  1762 +
  1763 + /* for(ScheduleRealInfo scheduleRealInfo:list){
  1764 + if(scheduleRealInfo != null){
  1765 + for(int i=0;i<yesterdayDataList.size();i++){
  1766 + if(scheduleRealInfo.getXlBm().equals(yesterdayDataList.get(i).get("xlBm")) && scheduleRealInfo.getClZbh().equals(yesterdayDataList.get(i).get("clZbh"))
  1767 + && scheduleRealInfo.getjGh().equals(yesterdayDataList.get(i).get("jGh"))){
  1768 + //根据线路代码获取公司
  1769 + Line li = lineRepository.findByLineCode(scheduleRealInfo.getXlBm());
  1770 + yesterdayDataList.get(i).put("company", li.getCompany());
  1771 + yesterdayDataList.get(i).put("bCompany", li.getBrancheCompany());
  1772 + //计算总公里
  1773 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1774 + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班
  1775 + if(childTaskPlans.isEmpty()){
  1776 + if(scheduleRealInfo.getStatus() == 2){
  1777 + yesterdayDataList.get(i).put("totalKilometers", scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc()+(double)(yesterdayDataList.get(i).get("totalKilometers")==null?0.0:yesterdayDataList.get(i).get("totalKilometers")));
  1778 + }
  1779 + }else{
  1780 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1781 + while(it.hasNext()){
  1782 + ChildTaskPlan childTaskPlan = it.next();
  1783 + if(!childTaskPlan.isDestroy()){
  1784 + yesterdayDataList.get(i).put("totalKilometers", childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage()+(double)(yesterdayDataList.get(i).get("totalKilometers")==null?0.0:yesterdayDataList.get(i).get("totalKilometers")));
  1785 + }
  1786 + }
  1787 + }
  1788 + }
  1789 + }
  1790 + }
  1791 + }*/
  1792 + //增加顺序号
  1793 + for (int i = 0; i < yesterdayDataList.size(); i++) {
  1794 + if (i == 0) {
  1795 + yesterdayDataList.get(i).put("seqNumber", 1);
  1796 + } else {
  1797 + if (yesterdayDataList.get(i - 1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))) {
  1798 + yesterdayDataList.get(i).put("seqNumber", 1 + (int) yesterdayDataList.get(i - 1).get("seqNumber"));
  1799 + } else {
  1800 + yesterdayDataList.get(i).put("seqNumber", 1);
  1801 + }
  1802 + }
  1803 + }
  1804 + return yesterdayDataList;
  1805 + }
  1806 +
  1807 + /**
  1808 + * 批量调整人车
  1809 + */
  1810 + @Override
  1811 + public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs) {
  1812 + Map<String, Object> rs = new HashMap<>();
  1813 + Set<ScheduleRealInfo> set = new HashSet<>();
  1814 +
  1815 + ScheduleRealInfo sch;
  1816 + BiMap<String, String> map = BasicData.deviceId2NbbmMap.inverse();
  1817 +
  1818 + for (ChangePersonCar cpc : cpcs) {
  1819 +
  1820 + if (map.get(cpc.getClZbh()) == null) {
  1821 + rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");
  1822 + rs.put("status", ResponseCode.ERROR);
  1823 + return rs;
  1824 + }
  1825 +
  1826 + sch = dayOfSchedule.get(cpc.getSchId());
  1827 + if (sch == null)
  1828 + continue;
  1829 +
  1830 + if (StringUtils.isNotEmpty(cpc.getJsy())) {
  1831 + //换驾驶员
  1832 + persoChange(sch, cpc.getJsy().split("/")[0]);
  1833 + }
  1834 +
  1835 + //换售票员
  1836 + if (StringUtils.isNotEmpty(cpc.getSpy())) {
  1837 + persoChangeSPY(sch, cpc.getSpy().split("/")[0]);
  1838 + }
  1839 +
  1840 + //换车
  1841 + if (StringUtils.isNotEmpty(cpc.getClZbh())) {
  1842 + set.add(sch);
  1843 + set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh()));
  1844 + }
  1845 +
  1846 + }
  1847 + rs.put("ts", set);
  1848 + rs.put("status", ResponseCode.SUCCESS);
  1849 + return rs;
  1850 + }
  1851 +
  1852 + /**
  1853 + * @Title: persoChange
  1854 + * @Description: TODO(班次换驾驶员)
  1855 + */
  1856 + public void persoChange(ScheduleRealInfo sch, String jGh) {
  1857 + if (sch.getjGh().equals(jGh))
  1858 + return;
  1859 + String jName = BasicData.allPerson.get(jGh);
  1860 + if (StringUtils.isNotEmpty(jName)) {
  1861 + sch.setjGh(jGh);
  1862 + sch.setjName(jName);
  1863 + }
  1864 + }
  1865 +
  1866 + /**
  1867 + * @Title: persoChange
  1868 + * @Description: TODO(班次换售票员)
  1869 + */
  1870 + public void persoChangeSPY(ScheduleRealInfo sch, String sGh) {
  1871 + if (sch.getsGh().equals(sGh))
  1872 + return;
  1873 + String sName = BasicData.allPerson.get(sGh);
  1874 + if (StringUtils.isNotEmpty(sName)) {
  1875 + sch.setsGh(sGh);
  1876 + sch.setsName(sName);
  1877 + }
  1878 + }
  1879 +
  1880 + /**
  1881 + * 批量待发调整
  1882 + */
  1883 + @Override
  1884 + public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) {
  1885 + Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>();
  1886 + List<ScheduleRealInfo> list = new ArrayList<>();
  1887 +
  1888 + ScheduleRealInfo sch, next;
  1889 + for (DfsjChange dc : dfsjcs) {
  1890 + if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))
  1891 + continue;
688 1892
689 - //通知页面刷新  
690 - sendUtils.refreshSch(ts);  
691 - } catch (Exception e) {  
692 - logger.error("", e);  
693 - rs.put("status", ResponseCode.ERROR);  
694 - }  
695 -  
696 - return rs;  
697 - } 1893 + /*sch = dayOfSchedule.get(dc.getSchId());
  1894 + if(sch==null)
  1895 + continue;
  1896 +
  1897 + sch.setDfsjAll(dc.getNew_dfsj());
  1898 + //重新计算终点时间
  1899 + sch.calcEndTime();
  1900 + list.add(sch);*/
  1901 + tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null);
698 1902
699 - @Override  
700 - public Map<String, Object> revokeDestroy(Long id) {  
701 - Map<String, Object> rs = new HashMap<>();  
702 - try {  
703 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
704 - if (sch.getStatus() != -1) {  
705 - rs.put("status", ResponseCode.ERROR);  
706 - rs.put("msg", "未烂班,无法撤销!");  
707 - } else {  
708 - sch.setStatus(0);  
709 - rs.put("status", ResponseCode.SUCCESS);  
710 - rs.put("t", sch); 1903 + if (tempMap.get("status").equals(ResponseCode.SUCCESS)) {
  1904 + list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts"));
  1905 + }
  1906 + //next=dayOfSchedule.next(sch);
  1907 + /*if(next.getQdzName().equals(sch.getZdzName())){
  1908 + next.setQdzArrDateJH(sch.getZdsj());
  1909 + list.add(next);
  1910 + }*/
  1911 + }
711 1912
712 - }  
713 - } catch (Exception e) {  
714 - logger.error("", e);  
715 - rs.put("status", ResponseCode.ERROR);  
716 - }  
717 - return rs;  
718 - } 1913 + rs.put("status", ResponseCode.SUCCESS);
  1914 + rs.put("ts", list);
  1915 + return rs;
  1916 + }
719 1917
720 - @Override  
721 - public Map<String, Object> revokeRealOutgo(Long id) {  
722 - Map<String, Object> rs = new HashMap<>();  
723 - List<ScheduleRealInfo> ts = new ArrayList<>();  
724 -  
725 - try {  
726 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
727 - if (sch.getFcsjActual() == null) {  
728 - rs.put("status", ResponseCode.ERROR);  
729 - rs.put("msg", "无实发时间,无法撤销!");  
730 - } else {  
731 - //将对应的到离站数据标记为不可信  
732 - List<ArrivalEntity> list = ArrivalData_GPS.findByNbbm(sch.getClZbh());  
733 - for(ArrivalEntity arr : list){  
734 - if(arr.getInOut() == 1  
735 - && arr.getUpDown() == Integer.parseInt(sch.getXlDir())  
736 - && arr.getStopNo().equals(sch.getQdzCode())  
737 - && Math.abs(arr.getTs() - sch.getFcsjActualTime()) < 1000 * 60){  
738 - arr.setEnable(false);  
739 - break;  
740 - }  
741 - }  
742 -  
743 - sch.clearFcsjActual();  
744 - rs.put("status", ResponseCode.SUCCESS);  
745 -  
746 - ts.add(sch);  
747 - rs.put("ts", ts);  
748 1918
749 - }  
750 - } catch (Exception e) {  
751 - logger.error("", e);  
752 - rs.put("status", ResponseCode.ERROR);  
753 - }  
754 - return rs;  
755 - } 1919 + @Override
  1920 + public Map<String, Object> findKMBC1(String jName, String clZbh,
  1921 + String date, String enddate) {
  1922 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate);
  1923 + DecimalFormat format = new DecimalFormat("0.00");
  1924 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  1925 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  1926 + int jhbc = 0, cjbc = 0, ljbc = 0;
  1927 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;
  1928 + float addMileage = 0l, remMileage = 0l;
  1929 + Map<String, Object> map = new HashMap<String, Object>();
  1930 + for (ScheduleRealInfo scheduleRealInfo : list) {
  1931 + if (scheduleRealInfo != null) {
  1932 + //计划里程(主任务过滤掉临加班次),
  1933 + //烂班里程(主任务烂班),
  1934 + //临加里程(主任务临加),
  1935 + //计划班次,烂班班次,增加班次
  1936 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1937 + if (scheduleRealInfo.isSflj()) {
  1938 + addMileage += tempJhlc;
  1939 + ljbc++;
  1940 + } else {
  1941 + jhlc += tempJhlc;
  1942 + jhbc++;
  1943 + if (scheduleRealInfo.getStatus() == -1) {
  1944 + remMileage += tempJhlc;
  1945 + cjbc++;
  1946 + }
  1947 + }
  1948 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1949 + //计算营运里程,空驶里程
  1950 + if (childTaskPlans.isEmpty()) {
  1951 + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  1952 + || scheduleRealInfo.getBcType().equals("venting")) {
  1953 + ksgl += tempJhlc;
  1954 + } else {
  1955 + yygl += tempJhlc;
  1956 + }
  1957 + } else {
  1958 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1959 + while (it.hasNext()) {
  1960 + ChildTaskPlan childTaskPlan = it.next();
  1961 + if (childTaskPlan.getMileageType().equals("empty")) {
  1962 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1963 + } else {
  1964 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1965 + }
  1966 + }
  1967 + }
  1968 + }
  1969 + }
  1970 + map.put("jhlc", format.format(jhlc));
  1971 + map.put("remMileage", format.format(remMileage));
  1972 + map.put("addMileage", format.format(addMileage));
  1973 + map.put("yygl", format.format(yygl));
  1974 + map.put("ksgl", format.format(ksgl));
  1975 + map.put("realMileage", format.format(yygl + ksgl));
  1976 + map.put("jhbc", jhbc);
  1977 + map.put("cjbc", cjbc);
  1978 + map.put("ljbc", ljbc);
  1979 + map.put("sjbc", jhbc - cjbc + ljbc);
  1980 + return map;
  1981 + }
  1982 +
  1983 + /**
  1984 + * 调整班次类型
  1985 + *
  1986 + * @param id
  1987 + * @param bcType
  1988 + * @param remarks
  1989 + * @return
  1990 + */
  1991 + @Override
  1992 + public Map<String, Object> changeBcType(Long id, String bcType, String remarks) {
  1993 + Map<String, Object> rs = new HashMap<>();
  1994 +
  1995 + try {
  1996 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  1997 + if (sch != null) {
  1998 + sch.setBcType(bcType);
  1999 + sch.addRemarks(remarks);
  2000 + //有时间记录一下相关变更数据
  2001 + rs.put("status", ResponseCode.SUCCESS);
  2002 + rs.put("t", sch);
  2003 + }
  2004 + } catch (Exception e) {
  2005 + logger.error("", e);
  2006 + rs.put("status", ResponseCode.ERROR);
  2007 + }
  2008 +
  2009 + return rs;
  2010 + }
  2011 +
  2012 + @Override
  2013 + public Map<String, Object> historySave(ScheduleRealInfo sch) {
  2014 + Map<String, Object> rs = new HashMap<>();
  2015 + rs.put("status", ResponseCode.ERROR);
  2016 +
  2017 + ScheduleRealInfo oldSch = super.findById(sch.getId());
  2018 + //修改车辆
  2019 + if (!oldSch.getClZbh().equals(sch.getClZbh())) {
  2020 + Set<String> allCar = BasicData.deviceId2NbbmMap.values();
  2021 + if (!allCar.contains(sch.getClZbh())) {
  2022 + rs.put("msg", "无效的车辆自编号");
  2023 + return rs;
  2024 + } else
  2025 + oldSch.setClZbh(sch.getClZbh());
  2026 + }
  2027 +
  2028 + //修改驾驶员
  2029 + if (!oldSch.getjGh().equals(sch.getjGh())) {
  2030 + Map<String, String> allPer = BasicData.allPerson;
  2031 + if (!allPer.containsKey(sch.getjGh())) {
  2032 + rs.put("msg", "无效的驾驶员");
  2033 + return rs;
  2034 + } else {
  2035 + oldSch.setjGh(sch.getjGh());
  2036 + oldSch.setjName(allPer.get(oldSch.getjGh()));
  2037 + }
  2038 + }
  2039 +
  2040 + //待发时间
  2041 + oldSch.setDfsj(sch.getDfsj());
  2042 + //实发时间
  2043 + oldSch.setFcsjActual(sch.getFcsjActual());
  2044 + //实际终点
  2045 + oldSch.setZdsjActual(sch.getZdsjActual());
  2046 + //备注
  2047 + oldSch.setRemarks(sch.getRemarks());
  2048 +
  2049 + scheduleRealInfoRepository.save(oldSch);
  2050 + rs.put("status", ResponseCode.SUCCESS);
  2051 + return rs;
  2052 + }
  2053 +
  2054 + @Autowired
  2055 + SvgAttributeRepository svgAttributeRepository;
  2056 +
  2057 + @Override
  2058 + public Map<String, Object> svgAttr(String jsonStr) {
  2059 + Map<String, Object> rs = new HashMap<>();
  2060 +
  2061 + try {
  2062 + JSONObject jObj = JSONObject.parseObject(StringEscapeUtils.unescapeHtml4(jsonStr));
  2063 +
  2064 + SvgAttribute svgAttribute = new SvgAttribute();
  2065 + svgAttribute.setLineCode(jObj.getString("lineCode"));
  2066 + svgAttribute.setHideStations(jObj.getString("hideStations"));
  2067 + svgAttribute.setNicknames(jObj.getString("nicknames"));
  2068 + svgAttributeRepository.save(svgAttribute);
  2069 +
  2070 + rs.put("t", svgAttribute);
  2071 + rs.put("status", ResponseCode.SUCCESS);
  2072 + } catch (Exception e) {
  2073 + logger.error("", e);
  2074 + rs.put("status", ResponseCode.ERROR);
  2075 + }
  2076 + return rs;
  2077 + }
  2078 +
  2079 + @Override
  2080 + public Map<String, Object> findSvgAttr(String idx) {
  2081 + Map<String, Object> rs = new HashMap<>();
  2082 + try {
  2083 + List<String> lineCodes = Splitter.on(",").splitToList(idx);
  2084 + List<SvgAttribute> list = svgAttributeRepository.findSvgAttr(lineCodes);
  2085 +
  2086 + rs.put("status", ResponseCode.SUCCESS);
  2087 + rs.put("list", list);
  2088 + } catch (Exception e) {
  2089 + logger.error("", e);
  2090 + rs.put("status", ResponseCode.ERROR);
  2091 + }
  2092 + return rs;
  2093 + }
  2094 +
  2095 + @Override
  2096 + public Map<String, Object> addRemarks(Long id, String remarks) {
  2097 + Map<String, Object> rs = new HashMap<>();
  2098 + try {
  2099 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  2100 + sch.addRemarks(remarks);
  2101 +
  2102 + rs.put("status", ResponseCode.SUCCESS);
  2103 + rs.put("t", sch);
  2104 + } catch (Exception e) {
  2105 + logger.error("", e);
  2106 + rs.put("status", ResponseCode.ERROR);
  2107 + }
  2108 + return rs;
  2109 + }
  2110 +
  2111 + @Override
  2112 + public List<Map<String, Object>> yesterdayDataList(String line) {
  2113 + // TODO Auto-generated method stub
  2114 + return null;
  2115 + }
756 2116
757 @Override 2117 @Override
758 - public Map<String, Object> spaceAdjust(Long[] ids, Integer space) {  
759 -  
760 - List<ScheduleRealInfo> list = new ArrayList<>()  
761 - ,updateList = new ArrayList<>();  
762 - Map<String, Object> rs = new HashMap<>();  
763 - try {  
764 - ScheduleRealInfo sch, next;  
765 - for (Long id : ids) {  
766 - sch = dayOfSchedule.get(id);  
767 - if (null != sch)  
768 - list.add(sch);  
769 - }  
770 -  
771 - int size = list.size();  
772 - if(size == 0){  
773 - rs.put("status", ResponseCode.ERROR);  
774 - }  
775 - else{  
776 - // 按发车时间排序  
777 - Collections.sort(list, new ScheduleComparator.FCSJ());  
778 -  
779 - // 以第一个实际发车/待发时间为起点,调整间隔  
780 - sch = list.get(0);  
781 - Long st = sch.getFcsjActualTime()==null?sch.getDfsjT():sch.getFcsjActualTime()  
782 - ,plus = space * 60 * 1000L;  
783 -  
784 - for(int i = 1; i < size; i ++){  
785 - st += plus;  
786 - sch = list.get(i);  
787 - sch.setDfsjAll(st);  
788 - //重新计算终点时间  
789 - sch.calcEndTime();  
790 -  
791 - dayOfSchedule.save(sch);  
792 -  
793 - updateList.add(sch);  
794 - next=dayOfSchedule.next(sch);  
795 - if(next.getQdzName().equals(sch.getZdzName())){  
796 - next.setQdzArrDateJH(sch.getZdsj());  
797 - updateList.add(next);  
798 - }  
799 - }  
800 -  
801 -  
802 - rs.put("status", ResponseCode.SUCCESS);  
803 - rs.put("ts", updateList);  
804 - }  
805 -  
806 - } catch (Exception e) {  
807 - logger.error("", e);  
808 - rs.put("status", ResponseCode.ERROR);  
809 - }  
810 - return rs;  
811 - }  
812 -  
813 - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");  
814 -  
815 - @Override  
816 - public Map<String, Object> schInfoFineTune(Map<String, String> map) {  
817 - Map<String, Object> rs = new HashMap<>();  
818 - List<ScheduleRealInfo> ts = new ArrayList<>();  
819 - try {  
820 - Long id = Long.parseLong(map.get("id"));  
821 - //班次类型  
822 - //String bcType = map.get("bcType");  
823 - //车辆自编号  
824 - //String clZbh = map.get("clZbh");  
825 - //计划发车时间  
826 - //String fcsj = map.get("fcsj");  
827 - //实际发车时间  
828 - String fcsjActual = map.get("fcsjActual");  
829 -  
830 - //实际终点时间  
831 - String zdsjActual = map.get("zdsjActual");  
832 - //备注  
833 - String remarks = map.get("remarks");  
834 -  
835 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
836 - if(null != sch){  
837 -// //驾驶员  
838 -// if(StringUtils.isNotBlank(map.get("jsy"))){  
839 -// String[] jsy = map.get("jsy").split("/");  
840 -// sch.setjGh(jsy[0]);  
841 -// sch.setjName(jsy[1]);  
842 -// }  
843 -  
844 - //售票员  
845 -// if(StringUtils.isNotBlank(map.get("spy"))){  
846 -// String[] spy = map.get("spy").split("/");  
847 -// sch.setsGh(spy[0]);  
848 -// sch.setsName(spy[1]);  
849 -// }  
850 -  
851 - //sch.setBcType(bcType);  
852 - //sch.setClZbh(clZbh);  
853 - //sch.setFcsjAll(fcsj);  
854 -  
855 - if(StringUtils.isNotBlank(fcsjActual)){  
856 - LineConfig config = lineConfigData.get(sch.getXlBm());  
857 - long t=0L;  
858 - //小于线路开始运营时间,则默认跨过24点  
859 - if(fcsjActual.compareTo(config.getStartOpt()) < 0)  
860 - t=fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME)+fcsjActual);  
861 - else  
862 - t=fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+fcsjActual);  
863 -  
864 - //调整实发  
865 - if(!fcsjActual.equals(sch.getFcsjActual()))  
866 - sch.setFcsjActualAll(t);  
867 - }  
868 - else{  
869 - //撤销实发  
870 - if(sch.getFcsjActual() != null)  
871 - revokeRealOutgo(sch.getId());  
872 - }  
873 -  
874 - //实达时间  
875 - if(StringUtils.isNotBlank(zdsjActual)){  
876 - if(!zdsjActual.equals(sch.getZdsjActual())){  
877 - //调整实达  
878 - sch.setZdsjActualAll(zdsjActual);  
879 - //下一班次起点到达时间  
880 - ScheduleRealInfo next = dayOfSchedule.next(sch);  
881 - if(null != next){  
882 - next.setQdzArrDateSJ(zdsjActual);  
883 - ts.add(next);  
884 - }  
885 -  
886 - //重新计算车辆执行班次  
887 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
888 - }  
889 - }  
890 - else {  
891 - /*if(sch.getZdsjActual() != null){  
892 - //将对应的到离站数据标记为不可信  
893 - List<ArrivalEntity> list = ArrivalData_GPS.findByNbbm(sch.getClZbh());  
894 - for(ArrivalEntity arr : list){  
895 - if(arr.getInOut() == 0  
896 - && arr.getUpDown() == Integer.parseInt(sch.getXlDir())  
897 - && arr.getStopNo().equals(sch.getZdzCode())  
898 - && Math.abs(arr.getTs() - sch.getZdsjActualTime()) < 1000 * 60){  
899 - arr.setEnable(false);  
900 - break;  
901 - }  
902 - }  
903 - }*/  
904 -  
905 - //清除实达时间  
906 - sch.clearZdsjActual();  
907 - //清除下一班次起点到达时间  
908 - ScheduleRealInfo next = dayOfSchedule.next(sch);  
909 - if(null != next){  
910 - next.setQdzArrDateSJ(null);  
911 - ts.add(next);  
912 - }  
913 - }  
914 -  
915 - sch.setRemarks(remarks);  
916 - }  
917 -  
918 - //班次状态  
919 - sch.calcStatus();  
920 - dayOfSchedule.save(sch);  
921 - //页面需要更新的班次信息  
922 - ts.add(sch);  
923 -  
924 - rs.put("status", ResponseCode.SUCCESS);  
925 - rs.put("ts", ts);  
926 - } catch (Exception e) {  
927 - logger.error("", e);  
928 - rs.put("status", ResponseCode.ERROR);  
929 - }  
930 - return rs;  
931 - }  
932 -  
933 - @Override  
934 - public Map<String, Object> outgoAdjustAll(String params) {  
935 - Map<String, Object> rs = new HashMap<>();  
936 - try{  
937 - JSONArray jsonArray = JSONArray.parseArray(params);  
938 -  
939 - ScheduleRealInfo schedule = null;  
940 - JSONObject jsonObj;  
941 - String dfsj;  
942 - for(int i = 0; i < jsonArray.size(); i ++){  
943 - jsonObj = jsonArray.getJSONObject(i);  
944 - dfsj = jsonObj.getString("t");  
945 - schedule = dayOfSchedule.get(jsonObj.getLong("id"));  
946 - //设置待发时间  
947 - schedule.setDfsjAll(dfsj);  
948 -  
949 - dayOfSchedule.save(schedule);  
950 - }  
951 -  
952 - rs.put("status", ResponseCode.SUCCESS);  
953 - //将更新的最后一个班次返回  
954 - rs.put("t", schedule);  
955 - }catch(Exception e){  
956 - logger.error("", e);  
957 - rs.put("status", ResponseCode.ERROR);  
958 - }  
959 - return rs;  
960 - }  
961 -  
962 - @Override  
963 - public Map<String, Object> findRouteByLine(String lineCode) {  
964 - Map<String, Object> map = new HashMap<>();  
965 - //上行  
966 - Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode);  
967 - map.put("line.id_eq", lineId);  
968 - map.put("directions_eq", 0);  
969 - List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map);  
970 -  
971 - //下行  
972 - map.put("directions_eq", 1);  
973 - List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map);  
974 -  
975 - Map<String, Object> rs = new HashMap<>();  
976 -  
977 - String upVectors = "", vec;  
978 - //拼接上行路段  
979 - for(Map<String, Object> temp : upList){  
980 - vec = temp.get("sectionBsectionVector").toString();  
981 - upVectors += vec.subSequence(11, vec.length() - 2) + " ";  
982 - }  
983 -  
984 - //拼接下行路段  
985 - String downVectors = "";  
986 - for(Map<String, Object> temp : downList){//LINESTRING(  
987 - vec = temp.get("sectionBsectionVector").toString();  
988 - downVectors += vec.subSequence(11, vec.length() - 2) + " ";  
989 - }  
990 -  
991 -  
992 - rs.put("up", upVectors);  
993 - //上行gcj  
994 - rs.put("up_gcj", BdToGcjString(upVectors));  
995 - rs.put("down", downVectors);  
996 - //下行gcj  
997 - rs.put("down_gcj", BdToGcjString(downVectors));  
998 - rs.put("lineId", lineId);  
999 -  
1000 - return rs;  
1001 - }  
1002 -  
1003 - /**  
1004 - *  
1005 - * @Title: BdToGcjString  
1006 - * @Description: TODO(将百度路由字符串 转 成GCJ 字符串)  
1007 - * @param @param bdStr  
1008 - * @throws  
1009 - */  
1010 - public String BdToGcjString(String bdStr){  
1011 - String[] array = bdStr.split(",")  
1012 - ,subArray;  
1013 - if(array.length == 0 || bdStr.length() < 2)  
1014 - return "";  
1015 -  
1016 - String gcjStr = "";  
1017 - TransGPS.Location location;  
1018 - for(String crd : array){  
1019 - subArray = crd.split(" ");  
1020 - if(subArray.length != 2)  
1021 - continue;  
1022 - location = TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1])));  
1023 -  
1024 - gcjStr += location.getLng() + " " + location.getLat() + ",";  
1025 - } 2118 + public List<ScheduleRealInfo> exportWaybillQp(String clZbh, String date, String line) {
  2119 + // TODO Auto-generated method stub
  2120 + ReportUtils ee = new ReportUtils();
  2121 + ReportRelatedUtils rru = new ReportRelatedUtils();
  2122 + List<Iterator<?>> list = new ArrayList<Iterator<?>>();
  2123 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill2( clZbh,date,line);
  2124 + List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
1026 2125
1027 - return gcjStr.substring(0, gcjStr.length() - 1);  
1028 - }  
1029 - public List<Map<String, String>> findLine(String line) {  
1030 - List<Line> listLine = lineRepository.findLine("%"+line+"%");  
1031 - List<Map<String,String>> list = new ArrayList<Map<String,String>>();  
1032 - Map<String,String> map;  
1033 - for(Line temp:listLine){  
1034 - if(temp != null){  
1035 - String xlName = temp.getName();  
1036 - if(xlName.indexOf(line) != -1){  
1037 - map = new HashMap<String, String>();  
1038 - map.put("id", temp.getLineCode());  
1039 - map.put("text", xlName);  
1040 - list.add(map);  
1041 - }  
1042 - }  
1043 - }  
1044 - return list;  
1045 - }  
1046 -  
1047 - public List<Map<String, String>> findLpName(String lpName) {  
1048 - List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%"+lpName+"%");  
1049 - List<Map<String,String>> list = new ArrayList<Map<String,String>>();  
1050 - Map<String,String> map;  
1051 - for(GuideboardInfo temp:listLpName){  
1052 - if(temp != null){  
1053 - String lp = temp.getLpName();  
1054 - if(lp.indexOf(lpName) != -1){  
1055 - map = new HashMap<String, String>();  
1056 - map.put("id", lp);  
1057 - map.put("text", lp);  
1058 - list.add(map);  
1059 - }  
1060 - }  
1061 - }  
1062 - return list;  
1063 - }  
1064 -  
1065 - @Override  
1066 - public Map<String, Object> findKMBC2(String jName, String clZbh,String date) {  
1067 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh , date);  
1068 -  
1069 DecimalFormat format = new DecimalFormat("0.00"); 2126 DecimalFormat format = new DecimalFormat("0.00");
1070 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); 2127 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1071 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); 2128 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
1072 int jhbc = 0,cjbc = 0,ljbc = 0; 2129 int jhbc = 0,cjbc = 0,ljbc = 0;
1073 - double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0; 2130 + double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0,jcclc=0;
1074 float addMileage = 0l,remMileage = 0l; 2131 float addMileage = 0l,remMileage = 0l;
1075 - String j_Name="";  
1076 - Map<String,Object> map = new HashMap<String, Object>();  
1077 - for(ScheduleRealInfo scheduleRealInfo : list){ 2132 +
  2133 + Map<String,Object> map;
  2134 + for(ScheduleRealInfo scheduleRealInfo : scheduleRealInfos){
1078 if(scheduleRealInfo != null){ 2135 if(scheduleRealInfo != null){
1079 - j_Name=scheduleRealInfo.getjName();  
1080 - //计划里程(主任务过滤掉临加班次),  
1081 - //烂班里程(主任务烂班),  
1082 - //临加里程(主任务临加),  
1083 - //计划班次,烂班班次,增加班次  
1084 - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();  
1085 - if(scheduleRealInfo.isSflj()){  
1086 - addMileage += tempJhlc;  
1087 - ljbc++;  
1088 - }else{  
1089 - jhlc += tempJhlc;  
1090 - jhbc++;  
1091 - if(scheduleRealInfo.getStatus() == -1){  
1092 - remMileage += tempJhlc;  
1093 - cjbc++;  
1094 - }  
1095 - }  
1096 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
1097 - //计算营运里程,空驶里程  
1098 - if(childTaskPlans.isEmpty()){  
1099 - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")  
1100 - || scheduleRealInfo.getBcType().equals("venting")){  
1101 - ksgl += tempJhlc; 2136 + //计算计划里程(主任务过滤掉临加班次),烂班里程,临加里程,计划班次,烂班班次,增加班次
  2137 + //计划里程(主任务过滤掉临加班次),
  2138 + //烂班里程(主任务烂班),
  2139 + //临加里程(主任务临加),
  2140 + //计划班次,烂班班次,增加班次
  2141 + tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  2142 + if(scheduleRealInfo.isSflj()){
  2143 + ljbc++;
1102 }else{ 2144 }else{
1103 - yygl += tempJhlc;  
1104 - }  
1105 - }else{  
1106 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
1107 - while(it.hasNext()){  
1108 - ChildTaskPlan childTaskPlan = it.next();  
1109 - if(childTaskPlan.getMileageType().equals("empty")){  
1110 - ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); 2145 + jhlc += tempJhlc;
  2146 + jhbc++;
  2147 + if(scheduleRealInfo.getStatus() == -1){
  2148 + remMileage += tempJhlc;
  2149 + cjbc++;
  2150 + }
  2151 + }
  2152 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  2153 + //计算营运里程,空驶里程
  2154 + if(childTaskPlans.isEmpty()){
  2155 + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  2156 + || scheduleRealInfo.getBcType().equals("venting")){
  2157 + ksgl += tempJhlc;
1111 }else{ 2158 }else{
1112 - yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); 2159 + yygl += tempJhlc;
  2160 + }
  2161 + }else{
  2162 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  2163 + while(it.hasNext()){
  2164 + ChildTaskPlan childTaskPlan = it.next();
  2165 + if(childTaskPlan.getMileageType().equals("empty")){
  2166 + if(scheduleRealInfo.isSflj()){
  2167 + addMileage += tempJhlc;
  2168 + }
  2169 + ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  2170 + }else{
  2171 + if(scheduleRealInfo.isSflj()){
  2172 + addMileage += tempJhlc;
  2173 + }
  2174 + yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  2175 + }
1113 } 2176 }
1114 } 2177 }
1115 - } 2178 +
  2179 + if(!(scheduleRealInfo.getBcType().equals("in")||scheduleRealInfo.getBcType().equals("out"))){
  2180 + map = new HashMap<String, Object>();
  2181 + try {
  2182 + map = rru.getMapValue(scheduleRealInfo);
  2183 + String zdsj = scheduleRealInfo.getZdsj();
  2184 + String zdsjActual = scheduleRealInfo.getZdsjActual();
  2185 + if(zdsj != null && zdsjActual != null &&
  2186 + !zdsj.equals(zdsjActual)){
  2187 + if(zdsj.compareTo(zdsjActual) > 0){
  2188 + map.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  2189 + map.put("slow", "");
  2190 + } else {
  2191 + map.put("fast", "");
  2192 + map.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  2193 + }
  2194 + } else {
  2195 + map.put("fast", "");
  2196 + map.put("slow", "");
  2197 + }
  2198 + listMap.add(map);
  2199 + } catch (Exception e) {
  2200 + e.printStackTrace();
  2201 + }
  2202 + }
1116 } 2203 }
1117 } 2204 }
1118 - map.put("j_name", j_Name);  
1119 - map.put("jhlc", format.format(jhlc));  
1120 - map.put("remMileage", format.format(remMileage));  
1121 - map.put("addMileage", format.format(addMileage));  
1122 - map.put("yygl", format.format(yygl)); 2205 +
  2206 + //计算里程和班次数,并放入Map里
  2207 + map = new HashMap<String, Object>();
  2208 + map.put("jhlc", format.format(jhlc+jcclc));
  2209 + map.put("yygljh", format.format(jhlc));
  2210 + map.put("ssgl", format.format(remMileage));
1123 map.put("ksgl", format.format(ksgl)); 2211 map.put("ksgl", format.format(ksgl));
1124 - map.put("realMileage", format.format(yygl+ksgl)); 2212 + map.put("yyglsj", format.format(yygl+remMileage));
1125 map.put("jhbc", jhbc); 2213 map.put("jhbc", jhbc);
1126 - map.put("cjbc", cjbc);  
1127 - map.put("ljbc", ljbc); 2214 + map.put("jcclc", jcclc);
  2215 +
  2216 + map.put("ljgl", format.format(addMileage));
  2217 + map.put("ssbc", cjbc);
  2218 + map.put("ysgl", format.format(yygl));
1128 map.put("sjbc", jhbc-cjbc+ljbc); 2219 map.put("sjbc", jhbc-cjbc+ljbc);
1129 - return map; 2220 + map.put("zgl", format.format(yygl+remMileage+ksgl+jcclc));
  2221 + map.put("ljbc", ljbc);
  2222 + String zdp="",zwdp="",wdp="";
  2223 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
  2224 + List<DutyEmployee> listDtuy= dutyEmployeeService.getDutyEmployee(line, date+"00:00", date+"23:59");
  2225 + try {
  2226 + Long fcsj1=sdf.parse(date+" 03:00").getTime();
  2227 + Long fcsj2=sdf.parse(date+" 11:00").getTime();
  2228 + Long fcsj3=sdf.parse(date+" 22:00").getTime();
  2229 + for(int i=0;i<list.size();i++){
  2230 + DutyEmployee t=listDtuy.get(i);
  2231 + Long ts=t.getTs();
  2232 + if(ts>fcsj1&&ts<fcsj2){
  2233 + if(zdp.indexOf(t.getuName())==-1){
  2234 + zdp +=t.getuName()+",";
  2235 +
  2236 + }
  2237 + }else if(ts>fcsj2 && ts<fcsj3){
  2238 + if(zwdp.indexOf(t.getuName())==-1){
  2239 + zwdp +=t.getuName()+",";
  2240 + }
  2241 + }else{
  2242 + if(wdp.indexOf(t.getuName())==-1){
  2243 + wdp +=t.getuName()+",";
  2244 + }
  2245 + }
  2246 + }
  2247 + }catch (ParseException e) {
  2248 + // TODO Auto-generated catch block
  2249 + e.printStackTrace();
  2250 + }
  2251 + map.put("zdp", zdp);
  2252 + map.put("zwdp", zwdp);
  2253 + map.put("wdp", wdp);
  2254 + String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";
  2255 + list.add(listMap.iterator());
  2256 + ee.excelReplace(list, new Object[] { scheduleRealInfos.get(0),map }, path+"mould/waybill_qingpu.xls",
  2257 + path+"export/" + date+"-"+clZbh+"-行车路单.xls");
  2258 +
  2259 + return scheduleRealInfos;
1130 } 2260 }
1131 -  
1132 - 2261 +
1133 @Override 2262 @Override
1134 - public Map<String, Object> findKMBC(String jName, String clZbh,  
1135 - String lpName,String date) {  
1136 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date); 2263 + public Map<String, Object> findKMBCQp(String clZbh, String date, String line) {
  2264 + // TODO Auto-generated method stub
  2265 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill2( clZbh,date,line);
1137 DecimalFormat format = new DecimalFormat("0.00"); 2266 DecimalFormat format = new DecimalFormat("0.00");
1138 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); 2267 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1139 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); 2268 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
@@ -1149,7 +2278,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1149,7 +2278,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1149 //计划班次,烂班班次,增加班次 2278 //计划班次,烂班班次,增加班次
1150 tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc(); 2279 tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1151 if(scheduleRealInfo.isSflj()){ 2280 if(scheduleRealInfo.isSflj()){
1152 - addMileage += tempJhlc;  
1153 ljbc++; 2281 ljbc++;
1154 }else{ 2282 }else{
1155 if( !(scheduleRealInfo.getBcType().equals("in") 2283 if( !(scheduleRealInfo.getBcType().equals("in")
@@ -1170,12 +2298,16 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1170,12 +2298,16 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1170 scheduleRealInfo.getBcType().equals("out")){ 2298 scheduleRealInfo.getBcType().equals("out")){
1171 jcclc +=tempJhlc; 2299 jcclc +=tempJhlc;
1172 } 2300 }
  2301 +
1173 //主任务 放空班次属于营运 2302 //主任务 放空班次属于营运
1174 // else if(scheduleRealInfo.getBcType().equals("venting")){ 2303 // else if(scheduleRealInfo.getBcType().equals("venting")){
1175 // ksgl += tempJhlc; 2304 // ksgl += tempJhlc;
1176 // } 2305 // }
1177 else{ 2306 else{
1178 if(scheduleRealInfo.getStatus() != -1){ 2307 if(scheduleRealInfo.getStatus() != -1){
  2308 + if(scheduleRealInfo.isSflj()){
  2309 + addMileage += tempJhlc;
  2310 + }
1179 yygl += tempJhlc; 2311 yygl += tempJhlc;
1180 } 2312 }
1181 } 2313 }
@@ -1187,6 +2319,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1187,6 +2319,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1187 if(childTaskPlan.isDestroy()){ 2319 if(childTaskPlan.isDestroy()){
1188 remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); 2320 remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1189 }else{ 2321 }else{
  2322 + if(scheduleRealInfo.isSflj()){
  2323 + addMileage += tempJhlc;
  2324 + }
1190 ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); 2325 ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1191 } 2326 }
1192 }else{ 2327 }else{
@@ -1194,6 +2329,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1194,6 +2329,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1194 remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); 2329 remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1195 // cjbc++; 2330 // cjbc++;
1196 }else{ 2331 }else{
  2332 + if(scheduleRealInfo.isSflj()){
  2333 + addMileage += tempJhlc;
  2334 + }
1197 yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage(); 2335 yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1198 } 2336 }
1199 } 2337 }
@@ -1201,59 +2339,33 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1201,59 +2339,33 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1201 } 2339 }
1202 } 2340 }
1203 } 2341 }
1204 - map.put("jhlc", format.format(jhlc));  
1205 - map.put("remMileage", format.format(remMileage));  
1206 - map.put("addMileage", format.format(addMileage));  
1207 - map.put("yygl", format.format(yygl)); 2342 + map.put("jhlc", format.format(jhlc+jcclc));
  2343 + map.put("yygljh", format.format(jhlc));
  2344 + map.put("ssgl", format.format(remMileage));
1208 map.put("ksgl", format.format(ksgl)); 2345 map.put("ksgl", format.format(ksgl));
1209 - map.put("realMileage", format.format(yygl+ksgl+jcclc)); 2346 + map.put("yyglsj", format.format(yygl+remMileage));
1210 map.put("jhbc", jhbc); 2347 map.put("jhbc", jhbc);
1211 - map.put("cjbc", cjbc);  
1212 - map.put("ljbc", ljbc);  
1213 - map.put("sjbc", jhbc-cjbc+ljbc);  
1214 map.put("jcclc", jcclc); 2348 map.put("jcclc", jcclc);
1215 - map.put("zkslc", format.format(ksgl+jcclc)); 2349 +
  2350 + map.put("ljgl", format.format(addMileage));
  2351 + map.put("ssbc", cjbc);
  2352 + map.put("ysgl", format.format(yygl));
  2353 + map.put("sjbc", jhbc-cjbc+ljbc);
  2354 + map.put("zgl", format.format(yygl+remMileage+ksgl+jcclc));
  2355 + map.put("ljbc", ljbc);
  2356 +
1216 return map; 2357 return map;
1217 } 2358 }
1218 2359
1219 @Override 2360 @Override
1220 - public List<Map<String, Object>> account(String line, String date,  
1221 - String code,String xlName) {  
1222 - List<Object[]> lsitObj = scheduleRealInfoRepository.account(line,date,code);  
1223 - List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();  
1224 - Map<String,Object> map;  
1225 - for(Object[] obj : lsitObj){  
1226 - if(obj != null){  
1227 - map = new HashMap<String,Object>();  
1228 - map.put("xlName", xlName);  
1229 - map.put("clZbh", obj[3]);  
1230 - map.put("company", obj[0]);  
1231 - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1]+"")).toUpperCase());  
1232 - map.put("requestTime", obj[2]);  
1233 - listMap.add(map);  
1234 - }  
1235 - }  
1236 - return listMap;  
1237 - }  
1238 -  
1239 - @Override  
1240 - public List<ScheduleRealInfo> correctForm(String line, String startDate,  
1241 - String endDate, String lpName, String code) {  
1242 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.correctForm(line,startDate,endDate,lpName,code);  
1243 - return list;  
1244 - }  
1245 -  
1246 - @Override  
1247 - public List<ScheduleRealInfo> queryListWaybill(String jName, String clZbh,  
1248 - String lpName,String date,String type) { 2361 + public List<ScheduleRealInfo> queryListWaybillQp(String clZbh, String date, String line) {
  2362 + // TODO Auto-generated method stub
1249 List <ScheduleRealInfo> list=null; 2363 List <ScheduleRealInfo> list=null;
1250 - if(type.equals("qp")){  
1251 - list= scheduleRealInfoRepository.queryListWaybill2(jName,clZbh,lpName,date);  
1252 - }else{  
1253 - list= scheduleRealInfoRepository.queryListWaybill(jName,clZbh,lpName,date);  
1254 - }  
1255 - for (int i = 0; i < list.size(); i++) {  
1256 - ScheduleRealInfo s=list.get(i); 2364 + list= scheduleRealInfoRepository.queryListWaybill2(clZbh,date,line);
  2365 + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  2366 + for (int i = 0; i < list.size(); i++) {
  2367 + ScheduleRealInfo s=list.get(i);
  2368 + if(!(s.getBcType().equals("in")||s.getBcType().equals("out"))){
1257 String remarks=""; 2369 String remarks="";
1258 if(s.getRemarks()!=null){ 2370 if(s.getRemarks()!=null){
1259 remarks +=s.getRemarks(); 2371 remarks +=s.getRemarks();
@@ -1270,627 +2382,211 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1270,627 +2382,211 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1270 } 2382 }
1271 } 2383 }
1272 s.setRemarks(remarks); 2384 s.setRemarks(remarks);
  2385 + newList.add(s);
1273 } 2386 }
1274 2387
1275 - return list;  
1276 - }  
1277 -  
1278 - @Override  
1279 - public Map<String, Object> removeChildTask(Long taskId) {  
1280 - Map<String, Object> rs = new HashMap<>();  
1281 - ChildTaskPlan chTask = cTaskPlanRepository.findOne(taskId);  
1282 -  
1283 - ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId());  
1284 - try {  
1285 -  
1286 - sch.getcTasks().remove(chTask);  
1287 - scheduleRealInfoRepository.save(sch);  
1288 - rs.put("status", ResponseCode.SUCCESS);  
1289 - } catch (Exception e) {  
1290 - logger.error("", e);  
1291 - rs.put("status", ResponseCode.ERROR);  
1292 - }  
1293 - return rs;  
1294 } 2388 }
1295 2389
  2390 + return newList;
  2391 + }
  2392 +
1296 @Override 2393 @Override
1297 - public List<Map<String, Object>> statisticsDaily(String line, String date,  
1298 - String xlName) {  
1299 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);  
1300 - List<Map<String,Object>> lMap = new ArrayList<Map<String,Object>>();  
1301 - DecimalFormat format = new DecimalFormat("0.00");  
1302 - double jhlc = 0, tempJhlc = 0,childMileage = 0;  
1303 - float sjgl = 0f,ssgl = 0f,ssgl_lz = 0f,ssgl_dm = 0f,ssgl_gz = 0f,ssgl_jf = 0f,ssgl_zs = 0f,ssgl_qr = 0f  
1304 - ,ssgl_qc = 0f,ssgl_kx = 0f,ssgl_qh = 0f,ssgl_yw = 0f,ssgl_other = 0f,ljgl = 0f;  
1305 - //班次  
1306 - int sj_0 = 6*60+31,sj_1 = 8*60+30,sj_2 = 16*60+1,sj_3 = 18*60;  
1307 - int jhbc = 0,jhbc_m = 0,jhbc_a = 0;  
1308 - int sjbc = 0,sjbc_m = 0,sjbc_a = 0;  
1309 - int ljbc = 0,ljbc_m = 0,ljbc_a = 0;  
1310 - int fzbc = 0,fzbc_m = 0,fzbc_a = 0;  
1311 - int dtbc = 0,dtbc_m = 0,dtbc_a = 0;  
1312 - int djg = 0,djg_m = 0,djg_a = 0,djg_time = 0;  
1313 - Map<String,Object> map = new HashMap<String, Object>();  
1314 - for(ScheduleRealInfo scheduleRealInfo: list){  
1315 - if(scheduleRealInfo != null){ 2394 + public Map<String, Object> MapById(Long id) {
  2395 + // TODO Auto-generated method stub
  2396 + Map<String, Object> map=new HashMap<String, Object>();
  2397 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
  2398 + ScheduleRealInfo s=scheduleRealInfoRepository.findOne(id);
  2399 + String xlbm=s.getXlBm();
  2400 + String fcrq=s.getScheduleDateStr();
  2401 +
1316 2402
1317 - if(!(scheduleRealInfo.getBcType().equals("in")  
1318 - ||scheduleRealInfo.getBcType().equals("out")) ){  
1319 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
1320 - //计算实际里程,少驶里程,计划里程=实际里程+少驶里程  
1321 - if(childTaskPlans.isEmpty()){  
1322 - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();  
1323 - //临加公里  
1324 - if(scheduleRealInfo.isSflj()){  
1325 - ljgl += tempJhlc;  
1326 - }else{  
1327 - jhlc += tempJhlc;  
1328 - }  
1329 - if(scheduleRealInfo.getStatus() == 2){  
1330 - sjgl += tempJhlc;  
1331 - }else if(scheduleRealInfo.getStatus() == -1){  
1332 - ssgl += tempJhlc;  
1333 - if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("路阻") != -1){  
1334 - ssgl_lz += tempJhlc;  
1335 - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("吊慢") != -1){  
1336 - ssgl_dm += tempJhlc;  
1337 - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("故障") != -1){  
1338 - ssgl_gz += tempJhlc;  
1339 - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("纠纷") != -1){  
1340 - ssgl_jf += tempJhlc;  
1341 - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("肇事") != -1){  
1342 - ssgl_zs += tempJhlc;  
1343 - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("缺人") != -1){  
1344 - ssgl_qr += tempJhlc;  
1345 - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("缺车") != -1){  
1346 - ssgl_qc += tempJhlc;  
1347 - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("客稀") != -1){  
1348 - ssgl_kx += tempJhlc;  
1349 - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("气候") != -1){  
1350 - ssgl_qh += tempJhlc;  
1351 - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("援外") != -1){  
1352 - ssgl_yw += tempJhlc;  
1353 - }else{  
1354 - ssgl_other += tempJhlc; 2403 + map.put("xlName", s.getXlName());
  2404 + map.put("clZbh", s.getClZbh());
  2405 + map.put("fcsjActual", s.getFcsjActual());
  2406 + map.put("zdzName", s.getZdzName());
  2407 + map.put("scheduleDate", s.getScheduleDateStr());
  2408 + String zdp="",zwdp="",wdp="";
  2409 + String zdpT="",zwdpT="",wdpT="";
  2410 +
  2411 + List<DutyEmployee> list= dutyEmployeeService.getDutyEmployee(xlbm, fcrq+"00:00", fcrq+"23:59");
  2412 + try {
  2413 + Long fcsj1=sdf.parse(fcrq+" 03:00").getTime();
  2414 + Long fcsj2=sdf.parse(fcrq+" 11:00").getTime();
  2415 + Long fcsj3=sdf.parse(fcrq+" 22:00").getTime();
  2416 + for(int i=0;i<list.size();i++){
  2417 + DutyEmployee t=list.get(i);
  2418 + Long ts=t.getTs();
  2419 + if(ts>fcsj1&&ts<fcsj2){
  2420 + if(zdp.indexOf(t.getuName())==-1){
  2421 + if(!(zdp.length()>0)){
  2422 + zdpT =t.getuName()+"...";
  2423 + }
  2424 + zdp +=t.getuName()+",";
  2425 +
1355 } 2426 }
1356 - }  
1357 - }else{  
1358 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
1359 - while(it.hasNext()){  
1360 - ChildTaskPlan childTaskPlan = it.next();  
1361 - childMileage = childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();  
1362 - jhlc += childMileage;  
1363 - if(childTaskPlan.isDestroy()){  
1364 - ssgl += childMileage;  
1365 - if(childTaskPlan.getDestroyReason().equals("路阻")){  
1366 - ssgl_lz += childTaskPlan.getMileage();  
1367 - }else if(childTaskPlan.getDestroyReason().equals("吊慢")){  
1368 - ssgl_dm += childTaskPlan.getMileage();  
1369 - }else if(childTaskPlan.getDestroyReason().equals("故障")){  
1370 - ssgl_gz += childTaskPlan.getMileage();  
1371 - }else if(childTaskPlan.getDestroyReason().equals("纠纷")){  
1372 - ssgl_jf += childTaskPlan.getMileage();  
1373 - }else if(childTaskPlan.getDestroyReason().equals("肇事")){  
1374 - ssgl_zs += childTaskPlan.getMileage();  
1375 - }else if(childTaskPlan.getDestroyReason().equals("缺人")){  
1376 - ssgl_qr += childTaskPlan.getMileage();  
1377 - }else if(childTaskPlan.getDestroyReason().equals("缺车")){  
1378 - ssgl_qc += childTaskPlan.getMileage();  
1379 - }else if(childTaskPlan.getDestroyReason().equals("客稀")){  
1380 - ssgl_kx += childTaskPlan.getMileage();  
1381 - }else if(childTaskPlan.getDestroyReason().equals("气候")){  
1382 - ssgl_qh += childTaskPlan.getMileage();  
1383 - }else if(childTaskPlan.getDestroyReason().equals("援外")){  
1384 - ssgl_yw += childTaskPlan.getMileage();  
1385 - }else{  
1386 - ssgl_other += childTaskPlan.getMileage(); 2427 + }else if(ts>fcsj2 && ts<fcsj3){
  2428 + if(zwdp.indexOf(t.getuName())==-1){
  2429 + if(!(zwdp.length()>0)){
  2430 + zwdpT =t.getuName()+"...";
1387 } 2431 }
1388 - }else{  
1389 - sjgl += childMileage; 2432 + zwdp +=t.getuName()+",";
1390 } 2433 }
1391 - }  
1392 - }  
1393 -  
1394 - //班次  
1395 - jhbc++;  
1396 - String[] fcsj = scheduleRealInfo.getFcsj().split(":");  
1397 - String[] fcsjActual = (scheduleRealInfo.getFcsjActual()==null?"0:00":scheduleRealInfo.getFcsjActual()).split(":");  
1398 - if((Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) > sj_0 && (Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) < sj_1){  
1399 - jhbc_m++;  
1400 - }else if((Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) > sj_2 && (Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) < sj_3){  
1401 - jhbc_a++;  
1402 - }  
1403 - if(scheduleRealInfo.getStatus() == 2){  
1404 - sjbc++;  
1405 - if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_1){  
1406 - sjbc_m++;  
1407 - }else if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_3){  
1408 - sjbc_a++;  
1409 - }  
1410 - }  
1411 - if(scheduleRealInfo.isSflj()){  
1412 - ljbc++;  
1413 - if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_1){  
1414 - ljbc_m++;  
1415 - }else if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_3){  
1416 - ljbc_a++;  
1417 - }  
1418 - }  
1419 - if(scheduleRealInfo.getBcType().equals("venting")){  
1420 - fzbc++;  
1421 - if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_1){  
1422 - fzbc_m++;  
1423 - }else if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_3){  
1424 - fzbc_a++;  
1425 - }  
1426 - }  
1427 - }  
1428 - }  
1429 - }  
1430 - map.put("xlName", xlName);  
1431 - map.put("jhlc", format.format(jhlc));  
1432 - map.put("sjgl", format.format(sjgl));  
1433 - map.put("ssgl", format.format(ssgl));  
1434 - map.put("ssgl_lz", ssgl_lz==0?0:format.format(ssgl_lz));  
1435 - map.put("ssgl_dm", ssgl_dm==0?0:format.format(ssgl_dm));  
1436 - map.put("ssgl_gz", ssgl_gz==0?0:format.format(ssgl_gz));  
1437 - map.put("ssgl_jf", ssgl_jf==0?0:format.format(ssgl_jf));  
1438 - map.put("ssgl_zs", ssgl_zs==0?0:format.format(ssgl_zs));  
1439 - map.put("ssgl_qr", ssgl_qr==0?0:format.format(ssgl_qr));  
1440 - map.put("ssgl_qc", ssgl_qc==0?0:format.format(ssgl_qc));  
1441 - map.put("ssgl_kx", ssgl_kx==0?0:format.format(ssgl_kx));  
1442 - map.put("ssgl_qh", ssgl_qh==0?0:format.format(ssgl_qh));  
1443 - map.put("ssgl_yw", ssgl_yw==0?0:format.format(ssgl_yw));  
1444 - map.put("ssgl_other", ssgl_other==0?0:format.format(ssgl_other));  
1445 - map.put("ljgl", ljgl==0?0:format.format(ljgl));  
1446 - map.put("jhbc", jhbc);  
1447 - map.put("jhbc_m", jhbc_m);  
1448 - map.put("jhbc_a", jhbc_a);  
1449 - map.put("sjbc", sjbc);  
1450 - map.put("sjbc_m", sjbc_m);  
1451 - map.put("sjbc_a", sjbc_a);  
1452 - map.put("ljbc", ljbc);  
1453 - map.put("ljbc_m", ljbc_m);  
1454 - map.put("ljbc_a", ljbc_a);  
1455 - map.put("fzbc", fzbc);  
1456 - map.put("fzbc_m", fzbc_m);  
1457 - map.put("fzbc_a", fzbc_a);  
1458 - map.put("dtbc", dtbc);  
1459 - map.put("dtbc_m", dtbc_m);  
1460 - map.put("dtbc_a", dtbc_a);  
1461 - map.put("djg", djg);  
1462 - map.put("djg_m", djg_m);  
1463 - map.put("djg_a", djg_a);  
1464 - map.put("djg_time", djg_time);  
1465 - lMap.add(map);  
1466 - return lMap;  
1467 - }  
1468 -  
1469 - @Override  
1470 - public Map<String,Object> scheduleDaily(String line, String date) {  
1471 - Map<String,String> tempMap = null;  
1472 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);  
1473 - Map<String, Object> map = new HashMap<String, Object>();  
1474 - Double jhlc = 0.00;  
1475 - Float sjgl = 0f,ssgl = 0f,ssgl_lz = 0f,ssgl_dm = 0f,ssgl_gz = 0f,ssgl_jf = 0f,ssgl_zs = 0f,ssgl_qr = 0f  
1476 - ,ssgl_qc = 0f,ssgl_kx = 0f,ssgl_qh = 0f,ssgl_yw = 0f,ssgl_other = 0f,ljgl = 0f;  
1477 - int jhbc = 0;  
1478 - for(ScheduleRealInfo scheduleRealInfo:scheduleRealInfos){  
1479 - if(scheduleRealInfo != null){  
1480 - //计算里程(包括子任务)  
1481 - jhlc += scheduleRealInfo.getJhlc();  
1482 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
1483 - if(!childTaskPlans.isEmpty()){  
1484 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
1485 - while(it.hasNext()){  
1486 - ChildTaskPlan childTaskPlan = it.next();  
1487 - //是否烂班,烂班就是少驶  
1488 - if(!childTaskPlan.isDestroy()){  
1489 - sjgl += childTaskPlan.getMileage();  
1490 }else{ 2434 }else{
1491 - ssgl += childTaskPlan.getMileage();  
1492 - if(childTaskPlan.getDestroyReason().equals("路阻")){  
1493 - ssgl_lz += childTaskPlan.getMileage();  
1494 - }else if(childTaskPlan.getDestroyReason().equals("吊慢")){  
1495 - ssgl_dm += childTaskPlan.getMileage();  
1496 - }else if(childTaskPlan.getDestroyReason().equals("故障")){  
1497 - ssgl_gz += childTaskPlan.getMileage();  
1498 - }else if(childTaskPlan.getDestroyReason().equals("纠纷")){  
1499 - ssgl_jf += childTaskPlan.getMileage();  
1500 - }else if(childTaskPlan.getDestroyReason().equals("肇事")){  
1501 - ssgl_zs += childTaskPlan.getMileage();  
1502 - }else if(childTaskPlan.getDestroyReason().equals("缺人")){  
1503 - ssgl_qr += childTaskPlan.getMileage();  
1504 - }else if(childTaskPlan.getDestroyReason().equals("缺车")){  
1505 - ssgl_qc += childTaskPlan.getMileage();  
1506 - }else if(childTaskPlan.getDestroyReason().equals("客稀")){  
1507 - ssgl_kx += childTaskPlan.getMileage();  
1508 - }else if(childTaskPlan.getDestroyReason().equals("气候")){  
1509 - ssgl_qh += childTaskPlan.getMileage();  
1510 - }else if(childTaskPlan.getDestroyReason().equals("援外")){  
1511 - ssgl_yw += childTaskPlan.getMileage();  
1512 - }else{  
1513 - ssgl_other += childTaskPlan.getMileage(); 2435 + if(wdp.indexOf(t.getuName())==-1){
  2436 + if(!(wdp.length()>0)){
  2437 + wdpT =t.getuName()+"...";
  2438 + }
  2439 + wdp +=t.getuName()+",";
1514 } 2440 }
1515 } 2441 }
1516 - //临加公里  
1517 - if(childTaskPlan.getType1().equals("临加")){  
1518 - ljgl += childTaskPlan.getMileage();  
1519 - }  
1520 } 2442 }
  2443 + } catch (ParseException e) {
  2444 + // TODO Auto-generated catch block
  2445 + e.printStackTrace();
1521 } 2446 }
1522 - //班次  
1523 - scheduleRealInfo.getFcsjT();  
1524 - scheduleRealInfo.getFcsjActualTime();  
1525 - }  
1526 - }  
1527 - map.put("jhlc", jhlc);  
1528 - map.put("sjgl", sjgl);  
1529 - map.put("ssgl", ssgl);  
1530 - map.put("ssgl_lz", ssgl_lz);  
1531 - map.put("ssgl_dm", ssgl_dm);  
1532 - map.put("ssgl_gz", ssgl_gz);  
1533 - map.put("ssgl_jf", ssgl_jf);  
1534 - map.put("ssgl_zs", ssgl_zs);  
1535 - map.put("ssgl_qr", ssgl_qr);  
1536 - map.put("ssgl_qc", ssgl_qc);  
1537 - map.put("ssgl_kx", ssgl_kx);  
1538 - map.put("ssgl_qh", ssgl_qh);  
1539 - map.put("ssgl_yw", ssgl_yw);  
1540 - map.put("ssgl_other", ssgl_other);  
1541 - map.put("ljgl", ljgl);  
1542 -  
1543 - map.put("jhbc", scheduleRealInfos.size());  
1544 - return null; 2447 + map.put("zdp", zdp);
  2448 + map.put("zwdp", zwdp);
  2449 + map.put("wdp", wdp);
  2450 + map.put("zdpT", zdpT);
  2451 + map.put("zwdpT", zwdpT);
  2452 + map.put("wdpT", wdpT);
  2453 + return map;
1545 } 2454 }
1546 2455
1547 @Override 2456 @Override
1548 - public int countByLineCodeAndDate(String xlBm, String schDate) {  
1549 - return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate);  
1550 - }  
1551 -  
1552 - @Override  
1553 - public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) {  
1554 - return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate);  
1555 - }  
1556 -  
1557 - @Override  
1558 - public void deleteByLineCodeAndDate(String xlBm, String schDate) {  
1559 - scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate);  
1560 - }  
1561 -  
1562 - @Override  
1563 - public Long getMaxId() {  
1564 - return scheduleRealInfoRepository.getMaxId();  
1565 - }  
1566 -  
1567 - @Override  
1568 - public List<ScheduleRealInfo> realScheduleList(String line, String date) {  
1569 - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.queryUserInfo(line, date);  
1570 - List<ScheduleRealInfo> listTotal = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);  
1571 - for(ScheduleRealInfo info:listInfo){  
1572 - for(ScheduleRealInfo total:listTotal){  
1573 - if(info.getjGh().equals(total.getjGh()) && info.getLpName().equals(total.getLpName()) && info.getClZbh().equals(total.getClZbh())){ 2457 + public List<Map<String, Object>> scheduleDailyQp(String line, String date) {
  2458 + // TODO Auto-generated method stub
  2459 + List<Map<String, Object>> list=new ArrayList<Map<String, Object>>();
  2460 + List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.scheduleDailyQp(line, date);
  2461 + Map<String, Object> map=null;
  2462 + String lp="lp";
  2463 + String jgh="jgh";
  2464 + String clzbh="clzbh";
  2465 + int bcs=0;
  2466 + String thclzbh="";
  2467 + String sgh="sgh";
  2468 + for(int i=0;i<scheduleRealInfos.size();i++){
  2469 + ScheduleRealInfo scheduleRealInfo=scheduleRealInfos.get(i);
  2470 + if(scheduleRealInfo.getLpName().equals(lp)){
  2471 + bcs++;
  2472 + String fcsj=scheduleRealInfo.getFcsj();
  2473 +
  2474 + if(!clzbh.equals(scheduleRealInfo.getClZbh())){
  2475 + clzbh=scheduleRealInfo.getClZbh();
  2476 + if(thclzbh==""){
  2477 + thclzbh +=scheduleRealInfo.getClZbh()+",";
  2478 + }else{
  2479 + thclzbh +=scheduleRealInfo.getClZbh();
  2480 + }
  2481 + map.put("thclzbh", thclzbh);
  2482 + }
  2483 +
  2484 + if(!jgh.equals(scheduleRealInfo.getjGh())){
  2485 + jgh=scheduleRealInfo.getjGh();
  2486 + if(map.get("jjb2")!=null){
  2487 + map.put("jjb3", scheduleRealInfo.getjGh()+"/"+
  2488 + scheduleRealInfo.getFcsjActual());
  2489 +
  2490 + }else{
  2491 + map.put("jjb2", scheduleRealInfo.getjGh()+"/"+
  2492 + scheduleRealInfo.getFcsjActual());
  2493 + }
1574 2494
1575 } 2495 }
1576 - }  
1577 - }  
1578 - return scheduleRealInfoRepository.scheduleByDateAndLine(line, date);  
1579 - }  
1580 -  
1581 -  
1582 - public List<Map<String,Object>> yesterdayDataList(String line,String date) {  
1583 - //前一天日期  
1584 -// String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1));  
1585 -// String date = "2016-09-20";  
1586 - List<Map<String,Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date);  
1587 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);  
1588 - for(ScheduleRealInfo scheduleRealInfo:list){  
1589 - if(scheduleRealInfo != null){  
1590 - for(int i=0;i<yesterdayDataList.size();i++){  
1591 - if(scheduleRealInfo.getXlBm().equals(yesterdayDataList.get(i).get("xlBm")) && scheduleRealInfo.getClZbh().equals(yesterdayDataList.get(i).get("clZbh"))  
1592 - && scheduleRealInfo.getjGh().equals(yesterdayDataList.get(i).get("jGh"))){  
1593 - //根据线路代码获取公司  
1594 - Line li = lineRepository.findByLineCode(scheduleRealInfo.getXlBm());  
1595 - yesterdayDataList.get(i).put("company", li.getCompany());  
1596 - yesterdayDataList.get(i).put("bCompany", li.getBrancheCompany());  
1597 - //计算总公里  
1598 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
1599 - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班  
1600 - if(childTaskPlans.isEmpty()){  
1601 - if(scheduleRealInfo.getStatus() == 2){  
1602 - yesterdayDataList.get(i).put("totalKilometers", scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc()+(double)(yesterdayDataList.get(i).get("totalKilometers")==null?0.0:yesterdayDataList.get(i).get("totalKilometers"))); 2496 +
  2497 + if(scheduleRealInfo.getsGh()!=null){
  2498 + if(!scheduleRealInfo.getsGh().equals(sgh)){
  2499 + sgh=scheduleRealInfo.getsGh();
  2500 + if(map.get("sjb1")!=null){
  2501 + if(map.get("sjb2")!=null){
  2502 + map.put("sjb3", scheduleRealInfo.getsGh()+"/"+
  2503 + scheduleRealInfo.getFcsjActual());
  2504 + }else{
  2505 + map.put("sjb2", scheduleRealInfo.getsGh()+"/"+
  2506 + scheduleRealInfo.getFcsjActual());
1603 } 2507 }
1604 }else{ 2508 }else{
1605 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
1606 - while(it.hasNext()){  
1607 - ChildTaskPlan childTaskPlan = it.next();  
1608 - if(!childTaskPlan.isDestroy()){  
1609 - yesterdayDataList.get(i).put("totalKilometers", childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage()+(double)(yesterdayDataList.get(i).get("totalKilometers")==null?0.0:yesterdayDataList.get(i).get("totalKilometers")));  
1610 - }  
1611 - } 2509 + map.put("sjb1", scheduleRealInfo.getsGh()+"/"+
  2510 + scheduleRealInfo.getFcsjActual());
1612 } 2511 }
1613 - } 2512 + }
1614 } 2513 }
1615 - }  
1616 - }  
1617 - //增加顺序号  
1618 - for(int i=0;i<yesterdayDataList.size();i++){  
1619 - if(i == 0){  
1620 - yesterdayDataList.get(i).put("seqNumber", 1);  
1621 - }else{  
1622 - if(yesterdayDataList.get(i-1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))){  
1623 - yesterdayDataList.get(i).put("seqNumber", 1+(int)yesterdayDataList.get(i-1).get("seqNumber")); 2514 + if(scheduleRealInfo.getFcsjActual()!=null){
  2515 + String fcsjs[]=fcsj.split(":");
  2516 + String fcsjActuals[]=scheduleRealInfo.getFcsjActual().split(":");
  2517 + int a=Integer.parseInt(fcsjActuals[0])*60+Integer.parseInt(fcsjActuals[1]);
  2518 + int b=Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1]);
  2519 + map.put("cz"+bcs, b-a);
1624 }else{ 2520 }else{
1625 - yesterdayDataList.get(i).put("seqNumber", 1); 2521 + map.put("cz"+bcs, "无");
1626 } 2522 }
1627 - }  
1628 - }  
1629 - return yesterdayDataList;  
1630 - }  
1631 -  
1632 - /**  
1633 - * 批量调整人车  
1634 - */  
1635 - @Override  
1636 - public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs) {  
1637 - Map<String, Object> rs = new HashMap<>();  
1638 - Set<ScheduleRealInfo> set = new HashSet<>();  
1639 -  
1640 - ScheduleRealInfo sch;  
1641 -  
1642 - for(ChangePersonCar cpc : cpcs){  
1643 -  
1644 - sch = dayOfSchedule.get(cpc.getSchId());  
1645 - if(sch==null)  
1646 - continue;  
1647 -  
1648 - if(StringUtils.isNotEmpty(cpc.getJsy())){  
1649 - //换驾驶员  
1650 - persoChange(sch, cpc.getJsy().split("/")[0]);  
1651 - }  
1652 -  
1653 - //换售票员  
1654 - if(StringUtils.isNotEmpty(cpc.getSpy())){  
1655 - persoChangeSPY(sch, cpc.getSpy().split("/")[0]);  
1656 - }  
1657 -  
1658 - //换车  
1659 - if(StringUtils.isNotEmpty(cpc.getClZbh())){  
1660 - set.add(sch);  
1661 - set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh()));  
1662 - }  
1663 -  
1664 - }  
1665 - rs.put("ts", set);  
1666 - rs.put("status", ResponseCode.SUCCESS);  
1667 - return rs;  
1668 - }  
1669 -  
1670 - /**  
1671 - *  
1672 - * @Title: persoChange  
1673 - * @Description: TODO(班次换驾驶员)  
1674 - */  
1675 - public void persoChange(ScheduleRealInfo sch, String jGh){  
1676 - if(sch.getjGh().equals(jGh))  
1677 - return;  
1678 - String jName = BasicData.allPerson.get(jGh);  
1679 - if(StringUtils.isNotEmpty(jName)){  
1680 - sch.setjGh(jGh);  
1681 - sch.setjName(jName);  
1682 - }  
1683 - }  
1684 -  
1685 - /**  
1686 - *  
1687 - * @Title: persoChange  
1688 - * @Description: TODO(班次换售票员)  
1689 - */  
1690 - public void persoChangeSPY(ScheduleRealInfo sch, String sGh){  
1691 - if(sch.getsGh().equals(sGh))  
1692 - return;  
1693 - String sName = BasicData.allPerson.get(sGh);  
1694 - if(StringUtils.isNotEmpty(sName)){  
1695 - sch.setsGh(sGh);  
1696 - sch.setsName(sName);  
1697 - }  
1698 - }  
1699 -  
1700 - /**  
1701 - * 批量待发调整  
1702 - */  
1703 - @Override  
1704 - public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) {  
1705 - Map<String, Object> rs = new HashMap<>()  
1706 - ,tempMap = new HashMap<>();  
1707 - List<ScheduleRealInfo> list = new ArrayList<>();  
1708 -  
1709 - ScheduleRealInfo sch,next;  
1710 - for(DfsjChange dc : dfsjcs){  
1711 - if(StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))  
1712 - continue;  
1713 -  
1714 - /*sch = dayOfSchedule.get(dc.getSchId());  
1715 - if(sch==null)  
1716 - continue;  
1717 -  
1718 - sch.setDfsjAll(dc.getNew_dfsj());  
1719 - //重新计算终点时间  
1720 - sch.calcEndTime();  
1721 - list.add(sch);*/  
1722 - tempMap = outgoAdjust(dc.getSchId(),"", dc.getNew_dfsj());  
1723 -  
1724 - if(tempMap.get("status").equals(ResponseCode.SUCCESS)){  
1725 - list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts"));  
1726 - }  
1727 - //next=dayOfSchedule.next(sch);  
1728 - /*if(next.getQdzName().equals(sch.getZdzName())){  
1729 - next.setQdzArrDateJH(sch.getZdsj());  
1730 - list.add(next);  
1731 - }*/  
1732 - }  
1733 -  
1734 - rs.put("status", ResponseCode.SUCCESS);  
1735 - rs.put("ts", list);  
1736 - return rs;  
1737 - }  
1738 -  
1739 -  
1740 - @Override  
1741 - public Map<String, Object> findKMBC1(String jName, String clZbh,  
1742 - String date, String enddate) {  
1743 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate);  
1744 - DecimalFormat format = new DecimalFormat("0.00");  
1745 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
1746 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
1747 - int jhbc = 0,cjbc = 0,ljbc = 0;  
1748 - double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0;  
1749 - float addMileage = 0l,remMileage = 0l;  
1750 - Map<String,Object> map = new HashMap<String, Object>();  
1751 - for(ScheduleRealInfo scheduleRealInfo : list){  
1752 - if(scheduleRealInfo != null){  
1753 - //计划里程(主任务过滤掉临加班次),  
1754 - //烂班里程(主任务烂班),  
1755 - //临加里程(主任务临加),  
1756 - //计划班次,烂班班次,增加班次  
1757 - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();  
1758 - if(scheduleRealInfo.isSflj()){  
1759 - addMileage += tempJhlc;  
1760 - ljbc++; 2523 + map.put("lp", scheduleRealInfo.getLpName());
  2524 + map.put("dd"+bcs, scheduleRealInfo.getZdsjActual());
  2525 + map.put("kc"+bcs, scheduleRealInfo.getFcsjActual());
  2526 +
  2527 + if(i<scheduleRealInfos.size()-1){
  2528 + if(!scheduleRealInfos.get(i+1).getLpName().equals
  2529 + (scheduleRealInfos.get(i).getLpName())){
  2530 + list.add(map);
  2531 + lp="lp";
  2532 + jgh="jgh";
  2533 + clzbh="clzbh";
  2534 + bcs=0;
  2535 + thclzbh="";
  2536 + sgh="sgh";
  2537 + }
1761 }else{ 2538 }else{
1762 - jhlc += tempJhlc;  
1763 - jhbc++;  
1764 - if(scheduleRealInfo.getStatus() == -1){  
1765 - remMileage += tempJhlc;  
1766 - cjbc++;  
1767 - } 2539 + list.add(map);
1768 } 2540 }
1769 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
1770 - //计算营运里程,空驶里程  
1771 - if(childTaskPlans.isEmpty()){  
1772 - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")  
1773 - || scheduleRealInfo.getBcType().equals("venting")){  
1774 - ksgl += tempJhlc;  
1775 - }else{  
1776 - yygl += tempJhlc;  
1777 - } 2541 + }else{
  2542 + bcs=1;
  2543 + map=new HashMap<String,Object>();
  2544 + lp=scheduleRealInfo.getLpName();
  2545 + jgh=scheduleRealInfo.getjGh();
  2546 + clzbh=scheduleRealInfo.getClZbh();
  2547 + if(scheduleRealInfo.getsGh()!=null){
  2548 + sgh=scheduleRealInfo.getsGh();
  2549 + map.put("sjb1",scheduleRealInfo.getsGh()+"/"+
  2550 + scheduleRealInfo.getFcsjActual());
  2551 + }
  2552 + String fcsj=scheduleRealInfo.getFcsj();
  2553 + scheduleRealInfo.getFcsjActual();
  2554 + map.put("jjb1", jgh+"/"+scheduleRealInfo.getFcsjActual());
  2555 + map.put("cccl", clzbh);
  2556 +
  2557 + if(scheduleRealInfo.getFcsjActual()!=null){
  2558 + String fcsjs[]=fcsj.split(":");
  2559 + String fcsjActuals[]=scheduleRealInfo.getFcsjActual().split(":");
  2560 + int a=Integer.parseInt(fcsjActuals[0])*60+Integer.parseInt(fcsjActuals[1]);
  2561 + int b=Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1]);
  2562 + map.put("cz"+bcs, b-a);
1778 }else{ 2563 }else{
1779 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
1780 - while(it.hasNext()){  
1781 - ChildTaskPlan childTaskPlan = it.next();  
1782 - if(childTaskPlan.getMileageType().equals("empty")){  
1783 - ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();  
1784 - }else{  
1785 - yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();  
1786 - } 2564 + map.put("cz"+bcs, "无");
  2565 + }
  2566 +
  2567 +
  2568 + map.put("lp", scheduleRealInfo.getLpName());
  2569 + map.put("dd"+bcs, scheduleRealInfo.getZdsjActual());
  2570 + map.put("kc"+bcs, scheduleRealInfo.getFcsjActual());
  2571 +
  2572 + if(i<scheduleRealInfos.size()-1){
  2573 + if(!scheduleRealInfos.get(i+1).getLpName().equals
  2574 + (scheduleRealInfos.get(i).getLpName())){
  2575 + list.add(map);
  2576 + lp="lp";
  2577 + jgh="jgh";
  2578 + clzbh="clzbh";
  2579 + bcs=0;
  2580 + thclzbh="";
  2581 + sgh="sgh";
1787 } 2582 }
  2583 + }else{
  2584 + list.add(map);
1788 } 2585 }
1789 } 2586 }
  2587 +
1790 } 2588 }
1791 - map.put("jhlc", format.format(jhlc));  
1792 - map.put("remMileage", format.format(remMileage));  
1793 - map.put("addMileage", format.format(addMileage));  
1794 - map.put("yygl", format.format(yygl));  
1795 - map.put("ksgl", format.format(ksgl));  
1796 - map.put("realMileage", format.format(yygl+ksgl));  
1797 - map.put("jhbc", jhbc);  
1798 - map.put("cjbc", cjbc);  
1799 - map.put("ljbc", ljbc);  
1800 - map.put("sjbc", jhbc-cjbc+ljbc);  
1801 - return map;  
1802 - }  
1803 -  
1804 - /**  
1805 - * 调整班次类型  
1806 - * @param id  
1807 - * @param bcType  
1808 - * @param remarks  
1809 - * @return  
1810 - */  
1811 - @Override  
1812 - public Map<String, Object> changeBcType(Long id, String bcType, String remarks) {  
1813 - Map<String, Object> rs = new HashMap<>();  
1814 -  
1815 - try {  
1816 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
1817 - if(sch != null){  
1818 - sch.setBcType(bcType);  
1819 - sch.addRemarks(remarks);  
1820 - //有时间记录一下相关变更数据  
1821 - rs.put("status", ResponseCode.SUCCESS);  
1822 - rs.put("t", sch);  
1823 - }  
1824 - } catch (Exception e) {  
1825 - logger.error("", e);  
1826 - rs.put("status", ResponseCode.ERROR);  
1827 - }  
1828 -  
1829 - return rs;  
1830 - }  
1831 -  
1832 - @Override  
1833 - public Map<String, Object> historySave(ScheduleRealInfo sch) {  
1834 - Map<String, Object> rs = new HashMap<>();  
1835 - rs.put("status", ResponseCode.ERROR);  
1836 -  
1837 - ScheduleRealInfo oldSch = super.findById(sch.getId());  
1838 - //修改车辆  
1839 - if(!oldSch.getClZbh().equals(sch.getClZbh())){  
1840 - Set<String> allCar=BasicData.deviceId2NbbmMap.values();  
1841 - if(!allCar.contains(sch.getClZbh())){  
1842 - rs.put("msg", "无效的车辆自编号");  
1843 - return rs;  
1844 - }  
1845 - else  
1846 - oldSch.setClZbh(sch.getClZbh());  
1847 - }  
1848 -  
1849 - //修改驾驶员  
1850 - if(!oldSch.getjGh().equals(sch.getjGh())){  
1851 - Map<String, String> allPer = BasicData.allPerson;  
1852 - if(!allPer.containsKey(sch.getjGh())){  
1853 - rs.put("msg", "无效的驾驶员");  
1854 - return rs;  
1855 - }  
1856 - else{  
1857 - oldSch.setjGh(sch.getjGh());  
1858 - oldSch.setjName(allPer.get(oldSch.getjGh()));  
1859 - }  
1860 - }  
1861 -  
1862 - //修改售票员  
1863 -/* if(!oldSch.getsGh().equals(sch.getsGh())){  
1864 - Map<String, String> allPer = BasicData.allPerson;  
1865 -  
1866 - if(StringUtils.isNotEmpty(sch.getsGh())){  
1867 - if(!allPer.containsKey(sch.getsGh())){  
1868 - rs.put("msg", "无效的售票员");  
1869 - return rs;  
1870 - }  
1871 - }  
1872 - oldSch.setsGh(sch.getsGh());  
1873 - oldSch.setsName(allPer.get(oldSch.getsGh()));  
1874 - }*/  
1875 -  
1876 - //待发时间  
1877 - oldSch.setDfsj(sch.getDfsj());  
1878 - //实发时间  
1879 - oldSch.setFcsjActual(sch.getFcsjActual());  
1880 - //实际终点  
1881 - oldSch.setZdsjActual(sch.getZdsjActual());  
1882 - //备注  
1883 - oldSch.setRemarks(sch.getRemarks());  
1884 -  
1885 - scheduleRealInfoRepository.save(oldSch);  
1886 - rs.put("status", ResponseCode.SUCCESS);  
1887 - return rs;  
1888 - }  
1889 -  
1890 - @Override  
1891 - public List<Map<String, Object>> yesterdayDataList(String line) {  
1892 - // TODO Auto-generated method stub  
1893 - return null; 2589 + return list;
1894 } 2590 }
1895 2591
1896 -} 2592 +}
1897 \ No newline at end of file 2593 \ No newline at end of file