Commit 65ac686b701dd66019da06b10df2b0bdd7aebc6e

Authored by 娄高锋
1 parent 1aa8b03f

行车路单添加:发车误点快慢(包括导出)

src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
@@ -2954,6 +2954,36 @@ public class BusIntervalServiceImpl implements BusIntervalService { @@ -2954,6 +2954,36 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2954 maps.put("fast", ""); 2954 maps.put("fast", "");
2955 maps.put("slow", ""); 2955 maps.put("slow", "");
2956 } 2956 }
  2957 +
  2958 + String fcsj = scheduleRealInfo.getFcsj();
  2959 + String fcsjActual = scheduleRealInfo.getFcsjActual();
  2960 + if (fcsj != null && fcsjActual != null &&
  2961 + !fcsj.equals(fcsjActual) &&
  2962 + !fcsj.equals("") &&
  2963 + !fcsjActual.equals("")) {
  2964 + int fcsjT = Integer.valueOf(fcsj.split(":")[0]) * 60 + Integer.valueOf(fcsj.split(":")[1]);
  2965 + int fcsjAT = Integer.valueOf(fcsjActual.split(":")[0]) * 60 + Integer.valueOf(fcsjActual.split(":")[1]);
  2966 + if (fcsj.compareTo(fcsjActual) > 0) {
  2967 + if (fcsjT - fcsjAT > 1000) {
  2968 + maps.put("fast_start", "");
  2969 + maps.put("slow_start", fcsjAT - fcsjT + 1440);
  2970 + } else {
  2971 + maps.put("fast_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));
  2972 + maps.put("slow_start", "");
  2973 + }
  2974 + } else {
  2975 + if (fcsjAT - fcsjT > 1000) {
  2976 + maps.put("fast_start", fcsjT - fcsjAT + 1440);
  2977 + maps.put("slow_start", "");
  2978 + } else {
  2979 + maps.put("fast_start", "");
  2980 + maps.put("slow_start", TimeUtils.getTimeDifference(fcsj, fcsjActual));
  2981 + }
  2982 + }
  2983 + } else {
  2984 + maps.put("fast_start", "");
  2985 + maps.put("slow_start", "");
  2986 + }
2957 listMap.add(maps); 2987 listMap.add(maps);
2958 } catch (Exception e) { 2988 } catch (Exception e) {
2959 e.printStackTrace(); 2989 e.printStackTrace();
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 - listMap.add(maps);  
1266 - } catch (Exception e) {  
1267 - e.printStackTrace();  
1268 - }  
1269 - }  
1270 -  
1271 - String xls = "";  
1272 - if (map.get("type").toString().equals("0")) {  
1273 - xls = "waybill_minhang.xls";  
1274 - } else {  
1275 - xls = "waybill_minhang_dl.xls";  
1276 - }  
1277 -  
1278 -  
1279 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
1280 -  
1281 - list.add(listMap.iterator());  
1282 - ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/" + xls,  
1283 - path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");  
1284 - return scheduleRealInfos;  
1285 - }  
1286 -  
1287 - @Override  
1288 - public List<Map<String, Object>> dailyInfo(String line, String date, String type) {  
1289 - DecimalFormat format = new DecimalFormat("0.00");  
1290 - ReportUtils ee = new ReportUtils();  
1291 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
1292 - List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date);  
1293 -  
1294 - double totalZGL = 0, totalKSGL = 0, totalYH = 0;  
1295 - int totalBCS = 0;  
1296 - for (int i = 0; i < list.size(); i++) {  
1297 - String zgl = format.format(Double.parseDouble(list.get(i).get("zgl") == null ? "0" : list.get(i).get("zgl").toString()));  
1298 - String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl") == null ? "0" : list.get(i).get("ksgl").toString()));  
1299 - if (type.equals("export")) {  
1300 - totalZGL += Double.parseDouble(zgl);  
1301 - totalKSGL += Double.parseDouble(ksgl);  
1302 - totalBCS += Integer.parseInt(list.get(i).get("bcs").toString());  
1303 - }  
1304 - list.get(i).put("zgl", zgl);  
1305 - list.get(i).put("ksgl", ksgl);  
1306 - }  
1307 - if (type.equals("export")) {  
1308 - Map<String, Object> map = new HashMap<String, Object>();  
1309 - map.put("line", line);  
1310 - map.put("date", date);  
1311 - map.put("totalZGL", totalZGL);  
1312 - map.put("totalKSGL", totalKSGL);  
1313 - map.put("totalYH", totalYH);  
1314 - map.put("totalBCS", totalBCS);  
1315 -  
1316 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
1317 -  
1318 - listI.add(list.iterator());  
1319 - try {  
1320 - ee.excelReplace(listI, new Object[]{map}, path + "mould/daily.xls",  
1321 - path + "export/班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");  
1322 - } catch (ParseException e) {  
1323 - e.printStackTrace();  
1324 - }  
1325 - }  
1326 - return list;  
1327 - }  
1328 -  
1329 - @Override  
1330 - public List<Object[]> historyMessage(String line, String date, String code, String type) {  
1331 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
1332 -  
1333 - long d = 0;  
1334 - long t = 0;  
1335 - if (date.length() > 0) {  
1336 - try {  
1337 - d = sdf.parse(date + " 00:00:00").getTime();  
1338 - t = sdf.parse(date + " 23:59:59").getTime();  
1339 - } catch (ParseException e) {  
1340 - // TODO Auto-generated catch block  
1341 - e.printStackTrace();  
1342 - }  
1343 -  
1344 - }  
1345 - String device = "";  
1346 - String device2 ="";  
1347 - long qyrqTime=0l;  
1348 - if (!code.equals("")) {  
1349 - try {  
1350 - List<CarDevice> deviceList=carDeviceRepository.findCarCode(code, sdf.parse(date+ " 00:00:00"));  
1351 - if(deviceList.size()>0){  
1352 - device=deviceList.get(0).getOldDeviceNo();  
1353 - Date qyrq=deviceList.get(0).getQyrq();  
1354 - qyrqTime=qyrq.getTime();  
1355 - if(qyrqTime<t){  
1356 - device2=deviceList.get(0).getNewDeviceNo();  
1357 - }  
1358 - }else{  
1359 - device = BasicData.deviceId2NbbmMap.inverse().get(code);  
1360 - }  
1361 - } catch (ParseException e) {  
1362 - // TODO Auto-generated catch block  
1363 - e.printStackTrace();  
1364 - }  
1365 - }  
1366 - List<Object[]> list=new ArrayList<Object[]>();  
1367 -  
1368 - device = device.replaceAll("BF-", "");  
1369 - List<Object[]> list0 =scheduleRealInfoRepository.historyMessage(line, device, d, t);  
1370 - for (Object[] obj : list0) {  
1371 - if (obj != null) {  
1372 - if(code.equals("")){  
1373 - if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) {  
1374 - List<CarDevice> carDeviceList = new ArrayList<CarDevice>();  
1375 - try {  
1376 - carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString())));  
1377 - //启用日期大于营运日期 还是根据旧设备号查询  
1378 - if(carDeviceList.size()==0){  
1379 - carDeviceList = carDeviceRepository.findCarOldDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString())));  
1380 - }  
1381 - } catch (Exception e) {  
1382 - // TODO Auto-generated catch block  
1383 - e.printStackTrace();  
1384 - }  
1385 - if (carDeviceList.size() > 0) {  
1386 - obj[0] = carDeviceList.get(0).getClZbh();  
1387 - } else {  
1388 - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString());  
1389 - }  
1390 - } else {  
1391 - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString());  
1392 - }  
1393 - }else{  
1394 - obj[0]=code;  
1395 - }  
1396 -  
1397 - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));  
1398 - obj[4] = BasicData.lineCode2NameMap.get(line);  
1399 - }  
1400 - }  
1401 - list.addAll(list0);  
1402 - if(!device2.equals("")){  
1403 - device2.replaceAll("BF-", "");  
1404 - List<Object[]> list1 =scheduleRealInfoRepository.historyMessage(line, device2, d, t);  
1405 - for (Object[] obj : list1) {  
1406 - if (obj != null) {  
1407 - obj[0] =code;  
1408 - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));  
1409 - obj[4] = BasicData.lineCode2NameMap.get(line);  
1410 - }  
1411 - }  
1412 - list.addAll(list1);  
1413 - }  
1414 -  
1415 - if (type != null && type.length() != 0 && type.equals("export")) {  
1416 - String lineName = BasicData.lineCode2NameMap.get(line);  
1417 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
1418 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
1419 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
1420 - Map<String, Object> m = new HashMap<String, Object>();  
1421 - ReportUtils ee = new ReportUtils();  
1422 - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();  
1423 - for (int i = 0; i < list.size(); i++) {  
1424 - Map<String, Object> map = new HashMap<String, Object>();  
1425 - Object[] obj = list.get(i);  
1426 - map.put("num", i + 1);  
1427 - map.put("line", obj[4]);  
1428 - map.put("clZbh", obj[0]);  
1429 - map.put("sender", obj[1]);  
1430 - map.put("date", obj[3]);  
1431 - map.put("text", obj[2]);  
1432 - map.put("reply46", "0".equals(obj[5]+"")?"是":"");  
1433 - map.put("reply47", "0".equals(obj[6]+"")?"是":"");  
1434 - newList.add(map);  
1435 - }  
1436 - try {  
1437 - listI.add(newList.iterator());  
1438 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
1439 - ee.excelReplace(listI, new Object[]{m}, path + "mould/historyMessage.xls",  
1440 - path + "export/" + sdfSimple.format(sdfMonth.parse(date))  
1441 - + "-" + lineName + "-调度历史消息.xls");  
1442 - } catch (Exception e) {  
1443 - // TODO: handle exception  
1444 - e.printStackTrace();  
1445 - }  
1446 - }  
1447 -  
1448 - if (type != null && type.length() != 0 && type.equals("export_msg")) {  
1449 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
1450 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
1451 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
1452 - Map<String, Object> m = new HashMap<String, Object>();  
1453 - ReportUtils ee = new ReportUtils();  
1454 - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();  
1455 - for (int i = 0; i < list.size(); i++) {  
1456 - Map<String, Object> map = new HashMap<String, Object>();  
1457 - Object[] obj = list.get(i);  
1458 - map.put("num", i + 1);  
1459 - map.put("line", obj[4]);  
1460 - map.put("clZbh", obj[0]);  
1461 - map.put("sender", obj[1]);  
1462 - map.put("date", obj[3]);  
1463 - map.put("text", obj[2]);  
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/message.xls",  
1470 - path + "export/调度消息分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");  
1471 - } catch (Exception e) {  
1472 - // TODO: handle exception  
1473 - e.printStackTrace();  
1474 - }  
1475 - }  
1476 - return list;  
1477 - }  
1478 -  
1479 - @Override  
1480 - public Map<Integer, Integer> trustStatus(String lineStr) {  
1481 - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr));  
1482 -  
1483 - Map<Integer, Integer> map = new HashMap<>();  
1484 - return map;  
1485 - }  
1486 -  
1487 - @Override  
1488 - public Map<String, Object> realOutAdjust(Map<String, String> map) {  
1489 - Map<String, Object> rs = new HashMap<>();  
1490 - List<ScheduleRealInfo> ts = new ArrayList<>();  
1491 - try {  
1492 - // 维修上报  
1493 - if (StringUtils.isNotBlank(map.get("reportTypes"))) {  
1494 - Map<String, Object> param = new HashMap<String, Object>();  
1495 - param.putAll(map);  
1496 - rs = repairReport(param, false);  
1497 - }  
1498 -  
1499 - Long id = Long.parseLong(map.get("id"));  
1500 - String remarks = map.get("remarks"), fcsjActual = map.get("fcsjActual");  
1501 -  
1502 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
1503 -  
1504 - LineConfig config = lineConfigData.get(sch.getXlBm());  
1505 - //小于线路开始运营时间,则默认跨过24点  
1506 - if (fcsjActual.compareTo(config.getStartOpt()) < 0) {  
1507 - sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME));  
1508 - } else {  
1509 - sch.setRealExecDate(sch.getScheduleDateStr());  
1510 - }  
1511 -  
1512 - //日志记录  
1513 - ScheduleModifyLogger.sftz(sch, fcsjActual, remarks);  
1514 -  
1515 - sch.setFcsjActualAll(fcsjActual);  
1516 - sch.setRemarks(remarks);  
1517 - sch.calcStatus();  
1518 - //if(sch.isLate2()){  
1519 - //取消应发未到标记  
1520 - // sch.setLate2(false);  
1521 - LateAdjustHandle.remove(sch);  
1522 - //}  
1523 -  
1524 - dayOfSchedule.save(sch);  
1525 -  
1526 - ts.add(sch);  
1527 -  
1528 - rs.put("status", ResponseCode.SUCCESS);  
1529 - rs.put("ts", ts);  
1530 -  
1531 - //通知页面刷新  
1532 - sendUtils.refreshSch(ts);  
1533 - } catch (Exception e) {  
1534 - logger.error("", e);  
1535 - rs.put("status", ResponseCode.ERROR);  
1536 - }  
1537 -  
1538 - return rs;  
1539 - }  
1540 -  
1541 - @Override  
1542 - public Map<String, Object> revokeDestroy(Long id) {  
1543 - Map<String, Object> rs = new HashMap<>();  
1544 - try {  
1545 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
1546 - if (sch.getStatus() != -1) {  
1547 - rs.put("status", ResponseCode.ERROR);  
1548 - rs.put("msg", "未烂班,无法撤销!");  
1549 - } else {  
1550 - //日志记录  
1551 - ScheduleModifyLogger.cxlb(sch);  
1552 -  
1553 - sch.setStatus(0);  
1554 - sch.setRemarks("");//清空备注  
1555 - sch.setJhlc(sch.getJhlcOrig());  
1556 -  
1557 - //入库  
1558 - dayOfSchedule.save(sch);  
1559 - //重新计算当前执行班次  
1560 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
1561 - rs.put("status", ResponseCode.SUCCESS);  
1562 - rs.put("t", sch);  
1563 -  
1564 - }  
1565 - } catch (Exception e) {  
1566 - logger.error("", e);  
1567 - rs.put("status", ResponseCode.ERROR);  
1568 - }  
1569 - return rs;  
1570 - }  
1571 -  
1572 - @Override  
1573 - public Map<String, Object> revokeRealOutgo(Long id) {  
1574 - Map<String, Object> rs = new HashMap<>();  
1575 - List<ScheduleRealInfo> ts = new ArrayList<>();  
1576 -  
1577 - try {  
1578 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
1579 - if (sch.getFcsjActual() == null) {  
1580 - rs.put("status", ResponseCode.ERROR);  
1581 - rs.put("msg", "无实发时间,无法撤销!");  
1582 - } else {  
1583 - //日志记录  
1584 - ScheduleModifyLogger.cxsf(sch);  
1585 -  
1586 - sch.clearFcsjActual();  
1587 - rs.put("status", ResponseCode.SUCCESS);  
1588 -  
1589 - ts.add(sch);  
1590 - rs.put("ts", ts);  
1591 -  
1592 - dayOfSchedule.save(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> spaceAdjust(Long[] ids, Integer space) {  
1604 -  
1605 - List<ScheduleRealInfo> list = new ArrayList<>(), ts = new ArrayList<>(), tempTs = null;  
1606 - Map<String, Object> rs = new HashMap<>(), tempRs = new HashMap<>();  
1607 - try {  
1608 - ScheduleRealInfo sch, next;  
1609 - for (Long id : ids) {  
1610 - sch = dayOfSchedule.get(id);  
1611 - if (null != sch)  
1612 - list.add(sch);  
1613 - }  
1614 -  
1615 - int size = list.size();  
1616 - if (size == 0) {  
1617 - rs.put("status", ResponseCode.ERROR);  
1618 - } else {  
1619 - // 按发车时间排序  
1620 - Collections.sort(list, new ScheduleComparator.FCSJ());  
1621 -  
1622 - // 以第一个实际发车/待发时间为起点,调整间隔  
1623 - sch = list.get(0);  
1624 - Long st = sch.getFcsjActualTime() == null ? sch.getDfsjT() : sch.getFcsjActualTime(), plus = space * 60 * 1000L;  
1625 -  
1626 - for (int i = 1; i < size; i++) {  
1627 - st += plus;  
1628 - sch = list.get(i);  
1629 -  
1630 - //调整待发  
1631 - tempRs = outgoAdjust(sch.getId(), null, fmtHHmm.print(st), null, "3", null);  
1632 -  
1633 - if (null != tempRs && tempRs.get("ts") != null)  
1634 - tempTs = (List<ScheduleRealInfo>) tempRs.get("ts");  
1635 -  
1636 - ts.addAll(tempTs);  
1637 - }  
1638 -  
1639 - rs.put("status", ResponseCode.SUCCESS);  
1640 - //返回最后一个班次,页面会全量刷新  
1641 - rs.put("ts", ts);  
1642 - }  
1643 -  
1644 - } catch (Exception e) {  
1645 - logger.error("", e);  
1646 - rs.put("status", ResponseCode.ERROR);  
1647 - }  
1648 - return rs;  
1649 - }  
1650 -  
1651 - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");  
1652 -  
1653 - @Transactional  
1654 - @Override  
1655 - public Map<String, Object> schInfoFineTune(Map<String, String> map) {  
1656 - Map<String, Object> rs = new HashMap<>();  
1657 - List<ScheduleRealInfo> ts = new ArrayList<>();  
1658 - try {  
1659 - // 维修上报  
1660 - if (StringUtils.isNotBlank(map.get("reportTypes"))) {  
1661 - Map<String, Object> param = new HashMap<String, Object>();  
1662 - param.putAll(map);  
1663 - rs = repairReport(param, false);  
1664 - }  
1665 -  
1666 - Long id = Long.parseLong(map.get("id"));  
1667 - String remarks = map.get("remarks");  
1668 -  
1669 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
1670 -  
1671 - if (null == sch) {  
1672 - rs.put("status", ResponseCode.ERROR);  
1673 - rs.put("msg", "不存在的班次!");  
1674 - return rs;  
1675 - }  
1676 -  
1677 - //日志记录器  
1678 - FcxxwtLogger fLog = FcxxwtLogger.start(sch, remarks);  
1679 -  
1680 - String clZbh = map.get("clZbh");  
1681 - String jsy = map.get("jsy");  
1682 - if (!clZbh.equals(sch.getClZbh())  
1683 - || !jsy.equals(sch.getjGh() + "/" + sch.getjName()))  
1684 - schModifyLog.saveChangetochange(sch, clZbh, jsy);//为换人换车情况表写入数据  
1685 - /**  
1686 - * 换车  
1687 - */  
1688 - if (StringUtils.isNotEmpty(clZbh) && !clZbh.equals(sch.getClZbh())) {  
1689 - //换车  
1690 - if (!carExist(sch.getGsBm(), clZbh)) {  
1691 - rs.put("status", ResponseCode.ERROR);  
1692 - rs.put("msg", "车辆 " + clZbh + " 不存在!");  
1693 - return rs;  
1694 - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) {  
1695 - rs.put("status", ResponseCode.ERROR);  
1696 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆");  
1697 - return rs;  
1698 - } else {  
1699 - fLog.log("换车", sch.getClZbh(), clZbh);  
1700 - dayOfSchedule.changeCar(sch, clZbh);  
1701 - }  
1702 - }  
1703 -  
1704 - if(StringUtils.isBlank(jsy) || "/".equals(StringUtils.trim(jsy))){  
1705 - rs.put("status", ResponseCode.ERROR);  
1706 - rs.put("msg", "无效的参数【驾驶员】");  
1707 - return rs;  
1708 - }  
1709 -  
1710 - /**  
1711 - * 换驾驶员  
1712 - */  
1713 - if (StringUtils.isNotEmpty(jsy)) {  
1714 - String jGh = jsy.split("/")[0];  
1715 - String jName = getPersonName(sch.getGsBm(), jGh);  
1716 - if (StringUtils.isEmpty(jName)) {  
1717 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员");  
1718 - rs.put("status", ResponseCode.ERROR);  
1719 - return rs;  
1720 - } else if (!jGh.equals(sch.getjGh())) {  
1721 - fLog.log("换驾驶员", sch.getjGh() + "/" + sch.getjName(), jsy);  
1722 - persoChange(sch, jGh);  
1723 - }  
1724 - }  
1725 -  
1726 - /**  
1727 - * 换售票员  
1728 - */  
1729 - String spy = map.get("spy");  
1730 - if (StringUtils.isNotEmpty(spy) && !StringUtils.trim(spy).equals("/")) {  
1731 - String sGh = spy.split("/")[0];  
1732 -  
1733 - String sName = getPersonName(sch.getGsBm(), sGh);  
1734 - if (StringUtils.isEmpty(sName)) {  
1735 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员");  
1736 - rs.put("status", ResponseCode.ERROR);  
1737 - return rs;  
1738 - } else if (!sGh.equals(sch.getsGh())) {  
1739 - fLog.log("换售票员", sch.getsGh() + "/" + sch.getsName(), spy);  
1740 - persoChangeSPY(sch, sGh);  
1741 - }  
1742 - } else if (StringUtils.isNotEmpty(sch.getsGh())) {  
1743 - fLog.log("撤销售票员");  
1744 - sch.setsGh("");  
1745 - sch.setsName("");  
1746 - }  
1747 -  
1748 - LineConfig config = lineConfigData.get(sch.getXlBm());  
1749 - /**  
1750 - * 调整实发  
1751 - */  
1752 - String fcsjActual = map.get("fcsjActual");  
1753 - if (StringUtils.isNotBlank(fcsjActual)  
1754 - && !fcsjActual.equals(sch.getFcsjActual())) {  
1755 -  
1756 - //long t = 0L;  
1757 - //小于线路开始运营时间,则默认跨过24点  
1758 - long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), fcsjActual, config);  
1759 - /* if (fcsjActual.compareTo(config.getStartOpt()) < 0)  
1760 - t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual);  
1761 - else  
1762 - t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual);*/  
1763 -  
1764 - fLog.log("调整实发时间", sch.getFcsjActual(), fcsjActual);  
1765 - sch.setFcsjActualAll(t);  
1766 - //取消应发未到标记  
1767 - //if(sch.isLate2()){  
1768 - // sch.setLate2(false);  
1769 - LateAdjustHandle.remove(sch);  
1770 - //}  
1771 - } else if (StringUtils.isNotEmpty(sch.getFcsjActual()) && StringUtils.isEmpty(fcsjActual)) {  
1772 - fLog.log("撤销实发时间", sch.getFcsjActual(), "");  
1773 - //撤销实发  
1774 - revokeRealOutgo(sch.getId());  
1775 - }  
1776 -  
1777 - /**  
1778 - * 调整实达  
1779 - */  
1780 - String zdsjActual = map.get("zdsjActual");  
1781 - if (StringUtils.isNotBlank(zdsjActual)  
1782 - && !zdsjActual.equals(sch.getZdsjActual())) {  
1783 -  
1784 - //调整实达  
1785 - fLog.log("调整实达时间", sch.getZdsjActual(), zdsjActual);  
1786 -  
1787 - long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), zdsjActual, config);  
1788 - sch.setZdsjActualAll(t);  
1789 - //路牌下一班起点到达时间  
1790 - ScheduleRealInfo next = dayOfSchedule.nextByLp2(sch);  
1791 - if (null != next) {  
1792 - next.setQdzArrDatesj(zdsjActual);  
1793 - next.setLate2(false);  
1794 - ts.add(next);  
1795 - }  
1796 -  
1797 - //重新计算车辆执行班次  
1798 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
1799 - //取消应发未到标记  
1800 - LateAdjustHandle.remove(sch);  
1801 - } else if (StringUtils.isNotEmpty(sch.getZdsjActual()) && StringUtils.isEmpty(zdsjActual)) {  
1802 - //清除实达时间  
1803 - fLog.log("撤销实达时间", sch.getZdsjActual(), "");  
1804 - sch.clearZdsjActual();  
1805 - //清除路牌下一班起点到达时间  
1806 - ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);  
1807 - if (null != next) {  
1808 - next.setQdzArrDatesj(null);  
1809 - ts.add(next);  
1810 - }  
1811 - //重新计算车辆执行班次  
1812 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
1813 - }  
1814 -  
1815 - /**  
1816 - * 备注  
1817 - */  
1818 - sch.setRemarks(remarks);  
1819 -  
1820 - /**  
1821 - * 烂班  
1822 - */  
1823 - if (map.get("status") != null  
1824 - && Integer.parseInt(map.get("status").toString()) == -1) {  
1825 - destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null);  
1826 - fLog.log("烂班");  
1827 - }  
1828 -  
1829 - /**  
1830 - * 修改班次里程  
1831 - */  
1832 - String jhlc = map.get("jhlc");  
1833 - if (StringUtils.isNotEmpty(jhlc)) {  
1834 - double jhlcNum = Double.parseDouble(jhlc);  
1835 - //烂班  
1836 - if (jhlcNum == 0 && sch.getJhlcOrig() != 0 && !sch._isInout() && !sch.isDestroy()) {  
1837 - destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null);  
1838 - fLog.log("里程设置为0,自动烂班");  
1839 - } else if (jhlcNum != sch.getJhlc()) {  
1840 - fLog.log("设置里程", sch.getJhlc(), jhlcNum);  
1841 - sch.setJhlc(jhlcNum);  
1842 - //临加班次,实际计划一起改  
1843 - if (sch.isSflj())  
1844 - sch.setJhlcOrig(jhlcNum);  
1845 - }  
1846 - }  
1847 -  
1848 - /**  
1849 - * 修改班次类型  
1850 - */  
1851 - String bcType = map.get("bcType");  
1852 - if (StringUtils.isNotEmpty(bcType) && !bcType.equals(sch.getBcType())) {  
1853 - fLog.log("修改班次类型", sch.getBcType(), bcType);  
1854 - sch.setBcType(bcType);  
1855 - }  
1856 -  
1857 - //重新计算班次状态  
1858 - sch.calcStatus();  
1859 - dayOfSchedule.save(sch);  
1860 - //页面需要更新的班次信息  
1861 - ts.add(sch);  
1862 -  
1863 - rs.put("status", ResponseCode.SUCCESS);  
1864 - rs.put("ts", ts);  
1865 -  
1866 - //日志记录结束  
1867 - fLog.end();  
1868 - } catch (Exception e) {  
1869 - logger.error("", e);  
1870 - rs.put("status", ResponseCode.ERROR);  
1871 - }  
1872 - return rs;  
1873 - }  
1874 -  
1875 - @Override  
1876 - public Map<String, Object> outgoAdjustAll(String params) {  
1877 - Map<String, Object> rs = new HashMap<>();  
1878 - try {  
1879 - JSONArray jsonArray = JSONArray.parseArray(params);  
1880 -  
1881 - ScheduleRealInfo schedule = null;  
1882 - JSONObject jsonObj;  
1883 - String dfsj;  
1884 - long id;  
1885 - for (int i = 0; i < jsonArray.size(); i++) {  
1886 - jsonObj = jsonArray.getJSONObject(i);  
1887 - dfsj = jsonObj.getString("t");  
1888 - id = jsonObj.getLong("id");  
1889 - schedule = dayOfSchedule.get(id);  
1890 -  
1891 - if (schedule != null)  
1892 - outgoAdjust(id, null, dfsj, null, "2", null);  
1893 - }  
1894 -  
1895 - rs.put("status", ResponseCode.SUCCESS);  
1896 - //将更新的最后一个班次返回,页面会做全量刷新  
1897 - rs.put("t", schedule);  
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> findRouteByLine(String lineCode) {  
1907 - Map<String, Object> map = new HashMap<>();  
1908 - //上行  
1909 - Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode);  
1910 - map.put("line.id_eq", lineId);  
1911 - map.put("directions_eq", 0);  
1912 - List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map);  
1913 -  
1914 - //下行  
1915 - map.put("directions_eq", 1);  
1916 - List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map);  
1917 -  
1918 - Map<String, Object> rs = new HashMap<>();  
1919 -  
1920 - String upVectors = "", vec;  
1921 - //拼接上行路段  
1922 - for (Map<String, Object> temp : upList) {  
1923 - vec = temp.get("sectionBsectionVector").toString();  
1924 - upVectors += vec.subSequence(11, vec.length() - 2) + " ";  
1925 - }  
1926 -  
1927 - //拼接下行路段  
1928 - String downVectors = "";  
1929 - for (Map<String, Object> temp : downList) {//LINESTRING(  
1930 - vec = temp.get("sectionBsectionVector").toString();  
1931 - downVectors += vec.subSequence(11, vec.length() - 2) + " ";  
1932 - }  
1933 -  
1934 -  
1935 - rs.put("up", upVectors);  
1936 - //上行gcj  
1937 - rs.put("up_gcj", BdToGcjString(upVectors));  
1938 - rs.put("down", downVectors);  
1939 - //下行gcj  
1940 - rs.put("down_gcj", BdToGcjString(downVectors));  
1941 - rs.put("lineId", lineId);  
1942 -  
1943 - return rs;  
1944 - }  
1945 -  
1946 - /**  
1947 - * @param @param bdStr  
1948 - * @throws  
1949 - * @Title: BdToGcjString  
1950 - * @Description: TODO(将百度路由字符串 转 成GCJ 字符串)  
1951 - */  
1952 - public String BdToGcjString(String bdStr) {  
1953 - String[] array = bdStr.split(","), subArray;  
1954 - if (array.length == 0 || bdStr.length() < 2)  
1955 - return "";  
1956 -  
1957 - String gcjStr = "";  
1958 - TransGPS.Location location;  
1959 - for (String crd : array) {  
1960 - subArray = crd.split(" ");  
1961 - if (subArray.length != 2)  
1962 - continue;  
1963 - location = TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1])));  
1964 -  
1965 - gcjStr += location.getLng() + " " + location.getLat() + ",";  
1966 - }  
1967 -  
1968 - return gcjStr.substring(0, gcjStr.length() - 1);  
1969 - }  
1970 -  
1971 - public List<Map<String, String>> findLine(String line) {  
1972 - List<Line> listLine = lineRepository.findLine("%" + line + "%");  
1973 - List<Map<String, String>> list = new ArrayList<Map<String, String>>();  
1974 - Map<String, String> map;  
1975 - for (Line temp : listLine) {  
1976 - if (temp != null) {  
1977 - String xlName = temp.getName();  
1978 - if (xlName.indexOf(line) != -1) {  
1979 - map = new HashMap<String, String>();  
1980 - map.put("id", temp.getLineCode());  
1981 - map.put("text", xlName);  
1982 - list.add(map);  
1983 - }  
1984 - }  
1985 - }  
1986 - return list;  
1987 - }  
1988 -  
1989 - public List<Map<String, String>> findLpName(String lpName) {  
1990 - List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%" + lpName + "%");  
1991 - List<Map<String, String>> list = new ArrayList<Map<String, String>>();  
1992 - Map<String, String> map;  
1993 - for (GuideboardInfo temp : listLpName) {  
1994 - if (temp != null) {  
1995 - String lp = temp.getLpName();  
1996 - if (lp.indexOf(lpName) != -1) {  
1997 - map = new HashMap<String, String>();  
1998 - map.put("id", lp);  
1999 - map.put("text", lp);  
2000 - list.add(map);  
2001 - }  
2002 - }  
2003 - }  
2004 - return list;  
2005 - }  
2006 -  
2007 - @Override  
2008 - public Map<String, Object> findKMBC2(String jName, String clZbh, String date) {  
2009 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date, "", "");  
2010 -  
2011 - DecimalFormat format = new DecimalFormat("0.00");  
2012 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
2013 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
2014 - int jhbc = 0, cjbc = 0, ljbc = 0;  
2015 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;  
2016 - float addMileage = 0l, remMileage = 0l;  
2017 - String j_Name = "";  
2018 - Map<String, Object> map = new HashMap<String, Object>();  
2019 - for (ScheduleRealInfo scheduleRealInfo : list) {  
2020 - if (scheduleRealInfo != null) {  
2021 - j_Name = scheduleRealInfo.getjName();  
2022 - //计划里程(主任务过滤掉临加班次),  
2023 - //烂班里程(主任务烂班),  
2024 - //临加里程(主任务临加),  
2025 - //计划班次,烂班班次,增加班次  
2026 - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();  
2027 - if (scheduleRealInfo.isSflj()) {  
2028 - addMileage += tempJhlc;  
2029 - ljbc++;  
2030 - } else {  
2031 - jhlc += tempJhlc;  
2032 - jhbc++;  
2033 - if (scheduleRealInfo.getStatus() == -1) {  
2034 - remMileage += tempJhlc;  
2035 - cjbc++;  
2036 - }  
2037 - }  
2038 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
2039 - //计算营运里程,空驶里程  
2040 - if (childTaskPlans.isEmpty()) {  
2041 - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")  
2042 - || scheduleRealInfo.getBcType().equals("venting")) {  
2043 - ksgl += tempJhlc;  
2044 - } else {  
2045 - yygl += tempJhlc;  
2046 - }  
2047 - } else {  
2048 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
2049 - while (it.hasNext()) {  
2050 - ChildTaskPlan childTaskPlan = it.next();  
2051 - if (childTaskPlan.getMileageType().equals("empty")) {  
2052 - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
2053 - } else {  
2054 - yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
2055 - }  
2056 - }  
2057 - }  
2058 - }  
2059 - }  
2060 - map.put("j_name", j_Name);  
2061 - map.put("jhlc", format.format(jhlc));  
2062 - map.put("remMileage", format.format(remMileage));  
2063 - map.put("addMileage", format.format(addMileage));  
2064 - map.put("yygl", format.format(yygl));  
2065 - map.put("ksgl", format.format(ksgl));  
2066 - map.put("realMileage", format.format(yygl + ksgl));  
2067 - map.put("jhbc", jhbc);  
2068 - map.put("cjbc", cjbc);  
2069 - map.put("ljbc", ljbc);  
2070 - map.put("sjbc", jhbc - cjbc + ljbc);  
2071 - return map;  
2072 - }  
2073 -  
2074 -  
2075 - public Map<String, Object> findKMBC(String jGh, String clZbh,  
2076 - String lpName, String date, String line) {  
2077 - Map<String, Object> map = new HashMap<String, Object>();  
2078 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);  
2079 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2080 - for (int i = 0; i < list.size(); i++) {  
2081 - ScheduleRealInfo s = list.get(i);  
2082 - Set<ChildTaskPlan> cts = s.getcTasks();  
2083 - if (cts != null && cts.size() > 0) {  
2084 - lists.add(s);  
2085 - } else {  
2086 - if (s.getFcsjActual() != null && s.getZdsjActual() != null) {  
2087 - lists.add(s);  
2088 - }  
2089 - }  
2090 - }  
2091 - map.put("jhbc", culateService.culateJhbc(list, ""));//计划班次  
2092 - map.put("jhlc", Arith.add(culateService.culateJhgl(list),  
2093 - culateService.culateJhJccgl(list))); //计划总里程  
2094 - map.put("cjbc", culateService.culateLbbc(list));//烂班班次  
2095 - map.put("remMileage", culateService.culateLbgl(list)); //烂班公里  
2096 - map.put("ljbc", culateService.culateLjbc(lists, ""));//临加班次  
2097 - double ljgl = culateService.culateLjgl(lists);  
2098 - map.put("addMileage", ljgl); //临加公里  
2099 - map.put("sjbc", culateService.culateSjbc(lists, "") + culateService.culateLjbc(lists, ""));  
2100 - double ksgl = culateService.culateKsgl(list);//子任务空驶公里  
2101 - double jccgl = culateService.culateJccgl(lists);//空驶班次公里  
2102 - map.put("ksgl", ksgl);//空驶公里  
2103 - double sjgl = culateService.culateSjgl(lists);//实际营运公里  
2104 - map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));//总公里  
2105 - map.put("zkslc", Arith.add(ksgl, jccgl));  
2106 - map.put("jcclc", jccgl);  
2107 - map.put("yygl", Arith.add(sjgl, ljgl)); //总营运公里  
2108 - return map;  
2109 - }  
2110 -  
2111 - public Map<String, Object> findKMBC_mh_2(String jGh, String clZbh,  
2112 - String lpName, String date, String line) {  
2113 - Map<String, Object> map = new HashMap<String, Object>();  
2114 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);  
2115 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2116 - for (int i = 0; i < list.size(); i++) {  
2117 - ScheduleRealInfo s = list.get(i);  
2118 - if (s.isDestroy() && s.isReissue()) {  
2119 - s.setRemark("");  
2120 - s.setFcsjActual(s.getDfsj());  
2121 - s.setZdsjActual(s.getZdsj());  
2122 - s.setStatus(2);  
2123 - s.setJhlc(s.getJhlcOrig());  
2124 - }  
2125 -  
2126 - Set<ChildTaskPlan> cts = s.getcTasks();  
2127 - if (cts != null && cts.size() > 0) {  
2128 - lists.add(s);  
2129 - } else {  
2130 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
2131 - lists.add(s);  
2132 - }  
2133 - }  
2134 - }  
2135 - double ksgl = culateService.culateKsgl(list);  
2136 - double sjgl = culateService.culateSjgl(lists);  
2137 - double jccgl = culateService.culateJccgl(lists);  
2138 - double ljgl = culateService.culateLjgl(lists);  
2139 -  
2140 - map.put("jhlc", Arith.add(culateService.culateJhgl(list), culateService.culateJhJccgl(list))); //计划里程  
2141 - map.put("remMileage", culateService.culateLbgl(list)); //烂班公里  
2142 - map.put("addMileage", ljgl); //临加公里  
2143 - map.put("yygl", Arith.add(sjgl, ljgl)); //实际公里  
2144 - map.put("ksgl", ksgl);//空驶公里  
2145 - map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));  
2146 -// map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage));  
2147 - map.put("jhbc", culateService.culateJhbc(list, ""));  
2148 - map.put("cjbc", culateService.culateLbbc(list));  
2149 - map.put("ljbc", culateService.culateLjbc(lists, ""));  
2150 - map.put("sjbc", culateService.culateJhbc(lists, "") - culateService.culateLbbc(lists) + culateService.culateLjbc(lists, ""));  
2151 - map.put("jcclc", jccgl);  
2152 - map.put("zkslc", Arith.add(ksgl, jccgl));  
2153 -// map.put("zkslc", format.format(ksgl + jcclc+addMileageJc));  
2154 - return map;  
2155 - }  
2156 -  
2157 -  
2158 - @Override  
2159 - public List<Map<String, Object>> accountPx(String line, String date,  
2160 - String code, String xlName, String px) {  
2161 -// List<Object[]> lsitObj = scheduleRealInfoRepository.accountPx(line, date, code,px);  
2162 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2163 - if (!code.trim().equals("")) {  
2164 - code = BasicData.deviceId2NbbmMap.inverse().get(code);  
2165 - }  
2166 - String fgs = "";  
2167 - List<Line> lineList = lineRepository.findLineByCode(line);  
2168 - if (lineList.size() > 0) {  
2169 - Line l = lineList.get(0);  
2170 - fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany());  
2171 - }  
2172 - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();  
2173 - String sql = "SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ,"  
2174 - + " device_id FROM bsth_v_report_80 WHERE "  
2175 - + " FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = '" + date + "' AND"  
2176 - + " line_id = '" + line + "' and device_id like '%" + code + "%'";  
2177 - Map<String, Object> map;  
2178 - List<Object[]> lsitObj = jdbcTemplate.query(sql,  
2179 - new RowMapper<Object[]>() {  
2180 - @Override  
2181 - public Object[] mapRow(ResultSet rs, int rowNum) throws SQLException {  
2182 - Object[] t = new Object[3];  
2183 - t[0] = rs.getString("request_code");  
2184 - t[1] = rs.getString("TIMESTAMP");  
2185 - t[2] = rs.getString("device_id");  
2186 - return t;  
2187 - }  
2188 - });  
2189 - int i = 1;  
2190 - for (Object[] obj : lsitObj) {  
2191 - if (obj != null) {  
2192 - map = new HashMap<String, Object>();  
2193 - map.put("num", i++);  
2194 - map.put("xlName", xlName);  
2195 - if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) {  
2196 - List<CarDevice> carDeviceList = new ArrayList<CarDevice>();  
2197 - try {  
2198 - carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString()));  
2199 - } catch (Exception e) {  
2200 - // TODO Auto-generated catch block  
2201 - e.printStackTrace();  
2202 - }  
2203 - if (carDeviceList.size() > 0) {  
2204 - map.put("clZbh", carDeviceList.get(0).getClZbh());  
2205 -  
2206 - } else {  
2207 - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));  
2208 - }  
2209 - } else {  
2210 - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));  
2211 -  
2212 - }  
2213 - map.put("company", fgs);  
2214 - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase());  
2215 - map.put("requestTime", obj[1]);  
2216 - listMap.add(map);  
2217 - }  
2218 - }  
2219 - if (listMap.size() > 1) {  
2220 - if (px.equals("asc")) {  
2221 - Collections.sort(listMap, new AccountMap());  
2222 - } else {  
2223 - Collections.sort(listMap, new AccountMap2());  
2224 - }  
2225 - }  
2226 - return listMap;  
2227 - }  
2228 -  
2229 - @Override  
2230 - public List<Map<String, Object>> account(String line, String date,  
2231 - String code, String xlName, String type) {  
2232 - if (!code.trim().equals("")) {  
2233 - code = BasicData.deviceId2NbbmMap.inverse().get(code);  
2234 - }  
2235 - String fgs = "";  
2236 - List<Line> lineList = lineRepository.findLineByCode(line);  
2237 - if (lineList.size() > 0) {  
2238 - Line l = lineList.get(0);  
2239 - fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany());  
2240 - }  
2241 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2242 - List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code);  
2243 - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();  
2244 - Map<String, Object> map;  
2245 - int i = 1;  
2246 - for (Object[] obj : lsitObj) {  
2247 - if (obj != null) {  
2248 - map = new HashMap<String, Object>();  
2249 - map.put("num", i++);  
2250 - map.put("xlName", xlName);  
2251 - if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) {  
2252 - List<CarDevice> carDeviceList = new ArrayList<CarDevice>();  
2253 - try {  
2254 - carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString()));  
2255 - } catch (Exception e) {  
2256 - // TODO Auto-generated catch block  
2257 - e.printStackTrace();  
2258 - }  
2259 - if (carDeviceList.size() > 0) {  
2260 - map.put("clZbh", carDeviceList.get(0).getClZbh());  
2261 -  
2262 - } else {  
2263 - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));  
2264 - }  
2265 - } else {  
2266 - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));  
2267 -  
2268 - }  
2269 - map.put("company", fgs);  
2270 - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase());  
2271 - map.put("requestTime", obj[1]);  
2272 - listMap.add(map);  
2273 - }  
2274 - }  
2275 -  
2276 - if (type != null && type.length() != 0 && type.equals("export")) {  
2277 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
2278 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
2279 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
2280 - Map<String, Object> m = new HashMap<String, Object>();  
2281 - ReportUtils ee = new ReportUtils();  
2282 - Map<String, Object> typeMap = new HashMap<String, Object>();  
2283 - typeMap.put("0xA1", "请求恢复运营");  
2284 - typeMap.put("0xA2", "申请调档");  
2285 - typeMap.put("0xA3", "出场请求");  
2286 - typeMap.put("0xA5", "进场请求");  
2287 - typeMap.put("0xA7", "加油请求");  
2288 - typeMap.put("0x50", "车辆故障");  
2289 - typeMap.put("0x70", "路阻报告");  
2290 - typeMap.put("0x60", "事故报告");  
2291 - typeMap.put("0x11", "扣证纠纷");  
2292 - typeMap.put("0x12", "报警");  
2293 - for (Map<String, Object> map1 : listMap) {  
2294 - map1.put("requestText", typeMap.get(map1.get("requestType")));  
2295 - }  
2296 - try {  
2297 - listI.add(listMap.iterator());  
2298 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
2299 - ee.excelReplace(listI, new Object[]{m}, path + "mould/account.xls",  
2300 - path + "export/" + sdfSimple.format(sdfMonth.parse(date))  
2301 - + "-" + xlName + "-驾驶员请求台账.xls");  
2302 - } catch (Exception e) {  
2303 - // TODO: handle exception  
2304 - e.printStackTrace();  
2305 - }  
2306 - }  
2307 -  
2308 - return listMap;  
2309 - }  
2310 -  
2311 - @Override  
2312 - public List<SchEditInfoDto> correctForm(String line, String date, String endDate,  
2313 - String lpName, String code, String type, String changType) {  
2314 -  
2315 -// var types = {'DFTZ': '待发调整', 'FCXXWT':'发车信息微调', 'JHLB': '班次取消', 'CXLB': '撤销烂班',  
2316 -// 'CXZX': '撤销执行', 'CXSF': '撤销实发', 'SFTZ': '实发调整', 'TZRC': '调整人车'};  
2317 - Map<String, Object> map = new HashMap<String, Object>();  
2318 - map.put("DFTZ", "待发调整");  
2319 - map.put("FCXXWT", "发车信息微调");  
2320 - map.put("JHLB", "班次取消");  
2321 - map.put("CXLB", "撤销烂班");  
2322 - map.put("CXZX", "撤销执行");  
2323 - map.put("CXSF", "撤销实发");  
2324 - map.put("SFTZ", "实发调整");  
2325 - map.put("TZRC", "调整人车");  
2326 -  
2327 - SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");  
2328 - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
2329 - String cont = "";  
2330 - cont = " and xl_bm ='" + line + "'";  
2331 - if (!lpName.equals("")) {  
2332 - cont += " and lp_name = '" + lpName + "'";  
2333 - }  
2334 - if (!code.equals("")) {  
2335 - cont += " and cl_zbh ='" + code + "'";  
2336 - }  
2337 - String sql = "select t1.*, t2.real_exec_date,"  
2338 - + "t2.fcsj,t2.lp_name,t2.cl_zbh,t2.j_gh,t2.j_name,"  
2339 - + "t2.xl_dir,t2.real_exec_date from (select * from "  
2340 - + "logger_sch_modify where rq BETWEEN ? and ? and line_code=? )"  
2341 - + " t1 INNER JOIN bsth_c_s_sp_info_real t2 on "  
2342 - + "t1.sch_id=t2.id where 1=1 " + cont;  
2343 -  
2344 - List<SchEditInfoDto> list = jdbcTemplate.query(sql,  
2345 - new BeanPropertyRowMapper(SchEditInfoDto.class), date, endDate, line);  
2346 - List<SchEditInfoDto> lists = new ArrayList<SchEditInfoDto>();  
2347 - for (int i = 0; i < list.size(); i++) {  
2348 - Long fcsjs = 0l;  
2349 - Long updsj = 0l;  
2350 - SchEditInfoDto t = list.get(i);  
2351 - if (map.get(t.getType()) != null) {  
2352 -  
2353 - if (changType.equals("")) {  
2354 - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";");  
2355 - } else {  
2356 - String fcsj = "";  
2357 - String updtime = "";  
2358 - try {  
2359 - fcsj = sdf1.format(sdf1.parse(t.getFcsj()));  
2360 - updtime = sdf1.format(sdf1.parse(t.getTimeStr()));  
2361 - fcsjs = sdf2.parse(t.getRealExecDate() + " " + fcsj).getTime();  
2362 - updsj = sdf2.parse(t.getRq() + " " + updtime).getTime();  
2363 - } catch (ParseException e) {  
2364 - // TODO Auto-generated catch block  
2365 - e.printStackTrace();  
2366 - }  
2367 - if (changType.equals("1")) {  
2368 - if (fcsjs > updsj) {  
2369 - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";");  
2370 - } else {  
2371 - t.setType2("");  
2372 - }  
2373 - } else if (changType.equals("2")) {  
2374 - if (fcsjs < updsj) {  
2375 - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";");  
2376 - } else {  
2377 - t.setType2("");  
2378 - }  
2379 - }  
2380 - }  
2381 - } else {  
2382 - t.setType2("");  
2383 - }  
2384 - boolean fage = true;  
2385 - for (int j = 0; j < lists.size(); j++) {  
2386 - SchEditInfoDto s = lists.get(j);  
2387 - if (s.getSchId() == t.getSchId()) {  
2388 - s.setType2(s.getType2() + " " + t.getType2());  
2389 - fage = false;  
2390 - }  
2391 - }  
2392 -  
2393 - if (fage) {  
2394 - if (changType.equals("")) {  
2395 - lists.add(t);  
2396 - } else {  
2397 - if (changType.equals("1")) {  
2398 - if (fcsjs > updsj) {  
2399 - lists.add(t);  
2400 - }  
2401 - } else if (changType.equals("2")) {  
2402 - if (fcsjs < updsj) {  
2403 - lists.add(t);  
2404 - }  
2405 - }  
2406 - }  
2407 - }  
2408 - }  
2409 -  
2410 - if (type != null && type.length() != 0 && type.equals("export")) {  
2411 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
2412 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
2413 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
2414 - Map<String, Object> m = new HashMap<String, Object>();  
2415 - m.put("dates", date);  
2416 - ReportUtils ee = new ReportUtils();  
2417 - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();  
2418 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2419 - for (SchEditInfoDto d : lists) {  
2420 - Map<String, Object> tempMap = new HashMap<String, Object>();  
2421 - tempMap.put("lpName", d.getLpName());  
2422 - tempMap.put("rq", d.getRq());  
2423 - tempMap.put("clZbh", d.getClZbh());  
2424 - tempMap.put("jName", d.getjName() + "/" + d.getjGh());  
2425 - tempMap.put("fcsj", d.getFcsj());  
2426 - tempMap.put("type", d.getType2());  
2427 - tempList.add(tempMap);  
2428 - }  
2429 - try {  
2430 - String dateTime = sdfSimple.format(sdfMonth.parse(date));  
2431 - if(!endDate.equals(date)){  
2432 - dateTime += "-" + sdfSimple.format(sdfMonth.parse(endDate));  
2433 - }  
2434 - String lineName = BasicData.lineCode2NameMap.get(line);  
2435 - listI.add(tempList.iterator());  
2436 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
2437 - ee.excelReplace(listI, new Object[]{m}, path + "mould/correctForm.xls",  
2438 - path + "export/" + dateTime + "-" + lineName + "-修正报表.xls");  
2439 - } catch (Exception e) {  
2440 - // TODO: handle exception  
2441 - e.printStackTrace();  
2442 - }  
2443 -// Map<String, Object> maps = tempList.get(tempList.size() - 1);  
2444 - }  
2445 - return lists;  
2446 - }  
2447 -  
2448 - @Override  
2449 - public List<ScheduleRealInfo> queryListWaybill(String jGh, String clZbh,  
2450 - String lpName, String date, String line) {  
2451 - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();  
2452 - List<ScheduleRealInfo> list = null;  
2453 - list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);  
2454 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
2455 - String minfcsj = "02:00";  
2456 - List<Line> lineList = lineRepository.findLineByCode(line);  
2457 - if (lineList.size() > 0) {  
2458 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
2459 - + " id = ("  
2460 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
2461 - + ")";  
2462 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
2463 - }  
2464 - String[] minSjs = minfcsj.split(":");  
2465 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
2466 -  
2467 - for (int i = 0; i < list.size(); i++) {  
2468 - ScheduleRealInfo s = list.get(i);  
2469 - if (s.getBcType().equals("out")) {  
2470 - s.setRemark("1");  
2471 - } else if (s.getBcType().equals("in")) {  
2472 - s.setRemark("3");  
2473 - } else {  
2474 - s.setRemark("2");  
2475 - }  
2476 - String[] fcsj = s.getFcsj().split(":");  
2477 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
2478 -  
2479 - Long fscjT = 0L;  
2480 - if (fcsjL < minSj) {  
2481 - Calendar calendar = new GregorianCalendar();  
2482 - calendar.setTime(s.getScheduleDate());  
2483 - calendar.add(calendar.DATE, 1);  
2484 - s.setScheduleDate(calendar.getTime());  
2485 - try {  
2486 - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();  
2487 - } catch (ParseException e) {  
2488 - // TODO Auto-generated catch block  
2489 - e.printStackTrace();  
2490 - }  
2491 -  
2492 - } else {  
2493 - try {  
2494 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
2495 - } catch (ParseException e) {  
2496 - // TODO Auto-generated catch block  
2497 - e.printStackTrace();  
2498 - }  
2499 - ;  
2500 - }  
2501 - s.setFcsjT(fscjT);  
2502 - }  
2503 - Collections.sort(list, new compareFcsjType());  
2504 - for (int i = 0; i < list.size(); i++) {  
2505 - ScheduleRealInfo s = list.get(i);  
2506 - s.setAdjustExps(i + 1 + "");  
2507 - String remarks = "";  
2508 - if (s.getRemarks() != null) {  
2509 - remarks += s.getRemarks();  
2510 - }  
2511 -  
2512 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
2513 - if (!childTaskPlans.isEmpty()) {  
2514 - s.setFcsjActual("");  
2515 - s.setZdsjActual("");  
2516 - s.setJhlc(0.0);  
2517 - }  
2518 -  
2519 - if (s.isDestroy()) {  
2520 - s.setFcsjActual("");  
2521 - s.setZdsjActual("");  
2522 - s.setJhlc(0.0);  
2523 - remarks += "(烂班)";  
2524 - s.setRemarks(remarks);  
2525 - }  
2526 -  
2527 - listSchedule.add(s);  
2528 - //计算营运里程,空驶里程  
2529 - if (!childTaskPlans.isEmpty()) {  
2530 -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
2531 - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);  
2532 - Collections.sort(listit, new ComparableChild());  
2533 - for (int j = 0; j < listit.size(); j++) {  
2534 - ScheduleRealInfo t = new ScheduleRealInfo();  
2535 - ChildTaskPlan childTaskPlan = listit.get(j);  
2536 - if (childTaskPlan.getCcId() == null) {  
2537 - if (childTaskPlan.isDestroy()) {  
2538 - t.setFcsjActual("");  
2539 - t.setZdsjActual("");  
2540 - t.setJhlc(0.0);  
2541 - } else {  
2542 - t.setFcsjActual(childTaskPlan.getStartDate());  
2543 - t.setZdsjActual(childTaskPlan.getEndDate());  
2544 - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));  
2545 - }  
2546 - t.setFcsj(childTaskPlan.getStartDate());  
2547 - t.setZdsj(childTaskPlan.getEndDate());  
2548 - t.setQdzName(childTaskPlan.getStartStationName());  
2549 - t.setZdzName(childTaskPlan.getEndStationName());  
2550 - t.setRemarks(childTaskPlan.getRemarks());  
2551 - t.setAdjustExps("子");  
2552 - listSchedule.add(t);  
2553 - }  
2554 - }  
2555 - }  
2556 - }  
2557 -  
2558 - return listSchedule;  
2559 - }  
2560 -  
2561 - @Override  
2562 - public List<ScheduleRealInfo> queryListWaybill2(String jName, String clZbh,  
2563 - String lpName, String date, String line) {  
2564 - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();  
2565 - List<ScheduleRealInfo> list = null;  
2566 - list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date, line);  
2567 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
2568 - String minfcsj = "02:00";  
2569 - List<Line> lineList = lineRepository.findLineByCode(line);  
2570 - if (lineList.size() > 0) {  
2571 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
2572 - + " id = ("  
2573 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
2574 - + ")";  
2575 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
2576 - }  
2577 - String[] minSjs = minfcsj.split(":");  
2578 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
2579 -  
2580 - for (int i = 0; i < list.size(); i++) {  
2581 - ScheduleRealInfo s = list.get(i);  
2582 - String[] fcsj = s.getFcsj().split(":");  
2583 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
2584 -  
2585 - Long fscjT = 0L;  
2586 - if (fcsjL < minSj) {  
2587 - Calendar calendar = new GregorianCalendar();  
2588 - calendar.setTime(s.getScheduleDate());  
2589 - calendar.add(calendar.DATE, 1);  
2590 - s.setScheduleDate(calendar.getTime());  
2591 - try {  
2592 - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();  
2593 - } catch (ParseException e) {  
2594 - // TODO Auto-generated catch block  
2595 - e.printStackTrace();  
2596 - }  
2597 -  
2598 - } else {  
2599 - try {  
2600 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
2601 - } catch (ParseException e) {  
2602 - // TODO Auto-generated catch block  
2603 - e.printStackTrace();  
2604 - }  
2605 - ;  
2606 - }  
2607 - s.setFcsjT(fscjT);  
2608 - }  
2609 - Collections.sort(list, new ComparableReal());  
2610 - for (int i = 0; i < list.size(); i++) {  
2611 - ScheduleRealInfo s = list.get(i);  
2612 - s.setAdjustExps(i + 1 + "");  
2613 - String remarks = "";  
2614 - if (s.getRemarks() != null) {  
2615 - remarks += s.getRemarks();  
2616 - }  
2617 -  
2618 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
2619 - if (!childTaskPlans.isEmpty()) {  
2620 - s.setFcsjActual("");  
2621 - s.setZdsjActual("");  
2622 - s.setJhlc(0.0);  
2623 - }  
2624 -  
2625 - if (s.isDestroy()) {  
2626 - if (s.isReissue()) {  
2627 - s.setFcsjActual(s.getDfsj());  
2628 - s.setZdsjActual(s.getZdsj());  
2629 - s.setRemarks("");  
2630 - s.setStatus(2);  
2631 - s.setJhlc(s.getJhlcOrig());  
2632 - } else {  
2633 - s.setFcsjActual("");  
2634 - s.setZdsjActual("");  
2635 - s.setJhlc(0.0);  
2636 - remarks += "(烂班)";  
2637 - s.setRemarks(remarks);  
2638 - }  
2639 - }  
2640 -  
2641 - listSchedule.add(s);  
2642 - //计算营运里程,空驶里程  
2643 - if (!childTaskPlans.isEmpty()) {  
2644 -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
2645 - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);  
2646 - Collections.sort(listit, new ComparableChild());  
2647 - for (int j = 0; j < listit.size(); j++) {  
2648 - ScheduleRealInfo t = new ScheduleRealInfo();  
2649 - ChildTaskPlan childTaskPlan = listit.get(j);  
2650 - if (childTaskPlan.isDestroy()) {  
2651 - t.setFcsjActual("");  
2652 - t.setZdsjActual("");  
2653 - t.setJhlc(0.0);  
2654 - } else {  
2655 - t.setFcsjActual(childTaskPlan.getStartDate());  
2656 - t.setZdsjActual(childTaskPlan.getEndDate());  
2657 - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));  
2658 - }  
2659 - t.setQdzName(childTaskPlan.getStartStationName());  
2660 - t.setZdzName(childTaskPlan.getEndStationName());  
2661 - t.setRemarks(childTaskPlan.getRemarks());  
2662 - t.setAdjustExps("子");  
2663 - listSchedule.add(t);  
2664 - }  
2665 - }  
2666 - }  
2667 -  
2668 - return listSchedule;  
2669 - }  
2670 -  
2671 - @Override  
2672 - public Map<String, Object> removeChildTask(Long taskId) {  
2673 - Map<String, Object> rs = new HashMap<>();  
2674 - ChildTaskPlan chTask = cTaskPlanRepository.findById(taskId).get();  
2675 -  
2676 - ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId());  
2677 - try {  
2678 -  
2679 - sch.getcTasks().remove(chTask);  
2680 - scheduleRealInfoRepository.save(sch);  
2681 - rs.put("status", ResponseCode.SUCCESS);  
2682 - } catch (Exception e) {  
2683 - logger.error("", e);  
2684 - rs.put("status", ResponseCode.ERROR);  
2685 - }  
2686 - return rs;  
2687 - }  
2688 -  
2689 - @Override  
2690 - public List<Map<String, Object>> statisticsDaily(String line, String date,  
2691 - String xlName, String type) {  
2692 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
2693 - List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);  
2694 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2695 - for (int i = 0; i < list_s.size(); i++) {  
2696 - ScheduleRealInfo s = list_s.get(i);  
2697 - Set<ChildTaskPlan> cts = s.getcTasks();  
2698 - if (cts != null && cts.size() > 0) {  
2699 - lists.add(s);  
2700 - } else {  
2701 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
2702 - lists.add(s);  
2703 - }  
2704 - }  
2705 - }  
2706 - Map<String, Object> map = new HashMap<String, Object>();  
2707 - map.put("xlName", xlName);  
2708 - double jhlc = culateService.culateJhgl(list_s);  
2709 - map.put("jhlc", jhlc);  
2710 - map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists)));  
2711 - double lbgl = culateService.culateLbgl(list_s);  
2712 - map.put("ssgl", lbgl);  
2713 - map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻"));  
2714 - map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢"));  
2715 - map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障"));  
2716 - map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷"));  
2717 - map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事"));  
2718 - map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人"));  
2719 - map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车"));  
2720 - map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀"));  
2721 - map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候"));  
2722 - map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外"));  
2723 - map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚"));  
2724 - double ssgl_pc = culateService.culateCJLC(list_s, "配车");  
2725 - double ssgl_by = culateService.culateCJLC(list_s, "保养");  
2726 - double ssgl_cj = culateService.culateCJLC(list_s, "抽减");  
2727 - double ssgl_qt = culateService.culateCJLC(list_s, "其他");  
2728 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
2729 - map.put("ssbc", culateService.culateLbbc(list_s));  
2730 - double ljgl = culateService.culateLjgl(lists);  
2731 - map.put("ljgl", ljgl);  
2732 - map.put("jhbc", culateService.culateJhbc(list_s, ""));  
2733 - map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf"));  
2734 - map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf"));  
2735 - map.put("sjbc", culateService.culateSjbc(lists, ""));  
2736 - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf"));  
2737 - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf"));  
2738 - map.put("ljbc", culateService.culateLjbc(lists, ""));  
2739 - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf"));  
2740 - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf"));  
2741 - map.put("fzbc", culateService.culateFzbc(lists, ""));  
2742 - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));  
2743 - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));  
2744 - map.put("dtbc", 0);  
2745 - map.put("dtbc_m", 0);  
2746 - map.put("dtbc_a", 0);  
2747 - List<CalcInterval> intervalList=calcIntervalRepository.selectByDateAndLine(line, date,"");  
2748 - if(intervalList.size()>0){  
2749 - CalcInterval c=intervalList.get(0);  
2750 - map.put("djg",c.getDjgAll());  
2751 - map.put("djg_m", c.getDjgZgf());  
2752 - map.put("djg_a", c.getDjgWgf());  
2753 - map.put("djg_time", c.getDjgTime());  
2754 - }else{  
2755 - Map<String, Object> m = culateService.culateDjg(list_s, line);  
2756 - map.put("djg", m.get("djgcsq"));  
2757 - map.put("djg_m", m.get("djgcsz"));  
2758 - map.put("djg_a", m.get("djgcsw"));  
2759 - map.put("djg_time", m.get("djgsj"));  
2760 - }  
2761 -  
2762 - map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl));  
2763 - lMap.add(map);  
2764 -  
2765 - if (date.length() == 10) {  
2766 - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59");  
2767 - String dbdp = "";  
2768 - try {  
2769 - for (int i = 0; i < list.size(); i++) {  
2770 - DutyEmployee t = list.get(i);  
2771 - if (dbdp.indexOf(t.getuName()) == -1) {  
2772 - if (!(dbdp.length() > 0)) {  
2773 - dbdp = t.getuName();  
2774 - } else {  
2775 - dbdp += "," + t.getuName();  
2776 - }  
2777 - }  
2778 - }  
2779 - } catch (Exception e) {  
2780 - // TODO: handle exception  
2781 - e.printStackTrace();  
2782 - }  
2783 - map.put("dbdp", dbdp);  
2784 - }  
2785 -  
2786 - return lMap;  
2787 - }  
2788 -  
2789 - @Override  
2790 - public List<Map<String, Object>> statisticsDaily_mh_2(String line, String date,  
2791 - String xlName, String type) {  
2792 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
2793 - List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);  
2794 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2795 - for (int i = 0; i < list_s.size(); i++) {  
2796 - ScheduleRealInfo s = list_s.get(i);  
2797 - if (s.isDestroy() && s.isReissue()) {  
2798 - s.setRemark("");  
2799 - s.setFcsjActual(s.getDfsj());  
2800 - s.setZdsjActual(s.getZdsj());  
2801 - s.setStatus(2);  
2802 - s.setJhlc(s.getJhlcOrig());  
2803 - }  
2804 -  
2805 - Set<ChildTaskPlan> cts = s.getcTasks();  
2806 - if (cts != null && cts.size() > 0) {  
2807 - lists.add(s);  
2808 - } else {  
2809 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
2810 - lists.add(s);  
2811 - }  
2812 - }  
2813 - }  
2814 - Map<String, Object> map = new HashMap<String, Object>();  
2815 - map.put("xlName", xlName);  
2816 - double jhlc = culateService.culateJhgl(list_s);  
2817 - map.put("jhlc", jhlc);  
2818 - map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists)));  
2819 - double lbgl = culateService.culateLbgl(list_s);  
2820 - map.put("ssgl", lbgl);  
2821 - map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻"));  
2822 - map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢"));  
2823 - map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障"));  
2824 - map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷"));  
2825 - map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事"));  
2826 - map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人"));  
2827 - map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车"));  
2828 - map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀"));  
2829 - map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候"));  
2830 - map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外"));  
2831 - map.put("ssgl_ljpm", culateService.culateCJLC(list_s, "路救抛锚"));  
2832 - double ssgl_pc = culateService.culateCJLC(list_s, "配车");  
2833 - double ssgl_by = culateService.culateCJLC(list_s, "保养");  
2834 - double ssgl_cj = culateService.culateCJLC(list_s, "抽减");  
2835 - double ssgl_qt = culateService.culateCJLC(list_s, "其他");  
2836 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
2837 - map.put("ssbc", culateService.culateLbbc(list_s));  
2838 - double ljgl = culateService.culateLjgl(lists);  
2839 - map.put("ljgl", ljgl);  
2840 - map.put("jhbc", culateService.culateJhbc(list_s, ""));  
2841 - map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf"));  
2842 - map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf"));  
2843 - map.put("sjbc", culateService.culateSjbc(lists, ""));  
2844 - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf"));  
2845 - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf"));  
2846 - map.put("ljbc", culateService.culateLjbc(lists, ""));  
2847 - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf"));  
2848 - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf"));  
2849 - map.put("fzbc", culateService.culateFzbc(lists, ""));  
2850 - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));  
2851 - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));  
2852 - map.put("dtbc", 0);  
2853 - map.put("dtbc_m", 0);  
2854 - map.put("dtbc_a", 0);  
2855 - map.put("djg", 0);  
2856 - map.put("djg_m", 0);  
2857 - map.put("djg_a", 0);  
2858 - map.put("djg_time", 0);  
2859 - map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl));  
2860 - lMap.add(map);  
2861 - return lMap;  
2862 - }  
2863 -  
2864 - public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,Map<String, Object> m) {  
2865 -  
2866 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2867 - for (int i = 0; i < list.size(); i++) {  
2868 - ScheduleRealInfo s = list.get(i);  
2869 - Set<ChildTaskPlan> cts = s.getcTasks();  
2870 - if (cts != null && cts.size() > 0) {  
2871 - lists.add(s);  
2872 - } else {  
2873 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
2874 - lists.add(s);  
2875 - }  
2876 - }  
2877 - }  
2878 - Map<String, Object> map = new HashMap<String, Object>();  
2879 - if (list.size() > 0) {  
2880 - map.put("gsBm", list.get(0).getGsBm());  
2881 - map.put("fgsBm", list.get(0).getFgsBm());  
2882 - map.put("xlBm", list.get(0).getXlBm());  
2883 - map.put("xlName", list.get(0).getXlName());  
2884 - map.put("fgsName", list.get(0).getFgsName());  
2885 - map.put("gsName", list.get(0).getGsName());  
2886 -  
2887 - try {  
2888 - map.put("xlNamePy", PinyinHelper.convertToPinyinString(list.get(0).getGsBm()+list.get(0).getFgsBm()+list.get(0).getXlName(), "", PinyinFormat.WITHOUT_TONE));  
2889 - } catch (PinyinException e) {  
2890 - // TODO Auto-generated catch block  
2891 - e.printStackTrace();  
2892 - }  
2893 - double jhyygl = culateService.culateJhgl(list);//计划营运公里  
2894 - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)  
2895 - map.put("jhlc", jhyygl);  
2896 - map.put("jcclc", jhjcclc);  
2897 - map.put("jhzlc", Arith.add(jhyygl, jhjcclc));  
2898 - double ljks=culateService.culateLjksgl(lists);  
2899 - map.put("ljks", ljks);  
2900 - double ljgl = culateService.culateLjgl(lists);  
2901 - double sjyygl = culateService.culateSjgl(lists);  
2902 - double zyygl = Arith.add(sjyygl, ljgl);  
2903 -  
2904 - double sjjccgl = culateService.culateJccgl(lists);  
2905 - double sjksgl = culateService.culateKsgl(lists);  
2906 - double zksgl = Arith.add(sjjccgl, sjksgl);  
2907 - map.put("sjzgl", Arith.add(zyygl, zksgl));  
2908 - map.put("sjgl", zyygl);  
2909 - map.put("sjksgl", zksgl);  
2910 - double ssgl = culateService.culateLbgl(list);  
2911 - map.put("ssgl", ssgl);  
2912 -  
2913 - //计划+临加-少驶=实驶  
2914 - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl);  
2915 - if (jl == zyygl) {  
2916 - map.put("zt", 0);  
2917 - } else {  
2918 - map.put("zt", 1);  
2919 - }  
2920 -  
2921 - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻"));  
2922 - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢"));  
2923 - map.put("ssgl_gz", culateService.culateCJLC(list, "故障"));  
2924 - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷"));  
2925 - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事"));  
2926 - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人"));  
2927 - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车"));  
2928 - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀"));  
2929 - map.put("ssgl_qh", culateService.culateCJLC(list, "气候"));  
2930 - map.put("ssgl_yw", culateService.culateCJLC(list, "援外"));  
2931 - map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚"));  
2932 - double ssgl_pc = culateService.culateCJLC(list, "配车");  
2933 - double ssgl_by = culateService.culateCJLC(list, "保养");  
2934 - double ssgl_cj = culateService.culateCJLC(list, "抽减");  
2935 - double ssgl_qt = culateService.culateCJLC(list, "其他");  
2936 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
2937 - map.put("ssbc", culateService.culateLbbc(list));  
2938 - map.put("ljgl", ljgl);  
2939 - map.put("jhbc", culateService.culateJhbc(list, ""));  
2940 - map.put("jhbc_m", culateService.culateJhbc(list, "zgf"));  
2941 - map.put("jhbc_a", culateService.culateJhbc(list, "wgf"));  
2942 - map.put("sjbc", culateService.culateSjbc(lists, ""));  
2943 - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf"));  
2944 - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf"));  
2945 - map.put("ljbc", culateService.culateLjbc(lists, ""));  
2946 - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf"));  
2947 - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf"));  
2948 - map.put("fzbc", culateService.culateFzbc(lists, ""));  
2949 - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));  
2950 - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));  
2951 - map.put("dtbc", 0);  
2952 - map.put("dtbc_m", 0);  
2953 - map.put("dtbc_a", 0);  
2954 - if(m.get("xl")==null){  
2955 - Map<String, Object> m_ = culateService.culateDjg(lists, list.get(0).getXlBm());  
2956 - map.put("djg", m_.get("djgcsq"));  
2957 - map.put("djg_m", m_.get("djgcsz"));  
2958 - map.put("djg_a", m_.get("djgcsw"));  
2959 - map.put("djg_time", m_.get("djgsj"));  
2960 - }else{  
2961 - map.put("djg", m.get("djgAll")==null?"0":m.get("djgAll"));  
2962 - map.put("djg_m", m.get("djgZgf")==null?"0":m.get("djgZgf"));  
2963 - map.put("djg_a", m.get("djgWgf")==null?"0":m.get("djgWgf"));  
2964 - map.put("djg_time", m.get("djgTime")==null?"0":m.get("djgTime"));  
2965 - }  
2966 - }  
2967 - return map;  
2968 - }  
2969 -  
2970 - @Override  
2971 - public List<Map<String, Object>> dispatchDailySum(String date, String date2, String nature, String type) {  
2972 - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();  
2973 -  
2974 -// List<Map<String, Object>> list = statisticsDailyTj("", "", "", date, date2, "", "query", nature);  
2975 - List<CalcStatistics> calc = calcWaybillService.calcStatisticsDaily("", "", "", date, date2, "", "query", nature);  
2976 - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();  
2977 - try {  
2978 - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();  
2979 - for(CalcStatistics c : calc){  
2980 - Map<String, Object> m = new HashMap<>();  
2981 - Field[] fields = c.getClass().getDeclaredFields();  
2982 - for(Field f : fields){  
2983 - f.setAccessible(true);  
2984 - String key = new String(f.getName());  
2985 - m.put(key, f.get(c));  
2986 - }  
2987 - tempList.add(m);  
2988 - }  
2989 - list = tempList;  
2990 - } catch (Exception e) {  
2991 - // TODO: handle exception  
2992 - e.printStackTrace();  
2993 - }  
2994 -  
2995 - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>();  
2996 - Map<String, Object> temp = new HashMap<String, Object>();  
2997 - temp.put("gsName", "杨高");temp.put("fgsName", "杨高分");temp.put("key", "05_5");  
2998 - resList.add(temp);keyMap.put("05_5", temp);  
2999 - temp = new HashMap<String, Object>();  
3000 - temp.put("gsName", "杨高");temp.put("fgsName", "金桥分");temp.put("key", "05_2");  
3001 - resList.add(temp);keyMap.put("05_2", temp);  
3002 - temp = new HashMap<String, Object>();  
3003 - temp.put("gsName", "杨高");temp.put("fgsName", "川沙分");temp.put("key", "05_1");  
3004 - resList.add(temp);keyMap.put("05_1", temp);  
3005 - temp = new HashMap<String, Object>();  
3006 - temp.put("gsName", "杨高");temp.put("fgsName", "周浦分");temp.put("key", "05_6");  
3007 - resList.add(temp);keyMap.put("05_6", temp);  
3008 - temp = new HashMap<String, Object>();  
3009 - temp.put("gsName", "杨高");temp.put("fgsName", "小计");temp.put("key", "05_sum");  
3010 - resList.add(temp);keyMap.put("05_sum", temp);  
3011 -  
3012 - temp = new HashMap<String, Object>();  
3013 - temp.put("gsName", "上南");temp.put("fgsName", "一分");temp.put("key", "55_4");  
3014 - resList.add(temp);keyMap.put("55_4", temp);  
3015 - temp = new HashMap<String, Object>();  
3016 - temp.put("gsName", "上南");temp.put("fgsName", "二分");temp.put("key", "55_1");  
3017 - resList.add(temp);keyMap.put("55_1", temp);  
3018 - temp = new HashMap<String, Object>();  
3019 - temp.put("gsName", "上南");temp.put("fgsName", "三分");temp.put("key", "55_2");  
3020 - resList.add(temp);keyMap.put("55_2", temp);  
3021 - temp = new HashMap<String, Object>();  
3022 - temp.put("gsName", "上南");temp.put("fgsName", "六分");temp.put("key", "55_3");  
3023 - resList.add(temp);keyMap.put("55_3", temp);  
3024 - temp = new HashMap<String, Object>();  
3025 - temp.put("gsName", "上南");temp.put("fgsName", "小计");temp.put("key", "55_sum");  
3026 - resList.add(temp);keyMap.put("55_sum", temp);  
3027 -  
3028 - temp = new HashMap<String, Object>();  
3029 - temp.put("gsName", "金高");temp.put("fgsName", "一分");temp.put("key", "22_5");  
3030 - resList.add(temp);keyMap.put("22_5", temp);  
3031 - temp = new HashMap<String, Object>();  
3032 - temp.put("gsName", "金高");temp.put("fgsName", "二分");temp.put("key", "22_2");  
3033 - resList.add(temp);keyMap.put("22_2", temp);  
3034 - temp = new HashMap<String, Object>();  
3035 - temp.put("gsName", "金高");temp.put("fgsName", "三分");temp.put("key", "22_3");  
3036 - resList.add(temp);keyMap.put("22_3", temp);  
3037 - temp = new HashMap<String, Object>();  
3038 - temp.put("gsName", "金高");temp.put("fgsName", "四分");temp.put("key", "22_1");  
3039 - resList.add(temp);keyMap.put("22_1", temp);  
3040 - temp = new HashMap<String, Object>();  
3041 - temp.put("gsName", "金高");temp.put("fgsName", "小计");temp.put("key", "22_sum");  
3042 - resList.add(temp);keyMap.put("22_sum", temp);  
3043 -  
3044 - temp = new HashMap<String, Object>();  
3045 - temp.put("gsName", "南汇");temp.put("fgsName", "一分");temp.put("key", "26_1");  
3046 - resList.add(temp);keyMap.put("26_1", temp);  
3047 - temp = new HashMap<String, Object>();  
3048 - temp.put("gsName", "南汇");temp.put("fgsName", "二分");temp.put("key", "26_2");  
3049 - resList.add(temp);keyMap.put("26_2", temp);  
3050 - temp = new HashMap<String, Object>();  
3051 - temp.put("gsName", "南汇");temp.put("fgsName", "三分");temp.put("key", "26_3");  
3052 - resList.add(temp);keyMap.put("26_3", temp);  
3053 - temp = new HashMap<String, Object>();  
3054 - temp.put("gsName", "南汇");temp.put("fgsName", "六分");temp.put("key", "26_6");  
3055 - resList.add(temp);keyMap.put("26_6", temp);  
3056 - temp = new HashMap<String, Object>();  
3057 - temp.put("gsName", "南汇");temp.put("fgsName", "小计");temp.put("key", "26_sum");  
3058 - resList.add(temp);keyMap.put("26_sum", temp);  
3059 -  
3060 - temp = new HashMap<String, Object>();  
3061 - temp.put("gsName", "浦交");temp.put("fgsName", " ");temp.put("key", "88");  
3062 - resList.add(temp);keyMap.put("88", temp);  
3063 -  
3064 - for(Map<String, Object> m : list){  
3065 - m.put("gsBm", m.get("gsdm"));  
3066 - m.put("fgsBm", m.get("fgsdm"));  
3067 - if(m.get("gsBm") != null && m.get("fgsBm") != null  
3068 - && m.get("gsBm").toString().trim().length() > 0  
3069 - && m.get("fgsBm").toString().trim().length() > 0){  
3070 - String gsBm = m.get("gsBm").toString().trim();  
3071 - String fgsBm = m.get("fgsBm").toString().trim();  
3072 - String key = gsBm + "_" + fgsBm;  
3073 - if(keyMap.containsKey(key)){  
3074 - Map<String, Object> t = keyMap.get(key);  
3075 - for(String s : m.keySet()){  
3076 - if("gsName,fgsName,key".contains(s)){  
3077 - continue;  
3078 - }  
3079 - try {  
3080 - if(t.containsKey(s)){  
3081 - t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));  
3082 - } else {  
3083 - t.put(s, m.get(s).toString());  
3084 - }  
3085 - } catch (Exception e) {  
3086 - // TODO: handle exception  
3087 - continue;  
3088 - }  
3089 - }  
3090 - }  
3091 - }  
3092 - }  
3093 -  
3094 - for(Map<String, Object> m : resList){  
3095 - String key = m.get("key").toString();  
3096 - if(key.contains("_sum") || key.equals("88")){  
3097 - continue;  
3098 - }  
3099 -  
3100 - Map<String, Object> t = keyMap.get(key.split("_")[0] + "_sum");  
3101 - for(String s : m.keySet()){  
3102 - if("gsName,fgsName,key".contains(s)){  
3103 - continue;  
3104 - }  
3105 - try {  
3106 - if(t.containsKey(s)){  
3107 - t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));  
3108 - } else {  
3109 - t.put(s, m.get(s).toString());  
3110 - }  
3111 - } catch (Exception e) {  
3112 - // TODO: handle exception  
3113 - continue;  
3114 - }  
3115 - }  
3116 -  
3117 - t = keyMap.get("88");  
3118 - for(String s : m.keySet()){  
3119 - if("gsName,fgsName,key".contains(s)){  
3120 - continue;  
3121 - }  
3122 - try {  
3123 - if(t.containsKey(s)){  
3124 - t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));  
3125 - } else {  
3126 - t.put(s, m.get(s).toString());  
3127 - }  
3128 - } catch (Exception e) {  
3129 - // TODO: handle exception  
3130 - continue;  
3131 - }  
3132 - }  
3133 - }  
3134 -  
3135 - for(Map<String, Object> m : resList){  
3136 - try {  
3137 - m.put("jhzlc", m.get("jhzlc"));  
3138 - m.put("jhlc", m.get("jhyylc"));  
3139 - m.put("jcclc", m.get("jhkslc"));  
3140 - m.put("sjzgl", m.get("sjzlc"));  
3141 - m.put("sjgl", m.get("sjyylc"));  
3142 - m.put("sjksgl", m.get("sjkslc"));  
3143 - m.put("ssbc", m.get("ssbc"));  
3144 - m.put("ssgl", m.get("sslc"));  
3145 - m.put("ssgl_lz", m.get("lzlc"));  
3146 - m.put("ssgl_dm", m.get("dmlc"));  
3147 - m.put("ssgl_gz", m.get("gzlc"));  
3148 - m.put("ssgl_jf", m.get("jflc"));  
3149 - m.put("ssgl_zs", m.get("zslc"));  
3150 - m.put("ssgl_qr", m.get("qrlc"));  
3151 - m.put("ssgl_qc", m.get("qclc"));  
3152 - m.put("ssgl_kx", m.get("kxlc"));  
3153 - m.put("ssgl_qh", m.get("qhlc"));  
3154 - m.put("ssgl_yw", m.get("ywlc"));  
3155 - m.put("ssgl_ljpm", m.get("ljpmlc"));  
3156 - m.put("ssgl_other", m.get("qtlc"));  
3157 - m.put("ljgl", m.get("ljlc"));  
3158 - m.put("ljks", m.get("ljkslc"));  
3159 - m.put("jhbc", m.get("jhbcq"));  
3160 - m.put("jhbc_m", m.get("jhbcz"));  
3161 - m.put("jhbc_a", m.get("jhbcw"));  
3162 - m.put("sjbc", m.get("sjbcq"));  
3163 - m.put("sjbc_m", m.get("sjbcz"));  
3164 - m.put("sjbc_a", m.get("sjbcw"));  
3165 - m.put("ljbc", m.get("ljbcq"));  
3166 - m.put("ljbc_m", m.get("ljbcz"));  
3167 - m.put("ljbc_a", m.get("ljbcw"));  
3168 - m.put("fzbc", m.get("fzbcq"));  
3169 - m.put("fzbc_m", m.get("fzbcz"));  
3170 - m.put("fzbc_a", m.get("fzbcw"));  
3171 - m.put("dtbc", m.get("dtbcq"));  
3172 - m.put("dtbc_m", m.get("dtbcz"));  
3173 - m.put("dtbc_a", m.get("dtbcw"));  
3174 - m.put("djg", m.get("djgq"));  
3175 - m.put("djg_m", m.get("djgz"));  
3176 - m.put("djg_a", m.get("djgw"));  
3177 - m.put("djg_time", m.get("djgsj"));  
3178 - m.put("ljzgl", new BigDecimal(m.get("ljgl").toString()).add(new BigDecimal(m.get("ljks").toString())));  
3179 - } catch (Exception e) {  
3180 - // TODO: handle exception  
3181 - m.put("ljzgl", "");  
3182 - continue;  
3183 - }  
3184 - }  
3185 -  
3186 - if (type != null && type.length() != 0 && type.equals("export")) {  
3187 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
3188 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
3189 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
3190 - Map<String, Object> m = new HashMap<String, Object>();  
3191 - ReportUtils ee = new ReportUtils();  
3192 - try {  
3193 - String dateTime = "";  
3194 - if (date.equals(date2)) {  
3195 - m.put("date", date);  
3196 - dateTime = sdfSimple.format(sdfMonth.parse(date));  
3197 - } else {  
3198 - m.put("date", date + "至" + date2);  
3199 - dateTime = sdfSimple.format(sdfMonth.parse(date))  
3200 - + "-" + sdfSimple.format(sdfMonth.parse(date2));  
3201 - }  
3202 - listI.add(resList.iterator());  
3203 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
3204 - ee.excelReplace(listI, new Object[]{m}, path + "mould/dispatchDailySum.xls",  
3205 - path + "export/" + dateTime + "-调度日报汇总表.xls");  
3206 - } catch (Exception e) {  
3207 - // TODO: handle exception  
3208 - //e.printStackTrace();  
3209 - logger.info("", e);  
3210 - }  
3211 - }  
3212 -  
3213 - return resList;  
3214 - }  
3215 -  
3216 - @Override  
3217 - public List<Map<String, Object>> statisticsDailyTj(String gsdm, String fgsdm, String line, String date, String date2,  
3218 - String xlName, String type,String nature) {  
3219 - List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>();  
3220 - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();  
3221 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
3222 - List<Object[]> listInterval=new ArrayList<Object[]>();  
3223 - line = line.trim();  
3224 - if(gsdm.equals("") && fgsdm.equals("") && line.equals("")){  
3225 - //查询所有公司  
3226 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj3(date, date2);  
3227 - listInterval = calcIntervalRepository.countByDate(date, date2);  
3228 - } else if (line.equals("")) {  
3229 - //查询所有线路  
3230 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);  
3231 - listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2);  
3232 - } else {  
3233 - //查询单条线路  
3234 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);  
3235 - listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2);  
3236 - }  
3237 - Map<String, Map<String,Object>> mapInterval=new HashMap<String, Map<String,Object>>();  
3238 - for (int i = 0; i < listInterval.size(); i++) {  
3239 - Object[] interval=listInterval.get(i);  
3240 - String gs=interval[0].toString();  
3241 - String fgs=interval[1].toString();  
3242 - String xl=interval[2].toString();  
3243 - Map<String, Object> m=new HashMap<String,Object>();  
3244 - m.put("gs", gs);  
3245 - m.put("fgs", fgs);  
3246 - m.put("xl", xl);  
3247 - m.put("djgAll", interval[3]);  
3248 - m.put("djgZgf", interval[6]);  
3249 - m.put("djgWgf", interval[7]);  
3250 - m.put("djgTime", interval[8]);  
3251 - mapInterval.put(gs+"-"+fgs+"-"+xl, m);  
3252 - }  
3253 - Map<String, Boolean> lineMap=lineService.lineNature();  
3254 - List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();  
3255 - for (int i = 0; i < listAll.size(); i++) {  
3256 - ScheduleRealInfo s=listAll.get(i);  
3257 - if (nature.equals("0")) {  
3258 - list.add(s);  
3259 - }else if(nature.equals("1")){  
3260 - if(lineMap.get(s.getXlBm())){  
3261 - list.add(s);  
3262 - }  
3263 - }else{  
3264 - if(!lineMap.get(s.getXlBm())){  
3265 - list.add(s);  
3266 - }  
3267 - }  
3268 - }  
3269 - for (int i = 0; i < list.size(); i++) {  
3270 - ScheduleRealInfo s = list.get(i);  
3271 - Set<ChildTaskPlan> cts = s.getcTasks();  
3272 - if (cts != null && cts.size() > 0) {  
3273 - list_s.add(s);  
3274 - } else {  
3275 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
3276 - list_s.add(s);  
3277 - }  
3278 - }  
3279 - }  
3280 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
3281 - for (int i = 0; i < list.size(); i++) {  
3282 - if (i < list.size() - 1) {  
3283 - if ((list.get(i+1).getGsBm()+"/"+list.get(i+1).getFgsBm()+"/"+list.get(i+1).getXlBm()).equals(  
3284 - list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm())) {  
3285 - lists.add(list.get(i));  
3286 - } else {  
3287 - lists.add(list.get(i));  
3288 - Map<String, Object> mm=new HashMap<String,Object>();  
3289 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3290 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3291 - }  
3292 - Map<String, Object> map = staticTj(lists,mm);  
3293 - lMap.add(map);  
3294 - lists = new ArrayList<ScheduleRealInfo>();  
3295 - }  
3296 - } else {  
3297 - if ((list.get(i).getGsBm()+"/"+list.get(i).getFgsBm()+"/"+list.get(i).getXlBm()).equals(  
3298 - list.get(i-1).getGsBm()+"/"+list.get(i-1).getFgsBm()+"/"+list.get(i-1).getXlBm())) {  
3299 - lists.add(list.get(i));  
3300 - Map<String, Object> mm=new HashMap<String,Object>();  
3301 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3302 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3303 - }  
3304 - Map<String, Object> map = staticTj(lists,mm);  
3305 - lMap.add(map);  
3306 - } else {  
3307 - lists = new ArrayList<ScheduleRealInfo>();  
3308 - lists.add(list.get(i));  
3309 - Map<String, Object> mm=new HashMap<String,Object>();  
3310 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3311 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3312 - }  
3313 - Map<String, Object> map = staticTj(lists,mm);  
3314 - lMap.add(map);  
3315 - }  
3316 - }  
3317 - }  
3318 -  
3319 - Collections.sort(lMap, new AccountXlbm());  
3320 - Map<String, Object> map = new HashMap<String, Object>();  
3321 - map.put("xlName", "合计");  
3322 - map.put("fgsName", "");  
3323 - map.put("gsName", "");  
3324 - double jhyygl = culateService.culateJhgl(list);//计划营运公里  
3325 - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)  
3326 - map.put("jhlc", jhyygl);  
3327 - map.put("jcclc", jhjcclc);  
3328 - map.put("jhzlc", Arith.add(jhyygl, jhjcclc));  
3329 -  
3330 - double ljgl = culateService.culateLjgl(list_s);  
3331 - double sjyygl = culateService.culateSjgl(list_s);  
3332 - double zyygl = Arith.add(sjyygl, ljgl);  
3333 - double ljks=culateService.culateLjksgl(list_s);  
3334 - map.put("ljks", ljks);  
3335 - double sjjccgl = culateService.culateJccgl(list_s);  
3336 - double sjksgl = culateService.culateKsgl(list_s);  
3337 - double zksgl = Arith.add(sjjccgl, sjksgl);  
3338 - map.put("sjzgl", Arith.add(zyygl, zksgl));  
3339 - map.put("sjgl", zyygl);  
3340 - map.put("sjksgl", zksgl);  
3341 -  
3342 - double ssgl = culateService.culateLbgl(list);  
3343 - map.put("ssgl", ssgl);  
3344 - //计划+临加-少驶=实驶  
3345 - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl);  
3346 - if (jl == zyygl) {  
3347 - map.put("zt", 0);  
3348 - } else {  
3349 - map.put("zt", 1);  
3350 - }  
3351 - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻"));  
3352 - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢"));  
3353 - map.put("ssgl_gz", culateService.culateCJLC(list, "故障"));  
3354 - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷"));  
3355 - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事"));  
3356 - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人"));  
3357 - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车"));  
3358 - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀"));  
3359 - map.put("ssgl_qh", culateService.culateCJLC(list, "气候"));  
3360 - map.put("ssgl_yw", culateService.culateCJLC(list, "援外"));  
3361 - map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚"));  
3362 - double ssgl_pc = culateService.culateCJLC(list, "配车");  
3363 - double ssgl_by = culateService.culateCJLC(list, "保养");  
3364 - double ssgl_cj = culateService.culateCJLC(list, "抽减");  
3365 - double ssgl_qt = culateService.culateCJLC(list, "其他");  
3366 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
3367 -  
3368 - map.put("ssbc", culateService.culateLbbc(list));  
3369 - map.put("ljgl", ljgl);  
3370 - map.put("jhbc", culateService.culateJhbc(list, ""));  
3371 - map.put("jhbc_m", culateService.culateJhbc(list, "zgf"));  
3372 - map.put("jhbc_a", culateService.culateJhbc(list, "wgf"));  
3373 - map.put("sjbc", culateService.culateSjbc(list_s, ""));  
3374 - map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf"));  
3375 - map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf"));  
3376 - map.put("ljbc", culateService.culateLjbc(list_s, ""));  
3377 - map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf"));  
3378 - map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf"));  
3379 - map.put("fzbc", culateService.culateFzbc(list_s, ""));  
3380 - map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf"));  
3381 - map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf"));  
3382 - map.put("dtbc", 0);  
3383 - map.put("dtbc_m", 0);  
3384 - map.put("dtbc_a", 0);  
3385 - if (list.size() > 0) {  
3386 - int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0;  
3387 - for (Map<String, Object> m : lMap) {  
3388 - if (m.containsKey("djg") && m.get("djg") != null)  
3389 - djg += Integer.valueOf(m.get("djg").toString());  
3390 - if (m.containsKey("djg_m") && m.get("djg_m") != null)  
3391 - djg_m += Integer.valueOf(m.get("djg_m").toString());  
3392 - if (m.containsKey("djg_a") && m.get("djg_a") != null)  
3393 - djg_a += Integer.valueOf(m.get("djg_a").toString());  
3394 - if (m.containsKey("djg_time") && m.get("djg_time") != null) {  
3395 - int t = Integer.valueOf(m.get("djg_time").toString());  
3396 - if (t > djg_time)  
3397 - djg_time = t;  
3398 - }  
3399 - }  
3400 - map.put("djg", djg);  
3401 - map.put("djg_m", djg_m);  
3402 - map.put("djg_a", djg_a);  
3403 - map.put("djg_time", djg_time);  
3404 -// Map<String, Object> m_=culateService.culateDjg(list_s, list.get(0).getXlBm());  
3405 -// map.put("djg", m_.get("djgcsq"));  
3406 -// map.put("djg_m", m_.get("djgcsz"));  
3407 -// map.put("djg_a", m_.get("djgcsw"));  
3408 -// map.put("djg_time", m_.get("djgsj"));  
3409 - } else {  
3410 - map.put("djg", "0");  
3411 - map.put("djg_m", "0");  
3412 - map.put("djg_a", "0");  
3413 - map.put("djg_time", "0");  
3414 - }  
3415 - lMap.add(map);  
3416 -  
3417 - if (type != null && type.length() != 0 && type.equals("export")) {  
3418 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
3419 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
3420 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
3421 - Map<String, Object> m = new HashMap<String, Object>();  
3422 - m.put("date", date + "至" + date2);  
3423 - ReportUtils ee = new ReportUtils();  
3424 - try {  
3425 - String dateTime = "";  
3426 - if (date.equals(date2)) {  
3427 - dateTime = sdfSimple.format(sdfMonth.parse(date));  
3428 - } else {  
3429 - dateTime = sdfSimple.format(sdfMonth.parse(date))  
3430 - + "-" + sdfSimple.format(sdfMonth.parse(date2));  
3431 - }  
3432 - listI.add(lMap.iterator());  
3433 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
3434 - ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_2.xls",  
3435 - path + "export/" + dateTime + "-" + xlName + "-统计日报.xls");  
3436 - } catch (Exception e) {  
3437 - // TODO: handle exception  
3438 - //e.printStackTrace();  
3439 - logger.info("", e);  
3440 - }  
3441 - }  
3442 -  
3443 - if (type != null && type.length() != 0 && type.equals("exportAll")) {  
3444 - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();  
3445 - Map<String, Map<String, Object>> tempMap = new HashMap<String, Map<String, Object>>();  
3446 - List<Map<String, Object>> removeList = new ArrayList<Map<String, Object>>();  
3447 - for(Map<String, Object> m : lMap){  
3448 - if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0  
3449 - && m.get("gsName").toString().trim().contains("临港")){  
3450 - removeList.add(m);  
3451 - }  
3452 - }  
3453 - for(Map<String, Object> m : removeList){  
3454 - lMap.remove(m);  
3455 - }  
3456 - for(Map<String, Object> m : lMap){  
3457 - if(m.get("gsName") != null && m.get("gsName").toString().trim().length() > 0){  
3458 - String gsName = m.get("gsName").toString().trim();  
3459 - Map<String, Object> temp = new HashMap<String, Object>();  
3460 - if(tempMap.get(gsName) != null){  
3461 - temp = tempMap.get(gsName);  
3462 - } else {  
3463 - temp.put("gsName", gsName);  
3464 - temp.put("fgsName", "小计");  
3465 - temp.put("xlName", "");  
3466 - tempList.add(temp);  
3467 - tempMap.put(gsName, temp);  
3468 - }  
3469 - for(String key : m.keySet()){  
3470 - try {  
3471 - temp.put(key, new BigDecimal(m.get(key).toString()).add(  
3472 - new BigDecimal(temp.get(key)!=null?temp.get(key).toString():"0")));  
3473 - } catch (Exception e) {  
3474 - // TODO: handle exception  
3475 - }  
3476 - }  
3477 - }  
3478 - }  
3479 - lMap.addAll(lMap.size()>0?lMap.size()-1:0, tempList);  
3480 -  
3481 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
3482 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
3483 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
3484 - Map<String, Object> m = new HashMap<String, Object>();  
3485 - m.put("date", date + "至" + date2);  
3486 - ReportUtils ee = new ReportUtils();  
3487 - try {  
3488 - String dateTime = "";  
3489 - if (date.equals(date2)) {  
3490 - dateTime = sdfSimple.format(sdfMonth.parse(date));  
3491 - } else {  
3492 - dateTime = sdfSimple.format(sdfMonth.parse(date))  
3493 - + "-" + sdfSimple.format(sdfMonth.parse(date2));  
3494 - }  
3495 - listI.add(lMap.iterator());  
3496 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
3497 - ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_4.xls",  
3498 - path + "export/" + dateTime + "-全部公司-统计日报.xls");  
3499 - } catch (Exception e) {  
3500 - // TODO: handle exception  
3501 - //e.printStackTrace();  
3502 - logger.info("", e);  
3503 - }  
3504 - }  
3505 -  
3506 - return lMap;  
3507 - }  
3508 -  
3509 - @Override  
3510 - public List<Map<String, Object>> statisticsDailyTjHb(String gsdm, String fgsdm, String line, String date, String date2,  
3511 - String xlName, String type,String nature) {  
3512 - List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>();  
3513 - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();  
3514 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
3515 - List<Object[]> listInterval=new ArrayList<Object[]>();  
3516 -  
3517 - line = line.trim();  
3518 - if (line.equals("")) {  
3519 - //查询所有线路  
3520 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);  
3521 - listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2);  
3522 - } else {  
3523 - //查询单条线路  
3524 - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);  
3525 - listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2);  
3526 - }  
3527 - Map<String, Map<String,Object>> mapInterval=new HashMap<>();  
3528 - for (int i = 0; i < listInterval.size(); i++) {  
3529 - Object[] interval=listInterval.get(i);  
3530 - String gs=interval[0].toString();  
3531 - String fgs=interval[1].toString();  
3532 - String xl=interval[2].toString();  
3533 - Map<String, Object> m=new HashMap<String,Object>();  
3534 - m.put("gs", gs);  
3535 - m.put("fgs", fgs);  
3536 - m.put("xl", xl);  
3537 - m.put("djgAll", interval[3]);  
3538 - m.put("djgZgf", interval[6]);  
3539 - m.put("djgWgf", interval[7]);  
3540 - m.put("djgTime", interval[8]);  
3541 - mapInterval.put(gs+"-"+fgs+"-"+xl, m);  
3542 - }  
3543 -  
3544 - Map<String, Boolean> lineMap=lineService.lineNature();  
3545 - List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();  
3546 - for (int i = 0; i < listAll.size(); i++) {  
3547 - ScheduleRealInfo s=listAll.get(i);  
3548 - if (nature.equals("0")) {  
3549 - list.add(s);  
3550 - }else if(nature.equals("1")){  
3551 - if(lineMap.get(s.getXlBm())){  
3552 - list.add(s);  
3553 - }  
3554 - }else{  
3555 - if(!lineMap.get(s.getXlBm())){  
3556 - list.add(s);  
3557 - }  
3558 - }  
3559 - }  
3560 - for (int i = 0; i < list.size(); i++) {  
3561 - ScheduleRealInfo s = list.get(i);  
3562 - Set<ChildTaskPlan> cts = s.getcTasks();  
3563 - if (cts != null && cts.size() > 0) {  
3564 - list_s.add(s);  
3565 - } else {  
3566 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
3567 - list_s.add(s);  
3568 - }  
3569 - }  
3570 - }  
3571 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
3572 - for (int i = 0; i < list.size(); i++) {  
3573 - if (i < list.size() - 1) {  
3574 - if ((list.get(i + 1).getFgsBm()+list.get(i + 1).getXlBm()).equals(list.get(i).getFgsBm()+list.get(i).getXlBm())) {  
3575 - lists.add(list.get(i));  
3576 - } else {  
3577 - lists.add(list.get(i));  
3578 - Map<String, Object> mm=new HashMap<String,Object>();  
3579 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3580 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3581 - }  
3582 - Map<String, Object> map = staticTj(lists,mm);  
3583 - lMap.add(map);  
3584 - lists = new ArrayList<ScheduleRealInfo>();  
3585 - }  
3586 - } else {  
3587 - if ((list.get(i).getFgsBm()+list.get(i).getXlBm()).equals(list.get(i - 1).getFgsBm()+list.get(i - 1).getXlBm())) {  
3588 - lists.add(list.get(i));  
3589 - Map<String, Object> mm=new HashMap<String,Object>();  
3590 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3591 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3592 - }  
3593 - Map<String, Object> map = staticTj(lists,mm);  
3594 - lMap.add(map);  
3595 - } else {  
3596 - lists = new ArrayList<ScheduleRealInfo>();  
3597 - lists.add(list.get(i));  
3598 - Map<String, Object> mm=new HashMap<String,Object>();  
3599 - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){  
3600 - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm());  
3601 - }  
3602 - Map<String, Object> map = staticTj(lists,mm);  
3603 - lMap.add(map);  
3604 - }  
3605 - }  
3606 - }  
3607 -  
3608 - Collections.sort(lMap, new AccountXlbm());  
3609 - Map<String, Object> map = new HashMap<String, Object>();  
3610 - map.put("xlBm", "hj");  
3611 - map.put("xlName", "合计");  
3612 - map.put("fgsBm", "");  
3613 - map.put("fgsName", "");  
3614 - map.put("gsBm", "");  
3615 - double jhyygl = culateService.culateJhgl(list);//计划营运公里  
3616 - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)  
3617 - map.put("jhlc", jhyygl);  
3618 - map.put("jcclc", jhjcclc);  
3619 - map.put("jhzlc", Arith.add(jhyygl, jhjcclc));  
3620 -  
3621 - double ljgl = culateService.culateLjgl(list_s);  
3622 - double sjyygl = culateService.culateSjgl(list_s);  
3623 - double zyygl = Arith.add(sjyygl, ljgl);  
3624 - double ljks=culateService.culateLjksgl(list_s);  
3625 - map.put("ljks", ljks);  
3626 - double sjjccgl = culateService.culateJccgl(list_s);  
3627 - double sjksgl = culateService.culateKsgl(list_s);  
3628 - double zksgl = Arith.add(sjjccgl, sjksgl);  
3629 - map.put("sjzgl", Arith.add(zyygl, zksgl));  
3630 - map.put("sjgl", zyygl);  
3631 - map.put("sjksgl", zksgl);  
3632 -  
3633 - double ssgl = culateService.culateLbgl(list);  
3634 - map.put("ssgl", ssgl);  
3635 - //计划+临加-少驶=实驶  
3636 - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl);  
3637 - if (jl == zyygl) {  
3638 - map.put("zt", 0);  
3639 - } else {  
3640 - map.put("zt", 1);  
3641 - }  
3642 - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻"));  
3643 - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢"));  
3644 - map.put("ssgl_gz", culateService.culateCJLC(list, "故障"));  
3645 - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷"));  
3646 - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事"));  
3647 - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人"));  
3648 - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车"));  
3649 - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀"));  
3650 - map.put("ssgl_qh", culateService.culateCJLC(list, "气候"));  
3651 - map.put("ssgl_yw", culateService.culateCJLC(list, "援外"));  
3652 - map.put("ssgl_ljpm", culateService.culateCJLC(list, "路救抛锚"));  
3653 - double ssgl_pc = culateService.culateCJLC(list, "配车");  
3654 - double ssgl_by = culateService.culateCJLC(list, "保养");  
3655 - double ssgl_cj = culateService.culateCJLC(list, "抽减");  
3656 - double ssgl_qt = culateService.culateCJLC(list, "其他");  
3657 - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt)));  
3658 -  
3659 - map.put("ssbc", culateService.culateLbbc(list));  
3660 - map.put("ljgl", ljgl);  
3661 - map.put("jhbc", culateService.culateJhbc(list, ""));  
3662 - map.put("jhbc_m", culateService.culateJhbc(list, "zgf"));  
3663 - map.put("jhbc_a", culateService.culateJhbc(list, "wgf"));  
3664 - map.put("sjbc", culateService.culateSjbc(list_s, ""));  
3665 - map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf"));  
3666 - map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf"));  
3667 - map.put("ljbc", culateService.culateLjbc(list_s, ""));  
3668 - map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf"));  
3669 - map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf"));  
3670 - map.put("fzbc", culateService.culateFzbc(list_s, ""));  
3671 - map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf"));  
3672 - map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf"));  
3673 - map.put("dtbc", 0);  
3674 - map.put("dtbc_m", 0);  
3675 - map.put("dtbc_a", 0);  
3676 - if (list.size() > 0) {  
3677 - int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0;  
3678 - for (Map<String, Object> m : lMap) {  
3679 - if (m.containsKey("djg") && m.get("djg") != null)  
3680 - djg += Integer.valueOf(m.get("djg").toString());  
3681 - if (m.containsKey("djg_m") && m.get("djg_m") != null)  
3682 - djg_m += Integer.valueOf(m.get("djg_m").toString());  
3683 - if (m.containsKey("djg_a") && m.get("djg_a") != null)  
3684 - djg_a += Integer.valueOf(m.get("djg_a").toString());  
3685 - if (m.containsKey("djg_time") && m.get("djg_time") != null) {  
3686 - int t = Integer.valueOf(m.get("djg_time").toString());  
3687 - if (t > djg_time)  
3688 - djg_time = t;  
3689 - }  
3690 - }  
3691 - map.put("djg", djg);  
3692 - map.put("djg_m", djg_m);  
3693 - map.put("djg_a", djg_a);  
3694 - map.put("djg_time", djg_time);  
3695 - } else {  
3696 - map.put("djg", "0");  
3697 - map.put("djg_m", "0");  
3698 - map.put("djg_a", "0");  
3699 - map.put("djg_time", "0");  
3700 - }  
3701 - lMap.add(map);  
3702 - return lMap;  
3703 - }  
3704 -  
3705 - @Override  
3706 - public Map<String, Object> scheduleDaily(String line, String date) {  
3707 - Map<String, String> tempMap = null;  
3708 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);  
3709 - Map<String, Object> map = new HashMap<String, Object>();  
3710 - Double jhlc = 0.00;  
3711 - Float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f,  
3712 - ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_ljpm = 0f,  
3713 - ssgl_other = 0f, ljgl = 0f;  
3714 - int jhbc = 0;  
3715 - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) {  
3716 - if (scheduleRealInfo != null) {  
3717 - //计算里程(包括子任务)  
3718 - jhlc += scheduleRealInfo.getJhlc();  
3719 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
3720 - if (!childTaskPlans.isEmpty()) {  
3721 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
3722 - while (it.hasNext()) {  
3723 - ChildTaskPlan childTaskPlan = it.next();  
3724 - //是否烂班,烂班就是少驶  
3725 - if (!childTaskPlan.isDestroy()) {  
3726 - sjgl += childTaskPlan.getMileage();  
3727 - } else {  
3728 - ssgl += childTaskPlan.getMileage();  
3729 - if (childTaskPlan.getDestroyReason().equals("路阻")) {  
3730 - ssgl_lz += childTaskPlan.getMileage();  
3731 - } else if (childTaskPlan.getDestroyReason().equals("吊慢")) {  
3732 - ssgl_dm += childTaskPlan.getMileage();  
3733 - } else if (childTaskPlan.getDestroyReason().equals("故障")) {  
3734 - ssgl_gz += childTaskPlan.getMileage();  
3735 - } else if (childTaskPlan.getDestroyReason().equals("纠纷")) {  
3736 - ssgl_jf += childTaskPlan.getMileage();  
3737 - } else if (childTaskPlan.getDestroyReason().equals("肇事")) {  
3738 - ssgl_zs += childTaskPlan.getMileage();  
3739 - } else if (childTaskPlan.getDestroyReason().equals("缺人")) {  
3740 - ssgl_qr += childTaskPlan.getMileage();  
3741 - } else if (childTaskPlan.getDestroyReason().equals("缺车")) {  
3742 - ssgl_qc += childTaskPlan.getMileage();  
3743 - } else if (childTaskPlan.getDestroyReason().equals("客稀")) {  
3744 - ssgl_kx += childTaskPlan.getMileage();  
3745 - } else if (childTaskPlan.getDestroyReason().equals("气候")) {  
3746 - ssgl_qh += childTaskPlan.getMileage();  
3747 - } else if (childTaskPlan.getDestroyReason().equals("援外")) {  
3748 - ssgl_yw += childTaskPlan.getMileage();  
3749 - } else if (childTaskPlan.getDestroyReason().equals("路救抛锚")) {  
3750 - ssgl_ljpm += childTaskPlan.getMileage();  
3751 - } else {  
3752 - ssgl_other += childTaskPlan.getMileage();  
3753 - }  
3754 - }  
3755 - //临加公里  
3756 - if (childTaskPlan.getType1().equals("临加")) {  
3757 - ljgl += childTaskPlan.getMileage();  
3758 - }  
3759 - }  
3760 - }  
3761 - //班次  
3762 - scheduleRealInfo.getFcsjT();  
3763 - scheduleRealInfo.getFcsjActualTime();  
3764 - }  
3765 - }  
3766 - map.put("jhlc", jhlc);  
3767 - map.put("sjgl", sjgl);  
3768 - map.put("ssgl", ssgl);  
3769 - map.put("ssgl_lz", ssgl_lz);  
3770 - map.put("ssgl_dm", ssgl_dm);  
3771 - map.put("ssgl_gz", ssgl_gz);  
3772 - map.put("ssgl_jf", ssgl_jf);  
3773 - map.put("ssgl_zs", ssgl_zs);  
3774 - map.put("ssgl_qr", ssgl_qr);  
3775 - map.put("ssgl_qc", ssgl_qc);  
3776 - map.put("ssgl_kx", ssgl_kx);  
3777 - map.put("ssgl_qh", ssgl_qh);  
3778 - map.put("ssgl_yw", ssgl_yw);  
3779 - map.put("ssgl_ljpm", ssgl_ljpm);  
3780 - map.put("ssgl_other", ssgl_other);  
3781 - map.put("ljgl", ljgl);  
3782 -  
3783 - map.put("jhbc", scheduleRealInfos.size());  
3784 - return null;  
3785 - }  
3786 -  
3787 - @Override  
3788 - public int countByLineCodeAndDate(String xlBm, String schDate) {  
3789 - return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate);  
3790 - }  
3791 -  
3792 - @Override  
3793 - public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) {  
3794 - return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate);  
3795 - }  
3796 -  
3797 - @Override  
3798 - public void deleteByLineCodeAndDate(String xlBm, String schDate) {  
3799 - scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate);  
3800 - }  
3801 -  
3802 - @Override  
3803 - public Long getMaxId() {  
3804 - return scheduleRealInfoRepository.getMaxId();  
3805 - }  
3806 -  
3807 - @Override  
3808 - public List<ScheduleRealInfo> realScheduleList(String line, String date) {  
3809 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
3810 - String lpName = "lpName";  
3811 - String zdsj = "";  
3812 - String zdsjActual = "";  
3813 - String zdsj1 = "";  
3814 - String zdsjActual1 = "";  
3815 - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date);  
3816 -  
3817 - /*  
3818 - * 对计划发车时间相同的班次进行排序 out最前 in最后  
3819 - */  
3820 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
3821 - SimpleDateFormat sdfnyr =new SimpleDateFormat("yyyy-MM-dd");  
3822 - String minfcsj = "02:00";  
3823 - List<Line> lineList = lineRepository.findLineByCode(line);  
3824 - if (lineList.size() > 0) {  
3825 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
3826 - + " id = ("  
3827 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
3828 - + ")";  
3829 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
3830 - }  
3831 - String[] minSjs = minfcsj.split(":");  
3832 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
3833 - for (int i = 0; i < listInfo.size(); i++) {  
3834 - ScheduleRealInfo s = listInfo.get(i);  
3835 - if (s.getBcType().equals("out")) {  
3836 - s.setRemark("1");  
3837 - } else if (s.getBcType().equals("in")) {  
3838 - s.setRemark("3");  
3839 - } else {  
3840 - s.setRemark("2");  
3841 - }  
3842 - String[] fcsj = s.getFcsj().split(":");  
3843 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
3844 -  
3845 - Long fscjT = 0L;  
3846 - if (fcsjL < minSj) {  
3847 - Calendar calendar = new GregorianCalendar();  
3848 - calendar.setTime(s.getScheduleDate());  
3849 - calendar.add(calendar.DATE, 1);  
3850 - Date date_sch= calendar.getTime();  
3851 - try {  
3852 - fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime();  
3853 - } catch (ParseException e) {  
3854 - // TODO Auto-generated catch block  
3855 - e.printStackTrace();  
3856 - }  
3857 -  
3858 - } else {  
3859 - try {  
3860 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
3861 - } catch (ParseException e) {  
3862 - // TODO Auto-generated catch block  
3863 - e.printStackTrace();  
3864 - };  
3865 - }  
3866 - s.setFcsjT(fscjT);  
3867 - }  
3868 - List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>();  
3869 - listInfo2.addAll(listInfo);  
3870 - Collections.sort(listInfo, new compareLpFcsjType());  
3871 - Collections.sort(listInfo2,new compareDirLpFcsjType());  
3872 - for (int i = 0; i < listInfo.size(); i++) {  
3873 - ScheduleRealInfo t = listInfo.get(i);  
3874 - if (!lpName.equals(t.getLpName())) {  
3875 - zdsjActual = t.getZdsjActual();  
3876 - zdsj = t.getZdsj();  
3877 - t.setZdsjActual("");  
3878 - t.setZdsj("");  
3879 - } else {  
3880 - zdsj1 = t.getZdsj();  
3881 - zdsjActual1 = t.getZdsjActual();  
3882 - t.setZdsjActual(zdsjActual);  
3883 - t.setZdsj(zdsj);  
3884 - zdsj = zdsj1;  
3885 - zdsjActual = zdsjActual1;  
3886 - }  
3887 - lpName = t.getLpName();  
3888 - list.add(t);  
3889 - }  
3890 -/*  
3891 - List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleDdrb2(line, date);  
3892 - for (int i = 0; i < listInfo2.size(); i++) {  
3893 - ScheduleRealInfo s = listInfo2.get(i);  
3894 - if (s.getBcType().equals("out")) {  
3895 - s.setRemark("1");  
3896 - } else if (s.getBcType().equals("in")) {  
3897 - s.setRemark("3");  
3898 - } else {  
3899 - s.setRemark("2");  
3900 - }  
3901 - String[] fcsj = s.getFcsj().split(":");  
3902 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
3903 -  
3904 - Long fscjT = 0L;  
3905 - if (fcsjL < minSj) {  
3906 - Calendar calendar = new GregorianCalendar();  
3907 - calendar.setTime(s.getScheduleDate());  
3908 - calendar.add(calendar.DATE, 1);  
3909 - s.setScheduleDate(calendar.getTime());  
3910 - try {  
3911 - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();  
3912 - } catch (ParseException e) {  
3913 - // TODO Auto-generated catch block  
3914 - e.printStackTrace();  
3915 - }  
3916 -  
3917 - } else {  
3918 - try {  
3919 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
3920 - } catch (ParseException e) {  
3921 - // TODO Auto-generated catch block  
3922 - e.printStackTrace();  
3923 - }  
3924 - ;  
3925 - }  
3926 - s.setFcsjT(fscjT);  
3927 - }*/  
3928 - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();  
3929 - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();  
3930 - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();  
3931 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
3932 - if (listInfo2.size() > 0) {  
3933 - int a = listInfo2.size() % 3;  
3934 - int b = listInfo2.size() / 3;  
3935 - int x = 0, y = 0;  
3936 - if (a == 2) {  
3937 - x = b + 1;  
3938 - y = x * 2;  
3939 - } else if (a == 1) {  
3940 - x = b + 1;  
3941 - y = x * 2 - 1;  
3942 - } else {  
3943 - x = b;  
3944 - y = 2 * x;  
3945 -  
3946 - }  
3947 - for (int i = 0; i < listInfo2.size(); i++) {  
3948 - ScheduleRealInfo s = listInfo2.get(i);  
3949 - if (i + 1 <= x) {  
3950 - xList.add(s);  
3951 - } else if ((i + 1) > x && (i + 1) <= y) {  
3952 - yList.add(s);  
3953 - } else {  
3954 - zList.add(s);  
3955 - }  
3956 - }  
3957 - for (int i = 0; i < x; i++) {  
3958 - newList.add(xList.get(i));  
3959 - if (yList.size() > i) {  
3960 - newList.add(yList.get(i));  
3961 - } else {  
3962 - newList.add(new ScheduleRealInfo());  
3963 - }  
3964 - if (zList.size() > i) {  
3965 - newList.add(zList.get(i));  
3966 - } else {  
3967 - newList.add(new ScheduleRealInfo());  
3968 - }  
3969 -  
3970 - }  
3971 - }  
3972 - for (int i = 0; i < newList.size(); i++) {  
3973 - ScheduleRealInfo t1 = newList.get(i);  
3974 - for (int j = 0; j < list.size(); j++) {  
3975 - ScheduleRealInfo t2 = list.get(j);  
3976 - if (t1.getId() == t2.getId()) {  
3977 - t1 = t2;  
3978 - }  
3979 - }  
3980 - }  
3981 -  
3982 - for (int i = 0; i < newList.size(); i++) {  
3983 - ScheduleRealInfo t1 = newList.get(i);  
3984 - String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks();  
3985 - if (reamrks1.length() > 4) {  
3986 - t1.setRemarks(reamrks1.substring(0, 4));  
3987 - t1.setRemark(reamrks1);  
3988 - } else {  
3989 - t1.setRemark(reamrks1);  
3990 - }  
3991 - }  
3992 - return newList;  
3993 - }  
3994 -  
3995 - @Override  
3996 - public List<ScheduleRealInfo> realScheduleList_zrw(String line, String date) {  
3997 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
3998 - String lpName = "lpName";  
3999 - String zdsj = "";  
4000 - String zdsjActual = "";  
4001 - String zdsj1 = "";  
4002 - String zdsjActual1 = "";  
4003 - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date);  
4004 -  
4005 - /*  
4006 - * 对计划发车时间相同的班次进行排序 out最前 in最后  
4007 - */  
4008 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
4009 - SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd");  
4010 -  
4011 - String minfcsj = "02:00";  
4012 - List<Line> lineList = lineRepository.findLineByCode(line);  
4013 - if (lineList.size() > 0) {  
4014 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
4015 - + " id = ("  
4016 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
4017 - + ")";  
4018 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
4019 - }  
4020 - String[] minSjs = minfcsj.split(":");  
4021 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
4022 - for (int i = 0; i < listInfo.size(); i++) {  
4023 - ScheduleRealInfo s = listInfo.get(i);  
4024 - if (s.getBcType().equals("out")) {  
4025 - s.setRemark("1");  
4026 - } else if (s.getBcType().equals("in")) {  
4027 - s.setRemark("3");  
4028 - } else {  
4029 - s.setRemark("2");  
4030 - }  
4031 - String[] fcsj = s.getFcsj().split(":");  
4032 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
4033 -  
4034 - Long fscjT = 0L;  
4035 - if (fcsjL < minSj) {  
4036 - Calendar calendar = new GregorianCalendar();  
4037 - calendar.setTime(s.getScheduleDate());  
4038 - calendar.add(calendar.DATE, 1);  
4039 - Date date_sch=calendar.getTime();  
4040 - try {  
4041 - fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime();  
4042 - } catch (ParseException e) {  
4043 - // TODO Auto-generated catch block  
4044 - e.printStackTrace();  
4045 - }  
4046 -  
4047 - } else {  
4048 - try {  
4049 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
4050 - } catch (ParseException e) {  
4051 - // TODO Auto-generated catch block  
4052 - e.printStackTrace();  
4053 - }  
4054 - ;  
4055 - }  
4056 - s.setFcsjT(fscjT);  
4057 - }  
4058 -  
4059 -// Collections.sort(listInfo, new compareLpFcsjType());  
4060 - List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>();  
4061 -  
4062 - Collections.sort(listInfo, new compareLpFcsjType());  
4063 - for (int i = 0; i < listInfo.size(); i++) {  
4064 - ScheduleRealInfo t = listInfo.get(i);  
4065 - if (!lpName.equals(t.getLpName())) {  
4066 - zdsjActual = t.getZdsjActual();  
4067 - zdsj = t.getZdsj();  
4068 - t.setZdsjActual("");  
4069 - t.setZdsj("");  
4070 - } else {  
4071 - zdsj1 = t.getZdsj();  
4072 - zdsjActual1 = t.getZdsjActual();  
4073 - t.setZdsjActual(zdsjActual);  
4074 - t.setZdsj(zdsj);  
4075 - zdsj = zdsj1;  
4076 - zdsjActual = zdsjActual1;  
4077 - }  
4078 -  
4079 -  
4080 -  
4081 - lpName = t.getLpName();  
4082 - listInfo2.add(t);  
4083 -  
4084 - }  
4085 -  
4086 - Collections.sort(listInfo2,new compareDirLpFcsjType());  
4087 - for (int i = 0; i < listInfo2.size(); i++) {  
4088 - ScheduleRealInfo t=listInfo2.get(i);  
4089 - list.add(t);  
4090 - Set<ChildTaskPlan> childTaskPlans = t.getcTasks();  
4091 - //计算营运里程,空驶里程  
4092 - if (!childTaskPlans.isEmpty()) {  
4093 - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);  
4094 - Collections.sort(listit, new ComparableChild());  
4095 - for (int j = 0; j < listit.size(); j++) {  
4096 - ScheduleRealInfo s = new ScheduleRealInfo();  
4097 - ChildTaskPlan childTaskPlan = listit.get(j);  
4098 - if (childTaskPlan.getCcId() == null) {  
4099 - if (childTaskPlan.isDestroy()) {  
4100 - s.setFcsjActual("");  
4101 - s.setZdsjActual("");  
4102 - } else {  
4103 - s.setFcsjActual(childTaskPlan.getStartDate());  
4104 - s.setZdsjActual("");  
4105 - s.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));  
4106 - }  
4107 - s.setFcsj(childTaskPlan.getStartDate());  
4108 - s.setZdsj("");  
4109 - s.setQdzName(childTaskPlan.getStartStationName());  
4110 - s.setZdzName(childTaskPlan.getEndStationName());  
4111 - s.setRemarks(childTaskPlan.getRemarks());  
4112 - s.setAdjustExps("子");  
4113 - s.setLpName("");  
4114 - list.add(s);  
4115 - }  
4116 - }  
4117 - }  
4118 - }  
4119 - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();  
4120 - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();  
4121 - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();  
4122 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
4123 - if (list.size() > 0) {  
4124 - int a = list.size() % 3;  
4125 - int b = list.size() / 3;  
4126 - int x = 0, y = 0;  
4127 - if (a == 2) {  
4128 - x = b + 1;  
4129 - y = x * 2;  
4130 - } else if (a == 1) {  
4131 - x = b + 1;  
4132 - y = x * 2 - 1;  
4133 - } else {  
4134 - x = b;  
4135 - y = 2 * x;  
4136 -  
4137 - }  
4138 - for (int i = 0; i < list.size(); i++) {  
4139 - ScheduleRealInfo s = list.get(i);  
4140 - if (i + 1 <= x) {  
4141 - xList.add(s);  
4142 - } else if ((i + 1) > x && (i + 1) <= y) {  
4143 - yList.add(s);  
4144 - } else {  
4145 - zList.add(s);  
4146 - }  
4147 - }  
4148 - for (int i = 0; i < x; i++) {  
4149 - newList.add(xList.get(i));  
4150 - if (yList.size() > i) {  
4151 - newList.add(yList.get(i));  
4152 - } else {  
4153 - newList.add(new ScheduleRealInfo());  
4154 - }  
4155 - if (zList.size() > i) {  
4156 - newList.add(zList.get(i));  
4157 - } else {  
4158 - newList.add(new ScheduleRealInfo());  
4159 - }  
4160 -  
4161 - }  
4162 - }  
4163 - /* for (int i = 0; i < newList.size(); i++) {  
4164 - ScheduleRealInfo t1 = newList.get(i);  
4165 - for (int j = 0; j < list.size(); j++) {  
4166 - ScheduleRealInfo t2 = list.get(j);  
4167 - if (t1.getId() == t2.getId()) {  
4168 - t1 = t2;  
4169 - }  
4170 - }  
4171 - }*/  
4172 -  
4173 - for (int i = 0; i < newList.size(); i++) {  
4174 - ScheduleRealInfo t1 = newList.get(i);  
4175 - String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks();  
4176 - if (reamrks1.length() > 4) {  
4177 - t1.setRemarks(reamrks1.substring(0, 4));  
4178 - t1.setRemark(reamrks1);  
4179 - } else {  
4180 - t1.setRemark(reamrks1);  
4181 - }  
4182 - }  
4183 - return newList;  
4184 - }  
4185 -  
4186 - @Override  
4187 - public List<ScheduleRealInfo> realScheduleList_mh_2(String line, String date) {  
4188 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
4189 - String lpName = "lpName";  
4190 - String zdsj = "";  
4191 - String zdsjActual = "";  
4192 - String zdsj1 = "";  
4193 - String zdsjActual1 = "";  
4194 - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date);  
4195 -  
4196 - for (ScheduleRealInfo s : listInfo) {  
4197 - if (s.isDestroy() && s.isReissue()) {  
4198 - s.setRemark("");  
4199 - s.setFcsjActual(s.getDfsj());  
4200 - s.setZdsjActual(s.getZdsj());  
4201 - s.setStatus(2);  
4202 - s.setJhlc(s.getJhlcOrig());  
4203 - }  
4204 - }  
4205 -  
4206 - for (int i = 0; i < listInfo.size(); i++) {  
4207 - ScheduleRealInfo t = listInfo.get(i);  
4208 - if (!lpName.equals(t.getLpName())) {  
4209 - zdsjActual = t.getZdsjActual();  
4210 - zdsj = t.getZdsj();  
4211 - t.setZdsjActual("");  
4212 - t.setZdsj("");  
4213 - } else {  
4214 - zdsj1 = t.getZdsj();  
4215 - zdsjActual1 = t.getZdsjActual();  
4216 - t.setZdsjActual(zdsjActual);  
4217 - t.setZdsj(zdsj);  
4218 - zdsj = zdsj1;  
4219 - zdsjActual = zdsjActual1;  
4220 - }  
4221 - lpName = t.getLpName();  
4222 - list.add(t);  
4223 - }  
4224 -  
4225 - List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleByDateAndLineQp2(line, date);  
4226 - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();  
4227 - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();  
4228 - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();  
4229 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
4230 - if (listInfo2.size() > 0) {  
4231 - int a = listInfo2.size() % 3;  
4232 - int b = listInfo2.size() / 3;  
4233 - int x = 0, y = 0;  
4234 - if (a == 2) {  
4235 - x = b + 1;  
4236 - y = x * 2;  
4237 - } else if (b == 1) {  
4238 - x = b + 1;  
4239 - y = x * 2 - 1;  
4240 - } else {  
4241 - x = b;  
4242 - y = 2 * x;  
4243 -  
4244 - }  
4245 - for (int i = 0; i < listInfo2.size(); i++) {  
4246 - ScheduleRealInfo s = listInfo2.get(i);  
4247 - if (i + 1 <= x) {  
4248 - xList.add(s);  
4249 - } else if ((i + 1) > x && (i + 1) <= y) {  
4250 - yList.add(s);  
4251 - } else {  
4252 - zList.add(s);  
4253 - }  
4254 - }  
4255 - for (int i = 0; i < x; i++) {  
4256 - newList.add(xList.get(i));  
4257 - if (yList.size() > i) {  
4258 - newList.add(yList.get(i));  
4259 - } else {  
4260 - newList.add(new ScheduleRealInfo());  
4261 - }  
4262 - if (zList.size() > i) {  
4263 - newList.add(zList.get(i));  
4264 - } else {  
4265 - newList.add(new ScheduleRealInfo());  
4266 - }  
4267 -  
4268 - }  
4269 - }  
4270 - for (int i = 0; i < newList.size(); i++) {  
4271 - ScheduleRealInfo t1 = newList.get(i);  
4272 - for (int j = 0; j < list.size(); j++) {  
4273 - ScheduleRealInfo t2 = list.get(j);  
4274 - if (t1.getId() == t2.getId()) {  
4275 - t1 = t2;  
4276 - }  
4277 - }  
4278 - }  
4279 - return newList;  
4280 - }  
4281 -  
4282 - @Override  
4283 - public List<ScheduleRealInfo> realScheduleListQp(String line, String date) {  
4284 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
4285 - String lpName = "lpName";  
4286 - String zdsj = "";  
4287 - String zdsjActual = "";  
4288 - String zdsj1 = "";  
4289 - String zdsjActual1 = "";  
4290 - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date);  
4291 - for (int i = 0; i < listInfo.size(); i++) {  
4292 - ScheduleRealInfo t = listInfo.get(i);  
4293 - if (!lpName.equals(t.getLpName())) {  
4294 - zdsjActual = t.getZdsjActual();  
4295 - zdsj = t.getZdsj();  
4296 - t.setZdsjActual("");  
4297 - t.setZdsj("");  
4298 - } else {  
4299 - zdsj1 = t.getZdsj();  
4300 - zdsjActual1 = t.getZdsjActual();  
4301 - t.setZdsjActual(zdsjActual);  
4302 - t.setZdsj(zdsj);  
4303 - zdsj = zdsj1;  
4304 - zdsjActual = zdsjActual1;  
4305 - }  
4306 -  
4307 - lpName = t.getLpName();  
4308 - list.add(t);  
4309 - }  
4310 - return list;  
4311 - }  
4312 -  
4313 - public List<Map<String, Object>> yesterdayDataList(String line, String date, String gsbm, String fgsbm, String jGh, String nbbm) {  
4314 - List<Map<String, Object>> yesterdayDataList = new ArrayList<Map<String, Object>>();  
4315 - if (line.equals("")) {  
4316 - yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date, gsbm, fgsbm, nbbm);  
4317 - } else {  
4318 - yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList_eq(line, date, gsbm, fgsbm, nbbm);  
4319 - }  
4320 - List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date, gsbm, fgsbm);  
4321 - for (int x = 0; x < yesterdayDataList.size(); x++) {  
4322 - String jsy = yesterdayDataList.get(x).get("jGh").toString();  
4323 - String clZbh = yesterdayDataList.get(x).get("clZbh").toString();  
4324 - String xlbm = yesterdayDataList.get(x).get("xlBm").toString();  
4325 - String lp = yesterdayDataList.get(x).get("lpName").toString();  
4326 - String realExecDate=yesterdayDataList.get(x).get("realExecDate").toString();  
4327 - String fcsj[] =realExecDate.split(" ");  
4328 - //取出最小计划发车时间  
4329 - yesterdayDataList.get(x).put("fcsj", fcsj[1]);  
4330 - Map<String, Object> map = new HashMap<String, Object>();  
4331 - boolean fage = true;  
4332 - String company = "";  
4333 - String bCompany = "";  
4334 - String lineName="";  
4335 - String jName="";  
4336 - List<ScheduleRealInfo> listS = new ArrayList<ScheduleRealInfo>();  
4337 - for (ScheduleRealInfo scheduleRealInfo : lists) {  
4338 - if (scheduleRealInfo.getjGh().equals(jsy)  
4339 - && scheduleRealInfo.getClZbh().equals(clZbh)  
4340 - && scheduleRealInfo.getXlBm().equals(xlbm)  
4341 - && scheduleRealInfo.getLpName().equals(lp)) {  
4342 - if (fage) {  
4343 - //根据线路代码获取公司  
4344 - company = scheduleRealInfo.getGsBm();  
4345 - bCompany = scheduleRealInfo.getFgsBm();  
4346 - lineName = scheduleRealInfo.getXlName();  
4347 - jName= scheduleRealInfo.getjName();  
4348 - fage = false;  
4349 - }  
4350 - Set<ChildTaskPlan> cts = scheduleRealInfo.getcTasks();  
4351 - if (cts != null && cts.size() > 0) {  
4352 - listS.add(scheduleRealInfo);  
4353 - } else {  
4354 - if (scheduleRealInfo.getZdsjActual() != null && scheduleRealInfo.getFcsjActual() != null) {  
4355 - listS.add(scheduleRealInfo);  
4356 - }  
4357 - }  
4358 - }  
4359 - }  
4360 - yesterdayDataList.get(x).put("company", company);  
4361 - yesterdayDataList.get(x).put("bCompany", bCompany);  
4362 - yesterdayDataList.get(x).put("lineName", lineName);  
4363 - yesterdayDataList.get(x).put("jName", jName);  
4364 - Double ljgl = culateMieageService.culateLjgl(listS);  
4365 - Double sjgl = culateMieageService.culateSjgl(listS);  
4366 - Double ksgl = culateMieageService.culateKsgl(listS);  
4367 - Double jccgl = culateMieageService.culateJccgl(listS);  
4368 - Double zyygl = Arith.add(sjgl, ljgl);  
4369 - Double zksgl = Arith.add(ksgl, jccgl);  
4370 - Double zlc = Arith.add(zyygl, zksgl);  
4371 - yesterdayDataList.get(x).put("totalKilometers", zlc);  
4372 -  
4373 - }  
4374 - //增加顺序号  
4375 - for (int i = 0; i < yesterdayDataList.size(); i++) {  
4376 - if (i == 0) {  
4377 - yesterdayDataList.get(i).put("seqNumber", 1);  
4378 - } else {  
4379 - if (yesterdayDataList.get(i - 1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))) {  
4380 - yesterdayDataList.get(i).put("seqNumber", 1 + (int) yesterdayDataList.get(i - 1).get("seqNumber"));  
4381 - } else {  
4382 - yesterdayDataList.get(i).put("seqNumber", 1);  
4383 - }  
4384 - }  
4385 - }  
4386 -  
4387 - return yesterdayDataList;  
4388 - }  
4389 -  
4390 - /**  
4391 - * 批量调整人车  
4392 - */  
4393 - @Override  
4394 - public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs, String userId) {  
4395 - Map<String, Object> rs = new HashMap<>();  
4396 - Set<ScheduleRealInfo> set = new HashSet<>();  
4397 -  
4398 - ScheduleRealInfo sch;  
4399 -  
4400 - String jGh = null, jName, sGh, sName;  
4401 - for (ChangePersonCar cpc : cpcs) {  
4402 -  
4403 - sch = dayOfSchedule.get(cpc.getSchId());  
4404 - if (sch == null)  
4405 - continue;  
4406 -  
4407 - if (cpc.getClZbh() != null) {  
4408 - if (!carExist(sch.getGsBm(), cpc.getClZbh())) {  
4409 - rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");  
4410 - rs.put("status", ResponseCode.ERROR);  
4411 - return rs;  
4412 - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(cpc.getClZbh()))) {  
4413 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + cpc.getClZbh() + "】的车辆");  
4414 - rs.put("status", ResponseCode.ERROR);  
4415 - return rs;  
4416 - }  
4417 - }  
4418 -  
4419 - if (StringUtils.isNotEmpty(cpc.getJsy())) {  
4420 - try{  
4421 - jGh = cpc.getJsy().split("/")[0];  
4422 - }catch (Exception e){  
4423 - logger.error("", e);  
4424 - rs.put("msg", "驾驶员参数异常!!");  
4425 - rs.put("status", ResponseCode.ERROR);  
4426 - return rs;  
4427 - }  
4428 -  
4429 - jName = getPersonName(sch.getGsBm(), jGh);  
4430 - if (StringUtils.isEmpty(jName)) {  
4431 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员");  
4432 - rs.put("status", ResponseCode.ERROR);  
4433 - return rs;  
4434 - }  
4435 - }  
4436 -  
4437 -  
4438 - //为换人换车情况表写入数据  
4439 - schModifyLog.saveChangetochange(sch, cpc, userId);  
4440 - //日志记录  
4441 - ScheduleModifyLogger.tzrc(sch, cpc, userId);  
4442 -  
4443 - //换驾驶员  
4444 - if (StringUtils.isNotEmpty(cpc.getJsy())) {  
4445 - //换驾驶员  
4446 - if (persoChange(sch, jGh))  
4447 - set.add(sch);  
4448 - }  
4449 -  
4450 - //换售票员  
4451 - if (StringUtils.isNotEmpty(cpc.getSpy())  
4452 - && !"/".equals(StringUtils.trim(cpc.getSpy()))) {  
4453 -  
4454 - sGh = cpc.getSpy().split("/")[0];  
4455 - sName = getPersonName(sch.getGsBm(), sGh);  
4456 - if (StringUtils.isEmpty(sName)) {  
4457 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员");  
4458 - rs.put("status", ResponseCode.ERROR);  
4459 - return rs;  
4460 - }  
4461 -  
4462 - /*if(!sGh.equals(sch.getsGh()))  
4463 - sb.append(sch.getsGh() + " 换 " + sGh + ";");*/  
4464 - if (persoChangeSPY(sch, sGh))  
4465 - set.add(sch);  
4466 - } else if (StringUtils.isNotEmpty(sch.getsGh())) {  
4467 - sch.setsGh("");  
4468 - sch.setsName("");  
4469 - }  
4470 -  
4471 - //换车  
4472 - if (StringUtils.isNotEmpty(cpc.getClZbh()) && !cpc.getClZbh().equals(sch.getClZbh())) {  
4473 - //sb.append(sch.getClZbh() + " 换 " + cpc.getClZbh() + ";");  
4474 - set.add(sch);  
4475 - set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh()));  
4476 - }  
4477 -  
4478 - /*if(sb.length() > 0)  
4479 - sch.setRemarks(sb.toString());*/  
4480 -  
4481 - dayOfSchedule.save(sch);  
4482 - set.add(sch);  
4483 -  
4484 - }  
4485 - rs.put("ts", set);  
4486 - rs.put("status", ResponseCode.SUCCESS);  
4487 - return rs;  
4488 - }  
4489 -  
4490 - /**  
4491 - * @Title: persoChange  
4492 - * @Description: TODO(班次换驾驶员)  
4493 - */  
4494 - public boolean persoChange(ScheduleRealInfo sch, String jGh) {  
4495 - if (sch.getjGh().equals(jGh))  
4496 - return false;  
4497 - String jName = getPersonName(sch.getGsBm(), jGh);  
4498 - if (StringUtils.isNotEmpty(jName)) {  
4499 -  
4500 - if (jGh.indexOf("-") != -1)  
4501 - sch.setjGh(jGh.substring(jGh.indexOf("-") + 1));  
4502 - else  
4503 - sch.setjGh(jGh);  
4504 -  
4505 - sch.setjName(jName);  
4506 - return true;  
4507 - }  
4508 - return false;  
4509 - }  
4510 -  
4511 - /**  
4512 - * @Title: persoChange  
4513 - * @Description: TODO(班次换售票员)  
4514 - */  
4515 - public boolean persoChangeSPY(ScheduleRealInfo sch, String sGh) {  
4516 - if (sch.getsGh().equals(sGh))  
4517 - return false;  
4518 - String sName = getPersonName(sch.getGsBm(), sGh);  
4519 - if (StringUtils.isNotEmpty(sName)) {  
4520 - if (sGh.indexOf("-") != -1)  
4521 - sch.setsGh(sGh.substring(sGh.indexOf("-") + 1));  
4522 - else  
4523 - sch.setsGh(sGh);  
4524 - sch.setsName(sName);  
4525 - return true;  
4526 - }  
4527 - return false;  
4528 - }  
4529 -  
4530 - /**  
4531 - * 批量待发调整  
4532 - */  
4533 - @Override  
4534 - public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) {  
4535 - Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>();  
4536 - List<ScheduleRealInfo> list = new ArrayList<>();  
4537 -  
4538 - for (DfsjChange dc : dfsjcs) {  
4539 - if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))  
4540 - continue;  
4541 -  
4542 - tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null, "2", null);  
4543 -  
4544 - if (tempMap.get("status").equals(ResponseCode.SUCCESS)) {  
4545 - list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts"));  
4546 - }  
4547 - }  
4548 -  
4549 - rs.put("status", ResponseCode.SUCCESS);  
4550 - rs.put("ts", list);  
4551 - return rs;  
4552 - }  
4553 -  
4554 -  
4555 - @Override  
4556 - public Map<String, Object> findKMBC1(String jName, String clZbh,  
4557 - String date, String enddate) {  
4558 - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate);  
4559 - DecimalFormat format = new DecimalFormat("0.00");  
4560 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
4561 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
4562 - int jhbc = 0, cjbc = 0, ljbc = 0;  
4563 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;  
4564 - float addMileage = 0l, remMileage = 0l;  
4565 - Map<String, Object> map = new HashMap<String, Object>();  
4566 - for (ScheduleRealInfo scheduleRealInfo : list) {  
4567 - if (scheduleRealInfo != null) {  
4568 - //计划里程(主任务过滤掉临加班次),  
4569 - //烂班里程(主任务烂班),  
4570 - //临加里程(主任务临加),  
4571 - //计划班次,烂班班次,增加班次  
4572 - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();  
4573 - if (scheduleRealInfo.isSflj()) {  
4574 - addMileage += tempJhlc;  
4575 - ljbc++;  
4576 - } else {  
4577 - jhlc += tempJhlc;  
4578 - jhbc++;  
4579 - if (scheduleRealInfo.getStatus() == -1) {  
4580 - remMileage += tempJhlc;  
4581 - cjbc++;  
4582 - }  
4583 - }  
4584 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
4585 - //计算营运里程,空驶里程  
4586 - if (childTaskPlans.isEmpty()) {  
4587 - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")  
4588 - || scheduleRealInfo.getBcType().equals("venting")) {  
4589 - ksgl += tempJhlc;  
4590 - } else {  
4591 - yygl += tempJhlc;  
4592 - }  
4593 - } else {  
4594 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
4595 - while (it.hasNext()) {  
4596 - ChildTaskPlan childTaskPlan = it.next();  
4597 - if (childTaskPlan.getMileageType().equals("empty")) {  
4598 - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4599 - } else {  
4600 - yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4601 - }  
4602 - }  
4603 - }  
4604 - }  
4605 - }  
4606 - map.put("jhlc", format.format(jhlc));  
4607 - map.put("remMileage", format.format(remMileage));  
4608 - map.put("addMileage", format.format(addMileage));  
4609 - map.put("yygl", format.format(yygl));  
4610 - map.put("ksgl", format.format(ksgl));  
4611 - map.put("realMileage", format.format(yygl + ksgl));  
4612 - map.put("jhbc", jhbc);  
4613 - map.put("cjbc", cjbc);  
4614 - map.put("ljbc", ljbc);  
4615 - map.put("sjbc", jhbc - cjbc + ljbc);  
4616 - return map;  
4617 - }  
4618 -  
4619 - /**  
4620 - * 调整班次类型  
4621 - *  
4622 - * @param id  
4623 - * @param bcType  
4624 - * @param remarks  
4625 - * @return  
4626 - */  
4627 - @Override  
4628 - public Map<String, Object> changeBcType(Long id, String bcType, String remarks, String majorStationName) {  
4629 - Map<String, Object> rs = new HashMap<>();  
4630 -  
4631 - try {  
4632 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
4633 - if (sch != null) {  
4634 - sch.setBcType(bcType);  
4635 - sch.setRemarks(remarks);  
4636 - rs.put("status", ResponseCode.SUCCESS);  
4637 - rs.put("t", sch);  
4638 -  
4639 - if ("major".equals(bcType)) {  
4640 - sch.setMajorStationName(majorStationName);  
4641 - }  
4642 -  
4643 - dayOfSchedule.save(sch);  
4644 - }  
4645 - } catch (Exception e) {  
4646 - logger.error("", e);  
4647 - rs.put("status", ResponseCode.ERROR);  
4648 - }  
4649 -  
4650 - return rs;  
4651 - }  
4652 -  
4653 - @Override  
4654 - public Map<String, Object> historySave(ScheduleRealInfo sch) {  
4655 - Map<String, Object> rs = new HashMap<>();  
4656 - rs.put("status", ResponseCode.ERROR);  
4657 -  
4658 - ScheduleRealInfo oldSch = super.findById(sch.getId());  
4659 - //事后日志记录  
4660 - AfterwardsLogger aflog = AfterwardsLogger.start(oldSch, "事后调整");  
4661 -  
4662 - //换车  
4663 - if (StringUtils.isNotEmpty(sch.getClZbh()) && !oldSch.getClZbh().equals(sch.getClZbh())) {  
4664 - if (!carExist(oldSch.getGsBm(), sch.getClZbh())) {  
4665 - rs.put("msg", "车辆 " + sch.getClZbh() + " 不存在!");  
4666 - return rs;  
4667 - } else {  
4668 - aflog.log("换车", oldSch.getClZbh(), sch.getClZbh());  
4669 - oldSch.setClZbh(sch.getClZbh());  
4670 - }  
4671 - }  
4672 -  
4673 - //换驾驶员  
4674 - if (StringUtils.isNotEmpty(sch.getjGh()) && !oldSch.getjGh().equals(sch.getjGh())) {  
4675 - String jName = getPersonName(oldSch.getGsBm(), sch.getjGh());  
4676 - if (StringUtils.isEmpty(jName)) {  
4677 - rs.put("msg", oldSch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员");  
4678 - return rs;  
4679 - }  
4680 - aflog.log("换驾驶员", oldSch.getjGh() + "/" + oldSch.getjName(), sch.getjGh() + "/" + sch.getjName());  
4681 - persoChange(oldSch, sch.getjGh());  
4682 - }  
4683 -  
4684 - //换售票员  
4685 - if (StringUtils.isNotEmpty(sch.getsGh()) && !oldSch.getsGh().equals(sch.getsGh())) {  
4686 - String sName = getPersonName(oldSch.getGsBm(), sch.getsGh());  
4687 - if (StringUtils.isEmpty(sName)) {  
4688 - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getsGh() + "】的售票员");  
4689 - return rs;  
4690 - }  
4691 - aflog.log("换售票员", oldSch.getsGh() + "/" + oldSch.getsName(), sch.getsGh() + "/" + sch.getsName());  
4692 - persoChangeSPY(oldSch, sch.getsGh());  
4693 - }  
4694 -  
4695 - //烂班  
4696 - boolean dest1 = oldSch.getStatus() == -1;  
4697 - boolean dest2 = sch.getStatus() == -1;  
4698 - if (!dest1 && dest2) {  
4699 - oldSch.destroy();  
4700 - aflog.log("烂班");  
4701 - } else if (dest1 && !dest2) {  
4702 - //撤销烂班  
4703 - oldSch.setJhlc(oldSch.getJhlcOrig());  
4704 - oldSch.setStatus(0);  
4705 - oldSch.calcStatus();  
4706 - oldSch.setAdjustExps(null);  
4707 - aflog.log("撤销烂班");  
4708 - }  
4709 -  
4710 - oldSch.setAdjustExps(sch.getAdjustExps());  
4711 -  
4712 - /**  
4713 - * 修改班次里程  
4714 - */  
4715 - if (!oldSch.getJhlc().equals(sch.getJhlc())) {  
4716 - double jhlcNum = sch.getJhlc();  
4717 - aflog.log("修改班次里程", oldSch.getJhlc(), jhlcNum);  
4718 - //烂班  
4719 - if (jhlcNum == 0 && oldSch.getJhlcOrig() != 0)  
4720 - oldSch.destroy();  
4721 - else {  
4722 - oldSch.setJhlc(jhlcNum);  
4723 - //临加班次,实际计划一起改  
4724 - if (oldSch.isSflj())  
4725 - oldSch.setJhlcOrig(jhlcNum);  
4726 - }  
4727 - }  
4728 -  
4729 - //待发时间  
4730 - if (!CustomStringUtils.equals(oldSch.getDfsj(), sch.getDfsj())) {  
4731 - aflog.log("修改待发时间", oldSch.getDfsj(), sch.getDfsj());  
4732 - oldSch.setDfsj(sch.getDfsj());  
4733 - }  
4734 - //实发时间  
4735 - if (!CustomStringUtils.equals(oldSch.getFcsjActual(), sch.getFcsjActual())) {  
4736 - aflog.log("修改实发时间", oldSch.getFcsjActual(), sch.getFcsjActual());  
4737 - oldSch.setFcsjActual(sch.getFcsjActual());  
4738 - }  
4739 - //实际终点  
4740 - if (!CustomStringUtils.equals(oldSch.getZdsjActual(), sch.getZdsjActual())) {  
4741 - aflog.log("修改实达时间", oldSch.getZdsjActual(), sch.getZdsjActual());  
4742 - oldSch.setZdsjActual(sch.getZdsjActual());  
4743 - }  
4744 -  
4745 - //备注  
4746 - if (!CustomStringUtils.equals(oldSch.getRemarks(), sch.getRemarks())) {  
4747 - aflog.log("修改备注", oldSch.getRemarks(), sch.getRemarks());  
4748 - oldSch.setRemarks(sch.getRemarks());  
4749 - }  
4750 -  
4751 - scheduleRealInfoRepository.save(oldSch);  
4752 -  
4753 - aflog.end();  
4754 - rs.put("status", ResponseCode.SUCCESS);  
4755 - return rs;  
4756 - }  
4757 -  
4758 - @Autowired  
4759 - SvgAttributeRepository svgAttributeRepository;  
4760 -  
4761 - @Override  
4762 - public Map<String, Object> svgAttr(String jsonStr) {  
4763 - Map<String, Object> rs = new HashMap<>();  
4764 -  
4765 - try {  
4766 - JSONObject jObj = JSONObject.parseObject(StringEscapeUtils.unescapeHtml4(jsonStr));  
4767 -  
4768 - SvgAttribute svgAttribute = new SvgAttribute();  
4769 - svgAttribute.setLineCode(jObj.getString("lineCode"));  
4770 - svgAttribute.setHideStations(jObj.getString("hideStations"));  
4771 - svgAttribute.setNicknames(jObj.getString("nicknames"));  
4772 - svgAttributeRepository.save(svgAttribute);  
4773 -  
4774 - rs.put("t", svgAttribute);  
4775 - rs.put("status", ResponseCode.SUCCESS);  
4776 - } catch (Exception e) {  
4777 - logger.error("", e);  
4778 - rs.put("status", ResponseCode.ERROR);  
4779 - }  
4780 - return rs;  
4781 - }  
4782 -  
4783 - @Override  
4784 - public Map<String, Object> findSvgAttr(String idx) {  
4785 - Map<String, Object> rs = new HashMap<>();  
4786 - try {  
4787 - List<String> lineCodes = Splitter.on(",").splitToList(idx);  
4788 - List<SvgAttribute> list = svgAttributeRepository.findSvgAttr(lineCodes);  
4789 -  
4790 - rs.put("status", ResponseCode.SUCCESS);  
4791 - rs.put("list", list);  
4792 - } catch (Exception e) {  
4793 - logger.error("", e);  
4794 - rs.put("status", ResponseCode.ERROR);  
4795 - }  
4796 - return rs;  
4797 - }  
4798 -  
4799 - @Override  
4800 - public Map<String, Object> addRemarks(Long id, String remarks) {  
4801 - Map<String, Object> rs = new HashMap<>();  
4802 - try {  
4803 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
4804 - sch.addRemarks(remarks);  
4805 -  
4806 - rs.put("status", ResponseCode.SUCCESS);  
4807 - rs.put("t", sch);  
4808 - } catch (Exception e) {  
4809 - logger.error("", e);  
4810 - rs.put("status", ResponseCode.ERROR);  
4811 - }  
4812 - return rs;  
4813 - }  
4814 -  
4815 - @Override  
4816 - public List<Map<String, Object>> yesterdayDataList(String line) {  
4817 - // TODO Auto-generated method stub  
4818 - return null;  
4819 - }  
4820 -  
4821 - @Override  
4822 - public List<ScheduleRealInfo> exportWaybillQp(String clZbh, String date, String line) {  
4823 - // TODO Auto-generated method stub  
4824 - ReportUtils ee = new ReportUtils();  
4825 - ReportRelatedUtils rru = new ReportRelatedUtils();  
4826 - List<Iterator<?>> list = new ArrayList<Iterator<?>>();  
4827 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line);  
4828 - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();  
4829 -  
4830 - DecimalFormat format = new DecimalFormat("0.00");  
4831 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
4832 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
4833 - int jhbc = 0, cjbc = 0, ljbc = 0;  
4834 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0;  
4835 - float addMileage = 0l, remMileage = 0l, addgl = 0, remgl = 0;  
4836 - int xyz = 1;  
4837 - Map<String, Object> map;  
4838 - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) {  
4839 - if (scheduleRealInfo != null) {  
4840 - //计算计划里程(主任务过滤掉临加班次),烂班里程,临加里程,计划班次,烂班班次,增加班次  
4841 - //计划里程(主任务过滤掉临加班次),  
4842 - //烂班里程(主任务烂班),  
4843 - //临加里程(主任务临加),  
4844 - //计划班次,烂班班次,增加班次  
4845 - double jh = 0, sj = 0;  
4846 - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();  
4847 - if (scheduleRealInfo.isSflj()) {  
4848 - ljbc++;  
4849 - } else {  
4850 - if (!(scheduleRealInfo.getBcType().equals("in")  
4851 - || scheduleRealInfo.getBcType().equals("out"))) {  
4852 - jhbc++;  
4853 - jh += tempJhlc;  
4854 - }  
4855 - if (scheduleRealInfo.getStatus() == -1) {  
4856 - remMileage += tempJhlc;  
4857 - cjbc++;  
4858 - }  
4859 - }  
4860 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
4861 - //计算营运里程,空驶里程  
4862 - if (childTaskPlans.isEmpty()) {  
4863 - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")  
4864 - ) {  
4865 - jcclc += tempJhlc;  
4866 - } else {  
4867 - if (scheduleRealInfo.getStatus() != -1) {  
4868 - if (scheduleRealInfo.isSflj()) {  
4869 - addMileage += tempJhlc;  
4870 - }  
4871 - sj += tempJhlc;  
4872 - }  
4873 - }  
4874 - } else {  
4875 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
4876 - while (it.hasNext()) {  
4877 - ChildTaskPlan childTaskPlan = it.next();  
4878 - if (childTaskPlan.getMileageType().equals("empty")) {  
4879 - if (childTaskPlan.isDestroy()) {  
4880 - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4881 - } else {  
4882 - if (scheduleRealInfo.isSflj()) {  
4883 - addMileage += tempJhlc;  
4884 - }  
4885 - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4886 - }  
4887 - } else {  
4888 - if (childTaskPlan.isDestroy()) {  
4889 - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4890 -// cjbc++;  
4891 - } else {  
4892 - if (scheduleRealInfo.isSflj()) {  
4893 - addMileage += tempJhlc;  
4894 - }  
4895 - sj += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
4896 - }  
4897 - }  
4898 - }  
4899 - }  
4900 -  
4901 - if (!(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out"))) {  
4902 - map = new HashMap<String, Object>();  
4903 - try {  
4904 - scheduleRealInfo.setBcs(xyz);  
4905 - xyz++;  
4906 - Set<ChildTaskPlan> cs = scheduleRealInfo.getcTasks();  
4907 - Double sjlc = 0.0;  
4908 - if (!cs.isEmpty()) {  
4909 - Iterator<ChildTaskPlan> it = cs.iterator();  
4910 - while (it.hasNext()) {  
4911 - ChildTaskPlan c = it.next();  
4912 - if (!c.isDestroy()) {  
4913 - sjlc += c.getMileage() == null ? 0 : c.getMileage();  
4914 - }  
4915 -  
4916 - }  
4917 - } else {  
4918 - if (scheduleRealInfo.getStatus() != -1) {  
4919 - sjlc = scheduleRealInfo.getJhlc();  
4920 - }  
4921 - }  
4922 - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName());  
4923 - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName());  
4924 - scheduleRealInfo.setSjlc(format.format(sjlc));  
4925 - map = rru.getMapValue(scheduleRealInfo);  
4926 - String zdsj = scheduleRealInfo.getZdsj();  
4927 - String zdsjActual = scheduleRealInfo.getZdsjActual();  
4928 - if (zdsj != null && zdsjActual != null &&  
4929 - !zdsj.equals(zdsjActual)) {  
4930 - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]);  
4931 - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]);  
4932 - if (zdsj.compareTo(zdsjActual) > 0) {  
4933 - if (zdsjT - zdsjAT > 1000) {  
4934 - map.put("fast", "");  
4935 - map.put("slow", zdsjAT - zdsjT + 1440);  
4936 - } else {  
4937 - map.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
4938 - map.put("slow", "");  
4939 - }  
4940 - } else {  
4941 - if (zdsjAT - zdsjT > 1000) {  
4942 - map.put("fast", zdsjT - zdsjAT + 1440);  
4943 - map.put("slow", "");  
4944 - } else {  
4945 - map.put("fast", "");  
4946 - map.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
4947 - }  
4948 - }  
4949 - } else {  
4950 - map.put("fast", "");  
4951 - map.put("slow", "");  
4952 - }  
4953 - listMap.add(map);  
4954 - } catch (Exception e) {  
4955 - e.printStackTrace();  
4956 - }  
4957 - }  
4958 - jhlc += jh;  
4959 - yygl += sj;  
4960 - if (jh > sj) {  
4961 - remgl += jh - sj;  
4962 - } else {  
4963 - addgl += sj - jh;  
4964 - }  
4965 - }  
4966 - }  
4967 -  
4968 -  
4969 - List<Ylxxb> listYlxxb = ylxxbRepository.queryListYlxxb(clZbh, date);  
4970 - Double jzl = 0.0;  
4971 - for (int t = 0; t < listYlxxb.size(); t++) {  
4972 - Ylxxb y = listYlxxb.get(t);  
4973 - jzl += y.getJzl();  
4974 - }  
4975 -  
4976 - //计算里程和班次数,并放入Map里  
4977 - map = findKMBCQp(clZbh, date, line);  
4978 - map.put("jzl", jzl);  
4979 -// map.put("jhlc", format.format(jhlc + jcclc));  
4980 -// map.put("yygljh", format.format(jhlc));  
4981 -// map.put("ssgl", format.format(remMileage));  
4982 -// map.put("ksgl", format.format(ksgl));  
4983 -// map.put("yyglsj", format.format(yygl));  
4984 -// map.put("jhbc", jhbc);  
4985 -// map.put("jcclc", jcclc);  
4986 -//  
4987 -// map.put("ljgl", format.format(addMileage));  
4988 -// map.put("ssbc", cjbc);  
4989 -// map.put("ysgl", format.format(yygl));  
4990 -// map.put("sjbc", jhbc - cjbc + ljbc);  
4991 -// map.put("zgl", format.format(yygl + ksgl + jcclc));  
4992 -// map.put("ljbc", ljbc);  
4993 -  
4994 - String zdp = "", zwdp = "", wdp = "";  
4995 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
4996 - List<DutyEmployee> listDtuy = dutyEmployeeService.getDutyEmployee(line, date + "00:00", date + "23:59");  
4997 - try {  
4998 - Long fcsj1 = sdf.parse(date + " 03:00").getTime();  
4999 - Long fcsj2 = sdf.parse(date + " 11:00").getTime();  
5000 - Long fcsj3 = sdf.parse(date + " 22:00").getTime();  
5001 - for (int i = 0; i < listDtuy.size(); i++) {  
5002 - DutyEmployee t = listDtuy.get(i);  
5003 - Long ts = t.getTs();  
5004 - if (ts > fcsj1 && ts < fcsj2) {  
5005 - if (zdp.indexOf(t.getuName()) == -1) {  
5006 - zdp += t.getuName() + ",";  
5007 -  
5008 - }  
5009 - } else if (ts > fcsj2 && ts < fcsj3) {  
5010 - if (zwdp.indexOf(t.getuName()) == -1) {  
5011 - zwdp += t.getuName() + ",";  
5012 - }  
5013 - } else {  
5014 - if (wdp.indexOf(t.getuName()) == -1) {  
5015 - wdp += t.getuName() + ",";  
5016 - }  
5017 - }  
5018 - }  
5019 - } catch (ParseException e) {  
5020 - // TODO Auto-generated catch block  
5021 - e.printStackTrace();  
5022 - }  
5023 - map.put("zdp", zdp);  
5024 - map.put("zwdp", zwdp);  
5025 - map.put("wdp", wdp);  
5026 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
5027 - list.add(listMap.iterator());  
5028 - ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/waybill_qingpu.xls",  
5029 - path + "export/" + date + "-" + clZbh + "-行车路单.xls");  
5030 -  
5031 - return scheduleRealInfos;  
5032 - }  
5033 -  
5034 - @Override  
5035 - public Map<String, Object> findKMBCQp(String clZbh, String date, String line) {  
5036 - // TODO Auto-generated method stub  
5037 - List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line);  
5038 - DecimalFormat format = new DecimalFormat("0.00");  
5039 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
5040 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
5041 - int jhbc = 0, cjbc = 0, ljbc = 0, sjbc = 0;  
5042 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0, ljjcclc = 0, jhjcclc = 0;  
5043 - double addMileage = 0, remMileage = 0, addgl = 0, remgl = 0;  
5044 - Map<String, Object> map = new HashMap<String, Object>();  
5045 - jhlc = culateMieageService.culateJhgl(lists);  
5046 - jcclc = culateMieageService.culateJccgl(lists);  
5047 - jhjcclc = culateMieageService.culateJhJccgl(lists);  
5048 - remMileage = culateMieageService.culateLbgl(lists);  
5049 - ksgl = culateMieageService.culateKsgl(lists);  
5050 - yygl = culateMieageService.culateSjgl(lists);  
5051 - jhbc = culateMieageService.culateJhbc(lists, "");  
5052 - addMileage = culateMieageService.culateLjgl(lists);  
5053 - cjbc = culateMieageService.culateLbbc(lists);  
5054 - sjbc = culateMieageService.culateSjbc(lists, "");  
5055 - ljbc = culateMieageService.culateLjbc(lists, "");  
5056 - double zyygl = Arith.add(yygl, addMileage);  
5057 - double zksgl = Arith.add(ksgl, jcclc);  
5058 - map.put("jhlc", Arith.add(jhlc, jhjcclc));  
5059 - map.put("yygljh", jhlc);  
5060 - map.put("ssgl", remMileage);  
5061 - map.put("ksgl", ksgl);  
5062 - map.put("yyglsj", Arith.add(yygl, addMileage));  
5063 - map.put("jcclc", jcclc);  
5064 - map.put("jhbc", jhbc);  
5065 - map.put("ljgl", addMileage);  
5066 - map.put("ssbc", cjbc);  
5067 - map.put("ysgl", Arith.add(yygl, addMileage));  
5068 - map.put("sjbc", sjbc);  
5069 - map.put("zgl", Arith.add(zyygl, zksgl));  
5070 - map.put("ljbc", ljbc);  
5071 -  
5072 - return map;  
5073 - }  
5074 -  
5075 - @Override  
5076 - public List<ScheduleRealInfo> queryListWaybillQp(String clZbh, String date, String line) {  
5077 - // TODO Auto-generated method stub  
5078 - DecimalFormat format = new DecimalFormat("0.00");  
5079 - List<ScheduleRealInfo> list = null;  
5080 - list = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line);  
5081 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
5082 - for (int i = 0; i < list.size(); i++) {  
5083 - ScheduleRealInfo s = list.get(i);  
5084 - if (!(s.getBcType().equals("in") || s.getBcType().equals("out"))) {  
5085 - String remarks = "";  
5086 - Double sjlc = 0.0;  
5087 - if (s.getRemarks() != null) {  
5088 - remarks += s.getRemarks();  
5089 - }  
5090 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
5091 - if (!childTaskPlans.isEmpty()) {  
5092 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
5093 - while (it.hasNext()) {  
5094 - ChildTaskPlan c = it.next();  
5095 - if (c.getRemarks() != null && c.getRemarks().length() > 0) {  
5096 - if (remarks.indexOf(c.getRemarks()) == -1) {  
5097 - remarks += c.getRemarks();  
5098 - }  
5099 - }  
5100 -  
5101 - if (!c.isDestroy()) {  
5102 - if (c.getMileageType().equals("service")) {  
5103 - sjlc += c.getMileage() == null ? 0 : c.getMileage();  
5104 - }  
5105 - }  
5106 -  
5107 - }  
5108 - } else {  
5109 - if (s.getStatus() != -1) {  
5110 - sjlc = s.getJhlc();  
5111 - }  
5112 - }  
5113 - s.setSjlc(format.format(sjlc));  
5114 - s.setRemarks(remarks);  
5115 - newList.add(s);  
5116 - }  
5117 -  
5118 - }  
5119 -  
5120 - return newList;  
5121 - }  
5122 -  
5123 - @Override  
5124 - public Map<String, Object> MapById(Long id) {  
5125 - // TODO Auto-generated method stub  
5126 - Map<String, Object> dMap=new HashMap<>();  
5127 - dMap.put("dGroup_eq", "oilType");  
5128 - Iterator<Dictionary> it= dictionaryService.list(dMap).iterator();  
5129 - while (it.hasNext()) {  
5130 - Dictionary d=it.next();  
5131 - dMap.put(d.getdCode(), d.getdName());  
5132 - }  
5133 - Map<String, Object> map = new HashMap<String, Object>();  
5134 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
5135 - ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id);  
5136 - String xlbm = s.getXlBm();  
5137 - String fcrq = s.getScheduleDateStr();  
5138 -  
5139 - int type = 2;  
5140 - Double ccyl = 0.0;  
5141 - Double jcyl = 0.0;  
5142 - Double yh = 0.0;  
5143 - Double jzl = 0.0;  
5144 - Double zlc = 0.0;  
5145 - String rylx="";  
5146 - int hyd = 0;  
5147 - Double czql = 0.0, jzql = 0.0, hq = 0.0, jql = 0.0;  
5148 - List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh());  
5149 - if (listCars.size() > 0) {  
5150 - if (listCars.get(0).getSfdc() != null) {  
5151 - if (listCars.get(0).getSfdc()) {  
5152 - List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);  
5153 - type = 1;  
5154 - for (int i = 0; i < listDlb.size(); i++) {  
5155 - Dlb d = listDlb.get(i);  
5156 - if (d.getLp() == null) {  
5157 - ccyl = Arith.add(ccyl, d.getCzcd());  
5158 - jcyl = Arith.add(jcyl, d.getJzcd());  
5159 - yh = Arith.add(yh, d.getHd());  
5160 - jzl = Arith.add(jzl, d.getCdl());  
5161 - zlc = Arith.add(zlc, d.getZlc());  
5162 - } else {  
5163 - if (d.getLp().equals(s.getLpName())) {  
5164 - ccyl = Arith.add(ccyl, d.getCzcd());  
5165 - jcyl = Arith.add(jcyl, d.getJzcd());  
5166 - yh = Arith.add(yh, d.getHd());  
5167 - jzl = Arith.add(jzl, d.getCdl());  
5168 - zlc = Arith.add(zlc, d.getZlc());  
5169 - }  
5170 - }  
5171 -  
5172 - }  
5173 - } else {  
5174 - List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);  
5175 - type = 0;  
5176 - for (int i = 0; i < listYlb.size(); i++) {  
5177 - Ylb y = listYlb.get(i);  
5178 - if (y.getLp() == null) {  
5179 - ccyl = Arith.add(ccyl, y.getCzyl());  
5180 - jcyl = Arith.add(jcyl, y.getJzyl());  
5181 - yh = Arith.add(yh, y.getYh());  
5182 - jzl = Arith.add(jzl, y.getJzl());  
5183 - zlc = Arith.add(zlc, y.getZlc());  
5184 - if(dMap.get(y.getRylx())!=null)  
5185 - rylx =dMap.get(y.getRylx()).toString();  
5186 - } else {  
5187 - if (y.getLp().equals(s.getLpName())) {  
5188 - ccyl = Arith.add(ccyl, y.getCzyl());  
5189 - jcyl = Arith.add(jcyl, y.getJzyl());  
5190 - yh = Arith.add(yh, y.getYh());  
5191 - jzl = Arith.add(jzl, y.getJzl());  
5192 - zlc = Arith.add(zlc, y.getZlc());  
5193 - if(dMap.get(y.getRylx())!=null)  
5194 - rylx =dMap.get(y.getRylx()).toString();  
5195 - }  
5196 - }  
5197 - }  
5198 - }  
5199 - }  
5200 - if(listCars.get(0).getHydrogen() != null && listCars.get(0).getHydrogen()){  
5201 - List<Qlb> listQlb = qlbRepository.queryListQlb(fcrq, s.getClZbh(), s.getjGh(), xlbm);  
5202 - hyd = 1;  
5203 - for (int i = 0; i < listQlb.size(); i++) {  
5204 - Qlb h = listQlb.get(i);  
5205 - if (h.getLp() == null) {  
5206 - czql = Arith.add(czql, h.getCzcl());  
5207 - jzql = Arith.add(jzql, h.getJzcl());  
5208 - hq = Arith.add(hq, h.getHn());  
5209 - jql = Arith.add(jql, h.getJql());  
5210 - } else {  
5211 - if (h.getLp().equals(s.getLpName())) {  
5212 - czql = Arith.add(czql, h.getCzcl());  
5213 - jzql = Arith.add(jzql, h.getJzcl());  
5214 - hq = Arith.add(hq, h.getHn());  
5215 - jql = Arith.add(jql, h.getJql());  
5216 - }  
5217 - }  
5218 - }  
5219 - }  
5220 - }  
5221 -  
5222 - map.put("hyd", hyd);  
5223 - map.put("czcl", czql);  
5224 - map.put("jzcl", jzql);  
5225 - map.put("hn", hq);  
5226 - map.put("jql", jql);  
5227 -  
5228 - map.put("rylx", "加注类别:"+rylx);  
5229 - map.put("jzl", jzl);  
5230 - map.put("yh", yh);  
5231 - map.put("ccyl", ccyl);  
5232 - map.put("jcyl", jcyl);  
5233 - map.put("type", type);  
5234 - map.put("zlc", zlc);  
5235 - map.put("xlName", s.getXlName());  
5236 - map.put("clZbh", s.getClZbh());  
5237 - map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh()));  
5238 - map.put("fcsjActual", s.getFcsjActual());  
5239 - map.put("zdzName", s.getZdzName());  
5240 - map.put("scheduleDate", s.getScheduleDateStr());  
5241 - map.put("lpName", s.getLpName());  
5242 - String zdp = "", zwdp = "", wdp = "";  
5243 - String zdpT = "", zwdpT = "", wdpT = "";  
5244 - String dbdp = "";  
5245 - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59");  
5246 - try {  
5247 - Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime();  
5248 - Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime();  
5249 - Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime();  
5250 - for (int i = 0; i < list.size(); i++) {  
5251 - DutyEmployee t = list.get(i);  
5252 - if (dbdp.indexOf(t.getuName()) == -1) {  
5253 - if (!(dbdp.length() > 0)) {  
5254 - dbdp = t.getuName();  
5255 - } else {  
5256 - dbdp += "," + t.getuName();  
5257 - }  
5258 - }  
5259 - Long ts = t.getTs();  
5260 - if (ts > fcsj1 && ts < fcsj2) {  
5261 - if (zdp.indexOf(t.getuName()) == -1) {  
5262 - if (!(zdp.length() > 0)) {  
5263 - zdpT = t.getuName() + "...";  
5264 - }  
5265 - zdp += t.getuName() + ",";  
5266 -  
5267 - }  
5268 - } else if (ts > fcsj2 && ts < fcsj3) {  
5269 - if (zwdp.indexOf(t.getuName()) == -1) {  
5270 - if (!(zwdp.length() > 0)) {  
5271 - zwdpT = t.getuName() + "...";  
5272 - }  
5273 - zwdp += t.getuName() + ",";  
5274 - }  
5275 - } else {  
5276 - if (wdp.indexOf(t.getuName()) == -1) {  
5277 - if (!(wdp.length() > 0)) {  
5278 - wdpT = t.getuName() + "...";  
5279 - }  
5280 - wdp += t.getuName() + ",";  
5281 - }  
5282 - }  
5283 - }  
5284 - } catch (ParseException e) {  
5285 - // TODO Auto-generated catch block  
5286 - e.printStackTrace();  
5287 - }  
5288 - map.put("zdp", zdp);  
5289 - map.put("zwdp", zwdp);  
5290 - map.put("wdp", wdp);  
5291 - map.put("zdpT", zdpT);  
5292 - map.put("zwdpT", zwdpT);  
5293 - map.put("wdpT", wdpT);  
5294 - map.put("dbdp", dbdp);  
5295 - return map;  
5296 - }  
5297 -  
5298 - @Override  
5299 - public Map<String, Object> MapByIdQp(Long id) {  
5300 - // TODO Auto-generated method stub  
5301 - Map<String, Object> map = new HashMap<String, Object>();  
5302 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
5303 - ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id);  
5304 - String xlbm = s.getXlBm();  
5305 - String fcrq = s.getScheduleDateStr();  
5306 -  
5307 - int type = 0;  
5308 - Double ccyl = 0.0;  
5309 - Double jcyl = 0.0;  
5310 - Double yh = 0.0;  
5311 - Double jzl = 0.0;  
5312 - Double zlc = 0.0;  
5313 -// List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(),xlbm);  
5314 -// List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(),xlbm);  
5315 -// if(listYlb.size()>0){  
5316 -// type=0;  
5317 -// for (int i = 0; i < listYlb.size(); i++) {  
5318 -// Ylb y = listYlb.get(i);  
5319 -// if(y.getLp()==null){  
5320 -// ccyl=Arith.add(ccyl, y.getCzyl());  
5321 -// jcyl=Arith.add(jcyl, y.getJzyl());  
5322 -// yh =Arith.add(yh ,y.getYh());  
5323 -// jzl =Arith.add(jzl, y.getJzl());  
5324 -// zlc =Arith.add(zlc, y.getZlc());  
5325 -// }else{  
5326 -// if(y.getLp().equals(s.getLpName())){  
5327 -// ccyl=Arith.add(ccyl, y.getCzyl());  
5328 -// jcyl=Arith.add(jcyl, y.getJzyl());  
5329 -// yh =Arith.add(yh ,y.getYh());  
5330 -// jzl =Arith.add(jzl, y.getJzl());  
5331 -// zlc =Arith.add(zlc, y.getZlc());  
5332 -// }  
5333 -// }  
5334 -//  
5335 -// }  
5336 -// }else{  
5337 -// type=1;  
5338 -// for (int i = 0; i < listDlb.size(); i++) {  
5339 -// Dlb d=listDlb.get(i);  
5340 -// if(d.getLp()==null){  
5341 -// ccyl=Arith.add(ccyl, d.getCzcd());  
5342 -// jcyl=Arith.add(jcyl, d.getJzcd());  
5343 -// yh =Arith.add(yh ,d.getHd());  
5344 -// jzl =Arith.add(jzl, d.getCdl());  
5345 -// zlc =Arith.add(zlc, d.getZlc());  
5346 -// }else{  
5347 -// if(d.getLp().equals(s.getLpName())){  
5348 -// ccyl=Arith.add(ccyl, d.getCzcd());  
5349 -// jcyl=Arith.add(jcyl, d.getJzcd());  
5350 -// yh =Arith.add(yh ,d.getHd());  
5351 -// jzl =Arith.add(jzl, d.getCdl());  
5352 -// zlc =Arith.add(zlc, d.getZlc());  
5353 -// }  
5354 -// }  
5355 -//  
5356 -// }  
5357 -// }  
5358 -  
5359 - List<Ylxxb> listylxxb = ylxxbRepository.queryListYlxxb(s.getClZbh(), fcrq);  
5360 - for (int i = 0; i < listylxxb.size(); i++) {  
5361 - Ylxxb t = listylxxb.get(i);  
5362 - jzl = Arith.add(jzl, t.getJzl());  
5363 - }  
5364 - map.put("jzl", jzl);  
5365 - map.put("yh", yh);  
5366 - map.put("ccyl", ccyl);  
5367 - map.put("jcyl", jcyl);  
5368 - map.put("type", type);  
5369 - map.put("zlc", zlc);  
5370 - map.put("xlName", s.getXlName());  
5371 - map.put("clZbh", s.getClZbh());  
5372 - map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh()));  
5373 - map.put("fcsjActual", s.getFcsjActual());  
5374 - map.put("zdzName", s.getZdzName());  
5375 - map.put("scheduleDate", s.getScheduleDateStr());  
5376 - map.put("lpName", s.getLpName());  
5377 - String zdp = "", zwdp = "", wdp = "";  
5378 - String zdpT = "", zwdpT = "", wdpT = "";  
5379 - String dbdp = "";  
5380 - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59");  
5381 - try {  
5382 - Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime();  
5383 - Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime();  
5384 - Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime();  
5385 - for (int i = 0; i < list.size(); i++) {  
5386 - DutyEmployee t = list.get(i);  
5387 - if (dbdp.indexOf(t.getuName()) == -1) {  
5388 - if (!(dbdp.length() > 0)) {  
5389 - dbdp = t.getuName();  
5390 - } else {  
5391 - dbdp += "," + t.getuName();  
5392 - }  
5393 - }  
5394 - Long ts = t.getTs();  
5395 - if (ts > fcsj1 && ts < fcsj2) {  
5396 - if (zdp.indexOf(t.getuName()) == -1) {  
5397 - if (!(zdp.length() > 0)) {  
5398 - zdpT = t.getuName() + "...";  
5399 - }  
5400 - zdp += t.getuName() + ",";  
5401 -  
5402 - }  
5403 - } else if (ts > fcsj2 && ts < fcsj3) {  
5404 - if (zwdp.indexOf(t.getuName()) == -1) {  
5405 - if (!(zwdp.length() > 0)) {  
5406 - zwdpT = t.getuName() + "...";  
5407 - }  
5408 - zwdp += t.getuName() + ",";  
5409 - }  
5410 - } else {  
5411 - if (wdp.indexOf(t.getuName()) == -1) {  
5412 - if (!(wdp.length() > 0)) {  
5413 - wdpT = t.getuName() + "...";  
5414 - }  
5415 - wdp += t.getuName() + ",";  
5416 - }  
5417 - }  
5418 - }  
5419 - } catch (ParseException e) {  
5420 - // TODO Auto-generated catch block  
5421 - e.printStackTrace();  
5422 - }  
5423 - map.put("zdp", zdp);  
5424 - map.put("zwdp", zwdp);  
5425 - map.put("wdp", wdp);  
5426 - map.put("zdpT", zdpT);  
5427 - map.put("zwdpT", zwdpT);  
5428 - map.put("wdpT", wdpT);  
5429 - map.put("dbdp", dbdp);  
5430 - return map;  
5431 - }  
5432 -  
5433 - @Override  
5434 - public List<Map<String, Object>> scheduleDailyQp(String line, String date) {  
5435 - // TODO Auto-generated method stub  
5436 - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();  
5437 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleDailyQp(line, date);  
5438 - Map<String, Object> map = null;  
5439 - String lp = "lp";  
5440 - String jgh = "jgh";  
5441 - String clzbh = "clzbh";  
5442 - int bcs = 0;  
5443 - String thclzbh = "";  
5444 - String sgh = "sgh";  
5445 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
5446 - ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(i);  
5447 - if (scheduleRealInfo.getLpName().equals(lp)) {  
5448 - bcs++;  
5449 - String fcsj = scheduleRealInfo.getFcsj();  
5450 -  
5451 - if (!clzbh.equals(scheduleRealInfo.getClZbh())) {  
5452 - clzbh = scheduleRealInfo.getClZbh();  
5453 - if (thclzbh == "") {  
5454 - thclzbh += scheduleRealInfo.getClZbh() + ",";  
5455 - } else {  
5456 - thclzbh += scheduleRealInfo.getClZbh();  
5457 - }  
5458 - map.put("thclzbh", thclzbh);  
5459 - }  
5460 -  
5461 - if (!jgh.equals(scheduleRealInfo.getjGh())) {  
5462 - jgh = scheduleRealInfo.getjGh();  
5463 - if (map.get("jjb2") != null) {  
5464 - map.put("jjb3", scheduleRealInfo.getjGh() + "/" +  
5465 - scheduleRealInfo.getFcsjActual());  
5466 -  
5467 - } else {  
5468 - map.put("jjb2", scheduleRealInfo.getjGh() + "/" +  
5469 - scheduleRealInfo.getFcsjActual());  
5470 - }  
5471 -  
5472 - }  
5473 -  
5474 - if (scheduleRealInfo.getsGh() != null) {  
5475 - if (!scheduleRealInfo.getsGh().equals(sgh)) {  
5476 - sgh = scheduleRealInfo.getsGh() == null ? "" : scheduleRealInfo.getsGh();  
5477 - if (!sgh.equals("")) {  
5478 - if (map.get("sjb1") != null) {  
5479 - if (map.get("sjb2") != null) {  
5480 - map.put("sjb3", scheduleRealInfo.getsGh() + "/" +  
5481 - scheduleRealInfo.getFcsjActual());  
5482 - } else {  
5483 - map.put("sjb2", scheduleRealInfo.getsGh() + "/" +  
5484 - scheduleRealInfo.getFcsjActual());  
5485 - }  
5486 - } else {  
5487 - map.put("sjb1", scheduleRealInfo.getsGh() + "/" +  
5488 - scheduleRealInfo.getFcsjActual());  
5489 - }  
5490 - }  
5491 - }  
5492 - }  
5493 - if (scheduleRealInfo.getFcsjActual() != null) {  
5494 - String fcsjs[] = fcsj.split(":");  
5495 - String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":");  
5496 - int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]);  
5497 - int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]);  
5498 - map.put("cz" + bcs, b - a);  
5499 - } else {  
5500 - map.put("cz" + bcs, "无");  
5501 - }  
5502 - map.put("lp", scheduleRealInfo.getLpName());  
5503 - map.put("dd" + bcs, scheduleRealInfo.getZdsjActual());  
5504 - map.put("kc" + bcs, scheduleRealInfo.getFcsjActual());  
5505 -  
5506 - if (i < scheduleRealInfos.size() - 1) {  
5507 - if (!scheduleRealInfos.get(i + 1).getLpName().equals  
5508 - (scheduleRealInfos.get(i).getLpName())) {  
5509 - list.add(map);  
5510 - lp = "lp";  
5511 - jgh = "jgh";  
5512 - clzbh = "clzbh";  
5513 - bcs = 0;  
5514 - thclzbh = "";  
5515 - sgh = "sgh";  
5516 - }  
5517 - } else {  
5518 - list.add(map);  
5519 - }  
5520 - } else {  
5521 - bcs = 1;  
5522 - map = new HashMap<String, Object>();  
5523 - lp = scheduleRealInfo.getLpName();  
5524 - jgh = scheduleRealInfo.getjGh();  
5525 - clzbh = scheduleRealInfo.getClZbh();  
5526 - if (scheduleRealInfo.getsGh() != null) {  
5527 - sgh = scheduleRealInfo.getsGh();  
5528 - map.put("sjb1", scheduleRealInfo.getsGh() + "/" +  
5529 - scheduleRealInfo.getFcsjActual());  
5530 - }  
5531 - String fcsj = scheduleRealInfo.getFcsj();  
5532 - scheduleRealInfo.getFcsjActual();  
5533 - map.put("jjb1", jgh + "/" + scheduleRealInfo.getFcsjActual());  
5534 - map.put("cccl", clzbh);  
5535 -  
5536 - if (scheduleRealInfo.getFcsjActual() != null) {  
5537 - String fcsjs[] = fcsj.split(":");  
5538 - String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":");  
5539 - int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]);  
5540 - int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]);  
5541 - map.put("cz" + bcs, b - a);  
5542 - } else {  
5543 - map.put("cz" + bcs, "无");  
5544 - }  
5545 -  
5546 -  
5547 - map.put("lp", scheduleRealInfo.getLpName());  
5548 - map.put("dd" + bcs, scheduleRealInfo.getZdsjActual());  
5549 - map.put("kc" + bcs, scheduleRealInfo.getFcsjActual());  
5550 -  
5551 - if (i < scheduleRealInfos.size() - 1) {  
5552 - if (!scheduleRealInfos.get(i + 1).getLpName().equals  
5553 - (scheduleRealInfos.get(i).getLpName())) {  
5554 - list.add(map);  
5555 - lp = "lp";  
5556 - jgh = "jgh";  
5557 - clzbh = "clzbh";  
5558 - bcs = 0;  
5559 - thclzbh = "";  
5560 - sgh = "sgh";  
5561 - }  
5562 - } else {  
5563 - list.add(map);  
5564 - }  
5565 - }  
5566 -  
5567 - }  
5568 - return list;  
5569 - }  
5570 -  
5571 -  
5572 - @Override  
5573 - public List<Map<String, Object>> scheduleDailyExport(Map<String, Object> map) {  
5574 - String line = map.get("line").toString();  
5575 - String date = map.get("date").toString();  
5576 - String xlName = map.get("xlName").toString();  
5577 - String state = map.get("state").toString();  
5578 - String type = map.get("type").toString();  
5579 - String genre =map.get("genre").toString();  
5580 - String df="";  
5581 - if(map.get("df")!=null){  
5582 - df=map.get("df").toString();  
5583 - }  
5584 -  
5585 - List<Map<String, Object>> dataList2 = new ArrayList<Map<String, Object>>();  
5586 - List<Map<String, Object>> dataList3 = new ArrayList<Map<String, Object>>();  
5587 - List<Map<String, Object>> list1 = this.statisticsDaily(line, date, xlName, null);  
5588 - List<ScheduleRealInfo> list2 = this.queryUserInfo(line, date, state);  
5589 - List<ScheduleRealInfo> list3 = new ArrayList<ScheduleRealInfo>();  
5590 - if(genre.equals("qp"))  
5591 - list3=this.realScheduleListQp(line, date);  
5592 - else if(genre.equals("zrw"))  
5593 - list3=this.realScheduleList_zrw(line, date);  
5594 - else  
5595 - list3=this.realScheduleList(line, date);  
5596 - Map<String, Object> nMap = new HashMap<String, Object>();  
5597 - nMap.put("date", xlName + date);  
5598 - nMap.put("jls", list1.get(0).get("jls"));  
5599 - nMap.put("sjgl", list1.get(0).get("sjgl"));  
5600 -  
5601 - int size = 0;  
5602 - Map<String, Object> tempMap = new HashMap<String, Object>();  
5603 - for (int i = 0; i < list2.size(); i++) {  
5604 - ScheduleRealInfo s = list2.get(i);  
5605 - if (size == 5) {  
5606 - size = 0;  
5607 - dataList2.add(tempMap);  
5608 - tempMap = new HashMap<String, Object>();  
5609 - }  
5610 - tempMap.put("lp" + size, s.getLpName());  
5611 - tempMap.put("ch" + size, s.getClZbh());  
5612 - tempMap.put("jz" + size, s.getjGh() + "/" + s.getjName());  
5613 - tempMap.put("sz" + size, "");  
5614 - tempMap.put("jw" + size, "");  
5615 - tempMap.put("sw" + size, "");  
5616 -  
5617 - size++;  
5618 - }  
5619 - if (size < 5) {  
5620 - for (; size < 5; size++) {  
5621 - tempMap.put("lp" + size, "");  
5622 - tempMap.put("ch" + size, "");  
5623 - tempMap.put("jz" + size, "");  
5624 - tempMap.put("sz" + size, "");  
5625 - tempMap.put("jw" + size, "");  
5626 - tempMap.put("sw" + size, "");  
5627 - }  
5628 - }  
5629 -  
5630 - dataList2.add(tempMap);  
5631 -  
5632 - size = 0;  
5633 - tempMap = new HashMap<String, Object>();  
5634 - for (ScheduleRealInfo schedule : list3) {  
5635 - int x = size % 3;  
5636 - if (x == 0 && size > 0) {  
5637 - dataList3.add(tempMap);  
5638 - tempMap = new HashMap<String, Object>();  
5639 - }  
5640 - tempMap.put("lpName" + x, schedule.getLpName());  
5641 - tempMap.put("qdzName" + x, schedule.getQdzName());  
5642 - tempMap.put("zdsj" + x, schedule.getZdsj());  
5643 - String zdsjActual = schedule.getZdsjActual() != null ? schedule.getZdsjActual() : "";  
5644 - tempMap.put("zdsjActual" + x, zdsjActual);  
5645 -  
5646 - String zdsjk = "";  
5647 - String zdsjm = "";  
5648 - if (!zdsjActual.equals("")) {  
5649 - String[] zdsj_s = schedule.getZdsj().split(":");  
5650 - String[] zdsjActual_s = zdsjActual.split(":");  
5651 - Long zdsj_ = Long.parseLong(zdsj_s[0]) * 60 + Long.parseLong(zdsj_s[1]);  
5652 - Long zdsjActual_ = Long.parseLong(zdsjActual_s[0]) * 60 + Long.parseLong(zdsjActual_s[1]);  
5653 - if ((zdsj_ - zdsjActual_) > 0) {  
5654 - if(zdsj_ - zdsjActual_>1200){  
5655 - zdsjm=String.valueOf(1440-(zdsj_-zdsjActual_));  
5656 - }else{  
5657 - zdsjk = String.valueOf(zdsj_ - zdsjActual_);  
5658 - }  
5659 - } else {  
5660 - if(zdsjActual_ - zdsj_>1200){  
5661 - zdsjk =String.valueOf(1440-(zdsjActual_ - zdsj_));  
5662 - }else{  
5663 - zdsjm = String.valueOf(zdsjActual_ - zdsj_);  
5664 - }  
5665 - }  
5666 - }  
5667 - tempMap.put("zdsjk" + x, zdsjk);  
5668 - tempMap.put("zdsjm" + x, zdsjm.equals("0")?"":zdsjm);  
5669 - tempMap.put("fcsj" + x, schedule.getFcsj());  
5670 - String fcsjActural = schedule.getFcsjActual() != null ? schedule.getFcsjActual() : "";  
5671 - String bcType = schedule.getBcType() != null ? schedule.getBcType() : "";  
5672 - String fcsjActuralstr = "";  
5673 - if (bcType.equals("in")) {  
5674 - fcsjActuralstr = fcsjActural + "(进)";  
5675 - } else if (bcType.equals("out")) {  
5676 - fcsjActuralstr = fcsjActural + "(出)";  
5677 - } else {  
5678 - fcsjActuralstr = fcsjActural;  
5679 - }  
5680 - tempMap.put("fcsjActual" + x, fcsjActuralstr);  
5681 - String fcsjk = "";  
5682 - String fcsjm = "";  
5683 - String dfsjk ="";  
5684 - String dfsjm="";  
5685 - if (!fcsjActural.equals("")) {  
5686 - String[] fcsj_s = schedule.getFcsj().split(":");  
5687 - String[] fcsjActural_s = fcsjActural.split(":");  
5688 - Long fcsj_ = Long.parseLong(fcsj_s[0]) * 60 + Long.parseLong(fcsj_s[1]);  
5689 - Long fcsjActural_ = Long.parseLong(fcsjActural_s[0]) * 60 + Long.parseLong(fcsjActural_s[1]);  
5690 - if ((fcsj_ - fcsjActural_) > 0) {  
5691 - if(fcsj_ - fcsjActural_>1200){  
5692 - fcsjm=String.valueOf(1440-(fcsj_ - fcsjActural_));  
5693 - }else{  
5694 - fcsjk = String.valueOf(fcsj_ - fcsjActural_);  
5695 - }  
5696 - } else {  
5697 - if(fcsjActural_ - fcsj_>1200){  
5698 - fcsjk =String.valueOf(1440-(fcsjActural_ - fcsj_));  
5699 - }  
5700 - else{  
5701 - fcsjm = String.valueOf(fcsjActural_ - fcsj_);  
5702 - }  
5703 - }  
5704 - if(df.equals("df")){  
5705 - String[] dfsj_s =schedule.getDfsj().split(":");  
5706 - Long dfsj_ = Long.parseLong(dfsj_s[0]) * 60 + Long.parseLong(dfsj_s[1]);  
5707 - if ((dfsj_ - fcsjActural_) > 0) {  
5708 - if(dfsj_ - fcsjActural_>1200){  
5709 - dfsjm=String.valueOf(1440-(dfsj_ - fcsjActural_));  
5710 - }else{  
5711 - dfsjk = String.valueOf(dfsj_ - fcsjActural_);  
5712 - }  
5713 - } else {  
5714 - if(fcsjActural_ - dfsj_>1200){  
5715 - dfsjk= String.valueOf(1440-(fcsjActural_ - dfsj_));  
5716 - }else{  
5717 - dfsjm = String.valueOf(fcsjActural_ - dfsj_);  
5718 - }  
5719 - }  
5720 - }  
5721 - }  
5722 - if(df.equals("df")){  
5723 - tempMap.put("dfsj"+x,schedule.getDfsj());  
5724 - tempMap.put("dfsjk" + x, dfsjk);  
5725 - tempMap.put("dfsjm" + x, dfsjm.equals("0")?"":dfsjm);  
5726 - }  
5727 - tempMap.put("fcsjk" + x, fcsjk);  
5728 - tempMap.put("fcsjm" + x, fcsjm.equals("0")?"":fcsjm);  
5729 - tempMap.put("remarks" + x, schedule.getRemark() != null ? schedule.getRemark() : "");  
5730 -  
5731 - size++;  
5732 - }  
5733 - if (tempMap.get("lpName0") != null) {  
5734 - if (tempMap.get("lpName1") == null) {  
5735 - tempMap.put("lpName1", "");  
5736 - tempMap.put("qdzName1", "");  
5737 - tempMap.put("zdsj1", "");  
5738 - tempMap.put("zdsjActual1", "");  
5739 - tempMap.put("zdsjk1", "");  
5740 - tempMap.put("zdsjm1", "");  
5741 - tempMap.put("fcsj1", "");  
5742 - tempMap.put("fcsjActual1", "");  
5743 - tempMap.put("fcsjk1", "");  
5744 - tempMap.put("fcsjm1", "");  
5745 - if(df.equals("df")){  
5746 - tempMap.put("dfsj1","");  
5747 - tempMap.put("dfsjk1" , "");  
5748 - tempMap.put("dfsjm1" , "");  
5749 - }  
5750 - tempMap.put("remarks1", "");  
5751 - }  
5752 - if (tempMap.get("lpName2") == null) {  
5753 - tempMap.put("lpName2", "");  
5754 - tempMap.put("qdzName2", "");  
5755 - tempMap.put("zdsj2", "");  
5756 - tempMap.put("zdsjActual2", "");  
5757 - tempMap.put("zdsjk2", "");  
5758 - tempMap.put("zdsjm2", "");  
5759 - tempMap.put("fcsj2", "");  
5760 - tempMap.put("fcsjActual2", "");  
5761 - tempMap.put("fcsjk2", "");  
5762 - tempMap.put("fcsjm2", "");  
5763 - if(df.equals("df")){  
5764 - tempMap.put("dfsj2","");  
5765 - tempMap.put("dfsjk2" , "");  
5766 - tempMap.put("dfsjm2" , "");  
5767 - }  
5768 - tempMap.put("remarks2", "");  
5769 - }  
5770 - dataList3.add(tempMap);  
5771 - }  
5772 -  
5773 - if (date.length() == 10) {  
5774 - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59");  
5775 - String dbdp = "";  
5776 - try {  
5777 - for (int i = 0; i < list.size(); i++) {  
5778 - DutyEmployee t = list.get(i);  
5779 - if (dbdp.indexOf(t.getuName()) == -1) {  
5780 - if (!(dbdp.length() > 0)) {  
5781 - dbdp = t.getuName();  
5782 - } else {  
5783 - dbdp += "," + t.getuName();  
5784 - }  
5785 - }  
5786 - }  
5787 - } catch (Exception e) {  
5788 - // TODO: handle exception  
5789 - e.printStackTrace();  
5790 - }  
5791 - nMap.put("dbdp", dbdp);  
5792 - }  
5793 -  
5794 - if (type.equals("export")) {  
5795 - String lineName = "";  
5796 - if (map.containsKey("lineName"))  
5797 - lineName = "-" + map.get("lineName").toString() + "-";  
5798 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
5799 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
5800 - Map<String, Object> m = new HashMap<String, Object>();  
5801 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
5802 - ReportUtils ee = new ReportUtils();  
5803 - try {  
5804 - listI.add(list1.iterator());  
5805 - listI.add(dataList2.iterator());  
5806 - listI.add(dataList3.iterator());  
5807 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
5808 - String sourcePath = path + "mould/scheduleDaily.xls";  
5809 - if (date.length() == 7) {  
5810 - sdfMonth = new SimpleDateFormat("yyyy-MM");  
5811 - sdfSimple = new SimpleDateFormat("yyyyMM");  
5812 - sourcePath = path + "mould/scheduleDaily_m.xls";  
5813 - }  
5814 - if(df.equals("df")){  
5815 - sourcePath =path + "mould/scheduleDaily_df.xls";  
5816 - }  
5817 - ee.excelReplace(listI, new Object[]{nMap}, sourcePath,  
5818 - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) + lineName + "调度日报.xls");  
5819 - } catch (Exception e) {  
5820 - // TODO: handle exception  
5821 - e.printStackTrace();  
5822 - }  
5823 - }  
5824 -  
5825 - return new ArrayList<Map<String, Object>>();  
5826 - }  
5827 -  
5828 - public void exportWaybill_pl(List<ScheduleRealInfo> listpl,  
5829 - String date, String jName, String clZbh, String lpName) {  
5830 - ReportUtils ee = new ReportUtils();  
5831 - ReportRelatedUtils rru = new ReportRelatedUtils();  
5832 - List<Iterator<?>> list = new ArrayList<Iterator<?>>();  
5833 - List<ScheduleRealInfo> scheduleRealInfos = listpl;  
5834 - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();  
5835 -// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line);  
5836 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
5837 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
5838 - ScheduleRealInfo s = scheduleRealInfos.get(i);  
5839 - Set<ChildTaskPlan> cts = s.getcTasks();  
5840 - if (cts != null && cts.size() > 0) {  
5841 - lists.add(s);  
5842 - } else {  
5843 - if (s.getZdsjActual() != null && s.getFcsjActual() != null) {  
5844 - lists.add(s);  
5845 - }  
5846 - }  
5847 - }  
5848 - DecimalFormat format = new DecimalFormat("0.00");  
5849 -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);  
5850 -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);  
5851 - //计算里程和班次数,并放入Map里  
5852 - Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId());  
5853 -  
5854 - map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos)));  
5855 - map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos));  
5856 - map.put("addMileage", culateMieageService.culateLjgl(lists));  
5857 - double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists));  
5858 - map.put("yygl", yygl);  
5859 - double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists));  
5860 - map.put("ksgl", ksgl);  
5861 - map.put("realMileage", Arith.add(yygl, ksgl));  
5862 - map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, ""));  
5863 - map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos));  
5864 - map.put("ljbc", culateMieageService.culateLjbc(lists, ""));  
5865 - int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, "");  
5866 - map.put("sjbc", sjbc);  
5867 -// map=new HashMap<String,Object>();  
5868 -  
5869 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
5870 - String minfcsj = "02:00";  
5871 - List<Line> lineList = lineRepository.findLineByCode(listpl.get(0).getXlBm());  
5872 - if (lineList.size() > 0) {  
5873 - String sqlMinYysj = "select start_opt from bsth_c_line_config where "  
5874 - + " id = ("  
5875 - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"  
5876 - + ")";  
5877 - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);  
5878 - }  
5879 - String[] minSjs = minfcsj.split(":");  
5880 - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);  
5881 -  
5882 -  
5883 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
5884 - ScheduleRealInfo s = scheduleRealInfos.get(i);  
5885 - String[] fcsj = s.getFcsj().split(":");  
5886 - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);  
5887 -  
5888 - Long fscjT = 0L;  
5889 - if (fcsjL < minSj) {  
5890 - Calendar calendar = new GregorianCalendar();  
5891 - calendar.setTime(s.getScheduleDate());  
5892 - calendar.add(calendar.DATE, 1);  
5893 - s.setScheduleDate(calendar.getTime());  
5894 - try {  
5895 - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();  
5896 - } catch (ParseException e) {  
5897 - // TODO Auto-generated catch block  
5898 - e.printStackTrace();  
5899 - }  
5900 -  
5901 - } else {  
5902 - try {  
5903 - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();  
5904 - } catch (ParseException e) {  
5905 - // TODO Auto-generated catch block  
5906 - e.printStackTrace();  
5907 - }  
5908 - ;  
5909 - }  
5910 - s.setFcsjT(fscjT);  
5911 - }  
5912 - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>();  
5913 - Collections.sort(scheduleRealInfos, new ComparableReal());  
5914 - for (int i = 0; i < scheduleRealInfos.size(); i++) {  
5915 - ScheduleRealInfo s = scheduleRealInfos.get(i);  
5916 - s.setAdjustExps(i + 1 + "");  
5917 - String remarks = "";  
5918 - if (s.getRemarks() != null) {  
5919 - remarks += s.getRemarks();  
5920 - }  
5921 -  
5922 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
5923 - if (!childTaskPlans.isEmpty()) {  
5924 - s.setFcsjActual("");  
5925 - s.setZdsjActual("");  
5926 - s.setJhlc(0.0);  
5927 - }  
5928 -  
5929 - if (s.isDestroy()) {  
5930 - s.setFcsjActual("");  
5931 - s.setZdsjActual("");  
5932 - s.setJhlc(0.0);  
5933 - remarks += "(烂班)";  
5934 - s.setRemarks(remarks);  
5935 - }  
5936 -  
5937 - listSchedule.add(s);  
5938 - //计算营运里程,空驶里程  
5939 - if (!childTaskPlans.isEmpty()) {  
5940 -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
5941 - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);  
5942 - Collections.sort(listit, new ComparableChild());  
5943 - for (int j = 0; j < listit.size(); j++) {  
5944 - ScheduleRealInfo t = new ScheduleRealInfo();  
5945 - ChildTaskPlan childTaskPlan = listit.get(j);  
5946 - if (childTaskPlan.isDestroy()) {  
5947 - t.setFcsjActual("");  
5948 - t.setZdsjActual("");  
5949 - t.setJhlc(0.0);  
5950 - } else {  
5951 - t.setFcsjActual(childTaskPlan.getStartDate());  
5952 - t.setZdsjActual(childTaskPlan.getEndDate());  
5953 - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));  
5954 - }  
5955 - t.setQdzName(childTaskPlan.getStartStationName());  
5956 - t.setZdzName(childTaskPlan.getEndStationName());  
5957 - t.setRemarks(childTaskPlan.getRemarks());  
5958 - t.setAdjustExps("子");  
5959 - t.setjGh("");  
5960 - t.setjName("");  
5961 - t.setsGh("");  
5962 - t.setsName("");  
5963 - listSchedule.add(t);  
5964 - }  
5965 - }  
5966 - }  
5967 - Map<String, Object> maps;  
5968 - for (ScheduleRealInfo scheduleRealInfo : listSchedule) {  
5969 - maps = new HashMap<String, Object>();  
5970 - try {  
5971 - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName());  
5972 - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName());  
5973 - maps = rru.getMapValue(scheduleRealInfo);  
5974 - maps.put("bcs", scheduleRealInfo.getAdjustExps());  
5975 - String zdsj = scheduleRealInfo.getZdsj();  
5976 - String zdsjActual = scheduleRealInfo.getZdsjActual();  
5977 - if (zdsj != null && zdsjActual != null &&  
5978 - !zdsj.equals(zdsjActual) &&  
5979 - !zdsj.equals("") &&  
5980 - !zdsjActual.equals("")) {  
5981 - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]);  
5982 - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]);  
5983 - if (zdsj.compareTo(zdsjActual) > 0) {  
5984 - if (zdsjT - zdsjAT > 1000) {  
5985 - maps.put("fast", "");  
5986 - maps.put("slow", zdsjAT - zdsjT + 1440);  
5987 - } else {  
5988 - maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
5989 - maps.put("slow", "");  
5990 - }  
5991 - } else {  
5992 - if (zdsjAT - zdsjT > 1000) {  
5993 - maps.put("fast", zdsjT - zdsjAT + 1440);  
5994 - maps.put("slow", "");  
5995 - } else {  
5996 - maps.put("fast", "");  
5997 - maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));  
5998 - }  
5999 - }  
6000 - } else {  
6001 - maps.put("fast", "");  
6002 - maps.put("slow", "");  
6003 - }  
6004 - listMap.add(maps);  
6005 - } catch (Exception e) {  
6006 - e.printStackTrace();  
6007 - }  
6008 - }  
6009 -  
6010 -  
6011 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
6012 - list.add(listMap.iterator());  
6013 - String xls = "";  
6014 - if (map.get("type").toString().equals("0")) {  
6015 - xls = "waybill_minhang.xls";  
6016 - } else {  
6017 - xls = "waybill_minhang_dl.xls";  
6018 - }  
6019 - map.put("sheetName", jName + "-" + clZbh + "-" + lpName);  
6020 - ee.excelReplace(list, new Object[]{map}, path + "mould/" + xls,  
6021 - path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");  
6022 - }  
6023 -  
6024 - @Override  
6025 - public Map<String, Object> exportWaybillMore(Map<String, Object> map) {  
6026 - String date = map.get("date").toString();  
6027 - String line = map.get("line").toString();  
6028 - ReportUtils ee = new ReportUtils();  
6029 - List<List> lists = JSON.parseArray(map.get("strs").toString(), List.class);  
6030 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/";  
6031 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
6032 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
6033 - int num = 0;  
6034 - File file = null;  
6035 - try {  
6036 - while (true) {  
6037 - String fileUrl = path + "行车路单" + sdfSimple.format(sdfMonth.parse(date));  
6038 -// file = new File(fileUrl + (num == 0 ? "/" : "(" + num + ")/")); //新建文件夹  
6039 - file = new File(fileUrl + (num == 0 ? ".xls" : "(" + num + ").xls")); //新建excel文件  
6040 - if (file.exists()) { //判断是否已存在重名  
6041 - num++;  
6042 - } else {  
6043 - break;  
6044 - }  
6045 - }  
6046 -// file.mkdirs(); //创建  
6047 - List<ScheduleRealInfo> lists_line = scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);  
6048 - List<File> files = new ArrayList<File>();  
6049 - for (List<String> list : lists) {  
6050 - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();  
6051 - String jName = list.get(0);  
6052 - String clZbh = list.get(1);  
6053 - String lpName = list.get(2);  
6054 - String jGh = list.get(3);  
6055 - for (int i = 0; i < lists_line.size(); i++) {  
6056 - ScheduleRealInfo s = lists_line.get(i);  
6057 - if (s.getjGh().equals(jGh) && s.getClZbh().equals(clZbh) && s.getLpName().equals(lpName)) {  
6058 - newList.add(s);  
6059 - }  
6060 - }  
6061 - this.exportWaybill_pl(newList, date, jName, clZbh, lpName);  
6062 - File temp = new File(path + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");  
6063 - String fileName = file.getName();  
6064 - files.add(temp);  
6065 - }  
6066 - for (int i = 1; i < files.size(); i++) {  
6067 - File file1 = files.get(0);  
6068 - File file2 = files.get(i);  
6069 - ee.copySheetByFile(file2, file1, 0, 145);  
6070 - }  
6071 - File newFile = files.get(0);  
6072 - newFile.renameTo(file);  
6073 -// temp.renameTo(new File(path + fileName + "/" + temp.getName()));  
6074 -// File[] listFiles = file.listFiles();  
6075 -// ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path + file.getName() + ".zip")));  
6076 -//// zos.setEncoding("gbk");  
6077 -//// zos.putNextEntry(new ZipEntry(fileName + "/"));  
6078 -// for (int i = 0; i < listFiles.length; i++) {  
6079 -// zos.putNextEntry(new ZipEntry(fileName + "/" + listFiles[i].getName()));  
6080 -// BufferedInputStream bis = new BufferedInputStream(new FileInputStream(listFiles[i]));  
6081 -// BufferedOutputStream bos = new BufferedOutputStream(zos);  
6082 -// int bytesRead = 0;  
6083 -// for (byte[] buffer = new byte[BUF_SIZE]; ((bytesRead = bis.read(buffer, 0, BUF_SIZE)) != -1); ) {  
6084 -//// zos.write(buffer, 0, bytesRead);  
6085 -//// zos.flush();  
6086 -// bos.write(buffer, 0, bytesRead);  
6087 -// bos.flush();  
6088 -// }  
6089 -//// bos.close();  
6090 -// bis.close();  
6091 -// }  
6092 -// zos.close();  
6093 -// }  
6094 -  
6095 - } catch (Exception e) {  
6096 - // TODO: handle exception  
6097 - e.printStackTrace();  
6098 - }  
6099 -  
6100 - map.put("fileName", file.getName());  
6101 - return map;  
6102 - }  
6103 -  
6104 - @Autowired  
6105 - SchedulePlanInfoService schPlanService;  
6106 -  
6107 - @Override  
6108 - public List<SchedulePlanInfo> currentSchedulePlan(String lineCode) {  
6109 - List<SchedulePlanInfo> rs = dayOfSchedule.schedulePlanMap.get(lineCode);  
6110 -  
6111 - if (rs == null || rs.size() == 0) {  
6112 - //尝试刷新内存  
6113 - Map<String, Object> data = new HashMap<>();  
6114 - data.put("scheduleDate_eq", dayOfSchedule.currSchDateMap.get(lineCode));  
6115 - data.put("xlBm_eq", lineCode);  
6116 - List<SchedulePlanInfo> planItr = dayOfSchedule.cleanSchPlanItr(schPlanService.list(data).iterator());  
6117 -  
6118 - if (planItr.size() > 0) {  
6119 - dayOfSchedule.schedulePlanMap.put(lineCode, planItr);  
6120 - return planItr;  
6121 - }  
6122 - }  
6123 - return rs;  
6124 - }  
6125 -  
6126 -  
6127 - @Override  
6128 - public Map<String, Object> lpChangeMulti(String leftIdx, String rightIdx, int type) {  
6129 - Map<String, Object> rs = new HashMap<>();  
6130 - Set<ScheduleRealInfo> ts = new HashSet<>();  
6131 - try {  
6132 - List<String> leftList = Splitter.on(",").splitToList(leftIdx);  
6133 - List<String> rightList = Splitter.on(",").splitToList(rightIdx);  
6134 - Set<String> lpSet = new HashSet<>();  
6135 - Set<String> carSet = new HashSet<>();  
6136 -  
6137 - List<ScheduleRealInfo> largeList, smallList;  
6138 - if (leftList.size() > rightList.size()) {  
6139 - largeList = getByIdx(leftList);  
6140 - smallList = getByIdx(rightList);  
6141 - } else {  
6142 - largeList = getByIdx(rightList);  
6143 - smallList = getByIdx(leftList);  
6144 - }  
6145 -  
6146 - ScheduleRealInfo leftSch, rightSch = null;  
6147 - for (int i = 0; i < largeList.size(); i++) {  
6148 - leftSch = largeList.get(i);  
6149 - leftSch.setLpChange(1);  
6150 - if (i < smallList.size()) {  
6151 - rightSch = smallList.get(i);  
6152 - rightSch.setLpChange(1);  
6153 - ts.add(rightSch);  
6154 - } else {  
6155 - //不对称时多出来的  
6156 - lpChangeByLeft(leftSch, largeList.get(i - 1), type);  
6157 - ts.add(leftSch);  
6158 - lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName());  
6159 - continue;  
6160 - }  
6161 -  
6162 - //调换路牌  
6163 - lpChange(leftSch, rightSch, type);  
6164 - ts.add(leftSch);  
6165 -  
6166 - lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName());  
6167 - lpSet.add(rightSch.getXlBm() + "_" + rightSch.getLpName());  
6168 -  
6169 - carSet.add(leftSch.getClZbh());  
6170 - carSet.add(rightSch.getClZbh());  
6171 - scheduleRealInfoRepository.updateLpChange(leftSch.getId());  
6172 - scheduleRealInfoRepository.updateLpChange(rightSch.getId());  
6173 - }  
6174 -  
6175 - //重新计算路牌的起点应到时间  
6176 - for (String lpName : lpSet) {  
6177 - ts.addAll(dayOfSchedule.updateQdzTimePlan(lpName));  
6178 - }  
6179 -  
6180 - //重新就算车辆当前执行班次  
6181 - for(String nbbm : carSet){  
6182 - dayOfSchedule.reCalcExecPlan(nbbm);  
6183 - }  
6184 -  
6185 -  
6186 - for (ScheduleRealInfo sch : ts) {  
6187 - dayOfSchedule.save(sch);  
6188 - }  
6189 -  
6190 - rs.put("status", ResponseCode.SUCCESS);  
6191 - rs.put("ts", ts);  
6192 - } catch (Exception e) {  
6193 - logger.error("", e);  
6194 - rs.put("status", ResponseCode.ERROR);  
6195 - rs.put("msg", e.getMessage());  
6196 - }  
6197 -  
6198 - return rs;  
6199 - }  
6200 -  
6201 - private List<ScheduleRealInfo> getByIdx(List<String> idList) {  
6202 - List<ScheduleRealInfo> list = new ArrayList<>();  
6203 - for (String id : idList) {  
6204 - list.add(dayOfSchedule.get(Long.parseLong(id)));  
6205 - }  
6206 - return list;  
6207 - }  
6208 -  
6209 - @Override  
6210 - public void lpChange(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) {  
6211 - //释放班次映射  
6212 - if (type > 0) {  
6213 - dayOfSchedule.removeNbbm2SchMapp(leftSch);  
6214 - dayOfSchedule.removeNbbm2SchMapp(rightSch);  
6215 - }  
6216 -  
6217 - //对调数据  
6218 - LpData leftData = new LpData(leftSch);  
6219 - LpData rightData = new LpData(rightSch);  
6220 -  
6221 - leftData.appendTo(rightSch, type);  
6222 - rightData.appendTo(leftSch, type);  
6223 -  
6224 - if (type > 0) {  
6225 - //重新映射  
6226 - dayOfSchedule.addNbbm2SchMapp(leftSch);  
6227 - dayOfSchedule.addNbbm2SchMapp(rightSch);  
6228 - }  
6229 - }  
6230 -  
6231 - /**  
6232 - * 更换左边班次的路牌,右边不变  
6233 - *  
6234 - * @param leftSch  
6235 - * @param rightSch  
6236 - * @param type  
6237 - */  
6238 - public void lpChangeByLeft(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) {  
6239 - //释放班次映射  
6240 - if (type > 0)  
6241 - dayOfSchedule.removeNbbm2SchMapp(leftSch);  
6242 -  
6243 - LpData rightData = new LpData(rightSch);  
6244 - rightData.appendTo(leftSch, type);  
6245 -  
6246 - //重新映射  
6247 - if (type > 0)  
6248 - dayOfSchedule.addNbbm2SchMapp(leftSch);  
6249 -  
6250 - }  
6251 -  
6252 - @Override  
6253 - public Map<String, Object> revokeRealArrive(Long id) {  
6254 - Map<String, Object> rs = new HashMap<>();  
6255 - List<ScheduleRealInfo> ts = new ArrayList<>();  
6256 -  
6257 - try {  
6258 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
6259 - if (sch.getZdsjActual() == null && sch.getFcsjActual() == null) {  
6260 - rs.put("status", ResponseCode.ERROR);  
6261 - rs.put("msg", "班次未执行,无法撤销!");  
6262 - } else {  
6263 - //日志记录  
6264 - ScheduleModifyLogger.cxzx(sch);  
6265 -  
6266 - sch.clearFcsjActual();  
6267 - sch.clearZdsjActual();  
6268 - //清除路牌下一个班的起点到达时间  
6269 - ScheduleRealInfo next = dayOfSchedule.nextByLp(sch);  
6270 - if (null != next) {  
6271 - next.setQdzArrDatesj(null);  
6272 - ts.add(next);  
6273 - }  
6274 -  
6275 - rs.put("status", ResponseCode.SUCCESS);  
6276 -  
6277 - ts.add(sch);  
6278 - rs.put("ts", ts);  
6279 -  
6280 - dayOfSchedule.save(sch);  
6281 - //重新计算当前执行班次  
6282 - dayOfSchedule.reCalcExecPlan(sch.getClZbh());  
6283 -  
6284 - }  
6285 - } catch (Exception e) {  
6286 - logger.error("", e);  
6287 - rs.put("status", ResponseCode.ERROR);  
6288 - }  
6289 - return rs;  
6290 - }  
6291 -  
6292 - @Override  
6293 - public Map<String, Object> lateAdjust(String idx, float minute) {  
6294 - Map<String, Object> rs = new HashMap<>();  
6295 - try {  
6296 - int count = 0;  
6297 - List<ScheduleRealInfo> list = new ArrayList<>();  
6298 - List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx);  
6299 -  
6300 - ScheduleRealInfo sch;  
6301 - for (String id : ids) {  
6302 - sch = dayOfSchedule.get(Long.parseLong(id));  
6303 - if (sch != null && sch.getStatus() == 0) {  
6304 - if (minute > 0) {  
6305 - sch.setLateMinute(minute);  
6306 - } else if (minute == 0) {  
6307 - LateAdjustHandle.remove(sch);  
6308 - }  
6309 - count++;  
6310 - list.add(sch);  
6311 - }  
6312 - }  
6313 -  
6314 - rs.put("status", ResponseCode.SUCCESS);  
6315 - rs.put("count", count);  
6316 - rs.put("ts", list);  
6317 - } catch (Exception e) {  
6318 - logger.error("", e);  
6319 - rs.put("status", ResponseCode.ERROR);  
6320 - rs.put("msg", e.getMessage());  
6321 - }  
6322 -  
6323 - return rs;  
6324 - }  
6325 -  
6326 - @Override  
6327 - public List<ScheduleRealInfo> allLate2(String idx) {  
6328 - List<ScheduleRealInfo> rs = new ArrayList<>();  
6329 - List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx);  
6330 -  
6331 - Collection<ScheduleRealInfo> all = LateAdjustHandle.allLateSch();  
6332 - for (ScheduleRealInfo sch : all) {  
6333 - if (ids.indexOf(sch.getXlBm()) != -1) {  
6334 - rs.add(sch);  
6335 - }  
6336 - }  
6337 - return rs;  
6338 - }  
6339 -  
6340 -  
6341 - @Override  
6342 - public List<Map<String, Object>> mileageReport(String gsdm,  
6343 - String fgsdm, String line, String date, String date2) {  
6344 -  
6345 - String sql = "select * from calc_mileage where 1=1 ";  
6346 - if (!line.equals(" ")) {  
6347 - sql = sql + " and line_code='" + line + "' ";  
6348 - }  
6349 - sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'";  
6350 - if (!gsdm.equals(" ")) {  
6351 - sql = sql + " and company_id=" + gsdm;  
6352 - }  
6353 - if (!gsdm.equals(" ")) {  
6354 - sql = sql + " and sub_company_id=" + fgsdm;  
6355 - }  
6356 - sql = sql + " order by line_code";  
6357 - List<MileageReport> list = jdbcTemplate.query(sql,  
6358 - new RowMapper<MileageReport>() {  
6359 - @Override  
6360 - public MileageReport mapRow(ResultSet rs, int rowNum) throws SQLException {  
6361 - MileageReport mr = new MileageReport();  
6362 - mr.setCompanyName(rs.getString("company_name"));  
6363 - mr.setSubCompanyName(rs.getString("sub_company_name"));  
6364 - mr.setLineName(rs.getString("line_name"));  
6365 - mr.setSjyygl(rs.getDouble("sjyygl"));  
6366 - mr.setSjksgl(rs.getDouble("sjksgl"));  
6367 - mr.setZgl(rs.getDouble("zyygl"));  
6368 - mr.setZddfgl(rs.getDouble("zddfgl"));  
6369 - mr.setSddfgl(rs.getDouble("sddfgl"));  
6370 - mr.setWqwxhgl(rs.getDouble("wqwxhgl"));  
6371 - mr.setBfwxhgl(rs.getDouble("bfwxhgl"));  
6372 - mr.setPygl(rs.getDouble("pygl"));  
6373 - mr.setLjgl(rs.getDouble("ljgl"));  
6374 - mr.setZrwgl(rs.getDouble("zrwgl"));  
6375 - mr.setOther(rs.getString("other"));  
6376 - return mr;  
6377 - }  
6378 - });  
6379 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
6380 - double sjyygl = 0.0;  
6381 - double sjksgl = 0.0;  
6382 - double zgl = 0.0;  
6383 - double sddfgl = 0.0;  
6384 - double zddfgl = 0.0;  
6385 - double wqwxhgl = 0.0;  
6386 - double bfwxhgl = 0.0;  
6387 - double pygl = 0.0;  
6388 - double ljgl = 0.0;  
6389 - double zrwgl = 0.0;  
6390 - for (MileageReport mr : list) {  
6391 - Map<String, Object> resMap = new HashMap<String, Object>();  
6392 - resMap.put("gsName", mr.getCompanyName());  
6393 - resMap.put("fgsName", mr.getSubCompanyName());  
6394 - resMap.put("xlName", mr.getLineName());  
6395 - resMap.put("sjyygl", mr.getSjyygl());  
6396 - resMap.put("sjksgl", mr.getSjksgl());  
6397 - resMap.put("zgl", mr.getZgl());  
6398 - resMap.put("sddfgl", mr.getSddfgl());  
6399 - resMap.put("zddfgl", mr.getZddfgl());  
6400 - resMap.put("wqwxhgl", mr.getWqwxhgl());  
6401 - resMap.put("bfwxhgl", mr.getBfwxhgl());  
6402 - resMap.put("pygl", mr.getPygl());  
6403 - resMap.put("ljgl", mr.getLjgl());  
6404 - resMap.put("zrwgl", mr.getZrwgl());  
6405 - resMap.put("other", mr.getOther());  
6406 - lMap.add(resMap);  
6407 - sjyygl = Arith.add(sjyygl, mr.getSjyygl());  
6408 - sjksgl = Arith.add(sjksgl, mr.getSjksgl());  
6409 - zgl = Arith.add(zgl, mr.getZgl());  
6410 - sddfgl = Arith.add(sddfgl, mr.getSddfgl());  
6411 - zddfgl = Arith.add(zddfgl, mr.getZddfgl());  
6412 - wqwxhgl = Arith.add(wqwxhgl, mr.getWqwxhgl());  
6413 - bfwxhgl = Arith.add(bfwxhgl, mr.getBfwxhgl());  
6414 - pygl = Arith.add(pygl, mr.getPygl());  
6415 - ljgl = Arith.add(ljgl, mr.getLjgl());  
6416 - zrwgl = Arith.add(zrwgl, mr.getZrwgl());  
6417 - }  
6418 - Map<String, Object> resMap = new HashMap<String, Object>();  
6419 - resMap.put("xlName", "合计");  
6420 - resMap.put("sjyygl", sjyygl);  
6421 - resMap.put("sjksgl", sjksgl);  
6422 - resMap.put("zgl", zgl);  
6423 - resMap.put("sddfgl", sddfgl);  
6424 - resMap.put("zddfgl", zddfgl);  
6425 - resMap.put("wqwxhgl", wqwxhgl);  
6426 - resMap.put("bfwxhgl", bfwxhgl);  
6427 - resMap.put("pygl", pygl);  
6428 - resMap.put("ljgl", ljgl);  
6429 - resMap.put("zrwgl", zrwgl);  
6430 - resMap.put("other", null);  
6431 - lMap.add(resMap);  
6432 - return lMap;  
6433 - }  
6434 -  
6435 - @Override  
6436 - public List<Map<String, Object>> scheduleCorrectionReport(String gsdm,  
6437 - String fgsdm, String line, String date, String date2) {  
6438 -  
6439 - String sql = "select * from calc_schedule where 1=1 ";  
6440 - if (!line.equals(" ")) {  
6441 - sql = sql + " and line_code='" + line + "' ";  
6442 - }  
6443 - sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'";  
6444 - if (!gsdm.equals(" ")) {  
6445 - sql = sql + " and company_id=" + gsdm;  
6446 - }  
6447 - if (!gsdm.equals(" ")) {  
6448 - sql = sql + " and sub_company_id=" + fgsdm;  
6449 - }  
6450 - sql = sql + " order by line_code";  
6451 - List<ScheduleCorrectionReport> list = jdbcTemplate.query(sql,  
6452 - new RowMapper<ScheduleCorrectionReport>() {  
6453 - @Override  
6454 - public ScheduleCorrectionReport mapRow(ResultSet rs, int rowNum) throws SQLException {  
6455 - ScheduleCorrectionReport sReport = new ScheduleCorrectionReport();  
6456 - sReport.setCompanyName(rs.getString("company_name"));  
6457 - sReport.setSubCompanyName(rs.getString("sub_company_name"));  
6458 - sReport.setLineName(rs.getString("line_name"));  
6459 - sReport.setSjyybc(rs.getInt("sjyybc"));  
6460 - sReport.setSjksbc(rs.getInt("sjksbc"));  
6461 - sReport.setZbc(rs.getInt("zyybc"));  
6462 - sReport.setZddfbc(rs.getInt("zddfbc"));  
6463 - sReport.setSddfbc(rs.getInt("sddfbc"));  
6464 - sReport.setWqwxhbc(rs.getInt("wqwxhbc"));  
6465 - sReport.setBfwxhbc(rs.getInt("bfwxhbc"));  
6466 - sReport.setPybc(rs.getInt("pybc"));  
6467 - sReport.setLjbc(rs.getInt("ljbc"));  
6468 - sReport.setZrwbc(rs.getInt("zrwbc"));  
6469 - sReport.setOther(rs.getString("other"));  
6470 - return sReport;  
6471 - }  
6472 - });  
6473 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
6474 - int sjyybc = 0;  
6475 - int sjksbc = 0;  
6476 - int zbc = 0;  
6477 - int sddfbc = 0;  
6478 - int zddfbc = 0;  
6479 - int wqwxhbc = 0;  
6480 - int bfwxhbc = 0;  
6481 - int pybc = 0;  
6482 - int ljbc = 0;  
6483 - int zrwbc = 0;  
6484 - for (ScheduleCorrectionReport sReport : list) {  
6485 - Map<String, Object> resMap = new HashMap<String, Object>();  
6486 - resMap.put("gsName", sReport.getCompanyName());  
6487 - resMap.put("fgsName", sReport.getSubCompanyName());  
6488 - resMap.put("xlName", sReport.getLineName());  
6489 - resMap.put("sjyybc", sReport.getSjyybc());  
6490 - resMap.put("sjksbc", sReport.getSjksbc());  
6491 - resMap.put("zbc", sReport.getZbc());  
6492 - resMap.put("sddfbc", sReport.getSddfbc());  
6493 - resMap.put("zddfbc", sReport.getZddfbc());  
6494 - resMap.put("wqwxhbc", sReport.getWqwxhbc());  
6495 - resMap.put("bfwxhbc", sReport.getBfwxhbc());  
6496 - resMap.put("pybc", sReport.getPybc());  
6497 - resMap.put("ljbc", sReport.getLjbc());  
6498 - resMap.put("zrwbc", sReport.getZrwbc());  
6499 - resMap.put("other", sReport.getOther());  
6500 - lMap.add(resMap);  
6501 - sjyybc = sjyybc + sReport.getSjyybc();  
6502 - sjksbc = sjksbc + sReport.getSjksbc();  
6503 - zbc = zbc + sReport.getZbc();  
6504 - sddfbc = sddfbc + sReport.getSddfbc();  
6505 - zddfbc = zddfbc + sReport.getZddfbc();  
6506 - wqwxhbc = wqwxhbc + sReport.getWqwxhbc();  
6507 - bfwxhbc = bfwxhbc + sReport.getBfwxhbc();  
6508 - pybc = pybc + sReport.getPybc();  
6509 - ljbc = ljbc + sReport.getLjbc();  
6510 - zrwbc = zrwbc + sReport.getZrwbc();  
6511 - }  
6512 - Map<String, Object> resMap = new HashMap<String, Object>();  
6513 - resMap.put("xlName", "合计");  
6514 - resMap.put("sjyybc", sjyybc);  
6515 - resMap.put("sjksbc", sjksbc);  
6516 - resMap.put("zbc", zbc);  
6517 - resMap.put("sddfbc", sddfbc);  
6518 - resMap.put("zddfbc", zddfbc);  
6519 - resMap.put("wqwxhbc", wqwxhbc);  
6520 - resMap.put("bfwxhbc", bfwxhbc);  
6521 - resMap.put("pybc", pybc);  
6522 - resMap.put("ljbc", ljbc);  
6523 - resMap.put("zrwbc", zrwbc);  
6524 - resMap.put("other", null);  
6525 - lMap.add(resMap);  
6526 - return lMap;  
6527 - }  
6528 -  
6529 - @Override  
6530 - public Integer isCircleQdz(String clzbh, String sdr, String xlbm, String qdzCode) {  
6531 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
6532 - String time =sdf.format(Long.parseLong(sdr));  
6533 -  
6534 - Long num=scheduleRealInfoRepository.isCircleQdz(clzbh, time, xlbm, qdzCode);  
6535 - Integer num2=num==0L?0:1;  
6536 - return num2;  
6537 - }  
6538 -  
6539 - @SuppressWarnings("unchecked")  
6540 - private static Map<String, Object> request(String url) {  
6541 - Map<String, Object> res = new HashMap<String, Object>();  
6542 - res.put("status", ResponseCode.SUCCESS);  
6543 - InputStream in = null;  
6544 - HttpURLConnection con = null;  
6545 - try {  
6546 - con = (HttpURLConnection)new URL(url).openConnection();  
6547 - con.setRequestMethod("POST");  
6548 - con.setRequestProperty("keep-alive", "true");  
6549 - con.setRequestProperty("accept", "application/json");  
6550 - con.setRequestProperty("content-type", "application/json");  
6551 - con.setDoInput(true);  
6552 - con.setReadTimeout(2500);  
6553 - con.setConnectTimeout(2500);  
6554 -  
6555 - con.connect();  
6556 - if (con.getResponseCode() == 200) {  
6557 - in = con.getInputStream();  
6558 - ByteArrayOutputStream bout = new ByteArrayOutputStream();  
6559 - IOUtils.copy(in, bout); bout.close();  
6560 - Map<String, Object> response = new ObjectMapper().readValue(bout.toByteArray(), Map.class);  
6561 - if (!"报修成功".equals(response.get("msg"))) {  
6562 - res.put("status", ResponseCode.ERROR);  
6563 - res.putAll(response);  
6564 - }  
6565 - } else {  
6566 - res.put("status", ResponseCode.ERROR);  
6567 - res.put("msg", "调用上报接口异常");  
6568 - }  
6569 - } catch (IOException e) {  
6570 - // TODO Auto-generated catch block  
6571 - res.put("status", ResponseCode.ERROR);  
6572 - res.put("msg", "调用上报接口异常");  
6573 - } finally {  
6574 - try {  
6575 - if (in != null) in.close();  
6576 - if (con != null) con.disconnect();  
6577 - } catch (IOException e) {  
6578 - // TODO Auto-generated catch block  
6579 - e.printStackTrace();  
6580 - }  
6581 - }  
6582 -  
6583 - return res;  
6584 - }  
6585 -  
6586 - /**  
6587 - ** 维修记录上报  
6588 - * @param param 参数信息  
6589 - * @param isActive 主/被动上报  
6590 - */  
6591 - @Override  
6592 - @Transactional  
6593 - public Map<String, Object> repairReport(Map<String, Object> param, boolean isActive) {  
6594 - Map<String, Object> res = new HashMap<String, Object>();  
6595 - res.put("status", ResponseCode.SUCCESS);  
6596 - // 获取实际排班信息  
6597 - Long id = Long.parseLong((String)param.get("id"));  
6598 - ScheduleRealInfo sch = dayOfSchedule.get(id);  
6599 -  
6600 - if (null == sch) {  
6601 - res.put("status", ResponseCode.ERROR);  
6602 - res.put("msg", "不存在的班次!");  
6603 -  
6604 - return res;  
6605 - }  
6606 -  
6607 - int reportState = -1;  
6608 - SysUser user = SecurityUtils.getCurrentUser();  
6609 - String reportUser = user.getUserName(), reportName = user.getName(), incode = (String)param.get("clZbh"), reportTypes = (String)param.get("reportTypes"), repairTypes = reportType2RepairType(reportTypes);  
6610 - // 分公司保存格式 分公司编码_公司编码  
6611 - String val = BasicData.nbbm2FgsCompanyCodeMap.get(incode);  
6612 - String[] arr = val.split("_");  
6613 - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1]));  
6614 - url.append("?nbbm=").append(incode).append("&bxy=").append(reportUser).append("&bxbm=").append(repairTypes).append("&fgs=").append(arr[0]);  
6615 -  
6616 - int count = repairReportRepository.repairReportBySch(id, isActive ? 1 : 0);  
6617 - if (count > 0) return res;  
6618 - RepairReport lrr = dayOfSchedule.getLastestRepairReport(incode);  
6619 - // 非主动上报并且无上报记录或上次已上报 则不用上报  
6620 - if (!isActive && (lrr == null || lrr.getReportState() != 0)) {  
6621 - reportState = 0;  
6622 - } else {  
6623 - res = request(url.toString());  
6624 - if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1;  
6625 - }  
6626 - // 持久化此次上报记录  
6627 - RepairReport rr = new RepairReport();  
6628 - rr.setLineId(sch.getXlBm());  
6629 - rr.setLineName(sch.getXlName());  
6630 - rr.setReportUser(reportUser);  
6631 - rr.setReportName(reportName);  
6632 - rr.setSchId(id);  
6633 - rr.setIncode(incode);  
6634 - rr.setDepartureTime(sch.getFcsj());  
6635 - rr.setRepairType(repairTypes);  
6636 - rr.setReportType(reportTypes);  
6637 - rr.setReportDate(new Date());  
6638 - rr.setReportState(reportState);  
6639 - rr.setReportMode(isActive ? 1 : 0);  
6640 - rr = repairReportRepository.save(rr);  
6641 - dayOfSchedule.setLastestRepairReport(rr);  
6642 - // 如果上报失败,放到重传队列  
6643 - if (rr.getReportState() == -1) queue.add(rr);  
6644 -  
6645 - return res;  
6646 - }  
6647 -  
6648 - private void repairReport(RepairReport rr) {  
6649 - int reportState = -1;  
6650 - // 分公司保存格式 分公司编码_公司编码  
6651 - String val = BasicData.nbbm2FgsCompanyCodeMap.get(rr.getIncode());  
6652 - String[] arr = val.split("_");  
6653 - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1]));  
6654 - url.append("?nbbm=").append(rr.getIncode()).append("&bxy=").append(rr.getReportUser()).append("&bxbm=").append(rr.getRepairType()).append("&fgs=").append(arr[0]);  
6655 -  
6656 - Map<String, Object> res = request(url.toString());  
6657 - if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1;  
6658 - if (reportState == 1) {  
6659 - rr.setReportState(1);  
6660 - repairReportRepository.save(rr);  
6661 - }  
6662 - }  
6663 -  
6664 - /**  
6665 - ** 业务类型转报修类型  
6666 - */  
6667 - private String reportType2RepairType(String reportType) {  
6668 - String[] reportTypes = reportType.split(";");  
6669 - List<String> repairTypes = new ArrayList<>();  
6670 - for (String rt : reportTypes) {  
6671 - repairTypes.add(report2repair.get(rt));  
6672 - }  
6673 -  
6674 - return StringUtils.join(repairTypes, ";");  
6675 - }  
6676 -  
6677 - @Override  
6678 - public List<RepairReport> repairReportList(String lineId, String date, String incode, String type) {  
6679 - List<RepairReport> result = new ArrayList<RepairReport>();  
6680 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
6681 -  
6682 - Date start = null, end = null;  
6683 - if (date.length() > 0) {  
6684 - try {  
6685 - start = sdf.parse(date + " 00:00:00");  
6686 - end = sdf.parse(date + " 23:59:59");  
6687 - } catch (ParseException e) {  
6688 - // TODO Auto-generated catch block  
6689 - e.printStackTrace();  
6690 - }  
6691 -  
6692 - }  
6693 -  
6694 - result = repairReportRepository.repairReportList(lineId, start, end, incode);  
6695 - Map<String, Object> dMap=new HashMap<>();  
6696 - dMap.put("dGroup_eq", "repairtype");  
6697 - Map<String, String> code2name = new HashMap<String, String>();  
6698 - for (Dictionary dic : dictionaryService.list(dMap)) {  
6699 - code2name.put(dic.getdCode(), dic.getdName());  
6700 - }  
6701 - for (RepairReport rr : result) {  
6702 - String reportType = rr.getReportType();  
6703 - String[] types = reportType.split(";");  
6704 - StringBuilder sb = new StringBuilder();  
6705 -  
6706 - for (String t : types) {  
6707 - sb.append(code2name.get(t)).append(";");  
6708 - }  
6709 -  
6710 - rr.setRepairType(sb.toString());  
6711 - rr.setReportDateStr(sdf.format(rr.getReportDate()));  
6712 - switch (rr.getReportState()) {  
6713 - case 0:  
6714 - rr.setReportStateStr("不报");  
6715 - break;  
6716 - case 1:  
6717 - rr.setReportStateStr("上报成功");  
6718 - break;  
6719 - case -1:  
6720 - rr.setReportStateStr("上报失败");  
6721 - break;  
6722 - default:  
6723 - break;  
6724 - }  
6725 - }  
6726 -  
6727 - if ("export".equals(type)) {  
6728 - String lineName = BasicData.lineCode2NameMap.get(lineId);  
6729 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
6730 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
6731 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
6732 - Map<String, Object> m = new HashMap<String, Object>();  
6733 - ReportUtils ee = new ReportUtils();  
6734 - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();  
6735 - for (int i = 0; i < result.size(); i++) {  
6736 - Map<String, Object> map = new HashMap<String, Object>();  
6737 - RepairReport rr = result.get(i);  
6738 - map.put("row", i + 1);  
6739 - map.put("lineId", rr.getLineName());  
6740 - map.put("incode", rr.getIncode());  
6741 - map.put("departureTime", rr.getDepartureTime());  
6742 - map.put("reportUser", rr.getReportUser());  
6743 - map.put("reportDateStr", rr.getReportDate());  
6744 - map.put("repairType", rr.getRepairType());  
6745 - map.put("reportStateStr", rr.getReportStateStr());  
6746 - newList.add(map);  
6747 - }  
6748 - try {  
6749 - listI.add(newList.iterator());  
6750 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
6751 - ee.excelReplace(listI, new Object[]{m}, path + "mould/repairReport.xls",  
6752 - path + "export/" + sdfSimple.format(sdfMonth.parse(date))  
6753 - + "-" + lineName + "-维修上报记录.xls");  
6754 - } catch (Exception e) {  
6755 - // TODO: handle exception  
6756 - e.printStackTrace();  
6757 - }  
6758 - }  
6759 -  
6760 - return result;  
6761 - }  
6762 -  
6763 - @Override  
6764 - public Map<String, String> getLevelsByLines(List<String> lines) {  
6765 - Map<String, String> result = new HashMap<String, String>(), currSchDate = dayOfSchedule.getCurrSchDate();  
6766 - for (String line : lines) {  
6767 - String level = BasicData.lineDate2Level.get(line + "_" + currSchDate.get(line));  
6768 - result.put(line, level == null ? "" : level);  
6769 - }  
6770 -  
6771 - return result;  
6772 - }  
6773 -  
6774 -  
6775 - @Override  
6776 - public void destroy() throws Exception {  
6777 - // TODO Auto-generated method stub  
6778 - exec.shutdown();  
6779 - }  
6780 -  
6781 -  
6782 - @Override  
6783 - public void afterPropertiesSet() throws Exception {  
6784 - // TODO Auto-generated method stub  
6785 - // 维修上报重发调度  
6786 - exec.scheduleAtFixedRate(new Runnable() {  
6787 -  
6788 - @Override  
6789 - public void run() {  
6790 - // TODO Auto-generated method stub  
6791 - try {  
6792 - Iterator<RepairReport> it = queue.iterator();  
6793 - while (it.hasNext()) {  
6794 - RepairReport rr = it.next();  
6795 - repairReport(rr);  
6796 - if (rr.getReportState() == 1 || System.currentTimeMillis() - rr.getReportDate().getTime() > 86400000) queue.remove(rr);  
6797 - }  
6798 - } catch (Exception e) {  
6799 - logger.error("维修上报重发错误", e);  
6800 - }  
6801 - }  
6802 - }, 30, 30, TimeUnit.MINUTES);  
6803 -  
6804 - //// ---  
6805 - exec.scheduleWithFixedDelay(new Runnable() {  
6806 - @Override  
6807 - public void run() {  
6808 - Map<String, Object> res = new HashMap<>();  
6809 - InputStream in = null;  
6810 - String url ="http://211.95.61.66:9008/modules/tSafedrivingCs/DSMBHforCLBH";  
6811 -  
6812 - try {  
6813 - HttpURLConnection con = (HttpURLConnection)new URL(url.toString()).openConnection();  
6814 - con.setDoInput(true);  
6815 - con.setRequestMethod("POST");  
6816 - con.setConnectTimeout(5000);  
6817 - con.setReadTimeout(5000);  
6818 - con.setRequestProperty("keep-alive", "true");  
6819 - con.setRequestProperty("accept", "*/*");  
6820 - con.setRequestProperty("content-type", "application/x-www-form-urlencoded");  
6821 - con.connect();  
6822 -  
6823 - if (con.getResponseCode() == 200) {  
6824 - in = con.getInputStream();  
6825 - ByteArrayOutputStream bout = new ByteArrayOutputStream();  
6826 - IOUtils.copy(in, bout);  
6827 - DIRMAP = new ObjectMapper().readValue(bout.toByteArray(), Map.class);  
6828 - }  
6829 - logger.info("IP打电话接口查询完成");  
6830 - } catch (MalformedURLException e) {  
6831 - // TODO Auto-generated catch block  
6832 - e.printStackTrace();  
6833 - logger.error("IP打电话接口出错",e);  
6834 - } catch (IOException e) {  
6835 - // TODO Auto-generated catch block  
6836 - e.printStackTrace();  
6837 - }  
6838 -  
6839 - }  
6840 - }, 0, 10, TimeUnit.MINUTES);  
6841 - }  
6842 -}  
6843 -  
6844 -class AccountMap implements Comparator<Map<String, Object>> {  
6845 - @Override  
6846 - public int compare(Map<String, Object> o1, Map<String, Object> o2) {  
6847 - // TODO Auto-generated method stub  
6848 - return o1.get("clZbh").toString().compareTo(o2.get("clZbh").toString());  
6849 - }  
6850 -}  
6851 -  
6852 -class AccountMap2 implements Comparator<Map<String, Object>> {  
6853 - @Override  
6854 - public int compare(Map<String, Object> o1, Map<String, Object> o2) {  
6855 - // TODO Auto-generated method stub  
6856 - return o2.get("clZbh").toString().compareTo(o1.get("clZbh").toString());  
6857 - }  
6858 -}  
6859 -  
6860 -class AccountXlbm implements Comparator<Map<String, Object>> {  
6861 - @Override  
6862 - public int compare(Map<String, Object> o1, Map<String, Object> o2) {  
6863 - // TODO Auto-generated method stub  
6864 -// PinyinHelper.convertToPinyinString(ppy.getName(),  
6865 -// "" , PinyinFormat.WITHOUT_TONE)  
6866 - return o1.get("xlNamePy").toString().compareTo(  
6867 - o2.get("xlNamePy").toString());  
6868 - }  
6869 -}  
6870 -  
6871 -class compareLpFcsjType implements Comparator<ScheduleRealInfo> {  
6872 - @Override  
6873 - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {  
6874 - // TODO Auto-generated method stub  
6875 - return (o1.getLpName()+o1.getFcsjT() + o1.getRemark()).compareTo(o2.getLpName()+o2.getFcsjT() + o2.getRemark());  
6876 - }  
6877 -  
6878 -}  
6879 -  
6880 -class compareDirLpFcsjType implements Comparator<ScheduleRealInfo> {  
6881 - @Override  
6882 - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {  
6883 - // TODO Auto-generated method stub  
6884 - return (o1.getXlDir()+o1.getFcsjT() + o1.getRemark()+o1.getLpName()).compareTo(o2.getXlDir()+o2.getFcsjT() + o2.getRemark()+o2.getLpName());  
6885 - }  
6886 -  
6887 -}  
6888 -class compareFcsjType implements Comparator<ScheduleRealInfo> {  
6889 - @Override  
6890 - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {  
6891 - // TODO Auto-generated method stub  
6892 - return (o1.getFcsjT() + o1.getRemark()).compareTo(o2.getFcsjT() + o2.getRemark());  
6893 - }  
6894 -  
6895 -} 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 +}
src/main/resources/static/pages/forms/mould/waybill_minhang.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/waybill_minhang_dl.xls
No preview for this file type
src/main/resources/static/pages/forms/statement/waybill.html
@@ -397,6 +397,24 @@ @@ -397,6 +397,24 @@
397 } 397 }
398 } 398 }
399 } 399 }
  400 + if(obj.fcsj != null && obj.fcsjActual != null ){
  401 + var fcsjActual = (obj.fcsjActual).split(":");
  402 + var fcsj = (obj.fcsj).split(":");
  403 + if(fcsjActual[0]*60+Number(fcsjActual[1]) > fcsj[0]*60+Number(fcsj[1])){
  404 + if(fcsjActual[0]*60+Number(fcsjActual[1]) - fcsj[0]*60+Number(fcsj[1]) > 1000){
  405 + obj["fast_start"] = (fcsj[0]*60+Number(fcsj[1])) - (fcsjActual[0]*60+Number(fcsjActual[1])) + 1440;
  406 + } else {
  407 + obj["slow_start"] = (fcsjActual[0]*60+Number(fcsjActual[1])) - (fcsj[0]*60+Number(fcsj[1]));
  408 + }
  409 + }
  410 + else if(fcsjActual[0]*60+Number(fcsjActual[1]) < fcsj[0]*60+Number(fcsj[1])){
  411 + if((fcsj[0]*60+Number(fcsj[1])) - (fcsjActual[0]*60+Number(fcsjActual[1])) > 1000){
  412 + obj["slow_start"] = (fcsjActual[0]*60+Number(fcsjActual[1])) - (fcsj[0]*60+Number(fcsj[1])) + 1440;
  413 + } else {
  414 + obj["fast_start"] = (fcsj[0]*60+Number(fcsj[1])) - (fcsjActual[0]*60+Number(fcsjActual[1]));
  415 + }
  416 + }
  417 + }
