Commit 0dcb03d27189b2f589670f27ca8f7119c49ce534

Authored by 王通
1 parent 3b396a03

1.解决临加或者历史维护添加的班次路牌为空的情况

src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
1 -package com.bsth.service.realcontrol.impl;  
2 -  
3 -import java.io.*;  
4 -import java.lang.reflect.Field;  
5 -import java.math.BigDecimal;  
6 -import java.net.HttpURLConnection;  
7 -import java.net.MalformedURLException;  
8 -import java.net.URL;  
9 -import java.net.URLEncoder;  
10 -import java.sql.ResultSet;  
11 -import java.sql.SQLException;  
12 -import java.text.DecimalFormat;  
13 -import java.text.ParseException;  
14 -import java.text.SimpleDateFormat;  
15 -import java.util.ArrayList;  
16 -import java.util.Calendar;  
17 -import java.util.Collection;  
18 -import java.util.Collections;  
19 -import java.util.Comparator;  
20 -import java.util.Date;  
21 -import java.util.GregorianCalendar;  
22 -import java.util.HashMap;  
23 -import java.util.HashSet;  
24 -import java.util.Iterator;  
25 -import java.util.List;  
26 -import java.util.Map;  
27 -import java.util.Queue;  
28 -import java.util.Set;  
29 -import java.util.concurrent.*;  
30 -import java.util.regex.Pattern;  
31 -  
32 -import org.apache.commons.io.IOUtils;  
33 -import org.apache.commons.lang3.StringEscapeUtils;  
34 -import org.apache.commons.lang3.StringUtils;  
35 -import org.joda.time.format.DateTimeFormat;  
36 -import org.joda.time.format.DateTimeFormatter;  
37 -import org.slf4j.Logger;  
38 -import org.slf4j.LoggerFactory;  
39 -import org.springframework.beans.factory.DisposableBean;  
40 -import org.springframework.beans.factory.InitializingBean;  
41 -import org.springframework.beans.factory.annotation.Autowired;  
42 -import org.springframework.jdbc.core.BeanPropertyRowMapper;  
43 -import org.springframework.jdbc.core.JdbcTemplate;  
44 -import org.springframework.jdbc.core.RowMapper;  
45 -import org.springframework.stereotype.Service;  
46 -import org.springframework.transaction.annotation.Transactional;  
47 -  
48 -import com.alibaba.fastjson.JSON;  
49 -import com.alibaba.fastjson.JSONArray;  
50 -import com.alibaba.fastjson.JSONObject;  
51 -import com.bsth.common.Constants;  
52 -import com.bsth.common.ResponseCode;  
53 -import com.bsth.controller.realcontrol.dto.ChangePersonCar;  
54 -import com.bsth.controller.realcontrol.dto.DfsjChange;  
55 -import com.bsth.controller.realcontrol.dto.LpData;  
56 -import com.bsth.data.BasicData;  
57 -import com.bsth.data.LineConfigData;  
58 -import com.bsth.data.Station2ParkBuffer;  
59 -import com.bsth.data.schedule.DayOfSchedule;  
60 -import com.bsth.data.schedule.SchAttrCalculator;  
61 -import com.bsth.data.schedule.ScheduleComparator;  
62 -import com.bsth.data.schedule.edit_logs.FormLogger;  
63 -import com.bsth.data.schedule.edit_logs.ScheduleModifyLogger;  
64 -import com.bsth.data.schedule.edit_logs.loggers.AfterwardsLogger;  
65 -import com.bsth.data.schedule.edit_logs.loggers.FcxxwtLogger;  
66 -import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;  
67 -import com.bsth.data.schedule.late_adjust.LateAdjustHandle;  
68 -import com.bsth.data.utils.CustomStringUtils;  
69 -import com.bsth.entity.CarDevice;  
70 -import com.bsth.entity.Cars;  
71 -import com.bsth.entity.Line;  
72 -import com.bsth.entity.Personnel;  
73 -import com.bsth.entity.calc.CalcInterval;  
74 -import com.bsth.entity.calc.CalcStatistics;  
75 -import com.bsth.entity.oil.Dlb;  
76 -import com.bsth.entity.oil.Qlb;  
77 -import com.bsth.entity.oil.Ylb;  
78 -import com.bsth.entity.oil.Ylxxb;  
79 -import com.bsth.entity.realcontrol.ChildTaskPlan;  
80 -import com.bsth.entity.realcontrol.LineConfig;  
81 -import com.bsth.entity.realcontrol.ScheduleRealInfo;  
82 -import com.bsth.entity.realcontrol.SvgAttribute;  
83 -import com.bsth.entity.report.MileageReport;  
84 -import com.bsth.entity.report.RepairReport;  
85 -import com.bsth.entity.report.ScheduleCorrectionReport;  
86 -import com.bsth.entity.schedule.CarConfigInfo;  
87 -import com.bsth.entity.schedule.EmployeeConfigInfo;  
88 -import com.bsth.entity.schedule.GuideboardInfo;  
89 -import com.bsth.entity.schedule.SchedulePlanInfo;  
90 -import com.bsth.entity.sys.Dictionary;  
91 -import com.bsth.entity.sys.DutyEmployee;  
92 -import com.bsth.entity.sys.SysUser;  
93 -import com.bsth.repository.CarDeviceRepository;  
94 -import com.bsth.repository.CarsRepository;  
95 -import com.bsth.repository.LineRepository;  
96 -import com.bsth.repository.RepairReportRepository;  
97 -import com.bsth.repository.calc.CalcIntervalRepository;  
98 -import com.bsth.repository.oil.DlbRepository;  
99 -import com.bsth.repository.oil.QlbRepository;  
100 -import com.bsth.repository.oil.YlbRepository;  
101 -import com.bsth.repository.oil.YlxxbRepository;  
102 -import com.bsth.repository.realcontrol.ChildTaskPlanRepository;  
103 -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;  
104 -import com.bsth.repository.realcontrol.SvgAttributeRepository;  
105 -import com.bsth.repository.schedule.CarConfigInfoRepository;  
106 -import com.bsth.repository.schedule.EmployeeConfigInfoRepository;  
107 -import com.bsth.repository.schedule.GuideboardInfoRepository;  
108 -import com.bsth.security.util.SecurityUtils;  
109 -import com.bsth.service.LineService;  
110 -import com.bsth.service.SectionRouteService;  
111 -import com.bsth.service.calc.CalcWaybillService;  
112 -import com.bsth.service.directive.DirectiveService;  
113 -import com.bsth.service.impl.BaseServiceImpl;  
114 -import com.bsth.service.realcontrol.ScheduleRealInfoService;  
115 -import com.bsth.service.report.CulateMileageService;  
116 -import com.bsth.service.report.ReportService;  
117 -import com.bsth.service.schedule.SchedulePlanInfoService;  
118 -import com.bsth.service.sys.DictionaryService;  
119 -import com.bsth.service.sys.DutyEmployeeService;  
120 -import com.bsth.util.Arith;  
121 -import com.bsth.util.ComparableChild;  
122 -import com.bsth.util.ComparableLp;  
123 -import com.bsth.util.ComparableReal;  
124 -import com.bsth.util.ConfigUtil;  
125 -import com.bsth.util.DateUtils;  
126 -import com.bsth.util.ReportRelatedUtils;  
127 -import com.bsth.util.ReportUtils;  
128 -import com.bsth.util.TimeUtils;  
129 -import com.bsth.util.TransGPS;  
130 -import com.bsth.websocket.handler.SendUtils;  
131 -import com.fasterxml.jackson.databind.ObjectMapper;  
132 -import com.github.stuxuhai.jpinyin.PinyinException;  
133 -import com.github.stuxuhai.jpinyin.PinyinFormat;  
134 -import com.github.stuxuhai.jpinyin.PinyinHelper;  
135 -import com.google.common.base.Splitter;  
136 -import com.google.common.collect.Lists;  
137 -  
138 -import javax.ws.rs.HEAD;  
139 -  
140 -@Service  
141 -public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long>  
142 - implements ScheduleRealInfoService, InitializingBean, DisposableBean {  
143 - @Autowired  
144 - JdbcTemplate jdbcTemplate;  
145 - @Autowired  
146 - ScheduleRealInfoRepository scheduleRealInfoRepository;  
147 -  
148 - @Autowired  
149 - EmployeeConfigInfoRepository employeeConfigInfoRepository;  
150 -  
151 - @Autowired  
152 - CarConfigInfoRepository carConfigInfoRepository;  
153 -  
154 - @Autowired  
155 - SectionRouteService sectionRouteService;  
156 -  
157 - @Autowired  
158 - CulateMileageService culateMieageService;  
159 -  
160 - @Autowired  
161 - DictionaryService dictionaryService;  
162 -  
163 - @Autowired  
164 - CalcWaybillService calcWaybillService;  
165 -  
166 - @Autowired  
167 - CalcIntervalRepository calcIntervalRepository;  
168 - /*@Autowired  
169 - BorrowCenter borrowCenter;*/  
170 -  
171 - @Autowired  
172 - LineRepository lineRepository;  
173 - @Autowired  
174 - LineService lineService;  
175 - @Autowired  
176 - GuideboardInfoRepository guideboardInfoRepository;  
177 -  
178 - @Autowired  
179 - ChildTaskPlanRepository cTaskPlanRepository;  
180 -  
181 - @Autowired  
182 - SendUtils sendUtils;  
183 -  
184 - @Autowired  
185 - DayOfSchedule dayOfSchedule;  
186 -  
187 - @Autowired  
188 - SchAttrCalculator schAttrCalculator;  
189 -  
190 - @Autowired  
191 - LineConfigData lineConfigData;  
192 -  
193 - @Autowired  
194 - DutyEmployeeService dutyEmployeeService;  
195 -  
196 - @Autowired  
197 - YlxxbRepository ylxxbRepository;  
198 -  
199 - @Autowired  
200 - YlbRepository ylbRepository;  
201 -  
202 - @Autowired  
203 - DlbRepository dlbRepository;  
204 -  
205 - @Autowired  
206 - QlbRepository qlbRepository;  
207 -  
208 - @Autowired  
209 - ReportService reposrService;  
210 -  
211 - @Autowired  
212 - CulateMileageService culateService;  
213 -  
214 - @Autowired  
215 - FormLogger schModifyLog;  
216 -  
217 - @Autowired  
218 - DirectiveService directiveService;  
219 -  
220 - @Autowired  
221 - CarDeviceRepository carDeviceRepository;  
222 -  
223 - @Autowired  
224 - CarsRepository carsRepository;  
225 -  
226 - @Autowired  
227 - RepairReportRepository repairReportRepository;  
228 - Logger logger = LoggerFactory.getLogger(this.getClass());  
229 -  
230 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
231 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
232 -  
233 - public static Map<String,String> DIRMAP = new ConcurrentHashMap<>(); // dvr电话  
234 - private Queue<RepairReport> queue = new ConcurrentLinkedQueue<>();  
235 -  
236 - private ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {  
237 -  
238 - @Override  
239 - public Thread newThread(Runnable r) {  
240 - // TODO Auto-generated method stub  
241 - Thread t = new Thread(r);  
242 - t.setName("RepairReportReissuer");  
243 -  
244 - return t;  
245 - }  
246 - });  
247 -  
248 -  
249 -  
250 - private static Map<String, String> report2repair = new HashMap<String, String>();  
251 -  
252 - static {  
253 - report2repair.put("9101", "9109");  
254 - report2repair.put("9102", "9102");  
255 - report2repair.put("9103", "9103");  
256 - report2repair.put("9104", "9104");  
257 - report2repair.put("9109", "9109");  
258 - report2repair.put("9201", "9201");  
259 - report2repair.put("9202", "9202");  
260 - report2repair.put("9203", "9203");  
261 - report2repair.put("9204", "9204");  
262 - report2repair.put("9209", "9209");  
263 - report2repair.put("9301", "9301");  
264 - report2repair.put("9302", "9302");  
265 - report2repair.put("9303", "9303");  
266 - report2repair.put("9304", "9304");  
267 - report2repair.put("9305", "9305");  
268 - report2repair.put("9306", "9306");  
269 - report2repair.put("9309", "9309");  
270 - }  
271 -  
272 -  
273 - /**  
274 - * 校验人车 和 班次的公司和分公司归属  
275 - *  
276 - * @param schId  
277 - * @param jGh  
278 - * @param sGh  
279 - * @param nbbm  
280 - * @return -2 跨营运公司,校验不过  
281 - * -1 跨分公司,二次确认  
282 - * 1 校验通过  
283 - */  
284 - @Override  
285 - public Map<String, Object> checkPCFgsAscription(Long schId, String jGh, String sGh, String nbbm) {  
286 - Map<String, Object> rs = new HashMap<>();  
287 - try {  
288 - rs.put("status", ResponseCode.SUCCESS);  
289 - rs.put("checkStatus", -2);  
290 -  
291 - String msg = null;  
292 - ScheduleRealInfo sch = dayOfSchedule.get(schId);  
293 - String gsbm = sch.getGsBm(), fgsbm = sch.getFgsBm();  
294 -  
295 - if (nbbm != null && !carExist(gsbm, nbbm)) {  
296 - msg = sch.getGsName() + "没有自编号为" + "[" + nbbm + "]的车辆";  
297 - rs.put("msg", msg);  
298 - return rs;  
299 - }  
300 -  
301 - if (nbbm != null && !sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(nbbm))) {  
302 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + nbbm + "】的车辆");  
303 - return rs;  
304 - }  
305 -  
306 - if (nbbm != null && !(fgsbm + "_" + gsbm).equals(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm))) {  
307 -  
308 - String clFgsName = BasicData.businessFgsCodeNameMap.get(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm));  
309 -  
310 - msg = ("【" + nbbm + "】" + "是" + clFgsName + "的车辆!");  
311 - rs.put("msg", msg);  
312 - rs.put("checkStatus", -1);  
313 - return rs;  
314 - }  
315 -  
316 - if(null != jGh && !"/".equals(StringUtils.trim(jGh))){  
317 - Personnel jsy = BasicData.perMap.get(gsbm + "-" + jGh);  
318 -  
319 - if (null == jsy) {  
320 - msg = "【驾驶员】:" + sch.getGsName() + "暂无工号为" + "【" + jGh + "】的人员";  
321 - rs.put("msg", msg);  
322 - return rs;  
323 - }  
324 - else if (!fgsbm.equals(jsy.getBrancheCompanyCode())) {  
325 - //校验分公司  
326 - msg = ("【驾驶员】:" + jGh + "/" + jsy.getPersonnelName() + "是" + jsy.getBrancheCompany() + "的人员");  
327 - rs.put("msg", msg);  
328 - rs.put("checkStatus", -1);  
329 - return rs;  
330 - }  
331 - }  
332 -  
333 - if (null != sGh && !"/".equals(StringUtils.trim(sGh))) {  
334 - Personnel spy = BasicData.perMap.get(gsbm + "-" + sGh);  
335 - if (null == spy) {  
336 - msg = "【售票员】: " + sch.getGsName() + "暂无工号为" + "【" + sGh + "】的人员";  
337 - rs.put("msg", msg);  
338 - return rs;  
339 - }  
340 - else if (!fgsbm.equals(spy.getBrancheCompanyCode())) {  
341 - msg = ("【售票员】: " + sGh + "/" + spy.getPersonnelName() + "是" + spy.getBrancheCompany() + "的人员");  
342 - rs.put("msg", msg);  
343 - rs.put("checkStatus", -1);  
344 - return rs;  
345 - }  
346 - }  
347 -  
348 - rs.put("checkStatus", 1);  
349 - } catch (Exception e) {  
350 - logger.error("", e);  
351 - rs.put("status", ResponseCode.ERROR);  
352 - }  
353 - return rs;  
354 - }  
355 -  
356 -  
357 - /**  
358 - * 车辆是否存在  
359 - *  
360 - * @param gsbm 公司编码  
361 - * @param nbbm 车辆自编号  
362 - * @return  
363 - */  
364 - private boolean carExist(String gsbm, String nbbm) {  
365 - return BasicData.nbbm2CompanyCodeMap.containsKey(nbbm);  
366 - }  
367 -  
368 - /**  
369 - * 获取人员姓名  
370 - *  
371 - * @param gsbm 公司编码  
372 - * @param gh 人员工号  
373 - * @return  
374 - */  
375 - private String getPersonName(String gsbm, String gh) {  
376 - return BasicData.allPerson.get(gsbm + '-' + gh);  
377 - }  
378 -  
379 - @Override  
380 - public Iterable<ScheduleRealInfo> list(Map<String, Object> map) {  
381 - Iterator<ScheduleRealInfo> iterator = super.list(map).iterator();  
382 - Set<ScheduleRealInfo> set = new HashSet<>(100);  
383 -  
384 - DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");  
385 - //计算时间戳  
386 - ScheduleRealInfo sch;  
387 - while (iterator.hasNext()) {  
388 - sch = iterator.next();  
389 - //待发时间戳  
390 - sch.setDfsjT(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getDfsj()));  
391 - //实发时间戳  
392 - if (StringUtils.isNotEmpty(sch.getFcsjActual())) {  
393 - sch.setFcsjActualTime(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getFcsjActual()));  
394 - }  
395 - set.add(sch);  
396 - }  
397 - return set;  
398 - }  
399 -  
400 - @Override  
401 - public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) {  
402 - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines));  
403 -  
404 - /*Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create();  
405 -  
406 - for (String lineCode : lineList) {  
407 - mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode));  
408 - }*/  
409 - return dayOfSchedule.findByLineCodes(lineList);  
410 - }  
411 -  
412 - private final static long DAY_TIME = 1000 * 60 * 60 * 24L;  
413 -  
414 - private static int BUF_SIZE = 1024;  
415 -  
416 - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");  
417 - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");  
418 -  
419 - @Override  
420 - public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType, String opType, String userId) {  
421 - Map<String, Object> map = new HashMap<>();  
422 - try {  
423 -  
424 - ScheduleRealInfo schedule = dayOfSchedule.get(id);  
425 -  
426 - if (schedule.getStatus() > 0) {  
427 - map.put("status", ResponseCode.SUCCESS);  
428 - map.put("flag", "4008");  
429 - map.put("t", schedule);  
430 - return map;  
431 - }  
432 -  
433 - LineConfig config = lineConfigData.get(schedule.getXlBm());  
434 - //小于线路开始运营时间,则默认跨过24点  
435 - if (dfsj.compareTo(config.getStartOpt()) < 0) {  
436 - schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME));  
437 - } else {  
438 - schedule.setRealExecDate(schedule.getScheduleDateStr());  
439 - }  
440 -  
441 - //记录日志  
442 - ScheduleModifyLogger.dftz(schedule, opType, schedule.getDfsj(), dfsj, remarks, userId);  
443 -  
444 - schedule.setDfsjAll(dfsj);  
445 - schedule.setDfAuto(false);  
446 - if ("1".equals(opType))  
447 - schedule.setRemarks(remarks);  
448 -  
449 - List<ScheduleRealInfo> ts = new ArrayList<>();  
450 - ts.add(schedule);  
451 - //调整终点时间和下一个班次的应到时间  
452 - //schedule.calcEndTime();  
453 - /*ScheduleRealInfo nextSch = dayOfSchedule.nextByLp2(schedule);  
454 - if (null != nextSch) {  
455 - nextSch.setQdzArrDatejh(schedule.getZdsj());  
456 - ts.add(nextSch);  
457 - }*/  
458 -  
459 - //调整班次类型  
460 - if (StringUtils.isNotEmpty(bcType) && !bcType.equals(schedule.getBcType())) {  
461 - if ((schedule.getBcType().equals("major")  
462 - || schedule.getBcType().equals("venting"))  
463 - && bcType.equals("normal")) {  
464 - //清空备注  
465 - schedule.setRemarks("");  
466 - }  
467 - schedule.setBcType(bcType);  
468 - }  
469 -  
470 - //如果正在执行该班次  
471 - //ScheduleRealInfo exec = dayOfSchedule.executeCurr(schedule.getClZbh());  
472 - //if(exec != null && exec == schedule){  
473 - //重新计算正在执行班次  
474 - dayOfSchedule.reCalcExecPlan(schedule.getClZbh());  
475 - //}  
476 -  
477 - //重新计算是否误点  
478 - schedule.reCalcLate();  
479 - //取消应发未到标记,不再自动调整待发  
480 - //if(schedule.isLate2()){  
481 - // schedule.setLate2(false);  
482 - //LateAdjustHandle.remove(schedule);  
483 - //}  
484 -  
485 - try {  
486 - if (!schedule.getDirectiveState().equals(-1) && schedule.getStatus() == 0) {  
487 - //重新下发调度指令  
488 - directiveService.send60Dispatch(schedule.getId(), "待发@系统");  
489 - }  
490 - } catch (Exception e) {  
491 - logger.error("", e);  
492 - }  
493 -  
494 - // 持久化到数据库  
495 - dayOfSchedule.save(schedule);  
496 -  
497 - map.put("status", ResponseCode.SUCCESS);  
498 - map.put("ts", ts);  
499 - } catch (Exception e) {  
500 - logger.error("", e);  
501 - map.put("status", ResponseCode.ERROR);  
502 - }  
503 - return map;  
504 - }  
505 -  
506 - @Override  
507 - public Map<String, Object> destroy(String idsStr, String remarks, String reason, String userId) {  
508 -  
509 - Map<String, Object> map = new HashMap<>();  
510 - List<ScheduleRealInfo> rsList = new ArrayList<>();  
511 - map.put("ts", rsList);  
512 - try {  
513 - List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr));  
514 -  
515 - ScheduleRealInfo schedule = null;  
516 - for (String id : idList) {  
517 - schedule = dayOfSchedule.get(Long.parseLong(id));  
518 - if (schedule.isDestroy()) {  
519 - map.put("status", ResponseCode.ERROR);  
520 - map.put("msg", "不必要的重复烂班!");  
521 - return map;  
522 - }  
523 - //记录日志  
524 - ScheduleModifyLogger.jhlb(schedule, remarks, userId);  
525 -  
526 - schedule.setAdjustExps(reason);  
527 - schedule.destroy();  
528 - schedule.addRemarks(remarks);  
529 -  
530 - dayOfSchedule.save(schedule);  
531 - rsList.add(schedule);  
532 - }  
533 -  
534 - //重新计算当前执行班次  
535 - dayOfSchedule.reCalcExecPlan(schedule.getClZbh());  
536 -  
537 - map.put("status", ResponseCode.SUCCESS);  
538 - } catch (Exception e) {  
539 - logger.error("", e);  
540 - map.put("status", ResponseCode.ERROR);  
541 - }  
542 - return map;  
543 - }  
544 -  
545 - // 线路id获取驾驶员  
546 - @Override  
547 - public List<Map<String, String>> findDriverByLine(String lineCode) {  
548 - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);  
549 -  
550 - List<Map<String, String>> rsList = new ArrayList<>();  
551 - Map<String, String> map = null;  
552 - Personnel driver = null;  
553 - String code = null;  
554 -  
555 - for (EmployeeConfigInfo employee : list) {  
556 - driver = employee.getJsy();  
557 - if (driver != null) {  
558 - map = new HashMap<>();  
559 - code = driver.getJobCode();  
560 - map.put("id", code + "/" + driver.getPersonnelName());  
561 - map.put("text", code + "/" + driver.getPersonnelName());  
562 - rsList.add(map);  
563 - }  
564 - }  
565 - return rsList;  
566 - }  
567 -  
568 - // 线路id获取售票员  
569 - @Override  
570 - public List<Map<String, String>> findConductorByLine(String lineCode) {  
571 - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);  
572 -  
573 - List<Map<String, String>> rsList = new ArrayList<>();  
574 - Map<String, String> map = null;  
575 - Personnel conductor = null;  
576 - String code = null;  
577 -  
578 - for (EmployeeConfigInfo employee : list) {  
579 - conductor = employee.getSpy();  
580 - if (conductor != null) {  
581 - code = conductor.getJobCode();  
582 - map = new HashMap<>();  
583 - map.put("id", code + "/" + conductor.getPersonnelName());  
584 - map.put("text", code + "/" + conductor.getPersonnelName());  
585 - rsList.add(map);  
586 - }  
587 - }  
588 - return rsList;  
589 - }  
590 -  
591 - @Override  
592 - public List<Map<String, String>> findCarByLine(String lineCode) {  
593 -  
594 - List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode);  
595 -  
596 - List<Map<String, String>> rsList = new ArrayList<>();  
597 - Map<String, String> map = null;  
598 - Cars car = null;  
599 - String code = null;  
600 -  
601 - for (CarConfigInfo cci : list) {  
602 - car = cci.getCl();  
603 - if (car != null) {  
604 - code = car.getInsideCode();  
605 - map = new HashMap<>();  
606 - map.put("id", code);  
607 - map.put("text", code);  
608 - rsList.add(map);  
609 - }  
610 - }  
611 - return rsList;  
612 - }  
613 -  
614 - /**  
615 - * 添加到历史库  
616 - *  
617 - * @param t  
618 - * @return  
619 - */  
620 - @Override  
621 - public Map<String, Object> addToHistory(ScheduleRealInfo t) {  
622 - Map<String, Object> rs = new HashMap<>();  
623 - try {  
624 - if (!carExist(t.getGsBm(), t.getClZbh())) {  
625 - rs.put("msg", "车辆 " + t.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");  
626 - rs.put("status", ResponseCode.ERROR);  
627 - return rs;  
628 - }  
629 -  
630 - SysUser user = SecurityUtils.getCurrentUser();  
631 - //String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm());  
632 -  
633 - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");  
634 -  
635 - if (StringUtils.isEmpty(t.getjGh())) {  
636 - rs.put("status", ResponseCode.ERROR);  
637 - rs.put("msg", "驾驶员工号不能为空!");  
638 - return rs;  
639 - }  
640 - //截取驾驶员工号  
641 - if (t.getjGh().indexOf("-") != -1) {  
642 - t.setjGh(t.getjGh().split("-")[1]);  
643 - }  
644 - //检查驾驶员工号  
645 - String jName = getPersonName(t.getGsBm(), t.getjGh());  
646 - if (StringUtils.isEmpty(jName)) {  
647 - rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的驾驶员");  
648 - rs.put("status", ResponseCode.ERROR);  
649 - return rs;  
650 - } else if (StringUtils.isEmpty(t.getjName())) {  
651 - t.setjName(jName);//补上驾驶员名称  
652 - }  
653 -  
654 - //有售票员  
655 - if (StringUtils.isNotEmpty(t.getsGh())) {  
656 - String sName = getPersonName(t.getGsBm(), t.getsGh());  
657 - if (StringUtils.isEmpty(sName)) {  
658 - rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的售票员");  
659 - rs.put("status", ResponseCode.ERROR);  
660 - return rs;  
661 - } else if (StringUtils.isEmpty(t.getsName())) {  
662 - t.setsName(sName);//补上售票员名称  
663 - }  
664 - } else {  
665 - t.setsGh("");  
666 - t.setsName("");  
667 - }  
668 -  
669 - //公司 和 分公司名称  
670 - t.setGsName(BasicData.businessCodeNameMap.get(t.getGsBm()));  
671 - t.setFgsName(BasicData.businessFgsCodeNameMap.get(t.getFgsBm()+ "_" + t.getGsBm() ));  
672 -  
673 - //t.setScheduleDateStr(schDate);  
674 - t.setScheduleDate(sdfyyyyMMdd.parse(t.getScheduleDateStr()));  
675 - t.setRealExecDate(t.getScheduleDateStr());  
676 - t.setCreateBy(user);  
677 - t.setSflj(true);  
678 - t.setLate(false);  
679 - t.setDfsj(t.getFcsj());  
680 - t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime());  
681 - t.setJhlcOrig(t.getJhlc());  
682 -  
683 - //班次历时  
684 - t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60);  
685 -  
686 - //起终点名称  
687 - String prefix = t.getXlBm() + "_" + t.getXlDir() + "_";  
688 - t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix));  
689 - t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix));  
690 -  
691 - //计算班次实际执行时间  
692 - schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t);  
693 - //处理计达跨24点  
694 - LineConfig conf = lineConfigData.get(t.getXlBm());  
695 - if (t.getZdsj().compareTo(conf.getStartOpt()) < 0) {  
696 - t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime() + (1000 * 60 * 60 * 24));  
697 - }  
698 - if (t.getZdsjT() < t.getFcsjT()) {  
699 - rs.put("status", ResponseCode.ERROR);  
700 - rs.put("msg", "起终点时间异常!");  
701 - return rs;  
702 - }  
703 -  
704 - t.setId(dayOfSchedule.getId());  
705 - //实时入库  
706 - rs = super.save(t);  
707 - } catch (Exception e) {  
708 - logger.error("", e);  
709 - rs.put("status", ResponseCode.ERROR);  
710 - }  
711 - return rs;  
712 - }  
713 -  
714 -  
715 - /**  
716 - * 临加班次  
717 - */  
718 - @Override  
719 - public Map<String, Object> save(ScheduleRealInfo sch) {  
720 - Map<String, Object> rs = new HashMap<>();  
721 - try {  
722 - String clZbh = sch.getClZbh();  
723 - if (StringUtils.isNotEmpty(clZbh)) {  
724 - //检测  
725 - if (!carExist(sch.getGsBm(), clZbh)) {  
726 - rs.put("status", ResponseCode.ERROR);  
727 - rs.put("msg", "车辆 " + clZbh + " 不存在!");  
728 - return rs;  
729 - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) {  
730 - rs.put("status", ResponseCode.ERROR);  
731 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆");  
732 - return rs;  
733 - }  
734 - }  
735 -  
736 - SysUser user = SecurityUtils.getCurrentUser();  
737 - String schDate = DayOfSchedule.currSchDateMap.get(sch.getXlBm());  
738 -  
739 - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");  
740 -  
741 - if (StringUtils.isEmpty(sch.getjGh())) {  
742 - rs.put("status", ResponseCode.ERROR);  
743 - rs.put("msg", "驾驶员工号不能为空!");  
744 - return rs;  
745 - }  
746 - //截取驾驶员工号  
747 - if (sch.getjGh().indexOf("-") != -1) {  
748 - sch.setjGh(sch.getjGh().split("-")[1]);  
749 - }  
750 - //检查驾驶员工号  
751 - String jName = getPersonName(sch.getGsBm(), sch.getjGh());  
752 - if (StringUtils.isEmpty(jName)) {  
753 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员");  
754 - rs.put("status", ResponseCode.ERROR);  
755 - return rs;  
756 - } else if (StringUtils.isEmpty(sch.getjName())) {  
757 - sch.setjName(jName);//补上驾驶员名称  
758 - }  
759 -  
760 - //有售票员  
761 - if (StringUtils.isNotEmpty(sch.getsGh())) {  
762 - String sName = getPersonName(sch.getGsBm(), sch.getsGh());  
763 - if (StringUtils.isEmpty(sName)) {  
764 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的售票员");  
765 - rs.put("status", ResponseCode.ERROR);  
766 - return rs;  
767 - } else if (StringUtils.isEmpty(sch.getsName())) {  
768 - sch.setsName(sName);//补上售票员名称  
769 - }  
770 - } else {  
771 - sch.setsGh("");  
772 - sch.setsName("");  
773 - }  
774 -  
775 - //公司 和 分公司名称  
776 - sch.setGsName(BasicData.businessCodeNameMap.get(sch.getGsBm()));  
777 - sch.setFgsName(BasicData.businessFgsCodeNameMap.get(sch.getFgsBm() + "_" + sch.getGsBm()));  
778 - sch.setCreateDate(new Date());  
779 - sch.setScheduleDateStr(schDate);  
780 - sch.setScheduleDate(sdfyyyyMMdd.parse(schDate));  
781 - sch.setRealExecDate(schDate);  
782 -  
783 - sch.setCreateBy(user);  
784 - sch.setSflj(true);  
785 - sch.setLate(false);  
786 - sch.setDfsj(sch.getFcsj());  
787 - sch.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + sch.getZdsj()).getTime());  
788 - sch.setJhlcOrig(sch.getJhlc());  
789 - sch.setCreateDate(new Date());  
790 - sch.setUpdateDate(new Date());  
791 - sch.setSpId(-1L);  
792 - //起终点名称  
793 - String prefix = sch.getXlBm() + "_" + sch.getXlDir() + "_";  
794 - sch.setQdzName(BasicData.getStationNameByCode(sch.getQdzCode(), prefix));  
795 - sch.setZdzName(BasicData.getStationNameByCode(sch.getZdzCode(), prefix));  
796 -  
797 - //计算班次实际执行时间  
798 - schAttrCalculator.calcRealDate(sch).calcAllTimeByFcsj(sch);  
799 -  
800 - //处理计达跨24点  
801 - LineConfig conf = lineConfigData.get(sch.getXlBm());  
802 - if (sch.getZdsj().compareTo(conf.getStartOpt()) < 0) {  
803 - sch.setZdsjT(sdfyyyyMMddHHmm.parse(sch.getScheduleDateStr() + sch.getZdsj()).getTime() + (1000 * 60 * 60 * 24));  
804 - }  
805 -  
806 - //班次历时  
807 - sch.setBcsj((int) ((sch.getZdsjT() - sch.getDfsjT()) / 1000 / 60));  
808 - if (sch.getZdsjT() < sch.getFcsjT()) {  
809 - rs.put("status", ResponseCode.ERROR);  
810 - rs.put("msg", "起终点时间异常!");  
811 - return rs;  
812 - }  
813 -  
814 - sch.setId(dayOfSchedule.getId());  
815 - //实时入库  
816 - super.save(sch);  
817 -  
818 - // 加入缓存  
819 - dayOfSchedule.put(sch);  
820 -  
821 - //更新起点应到时间  
822 - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch);  
823 -  
824 - //重新计算车辆当前执行班次  
825 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
826 -  
827 - //记录站到场历时数据  
828 - Station2ParkBuffer.put(sch);  
829 -  
830 - rs.put("ts", ts);  
831 - rs.put("t", sch);  
832 - } catch (Exception e) {  
833 - logger.error("", e);  
834 - rs.put("status", ResponseCode.ERROR);  
835 - }  
836 - return rs;  
837 - }  
838 -  
839 - /**  
840 - * 删除历史表临加班次  
841 - *  
842 - * @param id  
843 - * @return  
844 - */  
845 - @Override  
846 - public Map<String, Object> deleteToHistory(Long id) {  
847 - Map<String, Object> rs = new HashMap<>();  
848 - rs.put("status", ResponseCode.ERROR);  
849 -  
850 - try {  
851 - ScheduleRealInfo sch = super.findById(id);  
852 - if (sch == null) {  
853 - rs.put("msg", "无效的id号");  
854 - return rs;  
855 - }  
856 -  
857 - if (!sch.isSflj()) {  
858 - rs.put("msg", "你只能删除临加班次");  
859 - return rs;  
860 - }  
861 -  
862 - //解除和调度指令的外键约束  
863 - jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id);  
864 -  
865 - //数据库删除  
866 - rs = super.delete(id);  
867 - } catch (Exception e) {  
868 - logger.error("", e);  
869 - rs.put("msg", e.getMessage());  
870 - }  
871 -  
872 - return rs;  
873 - }  
874 -  
875 - @Override  
876 - public Map<String, Object> delete(Long id) {  
877 - Map<String, Object> rs = new HashMap<>();  
878 - rs.put("status", ResponseCode.ERROR);  
879 -  
880 - ScheduleRealInfo sch = null;  
881 - try {  
882 - sch = dayOfSchedule.get(id);  
883 - if (sch == null) {  
884 - rs.put("msg", "无效的id号");  
885 - return rs;  
886 - }  
887 -  
888 - if (!sch.isSflj()) {  
889 - rs.put("msg", "你只能删除临加班次");  
890 - return rs;  
891 - }  
892 -  
893 - sch.setDeleted(true);  
894 - //解除和调度指令的外键约束  
895 - jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id);  
896 -  
897 - //数据库删除  
898 - rs = super.delete(id);  
899 - if (rs.get("status").equals(ResponseCode.SUCCESS)) {  
900 - dayOfSchedule.delete(sch);  
901 - //更新起点应到时间  
902 - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch);  
903 - rs.put("ts", ts);  
904 - rs.put("delete", sch);  
905 - } else  
906 - sch.setDeleted(false);  
907 - } catch (Exception e) {  
908 - logger.error("", e);  
909 - rs.put("msg", e.getMessage());  
910 - sch.setDeleted(false);  
911 - }  
912 -  
913 - return rs;  
914 - }  
915 -  
916 - @Override  
917 - public List<Map<String, String>> sreachVehic(String nbbm) {  
918 - // 转大写  
919 - nbbm = nbbm.toUpperCase();  
920 -  
921 - List<Map<String, String>> list = new ArrayList<>();  
922 - Map<String, String> map;  
923 - Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();  
924 -  
925 - Line line;  
926 - for (String k : allSet) {  
927 - if (k.indexOf(nbbm) != -1) {  
928 - // 所属线路  
929 - map = new HashMap<>();  
930 - line = BasicData.nbbm2LineMap.get(k);  
931 - map.put("id", k);  
932 - map.put("text", k);  
933 - if (null != line) {  
934 - map.put("lineName", line.getName());  
935 - map.put("lineCode", line.getLineCode());  
936 - }  
937 -  
938 - list.add(map);  
939 - }  
940 -  
941 - if (list.size() > 20)  
942 - break;  
943 - }  
944 - return list;  
945 - }  
946 -  
947 - @Override  
948 - public void adjustCar(ScheduleRealInfo schedule, String car) {  
949 - schedule.setClZbh(car);  
950 - }  
951 -  
952 - @Override  
953 - public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) {  
954 - if (driver.indexOf("-") != -1)  
955 - driver = driver.split("-")[1];  
956 - schedule.setjGh(driver);  
957 - schedule.setjName(driverName);  
958 - }  
959 -  
960 - @Override  
961 - public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) {  
962 - if (conductor.indexOf("-") != -1)  
963 - conductor = conductor.split("-")[1];  
964 - schedule.setsGh(conductor);  
965 - schedule.setsName(conductorName);  
966 - }  
967 -  
968 - @Override  
969 - public List<ScheduleRealInfo> queryUserInfo(String line, String date, String state) {  
970 - List<ScheduleRealInfo> scheduleRealInfos = new ArrayList<>();  
971 - List<Object[]> objects = null;  
972 - if (state.equals("2")) {  
973 - objects = scheduleRealInfoRepository.queryUserInfo2(line, date);  
974 - for (Object[] objs : objects) {  
975 - ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo();  
976 - scheduleRealInfo.setId((Long)objs[0]);  
977 - scheduleRealInfo.setjGh((String)objs[1]);  
978 - scheduleRealInfo.setClZbh((String)objs[2]);  
979 - scheduleRealInfo.setLpName((String)objs[3]);  
980 - scheduleRealInfo.setjName((String)objs[4]);  
981 -  
982 - scheduleRealInfos.add(scheduleRealInfo);  
983 - }  
984 - } else {  
985 - objects = scheduleRealInfoRepository.queryUserInfo3(line, date);  
986 - for (Object[] objs : objects) {  
987 - ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo();  
988 - scheduleRealInfo.setId((Long)objs[0]);  
989 - scheduleRealInfo.setClZbh((String)objs[1]);  
990 -  
991 - scheduleRealInfos.add(scheduleRealInfo);  
992 - }  
993 - }  
994 -  
995 - return scheduleRealInfos;  
996 - }  
997 -  
998 - @Override  
999 - public List<ScheduleRealInfo> queryUserInfoPx(String line, String date, String state, String type) {  
1000 -// List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();  
1001 - state = state + "";  
1002 - String lpname = state;  
1003 - String px = type;  
1004 - if (state.equals("lpName")) {  
1005 - state = state + "+1";  
1006 - type = "ASC";  
1007 - }  
1008 - String minfcsj = "02:00";  
1009 - List<Line> lineList = lineRepository.findLineByCode(line);  
1010 - if (lineList.size() > 0) {  
1011 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
1012 - + " id = ("  
1013 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
1014 - + ")";  
1015 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
1016 - }  
1017 - String sqlPlan = "select * from (select * from ("  
1018 - + " select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, "  
1019 - + " s.lp_Name as lpName,min(s.j_Name) as jName,max(s.schedule_date_str) as dateStr ,"  
1020 - + " min(s.fcsj) as fcsj,1 as px from bsth_c_s_sp_info_real s where "  
1021 - + " s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'"  
1022 - + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name) x where x.fcsj >'" + minfcsj + "'"  
1023 - + " UNION "  
1024 - + " select * from ( select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, "  
1025 - + " s.lp_Name as lpName,min(s.j_Name) as jName, max(s.schedule_date_str) as dateStr,"  
1026 - + " min(s.fcsj) as fcsj,2 as px from bsth_c_s_sp_info_real s "  
1027 - + " where s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'"  
1028 - + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name"  
1029 - + " ) y where y.fcsj <='" + minfcsj + "') z order by (" + state + "),dateStr,px,fcsj " + type;  
1030 - List<ScheduleRealInfo> list = jdbcTemplate.query(sqlPlan,  
1031 - new RowMapper<ScheduleRealInfo>() {  
1032 - @Override  
1033 - public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException {  
1034 - ScheduleRealInfo t = new ScheduleRealInfo();  
1035 - t.setId(rs.getLong("id"));  
1036 - t.setjGh(rs.getString("jGh"));  
1037 - t.setClZbh(rs.getString("clZbh"));  
1038 - t.setLpName(rs.getString("lpName"));  
1039 - t.setjName(rs.getString("jName"));  
1040 - t.setFcsj(rs.getString("fcsj"));  
1041 - return t;  
1042 - }  
1043 - });  
1044 - if (lpname.equals("lpName")) {  
1045 -  
1046 - List<ScheduleRealInfo> listNew = new ArrayList<ScheduleRealInfo>();  
1047 - Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");  
1048 -// if (px.equals("desc")) {  
1049 - int zt = 0;  
1050 - for (int l = 0; l < 2; l++) {  
1051 - for (int i = 0; i < list.size(); i++) {  
1052 - ScheduleRealInfo t = list.get(i);  
1053 - if (t.getLpName().indexOf("+") != -1) {  
1054 - if (zt == 0) {  
1055 - listNew.add(t);  
1056 - }  
1057 - } else if (pattern.matcher(t.getLpName()).matches()) {  
1058 - if (zt == 1) {  
1059 - listNew.add(t);  
1060 - }  
1061 - } else {  
1062 - continue;  
1063 - }  
1064 - }  
1065 - zt++;  
1066 - }  
1067 -  
1068 - Collections.sort(list, new ComparableLp());  
1069 - for (int i = 0; i < list.size(); i++) {  
1070 - ScheduleRealInfo t = list.get(i);  
1071 - if (t.getLpName().indexOf("+") != -1) {  
1072 - continue;  
1073 - } else if (pattern.matcher(t.getLpName()).matches()) {  
1074 - continue;  
1075 - } else {  
1076 - listNew.add(t);  
1077 - }  
1078 - }  
1079 - return listNew;  
1080 - } else {  
1081 - return list;  
1082 - }  
1083 -  
1084 - }  
1085 -  
1086 - /**  
1087 - *  
1088 - */  
1089 - @Override  
1090 - public List<ScheduleRealInfo> exportWaybill(String jName,String jGh, String clZbh, String lpName, String date, String line) {  
1091 - ReportUtils ee = new ReportUtils();  
1092 - ReportRelatedUtils rru = new ReportRelatedUtils();  
1093 - List<Iterator<?>> list = new ArrayList<Iterator<?>>();  
1094 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);  
1095 - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();  
1096 -// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line);  
1097 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
1098 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
1099 - ScheduleRealInfo s = scheduleRealInfos.get(i);  
1100 - Set<ChildTaskPlan> cts = s.getcTasks();  
1101 - if (cts != null && cts.size() > 0) {  
1102 - lists.add(s);  
1103 - } else {  
1104 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
1105 - lists.add(s);  
1106 - }  
1107 - }  
1108 - }  
1109 - DecimalFormat format = new DecimalFormat("0.00");  
1110 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
1111 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
1112 - //计算里程和班次数,并放入Map里  
1113 - Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId());  
1114 -  
1115 - map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos)));  
1116 - map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos));  
1117 - map.put("addMileage", culateMieageService.culateLjgl(lists));  
1118 - double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists));  
1119 - map.put("yygl", yygl);  
1120 - double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists));  
1121 - map.put("ksgl", ksgl);  
1122 - map.put("realMileage", Arith.add(yygl, ksgl));  
1123 - map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, ""));  
1124 - map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos));  
1125 - map.put("ljbc", culateMieageService.culateLjbc(lists, ""));  
1126 - int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, "");  
1127 - map.put("sjbc", sjbc);  
1128 -// map=new HashMap<String,Object>();  
1129 -  
1130 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
1131 - String minfcsj = "02:00";  
1132 - List<Line> lineList = lineRepository.findLineByCode(line);  
1133 - if (lineList.size() > 0) {  
1134 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
1135 - + " id = ("  
1136 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
1137 - + ")";  
1138 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
1139 - }  
1140 - String[] minSjs = minfcsj.split(":");  
1141 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
1142 -  
1143 -  
1144 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
1145 - ScheduleRealInfo s = scheduleRealInfos.get(i);  
1146 - String[] fcsj = s.getFcsj().split(":");  
1147 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
1148 -  
1149 - Long fscjT = 0L;  
1150 - if (fcsjL < minSj) {  
1151 - Calendar calendar = new GregorianCalendar();  
1152 - calendar.setTime(s.getScheduleDate());  
1153 - calendar.add(calendar.DATE, 1);  
1154 - s.setScheduleDate(calendar.getTime());  
1155 - try {  
1156 - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();  
1157 - } catch (ParseException e) {  
1158 - // TODO Auto-generated catch block  
1159 - e.printStackTrace();  
1160 - }  
1161 -  
1162 - } else {  
1163 - try {  
1164 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
1165 - } catch (ParseException e) {  
1166 - // TODO Auto-generated catch block  
1167 - e.printStackTrace();  
1168 - }  
1169 - ;  
1170 - }  
1171 - s.setFcsjT(fscjT);  
1172 - }  
1173 - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();  
1174 - Collections.sort(scheduleRealInfos, new ComparableReal());  
1175 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
1176 - ScheduleRealInfo s = scheduleRealInfos.get(i);  
1177 - s.setAdjustExps(i + 1 + "");  
1178 - String remarks = "";  
1179 - if (s.getRemarks() != null) {  
1180 - remarks += s.getRemarks();  
1181 - }  
1182 -  
1183 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
1184 - if (!childTaskPlans.isEmpty()) {  
1185 - s.setFcsjActual("");  
1186 - s.setZdsjActual("");  
1187 - s.setJhlc(0.0);  
1188 - }  
1189 -  
1190 - if (s.isDestroy()) {  
1191 - s.setFcsjActual("");  
1192 - s.setZdsjActual("");  
1193 - s.setJhlc(0.0);  
1194 - remarks += "(烂班)";  
1195 - s.setRemarks(remarks);  
1196 - }  
1197 -  
1198 - listSchedule.add(s);  
1199 - //计算营运里程,空驶里程  
1200 - if (!childTaskPlans.isEmpty()) {  
1201 -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
1202 - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);  
1203 - Collections.sort(listit, new ComparableChild());  
1204 - for (int j = 0; j < listit.size(); j++) {  
1205 - ScheduleRealInfo t = new ScheduleRealInfo();  
1206 - ChildTaskPlan childTaskPlan = listit.get(j);  
1207 - if (childTaskPlan.isDestroy()) {  
1208 - t.setFcsjActual("");  
1209 - t.setZdsjActual("");  
1210 - t.setJhlc(0.0);  
1211 - } else {  
1212 - t.setFcsjActual(childTaskPlan.getStartDate());  
1213 - t.setZdsjActual(childTaskPlan.getEndDate());  
1214 - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));  
1215 - }  
1216 - t.setQdzName(childTaskPlan.getStartStationName());  
1217 - t.setZdzName(childTaskPlan.getEndStationName());  
1218 - t.setRemarks(childTaskPlan.getRemarks());  
1219 - t.setAdjustExps("子");  
1220 - t.setjGh("");  
1221 - t.setjName("");  
1222 - t.setsGh("");  
1223 - t.setsName("");  
1224 - listSchedule.add(t);  
1225 - }  
1226 - }  
1227 - }  
1228 - Map<String, Object> maps;  
1229 - for (ScheduleRealInfo scheduleRealInfo : listSchedule) {  
1230 - maps = new HashMap<String, Object>();  
1231 - try {  
1232 - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName());  
1233 - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName());  
1234 - maps = rru.getMapValue(scheduleRealInfo);  
1235 - maps.put("bcs", scheduleRealInfo.getAdjustExps());  
1236 - String zdsj = scheduleRealInfo.getZdsj();  
1237 - String zdsjActual = scheduleRealInfo.getZdsjActual();  
1238 - if (zdsj != null && zdsjActual != null &&  
1239 - !zdsj.equals(zdsjActual) &&  
1240 - !zdsj.equals("") &&  
1241 - !zdsjActual.equals("")) {  
1242 - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]);  
1243 - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]);  
1244 - if (zdsj.compareTo(zdsjActual) > 0) {  
1245 - if (zdsjT - zdsjAT > 1000) {  
1246 - maps.put("fast", "");  
1247 - maps.put("slow", zdsjAT - zdsjT + 1440);  
1248 - } else {  
1249 - maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
1250 - maps.put("slow", "");  
1251 - }  
1252 - } else {  
1253 - if (zdsjAT - zdsjT > 1000) {  
1254 - maps.put("fast", zdsjT - zdsjAT + 1440);  
1255 - maps.put("slow", "");  
1256 - } else {  
1257 - maps.put("fast", "");  
1258 - maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
1259 - }  
1260 - }  
1261 - } else {  
1262 - maps.put("fast", "");  
1263 - maps.put("slow", "");  
1264 - }  
1265 -  
1266 - String fcsj = scheduleRealInfo.getFcsj();  
1267 - String fcsjActual = scheduleRealInfo.getFcsjActual();  
1268 - if (fcsj != null && fcsjActual != null &&  
1269 - !fcsj.equals(fcsjActual) &&  
1270 - !fcsj.equals("") &&  
1271 - !fcsjActual.equals("")) {  
1272 - int fcsjT = Integer.valueOf(fcsj.split(":")[0]) * 60 + Integer.valueOf(fcsj.split(":")[1]);  
1273 - int fcsjAT = Integer.valueOf(fcsjActual.split(":")[0]) * 60 + Integer.valueOf(fcsjActual.split(":")[1]);  
1274 - if (fcsj.compareTo(fcsjActual) > 0) {  
1275 - if (fcsjT - fcsjAT > 1000) {  
1276 - maps.put("fast_start", "");  
1277 - maps.put("slow_start", fcsjAT - fcsjT + 1440);  
1278 - } else {  
1279 - maps.put("fast_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));  
1280 - maps.put("slow_start", "");  
1281 - }  
1282 - } else {  
1283 - if (fcsjAT - fcsjT > 1000) {  
1284 - maps.put("fast_start", fcsjT - fcsjAT + 1440);  
1285 - maps.put("slow_start", "");  
1286 - } else {  
1287 - maps.put("fast_start", "");  
1288 - maps.put("slow_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));  
1289 - }  
1290 - }  
1291 - } else {  
1292 - maps.put("fast_start", "");  
1293 - maps.put("slow_start", "");  
1294 - }  
1295 - listMap.add(maps);  
1296 - } catch (Exception e) {  
1297 - e.printStackTrace();  
1298 - }  
1299 - }  
1300 -  
1301 - String xls = "";  
1302 - if (map.get("type").toString().equals("0")) {  
1303 - xls = "waybill_minhang.xls";  
1304 - } else {  
1305 - xls = "waybill_minhang_dl.xls";  
1306 - }  
1307 -  
1308 -  
1309 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
1310 -  
1311 - list.add(listMap.iterator());  
1312 - ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/" + xls,  
1313 - path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");  
1314 - return scheduleRealInfos;  
1315 - }  
1316 -  
1317 - @Override  
1318 - public List<Map<String, Object>> dailyInfo(String line, String date, String type) {  
1319 - DecimalFormat format = new DecimalFormat("0.00");  
1320 - ReportUtils ee = new ReportUtils();  
1321 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
1322 - List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date);  
1323 -  
1324 - double totalZGL = 0, totalKSGL = 0, totalYH = 0;  
1325 - int totalBCS = 0;  
1326 - for (int i = 0; i < list.size(); i++) {  
1327 - String zgl = format.format(Double.parseDouble(list.get(i).get("zgl") == null ? "0" : list.get(i).get("zgl").toString()));  
1328 - String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl") == null ? "0" : list.get(i).get("ksgl").toString()));  
1329 - if (type.equals("export")) {  
1330 - totalZGL += Double.parseDouble(zgl);  
1331 - totalKSGL += Double.parseDouble(ksgl);  
1332 - totalBCS += Integer.parseInt(list.get(i).get("bcs").toString());  
1333 - }  
1334 - list.get(i).put("zgl", zgl);  
1335 - list.get(i).put("ksgl", ksgl);  
1336 - }  
1337 - if (type.equals("export")) {  
1338 - Map<String, Object> map = new HashMap<String, Object>();  
1339 - map.put("line", line);  
1340 - map.put("date", date);  
1341 - map.put("totalZGL", totalZGL);  
1342 - map.put("totalKSGL", totalKSGL);  
1343 - map.put("totalYH", totalYH);  
1344 - map.put("totalBCS", totalBCS);  
1345 -  
1346 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
1347 -  
1348 - listI.add(list.iterator());  
1349 - try {  
1350 - ee.excelReplace(listI, new Object[]{map}, path + "mould/daily.xls",  
1351 - path + "export/班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");  
1352 - } catch (ParseException e) {  
1353 - e.printStackTrace();  
1354 - }  
1355 - }  
1356 - return list;  
1357 - }  
1358 -  
1359 - @Override  
1360 - public List<Object[]> historyMessage(String line, String date, String code, String type) {  
1361 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
1362 -  
1363 - long d = 0;  
1364 - long t = 0;  
1365 - if (date.length() > 0) {  
1366 - try {  
1367 - d = sdf.parse(date + " 00:00:00").getTime();  
1368 - t = sdf.parse(date + " 23:59:59").getTime();  
1369 - } catch (ParseException e) {  
1370 - // TODO Auto-generated catch block  
1371 - e.printStackTrace();  
1372 - }  
1373 -  
1374 - }  
1375 - String device = "";  
1376 - String device2 ="";  
1377 - long qyrqTime=0l;  
1378 - if (!code.equals("")) {  
1379 - try {  
1380 - List<CarDevice> deviceList=carDeviceRepository.findCarCode(code, sdf.parse(date+ " 00:00:00"));  
1381 - if(deviceList.size()>0){  
1382 - device=deviceList.get(0).getOldDeviceNo();  
1383 - Date qyrq=deviceList.get(0).getQyrq();  
1384 - qyrqTime=qyrq.getTime();  
1385 - if(qyrqTime<t){  
1386 - device2=deviceList.get(0).getNewDeviceNo();  
1387 - }  
1388 - }else{  
1389 - device = BasicData.deviceId2NbbmMap.inverse().get(code);  
1390 - }  
1391 - } catch (ParseException e) {  
1392 - // TODO Auto-generated catch block  
1393 - e.printStackTrace();  
1394 - }  
1395 - }  
1396 - List<Object[]> list=new ArrayList<Object[]>();  
1397 -  
1398 - device = device.replaceAll("BF-", "");  
1399 - List<Object[]> list0 =scheduleRealInfoRepository.historyMessage(line, device, d, t);  
1400 - for (Object[] obj : list0) {  
1401 - if (obj != null) {  
1402 - if(code.equals("")){  
1403 - if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) {  
1404 - List<CarDevice> carDeviceList = new ArrayList<CarDevice>();  
1405 - try {  
1406 - carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString())));  
1407 - //启用日期大于营运日期 还是根据旧设备号查询  
1408 - if(carDeviceList.size()==0){  
1409 - carDeviceList = carDeviceRepository.findCarOldDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString())));  
1410 - }  
1411 - } catch (Exception e) {  
1412 - // TODO Auto-generated catch block  
1413 - e.printStackTrace();  
1414 - }  
1415 - if (carDeviceList.size() > 0) {  
1416 - obj[0] = carDeviceList.get(0).getClZbh();  
1417 - } else {  
1418 - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString());  
1419 - }  
1420 - } else {  
1421 - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString());  
1422 - }  
1423 - }else{  
1424 - obj[0]=code;  
1425 - }  
1426 -  
1427 - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));  
1428 - obj[4] = BasicData.lineCode2NameMap.get(line);  
1429 - }  
1430 - }  
1431 - list.addAll(list0);  
1432 - if(!device2.equals("")){  
1433 - device2.replaceAll("BF-", "");  
1434 - List<Object[]> list1 =scheduleRealInfoRepository.historyMessage(line, device2, d, t);  
1435 - for (Object[] obj : list1) {  
1436 - if (obj != null) {  
1437 - obj[0] =code;  
1438 - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));  
1439 - obj[4] = BasicData.lineCode2NameMap.get(line);  
1440 - }  
1441 - }  
1442 - list.addAll(list1);  
1443 - }  
1444 -  
1445 - if (type != null && type.length() != 0 && type.equals("export")) {  
1446 - String lineName = BasicData.lineCode2NameMap.get(line);  
1447 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
1448 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
1449 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
1450 - Map<String, Object> m = new HashMap<String, Object>();  
1451 - ReportUtils ee = new ReportUtils();  
1452 - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();  
1453 - for (int i = 0; i < list.size(); i++) {  
1454 - Map<String, Object> map = new HashMap<String, Object>();  
1455 - Object[] obj = list.get(i);  
1456 - map.put("num", i + 1);  
1457 - map.put("line", obj[4]);  
1458 - map.put("clZbh", obj[0]);  
1459 - map.put("sender", obj[1]);  
1460 - map.put("date", obj[3]);  
1461 - map.put("text", obj[2]);  
1462 - map.put("reply46", "0".equals(obj[5]+"")?"是":"");  
1463 - map.put("reply47", "0".equals(obj[6]+"")?"是":"");  
1464 - newList.add(map);  
1465 - }  
1466 - try {  
1467 - listI.add(newList.iterator());  
1468 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
1469 - ee.excelReplace(listI, new Object[]{m}, path + "mould/historyMessage.xls",  
1470 - path + "export/" + sdfSimple.format(sdfMonth.parse(date))  
1471 - + "-" + lineName + "-调度历史消息.xls");  
1472 - } catch (Exception e) {  
1473 - // TODO: handle exception  
1474 - e.printStackTrace();  
1475 - }  
1476 - }  
1477 -  
1478 - if (type != null && type.length() != 0 && type.equals("export_msg")) {  
1479 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
1480 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
1481 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
1482 - Map<String, Object> m = new HashMap<String, Object>();  
1483 - ReportUtils ee = new ReportUtils();  
1484 - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();  
1485 - for (int i = 0; i < list.size(); i++) {  
1486 - Map<String, Object> map = new HashMap<String, Object>();  
1487 - Object[] obj = list.get(i);  
1488 - map.put("num", i + 1);  
1489 - map.put("line", obj[4]);  
1490 - map.put("clZbh", obj[0]);  
1491 - map.put("sender", obj[1]);  
1492 - map.put("date", obj[3]);  
1493 - map.put("text", obj[2]);  
1494 - newList.add(map);  
1495 - }  
1496 - try {  
1497 - listI.add(newList.iterator());  
1498 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
1499 - ee.excelReplace(listI, new Object[]{m}, path + "mould/message.xls",  
1500 - path + "export/调度消息分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");  
1501 - } catch (Exception e) {  
1502 - // TODO: handle exception  
1503 - e.printStackTrace();  
1504 - }  
1505 - }  
1506 - return list;  
1507 - }  
1508 -  
1509 - @Override  
1510 - public Map<Integer, Integer> trustStatus(String lineStr) {  
1511 - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr));  
1512 -  
1513 - Map<Integer, Integer> map = new HashMap<>();  
1514 - return map;  
1515 - }  
1516 -  
1517 - @Override  
1518 - public Map<String, Object> realOutAdjust(Map<String, String> map) {  
1519 - Map<String, Object> rs = new HashMap<>();  
1520 - List<ScheduleRealInfo> ts = new ArrayList<>();  
1521 - try {  
1522 - // 维修上报  
1523 - if (StringUtils.isNotBlank(map.get("reportTypes"))) {  
1524 - Map<String, Object> param = new HashMap<String, Object>();  
1525 - param.putAll(map);  
1526 - rs = repairReport(param, false);  
1527 - }  
1528 -  
1529 - Long id = Long.parseLong(map.get("id"));  
1530 - String remarks = map.get("remarks"), fcsjActual = map.get("fcsjActual");  
1531 -  
1532 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
1533 -  
1534 - LineConfig config = lineConfigData.get(sch.getXlBm());  
1535 - //小于线路开始运营时间,则默认跨过24点  
1536 - if (fcsjActual.compareTo(config.getStartOpt()) < 0) {  
1537 - sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME));  
1538 - } else {  
1539 - sch.setRealExecDate(sch.getScheduleDateStr());  
1540 - }  
1541 -  
1542 - //日志记录  
1543 - ScheduleModifyLogger.sftz(sch, fcsjActual, remarks);  
1544 -  
1545 - sch.setFcsjActualAll(fcsjActual);  
1546 - sch.setRemarks(remarks);  
1547 - sch.calcStatus();  
1548 - //if(sch.isLate2()){  
1549 - //取消应发未到标记  
1550 - // sch.setLate2(false);  
1551 - LateAdjustHandle.remove(sch);  
1552 - //}  
1553 -  
1554 - dayOfSchedule.save(sch);  
1555 -  
1556 - ts.add(sch);  
1557 -  
1558 - rs.put("status", ResponseCode.SUCCESS);  
1559 - rs.put("ts", ts);  
1560 -  
1561 - //通知页面刷新  
1562 - sendUtils.refreshSch(ts);  
1563 - } catch (Exception e) {  
1564 - logger.error("", e);  
1565 - rs.put("status", ResponseCode.ERROR);  
1566 - }  
1567 -  
1568 - return rs;  
1569 - }  
1570 -  
1571 - @Override  
1572 - public Map<String, Object> revokeDestroy(Long id) {  
1573 - Map<String, Object> rs = new HashMap<>();  
1574 - try {  
1575 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
1576 - if (sch.getStatus() != -1) {  
1577 - rs.put("status", ResponseCode.ERROR);  
1578 - rs.put("msg", "未烂班,无法撤销!");  
1579 - } else {  
1580 - //日志记录  
1581 - ScheduleModifyLogger.cxlb(sch);  
1582 -  
1583 - sch.setStatus(0);  
1584 - sch.setRemarks("");//清空备注  
1585 - sch.setJhlc(sch.getJhlcOrig());  
1586 -  
1587 - //入库  
1588 - dayOfSchedule.save(sch);  
1589 - //重新计算当前执行班次  
1590 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
1591 - rs.put("status", ResponseCode.SUCCESS);  
1592 - rs.put("t", sch);  
1593 -  
1594 - }  
1595 - } catch (Exception e) {  
1596 - logger.error("", e);  
1597 - rs.put("status", ResponseCode.ERROR);  
1598 - }  
1599 - return rs;  
1600 - }  
1601 -  
1602 - @Override  
1603 - public Map<String, Object> revokeRealOutgo(Long id) {  
1604 - Map<String, Object> rs = new HashMap<>();  
1605 - List<ScheduleRealInfo> ts = new ArrayList<>();  
1606 -  
1607 - try {  
1608 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
1609 - if (sch.getFcsjActual() == null) {  
1610 - rs.put("status", ResponseCode.ERROR);  
1611 - rs.put("msg", "无实发时间,无法撤销!");  
1612 - } else {  
1613 - //日志记录  
1614 - ScheduleModifyLogger.cxsf(sch);  
1615 -  
1616 - sch.clearFcsjActual();  
1617 - rs.put("status", ResponseCode.SUCCESS);  
1618 -  
1619 - ts.add(sch);  
1620 - rs.put("ts", ts);  
1621 -  
1622 - dayOfSchedule.save(sch);  
1623 -  
1624 - }  
1625 - } catch (Exception e) {  
1626 - logger.error("", e);  
1627 - rs.put("status", ResponseCode.ERROR);  
1628 - }  
1629 - return rs;  
1630 - }  
1631 -  
1632 - @Override  
1633 - public Map<String, Object> spaceAdjust(Long[] ids, Integer space) {  
1634 -  
1635 - List<ScheduleRealInfo> list = new ArrayList<>(), ts = new ArrayList<>(), tempTs = null;  
1636 - Map<String, Object> rs = new HashMap<>(), tempRs = new HashMap<>();  
1637 - try {  
1638 - ScheduleRealInfo sch, next;  
1639 - for (Long id : ids) {  
1640 - sch = dayOfSchedule.get(id);  
1641 - if (null != sch)  
1642 - list.add(sch);  
1643 - }  
1644 -  
1645 - int size = list.size();  
1646 - if (size == 0) {  
1647 - rs.put("status", ResponseCode.ERROR);  
1648 - } else {  
1649 - // 按发车时间排序  
1650 - Collections.sort(list, new ScheduleComparator.FCSJ());  
1651 -  
1652 - // 以第一个实际发车/待发时间为起点,调整间隔  
1653 - sch = list.get(0);  
1654 - Long st = sch.getFcsjActualTime() == null ? sch.getDfsjT() : sch.getFcsjActualTime(), plus = space * 60 * 1000L;  
1655 -  
1656 - for (int i = 1; i < size; i++) {  
1657 - st += plus;  
1658 - sch = list.get(i);  
1659 -  
1660 - //调整待发  
1661 - tempRs = outgoAdjust(sch.getId(), null, fmtHHmm.print(st), null, "3", null);  
1662 -  
1663 - if (null != tempRs && tempRs.get("ts") != null)  
1664 - tempTs = (List<ScheduleRealInfo>) tempRs.get("ts");  
1665 -  
1666 - ts.addAll(tempTs);  
1667 - }  
1668 -  
1669 - rs.put("status", ResponseCode.SUCCESS);  
1670 - //返回最后一个班次,页面会全量刷新  
1671 - rs.put("ts", ts);  
1672 - }  
1673 -  
1674 - } catch (Exception e) {  
1675 - logger.error("", e);  
1676 - rs.put("status", ResponseCode.ERROR);  
1677 - }  
1678 - return rs;  
1679 - }  
1680 -  
1681 - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");  
1682 -  
1683 - @Transactional  
1684 - @Override  
1685 - public Map<String, Object> schInfoFineTune(Map<String, String> map) {  
1686 - Map<String, Object> rs = new HashMap<>();  
1687 - List<ScheduleRealInfo> ts = new ArrayList<>();  
1688 - try {  
1689 - // 维修上报  
1690 - if (StringUtils.isNotBlank(map.get("reportTypes"))) {  
1691 - Map<String, Object> param = new HashMap<String, Object>();  
1692 - param.putAll(map);  
1693 - rs = repairReport(param, false);  
1694 - }  
1695 -  
1696 - Long id = Long.parseLong(map.get("id"));  
1697 - String remarks = map.get("remarks");  
1698 -  
1699 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
1700 -  
1701 - if (null == sch) {  
1702 - rs.put("status", ResponseCode.ERROR);  
1703 - rs.put("msg", "不存在的班次!");  
1704 - return rs;  
1705 - }  
1706 -  
1707 - //日志记录器  
1708 - FcxxwtLogger fLog = FcxxwtLogger.start(sch, remarks);  
1709 -  
1710 - String clZbh = map.get("clZbh");  
1711 - String jsy = map.get("jsy");  
1712 - if (!clZbh.equals(sch.getClZbh())  
1713 - || !jsy.equals(sch.getjGh() + "/" + sch.getjName()))  
1714 - schModifyLog.saveChangetochange(sch, clZbh, jsy);//为换人换车情况表写入数据  
1715 - /**  
1716 - * 换车  
1717 - */  
1718 - if (StringUtils.isNotEmpty(clZbh) && !clZbh.equals(sch.getClZbh())) {  
1719 - //换车  
1720 - if (!carExist(sch.getGsBm(), clZbh)) {  
1721 - rs.put("status", ResponseCode.ERROR);  
1722 - rs.put("msg", "车辆 " + clZbh + " 不存在!");  
1723 - return rs;  
1724 - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) {  
1725 - rs.put("status", ResponseCode.ERROR);  
1726 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆");  
1727 - return rs;  
1728 - } else {  
1729 - fLog.log("换车", sch.getClZbh(), clZbh);  
1730 - dayOfSchedule.changeCar(sch, clZbh);  
1731 - }  
1732 - }  
1733 -  
1734 - if(StringUtils.isBlank(jsy) || "/".equals(StringUtils.trim(jsy))){  
1735 - rs.put("status", ResponseCode.ERROR);  
1736 - rs.put("msg", "无效的参数【驾驶员】");  
1737 - return rs;  
1738 - }  
1739 -  
1740 - /**  
1741 - * 换驾驶员  
1742 - */  
1743 - if (StringUtils.isNotEmpty(jsy)) {  
1744 - String jGh = jsy.split("/")[0];  
1745 - String jName = getPersonName(sch.getGsBm(), jGh);  
1746 - if (StringUtils.isEmpty(jName)) {  
1747 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员");  
1748 - rs.put("status", ResponseCode.ERROR);  
1749 - return rs;  
1750 - } else if (!jGh.equals(sch.getjGh())) {  
1751 - fLog.log("换驾驶员", sch.getjGh() + "/" + sch.getjName(), jsy);  
1752 - persoChange(sch, jGh);  
1753 - }  
1754 - }  
1755 -  
1756 - /**  
1757 - * 换售票员  
1758 - */  
1759 - String spy = map.get("spy");  
1760 - if (StringUtils.isNotEmpty(spy) && !StringUtils.trim(spy).equals("/")) {  
1761 - String sGh = spy.split("/")[0];  
1762 -  
1763 - String sName = getPersonName(sch.getGsBm(), sGh);  
1764 - if (StringUtils.isEmpty(sName)) {  
1765 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员");  
1766 - rs.put("status", ResponseCode.ERROR);  
1767 - return rs;  
1768 - } else if (!sGh.equals(sch.getsGh())) {  
1769 - fLog.log("换售票员", sch.getsGh() + "/" + sch.getsName(), spy);  
1770 - persoChangeSPY(sch, sGh);  
1771 - }  
1772 - } else if (StringUtils.isNotEmpty(sch.getsGh())) {  
1773 - fLog.log("撤销售票员");  
1774 - sch.setsGh("");  
1775 - sch.setsName("");  
1776 - }  
1777 -  
1778 - LineConfig config = lineConfigData.get(sch.getXlBm());  
1779 - /**  
1780 - * 调整实发  
1781 - */  
1782 - String fcsjActual = map.get("fcsjActual");  
1783 - if (StringUtils.isNotBlank(fcsjActual)  
1784 - && !fcsjActual.equals(sch.getFcsjActual())) {  
1785 -  
1786 - //long t = 0L;  
1787 - //小于线路开始运营时间,则默认跨过24点  
1788 - long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), fcsjActual, config);  
1789 - /* if (fcsjActual.compareTo(config.getStartOpt()) < 0)  
1790 - t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual);  
1791 - else  
1792 - t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual);*/  
1793 -  
1794 - fLog.log("调整实发时间", sch.getFcsjActual(), fcsjActual);  
1795 - sch.setFcsjActualAll(t);  
1796 - //取消应发未到标记  
1797 - //if(sch.isLate2()){  
1798 - // sch.setLate2(false);  
1799 - LateAdjustHandle.remove(sch);  
1800 - //}  
1801 - } else if (StringUtils.isNotEmpty(sch.getFcsjActual()) && StringUtils.isEmpty(fcsjActual)) {  
1802 - fLog.log("撤销实发时间", sch.getFcsjActual(), "");  
1803 - //撤销实发  
1804 - revokeRealOutgo(sch.getId());  
1805 - }  
1806 -  
1807 - /**  
1808 - * 调整实达  
1809 - */  
1810 - String zdsjActual = map.get("zdsjActual");  
1811 - if (StringUtils.isNotBlank(zdsjActual)  
1812 - && !zdsjActual.equals(sch.getZdsjActual())) {  
1813 -  
1814 - //调整实达  
1815 - fLog.log("调整实达时间", sch.getZdsjActual(), zdsjActual);  
1816 -  
1817 - long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), zdsjActual, config);  
1818 - sch.setZdsjActualAll(t);  
1819 - //路牌下一班起点到达时间  
1820 - ScheduleRealInfo next = dayOfSchedule.nextByLp2(sch);  
1821 - if (null != next) {  
1822 - next.setQdzArrDatesj(zdsjActual);  
1823 - next.setLate2(false);  
1824 - ts.add(next);  
1825 - }  
1826 -  
1827 - //重新计算车辆执行班次  
1828 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
1829 - //取消应发未到标记  
1830 - LateAdjustHandle.remove(sch);  
1831 - } else if (StringUtils.isNotEmpty(sch.getZdsjActual()) && StringUtils.isEmpty(zdsjActual)) {  
1832 - //清除实达时间  
1833 - fLog.log("撤销实达时间", sch.getZdsjActual(), "");  
1834 - sch.clearZdsjActual();  
1835 - //清除路牌下一班起点到达时间  
1836 - ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);  
1837 - if (null != next) {  
1838 - next.setQdzArrDatesj(null);  
1839 - ts.add(next);  
1840 - }  
1841 - //重新计算车辆执行班次  
1842 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
1843 - }  
1844 -  
1845 - /**  
1846 - * 备注  
1847 - */  
1848 - sch.setRemarks(remarks);  
1849 -  
1850 - /**  
1851 - * 烂班  
1852 - */  
1853 - if (map.get("status") != null  
1854 - && Integer.parseInt(map.get("status").toString()) == -1) {  
1855 - destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null);  
1856 - fLog.log("烂班");  
1857 - }  
1858 -  
1859 - /**  
1860 - * 修改班次里程  
1861 - */  
1862 - String jhlc = map.get("jhlc");  
1863 - if (StringUtils.isNotEmpty(jhlc)) {  
1864 - double jhlcNum = Double.parseDouble(jhlc);  
1865 - //烂班  
1866 - if (jhlcNum == 0 && sch.getJhlcOrig() != 0 && !sch._isInout() && !sch.isDestroy()) {  
1867 - destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null);  
1868 - fLog.log("里程设置为0,自动烂班");  
1869 - } else if (jhlcNum != sch.getJhlc()) {  
1870 - fLog.log("设置里程", sch.getJhlc(), jhlcNum);  
1871 - sch.setJhlc(jhlcNum);  
1872 - //临加班次,实际计划一起改  
1873 - if (sch.isSflj())  
1874 - sch.setJhlcOrig(jhlcNum);  
1875 - }  
1876 - }  
1877 -  
1878 - /**  
1879 - * 修改班次类型  
1880 - */  
1881 - String bcType = map.get("bcType");  
1882 - if (StringUtils.isNotEmpty(bcType) && !bcType.equals(sch.getBcType())) {  
1883 - fLog.log("修改班次类型", sch.getBcType(), bcType);  
1884 - sch.setBcType(bcType);  
1885 - }  
1886 -  
1887 - //重新计算班次状态  
1888 - sch.calcStatus();  
1889 - dayOfSchedule.save(sch);  
1890 - //页面需要更新的班次信息  
1891 - ts.add(sch);  
1892 -  
1893 - rs.put("status", ResponseCode.SUCCESS);  
1894 - rs.put("ts", ts);  
1895 -  
1896 - //日志记录结束  
1897 - fLog.end();  
1898 - } catch (Exception e) {  
1899 - logger.error("", e);  
1900 - rs.put("status", ResponseCode.ERROR);  
1901 - }  
1902 - return rs;  
1903 - }  
1904 -  
1905 - @Override  
1906 - public Map<String, Object> outgoAdjustAll(String params) {  
1907 - Map<String, Object> rs = new HashMap<>();  
1908 - try {  
1909 - JSONArray jsonArray = JSONArray.parseArray(params);  
1910 -  
1911 - ScheduleRealInfo schedule = null;  
1912 - JSONObject jsonObj;  
1913 - String dfsj;  
1914 - long id;  
1915 - for (int i = 0; i < jsonArray.size(); i++) {  
1916 - jsonObj = jsonArray.getJSONObject(i);  
1917 - dfsj = jsonObj.getString("t");  
1918 - id = jsonObj.getLong("id");  
1919 - schedule = dayOfSchedule.get(id);  
1920 -  
1921 - if (schedule != null)  
1922 - outgoAdjust(id, null, dfsj, null, "2", null);  
1923 - }  
1924 -  
1925 - rs.put("status", ResponseCode.SUCCESS);  
1926 - //将更新的最后一个班次返回,页面会做全量刷新  
1927 - rs.put("t", schedule);  
1928 - } catch (Exception e) {  
1929 - logger.error("", e);  
1930 - rs.put("status", ResponseCode.ERROR);  
1931 - }  
1932 - return rs;  
1933 - }  
1934 -  
1935 - @Override  
1936 - public Map<String, Object> findRouteByLine(String lineCode) {  
1937 - Map<String, Object> map = new HashMap<>();  
1938 - //上行  
1939 - Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode);  
1940 - map.put("line.id_eq", lineId);  
1941 - map.put("directions_eq", 0);  
1942 - List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map);  
1943 -  
1944 - //下行  
1945 - map.put("directions_eq", 1);  
1946 - List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map);  
1947 -  
1948 - Map<String, Object> rs = new HashMap<>();  
1949 -  
1950 - String upVectors = "", vec;  
1951 - //拼接上行路段  
1952 - for (Map<String, Object> temp : upList) {  
1953 - vec = temp.get("sectionBsectionVector").toString();  
1954 - upVectors += vec.subSequence(11, vec.length() - 2) + " ";  
1955 - }  
1956 -  
1957 - //拼接下行路段  
1958 - String downVectors = "";  
1959 - for (Map<String, Object> temp : downList) {//LINESTRING(  
1960 - vec = temp.get("sectionBsectionVector").toString();  
1961 - downVectors += vec.subSequence(11, vec.length() - 2) + " ";  
1962 - }  
1963 -  
1964 -  
1965 - rs.put("up", upVectors);  
1966 - //上行gcj  
1967 - rs.put("up_gcj", BdToGcjString(upVectors));  
1968 - rs.put("down", downVectors);  
1969 - //下行gcj  
1970 - rs.put("down_gcj", BdToGcjString(downVectors));  
1971 - rs.put("lineId", lineId);  
1972 -  
1973 - return rs;  
1974 - }  
1975 -  
1976 - /**  
1977 - * @param @param bdStr  
1978 - * @throws  
1979 - * @Title: BdToGcjString  
1980 - * @Description: TODO(将百度路由字符串 转 成GCJ 字符串)  
1981 - */  
1982 - public String BdToGcjString(String bdStr) {  
1983 - String[] array = bdStr.split(","), subArray;  
1984 - if (array.length == 0 || bdStr.length() < 2)  
1985 - return "";  
1986 -  
1987 - String gcjStr = "";  
1988 - TransGPS.Location location;  
1989 - for (String crd : array) {  
1990 - subArray = crd.split(" ");  
1991 - if (subArray.length != 2)  
1992 - continue;  
1993 - location = TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1])));  
1994 -  
1995 - gcjStr += location.getLng() + " " + location.getLat() + ",";  
1996 - }  
1997 -  
1998 - return gcjStr.substring(0, gcjStr.length() - 1);  
1999 - }  
2000 -  
2001 - public List<Map<String, String>> findLine(String line) {  
2002 - List<Line> listLine = lineRepository.findLine("%" + line + "%");  
2003 - List<Map<String, String>> list = new ArrayList<Map<String, String>>();  
2004 - Map<String, String> map;  
2005 - for (Line temp : listLine) {  
2006 - if (temp != null) {  
2007 - String xlName = temp.getName();  
2008 - if (xlName.indexOf(line) != -1) {  
2009 - map = new HashMap<String, String>();  
2010 - map.put("id", temp.getLineCode());  
2011 - map.put("text", xlName);  
2012 - list.add(map);  
2013 - }  
2014 - }  
2015 - }  
2016 - return list;  
2017 - }  
2018 -  
2019 - public List<Map<String, String>> findLpName(String lpName) {  
2020 - List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%" + lpName + "%");  
2021 - List<Map<String, String>> list = new ArrayList<Map<String, String>>();  
2022 - Map<String, String> map;  
2023 - for (GuideboardInfo temp : listLpName) {  
2024 - if (temp != null) {  
2025 - String lp = temp.getLpName();  
2026 - if (lp.indexOf(lpName) != -1) {  
2027 - map = new HashMap<String, String>();  
2028 - map.put("id", lp);  
2029 - map.put("text", lp);  
2030 - list.add(map);  
2031 - }  
2032 - }  
2033 - }  
2034 - return list;  
2035 - }  
2036 -  
2037 - @Override  
2038 - public Map<String, Object> findKMBC2(String jName, String clZbh, String date) {  
2039 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date, "", "");  
2040 -  
2041 - DecimalFormat format = new DecimalFormat("0.00");  
2042 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
2043 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
2044 - int jhbc = 0, cjbc = 0, ljbc = 0;  
2045 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;  
2046 - float addMileage = 0l, remMileage = 0l;  
2047 - String j_Name = "";  
2048 - Map<String, Object> map = new HashMap<String, Object>();  
2049 - for (ScheduleRealInfo scheduleRealInfo : list) {  
2050 - if (scheduleRealInfo != null) {  
2051 - j_Name = scheduleRealInfo.getjName();  
2052 - //计划里程(主任务过滤掉临加班次),  
2053 - //烂班里程(主任务烂班),  
2054 - //临加里程(主任务临加),  
2055 - //计划班次,烂班班次,增加班次  
2056 - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();  
2057 - if (scheduleRealInfo.isSflj()) {  
2058 - addMileage += tempJhlc;  
2059 - ljbc++;  
2060 - } else {  
2061 - jhlc += tempJhlc;  
2062 - jhbc++;  
2063 - if (scheduleRealInfo.getStatus() == -1) {  
2064 - remMileage += tempJhlc;  
2065 - cjbc++;  
2066 - }  
2067 - }  
2068 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
2069 - //计算营运里程,空驶里程  
2070 - if (childTaskPlans.isEmpty()) {  
2071 - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")  
2072 - || scheduleRealInfo.getBcType().equals("venting")) {  
2073 - ksgl += tempJhlc;  
2074 - } else {  
2075 - yygl += tempJhlc;  
2076 - }  
2077 - } else {  
2078 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
2079 - while (it.hasNext()) {  
2080 - ChildTaskPlan childTaskPlan = it.next();  
2081 - if (childTaskPlan.getMileageType().equals("empty")) {  
2082 - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
2083 - } else {  
2084 - yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
2085 - }  
2086 - }  
2087 - }  
2088 - }  
2089 - }  
2090 - map.put("j_name", j_Name);  
2091 - map.put("jhlc", format.format(jhlc));  
2092 - map.put("remMileage", format.format(remMileage));  
2093 - map.put("addMileage", format.format(addMileage));  
2094 - map.put("yygl", format.format(yygl));  
2095 - map.put("ksgl", format.format(ksgl));  
2096 - map.put("realMileage", format.format(yygl + ksgl));  
2097 - map.put("jhbc", jhbc);  
2098 - map.put("cjbc", cjbc);  
2099 - map.put("ljbc", ljbc);  
2100 - map.put("sjbc", jhbc - cjbc + ljbc);  
2101 - return map;  
2102 - }  
2103 -  
2104 -  
2105 - public Map<String, Object> findKMBC(String jGh, String clZbh,  
2106 - String lpName, String date, String line) {  
2107 - Map<String, Object> map = new HashMap<String, Object>();  
2108 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);  
2109 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2110 - for (int i = 0; i < list.size(); i++) {  
2111 - ScheduleRealInfo s = list.get(i);  
2112 - Set<ChildTaskPlan> cts = s.getcTasks();  
2113 - if (cts != null && cts.size() > 0) {  
2114 - lists.add(s);  
2115 - } else {  
2116 - if (s.getFcsjActual() != null && s.getZdsjActual() != null) {  
2117 - lists.add(s);  
2118 - }  
2119 - }  
2120 - }  
2121 - map.put("jhbc", culateService.culateJhbc(list, ""));//计划班次  
2122 - map.put("jhlc", Arith.add(culateService.culateJhgl(list),  
2123 - culateService.culateJhJccgl(list))); //计划总里程  
2124 - map.put("cjbc", culateService.culateLbbc(list));//烂班班次  
2125 - map.put("remMileage", culateService.culateLbgl(list)); //烂班公里  
2126 - map.put("ljbc", culateService.culateLjbc(lists, ""));//临加班次  
2127 - double ljgl = culateService.culateLjgl(lists);  
2128 - map.put("addMileage", ljgl); //临加公里  
2129 - map.put("sjbc", culateService.culateSjbc(lists, "") + culateService.culateLjbc(lists, ""));  
2130 - double ksgl = culateService.culateKsgl(list);//子任务空驶公里  
2131 - double jccgl = culateService.culateJccgl(lists);//空驶班次公里  
2132 - map.put("ksgl", ksgl);//空驶公里  
2133 - double sjgl = culateService.culateSjgl(lists);//实际营运公里  
2134 - map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));//总公里  
2135 - map.put("zkslc", Arith.add(ksgl, jccgl));  
2136 - map.put("jcclc", jccgl);  
2137 - map.put("yygl", Arith.add(sjgl, ljgl)); //总营运公里  
2138 - return map;  
2139 - }  
2140 -  
2141 - public Map<String, Object> findKMBC_mh_2(String jGh, String clZbh,  
2142 - String lpName, String date, String line) {  
2143 - Map<String, Object> map = new HashMap<String, Object>();  
2144 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);  
2145 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2146 - for (int i = 0; i < list.size(); i++) {  
2147 - ScheduleRealInfo s = list.get(i);  
2148 - if (s.isDestroy() && s.isReissue()) {  
2149 - s.setRemark("");  
2150 - s.setFcsjActual(s.getDfsj());  
2151 - s.setZdsjActual(s.getZdsj());  
2152 - s.setStatus(2);  
2153 - s.setJhlc(s.getJhlcOrig());  
2154 - }  
2155 -  
2156 - Set<ChildTaskPlan> cts = s.getcTasks();  
2157 - if (cts != null && cts.size() > 0) {  
2158 - lists.add(s);  
2159 - } else {  
2160 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
2161 - lists.add(s);  
2162 - }  
2163 - }  
2164 - }  
2165 - double ksgl = culateService.culateKsgl(list);  
2166 - double sjgl = culateService.culateSjgl(lists);  
2167 - double jccgl = culateService.culateJccgl(lists);  
2168 - double ljgl = culateService.culateLjgl(lists);  
2169 -  
2170 - map.put("jhlc", Arith.add(culateService.culateJhgl(list), culateService.culateJhJccgl(list))); //计划里程  
2171 - map.put("remMileage", culateService.culateLbgl(list)); //烂班公里  
2172 - map.put("addMileage", ljgl); //临加公里  
2173 - map.put("yygl", Arith.add(sjgl, ljgl)); //实际公里  
2174 - map.put("ksgl", ksgl);//空驶公里  
2175 - map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));  
2176 -// map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage));  
2177 - map.put("jhbc", culateService.culateJhbc(list, ""));  
2178 - map.put("cjbc", culateService.culateLbbc(list));  
2179 - map.put("ljbc", culateService.culateLjbc(lists, ""));  
2180 - map.put("sjbc", culateService.culateJhbc(lists, "") - culateService.culateLbbc(lists) + culateService.culateLjbc(lists, ""));  
2181 - map.put("jcclc", jccgl);  
2182 - map.put("zkslc", Arith.add(ksgl, jccgl));  
2183 -// map.put("zkslc", format.format(ksgl + jcclc+addMileageJc));  
2184 - return map;  
2185 - }  
2186 -  
2187 -  
2188 - @Override  
2189 - public List<Map<String, Object>> accountPx(String line, String date,  
2190 - String code, String xlName, String px) {  
2191 -// List<Object[]> lsitObj = scheduleRealInfoRepository.accountPx(line, date, code,px);  
2192 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2193 - if (!code.trim().equals("")) {  
2194 - code = BasicData.deviceId2NbbmMap.inverse().get(code);  
2195 - }  
2196 - String fgs = "";  
2197 - List<Line> lineList = lineRepository.findLineByCode(line);  
2198 - if (lineList.size() > 0) {  
2199 - Line l = lineList.get(0);  
2200 - fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany());  
2201 - }  
2202 - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();  
2203 - String sql = "SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ,"  
2204 - + " device_id FROM bsth_v_report_80 WHERE "  
2205 - + " FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = '" + date + "' AND"  
2206 - + " line_id = '" + line + "' and device_id like '%" + code + "%'";  
2207 - Map<String, Object> map;  
2208 - List<Object[]> lsitObj = jdbcTemplate.query(sql,  
2209 - new RowMapper<Object[]>() {  
2210 - @Override  
2211 - public Object[] mapRow(ResultSet rs, int rowNum) throws SQLException {  
2212 - Object[] t = new Object[3];  
2213 - t[0] = rs.getString("request_code");  
2214 - t[1] = rs.getString("TIMESTAMP");  
2215 - t[2] = rs.getString("device_id");  
2216 - return t;  
2217 - }  
2218 - });  
2219 - int i = 1;  
2220 - for (Object[] obj : lsitObj) {  
2221 - if (obj != null) {  
2222 - map = new HashMap<String, Object>();  
2223 - map.put("num", i++);  
2224 - map.put("xlName", xlName);  
2225 - if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) {  
2226 - List<CarDevice> carDeviceList = new ArrayList<CarDevice>();  
2227 - try {  
2228 - carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString()));  
2229 - } catch (Exception e) {  
2230 - // TODO Auto-generated catch block  
2231 - e.printStackTrace();  
2232 - }  
2233 - if (carDeviceList.size() > 0) {  
2234 - map.put("clZbh", carDeviceList.get(0).getClZbh());  
2235 -  
2236 - } else {  
2237 - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));  
2238 - }  
2239 - } else {  
2240 - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));  
2241 -  
2242 - }  
2243 - map.put("company", fgs);  
2244 - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase());  
2245 - map.put("requestTime", obj[1]);  
2246 - listMap.add(map);  
2247 - }  
2248 - }  
2249 - if (listMap.size() > 1) {  
2250 - if (px.equals("asc")) {  
2251 - Collections.sort(listMap, new AccountMap());  
2252 - } else {  
2253 - Collections.sort(listMap, new AccountMap2());  
2254 - }  
2255 - }  
2256 - return listMap;  
2257 - }  
2258 -  
2259 - @Override  
2260 - public List<Map<String, Object>> account(String line, String date,  
2261 - String code, String xlName, String type) {  
2262 - if (!code.trim().equals("")) {  
2263 - code = BasicData.deviceId2NbbmMap.inverse().get(code);  
2264 - }  
2265 - String fgs = "";  
2266 - List<Line> lineList = lineRepository.findLineByCode(line);  
2267 - if (lineList.size() > 0) {  
2268 - Line l = lineList.get(0);  
2269 - fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany());  
2270 - }  
2271 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2272 - List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code);  
2273 - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();  
2274 - Map<String, Object> map;  
2275 - int i = 1;  
2276 - for (Object[] obj : lsitObj) {  
2277 - if (obj != null) {  
2278 - map = new HashMap<String, Object>();  
2279 - map.put("num", i++);  
2280 - map.put("xlName", xlName);  
2281 - if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) {  
2282 - List<CarDevice> carDeviceList = new ArrayList<CarDevice>();  
2283 - try {  
2284 - carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString()));  
2285 - } catch (Exception e) {  
2286 - // TODO Auto-generated catch block  
2287 - e.printStackTrace();  
2288 - }  
2289 - if (carDeviceList.size() > 0) {  
2290 - map.put("clZbh", carDeviceList.get(0).getClZbh());  
2291 -  
2292 - } else {  
2293 - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));  
2294 - }  
2295 - } else {  
2296 - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));  
2297 -  
2298 - }  
2299 - map.put("company", fgs);  
2300 - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase());  
2301 - map.put("requestTime", obj[1]);  
2302 - listMap.add(map);  
2303 - }  
2304 - }  
2305 -  
2306 - if (type != null && type.length() != 0 && type.equals("export")) {  
2307 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
2308 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
2309 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
2310 - Map<String, Object> m = new HashMap<String, Object>();  
2311 - ReportUtils ee = new ReportUtils();  
2312 - Map<String, Object> typeMap = new HashMap<String, Object>();  
2313 - typeMap.put("0xA1", "请求恢复运营");  
2314 - typeMap.put("0xA2", "申请调档");  
2315 - typeMap.put("0xA3", "出场请求");  
2316 - typeMap.put("0xA5", "进场请求");  
2317 - typeMap.put("0xA7", "加油请求");  
2318 - typeMap.put("0x50", "车辆故障");  
2319 - typeMap.put("0x70", "路阻报告");  
2320 - typeMap.put("0x60", "事故报告");  
2321 - typeMap.put("0x11", "扣证纠纷");  
2322 - typeMap.put("0x12", "报警");  
2323 - for (Map<String, Object> map1 : listMap) {  
2324 - map1.put("requestText", typeMap.get(map1.get("requestType")));  
2325 - }  
2326 - try {  
2327 - listI.add(listMap.iterator());  
2328 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
2329 - ee.excelReplace(listI, new Object[]{m}, path + "mould/account.xls",  
2330 - path + "export/" + sdfSimple.format(sdfMonth.parse(date))  
2331 - + "-" + xlName + "-驾驶员请求台账.xls");  
2332 - } catch (Exception e) {  
2333 - // TODO: handle exception  
2334 - e.printStackTrace();  
2335 - }  
2336 - }  
2337 -  
2338 - return listMap;  
2339 - }  
2340 -  
2341 - @Override  
2342 - public List<SchEditInfoDto> correctForm(String line, String date, String endDate,  
2343 - String lpName, String code, String type, String changType) {  
2344 -  
2345 -// var types = {'DFTZ': '待发调整', 'FCXXWT':'发车信息微调', 'JHLB': '班次取消', 'CXLB': '撤销烂班',  
2346 -// 'CXZX': '撤销执行', 'CXSF': '撤销实发', 'SFTZ': '实发调整', 'TZRC': '调整人车'};  
2347 - Map<String, Object> map = new HashMap<String, Object>();  
2348 - map.put("DFTZ", "待发调整");  
2349 - map.put("FCXXWT", "发车信息微调");  
2350 - map.put("JHLB", "班次取消");  
2351 - map.put("CXLB", "撤销烂班");  
2352 - map.put("CXZX", "撤销执行");  
2353 - map.put("CXSF", "撤销实发");  
2354 - map.put("SFTZ", "实发调整");  
2355 - map.put("TZRC", "调整人车");  
2356 -  
2357 - SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");  
2358 - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
2359 - String cont = "";  
2360 - cont = " and xl_bm ='" + line + "'";  
2361 - if (!lpName.equals("")) {  
2362 - cont += " and lp_name = '" + lpName + "'";  
2363 - }  
2364 - if (!code.equals("")) {  
2365 - cont += " and cl_zbh ='" + code + "'";  
2366 - }  
2367 - String sql = "select t1.*, t2.real_exec_date,"  
2368 - + "t2.fcsj,t2.lp_name,t2.cl_zbh,t2.j_gh,t2.j_name,"  
2369 - + "t2.xl_dir,t2.real_exec_date from (select * from "  
2370 - + "logger_sch_modify where rq BETWEEN ? and ? and line_code=? )"  
2371 - + " t1 INNER JOIN bsth_c_s_sp_info_real t2 on "  
2372 - + "t1.sch_id=t2.id where 1=1 " + cont;  
2373 -  
2374 - List<SchEditInfoDto> list = jdbcTemplate.query(sql,  
2375 - new BeanPropertyRowMapper(SchEditInfoDto.class), date, endDate, line);  
2376 - List<SchEditInfoDto> lists = new ArrayList<SchEditInfoDto>();  
2377 - for (int i = 0; i < list.size(); i++) {  
2378 - Long fcsjs = 0l;  
2379 - Long updsj = 0l;  
2380 - SchEditInfoDto t = list.get(i);  
2381 - if (map.get(t.getType()) != null) {  
2382 -  
2383 - if (changType.equals("")) {  
2384 - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";");  
2385 - } else {  
2386 - String fcsj = "";  
2387 - String updtime = "";  
2388 - try {  
2389 - fcsj = sdf1.format(sdf1.parse(t.getFcsj()));  
2390 - updtime = sdf1.format(sdf1.parse(t.getTimeStr()));  
2391 - fcsjs = sdf2.parse(t.getRealExecDate() + " " + fcsj).getTime();  
2392 - updsj = sdf2.parse(t.getRq() + " " + updtime).getTime();  
2393 - } catch (ParseException e) {  
2394 - // TODO Auto-generated catch block  
2395 - e.printStackTrace();  
2396 - }  
2397 - if (changType.equals("1")) {  
2398 - if (fcsjs > updsj) {  
2399 - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";");  
2400 - } else {  
2401 - t.setType2("");  
2402 - }  
2403 - } else if (changType.equals("2")) {  
2404 - if (fcsjs < updsj) {  
2405 - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";");  
2406 - } else {  
2407 - t.setType2("");  
2408 - }  
2409 - }  
2410 - }  
2411 - } else {  
2412 - t.setType2("");  
2413 - }  
2414 - boolean fage = true;  
2415 - for (int j = 0; j < lists.size(); j++) {  
2416 - SchEditInfoDto s = lists.get(j);  
2417 - if (s.getSchId() == t.getSchId()) {  
2418 - s.setType2(s.getType2() + " " + t.getType2());  
2419 - fage = false;  
2420 - }  
2421 - }  
2422 -  
2423 - if (fage) {  
2424 - if (changType.equals("")) {  
2425 - lists.add(t);  
2426 - } else {  
2427 - if (changType.equals("1")) {  
2428 - if (fcsjs > updsj) {  
2429 - lists.add(t);  
2430 - }  
2431 - } else if (changType.equals("2")) {  
2432 - if (fcsjs < updsj) {  
2433 - lists.add(t);  
2434 - }  
2435 - }  
2436 - }  
2437 - }  
2438 - }  
2439 -  
2440 - if (type != null && type.length() != 0 && type.equals("export")) {  
2441 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
2442 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
2443 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
2444 - Map<String, Object> m = new HashMap<String, Object>();  
2445 - m.put("dates", date);  
2446 - ReportUtils ee = new ReportUtils();  
2447 - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();  
2448 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2449 - for (SchEditInfoDto d : lists) {  
2450 - Map<String, Object> tempMap = new HashMap<String, Object>();  
2451 - tempMap.put("lpName", d.getLpName());  
2452 - tempMap.put("rq", d.getRq());  
2453 - tempMap.put("clZbh", d.getClZbh());  
2454 - tempMap.put("jName", d.getjName() + "/" + d.getjGh());  
2455 - tempMap.put("fcsj", d.getFcsj());  
2456 - tempMap.put("type", d.getType2());  
2457 - tempList.add(tempMap);  
2458 - }  
2459 - try {  
2460 - String dateTime = sdfSimple.format(sdfMonth.parse(date));  
2461 - if(!endDate.equals(date)){  
2462 - dateTime += "-" + sdfSimple.format(sdfMonth.parse(endDate));  
2463 - }  
2464 - String lineName = BasicData.lineCode2NameMap.get(line);  
2465 - listI.add(tempList.iterator());  
2466 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
2467 - ee.excelReplace(listI, new Object[]{m}, path + "mould/correctForm.xls",  
2468 - path + "export/" + dateTime + "-" + lineName + "-修正报表.xls");  
2469 - } catch (Exception e) {  
2470 - // TODO: handle exception  
2471 - e.printStackTrace();  
2472 - }  
2473 -// Map<String, Object> maps = tempList.get(tempList.size() - 1);  
2474 - }  
2475 - return lists;  
2476 - }  
2477 -  
2478 - @Override  
2479 - public List<ScheduleRealInfo> queryListWaybill(String jGh, String clZbh,  
2480 - String lpName, String date, String line) {  
2481 - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();  
2482 - List<ScheduleRealInfo> list = null;  
2483 - list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);  
2484 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
2485 - String minfcsj = "02:00";  
2486 - List<Line> lineList = lineRepository.findLineByCode(line);  
2487 - if (lineList.size() > 0) {  
2488 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
2489 - + " id = ("  
2490 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
2491 - + ")";  
2492 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
2493 - }  
2494 - String[] minSjs = minfcsj.split(":");  
2495 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
2496 -  
2497 - for (int i = 0; i < list.size(); i++) {  
2498 - ScheduleRealInfo s = list.get(i);  
2499 - if (s.getBcType().equals("out")) {  
2500 - s.setRemark("1");  
2501 - } else if (s.getBcType().equals("in")) {  
2502 - s.setRemark("3");  
2503 - } else {  
2504 - s.setRemark("2");  
2505 - }  
2506 - String[] fcsj = s.getFcsj().split(":");  
2507 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
2508 -  
2509 - Long fscjT = 0L;  
2510 - if (fcsjL < minSj) {  
2511 - Calendar calendar = new GregorianCalendar();  
2512 - calendar.setTime(s.getScheduleDate());  
2513 - calendar.add(calendar.DATE, 1);  
2514 - s.setScheduleDate(calendar.getTime());  
2515 - try {  
2516 - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();  
2517 - } catch (ParseException e) {  
2518 - // TODO Auto-generated catch block  
2519 - e.printStackTrace();  
2520 - }  
2521 -  
2522 - } else {  
2523 - try {  
2524 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
2525 - } catch (ParseException e) {  
2526 - // TODO Auto-generated catch block  
2527 - e.printStackTrace();  
2528 - }  
2529 - ;  
2530 - }  
2531 - s.setFcsjT(fscjT);  
2532 - }  
2533 - Collections.sort(list, new compareFcsjType());  
2534 - for (int i = 0; i < list.size(); i++) {  
2535 - ScheduleRealInfo s = list.get(i);  
2536 - s.setAdjustExps(i + 1 + "");  
2537 - String remarks = "";  
2538 - if (s.getRemarks() != null) {  
2539 - remarks += s.getRemarks();  
2540 - }  
2541 -  
2542 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
2543 - if (!childTaskPlans.isEmpty()) {  
2544 - s.setFcsjActual("");  
2545 - s.setZdsjActual("");  
2546 - s.setJhlc(0.0);  
2547 - }  
2548 -  
2549 - if (s.isDestroy()) {  
2550 - s.setFcsjActual("");  
2551 - s.setZdsjActual("");  
2552 - s.setJhlc(0.0);  
2553 - remarks += "(烂班)";  
2554 - s.setRemarks(remarks);  
2555 - }  
2556 -  
2557 - listSchedule.add(s);  
2558 - //计算营运里程,空驶里程  
2559 - if (!childTaskPlans.isEmpty()) {  
2560 -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
2561 - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);  
2562 - Collections.sort(listit, new ComparableChild());  
2563 - for (int j = 0; j < listit.size(); j++) {  
2564 - ScheduleRealInfo t = new ScheduleRealInfo();  
2565 - ChildTaskPlan childTaskPlan = listit.get(j);  
2566 - if (childTaskPlan.getCcId() == null) {  
2567 - if (childTaskPlan.isDestroy()) {  
2568 - t.setFcsjActual("");  
2569 - t.setZdsjActual("");  
2570 - t.setJhlc(0.0);  
2571 - } else {  
2572 - t.setFcsjActual(childTaskPlan.getStartDate());  
2573 - t.setZdsjActual(childTaskPlan.getEndDate());  
2574 - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));  
2575 - }  
2576 - t.setFcsj(childTaskPlan.getStartDate());  
2577 - t.setZdsj(childTaskPlan.getEndDate());  
2578 - t.setQdzName(childTaskPlan.getStartStationName());  
2579 - t.setZdzName(childTaskPlan.getEndStationName());  
2580 - t.setRemarks(childTaskPlan.getRemarks());  
2581 - t.setAdjustExps("子");  
2582 - listSchedule.add(t);  
2583 - }  
2584 - }  
2585 - }  
2586 - }  
2587 -  
2588 - return listSchedule;  
2589 - }  
2590 -  
2591 - @Override  
2592 - public List<ScheduleRealInfo> queryListWaybill2(String jName, String clZbh,  
2593 - String lpName, String date, String line) {  
2594 - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();  
2595 - List<ScheduleRealInfo> list = null;  
2596 - list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date, line);  
2597 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
2598 - String minfcsj = "02:00";  
2599 - List<Line> lineList = lineRepository.findLineByCode(line);  
2600 - if (lineList.size() > 0) {  
2601 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
2602 - + " id = ("  
2603 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
2604 - + ")";  
2605 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
2606 - }  
2607 - String[] minSjs = minfcsj.split(":");  
2608 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
2609 -  
2610 - for (int i = 0; i < list.size(); i++) {  
2611 - ScheduleRealInfo s = list.get(i);  
2612 - String[] fcsj = s.getFcsj().split(":");  
2613 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
2614 -  
2615 - Long fscjT = 0L;  
2616 - if (fcsjL < minSj) {  
2617 - Calendar calendar = new GregorianCalendar();  
2618 - calendar.setTime(s.getScheduleDate());  
2619 - calendar.add(calendar.DATE, 1);  
2620 - s.setScheduleDate(calendar.getTime());  
2621 - try {  
2622 - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();  
2623 - } catch (ParseException e) {  
2624 - // TODO Auto-generated catch block  
2625 - e.printStackTrace();  
2626 - }  
2627 -  
2628 - } else {  
2629 - try {  
2630 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
2631 - } catch (ParseException e) {  
2632 - // TODO Auto-generated catch block  
2633 - e.printStackTrace();  
2634 - }  
2635 - ;  
2636 - }  
2637 - s.setFcsjT(fscjT);  
2638 - }  
2639 - Collections.sort(list, new ComparableReal());  
2640 - for (int i = 0; i < list.size(); i++) {  
2641 - ScheduleRealInfo s = list.get(i);  
2642 - s.setAdjustExps(i + 1 + "");  
2643 - String remarks = "";  
2644 - if (s.getRemarks() != null) {  
2645 - remarks += s.getRemarks();  
2646 - }  
2647 -  
2648 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
2649 - if (!childTaskPlans.isEmpty()) {  
2650 - s.setFcsjActual("");  
2651 - s.setZdsjActual("");  
2652 - s.setJhlc(0.0);  
2653 - }  
2654 -  
2655 - if (s.isDestroy()) {  
2656 - if (s.isReissue()) {  
2657 - s.setFcsjActual(s.getDfsj());  
2658 - s.setZdsjActual(s.getZdsj());  
2659 - s.setRemarks("");  
2660 - s.setStatus(2);  
2661 - s.setJhlc(s.getJhlcOrig());  
2662 - } else {  
2663 - s.setFcsjActual("");  
2664 - s.setZdsjActual("");  
2665 - s.setJhlc(0.0);  
2666 - remarks += "(烂班)";  
2667 - s.setRemarks(remarks);  
2668 - }  
2669 - }  
2670 -  
2671 - listSchedule.add(s);  
2672 - //计算营运里程,空驶里程  
2673 - if (!childTaskPlans.isEmpty()) {  
2674 -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
2675 - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);  
2676 - Collections.sort(listit, new ComparableChild());  
2677 - for (int j = 0; j < listit.size(); j++) {  
2678 - ScheduleRealInfo t = new ScheduleRealInfo();  
2679 - ChildTaskPlan childTaskPlan = listit.get(j);  
2680 - if (childTaskPlan.isDestroy()) {  
2681 - t.setFcsjActual("");  
2682 - t.setZdsjActual("");  
2683 - t.setJhlc(0.0);  
2684 - } else {  
2685 - t.setFcsjActual(childTaskPlan.getStartDate());  
2686 - t.setZdsjActual(childTaskPlan.getEndDate());  
2687 - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));  
2688 - }  
2689 - t.setQdzName(childTaskPlan.getStartStationName());  
2690 - t.setZdzName(childTaskPlan.getEndStationName());  
2691 - t.setRemarks(childTaskPlan.getRemarks());  
2692 - t.setAdjustExps("子");  
2693 - listSchedule.add(t);  
2694 - }  
2695 - }  
2696 - }  
2697 -  
2698 - return listSchedule;  
2699 - }  
2700 -  
2701 - @Override  
2702 - public Map<String, Object> removeChildTask(Long taskId) {  
2703 - Map<String, Object> rs = new HashMap<>();  
2704 - ChildTaskPlan chTask = cTaskPlanRepository.findById(taskId).get();  
2705 -  
2706 - ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId());  
2707 - try {  
2708 -  
2709 - sch.getcTasks().remove(chTask);  
2710 - scheduleRealInfoRepository.save(sch);  
2711 - rs.put("status", ResponseCode.SUCCESS);  
2712 - } catch (Exception e) {  
2713 - logger.error("", e);  
2714 - rs.put("status", ResponseCode.ERROR);  
2715 - }  
2716 - return rs;  
2717 - }  
2718 -  
2719 - @Override  
2720 - public List<Map<String, Object>> statisticsDaily(String line, String date,  
2721 - String xlName, String type) {  
2722 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
2723 - List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);  
2724 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2725 - for (int i = 0; i < list_s.size(); i++) {  
2726 - ScheduleRealInfo s = list_s.get(i);  
2727 - Set<ChildTaskPlan> cts = s.getcTasks();  
2728 - if (cts != null && cts.size() > 0) {  
2729 - lists.add(s);  
2730 - } else {  
2731 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
2732 - lists.add(s);  
2733 - }  
2734 - }  
2735 - }  
2736 - Map<String, Object> map = new HashMap<String, Object>();  
2737 - map.put("xlName", xlName);  
2738 - double jhlc = culateService.culateJhgl(list_s);  
2739 - map.put("jhlc", jhlc);  
2740 - map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists)));  
2741 - double lbgl = culateService.culateLbgl(list_s);  
2742 - map.put("ssgl", lbgl);  
2743 - map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻"));  
2744 - map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢"));  
2745 - map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障"));  
2746 - map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷"));  
2747 - map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事"));  
2748 - map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人"));  
2749 - map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车"));  
2750 - map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀"));  
2751 - map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候"));  
2752 - map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外"));  
2753 - map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚"));  
2754 - double ssgl_pc = culateService.culateCJLC(list_s, "配车");  
2755 - double ssgl_by = culateService.culateCJLC(list_s, "保养");  
2756 - double ssgl_cj = culateService.culateCJLC(list_s, "抽减");  
2757 - double ssgl_qt = culateService.culateCJLC(list_s, "其他");  
2758 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
2759 - map.put("ssbc", culateService.culateLbbc(list_s));  
2760 - double ljgl = culateService.culateLjgl(lists);  
2761 - map.put("ljgl", ljgl);  
2762 - map.put("jhbc", culateService.culateJhbc(list_s, ""));  
2763 - map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf"));  
2764 - map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf"));  
2765 - map.put("sjbc", culateService.culateSjbc(lists, ""));  
2766 - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf"));  
2767 - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf"));  
2768 - map.put("ljbc", culateService.culateLjbc(lists, ""));  
2769 - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf"));  
2770 - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf"));  
2771 - map.put("fzbc", culateService.culateFzbc(lists, ""));  
2772 - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));  
2773 - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));  
2774 - map.put("dtbc", 0);  
2775 - map.put("dtbc_m", 0);  
2776 - map.put("dtbc_a", 0);  
2777 - List<CalcInterval> intervalList=calcIntervalRepository.selectByDateAndLine(line, date,"");  
2778 - if(intervalList.size()>0){  
2779 - CalcInterval c=intervalList.get(0);  
2780 - map.put("djg",c.getDjgAll());  
2781 - map.put("djg_m", c.getDjgZgf());  
2782 - map.put("djg_a", c.getDjgWgf());  
2783 - map.put("djg_time", c.getDjgTime());  
2784 - }else{  
2785 - Map<String, Object> m = culateService.culateDjg(list_s, line);  
2786 - map.put("djg", m.get("djgcsq"));  
2787 - map.put("djg_m", m.get("djgcsz"));  
2788 - map.put("djg_a", m.get("djgcsw"));  
2789 - map.put("djg_time", m.get("djgsj"));  
2790 - }  
2791 -  
2792 - map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl));  
2793 - lMap.add(map);  
2794 -  
2795 - if (date.length() == 10) {  
2796 - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59");  
2797 - String dbdp = "";  
2798 - try {  
2799 - for (int i = 0; i < list.size(); i++) {  
2800 - DutyEmployee t = list.get(i);  
2801 - if (dbdp.indexOf(t.getuName()) == -1) {  
2802 - if (!(dbdp.length() > 0)) {  
2803 - dbdp = t.getuName();  
2804 - } else {  
2805 - dbdp += "," + t.getuName();  
2806 - }  
2807 - }  
2808 - }  
2809 - } catch (Exception e) {  
2810 - // TODO: handle exception  
2811 - e.printStackTrace();  
2812 - }  
2813 - map.put("dbdp", dbdp);  
2814 - }  
2815 -  
2816 - return lMap;  
2817 - }  
2818 -  
2819 - @Override  
2820 - public List<Map<String, Object>> statisticsDaily_mh_2(String line, String date,  
2821 - String xlName, String type) {  
2822 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
2823 - List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);  
2824 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2825 - for (int i = 0; i < list_s.size(); i++) {  
2826 - ScheduleRealInfo s = list_s.get(i);  
2827 - if (s.isDestroy() && s.isReissue()) {  
2828 - s.setRemark("");  
2829 - s.setFcsjActual(s.getDfsj());  
2830 - s.setZdsjActual(s.getZdsj());  
2831 - s.setStatus(2);  
2832 - s.setJhlc(s.getJhlcOrig());  
2833 - }  
2834 -  
2835 - Set<ChildTaskPlan> cts = s.getcTasks();  
2836 - if (cts != null && cts.size() > 0) {  
2837 - lists.add(s);  
2838 - } else {  
2839 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
2840 - lists.add(s);  
2841 - }  
2842 - }  
2843 - }  
2844 - Map<String, Object> map = new HashMap<String, Object>();  
2845 - map.put("xlName", xlName);  
2846 - double jhlc = culateService.culateJhgl(list_s);  
2847 - map.put("jhlc", jhlc);  
2848 - map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists)));  
2849 - double lbgl = culateService.culateLbgl(list_s);  
2850 - map.put("ssgl", lbgl);  
2851 - map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻"));  
2852 - map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢"));  
2853 - map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障"));  
2854 - map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷"));  
2855 - map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事"));  
2856 - map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人"));  
2857 - map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车"));  
2858 - map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀"));  
2859 - map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候"));  
2860 - map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外"));  
2861 - map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚"));  
2862 - double ssgl_pc = culateService.culateCJLC(list_s, "配车");  
2863 - double ssgl_by = culateService.culateCJLC(list_s, "保养");  
2864 - double ssgl_cj = culateService.culateCJLC(list_s, "抽减");  
2865 - double ssgl_qt = culateService.culateCJLC(list_s, "其他");  
2866 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
2867 - map.put("ssbc", culateService.culateLbbc(list_s));  
2868 - double ljgl = culateService.culateLjgl(lists);  
2869 - map.put("ljgl", ljgl);  
2870 - map.put("jhbc", culateService.culateJhbc(list_s, ""));  
2871 - map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf"));  
2872 - map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf"));  
2873 - map.put("sjbc", culateService.culateSjbc(lists, ""));  
2874 - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf"));  
2875 - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf"));  
2876 - map.put("ljbc", culateService.culateLjbc(lists, ""));  
2877 - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf"));  
2878 - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf"));  
2879 - map.put("fzbc", culateService.culateFzbc(lists, ""));  
2880 - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));  
2881 - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));  
2882 - map.put("dtbc", 0);  
2883 - map.put("dtbc_m", 0);  
2884 - map.put("dtbc_a", 0);  
2885 - map.put("djg", 0);  
2886 - map.put("djg_m", 0);  
2887 - map.put("djg_a", 0);  
2888 - map.put("djg_time", 0);  
2889 - map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl));  
2890 - lMap.add(map);  
2891 - return lMap;  
2892 - }  
2893 -  
2894 - public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,Map<String, Object> m) {  
2895 -  
2896 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2897 - for (int i = 0; i < list.size(); i++) {  
2898 - ScheduleRealInfo s = list.get(i);  
2899 - Set<ChildTaskPlan> cts = s.getcTasks();  
2900 - if (cts != null && cts.size() > 0) {  
2901 - lists.add(s);  
2902 - } else {  
2903 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
2904 - lists.add(s);  
2905 - }  
2906 - }  
2907 - }  
2908 - Map<String, Object> map = new HashMap<String, Object>();  
2909 - if (list.size() > 0) {  
2910 - map.put("gsBm", list.get(0).getGsBm());  
2911 - map.put("fgsBm", list.get(0).getFgsBm());  
2912 - map.put("xlBm", list.get(0).getXlBm());  
2913 - map.put("xlName", list.get(0).getXlName());  
2914 - map.put("fgsName", list.get(0).getFgsName());  
2915 - map.put("gsName", list.get(0).getGsName());  
2916 -  
2917 - try {  
2918 - map.put("xlNamePy", PinyinHelper.convertToPinyinString(list.get(0).getGsBm()+list.get(0).getFgsBm()+list.get(0).getXlName(), "", PinyinFormat.WITHOUT_TONE));  
2919 - } catch (PinyinException e) {  
2920 - // TODO Auto-generated catch block  
2921 - e.printStackTrace();  
2922 - }  
2923 - double jhyygl = culateService.culateJhgl(list);//计划营运公里  
2924 - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)  
2925 - map.put("jhlc", jhyygl);  
2926 - map.put("jcclc", jhjcclc);  
2927 - map.put("jhzlc", Arith.add(jhyygl, jhjcclc));  
2928 - double ljks=culateService.culateLjksgl(lists);  
2929 - map.put("ljks", ljks);  
2930 - double ljgl = culateService.culateLjgl(lists);  
2931 - double sjyygl = culateService.culateSjgl(lists);  
2932 - double zyygl = Arith.add(sjyygl, ljgl);  
2933 -  
2934 - double sjjccgl = culateService.culateJccgl(lists);  
2935 - double sjksgl = culateService.culateKsgl(lists);  
2936 - double zksgl = Arith.add(sjjccgl, sjksgl);  
2937 - map.put("sjzgl", Arith.add(zyygl, zksgl));  
2938 - map.put("sjgl", zyygl);  
2939 - map.put("sjksgl", zksgl);  
2940 - double ssgl = culateService.culateLbgl(list);  
2941 - map.put("ssgl", ssgl);  
2942 -  
2943 - //计划+临加-少驶=实驶  
2944 - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl);  
2945 - if (jl == zyygl) {  
2946 - map.put("zt", 0);  
2947 - } else {  
2948 - map.put("zt", 1);  
2949 - }  
2950 -  
2951 - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻"));  
2952 - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢"));  
2953 - map.put("ssgl_gz", culateService.culateCJLC(list, "故障"));  
2954 - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷"));  
2955 - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事"));  
2956 - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人"));  
2957 - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车"));  
2958 - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀"));  
2959 - map.put("ssgl_qh", culateService.culateCJLC(list, "气候"));  
2960 - map.put("ssgl_yw", culateService.culateCJLC(list, "援外"));  
2961 - map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚"));  
2962 - double ssgl_pc = culateService.culateCJLC(list, "配车");  
2963 - double ssgl_by = culateService.culateCJLC(list, "保养");  
2964 - double ssgl_cj = culateService.culateCJLC(list, "抽减");  
2965 - double ssgl_qt = culateService.culateCJLC(list, "其他");  
2966 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
2967 - map.put("ssbc", culateService.culateLbbc(list));  
2968 - map.put("ljgl", ljgl);  
2969 - map.put("jhbc", culateService.culateJhbc(list, ""));  
2970 - map.put("jhbc_m", culateService.culateJhbc(list, "zgf"));  
2971 - map.put("jhbc_a", culateService.culateJhbc(list, "wgf"));  
2972 - map.put("sjbc", culateService.culateSjbc(lists, ""));  
2973 - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf"));  
2974 - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf"));  
2975 - map.put("ljbc", culateService.culateLjbc(lists, ""));  
2976 - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf"));  
2977 - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf"));  
2978 - map.put("fzbc", culateService.culateFzbc(lists, ""));  
2979 - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));  
2980 - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));  
2981 - map.put("dtbc", 0);  
2982 - map.put("dtbc_m", 0);  
2983 - map.put("dtbc_a", 0);  
2984 - if(m.get("xl")==null){  
2985 - Map<String, Object> m_ = culateService.culateDjg(lists, list.get(0).getXlBm());  
2986 - map.put("djg", m_.get("djgcsq"));  
2987 - map.put("djg_m", m_.get("djgcsz"));  
2988 - map.put("djg_a", m_.get("djgcsw"));  
2989 - map.put("djg_time", m_.get("djgsj"));  
2990 - }else{  
2991 - map.put("djg", m.get("djgAll")==null?"0":m.get("djgAll"));  
2992 - map.put("djg_m", m.get("djgZgf")==null?"0":m.get("djgZgf"));  
2993 - map.put("djg_a", m.get("djgWgf")==null?"0":m.get("djgWgf"));  
2994 - map.put("djg_time", m.get("djgTime")==null?"0":m.get("djgTime"));  
2995 - }  
2996 - }  
2997 - return map;  
2998 - }  
2999 -  
3000 - @Override  
3001 - public List<Map<String, Object>> dispatchDailySum(String date, String date2, String nature, String type) {  
3002 - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();  
3003 -  
3004 -// List<Map<String, Object>> list = statisticsDailyTj("", "", "", date, date2, "", "query", nature);  
3005 - List<CalcStatistics> calc = calcWaybillService.calcStatisticsDaily("", "", "", date, date2, "", "query", nature);  
3006 - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();  
3007 - try {  
3008 - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();  
3009 - for(CalcStatistics c : calc){  
3010 - Map<String, Object> m = new HashMap<>();  
3011 - Field[] fields = c.getClass().getDeclaredFields();  
3012 - for(Field f : fields){  
3013 - f.setAccessible(true);  
3014 - String key = new String(f.getName());  
3015 - m.put(key, f.get(c));  
3016 - }  
3017 - tempList.add(m);  
3018 - }  
3019 - list = tempList;  
3020 - } catch (Exception e) {  
3021 - // TODO: handle exception  
3022 - e.printStackTrace();  
3023 - }  
3024 -  
3025 - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>();  
3026 - Map<String, Object> temp = new HashMap<String, Object>();  
3027 - temp.put("gsName", "杨高");temp.put("fgsName", "杨高分");temp.put("key", "05_5");  
3028 - resList.add(temp);keyMap.put("05_5", temp);  
3029 - temp = new HashMap<String, Object>();  
3030 - temp.put("gsName", "杨高");temp.put("fgsName", "金桥分");temp.put("key", "05_2");  
3031 - resList.add(temp);keyMap.put("05_2", temp);  
3032 - temp = new HashMap<String, Object>();  
3033 - temp.put("gsName", "杨高");temp.put("fgsName", "川沙分");temp.put("key", "05_1");  
3034 - resList.add(temp);keyMap.put("05_1", temp);  
3035 - temp = new HashMap<String, Object>();  
3036 - temp.put("gsName", "杨高");temp.put("fgsName", "周浦分");temp.put("key", "05_6");  
3037 - resList.add(temp);keyMap.put("05_6", temp);  
3038 - temp = new HashMap<String, Object>();  
3039 - temp.put("gsName", "杨高");temp.put("fgsName", "小计");temp.put("key", "05_sum");  
3040 - resList.add(temp);keyMap.put("05_sum", temp);  
3041 -  
3042 - temp = new HashMap<String, Object>();  
3043 - temp.put("gsName", "上南");temp.put("fgsName", "一分");temp.put("key", "55_4");  
3044 - resList.add(temp);keyMap.put("55_4", temp);  
3045 - temp = new HashMap<String, Object>();  
3046 - temp.put("gsName", "上南");temp.put("fgsName", "二分");temp.put("key", "55_1");  
3047 - resList.add(temp);keyMap.put("55_1", temp);  
3048 - temp = new HashMap<String, Object>();  
3049 - temp.put("gsName", "上南");temp.put("fgsName", "三分");temp.put("key", "55_2");  
3050 - resList.add(temp);keyMap.put("55_2", temp);  
3051 - temp = new HashMap<String, Object>();  
3052 - temp.put("gsName", "上南");temp.put("fgsName", "六分");temp.put("key", "55_3");  
3053 - resList.add(temp);keyMap.put("55_3", temp);  
3054 - temp = new HashMap<String, Object>();  
3055 - temp.put("gsName", "上南");temp.put("fgsName", "小计");temp.put("key", "55_sum");  
3056 - resList.add(temp);keyMap.put("55_sum", temp);  
3057 -  
3058 - temp = new HashMap<String, Object>();  
3059 - temp.put("gsName", "金高");temp.put("fgsName", "一分");temp.put("key", "22_5");  
3060 - resList.add(temp);keyMap.put("22_5", temp);  
3061 - temp = new HashMap<String, Object>();  
3062 - temp.put("gsName", "金高");temp.put("fgsName", "二分");temp.put("key", "22_2");  
3063 - resList.add(temp);keyMap.put("22_2", temp);  
3064 - temp = new HashMap<String, Object>();  
3065 - temp.put("gsName", "金高");temp.put("fgsName", "三分");temp.put("key", "22_3");  
3066 - resList.add(temp);keyMap.put("22_3", temp);  
3067 - temp = new HashMap<String, Object>();  
3068 - temp.put("gsName", "金高");temp.put("fgsName", "四分");temp.put("key", "22_1");  
3069 - resList.add(temp);keyMap.put("22_1", temp);  
3070 - temp = new HashMap<String, Object>();  
3071 - temp.put("gsName", "金高");temp.put("fgsName", "小计");temp.put("key", "22_sum");  
3072 - resList.add(temp);keyMap.put("22_sum", temp);  
3073 -  
3074 - temp = new HashMap<String, Object>();  
3075 - temp.put("gsName", "南汇");temp.put("fgsName", "一分");temp.put("key", "26_1");  
3076 - resList.add(temp);keyMap.put("26_1", temp);  
3077 - temp = new HashMap<String, Object>();  
3078 - temp.put("gsName", "南汇");temp.put("fgsName", "二分");temp.put("key", "26_2");  
3079 - resList.add(temp);keyMap.put("26_2", temp);  
3080 - temp = new HashMap<String, Object>();  
3081 - temp.put("gsName", "南汇");temp.put("fgsName", "三分");temp.put("key", "26_3");  
3082 - resList.add(temp);keyMap.put("26_3", temp);  
3083 - temp = new HashMap<String, Object>();  
3084 - temp.put("gsName", "南汇");temp.put("fgsName", "六分");temp.put("key", "26_6");  
3085 - resList.add(temp);keyMap.put("26_6", temp);  
3086 - temp = new HashMap<String, Object>();  
3087 - temp.put("gsName", "南汇");temp.put("fgsName", "小计");temp.put("key", "26_sum");  
3088 - resList.add(temp);keyMap.put("26_sum", temp);  
3089 -  
3090 - temp = new HashMap<String, Object>();  
3091 - temp.put("gsName", "浦交");temp.put("fgsName", " ");temp.put("key", "88");  
3092 - resList.add(temp);keyMap.put("88", temp);  
3093 -  
3094 - for(Map<String, Object> m : list){  
3095 - m.put("gsBm", m.get("gsdm"));  
3096 - m.put("fgsBm", m.get("fgsdm"));  
3097 - if(m.get("gsBm") != null && m.get("fgsBm") != null  
3098 - && m.get("gsBm").toString().trim().length() > 0  
3099 - && m.get("fgsBm").toString().trim().length() > 0){  
3100 - String gsBm = m.get("gsBm").toString().trim();  
3101 - String fgsBm = m.get("fgsBm").toString().trim();  
3102 - String key = gsBm + "_" + fgsBm;  
3103 - if(keyMap.containsKey(key)){  
3104 - Map<String, Object> t = keyMap.get(key);  
3105 - for(String s : m.keySet()){  
3106 - if("gsName,fgsName,key".contains(s)){  
3107 - continue;  
3108 - }  
3109 - try {  
3110 - if(t.containsKey(s)){  
3111 - t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));  
3112 - } else {  
3113 - t.put(s, m.get(s).toString());  
3114 - }  
3115 - } catch (Exception e) {  
3116 - // TODO: handle exception  
3117 - continue;  
3118 - }  
3119 - }  
3120 - }  
3121 - }  
3122 - }  
3123 -  
3124 - for(Map<String, Object> m : resList){  
3125 - String key = m.get("key").toString();  
3126 - if(key.contains("_sum") || key.equals("88")){  
3127 - continue;  
3128 - }  
3129 -  
3130 - Map<String, Object> t = keyMap.get(key.split("_")[0] + "_sum");  
3131 - for(String s : m.keySet()){  
3132 - if("gsName,fgsName,key".contains(s)){  
3133 - continue;  
3134 - }  
3135 - try {  
3136 - if(t.containsKey(s)){  
3137 - t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));  
3138 - } else {  
3139 - t.put(s, m.get(s).toString());  
3140 - }  
3141 - } catch (Exception e) {  
3142 - // TODO: handle exception  
3143 - continue;  
3144 - }  
3145 - }  
3146 -  
3147 - t = keyMap.get("88");  
3148 - for(String s : m.keySet()){  
3149 - if("gsName,fgsName,key".contains(s)){  
3150 - continue;  
3151 - }  
3152 - try {  
3153 - if(t.containsKey(s)){  
3154 - t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));  
3155 - } else {  
3156 - t.put(s, m.get(s).toString());  
3157 - }  
3158 - } catch (Exception e) {  
3159 - // TODO: handle exception  
3160 - continue;  
3161 - }  
3162 - }  
3163 - }  
3164 -  
3165 - for(Map<String, Object> m : resList){  
3166 - try {  
3167 - m.put("jhzlc", m.get("jhzlc"));  
3168 - m.put("jhlc", m.get("jhyylc"));  
3169 - m.put("jcclc", m.get("jhkslc"));  
3170 - m.put("sjzgl", m.get("sjzlc"));  
3171 - m.put("sjgl", m.get("sjyylc"));  
3172 - m.put("sjksgl", m.get("sjkslc"));  
3173 - m.put("ssbc", m.get("ssbc"));  
3174 - m.put("ssgl", m.get("sslc"));  
3175 - m.put("ssgl_lz", m.get("lzlc"));  
3176 - m.put("ssgl_dm", m.get("dmlc"));  
3177 - m.put("ssgl_gz", m.get("gzlc"));  
3178 - m.put("ssgl_jf", m.get("jflc"));  
3179 - m.put("ssgl_zs", m.get("zslc"));  
3180 - m.put("ssgl_qr", m.get("qrlc"));  
3181 - m.put("ssgl_qc", m.get("qclc"));  
3182 - m.put("ssgl_kx", m.get("kxlc"));  
3183 - m.put("ssgl_qh", m.get("qhlc"));  
3184 - m.put("ssgl_yw", m.get("ywlc"));  
3185 - m.put("ssgl_ljpm", m.get("ljpmlc"));  
3186 - m.put("ssgl_other", m.get("qtlc"));  
3187 - m.put("ljgl", m.get("ljlc"));  
3188 - m.put("ljks", m.get("ljkslc"));  
3189 - m.put("jhbc", m.get("jhbcq"));  
3190 - m.put("jhbc_m", m.get("jhbcz"));  
3191 - m.put("jhbc_a", m.get("jhbcw"));  
3192 - m.put("sjbc", m.get("sjbcq"));  
3193 - m.put("sjbc_m", m.get("sjbcz"));  
3194 - m.put("sjbc_a", m.get("sjbcw"));  
3195 - m.put("ljbc", m.get("ljbcq"));  
3196 - m.put("ljbc_m", m.get("ljbcz"));  
3197 - m.put("ljbc_a", m.get("ljbcw"));  
3198 - m.put("fzbc", m.get("fzbcq"));  
3199 - m.put("fzbc_m", m.get("fzbcz"));  
3200 - m.put("fzbc_a", m.get("fzbcw"));  
3201 - m.put("dtbc", m.get("dtbcq"));  
3202 - m.put("dtbc_m", m.get("dtbcz"));  
3203 - m.put("dtbc_a", m.get("dtbcw"));  
3204 - m.put("djg", m.get("djgq"));  
3205 - m.put("djg_m", m.get("djgz"));  
3206 - m.put("djg_a", m.get("djgw"));  
3207 - m.put("djg_time", m.get("djgsj"));  
3208 - m.put("ljzgl", new BigDecimal(m.get("ljgl").toString()).add(new BigDecimal(m.get("ljks").toString())));  
3209 - } catch (Exception e) {  
3210 - // TODO: handle exception  
3211 - m.put("ljzgl", "");  
3212 - continue;  
3213 - }  
3214 - }  
3215 -  
3216 - if (type != null && type.length() != 0 && type.equals("export")) {  
3217 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
3218 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
3219 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
3220 - Map<String, Object> m = new HashMap<String, Object>();  
3221 - ReportUtils ee = new ReportUtils();  
3222 - try {  
3223 - String dateTime = "";  
3224 - if (date.equals(date2)) {  
3225 - m.put("date", date);  
3226 - dateTime = sdfSimple.format(sdfMonth.parse(date));  
3227 - } else {  
3228 - m.put("date", date + "至" + date2);  
3229 - dateTime = sdfSimple.format(sdfMonth.parse(date))  
3230 - + "-" + sdfSimple.format(sdfMonth.parse(date2));  
3231 - }  
3232 - listI.add(resList.iterator());  
3233 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
3234 - ee.excelReplace(listI, new Object[]{m}, path + "mould/dispatchDailySum.xls",  
3235 - path + "export/" + dateTime + "-调度日报汇总表.xls");  
3236 - } catch (Exception e) {  
3237 - // TODO: handle exception  
3238 - //e.printStackTrace();  
3239 - logger.info("", e);  
3240 - }  
3241 - }  
3242 -  
3243 - return resList;  
3244 - }  
3245 -  
3246 - @Override  
3247 - public List<Map<String, Object>> statisticsDailyTj(String gsdm, String fgsdm, String line, String date, String date2,  
3248 - String xlName, String type,String nature) {  
3249 - List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>();  
3250 - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();  
3251 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
3252 - List<Object[]> listInterval=new ArrayList<Object[]>();  
3253 - line = line.trim();  
3254 - if(gsdm.equals("") && fgsdm.equals("") && line.equals("")){  
3255 - //查询所有公司  
3256 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj3(date, date2);  
3257 - listInterval = calcIntervalRepository.countByDate(date, date2);  
3258 - } else if (line.equals("")) {  
3259 - //查询所有线路  
3260 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);  
3261 - listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2);  
3262 - } else {  
3263 - //查询单条线路  
3264 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);  
3265 - listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2);  
3266 - }  
3267 - Map<String, Map<String,Object>> mapInterval=new HashMap<String, Map<String,Object>>();  
3268 - for (int i = 0; i < listInterval.size(); i++) {  
3269 - Object[] interval=listInterval.get(i);  
3270 - String gs=interval[0].toString();  
3271 - String fgs=interval[1].toString();  
3272 - String xl=interval[2].toString();  
3273 - Map<String, Object> m=new HashMap<String,Object>();  
3274 - m.put("gs", gs);  
3275 - m.put("fgs", fgs);  
3276 - m.put("xl", xl);  
3277 - m.put("djgAll", interval[3]);  
3278 - m.put("djgZgf", interval[6]);  
3279 - m.put("djgWgf", interval[7]);  
3280 - m.put("djgTime", interval[8]);  
3281 - mapInterval.put(gs+"-"+fgs+"-"+xl, m);  
3282 - }  
3283 - Map<String, Boolean> lineMap=lineService.lineNature();  
3284 - List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();  
3285 - for (int i = 0; i < listAll.size(); i++) {  
3286 - ScheduleRealInfo s=listAll.get(i);  
3287 - if (nature.equals("0")) {  
3288 - list.add(s);  
3289 - }else if(nature.equals("1")){  
3290 - if(lineMap.get(s.getXlBm())){  
3291 - list.add(s);  
3292 - }  
3293 - }else{  
3294 - if(!lineMap.get(s.getXlBm())){  
3295 - list.add(s);  
3296 - }  
3297 - }  
3298 - }  
3299 - for (int i = 0; i < list.size(); i++) {  
3300 - ScheduleRealInfo s = list.get(i);  
3301 - Set<ChildTaskPlan> cts = s.getcTasks();  
3302 - if (cts != null && cts.size() > 0) {  
3303 - list_s.add(s);  
3304 - } else {  
3305 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
3306 - list_s.add(s);  
3307 - }  
3308 - }  
3309 - }  
3310 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
3311 - for (int i = 0; i < list.size(); i++) {  
3312 - if (i < list.size() - 1) {  
3313 - if ((list.get(i+1).getGsBm()+"/"+list.get(i+1).getFgsBm()+"/"+list.get(i+1).getXlBm()).equals(  
3314 - list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm())) {  
3315 - lists.add(list.get(i));  
3316 - } else {  
3317 - lists.add(list.get(i));  
3318 - Map<String, Object> mm=new HashMap<String,Object>();  
3319 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3320 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3321 - }  
3322 - Map<String, Object> map = staticTj(lists,mm);  
3323 - lMap.add(map);  
3324 - lists = new ArrayList<ScheduleRealInfo>();  
3325 - }  
3326 - } else {  
3327 - if ((list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm()).equals(  
3328 - list.get(i-1).getGsBm()+"/"+list.get(i-1).getFgsBm()+"/"+list.get(i-1).getXlBm())) {  
3329 - lists.add(list.get(i));  
3330 - Map<String, Object> mm=new HashMap<String,Object>();  
3331 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3332 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3333 - }  
3334 - Map<String, Object> map = staticTj(lists,mm);  
3335 - lMap.add(map);  
3336 - } else {  
3337 - lists = new ArrayList<ScheduleRealInfo>();  
3338 - lists.add(list.get(i));  
3339 - Map<String, Object> mm=new HashMap<String,Object>();  
3340 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3341 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3342 - }  
3343 - Map<String, Object> map = staticTj(lists,mm);  
3344 - lMap.add(map);  
3345 - }  
3346 - }  
3347 - }  
3348 -  
3349 - Collections.sort(lMap, new AccountXlbm());  
3350 - Map<String, Object> map = new HashMap<String, Object>();  
3351 - map.put("xlName", "合计");  
3352 - map.put("fgsName", "");  
3353 - map.put("gsName", "");  
3354 - double jhyygl = culateService.culateJhgl(list);//计划营运公里  
3355 - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)  
3356 - map.put("jhlc", jhyygl);  
3357 - map.put("jcclc", jhjcclc);  
3358 - map.put("jhzlc", Arith.add(jhyygl, jhjcclc));  
3359 -  
3360 - double ljgl = culateService.culateLjgl(list_s);  
3361 - double sjyygl = culateService.culateSjgl(list_s);  
3362 - double zyygl = Arith.add(sjyygl, ljgl);  
3363 - double ljks=culateService.culateLjksgl(list_s);  
3364 - map.put("ljks", ljks);  
3365 - double sjjccgl = culateService.culateJccgl(list_s);  
3366 - double sjksgl = culateService.culateKsgl(list_s);  
3367 - double zksgl = Arith.add(sjjccgl, sjksgl);  
3368 - map.put("sjzgl", Arith.add(zyygl, zksgl));  
3369 - map.put("sjgl", zyygl);  
3370 - map.put("sjksgl", zksgl);  
3371 -  
3372 - double ssgl = culateService.culateLbgl(list);  
3373 - map.put("ssgl", ssgl);  
3374 - //计划+临加-少驶=实驶  
3375 - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl);  
3376 - if (jl == zyygl) {  
3377 - map.put("zt", 0);  
3378 - } else {  
3379 - map.put("zt", 1);  
3380 - }  
3381 - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻"));  
3382 - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢"));  
3383 - map.put("ssgl_gz", culateService.culateCJLC(list, "故障"));  
3384 - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷"));  
3385 - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事"));  
3386 - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人"));  
3387 - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车"));  
3388 - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀"));  
3389 - map.put("ssgl_qh", culateService.culateCJLC(list, "气候"));  
3390 - map.put("ssgl_yw", culateService.culateCJLC(list, "援外"));  
3391 - map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚"));  
3392 - double ssgl_pc = culateService.culateCJLC(list, "配车");  
3393 - double ssgl_by = culateService.culateCJLC(list, "保养");  
3394 - double ssgl_cj = culateService.culateCJLC(list, "抽减");  
3395 - double ssgl_qt = culateService.culateCJLC(list, "其他");  
3396 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
3397 -  
3398 - map.put("ssbc", culateService.culateLbbc(list));  
3399 - map.put("ljgl", ljgl);  
3400 - map.put("jhbc", culateService.culateJhbc(list, ""));  
3401 - map.put("jhbc_m", culateService.culateJhbc(list, "zgf"));  
3402 - map.put("jhbc_a", culateService.culateJhbc(list, "wgf"));  
3403 - map.put("sjbc", culateService.culateSjbc(list_s, ""));  
3404 - map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf"));  
3405 - map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf"));  
3406 - map.put("ljbc", culateService.culateLjbc(list_s, ""));  
3407 - map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf"));  
3408 - map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf"));  
3409 - map.put("fzbc", culateService.culateFzbc(list_s, ""));  
3410 - map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf"));  
3411 - map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf"));  
3412 - map.put("dtbc", 0);  
3413 - map.put("dtbc_m", 0);  
3414 - map.put("dtbc_a", 0);  
3415 - if (list.size() > 0) {  
3416 - int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0;  
3417 - for (Map<String, Object> m : lMap) {  
3418 - if (m.containsKey("djg") && m.get("djg") != null)  
3419 - djg += Integer.valueOf(m.get("djg").toString());  
3420 - if (m.containsKey("djg_m") && m.get("djg_m") != null)  
3421 - djg_m += Integer.valueOf(m.get("djg_m").toString());  
3422 - if (m.containsKey("djg_a") && m.get("djg_a") != null)  
3423 - djg_a += Integer.valueOf(m.get("djg_a").toString());  
3424 - if (m.containsKey("djg_time") && m.get("djg_time") != null) {  
3425 - int t = Integer.valueOf(m.get("djg_time").toString());  
3426 - if (t > djg_time)  
3427 - djg_time = t;  
3428 - }  
3429 - }  
3430 - map.put("djg", djg);  
3431 - map.put("djg_m", djg_m);  
3432 - map.put("djg_a", djg_a);  
3433 - map.put("djg_time", djg_time);  
3434 -// Map<String, Object> m_=culateService.culateDjg(list_s, list.get(0).getXlBm());  
3435 -// map.put("djg", m_.get("djgcsq"));  
3436 -// map.put("djg_m", m_.get("djgcsz"));  
3437 -// map.put("djg_a", m_.get("djgcsw"));  
3438 -// map.put("djg_time", m_.get("djgsj"));  
3439 - } else {  
3440 - map.put("djg", "0");  
3441 - map.put("djg_m", "0");  
3442 - map.put("djg_a", "0");  
3443 - map.put("djg_time", "0");  
3444 - }  
3445 - lMap.add(map);  
3446 -  
3447 - if (type != null && type.length() != 0 && type.equals("export")) {  
3448 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
3449 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
3450 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
3451 - Map<String, Object> m = new HashMap<String, Object>();  
3452 - m.put("date", date + "至" + date2);  
3453 - ReportUtils ee = new ReportUtils();  
3454 - try {  
3455 - String dateTime = "";  
3456 - if (date.equals(date2)) {  
3457 - dateTime = sdfSimple.format(sdfMonth.parse(date));  
3458 - } else {  
3459 - dateTime = sdfSimple.format(sdfMonth.parse(date))  
3460 - + "-" + sdfSimple.format(sdfMonth.parse(date2));  
3461 - }  
3462 - listI.add(lMap.iterator());  
3463 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
3464 - ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_2.xls",  
3465 - path + "export/" + dateTime + "-" + xlName + "-统计日报.xls");  
3466 - } catch (Exception e) {  
3467 - // TODO: handle exception  
3468 - //e.printStackTrace();  
3469 - logger.info("", e);  
3470 - }  
3471 - }  
3472 -  
3473 - if (type != null && type.length() != 0 && type.equals("exportAll")) {  
3474 - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();  
3475 - Map<String, Map<String, Object>> tempMap = new HashMap<String, Map<String, Object>>();  
3476 - List<Map<String, Object>> removeList = new ArrayList<Map<String, Object>>();  
3477 - for(Map<String, Object> m : lMap){  
3478 - if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0  
3479 - && m.get("gsName").toString().trim().contains("临港")){  
3480 - removeList.add(m);  
3481 - }  
3482 - }  
3483 - for(Map<String, Object> m : removeList){  
3484 - lMap.remove(m);  
3485 - }  
3486 - for(Map<String, Object> m : lMap){  
3487 - if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0){  
3488 - String gsName = m.get("gsName").toString().trim();  
3489 - Map<String, Object> temp = new HashMap<String, Object>();  
3490 - if(tempMap.get(gsName) != null){  
3491 - temp = tempMap.get(gsName);  
3492 - } else {  
3493 - temp.put("gsName", gsName);  
3494 - temp.put("fgsName", "小计");  
3495 - temp.put("xlName", "");  
3496 - tempList.add(temp);  
3497 - tempMap.put(gsName, temp);  
3498 - }  
3499 - for(String key : m.keySet()){  
3500 - try {  
3501 - temp.put(key, new BigDecimal(m.get(key).toString()).add(  
3502 - new BigDecimal(temp.get(key)!=null?temp.get(key).toString():"0")));  
3503 - } catch (Exception e) {  
3504 - // TODO: handle exception  
3505 - }  
3506 - }  
3507 - }  
3508 - }  
3509 - lMap.addAll(lMap.size()>0?lMap.size()-1:0, tempList);  
3510 -  
3511 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
3512 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
3513 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
3514 - Map<String, Object> m = new HashMap<String, Object>();  
3515 - m.put("date", date + "至" + date2);  
3516 - ReportUtils ee = new ReportUtils();  
3517 - try {  
3518 - String dateTime = "";  
3519 - if (date.equals(date2)) {  
3520 - dateTime = sdfSimple.format(sdfMonth.parse(date));  
3521 - } else {  
3522 - dateTime = sdfSimple.format(sdfMonth.parse(date))  
3523 - + "-" + sdfSimple.format(sdfMonth.parse(date2));  
3524 - }  
3525 - listI.add(lMap.iterator());  
3526 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
3527 - ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_4.xls",  
3528 - path + "export/" + dateTime + "-全部公司-统计日报.xls");  
3529 - } catch (Exception e) {  
3530 - // TODO: handle exception  
3531 - //e.printStackTrace();  
3532 - logger.info("", e);  
3533 - }  
3534 - }  
3535 -  
3536 - return lMap;  
3537 - }  
3538 -  
3539 - @Override  
3540 - public List<Map<String, Object>> statisticsDailyTjHb(String gsdm, String fgsdm, String line, String date, String date2,  
3541 - String xlName, String type,String nature) {  
3542 - List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>();  
3543 - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();  
3544 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
3545 - List<Object[]> listInterval=new ArrayList<Object[]>();  
3546 -  
3547 - line = line.trim();  
3548 - if (line.equals("")) {  
3549 - //查询所有线路  
3550 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);  
3551 - listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2);  
3552 - } else {  
3553 - //查询单条线路  
3554 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);  
3555 - listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2);  
3556 - }  
3557 - Map<String, Map<String,Object>> mapInterval=new HashMap<>();  
3558 - for (int i = 0; i < listInterval.size(); i++) {  
3559 - Object[] interval=listInterval.get(i);  
3560 - String gs=interval[0].toString();  
3561 - String fgs=interval[1].toString();  
3562 - String xl=interval[2].toString();  
3563 - Map<String, Object> m=new HashMap<String,Object>();  
3564 - m.put("gs", gs);  
3565 - m.put("fgs", fgs);  
3566 - m.put("xl", xl);  
3567 - m.put("djgAll", interval[3]);  
3568 - m.put("djgZgf", interval[6]);  
3569 - m.put("djgWgf", interval[7]);  
3570 - m.put("djgTime", interval[8]);  
3571 - mapInterval.put(gs+"-"+fgs+"-"+xl, m);  
3572 - }  
3573 -  
3574 - Map<String, Boolean> lineMap=lineService.lineNature();  
3575 - List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();  
3576 - for (int i = 0; i < listAll.size(); i++) {  
3577 - ScheduleRealInfo s=listAll.get(i);  
3578 - if (nature.equals("0")) {  
3579 - list.add(s);  
3580 - }else if(nature.equals("1")){  
3581 - if(lineMap.get(s.getXlBm())){  
3582 - list.add(s);  
3583 - }  
3584 - }else{  
3585 - if(!lineMap.get(s.getXlBm())){  
3586 - list.add(s);  
3587 - }  
3588 - }  
3589 - }  
3590 - for (int i = 0; i < list.size(); i++) {  
3591 - ScheduleRealInfo s = list.get(i);  
3592 - Set<ChildTaskPlan> cts = s.getcTasks();  
3593 - if (cts != null && cts.size() > 0) {  
3594 - list_s.add(s);  
3595 - } else {  
3596 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
3597 - list_s.add(s);  
3598 - }  
3599 - }  
3600 - }  
3601 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
3602 - for (int i = 0; i < list.size(); i++) {  
3603 - if (i < list.size() - 1) {  
3604 - if ((list.get(i + 1).getFgsBm()+list.get(i + 1).getXlBm()).equals(list.get(i).getFgsBm()+list.get(i).getXlBm())) {  
3605 - lists.add(list.get(i));  
3606 - } else {  
3607 - lists.add(list.get(i));  
3608 - Map<String, Object> mm=new HashMap<String,Object>();  
3609 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3610 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3611 - }  
3612 - Map<String, Object> map = staticTj(lists,mm);  
3613 - lMap.add(map);  
3614 - lists = new ArrayList<ScheduleRealInfo>();  
3615 - }  
3616 - } else {  
3617 - if ((list.get(i).getFgsBm()+list.get(i).getXlBm()).equals(list.get(i - 1).getFgsBm()+list.get(i - 1).getXlBm())) {  
3618 - lists.add(list.get(i));  
3619 - Map<String, Object> mm=new HashMap<String,Object>();  
3620 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3621 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3622 - }  
3623 - Map<String, Object> map = staticTj(lists,mm);  
3624 - lMap.add(map);  
3625 - } else {  
3626 - lists = new ArrayList<ScheduleRealInfo>();  
3627 - lists.add(list.get(i));  
3628 - Map<String, Object> mm=new HashMap<String,Object>();  
3629 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3630 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3631 - }  
3632 - Map<String, Object> map = staticTj(lists,mm);  
3633 - lMap.add(map);  
3634 - }  
3635 - }  
3636 - }  
3637 -  
3638 - Collections.sort(lMap, new AccountXlbm());  
3639 - Map<String, Object> map = new HashMap<String, Object>();  
3640 - map.put("xlBm", "hj");  
3641 - map.put("xlName", "合计");  
3642 - map.put("fgsBm", "");  
3643 - map.put("fgsName", "");  
3644 - map.put("gsBm", "");  
3645 - double jhyygl = culateService.culateJhgl(list);//计划营运公里  
3646 - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)  
3647 - map.put("jhlc", jhyygl);  
3648 - map.put("jcclc", jhjcclc);  
3649 - map.put("jhzlc", Arith.add(jhyygl, jhjcclc));  
3650 -  
3651 - double ljgl = culateService.culateLjgl(list_s);  
3652 - double sjyygl = culateService.culateSjgl(list_s);  
3653 - double zyygl = Arith.add(sjyygl, ljgl);  
3654 - double ljks=culateService.culateLjksgl(list_s);  
3655 - map.put("ljks", ljks);  
3656 - double sjjccgl = culateService.culateJccgl(list_s);  
3657 - double sjksgl = culateService.culateKsgl(list_s);  
3658 - double zksgl = Arith.add(sjjccgl, sjksgl);  
3659 - map.put("sjzgl", Arith.add(zyygl, zksgl));  
3660 - map.put("sjgl", zyygl);  
3661 - map.put("sjksgl", zksgl);  
3662 -  
3663 - double ssgl = culateService.culateLbgl(list);  
3664 - map.put("ssgl", ssgl);  
3665 - //计划+临加-少驶=实驶  
3666 - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl);  
3667 - if (jl == zyygl) {  
3668 - map.put("zt", 0);  
3669 - } else {  
3670 - map.put("zt", 1);  
3671 - }  
3672 - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻"));  
3673 - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢"));  
3674 - map.put("ssgl_gz", culateService.culateCJLC(list, "故障"));  
3675 - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷"));  
3676 - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事"));  
3677 - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人"));  
3678 - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车"));  
3679 - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀"));  
3680 - map.put("ssgl_qh", culateService.culateCJLC(list, "气候"));  
3681 - map.put("ssgl_yw", culateService.culateCJLC(list, "援外"));  
3682 - map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚"));  
3683 - double ssgl_pc = culateService.culateCJLC(list, "配车");  
3684 - double ssgl_by = culateService.culateCJLC(list, "保养");  
3685 - double ssgl_cj = culateService.culateCJLC(list, "抽减");  
3686 - double ssgl_qt = culateService.culateCJLC(list, "其他");  
3687 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
3688 -  
3689 - map.put("ssbc", culateService.culateLbbc(list));  
3690 - map.put("ljgl", ljgl);  
3691 - map.put("jhbc", culateService.culateJhbc(list, ""));  
3692 - map.put("jhbc_m", culateService.culateJhbc(list, "zgf"));  
3693 - map.put("jhbc_a", culateService.culateJhbc(list, "wgf"));  
3694 - map.put("sjbc", culateService.culateSjbc(list_s, ""));  
3695 - map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf"));  
3696 - map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf"));  
3697 - map.put("ljbc", culateService.culateLjbc(list_s, ""));  
3698 - map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf"));  
3699 - map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf"));  
3700 - map.put("fzbc", culateService.culateFzbc(list_s, ""));  
3701 - map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf"));  
3702 - map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf"));  
3703 - map.put("dtbc", 0);  
3704 - map.put("dtbc_m", 0);  
3705 - map.put("dtbc_a", 0);  
3706 - if (list.size() > 0) {  
3707 - int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0;  
3708 - for (Map<String, Object> m : lMap) {  
3709 - if (m.containsKey("djg") && m.get("djg") != null)  
3710 - djg += Integer.valueOf(m.get("djg").toString());  
3711 - if (m.containsKey("djg_m") && m.get("djg_m") != null)  
3712 - djg_m += Integer.valueOf(m.get("djg_m").toString());  
3713 - if (m.containsKey("djg_a") && m.get("djg_a") != null)  
3714 - djg_a += Integer.valueOf(m.get("djg_a").toString());  
3715 - if (m.containsKey("djg_time") && m.get("djg_time") != null) {  
3716 - int t = Integer.valueOf(m.get("djg_time").toString());  
3717 - if (t > djg_time)  
3718 - djg_time = t;  
3719 - }  
3720 - }  
3721 - map.put("djg", djg);  
3722 - map.put("djg_m", djg_m);  
3723 - map.put("djg_a", djg_a);  
3724 - map.put("djg_time", djg_time);  
3725 - } else {  
3726 - map.put("djg", "0");  
3727 - map.put("djg_m", "0");  
3728 - map.put("djg_a", "0");  
3729 - map.put("djg_time", "0");  
3730 - }  
3731 - lMap.add(map);  
3732 - return lMap;  
3733 - }  
3734 -  
3735 - @Override  
3736 - public Map<String, Object> scheduleDaily(String line, String date) {  
3737 - Map<String, String> tempMap = null;  
3738 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);  
3739 - Map<String, Object> map = new HashMap<String, Object>();  
3740 - Double jhlc = 0.00;  
3741 - Float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f,  
3742 - ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_ljpm = 0f,  
3743 - ssgl_other = 0f, ljgl = 0f;  
3744 - int jhbc = 0;  
3745 - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) {  
3746 - if (scheduleRealInfo != null) {  
3747 - //计算里程(包括子任务)  
3748 - jhlc += scheduleRealInfo.getJhlc();  
3749 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
3750 - if (!childTaskPlans.isEmpty()) {  
3751 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
3752 - while (it.hasNext()) {  
3753 - ChildTaskPlan childTaskPlan = it.next();  
3754 - //是否烂班,烂班就是少驶  
3755 - if (!childTaskPlan.isDestroy()) {  
3756 - sjgl += childTaskPlan.getMileage();  
3757 - } else {  
3758 - ssgl += childTaskPlan.getMileage();  
3759 - if (childTaskPlan.getDestroyReason().equals("路阻")) {  
3760 - ssgl_lz += childTaskPlan.getMileage();  
3761 - } else if (childTaskPlan.getDestroyReason().equals("吊慢")) {  
3762 - ssgl_dm += childTaskPlan.getMileage();  
3763 - } else if (childTaskPlan.getDestroyReason().equals("故障")) {  
3764 - ssgl_gz += childTaskPlan.getMileage();  
3765 - } else if (childTaskPlan.getDestroyReason().equals("纠纷")) {  
3766 - ssgl_jf += childTaskPlan.getMileage();  
3767 - } else if (childTaskPlan.getDestroyReason().equals("肇事")) {  
3768 - ssgl_zs += childTaskPlan.getMileage();  
3769 - } else if (childTaskPlan.getDestroyReason().equals("缺人")) {  
3770 - ssgl_qr += childTaskPlan.getMileage();  
3771 - } else if (childTaskPlan.getDestroyReason().equals("缺车")) {  
3772 - ssgl_qc += childTaskPlan.getMileage();  
3773 - } else if (childTaskPlan.getDestroyReason().equals("客稀")) {  
3774 - ssgl_kx += childTaskPlan.getMileage();  
3775 - } else if (childTaskPlan.getDestroyReason().equals("气候")) {  
3776 - ssgl_qh += childTaskPlan.getMileage();  
3777 - } else if (childTaskPlan.getDestroyReason().equals("援外")) {  
3778 - ssgl_yw += childTaskPlan.getMileage();  
3779 - } else if (childTaskPlan.getDestroyReason().equals("路救抛锚")) {  
3780 - ssgl_ljpm += childTaskPlan.getMileage();  
3781 - } else {  
3782 - ssgl_other += childTaskPlan.getMileage();  
3783 - }  
3784 - }  
3785 - //临加公里  
3786 - if (childTaskPlan.getType1().equals("临加")) {  
3787 - ljgl += childTaskPlan.getMileage();  
3788 - }  
3789 - }  
3790 - }  
3791 - //班次  
3792 - scheduleRealInfo.getFcsjT();  
3793 - scheduleRealInfo.getFcsjActualTime();  
3794 - }  
3795 - }  
3796 - map.put("jhlc", jhlc);  
3797 - map.put("sjgl", sjgl);  
3798 - map.put("ssgl", ssgl);  
3799 - map.put("ssgl_lz", ssgl_lz);  
3800 - map.put("ssgl_dm", ssgl_dm);  
3801 - map.put("ssgl_gz", ssgl_gz);  
3802 - map.put("ssgl_jf", ssgl_jf);  
3803 - map.put("ssgl_zs", ssgl_zs);  
3804 - map.put("ssgl_qr", ssgl_qr);  
3805 - map.put("ssgl_qc", ssgl_qc);  
3806 - map.put("ssgl_kx", ssgl_kx);  
3807 - map.put("ssgl_qh", ssgl_qh);  
3808 - map.put("ssgl_yw", ssgl_yw);  
3809 - map.put("ssgl_ljpm", ssgl_ljpm);  
3810 - map.put("ssgl_other", ssgl_other);  
3811 - map.put("ljgl", ljgl);  
3812 -  
3813 - map.put("jhbc", scheduleRealInfos.size());  
3814 - return null;  
3815 - }  
3816 -  
3817 - @Override  
3818 - public int countByLineCodeAndDate(String xlBm, String schDate) {  
3819 - return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate);  
3820 - }  
3821 -  
3822 - @Override  
3823 - public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) {  
3824 - return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate);  
3825 - }  
3826 -  
3827 - @Override  
3828 - public void deleteByLineCodeAndDate(String xlBm, String schDate) {  
3829 - scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate);  
3830 - }  
3831 -  
3832 - @Override  
3833 - public Long getMaxId() {  
3834 - return scheduleRealInfoRepository.getMaxId();  
3835 - }  
3836 -  
3837 - @Override  
3838 - public List<ScheduleRealInfo> realScheduleList(String line, String date) {  
3839 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
3840 - String lpName = "lpName";  
3841 - String zdsj = "";  
3842 - String zdsjActual = "";  
3843 - String zdsj1 = "";  
3844 - String zdsjActual1 = "";  
3845 - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date);  
3846 -  
3847 - /*  
3848 - * 对计划发车时间相同的班次进行排序 out最前 in最后  
3849 - */  
3850 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
3851 - SimpleDateFormat sdfnyr =new SimpleDateFormat("yyyy-MM-dd");  
3852 - String minfcsj = "02:00";  
3853 - List<Line> lineList = lineRepository.findLineByCode(line);  
3854 - if (lineList.size() > 0) {  
3855 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
3856 - + " id = ("  
3857 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
3858 - + ")";  
3859 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
3860 - }  
3861 - String[] minSjs = minfcsj.split(":");  
3862 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
3863 - for (int i = 0; i < listInfo.size(); i++) {  
3864 - ScheduleRealInfo s = listInfo.get(i);  
3865 - if (s.getBcType().equals("out")) {  
3866 - s.setRemark("1");  
3867 - } else if (s.getBcType().equals("in")) {  
3868 - s.setRemark("3");  
3869 - } else {  
3870 - s.setRemark("2");  
3871 - }  
3872 - String[] fcsj = s.getFcsj().split(":");  
3873 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
3874 -  
3875 - Long fscjT = 0L;  
3876 - if (fcsjL < minSj) {  
3877 - Calendar calendar = new GregorianCalendar();  
3878 - calendar.setTime(s.getScheduleDate());  
3879 - calendar.add(calendar.DATE, 1);  
3880 - Date date_sch= calendar.getTime();  
3881 - try {  
3882 - fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime();  
3883 - } catch (ParseException e) {  
3884 - // TODO Auto-generated catch block  
3885 - e.printStackTrace();  
3886 - }  
3887 -  
3888 - } else {  
3889 - try {  
3890 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
3891 - } catch (ParseException e) {  
3892 - // TODO Auto-generated catch block  
3893 - e.printStackTrace();  
3894 - };  
3895 - }  
3896 - s.setFcsjT(fscjT);  
3897 - }  
3898 - List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>();  
3899 - listInfo2.addAll(listInfo);  
3900 - Collections.sort(listInfo, new compareLpFcsjType());  
3901 - Collections.sort(listInfo2,new compareDirLpFcsjType());  
3902 - for (int i = 0; i < listInfo.size(); i++) {  
3903 - ScheduleRealInfo t = listInfo.get(i);  
3904 - if (!lpName.equals(t.getLpName())) {  
3905 - zdsjActual = t.getZdsjActual();  
3906 - zdsj = t.getZdsj();  
3907 - t.setZdsjActual("");  
3908 - t.setZdsj("");  
3909 - } else {  
3910 - zdsj1 = t.getZdsj();  
3911 - zdsjActual1 = t.getZdsjActual();  
3912 - t.setZdsjActual(zdsjActual);  
3913 - t.setZdsj(zdsj);  
3914 - zdsj = zdsj1;  
3915 - zdsjActual = zdsjActual1;  
3916 - }  
3917 - lpName = t.getLpName();  
3918 - list.add(t);  
3919 - }  
3920 -/*  
3921 - List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleDdrb2(line, date);  
3922 - for (int i = 0; i < listInfo2.size(); i++) {  
3923 - ScheduleRealInfo s = listInfo2.get(i);  
3924 - if (s.getBcType().equals("out")) {  
3925 - s.setRemark("1");  
3926 - } else if (s.getBcType().equals("in")) {  
3927 - s.setRemark("3");  
3928 - } else {  
3929 - s.setRemark("2");  
3930 - }  
3931 - String[] fcsj = s.getFcsj().split(":");  
3932 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
3933 -  
3934 - Long fscjT = 0L;  
3935 - if (fcsjL < minSj) {  
3936 - Calendar calendar = new GregorianCalendar();  
3937 - calendar.setTime(s.getScheduleDate());  
3938 - calendar.add(calendar.DATE, 1);  
3939 - s.setScheduleDate(calendar.getTime());  
3940 - try {  
3941 - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();  
3942 - } catch (ParseException e) {  
3943 - // TODO Auto-generated catch block  
3944 - e.printStackTrace();  
3945 - }  
3946 -  
3947 - } else {  
3948 - try {  
3949 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
3950 - } catch (ParseException e) {  
3951 - // TODO Auto-generated catch block  
3952 - e.printStackTrace();  
3953 - }  
3954 - ;  
3955 - }  
3956 - s.setFcsjT(fscjT);  
3957 - }*/  
3958 - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();  
3959 - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();  
3960 - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();  
3961 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
3962 - if (listInfo2.size() > 0) {  
3963 - int a = listInfo2.size() % 3;  
3964 - int b = listInfo2.size() / 3;  
3965 - int x = 0, y = 0;  
3966 - if (a == 2) {  
3967 - x = b + 1;  
3968 - y = x * 2;  
3969 - } else if (a == 1) {  
3970 - x = b + 1;  
3971 - y = x * 2 - 1;  
3972 - } else {  
3973 - x = b;  
3974 - y = 2 * x;  
3975 -  
3976 - }  
3977 - for (int i = 0; i < listInfo2.size(); i++) {  
3978 - ScheduleRealInfo s = listInfo2.get(i);  
3979 - if (i + 1 <= x) {  
3980 - xList.add(s);  
3981 - } else if ((i + 1) > x && (i + 1) <= y) {  
3982 - yList.add(s);  
3983 - } else {  
3984 - zList.add(s);  
3985 - }  
3986 - }  
3987 - for (int i = 0; i < x; i++) {  
3988 - newList.add(xList.get(i));  
3989 - if (yList.size() > i) {  
3990 - newList.add(yList.get(i));  
3991 - } else {  
3992 - newList.add(new ScheduleRealInfo());  
3993 - }  
3994 - if (zList.size() > i) {  
3995 - newList.add(zList.get(i));  
3996 - } else {  
3997 - newList.add(new ScheduleRealInfo());  
3998 - }  
3999 -  
4000 - }  
4001 - }  
4002 - for (int i = 0; i < newList.size(); i++) {  
4003 - ScheduleRealInfo t1 = newList.get(i);  
4004 - for (int j = 0; j < list.size(); j++) {  
4005 - ScheduleRealInfo t2 = list.get(j);  
4006 - if (t1.getId() == t2.getId()) {  
4007 - t1 = t2;  
4008 - }  
4009 - }  
4010 - }  
4011 -  
4012 - for (int i = 0; i < newList.size(); i++) {  
4013 - ScheduleRealInfo t1 = newList.get(i);  
4014 - String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks();  
4015 - if (reamrks1.length() > 4) {  
4016 - t1.setRemarks(reamrks1.substring(0, 4));  
4017 - t1.setRemark(reamrks1);  
4018 - } else {  
4019 - t1.setRemark(reamrks1);  
4020 - }  
4021 - }  
4022 - return newList;  
4023 - }  
4024 -  
4025 - @Override  
4026 - public List<ScheduleRealInfo> realScheduleList_zrw(String line, String date) {  
4027 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
4028 - String lpName = "lpName";  
4029 - String zdsj = "";  
4030 - String zdsjActual = "";  
4031 - String zdsj1 = "";  
4032 - String zdsjActual1 = "";  
4033 - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date);  
4034 -  
4035 - /*  
4036 - * 对计划发车时间相同的班次进行排序 out最前 in最后  
4037 - */  
4038 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
4039 - SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd");  
4040 -  
4041 - String minfcsj = "02:00";  
4042 - List<Line> lineList = lineRepository.findLineByCode(line);  
4043 - if (lineList.size() > 0) {  
4044 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
4045 - + " id = ("  
4046 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
4047 - + ")";  
4048 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
4049 - }  
4050 - String[] minSjs = minfcsj.split(":");  
4051 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
4052 - for (int i = 0; i < listInfo.size(); i++) {  
4053 - ScheduleRealInfo s = listInfo.get(i);  
4054 - if (s.getBcType().equals("out")) {  
4055 - s.setRemark("1");  
4056 - } else if (s.getBcType().equals("in")) {  
4057 - s.setRemark("3");  
4058 - } else {  
4059 - s.setRemark("2");  
4060 - }  
4061 - String[] fcsj = s.getFcsj().split(":");  
4062 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
4063 -  
4064 - Long fscjT = 0L;  
4065 - if (fcsjL < minSj) {  
4066 - Calendar calendar = new GregorianCalendar();  
4067 - calendar.setTime(s.getScheduleDate());  
4068 - calendar.add(calendar.DATE, 1);  
4069 - Date date_sch=calendar.getTime();  
4070 - try {  
4071 - fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime();  
4072 - } catch (ParseException e) {  
4073 - // TODO Auto-generated catch block  
4074 - e.printStackTrace();  
4075 - }  
4076 -  
4077 - } else {  
4078 - try {  
4079 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
4080 - } catch (ParseException e) {  
4081 - // TODO Auto-generated catch block  
4082 - e.printStackTrace();  
4083 - }  
4084 - ;  
4085 - }  
4086 - s.setFcsjT(fscjT);  
4087 - }  
4088 -  
4089 -// Collections.sort(listInfo, new compareLpFcsjType());  
4090 - List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>();  
4091 -  
4092 - Collections.sort(listInfo, new compareLpFcsjType());  
4093 - for (int i = 0; i < listInfo.size(); i++) {  
4094 - ScheduleRealInfo t = listInfo.get(i);  
4095 - if (!lpName.equals(t.getLpName())) {  
4096 - zdsjActual = t.getZdsjActual();  
4097 - zdsj = t.getZdsj();  
4098 - t.setZdsjActual("");  
4099 - t.setZdsj("");  
4100 - } else {  
4101 - zdsj1 = t.getZdsj();  
4102 - zdsjActual1 = t.getZdsjActual();  
4103 - t.setZdsjActual(zdsjActual);  
4104 - t.setZdsj(zdsj);  
4105 - zdsj = zdsj1;  
4106 - zdsjActual = zdsjActual1;  
4107 - }  
4108 -  
4109 -  
4110 -  
4111 - lpName = t.getLpName();  
4112 - listInfo2.add(t);  
4113 -  
4114 - }  
4115 -  
4116 - Collections.sort(listInfo2,new compareDirLpFcsjType());  
4117 - for (int i = 0; i < listInfo2.size(); i++) {  
4118 - ScheduleRealInfo t=listInfo2.get(i);  
4119 - list.add(t);  
4120 - Set<ChildTaskPlan> childTaskPlans = t.getcTasks();  
4121 - //计算营运里程,空驶里程  
4122 - if (!childTaskPlans.isEmpty()) {  
4123 - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);  
4124 - Collections.sort(listit, new ComparableChild());  
4125 - for (int j = 0; j < listit.size(); j++) {  
4126 - ScheduleRealInfo s = new ScheduleRealInfo();  
4127 - ChildTaskPlan childTaskPlan = listit.get(j);  
4128 - if (childTaskPlan.getCcId() == null) {  
4129 - if (childTaskPlan.isDestroy()) {  
4130 - s.setFcsjActual("");  
4131 - s.setZdsjActual("");  
4132 - } else {  
4133 - s.setFcsjActual(childTaskPlan.getStartDate());  
4134 - s.setZdsjActual("");  
4135 - s.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));  
4136 - }  
4137 - s.setFcsj(childTaskPlan.getStartDate());  
4138 - s.setZdsj("");  
4139 - s.setQdzName(childTaskPlan.getStartStationName());  
4140 - s.setZdzName(childTaskPlan.getEndStationName());  
4141 - s.setRemarks(childTaskPlan.getRemarks());  
4142 - s.setAdjustExps("子");  
4143 - s.setLpName("");  
4144 - list.add(s);  
4145 - }  
4146 - }  
4147 - }  
4148 - }  
4149 - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();  
4150 - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();  
4151 - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();  
4152 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
4153 - if (list.size() > 0) {  
4154 - int a = list.size() % 3;  
4155 - int b = list.size() / 3;  
4156 - int x = 0, y = 0;  
4157 - if (a == 2) {  
4158 - x = b + 1;  
4159 - y = x * 2;  
4160 - } else if (a == 1) {  
4161 - x = b + 1;  
4162 - y = x * 2 - 1;  
4163 - } else {  
4164 - x = b;  
4165 - y = 2 * x;  
4166 -  
4167 - }  
4168 - for (int i = 0; i < list.size(); i++) {  
4169 - ScheduleRealInfo s = list.get(i);  
4170 - if (i + 1 <= x) {  
4171 - xList.add(s);  
4172 - } else if ((i + 1) > x && (i + 1) <= y) {  
4173 - yList.add(s);  
4174 - } else {  
4175 - zList.add(s);  
4176 - }  
4177 - }  
4178 - for (int i = 0; i < x; i++) {  
4179 - newList.add(xList.get(i));  
4180 - if (yList.size() > i) {  
4181 - newList.add(yList.get(i));  
4182 - } else {  
4183 - newList.add(new ScheduleRealInfo());  
4184 - }  
4185 - if (zList.size() > i) {  
4186 - newList.add(zList.get(i));  
4187 - } else {  
4188 - newList.add(new ScheduleRealInfo());  
4189 - }  
4190 -  
4191 - }  
4192 - }  
4193 - /* for (int i = 0; i < newList.size(); i++) {  
4194 - ScheduleRealInfo t1 = newList.get(i);  
4195 - for (int j = 0; j < list.size(); j++) {  
4196 - ScheduleRealInfo t2 = list.get(j);  
4197 - if (t1.getId() == t2.getId()) {  
4198 - t1 = t2;  
4199 - }  
4200 - }  
4201 - }*/  
4202 -  
4203 - for (int i = 0; i < newList.size(); i++) {  
4204 - ScheduleRealInfo t1 = newList.get(i);  
4205 - String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks();  
4206 - if (reamrks1.length() > 4) {  
4207 - t1.setRemarks(reamrks1.substring(0, 4));  
4208 - t1.setRemark(reamrks1);  
4209 - } else {  
4210 - t1.setRemark(reamrks1);  
4211 - }  
4212 - }  
4213 - return newList;  
4214 - }  
4215 -  
4216 - @Override  
4217 - public List<ScheduleRealInfo> realScheduleList_mh_2(String line, String date) {  
4218 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
4219 - String lpName = "lpName";  
4220 - String zdsj = "";  
4221 - String zdsjActual = "";  
4222 - String zdsj1 = "";  
4223 - String zdsjActual1 = "";  
4224 - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date);  
4225 -  
4226 - for (ScheduleRealInfo s : listInfo) {  
4227 - if (s.isDestroy() && s.isReissue()) {  
4228 - s.setRemark("");  
4229 - s.setFcsjActual(s.getDfsj());  
4230 - s.setZdsjActual(s.getZdsj());  
4231 - s.setStatus(2);  
4232 - s.setJhlc(s.getJhlcOrig());  
4233 - }  
4234 - }  
4235 -  
4236 - for (int i = 0; i < listInfo.size(); i++) {  
4237 - ScheduleRealInfo t = listInfo.get(i);  
4238 - if (!lpName.equals(t.getLpName())) {  
4239 - zdsjActual = t.getZdsjActual();  
4240 - zdsj = t.getZdsj();  
4241 - t.setZdsjActual("");  
4242 - t.setZdsj("");  
4243 - } else {  
4244 - zdsj1 = t.getZdsj();  
4245 - zdsjActual1 = t.getZdsjActual();  
4246 - t.setZdsjActual(zdsjActual);  
4247 - t.setZdsj(zdsj);  
4248 - zdsj = zdsj1;  
4249 - zdsjActual = zdsjActual1;  
4250 - }  
4251 - lpName = t.getLpName();  
4252 - list.add(t);  
4253 - }  
4254 -  
4255 - List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleByDateAndLineQp2(line, date);  
4256 - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();  
4257 - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();  
4258 - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();  
4259 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
4260 - if (listInfo2.size() > 0) {  
4261 - int a = listInfo2.size() % 3;  
4262 - int b = listInfo2.size() / 3;  
4263 - int x = 0, y = 0;  
4264 - if (a == 2) {  
4265 - x = b + 1;  
4266 - y = x * 2;  
4267 - } else if (b == 1) {  
4268 - x = b + 1;  
4269 - y = x * 2 - 1;  
4270 - } else {  
4271 - x = b;  
4272 - y = 2 * x;  
4273 -  
4274 - }  
4275 - for (int i = 0; i < listInfo2.size(); i++) {  
4276 - ScheduleRealInfo s = listInfo2.get(i);  
4277 - if (i + 1 <= x) {  
4278 - xList.add(s);  
4279 - } else if ((i + 1) > x && (i + 1) <= y) {  
4280 - yList.add(s);  
4281 - } else {  
4282 - zList.add(s);  
4283 - }  
4284 - }  
4285 - for (int i = 0; i < x; i++) {  
4286 - newList.add(xList.get(i));  
4287 - if (yList.size() > i) {  
4288 - newList.add(yList.get(i));  
4289 - } else {  
4290 - newList.add(new ScheduleRealInfo());  
4291 - }  
4292 - if (zList.size() > i) {  
4293 - newList.add(zList.get(i));  
4294 - } else {  
4295 - newList.add(new ScheduleRealInfo());  
4296 - }  
4297 -  
4298 - }  
4299 - }  
4300 - for (int i = 0; i < newList.size(); i++) {  
4301 - ScheduleRealInfo t1 = newList.get(i);  
4302 - for (int j = 0; j < list.size(); j++) {  
4303 - ScheduleRealInfo t2 = list.get(j);  
4304 - if (t1.getId() == t2.getId()) {  
4305 - t1 = t2;  
4306 - }  
4307 - }  
4308 - }  
4309 - return newList;  
4310 - }  
4311 -  
4312 - @Override  
4313 - public List<ScheduleRealInfo> realScheduleListQp(String line, String date) {  
4314 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
4315 - String lpName = "lpName";  
4316 - String zdsj = "";  
4317 - String zdsjActual = "";  
4318 - String zdsj1 = "";  
4319 - String zdsjActual1 = "";  
4320 - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date);  
4321 - for (int i = 0; i < listInfo.size(); i++) {  
4322 - ScheduleRealInfo t = listInfo.get(i);  
4323 - if (!lpName.equals(t.getLpName())) {  
4324 - zdsjActual = t.getZdsjActual();  
4325 - zdsj = t.getZdsj();  
4326 - t.setZdsjActual("");  
4327 - t.setZdsj("");  
4328 - } else {  
4329 - zdsj1 = t.getZdsj();  
4330 - zdsjActual1 = t.getZdsjActual();  
4331 - t.setZdsjActual(zdsjActual);  
4332 - t.setZdsj(zdsj);  
4333 - zdsj = zdsj1;  
4334 - zdsjActual = zdsjActual1;  
4335 - }  
4336 -  
4337 - lpName = t.getLpName();  
4338 - list.add(t);  
4339 - }  
4340 - return list;  
4341 - }  
4342 -  
4343 - public List<Map<String, Object>> yesterdayDataList(String line, String date, String gsbm, String fgsbm, String jGh, String nbbm) {  
4344 - List<Map<String, Object>> yesterdayDataList = new ArrayList<Map<String, Object>>();  
4345 - if (line.equals("")) {  
4346 - yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date, gsbm, fgsbm, nbbm);  
4347 - } else {  
4348 - yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList_eq(line, date, gsbm, fgsbm, nbbm);  
4349 - }  
4350 - List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date, gsbm, fgsbm);  
4351 - for (int x = 0; x < yesterdayDataList.size(); x++) {  
4352 - String jsy = yesterdayDataList.get(x).get("jGh").toString();  
4353 - String clZbh = yesterdayDataList.get(x).get("clZbh").toString();  
4354 - String xlbm = yesterdayDataList.get(x).get("xlBm").toString();  
4355 - String lp = yesterdayDataList.get(x).get("lpName").toString();  
4356 - String realExecDate=yesterdayDataList.get(x).get("realExecDate").toString();  
4357 - String fcsj[] =realExecDate.split(" ");  
4358 - //取出最小计划发车时间  
4359 - yesterdayDataList.get(x).put("fcsj", fcsj[1]);  
4360 - Map<String, Object> map = new HashMap<String, Object>();  
4361 - boolean fage = true;  
4362 - String company = "";  
4363 - String bCompany = "";  
4364 - String lineName="";  
4365 - String jName="";  
4366 - List<ScheduleRealInfo> listS = new ArrayList<ScheduleRealInfo>();  
4367 - for (ScheduleRealInfo scheduleRealInfo : lists) {  
4368 - if (scheduleRealInfo.getjGh().equals(jsy)  
4369 - && scheduleRealInfo.getClZbh().equals(clZbh)  
4370 - && scheduleRealInfo.getXlBm().equals(xlbm)  
4371 - && scheduleRealInfo.getLpName().equals(lp)) {  
4372 - if (fage) {  
4373 - //根据线路代码获取公司  
4374 - company = scheduleRealInfo.getGsBm();  
4375 - bCompany = scheduleRealInfo.getFgsBm();  
4376 - lineName = scheduleRealInfo.getXlName();  
4377 - jName= scheduleRealInfo.getjName();  
4378 - fage = false;  
4379 - }  
4380 - Set<ChildTaskPlan> cts = scheduleRealInfo.getcTasks();  
4381 - if (cts != null && cts.size() > 0) {  
4382 - listS.add(scheduleRealInfo);  
4383 - } else {  
4384 - if (scheduleRealInfo.getZdsjActual() != null && scheduleRealInfo.getFcsjActual() != null) {  
4385 - listS.add(scheduleRealInfo);  
4386 - }  
4387 - }  
4388 - }  
4389 - }  
4390 - yesterdayDataList.get(x).put("company", company);  
4391 - yesterdayDataList.get(x).put("bCompany", bCompany);  
4392 - yesterdayDataList.get(x).put("lineName", lineName);  
4393 - yesterdayDataList.get(x).put("jName", jName);  
4394 - Double ljgl = culateMieageService.culateLjgl(listS);  
4395 - Double sjgl = culateMieageService.culateSjgl(listS);  
4396 - Double ksgl = culateMieageService.culateKsgl(listS);  
4397 - Double jccgl = culateMieageService.culateJccgl(listS);  
4398 - Double zyygl = Arith.add(sjgl, ljgl);  
4399 - Double zksgl = Arith.add(ksgl, jccgl);  
4400 - Double zlc = Arith.add(zyygl, zksgl);  
4401 - yesterdayDataList.get(x).put("totalKilometers", zlc);  
4402 -  
4403 - }  
4404 - //增加顺序号  
4405 - for (int i = 0; i < yesterdayDataList.size(); i++) {  
4406 - if (i == 0) {  
4407 - yesterdayDataList.get(i).put("seqNumber", 1);  
4408 - } else {  
4409 - if (yesterdayDataList.get(i - 1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))) {  
4410 - yesterdayDataList.get(i).put("seqNumber", 1 + (int) yesterdayDataList.get(i - 1).get("seqNumber"));  
4411 - } else {  
4412 - yesterdayDataList.get(i).put("seqNumber", 1);  
4413 - }  
4414 - }  
4415 - }  
4416 -  
4417 - return yesterdayDataList;  
4418 - }  
4419 -  
4420 - /**  
4421 - * 批量调整人车  
4422 - */  
4423 - @Override  
4424 - public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs, String userId) {  
4425 - Map<String, Object> rs = new HashMap<>();  
4426 - Set<ScheduleRealInfo> set = new HashSet<>();  
4427 -  
4428 - ScheduleRealInfo sch;  
4429 -  
4430 - String jGh = null, jName, sGh, sName;  
4431 - for (ChangePersonCar cpc : cpcs) {  
4432 -  
4433 - sch = dayOfSchedule.get(cpc.getSchId());  
4434 - if (sch == null)  
4435 - continue;  
4436 -  
4437 - if (cpc.getClZbh() != null) {  
4438 - if (!carExist(sch.getGsBm(), cpc.getClZbh())) {  
4439 - rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");  
4440 - rs.put("status", ResponseCode.ERROR);  
4441 - return rs;  
4442 - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(cpc.getClZbh()))) {  
4443 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + cpc.getClZbh() + "】的车辆");  
4444 - rs.put("status", ResponseCode.ERROR);  
4445 - return rs;  
4446 - }  
4447 - }  
4448 -  
4449 - if (StringUtils.isNotEmpty(cpc.getJsy())) {  
4450 - try{  
4451 - jGh = cpc.getJsy().split("/")[0];  
4452 - }catch (Exception e){  
4453 - logger.error("", e);  
4454 - rs.put("msg", "驾驶员参数异常!!");  
4455 - rs.put("status", ResponseCode.ERROR);  
4456 - return rs;  
4457 - }  
4458 -  
4459 - jName = getPersonName(sch.getGsBm(), jGh);  
4460 - if (StringUtils.isEmpty(jName)) {  
4461 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员");  
4462 - rs.put("status", ResponseCode.ERROR);  
4463 - return rs;  
4464 - }  
4465 - }  
4466 -  
4467 -  
4468 - //为换人换车情况表写入数据  
4469 - schModifyLog.saveChangetochange(sch, cpc, userId);  
4470 - //日志记录  
4471 - ScheduleModifyLogger.tzrc(sch, cpc, userId);  
4472 -  
4473 - //换驾驶员  
4474 - if (StringUtils.isNotEmpty(cpc.getJsy())) {  
4475 - //换驾驶员  
4476 - if (persoChange(sch, jGh))  
4477 - set.add(sch);  
4478 - }  
4479 -  
4480 - //换售票员  
4481 - if (StringUtils.isNotEmpty(cpc.getSpy())  
4482 - && !"/".equals(StringUtils.trim(cpc.getSpy()))) {  
4483 -  
4484 - sGh = cpc.getSpy().split("/")[0];  
4485 - sName = getPersonName(sch.getGsBm(), sGh);  
4486 - if (StringUtils.isEmpty(sName)) {  
4487 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员");  
4488 - rs.put("status", ResponseCode.ERROR);  
4489 - return rs;  
4490 - }  
4491 -  
4492 - /*if(!sGh.equals(sch.getsGh()))  
4493 - sb.append(sch.getsGh() + " 换 " + sGh + ";");*/  
4494 - if (persoChangeSPY(sch, sGh))  
4495 - set.add(sch);  
4496 - } else if (StringUtils.isNotEmpty(sch.getsGh())) {  
4497 - sch.setsGh("");  
4498 - sch.setsName("");  
4499 - }  
4500 -  
4501 - //换车  
4502 - if (StringUtils.isNotEmpty(cpc.getClZbh()) && !cpc.getClZbh().equals(sch.getClZbh())) {  
4503 - //sb.append(sch.getClZbh() + " 换 " + cpc.getClZbh() + ";");  
4504 - set.add(sch);  
4505 - set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh()));  
4506 - }  
4507 -  
4508 - /*if(sb.length() > 0)  
4509 - sch.setRemarks(sb.toString());*/  
4510 -  
4511 - dayOfSchedule.save(sch);  
4512 - set.add(sch);  
4513 -  
4514 - }  
4515 - rs.put("ts", set);  
4516 - rs.put("status", ResponseCode.SUCCESS);  
4517 - return rs;  
4518 - }  
4519 -  
4520 - /**  
4521 - * @Title: persoChange  
4522 - * @Description: TODO(班次换驾驶员)  
4523 - */  
4524 - public boolean persoChange(ScheduleRealInfo sch, String jGh) {  
4525 - if (sch.getjGh().equals(jGh))  
4526 - return false;  
4527 - String jName = getPersonName(sch.getGsBm(), jGh);  
4528 - if (StringUtils.isNotEmpty(jName)) {  
4529 -  
4530 - if (jGh.indexOf("-") != -1)  
4531 - sch.setjGh(jGh.substring(jGh.indexOf("-") + 1));  
4532 - else  
4533 - sch.setjGh(jGh);  
4534 -  
4535 - sch.setjName(jName);  
4536 - return true;  
4537 - }  
4538 - return false;  
4539 - }  
4540 -  
4541 - /**  
4542 - * @Title: persoChange  
4543 - * @Description: TODO(班次换售票员)  
4544 - */  
4545 - public boolean persoChangeSPY(ScheduleRealInfo sch, String sGh) {  
4546 - if (sch.getsGh().equals(sGh))  
4547 - return false;  
4548 - String sName = getPersonName(sch.getGsBm(), sGh);  
4549 - if (StringUtils.isNotEmpty(sName)) {  
4550 - if (sGh.indexOf("-") != -1)  
4551 - sch.setsGh(sGh.substring(sGh.indexOf("-") + 1));  
4552 - else  
4553 - sch.setsGh(sGh);  
4554 - sch.setsName(sName);  
4555 - return true;  
4556 - }  
4557 - return false;  
4558 - }  
4559 -  
4560 - /**  
4561 - * 批量待发调整  
4562 - */  
4563 - @Override  
4564 - public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) {  
4565 - Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>();  
4566 - List<ScheduleRealInfo> list = new ArrayList<>();  
4567 -  
4568 - for (DfsjChange dc : dfsjcs) {  
4569 - if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))  
4570 - continue;  
4571 -  
4572 - tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null, "2", null);  
4573 -  
4574 - if (tempMap.get("status").equals(ResponseCode.SUCCESS)) {  
4575 - list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts"));  
4576 - }  
4577 - }  
4578 -  
4579 - rs.put("status", ResponseCode.SUCCESS);  
4580 - rs.put("ts", list);  
4581 - return rs;  
4582 - }  
4583 -  
4584 -  
4585 - @Override  
4586 - public Map<String, Object> findKMBC1(String jName, String clZbh,  
4587 - String date, String enddate) {  
4588 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate);  
4589 - DecimalFormat format = new DecimalFormat("0.00");  
4590 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
4591 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
4592 - int jhbc = 0, cjbc = 0, ljbc = 0;  
4593 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;  
4594 - float addMileage = 0l, remMileage = 0l;  
4595 - Map<String, Object> map = new HashMap<String, Object>();  
4596 - for (ScheduleRealInfo scheduleRealInfo : list) {  
4597 - if (scheduleRealInfo != null) {  
4598 - //计划里程(主任务过滤掉临加班次),  
4599 - //烂班里程(主任务烂班),  
4600 - //临加里程(主任务临加),  
4601 - //计划班次,烂班班次,增加班次  
4602 - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();  
4603 - if (scheduleRealInfo.isSflj()) {  
4604 - addMileage += tempJhlc;  
4605 - ljbc++;  
4606 - } else {  
4607 - jhlc += tempJhlc;  
4608 - jhbc++;  
4609 - if (scheduleRealInfo.getStatus() == -1) {  
4610 - remMileage += tempJhlc;  
4611 - cjbc++;  
4612 - }  
4613 - }  
4614 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
4615 - //计算营运里程,空驶里程  
4616 - if (childTaskPlans.isEmpty()) {  
4617 - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")  
4618 - || scheduleRealInfo.getBcType().equals("venting")) {  
4619 - ksgl += tempJhlc;  
4620 - } else {  
4621 - yygl += tempJhlc;  
4622 - }  
4623 - } else {  
4624 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
4625 - while (it.hasNext()) {  
4626 - ChildTaskPlan childTaskPlan = it.next();  
4627 - if (childTaskPlan.getMileageType().equals("empty")) {  
4628 - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4629 - } else {  
4630 - yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4631 - }  
4632 - }  
4633 - }  
4634 - }  
4635 - }  
4636 - map.put("jhlc", format.format(jhlc));  
4637 - map.put("remMileage", format.format(remMileage));  
4638 - map.put("addMileage", format.format(addMileage));  
4639 - map.put("yygl", format.format(yygl));  
4640 - map.put("ksgl", format.format(ksgl));  
4641 - map.put("realMileage", format.format(yygl + ksgl));  
4642 - map.put("jhbc", jhbc);  
4643 - map.put("cjbc", cjbc);  
4644 - map.put("ljbc", ljbc);  
4645 - map.put("sjbc", jhbc - cjbc + ljbc);  
4646 - return map;  
4647 - }  
4648 -  
4649 - /**  
4650 - * 调整班次类型  
4651 - *  
4652 - * @param id  
4653 - * @param bcType  
4654 - * @param remarks  
4655 - * @return  
4656 - */  
4657 - @Override  
4658 - public Map<String, Object> changeBcType(Long id, String bcType, String remarks, String majorStationName) {  
4659 - Map<String, Object> rs = new HashMap<>();  
4660 -  
4661 - try {  
4662 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
4663 - if (sch != null) {  
4664 - sch.setBcType(bcType);  
4665 - sch.setRemarks(remarks);  
4666 - rs.put("status", ResponseCode.SUCCESS);  
4667 - rs.put("t", sch);  
4668 -  
4669 - if ("major".equals(bcType)) {  
4670 - sch.setMajorStationName(majorStationName);  
4671 - }  
4672 -  
4673 - dayOfSchedule.save(sch);  
4674 - }  
4675 - } catch (Exception e) {  
4676 - logger.error("", e);  
4677 - rs.put("status", ResponseCode.ERROR);  
4678 - }  
4679 -  
4680 - return rs;  
4681 - }  
4682 -  
4683 - @Override  
4684 - public Map<String, Object> historySave(ScheduleRealInfo sch) {  
4685 - Map<String, Object> rs = new HashMap<>();  
4686 - rs.put("status", ResponseCode.ERROR);  
4687 -  
4688 - ScheduleRealInfo oldSch = super.findById(sch.getId());  
4689 - //事后日志记录  
4690 - AfterwardsLogger aflog = AfterwardsLogger.start(oldSch, "事后调整");  
4691 -  
4692 - //换车  
4693 - if (StringUtils.isNotEmpty(sch.getClZbh()) && !oldSch.getClZbh().equals(sch.getClZbh())) {  
4694 - if (!carExist(oldSch.getGsBm(), sch.getClZbh())) {  
4695 - rs.put("msg", "车辆 " + sch.getClZbh() + " 不存在!");  
4696 - return rs;  
4697 - } else {  
4698 - aflog.log("换车", oldSch.getClZbh(), sch.getClZbh());  
4699 - oldSch.setClZbh(sch.getClZbh());  
4700 - }  
4701 - }  
4702 -  
4703 - //换驾驶员  
4704 - if (StringUtils.isNotEmpty(sch.getjGh()) && !oldSch.getjGh().equals(sch.getjGh())) {  
4705 - String jName = getPersonName(oldSch.getGsBm(), sch.getjGh());  
4706 - if (StringUtils.isEmpty(jName)) {  
4707 - rs.put("msg", oldSch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员");  
4708 - return rs;  
4709 - }  
4710 - aflog.log("换驾驶员", oldSch.getjGh() + "/" + oldSch.getjName(), sch.getjGh() + "/" + sch.getjName());  
4711 - persoChange(oldSch, sch.getjGh());  
4712 - }  
4713 -  
4714 - //换售票员  
4715 - if (StringUtils.isNotEmpty(sch.getsGh()) && !oldSch.getsGh().equals(sch.getsGh())) {  
4716 - String sName = getPersonName(oldSch.getGsBm(), sch.getsGh());  
4717 - if (StringUtils.isEmpty(sName)) {  
4718 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getsGh() + "】的售票员");  
4719 - return rs;  
4720 - }  
4721 - aflog.log("换售票员", oldSch.getsGh() + "/" + oldSch.getsName(), sch.getsGh() + "/" + sch.getsName());  
4722 - persoChangeSPY(oldSch, sch.getsGh());  
4723 - }  
4724 -  
4725 - //烂班  
4726 - boolean dest1 = oldSch.getStatus() == -1;  
4727 - boolean dest2 = sch.getStatus() == -1;  
4728 - if (!dest1 && dest2) {  
4729 - oldSch.destroy();  
4730 - aflog.log("烂班");  
4731 - } else if (dest1 && !dest2) {  
4732 - //撤销烂班  
4733 - oldSch.setJhlc(oldSch.getJhlcOrig());  
4734 - oldSch.setStatus(0);  
4735 - oldSch.calcStatus();  
4736 - oldSch.setAdjustExps(null);  
4737 - aflog.log("撤销烂班");  
4738 - }  
4739 -  
4740 - oldSch.setAdjustExps(sch.getAdjustExps());  
4741 -  
4742 - /**  
4743 - * 修改班次里程  
4744 - */  
4745 - if (!oldSch.getJhlc().equals(sch.getJhlc())) {  
4746 - double jhlcNum = sch.getJhlc();  
4747 - aflog.log("修改班次里程", oldSch.getJhlc(), jhlcNum);  
4748 - //烂班  
4749 - if (jhlcNum == 0 && oldSch.getJhlcOrig() != 0)  
4750 - oldSch.destroy();  
4751 - else {  
4752 - oldSch.setJhlc(jhlcNum);  
4753 - //临加班次,实际计划一起改  
4754 - if (oldSch.isSflj())  
4755 - oldSch.setJhlcOrig(jhlcNum);  
4756 - }  
4757 - }  
4758 -  
4759 - //待发时间  
4760 - if (!CustomStringUtils.equals(oldSch.getDfsj(), sch.getDfsj())) {  
4761 - aflog.log("修改待发时间", oldSch.getDfsj(), sch.getDfsj());  
4762 - oldSch.setDfsj(sch.getDfsj());  
4763 - }  
4764 - //实发时间  
4765 - if (!CustomStringUtils.equals(oldSch.getFcsjActual(), sch.getFcsjActual())) {  
4766 - aflog.log("修改实发时间", oldSch.getFcsjActual(), sch.getFcsjActual());  
4767 - oldSch.setFcsjActual(sch.getFcsjActual());  
4768 - }  
4769 - //实际终点  
4770 - if (!CustomStringUtils.equals(oldSch.getZdsjActual(), sch.getZdsjActual())) {  
4771 - aflog.log("修改实达时间", oldSch.getZdsjActual(), sch.getZdsjActual());  
4772 - oldSch.setZdsjActual(sch.getZdsjActual());  
4773 - }  
4774 -  
4775 - //备注  
4776 - if (!CustomStringUtils.equals(oldSch.getRemarks(), sch.getRemarks())) {  
4777 - aflog.log("修改备注", oldSch.getRemarks(), sch.getRemarks());  
4778 - oldSch.setRemarks(sch.getRemarks());  
4779 - }  
4780 -  
4781 - scheduleRealInfoRepository.save(oldSch);  
4782 -  
4783 - aflog.end();  
4784 - rs.put("status", ResponseCode.SUCCESS);  
4785 - return rs;  
4786 - }  
4787 -  
4788 - @Autowired  
4789 - SvgAttributeRepository svgAttributeRepository;  
4790 -  
4791 - @Override  
4792 - public Map<String, Object> svgAttr(String jsonStr) {  
4793 - Map<String, Object> rs = new HashMap<>();  
4794 -  
4795 - try {  
4796 - JSONObject jObj = JSONObject.parseObject(StringEscapeUtils.unescapeHtml4(jsonStr));  
4797 -  
4798 - SvgAttribute svgAttribute = new SvgAttribute();  
4799 - svgAttribute.setLineCode(jObj.getString("lineCode"));  
4800 - svgAttribute.setHideStations(jObj.getString("hideStations"));  
4801 - svgAttribute.setNicknames(jObj.getString("nicknames"));  
4802 - svgAttributeRepository.save(svgAttribute);  
4803 -  
4804 - rs.put("t", svgAttribute);  
4805 - rs.put("status", ResponseCode.SUCCESS);  
4806 - } catch (Exception e) {  
4807 - logger.error("", e);  
4808 - rs.put("status", ResponseCode.ERROR);  
4809 - }  
4810 - return rs;  
4811 - }  
4812 -  
4813 - @Override  
4814 - public Map<String, Object> findSvgAttr(String idx) {  
4815 - Map<String, Object> rs = new HashMap<>();  
4816 - try {  
4817 - List<String> lineCodes = Splitter.on(",").splitToList(idx);  
4818 - List<SvgAttribute> list = svgAttributeRepository.findSvgAttr(lineCodes);  
4819 -  
4820 - rs.put("status", ResponseCode.SUCCESS);  
4821 - rs.put("list", list);  
4822 - } catch (Exception e) {  
4823 - logger.error("", e);  
4824 - rs.put("status", ResponseCode.ERROR);  
4825 - }  
4826 - return rs;  
4827 - }  
4828 -  
4829 - @Override  
4830 - public Map<String, Object> addRemarks(Long id, String remarks) {  
4831 - Map<String, Object> rs = new HashMap<>();  
4832 - try {  
4833 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
4834 - sch.addRemarks(remarks);  
4835 -  
4836 - rs.put("status", ResponseCode.SUCCESS);  
4837 - rs.put("t", sch);  
4838 - } catch (Exception e) {  
4839 - logger.error("", e);  
4840 - rs.put("status", ResponseCode.ERROR);  
4841 - }  
4842 - return rs;  
4843 - }  
4844 -  
4845 - @Override  
4846 - public List<Map<String, Object>> yesterdayDataList(String line) {  
4847 - // TODO Auto-generated method stub  
4848 - return null;  
4849 - }  
4850 -  
4851 - @Override  
4852 - public List<ScheduleRealInfo> exportWaybillQp(String clZbh, String date, String line) {  
4853 - // TODO Auto-generated method stub  
4854 - ReportUtils ee = new ReportUtils();  
4855 - ReportRelatedUtils rru = new ReportRelatedUtils();  
4856 - List<Iterator<?>> list = new ArrayList<Iterator<?>>();  
4857 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line);  
4858 - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();  
4859 -  
4860 - DecimalFormat format = new DecimalFormat("0.00");  
4861 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
4862 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
4863 - int jhbc = 0, cjbc = 0, ljbc = 0;  
4864 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0;  
4865 - float addMileage = 0l, remMileage = 0l, addgl = 0, remgl = 0;  
4866 - int xyz = 1;  
4867 - Map<String, Object> map;  
4868 - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) {  
4869 - if (scheduleRealInfo != null) {  
4870 - //计算计划里程(主任务过滤掉临加班次),烂班里程,临加里程,计划班次,烂班班次,增加班次  
4871 - //计划里程(主任务过滤掉临加班次),  
4872 - //烂班里程(主任务烂班),  
4873 - //临加里程(主任务临加),  
4874 - //计划班次,烂班班次,增加班次  
4875 - double jh = 0, sj = 0;  
4876 - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();  
4877 - if (scheduleRealInfo.isSflj()) {  
4878 - ljbc++;  
4879 - } else {  
4880 - if (!(scheduleRealInfo.getBcType().equals("in")  
4881 - || scheduleRealInfo.getBcType().equals("out"))) {  
4882 - jhbc++;  
4883 - jh += tempJhlc;  
4884 - }  
4885 - if (scheduleRealInfo.getStatus() == -1) {  
4886 - remMileage += tempJhlc;  
4887 - cjbc++;  
4888 - }  
4889 - }  
4890 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
4891 - //计算营运里程,空驶里程  
4892 - if (childTaskPlans.isEmpty()) {  
4893 - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")  
4894 - ) {  
4895 - jcclc += tempJhlc;  
4896 - } else {  
4897 - if (scheduleRealInfo.getStatus() != -1) {  
4898 - if (scheduleRealInfo.isSflj()) {  
4899 - addMileage += tempJhlc;  
4900 - }  
4901 - sj += tempJhlc;  
4902 - }  
4903 - }  
4904 - } else {  
4905 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
4906 - while (it.hasNext()) {  
4907 - ChildTaskPlan childTaskPlan = it.next();  
4908 - if (childTaskPlan.getMileageType().equals("empty")) {  
4909 - if (childTaskPlan.isDestroy()) {  
4910 - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4911 - } else {  
4912 - if (scheduleRealInfo.isSflj()) {  
4913 - addMileage += tempJhlc;  
4914 - }  
4915 - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4916 - }  
4917 - } else {  
4918 - if (childTaskPlan.isDestroy()) {  
4919 - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4920 -// cjbc++;  
4921 - } else {  
4922 - if (scheduleRealInfo.isSflj()) {  
4923 - addMileage += tempJhlc;  
4924 - }  
4925 - sj += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4926 - }  
4927 - }  
4928 - }  
4929 - }  
4930 -  
4931 - if (!(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out"))) {  
4932 - map = new HashMap<String, Object>();  
4933 - try {  
4934 - scheduleRealInfo.setBcs(xyz);  
4935 - xyz++;  
4936 - Set<ChildTaskPlan> cs = scheduleRealInfo.getcTasks();  
4937 - Double sjlc = 0.0;  
4938 - if (!cs.isEmpty()) {  
4939 - Iterator<ChildTaskPlan> it = cs.iterator();  
4940 - while (it.hasNext()) {  
4941 - ChildTaskPlan c = it.next();  
4942 - if (!c.isDestroy()) {  
4943 - sjlc += c.getMileage() == null ? 0 : c.getMileage();  
4944 - }  
4945 -  
4946 - }  
4947 - } else {  
4948 - if (scheduleRealInfo.getStatus() != -1) {  
4949 - sjlc = scheduleRealInfo.getJhlc();  
4950 - }  
4951 - }  
4952 - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName());  
4953 - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName());  
4954 - scheduleRealInfo.setSjlc(format.format(sjlc));  
4955 - map = rru.getMapValue(scheduleRealInfo);  
4956 - String zdsj = scheduleRealInfo.getZdsj();  
4957 - String zdsjActual = scheduleRealInfo.getZdsjActual();  
4958 - if (zdsj != null && zdsjActual != null &&  
4959 - !zdsj.equals(zdsjActual)) {  
4960 - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]);  
4961 - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]);  
4962 - if (zdsj.compareTo(zdsjActual) > 0) {  
4963 - if (zdsjT - zdsjAT > 1000) {  
4964 - map.put("fast", "");  
4965 - map.put("slow", zdsjAT - zdsjT + 1440);  
4966 - } else {  
4967 - map.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
4968 - map.put("slow", "");  
4969 - }  
4970 - } else {  
4971 - if (zdsjAT - zdsjT > 1000) {  
4972 - map.put("fast", zdsjT - zdsjAT + 1440);  
4973 - map.put("slow", "");  
4974 - } else {  
4975 - map.put("fast", "");  
4976 - map.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
4977 - }  
4978 - }  
4979 - } else {  
4980 - map.put("fast", "");  
4981 - map.put("slow", "");  
4982 - }  
4983 - listMap.add(map);  
4984 - } catch (Exception e) {  
4985 - e.printStackTrace();  
4986 - }  
4987 - }  
4988 - jhlc += jh;  
4989 - yygl += sj;  
4990 - if (jh > sj) {  
4991 - remgl += jh - sj;  
4992 - } else {  
4993 - addgl += sj - jh;  
4994 - }  
4995 - }  
4996 - }  
4997 -  
4998 -  
4999 - List<Ylxxb> listYlxxb = ylxxbRepository.queryListYlxxb(clZbh, date);  
5000 - Double jzl = 0.0;  
5001 - for (int t = 0; t < listYlxxb.size(); t++) {  
5002 - Ylxxb y = listYlxxb.get(t);  
5003 - jzl += y.getJzl();  
5004 - }  
5005 -  
5006 - //计算里程和班次数,并放入Map里  
5007 - map = findKMBCQp(clZbh, date, line);  
5008 - map.put("jzl", jzl);  
5009 -// map.put("jhlc", format.format(jhlc + jcclc));  
5010 -// map.put("yygljh", format.format(jhlc));  
5011 -// map.put("ssgl", format.format(remMileage));  
5012 -// map.put("ksgl", format.format(ksgl));  
5013 -// map.put("yyglsj", format.format(yygl));  
5014 -// map.put("jhbc", jhbc);  
5015 -// map.put("jcclc", jcclc);  
5016 -//  
5017 -// map.put("ljgl", format.format(addMileage));  
5018 -// map.put("ssbc", cjbc);  
5019 -// map.put("ysgl", format.format(yygl));  
5020 -// map.put("sjbc", jhbc - cjbc + ljbc);  
5021 -// map.put("zgl", format.format(yygl + ksgl + jcclc));  
5022 -// map.put("ljbc", ljbc);  
5023 -  
5024 - String zdp = "", zwdp = "", wdp = "";  
5025 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
5026 - List<DutyEmployee> listDtuy = dutyEmployeeService.getDutyEmployee(line, date + "00:00", date + "23:59");  
5027 - try {  
5028 - Long fcsj1 = sdf.parse(date + " 03:00").getTime();  
5029 - Long fcsj2 = sdf.parse(date + " 11:00").getTime();  
5030 - Long fcsj3 = sdf.parse(date + " 22:00").getTime();  
5031 - for (int i = 0; i < listDtuy.size(); i++) {  
5032 - DutyEmployee t = listDtuy.get(i);  
5033 - Long ts = t.getTs();  
5034 - if (ts > fcsj1 && ts < fcsj2) {  
5035 - if (zdp.indexOf(t.getuName()) == -1) {  
5036 - zdp += t.getuName() + ",";  
5037 -  
5038 - }  
5039 - } else if (ts > fcsj2 && ts < fcsj3) {  
5040 - if (zwdp.indexOf(t.getuName()) == -1) {  
5041 - zwdp += t.getuName() + ",";  
5042 - }  
5043 - } else {  
5044 - if (wdp.indexOf(t.getuName()) == -1) {  
5045 - wdp += t.getuName() + ",";  
5046 - }  
5047 - }  
5048 - }  
5049 - } catch (ParseException e) {  
5050 - // TODO Auto-generated catch block  
5051 - e.printStackTrace();  
5052 - }  
5053 - map.put("zdp", zdp);  
5054 - map.put("zwdp", zwdp);  
5055 - map.put("wdp", wdp);  
5056 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
5057 - list.add(listMap.iterator());  
5058 - ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/waybill_qingpu.xls",  
5059 - path + "export/" + date + "-" + clZbh + "-行车路单.xls");  
5060 -  
5061 - return scheduleRealInfos;  
5062 - }  
5063 -  
5064 - @Override  
5065 - public Map<String, Object> findKMBCQp(String clZbh, String date, String line) {  
5066 - // TODO Auto-generated method stub  
5067 - List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line);  
5068 - DecimalFormat format = new DecimalFormat("0.00");  
5069 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
5070 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
5071 - int jhbc = 0, cjbc = 0, ljbc = 0, sjbc = 0;  
5072 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0, ljjcclc = 0, jhjcclc = 0;  
5073 - double addMileage = 0, remMileage = 0, addgl = 0, remgl = 0;  
5074 - Map<String, Object> map = new HashMap<String, Object>();  
5075 - jhlc = culateMieageService.culateJhgl(lists);  
5076 - jcclc = culateMieageService.culateJccgl(lists);  
5077 - jhjcclc = culateMieageService.culateJhJccgl(lists);  
5078 - remMileage = culateMieageService.culateLbgl(lists);  
5079 - ksgl = culateMieageService.culateKsgl(lists);  
5080 - yygl = culateMieageService.culateSjgl(lists);  
5081 - jhbc = culateMieageService.culateJhbc(lists, "");  
5082 - addMileage = culateMieageService.culateLjgl(lists);  
5083 - cjbc = culateMieageService.culateLbbc(lists);  
5084 - sjbc = culateMieageService.culateSjbc(lists, "");  
5085 - ljbc = culateMieageService.culateLjbc(lists, "");  
5086 - double zyygl = Arith.add(yygl, addMileage);  
5087 - double zksgl = Arith.add(ksgl, jcclc);  
5088 - map.put("jhlc", Arith.add(jhlc, jhjcclc));  
5089 - map.put("yygljh", jhlc);  
5090 - map.put("ssgl", remMileage);  
5091 - map.put("ksgl", ksgl);  
5092 - map.put("yyglsj", Arith.add(yygl, addMileage));  
5093 - map.put("jcclc", jcclc);  
5094 - map.put("jhbc", jhbc);  
5095 - map.put("ljgl", addMileage);  
5096 - map.put("ssbc", cjbc);  
5097 - map.put("ysgl", Arith.add(yygl, addMileage));  
5098 - map.put("sjbc", sjbc);  
5099 - map.put("zgl", Arith.add(zyygl, zksgl));  
5100 - map.put("ljbc", ljbc);  
5101 -  
5102 - return map;  
5103 - }  
5104 -  
5105 - @Override  
5106 - public List<ScheduleRealInfo> queryListWaybillQp(String clZbh, String date, String line) {  
5107 - // TODO Auto-generated method stub  
5108 - DecimalFormat format = new DecimalFormat("0.00");  
5109 - List<ScheduleRealInfo> list = null;  
5110 - list = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line);  
5111 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
5112 - for (int i = 0; i < list.size(); i++) {  
5113 - ScheduleRealInfo s = list.get(i);  
5114 - if (!(s.getBcType().equals("in") || s.getBcType().equals("out"))) {  
5115 - String remarks = "";  
5116 - Double sjlc = 0.0;  
5117 - if (s.getRemarks() != null) {  
5118 - remarks += s.getRemarks();  
5119 - }  
5120 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
5121 - if (!childTaskPlans.isEmpty()) {  
5122 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
5123 - while (it.hasNext()) {  
5124 - ChildTaskPlan c = it.next();  
5125 - if (c.getRemarks() != null && c.getRemarks().length() > 0) {  
5126 - if (remarks.indexOf(c.getRemarks()) == -1) {  
5127 - remarks += c.getRemarks();  
5128 - }  
5129 - }  
5130 -  
5131 - if (!c.isDestroy()) {  
5132 - if (c.getMileageType().equals("service")) {  
5133 - sjlc += c.getMileage() == null ? 0 : c.getMileage();  
5134 - }  
5135 - }  
5136 -  
5137 - }  
5138 - } else {  
5139 - if (s.getStatus() != -1) {  
5140 - sjlc = s.getJhlc();  
5141 - }  
5142 - }  
5143 - s.setSjlc(format.format(sjlc));  
5144 - s.setRemarks(remarks);  
5145 - newList.add(s);  
5146 - }  
5147 -  
5148 - }  
5149 -  
5150 - return newList;  
5151 - }  
5152 -  
5153 - @Override  
5154 - public Map<String, Object> MapById(Long id) {  
5155 - // TODO Auto-generated method stub  
5156 - Map<String, Object> dMap=new HashMap<>();  
5157 - dMap.put("dGroup_eq", "oilType");  
5158 - Iterator<Dictionary> it= dictionaryService.list(dMap).iterator();  
5159 - while (it.hasNext()) {  
5160 - Dictionary d=it.next();  
5161 - dMap.put(d.getdCode(), d.getdName());  
5162 - }  
5163 - Map<String, Object> map = new HashMap<String, Object>();  
5164 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
5165 - ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id);  
5166 - String xlbm = s.getXlBm();  
5167 - String fcrq = s.getScheduleDateStr();  
5168 -  
5169 - int type = 2;  
5170 - Double ccyl = 0.0;  
5171 - Double jcyl = 0.0;  
5172 - Double yh = 0.0;  
5173 - Double jzl = 0.0;  
5174 - Double zlc = 0.0;  
5175 - String rylx="";  
5176 - int hyd = 0;  
5177 - Double czql = 0.0, jzql = 0.0, hq = 0.0, jql = 0.0;  
5178 - List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh());  
5179 - if (listCars.size() > 0) {  
5180 - if (listCars.get(0).getSfdc() != null) {  
5181 - if (listCars.get(0).getSfdc()) {  
5182 - List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);  
5183 - type = 1;  
5184 - for (int i = 0; i < listDlb.size(); i++) {  
5185 - Dlb d = listDlb.get(i);  
5186 - if (d.getLp() == null) {  
5187 - ccyl = Arith.add(ccyl, d.getCzcd());  
5188 - jcyl = Arith.add(jcyl, d.getJzcd());  
5189 - yh = Arith.add(yh, d.getHd());  
5190 - jzl = Arith.add(jzl, d.getCdl());  
5191 - zlc = Arith.add(zlc, d.getZlc());  
5192 - } else {  
5193 - if (d.getLp().equals(s.getLpName())) {  
5194 - ccyl = Arith.add(ccyl, d.getCzcd());  
5195 - jcyl = Arith.add(jcyl, d.getJzcd());  
5196 - yh = Arith.add(yh, d.getHd());  
5197 - jzl = Arith.add(jzl, d.getCdl());  
5198 - zlc = Arith.add(zlc, d.getZlc());  
5199 - }  
5200 - }  
5201 -  
5202 - }  
5203 - } else {  
5204 - List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);  
5205 - type = 0;  
5206 - for (int i = 0; i < listYlb.size(); i++) {  
5207 - Ylb y = listYlb.get(i);  
5208 - if (y.getLp() == null) {  
5209 - ccyl = Arith.add(ccyl, y.getCzyl());  
5210 - jcyl = Arith.add(jcyl, y.getJzyl());  
5211 - yh = Arith.add(yh, y.getYh());  
5212 - jzl = Arith.add(jzl, y.getJzl());  
5213 - zlc = Arith.add(zlc, y.getZlc());  
5214 - if(dMap.get(y.getRylx())!=null)  
5215 - rylx =dMap.get(y.getRylx()).toString();  
5216 - } else {  
5217 - if (y.getLp().equals(s.getLpName())) {  
5218 - ccyl = Arith.add(ccyl, y.getCzyl());  
5219 - jcyl = Arith.add(jcyl, y.getJzyl());  
5220 - yh = Arith.add(yh, y.getYh());  
5221 - jzl = Arith.add(jzl, y.getJzl());  
5222 - zlc = Arith.add(zlc, y.getZlc());  
5223 - if(dMap.get(y.getRylx())!=null)  
5224 - rylx =dMap.get(y.getRylx()).toString();  
5225 - }  
5226 - }  
5227 - }  
5228 - }  
5229 - }  
5230 - if(listCars.get(0).getHydrogen() != null && listCars.get(0).getHydrogen()){  
5231 - List<Qlb> listQlb = qlbRepository.queryListQlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);  
5232 - hyd = 1;  
5233 - for (int i = 0; i < listQlb.size(); i++) {  
5234 - Qlb h = listQlb.get(i);  
5235 - if (h.getLp() == null) {  
5236 - czql = Arith.add(czql, h.getCzcl());  
5237 - jzql = Arith.add(jzql, h.getJzcl());  
5238 - hq = Arith.add(hq, h.getHn());  
5239 - jql = Arith.add(jql, h.getJql());  
5240 - } else {  
5241 - if (h.getLp().equals(s.getLpName())) {  
5242 - czql = Arith.add(czql, h.getCzcl());  
5243 - jzql = Arith.add(jzql, h.getJzcl());  
5244 - hq = Arith.add(hq, h.getHn());  
5245 - jql = Arith.add(jql, h.getJql());  
5246 - }  
5247 - }  
5248 - }  
5249 - }  
5250 - }  
5251 -  
5252 - map.put("hyd", hyd);  
5253 - map.put("czcl", czql);  
5254 - map.put("jzcl", jzql);  
5255 - map.put("hn", hq);  
5256 - map.put("jql", jql);  
5257 -  
5258 - map.put("rylx", "加注类别:"+rylx);  
5259 - map.put("jzl", jzl);  
5260 - map.put("yh", yh);  
5261 - map.put("ccyl", ccyl);  
5262 - map.put("jcyl", jcyl);  
5263 - map.put("type", type);  
5264 - map.put("zlc", zlc);  
5265 - map.put("xlName", s.getXlName());  
5266 - map.put("clZbh", s.getClZbh());  
5267 - map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh()));  
5268 - map.put("fcsjActual", s.getFcsjActual());  
5269 - map.put("zdzName", s.getZdzName());  
5270 - map.put("scheduleDate", s.getScheduleDateStr());  
5271 - map.put("lpName", s.getLpName());  
5272 - String zdp = "", zwdp = "", wdp = "";  
5273 - String zdpT = "", zwdpT = "", wdpT = "";  
5274 - String dbdp = "";  
5275 - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59");  
5276 - try {  
5277 - Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime();  
5278 - Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime();  
5279 - Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime();  
5280 - for (int i = 0; i < list.size(); i++) {  
5281 - DutyEmployee t = list.get(i);  
5282 - if (dbdp.indexOf(t.getuName()) == -1) {  
5283 - if (!(dbdp.length() > 0)) {  
5284 - dbdp = t.getuName();  
5285 - } else {  
5286 - dbdp += "," + t.getuName();  
5287 - }  
5288 - }  
5289 - Long ts = t.getTs();  
5290 - if (ts > fcsj1 && ts < fcsj2) {  
5291 - if (zdp.indexOf(t.getuName()) == -1) {  
5292 - if (!(zdp.length() > 0)) {  
5293 - zdpT = t.getuName() + "...";  
5294 - }  
5295 - zdp += t.getuName() + ",";  
5296 -  
5297 - }  
5298 - } else if (ts > fcsj2 && ts < fcsj3) {  
5299 - if (zwdp.indexOf(t.getuName()) == -1) {  
5300 - if (!(zwdp.length() > 0)) {  
5301 - zwdpT = t.getuName() + "...";  
5302 - }  
5303 - zwdp += t.getuName() + ",";  
5304 - }  
5305 - } else {  
5306 - if (wdp.indexOf(t.getuName()) == -1) {  
5307 - if (!(wdp.length() > 0)) {  
5308 - wdpT = t.getuName() + "...";  
5309 - }  
5310 - wdp += t.getuName() + ",";  
5311 - }  
5312 - }  
5313 - }  
5314 - } catch (ParseException e) {  
5315 - // TODO Auto-generated catch block  
5316 - e.printStackTrace();  
5317 - }  
5318 - map.put("zdp", zdp);  
5319 - map.put("zwdp", zwdp);  
5320 - map.put("wdp", wdp);  
5321 - map.put("zdpT", zdpT);  
5322 - map.put("zwdpT", zwdpT);  
5323 - map.put("wdpT", wdpT);  
5324 - map.put("dbdp", dbdp);  
5325 - return map;  
5326 - }  
5327 -  
5328 - @Override  
5329 - public Map<String, Object> MapByIdQp(Long id) {  
5330 - // TODO Auto-generated method stub  
5331 - Map<String, Object> map = new HashMap<String, Object>();  
5332 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
5333 - ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id);  
5334 - String xlbm = s.getXlBm();  
5335 - String fcrq = s.getScheduleDateStr();  
5336 -  
5337 - int type = 0;  
5338 - Double ccyl = 0.0;  
5339 - Double jcyl = 0.0;  
5340 - Double yh = 0.0;  
5341 - Double jzl = 0.0;  
5342 - Double zlc = 0.0;  
5343 -// List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(),xlbm);  
5344 -// List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(),xlbm);  
5345 -// if(listYlb.size()>0){  
5346 -// type=0;  
5347 -// for (int i = 0; i < listYlb.size(); i++) {  
5348 -// Ylb y = listYlb.get(i);  
5349 -// if(y.getLp()==null){  
5350 -// ccyl=Arith.add(ccyl, y.getCzyl());  
5351 -// jcyl=Arith.add(jcyl, y.getJzyl());  
5352 -// yh =Arith.add(yh ,y.getYh());  
5353 -// jzl =Arith.add(jzl, y.getJzl());  
5354 -// zlc =Arith.add(zlc, y.getZlc());  
5355 -// }else{  
5356 -// if(y.getLp().equals(s.getLpName())){  
5357 -// ccyl=Arith.add(ccyl, y.getCzyl());  
5358 -// jcyl=Arith.add(jcyl, y.getJzyl());  
5359 -// yh =Arith.add(yh ,y.getYh());  
5360 -// jzl =Arith.add(jzl, y.getJzl());  
5361 -// zlc =Arith.add(zlc, y.getZlc());  
5362 -// }  
5363 -// }  
5364 -//  
5365 -// }  
5366 -// }else{  
5367 -// type=1;  
5368 -// for (int i = 0; i < listDlb.size(); i++) {  
5369 -// Dlb d=listDlb.get(i);  
5370 -// if(d.getLp()==null){  
5371 -// ccyl=Arith.add(ccyl, d.getCzcd());  
5372 -// jcyl=Arith.add(jcyl, d.getJzcd());  
5373 -// yh =Arith.add(yh ,d.getHd());  
5374 -// jzl =Arith.add(jzl, d.getCdl());  
5375 -// zlc =Arith.add(zlc, d.getZlc());  
5376 -// }else{  
5377 -// if(d.getLp().equals(s.getLpName())){  
5378 -// ccyl=Arith.add(ccyl, d.getCzcd());  
5379 -// jcyl=Arith.add(jcyl, d.getJzcd());  
5380 -// yh =Arith.add(yh ,d.getHd());  
5381 -// jzl =Arith.add(jzl, d.getCdl());  
5382 -// zlc =Arith.add(zlc, d.getZlc());  
5383 -// }  
5384 -// }  
5385 -//  
5386 -// }  
5387 -// }  
5388 -  
5389 - List<Ylxxb> listylxxb = ylxxbRepository.queryListYlxxb(s.getClZbh(), fcrq);  
5390 - for (int i = 0; i < listylxxb.size(); i++) {  
5391 - Ylxxb t = listylxxb.get(i);  
5392 - jzl = Arith.add(jzl, t.getJzl());  
5393 - }  
5394 - map.put("jzl", jzl);  
5395 - map.put("yh", yh);  
5396 - map.put("ccyl", ccyl);  
5397 - map.put("jcyl", jcyl);  
5398 - map.put("type", type);  
5399 - map.put("zlc", zlc);  
5400 - map.put("xlName", s.getXlName());  
5401 - map.put("clZbh", s.getClZbh());  
5402 - map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh()));  
5403 - map.put("fcsjActual", s.getFcsjActual());  
5404 - map.put("zdzName", s.getZdzName());  
5405 - map.put("scheduleDate", s.getScheduleDateStr());  
5406 - map.put("lpName", s.getLpName());  
5407 - String zdp = "", zwdp = "", wdp = "";  
5408 - String zdpT = "", zwdpT = "", wdpT = "";  
5409 - String dbdp = "";  
5410 - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59");  
5411 - try {  
5412 - Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime();  
5413 - Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime();  
5414 - Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime();  
5415 - for (int i = 0; i < list.size(); i++) {  
5416 - DutyEmployee t = list.get(i);  
5417 - if (dbdp.indexOf(t.getuName()) == -1) {  
5418 - if (!(dbdp.length() > 0)) {  
5419 - dbdp = t.getuName();  
5420 - } else {  
5421 - dbdp += "," + t.getuName();  
5422 - }  
5423 - }  
5424 - Long ts = t.getTs();  
5425 - if (ts > fcsj1 && ts < fcsj2) {  
5426 - if (zdp.indexOf(t.getuName()) == -1) {  
5427 - if (!(zdp.length() > 0)) {  
5428 - zdpT = t.getuName() + "...";  
5429 - }  
5430 - zdp += t.getuName() + ",";  
5431 -  
5432 - }  
5433 - } else if (ts > fcsj2 && ts < fcsj3) {  
5434 - if (zwdp.indexOf(t.getuName()) == -1) {  
5435 - if (!(zwdp.length() > 0)) {  
5436 - zwdpT = t.getuName() + "...";  
5437 - }  
5438 - zwdp += t.getuName() + ",";  
5439 - }  
5440 - } else {  
5441 - if (wdp.indexOf(t.getuName()) == -1) {  
5442 - if (!(wdp.length() > 0)) {  
5443 - wdpT = t.getuName() + "...";  
5444 - }  
5445 - wdp += t.getuName() + ",";  
5446 - }  
5447 - }  
5448 - }  
5449 - } catch (ParseException e) {  
5450 - // TODO Auto-generated catch block  
5451 - e.printStackTrace();  
5452 - }  
5453 - map.put("zdp", zdp);  
5454 - map.put("zwdp", zwdp);  
5455 - map.put("wdp", wdp);  
5456 - map.put("zdpT", zdpT);  
5457 - map.put("zwdpT", zwdpT);  
5458 - map.put("wdpT", wdpT);  
5459 - map.put("dbdp", dbdp);  
5460 - return map;  
5461 - }  
5462 -  
5463 - @Override  
5464 - public List<Map<String, Object>> scheduleDailyQp(String line, String date) {  
5465 - // TODO Auto-generated method stub  
5466 - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();  
5467 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleDailyQp(line, date);  
5468 - Map<String, Object> map = null;  
5469 - String lp = "lp";  
5470 - String jgh = "jgh";  
5471 - String clzbh = "clzbh";  
5472 - int bcs = 0;  
5473 - String thclzbh = "";  
5474 - String sgh = "sgh";  
5475 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
5476 - ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(i);  
5477 - if (scheduleRealInfo.getLpName().equals(lp)) {  
5478 - bcs++;  
5479 - String fcsj = scheduleRealInfo.getFcsj();  
5480 -  
5481 - if (!clzbh.equals(scheduleRealInfo.getClZbh())) {  
5482 - clzbh = scheduleRealInfo.getClZbh();  
5483 - if (thclzbh == "") {  
5484 - thclzbh += scheduleRealInfo.getClZbh() + ",";  
5485 - } else {  
5486 - thclzbh += scheduleRealInfo.getClZbh();  
5487 - }  
5488 - map.put("thclzbh", thclzbh);  
5489 - }  
5490 -  
5491 - if (!jgh.equals(scheduleRealInfo.getjGh())) {  
5492 - jgh = scheduleRealInfo.getjGh();  
5493 - if (map.get("jjb2") != null) {  
5494 - map.put("jjb3", scheduleRealInfo.getjGh() + "/" +  
5495 - scheduleRealInfo.getFcsjActual());  
5496 -  
5497 - } else {  
5498 - map.put("jjb2", scheduleRealInfo.getjGh() + "/" +  
5499 - scheduleRealInfo.getFcsjActual());  
5500 - }  
5501 -  
5502 - }  
5503 -  
5504 - if (scheduleRealInfo.getsGh() != null) {  
5505 - if (!scheduleRealInfo.getsGh().equals(sgh)) {  
5506 - sgh = scheduleRealInfo.getsGh() == null ? "" : scheduleRealInfo.getsGh();  
5507 - if (!sgh.equals("")) {  
5508 - if (map.get("sjb1") != null) {  
5509 - if (map.get("sjb2") != null) {  
5510 - map.put("sjb3", scheduleRealInfo.getsGh() + "/" +  
5511 - scheduleRealInfo.getFcsjActual());  
5512 - } else {  
5513 - map.put("sjb2", scheduleRealInfo.getsGh() + "/" +  
5514 - scheduleRealInfo.getFcsjActual());  
5515 - }  
5516 - } else {  
5517 - map.put("sjb1", scheduleRealInfo.getsGh() + "/" +  
5518 - scheduleRealInfo.getFcsjActual());  
5519 - }  
5520 - }  
5521 - }  
5522 - }  
5523 - if (scheduleRealInfo.getFcsjActual() != null) {  
5524 - String fcsjs[] = fcsj.split(":");  
5525 - String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":");  
5526 - int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]);  
5527 - int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]);  
5528 - map.put("cz" + bcs, b - a);  
5529 - } else {  
5530 - map.put("cz" + bcs, "无");  
5531 - }  
5532 - map.put("lp", scheduleRealInfo.getLpName());  
5533 - map.put("dd" + bcs, scheduleRealInfo.getZdsjActual());  
5534 - map.put("kc" + bcs, scheduleRealInfo.getFcsjActual());  
5535 -  
5536 - if (i < scheduleRealInfos.size() - 1) {  
5537 - if (!scheduleRealInfos.get(i + 1).getLpName().equals  
5538 - (scheduleRealInfos.get(i).getLpName())) {  
5539 - list.add(map);  
5540 - lp = "lp";  
5541 - jgh = "jgh";  
5542 - clzbh = "clzbh";  
5543 - bcs = 0;  
5544 - thclzbh = "";  
5545 - sgh = "sgh";  
5546 - }  
5547 - } else {  
5548 - list.add(map);  
5549 - }  
5550 - } else {  
5551 - bcs = 1;  
5552 - map = new HashMap<String, Object>();  
5553 - lp = scheduleRealInfo.getLpName();  
5554 - jgh = scheduleRealInfo.getjGh();  
5555 - clzbh = scheduleRealInfo.getClZbh();  
5556 - if (scheduleRealInfo.getsGh() != null) {  
5557 - sgh = scheduleRealInfo.getsGh();  
5558 - map.put("sjb1", scheduleRealInfo.getsGh() + "/" +  
5559 - scheduleRealInfo.getFcsjActual());  
5560 - }  
5561 - String fcsj = scheduleRealInfo.getFcsj();  
5562 - scheduleRealInfo.getFcsjActual();  
5563 - map.put("jjb1", jgh + "/" + scheduleRealInfo.getFcsjActual());  
5564 - map.put("cccl", clzbh);  
5565 -  
5566 - if (scheduleRealInfo.getFcsjActual() != null) {  
5567 - String fcsjs[] = fcsj.split(":");  
5568 - String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":");  
5569 - int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]);  
5570 - int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]);  
5571 - map.put("cz" + bcs, b - a);  
5572 - } else {  
5573 - map.put("cz" + bcs, "无");  
5574 - }  
5575 -  
5576 -  
5577 - map.put("lp", scheduleRealInfo.getLpName());  
5578 - map.put("dd" + bcs, scheduleRealInfo.getZdsjActual());  
5579 - map.put("kc" + bcs, scheduleRealInfo.getFcsjActual());  
5580 -  
5581 - if (i < scheduleRealInfos.size() - 1) {  
5582 - if (!scheduleRealInfos.get(i + 1).getLpName().equals  
5583 - (scheduleRealInfos.get(i).getLpName())) {  
5584 - list.add(map);  
5585 - lp = "lp";  
5586 - jgh = "jgh";  
5587 - clzbh = "clzbh";  
5588 - bcs = 0;  
5589 - thclzbh = "";  
5590 - sgh = "sgh";  
5591 - }  
5592 - } else {  
5593 - list.add(map);  
5594 - }  
5595 - }  
5596 -  
5597 - }  
5598 - return list;  
5599 - }  
5600 -  
5601 -  
5602 - @Override  
5603 - public List<Map<String, Object>> scheduleDailyExport(Map<String, Object> map) {  
5604 - String line = map.get("line").toString();  
5605 - String date = map.get("date").toString();  
5606 - String xlName = map.get("xlName").toString();  
5607 - String state = map.get("state").toString();  
5608 - String type = map.get("type").toString();  
5609 - String genre =map.get("genre").toString();  
5610 - String df="";  
5611 - if(map.get("df")!=null){  
5612 - df=map.get("df").toString();  
5613 - }  
5614 -  
5615 - List<Map<String, Object>> dataList2 = new ArrayList<Map<String, Object>>();  
5616 - List<Map<String, Object>> dataList3 = new ArrayList<Map<String, Object>>();  
5617 - List<Map<String, Object>> list1 = this.statisticsDaily(line, date, xlName, null);  
5618 - List<ScheduleRealInfo> list2 = this.queryUserInfo(line, date, state);  
5619 - List<ScheduleRealInfo> list3 = new ArrayList<ScheduleRealInfo>();  
5620 - if(genre.equals("qp"))  
5621 - list3=this.realScheduleListQp(line, date);  
5622 - else if(genre.equals("zrw"))  
5623 - list3=this.realScheduleList_zrw(line, date);  
5624 - else  
5625 - list3=this.realScheduleList(line, date);  
5626 - Map<String, Object> nMap = new HashMap<String, Object>();  
5627 - nMap.put("date", xlName + date);  
5628 - nMap.put("jls", list1.get(0).get("jls"));  
5629 - nMap.put("sjgl", list1.get(0).get("sjgl"));  
5630 -  
5631 - int size = 0;  
5632 - Map<String, Object> tempMap = new HashMap<String, Object>();  
5633 - for (int i = 0; i < list2.size(); i++) {  
5634 - ScheduleRealInfo s = list2.get(i);  
5635 - if (size == 5) {  
5636 - size = 0;  
5637 - dataList2.add(tempMap);  
5638 - tempMap = new HashMap<String, Object>();  
5639 - }  
5640 - tempMap.put("lp" + size, s.getLpName());  
5641 - tempMap.put("ch" + size, s.getClZbh());  
5642 - tempMap.put("jz" + size, s.getjGh() + "/" + s.getjName());  
5643 - tempMap.put("sz" + size, "");  
5644 - tempMap.put("jw" + size, "");  
5645 - tempMap.put("sw" + size, "");  
5646 -  
5647 - size++;  
5648 - }  
5649 - if (size < 5) {  
5650 - for (; size < 5; size++) {  
5651 - tempMap.put("lp" + size, "");  
5652 - tempMap.put("ch" + size, "");  
5653 - tempMap.put("jz" + size, "");  
5654 - tempMap.put("sz" + size, "");  
5655 - tempMap.put("jw" + size, "");  
5656 - tempMap.put("sw" + size, "");  
5657 - }  
5658 - }  
5659 -  
5660 - dataList2.add(tempMap);  
5661 -  
5662 - size = 0;  
5663 - tempMap = new HashMap<String, Object>();  
5664 - for (ScheduleRealInfo schedule : list3) {  
5665 - int x = size % 3;  
5666 - if (x == 0 && size > 0) {  
5667 - dataList3.add(tempMap);  
5668 - tempMap = new HashMap<String, Object>();  
5669 - }  
5670 - tempMap.put("lpName" + x, schedule.getLpName());  
5671 - tempMap.put("qdzName" + x, schedule.getQdzName());  
5672 - tempMap.put("zdsj" + x, schedule.getZdsj());  
5673 - String zdsjActual = schedule.getZdsjActual() != null ? schedule.getZdsjActual() : "";  
5674 - tempMap.put("zdsjActual" + x, zdsjActual);  
5675 -  
5676 - String zdsjk = "";  
5677 - String zdsjm = "";  
5678 - if (!zdsjActual.equals("")) {  
5679 - String[] zdsj_s = schedule.getZdsj().split(":");  
5680 - String[] zdsjActual_s = zdsjActual.split(":");  
5681 - Long zdsj_ = Long.parseLong(zdsj_s[0]) * 60 + Long.parseLong(zdsj_s[1]);  
5682 - Long zdsjActual_ = Long.parseLong(zdsjActual_s[0]) * 60 + Long.parseLong(zdsjActual_s[1]);  
5683 - if ((zdsj_ - zdsjActual_) > 0) {  
5684 - if(zdsj_ - zdsjActual_>1200){  
5685 - zdsjm=String.valueOf(1440-(zdsj_-zdsjActual_));  
5686 - }else{  
5687 - zdsjk = String.valueOf(zdsj_ - zdsjActual_);  
5688 - }  
5689 - } else {  
5690 - if(zdsjActual_ - zdsj_>1200){  
5691 - zdsjk =String.valueOf(1440-(zdsjActual_ - zdsj_));  
5692 - }else{  
5693 - zdsjm = String.valueOf(zdsjActual_ - zdsj_);  
5694 - }  
5695 - }  
5696 - }  
5697 - tempMap.put("zdsjk" + x, zdsjk);  
5698 - tempMap.put("zdsjm" + x, zdsjm.equals("0")?"":zdsjm);  
5699 - tempMap.put("fcsj" + x, schedule.getFcsj());  
5700 - String fcsjActural = schedule.getFcsjActual() != null ? schedule.getFcsjActual() : "";  
5701 - String bcType = schedule.getBcType() != null ? schedule.getBcType() : "";  
5702 - String fcsjActuralstr = "";  
5703 - if (bcType.equals("in")) {  
5704 - fcsjActuralstr = fcsjActural + "(进)";  
5705 - } else if (bcType.equals("out")) {  
5706 - fcsjActuralstr = fcsjActural + "(出)";  
5707 - } else {  
5708 - fcsjActuralstr = fcsjActural;  
5709 - }  
5710 - tempMap.put("fcsjActual" + x, fcsjActuralstr);  
5711 - String fcsjk = "";  
5712 - String fcsjm = "";  
5713 - String dfsjk ="";  
5714 - String dfsjm="";  
5715 - if (!fcsjActural.equals("")) {  
5716 - String[] fcsj_s = schedule.getFcsj().split(":");  
5717 - String[] fcsjActural_s = fcsjActural.split(":");  
5718 - Long fcsj_ = Long.parseLong(fcsj_s[0]) * 60 + Long.parseLong(fcsj_s[1]);  
5719 - Long fcsjActural_ = Long.parseLong(fcsjActural_s[0]) * 60 + Long.parseLong(fcsjActural_s[1]);  
5720 - if ((fcsj_ - fcsjActural_) > 0) {  
5721 - if(fcsj_ - fcsjActural_>1200){  
5722 - fcsjm=String.valueOf(1440-(fcsj_ - fcsjActural_));  
5723 - }else{  
5724 - fcsjk = String.valueOf(fcsj_ - fcsjActural_);  
5725 - }  
5726 - } else {  
5727 - if(fcsjActural_ - fcsj_>1200){  
5728 - fcsjk =String.valueOf(1440-(fcsjActural_ - fcsj_));  
5729 - }  
5730 - else{  
5731 - fcsjm = String.valueOf(fcsjActural_ - fcsj_);  
5732 - }  
5733 - }  
5734 - if(df.equals("df")){  
5735 - String[] dfsj_s =schedule.getDfsj().split(":");  
5736 - Long dfsj_ = Long.parseLong(dfsj_s[0]) * 60 + Long.parseLong(dfsj_s[1]);  
5737 - if ((dfsj_ - fcsjActural_) > 0) {  
5738 - if(dfsj_ - fcsjActural_>1200){  
5739 - dfsjm=String.valueOf(1440-(dfsj_ - fcsjActural_));  
5740 - }else{  
5741 - dfsjk = String.valueOf(dfsj_ - fcsjActural_);  
5742 - }  
5743 - } else {  
5744 - if(fcsjActural_ - dfsj_>1200){  
5745 - dfsjk= String.valueOf(1440-(fcsjActural_ - dfsj_));  
5746 - }else{  
5747 - dfsjm = String.valueOf(fcsjActural_ - dfsj_);  
5748 - }  
5749 - }  
5750 - }  
5751 - }  
5752 - if(df.equals("df")){  
5753 - tempMap.put("dfsj"+x,schedule.getDfsj());  
5754 - tempMap.put("dfsjk" + x, dfsjk);  
5755 - tempMap.put("dfsjm" + x, dfsjm.equals("0")?"":dfsjm);  
5756 - }  
5757 - tempMap.put("fcsjk" + x, fcsjk);  
5758 - tempMap.put("fcsjm" + x, fcsjm.equals("0")?"":fcsjm);  
5759 - tempMap.put("remarks" + x, schedule.getRemark() != null ? schedule.getRemark() : "");  
5760 -  
5761 - size++;  
5762 - }  
5763 - if (tempMap.get("lpName0") != null) {  
5764 - if (tempMap.get("lpName1") == null) {  
5765 - tempMap.put("lpName1", "");  
5766 - tempMap.put("qdzName1", "");  
5767 - tempMap.put("zdsj1", "");  
5768 - tempMap.put("zdsjActual1", "");  
5769 - tempMap.put("zdsjk1", "");  
5770 - tempMap.put("zdsjm1", "");  
5771 - tempMap.put("fcsj1", "");  
5772 - tempMap.put("fcsjActual1", "");  
5773 - tempMap.put("fcsjk1", "");  
5774 - tempMap.put("fcsjm1", "");  
5775 - if(df.equals("df")){  
5776 - tempMap.put("dfsj1","");  
5777 - tempMap.put("dfsjk1" , "");  
5778 - tempMap.put("dfsjm1" , "");  
5779 - }  
5780 - tempMap.put("remarks1", "");  
5781 - }  
5782 - if (tempMap.get("lpName2") == null) {  
5783 - tempMap.put("lpName2", "");  
5784 - tempMap.put("qdzName2", "");  
5785 - tempMap.put("zdsj2", "");  
5786 - tempMap.put("zdsjActual2", "");  
5787 - tempMap.put("zdsjk2", "");  
5788 - tempMap.put("zdsjm2", "");  
5789 - tempMap.put("fcsj2", "");  
5790 - tempMap.put("fcsjActual2", "");  
5791 - tempMap.put("fcsjk2", "");  
5792 - tempMap.put("fcsjm2", "");  
5793 - if(df.equals("df")){  
5794 - tempMap.put("dfsj2","");  
5795 - tempMap.put("dfsjk2" , "");  
5796 - tempMap.put("dfsjm2" , "");  
5797 - }  
5798 - tempMap.put("remarks2", "");  
5799 - }  
5800 - dataList3.add(tempMap);  
5801 - }  
5802 -  
5803 - if (date.length() == 10) {  
5804 - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59");  
5805 - String dbdp = "";  
5806 - try {  
5807 - for (int i = 0; i < list.size(); i++) {  
5808 - DutyEmployee t = list.get(i);  
5809 - if (dbdp.indexOf(t.getuName()) == -1) {  
5810 - if (!(dbdp.length() > 0)) {  
5811 - dbdp = t.getuName();  
5812 - } else {  
5813 - dbdp += "," + t.getuName();  
5814 - }  
5815 - }  
5816 - }  
5817 - } catch (Exception e) {  
5818 - // TODO: handle exception  
5819 - e.printStackTrace();  
5820 - }  
5821 - nMap.put("dbdp", dbdp);  
5822 - }  
5823 -  
5824 - if (type.equals("export")) {  
5825 - String lineName = "";  
5826 - if (map.containsKey("lineName"))  
5827 - lineName = "-" + map.get("lineName").toString() + "-";  
5828 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
5829 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
5830 - Map<String, Object> m = new HashMap<String, Object>();  
5831 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
5832 - ReportUtils ee = new ReportUtils();  
5833 - try {  
5834 - listI.add(list1.iterator());  
5835 - listI.add(dataList2.iterator());  
5836 - listI.add(dataList3.iterator());  
5837 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
5838 - String sourcePath = path + "mould/scheduleDaily.xls";  
5839 - if (date.length() == 7) {  
5840 - sdfMonth = new SimpleDateFormat("yyyy-MM");  
5841 - sdfSimple = new SimpleDateFormat("yyyyMM");  
5842 - sourcePath = path + "mould/scheduleDaily_m.xls";  
5843 - }  
5844 - if(df.equals("df")){  
5845 - sourcePath =path + "mould/scheduleDaily_df.xls";  
5846 - }  
5847 - ee.excelReplace(listI, new Object[]{nMap}, sourcePath,  
5848 - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) + lineName + "调度日报.xls");  
5849 - } catch (Exception e) {  
5850 - // TODO: handle exception  
5851 - e.printStackTrace();  
5852 - }  
5853 - }  
5854 -  
5855 - return new ArrayList<Map<String, Object>>();  
5856 - }  
5857 -  
5858 - public void exportWaybill_pl(List<ScheduleRealInfo> listpl,  
5859 - String date, String jName, String clZbh, String lpName) {  
5860 - ReportUtils ee = new ReportUtils();  
5861 - ReportRelatedUtils rru = new ReportRelatedUtils();  
5862 - List<Iterator<?>> list = new ArrayList<Iterator<?>>();  
5863 - List<ScheduleRealInfo> scheduleRealInfos = listpl;  
5864 - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();  
5865 -// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line);  
5866 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
5867 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
5868 - ScheduleRealInfo s = scheduleRealInfos.get(i);  
5869 - Set<ChildTaskPlan> cts = s.getcTasks();  
5870 - if (cts != null && cts.size() > 0) {  
5871 - lists.add(s);  
5872 - } else {  
5873 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
5874 - lists.add(s);  
5875 - }  
5876 - }  
5877 - }  
5878 - DecimalFormat format = new DecimalFormat("0.00");  
5879 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
5880 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
5881 - //计算里程和班次数,并放入Map里  
5882 - Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId());  
5883 -  
5884 - map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos)));  
5885 - map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos));  
5886 - map.put("addMileage", culateMieageService.culateLjgl(lists));  
5887 - double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists));  
5888 - map.put("yygl", yygl);  
5889 - double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists));  
5890 - map.put("ksgl", ksgl);  
5891 - map.put("realMileage", Arith.add(yygl, ksgl));  
5892 - map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, ""));  
5893 - map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos));  
5894 - map.put("ljbc", culateMieageService.culateLjbc(lists, ""));  
5895 - int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, "");  
5896 - map.put("sjbc", sjbc);  
5897 -// map=new HashMap<String,Object>();  
5898 -  
5899 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
5900 - String minfcsj = "02:00";  
5901 - List<Line> lineList = lineRepository.findLineByCode(listpl.get(0).getXlBm());  
5902 - if (lineList.size() > 0) {  
5903 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
5904 - + " id = ("  
5905 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
5906 - + ")";  
5907 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
5908 - }  
5909 - String[] minSjs = minfcsj.split(":");  
5910 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
5911 -  
5912 -  
5913 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
5914 - ScheduleRealInfo s = scheduleRealInfos.get(i);  
5915 - String[] fcsj = s.getFcsj().split(":");  
5916 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
5917 -  
5918 - Long fscjT = 0L;  
5919 - if (fcsjL < minSj) {  
5920 - Calendar calendar = new GregorianCalendar();  
5921 - calendar.setTime(s.getScheduleDate());  
5922 - calendar.add(calendar.DATE, 1);  
5923 - s.setScheduleDate(calendar.getTime());  
5924 - try {  
5925 - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();  
5926 - } catch (ParseException e) {  
5927 - // TODO Auto-generated catch block  
5928 - e.printStackTrace();  
5929 - }  
5930 -  
5931 - } else {  
5932 - try {  
5933 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
5934 - } catch (ParseException e) {  
5935 - // TODO Auto-generated catch block  
5936 - e.printStackTrace();  
5937 - }  
5938 - ;  
5939 - }  
5940 - s.setFcsjT(fscjT);  
5941 - }  
5942 - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();  
5943 - Collections.sort(scheduleRealInfos, new ComparableReal());  
5944 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
5945 - ScheduleRealInfo s = scheduleRealInfos.get(i);  
5946 - s.setAdjustExps(i + 1 + "");  
5947 - String remarks = "";  
5948 - if (s.getRemarks() != null) {  
5949 - remarks += s.getRemarks();  
5950 - }  
5951 -  
5952 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
5953 - if (!childTaskPlans.isEmpty()) {  
5954 - s.setFcsjActual("");  
5955 - s.setZdsjActual("");  
5956 - s.setJhlc(0.0);  
5957 - }  
5958 -  
5959 - if (s.isDestroy()) {  
5960 - s.setFcsjActual("");  
5961 - s.setZdsjActual("");  
5962 - s.setJhlc(0.0);  
5963 - remarks += "(烂班)";  
5964 - s.setRemarks(remarks);  
5965 - }  
5966 -  
5967 - listSchedule.add(s);  
5968 - //计算营运里程,空驶里程  
5969 - if (!childTaskPlans.isEmpty()) {  
5970 -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
5971 - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);  
5972 - Collections.sort(listit, new ComparableChild());  
5973 - for (int j = 0; j < listit.size(); j++) {  
5974 - ScheduleRealInfo t = new ScheduleRealInfo();  
5975 - ChildTaskPlan childTaskPlan = listit.get(j);  
5976 - if (childTaskPlan.isDestroy()) {  
5977 - t.setFcsjActual("");  
5978 - t.setZdsjActual("");  
5979 - t.setJhlc(0.0);  
5980 - } else {  
5981 - t.setFcsjActual(childTaskPlan.getStartDate());  
5982 - t.setZdsjActual(childTaskPlan.getEndDate());  
5983 - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));  
5984 - }  
5985 - t.setQdzName(childTaskPlan.getStartStationName());  
5986 - t.setZdzName(childTaskPlan.getEndStationName());  
5987 - t.setRemarks(childTaskPlan.getRemarks());  
5988 - t.setAdjustExps("子");  
5989 - t.setjGh("");  
5990 - t.setjName("");  
5991 - t.setsGh("");  
5992 - t.setsName("");  
5993 - listSchedule.add(t);  
5994 - }  
5995 - }  
5996 - }  
5997 - Map<String, Object> maps;  
5998 - for (ScheduleRealInfo scheduleRealInfo : listSchedule) {  
5999 - maps = new HashMap<String, Object>();  
6000 - try {  
6001 - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName());  
6002 - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName());  
6003 - maps = rru.getMapValue(scheduleRealInfo);  
6004 - maps.put("bcs", scheduleRealInfo.getAdjustExps());  
6005 - String zdsj = scheduleRealInfo.getZdsj();  
6006 - String zdsjActual = scheduleRealInfo.getZdsjActual();  
6007 - if (zdsj != null && zdsjActual != null &&  
6008 - !zdsj.equals(zdsjActual) &&  
6009 - !zdsj.equals("") &&  
6010 - !zdsjActual.equals("")) {  
6011 - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]);  
6012 - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]);  
6013 - if (zdsj.compareTo(zdsjActual) > 0) {  
6014 - if (zdsjT - zdsjAT > 1000) {  
6015 - maps.put("fast", "");  
6016 - maps.put("slow", zdsjAT - zdsjT + 1440);  
6017 - } else {  
6018 - maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
6019 - maps.put("slow", "");  
6020 - }  
6021 - } else {  
6022 - if (zdsjAT - zdsjT > 1000) {  
6023 - maps.put("fast", zdsjT - zdsjAT + 1440);  
6024 - maps.put("slow", "");  
6025 - } else {  
6026 - maps.put("fast", "");  
6027 - maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
6028 - }  
6029 - }  
6030 - } else {  
6031 - maps.put("fast", "");  
6032 - maps.put("slow", "");  
6033 - }  
6034 -  
6035 - String fcsj = scheduleRealInfo.getFcsj();  
6036 - String fcsjActual = scheduleRealInfo.getFcsjActual();  
6037 - if (fcsj != null && fcsjActual != null &&  
6038 - !fcsj.equals(fcsjActual) &&  
6039 - !fcsj.equals("") &&  
6040 - !fcsjActual.equals("")) {  
6041 - int fcsjT = Integer.valueOf(fcsj.split(":")[0]) * 60 + Integer.valueOf(fcsj.split(":")[1]);  
6042 - int fcsjAT = Integer.valueOf(fcsjActual.split(":")[0]) * 60 + Integer.valueOf(fcsjActual.split(":")[1]);  
6043 - if (fcsj.compareTo(fcsjActual) > 0) {  
6044 - if (fcsjT - fcsjAT > 1000) {  
6045 - maps.put("fast_start", "");  
6046 - maps.put("slow_start", fcsjAT - fcsjT + 1440);  
6047 - } else {  
6048 - maps.put("fast_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));  
6049 - maps.put("slow_start", "");  
6050 - }  
6051 - } else {  
6052 - if (fcsjAT - fcsjT > 1000) {  
6053 - maps.put("fast_start", fcsjT - fcsjAT + 1440);  
6054 - maps.put("slow_start", "");  
6055 - } else {  
6056 - maps.put("fast_start", "");  
6057 - maps.put("slow_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));  
6058 - }  
6059 - }  
6060 - } else {  
6061 - maps.put("fast_start", "");  
6062 - maps.put("slow_start", "");  
6063 - }  
6064 - listMap.add(maps);  
6065 - } catch (Exception e) {  
6066 - e.printStackTrace();  
6067 - }  
6068 - }  
6069 -  
6070 -  
6071 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
6072 - list.add(listMap.iterator());  
6073 - String xls = "";  
6074 - if (map.get("type").toString().equals("0")) {  
6075 - xls = "waybill_minhang.xls";  
6076 - } else {  
6077 - xls = "waybill_minhang_dl.xls";  
6078 - }  
6079 - map.put("sheetName", jName + "-" + clZbh + "-" + lpName);  
6080 - ee.excelReplace(list, new Object[]{map}, path + "mould/" + xls,  
6081 - path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");  
6082 - }  
6083 -  
6084 - @Override  
6085 - public Map<String, Object> exportWaybillMore(Map<String, Object> map) {  
6086 - String date = map.get("date").toString();  
6087 - String line = map.get("line").toString();  
6088 - ReportUtils ee = new ReportUtils();  
6089 - List<List> lists = JSON.parseArray(map.get("strs").toString(), List.class);  
6090 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/";  
6091 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
6092 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
6093 - int num = 0;  
6094 - File file = null;  
6095 - try {  
6096 - while (true) {  
6097 - String fileUrl = path + "行车路单" + sdfSimple.format(sdfMonth.parse(date));  
6098 -// file = new File(fileUrl + (num == 0 ? "/" : "(" + num + ")/")); //新建文件夹  
6099 - file = new File(fileUrl + (num == 0 ? ".xls" : "(" + num + ").xls")); //新建excel文件  
6100 - if (file.exists()) { //判断是否已存在重名  
6101 - num++;  
6102 - } else {  
6103 - break;  
6104 - }  
6105 - }  
6106 -// file.mkdirs(); //创建  
6107 - List<ScheduleRealInfo> lists_line = scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);  
6108 - List<File> files = new ArrayList<File>();  
6109 - for (List<String> list : lists) {  
6110 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
6111 - String jName = list.get(0);  
6112 - String clZbh = list.get(1);  
6113 - String lpName = list.get(2);  
6114 - String jGh = list.get(3);  
6115 - for (int i = 0; i < lists_line.size(); i++) {  
6116 - ScheduleRealInfo s = lists_line.get(i);  
6117 - if (s.getjGh().equals(jGh) && s.getClZbh().equals(clZbh) && s.getLpName().equals(lpName)) {  
6118 - newList.add(s);  
6119 - }  
6120 - }  
6121 - this.exportWaybill_pl(newList, date, jName, clZbh, lpName);  
6122 - File temp = new File(path + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");  
6123 - String fileName = file.getName();  
6124 - files.add(temp);  
6125 - }  
6126 - for (int i = 1; i < files.size(); i++) {  
6127 - File file1 = files.get(0);  
6128 - File file2 = files.get(i);  
6129 - ee.copySheetByFile(file2, file1, 0, 145);  
6130 - }  
6131 - File newFile = files.get(0);  
6132 - newFile.renameTo(file);  
6133 -// temp.renameTo(new File(path + fileName + "/" + temp.getName()));  
6134 -// File[] listFiles = file.listFiles();  
6135 -// ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path + file.getName() + ".zip")));  
6136 -//// zos.setEncoding("gbk");  
6137 -//// zos.putNextEntry(new ZipEntry(fileName + "/"));  
6138 -// for (int i = 0; i < listFiles.length; i++) {  
6139 -// zos.putNextEntry(new ZipEntry(fileName + "/" + listFiles[i].getName()));  
6140 -// BufferedInputStream bis = new BufferedInputStream(new FileInputStream(listFiles[i]));  
6141 -// BufferedOutputStream bos = new BufferedOutputStream(zos);  
6142 -// int bytesRead = 0;  
6143 -// for (byte[] buffer = new byte[BUF_SIZE]; ((bytesRead = bis.read(buffer, 0, BUF_SIZE)) != -1); ) {  
6144 -//// zos.write(buffer, 0, bytesRead);  
6145 -//// zos.flush();  
6146 -// bos.write(buffer, 0, bytesRead);  
6147 -// bos.flush();  
6148 -// }  
6149 -//// bos.close();  
6150 -// bis.close();  
6151 -// }  
6152 -// zos.close();  
6153 -// }  
6154 -  
6155 - } catch (Exception e) {  
6156 - // TODO: handle exception  
6157 - e.printStackTrace();  
6158 - }  
6159 -  
6160 - map.put("fileName", file.getName());  
6161 - return map;  
6162 - }  
6163 -  
6164 - @Autowired  
6165 - SchedulePlanInfoService schPlanService;  
6166 -  
6167 - @Override  
6168 - public List<SchedulePlanInfo> currentSchedulePlan(String lineCode) {  
6169 - List<SchedulePlanInfo> rs = dayOfSchedule.schedulePlanMap.get(lineCode);  
6170 -  
6171 - if (rs == null || rs.size() == 0) {  
6172 - //尝试刷新内存  
6173 - Map<String, Object> data = new HashMap<>();  
6174 - data.put("scheduleDate_eq", dayOfSchedule.currSchDateMap.get(lineCode));  
6175 - data.put("xlBm_eq", lineCode);  
6176 - List<SchedulePlanInfo> planItr = dayOfSchedule.cleanSchPlanItr(schPlanService.list(data).iterator());  
6177 -  
6178 - if (planItr.size() > 0) {  
6179 - dayOfSchedule.schedulePlanMap.put(lineCode, planItr);  
6180 - return planItr;  
6181 - }  
6182 - }  
6183 - return rs;  
6184 - }  
6185 -  
6186 -  
6187 - @Override  
6188 - public Map<String, Object> lpChangeMulti(String leftIdx, String rightIdx, int type) {  
6189 - Map<String, Object> rs = new HashMap<>();  
6190 - Set<ScheduleRealInfo> ts = new HashSet<>();  
6191 - try {  
6192 - List<String> leftList = Splitter.on(",").splitToList(leftIdx);  
6193 - List<String> rightList = Splitter.on(",").splitToList(rightIdx);  
6194 - Set<String> lpSet = new HashSet<>();  
6195 - Set<String> carSet = new HashSet<>();  
6196 -  
6197 - List<ScheduleRealInfo> largeList, smallList;  
6198 - if (leftList.size() > rightList.size()) {  
6199 - largeList = getByIdx(leftList);  
6200 - smallList = getByIdx(rightList);  
6201 - } else {  
6202 - largeList = getByIdx(rightList);  
6203 - smallList = getByIdx(leftList);  
6204 - }  
6205 -  
6206 - ScheduleRealInfo leftSch, rightSch = null;  
6207 - for (int i = 0; i < largeList.size(); i++) {  
6208 - leftSch = largeList.get(i);  
6209 - leftSch.setLpChange(1);  
6210 - if (i < smallList.size()) {  
6211 - rightSch = smallList.get(i);  
6212 - rightSch.setLpChange(1);  
6213 - ts.add(rightSch);  
6214 - } else {  
6215 - //不对称时多出来的  
6216 - lpChangeByLeft(leftSch, largeList.get(i - 1), type);  
6217 - ts.add(leftSch);  
6218 - lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName());  
6219 - continue;  
6220 - }  
6221 -  
6222 - //调换路牌  
6223 - lpChange(leftSch, rightSch, type);  
6224 - ts.add(leftSch);  
6225 -  
6226 - lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName());  
6227 - lpSet.add(rightSch.getXlBm() + "_" + rightSch.getLpName());  
6228 -  
6229 - carSet.add(leftSch.getClZbh());  
6230 - carSet.add(rightSch.getClZbh());  
6231 - scheduleRealInfoRepository.updateLpChange(leftSch.getId());  
6232 - scheduleRealInfoRepository.updateLpChange(rightSch.getId());  
6233 - }  
6234 -  
6235 - //重新计算路牌的起点应到时间  
6236 - for (String lpName : lpSet) {  
6237 - ts.addAll(dayOfSchedule.updateQdzTimePlan(lpName));  
6238 - }  
6239 -  
6240 - //重新就算车辆当前执行班次  
6241 - for(String nbbm : carSet){  
6242 - dayOfSchedule.reCalcExecPlan(nbbm);  
6243 - }  
6244 -  
6245 -  
6246 - for (ScheduleRealInfo sch : ts) {  
6247 - dayOfSchedule.save(sch);  
6248 - }  
6249 -  
6250 - rs.put("status", ResponseCode.SUCCESS);  
6251 - rs.put("ts", ts);  
6252 - } catch (Exception e) {  
6253 - logger.error("", e);  
6254 - rs.put("status", ResponseCode.ERROR);  
6255 - rs.put("msg", e.getMessage());  
6256 - }  
6257 -  
6258 - return rs;  
6259 - }  
6260 -  
6261 - private List<ScheduleRealInfo> getByIdx(List<String> idList) {  
6262 - List<ScheduleRealInfo> list = new ArrayList<>();  
6263 - for (String id : idList) {  
6264 - list.add(dayOfSchedule.get(Long.parseLong(id)));  
6265 - }  
6266 - return list;  
6267 - }  
6268 -  
6269 - @Override  
6270 - public void lpChange(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) {  
6271 - //释放班次映射  
6272 - if (type > 0) {  
6273 - dayOfSchedule.removeNbbm2SchMapp(leftSch);  
6274 - dayOfSchedule.removeNbbm2SchMapp(rightSch);  
6275 - }  
6276 -  
6277 - //对调数据  
6278 - LpData leftData = new LpData(leftSch);  
6279 - LpData rightData = new LpData(rightSch);  
6280 -  
6281 - leftData.appendTo(rightSch, type);  
6282 - rightData.appendTo(leftSch, type);  
6283 -  
6284 - if (type > 0) {  
6285 - //重新映射  
6286 - dayOfSchedule.addNbbm2SchMapp(leftSch);  
6287 - dayOfSchedule.addNbbm2SchMapp(rightSch);  
6288 - }  
6289 - }  
6290 -  
6291 - /**  
6292 - * 更换左边班次的路牌,右边不变  
6293 - *  
6294 - * @param leftSch  
6295 - * @param rightSch  
6296 - * @param type  
6297 - */  
6298 - public void lpChangeByLeft(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) {  
6299 - //释放班次映射  
6300 - if (type > 0)  
6301 - dayOfSchedule.removeNbbm2SchMapp(leftSch);  
6302 -  
6303 - LpData rightData = new LpData(rightSch);  
6304 - rightData.appendTo(leftSch, type);  
6305 -  
6306 - //重新映射  
6307 - if (type > 0)  
6308 - dayOfSchedule.addNbbm2SchMapp(leftSch);  
6309 -  
6310 - }  
6311 -  
6312 - @Override  
6313 - public Map<String, Object> revokeRealArrive(Long id) {  
6314 - Map<String, Object> rs = new HashMap<>();  
6315 - List<ScheduleRealInfo> ts = new ArrayList<>();  
6316 -  
6317 - try {  
6318 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
6319 - if (sch.getZdsjActual() == null && sch.getFcsjActual() == null) {  
6320 - rs.put("status", ResponseCode.ERROR);  
6321 - rs.put("msg", "班次未执行,无法撤销!");  
6322 - } else {  
6323 - //日志记录  
6324 - ScheduleModifyLogger.cxzx(sch);  
6325 -  
6326 - sch.clearFcsjActual();  
6327 - sch.clearZdsjActual();  
6328 - //清除路牌下一个班的起点到达时间  
6329 - ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);  
6330 - if (null != next) {  
6331 - next.setQdzArrDatesj(null);  
6332 - ts.add(next);  
6333 - }  
6334 -  
6335 - rs.put("status", ResponseCode.SUCCESS);  
6336 -  
6337 - ts.add(sch);  
6338 - rs.put("ts", ts);  
6339 -  
6340 - dayOfSchedule.save(sch);  
6341 - //重新计算当前执行班次  
6342 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
6343 -  
6344 - }  
6345 - } catch (Exception e) {  
6346 - logger.error("", e);  
6347 - rs.put("status", ResponseCode.ERROR);  
6348 - }  
6349 - return rs;  
6350 - }  
6351 -  
6352 - @Override  
6353 - public Map<String, Object> lateAdjust(String idx, float minute) {  
6354 - Map<String, Object> rs = new HashMap<>();  
6355 - try {  
6356 - int count = 0;  
6357 - List<ScheduleRealInfo> list = new ArrayList<>();  
6358 - List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx);  
6359 -  
6360 - ScheduleRealInfo sch;  
6361 - for (String id : ids) {  
6362 - sch = dayOfSchedule.get(Long.parseLong(id));  
6363 - if (sch != null && sch.getStatus() == 0) {  
6364 - if (minute > 0) {  
6365 - sch.setLateMinute(minute);  
6366 - } else if (minute == 0) {  
6367 - LateAdjustHandle.remove(sch);  
6368 - }  
6369 - count++;  
6370 - list.add(sch);  
6371 - }  
6372 - }  
6373 -  
6374 - rs.put("status", ResponseCode.SUCCESS);  
6375 - rs.put("count", count);  
6376 - rs.put("ts", list);  
6377 - } catch (Exception e) {  
6378 - logger.error("", e);  
6379 - rs.put("status", ResponseCode.ERROR);  
6380 - rs.put("msg", e.getMessage());  
6381 - }  
6382 -  
6383 - return rs;  
6384 - }  
6385 -  
6386 - @Override  
6387 - public List<ScheduleRealInfo> allLate2(String idx) {  
6388 - List<ScheduleRealInfo> rs = new ArrayList<>();  
6389 - List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx);  
6390 -  
6391 - Collection<ScheduleRealInfo> all = LateAdjustHandle.allLateSch();  
6392 - for (ScheduleRealInfo sch : all) {  
6393 - if (ids.indexOf(sch.getXlBm()) != -1) {  
6394 - rs.add(sch);  
6395 - }  
6396 - }  
6397 - return rs;  
6398 - }  
6399 -  
6400 -  
6401 - @Override  
6402 - public List<Map<String, Object>> mileageReport(String gsdm,  
6403 - String fgsdm, String line, String date, String date2) {  
6404 -  
6405 - String sql = "select * from calc_mileage where 1=1 ";  
6406 - if (!line.equals(" ")) {  
6407 - sql = sql + " and line_code='" + line + "' ";  
6408 - }  
6409 - sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'";  
6410 - if (!gsdm.equals(" ")) {  
6411 - sql = sql + " and company_id=" + gsdm;  
6412 - }  
6413 - if (!gsdm.equals(" ")) {  
6414 - sql = sql + " and sub_company_id=" + fgsdm;  
6415 - }  
6416 - sql = sql + " order by line_code";  
6417 - List<MileageReport> list = jdbcTemplate.query(sql,  
6418 - new RowMapper<MileageReport>() {  
6419 - @Override  
6420 - public MileageReport mapRow(ResultSet rs, int rowNum) throws SQLException {  
6421 - MileageReport mr = new MileageReport();  
6422 - mr.setCompanyName(rs.getString("company_name"));  
6423 - mr.setSubCompanyName(rs.getString("sub_company_name"));  
6424 - mr.setLineName(rs.getString("line_name"));  
6425 - mr.setSjyygl(rs.getDouble("sjyygl"));  
6426 - mr.setSjksgl(rs.getDouble("sjksgl"));  
6427 - mr.setZgl(rs.getDouble("zyygl"));  
6428 - mr.setZddfgl(rs.getDouble("zddfgl"));  
6429 - mr.setSddfgl(rs.getDouble("sddfgl"));  
6430 - mr.setWqwxhgl(rs.getDouble("wqwxhgl"));  
6431 - mr.setBfwxhgl(rs.getDouble("bfwxhgl"));  
6432 - mr.setPygl(rs.getDouble("pygl"));  
6433 - mr.setLjgl(rs.getDouble("ljgl"));  
6434 - mr.setZrwgl(rs.getDouble("zrwgl"));  
6435 - mr.setOther(rs.getString("other"));  
6436 - return mr;  
6437 - }  
6438 - });  
6439 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
6440 - double sjyygl = 0.0;  
6441 - double sjksgl = 0.0;  
6442 - double zgl = 0.0;  
6443 - double sddfgl = 0.0;  
6444 - double zddfgl = 0.0;  
6445 - double wqwxhgl = 0.0;  
6446 - double bfwxhgl = 0.0;  
6447 - double pygl = 0.0;  
6448 - double ljgl = 0.0;  
6449 - double zrwgl = 0.0;  
6450 - for (MileageReport mr : list) {  
6451 - Map<String, Object> resMap = new HashMap<String, Object>();  
6452 - resMap.put("gsName", mr.getCompanyName());  
6453 - resMap.put("fgsName", mr.getSubCompanyName());  
6454 - resMap.put("xlName", mr.getLineName());  
6455 - resMap.put("sjyygl", mr.getSjyygl());  
6456 - resMap.put("sjksgl", mr.getSjksgl());  
6457 - resMap.put("zgl", mr.getZgl());  
6458 - resMap.put("sddfgl", mr.getSddfgl());  
6459 - resMap.put("zddfgl", mr.getZddfgl());  
6460 - resMap.put("wqwxhgl", mr.getWqwxhgl());  
6461 - resMap.put("bfwxhgl", mr.getBfwxhgl());  
6462 - resMap.put("pygl", mr.getPygl());  
6463 - resMap.put("ljgl", mr.getLjgl());  
6464 - resMap.put("zrwgl", mr.getZrwgl());  
6465 - resMap.put("other", mr.getOther());  
6466 - lMap.add(resMap);  
6467 - sjyygl = Arith.add(sjyygl, mr.getSjyygl());  
6468 - sjksgl = Arith.add(sjksgl, mr.getSjksgl());  
6469 - zgl = Arith.add(zgl, mr.getZgl());  
6470 - sddfgl = Arith.add(sddfgl, mr.getSddfgl());  
6471 - zddfgl = Arith.add(zddfgl, mr.getZddfgl());  
6472 - wqwxhgl = Arith.add(wqwxhgl, mr.getWqwxhgl());  
6473 - bfwxhgl = Arith.add(bfwxhgl, mr.getBfwxhgl());  
6474 - pygl = Arith.add(pygl, mr.getPygl());  
6475 - ljgl = Arith.add(ljgl, mr.getLjgl());  
6476 - zrwgl = Arith.add(zrwgl, mr.getZrwgl());  
6477 - }  
6478 - Map<String, Object> resMap = new HashMap<String, Object>();  
6479 - resMap.put("xlName", "合计");  
6480 - resMap.put("sjyygl", sjyygl);  
6481 - resMap.put("sjksgl", sjksgl);  
6482 - resMap.put("zgl", zgl);  
6483 - resMap.put("sddfgl", sddfgl);  
6484 - resMap.put("zddfgl", zddfgl);  
6485 - resMap.put("wqwxhgl", wqwxhgl);  
6486 - resMap.put("bfwxhgl", bfwxhgl);  
6487 - resMap.put("pygl", pygl);  
6488 - resMap.put("ljgl", ljgl);  
6489 - resMap.put("zrwgl", zrwgl);  
6490 - resMap.put("other", null);  
6491 - lMap.add(resMap);  
6492 - return lMap;  
6493 - }  
6494 -  
6495 - @Override  
6496 - public List<Map<String, Object>> scheduleCorrectionReport(String gsdm,  
6497 - String fgsdm, String line, String date, String date2) {  
6498 -  
6499 - String sql = "select * from calc_schedule where 1=1 ";  
6500 - if (!line.equals(" ")) {  
6501 - sql = sql + " and line_code='" + line + "' ";  
6502 - }  
6503 - sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'";  
6504 - if (!gsdm.equals(" ")) {  
6505 - sql = sql + " and company_id=" + gsdm;  
6506 - }  
6507 - if (!gsdm.equals(" ")) {  
6508 - sql = sql + " and sub_company_id=" + fgsdm;  
6509 - }  
6510 - sql = sql + " order by line_code";  
6511 - List<ScheduleCorrectionReport> list = jdbcTemplate.query(sql,  
6512 - new RowMapper<ScheduleCorrectionReport>() {  
6513 - @Override  
6514 - public ScheduleCorrectionReport mapRow(ResultSet rs, int rowNum) throws SQLException {  
6515 - ScheduleCorrectionReport sReport = new ScheduleCorrectionReport();  
6516 - sReport.setCompanyName(rs.getString("company_name"));  
6517 - sReport.setSubCompanyName(rs.getString("sub_company_name"));  
6518 - sReport.setLineName(rs.getString("line_name"));  
6519 - sReport.setSjyybc(rs.getInt("sjyybc"));  
6520 - sReport.setSjksbc(rs.getInt("sjksbc"));  
6521 - sReport.setZbc(rs.getInt("zyybc"));  
6522 - sReport.setZddfbc(rs.getInt("zddfbc"));  
6523 - sReport.setSddfbc(rs.getInt("sddfbc"));  
6524 - sReport.setWqwxhbc(rs.getInt("wqwxhbc"));  
6525 - sReport.setBfwxhbc(rs.getInt("bfwxhbc"));  
6526 - sReport.setPybc(rs.getInt("pybc"));  
6527 - sReport.setLjbc(rs.getInt("ljbc"));  
6528 - sReport.setZrwbc(rs.getInt("zrwbc"));  
6529 - sReport.setOther(rs.getString("other"));  
6530 - return sReport;  
6531 - }  
6532 - });  
6533 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
6534 - int sjyybc = 0;  
6535 - int sjksbc = 0;  
6536 - int zbc = 0;  
6537 - int sddfbc = 0;  
6538 - int zddfbc = 0;  
6539 - int wqwxhbc = 0;  
6540 - int bfwxhbc = 0;  
6541 - int pybc = 0;  
6542 - int ljbc = 0;  
6543 - int zrwbc = 0;  
6544 - for (ScheduleCorrectionReport sReport : list) {  
6545 - Map<String, Object> resMap = new HashMap<String, Object>();  
6546 - resMap.put("gsName", sReport.getCompanyName());  
6547 - resMap.put("fgsName", sReport.getSubCompanyName());  
6548 - resMap.put("xlName", sReport.getLineName());  
6549 - resMap.put("sjyybc", sReport.getSjyybc());  
6550 - resMap.put("sjksbc", sReport.getSjksbc());  
6551 - resMap.put("zbc", sReport.getZbc());  
6552 - resMap.put("sddfbc", sReport.getSddfbc());  
6553 - resMap.put("zddfbc", sReport.getZddfbc());  
6554 - resMap.put("wqwxhbc", sReport.getWqwxhbc());  
6555 - resMap.put("bfwxhbc", sReport.getBfwxhbc());  
6556 - resMap.put("pybc", sReport.getPybc());  
6557 - resMap.put("ljbc", sReport.getLjbc());  
6558 - resMap.put("zrwbc", sReport.getZrwbc());  
6559 - resMap.put("other", sReport.getOther());  
6560 - lMap.add(resMap);  
6561 - sjyybc = sjyybc + sReport.getSjyybc();  
6562 - sjksbc = sjksbc + sReport.getSjksbc();  
6563 - zbc = zbc + sReport.getZbc();  
6564 - sddfbc = sddfbc + sReport.getSddfbc();  
6565 - zddfbc = zddfbc + sReport.getZddfbc();  
6566 - wqwxhbc = wqwxhbc + sReport.getWqwxhbc();  
6567 - bfwxhbc = bfwxhbc + sReport.getBfwxhbc();  
6568 - pybc = pybc + sReport.getPybc();  
6569 - ljbc = ljbc + sReport.getLjbc();  
6570 - zrwbc = zrwbc + sReport.getZrwbc();  
6571 - }  
6572 - Map<String, Object> resMap = new HashMap<String, Object>();  
6573 - resMap.put("xlName", "合计");  
6574 - resMap.put("sjyybc", sjyybc);  
6575 - resMap.put("sjksbc", sjksbc);  
6576 - resMap.put("zbc", zbc);  
6577 - resMap.put("sddfbc", sddfbc);  
6578 - resMap.put("zddfbc", zddfbc);  
6579 - resMap.put("wqwxhbc", wqwxhbc);  
6580 - resMap.put("bfwxhbc", bfwxhbc);  
6581 - resMap.put("pybc", pybc);  
6582 - resMap.put("ljbc", ljbc);  
6583 - resMap.put("zrwbc", zrwbc);  
6584 - resMap.put("other", null);  
6585 - lMap.add(resMap);  
6586 - return lMap;  
6587 - }  
6588 -  
6589 - @Override  
6590 - public Integer isCircleQdz(String clzbh, String sdr, String xlbm, String qdzCode) {  
6591 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
6592 - String time =sdf.format(Long.parseLong(sdr));  
6593 -  
6594 - Long num=scheduleRealInfoRepository.isCircleQdz(clzbh, time, xlbm, qdzCode);  
6595 - Integer num2=num==0L?0:1;  
6596 - return num2;  
6597 - }  
6598 -  
6599 - @SuppressWarnings("unchecked")  
6600 - private static Map<String, Object> request(String url) {  
6601 - Map<String, Object> res = new HashMap<String, Object>();  
6602 - res.put("status", ResponseCode.SUCCESS);  
6603 - InputStream in = null;  
6604 - HttpURLConnection con = null;  
6605 - try {  
6606 - con = (HttpURLConnection)new URL(url).openConnection();  
6607 - con.setRequestMethod("POST");  
6608 - con.setRequestProperty("keep-alive", "true");  
6609 - con.setRequestProperty("accept", "application/json");  
6610 - con.setRequestProperty("content-type", "application/json");  
6611 - con.setDoInput(true);  
6612 - con.setReadTimeout(2500);  
6613 - con.setConnectTimeout(2500);  
6614 -  
6615 - con.connect();  
6616 - if (con.getResponseCode() == 200) {  
6617 - in = con.getInputStream();  
6618 - ByteArrayOutputStream bout = new ByteArrayOutputStream();  
6619 - IOUtils.copy(in, bout); bout.close();  
6620 - Map<String, Object> response = new ObjectMapper().readValue(bout.toByteArray(), Map.class);  
6621 - if (!"报修成功".equals(response.get("msg"))) {  
6622 - res.put("status", ResponseCode.ERROR);  
6623 - res.putAll(response);  
6624 - }  
6625 - } else {  
6626 - res.put("status", ResponseCode.ERROR);  
6627 - res.put("msg", "调用上报接口异常");  
6628 - }  
6629 - } catch (IOException e) {  
6630 - // TODO Auto-generated catch block  
6631 - res.put("status", ResponseCode.ERROR);  
6632 - res.put("msg", "调用上报接口异常");  
6633 - } finally {  
6634 - try {  
6635 - if (in != null) in.close();  
6636 - if (con != null) con.disconnect();  
6637 - } catch (IOException e) {  
6638 - // TODO Auto-generated catch block  
6639 - e.printStackTrace();  
6640 - }  
6641 - }  
6642 -  
6643 - return res;  
6644 - }  
6645 -  
6646 - /**  
6647 - ** 维修记录上报  
6648 - * @param param 参数信息  
6649 - * @param isActive 主/被动上报  
6650 - */  
6651 - @Override  
6652 - @Transactional  
6653 - public Map<String, Object> repairReport(Map<String, Object> param, boolean isActive) {  
6654 - Map<String, Object> res = new HashMap<String, Object>();  
6655 - res.put("status", ResponseCode.SUCCESS);  
6656 - // 获取实际排班信息  
6657 - Long id = Long.parseLong((String)param.get("id"));  
6658 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
6659 -  
6660 - if (null == sch) {  
6661 - res.put("status", ResponseCode.ERROR);  
6662 - res.put("msg", "不存在的班次!");  
6663 -  
6664 - return res;  
6665 - }  
6666 -  
6667 - int reportState = -1;  
6668 - SysUser user = SecurityUtils.getCurrentUser();  
6669 - String reportUser = user.getUserName(), reportName = user.getName(), incode = (String)param.get("clZbh"), reportTypes = (String)param.get("reportTypes"), repairTypes = reportType2RepairType(reportTypes);  
6670 - // 分公司保存格式 分公司编码_公司编码  
6671 - String val = BasicData.nbbm2FgsCompanyCodeMap.get(incode);  
6672 - String[] arr = val.split("_");  
6673 - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1]));  
6674 - url.append("?nbbm=").append(incode).append("&bxy=").append(reportUser).append("&bxbm=").append(repairTypes).append("&fgs=").append(arr[0]);  
6675 -  
6676 - int count = repairReportRepository.repairReportBySch(id, isActive ? 1 : 0);  
6677 - if (count > 0) return res;  
6678 - RepairReport lrr = dayOfSchedule.getLastestRepairReport(incode);  
6679 - // 非主动上报并且无上报记录或上次已上报 则不用上报  
6680 - if (!isActive && (lrr == null || lrr.getReportState() != 0)) {  
6681 - reportState = 0;  
6682 - } else {  
6683 - res = request(url.toString());  
6684 - if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1;  
6685 - }  
6686 - // 持久化此次上报记录  
6687 - RepairReport rr = new RepairReport();  
6688 - rr.setLineId(sch.getXlBm());  
6689 - rr.setLineName(sch.getXlName());  
6690 - rr.setReportUser(reportUser);  
6691 - rr.setReportName(reportName);  
6692 - rr.setSchId(id);  
6693 - rr.setIncode(incode);  
6694 - rr.setDepartureTime(sch.getFcsj());  
6695 - rr.setRepairType(repairTypes);  
6696 - rr.setReportType(reportTypes);  
6697 - rr.setReportDate(new Date());  
6698 - rr.setReportState(reportState);  
6699 - rr.setReportMode(isActive ? 1 : 0);  
6700 - rr = repairReportRepository.save(rr);  
6701 - dayOfSchedule.setLastestRepairReport(rr);  
6702 - // 如果上报失败,放到重传队列  
6703 - if (rr.getReportState() == -1) queue.add(rr);  
6704 -  
6705 - return res;  
6706 - }  
6707 -  
6708 - private void repairReport(RepairReport rr) {  
6709 - int reportState = -1;  
6710 - // 分公司保存格式 分公司编码_公司编码  
6711 - String val = BasicData.nbbm2FgsCompanyCodeMap.get(rr.getIncode());  
6712 - String[] arr = val.split("_");  
6713 - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1]));  
6714 - url.append("?nbbm=").append(rr.getIncode()).append("&bxy=").append(rr.getReportUser()).append("&bxbm=").append(rr.getRepairType()).append("&fgs=").append(arr[0]);  
6715 -  
6716 - Map<String, Object> res = request(url.toString());  
6717 - if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1;  
6718 - if (reportState == 1) {  
6719 - rr.setReportState(1);  
6720 - repairReportRepository.save(rr);  
6721 - }  
6722 - }  
6723 -  
6724 - /**  
6725 - ** 业务类型转报修类型  
6726 - */  
6727 - private String reportType2RepairType(String reportType) {  
6728 - String[] reportTypes = reportType.split(";");  
6729 - List<String> repairTypes = new ArrayList<>();  
6730 - for (String rt : reportTypes) {  
6731 - repairTypes.add(report2repair.get(rt));  
6732 - }  
6733 -  
6734 - return StringUtils.join(repairTypes, ";");  
6735 - }  
6736 -  
6737 - @Override  
6738 - public List<RepairReport> repairReportList(String lineId, String date, String incode, String type) {  
6739 - List<RepairReport> result = new ArrayList<RepairReport>();  
6740 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
6741 -  
6742 - Date start = null, end = null;  
6743 - if (date.length() > 0) {  
6744 - try {  
6745 - start = sdf.parse(date + " 00:00:00");  
6746 - end = sdf.parse(date + " 23:59:59");  
6747 - } catch (ParseException e) {  
6748 - // TODO Auto-generated catch block  
6749 - e.printStackTrace();  
6750 - }  
6751 -  
6752 - }  
6753 -  
6754 - result = repairReportRepository.repairReportList(lineId, start, end, incode);  
6755 - Map<String, Object> dMap=new HashMap<>();  
6756 - dMap.put("dGroup_eq", "repairtype");  
6757 - Map<String, String> code2name = new HashMap<String, String>();  
6758 - for (Dictionary dic : dictionaryService.list(dMap)) {  
6759 - code2name.put(dic.getdCode(), dic.getdName());  
6760 - }  
6761 - for (RepairReport rr : result) {  
6762 - String reportType = rr.getReportType();  
6763 - String[] types = reportType.split(";");  
6764 - StringBuilder sb = new StringBuilder();  
6765 -  
6766 - for (String t : types) {  
6767 - sb.append(code2name.get(t)).append(";");  
6768 - }  
6769 -  
6770 - rr.setRepairType(sb.toString());  
6771 - rr.setReportDateStr(sdf.format(rr.getReportDate()));  
6772 - switch (rr.getReportState()) {  
6773 - case 0:  
6774 - rr.setReportStateStr("不报");  
6775 - break;  
6776 - case 1:  
6777 - rr.setReportStateStr("上报成功");  
6778 - break;  
6779 - case -1:  
6780 - rr.setReportStateStr("上报失败");  
6781 - break;  
6782 - default:  
6783 - break;  
6784 - }  
6785 - }  
6786 -  
6787 - if ("export".equals(type)) {  
6788 - String lineName = BasicData.lineCode2NameMap.get(lineId);  
6789 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
6790 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
6791 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
6792 - Map<String, Object> m = new HashMap<String, Object>();  
6793 - ReportUtils ee = new ReportUtils();  
6794 - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();  
6795 - for (int i = 0; i < result.size(); i++) {  
6796 - Map<String, Object> map = new HashMap<String, Object>();  
6797 - RepairReport rr = result.get(i);  
6798 - map.put("row", i + 1);  
6799 - map.put("lineId", rr.getLineName());  
6800 - map.put("incode", rr.getIncode());  
6801 - map.put("departureTime", rr.getDepartureTime());  
6802 - map.put("reportUser", rr.getReportUser());  
6803 - map.put("reportDateStr", rr.getReportDate());  
6804 - map.put("repairType", rr.getRepairType());  
6805 - map.put("reportStateStr", rr.getReportStateStr());  
6806 - newList.add(map);  
6807 - }  
6808 - try {  
6809 - listI.add(newList.iterator());  
6810 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
6811 - ee.excelReplace(listI, new Object[]{m}, path + "mould/repairReport.xls",  
6812 - path + "export/" + sdfSimple.format(sdfMonth.parse(date))  
6813 - + "-" + lineName + "-维修上报记录.xls");  
6814 - } catch (Exception e) {  
6815 - // TODO: handle exception  
6816 - e.printStackTrace();  
6817 - }  
6818 - }  
6819 -  
6820 - return result;  
6821 - }  
6822 -  
6823 - @Override  
6824 - public Map<String, String> getLevelsByLines(List<String> lines) {  
6825 - Map<String, String> result = new HashMap<String, String>(), currSchDate = dayOfSchedule.getCurrSchDate();  
6826 - for (String line : lines) {  
6827 - String level = BasicData.lineDate2Level.get(line + "_" + currSchDate.get(line));  
6828 - result.put(line, level == null ? "" : level);  
6829 - }  
6830 -  
6831 - return result;  
6832 - }  
6833 -  
6834 -  
6835 - @Override  
6836 - public void destroy() throws Exception {  
6837 - // TODO Auto-generated method stub  
6838 - exec.shutdown();  
6839 - }  
6840 -  
6841 -  
6842 - @Override  
6843 - public void afterPropertiesSet() throws Exception {  
6844 - // TODO Auto-generated method stub  
6845 - // 维修上报重发调度  
6846 - exec.scheduleAtFixedRate(new Runnable() {  
6847 -  
6848 - @Override  
6849 - public void run() {  
6850 - // TODO Auto-generated method stub  
6851 - try {  
6852 - Iterator<RepairReport> it = queue.iterator();  
6853 - while (it.hasNext()) {  
6854 - RepairReport rr = it.next();  
6855 - repairReport(rr);  
6856 - if (rr.getReportState() == 1 || System.currentTimeMillis() - rr.getReportDate().getTime() > 86400000) queue.remove(rr);  
6857 - }  
6858 - } catch (Exception e) {  
6859 - logger.error("维修上报重发错误", e);  
6860 - }  
6861 - }  
6862 - }, 30, 30, TimeUnit.MINUTES);  
6863 -  
6864 - //// ---  
6865 - exec.scheduleWithFixedDelay(new Runnable() {  
6866 - @Override  
6867 - public void run() {  
6868 - Map<String, Object> res = new HashMap<>();  
6869 - InputStream in = null;  
6870 - String url ="http://211.95.61.66:9008/modules/tSafedrivingCs/DSMBHforCLBH";  
6871 -  
6872 - try {  
6873 - HttpURLConnection con = (HttpURLConnection)new URL(url.toString()).openConnection();  
6874 - con.setDoInput(true);  
6875 - con.setRequestMethod("POST");  
6876 - con.setConnectTimeout(5000);  
6877 - con.setReadTimeout(5000);  
6878 - con.setRequestProperty("keep-alive", "true");  
6879 - con.setRequestProperty("accept", "*/*");  
6880 - con.setRequestProperty("content-type", "application/x-www-form-urlencoded");  
6881 - con.connect();  
6882 -  
6883 - if (con.getResponseCode() == 200) {  
6884 - in = con.getInputStream();  
6885 - ByteArrayOutputStream bout = new ByteArrayOutputStream();  
6886 - IOUtils.copy(in, bout);  
6887 - DIRMAP = new ObjectMapper().readValue(bout.toByteArray(), Map.class);  
6888 - }  
6889 - logger.info("IP打电话接口查询完成");  
6890 - } catch (MalformedURLException e) {  
6891 - // TODO Auto-generated catch block  
6892 - e.printStackTrace();  
6893 - logger.error("IP打电话接口出错",e);  
6894 - } catch (IOException e) {  
6895 - // TODO Auto-generated catch block  
6896 - e.printStackTrace();  
6897 - }  
6898 -  
6899 - }  
6900 - }, 0, 10, TimeUnit.MINUTES);  
6901 - }  
6902 -}  
6903 -  
6904 -class AccountMap implements Comparator<Map<String, Object>> {  
6905 - @Override  
6906 - public int compare(Map<String, Object> o1, Map<String, Object> o2) {  
6907 - // TODO Auto-generated method stub  
6908 - return o1.get("clZbh").toString().compareTo(o2.get("clZbh").toString());  
6909 - }  
6910 -}  
6911 -  
6912 -class AccountMap2 implements Comparator<Map<String, Object>> {  
6913 - @Override  
6914 - public int compare(Map<String, Object> o1, Map<String, Object> o2) {  
6915 - // TODO Auto-generated method stub  
6916 - return o2.get("clZbh").toString().compareTo(o1.get("clZbh").toString());  
6917 - }  
6918 -}  
6919 -  
6920 -class AccountXlbm implements Comparator<Map<String, Object>> {  
6921 - @Override  
6922 - public int compare(Map<String, Object> o1, Map<String, Object> o2) {  
6923 - // TODO Auto-generated method stub  
6924 -// PinyinHelper.convertToPinyinString(ppy.getName(),  
6925 -// "" , PinyinFormat.WITHOUT_TONE)  
6926 - return o1.get("xlNamePy").toString().compareTo(  
6927 - o2.get("xlNamePy").toString());  
6928 - }  
6929 -}  
6930 -  
6931 -class compareLpFcsjType implements Comparator<ScheduleRealInfo> {  
6932 - @Override  
6933 - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {  
6934 - // TODO Auto-generated method stub  
6935 - return (o1.getLpName()+o1.getFcsjT() + o1.getRemark()).compareTo(o2.getLpName()+o2.getFcsjT() + o2.getRemark());  
6936 - }  
6937 -  
6938 -}  
6939 -  
6940 -class compareDirLpFcsjType implements Comparator<ScheduleRealInfo> {  
6941 - @Override  
6942 - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {  
6943 - // TODO Auto-generated method stub  
6944 - return (o1.getXlDir()+o1.getFcsjT() + o1.getRemark()+o1.getLpName()).compareTo(o2.getXlDir()+o2.getFcsjT() + o2.getRemark()+o2.getLpName());  
6945 - }  
6946 -  
6947 -}  
6948 -class compareFcsjType implements Comparator<ScheduleRealInfo> {  
6949 - @Override  
6950 - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {  
6951 - // TODO Auto-generated method stub  
6952 - return (o1.getFcsjT() + o1.getRemark()).compareTo(o2.getFcsjT() + o2.getRemark());  
6953 - }  
6954 -  
6955 -} 1 +package com.bsth.service.realcontrol.impl;
  2 +
  3 +import java.io.*;
  4 +import java.lang.reflect.Field;
  5 +import java.math.BigDecimal;
  6 +import java.net.HttpURLConnection;
  7 +import java.net.MalformedURLException;
  8 +import java.net.URL;
  9 +import java.net.URLEncoder;
  10 +import java.sql.ResultSet;
  11 +import java.sql.SQLException;
  12 +import java.text.DecimalFormat;
  13 +import java.text.ParseException;
  14 +import java.text.SimpleDateFormat;
  15 +import java.util.ArrayList;
  16 +import java.util.Calendar;
  17 +import java.util.Collection;
  18 +import java.util.Collections;
  19 +import java.util.Comparator;
  20 +import java.util.Date;
  21 +import java.util.GregorianCalendar;
  22 +import java.util.HashMap;
  23 +import java.util.HashSet;
  24 +import java.util.Iterator;
  25 +import java.util.List;
  26 +import java.util.Map;
  27 +import java.util.Queue;
  28 +import java.util.Set;
  29 +import java.util.concurrent.*;
  30 +import java.util.regex.Pattern;
  31 +
  32 +import org.apache.commons.io.IOUtils;
  33 +import org.apache.commons.lang3.StringEscapeUtils;
  34 +import org.apache.commons.lang3.StringUtils;
  35 +import org.joda.time.format.DateTimeFormat;
  36 +import org.joda.time.format.DateTimeFormatter;
  37 +import org.slf4j.Logger;
  38 +import org.slf4j.LoggerFactory;
  39 +import org.springframework.beans.factory.DisposableBean;
  40 +import org.springframework.beans.factory.InitializingBean;
  41 +import org.springframework.beans.factory.annotation.Autowired;
  42 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  43 +import org.springframework.jdbc.core.JdbcTemplate;
  44 +import org.springframework.jdbc.core.RowMapper;
  45 +import org.springframework.stereotype.Service;
  46 +import org.springframework.transaction.annotation.Transactional;
  47 +
  48 +import com.alibaba.fastjson.JSON;
  49 +import com.alibaba.fastjson.JSONArray;
  50 +import com.alibaba.fastjson.JSONObject;
  51 +import com.bsth.common.Constants;
  52 +import com.bsth.common.ResponseCode;
  53 +import com.bsth.controller.realcontrol.dto.ChangePersonCar;
  54 +import com.bsth.controller.realcontrol.dto.DfsjChange;
  55 +import com.bsth.controller.realcontrol.dto.LpData;
  56 +import com.bsth.data.BasicData;
  57 +import com.bsth.data.LineConfigData;
  58 +import com.bsth.data.Station2ParkBuffer;
  59 +import com.bsth.data.schedule.DayOfSchedule;
  60 +import com.bsth.data.schedule.SchAttrCalculator;
  61 +import com.bsth.data.schedule.ScheduleComparator;
  62 +import com.bsth.data.schedule.edit_logs.FormLogger;
  63 +import com.bsth.data.schedule.edit_logs.ScheduleModifyLogger;
  64 +import com.bsth.data.schedule.edit_logs.loggers.AfterwardsLogger;
  65 +import com.bsth.data.schedule.edit_logs.loggers.FcxxwtLogger;
  66 +import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
  67 +import com.bsth.data.schedule.late_adjust.LateAdjustHandle;
  68 +import com.bsth.data.utils.CustomStringUtils;
  69 +import com.bsth.entity.CarDevice;
  70 +import com.bsth.entity.Cars;
  71 +import com.bsth.entity.Line;
  72 +import com.bsth.entity.Personnel;
  73 +import com.bsth.entity.calc.CalcInterval;
  74 +import com.bsth.entity.calc.CalcStatistics;
  75 +import com.bsth.entity.oil.Dlb;
  76 +import com.bsth.entity.oil.Qlb;
  77 +import com.bsth.entity.oil.Ylb;
  78 +import com.bsth.entity.oil.Ylxxb;
  79 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  80 +import com.bsth.entity.realcontrol.LineConfig;
  81 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  82 +import com.bsth.entity.realcontrol.SvgAttribute;
  83 +import com.bsth.entity.report.MileageReport;
  84 +import com.bsth.entity.report.RepairReport;
  85 +import com.bsth.entity.report.ScheduleCorrectionReport;
  86 +import com.bsth.entity.schedule.CarConfigInfo;
  87 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  88 +import com.bsth.entity.schedule.GuideboardInfo;
  89 +import com.bsth.entity.schedule.SchedulePlanInfo;
  90 +import com.bsth.entity.sys.Dictionary;
  91 +import com.bsth.entity.sys.DutyEmployee;
  92 +import com.bsth.entity.sys.SysUser;
  93 +import com.bsth.repository.CarDeviceRepository;
  94 +import com.bsth.repository.CarsRepository;
  95 +import com.bsth.repository.LineRepository;
  96 +import com.bsth.repository.RepairReportRepository;
  97 +import com.bsth.repository.calc.CalcIntervalRepository;
  98 +import com.bsth.repository.oil.DlbRepository;
  99 +import com.bsth.repository.oil.QlbRepository;
  100 +import com.bsth.repository.oil.YlbRepository;
  101 +import com.bsth.repository.oil.YlxxbRepository;
  102 +import com.bsth.repository.realcontrol.ChildTaskPlanRepository;
  103 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  104 +import com.bsth.repository.realcontrol.SvgAttributeRepository;
  105 +import com.bsth.repository.schedule.CarConfigInfoRepository;
  106 +import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
  107 +import com.bsth.repository.schedule.GuideboardInfoRepository;
  108 +import com.bsth.security.util.SecurityUtils;
  109 +import com.bsth.service.LineService;
  110 +import com.bsth.service.SectionRouteService;
  111 +import com.bsth.service.calc.CalcWaybillService;
  112 +import com.bsth.service.directive.DirectiveService;
  113 +import com.bsth.service.impl.BaseServiceImpl;
  114 +import com.bsth.service.realcontrol.ScheduleRealInfoService;
  115 +import com.bsth.service.report.CulateMileageService;
  116 +import com.bsth.service.report.ReportService;
  117 +import com.bsth.service.schedule.SchedulePlanInfoService;
  118 +import com.bsth.service.sys.DictionaryService;
  119 +import com.bsth.service.sys.DutyEmployeeService;
  120 +import com.bsth.util.Arith;
  121 +import com.bsth.util.ComparableChild;
  122 +import com.bsth.util.ComparableLp;
  123 +import com.bsth.util.ComparableReal;
  124 +import com.bsth.util.ConfigUtil;
  125 +import com.bsth.util.DateUtils;
  126 +import com.bsth.util.ReportRelatedUtils;
  127 +import com.bsth.util.ReportUtils;
  128 +import com.bsth.util.TimeUtils;
  129 +import com.bsth.util.TransGPS;
  130 +import com.bsth.websocket.handler.SendUtils;
  131 +import com.fasterxml.jackson.databind.ObjectMapper;
  132 +import com.github.stuxuhai.jpinyin.PinyinException;
  133 +import com.github.stuxuhai.jpinyin.PinyinFormat;
  134 +import com.github.stuxuhai.jpinyin.PinyinHelper;
  135 +import com.google.common.base.Splitter;
  136 +import com.google.common.collect.Lists;
  137 +
  138 +import javax.ws.rs.HEAD;
  139 +
  140 +@Service
  141 +public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long>
  142 + implements ScheduleRealInfoService, InitializingBean, DisposableBean {
  143 + @Autowired
  144 + JdbcTemplate jdbcTemplate;
  145 + @Autowired
  146 + ScheduleRealInfoRepository scheduleRealInfoRepository;
  147 +
  148 + @Autowired
  149 + EmployeeConfigInfoRepository employeeConfigInfoRepository;
  150 +
  151 + @Autowired
  152 + CarConfigInfoRepository carConfigInfoRepository;
  153 +
  154 + @Autowired
  155 + SectionRouteService sectionRouteService;
  156 +
  157 + @Autowired
  158 + CulateMileageService culateMieageService;
  159 +
  160 + @Autowired
  161 + DictionaryService dictionaryService;
  162 +
  163 + @Autowired
  164 + CalcWaybillService calcWaybillService;
  165 +
  166 + @Autowired
  167 + CalcIntervalRepository calcIntervalRepository;
  168 + /*@Autowired
  169 + BorrowCenter borrowCenter;*/
  170 +
  171 + @Autowired
  172 + LineRepository lineRepository;
  173 + @Autowired
  174 + LineService lineService;
  175 + @Autowired
  176 + GuideboardInfoRepository guideboardInfoRepository;
  177 +
  178 + @Autowired
  179 + ChildTaskPlanRepository cTaskPlanRepository;
  180 +
  181 + @Autowired
  182 + SendUtils sendUtils;
  183 +
  184 + @Autowired
  185 + DayOfSchedule dayOfSchedule;
  186 +
  187 + @Autowired
  188 + SchAttrCalculator schAttrCalculator;
  189 +
  190 + @Autowired
  191 + LineConfigData lineConfigData;
  192 +
  193 + @Autowired
  194 + DutyEmployeeService dutyEmployeeService;
  195 +
  196 + @Autowired
  197 + YlxxbRepository ylxxbRepository;
  198 +
  199 + @Autowired
  200 + YlbRepository ylbRepository;
  201 +
  202 + @Autowired
  203 + DlbRepository dlbRepository;
  204 +
  205 + @Autowired
  206 + QlbRepository qlbRepository;
  207 +
  208 + @Autowired
  209 + ReportService reposrService;
  210 +
  211 + @Autowired
  212 + CulateMileageService culateService;
  213 +
  214 + @Autowired
  215 + FormLogger schModifyLog;
  216 +
  217 + @Autowired
  218 + DirectiveService directiveService;
  219 +
  220 + @Autowired
  221 + CarDeviceRepository carDeviceRepository;
  222 +
  223 + @Autowired
  224 + CarsRepository carsRepository;
  225 +
  226 + @Autowired
  227 + RepairReportRepository repairReportRepository;
  228 + Logger logger = LoggerFactory.getLogger(this.getClass());
  229 +
  230 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  231 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  232 +
  233 + public static Map<String,String> DIRMAP = new ConcurrentHashMap<>(); // dvr电话
  234 + private Queue<RepairReport> queue = new ConcurrentLinkedQueue<>();
  235 +
  236 + private ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
  237 +
  238 + @Override
  239 + public Thread newThread(Runnable r) {
  240 + // TODO Auto-generated method stub
  241 + Thread t = new Thread(r);
  242 + t.setName("RepairReportReissuer");
  243 +
  244 + return t;
  245 + }
  246 + });
  247 +
  248 +
  249 +
  250 + private static Map<String, String> report2repair = new HashMap<String, String>();
  251 +
  252 + static {
  253 + report2repair.put("9101", "9109");
  254 + report2repair.put("9102", "9102");
  255 + report2repair.put("9103", "9103");
  256 + report2repair.put("9104", "9104");
  257 + report2repair.put("9109", "9109");
  258 + report2repair.put("9201", "9201");
  259 + report2repair.put("9202", "9202");
  260 + report2repair.put("9203", "9203");
  261 + report2repair.put("9204", "9204");
  262 + report2repair.put("9209", "9209");
  263 + report2repair.put("9301", "9301");
  264 + report2repair.put("9302", "9302");
  265 + report2repair.put("9303", "9303");
  266 + report2repair.put("9304", "9304");
  267 + report2repair.put("9305", "9305");
  268 + report2repair.put("9306", "9306");
  269 + report2repair.put("9309", "9309");
  270 + }
  271 +
  272 +
  273 + /**
  274 + * 校验人车 和 班次的公司和分公司归属
  275 + *
  276 + * @param schId
  277 + * @param jGh
  278 + * @param sGh
  279 + * @param nbbm
  280 + * @return -2 跨营运公司,校验不过
  281 + * -1 跨分公司,二次确认
  282 + * 1 校验通过
  283 + */
  284 + @Override
  285 + public Map<String, Object> checkPCFgsAscription(Long schId, String jGh, String sGh, String nbbm) {
  286 + Map<String, Object> rs = new HashMap<>();
  287 + try {
  288 + rs.put("status", ResponseCode.SUCCESS);
  289 + rs.put("checkStatus", -2);
  290 +
  291 + String msg = null;
  292 + ScheduleRealInfo sch = dayOfSchedule.get(schId);
  293 + String gsbm = sch.getGsBm(), fgsbm = sch.getFgsBm();
  294 +
  295 + if (nbbm != null && !carExist(gsbm, nbbm)) {
  296 + msg = sch.getGsName() + "没有自编号为" + "[" + nbbm + "]的车辆";
  297 + rs.put("msg", msg);
  298 + return rs;
  299 + }
  300 +
  301 + if (nbbm != null && !sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(nbbm))) {
  302 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + nbbm + "】的车辆");
  303 + return rs;
  304 + }
  305 +
  306 + if (nbbm != null && !(fgsbm + "_" + gsbm).equals(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm))) {
  307 +
  308 + String clFgsName = BasicData.businessFgsCodeNameMap.get(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm));
  309 +
  310 + msg = ("【" + nbbm + "】" + "是" + clFgsName + "的车辆!");
  311 + rs.put("msg", msg);
  312 + rs.put("checkStatus", -1);
  313 + return rs;
  314 + }
  315 +
  316 + if(null != jGh && !"/".equals(StringUtils.trim(jGh))){
  317 + Personnel jsy = BasicData.perMap.get(gsbm + "-" + jGh);
  318 +
  319 + if (null == jsy) {
  320 + msg = "【驾驶员】:" + sch.getGsName() + "暂无工号为" + "【" + jGh + "】的人员";
  321 + rs.put("msg", msg);
  322 + return rs;
  323 + }
  324 + else if (!fgsbm.equals(jsy.getBrancheCompanyCode())) {
  325 + //校验分公司
  326 + msg = ("【驾驶员】:" + jGh + "/" + jsy.getPersonnelName() + "是" + jsy.getBrancheCompany() + "的人员");
  327 + rs.put("msg", msg);
  328 + rs.put("checkStatus", -1);
  329 + return rs;
  330 + }
  331 + }
  332 +
  333 + if (null != sGh && !"/".equals(StringUtils.trim(sGh))) {
  334 + Personnel spy = BasicData.perMap.get(gsbm + "-" + sGh);
  335 + if (null == spy) {
  336 + msg = "【售票员】: " + sch.getGsName() + "暂无工号为" + "【" + sGh + "】的人员";
  337 + rs.put("msg", msg);
  338 + return rs;
  339 + }
  340 + else if (!fgsbm.equals(spy.getBrancheCompanyCode())) {
  341 + msg = ("【售票员】: " + sGh + "/" + spy.getPersonnelName() + "是" + spy.getBrancheCompany() + "的人员");
  342 + rs.put("msg", msg);
  343 + rs.put("checkStatus", -1);
  344 + return rs;
  345 + }
  346 + }
  347 +
  348 + rs.put("checkStatus", 1);
  349 + } catch (Exception e) {
  350 + logger.error("", e);
  351 + rs.put("status", ResponseCode.ERROR);
  352 + }
  353 + return rs;
  354 + }
  355 +
  356 +
  357 + /**
  358 + * 车辆是否存在
  359 + *
  360 + * @param gsbm 公司编码
  361 + * @param nbbm 车辆自编号
  362 + * @return
  363 + */
  364 + private boolean carExist(String gsbm, String nbbm) {
  365 + return BasicData.nbbm2CompanyCodeMap.containsKey(nbbm);
  366 + }
  367 +
  368 + /**
  369 + * 获取人员姓名
  370 + *
  371 + * @param gsbm 公司编码
  372 + * @param gh 人员工号
  373 + * @return
  374 + */
  375 + private String getPersonName(String gsbm, String gh) {
  376 + return BasicData.allPerson.get(gsbm + '-' + gh);
  377 + }
  378 +
  379 + @Override
  380 + public Iterable<ScheduleRealInfo> list(Map<String, Object> map) {
  381 + Iterator<ScheduleRealInfo> iterator = super.list(map).iterator();
  382 + Set<ScheduleRealInfo> set = new HashSet<>(100);
  383 +
  384 + DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
  385 + //计算时间戳
  386 + ScheduleRealInfo sch;
  387 + while (iterator.hasNext()) {
  388 + sch = iterator.next();
  389 + //待发时间戳
  390 + sch.setDfsjT(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getDfsj()));
  391 + //实发时间戳
  392 + if (StringUtils.isNotEmpty(sch.getFcsjActual())) {
  393 + sch.setFcsjActualTime(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getFcsjActual()));
  394 + }
  395 + set.add(sch);
  396 + }
  397 + return set;
  398 + }
  399 +
  400 + @Override
  401 + public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) {
  402 + List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines));
  403 +
  404 + /*Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create();
  405 +
  406 + for (String lineCode : lineList) {
  407 + mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode));
  408 + }*/
  409 + return dayOfSchedule.findByLineCodes(lineList);
  410 + }
  411 +
  412 + private final static long DAY_TIME = 1000 * 60 * 60 * 24L;
  413 +
  414 + private static int BUF_SIZE = 1024;
  415 +
  416 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  417 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
  418 +
  419 + @Override
  420 + public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType, String opType, String userId) {
  421 + Map<String, Object> map = new HashMap<>();
  422 + try {
  423 +
  424 + ScheduleRealInfo schedule = dayOfSchedule.get(id);
  425 +
  426 + if (schedule.getStatus() > 0) {
  427 + map.put("status", ResponseCode.SUCCESS);
  428 + map.put("flag", "4008");
  429 + map.put("t", schedule);
  430 + return map;
  431 + }
  432 +
  433 + LineConfig config = lineConfigData.get(schedule.getXlBm());
  434 + //小于线路开始运营时间,则默认跨过24点
  435 + if (dfsj.compareTo(config.getStartOpt()) < 0) {
  436 + schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME));
  437 + } else {
  438 + schedule.setRealExecDate(schedule.getScheduleDateStr());
  439 + }
  440 +
  441 + //记录日志
  442 + ScheduleModifyLogger.dftz(schedule, opType, schedule.getDfsj(), dfsj, remarks, userId);
  443 +
  444 + schedule.setDfsjAll(dfsj);
  445 + schedule.setDfAuto(false);
  446 + if ("1".equals(opType))
  447 + schedule.setRemarks(remarks);
  448 +
  449 + List<ScheduleRealInfo> ts = new ArrayList<>();
  450 + ts.add(schedule);
  451 + //调整终点时间和下一个班次的应到时间
  452 + //schedule.calcEndTime();
  453 + /*ScheduleRealInfo nextSch = dayOfSchedule.nextByLp2(schedule);
  454 + if (null != nextSch) {
  455 + nextSch.setQdzArrDatejh(schedule.getZdsj());
  456 + ts.add(nextSch);
  457 + }*/
  458 +
  459 + //调整班次类型
  460 + if (StringUtils.isNotEmpty(bcType) && !bcType.equals(schedule.getBcType())) {
  461 + if ((schedule.getBcType().equals("major")
  462 + || schedule.getBcType().equals("venting"))
  463 + && bcType.equals("normal")) {
  464 + //清空备注
  465 + schedule.setRemarks("");
  466 + }
  467 + schedule.setBcType(bcType);
  468 + }
  469 +
  470 + //如果正在执行该班次
  471 + //ScheduleRealInfo exec = dayOfSchedule.executeCurr(schedule.getClZbh());
  472 + //if(exec != null && exec == schedule){
  473 + //重新计算正在执行班次
  474 + dayOfSchedule.reCalcExecPlan(schedule.getClZbh());
  475 + //}
  476 +
  477 + //重新计算是否误点
  478 + schedule.reCalcLate();
  479 + //取消应发未到标记,不再自动调整待发
  480 + //if(schedule.isLate2()){
  481 + // schedule.setLate2(false);
  482 + //LateAdjustHandle.remove(schedule);
  483 + //}
  484 +
  485 + try {
  486 + if (!schedule.getDirectiveState().equals(-1) && schedule.getStatus() == 0) {
  487 + //重新下发调度指令
  488 + directiveService.send60Dispatch(schedule.getId(), "待发@系统");
  489 + }
  490 + } catch (Exception e) {
  491 + logger.error("", e);
  492 + }
  493 +
  494 + // 持久化到数据库
  495 + dayOfSchedule.save(schedule);
  496 +
  497 + map.put("status", ResponseCode.SUCCESS);
  498 + map.put("ts", ts);
  499 + } catch (Exception e) {
  500 + logger.error("", e);
  501 + map.put("status", ResponseCode.ERROR);
  502 + }
  503 + return map;
  504 + }
  505 +
  506 + @Override
  507 + public Map<String, Object> destroy(String idsStr, String remarks, String reason, String userId) {
  508 +
  509 + Map<String, Object> map = new HashMap<>();
  510 + List<ScheduleRealInfo> rsList = new ArrayList<>();
  511 + map.put("ts", rsList);
  512 + try {
  513 + List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr));
  514 +
  515 + ScheduleRealInfo schedule = null;
  516 + for (String id : idList) {
  517 + schedule = dayOfSchedule.get(Long.parseLong(id));
  518 + if (schedule.isDestroy()) {
  519 + map.put("status", ResponseCode.ERROR);
  520 + map.put("msg", "不必要的重复烂班!");
  521 + return map;
  522 + }
  523 + //记录日志
  524 + ScheduleModifyLogger.jhlb(schedule, remarks, userId);
  525 +
  526 + schedule.setAdjustExps(reason);
  527 + schedule.destroy();
  528 + schedule.addRemarks(remarks);
  529 +
  530 + dayOfSchedule.save(schedule);
  531 + rsList.add(schedule);
  532 + }
  533 +
  534 + //重新计算当前执行班次
  535 + dayOfSchedule.reCalcExecPlan(schedule.getClZbh());
  536 +
  537 + map.put("status", ResponseCode.SUCCESS);
  538 + } catch (Exception e) {
  539 + logger.error("", e);
  540 + map.put("status", ResponseCode.ERROR);
  541 + }
  542 + return map;
  543 + }
  544 +
  545 + // 线路id获取驾驶员
  546 + @Override
  547 + public List<Map<String, String>> findDriverByLine(String lineCode) {
  548 + List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
  549 +
  550 + List<Map<String, String>> rsList = new ArrayList<>();
  551 + Map<String, String> map = null;
  552 + Personnel driver = null;
  553 + String code = null;
  554 +
  555 + for (EmployeeConfigInfo employee : list) {
  556 + driver = employee.getJsy();
  557 + if (driver != null) {
  558 + map = new HashMap<>();
  559 + code = driver.getJobCode();
  560 + map.put("id", code + "/" + driver.getPersonnelName());
  561 + map.put("text", code + "/" + driver.getPersonnelName());
  562 + rsList.add(map);
  563 + }
  564 + }
  565 + return rsList;
  566 + }
  567 +
  568 + // 线路id获取售票员
  569 + @Override
  570 + public List<Map<String, String>> findConductorByLine(String lineCode) {
  571 + List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
  572 +
  573 + List<Map<String, String>> rsList = new ArrayList<>();
  574 + Map<String, String> map = null;
  575 + Personnel conductor = null;
  576 + String code = null;
  577 +
  578 + for (EmployeeConfigInfo employee : list) {
  579 + conductor = employee.getSpy();
  580 + if (conductor != null) {
  581 + code = conductor.getJobCode();
  582 + map = new HashMap<>();
  583 + map.put("id", code + "/" + conductor.getPersonnelName());
  584 + map.put("text", code + "/" + conductor.getPersonnelName());
  585 + rsList.add(map);
  586 + }
  587 + }
  588 + return rsList;
  589 + }
  590 +
  591 + @Override
  592 + public List<Map<String, String>> findCarByLine(String lineCode) {
  593 +
  594 + List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode);
  595 +
  596 + List<Map<String, String>> rsList = new ArrayList<>();
  597 + Map<String, String> map = null;
  598 + Cars car = null;
  599 + String code = null;
  600 +
  601 + for (CarConfigInfo cci : list) {
  602 + car = cci.getCl();
  603 + if (car != null) {
  604 + code = car.getInsideCode();
  605 + map = new HashMap<>();
  606 + map.put("id", code);
  607 + map.put("text", code);
  608 + rsList.add(map);
  609 + }
  610 + }
  611 + return rsList;
  612 + }
  613 +
  614 + /**
  615 + * 添加到历史库
  616 + *
  617 + * @param t
  618 + * @return
  619 + */
  620 + @Override
  621 + public Map<String, Object> addToHistory(ScheduleRealInfo t) {
  622 + Map<String, Object> rs = new HashMap<>();
  623 + try {
  624 + String clZbh = t.getClZbh(), lpName = t.getLpName();
  625 + if (StringUtils.isEmpty(lpName) || StringUtils.isEmpty(lpName.trim())) {
  626 + rs.put("status", ResponseCode.ERROR);
  627 + rs.put("msg", "路牌信息缺失");
  628 + return rs;
  629 + }
  630 + if (!carExist(t.getGsBm(), clZbh)) {
  631 + rs.put("msg", "车辆 " + clZbh + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");
  632 + rs.put("status", ResponseCode.ERROR);
  633 + return rs;
  634 + }
  635 +
  636 + SysUser user = SecurityUtils.getCurrentUser();
  637 + //String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm());
  638 +
  639 + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");
  640 +
  641 + if (StringUtils.isEmpty(t.getjGh())) {
  642 + rs.put("status", ResponseCode.ERROR);
  643 + rs.put("msg", "驾驶员工号不能为空!");
  644 + return rs;
  645 + }
  646 + //截取驾驶员工号
  647 + if (t.getjGh().indexOf("-") != -1) {
  648 + t.setjGh(t.getjGh().split("-")[1]);
  649 + }
  650 + //检查驾驶员工号
  651 + String jName = getPersonName(t.getGsBm(), t.getjGh());
  652 + if (StringUtils.isEmpty(jName)) {
  653 + rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的驾驶员");
  654 + rs.put("status", ResponseCode.ERROR);
  655 + return rs;
  656 + } else if (StringUtils.isEmpty(t.getjName())) {
  657 + t.setjName(jName);//补上驾驶员名称
  658 + }
  659 +
  660 + //有售票员
  661 + if (StringUtils.isNotEmpty(t.getsGh())) {
  662 + String sName = getPersonName(t.getGsBm(), t.getsGh());
  663 + if (StringUtils.isEmpty(sName)) {
  664 + rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的售票员");
  665 + rs.put("status", ResponseCode.ERROR);
  666 + return rs;
  667 + } else if (StringUtils.isEmpty(t.getsName())) {
  668 + t.setsName(sName);//补上售票员名称
  669 + }
  670 + } else {
  671 + t.setsGh("");
  672 + t.setsName("");
  673 + }
  674 +
  675 + //公司 和 分公司名称
  676 + t.setGsName(BasicData.businessCodeNameMap.get(t.getGsBm()));
  677 + t.setFgsName(BasicData.businessFgsCodeNameMap.get(t.getFgsBm()+ "_" + t.getGsBm() ));
  678 +
  679 + //t.setScheduleDateStr(schDate);
  680 + t.setScheduleDate(sdfyyyyMMdd.parse(t.getScheduleDateStr()));
  681 + t.setRealExecDate(t.getScheduleDateStr());
  682 + t.setCreateBy(user);
  683 + t.setSflj(true);
  684 + t.setLate(false);
  685 + t.setDfsj(t.getFcsj());
  686 + t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime());
  687 + t.setJhlcOrig(t.getJhlc());
  688 +
  689 + //班次历时
  690 + t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60);
  691 +
  692 + //起终点名称
  693 + String prefix = t.getXlBm() + "_" + t.getXlDir() + "_";
  694 + t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix));
  695 + t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix));
  696 +
  697 + //计算班次实际执行时间
  698 + schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t);
  699 + //处理计达跨24点
  700 + LineConfig conf = lineConfigData.get(t.getXlBm());
  701 + if (t.getZdsj().compareTo(conf.getStartOpt()) < 0) {
  702 + t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime() + (1000 * 60 * 60 * 24));
  703 + }
  704 + if (t.getZdsjT() < t.getFcsjT()) {
  705 + rs.put("status", ResponseCode.ERROR);
  706 + rs.put("msg", "起终点时间异常!");
  707 + return rs;
  708 + }
  709 +
  710 + t.setId(dayOfSchedule.getId());
  711 + //实时入库
  712 + rs = super.save(t);
  713 + } catch (Exception e) {
  714 + logger.error("", e);
  715 + rs.put("status", ResponseCode.ERROR);
  716 + }
  717 + return rs;
  718 + }
  719 +
  720 +
  721 + /**
  722 + * 临加班次
  723 + */
  724 + @Override
  725 + public Map<String, Object> save(ScheduleRealInfo sch) {
  726 + Map<String, Object> rs = new HashMap<>();
  727 + try {
  728 + String clZbh = sch.getClZbh(), lpName = sch.getLpName();
  729 + if (StringUtils.isEmpty(lpName) || StringUtils.isEmpty(lpName.trim())) {
  730 + rs.put("status", ResponseCode.ERROR);
  731 + rs.put("msg", "路牌信息缺失");
  732 + return rs;
  733 + }
  734 + if (StringUtils.isNotEmpty(clZbh)) {
  735 + //检测
  736 + if (!carExist(sch.getGsBm(), clZbh)) {
  737 + rs.put("status", ResponseCode.ERROR);
  738 + rs.put("msg", "车辆 " + clZbh + " 不存在!");
  739 + return rs;
  740 + } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) {
  741 + rs.put("status", ResponseCode.ERROR);
  742 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆");
  743 + return rs;
  744 + }
  745 + }
  746 +
  747 + SysUser user = SecurityUtils.getCurrentUser();
  748 + String schDate = DayOfSchedule.currSchDateMap.get(sch.getXlBm());
  749 +
  750 + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");
  751 +
  752 + if (StringUtils.isEmpty(sch.getjGh())) {
  753 + rs.put("status", ResponseCode.ERROR);
  754 + rs.put("msg", "驾驶员工号不能为空!");
  755 + return rs;
  756 + }
  757 + //截取驾驶员工号
  758 + if (sch.getjGh().indexOf("-") != -1) {
  759 + sch.setjGh(sch.getjGh().split("-")[1]);
  760 + }
  761 + //检查驾驶员工号
  762 + String jName = getPersonName(sch.getGsBm(), sch.getjGh());
  763 + if (StringUtils.isEmpty(jName)) {
  764 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员");
  765 + rs.put("status", ResponseCode.ERROR);
  766 + return rs;
  767 + } else if (StringUtils.isEmpty(sch.getjName())) {
  768 + sch.setjName(jName);//补上驾驶员名称
  769 + }
  770 +
  771 + //有售票员
  772 + if (StringUtils.isNotEmpty(sch.getsGh())) {
  773 + String sName = getPersonName(sch.getGsBm(), sch.getsGh());
  774 + if (StringUtils.isEmpty(sName)) {
  775 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的售票员");
  776 + rs.put("status", ResponseCode.ERROR);
  777 + return rs;
  778 + } else if (StringUtils.isEmpty(sch.getsName())) {
  779 + sch.setsName(sName);//补上售票员名称
  780 + }
  781 + } else {
  782 + sch.setsGh("");
  783 + sch.setsName("");
  784 + }
  785 +
  786 + //公司 和 分公司名称
  787 + sch.setGsName(BasicData.businessCodeNameMap.get(sch.getGsBm()));
  788 + sch.setFgsName(BasicData.businessFgsCodeNameMap.get(sch.getFgsBm() + "_" + sch.getGsBm()));
  789 + sch.setCreateDate(new Date());
  790 + sch.setScheduleDateStr(schDate);
  791 + sch.setScheduleDate(sdfyyyyMMdd.parse(schDate));
  792 + sch.setRealExecDate(schDate);
  793 +
  794 + sch.setCreateBy(user);
  795 + sch.setSflj(true);
  796 + sch.setLate(false);
  797 + sch.setDfsj(sch.getFcsj());
  798 + sch.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + sch.getZdsj()).getTime());
  799 + sch.setJhlcOrig(sch.getJhlc());
  800 + sch.setCreateDate(new Date());
  801 + sch.setUpdateDate(new Date());
  802 + sch.setSpId(-1L);
  803 + //起终点名称
  804 + String prefix = sch.getXlBm() + "_" + sch.getXlDir() + "_";
  805 + sch.setQdzName(BasicData.getStationNameByCode(sch.getQdzCode(), prefix));
  806 + sch.setZdzName(BasicData.getStationNameByCode(sch.getZdzCode(), prefix));
  807 +
  808 + //计算班次实际执行时间
  809 + schAttrCalculator.calcRealDate(sch).calcAllTimeByFcsj(sch);
  810 +
  811 + //处理计达跨24点
  812 + LineConfig conf = lineConfigData.get(sch.getXlBm());
  813 + if (sch.getZdsj().compareTo(conf.getStartOpt()) < 0) {
  814 + sch.setZdsjT(sdfyyyyMMddHHmm.parse(sch.getScheduleDateStr() + sch.getZdsj()).getTime() + (1000 * 60 * 60 * 24));
  815 + }
  816 +
  817 + //班次历时
  818 + sch.setBcsj((int) ((sch.getZdsjT() - sch.getDfsjT()) / 1000 / 60));
  819 + if (sch.getZdsjT() < sch.getFcsjT()) {
  820 + rs.put("status", ResponseCode.ERROR);
  821 + rs.put("msg", "起终点时间异常!");
  822 + return rs;
  823 + }
  824 +
  825 + sch.setId(dayOfSchedule.getId());
  826 + //实时入库
  827 + super.save(sch);
  828 +
  829 + // 加入缓存
  830 + dayOfSchedule.put(sch);
  831 +
  832 + //更新起点应到时间
  833 + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch);
  834 +
  835 + //重新计算车辆当前执行班次
  836 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
  837 +
  838 + //记录站到场历时数据
  839 + Station2ParkBuffer.put(sch);
  840 +
  841 + rs.put("ts", ts);
  842 + rs.put("t", sch);
  843 + } catch (Exception e) {
  844 + logger.error("", e);
  845 + rs.put("status", ResponseCode.ERROR);
  846 + }
  847 + return rs;
  848 + }
  849 +
  850 + /**
  851 + * 删除历史表临加班次
  852 + *
  853 + * @param id
  854 + * @return
  855 + */
  856 + @Override
  857 + public Map<String, Object> deleteToHistory(Long id) {
  858 + Map<String, Object> rs = new HashMap<>();
  859 + rs.put("status", ResponseCode.ERROR);
  860 +
  861 + try {
  862 + ScheduleRealInfo sch = super.findById(id);
  863 + if (sch == null) {
  864 + rs.put("msg", "无效的id号");
  865 + return rs;
  866 + }
  867 +
  868 + if (!sch.isSflj()) {
  869 + rs.put("msg", "你只能删除临加班次");
  870 + return rs;
  871 + }
  872 +
  873 + //解除和调度指令的外键约束
  874 + jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id);
  875 +
  876 + //数据库删除
  877 + rs = super.delete(id);
  878 + } catch (Exception e) {
  879 + logger.error("", e);
  880 + rs.put("msg", e.getMessage());
  881 + }
  882 +
  883 + return rs;
  884 + }
  885 +
  886 + @Override
  887 + public Map<String, Object> delete(Long id) {
  888 + Map<String, Object> rs = new HashMap<>();
  889 + rs.put("status", ResponseCode.ERROR);
  890 +
  891 + ScheduleRealInfo sch = null;
  892 + try {
  893 + sch = dayOfSchedule.get(id);
  894 + if (sch == null) {
  895 + rs.put("msg", "无效的id号");
  896 + return rs;
  897 + }
  898 +
  899 + if (!sch.isSflj()) {
  900 + rs.put("msg", "你只能删除临加班次");
  901 + return rs;
  902 + }
  903 +
  904 + sch.setDeleted(true);
  905 + //解除和调度指令的外键约束
  906 + jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id);
  907 +
  908 + //数据库删除
  909 + rs = super.delete(id);
  910 + if (rs.get("status").equals(ResponseCode.SUCCESS)) {
  911 + dayOfSchedule.delete(sch);
  912 + //更新起点应到时间
  913 + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch);
  914 + rs.put("ts", ts);
  915 + rs.put("delete", sch);
  916 + } else
  917 + sch.setDeleted(false);
  918 + } catch (Exception e) {
  919 + logger.error("", e);
  920 + rs.put("msg", e.getMessage());
  921 + sch.setDeleted(false);
  922 + }
  923 +
  924 + return rs;
  925 + }
  926 +
  927 + @Override
  928 + public List<Map<String, String>> sreachVehic(String nbbm) {
  929 + // 转大写
  930 + nbbm = nbbm.toUpperCase();
  931 +
  932 + List<Map<String, String>> list = new ArrayList<>();
  933 + Map<String, String> map;
  934 + Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();
  935 +
  936 + Line line;
  937 + for (String k : allSet) {
  938 + if (k.indexOf(nbbm) != -1) {
  939 + // 所属线路
  940 + map = new HashMap<>();
  941 + line = BasicData.nbbm2LineMap.get(k);
  942 + map.put("id", k);
  943 + map.put("text", k);
  944 + if (null != line) {
  945 + map.put("lineName", line.getName());
  946 + map.put("lineCode", line.getLineCode());
  947 + }
  948 +
  949 + list.add(map);
  950 + }
  951 +
  952 + if (list.size() > 20)
  953 + break;
  954 + }
  955 + return list;
  956 + }
  957 +
  958 + @Override
  959 + public void adjustCar(ScheduleRealInfo schedule, String car) {
  960 + schedule.setClZbh(car);
  961 + }
  962 +
  963 + @Override
  964 + public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) {
  965 + if (driver.indexOf("-") != -1)
  966 + driver = driver.split("-")[1];
  967 + schedule.setjGh(driver);
  968 + schedule.setjName(driverName);
  969 + }
  970 +
  971 + @Override
  972 + public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) {
  973 + if (conductor.indexOf("-") != -1)
  974 + conductor = conductor.split("-")[1];
  975 + schedule.setsGh(conductor);
  976 + schedule.setsName(conductorName);
  977 + }
  978 +
  979 + @Override
  980 + public List<ScheduleRealInfo> queryUserInfo(String line, String date, String state) {
  981 + List<ScheduleRealInfo> scheduleRealInfos = new ArrayList<>();
  982 + List<Object[]> objects = null;
  983 + if (state.equals("2")) {
  984 + objects = scheduleRealInfoRepository.queryUserInfo2(line, date);
  985 + for (Object[] objs : objects) {
  986 + ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo();
  987 + scheduleRealInfo.setId((Long)objs[0]);
  988 + scheduleRealInfo.setjGh((String)objs[1]);
  989 + scheduleRealInfo.setClZbh((String)objs[2]);
  990 + scheduleRealInfo.setLpName((String)objs[3]);
  991 + scheduleRealInfo.setjName((String)objs[4]);
  992 +
  993 + scheduleRealInfos.add(scheduleRealInfo);
  994 + }
  995 + } else {
  996 + objects = scheduleRealInfoRepository.queryUserInfo3(line, date);
  997 + for (Object[] objs : objects) {
  998 + ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo();
  999 + scheduleRealInfo.setId((Long)objs[0]);
  1000 + scheduleRealInfo.setClZbh((String)objs[1]);
  1001 +
  1002 + scheduleRealInfos.add(scheduleRealInfo);
  1003 + }
  1004 + }
  1005 +
  1006 + return scheduleRealInfos;
  1007 + }
  1008 +
  1009 + @Override
  1010 + public List<ScheduleRealInfo> queryUserInfoPx(String line, String date, String state, String type) {
  1011 +// List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();
  1012 + state = state + "";
  1013 + String lpname = state;
  1014 + String px = type;
  1015 + if (state.equals("lpName")) {
  1016 + state = state + "+1";
  1017 + type = "ASC";
  1018 + }
  1019 + String minfcsj = "02:00";
  1020 + List<Line> lineList = lineRepository.findLineByCode(line);
  1021 + if (lineList.size() > 0) {
  1022 + String sqlMinYysj = "select start_opt from bsth_c_line_config where "
  1023 + + " id = ("
  1024 + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"
  1025 + + ")";
  1026 + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  1027 + }
  1028 + String sqlPlan = "select * from (select * from ("
  1029 + + " select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, "
  1030 + + " s.lp_Name as lpName,min(s.j_Name) as jName,max(s.schedule_date_str) as dateStr ,"
  1031 + + " min(s.fcsj) as fcsj,1 as px from bsth_c_s_sp_info_real s where "
  1032 + + " s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'"
  1033 + + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name) x where x.fcsj >'" + minfcsj + "'"
  1034 + + " UNION "
  1035 + + " select * from ( select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, "
  1036 + + " s.lp_Name as lpName,min(s.j_Name) as jName, max(s.schedule_date_str) as dateStr,"
  1037 + + " min(s.fcsj) as fcsj,2 as px from bsth_c_s_sp_info_real s "
  1038 + + " where s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'"
  1039 + + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name"
  1040 + + " ) y where y.fcsj <='" + minfcsj + "') z order by (" + state + "),dateStr,px,fcsj " + type;
  1041 + List<ScheduleRealInfo> list = jdbcTemplate.query(sqlPlan,
  1042 + new RowMapper<ScheduleRealInfo>() {
  1043 + @Override
  1044 + public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  1045 + ScheduleRealInfo t = new ScheduleRealInfo();
  1046 + t.setId(rs.getLong("id"));
  1047 + t.setjGh(rs.getString("jGh"));
  1048 + t.setClZbh(rs.getString("clZbh"));
  1049 + t.setLpName(rs.getString("lpName"));
  1050 + t.setjName(rs.getString("jName"));
  1051 + t.setFcsj(rs.getString("fcsj"));
  1052 + return t;
  1053 + }
  1054 + });
  1055 + if (lpname.equals("lpName")) {
  1056 +
  1057 + List<ScheduleRealInfo> listNew = new ArrayList<ScheduleRealInfo>();
  1058 + Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
  1059 +// if (px.equals("desc")) {
  1060 + int zt = 0;
  1061 + for (int l = 0; l < 2; l++) {
  1062 + for (int i = 0; i < list.size(); i++) {
  1063 + ScheduleRealInfo t = list.get(i);
  1064 + if (t.getLpName().indexOf("+") != -1) {
  1065 + if (zt == 0) {
  1066 + listNew.add(t);
  1067 + }
  1068 + } else if (pattern.matcher(t.getLpName()).matches()) {
  1069 + if (zt == 1) {
  1070 + listNew.add(t);
  1071 + }
  1072 + } else {
  1073 + continue;
  1074 + }
  1075 + }
  1076 + zt++;
  1077 + }
  1078 +
  1079 + Collections.sort(list, new ComparableLp());
  1080 + for (int i = 0; i < list.size(); i++) {
  1081 + ScheduleRealInfo t = list.get(i);
  1082 + if (t.getLpName().indexOf("+") != -1) {
  1083 + continue;
  1084 + } else if (pattern.matcher(t.getLpName()).matches()) {
  1085 + continue;
  1086 + } else {
  1087 + listNew.add(t);
  1088 + }
  1089 + }
  1090 + return listNew;
  1091 + } else {
  1092 + return list;
  1093 + }
  1094 +
  1095 + }
  1096 +
  1097 + /**
  1098 + *
  1099 + */
  1100 + @Override
  1101 + public List<ScheduleRealInfo> exportWaybill(String jName,String jGh, String clZbh, String lpName, String date, String line) {
  1102 + ReportUtils ee = new ReportUtils();
  1103 + ReportRelatedUtils rru = new ReportRelatedUtils();
  1104 + List<Iterator<?>> list = new ArrayList<Iterator<?>>();
  1105 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);
  1106 + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
  1107 +// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line);
  1108 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  1109 + for (int i = 0; i < scheduleRealInfos.size(); i++) {
  1110 + ScheduleRealInfo s = scheduleRealInfos.get(i);
  1111 + Set<ChildTaskPlan> cts = s.getcTasks();
  1112 + if (cts != null && cts.size() > 0) {
  1113 + lists.add(s);
  1114 + } else {
  1115 + if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  1116 + lists.add(s);
  1117 + }
  1118 + }
  1119 + }
  1120 + DecimalFormat format = new DecimalFormat("0.00");
  1121 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  1122 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  1123 + //计算里程和班次数,并放入Map里
  1124 + Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId());
  1125 +
  1126 + map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos)));
  1127 + map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos));
  1128 + map.put("addMileage", culateMieageService.culateLjgl(lists));
  1129 + double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists));
  1130 + map.put("yygl", yygl);
  1131 + double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists));
  1132 + map.put("ksgl", ksgl);
  1133 + map.put("realMileage", Arith.add(yygl, ksgl));
  1134 + map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, ""));
  1135 + map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos));
  1136 + map.put("ljbc", culateMieageService.culateLjbc(lists, ""));
  1137 + int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, "");
  1138 + map.put("sjbc", sjbc);
  1139 +// map=new HashMap<String,Object>();
  1140 +
  1141 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  1142 + String minfcsj = "02:00";
  1143 + List<Line> lineList = lineRepository.findLineByCode(line);
  1144 + if (lineList.size() > 0) {
  1145 + String sqlMinYysj = "select start_opt from bsth_c_line_config where "
  1146 + + " id = ("
  1147 + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"
  1148 + + ")";
  1149 + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  1150 + }
  1151 + String[] minSjs = minfcsj.split(":");
  1152 + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);
  1153 +
  1154 +
  1155 + for (int i = 0; i < scheduleRealInfos.size(); i++) {
  1156 + ScheduleRealInfo s = scheduleRealInfos.get(i);
  1157 + String[] fcsj = s.getFcsj().split(":");
  1158 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  1159 +
  1160 + Long fscjT = 0L;
  1161 + if (fcsjL < minSj) {
  1162 + Calendar calendar = new GregorianCalendar();
  1163 + calendar.setTime(s.getScheduleDate());
  1164 + calendar.add(calendar.DATE, 1);
  1165 + s.setScheduleDate(calendar.getTime());
  1166 + try {
  1167 + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();
  1168 + } catch (ParseException e) {
  1169 + // TODO Auto-generated catch block
  1170 + e.printStackTrace();
  1171 + }
  1172 +
  1173 + } else {
  1174 + try {
  1175 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  1176 + } catch (ParseException e) {
  1177 + // TODO Auto-generated catch block
  1178 + e.printStackTrace();
  1179 + }
  1180 + ;
  1181 + }
  1182 + s.setFcsjT(fscjT);
  1183 + }
  1184 + List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();
  1185 + Collections.sort(scheduleRealInfos, new ComparableReal());
  1186 + for (int i = 0; i < scheduleRealInfos.size(); i++) {
  1187 + ScheduleRealInfo s = scheduleRealInfos.get(i);
  1188 + s.setAdjustExps(i + 1 + "");
  1189 + String remarks = "";
  1190 + if (s.getRemarks() != null) {
  1191 + remarks += s.getRemarks();
  1192 + }
  1193 +
  1194 + Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
  1195 + if (!childTaskPlans.isEmpty()) {
  1196 + s.setFcsjActual("");
  1197 + s.setZdsjActual("");
  1198 + s.setJhlc(0.0);
  1199 + }
  1200 +
  1201 + if (s.isDestroy()) {
  1202 + s.setFcsjActual("");
  1203 + s.setZdsjActual("");
  1204 + s.setJhlc(0.0);
  1205 + remarks += "(烂班)";
  1206 + s.setRemarks(remarks);
  1207 + }
  1208 +
  1209 + listSchedule.add(s);
  1210 + //计算营运里程,空驶里程
  1211 + if (!childTaskPlans.isEmpty()) {
  1212 +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1213 + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);
  1214 + Collections.sort(listit, new ComparableChild());
  1215 + for (int j = 0; j < listit.size(); j++) {
  1216 + ScheduleRealInfo t = new ScheduleRealInfo();
  1217 + ChildTaskPlan childTaskPlan = listit.get(j);
  1218 + if (childTaskPlan.isDestroy()) {
  1219 + t.setFcsjActual("");
  1220 + t.setZdsjActual("");
  1221 + t.setJhlc(0.0);
  1222 + } else {
  1223 + t.setFcsjActual(childTaskPlan.getStartDate());
  1224 + t.setZdsjActual(childTaskPlan.getEndDate());
  1225 + t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));
  1226 + }
  1227 + t.setQdzName(childTaskPlan.getStartStationName());
  1228 + t.setZdzName(childTaskPlan.getEndStationName());
  1229 + t.setRemarks(childTaskPlan.getRemarks());
  1230 + t.setAdjustExps("子");
  1231 + t.setjGh("");
  1232 + t.setjName("");
  1233 + t.setsGh("");
  1234 + t.setsName("");
  1235 + listSchedule.add(t);
  1236 + }
  1237 + }
  1238 + }
  1239 + Map<String, Object> maps;
  1240 + for (ScheduleRealInfo scheduleRealInfo : listSchedule) {
  1241 + maps = new HashMap<String, Object>();
  1242 + try {
  1243 + scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName());
  1244 + scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName());
  1245 + maps = rru.getMapValue(scheduleRealInfo);
  1246 + maps.put("bcs", scheduleRealInfo.getAdjustExps());
  1247 + String zdsj = scheduleRealInfo.getZdsj();
  1248 + String zdsjActual = scheduleRealInfo.getZdsjActual();
  1249 + if (zdsj != null && zdsjActual != null &&
  1250 + !zdsj.equals(zdsjActual) &&
  1251 + !zdsj.equals("") &&
  1252 + !zdsjActual.equals("")) {
  1253 + int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]);
  1254 + int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]);
  1255 + if (zdsj.compareTo(zdsjActual) > 0) {
  1256 + if (zdsjT - zdsjAT > 1000) {
  1257 + maps.put("fast", "");
  1258 + maps.put("slow", zdsjAT - zdsjT + 1440);
  1259 + } else {
  1260 + maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  1261 + maps.put("slow", "");
  1262 + }
  1263 + } else {
  1264 + if (zdsjAT - zdsjT > 1000) {
  1265 + maps.put("fast", zdsjT - zdsjAT + 1440);
  1266 + maps.put("slow", "");
  1267 + } else {
  1268 + maps.put("fast", "");
  1269 + maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  1270 + }
  1271 + }
  1272 + } else {
  1273 + maps.put("fast", "");
  1274 + maps.put("slow", "");
  1275 + }
  1276 +
  1277 + String fcsj = scheduleRealInfo.getFcsj();
  1278 + String fcsjActual = scheduleRealInfo.getFcsjActual();
  1279 + if (fcsj != null && fcsjActual != null &&
  1280 + !fcsj.equals(fcsjActual) &&
  1281 + !fcsj.equals("") &&
  1282 + !fcsjActual.equals("")) {
  1283 + int fcsjT = Integer.valueOf(fcsj.split(":")[0]) * 60 + Integer.valueOf(fcsj.split(":")[1]);
  1284 + int fcsjAT = Integer.valueOf(fcsjActual.split(":")[0]) * 60 + Integer.valueOf(fcsjActual.split(":")[1]);
  1285 + if (fcsj.compareTo(fcsjActual) > 0) {
  1286 + if (fcsjT - fcsjAT > 1000) {
  1287 + maps.put("fast_start", "");
  1288 + maps.put("slow_start", fcsjAT - fcsjT + 1440);
  1289 + } else {
  1290 + maps.put("fast_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));
  1291 + maps.put("slow_start", "");
  1292 + }
  1293 + } else {
  1294 + if (fcsjAT - fcsjT > 1000) {
  1295 + maps.put("fast_start", fcsjT - fcsjAT + 1440);
  1296 + maps.put("slow_start", "");
  1297 + } else {
  1298 + maps.put("fast_start", "");
  1299 + maps.put("slow_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));
  1300 + }
  1301 + }
  1302 + } else {
  1303 + maps.put("fast_start", "");
  1304 + maps.put("slow_start", "");
  1305 + }
  1306 + listMap.add(maps);
  1307 + } catch (Exception e) {
  1308 + e.printStackTrace();
  1309 + }
  1310 + }
  1311 +
  1312 + String xls = "";
  1313 + if (map.get("type").toString().equals("0")) {
  1314 + xls = "waybill_minhang.xls";
  1315 + } else {
  1316 + xls = "waybill_minhang_dl.xls";
  1317 + }
  1318 +
  1319 +
  1320 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  1321 +
  1322 + list.add(listMap.iterator());
  1323 + ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/" + xls,
  1324 + path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");
  1325 + return scheduleRealInfos;
  1326 + }
  1327 +
  1328 + @Override
  1329 + public List<Map<String, Object>> dailyInfo(String line, String date, String type) {
  1330 + DecimalFormat format = new DecimalFormat("0.00");
  1331 + ReportUtils ee = new ReportUtils();
  1332 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1333 + List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date);
  1334 +
  1335 + double totalZGL = 0, totalKSGL = 0, totalYH = 0;
  1336 + int totalBCS = 0;
  1337 + for (int i = 0; i < list.size(); i++) {
  1338 + String zgl = format.format(Double.parseDouble(list.get(i).get("zgl") == null ? "0" : list.get(i).get("zgl").toString()));
  1339 + String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl") == null ? "0" : list.get(i).get("ksgl").toString()));
  1340 + if (type.equals("export")) {
  1341 + totalZGL += Double.parseDouble(zgl);
  1342 + totalKSGL += Double.parseDouble(ksgl);
  1343 + totalBCS += Integer.parseInt(list.get(i).get("bcs").toString());
  1344 + }
  1345 + list.get(i).put("zgl", zgl);
  1346 + list.get(i).put("ksgl", ksgl);
  1347 + }
  1348 + if (type.equals("export")) {
  1349 + Map<String, Object> map = new HashMap<String, Object>();
  1350 + map.put("line", line);
  1351 + map.put("date", date);
  1352 + map.put("totalZGL", totalZGL);
  1353 + map.put("totalKSGL", totalKSGL);
  1354 + map.put("totalYH", totalYH);
  1355 + map.put("totalBCS", totalBCS);
  1356 +
  1357 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  1358 +
  1359 + listI.add(list.iterator());
  1360 + try {
  1361 + ee.excelReplace(listI, new Object[]{map}, path + "mould/daily.xls",
  1362 + path + "export/班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  1363 + } catch (ParseException e) {
  1364 + e.printStackTrace();
  1365 + }
  1366 + }
  1367 + return list;
  1368 + }
  1369 +
  1370 + @Override
  1371 + public List<Object[]> historyMessage(String line, String date, String code, String type) {
  1372 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1373 +
  1374 + long d = 0;
  1375 + long t = 0;
  1376 + if (date.length() > 0) {
  1377 + try {
  1378 + d = sdf.parse(date + " 00:00:00").getTime();
  1379 + t = sdf.parse(date + " 23:59:59").getTime();
  1380 + } catch (ParseException e) {
  1381 + // TODO Auto-generated catch block
  1382 + e.printStackTrace();
  1383 + }
  1384 +
  1385 + }
  1386 + String device = "";
  1387 + String device2 ="";
  1388 + long qyrqTime=0l;
  1389 + if (!code.equals("")) {
  1390 + try {
  1391 + List<CarDevice> deviceList=carDeviceRepository.findCarCode(code, sdf.parse(date+ " 00:00:00"));
  1392 + if(deviceList.size()>0){
  1393 + device=deviceList.get(0).getOldDeviceNo();
  1394 + Date qyrq=deviceList.get(0).getQyrq();
  1395 + qyrqTime=qyrq.getTime();
  1396 + if(qyrqTime<t){
  1397 + device2=deviceList.get(0).getNewDeviceNo();
  1398 + }
  1399 + }else{
  1400 + device = BasicData.deviceId2NbbmMap.inverse().get(code);
  1401 + }
  1402 + } catch (ParseException e) {
  1403 + // TODO Auto-generated catch block
  1404 + e.printStackTrace();
  1405 + }
  1406 + }
  1407 + List<Object[]> list=new ArrayList<Object[]>();
  1408 +
  1409 + device = device.replaceAll("BF-", "");
  1410 + List<Object[]> list0 =scheduleRealInfoRepository.historyMessage(line, device, d, t);
  1411 + for (Object[] obj : list0) {
  1412 + if (obj != null) {
  1413 + if(code.equals("")){
  1414 + if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) {
  1415 + List<CarDevice> carDeviceList = new ArrayList<CarDevice>();
  1416 + try {
  1417 + carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString())));
  1418 + //启用日期大于营运日期 还是根据旧设备号查询
  1419 + if(carDeviceList.size()==0){
  1420 + carDeviceList = carDeviceRepository.findCarOldDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString())));
  1421 + }
  1422 + } catch (Exception e) {
  1423 + // TODO Auto-generated catch block
  1424 + e.printStackTrace();
  1425 + }
  1426 + if (carDeviceList.size() > 0) {
  1427 + obj[0] = carDeviceList.get(0).getClZbh();
  1428 + } else {
  1429 + obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString());
  1430 + }
  1431 + } else {
  1432 + obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString());
  1433 + }
  1434 + }else{
  1435 + obj[0]=code;
  1436 + }
  1437 +
  1438 + obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));
  1439 + obj[4] = BasicData.lineCode2NameMap.get(line);
  1440 + }
  1441 + }
  1442 + list.addAll(list0);
  1443 + if(!device2.equals("")){
  1444 + device2.replaceAll("BF-", "");
  1445 + List<Object[]> list1 =scheduleRealInfoRepository.historyMessage(line, device2, d, t);
  1446 + for (Object[] obj : list1) {
  1447 + if (obj != null) {
  1448 + obj[0] =code;
  1449 + obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));
  1450 + obj[4] = BasicData.lineCode2NameMap.get(line);
  1451 + }
  1452 + }
  1453 + list.addAll(list1);
  1454 + }
  1455 +
  1456 + if (type != null && type.length() != 0 && type.equals("export")) {
  1457 + String lineName = BasicData.lineCode2NameMap.get(line);
  1458 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  1459 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  1460 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1461 + Map<String, Object> m = new HashMap<String, Object>();
  1462 + ReportUtils ee = new ReportUtils();
  1463 + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
  1464 + for (int i = 0; i < list.size(); i++) {
  1465 + Map<String, Object> map = new HashMap<String, Object>();
  1466 + Object[] obj = list.get(i);
  1467 + map.put("num", i + 1);
  1468 + map.put("line", obj[4]);
  1469 + map.put("clZbh", obj[0]);
  1470 + map.put("sender", obj[1]);
  1471 + map.put("date", obj[3]);
  1472 + map.put("text", obj[2]);
  1473 + map.put("reply46", "0".equals(obj[5]+"")?"是":"");
  1474 + map.put("reply47", "0".equals(obj[6]+"")?"是":"");
  1475 + newList.add(map);
  1476 + }
  1477 + try {
  1478 + listI.add(newList.iterator());
  1479 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  1480 + ee.excelReplace(listI, new Object[]{m}, path + "mould/historyMessage.xls",
  1481 + path + "export/" + sdfSimple.format(sdfMonth.parse(date))
  1482 + + "-" + lineName + "-调度历史消息.xls");
  1483 + } catch (Exception e) {
  1484 + // TODO: handle exception
  1485 + e.printStackTrace();
  1486 + }
  1487 + }
  1488 +
  1489 + if (type != null && type.length() != 0 && type.equals("export_msg")) {
  1490 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  1491 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  1492 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1493 + Map<String, Object> m = new HashMap<String, Object>();
  1494 + ReportUtils ee = new ReportUtils();
  1495 + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
  1496 + for (int i = 0; i < list.size(); i++) {
  1497 + Map<String, Object> map = new HashMap<String, Object>();
  1498 + Object[] obj = list.get(i);
  1499 + map.put("num", i + 1);
  1500 + map.put("line", obj[4]);
  1501 + map.put("clZbh", obj[0]);
  1502 + map.put("sender", obj[1]);
  1503 + map.put("date", obj[3]);
  1504 + map.put("text", obj[2]);
  1505 + newList.add(map);
  1506 + }
  1507 + try {
  1508 + listI.add(newList.iterator());
  1509 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  1510 + ee.excelReplace(listI, new Object[]{m}, path + "mould/message.xls",
  1511 + path + "export/调度消息分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  1512 + } catch (Exception e) {
  1513 + // TODO: handle exception
  1514 + e.printStackTrace();
  1515 + }
  1516 + }
  1517 + return list;
  1518 + }
  1519 +
  1520 + @Override
  1521 + public Map<Integer, Integer> trustStatus(String lineStr) {
  1522 + List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr));
  1523 +
  1524 + Map<Integer, Integer> map = new HashMap<>();
  1525 + return map;
  1526 + }
  1527 +
  1528 + @Override
  1529 + public Map<String, Object> realOutAdjust(Map<String, String> map) {
  1530 + Map<String, Object> rs = new HashMap<>();
  1531 + List<ScheduleRealInfo> ts = new ArrayList<>();
  1532 + try {
  1533 + // 维修上报
  1534 + if (StringUtils.isNotBlank(map.get("reportTypes"))) {
  1535 + Map<String, Object> param = new HashMap<String, Object>();
  1536 + param.putAll(map);
  1537 + rs = repairReport(param, false);
  1538 + }
  1539 +
  1540 + Long id = Long.parseLong(map.get("id"));
  1541 + String remarks = map.get("remarks"), fcsjActual = map.get("fcsjActual");
  1542 +
  1543 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  1544 +
  1545 + LineConfig config = lineConfigData.get(sch.getXlBm());
  1546 + //小于线路开始运营时间,则默认跨过24点
  1547 + if (fcsjActual.compareTo(config.getStartOpt()) < 0) {
  1548 + sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME));
  1549 + } else {
  1550 + sch.setRealExecDate(sch.getScheduleDateStr());
  1551 + }
  1552 +
  1553 + //日志记录
  1554 + ScheduleModifyLogger.sftz(sch, fcsjActual, remarks);
  1555 +
  1556 + sch.setFcsjActualAll(fcsjActual);
  1557 + sch.setRemarks(remarks);
  1558 + sch.calcStatus();
  1559 + //if(sch.isLate2()){
  1560 + //取消应发未到标记
  1561 + // sch.setLate2(false);
  1562 + LateAdjustHandle.remove(sch);
  1563 + //}
  1564 +
  1565 + dayOfSchedule.save(sch);
  1566 +
  1567 + ts.add(sch);
  1568 +
  1569 + rs.put("status", ResponseCode.SUCCESS);
  1570 + rs.put("ts", ts);
  1571 +
  1572 + //通知页面刷新
  1573 + sendUtils.refreshSch(ts);
  1574 + } catch (Exception e) {
  1575 + logger.error("", e);
  1576 + rs.put("status", ResponseCode.ERROR);
  1577 + }
  1578 +
  1579 + return rs;
  1580 + }
  1581 +
  1582 + @Override
  1583 + public Map<String, Object> revokeDestroy(Long id) {
  1584 + Map<String, Object> rs = new HashMap<>();
  1585 + try {
  1586 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  1587 + if (sch.getStatus() != -1) {
  1588 + rs.put("status", ResponseCode.ERROR);
  1589 + rs.put("msg", "未烂班,无法撤销!");
  1590 + } else {
  1591 + //日志记录
  1592 + ScheduleModifyLogger.cxlb(sch);
  1593 +
  1594 + sch.setStatus(0);
  1595 + sch.setRemarks("");//清空备注
  1596 + sch.setJhlc(sch.getJhlcOrig());
  1597 +
  1598 + //入库
  1599 + dayOfSchedule.save(sch);
  1600 + //重新计算当前执行班次
  1601 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
  1602 + rs.put("status", ResponseCode.SUCCESS);
  1603 + rs.put("t", sch);
  1604 +
  1605 + }
  1606 + } catch (Exception e) {
  1607 + logger.error("", e);
  1608 + rs.put("status", ResponseCode.ERROR);
  1609 + }
  1610 + return rs;
  1611 + }
  1612 +
  1613 + @Override
  1614 + public Map<String, Object> revokeRealOutgo(Long id) {
  1615 + Map<String, Object> rs = new HashMap<>();
  1616 + List<ScheduleRealInfo> ts = new ArrayList<>();
  1617 +
  1618 + try {
  1619 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  1620 + if (sch.getFcsjActual() == null) {
  1621 + rs.put("status", ResponseCode.ERROR);
  1622 + rs.put("msg", "无实发时间,无法撤销!");
  1623 + } else {
  1624 + //日志记录
  1625 + ScheduleModifyLogger.cxsf(sch);
  1626 +
  1627 + sch.clearFcsjActual();
  1628 + rs.put("status", ResponseCode.SUCCESS);
  1629 +
  1630 + ts.add(sch);
  1631 + rs.put("ts", ts);
  1632 +
  1633 + dayOfSchedule.save(sch);
  1634 +
  1635 + }
  1636 + } catch (Exception e) {
  1637 + logger.error("", e);
  1638 + rs.put("status", ResponseCode.ERROR);
  1639 + }
  1640 + return rs;
  1641 + }
  1642 +
  1643 + @Override
  1644 + public Map<String, Object> spaceAdjust(Long[] ids, Integer space) {
  1645 +
  1646 + List<ScheduleRealInfo> list = new ArrayList<>(), ts = new ArrayList<>(), tempTs = null;
  1647 + Map<String, Object> rs = new HashMap<>(), tempRs = new HashMap<>();
  1648 + try {
  1649 + ScheduleRealInfo sch, next;
  1650 + for (Long id : ids) {
  1651 + sch = dayOfSchedule.get(id);
  1652 + if (null != sch)
  1653 + list.add(sch);
  1654 + }
  1655 +
  1656 + int size = list.size();
  1657 + if (size == 0) {
  1658 + rs.put("status", ResponseCode.ERROR);
  1659 + } else {
  1660 + // 按发车时间排序
  1661 + Collections.sort(list, new ScheduleComparator.FCSJ());
  1662 +
  1663 + // 以第一个实际发车/待发时间为起点,调整间隔
  1664 + sch = list.get(0);
  1665 + Long st = sch.getFcsjActualTime() == null ? sch.getDfsjT() : sch.getFcsjActualTime(), plus = space * 60 * 1000L;
  1666 +
  1667 + for (int i = 1; i < size; i++) {
  1668 + st += plus;
  1669 + sch = list.get(i);
  1670 +
  1671 + //调整待发
  1672 + tempRs = outgoAdjust(sch.getId(), null, fmtHHmm.print(st), null, "3", null);
  1673 +
  1674 + if (null != tempRs && tempRs.get("ts") != null)
  1675 + tempTs = (List<ScheduleRealInfo>) tempRs.get("ts");
  1676 +
  1677 + ts.addAll(tempTs);
  1678 + }
  1679 +
  1680 + rs.put("status", ResponseCode.SUCCESS);
  1681 + //返回最后一个班次,页面会全量刷新
  1682 + rs.put("ts", ts);
  1683 + }
  1684 +
  1685 + } catch (Exception e) {
  1686 + logger.error("", e);
  1687 + rs.put("status", ResponseCode.ERROR);
  1688 + }
  1689 + return rs;
  1690 + }
  1691 +
  1692 + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
  1693 +
  1694 + @Transactional
  1695 + @Override
  1696 + public Map<String, Object> schInfoFineTune(Map<String, String> map) {
  1697 + Map<String, Object> rs = new HashMap<>();
  1698 + List<ScheduleRealInfo> ts = new ArrayList<>();
  1699 + try {
  1700 + // 维修上报
  1701 + if (StringUtils.isNotBlank(map.get("reportTypes"))) {
  1702 + Map<String, Object> param = new HashMap<String, Object>();
  1703 + param.putAll(map);
  1704 + rs = repairReport(param, false);
  1705 + }
  1706 +
  1707 + Long id = Long.parseLong(map.get("id"));
  1708 + String remarks = map.get("remarks");
  1709 +
  1710 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  1711 +
  1712 + if (null == sch) {
  1713 + rs.put("status", ResponseCode.ERROR);
  1714 + rs.put("msg", "不存在的班次!");
  1715 + return rs;
  1716 + }
  1717 +
  1718 + //日志记录器
  1719 + FcxxwtLogger fLog = FcxxwtLogger.start(sch, remarks);
  1720 +
  1721 + String clZbh = map.get("clZbh");
  1722 + String jsy = map.get("jsy");
  1723 + if (!clZbh.equals(sch.getClZbh())
  1724 + || !jsy.equals(sch.getjGh() + "/" + sch.getjName()))
  1725 + schModifyLog.saveChangetochange(sch, clZbh, jsy);//为换人换车情况表写入数据
  1726 + /**
  1727 + * 换车
  1728 + */
  1729 + if (StringUtils.isNotEmpty(clZbh) && !clZbh.equals(sch.getClZbh())) {
  1730 + //换车
  1731 + if (!carExist(sch.getGsBm(), clZbh)) {
  1732 + rs.put("status", ResponseCode.ERROR);
  1733 + rs.put("msg", "车辆 " + clZbh + " 不存在!");
  1734 + return rs;
  1735 + } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) {
  1736 + rs.put("status", ResponseCode.ERROR);
  1737 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆");
  1738 + return rs;
  1739 + } else {
  1740 + fLog.log("换车", sch.getClZbh(), clZbh);
  1741 + dayOfSchedule.changeCar(sch, clZbh);
  1742 + }
  1743 + }
  1744 +
  1745 + if(StringUtils.isBlank(jsy) || "/".equals(StringUtils.trim(jsy))){
  1746 + rs.put("status", ResponseCode.ERROR);
  1747 + rs.put("msg", "无效的参数【驾驶员】");
  1748 + return rs;
  1749 + }
  1750 +
  1751 + /**
  1752 + * 换驾驶员
  1753 + */
  1754 + if (StringUtils.isNotEmpty(jsy)) {
  1755 + String jGh = jsy.split("/")[0];
  1756 + String jName = getPersonName(sch.getGsBm(), jGh);
  1757 + if (StringUtils.isEmpty(jName)) {
  1758 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员");
  1759 + rs.put("status", ResponseCode.ERROR);
  1760 + return rs;
  1761 + } else if (!jGh.equals(sch.getjGh())) {
  1762 + fLog.log("换驾驶员", sch.getjGh() + "/" + sch.getjName(), jsy);
  1763 + persoChange(sch, jGh);
  1764 + }
  1765 + }
  1766 +
  1767 + /**
  1768 + * 换售票员
  1769 + */
  1770 + String spy = map.get("spy");
  1771 + if (StringUtils.isNotEmpty(spy) && !StringUtils.trim(spy).equals("/")) {
  1772 + String sGh = spy.split("/")[0];
  1773 +
  1774 + String sName = getPersonName(sch.getGsBm(), sGh);
  1775 + if (StringUtils.isEmpty(sName)) {
  1776 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员");
  1777 + rs.put("status", ResponseCode.ERROR);
  1778 + return rs;
  1779 + } else if (!sGh.equals(sch.getsGh())) {
  1780 + fLog.log("换售票员", sch.getsGh() + "/" + sch.getsName(), spy);
  1781 + persoChangeSPY(sch, sGh);
  1782 + }
  1783 + } else if (StringUtils.isNotEmpty(sch.getsGh())) {
  1784 + fLog.log("撤销售票员");
  1785 + sch.setsGh("");
  1786 + sch.setsName("");
  1787 + }
  1788 +
  1789 + LineConfig config = lineConfigData.get(sch.getXlBm());
  1790 + /**
  1791 + * 调整实发
  1792 + */
  1793 + String fcsjActual = map.get("fcsjActual");
  1794 + if (StringUtils.isNotBlank(fcsjActual)
  1795 + && !fcsjActual.equals(sch.getFcsjActual())) {
  1796 +
  1797 + //long t = 0L;
  1798 + //小于线路开始运营时间,则默认跨过24点
  1799 + long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), fcsjActual, config);
  1800 + /* if (fcsjActual.compareTo(config.getStartOpt()) < 0)
  1801 + t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual);
  1802 + else
  1803 + t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual);*/
  1804 +
  1805 + fLog.log("调整实发时间", sch.getFcsjActual(), fcsjActual);
  1806 + sch.setFcsjActualAll(t);
  1807 + //取消应发未到标记
  1808 + //if(sch.isLate2()){
  1809 + // sch.setLate2(false);
  1810 + LateAdjustHandle.remove(sch);
  1811 + //}
  1812 + } else if (StringUtils.isNotEmpty(sch.getFcsjActual()) && StringUtils.isEmpty(fcsjActual)) {
  1813 + fLog.log("撤销实发时间", sch.getFcsjActual(), "");
  1814 + //撤销实发
  1815 + revokeRealOutgo(sch.getId());
  1816 + }
  1817 +
  1818 + /**
  1819 + * 调整实达
  1820 + */
  1821 + String zdsjActual = map.get("zdsjActual");
  1822 + if (StringUtils.isNotBlank(zdsjActual)
  1823 + && !zdsjActual.equals(sch.getZdsjActual())) {
  1824 +
  1825 + //调整实达
  1826 + fLog.log("调整实达时间", sch.getZdsjActual(), zdsjActual);
  1827 +
  1828 + long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), zdsjActual, config);
  1829 + sch.setZdsjActualAll(t);
  1830 + //路牌下一班起点到达时间
  1831 + ScheduleRealInfo next = dayOfSchedule.nextByLp2(sch);
  1832 + if (null != next) {
  1833 + next.setQdzArrDatesj(zdsjActual);
  1834 + next.setLate2(false);
  1835 + ts.add(next);
  1836 + }
  1837 +
  1838 + //重新计算车辆执行班次
  1839 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
  1840 + //取消应发未到标记
  1841 + LateAdjustHandle.remove(sch);
  1842 + } else if (StringUtils.isNotEmpty(sch.getZdsjActual()) && StringUtils.isEmpty(zdsjActual)) {
  1843 + //清除实达时间
  1844 + fLog.log("撤销实达时间", sch.getZdsjActual(), "");
  1845 + sch.clearZdsjActual();
  1846 + //清除路牌下一班起点到达时间
  1847 + ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);
  1848 + if (null != next) {
  1849 + next.setQdzArrDatesj(null);
  1850 + ts.add(next);
  1851 + }
  1852 + //重新计算车辆执行班次
  1853 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
  1854 + }
  1855 +
  1856 + /**
  1857 + * 备注
  1858 + */
  1859 + sch.setRemarks(remarks);
  1860 +
  1861 + /**
  1862 + * 烂班
  1863 + */
  1864 + if (map.get("status") != null
  1865 + && Integer.parseInt(map.get("status").toString()) == -1) {
  1866 + destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null);
  1867 + fLog.log("烂班");
  1868 + }
  1869 +
  1870 + /**
  1871 + * 修改班次里程
  1872 + */
  1873 + String jhlc = map.get("jhlc");
  1874 + if (StringUtils.isNotEmpty(jhlc)) {
  1875 + double jhlcNum = Double.parseDouble(jhlc);
  1876 + //烂班
  1877 + if (jhlcNum == 0 && sch.getJhlcOrig() != 0 && !sch._isInout() && !sch.isDestroy()) {
  1878 + destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null);
  1879 + fLog.log("里程设置为0,自动烂班");
  1880 + } else if (jhlcNum != sch.getJhlc()) {
  1881 + fLog.log("设置里程", sch.getJhlc(), jhlcNum);
  1882 + sch.setJhlc(jhlcNum);
  1883 + //临加班次,实际计划一起改
  1884 + if (sch.isSflj())
  1885 + sch.setJhlcOrig(jhlcNum);
  1886 + }
  1887 + }
  1888 +
  1889 + /**
  1890 + * 修改班次类型
  1891 + */
  1892 + String bcType = map.get("bcType");
  1893 + if (StringUtils.isNotEmpty(bcType) && !bcType.equals(sch.getBcType())) {
  1894 + fLog.log("修改班次类型", sch.getBcType(), bcType);
  1895 + sch.setBcType(bcType);
  1896 + }
  1897 +
  1898 + //重新计算班次状态
  1899 + sch.calcStatus();
  1900 + dayOfSchedule.save(sch);
  1901 + //页面需要更新的班次信息
  1902 + ts.add(sch);
  1903 +
  1904 + rs.put("status", ResponseCode.SUCCESS);
  1905 + rs.put("ts", ts);
  1906 +
  1907 + //日志记录结束
  1908 + fLog.end();
  1909 + } catch (Exception e) {
  1910 + logger.error("", e);
  1911 + rs.put("status", ResponseCode.ERROR);
  1912 + }
  1913 + return rs;
  1914 + }
  1915 +
  1916 + @Override
  1917 + public Map<String, Object> outgoAdjustAll(String params) {
  1918 + Map<String, Object> rs = new HashMap<>();
  1919 + try {
  1920 + JSONArray jsonArray = JSONArray.parseArray(params);
  1921 +
  1922 + ScheduleRealInfo schedule = null;
  1923 + JSONObject jsonObj;
  1924 + String dfsj;
  1925 + long id;
  1926 + for (int i = 0; i < jsonArray.size(); i++) {
  1927 + jsonObj = jsonArray.getJSONObject(i);
  1928 + dfsj = jsonObj.getString("t");
  1929 + id = jsonObj.getLong("id");
  1930 + schedule = dayOfSchedule.get(id);
  1931 +
  1932 + if (schedule != null)
  1933 + outgoAdjust(id, null, dfsj, null, "2", null);
  1934 + }
  1935 +
  1936 + rs.put("status", ResponseCode.SUCCESS);
  1937 + //将更新的最后一个班次返回,页面会做全量刷新
  1938 + rs.put("t", schedule);
  1939 + } catch (Exception e) {
  1940 + logger.error("", e);
  1941 + rs.put("status", ResponseCode.ERROR);
  1942 + }
  1943 + return rs;
  1944 + }
  1945 +
  1946 + @Override
  1947 + public Map<String, Object> findRouteByLine(String lineCode) {
  1948 + Map<String, Object> map = new HashMap<>();
  1949 + //上行
  1950 + Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode);
  1951 + map.put("line.id_eq", lineId);
  1952 + map.put("directions_eq", 0);
  1953 + List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map);
  1954 +
  1955 + //下行
  1956 + map.put("directions_eq", 1);
  1957 + List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map);
  1958 +
  1959 + Map<String, Object> rs = new HashMap<>();
  1960 +
  1961 + String upVectors = "", vec;
  1962 + //拼接上行路段
  1963 + for (Map<String, Object> temp : upList) {
  1964 + vec = temp.get("sectionBsectionVector").toString();
  1965 + upVectors += vec.subSequence(11, vec.length() - 2) + " ";
  1966 + }
  1967 +
  1968 + //拼接下行路段
  1969 + String downVectors = "";
  1970 + for (Map<String, Object> temp : downList) {//LINESTRING(
  1971 + vec = temp.get("sectionBsectionVector").toString();
  1972 + downVectors += vec.subSequence(11, vec.length() - 2) + " ";
  1973 + }
  1974 +
  1975 +
  1976 + rs.put("up", upVectors);
  1977 + //上行gcj
  1978 + rs.put("up_gcj", BdToGcjString(upVectors));
  1979 + rs.put("down", downVectors);
  1980 + //下行gcj
  1981 + rs.put("down_gcj", BdToGcjString(downVectors));
  1982 + rs.put("lineId", lineId);
  1983 +
  1984 + return rs;
  1985 + }
  1986 +
  1987 + /**
  1988 + * @param @param bdStr
  1989 + * @throws
  1990 + * @Title: BdToGcjString
  1991 + * @Description: TODO(将百度路由字符串 转 成GCJ 字符串)
  1992 + */
  1993 + public String BdToGcjString(String bdStr) {
  1994 + String[] array = bdStr.split(","), subArray;
  1995 + if (array.length == 0 || bdStr.length() < 2)
  1996 + return "";
  1997 +
  1998 + String gcjStr = "";
  1999 + TransGPS.Location location;
  2000 + for (String crd : array) {
  2001 + subArray = crd.split(" ");
  2002 + if (subArray.length != 2)
  2003 + continue;
  2004 + location = TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1])));
  2005 +
  2006 + gcjStr += location.getLng() + " " + location.getLat() + ",";
  2007 + }
  2008 +
  2009 + return gcjStr.substring(0, gcjStr.length() - 1);
  2010 + }
  2011 +
  2012 + public List<Map<String, String>> findLine(String line) {
  2013 + List<Line> listLine = lineRepository.findLine("%" + line + "%");
  2014 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  2015 + Map<String, String> map;
  2016 + for (Line temp : listLine) {
  2017 + if (temp != null) {
  2018 + String xlName = temp.getName();
  2019 + if (xlName.indexOf(line) != -1) {
  2020 + map = new HashMap<String, String>();
  2021 + map.put("id", temp.getLineCode());
  2022 + map.put("text", xlName);
  2023 + list.add(map);
  2024 + }
  2025 + }
  2026 + }
  2027 + return list;
  2028 + }
  2029 +
  2030 + public List<Map<String, String>> findLpName(String lpName) {
  2031 + List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%" + lpName + "%");
  2032 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  2033 + Map<String, String> map;
  2034 + for (GuideboardInfo temp : listLpName) {
  2035 + if (temp != null) {
  2036 + String lp = temp.getLpName();
  2037 + if (lp.indexOf(lpName) != -1) {
  2038 + map = new HashMap<String, String>();
  2039 + map.put("id", lp);
  2040 + map.put("text", lp);
  2041 + list.add(map);
  2042 + }
  2043 + }
  2044 + }
  2045 + return list;
  2046 + }
  2047 +
  2048 + @Override
  2049 + public Map<String, Object> findKMBC2(String jName, String clZbh, String date) {
  2050 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date, "", "");
  2051 +
  2052 + DecimalFormat format = new DecimalFormat("0.00");
  2053 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  2054 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  2055 + int jhbc = 0, cjbc = 0, ljbc = 0;
  2056 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;
  2057 + float addMileage = 0l, remMileage = 0l;
  2058 + String j_Name = "";
  2059 + Map<String, Object> map = new HashMap<String, Object>();
  2060 + for (ScheduleRealInfo scheduleRealInfo : list) {
  2061 + if (scheduleRealInfo != null) {
  2062 + j_Name = scheduleRealInfo.getjName();
  2063 + //计划里程(主任务过滤掉临加班次),
  2064 + //烂班里程(主任务烂班),
  2065 + //临加里程(主任务临加),
  2066 + //计划班次,烂班班次,增加班次
  2067 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  2068 + if (scheduleRealInfo.isSflj()) {
  2069 + addMileage += tempJhlc;
  2070 + ljbc++;
  2071 + } else {
  2072 + jhlc += tempJhlc;
  2073 + jhbc++;
  2074 + if (scheduleRealInfo.getStatus() == -1) {
  2075 + remMileage += tempJhlc;
  2076 + cjbc++;
  2077 + }
  2078 + }
  2079 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  2080 + //计算营运里程,空驶里程
  2081 + if (childTaskPlans.isEmpty()) {
  2082 + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  2083 + || scheduleRealInfo.getBcType().equals("venting")) {
  2084 + ksgl += tempJhlc;
  2085 + } else {
  2086 + yygl += tempJhlc;
  2087 + }
  2088 + } else {
  2089 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  2090 + while (it.hasNext()) {
  2091 + ChildTaskPlan childTaskPlan = it.next();
  2092 + if (childTaskPlan.getMileageType().equals("empty")) {
  2093 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  2094 + } else {
  2095 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  2096 + }
  2097 + }
  2098 + }
  2099 + }
  2100 + }
  2101 + map.put("j_name", j_Name);
  2102 + map.put("jhlc", format.format(jhlc));
  2103 + map.put("remMileage", format.format(remMileage));
  2104 + map.put("addMileage", format.format(addMileage));
  2105 + map.put("yygl", format.format(yygl));
  2106 + map.put("ksgl", format.format(ksgl));
  2107 + map.put("realMileage", format.format(yygl + ksgl));
  2108 + map.put("jhbc", jhbc);
  2109 + map.put("cjbc", cjbc);
  2110 + map.put("ljbc", ljbc);
  2111 + map.put("sjbc", jhbc - cjbc + ljbc);
  2112 + return map;
  2113 + }
  2114 +
  2115 +
  2116 + public Map<String, Object> findKMBC(String jGh, String clZbh,
  2117 + String lpName, String date, String line) {
  2118 + Map<String, Object> map = new HashMap<String, Object>();
  2119 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);
  2120 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  2121 + for (int i = 0; i < list.size(); i++) {
  2122 + ScheduleRealInfo s = list.get(i);
  2123 + Set<ChildTaskPlan> cts = s.getcTasks();
  2124 + if (cts != null && cts.size() > 0) {
  2125 + lists.add(s);
  2126 + } else {
  2127 + if (s.getFcsjActual() != null && s.getZdsjActual() != null) {
  2128 + lists.add(s);
  2129 + }
  2130 + }
  2131 + }
  2132 + map.put("jhbc", culateService.culateJhbc(list, ""));//计划班次
  2133 + map.put("jhlc", Arith.add(culateService.culateJhgl(list),
  2134 + culateService.culateJhJccgl(list))); //计划总里程
  2135 + map.put("cjbc", culateService.culateLbbc(list));//烂班班次
  2136 + map.put("remMileage", culateService.culateLbgl(list)); //烂班公里
  2137 + map.put("ljbc", culateService.culateLjbc(lists, ""));//临加班次
  2138 + double ljgl = culateService.culateLjgl(lists);
  2139 + map.put("addMileage", ljgl); //临加公里
  2140 + map.put("sjbc", culateService.culateSjbc(lists, "") + culateService.culateLjbc(lists, ""));
  2141 + double ksgl = culateService.culateKsgl(list);//子任务空驶公里
  2142 + double jccgl = culateService.culateJccgl(lists);//空驶班次公里
  2143 + map.put("ksgl", ksgl);//空驶公里
  2144 + double sjgl = culateService.culateSjgl(lists);//实际营运公里
  2145 + map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));//总公里
  2146 + map.put("zkslc", Arith.add(ksgl, jccgl));
  2147 + map.put("jcclc", jccgl);
  2148 + map.put("yygl", Arith.add(sjgl, ljgl)); //总营运公里
  2149 + return map;
  2150 + }
  2151 +
  2152 + public Map<String, Object> findKMBC_mh_2(String jGh, String clZbh,
  2153 + String lpName, String date, String line) {
  2154 + Map<String, Object> map = new HashMap<String, Object>();
  2155 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);
  2156 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  2157 + for (int i = 0; i < list.size(); i++) {
  2158 + ScheduleRealInfo s = list.get(i);
  2159 + if (s.isDestroy() && s.isReissue()) {
  2160 + s.setRemark("");
  2161 + s.setFcsjActual(s.getDfsj());
  2162 + s.setZdsjActual(s.getZdsj());
  2163 + s.setStatus(2);
  2164 + s.setJhlc(s.getJhlcOrig());
  2165 + }
  2166 +
  2167 + Set<ChildTaskPlan> cts = s.getcTasks();
  2168 + if (cts != null && cts.size() > 0) {
  2169 + lists.add(s);
  2170 + } else {
  2171 + if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  2172 + lists.add(s);
  2173 + }
  2174 + }
  2175 + }
  2176 + double ksgl = culateService.culateKsgl(list);
  2177 + double sjgl = culateService.culateSjgl(lists);
  2178 + double jccgl = culateService.culateJccgl(lists);
  2179 + double ljgl = culateService.culateLjgl(lists);
  2180 +
  2181 + map.put("jhlc", Arith.add(culateService.culateJhgl(list), culateService.culateJhJccgl(list))); //计划里程
  2182 + map.put("remMileage", culateService.culateLbgl(list)); //烂班公里
  2183 + map.put("addMileage", ljgl); //临加公里
  2184 + map.put("yygl", Arith.add(sjgl, ljgl)); //实际公里
  2185 + map.put("ksgl", ksgl);//空驶公里
  2186 + map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));
  2187 +// map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage));
  2188 + map.put("jhbc", culateService.culateJhbc(list, ""));
  2189 + map.put("cjbc", culateService.culateLbbc(list));
  2190 + map.put("ljbc", culateService.culateLjbc(lists, ""));
  2191 + map.put("sjbc", culateService.culateJhbc(lists, "") - culateService.culateLbbc(lists) + culateService.culateLjbc(lists, ""));
  2192 + map.put("jcclc", jccgl);
  2193 + map.put("zkslc", Arith.add(ksgl, jccgl));
  2194 +// map.put("zkslc", format.format(ksgl + jcclc+addMileageJc));
  2195 + return map;
  2196 + }
  2197 +
  2198 +
  2199 + @Override
  2200 + public List<Map<String, Object>> accountPx(String line, String date,
  2201 + String code, String xlName, String px) {
  2202 +// List<Object[]> lsitObj = scheduleRealInfoRepository.accountPx(line, date, code,px);
  2203 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2204 + if (!code.trim().equals("")) {
  2205 + code = BasicData.deviceId2NbbmMap.inverse().get(code);
  2206 + }
  2207 + String fgs = "";
  2208 + List<Line> lineList = lineRepository.findLineByCode(line);
  2209 + if (lineList.size() > 0) {
  2210 + Line l = lineList.get(0);
  2211 + fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany());
  2212 + }
  2213 + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
  2214 + String sql = "SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ,"
  2215 + + " device_id FROM bsth_v_report_80 WHERE "
  2216 + + " FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = '" + date + "' AND"
  2217 + + " line_id = '" + line + "' and device_id like '%" + code + "%'";
  2218 + Map<String, Object> map;
  2219 + List<Object[]> lsitObj = jdbcTemplate.query(sql,
  2220 + new RowMapper<Object[]>() {
  2221 + @Override
  2222 + public Object[] mapRow(ResultSet rs, int rowNum) throws SQLException {
  2223 + Object[] t = new Object[3];
  2224 + t[0] = rs.getString("request_code");
  2225 + t[1] = rs.getString("TIMESTAMP");
  2226 + t[2] = rs.getString("device_id");
  2227 + return t;
  2228 + }
  2229 + });
  2230 + int i = 1;
  2231 + for (Object[] obj : lsitObj) {
  2232 + if (obj != null) {
  2233 + map = new HashMap<String, Object>();
  2234 + map.put("num", i++);
  2235 + map.put("xlName", xlName);
  2236 + if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) {
  2237 + List<CarDevice> carDeviceList = new ArrayList<CarDevice>();
  2238 + try {
  2239 + carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString()));
  2240 + } catch (Exception e) {
  2241 + // TODO Auto-generated catch block
  2242 + e.printStackTrace();
  2243 + }
  2244 + if (carDeviceList.size() > 0) {
  2245 + map.put("clZbh", carDeviceList.get(0).getClZbh());
  2246 +
  2247 + } else {
  2248 + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));
  2249 + }
  2250 + } else {
  2251 + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));
  2252 +
  2253 + }
  2254 + map.put("company", fgs);
  2255 + map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase());
  2256 + map.put("requestTime", obj[1]);
  2257 + listMap.add(map);
  2258 + }
  2259 + }
  2260 + if (listMap.size() > 1) {
  2261 + if (px.equals("asc")) {
  2262 + Collections.sort(listMap, new AccountMap());
  2263 + } else {
  2264 + Collections.sort(listMap, new AccountMap2());
  2265 + }
  2266 + }
  2267 + return listMap;
  2268 + }
  2269 +
  2270 + @Override
  2271 + public List<Map<String, Object>> account(String line, String date,
  2272 + String code, String xlName, String type) {
  2273 + if (!code.trim().equals("")) {
  2274 + code = BasicData.deviceId2NbbmMap.inverse().get(code);
  2275 + }
  2276 + String fgs = "";
  2277 + List<Line> lineList = lineRepository.findLineByCode(line);
  2278 + if (lineList.size() > 0) {
  2279 + Line l = lineList.get(0);
  2280 + fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany());
  2281 + }
  2282 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2283 + List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code);
  2284 + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
  2285 + Map<String, Object> map;
  2286 + int i = 1;
  2287 + for (Object[] obj : lsitObj) {
  2288 + if (obj != null) {
  2289 + map = new HashMap<String, Object>();
  2290 + map.put("num", i++);
  2291 + map.put("xlName", xlName);
  2292 + if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) {
  2293 + List<CarDevice> carDeviceList = new ArrayList<CarDevice>();
  2294 + try {
  2295 + carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString()));
  2296 + } catch (Exception e) {
  2297 + // TODO Auto-generated catch block
  2298 + e.printStackTrace();
  2299 + }
  2300 + if (carDeviceList.size() > 0) {
  2301 + map.put("clZbh", carDeviceList.get(0).getClZbh());
  2302 +
  2303 + } else {
  2304 + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));
  2305 + }
  2306 + } else {
  2307 + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));
  2308 +
  2309 + }
  2310 + map.put("company", fgs);
  2311 + map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase());
  2312 + map.put("requestTime", obj[1]);
  2313 + listMap.add(map);
  2314 + }
  2315 + }
  2316 +
  2317 + if (type != null && type.length() != 0 && type.equals("export")) {
  2318 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  2319 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  2320 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  2321 + Map<String, Object> m = new HashMap<String, Object>();
  2322 + ReportUtils ee = new ReportUtils();
  2323 + Map<String, Object> typeMap = new HashMap<String, Object>();
  2324 + typeMap.put("0xA1", "请求恢复运营");
  2325 + typeMap.put("0xA2", "申请调档");
  2326 + typeMap.put("0xA3", "出场请求");
  2327 + typeMap.put("0xA5", "进场请求");
  2328 + typeMap.put("0xA7", "加油请求");
  2329 + typeMap.put("0x50", "车辆故障");
  2330 + typeMap.put("0x70", "路阻报告");
  2331 + typeMap.put("0x60", "事故报告");
  2332 + typeMap.put("0x11", "扣证纠纷");
  2333 + typeMap.put("0x12", "报警");
  2334 + for (Map<String, Object> map1 : listMap) {
  2335 + map1.put("requestText", typeMap.get(map1.get("requestType")));
  2336 + }
  2337 + try {
  2338 + listI.add(listMap.iterator());
  2339 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  2340 + ee.excelReplace(listI, new Object[]{m}, path + "mould/account.xls",
  2341 + path + "export/" + sdfSimple.format(sdfMonth.parse(date))
  2342 + + "-" + xlName + "-驾驶员请求台账.xls");
  2343 + } catch (Exception e) {
  2344 + // TODO: handle exception
  2345 + e.printStackTrace();
  2346 + }
  2347 + }
  2348 +
  2349 + return listMap;
  2350 + }
  2351 +
  2352 + @Override
  2353 + public List<SchEditInfoDto> correctForm(String line, String date, String endDate,
  2354 + String lpName, String code, String type, String changType) {
  2355 +
  2356 +// var types = {'DFTZ': '待发调整', 'FCXXWT':'发车信息微调', 'JHLB': '班次取消', 'CXLB': '撤销烂班',
  2357 +// 'CXZX': '撤销执行', 'CXSF': '撤销实发', 'SFTZ': '实发调整', 'TZRC': '调整人车'};
  2358 + Map<String, Object> map = new HashMap<String, Object>();
  2359 + map.put("DFTZ", "待发调整");
  2360 + map.put("FCXXWT", "发车信息微调");
  2361 + map.put("JHLB", "班次取消");
  2362 + map.put("CXLB", "撤销烂班");
  2363 + map.put("CXZX", "撤销执行");
  2364 + map.put("CXSF", "撤销实发");
  2365 + map.put("SFTZ", "实发调整");
  2366 + map.put("TZRC", "调整人车");
  2367 +
  2368 + SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");
  2369 + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  2370 + String cont = "";
  2371 + cont = " and xl_bm ='" + line + "'";
  2372 + if (!lpName.equals("")) {
  2373 + cont += " and lp_name = '" + lpName + "'";
  2374 + }
  2375 + if (!code.equals("")) {
  2376 + cont += " and cl_zbh ='" + code + "'";
  2377 + }
  2378 + String sql = "select t1.*, t2.real_exec_date,"
  2379 + + "t2.fcsj,t2.lp_name,t2.cl_zbh,t2.j_gh,t2.j_name,"
  2380 + + "t2.xl_dir,t2.real_exec_date from (select * from "
  2381 + + "logger_sch_modify where rq BETWEEN ? and ? and line_code=? )"
  2382 + + " t1 INNER JOIN bsth_c_s_sp_info_real t2 on "
  2383 + + "t1.sch_id=t2.id where 1=1 " + cont;
  2384 +
  2385 + List<SchEditInfoDto> list = jdbcTemplate.query(sql,
  2386 + new BeanPropertyRowMapper(SchEditInfoDto.class), date, endDate, line);
  2387 + List<SchEditInfoDto> lists = new ArrayList<SchEditInfoDto>();
  2388 + for (int i = 0; i < list.size(); i++) {
  2389 + Long fcsjs = 0l;
  2390 + Long updsj = 0l;
  2391 + SchEditInfoDto t = list.get(i);
  2392 + if (map.get(t.getType()) != null) {
  2393 +
  2394 + if (changType.equals("")) {
  2395 + t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";");
  2396 + } else {
  2397 + String fcsj = "";
  2398 + String updtime = "";
  2399 + try {
  2400 + fcsj = sdf1.format(sdf1.parse(t.getFcsj()));
  2401 + updtime = sdf1.format(sdf1.parse(t.getTimeStr()));
  2402 + fcsjs = sdf2.parse(t.getRealExecDate() + " " + fcsj).getTime();
  2403 + updsj = sdf2.parse(t.getRq() + " " + updtime).getTime();
  2404 + } catch (ParseException e) {
  2405 + // TODO Auto-generated catch block
  2406 + e.printStackTrace();
  2407 + }
  2408 + if (changType.equals("1")) {
  2409 + if (fcsjs > updsj) {
  2410 + t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";");
  2411 + } else {
  2412 + t.setType2("");
  2413 + }
  2414 + } else if (changType.equals("2")) {
  2415 + if (fcsjs < updsj) {
  2416 + t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";");
  2417 + } else {
  2418 + t.setType2("");
  2419 + }
  2420 + }
  2421 + }
  2422 + } else {
  2423 + t.setType2("");
  2424 + }
  2425 + boolean fage = true;
  2426 + for (int j = 0; j < lists.size(); j++) {
  2427 + SchEditInfoDto s = lists.get(j);
  2428 + if (s.getSchId() == t.getSchId()) {
  2429 + s.setType2(s.getType2() + " " + t.getType2());
  2430 + fage = false;
  2431 + }
  2432 + }
  2433 +
  2434 + if (fage) {
  2435 + if (changType.equals("")) {
  2436 + lists.add(t);
  2437 + } else {
  2438 + if (changType.equals("1")) {
  2439 + if (fcsjs > updsj) {
  2440 + lists.add(t);
  2441 + }
  2442 + } else if (changType.equals("2")) {
  2443 + if (fcsjs < updsj) {
  2444 + lists.add(t);
  2445 + }
  2446 + }
  2447 + }
  2448 + }
  2449 + }
  2450 +
  2451 + if (type != null && type.length() != 0 && type.equals("export")) {
  2452 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  2453 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  2454 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  2455 + Map<String, Object> m = new HashMap<String, Object>();
  2456 + m.put("dates", date);
  2457 + ReportUtils ee = new ReportUtils();
  2458 + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
  2459 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2460 + for (SchEditInfoDto d : lists) {
  2461 + Map<String, Object> tempMap = new HashMap<String, Object>();
  2462 + tempMap.put("lpName", d.getLpName());
  2463 + tempMap.put("rq", d.getRq());
  2464 + tempMap.put("clZbh", d.getClZbh());
  2465 + tempMap.put("jName", d.getjName() + "/" + d.getjGh());
  2466 + tempMap.put("fcsj", d.getFcsj());
  2467 + tempMap.put("type", d.getType2());
  2468 + tempList.add(tempMap);
  2469 + }
  2470 + try {
  2471 + String dateTime = sdfSimple.format(sdfMonth.parse(date));
  2472 + if(!endDate.equals(date)){
  2473 + dateTime += "-" + sdfSimple.format(sdfMonth.parse(endDate));
  2474 + }
  2475 + String lineName = BasicData.lineCode2NameMap.get(line);
  2476 + listI.add(tempList.iterator());
  2477 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  2478 + ee.excelReplace(listI, new Object[]{m}, path + "mould/correctForm.xls",
  2479 + path + "export/" + dateTime + "-" + lineName + "-修正报表.xls");
  2480 + } catch (Exception e) {
  2481 + // TODO: handle exception
  2482 + e.printStackTrace();
  2483 + }
  2484 +// Map<String, Object> maps = tempList.get(tempList.size() - 1);
  2485 + }
  2486 + return lists;
  2487 + }
  2488 +
  2489 + @Override
  2490 + public List<ScheduleRealInfo> queryListWaybill(String jGh, String clZbh,
  2491 + String lpName, String date, String line) {
  2492 + List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();
  2493 + List<ScheduleRealInfo> list = null;
  2494 + list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);
  2495 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  2496 + String minfcsj = "02:00";
  2497 + List<Line> lineList = lineRepository.findLineByCode(line);
  2498 + if (lineList.size() > 0) {
  2499 + String sqlMinYysj = "select start_opt from bsth_c_line_config where "
  2500 + + " id = ("
  2501 + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"
  2502 + + ")";
  2503 + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  2504 + }
  2505 + String[] minSjs = minfcsj.split(":");
  2506 + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);
  2507 +
  2508 + for (int i = 0; i < list.size(); i++) {
  2509 + ScheduleRealInfo s = list.get(i);
  2510 + if (s.getBcType().equals("out")) {
  2511 + s.setRemark("1");
  2512 + } else if (s.getBcType().equals("in")) {
  2513 + s.setRemark("3");
  2514 + } else {
  2515 + s.setRemark("2");
  2516 + }
  2517 + String[] fcsj = s.getFcsj().split(":");
  2518 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  2519 +
  2520 + Long fscjT = 0L;
  2521 + if (fcsjL < minSj) {
  2522 + Calendar calendar = new GregorianCalendar();
  2523 + calendar.setTime(s.getScheduleDate());
  2524 + calendar.add(calendar.DATE, 1);
  2525 + s.setScheduleDate(calendar.getTime());
  2526 + try {
  2527 + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();
  2528 + } catch (ParseException e) {
  2529 + // TODO Auto-generated catch block
  2530 + e.printStackTrace();
  2531 + }
  2532 +
  2533 + } else {
  2534 + try {
  2535 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  2536 + } catch (ParseException e) {
  2537 + // TODO Auto-generated catch block
  2538 + e.printStackTrace();
  2539 + }
  2540 + ;
  2541 + }
  2542 + s.setFcsjT(fscjT);
  2543 + }
  2544 + Collections.sort(list, new compareFcsjType());
  2545 + for (int i = 0; i < list.size(); i++) {
  2546 + ScheduleRealInfo s = list.get(i);
  2547 + s.setAdjustExps(i + 1 + "");
  2548 + String remarks = "";
  2549 + if (s.getRemarks() != null) {
  2550 + remarks += s.getRemarks();
  2551 + }
  2552 +
  2553 + Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
  2554 + if (!childTaskPlans.isEmpty()) {
  2555 + s.setFcsjActual("");
  2556 + s.setZdsjActual("");
  2557 + s.setJhlc(0.0);
  2558 + }
  2559 +
  2560 + if (s.isDestroy()) {
  2561 + s.setFcsjActual("");
  2562 + s.setZdsjActual("");
  2563 + s.setJhlc(0.0);
  2564 + remarks += "(烂班)";
  2565 + s.setRemarks(remarks);
  2566 + }
  2567 +
  2568 + listSchedule.add(s);
  2569 + //计算营运里程,空驶里程
  2570 + if (!childTaskPlans.isEmpty()) {
  2571 +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  2572 + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);
  2573 + Collections.sort(listit, new ComparableChild());
  2574 + for (int j = 0; j < listit.size(); j++) {
  2575 + ScheduleRealInfo t = new ScheduleRealInfo();
  2576 + ChildTaskPlan childTaskPlan = listit.get(j);
  2577 + if (childTaskPlan.getCcId() == null) {
  2578 + if (childTaskPlan.isDestroy()) {
  2579 + t.setFcsjActual("");
  2580 + t.setZdsjActual("");
  2581 + t.setJhlc(0.0);
  2582 + } else {
  2583 + t.setFcsjActual(childTaskPlan.getStartDate());
  2584 + t.setZdsjActual(childTaskPlan.getEndDate());
  2585 + t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));
  2586 + }
  2587 + t.setFcsj(childTaskPlan.getStartDate());
  2588 + t.setZdsj(childTaskPlan.getEndDate());
  2589 + t.setQdzName(childTaskPlan.getStartStationName());
  2590 + t.setZdzName(childTaskPlan.getEndStationName());
  2591 + t.setRemarks(childTaskPlan.getRemarks());
  2592 + t.setAdjustExps("子");
  2593 + listSchedule.add(t);
  2594 + }
  2595 + }
  2596 + }
  2597 + }
  2598 +
  2599 + return listSchedule;
  2600 + }
  2601 +
  2602 + @Override
  2603 + public List<ScheduleRealInfo> queryListWaybill2(String jName, String clZbh,
  2604 + String lpName, String date, String line) {
  2605 + List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();
  2606 + List<ScheduleRealInfo> list = null;
  2607 + list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date, line);
  2608 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  2609 + String minfcsj = "02:00";
  2610 + List<Line> lineList = lineRepository.findLineByCode(line);
  2611 + if (lineList.size() > 0) {
  2612 + String sqlMinYysj = "select start_opt from bsth_c_line_config where "
  2613 + + " id = ("
  2614 + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"
  2615 + + ")";
  2616 + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  2617 + }
  2618 + String[] minSjs = minfcsj.split(":");
  2619 + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);
  2620 +
  2621 + for (int i = 0; i < list.size(); i++) {
  2622 + ScheduleRealInfo s = list.get(i);
  2623 + String[] fcsj = s.getFcsj().split(":");
  2624 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  2625 +
  2626 + Long fscjT = 0L;
  2627 + if (fcsjL < minSj) {
  2628 + Calendar calendar = new GregorianCalendar();
  2629 + calendar.setTime(s.getScheduleDate());
  2630 + calendar.add(calendar.DATE, 1);
  2631 + s.setScheduleDate(calendar.getTime());
  2632 + try {
  2633 + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();
  2634 + } catch (ParseException e) {
  2635 + // TODO Auto-generated catch block
  2636 + e.printStackTrace();
  2637 + }
  2638 +
  2639 + } else {
  2640 + try {
  2641 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  2642 + } catch (ParseException e) {
  2643 + // TODO Auto-generated catch block
  2644 + e.printStackTrace();
  2645 + }
  2646 + ;
  2647 + }
  2648 + s.setFcsjT(fscjT);
  2649 + }
  2650 + Collections.sort(list, new ComparableReal());
  2651 + for (int i = 0; i < list.size(); i++) {
  2652 + ScheduleRealInfo s = list.get(i);
  2653 + s.setAdjustExps(i + 1 + "");
  2654 + String remarks = "";
  2655 + if (s.getRemarks() != null) {
  2656 + remarks += s.getRemarks();
  2657 + }
  2658 +
  2659 + Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
  2660 + if (!childTaskPlans.isEmpty()) {
  2661 + s.setFcsjActual("");
  2662 + s.setZdsjActual("");
  2663 + s.setJhlc(0.0);
  2664 + }
  2665 +
  2666 + if (s.isDestroy()) {
  2667 + if (s.isReissue()) {
  2668 + s.setFcsjActual(s.getDfsj());
  2669 + s.setZdsjActual(s.getZdsj());
  2670 + s.setRemarks("");
  2671 + s.setStatus(2);
  2672 + s.setJhlc(s.getJhlcOrig());
  2673 + } else {
  2674 + s.setFcsjActual("");
  2675 + s.setZdsjActual("");
  2676 + s.setJhlc(0.0);
  2677 + remarks += "(烂班)";
  2678 + s.setRemarks(remarks);
  2679 + }
  2680 + }
  2681 +
  2682 + listSchedule.add(s);
  2683 + //计算营运里程,空驶里程
  2684 + if (!childTaskPlans.isEmpty()) {
  2685 +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  2686 + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);
  2687 + Collections.sort(listit, new ComparableChild());
  2688 + for (int j = 0; j < listit.size(); j++) {
  2689 + ScheduleRealInfo t = new ScheduleRealInfo();
  2690 + ChildTaskPlan childTaskPlan = listit.get(j);
  2691 + if (childTaskPlan.isDestroy()) {
  2692 + t.setFcsjActual("");
  2693 + t.setZdsjActual("");
  2694 + t.setJhlc(0.0);
  2695 + } else {
  2696 + t.setFcsjActual(childTaskPlan.getStartDate());
  2697 + t.setZdsjActual(childTaskPlan.getEndDate());
  2698 + t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));
  2699 + }
  2700 + t.setQdzName(childTaskPlan.getStartStationName());
  2701 + t.setZdzName(childTaskPlan.getEndStationName());
  2702 + t.setRemarks(childTaskPlan.getRemarks());
  2703 + t.setAdjustExps("子");
  2704 + listSchedule.add(t);
  2705 + }
  2706 + }
  2707 + }
  2708 +
  2709 + return listSchedule;
  2710 + }
  2711 +
  2712 + @Override
  2713 + public Map<String, Object> removeChildTask(Long taskId) {
  2714 + Map<String, Object> rs = new HashMap<>();
  2715 + ChildTaskPlan chTask = cTaskPlanRepository.findById(taskId).get();
  2716 +
  2717 + ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId());
  2718 + try {
  2719 +
  2720 + sch.getcTasks().remove(chTask);
  2721 + scheduleRealInfoRepository.save(sch);
  2722 + rs.put("status", ResponseCode.SUCCESS);
  2723 + } catch (Exception e) {
  2724 + logger.error("", e);
  2725 + rs.put("status", ResponseCode.ERROR);
  2726 + }
  2727 + return rs;
  2728 + }
  2729 +
  2730 + @Override
  2731 + public List<Map<String, Object>> statisticsDaily(String line, String date,
  2732 + String xlName, String type) {
  2733 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  2734 + List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);
  2735 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  2736 + for (int i = 0; i < list_s.size(); i++) {
  2737 + ScheduleRealInfo s = list_s.get(i);
  2738 + Set<ChildTaskPlan> cts = s.getcTasks();
  2739 + if (cts != null && cts.size() > 0) {
  2740 + lists.add(s);
  2741 + } else {
  2742 + if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  2743 + lists.add(s);
  2744 + }
  2745 + }
  2746 + }
  2747 + Map<String, Object> map = new HashMap<String, Object>();
  2748 + map.put("xlName", xlName);
  2749 + double jhlc = culateService.culateJhgl(list_s);
  2750 + map.put("jhlc", jhlc);
  2751 + map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists)));
  2752 + double lbgl = culateService.culateLbgl(list_s);
  2753 + map.put("ssgl", lbgl);
  2754 + map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻"));
  2755 + map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢"));
  2756 + map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障"));
  2757 + map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷"));
  2758 + map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事"));
  2759 + map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人"));
  2760 + map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车"));
  2761 + map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀"));
  2762 + map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候"));
  2763 + map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外"));
  2764 + map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚"));
  2765 + double ssgl_pc = culateService.culateCJLC(list_s, "配车");
  2766 + double ssgl_by = culateService.culateCJLC(list_s, "保养");
  2767 + double ssgl_cj = culateService.culateCJLC(list_s, "抽减");
  2768 + double ssgl_qt = culateService.culateCJLC(list_s, "其他");
  2769 + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));
  2770 + map.put("ssbc", culateService.culateLbbc(list_s));
  2771 + double ljgl = culateService.culateLjgl(lists);
  2772 + map.put("ljgl", ljgl);
  2773 + map.put("jhbc", culateService.culateJhbc(list_s, ""));
  2774 + map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf"));
  2775 + map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf"));
  2776 + map.put("sjbc", culateService.culateSjbc(lists, ""));
  2777 + map.put("sjbc_m", culateService.culateSjbc(lists, "zgf"));
  2778 + map.put("sjbc_a", culateService.culateSjbc(lists, "wgf"));
  2779 + map.put("ljbc", culateService.culateLjbc(lists, ""));
  2780 + map.put("ljbc_m", culateService.culateLjbc(lists, "zgf"));
  2781 + map.put("ljbc_a", culateService.culateLjbc(lists, "wgf"));
  2782 + map.put("fzbc", culateService.culateFzbc(lists, ""));
  2783 + map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));
  2784 + map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));
  2785 + map.put("dtbc", 0);
  2786 + map.put("dtbc_m", 0);
  2787 + map.put("dtbc_a", 0);
  2788 + List<CalcInterval> intervalList=calcIntervalRepository.selectByDateAndLine(line, date,"");
  2789 + if(intervalList.size()>0){
  2790 + CalcInterval c=intervalList.get(0);
  2791 + map.put("djg",c.getDjgAll());
  2792 + map.put("djg_m", c.getDjgZgf());
  2793 + map.put("djg_a", c.getDjgWgf());
  2794 + map.put("djg_time", c.getDjgTime());
  2795 + }else{
  2796 + Map<String, Object> m = culateService.culateDjg(list_s, line);
  2797 + map.put("djg", m.get("djgcsq"));
  2798 + map.put("djg_m", m.get("djgcsz"));
  2799 + map.put("djg_a", m.get("djgcsw"));
  2800 + map.put("djg_time", m.get("djgsj"));
  2801 + }
  2802 +
  2803 + map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl));
  2804 + lMap.add(map);
  2805 +
  2806 + if (date.length() == 10) {
  2807 + List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59");
  2808 + String dbdp = "";
  2809 + try {
  2810 + for (int i = 0; i < list.size(); i++) {
  2811 + DutyEmployee t = list.get(i);
  2812 + if (dbdp.indexOf(t.getuName()) == -1) {
  2813 + if (!(dbdp.length() > 0)) {
  2814 + dbdp = t.getuName();
  2815 + } else {
  2816 + dbdp += "," + t.getuName();
  2817 + }
  2818 + }
  2819 + }
  2820 + } catch (Exception e) {
  2821 + // TODO: handle exception
  2822 + e.printStackTrace();
  2823 + }
  2824 + map.put("dbdp", dbdp);
  2825 + }
  2826 +
  2827 + return lMap;
  2828 + }
  2829 +
  2830 + @Override
  2831 + public List<Map<String, Object>> statisticsDaily_mh_2(String line, String date,
  2832 + String xlName, String type) {
  2833 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  2834 + List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);
  2835 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  2836 + for (int i = 0; i < list_s.size(); i++) {
  2837 + ScheduleRealInfo s = list_s.get(i);
  2838 + if (s.isDestroy() && s.isReissue()) {
  2839 + s.setRemark("");
  2840 + s.setFcsjActual(s.getDfsj());
  2841 + s.setZdsjActual(s.getZdsj());
  2842 + s.setStatus(2);
  2843 + s.setJhlc(s.getJhlcOrig());
  2844 + }
  2845 +
  2846 + Set<ChildTaskPlan> cts = s.getcTasks();
  2847 + if (cts != null && cts.size() > 0) {
  2848 + lists.add(s);
  2849 + } else {
  2850 + if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  2851 + lists.add(s);
  2852 + }
  2853 + }
  2854 + }
  2855 + Map<String, Object> map = new HashMap<String, Object>();
  2856 + map.put("xlName", xlName);
  2857 + double jhlc = culateService.culateJhgl(list_s);
  2858 + map.put("jhlc", jhlc);
  2859 + map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists)));
  2860 + double lbgl = culateService.culateLbgl(list_s);
  2861 + map.put("ssgl", lbgl);
  2862 + map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻"));
  2863 + map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢"));
  2864 + map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障"));
  2865 + map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷"));
  2866 + map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事"));
  2867 + map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人"));
  2868 + map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车"));
  2869 + map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀"));
  2870 + map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候"));
  2871 + map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外"));
  2872 + map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚"));
  2873 + double ssgl_pc = culateService.culateCJLC(list_s, "配车");
  2874 + double ssgl_by = culateService.culateCJLC(list_s, "保养");
  2875 + double ssgl_cj = culateService.culateCJLC(list_s, "抽减");
  2876 + double ssgl_qt = culateService.culateCJLC(list_s, "其他");
  2877 + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));
  2878 + map.put("ssbc", culateService.culateLbbc(list_s));
  2879 + double ljgl = culateService.culateLjgl(lists);
  2880 + map.put("ljgl", ljgl);
  2881 + map.put("jhbc", culateService.culateJhbc(list_s, ""));
  2882 + map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf"));
  2883 + map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf"));
  2884 + map.put("sjbc", culateService.culateSjbc(lists, ""));
  2885 + map.put("sjbc_m", culateService.culateSjbc(lists, "zgf"));
  2886 + map.put("sjbc_a", culateService.culateSjbc(lists, "wgf"));
  2887 + map.put("ljbc", culateService.culateLjbc(lists, ""));
  2888 + map.put("ljbc_m", culateService.culateLjbc(lists, "zgf"));
  2889 + map.put("ljbc_a", culateService.culateLjbc(lists, "wgf"));
  2890 + map.put("fzbc", culateService.culateFzbc(lists, ""));
  2891 + map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));
  2892 + map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));
  2893 + map.put("dtbc", 0);
  2894 + map.put("dtbc_m", 0);
  2895 + map.put("dtbc_a", 0);
  2896 + map.put("djg", 0);
  2897 + map.put("djg_m", 0);
  2898 + map.put("djg_a", 0);
  2899 + map.put("djg_time", 0);
  2900 + map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl));
  2901 + lMap.add(map);
  2902 + return lMap;
  2903 + }
  2904 +
  2905 + public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,Map<String, Object> m) {
  2906 +
  2907 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  2908 + for (int i = 0; i < list.size(); i++) {
  2909 + ScheduleRealInfo s = list.get(i);
  2910 + Set<ChildTaskPlan> cts = s.getcTasks();
  2911 + if (cts != null && cts.size() > 0) {
  2912 + lists.add(s);
  2913 + } else {
  2914 + if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  2915 + lists.add(s);
  2916 + }
  2917 + }
  2918 + }
  2919 + Map<String, Object> map = new HashMap<String, Object>();
  2920 + if (list.size() > 0) {
  2921 + map.put("gsBm", list.get(0).getGsBm());
  2922 + map.put("fgsBm", list.get(0).getFgsBm());
  2923 + map.put("xlBm", list.get(0).getXlBm());
  2924 + map.put("xlName", list.get(0).getXlName());
  2925 + map.put("fgsName", list.get(0).getFgsName());
  2926 + map.put("gsName", list.get(0).getGsName());
  2927 +
  2928 + try {
  2929 + map.put("xlNamePy", PinyinHelper.convertToPinyinString(list.get(0).getGsBm()+list.get(0).getFgsBm()+list.get(0).getXlName(), "", PinyinFormat.WITHOUT_TONE));
  2930 + } catch (PinyinException e) {
  2931 + // TODO Auto-generated catch block
  2932 + e.printStackTrace();
  2933 + }
  2934 + double jhyygl = culateService.culateJhgl(list);//计划营运公里
  2935 + double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)
  2936 + map.put("jhlc", jhyygl);
  2937 + map.put("jcclc", jhjcclc);
  2938 + map.put("jhzlc", Arith.add(jhyygl, jhjcclc));
  2939 + double ljks=culateService.culateLjksgl(lists);
  2940 + map.put("ljks", ljks);
  2941 + double ljgl = culateService.culateLjgl(lists);
  2942 + double sjyygl = culateService.culateSjgl(lists);
  2943 + double zyygl = Arith.add(sjyygl, ljgl);
  2944 +
  2945 + double sjjccgl = culateService.culateJccgl(lists);
  2946 + double sjksgl = culateService.culateKsgl(lists);
  2947 + double zksgl = Arith.add(sjjccgl, sjksgl);
  2948 + map.put("sjzgl", Arith.add(zyygl, zksgl));
  2949 + map.put("sjgl", zyygl);
  2950 + map.put("sjksgl", zksgl);
  2951 + double ssgl = culateService.culateLbgl(list);
  2952 + map.put("ssgl", ssgl);
  2953 +
  2954 + //计划+临加-少驶=实驶
  2955 + double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl);
  2956 + if (jl == zyygl) {
  2957 + map.put("zt", 0);
  2958 + } else {
  2959 + map.put("zt", 1);
  2960 + }
  2961 +
  2962 + map.put("ssgl_lz", culateService.culateCJLC(list, "路阻"));
  2963 + map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢"));
  2964 + map.put("ssgl_gz", culateService.culateCJLC(list, "故障"));
  2965 + map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷"));
  2966 + map.put("ssgl_zs", culateService.culateCJLC(list, "肇事"));
  2967 + map.put("ssgl_qr", culateService.culateCJLC(list, "缺人"));
  2968 + map.put("ssgl_qc", culateService.culateCJLC(list, "缺车"));
  2969 + map.put("ssgl_kx", culateService.culateCJLC(list, "客稀"));
  2970 + map.put("ssgl_qh", culateService.culateCJLC(list, "气候"));
  2971 + map.put("ssgl_yw", culateService.culateCJLC(list, "援外"));
  2972 + map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚"));
  2973 + double ssgl_pc = culateService.culateCJLC(list, "配车");
  2974 + double ssgl_by = culateService.culateCJLC(list, "保养");
  2975 + double ssgl_cj = culateService.culateCJLC(list, "抽减");
  2976 + double ssgl_qt = culateService.culateCJLC(list, "其他");
  2977 + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));
  2978 + map.put("ssbc", culateService.culateLbbc(list));
  2979 + map.put("ljgl", ljgl);
  2980 + map.put("jhbc", culateService.culateJhbc(list, ""));
  2981 + map.put("jhbc_m", culateService.culateJhbc(list, "zgf"));
  2982 + map.put("jhbc_a", culateService.culateJhbc(list, "wgf"));
  2983 + map.put("sjbc", culateService.culateSjbc(lists, ""));
  2984 + map.put("sjbc_m", culateService.culateSjbc(lists, "zgf"));
  2985 + map.put("sjbc_a", culateService.culateSjbc(lists, "wgf"));
  2986 + map.put("ljbc", culateService.culateLjbc(lists, ""));
  2987 + map.put("ljbc_m", culateService.culateLjbc(lists, "zgf"));
  2988 + map.put("ljbc_a", culateService.culateLjbc(lists, "wgf"));
  2989 + map.put("fzbc", culateService.culateFzbc(lists, ""));
  2990 + map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));
  2991 + map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));
  2992 + map.put("dtbc", 0);
  2993 + map.put("dtbc_m", 0);
  2994 + map.put("dtbc_a", 0);
  2995 + if(m.get("xl")==null){
  2996 + Map<String, Object> m_ = culateService.culateDjg(lists, list.get(0).getXlBm());
  2997 + map.put("djg", m_.get("djgcsq"));
  2998 + map.put("djg_m", m_.get("djgcsz"));
  2999 + map.put("djg_a", m_.get("djgcsw"));
  3000 + map.put("djg_time", m_.get("djgsj"));
  3001 + }else{
  3002 + map.put("djg", m.get("djgAll")==null?"0":m.get("djgAll"));
  3003 + map.put("djg_m", m.get("djgZgf")==null?"0":m.get("djgZgf"));
  3004 + map.put("djg_a", m.get("djgWgf")==null?"0":m.get("djgWgf"));
  3005 + map.put("djg_time", m.get("djgTime")==null?"0":m.get("djgTime"));
  3006 + }
  3007 + }
  3008 + return map;
  3009 + }
  3010 +
  3011 + @Override
  3012 + public List<Map<String, Object>> dispatchDailySum(String date, String date2, String nature, String type) {
  3013 + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  3014 +
  3015 +// List<Map<String, Object>> list = statisticsDailyTj("", "", "", date, date2, "", "query", nature);
  3016 + List<CalcStatistics> calc = calcWaybillService.calcStatisticsDaily("", "", "", date, date2, "", "query", nature);
  3017 + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  3018 + try {
  3019 + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
  3020 + for(CalcStatistics c : calc){
  3021 + Map<String, Object> m = new HashMap<>();
  3022 + Field[] fields = c.getClass().getDeclaredFields();
  3023 + for(Field f : fields){
  3024 + f.setAccessible(true);
  3025 + String key = new String(f.getName());
  3026 + m.put(key, f.get(c));
  3027 + }
  3028 + tempList.add(m);
  3029 + }
  3030 + list = tempList;
  3031 + } catch (Exception e) {
  3032 + // TODO: handle exception
  3033 + e.printStackTrace();
  3034 + }
  3035 +
  3036 + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>();
  3037 + Map<String, Object> temp = new HashMap<String, Object>();
  3038 + temp.put("gsName", "杨高");temp.put("fgsName", "杨高分");temp.put("key", "05_5");
  3039 + resList.add(temp);keyMap.put("05_5", temp);
  3040 + temp = new HashMap<String, Object>();
  3041 + temp.put("gsName", "杨高");temp.put("fgsName", "金桥分");temp.put("key", "05_2");
  3042 + resList.add(temp);keyMap.put("05_2", temp);
  3043 + temp = new HashMap<String, Object>();
  3044 + temp.put("gsName", "杨高");temp.put("fgsName", "川沙分");temp.put("key", "05_1");
  3045 + resList.add(temp);keyMap.put("05_1", temp);
  3046 + temp = new HashMap<String, Object>();
  3047 + temp.put("gsName", "杨高");temp.put("fgsName", "周浦分");temp.put("key", "05_6");
  3048 + resList.add(temp);keyMap.put("05_6", temp);
  3049 + temp = new HashMap<String, Object>();
  3050 + temp.put("gsName", "杨高");temp.put("fgsName", "小计");temp.put("key", "05_sum");
  3051 + resList.add(temp);keyMap.put("05_sum", temp);
  3052 +
  3053 + temp = new HashMap<String, Object>();
  3054 + temp.put("gsName", "上南");temp.put("fgsName", "一分");temp.put("key", "55_4");
  3055 + resList.add(temp);keyMap.put("55_4", temp);
  3056 + temp = new HashMap<String, Object>();
  3057 + temp.put("gsName", "上南");temp.put("fgsName", "二分");temp.put("key", "55_1");
  3058 + resList.add(temp);keyMap.put("55_1", temp);
  3059 + temp = new HashMap<String, Object>();
  3060 + temp.put("gsName", "上南");temp.put("fgsName", "三分");temp.put("key", "55_2");
  3061 + resList.add(temp);keyMap.put("55_2", temp);
  3062 + temp = new HashMap<String, Object>();
  3063 + temp.put("gsName", "上南");temp.put("fgsName", "六分");temp.put("key", "55_3");
  3064 + resList.add(temp);keyMap.put("55_3", temp);
  3065 + temp = new HashMap<String, Object>();
  3066 + temp.put("gsName", "上南");temp.put("fgsName", "小计");temp.put("key", "55_sum");
  3067 + resList.add(temp);keyMap.put("55_sum", temp);
  3068 +
  3069 + temp = new HashMap<String, Object>();
  3070 + temp.put("gsName", "金高");temp.put("fgsName", "一分");temp.put("key", "22_5");
  3071 + resList.add(temp);keyMap.put("22_5", temp);
  3072 + temp = new HashMap<String, Object>();
  3073 + temp.put("gsName", "金高");temp.put("fgsName", "二分");temp.put("key", "22_2");
  3074 + resList.add(temp);keyMap.put("22_2", temp);
  3075 + temp = new HashMap<String, Object>();
  3076 + temp.put("gsName", "金高");temp.put("fgsName", "三分");temp.put("key", "22_3");
  3077 + resList.add(temp);keyMap.put("22_3", temp);
  3078 + temp = new HashMap<String, Object>();
  3079 + temp.put("gsName", "金高");temp.put("fgsName", "四分");temp.put("key", "22_1");
  3080 + resList.add(temp);keyMap.put("22_1", temp);
  3081 + temp = new HashMap<String, Object>();
  3082 + temp.put("gsName", "金高");temp.put("fgsName", "小计");temp.put("key", "22_sum");
  3083 + resList.add(temp);keyMap.put("22_sum", temp);
  3084 +
  3085 + temp = new HashMap<String, Object>();
  3086 + temp.put("gsName", "南汇");temp.put("fgsName", "一分");temp.put("key", "26_1");
  3087 + resList.add(temp);keyMap.put("26_1", temp);
  3088 + temp = new HashMap<String, Object>();
  3089 + temp.put("gsName", "南汇");temp.put("fgsName", "二分");temp.put("key", "26_2");
  3090 + resList.add(temp);keyMap.put("26_2", temp);
  3091 + temp = new HashMap<String, Object>();
  3092 + temp.put("gsName", "南汇");temp.put("fgsName", "三分");temp.put("key", "26_3");
  3093 + resList.add(temp);keyMap.put("26_3", temp);
  3094 + temp = new HashMap<String, Object>();
  3095 + temp.put("gsName", "南汇");temp.put("fgsName", "六分");temp.put("key", "26_6");
  3096 + resList.add(temp);keyMap.put("26_6", temp);
  3097 + temp = new HashMap<String, Object>();
  3098 + temp.put("gsName", "南汇");temp.put("fgsName", "小计");temp.put("key", "26_sum");
  3099 + resList.add(temp);keyMap.put("26_sum", temp);
  3100 +
  3101 + temp = new HashMap<String, Object>();
  3102 + temp.put("gsName", "浦交");temp.put("fgsName", " ");temp.put("key", "88");
  3103 + resList.add(temp);keyMap.put("88", temp);
  3104 +
  3105 + for(Map<String, Object> m : list){
  3106 + m.put("gsBm", m.get("gsdm"));
  3107 + m.put("fgsBm", m.get("fgsdm"));
  3108 + if(m.get("gsBm") != null && m.get("fgsBm") != null
  3109 + && m.get("gsBm").toString().trim().length() > 0
  3110 + && m.get("fgsBm").toString().trim().length() > 0){
  3111 + String gsBm = m.get("gsBm").toString().trim();
  3112 + String fgsBm = m.get("fgsBm").toString().trim();
  3113 + String key = gsBm + "_" + fgsBm;
  3114 + if(keyMap.containsKey(key)){
  3115 + Map<String, Object> t = keyMap.get(key);
  3116 + for(String s : m.keySet()){
  3117 + if("gsName,fgsName,key".contains(s)){
  3118 + continue;
  3119 + }
  3120 + try {
  3121 + if(t.containsKey(s)){
  3122 + t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));
  3123 + } else {
  3124 + t.put(s, m.get(s).toString());
  3125 + }
  3126 + } catch (Exception e) {
  3127 + // TODO: handle exception
  3128 + continue;
  3129 + }
  3130 + }
  3131 + }
  3132 + }
  3133 + }
  3134 +
  3135 + for(Map<String, Object> m : resList){
  3136 + String key = m.get("key").toString();
  3137 + if(key.contains("_sum") || key.equals("88")){
  3138 + continue;
  3139 + }
  3140 +
  3141 + Map<String, Object> t = keyMap.get(key.split("_")[0] + "_sum");
  3142 + for(String s : m.keySet()){
  3143 + if("gsName,fgsName,key".contains(s)){
  3144 + continue;
  3145 + }
  3146 + try {
  3147 + if(t.containsKey(s)){
  3148 + t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));
  3149 + } else {
  3150 + t.put(s, m.get(s).toString());
  3151 + }
  3152 + } catch (Exception e) {
  3153 + // TODO: handle exception
  3154 + continue;
  3155 + }
  3156 + }
  3157 +
  3158 + t = keyMap.get("88");
  3159 + for(String s : m.keySet()){
  3160 + if("gsName,fgsName,key".contains(s)){
  3161 + continue;
  3162 + }
  3163 + try {
  3164 + if(t.containsKey(s)){
  3165 + t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));
  3166 + } else {
  3167 + t.put(s, m.get(s).toString());
  3168 + }
  3169 + } catch (Exception e) {
  3170 + // TODO: handle exception
  3171 + continue;
  3172 + }
  3173 + }
  3174 + }
  3175 +
  3176 + for(Map<String, Object> m : resList){
  3177 + try {
  3178 + m.put("jhzlc", m.get("jhzlc"));
  3179 + m.put("jhlc", m.get("jhyylc"));
  3180 + m.put("jcclc", m.get("jhkslc"));
  3181 + m.put("sjzgl", m.get("sjzlc"));
  3182 + m.put("sjgl", m.get("sjyylc"));
  3183 + m.put("sjksgl", m.get("sjkslc"));
  3184 + m.put("ssbc", m.get("ssbc"));
  3185 + m.put("ssgl", m.get("sslc"));
  3186 + m.put("ssgl_lz", m.get("lzlc"));
  3187 + m.put("ssgl_dm", m.get("dmlc"));
  3188 + m.put("ssgl_gz", m.get("gzlc"));
  3189 + m.put("ssgl_jf", m.get("jflc"));
  3190 + m.put("ssgl_zs", m.get("zslc"));
  3191 + m.put("ssgl_qr", m.get("qrlc"));
  3192 + m.put("ssgl_qc", m.get("qclc"));
  3193 + m.put("ssgl_kx", m.get("kxlc"));
  3194 + m.put("ssgl_qh", m.get("qhlc"));
  3195 + m.put("ssgl_yw", m.get("ywlc"));
  3196 + m.put("ssgl_ljpm", m.get("ljpmlc"));
  3197 + m.put("ssgl_other", m.get("qtlc"));
  3198 + m.put("ljgl", m.get("ljlc"));
  3199 + m.put("ljks", m.get("ljkslc"));
  3200 + m.put("jhbc", m.get("jhbcq"));
  3201 + m.put("jhbc_m", m.get("jhbcz"));
  3202 + m.put("jhbc_a", m.get("jhbcw"));
  3203 + m.put("sjbc", m.get("sjbcq"));
  3204 + m.put("sjbc_m", m.get("sjbcz"));
  3205 + m.put("sjbc_a", m.get("sjbcw"));
  3206 + m.put("ljbc", m.get("ljbcq"));
  3207 + m.put("ljbc_m", m.get("ljbcz"));
  3208 + m.put("ljbc_a", m.get("ljbcw"));
  3209 + m.put("fzbc", m.get("fzbcq"));
  3210 + m.put("fzbc_m", m.get("fzbcz"));
  3211 + m.put("fzbc_a", m.get("fzbcw"));
  3212 + m.put("dtbc", m.get("dtbcq"));
  3213 + m.put("dtbc_m", m.get("dtbcz"));
  3214 + m.put("dtbc_a", m.get("dtbcw"));
  3215 + m.put("djg", m.get("djgq"));
  3216 + m.put("djg_m", m.get("djgz"));
  3217 + m.put("djg_a", m.get("djgw"));
  3218 + m.put("djg_time", m.get("djgsj"));
  3219 + m.put("ljzgl", new BigDecimal(m.get("ljgl").toString()).add(new BigDecimal(m.get("ljks").toString())));
  3220 + } catch (Exception e) {
  3221 + // TODO: handle exception
  3222 + m.put("ljzgl", "");
  3223 + continue;
  3224 + }
  3225 + }
  3226 +
  3227 + if (type != null && type.length() != 0 && type.equals("export")) {
  3228 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  3229 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  3230 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  3231 + Map<String, Object> m = new HashMap<String, Object>();
  3232 + ReportUtils ee = new ReportUtils();
  3233 + try {
  3234 + String dateTime = "";
  3235 + if (date.equals(date2)) {
  3236 + m.put("date", date);
  3237 + dateTime = sdfSimple.format(sdfMonth.parse(date));
  3238 + } else {
  3239 + m.put("date", date + "至" + date2);
  3240 + dateTime = sdfSimple.format(sdfMonth.parse(date))
  3241 + + "-" + sdfSimple.format(sdfMonth.parse(date2));
  3242 + }
  3243 + listI.add(resList.iterator());
  3244 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  3245 + ee.excelReplace(listI, new Object[]{m}, path + "mould/dispatchDailySum.xls",
  3246 + path + "export/" + dateTime + "-调度日报汇总表.xls");
  3247 + } catch (Exception e) {
  3248 + // TODO: handle exception
  3249 + //e.printStackTrace();
  3250 + logger.info("", e);
  3251 + }
  3252 + }
  3253 +
  3254 + return resList;
  3255 + }
  3256 +
  3257 + @Override
  3258 + public List<Map<String, Object>> statisticsDailyTj(String gsdm, String fgsdm, String line, String date, String date2,
  3259 + String xlName, String type,String nature) {
  3260 + List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>();
  3261 + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();
  3262 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  3263 + List<Object[]> listInterval=new ArrayList<Object[]>();
  3264 + line = line.trim();
  3265 + if(gsdm.equals("") && fgsdm.equals("") && line.equals("")){
  3266 + //查询所有公司
  3267 + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj3(date, date2);
  3268 + listInterval = calcIntervalRepository.countByDate(date, date2);
  3269 + } else if (line.equals("")) {
  3270 + //查询所有线路
  3271 + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);
  3272 + listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2);
  3273 + } else {
  3274 + //查询单条线路
  3275 + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);
  3276 + listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2);
  3277 + }
  3278 + Map<String, Map<String,Object>> mapInterval=new HashMap<String, Map<String,Object>>();
  3279 + for (int i = 0; i < listInterval.size(); i++) {
  3280 + Object[] interval=listInterval.get(i);
  3281 + String gs=interval[0].toString();
  3282 + String fgs=interval[1].toString();
  3283 + String xl=interval[2].toString();
  3284 + Map<String, Object> m=new HashMap<String,Object>();
  3285 + m.put("gs", gs);
  3286 + m.put("fgs", fgs);
  3287 + m.put("xl", xl);
  3288 + m.put("djgAll", interval[3]);
  3289 + m.put("djgZgf", interval[6]);
  3290 + m.put("djgWgf", interval[7]);
  3291 + m.put("djgTime", interval[8]);
  3292 + mapInterval.put(gs+"-"+fgs+"-"+xl, m);
  3293 + }
  3294 + Map<String, Boolean> lineMap=lineService.lineNature();
  3295 + List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();
  3296 + for (int i = 0; i < listAll.size(); i++) {
  3297 + ScheduleRealInfo s=listAll.get(i);
  3298 + if (nature.equals("0")) {
  3299 + list.add(s);
  3300 + }else if(nature.equals("1")){
  3301 + if(lineMap.get(s.getXlBm())){
  3302 + list.add(s);
  3303 + }
  3304 + }else{
  3305 + if(!lineMap.get(s.getXlBm())){
  3306 + list.add(s);
  3307 + }
  3308 + }
  3309 + }
  3310 + for (int i = 0; i < list.size(); i++) {
  3311 + ScheduleRealInfo s = list.get(i);
  3312 + Set<ChildTaskPlan> cts = s.getcTasks();
  3313 + if (cts != null && cts.size() > 0) {
  3314 + list_s.add(s);
  3315 + } else {
  3316 + if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  3317 + list_s.add(s);
  3318 + }
  3319 + }
  3320 + }
  3321 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  3322 + for (int i = 0; i < list.size(); i++) {
  3323 + if (i < list.size() - 1) {
  3324 + if ((list.get(i+1).getGsBm()+"/"+list.get(i+1).getFgsBm()+"/"+list.get(i+1).getXlBm()).equals(
  3325 + list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm())) {
  3326 + lists.add(list.get(i));
  3327 + } else {
  3328 + lists.add(list.get(i));
  3329 + Map<String, Object> mm=new HashMap<String,Object>();
  3330 + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){
  3331 + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());
  3332 + }
  3333 + Map<String, Object> map = staticTj(lists,mm);
  3334 + lMap.add(map);
  3335 + lists = new ArrayList<ScheduleRealInfo>();
  3336 + }
  3337 + } else {
  3338 + if ((list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm()).equals(
  3339 + list.get(i-1).getGsBm()+"/"+list.get(i-1).getFgsBm()+"/"+list.get(i-1).getXlBm())) {
  3340 + lists.add(list.get(i));
  3341 + Map<String, Object> mm=new HashMap<String,Object>();
  3342 + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){
  3343 + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());
  3344 + }
  3345 + Map<String, Object> map = staticTj(lists,mm);
  3346 + lMap.add(map);
  3347 + } else {
  3348 + lists = new ArrayList<ScheduleRealInfo>();
  3349 + lists.add(list.get(i));
  3350 + Map<String, Object> mm=new HashMap<String,Object>();
  3351 + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){
  3352 + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());
  3353 + }
  3354 + Map<String, Object> map = staticTj(lists,mm);
  3355 + lMap.add(map);
  3356 + }
  3357 + }
  3358 + }
  3359 +
  3360 + Collections.sort(lMap, new AccountXlbm());
  3361 + Map<String, Object> map = new HashMap<String, Object>();
  3362 + map.put("xlName", "合计");
  3363 + map.put("fgsName", "");
  3364 + map.put("gsName", "");
  3365 + double jhyygl = culateService.culateJhgl(list);//计划营运公里
  3366 + double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)
  3367 + map.put("jhlc", jhyygl);
  3368 + map.put("jcclc", jhjcclc);
  3369 + map.put("jhzlc", Arith.add(jhyygl, jhjcclc));
  3370 +
  3371 + double ljgl = culateService.culateLjgl(list_s);
  3372 + double sjyygl = culateService.culateSjgl(list_s);
  3373 + double zyygl = Arith.add(sjyygl, ljgl);
  3374 + double ljks=culateService.culateLjksgl(list_s);
  3375 + map.put("ljks", ljks);
  3376 + double sjjccgl = culateService.culateJccgl(list_s);
  3377 + double sjksgl = culateService.culateKsgl(list_s);
  3378 + double zksgl = Arith.add(sjjccgl, sjksgl);
  3379 + map.put("sjzgl", Arith.add(zyygl, zksgl));
  3380 + map.put("sjgl", zyygl);
  3381 + map.put("sjksgl", zksgl);
  3382 +
  3383 + double ssgl = culateService.culateLbgl(list);
  3384 + map.put("ssgl", ssgl);
  3385 + //计划+临加-少驶=实驶
  3386 + double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl);
  3387 + if (jl == zyygl) {
  3388 + map.put("zt", 0);
  3389 + } else {
  3390 + map.put("zt", 1);
  3391 + }
  3392 + map.put("ssgl_lz", culateService.culateCJLC(list, "路阻"));
  3393 + map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢"));
  3394 + map.put("ssgl_gz", culateService.culateCJLC(list, "故障"));
  3395 + map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷"));
  3396 + map.put("ssgl_zs", culateService.culateCJLC(list, "肇事"));
  3397 + map.put("ssgl_qr", culateService.culateCJLC(list, "缺人"));
  3398 + map.put("ssgl_qc", culateService.culateCJLC(list, "缺车"));
  3399 + map.put("ssgl_kx", culateService.culateCJLC(list, "客稀"));
  3400 + map.put("ssgl_qh", culateService.culateCJLC(list, "气候"));
  3401 + map.put("ssgl_yw", culateService.culateCJLC(list, "援外"));
  3402 + map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚"));
  3403 + double ssgl_pc = culateService.culateCJLC(list, "配车");
  3404 + double ssgl_by = culateService.culateCJLC(list, "保养");
  3405 + double ssgl_cj = culateService.culateCJLC(list, "抽减");
  3406 + double ssgl_qt = culateService.culateCJLC(list, "其他");
  3407 + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));
  3408 +
  3409 + map.put("ssbc", culateService.culateLbbc(list));
  3410 + map.put("ljgl", ljgl);
  3411 + map.put("jhbc", culateService.culateJhbc(list, ""));
  3412 + map.put("jhbc_m", culateService.culateJhbc(list, "zgf"));
  3413 + map.put("jhbc_a", culateService.culateJhbc(list, "wgf"));
  3414 + map.put("sjbc", culateService.culateSjbc(list_s, ""));
  3415 + map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf"));
  3416 + map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf"));
  3417 + map.put("ljbc", culateService.culateLjbc(list_s, ""));
  3418 + map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf"));
  3419 + map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf"));
  3420 + map.put("fzbc", culateService.culateFzbc(list_s, ""));
  3421 + map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf"));
  3422 + map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf"));
  3423 + map.put("dtbc", 0);
  3424 + map.put("dtbc_m", 0);
  3425 + map.put("dtbc_a", 0);
  3426 + if (list.size() > 0) {
  3427 + int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0;
  3428 + for (Map<String, Object> m : lMap) {
  3429 + if (m.containsKey("djg") && m.get("djg") != null)
  3430 + djg += Integer.valueOf(m.get("djg").toString());
  3431 + if (m.containsKey("djg_m") && m.get("djg_m") != null)
  3432 + djg_m += Integer.valueOf(m.get("djg_m").toString());
  3433 + if (m.containsKey("djg_a") && m.get("djg_a") != null)
  3434 + djg_a += Integer.valueOf(m.get("djg_a").toString());
  3435 + if (m.containsKey("djg_time") && m.get("djg_time") != null) {
  3436 + int t = Integer.valueOf(m.get("djg_time").toString());
  3437 + if (t > djg_time)
  3438 + djg_time = t;
  3439 + }
  3440 + }
  3441 + map.put("djg", djg);
  3442 + map.put("djg_m", djg_m);
  3443 + map.put("djg_a", djg_a);
  3444 + map.put("djg_time", djg_time);
  3445 +// Map<String, Object> m_=culateService.culateDjg(list_s, list.get(0).getXlBm());
  3446 +// map.put("djg", m_.get("djgcsq"));
  3447 +// map.put("djg_m", m_.get("djgcsz"));
  3448 +// map.put("djg_a", m_.get("djgcsw"));
  3449 +// map.put("djg_time", m_.get("djgsj"));
  3450 + } else {
  3451 + map.put("djg", "0");
  3452 + map.put("djg_m", "0");
  3453 + map.put("djg_a", "0");
  3454 + map.put("djg_time", "0");
  3455 + }
  3456 + lMap.add(map);
  3457 +
  3458 + if (type != null && type.length() != 0 && type.equals("export")) {
  3459 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  3460 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  3461 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  3462 + Map<String, Object> m = new HashMap<String, Object>();
  3463 + m.put("date", date + "至" + date2);
  3464 + ReportUtils ee = new ReportUtils();
  3465 + try {
  3466 + String dateTime = "";
  3467 + if (date.equals(date2)) {
  3468 + dateTime = sdfSimple.format(sdfMonth.parse(date));
  3469 + } else {
  3470 + dateTime = sdfSimple.format(sdfMonth.parse(date))
  3471 + + "-" + sdfSimple.format(sdfMonth.parse(date2));
  3472 + }
  3473 + listI.add(lMap.iterator());
  3474 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  3475 + ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_2.xls",
  3476 + path + "export/" + dateTime + "-" + xlName + "-统计日报.xls");
  3477 + } catch (Exception e) {
  3478 + // TODO: handle exception
  3479 + //e.printStackTrace();
  3480 + logger.info("", e);
  3481 + }
  3482 + }
  3483 +
  3484 + if (type != null && type.length() != 0 && type.equals("exportAll")) {
  3485 + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
  3486 + Map<String, Map<String, Object>> tempMap = new HashMap<String, Map<String, Object>>();
  3487 + List<Map<String, Object>> removeList = new ArrayList<Map<String, Object>>();
  3488 + for(Map<String, Object> m : lMap){
  3489 + if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0
  3490 + && m.get("gsName").toString().trim().contains("临港")){
  3491 + removeList.add(m);
  3492 + }
  3493 + }
  3494 + for(Map<String, Object> m : removeList){
  3495 + lMap.remove(m);
  3496 + }
  3497 + for(Map<String, Object> m : lMap){
  3498 + if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0){
  3499 + String gsName = m.get("gsName").toString().trim();
  3500 + Map<String, Object> temp = new HashMap<String, Object>();
  3501 + if(tempMap.get(gsName) != null){
  3502 + temp = tempMap.get(gsName);
  3503 + } else {
  3504 + temp.put("gsName", gsName);
  3505 + temp.put("fgsName", "小计");
  3506 + temp.put("xlName", "");
  3507 + tempList.add(temp);
  3508 + tempMap.put(gsName, temp);
  3509 + }
  3510 + for(String key : m.keySet()){
  3511 + try {
  3512 + temp.put(key, new BigDecimal(m.get(key).toString()).add(
  3513 + new BigDecimal(temp.get(key)!=null?temp.get(key).toString():"0")));
  3514 + } catch (Exception e) {
  3515 + // TODO: handle exception
  3516 + }
  3517 + }
  3518 + }
  3519 + }
  3520 + lMap.addAll(lMap.size()>0?lMap.size()-1:0, tempList);
  3521 +
  3522 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  3523 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  3524 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  3525 + Map<String, Object> m = new HashMap<String, Object>();
  3526 + m.put("date", date + "至" + date2);
  3527 + ReportUtils ee = new ReportUtils();
  3528 + try {
  3529 + String dateTime = "";
  3530 + if (date.equals(date2)) {
  3531 + dateTime = sdfSimple.format(sdfMonth.parse(date));
  3532 + } else {
  3533 + dateTime = sdfSimple.format(sdfMonth.parse(date))
  3534 + + "-" + sdfSimple.format(sdfMonth.parse(date2));
  3535 + }
  3536 + listI.add(lMap.iterator());
  3537 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  3538 + ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_4.xls",
  3539 + path + "export/" + dateTime + "-全部公司-统计日报.xls");
  3540 + } catch (Exception e) {
  3541 + // TODO: handle exception
  3542 + //e.printStackTrace();
  3543 + logger.info("", e);
  3544 + }
  3545 + }
  3546 +
  3547 + return lMap;
  3548 + }
  3549 +
  3550 + @Override
  3551 + public List<Map<String, Object>> statisticsDailyTjHb(String gsdm, String fgsdm, String line, String date, String date2,
  3552 + String xlName, String type,String nature) {
  3553 + List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>();
  3554 + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();
  3555 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  3556 + List<Object[]> listInterval=new ArrayList<Object[]>();
  3557 +
  3558 + line = line.trim();
  3559 + if (line.equals("")) {
  3560 + //查询所有线路
  3561 + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);
  3562 + listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2);
  3563 + } else {
  3564 + //查询单条线路
  3565 + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);
  3566 + listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2);
  3567 + }
  3568 + Map<String, Map<String,Object>> mapInterval=new HashMap<>();
  3569 + for (int i = 0; i < listInterval.size(); i++) {
  3570 + Object[] interval=listInterval.get(i);
  3571 + String gs=interval[0].toString();
  3572 + String fgs=interval[1].toString();
  3573 + String xl=interval[2].toString();
  3574 + Map<String, Object> m=new HashMap<String,Object>();
  3575 + m.put("gs", gs);
  3576 + m.put("fgs", fgs);
  3577 + m.put("xl", xl);
  3578 + m.put("djgAll", interval[3]);
  3579 + m.put("djgZgf", interval[6]);
  3580 + m.put("djgWgf", interval[7]);
  3581 + m.put("djgTime", interval[8]);
  3582 + mapInterval.put(gs+"-"+fgs+"-"+xl, m);
  3583 + }
  3584 +
  3585 + Map<String, Boolean> lineMap=lineService.lineNature();
  3586 + List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();
  3587 + for (int i = 0; i < listAll.size(); i++) {
  3588 + ScheduleRealInfo s=listAll.get(i);
  3589 + if (nature.equals("0")) {
  3590 + list.add(s);
  3591 + }else if(nature.equals("1")){
  3592 + if(lineMap.get(s.getXlBm())){
  3593 + list.add(s);
  3594 + }
  3595 + }else{
  3596 + if(!lineMap.get(s.getXlBm())){
  3597 + list.add(s);
  3598 + }
  3599 + }
  3600 + }
  3601 + for (int i = 0; i < list.size(); i++) {
  3602 + ScheduleRealInfo s = list.get(i);
  3603 + Set<ChildTaskPlan> cts = s.getcTasks();
  3604 + if (cts != null && cts.size() > 0) {
  3605 + list_s.add(s);
  3606 + } else {
  3607 + if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  3608 + list_s.add(s);
  3609 + }
  3610 + }
  3611 + }
  3612 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  3613 + for (int i = 0; i < list.size(); i++) {
  3614 + if (i < list.size() - 1) {
  3615 + if ((list.get(i + 1).getFgsBm()+list.get(i + 1).getXlBm()).equals(list.get(i).getFgsBm()+list.get(i).getXlBm())) {
  3616 + lists.add(list.get(i));
  3617 + } else {
  3618 + lists.add(list.get(i));
  3619 + Map<String, Object> mm=new HashMap<String,Object>();
  3620 + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){
  3621 + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());
  3622 + }
  3623 + Map<String, Object> map = staticTj(lists,mm);
  3624 + lMap.add(map);
  3625 + lists = new ArrayList<ScheduleRealInfo>();
  3626 + }
  3627 + } else {
  3628 + if ((list.get(i).getFgsBm()+list.get(i).getXlBm()).equals(list.get(i - 1).getFgsBm()+list.get(i - 1).getXlBm())) {
  3629 + lists.add(list.get(i));
  3630 + Map<String, Object> mm=new HashMap<String,Object>();
  3631 + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){
  3632 + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());
  3633 + }
  3634 + Map<String, Object> map = staticTj(lists,mm);
  3635 + lMap.add(map);
  3636 + } else {
  3637 + lists = new ArrayList<ScheduleRealInfo>();
  3638 + lists.add(list.get(i));
  3639 + Map<String, Object> mm=new HashMap<String,Object>();
  3640 + if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){
  3641 + mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());
  3642 + }
  3643 + Map<String, Object> map = staticTj(lists,mm);
  3644 + lMap.add(map);
  3645 + }
  3646 + }
  3647 + }
  3648 +
  3649 + Collections.sort(lMap, new AccountXlbm());
  3650 + Map<String, Object> map = new HashMap<String, Object>();
  3651 + map.put("xlBm", "hj");
  3652 + map.put("xlName", "合计");
  3653 + map.put("fgsBm", "");
  3654 + map.put("fgsName", "");
  3655 + map.put("gsBm", "");
  3656 + double jhyygl = culateService.culateJhgl(list);//计划营运公里
  3657 + double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)
  3658 + map.put("jhlc", jhyygl);
  3659 + map.put("jcclc", jhjcclc);
  3660 + map.put("jhzlc", Arith.add(jhyygl, jhjcclc));
  3661 +
  3662 + double ljgl = culateService.culateLjgl(list_s);
  3663 + double sjyygl = culateService.culateSjgl(list_s);
  3664 + double zyygl = Arith.add(sjyygl, ljgl);
  3665 + double ljks=culateService.culateLjksgl(list_s);
  3666 + map.put("ljks", ljks);
  3667 + double sjjccgl = culateService.culateJccgl(list_s);
  3668 + double sjksgl = culateService.culateKsgl(list_s);
  3669 + double zksgl = Arith.add(sjjccgl, sjksgl);
  3670 + map.put("sjzgl", Arith.add(zyygl, zksgl));
  3671 + map.put("sjgl", zyygl);
  3672 + map.put("sjksgl", zksgl);
  3673 +
  3674 + double ssgl = culateService.culateLbgl(list);
  3675 + map.put("ssgl", ssgl);
  3676 + //计划+临加-少驶=实驶
  3677 + double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl);
  3678 + if (jl == zyygl) {
  3679 + map.put("zt", 0);
  3680 + } else {
  3681 + map.put("zt", 1);
  3682 + }
  3683 + map.put("ssgl_lz", culateService.culateCJLC(list, "路阻"));
  3684 + map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢"));
  3685 + map.put("ssgl_gz", culateService.culateCJLC(list, "故障"));
  3686 + map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷"));
  3687 + map.put("ssgl_zs", culateService.culateCJLC(list, "肇事"));
  3688 + map.put("ssgl_qr", culateService.culateCJLC(list, "缺人"));
  3689 + map.put("ssgl_qc", culateService.culateCJLC(list, "缺车"));
  3690 + map.put("ssgl_kx", culateService.culateCJLC(list, "客稀"));
  3691 + map.put("ssgl_qh", culateService.culateCJLC(list, "气候"));
  3692 + map.put("ssgl_yw", culateService.culateCJLC(list, "援外"));
  3693 + map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚"));
  3694 + double ssgl_pc = culateService.culateCJLC(list, "配车");
  3695 + double ssgl_by = culateService.culateCJLC(list, "保养");
  3696 + double ssgl_cj = culateService.culateCJLC(list, "抽减");
  3697 + double ssgl_qt = culateService.culateCJLC(list, "其他");
  3698 + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));
  3699 +
  3700 + map.put("ssbc", culateService.culateLbbc(list));
  3701 + map.put("ljgl", ljgl);
  3702 + map.put("jhbc", culateService.culateJhbc(list, ""));
  3703 + map.put("jhbc_m", culateService.culateJhbc(list, "zgf"));
  3704 + map.put("jhbc_a", culateService.culateJhbc(list, "wgf"));
  3705 + map.put("sjbc", culateService.culateSjbc(list_s, ""));
  3706 + map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf"));
  3707 + map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf"));
  3708 + map.put("ljbc", culateService.culateLjbc(list_s, ""));
  3709 + map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf"));
  3710 + map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf"));
  3711 + map.put("fzbc", culateService.culateFzbc(list_s, ""));
  3712 + map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf"));
  3713 + map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf"));
  3714 + map.put("dtbc", 0);
  3715 + map.put("dtbc_m", 0);
  3716 + map.put("dtbc_a", 0);
  3717 + if (list.size() > 0) {
  3718 + int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0;
  3719 + for (Map<String, Object> m : lMap) {
  3720 + if (m.containsKey("djg") && m.get("djg") != null)
  3721 + djg += Integer.valueOf(m.get("djg").toString());
  3722 + if (m.containsKey("djg_m") && m.get("djg_m") != null)
  3723 + djg_m += Integer.valueOf(m.get("djg_m").toString());
  3724 + if (m.containsKey("djg_a") && m.get("djg_a") != null)
  3725 + djg_a += Integer.valueOf(m.get("djg_a").toString());
  3726 + if (m.containsKey("djg_time") && m.get("djg_time") != null) {
  3727 + int t = Integer.valueOf(m.get("djg_time").toString());
  3728 + if (t > djg_time)
  3729 + djg_time = t;
  3730 + }
  3731 + }
  3732 + map.put("djg", djg);
  3733 + map.put("djg_m", djg_m);
  3734 + map.put("djg_a", djg_a);
  3735 + map.put("djg_time", djg_time);
  3736 + } else {
  3737 + map.put("djg", "0");
  3738 + map.put("djg_m", "0");
  3739 + map.put("djg_a", "0");
  3740 + map.put("djg_time", "0");
  3741 + }
  3742 + lMap.add(map);
  3743 + return lMap;
  3744 + }
  3745 +
  3746 + @Override
  3747 + public Map<String, Object> scheduleDaily(String line, String date) {
  3748 + Map<String, String> tempMap = null;
  3749 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  3750 + Map<String, Object> map = new HashMap<String, Object>();
  3751 + Double jhlc = 0.00;
  3752 + Float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f,
  3753 + ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_ljpm = 0f,
  3754 + ssgl_other = 0f, ljgl = 0f;
  3755 + int jhbc = 0;
  3756 + for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) {
  3757 + if (scheduleRealInfo != null) {
  3758 + //计算里程(包括子任务)
  3759 + jhlc += scheduleRealInfo.getJhlc();
  3760 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  3761 + if (!childTaskPlans.isEmpty()) {
  3762 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  3763 + while (it.hasNext()) {
  3764 + ChildTaskPlan childTaskPlan = it.next();
  3765 + //是否烂班,烂班就是少驶
  3766 + if (!childTaskPlan.isDestroy()) {
  3767 + sjgl += childTaskPlan.getMileage();
  3768 + } else {
  3769 + ssgl += childTaskPlan.getMileage();
  3770 + if (childTaskPlan.getDestroyReason().equals("路阻")) {
  3771 + ssgl_lz += childTaskPlan.getMileage();
  3772 + } else if (childTaskPlan.getDestroyReason().equals("吊慢")) {
  3773 + ssgl_dm += childTaskPlan.getMileage();
  3774 + } else if (childTaskPlan.getDestroyReason().equals("故障")) {
  3775 + ssgl_gz += childTaskPlan.getMileage();
  3776 + } else if (childTaskPlan.getDestroyReason().equals("纠纷")) {
  3777 + ssgl_jf += childTaskPlan.getMileage();
  3778 + } else if (childTaskPlan.getDestroyReason().equals("肇事")) {
  3779 + ssgl_zs += childTaskPlan.getMileage();
  3780 + } else if (childTaskPlan.getDestroyReason().equals("缺人")) {
  3781 + ssgl_qr += childTaskPlan.getMileage();
  3782 + } else if (childTaskPlan.getDestroyReason().equals("缺车")) {
  3783 + ssgl_qc += childTaskPlan.getMileage();
  3784 + } else if (childTaskPlan.getDestroyReason().equals("客稀")) {
  3785 + ssgl_kx += childTaskPlan.getMileage();
  3786 + } else if (childTaskPlan.getDestroyReason().equals("气候")) {
  3787 + ssgl_qh += childTaskPlan.getMileage();
  3788 + } else if (childTaskPlan.getDestroyReason().equals("援外")) {
  3789 + ssgl_yw += childTaskPlan.getMileage();
  3790 + } else if (childTaskPlan.getDestroyReason().equals("路救抛锚")) {
  3791 + ssgl_ljpm += childTaskPlan.getMileage();
  3792 + } else {
  3793 + ssgl_other += childTaskPlan.getMileage();
  3794 + }
  3795 + }
  3796 + //临加公里
  3797 + if (childTaskPlan.getType1().equals("临加")) {
  3798 + ljgl += childTaskPlan.getMileage();
  3799 + }
  3800 + }
  3801 + }
  3802 + //班次
  3803 + scheduleRealInfo.getFcsjT();
  3804 + scheduleRealInfo.getFcsjActualTime();
  3805 + }
  3806 + }
  3807 + map.put("jhlc", jhlc);
  3808 + map.put("sjgl", sjgl);
  3809 + map.put("ssgl", ssgl);
  3810 + map.put("ssgl_lz", ssgl_lz);
  3811 + map.put("ssgl_dm", ssgl_dm);
  3812 + map.put("ssgl_gz", ssgl_gz);
  3813 + map.put("ssgl_jf", ssgl_jf);
  3814 + map.put("ssgl_zs", ssgl_zs);
  3815 + map.put("ssgl_qr", ssgl_qr);
  3816 + map.put("ssgl_qc", ssgl_qc);
  3817 + map.put("ssgl_kx", ssgl_kx);
  3818 + map.put("ssgl_qh", ssgl_qh);
  3819 + map.put("ssgl_yw", ssgl_yw);
  3820 + map.put("ssgl_ljpm", ssgl_ljpm);
  3821 + map.put("ssgl_other", ssgl_other);
  3822 + map.put("ljgl", ljgl);
  3823 +
  3824 + map.put("jhbc", scheduleRealInfos.size());
  3825 + return null;
  3826 + }
  3827 +
  3828 + @Override
  3829 + public int countByLineCodeAndDate(String xlBm, String schDate) {
  3830 + return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate);
  3831 + }
  3832 +
  3833 + @Override
  3834 + public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) {
  3835 + return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate);
  3836 + }
  3837 +
  3838 + @Override
  3839 + public void deleteByLineCodeAndDate(String xlBm, String schDate) {
  3840 + scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate);
  3841 + }
  3842 +
  3843 + @Override
  3844 + public Long getMaxId() {
  3845 + return scheduleRealInfoRepository.getMaxId();
  3846 + }
  3847 +
  3848 + @Override
  3849 + public List<ScheduleRealInfo> realScheduleList(String line, String date) {
  3850 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  3851 + String lpName = "lpName";
  3852 + String zdsj = "";
  3853 + String zdsjActual = "";
  3854 + String zdsj1 = "";
  3855 + String zdsjActual1 = "";
  3856 + List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date);
  3857 +
  3858 + /*
  3859 + * 对计划发车时间相同的班次进行排序 out最前 in最后
  3860 + */
  3861 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  3862 + SimpleDateFormat sdfnyr =new SimpleDateFormat("yyyy-MM-dd");
  3863 + String minfcsj = "02:00";
  3864 + List<Line> lineList = lineRepository.findLineByCode(line);
  3865 + if (lineList.size() > 0) {
  3866 + String sqlMinYysj = "select start_opt from bsth_c_line_config where "
  3867 + + " id = ("
  3868 + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"
  3869 + + ")";
  3870 + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  3871 + }
  3872 + String[] minSjs = minfcsj.split(":");
  3873 + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);
  3874 + for (int i = 0; i < listInfo.size(); i++) {
  3875 + ScheduleRealInfo s = listInfo.get(i);
  3876 + if (s.getBcType().equals("out")) {
  3877 + s.setRemark("1");
  3878 + } else if (s.getBcType().equals("in")) {
  3879 + s.setRemark("3");
  3880 + } else {
  3881 + s.setRemark("2");
  3882 + }
  3883 + String[] fcsj = s.getFcsj().split(":");
  3884 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  3885 +
  3886 + Long fscjT = 0L;
  3887 + if (fcsjL < minSj) {
  3888 + Calendar calendar = new GregorianCalendar();
  3889 + calendar.setTime(s.getScheduleDate());
  3890 + calendar.add(calendar.DATE, 1);
  3891 + Date date_sch= calendar.getTime();
  3892 + try {
  3893 + fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime();
  3894 + } catch (ParseException e) {
  3895 + // TODO Auto-generated catch block
  3896 + e.printStackTrace();
  3897 + }
  3898 +
  3899 + } else {
  3900 + try {
  3901 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  3902 + } catch (ParseException e) {
  3903 + // TODO Auto-generated catch block
  3904 + e.printStackTrace();
  3905 + };
  3906 + }
  3907 + s.setFcsjT(fscjT);
  3908 + }
  3909 + List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>();
  3910 + listInfo2.addAll(listInfo);
  3911 + Collections.sort(listInfo, new compareLpFcsjType());
  3912 + Collections.sort(listInfo2,new compareDirLpFcsjType());
  3913 + for (int i = 0; i < listInfo.size(); i++) {
  3914 + ScheduleRealInfo t = listInfo.get(i);
  3915 + if (!lpName.equals(t.getLpName())) {
  3916 + zdsjActual = t.getZdsjActual();
  3917 + zdsj = t.getZdsj();
  3918 + t.setZdsjActual("");
  3919 + t.setZdsj("");
  3920 + } else {
  3921 + zdsj1 = t.getZdsj();
  3922 + zdsjActual1 = t.getZdsjActual();
  3923 + t.setZdsjActual(zdsjActual);
  3924 + t.setZdsj(zdsj);
  3925 + zdsj = zdsj1;
  3926 + zdsjActual = zdsjActual1;
  3927 + }
  3928 + lpName = t.getLpName();
  3929 + list.add(t);
  3930 + }
  3931 +/*
  3932 + List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleDdrb2(line, date);
  3933 + for (int i = 0; i < listInfo2.size(); i++) {
  3934 + ScheduleRealInfo s = listInfo2.get(i);
  3935 + if (s.getBcType().equals("out")) {
  3936 + s.setRemark("1");
  3937 + } else if (s.getBcType().equals("in")) {
  3938 + s.setRemark("3");
  3939 + } else {
  3940 + s.setRemark("2");
  3941 + }
  3942 + String[] fcsj = s.getFcsj().split(":");
  3943 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  3944 +
  3945 + Long fscjT = 0L;
  3946 + if (fcsjL < minSj) {
  3947 + Calendar calendar = new GregorianCalendar();
  3948 + calendar.setTime(s.getScheduleDate());
  3949 + calendar.add(calendar.DATE, 1);
  3950 + s.setScheduleDate(calendar.getTime());
  3951 + try {
  3952 + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();
  3953 + } catch (ParseException e) {
  3954 + // TODO Auto-generated catch block
  3955 + e.printStackTrace();
  3956 + }
  3957 +
  3958 + } else {
  3959 + try {
  3960 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  3961 + } catch (ParseException e) {
  3962 + // TODO Auto-generated catch block
  3963 + e.printStackTrace();
  3964 + }
  3965 + ;
  3966 + }
  3967 + s.setFcsjT(fscjT);
  3968 + }*/
  3969 + List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();
  3970 + List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();
  3971 + List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();
  3972 + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();
  3973 + if (listInfo2.size() > 0) {
  3974 + int a = listInfo2.size() % 3;
  3975 + int b = listInfo2.size() / 3;
  3976 + int x = 0, y = 0;
  3977 + if (a == 2) {
  3978 + x = b + 1;
  3979 + y = x * 2;
  3980 + } else if (a == 1) {
  3981 + x = b + 1;
  3982 + y = x * 2 - 1;
  3983 + } else {
  3984 + x = b;
  3985 + y = 2 * x;
  3986 +
  3987 + }
  3988 + for (int i = 0; i < listInfo2.size(); i++) {
  3989 + ScheduleRealInfo s = listInfo2.get(i);
  3990 + if (i + 1 <= x) {
  3991 + xList.add(s);
  3992 + } else if ((i + 1) > x && (i + 1) <= y) {
  3993 + yList.add(s);
  3994 + } else {
  3995 + zList.add(s);
  3996 + }
  3997 + }
  3998 + for (int i = 0; i < x; i++) {
  3999 + newList.add(xList.get(i));
  4000 + if (yList.size() > i) {
  4001 + newList.add(yList.get(i));
  4002 + } else {
  4003 + newList.add(new ScheduleRealInfo());
  4004 + }
  4005 + if (zList.size() > i) {
  4006 + newList.add(zList.get(i));
  4007 + } else {
  4008 + newList.add(new ScheduleRealInfo());
  4009 + }
  4010 +
  4011 + }
  4012 + }
  4013 + for (int i = 0; i < newList.size(); i++) {
  4014 + ScheduleRealInfo t1 = newList.get(i);
  4015 + for (int j = 0; j < list.size(); j++) {
  4016 + ScheduleRealInfo t2 = list.get(j);
  4017 + if (t1.getId() == t2.getId()) {
  4018 + t1 = t2;
  4019 + }
  4020 + }
  4021 + }
  4022 +
  4023 + for (int i = 0; i < newList.size(); i++) {
  4024 + ScheduleRealInfo t1 = newList.get(i);
  4025 + String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks();
  4026 + if (reamrks1.length() > 4) {
  4027 + t1.setRemarks(reamrks1.substring(0, 4));
  4028 + t1.setRemark(reamrks1);
  4029 + } else {
  4030 + t1.setRemark(reamrks1);
  4031 + }
  4032 + }
  4033 + return newList;
  4034 + }
  4035 +
  4036 + @Override
  4037 + public List<ScheduleRealInfo> realScheduleList_zrw(String line, String date) {
  4038 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  4039 + String lpName = "lpName";
  4040 + String zdsj = "";
  4041 + String zdsjActual = "";
  4042 + String zdsj1 = "";
  4043 + String zdsjActual1 = "";
  4044 + List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date);
  4045 +
  4046 + /*
  4047 + * 对计划发车时间相同的班次进行排序 out最前 in最后
  4048 + */
  4049 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  4050 + SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd");
  4051 +
  4052 + String minfcsj = "02:00";
  4053 + List<Line> lineList = lineRepository.findLineByCode(line);
  4054 + if (lineList.size() > 0) {
  4055 + String sqlMinYysj = "select start_opt from bsth_c_line_config where "
  4056 + + " id = ("
  4057 + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"
  4058 + + ")";
  4059 + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  4060 + }
  4061 + String[] minSjs = minfcsj.split(":");
  4062 + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);
  4063 + for (int i = 0; i < listInfo.size(); i++) {
  4064 + ScheduleRealInfo s = listInfo.get(i);
  4065 + if (s.getBcType().equals("out")) {
  4066 + s.setRemark("1");
  4067 + } else if (s.getBcType().equals("in")) {
  4068 + s.setRemark("3");
  4069 + } else {
  4070 + s.setRemark("2");
  4071 + }
  4072 + String[] fcsj = s.getFcsj().split(":");
  4073 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  4074 +
  4075 + Long fscjT = 0L;
  4076 + if (fcsjL < minSj) {
  4077 + Calendar calendar = new GregorianCalendar();
  4078 + calendar.setTime(s.getScheduleDate());
  4079 + calendar.add(calendar.DATE, 1);
  4080 + Date date_sch=calendar.getTime();
  4081 + try {
  4082 + fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime();
  4083 + } catch (ParseException e) {
  4084 + // TODO Auto-generated catch block
  4085 + e.printStackTrace();
  4086 + }
  4087 +
  4088 + } else {
  4089 + try {
  4090 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  4091 + } catch (ParseException e) {
  4092 + // TODO Auto-generated catch block
  4093 + e.printStackTrace();
  4094 + }
  4095 + ;
  4096 + }
  4097 + s.setFcsjT(fscjT);
  4098 + }
  4099 +
  4100 +// Collections.sort(listInfo, new compareLpFcsjType());
  4101 + List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>();
  4102 +
  4103 + Collections.sort(listInfo, new compareLpFcsjType());
  4104 + for (int i = 0; i < listInfo.size(); i++) {
  4105 + ScheduleRealInfo t = listInfo.get(i);
  4106 + if (!lpName.equals(t.getLpName())) {
  4107 + zdsjActual = t.getZdsjActual();
  4108 + zdsj = t.getZdsj();
  4109 + t.setZdsjActual("");
  4110 + t.setZdsj("");
  4111 + } else {
  4112 + zdsj1 = t.getZdsj();
  4113 + zdsjActual1 = t.getZdsjActual();
  4114 + t.setZdsjActual(zdsjActual);
  4115 + t.setZdsj(zdsj);
  4116 + zdsj = zdsj1;
  4117 + zdsjActual = zdsjActual1;
  4118 + }
  4119 +
  4120 +
  4121 +
  4122 + lpName = t.getLpName();
  4123 + listInfo2.add(t);
  4124 +
  4125 + }
  4126 +
  4127 + Collections.sort(listInfo2,new compareDirLpFcsjType());
  4128 + for (int i = 0; i < listInfo2.size(); i++) {
  4129 + ScheduleRealInfo t=listInfo2.get(i);
  4130 + list.add(t);
  4131 + Set<ChildTaskPlan> childTaskPlans = t.getcTasks();
  4132 + //计算营运里程,空驶里程
  4133 + if (!childTaskPlans.isEmpty()) {
  4134 + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);
  4135 + Collections.sort(listit, new ComparableChild());
  4136 + for (int j = 0; j < listit.size(); j++) {
  4137 + ScheduleRealInfo s = new ScheduleRealInfo();
  4138 + ChildTaskPlan childTaskPlan = listit.get(j);
  4139 + if (childTaskPlan.getCcId() == null) {
  4140 + if (childTaskPlan.isDestroy()) {
  4141 + s.setFcsjActual("");
  4142 + s.setZdsjActual("");
  4143 + } else {
  4144 + s.setFcsjActual(childTaskPlan.getStartDate());
  4145 + s.setZdsjActual("");
  4146 + s.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));
  4147 + }
  4148 + s.setFcsj(childTaskPlan.getStartDate());
  4149 + s.setZdsj("");
  4150 + s.setQdzName(childTaskPlan.getStartStationName());
  4151 + s.setZdzName(childTaskPlan.getEndStationName());
  4152 + s.setRemarks(childTaskPlan.getRemarks());
  4153 + s.setAdjustExps("子");
  4154 + s.setLpName("");
  4155 + list.add(s);
  4156 + }
  4157 + }
  4158 + }
  4159 + }
  4160 + List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();
  4161 + List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();
  4162 + List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();
  4163 + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();
  4164 + if (list.size() > 0) {
  4165 + int a = list.size() % 3;
  4166 + int b = list.size() / 3;
  4167 + int x = 0, y = 0;
  4168 + if (a == 2) {
  4169 + x = b + 1;
  4170 + y = x * 2;
  4171 + } else if (a == 1) {
  4172 + x = b + 1;
  4173 + y = x * 2 - 1;
  4174 + } else {
  4175 + x = b;
  4176 + y = 2 * x;
  4177 +
  4178 + }
  4179 + for (int i = 0; i < list.size(); i++) {
  4180 + ScheduleRealInfo s = list.get(i);
  4181 + if (i + 1 <= x) {
  4182 + xList.add(s);
  4183 + } else if ((i + 1) > x && (i + 1) <= y) {
  4184 + yList.add(s);
  4185 + } else {
  4186 + zList.add(s);
  4187 + }
  4188 + }
  4189 + for (int i = 0; i < x; i++) {
  4190 + newList.add(xList.get(i));
  4191 + if (yList.size() > i) {
  4192 + newList.add(yList.get(i));
  4193 + } else {
  4194 + newList.add(new ScheduleRealInfo());
  4195 + }
  4196 + if (zList.size() > i) {
  4197 + newList.add(zList.get(i));
  4198 + } else {
  4199 + newList.add(new ScheduleRealInfo());
  4200 + }
  4201 +
  4202 + }
  4203 + }
  4204 + /* for (int i = 0; i < newList.size(); i++) {
  4205 + ScheduleRealInfo t1 = newList.get(i);
  4206 + for (int j = 0; j < list.size(); j++) {
  4207 + ScheduleRealInfo t2 = list.get(j);
  4208 + if (t1.getId() == t2.getId()) {
  4209 + t1 = t2;
  4210 + }
  4211 + }
  4212 + }*/
  4213 +
  4214 + for (int i = 0; i < newList.size(); i++) {
  4215 + ScheduleRealInfo t1 = newList.get(i);
  4216 + String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks();
  4217 + if (reamrks1.length() > 4) {
  4218 + t1.setRemarks(reamrks1.substring(0, 4));
  4219 + t1.setRemark(reamrks1);
  4220 + } else {
  4221 + t1.setRemark(reamrks1);
  4222 + }
  4223 + }
  4224 + return newList;
  4225 + }
  4226 +
  4227 + @Override
  4228 + public List<ScheduleRealInfo> realScheduleList_mh_2(String line, String date) {
  4229 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  4230 + String lpName = "lpName";
  4231 + String zdsj = "";
  4232 + String zdsjActual = "";
  4233 + String zdsj1 = "";
  4234 + String zdsjActual1 = "";
  4235 + List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date);
  4236 +
  4237 + for (ScheduleRealInfo s : listInfo) {
  4238 + if (s.isDestroy() && s.isReissue()) {
  4239 + s.setRemark("");
  4240 + s.setFcsjActual(s.getDfsj());
  4241 + s.setZdsjActual(s.getZdsj());
  4242 + s.setStatus(2);
  4243 + s.setJhlc(s.getJhlcOrig());
  4244 + }
  4245 + }
  4246 +
  4247 + for (int i = 0; i < listInfo.size(); i++) {
  4248 + ScheduleRealInfo t = listInfo.get(i);
  4249 + if (!lpName.equals(t.getLpName())) {
  4250 + zdsjActual = t.getZdsjActual();
  4251 + zdsj = t.getZdsj();
  4252 + t.setZdsjActual("");
  4253 + t.setZdsj("");
  4254 + } else {
  4255 + zdsj1 = t.getZdsj();
  4256 + zdsjActual1 = t.getZdsjActual();
  4257 + t.setZdsjActual(zdsjActual);
  4258 + t.setZdsj(zdsj);
  4259 + zdsj = zdsj1;
  4260 + zdsjActual = zdsjActual1;
  4261 + }
  4262 + lpName = t.getLpName();
  4263 + list.add(t);
  4264 + }
  4265 +
  4266 + List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleByDateAndLineQp2(line, date);
  4267 + List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();
  4268 + List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();
  4269 + List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();
  4270 + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();
  4271 + if (listInfo2.size() > 0) {
  4272 + int a = listInfo2.size() % 3;
  4273 + int b = listInfo2.size() / 3;
  4274 + int x = 0, y = 0;
  4275 + if (a == 2) {
  4276 + x = b + 1;
  4277 + y = x * 2;
  4278 + } else if (b == 1) {
  4279 + x = b + 1;
  4280 + y = x * 2 - 1;
  4281 + } else {
  4282 + x = b;
  4283 + y = 2 * x;
  4284 +
  4285 + }
  4286 + for (int i = 0; i < listInfo2.size(); i++) {
  4287 + ScheduleRealInfo s = listInfo2.get(i);
  4288 + if (i + 1 <= x) {
  4289 + xList.add(s);
  4290 + } else if ((i + 1) > x && (i + 1) <= y) {
  4291 + yList.add(s);
  4292 + } else {
  4293 + zList.add(s);
  4294 + }
  4295 + }
  4296 + for (int i = 0; i < x; i++) {
  4297 + newList.add(xList.get(i));
  4298 + if (yList.size() > i) {
  4299 + newList.add(yList.get(i));
  4300 + } else {
  4301 + newList.add(new ScheduleRealInfo());
  4302 + }
  4303 + if (zList.size() > i) {
  4304 + newList.add(zList.get(i));
  4305 + } else {
  4306 + newList.add(new ScheduleRealInfo());
  4307 + }
  4308 +
  4309 + }
  4310 + }
  4311 + for (int i = 0; i < newList.size(); i++) {
  4312 + ScheduleRealInfo t1 = newList.get(i);
  4313 + for (int j = 0; j < list.size(); j++) {
  4314 + ScheduleRealInfo t2 = list.get(j);
  4315 + if (t1.getId() == t2.getId()) {
  4316 + t1 = t2;
  4317 + }
  4318 + }
  4319 + }
  4320 + return newList;
  4321 + }
  4322 +
  4323 + @Override
  4324 + public List<ScheduleRealInfo> realScheduleListQp(String line, String date) {
  4325 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  4326 + String lpName = "lpName";
  4327 + String zdsj = "";
  4328 + String zdsjActual = "";
  4329 + String zdsj1 = "";
  4330 + String zdsjActual1 = "";
  4331 + List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date);
  4332 + for (int i = 0; i < listInfo.size(); i++) {
  4333 + ScheduleRealInfo t = listInfo.get(i);
  4334 + if (!lpName.equals(t.getLpName())) {
  4335 + zdsjActual = t.getZdsjActual();
  4336 + zdsj = t.getZdsj();
  4337 + t.setZdsjActual("");
  4338 + t.setZdsj("");
  4339 + } else {
  4340 + zdsj1 = t.getZdsj();
  4341 + zdsjActual1 = t.getZdsjActual();
  4342 + t.setZdsjActual(zdsjActual);
  4343 + t.setZdsj(zdsj);
  4344 + zdsj = zdsj1;
  4345 + zdsjActual = zdsjActual1;
  4346 + }
  4347 +
  4348 + lpName = t.getLpName();
  4349 + list.add(t);
  4350 + }
  4351 + return list;
  4352 + }
  4353 +
  4354 + public List<Map<String, Object>> yesterdayDataList(String line, String date, String gsbm, String fgsbm, String jGh, String nbbm) {
  4355 + List<Map<String, Object>> yesterdayDataList = new ArrayList<Map<String, Object>>();
  4356 + if (line.equals("")) {
  4357 + yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date, gsbm, fgsbm, nbbm);
  4358 + } else {
  4359 + yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList_eq(line, date, gsbm, fgsbm, nbbm);
  4360 + }
  4361 + List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date, gsbm, fgsbm);
  4362 + for (int x = 0; x < yesterdayDataList.size(); x++) {
  4363 + String jsy = yesterdayDataList.get(x).get("jGh").toString();
  4364 + String clZbh = yesterdayDataList.get(x).get("clZbh").toString();
  4365 + String xlbm = yesterdayDataList.get(x).get("xlBm").toString();
  4366 + String lp = yesterdayDataList.get(x).get("lpName").toString();
  4367 + String realExecDate=yesterdayDataList.get(x).get("realExecDate").toString();
  4368 + String fcsj[] =realExecDate.split(" ");
  4369 + //取出最小计划发车时间
  4370 + yesterdayDataList.get(x).put("fcsj", fcsj[1]);
  4371 + Map<String, Object> map = new HashMap<String, Object>();
  4372 + boolean fage = true;
  4373 + String company = "";
  4374 + String bCompany = "";
  4375 + String lineName="";
  4376 + String jName="";
  4377 + List<ScheduleRealInfo> listS = new ArrayList<ScheduleRealInfo>();
  4378 + for (ScheduleRealInfo scheduleRealInfo : lists) {
  4379 + if (scheduleRealInfo.getjGh().equals(jsy)
  4380 + && scheduleRealInfo.getClZbh().equals(clZbh)
  4381 + && scheduleRealInfo.getXlBm().equals(xlbm)
  4382 + && scheduleRealInfo.getLpName().equals(lp)) {
  4383 + if (fage) {
  4384 + //根据线路代码获取公司
  4385 + company = scheduleRealInfo.getGsBm();
  4386 + bCompany = scheduleRealInfo.getFgsBm();
  4387 + lineName = scheduleRealInfo.getXlName();
  4388 + jName= scheduleRealInfo.getjName();
  4389 + fage = false;
  4390 + }
  4391 + Set<ChildTaskPlan> cts = scheduleRealInfo.getcTasks();
  4392 + if (cts != null && cts.size() > 0) {
  4393 + listS.add(scheduleRealInfo);
  4394 + } else {
  4395 + if (scheduleRealInfo.getZdsjActual() != null && scheduleRealInfo.getFcsjActual() != null) {
  4396 + listS.add(scheduleRealInfo);
  4397 + }
  4398 + }
  4399 + }
  4400 + }
  4401 + yesterdayDataList.get(x).put("company", company);
  4402 + yesterdayDataList.get(x).put("bCompany", bCompany);
  4403 + yesterdayDataList.get(x).put("lineName", lineName);
  4404 + yesterdayDataList.get(x).put("jName", jName);
  4405 + Double ljgl = culateMieageService.culateLjgl(listS);
  4406 + Double sjgl = culateMieageService.culateSjgl(listS);
  4407 + Double ksgl = culateMieageService.culateKsgl(listS);
  4408 + Double jccgl = culateMieageService.culateJccgl(listS);
  4409 + Double zyygl = Arith.add(sjgl, ljgl);
  4410 + Double zksgl = Arith.add(ksgl, jccgl);
  4411 + Double zlc = Arith.add(zyygl, zksgl);
  4412 + yesterdayDataList.get(x).put("totalKilometers", zlc);
  4413 +
  4414 + }
  4415 + //增加顺序号
  4416 + for (int i = 0; i < yesterdayDataList.size(); i++) {
  4417 + if (i == 0) {
  4418 + yesterdayDataList.get(i).put("seqNumber", 1);
  4419 + } else {
  4420 + if (yesterdayDataList.get(i - 1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))) {
  4421 + yesterdayDataList.get(i).put("seqNumber", 1 + (int) yesterdayDataList.get(i - 1).get("seqNumber"));
  4422 + } else {
  4423 + yesterdayDataList.get(i).put("seqNumber", 1);
  4424 + }
  4425 + }
  4426 + }
  4427 +
  4428 + return yesterdayDataList;
  4429 + }
  4430 +
  4431 + /**
  4432 + * 批量调整人车
  4433 + */
  4434 + @Override
  4435 + public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs, String userId) {
  4436 + Map<String, Object> rs = new HashMap<>();
  4437 + Set<ScheduleRealInfo> set = new HashSet<>();
  4438 +
  4439 + ScheduleRealInfo sch;
  4440 +
  4441 + String jGh = null, jName, sGh, sName;
  4442 + for (ChangePersonCar cpc : cpcs) {
  4443 +
  4444 + sch = dayOfSchedule.get(cpc.getSchId());
  4445 + if (sch == null)
  4446 + continue;
  4447 +
  4448 + if (cpc.getClZbh() != null) {
  4449 + if (!carExist(sch.getGsBm(), cpc.getClZbh())) {
  4450 + rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");
  4451 + rs.put("status", ResponseCode.ERROR);
  4452 + return rs;
  4453 + } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(cpc.getClZbh()))) {
  4454 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + cpc.getClZbh() + "】的车辆");
  4455 + rs.put("status", ResponseCode.ERROR);
  4456 + return rs;
  4457 + }
  4458 + }
  4459 +
  4460 + if (StringUtils.isNotEmpty(cpc.getJsy())) {
  4461 + try{
  4462 + jGh = cpc.getJsy().split("/")[0];
  4463 + }catch (Exception e){
  4464 + logger.error("", e);
  4465 + rs.put("msg", "驾驶员参数异常!!");
  4466 + rs.put("status", ResponseCode.ERROR);
  4467 + return rs;
  4468 + }
  4469 +
  4470 + jName = getPersonName(sch.getGsBm(), jGh);
  4471 + if (StringUtils.isEmpty(jName)) {
  4472 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员");
  4473 + rs.put("status", ResponseCode.ERROR);
  4474 + return rs;
  4475 + }
  4476 + }
  4477 +
  4478 +
  4479 + //为换人换车情况表写入数据
  4480 + schModifyLog.saveChangetochange(sch, cpc, userId);
  4481 + //日志记录
  4482 + ScheduleModifyLogger.tzrc(sch, cpc, userId);
  4483 +
  4484 + //换驾驶员
  4485 + if (StringUtils.isNotEmpty(cpc.getJsy())) {
  4486 + //换驾驶员
  4487 + if (persoChange(sch, jGh))
  4488 + set.add(sch);
  4489 + }
  4490 +
  4491 + //换售票员
  4492 + if (StringUtils.isNotEmpty(cpc.getSpy())
  4493 + && !"/".equals(StringUtils.trim(cpc.getSpy()))) {
  4494 +
  4495 + sGh = cpc.getSpy().split("/")[0];
  4496 + sName = getPersonName(sch.getGsBm(), sGh);
  4497 + if (StringUtils.isEmpty(sName)) {
  4498 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员");
  4499 + rs.put("status", ResponseCode.ERROR);
  4500 + return rs;
  4501 + }
  4502 +
  4503 + /*if(!sGh.equals(sch.getsGh()))
  4504 + sb.append(sch.getsGh() + " 换 " + sGh + ";");*/
  4505 + if (persoChangeSPY(sch, sGh))
  4506 + set.add(sch);
  4507 + } else if (StringUtils.isNotEmpty(sch.getsGh())) {
  4508 + sch.setsGh("");
  4509 + sch.setsName("");
  4510 + }
  4511 +
  4512 + //换车
  4513 + if (StringUtils.isNotEmpty(cpc.getClZbh()) && !cpc.getClZbh().equals(sch.getClZbh())) {
  4514 + //sb.append(sch.getClZbh() + " 换 " + cpc.getClZbh() + ";");
  4515 + set.add(sch);
  4516 + set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh()));
  4517 + }
  4518 +
  4519 + /*if(sb.length() > 0)
  4520 + sch.setRemarks(sb.toString());*/
  4521 +
  4522 + dayOfSchedule.save(sch);
  4523 + set.add(sch);
  4524 +
  4525 + }
  4526 + rs.put("ts", set);
  4527 + rs.put("status", ResponseCode.SUCCESS);
  4528 + return rs;
  4529 + }
  4530 +
  4531 + /**
  4532 + * @Title: persoChange
  4533 + * @Description: TODO(班次换驾驶员)
  4534 + */
  4535 + public boolean persoChange(ScheduleRealInfo sch, String jGh) {
  4536 + if (sch.getjGh().equals(jGh))
  4537 + return false;
  4538 + String jName = getPersonName(sch.getGsBm(), jGh);
  4539 + if (StringUtils.isNotEmpty(jName)) {
  4540 +
  4541 + if (jGh.indexOf("-") != -1)
  4542 + sch.setjGh(jGh.substring(jGh.indexOf("-") + 1));
  4543 + else
  4544 + sch.setjGh(jGh);
  4545 +
  4546 + sch.setjName(jName);
  4547 + return true;
  4548 + }
  4549 + return false;
  4550 + }
  4551 +
  4552 + /**
  4553 + * @Title: persoChange
  4554 + * @Description: TODO(班次换售票员)
  4555 + */
  4556 + public boolean persoChangeSPY(ScheduleRealInfo sch, String sGh) {
  4557 + if (sch.getsGh().equals(sGh))
  4558 + return false;
  4559 + String sName = getPersonName(sch.getGsBm(), sGh);
  4560 + if (StringUtils.isNotEmpty(sName)) {
  4561 + if (sGh.indexOf("-") != -1)
  4562 + sch.setsGh(sGh.substring(sGh.indexOf("-") + 1));
  4563 + else
  4564 + sch.setsGh(sGh);
  4565 + sch.setsName(sName);
  4566 + return true;
  4567 + }
  4568 + return false;
  4569 + }
  4570 +
  4571 + /**
  4572 + * 批量待发调整
  4573 + */
  4574 + @Override
  4575 + public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) {
  4576 + Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>();
  4577 + List<ScheduleRealInfo> list = new ArrayList<>();
  4578 +
  4579 + for (DfsjChange dc : dfsjcs) {
  4580 + if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))
  4581 + continue;
  4582 +
  4583 + tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null, "2", null);
  4584 +
  4585 + if (tempMap.get("status").equals(ResponseCode.SUCCESS)) {
  4586 + list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts"));
  4587 + }
  4588 + }
  4589 +
  4590 + rs.put("status", ResponseCode.SUCCESS);
  4591 + rs.put("ts", list);
  4592 + return rs;
  4593 + }
  4594 +
  4595 +
  4596 + @Override
  4597 + public Map<String, Object> findKMBC1(String jName, String clZbh,
  4598 + String date, String enddate) {
  4599 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate);
  4600 + DecimalFormat format = new DecimalFormat("0.00");
  4601 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  4602 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  4603 + int jhbc = 0, cjbc = 0, ljbc = 0;
  4604 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;
  4605 + float addMileage = 0l, remMileage = 0l;
  4606 + Map<String, Object> map = new HashMap<String, Object>();
  4607 + for (ScheduleRealInfo scheduleRealInfo : list) {
  4608 + if (scheduleRealInfo != null) {
  4609 + //计划里程(主任务过滤掉临加班次),
  4610 + //烂班里程(主任务烂班),
  4611 + //临加里程(主任务临加),
  4612 + //计划班次,烂班班次,增加班次
  4613 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  4614 + if (scheduleRealInfo.isSflj()) {
  4615 + addMileage += tempJhlc;
  4616 + ljbc++;
  4617 + } else {
  4618 + jhlc += tempJhlc;
  4619 + jhbc++;
  4620 + if (scheduleRealInfo.getStatus() == -1) {
  4621 + remMileage += tempJhlc;
  4622 + cjbc++;
  4623 + }
  4624 + }
  4625 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  4626 + //计算营运里程,空驶里程
  4627 + if (childTaskPlans.isEmpty()) {
  4628 + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  4629 + || scheduleRealInfo.getBcType().equals("venting")) {
  4630 + ksgl += tempJhlc;
  4631 + } else {
  4632 + yygl += tempJhlc;
  4633 + }
  4634 + } else {
  4635 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  4636 + while (it.hasNext()) {
  4637 + ChildTaskPlan childTaskPlan = it.next();
  4638 + if (childTaskPlan.getMileageType().equals("empty")) {
  4639 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  4640 + } else {
  4641 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  4642 + }
  4643 + }
  4644 + }
  4645 + }
  4646 + }
  4647 + map.put("jhlc", format.format(jhlc));
  4648 + map.put("remMileage", format.format(remMileage));
  4649 + map.put("addMileage", format.format(addMileage));
  4650 + map.put("yygl", format.format(yygl));
  4651 + map.put("ksgl", format.format(ksgl));
  4652 + map.put("realMileage", format.format(yygl + ksgl));
  4653 + map.put("jhbc", jhbc);
  4654 + map.put("cjbc", cjbc);
  4655 + map.put("ljbc", ljbc);
  4656 + map.put("sjbc", jhbc - cjbc + ljbc);
  4657 + return map;
  4658 + }
  4659 +
  4660 + /**
  4661 + * 调整班次类型
  4662 + *
  4663 + * @param id
  4664 + * @param bcType
  4665 + * @param remarks
  4666 + * @return
  4667 + */
  4668 + @Override
  4669 + public Map<String, Object> changeBcType(Long id, String bcType, String remarks, String majorStationName) {
  4670 + Map<String, Object> rs = new HashMap<>();
  4671 +
  4672 + try {
  4673 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  4674 + if (sch != null) {
  4675 + sch.setBcType(bcType);
  4676 + sch.setRemarks(remarks);
  4677 + rs.put("status", ResponseCode.SUCCESS);
  4678 + rs.put("t", sch);
  4679 +
  4680 + if ("major".equals(bcType)) {
  4681 + sch.setMajorStationName(majorStationName);
  4682 + }
  4683 +
  4684 + dayOfSchedule.save(sch);
  4685 + }
  4686 + } catch (Exception e) {
  4687 + logger.error("", e);
  4688 + rs.put("status", ResponseCode.ERROR);
  4689 + }
  4690 +
  4691 + return rs;
  4692 + }
  4693 +
  4694 + @Override
  4695 + public Map<String, Object> historySave(ScheduleRealInfo sch) {
  4696 + Map<String, Object> rs = new HashMap<>();
  4697 + rs.put("status", ResponseCode.ERROR);
  4698 +
  4699 + ScheduleRealInfo oldSch = super.findById(sch.getId());
  4700 + //事后日志记录
  4701 + AfterwardsLogger aflog = AfterwardsLogger.start(oldSch, "事后调整");
  4702 +
  4703 + //换车
  4704 + if (StringUtils.isNotEmpty(sch.getClZbh()) && !oldSch.getClZbh().equals(sch.getClZbh())) {
  4705 + if (!carExist(oldSch.getGsBm(), sch.getClZbh())) {
  4706 + rs.put("msg", "车辆 " + sch.getClZbh() + " 不存在!");
  4707 + return rs;
  4708 + } else {
  4709 + aflog.log("换车", oldSch.getClZbh(), sch.getClZbh());
  4710 + oldSch.setClZbh(sch.getClZbh());
  4711 + }
  4712 + }
  4713 +
  4714 + //换驾驶员
  4715 + if (StringUtils.isNotEmpty(sch.getjGh()) && !oldSch.getjGh().equals(sch.getjGh())) {
  4716 + String jName = getPersonName(oldSch.getGsBm(), sch.getjGh());
  4717 + if (StringUtils.isEmpty(jName)) {
  4718 + rs.put("msg", oldSch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员");
  4719 + return rs;
  4720 + }
  4721 + aflog.log("换驾驶员", oldSch.getjGh() + "/" + oldSch.getjName(), sch.getjGh() + "/" + sch.getjName());
  4722 + persoChange(oldSch, sch.getjGh());
  4723 + }
  4724 +
  4725 + //换售票员
  4726 + if (StringUtils.isNotEmpty(sch.getsGh()) && !oldSch.getsGh().equals(sch.getsGh())) {
  4727 + String sName = getPersonName(oldSch.getGsBm(), sch.getsGh());
  4728 + if (StringUtils.isEmpty(sName)) {
  4729 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getsGh() + "】的售票员");
  4730 + return rs;
  4731 + }
  4732 + aflog.log("换售票员", oldSch.getsGh() + "/" + oldSch.getsName(), sch.getsGh() + "/" + sch.getsName());
  4733 + persoChangeSPY(oldSch, sch.getsGh());
  4734 + }
  4735 +
  4736 + //烂班
  4737 + boolean dest1 = oldSch.getStatus() == -1;
  4738 + boolean dest2 = sch.getStatus() == -1;
  4739 + if (!dest1 && dest2) {
  4740 + oldSch.destroy();
  4741 + aflog.log("烂班");
  4742 + } else if (dest1 && !dest2) {
  4743 + //撤销烂班
  4744 + oldSch.setJhlc(oldSch.getJhlcOrig());
  4745 + oldSch.setStatus(0);
  4746 + oldSch.calcStatus();
  4747 + oldSch.setAdjustExps(null);
  4748 + aflog.log("撤销烂班");
  4749 + }
  4750 +
  4751 + oldSch.setAdjustExps(sch.getAdjustExps());
  4752 +
  4753 + /**
  4754 + * 修改班次里程
  4755 + */
  4756 + if (!oldSch.getJhlc().equals(sch.getJhlc())) {
  4757 + double jhlcNum = sch.getJhlc();
  4758 + aflog.log("修改班次里程", oldSch.getJhlc(), jhlcNum);
  4759 + //烂班
  4760 + if (jhlcNum == 0 && oldSch.getJhlcOrig() != 0)
  4761 + oldSch.destroy();
  4762 + else {
  4763 + oldSch.setJhlc(jhlcNum);
  4764 + //临加班次,实际计划一起改
  4765 + if (oldSch.isSflj())
  4766 + oldSch.setJhlcOrig(jhlcNum);
  4767 + }
  4768 + }
  4769 +
  4770 + //待发时间
  4771 + if (!CustomStringUtils.equals(oldSch.getDfsj(), sch.getDfsj())) {
  4772 + aflog.log("修改待发时间", oldSch.getDfsj(), sch.getDfsj());
  4773 + oldSch.setDfsj(sch.getDfsj());
  4774 + }
  4775 + //实发时间
  4776 + if (!CustomStringUtils.equals(oldSch.getFcsjActual(), sch.getFcsjActual())) {
  4777 + aflog.log("修改实发时间", oldSch.getFcsjActual(), sch.getFcsjActual());
  4778 + oldSch.setFcsjActual(sch.getFcsjActual());
  4779 + }
  4780 + //实际终点
  4781 + if (!CustomStringUtils.equals(oldSch.getZdsjActual(), sch.getZdsjActual())) {
  4782 + aflog.log("修改实达时间", oldSch.getZdsjActual(), sch.getZdsjActual());
  4783 + oldSch.setZdsjActual(sch.getZdsjActual());
  4784 + }
  4785 +
  4786 + //备注
  4787 + if (!CustomStringUtils.equals(oldSch.getRemarks(), sch.getRemarks())) {
  4788 + aflog.log("修改备注", oldSch.getRemarks(), sch.getRemarks());
  4789 + oldSch.setRemarks(sch.getRemarks());
  4790 + }
  4791 +
  4792 + scheduleRealInfoRepository.save(oldSch);
  4793 +
  4794 + aflog.end();
  4795 + rs.put("status", ResponseCode.SUCCESS);
  4796 + return rs;
  4797 + }
  4798 +
  4799 + @Autowired
  4800 + SvgAttributeRepository svgAttributeRepository;
  4801 +
  4802 + @Override
  4803 + public Map<String, Object> svgAttr(String jsonStr) {
  4804 + Map<String, Object> rs = new HashMap<>();
  4805 +
  4806 + try {
  4807 + JSONObject jObj = JSONObject.parseObject(StringEscapeUtils.unescapeHtml4(jsonStr));
  4808 +
  4809 + SvgAttribute svgAttribute = new SvgAttribute();
  4810 + svgAttribute.setLineCode(jObj.getString("lineCode"));
  4811 + svgAttribute.setHideStations(jObj.getString("hideStations"));
  4812 + svgAttribute.setNicknames(jObj.getString("nicknames"));
  4813 + svgAttributeRepository.save(svgAttribute);
  4814 +
  4815 + rs.put("t", svgAttribute);
  4816 + rs.put("status", ResponseCode.SUCCESS);
  4817 + } catch (Exception e) {
  4818 + logger.error("", e);
  4819 + rs.put("status", ResponseCode.ERROR);
  4820 + }
  4821 + return rs;
  4822 + }
  4823 +
  4824 + @Override
  4825 + public Map<String, Object> findSvgAttr(String idx) {
  4826 + Map<String, Object> rs = new HashMap<>();
  4827 + try {
  4828 + List<String> lineCodes = Splitter.on(",").splitToList(idx);
  4829 + List<SvgAttribute> list = svgAttributeRepository.findSvgAttr(lineCodes);
  4830 +
  4831 + rs.put("status", ResponseCode.SUCCESS);
  4832 + rs.put("list", list);
  4833 + } catch (Exception e) {
  4834 + logger.error("", e);
  4835 + rs.put("status", ResponseCode.ERROR);
  4836 + }
  4837 + return rs;
  4838 + }
  4839 +
  4840 + @Override
  4841 + public Map<String, Object> addRemarks(Long id, String remarks) {
  4842 + Map<String, Object> rs = new HashMap<>();
  4843 + try {
  4844 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  4845 + sch.addRemarks(remarks);
  4846 +
  4847 + rs.put("status", ResponseCode.SUCCESS);
  4848 + rs.put("t", sch);
  4849 + } catch (Exception e) {
  4850 + logger.error("", e);
  4851 + rs.put("status", ResponseCode.ERROR);
  4852 + }
  4853 + return rs;
  4854 + }
  4855 +
  4856 + @Override
  4857 + public List<Map<String, Object>> yesterdayDataList(String line) {
  4858 + // TODO Auto-generated method stub
  4859 + return null;
  4860 + }
  4861 +
  4862 + @Override
  4863 + public List<ScheduleRealInfo> exportWaybillQp(String clZbh, String date, String line) {
  4864 + // TODO Auto-generated method stub
  4865 + ReportUtils ee = new ReportUtils();
  4866 + ReportRelatedUtils rru = new ReportRelatedUtils();
  4867 + List<Iterator<?>> list = new ArrayList<Iterator<?>>();
  4868 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line);
  4869 + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
  4870 +
  4871 + DecimalFormat format = new DecimalFormat("0.00");
  4872 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  4873 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  4874 + int jhbc = 0, cjbc = 0, ljbc = 0;
  4875 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0;
  4876 + float addMileage = 0l, remMileage = 0l, addgl = 0, remgl = 0;
  4877 + int xyz = 1;
  4878 + Map<String, Object> map;
  4879 + for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) {
  4880 + if (scheduleRealInfo != null) {
  4881 + //计算计划里程(主任务过滤掉临加班次),烂班里程,临加里程,计划班次,烂班班次,增加班次
  4882 + //计划里程(主任务过滤掉临加班次),
  4883 + //烂班里程(主任务烂班),
  4884 + //临加里程(主任务临加),
  4885 + //计划班次,烂班班次,增加班次
  4886 + double jh = 0, sj = 0;
  4887 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  4888 + if (scheduleRealInfo.isSflj()) {
  4889 + ljbc++;
  4890 + } else {
  4891 + if (!(scheduleRealInfo.getBcType().equals("in")
  4892 + || scheduleRealInfo.getBcType().equals("out"))) {
  4893 + jhbc++;
  4894 + jh += tempJhlc;
  4895 + }
  4896 + if (scheduleRealInfo.getStatus() == -1) {
  4897 + remMileage += tempJhlc;
  4898 + cjbc++;
  4899 + }
  4900 + }
  4901 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  4902 + //计算营运里程,空驶里程
  4903 + if (childTaskPlans.isEmpty()) {
  4904 + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  4905 + ) {
  4906 + jcclc += tempJhlc;
  4907 + } else {
  4908 + if (scheduleRealInfo.getStatus() != -1) {
  4909 + if (scheduleRealInfo.isSflj()) {
  4910 + addMileage += tempJhlc;
  4911 + }
  4912 + sj += tempJhlc;
  4913 + }
  4914 + }
  4915 + } else {
  4916 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  4917 + while (it.hasNext()) {
  4918 + ChildTaskPlan childTaskPlan = it.next();
  4919 + if (childTaskPlan.getMileageType().equals("empty")) {
  4920 + if (childTaskPlan.isDestroy()) {
  4921 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  4922 + } else {
  4923 + if (scheduleRealInfo.isSflj()) {
  4924 + addMileage += tempJhlc;
  4925 + }
  4926 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  4927 + }
  4928 + } else {
  4929 + if (childTaskPlan.isDestroy()) {
  4930 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  4931 +// cjbc++;
  4932 + } else {
  4933 + if (scheduleRealInfo.isSflj()) {
  4934 + addMileage += tempJhlc;
  4935 + }
  4936 + sj += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  4937 + }
  4938 + }
  4939 + }
  4940 + }
  4941 +
  4942 + if (!(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out"))) {
  4943 + map = new HashMap<String, Object>();
  4944 + try {
  4945 + scheduleRealInfo.setBcs(xyz);
  4946 + xyz++;
  4947 + Set<ChildTaskPlan> cs = scheduleRealInfo.getcTasks();
  4948 + Double sjlc = 0.0;
  4949 + if (!cs.isEmpty()) {
  4950 + Iterator<ChildTaskPlan> it = cs.iterator();
  4951 + while (it.hasNext()) {
  4952 + ChildTaskPlan c = it.next();
  4953 + if (!c.isDestroy()) {
  4954 + sjlc += c.getMileage() == null ? 0 : c.getMileage();
  4955 + }
  4956 +
  4957 + }
  4958 + } else {
  4959 + if (scheduleRealInfo.getStatus() != -1) {
  4960 + sjlc = scheduleRealInfo.getJhlc();
  4961 + }
  4962 + }
  4963 + scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName());
  4964 + scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName());
  4965 + scheduleRealInfo.setSjlc(format.format(sjlc));
  4966 + map = rru.getMapValue(scheduleRealInfo);
  4967 + String zdsj = scheduleRealInfo.getZdsj();
  4968 + String zdsjActual = scheduleRealInfo.getZdsjActual();
  4969 + if (zdsj != null && zdsjActual != null &&
  4970 + !zdsj.equals(zdsjActual)) {
  4971 + int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]);
  4972 + int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]);
  4973 + if (zdsj.compareTo(zdsjActual) > 0) {
  4974 + if (zdsjT - zdsjAT > 1000) {
  4975 + map.put("fast", "");
  4976 + map.put("slow", zdsjAT - zdsjT + 1440);
  4977 + } else {
  4978 + map.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  4979 + map.put("slow", "");
  4980 + }
  4981 + } else {
  4982 + if (zdsjAT - zdsjT > 1000) {
  4983 + map.put("fast", zdsjT - zdsjAT + 1440);
  4984 + map.put("slow", "");
  4985 + } else {
  4986 + map.put("fast", "");
  4987 + map.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  4988 + }
  4989 + }
  4990 + } else {
  4991 + map.put("fast", "");
  4992 + map.put("slow", "");
  4993 + }
  4994 + listMap.add(map);
  4995 + } catch (Exception e) {
  4996 + e.printStackTrace();
  4997 + }
  4998 + }
  4999 + jhlc += jh;
  5000 + yygl += sj;
  5001 + if (jh > sj) {
  5002 + remgl += jh - sj;
  5003 + } else {
  5004 + addgl += sj - jh;
  5005 + }
  5006 + }
  5007 + }
  5008 +
  5009 +
  5010 + List<Ylxxb> listYlxxb = ylxxbRepository.queryListYlxxb(clZbh, date);
  5011 + Double jzl = 0.0;
  5012 + for (int t = 0; t < listYlxxb.size(); t++) {
  5013 + Ylxxb y = listYlxxb.get(t);
  5014 + jzl += y.getJzl();
  5015 + }
  5016 +
  5017 + //计算里程和班次数,并放入Map里
  5018 + map = findKMBCQp(clZbh, date, line);
  5019 + map.put("jzl", jzl);
  5020 +// map.put("jhlc", format.format(jhlc + jcclc));
  5021 +// map.put("yygljh", format.format(jhlc));
  5022 +// map.put("ssgl", format.format(remMileage));
  5023 +// map.put("ksgl", format.format(ksgl));
  5024 +// map.put("yyglsj", format.format(yygl));
  5025 +// map.put("jhbc", jhbc);
  5026 +// map.put("jcclc", jcclc);
  5027 +//
  5028 +// map.put("ljgl", format.format(addMileage));
  5029 +// map.put("ssbc", cjbc);
  5030 +// map.put("ysgl", format.format(yygl));
  5031 +// map.put("sjbc", jhbc - cjbc + ljbc);
  5032 +// map.put("zgl", format.format(yygl + ksgl + jcclc));
  5033 +// map.put("ljbc", ljbc);
  5034 +
  5035 + String zdp = "", zwdp = "", wdp = "";
  5036 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  5037 + List<DutyEmployee> listDtuy = dutyEmployeeService.getDutyEmployee(line, date + "00:00", date + "23:59");
  5038 + try {
  5039 + Long fcsj1 = sdf.parse(date + " 03:00").getTime();
  5040 + Long fcsj2 = sdf.parse(date + " 11:00").getTime();
  5041 + Long fcsj3 = sdf.parse(date + " 22:00").getTime();
  5042 + for (int i = 0; i < listDtuy.size(); i++) {
  5043 + DutyEmployee t = listDtuy.get(i);
  5044 + Long ts = t.getTs();
  5045 + if (ts > fcsj1 && ts < fcsj2) {
  5046 + if (zdp.indexOf(t.getuName()) == -1) {
  5047 + zdp += t.getuName() + ",";
  5048 +
  5049 + }
  5050 + } else if (ts > fcsj2 && ts < fcsj3) {
  5051 + if (zwdp.indexOf(t.getuName()) == -1) {
  5052 + zwdp += t.getuName() + ",";
  5053 + }
  5054 + } else {
  5055 + if (wdp.indexOf(t.getuName()) == -1) {
  5056 + wdp += t.getuName() + ",";
  5057 + }
  5058 + }
  5059 + }
  5060 + } catch (ParseException e) {
  5061 + // TODO Auto-generated catch block
  5062 + e.printStackTrace();
  5063 + }
  5064 + map.put("zdp", zdp);
  5065 + map.put("zwdp", zwdp);
  5066 + map.put("wdp", wdp);
  5067 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  5068 + list.add(listMap.iterator());
  5069 + ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/waybill_qingpu.xls",
  5070 + path + "export/" + date + "-" + clZbh + "-行车路单.xls");
  5071 +
  5072 + return scheduleRealInfos;
  5073 + }
  5074 +
  5075 + @Override
  5076 + public Map<String, Object> findKMBCQp(String clZbh, String date, String line) {
  5077 + // TODO Auto-generated method stub
  5078 + List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line);
  5079 + DecimalFormat format = new DecimalFormat("0.00");
  5080 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  5081 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  5082 + int jhbc = 0, cjbc = 0, ljbc = 0, sjbc = 0;
  5083 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0, ljjcclc = 0, jhjcclc = 0;
  5084 + double addMileage = 0, remMileage = 0, addgl = 0, remgl = 0;
  5085 + Map<String, Object> map = new HashMap<String, Object>();
  5086 + jhlc = culateMieageService.culateJhgl(lists);
  5087 + jcclc = culateMieageService.culateJccgl(lists);
  5088 + jhjcclc = culateMieageService.culateJhJccgl(lists);
  5089 + remMileage = culateMieageService.culateLbgl(lists);
  5090 + ksgl = culateMieageService.culateKsgl(lists);
  5091 + yygl = culateMieageService.culateSjgl(lists);
  5092 + jhbc = culateMieageService.culateJhbc(lists, "");
  5093 + addMileage = culateMieageService.culateLjgl(lists);
  5094 + cjbc = culateMieageService.culateLbbc(lists);
  5095 + sjbc = culateMieageService.culateSjbc(lists, "");
  5096 + ljbc = culateMieageService.culateLjbc(lists, "");
  5097 + double zyygl = Arith.add(yygl, addMileage);
  5098 + double zksgl = Arith.add(ksgl, jcclc);
  5099 + map.put("jhlc", Arith.add(jhlc, jhjcclc));
  5100 + map.put("yygljh", jhlc);
  5101 + map.put("ssgl", remMileage);
  5102 + map.put("ksgl", ksgl);
  5103 + map.put("yyglsj", Arith.add(yygl, addMileage));
  5104 + map.put("jcclc", jcclc);
  5105 + map.put("jhbc", jhbc);
  5106 + map.put("ljgl", addMileage);
  5107 + map.put("ssbc", cjbc);
  5108 + map.put("ysgl", Arith.add(yygl, addMileage));
  5109 + map.put("sjbc", sjbc);
  5110 + map.put("zgl", Arith.add(zyygl, zksgl));
  5111 + map.put("ljbc", ljbc);
  5112 +
  5113 + return map;
  5114 + }
  5115 +
  5116 + @Override
  5117 + public List<ScheduleRealInfo> queryListWaybillQp(String clZbh, String date, String line) {
  5118 + // TODO Auto-generated method stub
  5119 + DecimalFormat format = new DecimalFormat("0.00");
  5120 + List<ScheduleRealInfo> list = null;
  5121 + list = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line);
  5122 + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();
  5123 + for (int i = 0; i < list.size(); i++) {
  5124 + ScheduleRealInfo s = list.get(i);
  5125 + if (!(s.getBcType().equals("in") || s.getBcType().equals("out"))) {
  5126 + String remarks = "";
  5127 + Double sjlc = 0.0;
  5128 + if (s.getRemarks() != null) {
  5129 + remarks += s.getRemarks();
  5130 + }
  5131 + Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
  5132 + if (!childTaskPlans.isEmpty()) {
  5133 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  5134 + while (it.hasNext()) {
  5135 + ChildTaskPlan c = it.next();
  5136 + if (c.getRemarks() != null && c.getRemarks().length() > 0) {
  5137 + if (remarks.indexOf(c.getRemarks()) == -1) {
  5138 + remarks += c.getRemarks();
  5139 + }
  5140 + }
  5141 +
  5142 + if (!c.isDestroy()) {
  5143 + if (c.getMileageType().equals("service")) {
  5144 + sjlc += c.getMileage() == null ? 0 : c.getMileage();
  5145 + }
  5146 + }
  5147 +
  5148 + }
  5149 + } else {
  5150 + if (s.getStatus() != -1) {
  5151 + sjlc = s.getJhlc();
  5152 + }
  5153 + }
  5154 + s.setSjlc(format.format(sjlc));
  5155 + s.setRemarks(remarks);
  5156 + newList.add(s);
  5157 + }
  5158 +
  5159 + }
  5160 +
  5161 + return newList;
  5162 + }
  5163 +
  5164 + @Override
  5165 + public Map<String, Object> MapById(Long id) {
  5166 + // TODO Auto-generated method stub
  5167 + Map<String, Object> dMap=new HashMap<>();
  5168 + dMap.put("dGroup_eq", "oilType");
  5169 + Iterator<Dictionary> it= dictionaryService.list(dMap).iterator();
  5170 + while (it.hasNext()) {
  5171 + Dictionary d=it.next();
  5172 + dMap.put(d.getdCode(), d.getdName());
  5173 + }
  5174 + Map<String, Object> map = new HashMap<String, Object>();
  5175 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  5176 + ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id);
  5177 + String xlbm = s.getXlBm();
  5178 + String fcrq = s.getScheduleDateStr();
  5179 +
  5180 + int type = 2;
  5181 + Double ccyl = 0.0;
  5182 + Double jcyl = 0.0;
  5183 + Double yh = 0.0;
  5184 + Double jzl = 0.0;
  5185 + Double zlc = 0.0;
  5186 + String rylx="";
  5187 + int hyd = 0;
  5188 + Double czql = 0.0, jzql = 0.0, hq = 0.0, jql = 0.0;
  5189 + List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh());
  5190 + if (listCars.size() > 0) {
  5191 + if (listCars.get(0).getSfdc() != null) {
  5192 + if (listCars.get(0).getSfdc()) {
  5193 + List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  5194 + type = 1;
  5195 + for (int i = 0; i < listDlb.size(); i++) {
  5196 + Dlb d = listDlb.get(i);
  5197 + if (d.getLp() == null) {
  5198 + ccyl = Arith.add(ccyl, d.getCzcd());
  5199 + jcyl = Arith.add(jcyl, d.getJzcd());
  5200 + yh = Arith.add(yh, d.getHd());
  5201 + jzl = Arith.add(jzl, d.getCdl());
  5202 + zlc = Arith.add(zlc, d.getZlc());
  5203 + } else {
  5204 + if (d.getLp().equals(s.getLpName())) {
  5205 + ccyl = Arith.add(ccyl, d.getCzcd());
  5206 + jcyl = Arith.add(jcyl, d.getJzcd());
  5207 + yh = Arith.add(yh, d.getHd());
  5208 + jzl = Arith.add(jzl, d.getCdl());
  5209 + zlc = Arith.add(zlc, d.getZlc());
  5210 + }
  5211 + }
  5212 +
  5213 + }
  5214 + } else {
  5215 + List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  5216 + type = 0;
  5217 + for (int i = 0; i < listYlb.size(); i++) {
  5218 + Ylb y = listYlb.get(i);
  5219 + if (y.getLp() == null) {
  5220 + ccyl = Arith.add(ccyl, y.getCzyl());
  5221 + jcyl = Arith.add(jcyl, y.getJzyl());
  5222 + yh = Arith.add(yh, y.getYh());
  5223 + jzl = Arith.add(jzl, y.getJzl());
  5224 + zlc = Arith.add(zlc, y.getZlc());
  5225 + if(dMap.get(y.getRylx())!=null)
  5226 + rylx =dMap.get(y.getRylx()).toString();
  5227 + } else {
  5228 + if (y.getLp().equals(s.getLpName())) {
  5229 + ccyl = Arith.add(ccyl, y.getCzyl());
  5230 + jcyl = Arith.add(jcyl, y.getJzyl());
  5231 + yh = Arith.add(yh, y.getYh());
  5232 + jzl = Arith.add(jzl, y.getJzl());
  5233 + zlc = Arith.add(zlc, y.getZlc());
  5234 + if(dMap.get(y.getRylx())!=null)
  5235 + rylx =dMap.get(y.getRylx()).toString();
  5236 + }
  5237 + }
  5238 + }
  5239 + }
  5240 + }
  5241 + if(listCars.get(0).getHydrogen() != null && listCars.get(0).getHydrogen()){
  5242 + List<Qlb> listQlb = qlbRepository.queryListQlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);
  5243 + hyd = 1;
  5244 + for (int i = 0; i < listQlb.size(); i++) {
  5245 + Qlb h = listQlb.get(i);
  5246 + if (h.getLp() == null) {
  5247 + czql = Arith.add(czql, h.getCzcl());
  5248 + jzql = Arith.add(jzql, h.getJzcl());
  5249 + hq = Arith.add(hq, h.getHn());
  5250 + jql = Arith.add(jql, h.getJql());
  5251 + } else {
  5252 + if (h.getLp().equals(s.getLpName())) {
  5253 + czql = Arith.add(czql, h.getCzcl());
  5254 + jzql = Arith.add(jzql, h.getJzcl());
  5255 + hq = Arith.add(hq, h.getHn());
  5256 + jql = Arith.add(jql, h.getJql());
  5257 + }
  5258 + }
  5259 + }
  5260 + }
  5261 + }
  5262 +
  5263 + map.put("hyd", hyd);
  5264 + map.put("czcl", czql);
  5265 + map.put("jzcl", jzql);
  5266 + map.put("hn", hq);
  5267 + map.put("jql", jql);
  5268 +
  5269 + map.put("rylx", "加注类别:"+rylx);
  5270 + map.put("jzl", jzl);
  5271 + map.put("yh", yh);
  5272 + map.put("ccyl", ccyl);
  5273 + map.put("jcyl", jcyl);
  5274 + map.put("type", type);
  5275 + map.put("zlc", zlc);
  5276 + map.put("xlName", s.getXlName());
  5277 + map.put("clZbh", s.getClZbh());
  5278 + map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh()));
  5279 + map.put("fcsjActual", s.getFcsjActual());
  5280 + map.put("zdzName", s.getZdzName());
  5281 + map.put("scheduleDate", s.getScheduleDateStr());
  5282 + map.put("lpName", s.getLpName());
  5283 + String zdp = "", zwdp = "", wdp = "";
  5284 + String zdpT = "", zwdpT = "", wdpT = "";
  5285 + String dbdp = "";
  5286 + List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59");
  5287 + try {
  5288 + Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime();
  5289 + Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime();
  5290 + Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime();
  5291 + for (int i = 0; i < list.size(); i++) {
  5292 + DutyEmployee t = list.get(i);
  5293 + if (dbdp.indexOf(t.getuName()) == -1) {
  5294 + if (!(dbdp.length() > 0)) {
  5295 + dbdp = t.getuName();
  5296 + } else {
  5297 + dbdp += "," + t.getuName();
  5298 + }
  5299 + }
  5300 + Long ts = t.getTs();
  5301 + if (ts > fcsj1 && ts < fcsj2) {
  5302 + if (zdp.indexOf(t.getuName()) == -1) {
  5303 + if (!(zdp.length() > 0)) {
  5304 + zdpT = t.getuName() + "...";
  5305 + }
  5306 + zdp += t.getuName() + ",";
  5307 +
  5308 + }
  5309 + } else if (ts > fcsj2 && ts < fcsj3) {
  5310 + if (zwdp.indexOf(t.getuName()) == -1) {
  5311 + if (!(zwdp.length() > 0)) {
  5312 + zwdpT = t.getuName() + "...";
  5313 + }
  5314 + zwdp += t.getuName() + ",";
  5315 + }
  5316 + } else {
  5317 + if (wdp.indexOf(t.getuName()) == -1) {
  5318 + if (!(wdp.length() > 0)) {
  5319 + wdpT = t.getuName() + "...";
  5320 + }
  5321 + wdp += t.getuName() + ",";
  5322 + }
  5323 + }
  5324 + }
  5325 + } catch (ParseException e) {
  5326 + // TODO Auto-generated catch block
  5327 + e.printStackTrace();
  5328 + }
  5329 + map.put("zdp", zdp);
  5330 + map.put("zwdp", zwdp);
  5331 + map.put("wdp", wdp);
  5332 + map.put("zdpT", zdpT);
  5333 + map.put("zwdpT", zwdpT);
  5334 + map.put("wdpT", wdpT);
  5335 + map.put("dbdp", dbdp);
  5336 + return map;
  5337 + }
  5338 +
  5339 + @Override
  5340 + public Map<String, Object> MapByIdQp(Long id) {
  5341 + // TODO Auto-generated method stub
  5342 + Map<String, Object> map = new HashMap<String, Object>();
  5343 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  5344 + ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id);
  5345 + String xlbm = s.getXlBm();
  5346 + String fcrq = s.getScheduleDateStr();
  5347 +
  5348 + int type = 0;
  5349 + Double ccyl = 0.0;
  5350 + Double jcyl = 0.0;
  5351 + Double yh = 0.0;
  5352 + Double jzl = 0.0;
  5353 + Double zlc = 0.0;
  5354 +// List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(),xlbm);
  5355 +// List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(),xlbm);
  5356 +// if(listYlb.size()>0){
  5357 +// type=0;
  5358 +// for (int i = 0; i < listYlb.size(); i++) {
  5359 +// Ylb y = listYlb.get(i);
  5360 +// if(y.getLp()==null){
  5361 +// ccyl=Arith.add(ccyl, y.getCzyl());
  5362 +// jcyl=Arith.add(jcyl, y.getJzyl());
  5363 +// yh =Arith.add(yh ,y.getYh());
  5364 +// jzl =Arith.add(jzl, y.getJzl());
  5365 +// zlc =Arith.add(zlc, y.getZlc());
  5366 +// }else{
  5367 +// if(y.getLp().equals(s.getLpName())){
  5368 +// ccyl=Arith.add(ccyl, y.getCzyl());
  5369 +// jcyl=Arith.add(jcyl, y.getJzyl());
  5370 +// yh =Arith.add(yh ,y.getYh());
  5371 +// jzl =Arith.add(jzl, y.getJzl());
  5372 +// zlc =Arith.add(zlc, y.getZlc());
  5373 +// }
  5374 +// }
  5375 +//
  5376 +// }
  5377 +// }else{
  5378 +// type=1;
  5379 +// for (int i = 0; i < listDlb.size(); i++) {
  5380 +// Dlb d=listDlb.get(i);
  5381 +// if(d.getLp()==null){
  5382 +// ccyl=Arith.add(ccyl, d.getCzcd());
  5383 +// jcyl=Arith.add(jcyl, d.getJzcd());
  5384 +// yh =Arith.add(yh ,d.getHd());
  5385 +// jzl =Arith.add(jzl, d.getCdl());
  5386 +// zlc =Arith.add(zlc, d.getZlc());
  5387 +// }else{
  5388 +// if(d.getLp().equals(s.getLpName())){
  5389 +// ccyl=Arith.add(ccyl, d.getCzcd());
  5390 +// jcyl=Arith.add(jcyl, d.getJzcd());
  5391 +// yh =Arith.add(yh ,d.getHd());
  5392 +// jzl =Arith.add(jzl, d.getCdl());
  5393 +// zlc =Arith.add(zlc, d.getZlc());
  5394 +// }
  5395 +// }
  5396 +//
  5397 +// }
  5398 +// }
  5399 +
  5400 + List<Ylxxb> listylxxb = ylxxbRepository.queryListYlxxb(s.getClZbh(), fcrq);
  5401 + for (int i = 0; i < listylxxb.size(); i++) {
  5402 + Ylxxb t = listylxxb.get(i);
  5403 + jzl = Arith.add(jzl, t.getJzl());
  5404 + }
  5405 + map.put("jzl", jzl);
  5406 + map.put("yh", yh);
  5407 + map.put("ccyl", ccyl);
  5408 + map.put("jcyl", jcyl);
  5409 + map.put("type", type);
  5410 + map.put("zlc", zlc);
  5411 + map.put("xlName", s.getXlName());
  5412 + map.put("clZbh", s.getClZbh());
  5413 + map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh()));
  5414 + map.put("fcsjActual", s.getFcsjActual());
  5415 + map.put("zdzName", s.getZdzName());
  5416 + map.put("scheduleDate", s.getScheduleDateStr());
  5417 + map.put("lpName", s.getLpName());
  5418 + String zdp = "", zwdp = "", wdp = "";
  5419 + String zdpT = "", zwdpT = "", wdpT = "";
  5420 + String dbdp = "";
  5421 + List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59");
  5422 + try {
  5423 + Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime();
  5424 + Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime();
  5425 + Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime();
  5426 + for (int i = 0; i < list.size(); i++) {
  5427 + DutyEmployee t = list.get(i);
  5428 + if (dbdp.indexOf(t.getuName()) == -1) {
  5429 + if (!(dbdp.length() > 0)) {
  5430 + dbdp = t.getuName();
  5431 + } else {
  5432 + dbdp += "," + t.getuName();
  5433 + }
  5434 + }
  5435 + Long ts = t.getTs();
  5436 + if (ts > fcsj1 && ts < fcsj2) {
  5437 + if (zdp.indexOf(t.getuName()) == -1) {
  5438 + if (!(zdp.length() > 0)) {
  5439 + zdpT = t.getuName() + "...";
  5440 + }
  5441 + zdp += t.getuName() + ",";
  5442 +
  5443 + }
  5444 + } else if (ts > fcsj2 && ts < fcsj3) {
  5445 + if (zwdp.indexOf(t.getuName()) == -1) {
  5446 + if (!(zwdp.length() > 0)) {
  5447 + zwdpT = t.getuName() + "...";
  5448 + }
  5449 + zwdp += t.getuName() + ",";
  5450 + }
  5451 + } else {
  5452 + if (wdp.indexOf(t.getuName()) == -1) {
  5453 + if (!(wdp.length() > 0)) {
  5454 + wdpT = t.getuName() + "...";
  5455 + }
  5456 + wdp += t.getuName() + ",";
  5457 + }
  5458 + }
  5459 + }
  5460 + } catch (ParseException e) {
  5461 + // TODO Auto-generated catch block
  5462 + e.printStackTrace();
  5463 + }
  5464 + map.put("zdp", zdp);
  5465 + map.put("zwdp", zwdp);
  5466 + map.put("wdp", wdp);
  5467 + map.put("zdpT", zdpT);
  5468 + map.put("zwdpT", zwdpT);
  5469 + map.put("wdpT", wdpT);
  5470 + map.put("dbdp", dbdp);
  5471 + return map;
  5472 + }
  5473 +
  5474 + @Override
  5475 + public List<Map<String, Object>> scheduleDailyQp(String line, String date) {
  5476 + // TODO Auto-generated method stub
  5477 + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  5478 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleDailyQp(line, date);
  5479 + Map<String, Object> map = null;
  5480 + String lp = "lp";
  5481 + String jgh = "jgh";
  5482 + String clzbh = "clzbh";
  5483 + int bcs = 0;
  5484 + String thclzbh = "";
  5485 + String sgh = "sgh";
  5486 + for (int i = 0; i < scheduleRealInfos.size(); i++) {
  5487 + ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(i);
  5488 + if (scheduleRealInfo.getLpName().equals(lp)) {
  5489 + bcs++;
  5490 + String fcsj = scheduleRealInfo.getFcsj();
  5491 +
  5492 + if (!clzbh.equals(scheduleRealInfo.getClZbh())) {
  5493 + clzbh = scheduleRealInfo.getClZbh();
  5494 + if (thclzbh == "") {
  5495 + thclzbh += scheduleRealInfo.getClZbh() + ",";
  5496 + } else {
  5497 + thclzbh += scheduleRealInfo.getClZbh();
  5498 + }
  5499 + map.put("thclzbh", thclzbh);
  5500 + }
  5501 +
  5502 + if (!jgh.equals(scheduleRealInfo.getjGh())) {
  5503 + jgh = scheduleRealInfo.getjGh();
  5504 + if (map.get("jjb2") != null) {
  5505 + map.put("jjb3", scheduleRealInfo.getjGh() + "/" +
  5506 + scheduleRealInfo.getFcsjActual());
  5507 +
  5508 + } else {
  5509 + map.put("jjb2", scheduleRealInfo.getjGh() + "/" +
  5510 + scheduleRealInfo.getFcsjActual());
  5511 + }
  5512 +
  5513 + }
  5514 +
  5515 + if (scheduleRealInfo.getsGh() != null) {
  5516 + if (!scheduleRealInfo.getsGh().equals(sgh)) {
  5517 + sgh = scheduleRealInfo.getsGh() == null ? "" : scheduleRealInfo.getsGh();
  5518 + if (!sgh.equals("")) {
  5519 + if (map.get("sjb1") != null) {
  5520 + if (map.get("sjb2") != null) {
  5521 + map.put("sjb3", scheduleRealInfo.getsGh() + "/" +
  5522 + scheduleRealInfo.getFcsjActual());
  5523 + } else {
  5524 + map.put("sjb2", scheduleRealInfo.getsGh() + "/" +
  5525 + scheduleRealInfo.getFcsjActual());
  5526 + }
  5527 + } else {
  5528 + map.put("sjb1", scheduleRealInfo.getsGh() + "/" +
  5529 + scheduleRealInfo.getFcsjActual());
  5530 + }
  5531 + }
  5532 + }
  5533 + }
  5534 + if (scheduleRealInfo.getFcsjActual() != null) {
  5535 + String fcsjs[] = fcsj.split(":");
  5536 + String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":");
  5537 + int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]);
  5538 + int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]);
  5539 + map.put("cz" + bcs, b - a);
  5540 + } else {
  5541 + map.put("cz" + bcs, "无");
  5542 + }
  5543 + map.put("lp", scheduleRealInfo.getLpName());
  5544 + map.put("dd" + bcs, scheduleRealInfo.getZdsjActual());
  5545 + map.put("kc" + bcs, scheduleRealInfo.getFcsjActual());
  5546 +
  5547 + if (i < scheduleRealInfos.size() - 1) {
  5548 + if (!scheduleRealInfos.get(i + 1).getLpName().equals
  5549 + (scheduleRealInfos.get(i).getLpName())) {
  5550 + list.add(map);
  5551 + lp = "lp";
  5552 + jgh = "jgh";
  5553 + clzbh = "clzbh";
  5554 + bcs = 0;
  5555 + thclzbh = "";
  5556 + sgh = "sgh";
  5557 + }
  5558 + } else {
  5559 + list.add(map);
  5560 + }
  5561 + } else {
  5562 + bcs = 1;
  5563 + map = new HashMap<String, Object>();
  5564 + lp = scheduleRealInfo.getLpName();
  5565 + jgh = scheduleRealInfo.getjGh();
  5566 + clzbh = scheduleRealInfo.getClZbh();
  5567 + if (scheduleRealInfo.getsGh() != null) {
  5568 + sgh = scheduleRealInfo.getsGh();
  5569 + map.put("sjb1", scheduleRealInfo.getsGh() + "/" +
  5570 + scheduleRealInfo.getFcsjActual());
  5571 + }
  5572 + String fcsj = scheduleRealInfo.getFcsj();
  5573 + scheduleRealInfo.getFcsjActual();
  5574 + map.put("jjb1", jgh + "/" + scheduleRealInfo.getFcsjActual());
  5575 + map.put("cccl", clzbh);
  5576 +
  5577 + if (scheduleRealInfo.getFcsjActual() != null) {
  5578 + String fcsjs[] = fcsj.split(":");
  5579 + String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":");
  5580 + int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]);
  5581 + int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]);
  5582 + map.put("cz" + bcs, b - a);
  5583 + } else {
  5584 + map.put("cz" + bcs, "无");
  5585 + }
  5586 +
  5587 +
  5588 + map.put("lp", scheduleRealInfo.getLpName());
  5589 + map.put("dd" + bcs, scheduleRealInfo.getZdsjActual());
  5590 + map.put("kc" + bcs, scheduleRealInfo.getFcsjActual());
  5591 +
  5592 + if (i < scheduleRealInfos.size() - 1) {
  5593 + if (!scheduleRealInfos.get(i + 1).getLpName().equals
  5594 + (scheduleRealInfos.get(i).getLpName())) {
  5595 + list.add(map);
  5596 + lp = "lp";
  5597 + jgh = "jgh";
  5598 + clzbh = "clzbh";
  5599 + bcs = 0;
  5600 + thclzbh = "";
  5601 + sgh = "sgh";
  5602 + }
  5603 + } else {
  5604 + list.add(map);
  5605 + }
  5606 + }
  5607 +
  5608 + }
  5609 + return list;
  5610 + }
  5611 +
  5612 +
  5613 + @Override
  5614 + public List<Map<String, Object>> scheduleDailyExport(Map<String, Object> map) {
  5615 + String line = map.get("line").toString();
  5616 + String date = map.get("date").toString();
  5617 + String xlName = map.get("xlName").toString();
  5618 + String state = map.get("state").toString();
  5619 + String type = map.get("type").toString();
  5620 + String genre =map.get("genre").toString();
  5621 + String df="";
  5622 + if(map.get("df")!=null){
  5623 + df=map.get("df").toString();
  5624 + }
  5625 +
  5626 + List<Map<String, Object>> dataList2 = new ArrayList<Map<String, Object>>();
  5627 + List<Map<String, Object>> dataList3 = new ArrayList<Map<String, Object>>();
  5628 + List<Map<String, Object>> list1 = this.statisticsDaily(line, date, xlName, null);
  5629 + List<ScheduleRealInfo> list2 = this.queryUserInfo(line, date, state);
  5630 + List<ScheduleRealInfo> list3 = new ArrayList<ScheduleRealInfo>();
  5631 + if(genre.equals("qp"))
  5632 + list3=this.realScheduleListQp(line, date);
  5633 + else if(genre.equals("zrw"))
  5634 + list3=this.realScheduleList_zrw(line, date);
  5635 + else
  5636 + list3=this.realScheduleList(line, date);
  5637 + Map<String, Object> nMap = new HashMap<String, Object>();
  5638 + nMap.put("date", xlName + date);
  5639 + nMap.put("jls", list1.get(0).get("jls"));
  5640 + nMap.put("sjgl", list1.get(0).get("sjgl"));
  5641 +
  5642 + int size = 0;
  5643 + Map<String, Object> tempMap = new HashMap<String, Object>();
  5644 + for (int i = 0; i < list2.size(); i++) {
  5645 + ScheduleRealInfo s = list2.get(i);
  5646 + if (size == 5) {
  5647 + size = 0;
  5648 + dataList2.add(tempMap);
  5649 + tempMap = new HashMap<String, Object>();
  5650 + }
  5651 + tempMap.put("lp" + size, s.getLpName());
  5652 + tempMap.put("ch" + size, s.getClZbh());
  5653 + tempMap.put("jz" + size, s.getjGh() + "/" + s.getjName());
  5654 + tempMap.put("sz" + size, "");
  5655 + tempMap.put("jw" + size, "");
  5656 + tempMap.put("sw" + size, "");
  5657 +
  5658 + size++;
  5659 + }
  5660 + if (size < 5) {
  5661 + for (; size < 5; size++) {
  5662 + tempMap.put("lp" + size, "");
  5663 + tempMap.put("ch" + size, "");
  5664 + tempMap.put("jz" + size, "");
  5665 + tempMap.put("sz" + size, "");
  5666 + tempMap.put("jw" + size, "");
  5667 + tempMap.put("sw" + size, "");
  5668 + }
  5669 + }
  5670 +
  5671 + dataList2.add(tempMap);
  5672 +
  5673 + size = 0;
  5674 + tempMap = new HashMap<String, Object>();
  5675 + for (ScheduleRealInfo schedule : list3) {
  5676 + int x = size % 3;
  5677 + if (x == 0 && size > 0) {
  5678 + dataList3.add(tempMap);
  5679 + tempMap = new HashMap<String, Object>();
  5680 + }
  5681 + tempMap.put("lpName" + x, schedule.getLpName());
  5682 + tempMap.put("qdzName" + x, schedule.getQdzName());
  5683 + tempMap.put("zdsj" + x, schedule.getZdsj());
  5684 + String zdsjActual = schedule.getZdsjActual() != null ? schedule.getZdsjActual() : "";
  5685 + tempMap.put("zdsjActual" + x, zdsjActual);
  5686 +
  5687 + String zdsjk = "";
  5688 + String zdsjm = "";
  5689 + if (!zdsjActual.equals("")) {
  5690 + String[] zdsj_s = schedule.getZdsj().split(":");
  5691 + String[] zdsjActual_s = zdsjActual.split(":");
  5692 + Long zdsj_ = Long.parseLong(zdsj_s[0]) * 60 + Long.parseLong(zdsj_s[1]);
  5693 + Long zdsjActual_ = Long.parseLong(zdsjActual_s[0]) * 60 + Long.parseLong(zdsjActual_s[1]);
  5694 + if ((zdsj_ - zdsjActual_) > 0) {
  5695 + if(zdsj_ - zdsjActual_>1200){
  5696 + zdsjm=String.valueOf(1440-(zdsj_-zdsjActual_));
  5697 + }else{
  5698 + zdsjk = String.valueOf(zdsj_ - zdsjActual_);
  5699 + }
  5700 + } else {
  5701 + if(zdsjActual_ - zdsj_>1200){
  5702 + zdsjk =String.valueOf(1440-(zdsjActual_ - zdsj_));
  5703 + }else{
  5704 + zdsjm = String.valueOf(zdsjActual_ - zdsj_);
  5705 + }
  5706 + }
  5707 + }
  5708 + tempMap.put("zdsjk" + x, zdsjk);
  5709 + tempMap.put("zdsjm" + x, zdsjm.equals("0")?"":zdsjm);
  5710 + tempMap.put("fcsj" + x, schedule.getFcsj());
  5711 + String fcsjActural = schedule.getFcsjActual() != null ? schedule.getFcsjActual() : "";
  5712 + String bcType = schedule.getBcType() != null ? schedule.getBcType() : "";
  5713 + String fcsjActuralstr = "";
  5714 + if (bcType.equals("in")) {
  5715 + fcsjActuralstr = fcsjActural + "(进)";
  5716 + } else if (bcType.equals("out")) {
  5717 + fcsjActuralstr = fcsjActural + "(出)";
  5718 + } else {
  5719 + fcsjActuralstr = fcsjActural;
  5720 + }
  5721 + tempMap.put("fcsjActual" + x, fcsjActuralstr);
  5722 + String fcsjk = "";
  5723 + String fcsjm = "";
  5724 + String dfsjk ="";
  5725 + String dfsjm="";
  5726 + if (!fcsjActural.equals("")) {
  5727 + String[] fcsj_s = schedule.getFcsj().split(":");
  5728 + String[] fcsjActural_s = fcsjActural.split(":");
  5729 + Long fcsj_ = Long.parseLong(fcsj_s[0]) * 60 + Long.parseLong(fcsj_s[1]);
  5730 + Long fcsjActural_ = Long.parseLong(fcsjActural_s[0]) * 60 + Long.parseLong(fcsjActural_s[1]);
  5731 + if ((fcsj_ - fcsjActural_) > 0) {
  5732 + if(fcsj_ - fcsjActural_>1200){
  5733 + fcsjm=String.valueOf(1440-(fcsj_ - fcsjActural_));
  5734 + }else{
  5735 + fcsjk = String.valueOf(fcsj_ - fcsjActural_);
  5736 + }
  5737 + } else {
  5738 + if(fcsjActural_ - fcsj_>1200){
  5739 + fcsjk =String.valueOf(1440-(fcsjActural_ - fcsj_));
  5740 + }
  5741 + else{
  5742 + fcsjm = String.valueOf(fcsjActural_ - fcsj_);
  5743 + }
  5744 + }
  5745 + if(df.equals("df")){
  5746 + String[] dfsj_s =schedule.getDfsj().split(":");
  5747 + Long dfsj_ = Long.parseLong(dfsj_s[0]) * 60 + Long.parseLong(dfsj_s[1]);
  5748 + if ((dfsj_ - fcsjActural_) > 0) {
  5749 + if(dfsj_ - fcsjActural_>1200){
  5750 + dfsjm=String.valueOf(1440-(dfsj_ - fcsjActural_));
  5751 + }else{
  5752 + dfsjk = String.valueOf(dfsj_ - fcsjActural_);
  5753 + }
  5754 + } else {
  5755 + if(fcsjActural_ - dfsj_>1200){
  5756 + dfsjk= String.valueOf(1440-(fcsjActural_ - dfsj_));
  5757 + }else{
  5758 + dfsjm = String.valueOf(fcsjActural_ - dfsj_);
  5759 + }
  5760 + }
  5761 + }
  5762 + }
  5763 + if(df.equals("df")){
  5764 + tempMap.put("dfsj"+x,schedule.getDfsj());
  5765 + tempMap.put("dfsjk" + x, dfsjk);
  5766 + tempMap.put("dfsjm" + x, dfsjm.equals("0")?"":dfsjm);
  5767 + }
  5768 + tempMap.put("fcsjk" + x, fcsjk);
  5769 + tempMap.put("fcsjm" + x, fcsjm.equals("0")?"":fcsjm);
  5770 + tempMap.put("remarks" + x, schedule.getRemark() != null ? schedule.getRemark() : "");
  5771 +
  5772 + size++;
  5773 + }
  5774 + if (tempMap.get("lpName0") != null) {
  5775 + if (tempMap.get("lpName1") == null) {
  5776 + tempMap.put("lpName1", "");
  5777 + tempMap.put("qdzName1", "");
  5778 + tempMap.put("zdsj1", "");
  5779 + tempMap.put("zdsjActual1", "");
  5780 + tempMap.put("zdsjk1", "");
  5781 + tempMap.put("zdsjm1", "");
  5782 + tempMap.put("fcsj1", "");
  5783 + tempMap.put("fcsjActual1", "");
  5784 + tempMap.put("fcsjk1", "");
  5785 + tempMap.put("fcsjm1", "");
  5786 + if(df.equals("df")){
  5787 + tempMap.put("dfsj1","");
  5788 + tempMap.put("dfsjk1" , "");
  5789 + tempMap.put("dfsjm1" , "");
  5790 + }
  5791 + tempMap.put("remarks1", "");
  5792 + }
  5793 + if (tempMap.get("lpName2") == null) {
  5794 + tempMap.put("lpName2", "");
  5795 + tempMap.put("qdzName2", "");
  5796 + tempMap.put("zdsj2", "");
  5797 + tempMap.put("zdsjActual2", "");
  5798 + tempMap.put("zdsjk2", "");
  5799 + tempMap.put("zdsjm2", "");
  5800 + tempMap.put("fcsj2", "");
  5801 + tempMap.put("fcsjActual2", "");
  5802 + tempMap.put("fcsjk2", "");
  5803 + tempMap.put("fcsjm2", "");
  5804 + if(df.equals("df")){
  5805 + tempMap.put("dfsj2","");
  5806 + tempMap.put("dfsjk2" , "");
  5807 + tempMap.put("dfsjm2" , "");
  5808 + }
  5809 + tempMap.put("remarks2", "");
  5810 + }
  5811 + dataList3.add(tempMap);
  5812 + }
  5813 +
  5814 + if (date.length() == 10) {
  5815 + List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59");
  5816 + String dbdp = "";
  5817 + try {
  5818 + for (int i = 0; i < list.size(); i++) {
  5819 + DutyEmployee t = list.get(i);
  5820 + if (dbdp.indexOf(t.getuName()) == -1) {
  5821 + if (!(dbdp.length() > 0)) {
  5822 + dbdp = t.getuName();
  5823 + } else {
  5824 + dbdp += "," + t.getuName();
  5825 + }
  5826 + }
  5827 + }
  5828 + } catch (Exception e) {
  5829 + // TODO: handle exception
  5830 + e.printStackTrace();
  5831 + }
  5832 + nMap.put("dbdp", dbdp);
  5833 + }
  5834 +
  5835 + if (type.equals("export")) {
  5836 + String lineName = "";
  5837 + if (map.containsKey("lineName"))
  5838 + lineName = "-" + map.get("lineName").toString() + "-";
  5839 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  5840 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  5841 + Map<String, Object> m = new HashMap<String, Object>();
  5842 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  5843 + ReportUtils ee = new ReportUtils();
  5844 + try {
  5845 + listI.add(list1.iterator());
  5846 + listI.add(dataList2.iterator());
  5847 + listI.add(dataList3.iterator());
  5848 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  5849 + String sourcePath = path + "mould/scheduleDaily.xls";
  5850 + if (date.length() == 7) {
  5851 + sdfMonth = new SimpleDateFormat("yyyy-MM");
  5852 + sdfSimple = new SimpleDateFormat("yyyyMM");
  5853 + sourcePath = path + "mould/scheduleDaily_m.xls";
  5854 + }
  5855 + if(df.equals("df")){
  5856 + sourcePath =path + "mould/scheduleDaily_df.xls";
  5857 + }
  5858 + ee.excelReplace(listI, new Object[]{nMap}, sourcePath,
  5859 + path + "export/" + sdfSimple.format(sdfMonth.parse(date)) + lineName + "调度日报.xls");
  5860 + } catch (Exception e) {
  5861 + // TODO: handle exception
  5862 + e.printStackTrace();
  5863 + }
  5864 + }
  5865 +
  5866 + return new ArrayList<Map<String, Object>>();
  5867 + }
  5868 +
  5869 + public void exportWaybill_pl(List<ScheduleRealInfo> listpl,
  5870 + String date, String jName, String clZbh, String lpName) {
  5871 + ReportUtils ee = new ReportUtils();
  5872 + ReportRelatedUtils rru = new ReportRelatedUtils();
  5873 + List<Iterator<?>> list = new ArrayList<Iterator<?>>();
  5874 + List<ScheduleRealInfo> scheduleRealInfos = listpl;
  5875 + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
  5876 +// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line);
  5877 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  5878 + for (int i = 0; i < scheduleRealInfos.size(); i++) {
  5879 + ScheduleRealInfo s = scheduleRealInfos.get(i);
  5880 + Set<ChildTaskPlan> cts = s.getcTasks();
  5881 + if (cts != null && cts.size() > 0) {
  5882 + lists.add(s);
  5883 + } else {
  5884 + if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  5885 + lists.add(s);
  5886 + }
  5887 + }
  5888 + }
  5889 + DecimalFormat format = new DecimalFormat("0.00");
  5890 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  5891 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  5892 + //计算里程和班次数,并放入Map里
  5893 + Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId());
  5894 +
  5895 + map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos)));
  5896 + map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos));
  5897 + map.put("addMileage", culateMieageService.culateLjgl(lists));
  5898 + double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists));
  5899 + map.put("yygl", yygl);
  5900 + double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists));
  5901 + map.put("ksgl", ksgl);
  5902 + map.put("realMileage", Arith.add(yygl, ksgl));
  5903 + map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, ""));
  5904 + map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos));
  5905 + map.put("ljbc", culateMieageService.culateLjbc(lists, ""));
  5906 + int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, "");
  5907 + map.put("sjbc", sjbc);
  5908 +// map=new HashMap<String,Object>();
  5909 +
  5910 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  5911 + String minfcsj = "02:00";
  5912 + List<Line> lineList = lineRepository.findLineByCode(listpl.get(0).getXlBm());
  5913 + if (lineList.size() > 0) {
  5914 + String sqlMinYysj = "select start_opt from bsth_c_line_config where "
  5915 + + " id = ("
  5916 + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"
  5917 + + ")";
  5918 + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  5919 + }
  5920 + String[] minSjs = minfcsj.split(":");
  5921 + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);
  5922 +
  5923 +
  5924 + for (int i = 0; i < scheduleRealInfos.size(); i++) {
  5925 + ScheduleRealInfo s = scheduleRealInfos.get(i);
  5926 + String[] fcsj = s.getFcsj().split(":");
  5927 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  5928 +
  5929 + Long fscjT = 0L;
  5930 + if (fcsjL < minSj) {
  5931 + Calendar calendar = new GregorianCalendar();
  5932 + calendar.setTime(s.getScheduleDate());
  5933 + calendar.add(calendar.DATE, 1);
  5934 + s.setScheduleDate(calendar.getTime());
  5935 + try {
  5936 + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();
  5937 + } catch (ParseException e) {
  5938 + // TODO Auto-generated catch block
  5939 + e.printStackTrace();
  5940 + }
  5941 +
  5942 + } else {
  5943 + try {
  5944 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  5945 + } catch (ParseException e) {
  5946 + // TODO Auto-generated catch block
  5947 + e.printStackTrace();
  5948 + }
  5949 + ;
  5950 + }
  5951 + s.setFcsjT(fscjT);
  5952 + }
  5953 + List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();
  5954 + Collections.sort(scheduleRealInfos, new ComparableReal());
  5955 + for (int i = 0; i < scheduleRealInfos.size(); i++) {
  5956 + ScheduleRealInfo s = scheduleRealInfos.get(i);
  5957 + s.setAdjustExps(i + 1 + "");
  5958 + String remarks = "";
  5959 + if (s.getRemarks() != null) {
  5960 + remarks += s.getRemarks();
  5961 + }
  5962 +
  5963 + Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
  5964 + if (!childTaskPlans.isEmpty()) {
  5965 + s.setFcsjActual("");
  5966 + s.setZdsjActual("");
  5967 + s.setJhlc(0.0);
  5968 + }
  5969 +
  5970 + if (s.isDestroy()) {
  5971 + s.setFcsjActual("");
  5972 + s.setZdsjActual("");
  5973 + s.setJhlc(0.0);
  5974 + remarks += "(烂班)";
  5975 + s.setRemarks(remarks);
  5976 + }
  5977 +
  5978 + listSchedule.add(s);
  5979 + //计算营运里程,空驶里程
  5980 + if (!childTaskPlans.isEmpty()) {
  5981 +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  5982 + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);
  5983 + Collections.sort(listit, new ComparableChild());
  5984 + for (int j = 0; j < listit.size(); j++) {
  5985 + ScheduleRealInfo t = new ScheduleRealInfo();
  5986 + ChildTaskPlan childTaskPlan = listit.get(j);
  5987 + if (childTaskPlan.isDestroy()) {
  5988 + t.setFcsjActual("");
  5989 + t.setZdsjActual("");
  5990 + t.setJhlc(0.0);
  5991 + } else {
  5992 + t.setFcsjActual(childTaskPlan.getStartDate());
  5993 + t.setZdsjActual(childTaskPlan.getEndDate());
  5994 + t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));
  5995 + }
  5996 + t.setQdzName(childTaskPlan.getStartStationName());
  5997 + t.setZdzName(childTaskPlan.getEndStationName());
  5998 + t.setRemarks(childTaskPlan.getRemarks());
  5999 + t.setAdjustExps("子");
  6000 + t.setjGh("");
  6001 + t.setjName("");
  6002 + t.setsGh("");
  6003 + t.setsName("");
  6004 + listSchedule.add(t);
  6005 + }
  6006 + }
  6007 + }
  6008 + Map<String, Object> maps;
  6009 + for (ScheduleRealInfo scheduleRealInfo : listSchedule) {
  6010 + maps = new HashMap<String, Object>();
  6011 + try {
  6012 + scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName());
  6013 + scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName());
  6014 + maps = rru.getMapValue(scheduleRealInfo);
  6015 + maps.put("bcs", scheduleRealInfo.getAdjustExps());
  6016 + String zdsj = scheduleRealInfo.getZdsj();
  6017 + String zdsjActual = scheduleRealInfo.getZdsjActual();
  6018 + if (zdsj != null && zdsjActual != null &&
  6019 + !zdsj.equals(zdsjActual) &&
  6020 + !zdsj.equals("") &&
  6021 + !zdsjActual.equals("")) {
  6022 + int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]);
  6023 + int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]);
  6024 + if (zdsj.compareTo(zdsjActual) > 0) {
  6025 + if (zdsjT - zdsjAT > 1000) {
  6026 + maps.put("fast", "");
  6027 + maps.put("slow", zdsjAT - zdsjT + 1440);
  6028 + } else {
  6029 + maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  6030 + maps.put("slow", "");
  6031 + }
  6032 + } else {
  6033 + if (zdsjAT - zdsjT > 1000) {
  6034 + maps.put("fast", zdsjT - zdsjAT + 1440);
  6035 + maps.put("slow", "");
  6036 + } else {
  6037 + maps.put("fast", "");
  6038 + maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  6039 + }
  6040 + }
  6041 + } else {
  6042 + maps.put("fast", "");
  6043 + maps.put("slow", "");
  6044 + }
  6045 +
  6046 + String fcsj = scheduleRealInfo.getFcsj();
  6047 + String fcsjActual = scheduleRealInfo.getFcsjActual();
  6048 + if (fcsj != null && fcsjActual != null &&
  6049 + !fcsj.equals(fcsjActual) &&
  6050 + !fcsj.equals("") &&
  6051 + !fcsjActual.equals("")) {
  6052 + int fcsjT = Integer.valueOf(fcsj.split(":")[0]) * 60 + Integer.valueOf(fcsj.split(":")[1]);
  6053 + int fcsjAT = Integer.valueOf(fcsjActual.split(":")[0]) * 60 + Integer.valueOf(fcsjActual.split(":")[1]);
  6054 + if (fcsj.compareTo(fcsjActual) > 0) {
  6055 + if (fcsjT - fcsjAT > 1000) {
  6056 + maps.put("fast_start", "");
  6057 + maps.put("slow_start", fcsjAT - fcsjT + 1440);
  6058 + } else {
  6059 + maps.put("fast_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));
  6060 + maps.put("slow_start", "");
  6061 + }
  6062 + } else {
  6063 + if (fcsjAT - fcsjT > 1000) {
  6064 + maps.put("fast_start", fcsjT - fcsjAT + 1440);
  6065 + maps.put("slow_start", "");
  6066 + } else {
  6067 + maps.put("fast_start", "");
  6068 + maps.put("slow_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));
  6069 + }
  6070 + }
  6071 + } else {
  6072 + maps.put("fast_start", "");
  6073 + maps.put("slow_start", "");
  6074 + }
  6075 + listMap.add(maps);
  6076 + } catch (Exception e) {
  6077 + e.printStackTrace();
  6078 + }
  6079 + }
  6080 +
  6081 +
  6082 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  6083 + list.add(listMap.iterator());
  6084 + String xls = "";
  6085 + if (map.get("type").toString().equals("0")) {
  6086 + xls = "waybill_minhang.xls";
  6087 + } else {
  6088 + xls = "waybill_minhang_dl.xls";
  6089 + }
  6090 + map.put("sheetName", jName + "-" + clZbh + "-" + lpName);
  6091 + ee.excelReplace(list, new Object[]{map}, path + "mould/" + xls,
  6092 + path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");
  6093 + }
  6094 +
  6095 + @Override
  6096 + public Map<String, Object> exportWaybillMore(Map<String, Object> map) {
  6097 + String date = map.get("date").toString();
  6098 + String line = map.get("line").toString();
  6099 + ReportUtils ee = new ReportUtils();
  6100 + List<List> lists = JSON.parseArray(map.get("strs").toString(), List.class);
  6101 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/";
  6102 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  6103 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  6104 + int num = 0;
  6105 + File file = null;
  6106 + try {
  6107 + while (true) {
  6108 + String fileUrl = path + "行车路单" + sdfSimple.format(sdfMonth.parse(date));
  6109 +// file = new File(fileUrl + (num == 0 ? "/" : "(" + num + ")/")); //新建文件夹
  6110 + file = new File(fileUrl + (num == 0 ? ".xls" : "(" + num + ").xls")); //新建excel文件
  6111 + if (file.exists()) { //判断是否已存在重名
  6112 + num++;
  6113 + } else {
  6114 + break;
  6115 + }
  6116 + }
  6117 +// file.mkdirs(); //创建
  6118 + List<ScheduleRealInfo> lists_line = scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  6119 + List<File> files = new ArrayList<File>();
  6120 + for (List<String> list : lists) {
  6121 + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();
  6122 + String jName = list.get(0);
  6123 + String clZbh = list.get(1);
  6124 + String lpName = list.get(2);
  6125 + String jGh = list.get(3);
  6126 + for (int i = 0; i < lists_line.size(); i++) {
  6127 + ScheduleRealInfo s = lists_line.get(i);
  6128 + if (s.getjGh().equals(jGh) && s.getClZbh().equals(clZbh) && s.getLpName().equals(lpName)) {
  6129 + newList.add(s);
  6130 + }
  6131 + }
  6132 + this.exportWaybill_pl(newList, date, jName, clZbh, lpName);
  6133 + File temp = new File(path + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");
  6134 + String fileName = file.getName();
  6135 + files.add(temp);
  6136 + }
  6137 + for (int i = 1; i < files.size(); i++) {
  6138 + File file1 = files.get(0);
  6139 + File file2 = files.get(i);
  6140 + ee.copySheetByFile(file2, file1, 0, 145);
  6141 + }
  6142 + File newFile = files.get(0);
  6143 + newFile.renameTo(file);
  6144 +// temp.renameTo(new File(path + fileName + "/" + temp.getName()));
  6145 +// File[] listFiles = file.listFiles();
  6146 +// ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path + file.getName() + ".zip")));
  6147 +//// zos.setEncoding("gbk");
  6148 +//// zos.putNextEntry(new ZipEntry(fileName + "/"));
  6149 +// for (int i = 0; i < listFiles.length; i++) {
  6150 +// zos.putNextEntry(new ZipEntry(fileName + "/" + listFiles[i].getName()));
  6151 +// BufferedInputStream bis = new BufferedInputStream(new FileInputStream(listFiles[i]));
  6152 +// BufferedOutputStream bos = new BufferedOutputStream(zos);
  6153 +// int bytesRead = 0;
  6154 +// for (byte[] buffer = new byte[BUF_SIZE]; ((bytesRead = bis.read(buffer, 0, BUF_SIZE)) != -1); ) {
  6155 +//// zos.write(buffer, 0, bytesRead);
  6156 +//// zos.flush();
  6157 +// bos.write(buffer, 0, bytesRead);
  6158 +// bos.flush();
  6159 +// }
  6160 +//// bos.close();
  6161 +// bis.close();
  6162 +// }
  6163 +// zos.close();
  6164 +// }
  6165 +
  6166 + } catch (Exception e) {
  6167 + // TODO: handle exception
  6168 + e.printStackTrace();
  6169 + }
  6170 +
  6171 + map.put("fileName", file.getName());
  6172 + return map;
  6173 + }
  6174 +
  6175 + @Autowired
  6176 + SchedulePlanInfoService schPlanService;
  6177 +
  6178 + @Override
  6179 + public List<SchedulePlanInfo> currentSchedulePlan(String lineCode) {
  6180 + List<SchedulePlanInfo> rs = dayOfSchedule.schedulePlanMap.get(lineCode);
  6181 +
  6182 + if (rs == null || rs.size() == 0) {
  6183 + //尝试刷新内存
  6184 + Map<String, Object> data = new HashMap<>();
  6185 + data.put("scheduleDate_eq", dayOfSchedule.currSchDateMap.get(lineCode));
  6186 + data.put("xlBm_eq", lineCode);
  6187 + List<SchedulePlanInfo> planItr = dayOfSchedule.cleanSchPlanItr(schPlanService.list(data).iterator());
  6188 +
  6189 + if (planItr.size() > 0) {
  6190 + dayOfSchedule.schedulePlanMap.put(lineCode, planItr);
  6191 + return planItr;
  6192 + }
  6193 + }
  6194 + return rs;
  6195 + }
  6196 +
  6197 +
  6198 + @Override
  6199 + public Map<String, Object> lpChangeMulti(String leftIdx, String rightIdx, int type) {
  6200 + Map<String, Object> rs = new HashMap<>();
  6201 + Set<ScheduleRealInfo> ts = new HashSet<>();
  6202 + try {
  6203 + List<String> leftList = Splitter.on(",").splitToList(leftIdx);
  6204 + List<String> rightList = Splitter.on(",").splitToList(rightIdx);
  6205 + Set<String> lpSet = new HashSet<>();
  6206 + Set<String> carSet = new HashSet<>();
  6207 +
  6208 + List<ScheduleRealInfo> largeList, smallList;
  6209 + if (leftList.size() > rightList.size()) {
  6210 + largeList = getByIdx(leftList);
  6211 + smallList = getByIdx(rightList);
  6212 + } else {
  6213 + largeList = getByIdx(rightList);
  6214 + smallList = getByIdx(leftList);
  6215 + }
  6216 +
  6217 + ScheduleRealInfo leftSch, rightSch = null;
  6218 + for (int i = 0; i < largeList.size(); i++) {
  6219 + leftSch = largeList.get(i);
  6220 + leftSch.setLpChange(1);
  6221 + if (i < smallList.size()) {
  6222 + rightSch = smallList.get(i);
  6223 + rightSch.setLpChange(1);
  6224 + ts.add(rightSch);
  6225 + } else {
  6226 + //不对称时多出来的
  6227 + lpChangeByLeft(leftSch, largeList.get(i - 1), type);
  6228 + ts.add(leftSch);
  6229 + lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName());
  6230 + continue;
  6231 + }
  6232 +
  6233 + //调换路牌
  6234 + lpChange(leftSch, rightSch, type);
  6235 + ts.add(leftSch);
  6236 +
  6237 + lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName());
  6238 + lpSet.add(rightSch.getXlBm() + "_" + rightSch.getLpName());
  6239 +
  6240 + carSet.add(leftSch.getClZbh());
  6241 + carSet.add(rightSch.getClZbh());
  6242 + scheduleRealInfoRepository.updateLpChange(leftSch.getId());
  6243 + scheduleRealInfoRepository.updateLpChange(rightSch.getId());
  6244 + }
  6245 +
  6246 + //重新计算路牌的起点应到时间
  6247 + for (String lpName : lpSet) {
  6248 + ts.addAll(dayOfSchedule.updateQdzTimePlan(lpName));
  6249 + }
  6250 +
  6251 + //重新就算车辆当前执行班次
  6252 + for(String nbbm : carSet){
  6253 + dayOfSchedule.reCalcExecPlan(nbbm);
  6254 + }
  6255 +
  6256 +
  6257 + for (ScheduleRealInfo sch : ts) {
  6258 + dayOfSchedule.save(sch);
  6259 + }
  6260 +
  6261 + rs.put("status", ResponseCode.SUCCESS);
  6262 + rs.put("ts", ts);
  6263 + } catch (Exception e) {
  6264 + logger.error("", e);
  6265 + rs.put("status", ResponseCode.ERROR);
  6266 + rs.put("msg", e.getMessage());
  6267 + }
  6268 +
  6269 + return rs;
  6270 + }
  6271 +
  6272 + private List<ScheduleRealInfo> getByIdx(List<String> idList) {
  6273 + List<ScheduleRealInfo> list = new ArrayList<>();
  6274 + for (String id : idList) {
  6275 + list.add(dayOfSchedule.get(Long.parseLong(id)));
  6276 + }
  6277 + return list;
  6278 + }
  6279 +
  6280 + @Override
  6281 + public void lpChange(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) {
  6282 + //释放班次映射
  6283 + if (type > 0) {
  6284 + dayOfSchedule.removeNbbm2SchMapp(leftSch);
  6285 + dayOfSchedule.removeNbbm2SchMapp(rightSch);
  6286 + }
  6287 +
  6288 + //对调数据
  6289 + LpData leftData = new LpData(leftSch);
  6290 + LpData rightData = new LpData(rightSch);
  6291 +
  6292 + leftData.appendTo(rightSch, type);
  6293 + rightData.appendTo(leftSch, type);
  6294 +
  6295 + if (type > 0) {
  6296 + //重新映射
  6297 + dayOfSchedule.addNbbm2SchMapp(leftSch);
  6298 + dayOfSchedule.addNbbm2SchMapp(rightSch);
  6299 + }
  6300 + }
  6301 +
  6302 + /**
  6303 + * 更换左边班次的路牌,右边不变
  6304 + *
  6305 + * @param leftSch
  6306 + * @param rightSch
  6307 + * @param type
  6308 + */
  6309 + public void lpChangeByLeft(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) {
  6310 + //释放班次映射
  6311 + if (type > 0)
  6312 + dayOfSchedule.removeNbbm2SchMapp(leftSch);
  6313 +
  6314 + LpData rightData = new LpData(rightSch);
  6315 + rightData.appendTo(leftSch, type);
  6316 +
  6317 + //重新映射
  6318 + if (type > 0)
  6319 + dayOfSchedule.addNbbm2SchMapp(leftSch);
  6320 +
  6321 + }
  6322 +
  6323 + @Override
  6324 + public Map<String, Object> revokeRealArrive(Long id) {
  6325 + Map<String, Object> rs = new HashMap<>();
  6326 + List<ScheduleRealInfo> ts = new ArrayList<>();
  6327 +
  6328 + try {
  6329 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  6330 + if (sch.getZdsjActual() == null && sch.getFcsjActual() == null) {
  6331 + rs.put("status", ResponseCode.ERROR);
  6332 + rs.put("msg", "班次未执行,无法撤销!");
  6333 + } else {
  6334 + //日志记录
  6335 + ScheduleModifyLogger.cxzx(sch);
  6336 +
  6337 + sch.clearFcsjActual();
  6338 + sch.clearZdsjActual();
  6339 + //清除路牌下一个班的起点到达时间
  6340 + ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);
  6341 + if (null != next) {
  6342 + next.setQdzArrDatesj(null);
  6343 + ts.add(next);
  6344 + }
  6345 +
  6346 + rs.put("status", ResponseCode.SUCCESS);
  6347 +
  6348 + ts.add(sch);
  6349 + rs.put("ts", ts);
  6350 +
  6351 + dayOfSchedule.save(sch);
  6352 + //重新计算当前执行班次
  6353 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
  6354 +
  6355 + }
  6356 + } catch (Exception e) {
  6357 + logger.error("", e);
  6358 + rs.put("status", ResponseCode.ERROR);
  6359 + }
  6360 + return rs;
  6361 + }
  6362 +
  6363 + @Override
  6364 + public Map<String, Object> lateAdjust(String idx, float minute) {
  6365 + Map<String, Object> rs = new HashMap<>();
  6366 + try {
  6367 + int count = 0;
  6368 + List<ScheduleRealInfo> list = new ArrayList<>();
  6369 + List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx);
  6370 +
  6371 + ScheduleRealInfo sch;
  6372 + for (String id : ids) {
  6373 + sch = dayOfSchedule.get(Long.parseLong(id));
  6374 + if (sch != null && sch.getStatus() == 0) {
  6375 + if (minute > 0) {
  6376 + sch.setLateMinute(minute);
  6377 + } else if (minute == 0) {
  6378 + LateAdjustHandle.remove(sch);
  6379 + }
  6380 + count++;
  6381 + list.add(sch);
  6382 + }
  6383 + }
  6384 +
  6385 + rs.put("status", ResponseCode.SUCCESS);
  6386 + rs.put("count", count);
  6387 + rs.put("ts", list);
  6388 + } catch (Exception e) {
  6389 + logger.error("", e);
  6390 + rs.put("status", ResponseCode.ERROR);
  6391 + rs.put("msg", e.getMessage());
  6392 + }
  6393 +
  6394 + return rs;
  6395 + }
  6396 +
  6397 + @Override
  6398 + public List<ScheduleRealInfo> allLate2(String idx) {
  6399 + List<ScheduleRealInfo> rs = new ArrayList<>();
  6400 + List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx);
  6401 +
  6402 + Collection<ScheduleRealInfo> all = LateAdjustHandle.allLateSch();
  6403 + for (ScheduleRealInfo sch : all) {
  6404 + if (ids.indexOf(sch.getXlBm()) != -1) {
  6405 + rs.add(sch);
  6406 + }
  6407 + }
  6408 + return rs;
  6409 + }
  6410 +
  6411 +
  6412 + @Override
  6413 + public List<Map<String, Object>> mileageReport(String gsdm,
  6414 + String fgsdm, String line, String date, String date2) {
  6415 +
  6416 + String sql = "select * from calc_mileage where 1=1 ";
  6417 + if (!line.equals(" ")) {
  6418 + sql = sql + " and line_code='" + line + "' ";
  6419 + }
  6420 + sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'";
  6421 + if (!gsdm.equals(" ")) {
  6422 + sql = sql + " and company_id=" + gsdm;
  6423 + }
  6424 + if (!gsdm.equals(" ")) {
  6425 + sql = sql + " and sub_company_id=" + fgsdm;
  6426 + }
  6427 + sql = sql + " order by line_code";
  6428 + List<MileageReport> list = jdbcTemplate.query(sql,
  6429 + new RowMapper<MileageReport>() {
  6430 + @Override
  6431 + public MileageReport mapRow(ResultSet rs, int rowNum) throws SQLException {
  6432 + MileageReport mr = new MileageReport();
  6433 + mr.setCompanyName(rs.getString("company_name"));
  6434 + mr.setSubCompanyName(rs.getString("sub_company_name"));
  6435 + mr.setLineName(rs.getString("line_name"));
  6436 + mr.setSjyygl(rs.getDouble("sjyygl"));
  6437 + mr.setSjksgl(rs.getDouble("sjksgl"));
  6438 + mr.setZgl(rs.getDouble("zyygl"));
  6439 + mr.setZddfgl(rs.getDouble("zddfgl"));
  6440 + mr.setSddfgl(rs.getDouble("sddfgl"));
  6441 + mr.setWqwxhgl(rs.getDouble("wqwxhgl"));
  6442 + mr.setBfwxhgl(rs.getDouble("bfwxhgl"));
  6443 + mr.setPygl(rs.getDouble("pygl"));
  6444 + mr.setLjgl(rs.getDouble("ljgl"));
  6445 + mr.setZrwgl(rs.getDouble("zrwgl"));
  6446 + mr.setOther(rs.getString("other"));
  6447 + return mr;
  6448 + }
  6449 + });
  6450 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  6451 + double sjyygl = 0.0;
  6452 + double sjksgl = 0.0;
  6453 + double zgl = 0.0;
  6454 + double sddfgl = 0.0;
  6455 + double zddfgl = 0.0;
  6456 + double wqwxhgl = 0.0;
  6457 + double bfwxhgl = 0.0;
  6458 + double pygl = 0.0;
  6459 + double ljgl = 0.0;
  6460 + double zrwgl = 0.0;
  6461 + for (MileageReport mr : list) {
  6462 + Map<String, Object> resMap = new HashMap<String, Object>();
  6463 + resMap.put("gsName", mr.getCompanyName());
  6464 + resMap.put("fgsName", mr.getSubCompanyName());
  6465 + resMap.put("xlName", mr.getLineName());
  6466 + resMap.put("sjyygl", mr.getSjyygl());
  6467 + resMap.put("sjksgl", mr.getSjksgl());
  6468 + resMap.put("zgl", mr.getZgl());
  6469 + resMap.put("sddfgl", mr.getSddfgl());
  6470 + resMap.put("zddfgl", mr.getZddfgl());
  6471 + resMap.put("wqwxhgl", mr.getWqwxhgl());
  6472 + resMap.put("bfwxhgl", mr.getBfwxhgl());
  6473 + resMap.put("pygl", mr.getPygl());
  6474 + resMap.put("ljgl", mr.getLjgl());
  6475 + resMap.put("zrwgl", mr.getZrwgl());
  6476 + resMap.put("other", mr.getOther());
  6477 + lMap.add(resMap);
  6478 + sjyygl = Arith.add(sjyygl, mr.getSjyygl());
  6479 + sjksgl = Arith.add(sjksgl, mr.getSjksgl());
  6480 + zgl = Arith.add(zgl, mr.getZgl());
  6481 + sddfgl = Arith.add(sddfgl, mr.getSddfgl());
  6482 + zddfgl = Arith.add(zddfgl, mr.getZddfgl());
  6483 + wqwxhgl = Arith.add(wqwxhgl, mr.getWqwxhgl());
  6484 + bfwxhgl = Arith.add(bfwxhgl, mr.getBfwxhgl());
  6485 + pygl = Arith.add(pygl, mr.getPygl());
  6486 + ljgl = Arith.add(ljgl, mr.getLjgl());
  6487 + zrwgl = Arith.add(zrwgl, mr.getZrwgl());
  6488 + }
  6489 + Map<String, Object> resMap = new HashMap<String, Object>();
  6490 + resMap.put("xlName", "合计");
  6491 + resMap.put("sjyygl", sjyygl);
  6492 + resMap.put("sjksgl", sjksgl);
  6493 + resMap.put("zgl", zgl);
  6494 + resMap.put("sddfgl", sddfgl);
  6495 + resMap.put("zddfgl", zddfgl);
  6496 + resMap.put("wqwxhgl", wqwxhgl);
  6497 + resMap.put("bfwxhgl", bfwxhgl);
  6498 + resMap.put("pygl", pygl);
  6499 + resMap.put("ljgl", ljgl);
  6500 + resMap.put("zrwgl", zrwgl);
  6501 + resMap.put("other", null);
  6502 + lMap.add(resMap);
  6503 + return lMap;
  6504 + }
  6505 +
  6506 + @Override
  6507 + public List<Map<String, Object>> scheduleCorrectionReport(String gsdm,
  6508 + String fgsdm, String line, String date, String date2) {
  6509 +
  6510 + String sql = "select * from calc_schedule where 1=1 ";
  6511 + if (!line.equals(" ")) {
  6512 + sql = sql + " and line_code='" + line + "' ";
  6513 + }
  6514 + sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'";
  6515 + if (!gsdm.equals(" ")) {
  6516 + sql = sql + " and company_id=" + gsdm;
  6517 + }
  6518 + if (!gsdm.equals(" ")) {
  6519 + sql = sql + " and sub_company_id=" + fgsdm;
  6520 + }
  6521 + sql = sql + " order by line_code";
  6522 + List<ScheduleCorrectionReport> list = jdbcTemplate.query(sql,
  6523 + new RowMapper<ScheduleCorrectionReport>() {
  6524 + @Override
  6525 + public ScheduleCorrectionReport mapRow(ResultSet rs, int rowNum) throws SQLException {
  6526 + ScheduleCorrectionReport sReport = new ScheduleCorrectionReport();
  6527 + sReport.setCompanyName(rs.getString("company_name"));
  6528 + sReport.setSubCompanyName(rs.getString("sub_company_name"));
  6529 + sReport.setLineName(rs.getString("line_name"));
  6530 + sReport.setSjyybc(rs.getInt("sjyybc"));
  6531 + sReport.setSjksbc(rs.getInt("sjksbc"));
  6532 + sReport.setZbc(rs.getInt("zyybc"));
  6533 + sReport.setZddfbc(rs.getInt("zddfbc"));
  6534 + sReport.setSddfbc(rs.getInt("sddfbc"));
  6535 + sReport.setWqwxhbc(rs.getInt("wqwxhbc"));
  6536 + sReport.setBfwxhbc(rs.getInt("bfwxhbc"));
  6537 + sReport.setPybc(rs.getInt("pybc"));
  6538 + sReport.setLjbc(rs.getInt("ljbc"));
  6539 + sReport.setZrwbc(rs.getInt("zrwbc"));
  6540 + sReport.setOther(rs.getString("other"));
  6541 + return sReport;
  6542 + }
  6543 + });
  6544 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  6545 + int sjyybc = 0;
  6546 + int sjksbc = 0;
  6547 + int zbc = 0;
  6548 + int sddfbc = 0;
  6549 + int zddfbc = 0;
  6550 + int wqwxhbc = 0;
  6551 + int bfwxhbc = 0;
  6552 + int pybc = 0;
  6553 + int ljbc = 0;
  6554 + int zrwbc = 0;
  6555 + for (ScheduleCorrectionReport sReport : list) {
  6556 + Map<String, Object> resMap = new HashMap<String, Object>();
  6557 + resMap.put("gsName", sReport.getCompanyName());
  6558 + resMap.put("fgsName", sReport.getSubCompanyName());
  6559 + resMap.put("xlName", sReport.getLineName());
  6560 + resMap.put("sjyybc", sReport.getSjyybc());
  6561 + resMap.put("sjksbc", sReport.getSjksbc());
  6562 + resMap.put("zbc", sReport.getZbc());
  6563 + resMap.put("sddfbc", sReport.getSddfbc());
  6564 + resMap.put("zddfbc", sReport.getZddfbc());
  6565 + resMap.put("wqwxhbc", sReport.getWqwxhbc());
  6566 + resMap.put("bfwxhbc", sReport.getBfwxhbc());
  6567 + resMap.put("pybc", sReport.getPybc());
  6568 + resMap.put("ljbc", sReport.getLjbc());
  6569 + resMap.put("zrwbc", sReport.getZrwbc());
  6570 + resMap.put("other", sReport.getOther());
  6571 + lMap.add(resMap);
  6572 + sjyybc = sjyybc + sReport.getSjyybc();
  6573 + sjksbc = sjksbc + sReport.getSjksbc();
  6574 + zbc = zbc + sReport.getZbc();
  6575 + sddfbc = sddfbc + sReport.getSddfbc();
  6576 + zddfbc = zddfbc + sReport.getZddfbc();
  6577 + wqwxhbc = wqwxhbc + sReport.getWqwxhbc();
  6578 + bfwxhbc = bfwxhbc + sReport.getBfwxhbc();
  6579 + pybc = pybc + sReport.getPybc();
  6580 + ljbc = ljbc + sReport.getLjbc();
  6581 + zrwbc = zrwbc + sReport.getZrwbc();
  6582 + }
  6583 + Map<String, Object> resMap = new HashMap<String, Object>();
  6584 + resMap.put("xlName", "合计");
  6585 + resMap.put("sjyybc", sjyybc);
  6586 + resMap.put("sjksbc", sjksbc);
  6587 + resMap.put("zbc", zbc);
  6588 + resMap.put("sddfbc", sddfbc);
  6589 + resMap.put("zddfbc", zddfbc);
  6590 + resMap.put("wqwxhbc", wqwxhbc);
  6591 + resMap.put("bfwxhbc", bfwxhbc);
  6592 + resMap.put("pybc", pybc);
  6593 + resMap.put("ljbc", ljbc);
  6594 + resMap.put("zrwbc", zrwbc);
  6595 + resMap.put("other", null);
  6596 + lMap.add(resMap);
  6597 + return lMap;
  6598 + }
  6599 +
  6600 + @Override
  6601 + public Integer isCircleQdz(String clzbh, String sdr, String xlbm, String qdzCode) {
  6602 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  6603 + String time =sdf.format(Long.parseLong(sdr));
  6604 +
  6605 + Long num=scheduleRealInfoRepository.isCircleQdz(clzbh, time, xlbm, qdzCode);
  6606 + Integer num2=num==0L?0:1;
  6607 + return num2;
  6608 + }
  6609 +
  6610 + @SuppressWarnings("unchecked")
  6611 + private static Map<String, Object> request(String url) {
  6612 + Map<String, Object> res = new HashMap<String, Object>();
  6613 + res.put("status", ResponseCode.SUCCESS);
  6614 + InputStream in = null;
  6615 + HttpURLConnection con = null;
  6616 + try {
  6617 + con = (HttpURLConnection)new URL(url).openConnection();
  6618 + con.setRequestMethod("POST");
  6619 + con.setRequestProperty("keep-alive", "true");
  6620 + con.setRequestProperty("accept", "application/json");
  6621 + con.setRequestProperty("content-type", "application/json");
  6622 + con.setDoInput(true);
  6623 + con.setReadTimeout(2500);
  6624 + con.setConnectTimeout(2500);
  6625 +
  6626 + con.connect();
  6627 + if (con.getResponseCode() == 200) {
  6628 + in = con.getInputStream();
  6629 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
  6630 + IOUtils.copy(in, bout); bout.close();
  6631 + Map<String, Object> response = new ObjectMapper().readValue(bout.toByteArray(), Map.class);
  6632 + if (!"报修成功".equals(response.get("msg"))) {
  6633 + res.put("status", ResponseCode.ERROR);
  6634 + res.putAll(response);
  6635 + }
  6636 + } else {
  6637 + res.put("status", ResponseCode.ERROR);
  6638 + res.put("msg", "调用上报接口异常");
  6639 + }
  6640 + } catch (IOException e) {
  6641 + // TODO Auto-generated catch block
  6642 + res.put("status", ResponseCode.ERROR);
  6643 + res.put("msg", "调用上报接口异常");
  6644 + } finally {
  6645 + try {
  6646 + if (in != null) in.close();
  6647 + if (con != null) con.disconnect();
  6648 + } catch (IOException e) {
  6649 + // TODO Auto-generated catch block
  6650 + e.printStackTrace();
  6651 + }
  6652 + }
  6653 +
  6654 + return res;
  6655 + }
  6656 +
  6657 + /**
  6658 + ** 维修记录上报
  6659 + * @param param 参数信息
  6660 + * @param isActive 主/被动上报
  6661 + */
  6662 + @Override
  6663 + @Transactional
  6664 + public Map<String, Object> repairReport(Map<String, Object> param, boolean isActive) {
  6665 + Map<String, Object> res = new HashMap<String, Object>();
  6666 + res.put("status", ResponseCode.SUCCESS);
  6667 + // 获取实际排班信息
  6668 + Long id = Long.parseLong((String)param.get("id"));
  6669 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  6670 +
  6671 + if (null == sch) {
  6672 + res.put("status", ResponseCode.ERROR);
  6673 + res.put("msg", "不存在的班次!");
  6674 +
  6675 + return res;
  6676 + }
  6677 +
  6678 + int reportState = -1;
  6679 + SysUser user = SecurityUtils.getCurrentUser();
  6680 + String reportUser = user.getUserName(), reportName = user.getName(), incode = (String)param.get("clZbh"), reportTypes = (String)param.get("reportTypes"), repairTypes = reportType2RepairType(reportTypes);
  6681 + // 分公司保存格式 分公司编码_公司编码
  6682 + String val = BasicData.nbbm2FgsCompanyCodeMap.get(incode);
  6683 + String[] arr = val.split("_");
  6684 + StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1]));
  6685 + url.append("?nbbm=").append(incode).append("&bxy=").append(reportUser).append("&bxbm=").append(repairTypes).append("&fgs=").append(arr[0]);
  6686 +
  6687 + int count = repairReportRepository.repairReportBySch(id, isActive ? 1 : 0);
  6688 + if (count > 0) return res;
  6689 + RepairReport lrr = dayOfSchedule.getLastestRepairReport(incode);
  6690 + // 非主动上报并且无上报记录或上次已上报 则不用上报
  6691 + if (!isActive && (lrr == null || lrr.getReportState() != 0)) {
  6692 + reportState = 0;
  6693 + } else {
  6694 + res = request(url.toString());
  6695 + if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1;
  6696 + }
  6697 + // 持久化此次上报记录
  6698 + RepairReport rr = new RepairReport();
  6699 + rr.setLineId(sch.getXlBm());
  6700 + rr.setLineName(sch.getXlName());
  6701 + rr.setReportUser(reportUser);
  6702 + rr.setReportName(reportName);
  6703 + rr.setSchId(id);
  6704 + rr.setIncode(incode);
  6705 + rr.setDepartureTime(sch.getFcsj());
  6706 + rr.setRepairType(repairTypes);
  6707 + rr.setReportType(reportTypes);
  6708 + rr.setReportDate(new Date());
  6709 + rr.setReportState(reportState);
  6710 + rr.setReportMode(isActive ? 1 : 0);
  6711 + rr = repairReportRepository.save(rr);
  6712 + dayOfSchedule.setLastestRepairReport(rr);
  6713 + // 如果上报失败,放到重传队列
  6714 + if (rr.getReportState() == -1) queue.add(rr);
  6715 +
  6716 + return res;
  6717 + }
  6718 +
  6719 + private void repairReport(RepairReport rr) {
  6720 + int reportState = -1;
  6721 + // 分公司保存格式 分公司编码_公司编码
  6722 + String val = BasicData.nbbm2FgsCompanyCodeMap.get(rr.getIncode());
  6723 + String[] arr = val.split("_");
  6724 + StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1]));
  6725 + url.append("?nbbm=").append(rr.getIncode()).append("&bxy=").append(rr.getReportUser()).append("&bxbm=").append(rr.getRepairType()).append("&fgs=").append(arr[0]);
  6726 +
  6727 + Map<String, Object> res = request(url.toString());
  6728 + if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1;
  6729 + if (reportState == 1) {
  6730 + rr.setReportState(1);
  6731 + repairReportRepository.save(rr);
  6732 + }
  6733 + }
  6734 +
  6735 + /**
  6736 + ** 业务类型转报修类型
  6737 + */
  6738 + private String reportType2RepairType(String reportType) {
  6739 + String[] reportTypes = reportType.split(";");
  6740 + List<String> repairTypes = new ArrayList<>();
  6741 + for (String rt : reportTypes) {
  6742 + repairTypes.add(report2repair.get(rt));
  6743 + }
  6744 +
  6745 + return StringUtils.join(repairTypes, ";");
  6746 + }
  6747 +
  6748 + @Override
  6749 + public List<RepairReport> repairReportList(String lineId, String date, String incode, String type) {
  6750 + List<RepairReport> result = new ArrayList<RepairReport>();
  6751 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  6752 +
  6753 + Date start = null, end = null;
  6754 + if (date.length() > 0) {
  6755 + try {
  6756 + start = sdf.parse(date + " 00:00:00");
  6757 + end = sdf.parse(date + " 23:59:59");
  6758 + } catch (ParseException e) {
  6759 + // TODO Auto-generated catch block
  6760 + e.printStackTrace();
  6761 + }
  6762 +
  6763 + }
  6764 +
  6765 + result = repairReportRepository.repairReportList(lineId, start, end, incode);
  6766 + Map<String, Object> dMap=new HashMap<>();
  6767 + dMap.put("dGroup_eq", "repairtype");
  6768 + Map<String, String> code2name = new HashMap<String, String>();
  6769 + for (Dictionary dic : dictionaryService.list(dMap)) {
  6770 + code2name.put(dic.getdCode(), dic.getdName());
  6771 + }
  6772 + for (RepairReport rr : result) {
  6773 + String reportType = rr.getReportType();
  6774 + String[] types = reportType.split(";");
  6775 + StringBuilder sb = new StringBuilder();
  6776 +
  6777 + for (String t : types) {
  6778 + sb.append(code2name.get(t)).append(";");
  6779 + }
  6780 +
  6781 + rr.setRepairType(sb.toString());
  6782 + rr.setReportDateStr(sdf.format(rr.getReportDate()));
  6783 + switch (rr.getReportState()) {
  6784 + case 0:
  6785 + rr.setReportStateStr("不报");
  6786 + break;
  6787 + case 1:
  6788 + rr.setReportStateStr("上报成功");
  6789 + break;
  6790 + case -1:
  6791 + rr.setReportStateStr("上报失败");
  6792 + break;
  6793 + default:
  6794 + break;
  6795 + }
  6796 + }
  6797 +
  6798 + if ("export".equals(type)) {
  6799 + String lineName = BasicData.lineCode2NameMap.get(lineId);
  6800 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  6801 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  6802 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  6803 + Map<String, Object> m = new HashMap<String, Object>();
  6804 + ReportUtils ee = new ReportUtils();
  6805 + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
  6806 + for (int i = 0; i < result.size(); i++) {
  6807 + Map<String, Object> map = new HashMap<String, Object>();
  6808 + RepairReport rr = result.get(i);
  6809 + map.put("row", i + 1);
  6810 + map.put("lineId", rr.getLineName());
  6811 + map.put("incode", rr.getIncode());
  6812 + map.put("departureTime", rr.getDepartureTime());
  6813 + map.put("reportUser", rr.getReportUser());
  6814 + map.put("reportDateStr", rr.getReportDate());
  6815 + map.put("repairType", rr.getRepairType());
  6816 + map.put("reportStateStr", rr.getReportStateStr());
  6817 + newList.add(map);
  6818 + }
  6819 + try {
  6820 + listI.add(newList.iterator());
  6821 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  6822 + ee.excelReplace(listI, new Object[]{m}, path + "mould/repairReport.xls",
  6823 + path + "export/" + sdfSimple.format(sdfMonth.parse(date))
  6824 + + "-" + lineName + "-维修上报记录.xls");
  6825 + } catch (Exception e) {
  6826 + // TODO: handle exception
  6827 + e.printStackTrace();
  6828 + }
  6829 + }
  6830 +
  6831 + return result;
  6832 + }
  6833 +
  6834 + @Override
  6835 + public Map<String, String> getLevelsByLines(List<String> lines) {
  6836 + Map<String, String> result = new HashMap<String, String>(), currSchDate = dayOfSchedule.getCurrSchDate();
  6837 + for (String line : lines) {
  6838 + String level = BasicData.lineDate2Level.get(line + "_" + currSchDate.get(line));
  6839 + result.put(line, level == null ? "" : level);
  6840 + }
  6841 +
  6842 + return result;
  6843 + }
  6844 +
  6845 +
  6846 + @Override
  6847 + public void destroy() throws Exception {
  6848 + // TODO Auto-generated method stub
  6849 + exec.shutdown();
  6850 + }
  6851 +
  6852 +
  6853 + @Override
  6854 + public void afterPropertiesSet() throws Exception {
  6855 + // TODO Auto-generated method stub
  6856 + // 维修上报重发调度
  6857 + exec.scheduleAtFixedRate(new Runnable() {
  6858 +
  6859 + @Override
  6860 + public void run() {
  6861 + // TODO Auto-generated method stub
  6862 + try {
  6863 + Iterator<RepairReport> it = queue.iterator();
  6864 + while (it.hasNext()) {
  6865 + RepairReport rr = it.next();
  6866 + repairReport(rr);
  6867 + if (rr.getReportState() == 1 || System.currentTimeMillis() - rr.getReportDate().getTime() > 86400000) queue.remove(rr);
  6868 + }
  6869 + } catch (Exception e) {
  6870 + logger.error("维修上报重发错误", e);
  6871 + }
  6872 + }
  6873 + }, 30, 30, TimeUnit.MINUTES);
  6874 +
  6875 + //// ---
  6876 + exec.scheduleWithFixedDelay(new Runnable() {
  6877 + @Override
  6878 + public void run() {
  6879 + Map<String, Object> res = new HashMap<>();
  6880 + InputStream in = null;
  6881 + String url ="http://211.95.61.66:9008/modules/tSafedrivingCs/DSMBHforCLBH";
  6882 +
  6883 + try {
  6884 + HttpURLConnection con = (HttpURLConnection)new URL(url.toString()).openConnection();
  6885 + con.setDoInput(true);
  6886 + con.setRequestMethod("POST");
  6887 + con.setConnectTimeout(5000);
  6888 + con.setReadTimeout(5000);
  6889 + con.setRequestProperty("keep-alive", "true");
  6890 + con.setRequestProperty("accept", "*/*");
  6891 + con.setRequestProperty("content-type", "application/x-www-form-urlencoded");
  6892 + con.connect();
  6893 +
  6894 + if (con.getResponseCode() == 200) {
  6895 + in = con.getInputStream();
  6896 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
  6897 + IOUtils.copy(in, bout);
  6898 + DIRMAP = new ObjectMapper().readValue(bout.toByteArray(), Map.class);
  6899 + }
  6900 + logger.info("IP打电话接口查询完成");
  6901 + } catch (MalformedURLException e) {
  6902 + // TODO Auto-generated catch block
  6903 + e.printStackTrace();
  6904 + logger.error("IP打电话接口出错",e);
  6905 + } catch (IOException e) {
  6906 + // TODO Auto-generated catch block
  6907 + e.printStackTrace();
  6908 + }
  6909 +
  6910 + }
  6911 + }, 0, 10, TimeUnit.MINUTES);
  6912 + }
  6913 +}
  6914 +
  6915 +class AccountMap implements Comparator<Map<String, Object>> {
  6916 + @Override
  6917 + public int compare(Map<String, Object> o1, Map<String, Object> o2) {
  6918 + // TODO Auto-generated method stub
  6919 + return o1.get("clZbh").toString().compareTo(o2.get("clZbh").toString());
  6920 + }
  6921 +}
  6922 +
  6923 +class AccountMap2 implements Comparator<Map<String, Object>> {
  6924 + @Override
  6925 + public int compare(Map<String, Object> o1, Map<String, Object> o2) {
  6926 + // TODO Auto-generated method stub
  6927 + return o2.get("clZbh").toString().compareTo(o1.get("clZbh").toString());
  6928 + }
  6929 +}
  6930 +
  6931 +class AccountXlbm implements Comparator<Map<String, Object>> {
  6932 + @Override
  6933 + public int compare(Map<String, Object> o1, Map<String, Object> o2) {
  6934 + // TODO Auto-generated method stub
  6935 +// PinyinHelper.convertToPinyinString(ppy.getName(),
  6936 +// "" , PinyinFormat.WITHOUT_TONE)
  6937 + return o1.get("xlNamePy").toString().compareTo(
  6938 + o2.get("xlNamePy").toString());
  6939 + }
  6940 +}
  6941 +
  6942 +class compareLpFcsjType implements Comparator<ScheduleRealInfo> {
  6943 + @Override
  6944 + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
  6945 + // TODO Auto-generated method stub
  6946 + return (o1.getLpName()+o1.getFcsjT() + o1.getRemark()).compareTo(o2.getLpName()+o2.getFcsjT() + o2.getRemark());
  6947 + }
  6948 +
  6949 +}
  6950 +
  6951 +class compareDirLpFcsjType implements Comparator<ScheduleRealInfo> {
  6952 + @Override
  6953 + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
  6954 + // TODO Auto-generated method stub
  6955 + return (o1.getXlDir()+o1.getFcsjT() + o1.getRemark()+o1.getLpName()).compareTo(o2.getXlDir()+o2.getFcsjT() + o2.getRemark()+o2.getLpName());
  6956 + }
  6957 +
  6958 +}
  6959 +class compareFcsjType implements Comparator<ScheduleRealInfo> {
  6960 + @Override
  6961 + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
  6962 + // TODO Auto-generated method stub
  6963 + return (o1.getFcsjT() + o1.getRemark()).compareTo(o2.getFcsjT() + o2.getRemark());
  6964 + }
  6965 +
  6966 +}