400 }); 418 });
401 } 419 }
402 }); 420 });
@@ -434,10 +452,10 @@ @@ -434,10 +452,10 @@
434 </script> 452 </script>
435 <script type="text/html" id="ludan_1"> 453 <script type="text/html" id="ludan_1">
436 <tr> 454 <tr>
437 - <td colspan="14">行车路单</td> 455 + <td colspan="15">行车路单</td>
438 </tr> 456 </tr>
439 <tr> 457 <tr>
440 - <td colspan="14">路别:{{xlName}} 路牌:{{lpName}} 车号:{{clZbh}}({{plate}}) 出场时间:{{fcsjActual}} 到达站名:{{zdzName}} 当班调派:{{dbdp}} 日期:{{scheduleDate}}</td> 458 + <td colspan="15">路别:{{xlName}} 路牌:{{lpName}} 车号:{{clZbh}}({{plate}}) 出场时间:{{fcsjActual}} 到达站名:{{zdzName}} 当班调派:{{dbdp}} 日期:{{scheduleDate}}</td>
441 </tr> 459 </tr>
442 <tr> 460 <tr>
443 {{if type==0 && hyd!=1}} 461 {{if type==0 && hyd!=1}}
@@ -446,21 +464,21 @@ @@ -446,21 +464,21 @@
446 <td colspan="2">进场存油 {{jcyl}}升</td> 464 <td colspan="2">进场存油 {{jcyl}}升</td>
447 <td colspan="2">加注机油 &nbsp;升</td> 465 <td colspan="2">加注机油 &nbsp;升</td>
448 <td colspan="3">{{rylx}}</td> 466 <td colspan="3">{{rylx}}</td>
449 - <td colspan="3">本日耗油 {{yh}}升</td> 467 + <td colspan="4">本日耗油 {{yh}}升</td>
450 {{/if}} 468 {{/if}}
451 {{if type==1}} 469 {{if type==1}}
452 <td colspan="2">出场存电 {{ccyl}}%</td> 470 <td colspan="2">出场存电 {{ccyl}}%</td>
453 <td colspan="2">充电量 {{jzl}}度</td> 471 <td colspan="2">充电量 {{jzl}}度</td>
454 <td colspan="2">进场存电 {{jcyl}}%</td> 472 <td colspan="2">进场存电 {{jcyl}}%</td>
455 <td colspan="4">加注机油 &nbsp;升</td> 473 <td colspan="4">加注机油 &nbsp;升</td>
456 - <td colspan="4">本日耗电 {{yh}}度</td> 474 + <td colspan="5">本日耗电 {{yh}}度</td>
457 {{/if}} 475 {{/if}}
458 {{if type==2}} 476 {{if type==2}}
459 <td colspan="2">出场存电 {{ccyl}}%</td> 477 <td colspan="2">出场存电 {{ccyl}}%</td>
460 <td colspan="2">充电量 {{jzl}}度</td> 478 <td colspan="2">充电量 {{jzl}}度</td>
461 <td colspan="2">进场存电 {{jcyl}}%</td> 479 <td colspan="2">进场存电 {{jcyl}}%</td>
462 <td colspan="4">加注机油 &nbsp;升</td> 480 <td colspan="4">加注机油 &nbsp;升</td>
463 - <td colspan="4">本日耗电 {{yh}}度</td> 481 + <td colspan="5">本日耗电 {{yh}}度</td>
464 {{/if}} 482 {{/if}}
465 </tr> 483 </tr>
466 {{if hyd==1}} 484 {{if hyd==1}}
@@ -469,7 +487,7 @@ @@ -469,7 +487,7 @@
469 <td colspan="2">充氢量 {{jql}}方</td> 487 <td colspan="2">充氢量 {{jql}}方</td>
470 <td colspan="2">进场存氢 {{jzcl}}%</td> 488 <td colspan="2">进场存氢 {{jzcl}}%</td>
471 <td colspan="4">加注机油 &nbsp;升</td> 489 <td colspan="4">加注机油 &nbsp;升</td>
472 - <td colspan="4">本日耗氢 {{hn}}方</td> 490 + <td colspan="5">本日耗氢 {{hn}}方</td>
473 </tr> 491 </tr>
474 {{/if}} 492 {{/if}}
475 <tr> 493 <tr>
@@ -478,30 +496,27 @@ @@ -478,30 +496,27 @@
478 <td rowspan="2">早班</td> 496 <td rowspan="2">早班</td>
479 <td colspan="1">&nbsp;</td> 497 <td colspan="1">&nbsp;</td>
480 <td rowspan="2">夜班</td> 498 <td rowspan="2">夜班</td>
481 - <td colspan="1">&nbsp;</td>  
482 - <td rowspan="2" colspan="2">交叉</td>  
483 <td colspan="2">&nbsp;</td> 499 <td colspan="2">&nbsp;</td>
484 - <td rowspan="2">其他</td>  
485 - <td colspan="1">&nbsp;</td>  
486 - <td colspan="1">&nbsp;</td>  
487 - <td colspan="1">&nbsp;</td> 500 + <td rowspan="2">交叉</td>
  501 + <td colspan="3">&nbsp;</td>
  502 + <td rowspan="2" colspan="2">其他</td>
  503 + <td colspan="2">&nbsp;</td>
488 </tr> 504 </tr>
489 <tr> 505 <tr>
490 <td colspan="1">&nbsp;</td> 506 <td colspan="1">&nbsp;</td>
491 <td colspan="1">&nbsp;</td> 507 <td colspan="1">&nbsp;</td>
492 - <td colspan="1">&nbsp;</td>  
493 <td colspan="2">&nbsp;</td> 508 <td colspan="2">&nbsp;</td>
494 - <td colspan="1">&nbsp;</td>  
495 - <td colspan="1">&nbsp;</td>  
496 - <td colspan="1">&nbsp;</td> 509 + <td colspan="3">&nbsp;</td>
  510 + <td colspan="2">&nbsp;</td>
497 </tr> 511 </tr>
498 <tr> 512 <tr>
499 <td rowspan="2">车次</td> 513 <td rowspan="2">车次</td>
500 <td colspan="2">工号</td> 514 <td colspan="2">工号</td>
501 - <td rowspan="2">公里耗油</td> 515 + <!-- <td rowspan="2">公里耗油</td> -->
502 <td colspan="2">起讫站</td> 516 <td colspan="2">起讫站</td>
503 <td colspan="4">时间</td> 517 <td colspan="4">时间</td>
504 - <td colspan="2">误点</td> 518 + <td colspan="2">发车误点</td>
  519 + <td colspan="2">到站误点</td>
505 <td rowspan="2" width="66px">里程(公里)计划</td> 520 <td rowspan="2" width="66px">里程(公里)计划</td>
506 <td rowspan="2">备注</td> 521 <td rowspan="2">备注</td>
507 </tr> 522 </tr>
@@ -516,6 +531,8 @@ @@ -516,6 +531,8 @@
516 <td colspan="1">实到</td> 531 <td colspan="1">实到</td>
517 <td colspan="1">快</td> 532 <td colspan="1">快</td>
518 <td colspan="1">慢</td> 533 <td colspan="1">慢</td>
  534 + <td colspan="1">快</td>
  535 + <td colspan="1">慢</td>
519 </tr> 536 </tr>
520 </script> 537 </script>
521 <script type="text/html" id="ludan_2"> 538 <script type="text/html" id="ludan_2">
@@ -527,13 +544,15 @@ @@ -527,13 +544,15 @@
527 {{obj.sGh}}{{obj.sName}} 544 {{obj.sGh}}{{obj.sName}}
528 {{/if}} 545 {{/if}}
529 </td> 546 </td>
530 - <td>&nbsp;</td> 547 + <!-- <td>&nbsp;</td> -->
531 <td>{{obj.qdzName}}</td> 548 <td>{{obj.qdzName}}</td>
532 <td>{{obj.zdzName}}</td> 549 <td>{{obj.zdzName}}</td>
533 <td>{{obj.fcsj}}</td> 550 <td>{{obj.fcsj}}</td>
534 <td>{{obj.fcsjActual}}</td> 551 <td>{{obj.fcsjActual}}</td>
535 <td>{{obj.zdsj}}</td> 552 <td>{{obj.zdsj}}</td>
536 <td>{{obj.zdsjActual}}</td> 553 <td>{{obj.zdsjActual}}</td>
  554 + <td>{{obj.fast_start}}</td>
  555 + <td>{{obj.slow_start}}</td>
537 <td>{{obj.fast}}</td> 556 <td>{{obj.fast}}</td>
538 <td>{{obj.slow}}</td> 557 <td>{{obj.slow}}</td>
539 <td> 558 <td>
@@ -556,30 +575,30 @@ @@ -556,30 +575,30 @@
556 <tr> 575 <tr>
557 <td colspan="2">计划班次</td> 576 <td colspan="2">计划班次</td>
558 <td>{{jhbc}}</td> 577 <td>{{jhbc}}</td>
559 - <td colspan="2">计划公里</td> 578 + <td colspan="1">计划公里</td>
560 <td>{{jhlc}}</td> 579 <td>{{jhlc}}</td>
561 - <td colspan="2">烂班班次</td>  
562 - <td>{{cjbc}}</td> 580 + <td colspan="3">烂班班次</td>
  581 + <td colspan="2">{{cjbc}}</td>
563 <td colspan="3"> 烂班公里</td> 582 <td colspan="3"> 烂班公里</td>
564 <td colspan="2">{{remMileage}}</td> 583 <td colspan="2">{{remMileage}}</td>
565 </tr> 584 </tr>
566 <tr> 585 <tr>
567 <td colspan="2">临加班次</td> 586 <td colspan="2">临加班次</td>
568 <td>{{ljbc}}</td> 587 <td>{{ljbc}}</td>
569 - <td colspan="2">临加公里</td> 588 + <td colspan="1">临加公里</td>
570 <td>{{addMileage}}</td> 589 <td>{{addMileage}}</td>
571 - <td colspan="2">实际班次</td>  
572 - <td>{{sjbc}}</td> 590 + <td colspan="3">实际班次</td>
  591 + <td colspan="2">{{sjbc}}</td>
573 <td colspan="3">营运公里</td> 592 <td colspan="3">营运公里</td>
574 <td colspan="2">{{yygl}}</td> 593 <td colspan="2">{{yygl}}</td>
575 </tr> 594 </tr>
576 <tr> 595 <tr>
577 <td colspan="2">空驶公里</td> 596 <td colspan="2">空驶公里</td>
578 <td>{{zkslc}}</td> 597 <td>{{zkslc}}</td>
579 - <td colspan="2">总公里</td> 598 + <td colspan="1">总公里</td>
580 <td>{{realMileage}}</td> 599 <td>{{realMileage}}</td>
  600 + <td colspan="3"></td>
581 <td colspan="2"></td> 601 <td colspan="2"></td>
582 - <td></td>  
583 <td colspan="3"></td> 602 <td colspan="3"></td>
584 <td colspan="2"></td> 603 <td colspan="2"></td>
585 </tr> 604 </tr>