Commit 026c3f25c97779c6be61692a1453b341f4add80b

Authored by 王通
1 parent 4ccd76ef

1.

src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
1 -package com.bsth.service.report.impl;  
2 -import com.bsth.common.ResponseCode;  
3 -import com.bsth.data.BasicData;  
4 -import com.bsth.entity.Business;  
5 -import com.bsth.entity.Line;  
6 -import com.bsth.entity.Personnel;  
7 -import com.bsth.entity.StationRoute;  
8 -import com.bsth.entity.excep.ArrivalInfo;  
9 -import com.bsth.entity.mcy_forms.Singledata;  
10 -import com.bsth.entity.oil.Dlb;  
11 -import com.bsth.entity.oil.Ylb;  
12 -import com.bsth.entity.realcontrol.ChildTaskPlan;  
13 -import com.bsth.entity.realcontrol.ScheduleRealInfo;  
14 -import com.bsth.entity.sys.Dictionary;  
15 -import com.bsth.entity.sys.Interval;  
16 -import com.bsth.repository.BusinessRepository;  
17 -import com.bsth.repository.LineRepository;  
18 -import com.bsth.repository.LsStationRouteRepository;  
19 -import com.bsth.repository.StationRouteRepository;  
20 -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;  
21 -import com.bsth.service.LineService;  
22 -import com.bsth.service.calc.CalcWaybillService;  
23 -import com.bsth.service.report.CulateMileageService;  
24 -import com.bsth.service.report.ReportService;  
25 -import com.bsth.service.sys.DictionaryService;  
26 -import com.bsth.util.Arith;  
27 -import com.bsth.util.ComparableChild;  
28 -import com.bsth.util.ComparableJob;  
29 -import com.bsth.util.ReportUtils;  
30 -import com.bsth.util.db.DBUtils_MS;  
31 -  
32 -import org.apache.commons.lang.StringUtils;  
33 -import org.slf4j.Logger;  
34 -import org.slf4j.LoggerFactory;  
35 -import org.springframework.beans.factory.annotation.Autowired;  
36 -import org.springframework.jdbc.core.JdbcTemplate;  
37 -import org.springframework.jdbc.core.RowMapper;  
38 -import org.springframework.stereotype.Service;  
39 -  
40 -import java.math.BigDecimal;  
41 -import java.sql.Connection;  
42 -import java.sql.PreparedStatement;  
43 -import java.sql.ResultSet;  
44 -import java.sql.SQLException;  
45 -import java.text.DecimalFormat;  
46 -import java.text.ParseException;  
47 -import java.text.SimpleDateFormat;  
48 -import java.util.*;  
49 -  
50 -@Service  
51 -public class ReportServiceImpl implements ReportService{  
52 -  
53 - private static long zgf1 = 6 * 60 + 31,  
54 - zgf2 = 8 * 60 + 30,  
55 - wgf1 = 16 * 60 + 1,  
56 - wgf2 = 18 * 60;  
57 -  
58 - private Logger logger = LoggerFactory.getLogger(this.getClass());  
59 -  
60 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
61 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
62 -  
63 - @Autowired  
64 - JdbcTemplate jdbcTemplate;  
65 -  
66 - @Autowired  
67 - ScheduleRealInfoRepository scheduleRealInfoRepository;  
68 - @Autowired  
69 - StationRouteRepository stationRoutRepository;  
70 - @Autowired  
71 - CulateMileageService culateService;  
72 - @Autowired  
73 - LineService lineService;  
74 - @Autowired  
75 - LineRepository lineRepository;  
76 - @Autowired  
77 - StationRouteRepository stationRouteRepository;  
78 - @Autowired  
79 - LsStationRouteRepository lsStationRouteRepository;  
80 - @Autowired  
81 - CulateMileageService culateMileageService;  
82 - @Autowired  
83 - DictionaryService dictionaryService;  
84 - @Autowired  
85 - CalcWaybillService calcWaybillService;  
86 - @Autowired  
87 - BusinessRepository businessRepository;  
88 -  
89 - @Override  
90 - public List<ScheduleRealInfo> queryListBczx(String line, String date,String clzbh) {  
91 - // TODO Auto-generated method stub  
92 - List<ScheduleRealInfo> list=scheduleRealInfoRepository.findByDate2(line,date,clzbh);  
93 -  
94 -// jdbcTemplate.query("select * from bsth_c_s_sp_info_real where line=?1 "  
95 -// + "and DATE_FORMAT(schedule_date,'%Y-%m-%d')=?2 and cl_zbl=?3",  
96 -// new Object[]{line,date,clzbh},  
97 -// new RowMapper(){  
98 -// @Override  
99 -// public Object mapRow(ResultSet rs, int rowNum) throws SQLException {  
100 -// ScheduleRealInfo s = new ScheduleRealInfo();  
101 -//// s.  
102 -// return s;  
103 -// }  
104 -// });  
105 -  
106 - return list;  
107 - }  
108 - @Override  
109 - public List<ArrivalInfo> queryListZdxx(String line, String date, String clzbh, String sjfc, String sjdd) {  
110 - // TODO Auto-generated method stub  
111 - List<ArrivalInfo> list=new ArrayList<ArrivalInfo>();  
112 - try {  
113 - String sbbb=BasicData.deviceId2NbbmMap.inverse().get(clzbh);  
114 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
115 - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");  
116 -// Long date1=simpleDateFormat.parse(date+" "+sjfc+":00").getTime();  
117 -// Long date2=simpleDateFormat.parse(date+" "+sjdd+":00").getTime();  
118 - Long date1=simpleDateFormat.parse(sjfc+":00").getTime();  
119 - Long date2=simpleDateFormat.parse(sjdd+":00").getTime();  
120 - Date dates=simpleDateFormat.parse(date+" 00:00:00");  
121 - List<ArrivalInfo> lists=load(line,sbbb,date1,date2,dates,date);  
122 -  
123 - for(int i=0;i<lists.size();i++){  
124 - ArrivalInfo t1=lists.get(i);  
125 - if(t1.getInOut()==0){  
126 - t1.setJzsj(sdf.format(new Date(t1.getTs())));  
127 - for(int j=0;j<lists.size();j++){  
128 - ArrivalInfo t2=lists.get(j);  
129 - if(t2.getInOut()==1 && t2.getDeviceId().equals(t1.getDeviceId()) && t2.getStopNo().equals(t1.getStopNo())){  
130 - t1.setCzsj(sdf.format(new Date(t2.getTs())));  
131 - }  
132 - }  
133 - list.add(t1);  
134 - }  
135 -  
136 - }  
137 -  
138 -  
139 - } catch (ParseException e) {  
140 - // TODO Auto-generated catch block  
141 - e.printStackTrace();  
142 - }  
143 -  
144 - return list;  
145 - }  
146 -  
147 -  
148 - public List<ArrivalInfo> load(String line,String sbbb,Long date1,Long date2,Date dates,String date){  
149 - List<ArrivalInfo> list = null;  
150 - Calendar cal = Calendar.getInstance();  
151 - cal.setTime(dates);  
152 - //周数,表分区字段  
153 - int weeks_year = cal.get(Calendar.WEEK_OF_YEAR);  
154 - int weeks_year_next=weeks_year +1;  
155 - Connection conn = null;  
156 - PreparedStatement ps = null;  
157 - ResultSet rs = null;  
158 - String year=date.substring(0,4);  
159 - String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year in (?, ?) AND line_id=? "  
160 - + " AND ts >= ? AND ts <=? AND device_id=? order by ts";  
161 - try{  
162 - conn = DBUtils_MS.getConnection();  
163 - ps = conn.prepareStatement(sql);  
164 - ps.setInt(1, weeks_year);  
165 - ps.setInt(2, weeks_year_next);  
166 - ps.setString(3,line);  
167 - ps.setLong(4, date1);  
168 - ps.setLong(5, date2);  
169 - ps.setString(6, sbbb);  
170 - rs = ps.executeQuery();  
171 -  
172 - list = resultSet2Set(rs);  
173 - }catch(Exception e){  
174 - logger.error("", e);  
175 - }finally {  
176 - DBUtils_MS.close(rs, ps, conn);  
177 - }  
178 - return list;  
179 - }  
180 -  
181 - public List<ArrivalInfo> resultSet2Set(ResultSet rs) throws SQLException{  
182 - List<ArrivalInfo> list = new ArrayList<>();  
183 -  
184 - ArrivalInfo arr;  
185 - while(rs.next()){  
186 - arr = new ArrivalInfo();  
187 - arr.setDeviceId(rs.getString("device_id"));  
188 - String nbbm=BasicData.deviceId2NbbmMap.get(arr.getDeviceId());  
189 - arr.setNbbm(nbbm);  
190 - arr.setPzh(BasicData.nbbmCompanyPlateMap.get(nbbm));  
191 - if(null == arr.getNbbm()){  
192 - logger.warn("未注册的设备号," + arr.getDeviceId());  
193 - continue;  
194 - }  
195 -  
196 - arr.setTs(rs.getLong("ts"));  
197 - arr.setLineCode(rs.getString("line_id"));  
198 - arr.setUpDown(rs.getInt("up_down"));  
199 - arr.setStopNo(rs.getString("stop_no"));  
200 - arr.setStopName(BasicData.stationCode2NameMap.get(rs.getString("line_id")+"_"+rs.getInt("up_down")+"_"+rs.getString("stop_no")));  
201 - arr.setInOut(rs.getInt("in_out"));  
202 - arr.setCreateDate(rs.getLong("create_timestamp"));  
203 - arr.setWeeksYear(rs.getInt("weeks_year"));  
204 - arr.setEnable(true);  
205 -  
206 - list.add(arr);  
207 - }  
208 - return list;  
209 - }  
210 - @Override  
211 - public List<ArrivalInfo> queryListClzd(String line, String zd, String zdlx, String fcsj, String ddsj) {  
212 - // TODO Auto-generated method stub  
213 - List<ArrivalInfo> list=new ArrayList<ArrivalInfo>();  
214 - try {  
215 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
216 - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");  
217 - Long date1=simpleDateFormat.parse(fcsj+":00").getTime();  
218 - Long date2=simpleDateFormat.parse(ddsj+":00").getTime();  
219 - Date dates1=simpleDateFormat.parse(fcsj+":00");  
220 - Date dates2=simpleDateFormat.parse(ddsj+":00");  
221 - List<ArrivalInfo> lists = new ArrayList<ArrivalInfo>();  
222 - if(zd.contains(",")){  
223 - String[] split = zd.split(",");  
224 - for(String s : split){  
225 - lists.addAll(load2(line,date1,date2,dates1,dates2,s,zdlx,fcsj));  
226 - }  
227 - } else {  
228 - lists.addAll(load2(line,date1,date2,dates1,dates2,zd,zdlx,fcsj));  
229 - }  
230 -  
231 - for(int i=0;i<lists.size();i++){  
232 - ArrivalInfo t1=lists.get(i);  
233 - if(t1.getInOut()==0){  
234 - t1.setJzsj(sdf.format(new Date(t1.getTs())));  
235 - for(int j=0;j<lists.size();j++){  
236 - ArrivalInfo t2=lists.get(j);  
237 - if(t2.getDeviceId().equals(t1.getDeviceId())  
238 - && t2.getStopNo().equals(t1.getStopNo())  
239 - && t2.getTs()>t1.getTs()){  
240 - if(t2.getInOut() == 1){//下一个同站同车是出站信号则获取出站时间  
241 - t1.setCzsj(sdf.format(new Date(t2.getTs())));  
242 - break;//下一个同站同车是进站信号则认为出站信号丢失  
243 - } else if(t2.getInOut() == 0){  
244 - break;  
245 - }  
246 - }  
247 - }  
248 - list.add(t1);  
249 - }  
250 -  
251 - }  
252 -  
253 -  
254 - } catch (ParseException e) {  
255 - // TODO Auto-generated catch block  
256 - e.printStackTrace();  
257 - }  
258 -  
259 - return list;  
260 - }  
261 -  
262 -  
263 - public List<ArrivalInfo> load2(String line,Long date1,Long date2,Date dates1,Date dates2,String zd,String zdlx,String fcsj){  
264 - SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");  
265 - List<ArrivalInfo> list = new ArrayList<ArrivalInfo>();  
266 - Calendar cal = Calendar.getInstance();  
267 - cal.setTime(dates1);  
268 - //周数,表分区字段  
269 - int weeks_year1 = cal.get(Calendar.WEEK_OF_YEAR);  
270 - cal.setTime(dates2);  
271 - int weeks_year2 = cal.get(Calendar.WEEK_OF_YEAR);  
272 - Connection conn = null;  
273 - PreparedStatement ps = null;  
274 - ResultSet rs = null;  
275 - String year=fcsj.substring(0,4);  
276 -  
277 - String year1 = yearFormat.format(dates1);  
278 - String year2 = yearFormat.format(dates2);  
279 - List<Integer> weeksList = new ArrayList<Integer>();  
280 - if(year1.equals(year2)){  
281 - //把每一周的编号加入list,一年最多五十几周。最多循环60次避免意外死循环  
282 - for(int w = 0, weeks_num = weeks_year1; w < 60 && weeks_num <= weeks_year2; w++, weeks_num++){  
283 - weeksList.add(weeks_num);  
284 - }  
285 - } else {  
286 - weeksList.add(weeks_year1);  
287 - weeksList.add(weeks_year2);  
288 - }  
289 -  
290 - String tempStr = "";  
291 - for(int i = 0; i < weeksList.size(); i++){  
292 - tempStr += "?,";  
293 - }  
294 - if(tempStr.length() > 0){  
295 - tempStr = tempStr.substring(0, tempStr.length() - 1);  
296 - }  
297 -  
298 - String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year in ("+tempStr+") "  
299 - + " AND line_id=? AND up_down=? AND stop_no like ? AND ts between ? AND ? order by ts";  
300 - System.out.println(sql);  
301 - try{  
302 - conn = DBUtils_MS.getConnection();  
303 - ps = conn.prepareStatement(sql);  
304 - int no = 1;  
305 - for(;no <= weeksList.size(); no++){  
306 - ps.setInt(no, weeksList.get(no-1));  
307 - }  
308 - ps.setString(no++, line);  
309 - ps.setString(no++, zdlx);  
310 - ps.setString(no++, ""+zd+"%");  
311 - ps.setLong(no++, date1);  
312 - ps.setLong(no++, date2);  
313 - rs = ps.executeQuery();  
314 -  
315 - list = resultSet2Set(rs);  
316 - }catch(Exception e){  
317 - logger.error("", e);  
318 - }finally {  
319 - DBUtils_MS.close(rs, ps, conn);  
320 - }  
321 - return list;  
322 - }  
323 - @Override  
324 - public List<Map<String, String>> sreachZd(String line, int zdlx, String date1, String date2) {  
325 - List<Map<String, String>> list = new ArrayList<>();  
326 - // TODO Auto-generated method stub  
327 - if(date1.length() >= 10 && date1.length() >= 10){  
328 - date1 = date1.substring(0, 10);  
329 - date2 = date2.substring(0, 10);  
330 - List<Object[]> findHistory = lsStationRouteRepository.findHistory(line, zdlx, date1, date2);  
331 - Set<String> tempSet = new HashSet<String>();  
332 - for(Object[] obj : findHistory){  
333 - if(obj[2] != null && obj[2].toString().trim().length() > 0){  
334 - tempSet.add(obj[2].toString().trim());  
335 - }  
336 - }  
337 - for(Object[] obj : findHistory){  
338 - int length = tempSet.toArray().length;  
339 - Map<String, String> reMap = new HashMap<String, String>();  
340 - reMap.put("id", obj[0].toString());  
341 - reMap.put("text", obj[1] + (length > 1 ? (" -版本" + obj[2]) : ""));  
342 - list.add(reMap);  
343 - }  
344 - }  
345 -  
346 - return list;  
347 - }  
348 - @Override  
349 - public List<Object[]> historyMessageCount(String line, String date, String code) {  
350 - // TODO Auto-generated method stub  
351 - List<Object[]> list = scheduleRealInfoRepository.historyMessageCount(line, date, code);  
352 - return list;  
353 - }  
354 - @Override  
355 - public List<Object[]> historyMessageList(String line, String date, String code,String type) {  
356 - // TODO Auto-generated method stub  
357 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
358 -  
359 - List<Object[]> list = scheduleRealInfoRepository.historyMessageList(line, date, code);  
360 - for (Object[] obj : list) {  
361 - if (obj != null) {  
362 - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));  
363 - }  
364 - }  
365 -  
366 - if (type != null && type.length() != 0 && type.equals("export_msg")) {  
367 - String lineName = BasicData.lineCode2NameMap.get(line);  
368 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
369 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
370 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
371 - Map<String, Object> m = new HashMap<String, Object>();  
372 - ReportUtils ee = new ReportUtils();  
373 - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();  
374 - for (int i = 0; i < list.size(); i++) {  
375 - Map<String, Object> map = new HashMap<String, Object>();  
376 - Object[] obj = list.get(i);  
377 - map.put("num", i + 1);  
378 - map.put("line", obj[0]);  
379 - map.put("clZbh", obj[1]);  
380 - map.put("sender", obj[2]);  
381 - map.put("date", obj[3]);  
382 - map.put("text", obj[4]);  
383 - newList.add(map);  
384 - }  
385 - try {  
386 - listI.add(newList.iterator());  
387 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
388 - ee.excelReplace(listI, new Object[]{m}, path + "mould/message.xls",  
389 - path + "export/" + sdfSimple.format(sdfMonth.parse(date))  
390 - + "-" + lineName + "-调度消息分析.xls");  
391 - } catch (Exception e) {  
392 - // TODO: handle exception  
393 - e.printStackTrace();  
394 - }  
395 - }  
396 - return list;  
397 - }  
398 -  
399 - @Override  
400 - public Map<String, Object> tbodyTime1(String line, String ttinfo) {  
401 - DecimalFormat df = new DecimalFormat("#0.00");  
402 - Map<String, Object> map=new HashMap<String,Object>();  
403 - // TODO Auto-generated method stub  
404 -  
405 - List<String> objList = new ArrayList<String>();  
406 - objList.add(ttinfo);  
407 -  
408 - //查询配车  
409 - String sqlPc=" select count(*) from (select lp, count(*) from"  
410 - + " bsth_c_s_ttinfo_detail where ttinfo = ?"  
411 - + " group by lp ) a";  
412 - //配车  
413 - int pcs=jdbcTemplate.queryForObject(sqlPc, objList.toArray(), Integer.class);  
414 -  
415 -  
416 - String sqlPlan=" SELECT jhlc,bc_type,fcsj FROM bsth_c_s_ttinfo_detail "  
417 - +" where ttinfo = ? ";  
418 -  
419 - //查询班次  
420 - List<Map<String, Object>> listPlan= jdbcTemplate.query(sqlPlan, objList.toArray(),  
421 - new RowMapper<Map<String, Object>>(){  
422 - @Override  
423 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
424 - Map<String, Object> m2=new HashMap<String,Object>();  
425 - m2.put("jhlc", rs.getDouble("jhlc"));  
426 - m2.put("bcType", rs.getString("bc_type"));  
427 - m2.put("fcsj", rs.getString("fcsj"));  
428 - return m2;  
429 - }  
430 - });  
431 -  
432 - //班次  
433 - int zgf_0 = 6*60+31,zgf_1 = 8*60+30,wgf_0 = 16*60+1,wgf_1 = 18*60;  
434 - int qcBc=0,qjBc=0,zqcBc=0,zqjBc=0,wqcBc=0,wqjBc=0;  
435 - double zlc = 0 , yylc = 0,kslc=0;  
436 -  
437 - for (int i = 0; i < listPlan.size(); i++) {  
438 - Map<String, Object> m=listPlan.get(i);  
439 - double jhlc=Double.parseDouble(m.get("jhlc").toString());  
440 - String bcType=m.get("bcType").toString();  
441 - String fcsjs[]=m.get("fcsj").toString().split(":");  
442 -  
443 - zlc +=jhlc;  
444 - if(bcType.equals("in") || bcType.equals("out")){  
445 - kslc+=jhlc;  
446 - }  
447 - else if(bcType.equals("region")){  
448 - qjBc++;  
449 - if((Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) > zgf_0  
450 - && (Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) < zgf_1){  
451 - zqjBc++;  
452 - }else if((Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) > wgf_0  
453 - && (Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) < wgf_1){  
454 - wqjBc++;  
455 - }  
456 -  
457 - yylc+=jhlc;  
458 - }else{  
459 - qcBc ++;  
460 - if((Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) > zgf_0  
461 - && (Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) < zgf_1){  
462 - zqcBc++;  
463 - }else if((Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) > wgf_0  
464 - && (Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) < wgf_1){  
465 - wqcBc++;  
466 - }  
467 - yylc +=jhlc;  
468 - }  
469 - }  
470 -  
471 - map.put("pcs", pcs);  
472 - map.put("qcbc", qcBc);  
473 - map.put("qjbc", qjBc);  
474 - map.put("zqcbc", zqcBc);  
475 - map.put("zqjbc", zqjBc);  
476 - map.put("wqcbc", wqcBc);  
477 - map.put("wqjbc", wqjBc);  
478 - map.put("zlc", df.format( zlc));  
479 - map.put("yylc", df.format(yylc));  
480 - map.put("kslc",df.format( kslc));  
481 - //查询里程  
482 - return map;  
483 - }  
484 - @Override  
485 - public Map<String, Object> tbodyTime2(String line, String ttinfo) {  
486 - DecimalFormat df = new DecimalFormat("#0.00");  
487 - // TODO Auto-generated method stub  
488 - //最早营运时间 区分夜宵线  
489 - String minfcsj="02:00";  
490 - List<Line> lineList=lineRepository.findLineByCode(line);  
491 - if(lineList.size()>0){  
492 - List<String> objList = new ArrayList<String>();  
493 - objList.add(lineList.get(0).getId() + "");  
494 - String sql = "select count(*) from bsth_c_line_config where line = ? ";  
495 - if(jdbcTemplate.queryForObject(sql, objList.toArray(), Integer.class) > 0){  
496 - String sqlMinYysj="select start_opt from bsth_c_line_config where "  
497 - + " id = ("  
498 - + "select max(id) from bsth_c_line_config where line = ? "  
499 - + ")";  
500 - minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, objList.toArray(), String.class);  
501 - }  
502 - }  
503 - String[] minSjs = minfcsj.split(":");  
504 - int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]);  
505 -  
506 - List<String> objList = new ArrayList<String>();  
507 - objList.add(ttinfo);  
508 - objList.add(minfcsj);  
509 - objList.add(ttinfo);  
510 - objList.add(minfcsj);  
511 - //查询时间里程  
512 - String sqlPc=" (SELECT jhlc,fcsj,bc_type,bcsj,lp,2 as xh, ists FROM bsth_c_s_ttinfo_detail "  
513 - + " where ttinfo = ? and fcsj <= ? ) "  
514 - + " union "  
515 - + " (SELECT jhlc,fcsj,bc_type,bcsj,lp,1 as xh, ists FROM bsth_c_s_ttinfo_detail "  
516 - + " where ttinfo = ? and fcsj > ? ) order by lp,xh,fcsj";  
517 - Map<String, Object> map=new HashMap<String,Object>();  
518 - List<Map<String, Object>> list= jdbcTemplate.query(sqlPc, objList.toArray(),  
519 - new RowMapper<Map<String, Object>>(){  
520 - @Override  
521 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
522 - Map<String, Object> m=new HashMap<String,Object>();  
523 - m.put("fcsj", rs.getString("fcsj"));  
524 - m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc"));  
525 - m.put("bcType", rs.getString("bc_type"));  
526 - m.put("bcsj", rs.getString("bcsj"));  
527 - m.put("lp", rs.getString("lp"));  
528 - m.put("ists", rs.getObject("ists")==null?"0":rs.getString("ists"));  
529 - return m;  
530 - }  
531 - });  
532 -  
533 - int yysj=0;  
534 - double yycs=0 ,yygl=0;  
535 - String lp ="0";  
536 - int sj=0, bcsj = 0;  
537 - int temp = 0;  
538 - for(int i=0;i<list.size();i++){  
539 - Map<String, Object> m=list.get(i);  
540 - String time=m.get("fcsj").toString();  
541 - String[] times = time.split(":");  
542 - int sjT = Integer.parseInt(times[0])*60+Integer.parseInt(times[1]);  
543 - if(lp.equals(m.get("lp").toString())){  
544 - if(sjT <= minSj){  
545 - if(m.get("bcType").equals("in") || m.get("bcType").equals("out")){  
546 - if(m.get("bcType").equals("in")){  
547 - if(sj!=0){  
548 -// yysj += sjT + (24*60) - sj;  
549 - yysj += bcsj;  
550 - bcsj = 0;  
551 - }  
552 - sj=0;  
553 - }  
554 - }else{  
555 - yygl += Double.parseDouble(m.get("yygl").toString());  
556 -  
557 - if(sj==0){  
558 - sj = sjT + (24*60);  
559 - }else{  
560 - yysj += sjT + (24*60) - sj;  
561 - if(m.containsKey("ists") && m.get("ists").equals("1")){  
562 - yysj += Integer.valueOf(m.get("bcsj").toString());  
563 - } else {  
564 - sj = sjT + (24*60);  
565 - }  
566 - }  
567 - }  
568 - }else{  
569 - if(m.get("bcType").equals("in") || m.get("bcType").equals("out")){  
570 - if(m.get("bcType").equals("in")){  
571 - if(sj!=0){  
572 -// yysj += sjT - sj;  
573 - yysj += bcsj;  
574 - bcsj = 0;  
575 - }  
576 - sj=0;  
577 - }  
578 - } else {  
579 - yygl += Double.parseDouble(m.get("yygl").toString());  
580 -  
581 - if(sj==0){  
582 - sj = sjT;  
583 - }else{  
584 - yysj += sjT - sj;  
585 - if(m.containsKey("ists") && m.get("ists").equals("1")){  
586 - yysj += Integer.valueOf(m.get("bcsj").toString());  
587 - } else {  
588 - sj = sjT;  
589 - }  
590 - }  
591 - }  
592 - }  
593 - }else{  
594 - if(sj == 0){  
595 - yysj += bcsj;  
596 - bcsj = 0;  
597 - }  
598 - if( !(m.get("bcType").equals("in") || m.get("bcType").equals("out"))){  
599 - yygl += Double.parseDouble(m.get("yygl").toString());  
600 - sj = sjT;  
601 - }else{  
602 - sj=0;  
603 - }  
604 - lp=m.get("lp").toString();  
605 - }  
606 -  
607 - if(m.containsKey("ists") && m.get("ists").equals("1")){  
608 - sj = 0;  
609 - }  
610 - if( !(m.get("bcType").equals("in") || m.get("bcType").equals("out")))  
611 - bcsj = Integer.valueOf(m.get("bcsj").toString());  
612 - }  
613 -  
614 - if(yysj>0){  
615 - yycs =yygl/(yysj*1.0/60);  
616 - }  
617 - int hh=yysj/60;  
618 - int mm=yysj%60;  
619 -  
620 - map.put("yysj", hh+":"+mm);  
621 - map.put("yycs", df.format(yycs)+"公里/小时");  
622 -// map.put(key, value)  
623 -  
624 - return map;  
625 - }  
626 -  
627 - public static void main(String[] args) {  
628 - System.out.println(609360/60);  
629 - System.out.println(609360%60);  
630 - }  
631 -  
632 - @Override  
633 - public List<Map<String, Object>> tbodyTime3(String line, String ttinfo) {  
634 - // TODO Auto-generated method stub  
635 - List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();  
636 - List<Map<String, Object>> list_s=new ArrayList<Map<String,Object>>();  
637 -  
638 - List<String> objList = new ArrayList<String>();  
639 - objList.add(ttinfo);  
640 - String sqlCl="SELECT lp cl_zbh,qdz_name,bc_type,fcsj,bcsj FROM"  
641 - + " bsth_c_s_ttinfo_detail WHERE ttinfo = ? "  
642 - + " AND (bc_type = 'normal' or bc_type='region') order by qdz_name";  
643 -  
644 - List<Map<String, Object>> listj= jdbcTemplate.query(sqlCl, objList.toArray(),  
645 - new RowMapper<Map<String, Object>>(){  
646 - @Override  
647 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
648 - Map<String, Object> m=new HashMap<String,Object>();  
649 - m.put("cl_zbh", rs.getString("cl_zbh"));  
650 - m.put("qdz_name", rs.getString("qdz_name"));  
651 - m.put("bcType", rs.getString("bc_type"));  
652 - m.put("fcsj", rs.getString("fcsj"));  
653 - m.put("bcsj", rs.getString("bcsj"));  
654 - return m;  
655 - }  
656 - });  
657 -  
658 - String sqlZd="select qdz_name,bc_type from bsth_c_s_ttinfo_detail WHERE ttinfo = ? "  
659 - + " AND (bc_type = 'normal' or bc_type='region') group by qdz_name ,bc_type "  
660 - + " order by qdz_name";  
661 - List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd, objList.toArray(),  
662 - new RowMapper<Map<String, Object>>(){  
663 - @Override  
664 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
665 - Map<String, Object> m=new HashMap<String,Object>();  
666 - m.put("zdm", rs.getString("qdz_name"));  
667 - m.put("bcType", rs.getString("bc_type"));  
668 - return m;  
669 - }  
670 - });  
671 -  
672 - for (int i = 0; i < lists.size(); i++) {  
673 - Map<String, Object> z=new HashMap<String,Object>();  
674 - Map<String, Object> w=new HashMap<String,Object>();  
675 - Map<String, Object> p=lists.get(i);  
676 - int zbcs=0;  
677 - int wbcs=0;  
678 - if(p.get("bcType").toString().equals("normal")){  
679 - for (int j = 0; j < listj.size(); j++) {  
680 - if(listj.get(j).get("qdz_name").toString().equals(p.get("zdm").toString()) &&  
681 - listj.get(j).get("bcType").toString().equals("normal")){  
682 - String time=listj.get(j).get("fcsj").toString();  
683 - long bcsj= Long.parseLong(listj.get(j).get("bcsj").toString());  
684 - String clZbh=listj.get(j).get("cl_zbh").toString();  
685 - String[] fcsjStr = time.split(":");  
686 - long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);  
687 - long ddsj=fcsj+bcsj;  
688 - if((fcsj>=zgf1 && fcsj<=zgf2) || (ddsj>=zgf1&&ddsj<=zgf2)  
689 - || (fcsj<zgf1&&ddsj>zgf2)){  
690 - if(p.get("z"+clZbh)==null){  
691 - zbcs++;  
692 - p.put("z"+clZbh, clZbh);  
693 - }  
694 - }  
695 -  
696 - if((fcsj>=wgf1 && fcsj<=wgf2) || (ddsj>=wgf1&&ddsj<=wgf2)  
697 - || (fcsj<wgf1&&ddsj>wgf2)){  
698 - if(p.get("w"+clZbh)==null){  
699 - wbcs++;  
700 - p.put("w"+clZbh, clZbh);  
701 - }  
702 - }  
703 - }  
704 -  
705 - }  
706 - if(zbcs>0){  
707 - z.put("zdm", p.get("zdm"));  
708 - z.put("cls", zbcs);  
709 - z.put("lx", "zqc");  
710 - list_s.add(z);  
711 - }  
712 - if(wbcs>0){  
713 - w.put("zdm", p.get("zdm"));  
714 - w.put("cls", zbcs);  
715 - w.put("lx", "wqc");  
716 - list_s.add(w);  
717 - }  
718 -  
719 - }  
720 -  
721 - if(p.get("bcType").equals("region")){  
722 - for (int j = 0; j < listj.size(); j++) {  
723 - if(listj.get(j).get("qdz_name").toString().equals(p.get("zdm").toString()) &&  
724 - listj.get(j).get("bcType").toString().equals("region")){  
725 - String time=listj.get(j).get("fcsj").toString();  
726 - long bcsj= Long.parseLong(listj.get(j).get("bcsj").toString());  
727 - String clZbh=listj.get(j).get("cl_zbh").toString();  
728 - String[] fcsjStr = time.split(":");  
729 - long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);  
730 - long ddsj=fcsj+bcsj;  
731 - if((fcsj>=zgf1 && fcsj<=zgf2) || (ddsj>=zgf1&&ddsj<=zgf2)  
732 - || (fcsj<zgf1&&ddsj>zgf2)){  
733 - if(p.get("z"+clZbh)==null){  
734 - zbcs++;  
735 - p.put("z"+clZbh, clZbh);  
736 - }  
737 - }  
738 -  
739 - if((fcsj>=wgf1 && fcsj<=wgf2) || (ddsj>=wgf1&&ddsj<=wgf2)  
740 - || (fcsj<wgf1&&ddsj>wgf2)){  
741 - if(p.get("w"+clZbh)==null){  
742 - wbcs++;  
743 - p.put("w"+clZbh, clZbh);  
744 - }  
745 - }  
746 - }  
747 -  
748 - }  
749 - if(zbcs>0){  
750 - z.put("zdm", p.get("zdm"));  
751 - z.put("cls", zbcs);  
752 - z.put("lx", "zqj");  
753 - list_s.add(z);  
754 - }  
755 - if(wbcs>0){  
756 - w.put("zdm", p.get("zdm"));  
757 - w.put("cls", zbcs);  
758 - w.put("lx", "wqj");  
759 - list_s.add(w);  
760 - }  
761 - }  
762 -  
763 - }  
764 - int a=0;  
765 - int b=0;  
766 - int c=0;  
767 - int d=0;  
768 - for(int i=0;i<list_s.size();i++){  
769 - boolean fage=true;  
770 - Map<String, Object> newMap= new HashMap<String, Object>();  
771 - list.add(newMap);  
772 - Map<String, Object> maps=list_s.get(i);  
773 - if(maps.get("lx").equals("zqc")){  
774 - list.get(a).put("zqcZm", maps.get("zdm"));  
775 - list.get(a).put("zqcCls", maps.get("cls"));  
776 - a++;  
777 - fage=false;  
778 - }else if(maps.get("lx").equals("wqc")){  
779 - list.get(b).put("wqcZm", maps.get("zdm"));  
780 - list.get(b).put("wqcCls", maps.get("cls"));  
781 - b++;  
782 - fage=false;  
783 - }else if(maps.get("lx").equals("zqj")){  
784 - list.get(c).put("zqjZm", maps.get("zdm"));  
785 - list.get(c).put("zqjCls", maps.get("cls"));  
786 - c++;  
787 - fage=false;  
788 - }else if(maps.get("lx").equals("wqj")){  
789 - list.get(d).put("wqjZm", maps.get("zdm"));  
790 - list.get(d).put("wqjCls", maps.get("cls"));  
791 - d++;  
792 - fage=false;  
793 - }  
794 - if(fage){  
795 - break;  
796 - }  
797 - }  
798 - boolean status=true;  
799 - while (status) {  
800 - if(list.size() == 0)  
801 - break;  
802 - for (int i = 0; i < list.size(); i++) {  
803 - if(list.get(i).isEmpty()){  
804 - list.remove(i);  
805 - status=true;  
806 - }else{  
807 - status=false;  
808 - }  
809 - }  
810 - }  
811 -  
812 - return list;  
813 - }  
814 -  
815 - @Override  
816 - public List<Map<String, Object>> tbodyTime4(String line, String ttinfo) {  
817 - List<Map<String, Object>> list =new ArrayList<>();  
818 - // TODO Auto-generated method stub  
819 - //最早营运时间 区分夜宵线  
820 - String minfcsj="02:00";  
821 - List<Line> lineList=lineRepository.findLineByCode(line);  
822 - if(lineList.size()>0){  
823 - List<String> objList = new ArrayList<String>();  
824 - objList.add(lineList.get(0).getId() + "");  
825 - String sql = "select count(*) from bsth_c_line_config where line = ? ";  
826 - if(jdbcTemplate.queryForObject(sql, objList.toArray(), Integer.class) > 0){  
827 - String sqlMinYysj="select start_opt from bsth_c_line_config where "  
828 - + " id = ("  
829 - + "select max(id) from bsth_c_line_config where line = ?"  
830 - + ")";  
831 - minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, objList.toArray(), String.class);  
832 - }  
833 - }  
834 -  
835 - List<String> objList = new ArrayList<String>();  
836 - objList.add(ttinfo);  
837 - objList.add(minfcsj);  
838 - objList.add(ttinfo);  
839 - objList.add(minfcsj);  
840 - //查询全程  
841 - String sqlqc="select t.* from ( "  
842 - + " (SELECT bc_type, fcsj,qdz,2 as xh,xl_dir,qdz_name FROM bsth_c_s_ttinfo_detail "  
843 - + " where ttinfo = ? and (bc_type='normal' || bc_type='region') "  
844 - + " and fcsj <= ?) "  
845 - + " union "  
846 - + " (SELECT bc_type, fcsj,qdz,1 as xh,xl_dir,qdz_name FROM bsth_c_s_ttinfo_detail "  
847 - + " where ttinfo = ? and (bc_type='normal' || bc_type='region') "  
848 - + " and fcsj > ?) "  
849 - + "order by xl_dir,xh,fcsj ) t ";  
850 - List<Map<String, String>> qclist= jdbcTemplate.query(sqlqc, objList.toArray(),  
851 - new RowMapper<Map<String, String>>(){  
852 - @Override  
853 - public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {  
854 - Map<String, String> m=new HashMap<String,String>();  
855 - m.put("qdz_name", rs.getString("qdz_name"));  
856 - m.put("bcType", rs.getString("bc_type"));  
857 - m.put("fcsj", rs.getString("fcsj"));  
858 - m.put("xl", rs.getString("xl_dir"));  
859 - m.put("xh", rs.getString("xh"));  
860 - return m;  
861 - }  
862 -  
863 - });  
864 -  
865 - List<List<Map<String, String>>> mapList = new ArrayList<List<Map<String,String>>>();  
866 - mapList.add(new ArrayList<Map<String, String>>());  
867 - mapList.add(new ArrayList<Map<String, String>>());  
868 - for(Map<String, String> m : qclist){  
869 - String bcType = m.get("bcType");  
870 - if(bcType.equals("normal")){  
871 - mapList.get(0).add(m);  
872 - } else {  
873 - mapList.get(1).add(m);  
874 - }  
875 - }  
876 -  
877 - for(int i = 0; i < mapList.size(); i++){  
878 - List<Map<String, String>> l = mapList.get(i);  
879 - Map<String, Object> tempMap = new HashMap<String, Object>();  
880 - List<String> upfcsj = new ArrayList<String>();  
881 - List<String> downfcsj = new ArrayList<String>();  
882 - String sxqdz = "", xxqdz = "";  
883 - String sxfcsj = "", xxfcsj = "";  
884 - int sxbc = 0, xxbc = 0;  
885 - for(Map<String, String> m : l){  
886 - if(m.get("xl").equals("0")){  
887 - sxbc++;  
888 - upfcsj.add(m.get("fcsj"));  
889 - if(sxqdz.length() == 0 && m.containsKey("qdz_name"))  
890 - sxqdz = m.get("qdz_name")==null?"":m.get("qdz_name").toString();  
891 - } else {  
892 - xxbc++;  
893 - downfcsj.add(m.get("fcsj"));  
894 - if(xxqdz.length() == 0 && m.containsKey("qdz_name"))  
895 - xxqdz = m.get("qdz_name")==null?"":m.get("qdz_name").toString();  
896 - }  
897 - }  
898 - if(upfcsj.size() != 0)  
899 - sxfcsj = upfcsj.get(0) + "-" + upfcsj.get(upfcsj.size() - 1);  
900 - if(downfcsj.size() != 0)  
901 - xxfcsj = downfcsj.get(0) + "-" + downfcsj.get(downfcsj.size() - 1);  
902 - tempMap.put("sxqdz", sxqdz);  
903 - tempMap.put("sxfcsj", i==0?sxfcsj:"");  
904 - tempMap.put("sxbc", sxbc!=0?sxbc:"");  
905 - tempMap.put("xxqdz", xxqdz);  
906 - tempMap.put("xxfcsj", i==0?xxfcsj:"");  
907 - tempMap.put("xxbc", xxbc!=0?xxbc:"");  
908 - tempMap.put("bcType", i);  
909 - if(sxqdz.length()!=0 || xxqdz.length()!=0)  
910 - list.add(tempMap);  
911 - }  
912 -  
913 - return list;  
914 - }  
915 - @Override  
916 - public List<Map<String, Object>> tbodyTime5(String line, String ttinfo) {  
917 - // TODO Auto-generated method stub  
918 - //最早营运时间 区分夜宵线  
919 - String minfcsj="02:00";  
920 - List<Line> lineList=lineRepository.findLineByCode(line);  
921 - if(lineList.size()>0){  
922 - List<String> objList = new ArrayList<String>();  
923 - objList.add(lineList.get(0).getId() + "");  
924 - String sql = "select count(*) from bsth_c_line_config where line = ? ";  
925 - if(jdbcTemplate.queryForObject(sql, objList.toArray(), Integer.class) > 0){  
926 - String sqlMinYysj="select start_opt from bsth_c_line_config where "  
927 - + " id = ("  
928 - + "select max(id) from bsth_c_line_config where line = ?"  
929 - + ")";  
930 - minfcsj= jdbcTemplate.queryForObject(sqlMinYysj, objList.toArray(), String.class);  
931 - }  
932 - }  
933 - String[] minSjs = minfcsj.split(":");  
934 - int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]);  
935 -  
936 - List<String> objList = new ArrayList<String>();  
937 - objList.add(ttinfo);  
938 - objList.add(minfcsj);  
939 - objList.add(ttinfo);  
940 - objList.add(minfcsj);  
941 - //查询时间里程  
942 - String sqlPc=" (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,2 as xh FROM "  
943 - + " bsth_c_s_ttinfo_detail where ttinfo = ? and "  
944 - + " fcsj <= ? and bc_type!='ldks'"  
945 - + " and bc_type !='region' and bc_type !='venting' and bc_type !='major') "  
946 - + " union "  
947 - + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,1 as xh FROM "  
948 - + " bsth_c_s_ttinfo_detail where ttinfo = ? and "  
949 - + " fcsj > ? and bc_type!='ldks' "  
950 - + " and bc_type !='region' and bc_type !='venting' and bc_type !='major') "  
951 - + " order by xh, lp,fcsj";  
952 - Map<String, Object> map=new HashMap<String,Object>();  
953 - List<Map<String, Object>> list= jdbcTemplate.query(sqlPc, objList.toArray(),  
954 - new RowMapper<Map<String, Object>>(){  
955 - @Override  
956 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
957 - Map<String, Object> m=new HashMap<String,Object>();  
958 - m.put("fcsj", rs.getString("fcsj"));  
959 - m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc"));  
960 - m.put("bcsj", rs.getString("bcsj"));  
961 - m.put("bcType", rs.getString("bc_type"));  
962 - m.put("lp", rs.getString("lp"));  
963 - m.put("dir", rs.getString("xl_dir"));  
964 - m.put("ists", rs.getString("ists")!=null?rs.getString("ists"):"");  
965 - String[] split = m.get("fcsj").toString().split(":");  
966 - if(rs.getString("xh").equals("2")){  
967 - m.put("fcsj", (Integer.valueOf(split[0]) + 24) + ":"+split[1]);  
968 - }  
969 -  
970 - return m;  
971 - }  
972 - });  
973 - List<Map<String, Object>> newList=new ArrayList<Map<String,Object>>();  
974 - int yysxZq=0,yyxxZq=0,tzsxZq=0,tzxxZq=0,minZqcj=0,maxZqcj=0,sxcountZqbc=0,xxcountZqbc=0; //早前  
975 - int yysxZgf=0,yyxxZgf=0,tzsxZgf=0,tzxxZgf=0,minZgfcj=0,maxZgfcj=0,sxcountZgfbc=0,xxcountZgfbc=0;//早高峰  
976 - int yysxZw=0,yyxxZw=0,tzsxZw=0,tzxxZw=0,minZwcj=0,maxZwcj=0,sxcountZwbc=0,xxcountZwbc=0;//中午  
977 - int yysxWgf=0,yyxxWgf=0,tzsxWgf=0,tzxxWgf=0,minWgfcj=0,maxWgfcj=0,sxcountWgfbc=0,xxcountWgfbc=0;//晚高峰  
978 - int yysxWh=0,yyxxWh=0,tzsxWh=0,tzxxWh=0,minWhcj=0,maxWhcj=0,sxcountWhbc=0,xxcountWhbc=0;//晚后  
979 - List<Integer> zqFcsj0=new ArrayList<Integer>();  
980 - List<Integer> zgfFcsj0=new ArrayList<Integer>();  
981 - List<Integer> zwFcsj0=new ArrayList<Integer>();  
982 - List<Integer> wgfFcsj0=new ArrayList<Integer>();  
983 - List<Integer> whFcsj0=new ArrayList<Integer>();  
984 -  
985 - List<Integer> zqFcsj1=new ArrayList<Integer>();  
986 - List<Integer> zgfFcsj1=new ArrayList<Integer>();  
987 - List<Integer> zwFcsj1=new ArrayList<Integer>();  
988 - List<Integer> wgfFcsj1=new ArrayList<Integer>();  
989 - List<Integer> whFcsj1=new ArrayList<Integer>();  
990 - int temp = 48*60+1, zcj = 0;  
991 - boolean ists = true;  
992 - String lpname="";  
993 - int dir =-1;  
994 - int fcsjT_= 0;  
995 - for (int i = 0; i < list.size(); i++) {  
996 - Map<String, Object> m=list.get(i);  
997 - int xlDir = Integer.valueOf(m.get("dir").toString());  
998 - String[] split = m.get("fcsj").toString().split(":");  
999 - int fcsjT = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]);  
1000 - String bcType=m.get("bcType").toString();  
1001 - int bcsj = Integer.valueOf(m.get("bcsj").toString());  
1002 - if(i==0){  
1003 - lpname=m.get("lp").toString();  
1004 - if(temp>fcsjT){  
1005 - temp=fcsjT+bcsj;  
1006 - }  
1007 - dir =xlDir;  
1008 - if(bcType.equals("in") || bcType.equals("out")){  
1009 - ists=false;  
1010 - }  
1011 - }else{  
1012 -// if(temp>fcsjT){  
1013 -// temp=fcsjT;  
1014 -// }  
1015 - if(bcType.equals("in") || bcType.equals("out")){  
1016 - temp = fcsjT+bcsj;  
1017 - lpname=m.get("lp").toString();  
1018 - dir =xlDir;  
1019 - ists=false;  
1020 - }else{  
1021 -// if(xlDir==0){  
1022 - //上行数据  
1023 - if(fcsjT>= minSj && fcsjT <= 6*60+30){  
1024 - //早高峰前  
1025 - if(xlDir==0){  
1026 - yysxZq +=bcsj;  
1027 - sxcountZqbc ++;  
1028 - zqFcsj0.add(fcsjT);  
1029 - }else{  
1030 - yyxxZq +=bcsj;  
1031 - xxcountZqbc ++;  
1032 - zqFcsj1.add(fcsjT);  
1033 - }  
1034 - if(ists){  
1035 - if(lpname.equals(m.get("lp").toString())){  
1036 - if(dir==0)  
1037 - tzsxZq +=fcsjT-temp;  
1038 - else  
1039 - tzxxZq +=fcsjT-temp;  
1040 - }  
1041 - }  
1042 - temp = fcsjT+bcsj;  
1043 -  
1044 - }else if(fcsjT > 6*60+30 && fcsjT <= 8*60+30){  
1045 - //早高峰  
1046 - if(xlDir==0){  
1047 - yysxZgf +=bcsj;  
1048 - sxcountZgfbc ++;  
1049 - zgfFcsj0.add(fcsjT);  
1050 - }else{  
1051 - yyxxZgf +=bcsj;  
1052 - xxcountZgfbc ++;  
1053 - zgfFcsj1.add(fcsjT);  
1054 - }  
1055 -  
1056 - if(ists){  
1057 - if(lpname.equals(m.get("lp").toString())){  
1058 - if(dir==0){  
1059 - if(fcsjT_>= minSj && fcsjT_ <= 6*60+30)  
1060 - tzsxZq +=fcsjT-temp;  
1061 - else  
1062 - tzsxZgf +=fcsjT-temp;  
1063 - }else{  
1064 - if(fcsjT_>= minSj && fcsjT_ <= 6*60+30)  
1065 - tzxxZq +=fcsjT-temp;  
1066 - else  
1067 - tzxxZgf +=fcsjT-temp;  
1068 - }  
1069 - }  
1070 - }  
1071 - temp =fcsjT+bcsj;  
1072 -  
1073 - }else if(fcsjT > 8*60+30 && fcsjT <= 16*60){  
1074 - //中午  
1075 - if(xlDir==0){  
1076 - yysxZw +=bcsj;  
1077 - sxcountZwbc ++;  
1078 - zwFcsj0.add(fcsjT);  
1079 - }else{  
1080 - yyxxZw +=bcsj;  
1081 - xxcountZwbc ++;  
1082 - zwFcsj1.add(fcsjT);  
1083 - }  
1084 - if(ists){  
1085 - if(lpname.equals(m.get("lp").toString())){  
1086 - if(dir==0){  
1087 - if(fcsjT_ > 6*60+30 && fcsjT_ <= 8*60+30)  
1088 - tzsxZgf +=fcsjT-temp;  
1089 - else  
1090 - tzsxZw +=fcsjT-temp;  
1091 - }else{  
1092 - if(fcsjT_ > 6*60+30 && fcsjT_ <= 8*60+30)  
1093 - tzxxZgf +=fcsjT-temp;  
1094 - else  
1095 - tzxxZw +=fcsjT-temp;  
1096 - }  
1097 - }  
1098 - }  
1099 - temp =fcsjT+bcsj;  
1100 - }else if(fcsjT > 16*60 && fcsjT <= 18*60){  
1101 - //晚高峰  
1102 - if(xlDir==0){  
1103 - yysxWgf +=bcsj;  
1104 - sxcountWgfbc ++;  
1105 - wgfFcsj0.add(fcsjT);  
1106 - }else{  
1107 - yyxxWgf +=bcsj;  
1108 - xxcountWgfbc ++;  
1109 - wgfFcsj1.add(fcsjT);  
1110 - }  
1111 -  
1112 - if(ists){  
1113 - if(lpname.equals(m.get("lp").toString())){  
1114 - if(dir==0){  
1115 - if(fcsjT_ > 8*60+30 && fcsjT_ <= 16*60)  
1116 - tzsxZw +=fcsjT-temp;  
1117 - else  
1118 - tzsxWgf +=fcsjT-temp;  
1119 - }else{  
1120 - if(fcsjT_ > 8*60+30 && fcsjT_ <= 16*60)  
1121 - tzxxZw +=fcsjT-temp;  
1122 - else  
1123 - tzxxWgf +=fcsjT-temp;  
1124 - }  
1125 - }  
1126 - }  
1127 - temp =fcsjT+bcsj;  
1128 - }else{  
1129 - //晚高峰后  
1130 - if(xlDir==0){  
1131 - yysxWh +=bcsj;  
1132 - sxcountWhbc ++;  
1133 - whFcsj0.add(fcsjT);  
1134 - }else{  
1135 - yyxxWh +=bcsj;  
1136 - xxcountWhbc ++;  
1137 - whFcsj1.add(fcsjT);  
1138 - }  
1139 - if(ists){  
1140 - if(lpname.equals(m.get("lp").toString())){  
1141 - if(dir==0){  
1142 - if(fcsjT_ > 16*60 && fcsjT_ <= 18*60)  
1143 - tzsxWgf +=fcsjT-temp;  
1144 - else  
1145 - tzsxWh +=fcsjT-temp;  
1146 - }else{  
1147 - if(fcsjT_ > 16*60 && fcsjT_ <= 18*60)  
1148 - tzxxWgf +=fcsjT-temp;  
1149 - else  
1150 - tzxxWh +=fcsjT-temp;  
1151 - }  
1152 - }  
1153 - }  
1154 - temp =fcsjT+bcsj;  
1155 - }  
1156 -  
1157 - /*}else{  
1158 - //下行数据  
1159 - if(fcsjT>= minSj && fcsjT <= 6*60+30){  
1160 - //早高峰前  
1161 - yyxxZq +=bcsj;  
1162 - xxcountZqbc ++;  
1163 - zqFcsj1.add(fcsjT);  
1164 - if(ists){  
1165 - if(lpname.equals(m.get("lp").toString())){  
1166 - tzxxZq +=fcsjT-temp;  
1167 - }  
1168 - }  
1169 - temp =fcsjT+bcsj;  
1170 - }else if(fcsjT > 6*60+30 && fcsjT <= 8*60+30){  
1171 - //早高峰  
1172 - yyxxZgf +=bcsj;  
1173 - xxcountZgfbc ++;  
1174 - zgfFcsj1.add(fcsjT);  
1175 - if(ists){  
1176 - if(lpname.equals(m.get("lp").toString())){  
1177 - if(fcsjT_>= minSj && fcsjT_ <= 6*60+30)  
1178 - tzxxZq +=fcsjT-temp;  
1179 - else  
1180 - tzxxZgf +=fcsjT-temp;  
1181 - }  
1182 - }  
1183 - temp =fcsjT+bcsj;  
1184 - }else if(fcsjT > 8*60+30 && fcsjT <= 16*60){  
1185 - //中午  
1186 - yyxxZw +=bcsj;  
1187 - xxcountZwbc ++;  
1188 - zwFcsj1.add(fcsjT);  
1189 - if(ists){  
1190 - if(lpname.equals(m.get("lp").toString())){  
1191 - if(fcsjT_ > 6*60+30 && fcsjT_ <= 8*60+30)  
1192 - tzxxZgf +=fcsjT-temp;  
1193 - else  
1194 - tzxxZw +=fcsjT-temp;  
1195 - }  
1196 - }  
1197 - temp =fcsjT+bcsj;  
1198 - }else if(fcsjT > 16*60 && fcsjT <= 18*60){  
1199 - //晚高峰  
1200 - yyxxWgf +=bcsj;  
1201 - xxcountWgfbc ++;  
1202 - wgfFcsj1.add(fcsjT);  
1203 - if(ists){  
1204 - if(lpname.equals(m.get("lp").toString())){  
1205 - if(fcsjT_ > 8*60+30 && fcsjT_ <= 16*60)  
1206 - tzxxZw +=fcsjT-temp;  
1207 - else  
1208 - tzxxWgf +=fcsjT-temp;  
1209 - }  
1210 - }  
1211 - temp =fcsjT+bcsj;  
1212 - }else{  
1213 - //晚高峰后  
1214 - yyxxWh +=bcsj;  
1215 - xxcountWhbc ++;  
1216 - whFcsj1.add(fcsjT);  
1217 - if(ists){  
1218 - if(lpname.equals(m.get("lp").toString())){  
1219 - if(fcsjT_ > 16*60 && fcsjT_ <= 18*60)  
1220 - tzxxWgf +=fcsjT-temp;  
1221 - else  
1222 - tzxxWh +=fcsjT-temp;  
1223 - }  
1224 - }  
1225 - temp =fcsjT+bcsj;  
1226 - }  
1227 -// }  
1228 - }*/  
1229 - lpname=m.get("lp").toString();  
1230 - fcsjT_=fcsjT;  
1231 - dir =xlDir;  
1232 - if(m.get("ists").toString().trim().equals("1")){  
1233 - ists=false;  
1234 - }else{  
1235 - ists = true;  
1236 - }  
1237 - }  
1238 - }  
1239 -  
1240 - }  
1241 -  
1242 - //---------------------------------------早前  
1243 - List<Integer> cjs = new ArrayList<Integer>();  
1244 - Collections.sort(zqFcsj0);  
1245 - int fcsjs=0;  
1246 - for (int i = 0; i < zqFcsj0.size(); i++) {  
1247 - if(i==0){  
1248 - fcsjs =zqFcsj0.get(i);  
1249 - }else{  
1250 - cjs.add(zqFcsj0.get(i)-fcsjs);  
1251 - fcsjs=zqFcsj0.get(i);  
1252 - }  
1253 -  
1254 - }  
1255 - Collections.sort(zqFcsj1);  
1256 - int fcsjx=0;  
1257 - for (int i = 0; i < zqFcsj1.size(); i++) {  
1258 - if(i==0){  
1259 - fcsjx =zqFcsj1.get(i);  
1260 - }else{  
1261 - cjs.add(zqFcsj1.get(i)-fcsjx);  
1262 - fcsjx =zqFcsj1.get(i);  
1263 - }  
1264 -  
1265 - }  
1266 - Collections.sort(cjs);  
1267 - for(int i : cjs){  
1268 - zcj += i;  
1269 - }  
1270 - Map<String, Object> tempMap = new HashMap<String, Object>();  
1271 - double sxtszq=0.0;  
1272 - double sxsjzq=0.0;  
1273 - if(sxcountZqbc>0){  
1274 - sxtszq=Arith.div(tzsxZq, sxcountZqbc, 1);  
1275 - sxsjzq=Arith.div(yysxZq, sxcountZqbc,1);  
1276 - }  
1277 -  
1278 - double xxtszq=0.0;  
1279 - double xxsjzq=0.0;  
1280 - if(xxcountZqbc>0){  
1281 - xxtszq=Arith.div(tzxxZq, xxcountZqbc, 1);  
1282 - xxsjzq=Arith.div(yyxxZq, xxcountZqbc,1);  
1283 - }  
1284 - tempMap.put("sjd", "(首)——6:30");  
1285 - tempMap.put("sxsj", sxsjzq);  
1286 - tempMap.put("xxsj", xxsjzq);  
1287 - tempMap.put("sxtssj", sxtszq);  
1288 - tempMap.put("xxtssj", xxtszq);  
1289 - tempMap.put("fqsj", Arith.add(Arith.add(sxtszq, sxsjzq), Arith.add(xxtszq, xxsjzq)));  
1290 - tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");  
1291 - tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");  
1292 - newList.add(tempMap);  
1293 -  
1294 - //----------------------------------早高峰  
1295 - cjs = new ArrayList<Integer>();  
1296 - zcj =0;  
1297 -  
1298 - Collections.sort(zgfFcsj0);  
1299 - fcsjs=0;  
1300 - for (int i = 0; i < zgfFcsj0.size(); i++) {  
1301 - if(i==0){  
1302 - fcsjs =zgfFcsj0.get(i);  
1303 - }else{  
1304 - cjs.add(zgfFcsj0.get(i)-fcsjs);  
1305 - fcsjs=zgfFcsj0.get(i);  
1306 - }  
1307 -  
1308 - }  
1309 - Collections.sort(zgfFcsj1);  
1310 - fcsjx=0;  
1311 - for (int i = 0; i < zgfFcsj1.size(); i++) {  
1312 - if(i==0){  
1313 - fcsjx =zgfFcsj1.get(i);  
1314 - }else{  
1315 - cjs.add(zgfFcsj1.get(i)-fcsjx);  
1316 - fcsjx =zgfFcsj1.get(i);  
1317 - }  
1318 -  
1319 - }  
1320 - Collections.sort(cjs);  
1321 - for(int i : cjs){  
1322 - zcj += i;  
1323 - }  
1324 - double sxtszgf=0.0;  
1325 - double sxsjzgf=0.0;  
1326 - if(sxcountZgfbc>0){  
1327 - sxtszgf=Arith.div(tzsxZgf, sxcountZgfbc, 1);  
1328 - sxsjzgf =Arith.div(yysxZgf, sxcountZgfbc, 1);  
1329 - }  
1330 -  
1331 - double xxtszgf=0.0;  
1332 - double xxsjzgf=0.0;  
1333 - if(xxcountZgfbc>0){  
1334 - xxtszgf=Arith.div(tzxxZgf, xxcountZgfbc, 1);  
1335 - xxsjzgf=Arith.div(yyxxZgf, xxcountZgfbc,1);  
1336 - }  
1337 -  
1338 -  
1339 - tempMap = new HashMap<String, Object>();  
1340 - tempMap.put("sjd", "6:31——8:30");  
1341 - tempMap.put("sxsj", sxsjzgf);  
1342 - tempMap.put("xxsj", xxsjzgf);  
1343 - tempMap.put("sxtssj", sxtszgf);  
1344 - tempMap.put("xxtssj", xxtszgf);  
1345 - tempMap.put("fqsj", Arith.add(Arith.add(sxtszgf, sxsjzgf), Arith.add(xxtszgf, xxsjzgf)));  
1346 - tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");  
1347 - tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");  
1348 - newList.add(tempMap);  
1349 - //----------------------------------------------中午  
1350 - cjs = new ArrayList<Integer>();  
1351 - zcj =0;  
1352 -  
1353 - Collections.sort(zwFcsj0);  
1354 - fcsjs=0;  
1355 - for (int i = 0; i < zwFcsj0.size(); i++) {  
1356 - if(i==0){  
1357 - fcsjs =zwFcsj0.get(i);  
1358 - }else{  
1359 - cjs.add(zwFcsj0.get(i)-fcsjs);  
1360 - fcsjs=zwFcsj0.get(i);  
1361 - }  
1362 -  
1363 - }  
1364 - Collections.sort(zwFcsj1);  
1365 - fcsjx=0;  
1366 - for (int i = 0; i < zwFcsj1.size(); i++) {  
1367 - if(i==0){  
1368 - fcsjx =zwFcsj1.get(i);  
1369 - }else{  
1370 - cjs.add(zwFcsj1.get(i)-fcsjx);  
1371 - fcsjx =zwFcsj1.get(i);  
1372 - }  
1373 -  
1374 - }  
1375 - Collections.sort(cjs);  
1376 - for(int i : cjs){  
1377 - zcj += i;  
1378 - }  
1379 - double sxtzsjzw=0.0;  
1380 - double sxsjsjzw=0.0;  
1381 - if(sxcountZwbc>0){  
1382 - sxtzsjzw=Arith.div(tzsxZw, sxcountZwbc, 1);  
1383 - sxsjsjzw=Arith.div(yysxZw, sxcountZwbc,1);  
1384 - }  
1385 -  
1386 - double xxtzsjzw=0.0;  
1387 - double xxsjsjzw=0.0;  
1388 - if(xxcountZwbc>0){  
1389 - xxtzsjzw=Arith.div(tzxxZw, xxcountZwbc,1);  
1390 - xxsjsjzw=Arith.div(yyxxZw, xxcountZwbc, 1);  
1391 - }  
1392 - tempMap = new HashMap<String, Object>();  
1393 - tempMap.put("sjd", "8:31——16:00");  
1394 - tempMap.put("sxsj", sxsjsjzw);  
1395 - tempMap.put("xxsj", xxsjsjzw);  
1396 - tempMap.put("sxtssj", sxtzsjzw);  
1397 - tempMap.put("xxtssj", xxtzsjzw);  
1398 - tempMap.put("fqsj", Arith.add(Arith.add(sxtzsjzw, sxsjsjzw), Arith.add(xxtzsjzw, xxsjsjzw)));  
1399 - tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");  
1400 - tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");  
1401 - newList.add(tempMap);  
1402 - //-------------------------------------------------晚高峰  
1403 - cjs = new ArrayList<Integer>();  
1404 - zcj =0;  
1405 -  
1406 - Collections.sort(wgfFcsj0);  
1407 - fcsjs=0;  
1408 - for (int i = 0; i < wgfFcsj0.size(); i++) {  
1409 - if(i==0){  
1410 - fcsjs =wgfFcsj0.get(i);  
1411 - }else{  
1412 - cjs.add(wgfFcsj0.get(i)-fcsjs);  
1413 - fcsjs=wgfFcsj0.get(i);  
1414 - }  
1415 -  
1416 - }  
1417 - Collections.sort(wgfFcsj1);  
1418 - fcsjx=0;  
1419 - for (int i = 0; i < wgfFcsj1.size(); i++) {  
1420 - if(i==0){  
1421 - fcsjx =wgfFcsj1.get(i);  
1422 - }else{  
1423 - cjs.add(wgfFcsj1.get(i)-fcsjx);  
1424 - fcsjx =wgfFcsj1.get(i);  
1425 - }  
1426 -  
1427 - }  
1428 - Collections.sort(cjs);  
1429 - for(int i : cjs){  
1430 - zcj += i;  
1431 - }  
1432 -  
1433 - double sxtzsjwgf=0.0;  
1434 - double sxsjsjwgf=0.0;  
1435 - if(sxcountWgfbc>0){  
1436 - sxtzsjwgf=Arith.div(tzsxWgf, sxcountWgfbc, 1);  
1437 - sxsjsjwgf=Arith.div(yysxWgf, sxcountWgfbc,1);  
1438 - }  
1439 -  
1440 - double xxtzsjwgf=0.0;  
1441 - double xxsjsjwgf=0.0;  
1442 - if(xxcountWgfbc>0){  
1443 - xxtzsjwgf=Arith.div(tzxxWgf, xxcountWgfbc, 1);  
1444 - xxsjsjwgf=Arith.div(yyxxWgf, xxcountWgfbc,1);  
1445 - }  
1446 -  
1447 - tempMap = new HashMap<String, Object>();  
1448 - tempMap.put("sjd", "16:01——18:00");  
1449 - tempMap.put("sxsj", sxsjsjwgf);  
1450 - tempMap.put("xxsj", xxsjsjwgf);  
1451 - tempMap.put("sxtssj", sxtzsjwgf);  
1452 - tempMap.put("xxtssj", xxtzsjwgf);  
1453 - tempMap.put("fqsj", Arith.add(Arith.add(sxsjsjwgf, sxtzsjwgf), Arith.add(xxsjsjwgf, xxtzsjwgf)));  
1454 - tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");  
1455 - tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");  
1456 - newList.add(tempMap);  
1457 -  
1458 - //----------------------------------晚后  
1459 - cjs = new ArrayList<Integer>();  
1460 - zcj =0;  
1461 -  
1462 - Collections.sort(whFcsj0);  
1463 - fcsjs=0;  
1464 - for (int i = 0; i < whFcsj0.size(); i++) {  
1465 - if(i==0){  
1466 - fcsjs =whFcsj0.get(i);  
1467 - }else{  
1468 - cjs.add(whFcsj0.get(i)-fcsjs);  
1469 - fcsjs=whFcsj0.get(i);  
1470 - }  
1471 -  
1472 - }  
1473 - Collections.sort(whFcsj1);  
1474 - fcsjx=0;  
1475 - for (int i = 0; i < whFcsj1.size(); i++) {  
1476 - if(i==0){  
1477 - fcsjx =whFcsj1.get(i);  
1478 - }else{  
1479 - cjs.add(whFcsj1.get(i)-fcsjx);  
1480 - fcsjx =whFcsj1.get(i);  
1481 - }  
1482 -  
1483 - }  
1484 - Collections.sort(cjs);  
1485 - for(int i : cjs){  
1486 - zcj += i;  
1487 - }  
1488 - double sxtzsjwh=0.0;  
1489 - double sxsjsjwh=0.0;  
1490 - if(sxcountWhbc>0){  
1491 - sxtzsjwh=Arith.div(tzsxWh,sxcountWhbc,1);  
1492 - sxsjsjwh=Arith.div(yysxWh, sxcountWhbc,1);  
1493 - }  
1494 -  
1495 - double xxtzsjwh=0.0;  
1496 - double xxsjsjwh=0.0;  
1497 - if(xxcountWhbc>0){  
1498 - xxtzsjwh=Arith.div(tzxxWh, xxcountWhbc,1);  
1499 - xxsjsjwh=Arith.div(yyxxWh, xxcountWhbc, 1);  
1500 - }  
1501 - tempMap = new HashMap<String, Object>();  
1502 - tempMap.put("sjd", "18:01——(末)");  
1503 - tempMap.put("sxsj", sxsjsjwh);  
1504 - tempMap.put("xxsj", xxsjsjwh);  
1505 - tempMap.put("sxtssj", sxtzsjwh);  
1506 - tempMap.put("xxtssj", xxtzsjwh);  
1507 - tempMap.put("fqsj", Arith.add(Arith.add(sxsjsjwh, sxtzsjwh), Arith.add(xxsjsjwh,xxtzsjwh)));  
1508 - tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");  
1509 - tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");  
1510 - newList.add(tempMap);  
1511 - /*  
1512 - Map<String, List<Map<String, Object>>> keyMap = new HashMap<String, List<Map<String, Object>>>();  
1513 - Map<String, Map<String, Object>> maps = new HashMap<String, Map<String, Object>>();  
1514 - keyMap.put("(首)——6:30", new ArrayList<Map<String, Object>>());  
1515 - keyMap.put("6:31——8:30", new ArrayList<Map<String, Object>>());  
1516 - keyMap.put("8:31——16:00", new ArrayList<Map<String, Object>>());  
1517 - keyMap.put("16:01——18:00", new ArrayList<Map<String, Object>>());  
1518 - keyMap.put("18:01——(末)", new ArrayList<Map<String, Object>>());  
1519 - for(int i = 0; i < list.size(); i++){  
1520 - Map<String, Object> ttMap = list.get(i);  
1521 - String fcsj = ttMap.get("fcsj").toString();  
1522 - String[] split = fcsj.split(":");  
1523 - int fcsjT = Integer.valueOf(split[0])*60+Integer.valueOf(split[1]);  
1524 - if(fcsjT >= minSj && fcsjT <= 6*60+30){  
1525 - keyMap.get("(首)——6:30").add(ttMap);  
1526 - } else if(fcsjT > 6*60+30 && fcsjT <= 8*60+30){  
1527 - keyMap.get("6:31——8:30").add(ttMap);  
1528 - } else if(fcsjT > 8*60+30 && fcsjT <= 16*60){  
1529 - keyMap.get("8:31——16:00").add(ttMap);  
1530 - } else if(fcsjT > 16*60 && fcsjT <= 18*60){  
1531 - keyMap.get("16:01——18:00").add(ttMap);  
1532 - } else {  
1533 - keyMap.get("18:01——(末)").add(ttMap);  
1534 - }  
1535 - }  
1536 -  
1537 - for(String key : keyMap.keySet()){  
1538 - Map<String, Object> tempMap = new HashMap<String, Object>();  
1539 - List<Map<String, Object>> list2 = keyMap.get(key);  
1540 - List<Integer> cjs = new ArrayList<Integer>();  
1541 - List<Integer> fcsj_s = new ArrayList<Integer>();  
1542 - List<Integer> fcsj_x = new ArrayList<Integer>();  
1543 - int sxsj = 0, xxsj = 0, sxtssj = 0, xxtssj = 0;  
1544 - int sxbc = 0, xxbc = 0, sxtsbc = 0, xxtsbc = 0;  
1545 - int temp = 48*60+1, zcj = 0;  
1546 - boolean ists = false;  
1547 - String lpname="";  
1548 - for(Map<String, Object> m : list2){  
1549 - String bcType=m.get("bcType").toString();  
1550 - if(bcType.equals("in") || bcType.equals("out")){  
1551 - temp=24*60+1;  
1552 - }else{  
1553 - String[] split = m.get("fcsj").toString().split(":");  
1554 - int fcsj = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]);  
1555 -  
1556 - int xlDir = Integer.valueOf(m.get("dir").toString());  
1557 - int bcsj = Integer.valueOf(m.get("bcsj").toString());  
1558 - if(temp >= fcsj){  
1559 - temp = fcsj+bcsj;  
1560 - ists = false;  
1561 - }  
1562 - if(xlDir == 0){  
1563 - fcsj_s.add(fcsj);  
1564 - sxsj += bcsj;  
1565 - sxbc ++;  
1566 - if(!ists){  
1567 - if(lpname.equals("")){  
1568 - lpname=m.get("lp").toString();  
1569 - }else{  
1570 - if(lpname.equals(m.get("lp").toString())){  
1571 - if(fcsj-temp<90){  
1572 - sxtssj += fcsj - temp;  
1573 - }  
1574 - }  
1575 - lpname=m.get("lp").toString();  
1576 -  
1577 - }  
1578 - sxtsbc++;  
1579 - }  
1580 -  
1581 - } else {  
1582 -  
1583 - fcsj_x.add(fcsj);  
1584 - xxsj += bcsj;  
1585 - xxbc ++;  
1586 -  
1587 - if(!ists){  
1588 - if(lpname.equals("")){  
1589 - lpname=m.get("lp").toString();  
1590 - }else{  
1591 - if(lpname.equals(m.get("lp").toString())){  
1592 - if(fcsj-temp<90){  
1593 - xxtssj += fcsj- temp;  
1594 - }  
1595 - }  
1596 - lpname=m.get("lp").toString();  
1597 - }  
1598 - xxtsbc++;  
1599 - }  
1600 -  
1601 - }  
1602 - if(temp < fcsj){  
1603 - cjs.add(fcsj - temp);  
1604 - temp = fcsj;  
1605 - }  
1606 - if(m.get("ists").toString().trim().equals("1")){  
1607 - ists = true;  
1608 - }else{  
1609 - ists=false;  
1610 - }  
1611 - }  
1612 - }  
1613 - Collections.sort(fcsj_s);  
1614 - int fcsjs=0;  
1615 - for (int i = 0; i < fcsj_s.size(); i++) {  
1616 - if(i==0){  
1617 - fcsjs =fcsj_s.get(i);  
1618 - }else{  
1619 - cjs.add(fcsj_s.get(i)-fcsjs);  
1620 - fcsjs=fcsj_s.get(i);  
1621 - }  
1622 -  
1623 - }  
1624 - Collections.sort(fcsj_x);  
1625 - int fcsjx=0;  
1626 - for (int i = 0; i < fcsj_x.size(); i++) {  
1627 - if(i==0){  
1628 - fcsjx =fcsj_x.get(i);  
1629 - }else{  
1630 - cjs.add(fcsj_x.get(i)-fcsjx);  
1631 - fcsjx =fcsj_x.get(i);  
1632 - }  
1633 -  
1634 - }  
1635 - Collections.sort(cjs);  
1636 - for(int i : cjs){  
1637 - zcj += i;  
1638 - }  
1639 - tempMap.put("sjd", key);  
1640 - tempMap.put("sxsj", sxbc != 0 ? sxsj / sxbc : "0");  
1641 - tempMap.put("xxsj", xxbc != 0 ? xxsj / xxbc : "0");  
1642 - tempMap.put("sxtssj", sxtsbc != 0 ? sxtssj / sxtsbc : "0");  
1643 - tempMap.put("xxtssj", xxtsbc != 0 ? xxtssj / xxtsbc : "0");  
1644 - tempMap.put("fqsj", Integer.valueOf(tempMap.get("sxsj").toString()) + Integer.valueOf(tempMap.get("xxsj").toString())  
1645 - + Integer.valueOf(tempMap.get("sxtssj").toString()) + Integer.valueOf(tempMap.get("xxtssj").toString()));  
1646 - tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");  
1647 - tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");  
1648 - maps.put(key, tempMap);  
1649 - }  
1650 - newList.add(maps.get("(首)——6:30"));  
1651 - newList.add(maps.get("6:31——8:30"));  
1652 - newList.add(maps.get("8:31——16:00"));  
1653 - newList.add(maps.get("16:01——18:00"));  
1654 - newList.add(maps.get("18:01——(末)"));*/  
1655 -  
1656 - return newList;  
1657 - }  
1658 - @Override  
1659 - public List<Map<String, Object>> getTtinfo(Map<String, Object> map) {  
1660 - // TODO Auto-generated method stub  
1661 - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();  
1662 - String line = map.get("line").toString();  
1663 - try {  
1664 - List<String> objList = new ArrayList<String>();  
1665 - String sql = "select tt.id, tt.name from bsth_c_s_ttinfo tt"  
1666 - + " left join bsth_c_line cl on cl.id = tt.xl"  
1667 - + " where tt.is_cancel = 0 and tt.is_enable_dis_template = 1";  
1668 - if(line.length() != 0){  
1669 - sql += " and cl.line_code = ?";  
1670 - objList.add(line);  
1671 - }  
1672 - sql += " order by tt.create_date desc";  
1673 -  
1674 - list = jdbcTemplate.query(sql, objList.toArray(),  
1675 - new RowMapper<Map<String, Object>>(){  
1676 - @Override  
1677 - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {  
1678 - Map<String, Object> map = new HashMap<String, Object>();  
1679 - map.put("id", rs.getString("id"));  
1680 - map.put("name", rs.getString("name"));  
1681 - return map;  
1682 - }  
1683 - });  
1684 - }catch (Exception e) {  
1685 - // TODO Auto-generated catch block  
1686 - e.printStackTrace();  
1687 - }  
1688 - return list;  
1689 - }  
1690 -  
1691 - @Override  
1692 - public List<Map<String, Object>> jobFwqk(Map<String, Object> map) {  
1693 - // TODO Auto-generated method stub  
1694 - String[] lblxs = {"配车","保养","故障","肇事","路阻","纠纷","缺人","客稀","缺车","气候","援外","吊慢","抽减","路救抛锚","其他" };  
1695 - Set<String> lblxSet = new HashSet<String>();  
1696 - for(String s : lblxs){  
1697 - lblxSet.add(s);  
1698 - }  
1699 - String line=map.get("line").toString();  
1700 - String date=map.get("date").toString();  
1701 - map.put("bcType", "normal");  
1702 - List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();  
1703 - List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);  
1704 - for (int i = 0; i < sList.size(); i++) {  
1705 - ScheduleRealInfo scheduleRealInfo = sList.get(i);  
1706 - if (!(scheduleRealInfo.getBcType().equals("in")  
1707 - || scheduleRealInfo.getBcType().equals("out")  
1708 - ||scheduleRealInfo.getBcType().equals("ldks"))) {  
1709 - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
1710 - if (childTaskPlans.isEmpty()) {  
1711 - Map<String, Object> newMap = new HashMap<String, Object>();  
1712 - String adjustExps = "";  
1713 - if (scheduleRealInfo.getAdjustExps() == null) {  
1714 - adjustExps = "其他";  
1715 - } else if(scheduleRealInfo.getAdjustExps().equals("")){  
1716 - adjustExps = "其他";  
1717 - } else if(!(lblxSet.contains(scheduleRealInfo.getAdjustExps()))){  
1718 - adjustExps = "其他";  
1719 - } else {  
1720 - adjustExps = scheduleRealInfo.getAdjustExps();  
1721 - }  
1722 - if (scheduleRealInfo.getStatus() == -1) {  
1723 - newMap.put("nr", adjustExps);  
1724 - newMap.put("lp", scheduleRealInfo.getLpName());  
1725 - newMap.put("nbbm", scheduleRealInfo.getClZbh());  
1726 - newMap.put("jgh", scheduleRealInfo.getjGh()+scheduleRealInfo.getjName()+"/"+scheduleRealInfo.getsGh()+scheduleRealInfo.getsName());  
1727 - newMap.put("dz", scheduleRealInfo.getQdzName());  
1728 - newMap.put("sj", scheduleRealInfo.getFcsj());  
1729 - newMap.put("lbbc", 1);  
1730 - newMap.put("gzf", " ");  
1731 - newMap.put("lblc", scheduleRealInfo.getJhlcOrig());  
1732 - newMap.put("jyqp", scheduleRealInfo.getRemarks());  
1733 - list.add(newMap);  
1734 - }  
1735 -  
1736 - } else {  
1737 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
1738 - if (scheduleRealInfo.getStatus() == -1) {  
1739 - double zlblc=0.0;  
1740 - while (it.hasNext()) {  
1741 - ChildTaskPlan childTaskPlan = it.next();  
1742 - if(childTaskPlan.getMileageType().equals("service")){  
1743 - if (childTaskPlan.isDestroy()) {  
1744 - zlblc=Arith.add(zlblc,childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage());  
1745 - }  
1746 - }  
1747 - }  
1748 - Map<String, Object> newMap = new HashMap<String, Object>();  
1749 - String adjustExps = "";  
1750 - if (scheduleRealInfo.getAdjustExps() == "" || scheduleRealInfo.getAdjustExps() == null) {  
1751 - adjustExps = "其他";  
1752 - } else if(!(lblxSet.contains(scheduleRealInfo.getAdjustExps()))){  
1753 - adjustExps = "其他";  
1754 - } else {  
1755 - adjustExps = scheduleRealInfo.getAdjustExps();  
1756 - }  
1757 - newMap.put("nr", adjustExps);  
1758 - newMap.put("lp", scheduleRealInfo.getLpName());  
1759 - newMap.put("nbbm", scheduleRealInfo.getClZbh());  
1760 - newMap.put("jgh", scheduleRealInfo.getjGh()+scheduleRealInfo.getjName()+"/"+scheduleRealInfo.getsGh()+scheduleRealInfo.getsName());  
1761 - newMap.put("dz", scheduleRealInfo.getQdzName());  
1762 - newMap.put("sj", scheduleRealInfo.getFcsj());  
1763 - newMap.put("lbbc", 1);  
1764 - newMap.put("lblc", zlblc);  
1765 - newMap.put("jyqp", scheduleRealInfo.getRemarks());  
1766 - list.add(newMap);  
1767 - } else {  
1768 - while (it.hasNext()) {  
1769 - ChildTaskPlan childTaskPlan = it.next();  
1770 - if (childTaskPlan.isDestroy()) {  
1771 - if(childTaskPlan.getMileageType().equals("service")){  
1772 - String destroyReason = "";  
1773 - if (childTaskPlan.getDestroyReason() == null) {  
1774 - destroyReason = "其他";  
1775 - } else if (childTaskPlan.getDestroyReason().equals("")) {  
1776 - destroyReason = "其他";  
1777 - } else if(!(lblxSet.contains(childTaskPlan.getDestroyReason()))){  
1778 - destroyReason = "其他";  
1779 - } else {  
1780 - destroyReason = childTaskPlan.getDestroyReason();  
1781 - }  
1782 - Map<String, Object> newMap = new HashMap<String, Object>();  
1783 - newMap.put("nr", destroyReason);  
1784 - newMap.put("lp", scheduleRealInfo.getLpName());  
1785 - newMap.put("nbbm", scheduleRealInfo.getClZbh());  
1786 - newMap.put("jgh", scheduleRealInfo.getjGh()+scheduleRealInfo.getjName()+"/"+scheduleRealInfo.getsGh()+scheduleRealInfo.getsName());  
1787 - newMap.put("dz", childTaskPlan.getStartStationName());  
1788 - newMap.put("sj", childTaskPlan.getStartDate());  
1789 - newMap.put("gzf", " ");  
1790 - newMap.put("lbbc", 0);  
1791 - newMap.put("lblc", childTaskPlan.getMileage());  
1792 - newMap.put("jyqp", childTaskPlan.getRemarks());  
1793 - list.add(newMap);  
1794 - }  
1795 - }  
1796 - }  
1797 - }  
1798 -  
1799 - }  
1800 - }  
1801 - }  
1802 - List<Map<String, Object>> listNew=new ArrayList<Map<String,Object>>();  
1803 - for (int i = 0; i < lblxs.length; i++) {  
1804 - String lx=lblxs[i];  
1805 - double lblc=0.0;  
1806 - int lbbc=0;  
1807 - for (int j = 0; j < list.size(); j++) {  
1808 - Map<String, Object> m1=list.get(j);  
1809 - if(lx.equals(m1.get("nr").toString())){  
1810 - m1.put("lx", 0);  
1811 - listNew.add(m1);  
1812 - lblc =Arith.add(lblc,Double.parseDouble(m1.get("lblc").toString()));  
1813 - lbbc += Integer.parseInt(m1.get("lbbc").toString());  
1814 - }  
1815 - }  
1816 - if(lblc>0){  
1817 - Map<String, Object> newMap = new HashMap<String, Object>();  
1818 - newMap.put("lx", 1);  
1819 - newMap.put("nr", lx);  
1820 - newMap.put("lp", "小计");  
1821 - newMap.put("nbbm", "少驶班次");  
1822 - newMap.put("jgh", lbbc);  
1823 - newMap.put("lbbc", "少驶公里");  
1824 - newMap.put("lblc", lblc);  
1825 - newMap.put("dz", " ");  
1826 - newMap.put("sj", " ");  
1827 - newMap.put("gzf", " ");  
1828 - newMap.put("jyqp"," ");  
1829 - listNew.add(newMap);  
1830 - }  
1831 -  
1832 -  
1833 - }  
1834 - Collections.sort(listNew, new ComparableJob());  
1835 - return listNew;  
1836 - }  
1837 -  
1838 - //统计临加班次详细信息  
1839 - @Override  
1840 - public List<Map<String, Object>> jobLjqk(Map<String, Object> map) {  
1841 - // TODO Auto-generated method stub  
1842 - String line=map.get("line").toString();  
1843 - String date=map.get("date").toString();  
1844 - map.put("bcType", "normal");  
1845 - List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();  
1846 - List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);  
1847 - for (int i = 0; i < sList.size(); i++) {  
1848 - ScheduleRealInfo scheduleRealInfo=sList.get(i);  
1849 - if (!(scheduleRealInfo.getBcType().equals("in")  
1850 - || scheduleRealInfo.getBcType().equals("out")  
1851 - || scheduleRealInfo.getBcType().equals("ldks"))) {  
1852 -// Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();  
1853 -// if(childTaskPlans.isEmpty()){  
1854 - if(scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){  
1855 - Map<String, Object> newMap=new HashMap<String,Object>();  
1856 - newMap.put("lp", scheduleRealInfo.getLpName());  
1857 - newMap.put("nbbm", scheduleRealInfo.getClZbh());  
1858 - newMap.put("jgh", scheduleRealInfo.getjGh());  
1859 - newMap.put("dz", scheduleRealInfo.getQdzName());  
1860 - newMap.put("sj", scheduleRealInfo.getFcsj());  
1861 - newMap.put("ljlc", scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());  
1862 - newMap.put("jyqp", scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks());  
1863 - list.add(newMap);  
1864 - }  
1865 -// }else{  
1866 -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
1867 -// while (it.hasNext()) {  
1868 -// ChildTaskPlan childTaskPlan = it.next();  
1869 -// if (childTaskPlan.isDestroy()) {  
1870 -// }  
1871 -// }  
1872 -// }  
1873 - }  
1874 - }  
1875 - return list;  
1876 - }  
1877 -  
1878 - public static double culateCJLC2(List<ScheduleRealInfo> list, String item) {  
1879 - // TODO Auto-generated method stub  
1880 - double sum = 0;  
1881 - Set<ChildTaskPlan> cts;  
1882 - for(ScheduleRealInfo sch : list){  
1883 - if (sch.isSflj())  
1884 - continue;  
1885 - cts = sch.getcTasks();  
1886 - //有子任务  
1887 - if (cts != null && cts.size() > 0) {  
1888 - for(ChildTaskPlan c : cts){  
1889 - if(c.isDestroy() && c.getDestroyReason().equals(item))  
1890 - sum = Arith.add(sum, c.getMileage());  
1891 - }  
1892 - }  
1893 -// else if(isInOut(sch))  
1894 -// continue;  
1895 - //主任务烂班  
1896 - else if(sch.getStatus() == -1){  
1897 - if(sch.getAdjustExps().equals(item) ||  
1898 - (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){  
1899 - sum = Arith.add(sum, sch.getJhlcOrig());  
1900 - }  
1901 - }  
1902 - else if(item.equals("其他")){  
1903 - double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());  
1904 - if(diff > 0){  
1905 - sum = Arith.add(sum, diff);  
1906 - }  
1907 - }  
1908 - }  
1909 - return sum;  
1910 -  
1911 - }  
1912 - @Override  
1913 - public Map<String, Object> jobHzxx(Map<String, Object> map) {  
1914 - // TODO Auto-generated method stub  
1915 - String line="";  
1916 - if(map.get("line")!=null){  
1917 - line=map.get("line").toString();  
1918 - }  
1919 - String date="";  
1920 - if(map.get("date")!=null){  
1921 - date=map.get("date").toString();  
1922 - }  
1923 -  
1924 - List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);  
1925 - List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>();  
1926 - for (int i = 0; i < sList.size(); i++) {  
1927 - ScheduleRealInfo s=sList.get(i);  
1928 - Set<ChildTaskPlan> cts = s.getcTasks();  
1929 - if(cts != null && cts.size() > 0){  
1930 - lists.add(s);  
1931 - }else{  
1932 - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){  
1933 - lists.add(s);  
1934 - }  
1935 - }  
1936 - }  
1937 - Map<String, Object> newMap=culateService.culateWdbcs(lists);  
1938 - newMap.put("jhbc", culateService.culateJhbc(sList,""));  
1939 - newMap.put("jhbczgf", culateService.culateJhbc(sList,"zgf"));  
1940 - newMap.put("jhbcwgf", culateService.culateJhbc(sList,"wgf"));  
1941 - newMap.put("jhgl", culateService.culateJhgl(sList));  
1942 - newMap.put("jhglzgf", culateService.culateJhgl_(sList,"zgf"));  
1943 - newMap.put("jhglwgf", culateService.culateJhgl_(sList,"wgf"));  
1944 -  
1945 - newMap.put("lbgl", culateService.culateLbgl(sList));  
1946 - newMap.put("lbbc", culateService.culateLbbc(sList));  
1947 -  
1948 - newMap.put("sjbc", culateService.culateSjbc(lists,""));  
1949 - newMap.put("sjbczgf", culateService.culateSjbc(lists,"zgf"));  
1950 - newMap.put("sjbcwgf", culateService.culateSjbc(lists,"wgf"));  
1951 - newMap.put("sjgl", culateService.culateSjgl(lists));  
1952 - newMap.put("sjglzgf", culateService.culateSjgl_(lists,"zgf"));  
1953 - newMap.put("sjglwgf", culateService.culateSjgl_(lists,"wgf"));  
1954 -  
1955 -  
1956 - newMap.put("ljgl", culateService.culateLjgl(lists));  
1957 - newMap.put("ljglzgf", culateService.culateLjgl_(lists,"zgf"));  
1958 - newMap.put("ljglwgf", culateService.culateLjgl_(lists,"wgf"));  
1959 -  
1960 - newMap.put("ljbc", culateService.culateLjbc(lists,""));  
1961 - newMap.put("ksgl", culateService.culateKsgl(lists));  
1962 -  
1963 - newMap.put("jhfbbc",culateService.culateDtfzbc(lists, "venting", "jh", ""));  
1964 - newMap.put("jhfbbczgf",culateService.culateDtfzbc(lists, "venting", "jh", "zgf"));  
1965 - newMap.put("jhfbbcwgf",culateService.culateDtfzbc(lists, "venting", "jh", "wgf"));  
1966 - newMap.put("sjfbbc",culateService.culateDtfzbc(lists, "venting", "sj", ""));  
1967 - newMap.put("sjfbbczgf",culateService.culateDtfzbc(lists, "venting", "sj", "zgf"));  
1968 - newMap.put("sjfbbcwgf",culateService.culateDtfzbc(lists, "venting", "sj", "wgf"));  
1969 -  
1970 - newMap.put("jhdtbc",culateService.culateDtfzbc(lists, "major", "jh", ""));  
1971 - newMap.put("jhdtbczgf",culateService.culateDtfzbc(lists, "major", "jh", "zgf"));  
1972 - newMap.put("jhdtbcwgf",culateService.culateDtfzbc(lists, "major", "jh", "wgf"));  
1973 - newMap.put("sjdtbc",culateService.culateDtfzbc(lists, "major", "sj", ""));  
1974 - newMap.put("sjdtbczgf",culateService.culateDtfzbc(lists, "major", "sj", "zgf"));  
1975 - newMap.put("sjdtbcwgf",culateService.culateDtfzbc(lists, "major", "sj", "wgf"));  
1976 - return newMap;  
1977 - }  
1978 - @Override  
1979 - public List<Map<String, Object>> lineList() {  
1980 - // TODO Auto-generated method stub  
1981 - List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();  
1982 - List<Line> findAllLine = lineRepository.findAllLine();  
1983 - for(Line line : findAllLine){  
1984 - Map<String, Object> map=new HashMap<String,Object>();  
1985 - map.put("gsbm", line.getCompany());  
1986 - map.put("fgsbm", line.getBrancheCompany());  
1987 - map.put("xlbm", line.getLineCode());  
1988 - if(line.getDestroy() == 1){  
1989 - map.put("xlname", line.getName() + "(撤销)");  
1990 - } else {  
1991 - map.put("xlname", line.getName());  
1992 - }  
1993 - list.add(map);  
1994 - }  
1995 - return list;  
1996 - }  
1997 - @Override  
1998 - public List<Map<String, Object>> lineListNotDestroy() {  
1999 - // TODO Auto-generated method stub  
2000 - List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();  
2001 - Iterator<Line> iterator = lineRepository.findAllService().iterator();  
2002 - Line line;  
2003 - while (iterator.hasNext()) {  
2004 - line = iterator.next();  
2005 - Map<String, Object> map=new HashMap<String,Object>();  
2006 - map.put("gsbm", line.getCompany());  
2007 - map.put("fgsbm", line.getBrancheCompany());  
2008 - map.put("xlbm", line.getLineCode());  
2009 - map.put("xlname", line.getName());  
2010 - list.add(map);  
2011 - }  
2012 - return list;  
2013 - }  
2014 - @Override  
2015 - public List<Map<String, String>> carList(Map<String, Object> maps) {  
2016 - // TODO Auto-generated method stub  
2017 - // 转大写  
2018 - String nbbm =maps.get("nbbm").toString().toUpperCase();  
2019 - String gsbm="";  
2020 -  
2021 - if(maps.get("gsbm")!=null)  
2022 - gsbm= maps.get("gsbm").toString().trim();  
2023 -// String fgsbm=maps.get("fgsbm").toString().trim();  
2024 - String xlbm=maps.get("xlbm").toString().trim();  
2025 - List<Map<String, String>> list = new ArrayList<Map<String, String>>();  
2026 - Map<String, String> map;  
2027 - Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();  
2028 -  
2029 - Line line;  
2030 - for (String k : allSet) {  
2031 - if (k.indexOf(nbbm) != -1) {  
2032 - // 所属线路  
2033 - boolean fage=true;  
2034 - map = new HashMap<>();  
2035 - line = BasicData.nbbm2LineMap.get(k);  
2036 - String clgsdm= BasicData.nbbm2CompanyCodeMap.get(k);  
2037 -  
2038 - map.put("id", k);  
2039 - map.put("text", k);  
2040 - if (null != line) {  
2041 - map.put("lineName", line.getName());  
2042 - map.put("lineCode", line.getLineCode());  
2043 - }  
2044 -  
2045 - if(!xlbm.equals("")){  
2046 - if(null!=line){  
2047 - if(!line.getLineCode().equals(xlbm)){  
2048 - fage=false;  
2049 - }  
2050 - }  
2051 -  
2052 - }  
2053 -  
2054 - if(!gsbm.equals("")){  
2055 - if(!clgsdm.equals(gsbm)){  
2056 - fage=false;  
2057 - }  
2058 - }  
2059 -  
2060 - if(fage){  
2061 - list.add(map);  
2062 - }  
2063 -  
2064 - }  
2065 -  
2066 - if (list.size() > 20)  
2067 - break;  
2068 - }  
2069 - return list;  
2070 - }  
2071 - @Override  
2072 - public List<Map<String, String>> carListByHistory(Map<String, Object> maps) {  
2073 - // TODO Auto-generated method stub  
2074 - // 转大写  
2075 - String nbbm = maps.get("nbbm").toString().toUpperCase();  
2076 -  
2077 - String xlbm = maps.get("xlbm").toString().trim();  
2078 - List<Map<String, String>> list = new ArrayList<Map<String, String>>();  
2079 - Map<String, String> map;  
2080 -  
2081 - List<String> allNbbm = BasicData.lineCodeHistoryNbbmMap.get(xlbm);  
2082 -  
2083 - if(allNbbm != null){  
2084 - for(String n : allNbbm){  
2085 - if(n.indexOf(nbbm) != -1){  
2086 - map = new HashMap<>();  
2087 - map.put("id", n);  
2088 - map.put("text", n);  
2089 -  
2090 - list.add(map);  
2091 - }  
2092 -  
2093 - if (list.size() > 20)  
2094 - break;  
2095 - }  
2096 - }  
2097 -  
2098 - return list;  
2099 - }  
2100 -  
2101 -  
2102 - @Override  
2103 - public List<Map<String, String>> userList(Map<String, Object> maps) {  
2104 - // TODO Auto-generated method stub  
2105 - // 转大写  
2106 - String jsy =maps.get("jsy").toString().toUpperCase();  
2107 - String gsbm="";  
2108 - if(maps.get("gsbm")!=null)  
2109 - gsbm=maps.get("gsbm").toString().trim();  
2110 -// String fgsbm=maps.get("fgsbm").toString().trim();  
2111 - List<Map<String, String>> list = new ArrayList<Map<String, String>>();  
2112 - Map<String, String> map;  
2113 -// Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();  
2114 - Set<String> allJsy = BasicData.perMap.keySet();  
2115 -  
2116 - Personnel per;  
2117 - for (String k : allJsy) {  
2118 - if (k.indexOf(jsy) != -1) {  
2119 - map = new HashMap<>();  
2120 - // 通过人员查找公司  
2121 - per = BasicData.perMap.get(k);  
2122 - String rygsdm="";  
2123 - if(null != per){  
2124 - if(per.getCompanyCode()!=null){  
2125 - rygsdm = per.getCompanyCode();  
2126 - }  
2127 - String jboCode=per.getJobCode().substring(per.getJobCode().indexOf("-")+1);  
2128 - map.put("id", jboCode);  
2129 - map.put("text", jboCode+"/"+per.getPersonnelName());  
2130 - if(!gsbm.equals("")){  
2131 - if(rygsdm.equals(gsbm)){  
2132 - list.add(map);  
2133 - }  
2134 - }  
2135 - }  
2136 - }  
2137 -  
2138 - if (list.size() > 20)  
2139 - break;  
2140 - }  
2141 - return list;  
2142 - }  
2143 -  
2144 - public List<ArrivalInfo> load4(String line, String date, int zd,String minfcsj){  
2145 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2146 - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");  
2147 - Long date1=0L;  
2148 - Long date2=0L;  
2149 - Calendar cal = Calendar.getInstance();  
2150 - List<ArrivalInfo> list=null;  
2151 - try {  
2152 - Date dates1 = simpleDateFormat.parse(date+" "+minfcsj+":01");  
2153 - String d1=date+" "+minfcsj+":01";  
2154 -// Date dates2=simpleDateFormat.parse(date+" 23:59:59");  
2155 - date1=dates1.getTime();  
2156 -  
2157 - cal.setTime(dates1);  
2158 - int weeks_year1 = cal.get(Calendar.WEEK_OF_YEAR);  
2159 - cal.add(cal.DATE,1);//把日期往后增加一天.整数往后推,负数往前移动  
2160 - int weeks_year2 = cal.get(Calendar.WEEK_OF_YEAR);  
2161 - Date dates2=cal.getTime();  
2162 - date2=dates2.getTime();  
2163 - String d2=simpleDateFormat.format(dates2);  
2164 -  
2165 - Connection conn = null;  
2166 - PreparedStatement ps = null;  
2167 - ResultSet rs = null;  
2168 - String year=date.substring(0,4);  
2169 - String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year=? AND line_id=? "  
2170 - + " AND up_down=? AND ts >= ? AND ts <=? order by device_id,ts";  
2171 - try{  
2172 - conn = DBUtils_MS.getConnection();  
2173 - ps = conn.prepareStatement(sql);  
2174 - ps.setInt(1, weeks_year1);  
2175 - ps.setString(2, line);  
2176 - ps.setInt(3, zd);  
2177 - ps.setLong(4, date1);  
2178 - ps.setLong(5, date2);  
2179 - rs = ps.executeQuery();  
2180 -  
2181 - list = resultSet2Set(rs);  
2182 - }catch(Exception e){  
2183 - logger.error("", e);  
2184 - }finally {  
2185 - DBUtils_MS.close(rs, ps, conn);  
2186 - }  
2187 -  
2188 - } catch (ParseException e1) {  
2189 - // TODO Auto-generated catch block  
2190 - e1.printStackTrace();  
2191 - }  
2192 - return list;  
2193 -  
2194 - }  
2195 -  
2196 - public List<ArrivalInfo> load3(String line, String date, int zd){  
2197 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2198 - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");  
2199 - Long date1=0L;  
2200 - Long date2=0L;  
2201 - Calendar cal = Calendar.getInstance();  
2202 - try {  
2203 - Date dates1 = simpleDateFormat.parse(date+" 00:00:01");  
2204 - Date dates2=simpleDateFormat.parse(date+" 23:59:59");  
2205 - date1=dates1.getTime();  
2206 - date2=dates2.getTime();  
2207 - cal.setTime(dates1);  
2208 - } catch (ParseException e1) {  
2209 - // TODO Auto-generated catch block  
2210 - e1.printStackTrace();  
2211 - }  
2212 - //周数,表分区字段  
2213 - int weeks_year1 = cal.get(Calendar.WEEK_OF_YEAR);  
2214 - List<ArrivalInfo> list = null;  
2215 - Connection conn = null;  
2216 - PreparedStatement ps = null;  
2217 - ResultSet rs = null;  
2218 - String year=date.substring(0,4);  
2219 - String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year=? AND line_id=? "  
2220 - + " AND up_down=? AND ts >= ? AND ts <=? order by device_id,ts";  
2221 - try{  
2222 - conn = DBUtils_MS.getConnection();  
2223 - ps = conn.prepareStatement(sql);  
2224 - ps.setInt(1, weeks_year1);  
2225 - ps.setString(2, line);  
2226 - ps.setInt(3, zd);  
2227 - ps.setLong(4, date1);  
2228 - ps.setLong(5, date2);  
2229 - rs = ps.executeQuery();  
2230 -  
2231 - list = resultSet2Set(rs);  
2232 - }catch(Exception e){  
2233 - logger.error("", e);  
2234 - }finally {  
2235 - DBUtils_MS.close(rs, ps, conn);  
2236 - }  
2237 - return list;  
2238 - }  
2239 -  
2240 - //根据排班查到离站  
2241 - @Override  
2242 - public List<Map<String, Object>> queryInOutStrtion(String line, String date, int zd,String lzsj) {  
2243 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2244 - //查询线路所有的站点  
2245 - List<ArrivalInfo> arrInfoList=this.load3(line, date, zd);  
2246 - List<StationRoute> listStation= stationRouteRepository.findByLine(line,zd);  
2247 - List<Map<String, Object>> inoutList=new ArrayList<Map<String,Object>>();  
2248 - //保存的所以的站点信息  
2249 - Map<String, Object> map1=new HashMap<String,Object>();  
2250 - map1.put("bc", "");  
2251 - map1.put("nbbm", "");  
2252 -  
2253 - //所有的班次信息(实际排班排序)  
2254 - List<ScheduleRealInfo> realList= scheduleRealInfoRepository.scheduleByDateAndLineInOut(line, date,zd+"");  
2255 - for (int i = 0; i < listStation.size(); i++) {  
2256 - map1.put(listStation.get(i).getStationCode()+"in"  
2257 - , listStation.get(i).getStationName());  
2258 - map1.put(listStation.get(i).getStationCode()+"out"  
2259 - , (i+1));  
2260 - }  
2261 - inoutList.add(map1);  
2262 -  
2263 - for (int i = 0; i < realList.size(); i++) {  
2264 - ScheduleRealInfo sinfo=realList.get(i);  
2265 - String devuceId=BasicData.deviceId2NbbmMap.inverse().get(sinfo.getClZbh());  
2266 - String sjfcsj=sinfo.getRealExecDate()+" "+sinfo.getFcsjActual()+":00";  
2267 - String sjddsj=sinfo.getRealExecDate()+" "+sinfo.getZdsjActual()+":59";  
2268 -  
2269 - try {  
2270 - Date dates1 = simpleDateFormat.parse(sjfcsj);  
2271 - Date dates2=simpleDateFormat.parse(sjddsj);  
2272 - Long date1=dates1.getTime();  
2273 - Long date2=dates2.getTime();  
2274 - List<ArrivalInfo> arrList=new ArrayList<ArrivalInfo>();  
2275 - for (int j = 0; j < arrInfoList.size(); j++) {  
2276 - ArrivalInfo a=arrInfoList.get(j);  
2277 - if(a.getDeviceId().equals(devuceId) && a.getTs()>=date1 && a.getTs()<=date2){  
2278 - arrList.add(a);  
2279 - }  
2280 - }  
2281 -  
2282 - Map<String, Object> map2=new HashMap<String,Object>();  
2283 - map2.put("bc", (i+1));  
2284 - map2.put("nbbm", sinfo.getClZbh());  
2285 -  
2286 - for (int j = 0; j < listStation.size(); j++) {  
2287 - StationRoute s=listStation.get(j);  
2288 - List<ArrivalInfo> arrivalList=new ArrayList<ArrivalInfo>();  
2289 - for (int j2 = 0; j2 < arrList.size(); j2++) {  
2290 - ArrivalInfo a=arrList.get(j2);  
2291 - if(s.getStationCode().equals(a.getStopNo())){  
2292 - arrivalList.add(a);  
2293 - }  
2294 - }  
2295 - Map<String, String> m=this.strInOut(arrivalList,lzsj);  
2296 -  
2297 - map2.put(s.getStationCode()+"in", m.get("in"));  
2298 - map2.put(s.getStationCode()+"out", m.get("out"));  
2299 - map2.put(s.getStationCode(), m.get("type"));  
2300 - }  
2301 - inoutList.add(map2);  
2302 - } catch (ParseException e) {  
2303 - // TODO Auto-generated catch block  
2304 - e.printStackTrace();  
2305 - }  
2306 - }  
2307 - return inoutList;  
2308 - }  
2309 -  
2310 - //根据GPS查到离站  
2311 - @Override  
2312 - public List<Map<String, Object>> queryInOutStrtions(String line, String date, int zd,String lzsj) {  
2313 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
2314 - String minfcsj="02:00";  
2315 - List<Line> lineList=lineRepository.findLineByCode(line);  
2316 - if(lineList.size()>0){  
2317 - List<String> objList = new ArrayList<String>();  
2318 - objList.add(lineList.get(0).getId() + "");  
2319 - String sqlMinYysj="select start_opt from bsth_c_line_config where "  
2320 - + " id = ("  
2321 - + "select max(id) from bsth_c_line_config where line = ?"  
2322 - + ")";  
2323 - minfcsj= jdbcTemplate.queryForObject(sqlMinYysj, objList.toArray(), String.class);  
2324 - }  
2325 - List<ArrivalInfo> arrInfoList=this.load4(line, date, zd,minfcsj);  
2326 -  
2327 - //查询线路所有的站点  
2328 - List<StationRoute> listStation= stationRouteRepository.findByLine(line,zd);  
2329 - List<Map<String, Object>> inoutList=new ArrayList<Map<String,Object>>();  
2330 - //保存的所以的站点信息  
2331 - Map<String, Object> map1=new HashMap<String,Object>();  
2332 - map1.put("bc", "");  
2333 - map1.put("nbbm", "");  
2334 -  
2335 - for (int i = 0; i < listStation.size(); i++) {  
2336 - map1.put(listStation.get(i).getStationCode()+"in"  
2337 - , listStation.get(i).getStationName());  
2338 - map1.put(listStation.get(i).getStationCode()+"out"  
2339 - , (i+1));  
2340 - }  
2341 - inoutList.add(map1);  
2342 - List<String> list_nbbm=new ArrayList<String>();  
2343 - Map<String, Object> m=new HashMap<String,Object>();  
2344 - for (int i = 0; i < arrInfoList.size(); i++) {  
2345 - arrInfoList.get(i).setRoute(-1);  
2346 - for (int j = 0; j < listStation.size(); j++) {  
2347 - if(arrInfoList.get(i).getStopNo().equals(listStation.get(j).getStationCode())){  
2348 - arrInfoList.get(i).setRoute(listStation.get(j).getStationRouteCode());  
2349 -  
2350 - }  
2351 - }  
2352 - if(m.get(arrInfoList.get(i).getDeviceId())==null){  
2353 - m.put(arrInfoList.get(i).getDeviceId(), arrInfoList.get(i).getDeviceId());  
2354 - list_nbbm.add(arrInfoList.get(i).getDeviceId());  
2355 - }  
2356 - }  
2357 -  
2358 - Map<String, Object> map2=new HashMap<String, Object>();  
2359 - for (int i = 0; i < list_nbbm.size(); i++) {  
2360 - String nbbm=list_nbbm.get(i);  
2361 -  
2362 - int zdbm =0;  
2363 - int inout=-1;  
2364 - List<ArrivalInfo> arrivalList=new ArrayList<ArrivalInfo>();  
2365 - for (int j = 0; j < arrInfoList.size(); j++) {  
2366 - ArrivalInfo aif=arrInfoList.get(j);  
2367 -  
2368 - if(aif.getDeviceId().equals(nbbm)){  
2369 - map2.put("nbbm", BasicData.deviceId2NbbmMap.get(nbbm));  
2370 - if(aif.getRoute()>-1){  
2371 - if(((inout==aif.getInOut() && zdbm==aif.getRoute()) || !(zdbm ==aif.getRoute()))){  
2372 - if(aif.getRoute()<=zdbm ){  
2373 - inoutList.add(map2);  
2374 - map2=new HashMap<String, Object>();  
2375 - arrivalList=new ArrayList<ArrivalInfo>();  
2376 - }  
2377 - }  
2378 - arrivalList.add(aif);  
2379 -// if(!(zdbm ==aif.getRoute())){  
2380 - Map<String, String> m_=this.strInOut(arrivalList,lzsj);  
2381 - map2.put(aif.getStopNo()+"in", m_.get("in"));  
2382 - map2.put(aif.getStopNo()+"out", m_.get("out"));  
2383 - map2.put(aif.getStopNo(), m_.get("type"));  
2384 -// arrivalList=new ArrayList<ArrivalInfo>();  
2385 -// }  
2386 - zdbm =aif.getRoute();  
2387 - inout=aif.getInOut();  
2388 -  
2389 - }  
2390 -  
2391 - }  
2392 -  
2393 - }  
2394 - }  
2395 -  
2396 - return inoutList;  
2397 - }  
2398 -  
2399 - public Map<String, String> strInOut(List<ArrivalInfo> lists,String lzsj){  
2400 - String inout="";  
2401 - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");  
2402 - Long in=0L;  
2403 - Long out=0L;  
2404 - for(int i=0;i<lists.size();i++){  
2405 - ArrivalInfo t1=lists.get(i);  
2406 - if(t1.getInOut()==0){  
2407 - in=t1.getTs();  
2408 - t1.setJzsj(sdf.format(new Date(t1.getTs())));  
2409 - for(int j=0;j<lists.size();j++){  
2410 - ArrivalInfo t2=lists.get(j);  
2411 - if(t2.getInOut()==1 && t2.getDeviceId().equals(t1.getDeviceId())  
2412 - && t2.getStopNo().equals(t1.getStopNo())  
2413 - && t2.getTs()>t1.getTs()){  
2414 - t1.setCzsj(sdf.format(new Date(t2.getTs())));  
2415 - out =t2.getTs();  
2416 - break;  
2417 - }else{  
2418 - t1.setCzsj("");  
2419 - out =0l;  
2420 - }  
2421 - }  
2422 -  
2423 - }else{  
2424 - out =t1.getTs();  
2425 - t1.setCzsj(sdf.format(new Date(t1.getTs())));  
2426 - for(int j=0;j<lists.size();j++){  
2427 - ArrivalInfo t2=lists.get(j);  
2428 - if(t2.getInOut()==0 && t2.getDeviceId().equals(t1.getDeviceId())  
2429 - && t2.getStopNo().equals(t1.getStopNo())  
2430 - && t2.getTs()>t1.getTs()){  
2431 - in =t2.getTs();  
2432 - t1.setJzsj(sdf.format(new Date(t2.getTs())));  
2433 - break;  
2434 - }  
2435 - }  
2436 - }  
2437 - }  
2438 -  
2439 - Map<String, String> map=new HashMap<String,String>();  
2440 - if(in>0 ){  
2441 - map.put("in",sdf.format(new Date(in)));  
2442 -  
2443 - }else{  
2444 - map.put("in", "");  
2445 - }  
2446 - if(out>0){  
2447 - map.put("out", sdf.format(new Date(out)));  
2448 - }else{  
2449 - map.put("out", "");  
2450 - }  
2451 - Long sj=1000000000L;  
2452 - if(!lzsj.trim().equals("")){  
2453 - sj =Long.parseLong(lzsj);  
2454 - }  
2455 - if(in>0 && out >0){  
2456 - if((out-in)/1000>sj){  
2457 - map.put("type", "y");  
2458 - }else{  
2459 - map.put("type", "n");  
2460 - }  
2461 - }  
2462 - return map;  
2463 - }  
2464 - @Override  
2465 - public List<StationRoute> queryStrinon(String line, int zd) {  
2466 - // TODO Auto-generated method stub  
2467 - List<StationRoute> listStation= stationRouteRepository.findByLine(line,zd);  
2468 - return listStation;  
2469 - }  
2470 -  
2471 - @Override  
2472 - public List<Map<String, Object>> countMileageSum(Map<String, Object> map) {  
2473 - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();  
2474 -  
2475 - String date="", date2="";  
2476 - if(map.get("date")!=null){  
2477 - date=map.get("date").toString();  
2478 - }  
2479 - if(map.get("date2")!=null){  
2480 - date2=map.get("date2").toString();  
2481 - }  
2482 - String nature="0";  
2483 - if(map.get("nature")!=null){  
2484 - nature=map.get("nature").toString();  
2485 - }  
2486 - String type="";  
2487 - if(map.get("type")!=null){  
2488 - type=map.get("type").toString();  
2489 - }  
2490 -  
2491 - List<Map<String, Object>> listAll = calcWaybillService.getLineMileage("", "", "", date, date2, "", "", "", "query");  
2492 - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();  
2493 - Map<String, Boolean> lineMap=lineService.lineNature();  
2494 - if(nature.equals("0")){  
2495 - list=listAll;  
2496 - }else{  
2497 - for (Map<String, Object> m : listAll) {  
2498 - if(m.get("xl") != null && m.get("xl").toString().trim().length() > 0){  
2499 - String xl = m.get("xl").toString();  
2500 - if(nature.equals("1")){  
2501 - if(lineMap.containsKey(xl) && lineMap.get(xl)){  
2502 - list.add(m);  
2503 - }  
2504 - }else{  
2505 - if(!(lineMap.containsKey(xl) && lineMap.get(xl))){  
2506 - list.add(m);  
2507 - }  
2508 - }  
2509 - }  
2510 - }  
2511 - }  
2512 -  
2513 - List<Business> allBusiness = businessRepository.getOrder();  
2514 - Set<String> gsFgsSet = new HashSet<String>(); // 有排序编号的公司,防止乱序或者合计值出问题。  
2515 - for(Business b : allBusiness){  
2516 - gsFgsSet.add(b.getUpCode() + "_" + b.getBusinessCode());  
2517 - gsFgsSet.add(b.getBusinessCode());  
2518 - }  
2519 -  
2520 - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>();  
2521 - List<String> keyList = new ArrayList<String>();  
2522 -  
2523 - Map<String, Object> hj = new HashMap<String, Object>(); // 合计  
2524 - hj.put("gsName", "合计");  
2525 - hj.put("fgsBm", " ");  
2526 -  
2527 - for(Map<String, Object> m : list){  
2528 - m.put("gsBm", m.get("gsdm"));  
2529 - m.put("fgsBm", m.get("fgsdm"));  
2530 - if(m.get("gsBm") != null && m.get("fgsBm") != null  
2531 - && m.get("gsBm").toString().trim().length() > 0  
2532 - && m.get("fgsBm").toString().trim().length() > 0){  
2533 - String gsBm = m.get("gsBm").toString().trim();  
2534 - String fgsBm = m.get("fgsBm").toString().trim();  
2535 - String key = gsBm + "_" + fgsBm; // 分公司key  
2536 - String key2 = gsBm + "_sum"; // 直属公司key  
2537 - if(!gsFgsSet.contains(key) && !gsFgsSet.contains(gsBm)){  
2538 - continue;  
2539 - }  
2540 - if(!keyMap.containsKey(key)){ // 每个分公司一条  
2541 - Map<String, Object> t = new HashMap<String, Object>();  
2542 - t.put("gsName", m.get("gs"));  
2543 - t.put("fgsName", m.get("fgs"));  
2544 - t.put("key", key);  
2545 - keyMap.put(key, t);  
2546 - keyList.add(key);  
2547 - if(!keyMap.containsKey(key2)){ // 直属公司小计  
2548 - Map<String, Object> t2 = new HashMap<String, Object>();  
2549 - t2.put("gsName", m.get("gs"));  
2550 - t2.put("fgsName", "小计");  
2551 - t2.put("key", key2);  
2552 - keyMap.put(key2, t2);  
2553 - keyList.add(key2);  
2554 - }  
2555 - }  
2556 - Map<String, Object> t = keyMap.get(key);  
2557 - Map<String, Object> t2 = keyMap.get(key2);  
2558 - for(String s : m.keySet()){  
2559 - if("gsName,fgsName,key".contains(s)){  
2560 - continue;  
2561 - }  
2562 - try {  
2563 - if(t.containsKey(s)){ // 分公司  
2564 - t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));  
2565 - } else {  
2566 - t.put(s, m.get(s).toString());  
2567 - }  
2568 - if(t2.containsKey(s)){ // 直属公司  
2569 - t2.put(s, new BigDecimal(t2.get(s).toString()).add(new BigDecimal(m.get(s).toString())));  
2570 - } else {  
2571 - t2.put(s, m.get(s).toString());  
2572 - }  
2573 - if(hj.containsKey(s)){ // 合计  
2574 - hj.put(s, new BigDecimal(hj.get(s).toString()).add(new BigDecimal(m.get(s).toString())));  
2575 - } else {  
2576 - hj.put(s, m.get(s).toString());  
2577 - }  
2578 - } catch (Exception e) {  
2579 - // TODO: handle exception  
2580 - continue;  
2581 - }  
2582 - }  
2583 - }  
2584 - }  
2585 -  
2586 - for(Business b : allBusiness){ // 根据公司排序插入返回对象  
2587 - String gs = b.getBusinessCode();  
2588 - String gsfgs = b.getUpCode() + "_" + b.getBusinessCode();  
2589 - for(String key : keyList){  
2590 - if(key.equals(gsfgs)){  
2591 - resList.add(keyMap.get(key));  
2592 - break;  
2593 - } else if(key.replaceAll("_sum", "").equals(gs)){  
2594 - resList.add(keyMap.get(key));  
2595 - break;  
2596 - }  
2597 - }  
2598 - }  
2599 - resList.add(hj);  
2600 -  
2601 - if(type.equals("export")){  
2602 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
2603 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
2604 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
2605 - Map<String, Object> m = new HashMap<String, Object>();  
2606 - String xls="countMileageSum.xls";  
2607 - ReportUtils ee = new ReportUtils();  
2608 - try {  
2609 - String dateTime = "";  
2610 - if(date.equals(date2)){  
2611 - m.put("date", date);  
2612 - dateTime = sdfSimple.format(sdfMonth.parse(date));  
2613 - } else {  
2614 - m.put("date", date + "至" + date2);  
2615 - dateTime = sdfSimple.format(sdfMonth.parse(date))  
2616 - +"-"+sdfSimple.format(sdfMonth.parse(date2));  
2617 - }  
2618 - listI.add(resList.iterator());  
2619 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
2620 - ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls,  
2621 - path + "export/"+dateTime+"-审计公里汇总表.xls");  
2622 - } catch (Exception e) {  
2623 - // TODO: handle exception  
2624 - e.printStackTrace();  
2625 - }  
2626 - }  
2627 -  
2628 - return resList;  
2629 - }  
2630 -  
2631 - @Override  
2632 - public List<Map<String, Object>> countByList(Map<String, Object> map) {  
2633 - // TODO Auto-generated method stub  
2634 -  
2635 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
2636 - String gsdm="";  
2637 - if(map.get("gsdm")!=null){  
2638 - gsdm=map.get("gsdm").toString();  
2639 - }  
2640 - String fgsdm="";  
2641 - if(map.get("fgsdm")!=null){  
2642 - fgsdm=map.get("fgsdm").toString();  
2643 - }  
2644 - String line="";  
2645 - if(map.get("line")!=null){  
2646 - line=map.get("line").toString();  
2647 - }  
2648 - String date="";  
2649 - if(map.get("date")!=null){  
2650 - date=map.get("date").toString();  
2651 - }  
2652 - String date2="";  
2653 - if(map.get("date2")!=null){  
2654 - date2=map.get("date2").toString();  
2655 - }  
2656 - String xlName="";  
2657 - if(map.get("xlName")!=null){  
2658 - xlName=map.get("xlName").toString();  
2659 - }  
2660 - String nature="0";  
2661 - if(map.get("nature")!=null){  
2662 - nature=map.get("nature").toString();  
2663 - }  
2664 - String type="";  
2665 - if(map.get("type")!=null){  
2666 - type=map.get("type").toString();  
2667 - }  
2668 - //所有班次信息  
2669 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
2670 - line =line.trim();  
2671 - if(gsdm.equals("") && fgsdm.equals("") && line.equals("")){  
2672 - list = scheduleRealInfoRepository.scheduleByDateAndLineTj3(date, date2);  
2673 - } else if(line.equals("")){  
2674 - //查询所有线路  
2675 - list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date,date2,gsdm,fgsdm);  
2676 - }else{  
2677 - //查询单条线路  
2678 - list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date,date2);  
2679 - }  
2680 -  
2681 - Map<String, Boolean> lineMap = lineService.lineNature();  
2682 -  
2683 - List<String> objList = new ArrayList<String>();  
2684 - String sql="select r.xl_bm"  
2685 - + " from bsth_c_s_sp_info_real r where"  
2686 - + " r.schedule_date_str BETWEEN ? and ?";  
2687 - objList.add(date);  
2688 - objList.add(date2);  
2689 - if("".equals(gsdm.trim()) && "".equals(fgsdm.trim()) && "".equals(line.trim())){  
2690 -  
2691 - } else if(line.equals("")){  
2692 - sql +=" and r.gs_bm=?"  
2693 - + " and r.fgs_bm like CONCAT('%',?,'%')";  
2694 - objList.add(gsdm);  
2695 - objList.add(fgsdm);  
2696 - }else{  
2697 - sql += " and r.xl_bm = ?";  
2698 - objList.add(line);  
2699 - }  
2700 - sql += " group by r.xl_bm";  
2701 -  
2702 - List<String> listLine=jdbcTemplate.query(sql, objList.toArray(), new RowMapper<String>() {  
2703 - @Override  
2704 - public String mapRow(ResultSet arg0, int arg1) throws SQLException {  
2705 - String ve = arg0.getString("xl_bm");  
2706 - return ve;  
2707 - }  
2708 - });  
2709 - for (int i = 0; i < listLine.size(); i++) {  
2710 - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();  
2711 - String lineStr=listLine.get(i);  
2712 - if("0".equals(nature)){ // 全部  
2713 -  
2714 - } else if("1".equals(nature)){ // 营运  
2715 - if(!(lineMap.containsKey(lineStr) && lineMap.get(lineStr))){  
2716 - continue;  
2717 - }  
2718 - } else { // 非营运  
2719 - if(lineMap.containsKey(lineStr) && lineMap.get(lineStr)){  
2720 - continue;  
2721 - }  
2722 - }  
2723 -  
2724 - for (int j = 0; j < list.size(); j++) {  
2725 - ScheduleRealInfo s=list.get(j);  
2726 - if(s.getXlBm().equals(lineStr)){  
2727 - lists.add(s);  
2728 - }  
2729 - }  
2730 -  
2731 - //计算线路的各项公里  
2732 - if(lists.size()>0){  
2733 - Map<String, Object> newMap=staticTj(lists,"z");  
2734 - lMap.add(newMap);  
2735 - }  
2736 - }  
2737 - if(list.size()>0){  
2738 - Map<String, Object> newMap=staticTj(list,"f");  
2739 - lMap.add(newMap);  
2740 - }  
2741 - if(type.equals("export")){  
2742 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
2743 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
2744 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
2745 - Map<String, Object> m = new HashMap<String, Object>();  
2746 - m.put("date", date);  
2747 - m.put("date1", date2);  
2748 - String by=map.get("by").toString();  
2749 - String xls="";  
2750 - if(by.equals("sj")){  
2751 - xls="countByLine.xls";  
2752 - }else{  
2753 - xls="countByLines.xls";  
2754 - }  
2755 - ReportUtils ee = new ReportUtils();  
2756 - try {  
2757 - String dateTime = "";  
2758 - if(date.equals(date2)){  
2759 - dateTime = sdfSimple.format(sdfMonth.parse(date));  
2760 - } else {  
2761 - dateTime = sdfSimple.format(sdfMonth.parse(date))  
2762 - +"-"+sdfSimple.format(sdfMonth.parse(date2));  
2763 - }  
2764 - listI.add(lMap.iterator());  
2765 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
2766 - ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls,  
2767 - path + "export/"+dateTime+"-"+xlName+"-线路公里统计表.xls");  
2768 - } catch (Exception e) {  
2769 - // TODO: handle exception  
2770 - e.printStackTrace();  
2771 - }  
2772 - }  
2773 - return lMap;  
2774 - }  
2775 -  
2776 -  
2777 - @Override  
2778 - public List<Map<String, Object>> countByList2(Map<String, Object> map) {  
2779 - // TODO Auto-generated method stub  
2780 -  
2781 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
2782 - String gsdm="";  
2783 - if(map.get("gsdm")!=null){  
2784 - gsdm=map.get("gsdm").toString();  
2785 - }  
2786 - String fgsdm="";  
2787 - if(map.get("fgsdm")!=null){  
2788 - fgsdm=map.get("fgsdm").toString();  
2789 - }  
2790 - String line="";  
2791 - if(map.get("line")!=null){  
2792 - line=map.get("line").toString();  
2793 - }  
2794 - String date="";  
2795 - if(map.get("date")!=null){  
2796 - date=map.get("date").toString();  
2797 - }  
2798 - String date2="";  
2799 - if(map.get("date2")!=null){  
2800 - date2=map.get("date2").toString();  
2801 - }  
2802 - String xlName="";  
2803 - if(map.get("xlName")!=null){  
2804 - xlName=map.get("xlName").toString();  
2805 - }  
2806 - String type="";  
2807 - if(map.get("type")!=null){  
2808 - type=map.get("type").toString();  
2809 - }  
2810 - //所有班次信息  
2811 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
2812 - line = line.trim();  
2813 -  
2814 - List<String> objList = new ArrayList<String>();  
2815 - objList.add(date);  
2816 - objList.add(date2);  
2817 - String sql="select r.xl_bm"  
2818 - + " from bsth_c_s_sp_info_real r where"  
2819 - + " r.schedule_date_str >= ? and r.schedule_date_str >= ?";  
2820 -  
2821 -  
2822 - if(line.equals("")){  
2823 - sql +=" and r.gs_bm = ?"  
2824 - + " and r.fgs_bm = ?";  
2825 - objList.add(gsdm);  
2826 - objList.add(fgsdm);  
2827 - }else{  
2828 - sql += " and r.xl_bm = ?";  
2829 - objList.add(line);  
2830 - }  
2831 - sql += " group by r.xl_bm";  
2832 -  
2833 - List<String> listLine=jdbcTemplate.query(sql, objList.toArray(), new RowMapper<String>() {  
2834 - @Override  
2835 - public String mapRow(ResultSet arg0, int arg1) throws SQLException {  
2836 - String ve = arg0.getString("xl_bm");  
2837 - return ve;  
2838 - }  
2839 - });  
2840 - for (int i = 0; i < listLine.size(); i++) {  
2841 - List<ScheduleRealInfo> lists =scheduleRealInfoRepository.scheduleByDateAndLineTj2(listLine.get(i), date,date2);  
2842 - list.addAll(lists);  
2843 - //计算线路的各项公里  
2844 - if(lists.size()>0){  
2845 - Map<String, Object> newMap=staticTj(lists,"z");  
2846 - lMap.add(newMap);  
2847 - }  
2848 - }  
2849 - if(list.size()>0){  
2850 - Map<String, Object> newMap=staticTj(list,"f");  
2851 - lMap.add(newMap);  
2852 - }  
2853 - if(type.equals("export")){  
2854 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
2855 - Map<String, Object> m = new HashMap<String, Object>();  
2856 - m.put("date", date);  
2857 - m.put("date1", date2);  
2858 - String by=map.get("by").toString();  
2859 - String xls="";  
2860 - if(by.equals("sj")){  
2861 - xls="countByLine.xls";  
2862 - }else{  
2863 - xls="countByLines.xls";  
2864 - }  
2865 - ReportUtils ee = new ReportUtils();  
2866 - try {  
2867 - listI.add(lMap.iterator());  
2868 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
2869 - ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls,  
2870 - path + "export/线路公里统计表.xls");  
2871 - } catch (Exception e) {  
2872 - // TODO: handle exception  
2873 - e.printStackTrace();  
2874 - }  
2875 - }  
2876 - return lMap;  
2877 - }  
2878 -  
2879 - public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,String status){  
2880 -  
2881 - List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>();  
2882 - for(int i=0;i<list.size();i++){  
2883 - ScheduleRealInfo s=list.get(i);  
2884 - Set<ChildTaskPlan> cts = s.getcTasks();  
2885 - if(cts != null && cts.size() > 0){  
2886 - lists.add(s);  
2887 - }else{  
2888 - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){  
2889 - lists.add(s);  
2890 - }  
2891 - }  
2892 - }  
2893 - Map<String, Object> map = new HashMap<String, Object>();  
2894 - if(list.size()>0){  
2895 - if(status.equals("f")){  
2896 - map.put("xlName","合计");  
2897 - map.put("gs", "");  
2898 - map.put("fgs", "");  
2899 - }else{  
2900 - map.put("xlName", list.get(0).getXlName());  
2901 - map.put("xlBm", list.get(0).getXlBm());  
2902 - map.put("gsBm", list.get(0).getGsBm());  
2903 - map.put("fgsBm", list.get(0).getFgsBm());  
2904 - map.put("gs", list.get(0).getGsName());  
2905 - map.put("fgs", list.get(0).getFgsName());  
2906 - map.put("jGh", list.get(0).getjGh());  
2907 - map.put("sGh", list.get(0).getsGh()==null?"":list.get(0).getsGh());  
2908 - map.put("nbbm",list.get(0).getClZbh());  
2909 - map.put("line", list.get(0).getXlBm());  
2910 - }  
2911 -  
2912 - double jhyygl=culateService.culateJhgl(list);//计划营运公里  
2913 - double jhjcclc= culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)  
2914 - map.put("jhlc", jhyygl);  
2915 - map.put("jcclc", jhjcclc);  
2916 - map.put("jhzlc", Arith.add(jhyygl, jhjcclc));//计划总里程  
2917 -  
2918 - //计划内外营运  
2919 - Map<String, Double> culateSjlcMap=culateService.culateSjlcMap(lists);  
2920 - double jhnlc=culateSjlcMap.get("jhnlc");  
2921 - double jhwlc=culateSjlcMap.get("jhwlc");  
2922 - map.put("jhnlc", jhnlc);  
2923 - map.put("jhwlc", jhwlc);  
2924 - double zyylc=Arith.add(jhnlc, jhwlc);  
2925 -  
2926 - //计划内外进出场  
2927 - Map<String, Double> culateSjJcclcMap=culateService.culateSjJcclcMap(lists);  
2928 - double jhwjcclc=culateSjJcclcMap.get("jhwlc");  
2929 - double jhnjcclc=culateSjJcclcMap.get("jhnlc");  
2930 - map.put("jhwjcclc", jhwjcclc);  
2931 - map.put("jhnjcclc", jhnjcclc);  
2932 - double zjcclc=Arith.add(jhwjcclc, jhnjcclc);  
2933 -  
2934 - //临加公里  
2935 - Map<String, Double> culateLjMile=culateService.culateLjMile(lists);  
2936 - double ljyy=culateLjMile.get("ljyy");  
2937 - double ljjcc=culateLjMile.get("ljjcc");  
2938 - double ljkfks=culateLjMile.get("ljkfks");  
2939 - map.put("ljyy", ljyy);  
2940 - map.put("ljjcc", ljjcc);  
2941 - map.put("ljkfks", ljkfks);  
2942 -  
2943 - double ljlc=Arith.add(Arith.add(ljyy, ljjcc),ljkfks);  
2944 -  
2945 - double lbss=culateService.culateSsMile(list);//烂班少驶  
2946 - map.put("lbss", lbss);  
2947 - map.put("ssgl_lz", culateService.culateSsMileXx(list, "路阻"));  
2948 - map.put("ssgl_dm", culateService.culateSsMileXx(list, "吊慢"));  
2949 - map.put("ssgl_gz", culateService.culateSsMileXx(list, "故障"));  
2950 - map.put("ssgl_jf", culateService.culateSsMileXx(list, "纠纷"));  
2951 - map.put("ssgl_zs", culateService.culateSsMileXx(list, "肇事"));  
2952 - map.put("ssgl_qr", culateService.culateSsMileXx(list, "缺人"));  
2953 - map.put("ssgl_qc", culateService.culateSsMileXx(list, "缺车"));  
2954 - map.put("ssgl_kx", culateService.culateSsMileXx(list, "客稀"));  
2955 - map.put("ssgl_qh", culateService.culateSsMileXx(list, "气候"));  
2956 - map.put("ssgl_yw", culateService.culateSsMileXx(list, "援外"));  
2957 - map.put("ssgl_ljpm", culateService.culateSsMileXx(list, "路救抛锚"));  
2958 - map.put("ssgl_other", culateService.culateSsMileXx(list, "其他"));  
2959 -  
2960 -  
2961 - double zrwjcclc=culateService.culateZrwJccLc(list, "故障");  
2962 - double zrwjcclc1=culateService.culateZrwJccLc(list, "肇事");  
2963 - double zrwjcclc2=culateService.culateZrwJccLc(list, "纠纷");  
2964 - double zrwjcclcqt=Arith.add(culateService.culateZrwJccLc(list, "其他"),culateService.culateZrwJccLc(list, ""));  
2965 - map.put("jhwjcclc_z", Arith.add(jhwjcclc,zrwjcclcqt));  
2966 - map.put("zrwjcclc", zrwjcclc);  
2967 - map.put("zrwjcclc1", zrwjcclc1);  
2968 - map.put("zrwjcclc2", zrwjcclc2);  
2969 - map.put("zrwjcclcqt", zrwjcclcqt);  
2970 - double zrwjcc=Arith.add(Arith.add(Arith.add(zrwjcclc, zrwjcclc1), zrwjcclc2),zrwjcclcqt);  
2971 - double kfks=culateService.culateKfksLc(lists);  
2972 - map.put("kfks", kfks);  
2973 - double zlc=Arith.add(Arith.add(Arith.add(zrwjcc, ljlc),  
2974 - Arith.add(zjcclc, zyylc)),kfks);  
2975 - map.put("zlc", zlc);  
2976 -  
2977 - //备用  
2978 - double ljgl= culateService.culateLjgl(lists);  
2979 - double sjyygl= culateService.culateSjgl(lists);  
2980 - double zyygl= Arith.add(sjyygl,ljgl);  
2981 -  
2982 - double sjjccgl=culateService.culateJccgl(lists);  
2983 - double sjksgl=culateService.culateKsgl(lists);  
2984 - double zksgl=Arith.add(sjjccgl, sjksgl);  
2985 - map.put("sjzgl", Arith.add(zyygl, zksgl));  
2986 - }  
2987 - return map;  
2988 - }  
2989 - @Override  
2990 - public List<Map<String, Object>> countByBusList(Map<String, Object> map) {  
2991 - // TODO Auto-generated method stub  
2992 - SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");  
2993 - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();  
2994 - List<Map<String, Object>> lMaps = new ArrayList<Map<String, Object>>();  
2995 - String gsdm="";  
2996 - if(map.get("gsdm")!=null){  
2997 - gsdm=map.get("gsdm").toString();  
2998 - }  
2999 - String fgsdm="";  
3000 - if(map.get("fgsdm")!=null){  
3001 - fgsdm=map.get("fgsdm").toString();  
3002 - }  
3003 - String line="";  
3004 - if(map.get("line")!=null){  
3005 - line=map.get("line").toString();  
3006 - }  
3007 - String date="";  
3008 - if(map.get("date")!=null){  
3009 - date=map.get("date").toString();  
3010 - }  
3011 - String date2="";  
3012 - if(map.get("date2")!=null){  
3013 - date2=map.get("date2").toString();  
3014 - }  
3015 - String xlName="";  
3016 - if(map.get("xlName")!=null){  
3017 - xlName=map.get("xlName").toString();  
3018 - }  
3019 - String zt="";  
3020 - if(map.get("zt")!=null){  
3021 - zt=map.get("zt").toString();  
3022 - }  
3023 - String type="";  
3024 - if(map.get("type")!=null){  
3025 - type=map.get("type").toString();  
3026 - }  
3027 - //所有班次信息  
3028 - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();  
3029 - line =line.trim();  
3030 - if(line.equals("")){  
3031 - //查询所有线路  
3032 - list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date,date2,gsdm,fgsdm);  
3033 - }else{  
3034 - //查询单条线路  
3035 - list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date,date2);  
3036 - }  
3037 -  
3038 - List<String> objList = new ArrayList<String>();  
3039 - objList.add(date);  
3040 - objList.add(date2);  
3041 - String ylbSql=" select * from bsth_c_ylb where rq BETWEEN ? and ?";  
3042 - if(line.equals("")){  
3043 - ylbSql +=" and ssgsdm = ?"  
3044 - + " and fgsdm = ?";  
3045 - objList.add(gsdm);  
3046 - objList.add(fgsdm);  
3047 - }else{  
3048 - ylbSql += " and xlbm = ?";  
3049 - objList.add(line);  
3050 - }  
3051 - List<Ylb> ylbList = ylbList(ylbSql, objList);  
3052 -  
3053 - List<String> objList2 = new ArrayList<String>();  
3054 - objList2.add(date);  
3055 - objList2.add(date2);  
3056 - String dlbSql=" select * from bsth_c_dlb where rq BETWEEN ? and ?";  
3057 - if(line.equals("")){  
3058 - dlbSql +=" and ssgsdm = ?"  
3059 - + " and fgsdm = ?";  
3060 - objList2.add(gsdm);  
3061 - objList2.add(fgsdm);  
3062 - }else{  
3063 - dlbSql += " and xlbm = ?";  
3064 - objList2.add(line);  
3065 - }  
3066 - List<Dlb> dlbList=dlbList(dlbSql, objList2);  
3067 - List<Map<String, Object>> listGroupBy =null;  
3068 - String sql="";  
3069 - if(zt.equals("zbh")){  
3070 - List<String> objList3 = new ArrayList<String>();  
3071 - objList3.add(date);  
3072 - objList3.add(date2);  
3073 - sql+="select r.xl_bm,r.cl_zbh"  
3074 - + " from bsth_c_s_sp_info_real r where"  
3075 - + " r.schedule_date_str BETWEEN ? and ?";  
3076 - if(line.equals("")){  
3077 - sql +=" and r.gs_bm = ?"  
3078 - + " and r.fgs_bm = ?";  
3079 - objList3.add(gsdm);  
3080 - objList3.add(fgsdm);  
3081 - }else{  
3082 - sql += " and r.xl_bm = ?";  
3083 - objList3.add(line);  
3084 - }  
3085 - sql += " group by r.xl_bm,r.cl_zbh";  
3086 - listGroupBy=jdbcTemplate.query(sql, objList3.toArray(), new RowMapper<Map<String, Object>>() {  
3087 - @Override  
3088 - public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {  
3089 - Map<String, Object> map=new HashMap<String,Object>();  
3090 - map.put("line",arg0.getString("xl_bm"));  
3091 - map.put("nbbm", arg0.getString("cl_zbh"));  
3092 - return map;  
3093 - }  
3094 - });  
3095 - }else{  
3096 - List<String> objList4 = new ArrayList<String>();  
3097 - objList4.add(date);  
3098 - objList4.add(date2);  
3099 - sql+="select r.xl_bm,r.cl_zbh,r.j_gh,r.s_gh"  
3100 - + " from bsth_c_s_sp_info_real r where"  
3101 - + " r.schedule_date_str BETWEEN ? and ?";  
3102 - if(line.equals("")){  
3103 - sql +=" and r.gs_bm = ? "  
3104 - + " and r.fgs_bm = ?";  
3105 - objList4.add(gsdm);  
3106 - objList4.add(fgsdm);  
3107 - }else{  
3108 - sql += " and r.xl_bm = ?";  
3109 - objList4.add(line);  
3110 - }  
3111 - sql += " group by r.xl_bm,r.cl_zbh,r.j_gh,r.s_gh";  
3112 - listGroupBy=jdbcTemplate.query(sql, objList4.toArray(), new RowMapper<Map<String, Object>>() {  
3113 - @Override  
3114 - public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {  
3115 - Map<String, Object> map=new HashMap<String,Object>();  
3116 - map.put("line",arg0.getString("xl_bm"));  
3117 - map.put("nbbm", arg0.getString("cl_zbh"));  
3118 - map.put("jGh", arg0.getString("j_gh"));  
3119 - map.put("sGh", arg0.getString("s_gh"));  
3120 -// map.put("jName", arg0.getString("j_name"));  
3121 -// map.put("sName", arg0.getString("s_name"));  
3122 - return map;  
3123 - }  
3124 - });  
3125 - }  
3126 -  
3127 -  
3128 - for (int i = 0; i < listGroupBy.size(); i++) {  
3129 - Map<String, Object> m=listGroupBy.get(i);  
3130 - String xl_bm=m.get("line")==null?"":m.get("line").toString();  
3131 - String nbbm =m.get("nbbm")==null?"":m.get("nbbm").toString();  
3132 - String jGh= m.get("jGh")==null?"":m.get("jGh").toString();  
3133 - String sGh= m.get("sGh")==null?"":m.get("sGh").toString();  
3134 - List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>();  
3135 - for (int j = 0; j < list.size(); j++) {  
3136 - ScheduleRealInfo s=list.get(j);  
3137 - if(zt.equals("zbh")){  
3138 - if(xl_bm.equals(s.getXlBm())  
3139 - && nbbm.equals(s.getClZbh())){  
3140 - lists.add(s);  
3141 - }  
3142 - }else{  
3143 - if(xl_bm.equals(s.getXlBm()) && nbbm.equals(s.getClZbh())  
3144 - && jGh.equals(s.getjGh()) && sGh.equals(s.getsGh())){  
3145 - lists.add(s);  
3146 -  
3147 - if((m.get("jName") == null || m.get("jName").toString().length() == 0)  
3148 - && s.getjName() != null && s.getjName().length() > 0){  
3149 - m.put("jName", s.getjName());  
3150 - }  
3151 - if((m.get("sName") == null || m.get("sName").toString().length() == 0)  
3152 - && s.getsName() != null && s.getsName().length() > 0){  
3153 - m.put("sName", s.getsName());  
3154 - }  
3155 - }  
3156 - }  
3157 - }  
3158 -  
3159 - if(zt.equals("zbh")){  
3160 - Map<String, Object> newMap=staticTj(lists, "");  
3161 - double yhl=0.0;  
3162 - double jzl=0.0;  
3163 - double hyl=0.0;  
3164 - double dhl=0.0;  
3165 - double cdl=0.0;  
3166 - for (int j = 0; j < ylbList.size(); j++) {  
3167 - Ylb y=ylbList.get(j);  
3168 - if(nbbm.equals(y.getNbbm()) && xl_bm.equals(y.getXlbm())){  
3169 - yhl=Arith.add(yhl, y.getYh());  
3170 - jzl=Arith.add(jzl, y.getJzl());  
3171 - hyl=Arith.add(hyl, y.getSh());  
3172 - }  
3173 -  
3174 - }  
3175 - for (int j = 0; j < dlbList.size(); j++) {  
3176 - Dlb d=dlbList.get(j);  
3177 - if(nbbm.equals(d.getNbbm())&&xl_bm.equals(d.getXlbm())){  
3178 - dhl=Arith.add(dhl, d.getHd());  
3179 - cdl=Arith.add(cdl, d.getCdl());  
3180 - }  
3181 - }  
3182 - if(date.equals(date2)){  
3183 - newMap.put("rq",date);  
3184 - }else{  
3185 - newMap.put("rq",date+"至"+date2);  
3186 - }  
3187 - newMap.put("yhl", yhl);  
3188 - newMap.put("jzl", jzl);  
3189 - newMap.put("hyl", hyl);  
3190 - newMap.put("dhl", dhl);  
3191 - newMap.put("cdl", cdl);  
3192 - lMap.add(newMap);  
3193 - }else{  
3194 - Map<String, Object> newMap=staticTj(lists, "");  
3195 - double lc=Double.parseDouble(newMap.get("zlc").toString());  
3196 - double yhl=0.0;  
3197 - double jzl=0.0;  
3198 - double hyl=0.0;  
3199 - double dhl=0.0;  
3200 - double cdl=0.0;  
3201 - double zlc=0.0;  
3202 - for (int j = 0; j < ylbList.size(); j++) {  
3203 - Ylb y=ylbList.get(j);  
3204 - if(nbbm.equals(y.getNbbm()) && xl_bm.equals(y.getXlbm())  
3205 - &&jGh.equals(y.getJsy())){  
3206 - yhl=Arith.add(yhl, y.getYh());  
3207 - jzl=Arith.add(jzl, y.getJzl());  
3208 - hyl=Arith.add(hyl, y.getSh());  
3209 - zlc=Arith.add(zlc, y.getZlc());  
3210 - }  
3211 -  
3212 - }  
3213 -  
3214 - for (int j = 0; j < dlbList.size(); j++) {  
3215 - Dlb d=dlbList.get(j);  
3216 - if(nbbm.equals(d.getNbbm())&&xl_bm.equals(d.getXlbm())  
3217 - &&jGh.equals(d.getJsy())){  
3218 - dhl=Arith.add(dhl, d.getHd());  
3219 - cdl=Arith.add(cdl, d.getCdl());  
3220 - zlc=Arith.add(zlc, d.getZlc());  
3221 - }  
3222 - }  
3223 - double div=0.0;  
3224 - if(lc>0){  
3225 - div=Arith.div(zlc, lc,2);  
3226 - }  
3227 - newMap.put("yhl", yhl*div);  
3228 - newMap.put("jzl", jzl*div);  
3229 - newMap.put("hyl", hyl*div);  
3230 - newMap.put("dhl", dhl*div);  
3231 - newMap.put("cdl", cdl*div);  
3232 - lMaps.add(newMap);  
3233 - }  
3234 -  
3235 - }  
3236 - if(!zt.equals("zbh")){  
3237 - lMap=lists(listGroupBy, lMaps, gsdm, fgsdm, date, date2);  
3238 - }  
3239 - if(type.equals("export")){  
3240 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
3241 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
3242 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
3243 - Map<String, Object> m = new HashMap<String, Object>();  
3244 - m.put("date", date);  
3245 - m.put("date1", date2);  
3246 - String xls="";  
3247 - String by=map.get("by").toString();  
3248 -  
3249 -  
3250 - if(zt.equals("zbh")){  
3251 - if(by.equals("sj")){  
3252 - xls="countByBus1.xls";  
3253 - }else{  
3254 - xls="countByBus1s.xls";  
3255 - }  
3256 - }else{  
3257 -  
3258 - if(by.equals("sj")){  
3259 - xls="countByBus2.xls";  
3260 - }else{  
3261 - xls="countByBus2s.xls";  
3262 - }  
3263 - }  
3264 - ReportUtils ee = new ReportUtils();  
3265 - try {  
3266 - String dateTime = "";  
3267 - if(date.equals(date2)){  
3268 - dateTime = sdfSimple.format(sdfMonth.parse(date));  
3269 - } else {  
3270 - dateTime = sdfSimple.format(sdfMonth.parse(date))  
3271 - +"-"+sdfSimple.format(sdfMonth.parse(date2));  
3272 - }  
3273 - listI.add(lMap.iterator());  
3274 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
3275 - ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls,  
3276 - path + "export/"+dateTime+"-"+xlName+"-路单数据统计表.xls");  
3277 - } catch (Exception e) {  
3278 - // TODO: handle exception  
3279 - e.printStackTrace();  
3280 - }  
3281 - }  
3282 -  
3283 - return lMap;  
3284 - }  
3285 -  
3286 - public final List<Ylb> ylbList(String sql, List<String> objList){  
3287 - List<Ylb> ylbList= jdbcTemplate.query(sql, objList.toArray(), new RowMapper<Ylb>() {  
3288 - @Override  
3289 - public Ylb mapRow(ResultSet arg0, int arg1) throws SQLException {  
3290 - Ylb y = new Ylb();  
3291 - y.setRq(arg0.getDate("rq"));  
3292 - y.setJsy(arg0.getString("jsy"));  
3293 - y.setXlbm(arg0.getString("xlbm"));  
3294 - y.setZlc(arg0.getDouble("zlc"));  
3295 - y.setNbbm(arg0.getString("nbbm"));  
3296 - y.setJzl(arg0.getDouble("jzl"));  
3297 - y.setYh(arg0.getDouble("yh"));  
3298 - y.setSh(arg0.getDouble("sh"));  
3299 - return y;  
3300 - }  
3301 - });  
3302 - return ylbList;  
3303 - }  
3304 -  
3305 - public final List<Dlb> dlbList(String sql, List<String> objList){  
3306 - List<Dlb> dlbList= jdbcTemplate.query(sql, objList.toArray(), new RowMapper<Dlb>() {  
3307 - @Override  
3308 - public Dlb mapRow(ResultSet arg0, int arg1) throws SQLException {  
3309 - Dlb y = new Dlb();  
3310 - y.setRq(arg0.getDate("rq"));  
3311 - y.setXlbm(arg0.getString("xlbm"));  
3312 - y.setJsy(arg0.getString("jsy"));  
3313 - y.setNbbm(arg0.getString("nbbm"));  
3314 - y.setZlc(arg0.getDouble("zlc"));  
3315 - y.setCdl(arg0.getDouble("cdl"));  
3316 - y.setHd(arg0.getDouble("hd"));  
3317 - y.setSh(arg0.getDouble("sh"));  
3318 - return y;  
3319 - }  
3320 - });  
3321 - return dlbList;  
3322 - }  
3323 -  
3324 - public final List<Map<String, Object>> lists(List<Map<String, Object>> listGb,  
3325 - List<Map<String, Object>> listLc,  
3326 - String gsdm,String fgsdm,  
3327 - String date,String date2){  
3328 - List<Map<String, Object>> lMap=new ArrayList<Map<String,Object>>();  
3329 - for (int i = 0; i < listGb.size(); i++) {  
3330 - Map<String, Object> m=listGb.get(i);  
3331 - String xl_bm=m.get("line")==null?"":m.get("line").toString();  
3332 - String nbbm =m.get("nbbm")==null?"":m.get("nbbm").toString();  
3333 - String jGh= m.get("jGh")==null?"":m.get("jGh").toString();  
3334 - String jName=m.get("jName")==null?"":m.get("jName").toString();  
3335 - String sGh= m.get("sGh")==null?"":m.get("sGh").toString();  
3336 - String sName=m.get("sName")==null?"":m.get("sName").toString();  
3337 - double jhzlc = 0.0,jhlc= 0.0,jcclc= 0.0,zlc= 0.0,jhnlc= 0.0,jhwlc= 0.0,  
3338 - jhnjcclc= 0.0,jhwjcclc= 0.0,jhwjcclc_z=0.0,zrwjcclc= 0.0,zrwjcclc1= 0.0,zrwjcclc2= 0.0,  
3339 - zrwjcclcqt=0.0,lbss= 0.0,ssgl_lz= 0.0,  
3340 - ssgl_dm= 0.0,ssgl_gz= 0.0,ssgl_jf= 0.0,ssgl_zs= 0.0,ssgl_qr= 0.0,ssgl_qc= 0.0,  
3341 - ssgl_kx= 0.0,ssgl_qh= 0.0,ssgl_yw= 0.0,ssgl_other= 0.0,ljyy=0.0,ljjcc=0.0,  
3342 - kfks=0.0,yhl=0.0,jzl=0.0,hyl=0.0,dhl=0.0,cdl=0.0;  
3343 -  
3344 - for (int j = 0; j < listLc.size(); j++) {  
3345 - Map<String, Object> map=listLc.get(j);  
3346 - if(xl_bm.equals(map.get("line").toString())  
3347 - && nbbm.equals(map.get("nbbm").toString())  
3348 - && sGh.equals(map.get("sGh")==null?"":map.get("sGh").toString())  
3349 - && jGh.equals(map.get("jGh").toString())){  
3350 - jhzlc=Arith.add(jhzlc, map.get("jhzlc"));  
3351 - jhlc =Arith.add(jhlc, map.get("jhlc"));  
3352 - jcclc=Arith.add(jcclc, map.get("jcclc"));  
3353 - zlc=Arith.add(zlc, map.get("zlc"));  
3354 - jhnlc=Arith.add(jhnlc, map.get("jhnlc"));  
3355 - jhwlc=Arith.add(jhwlc, map.get("jhwlc"));  
3356 - jhnjcclc=Arith.add(jhnjcclc, map.get("jhnjcclc"));  
3357 - jhwjcclc=Arith.add(jhwjcclc, map.get("jhwjcclc"));  
3358 - jhwjcclc_z=Arith.add(jhwjcclc_z, map.get("jhwjcclc_z"));  
3359 - zrwjcclc=Arith.add(zrwjcclc, map.get("zrwjcclc"));  
3360 - zrwjcclc1=Arith.add(zrwjcclc1, map.get("zrwjcclc1"));  
3361 - zrwjcclc2=Arith.add(zrwjcclc2, map.get("zrwjcclc2"));  
3362 - zrwjcclcqt=Arith.add(zrwjcclcqt, map.get("zrwjcclcqt"));  
3363 - lbss=Arith.add(lbss, map.get("lbss"));  
3364 - ssgl_lz=Arith.add(ssgl_lz, map.get("ssgl_lz"));  
3365 - ssgl_dm=Arith.add(ssgl_dm, map.get("ssgl_dm"));  
3366 - ssgl_gz=Arith.add(ssgl_gz, map.get("ssgl_gz"));  
3367 - ssgl_jf=Arith.add(ssgl_jf, map.get("ssgl_jf"));  
3368 - ssgl_zs=Arith.add(ssgl_zs, map.get("ssgl_zs"));  
3369 - ssgl_qr=Arith.add(ssgl_qr, map.get("ssgl_qr"));  
3370 - ssgl_qc=Arith.add(ssgl_qc, map.get("ssgl_qc"));  
3371 - ssgl_kx=Arith.add(ssgl_kx, map.get("ssgl_kx"));  
3372 - ssgl_qh=Arith.add(ssgl_qh, map.get("ssgl_qh"));  
3373 - ssgl_yw=Arith.add(ssgl_yw, map.get("ssgl_yw"));  
3374 - ssgl_other=Arith.add(ssgl_other, map.get("ssgl_other"));  
3375 - kfks=Arith.add(kfks, map.get("kfks"));  
3376 - ljyy=Arith.add(ljyy, map.get("ljyy"));  
3377 - ljjcc=Arith.add(ljjcc, map.get("ljjcc"));  
3378 - yhl=Arith.add(yhl, map.get("yhl"));  
3379 - jzl=Arith.add(jzl, map.get("jzl"));  
3380 - hyl=Arith.add(hyl, map.get("hyl"));  
3381 - dhl=Arith.add(dhl, map.get("dhl"));  
3382 - cdl=Arith.add(cdl, map.get("cdl"));  
3383 -  
3384 -  
3385 - }  
3386 - }  
3387 -  
3388 - Map<String, Object> newMap=new HashMap<String,Object>();  
3389 - if(date.equals(date2)){  
3390 - newMap.put("rq", date);  
3391 - }else{  
3392 - newMap.put("rq", date+"至"+date2);  
3393 - }  
3394 - newMap.put("fgs", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
3395 - newMap.put("xlName", BasicData.lineCode2NameMap.get(xl_bm));  
3396 - newMap.put("xlBm", xl_bm);  
3397 - newMap.put("jGh", jGh);  
3398 - newMap.put("jName", jName);  
3399 - newMap.put("sGh",sGh);  
3400 - newMap.put("sName", sName);  
3401 - newMap.put("nbbm", nbbm);  
3402 - newMap.put("jhzlc", jhzlc);  
3403 - newMap.put("jhlc", jhlc);  
3404 - newMap.put("jcclc", jcclc);  
3405 - newMap.put("zlc", zlc);  
3406 - newMap.put("jhnlc", jhnlc);  
3407 - newMap.put("jhwlc", jhwlc);  
3408 - newMap.put("jhnjcclc", jhnjcclc);  
3409 - newMap.put("jhwjcclc", jhwjcclc);  
3410 - newMap.put("jhwjcclc_z", jhwjcclc_z);  
3411 - newMap.put("zrwjcclc", zrwjcclc);  
3412 - newMap.put("zrwjcclc1", zrwjcclc1);  
3413 - newMap.put("zrwjcclc2", zrwjcclc2);  
3414 - newMap.put("zrwjcclcqt", zrwjcclcqt);  
3415 - newMap.put("lbss", lbss);  
3416 - newMap.put("ssgl_lz", ssgl_lz);  
3417 - newMap.put("ssgl_dm",ssgl_dm);  
3418 - newMap.put("ssgl_gz", ssgl_gz);  
3419 - newMap.put("ssgl_jf", ssgl_jf);  
3420 - newMap.put("ssgl_zs", ssgl_zs);  
3421 - newMap.put("ssgl_qr", ssgl_qr);  
3422 - newMap.put("ssgl_qc", ssgl_qc);  
3423 - newMap.put("ssgl_kx", ssgl_kx);  
3424 - newMap.put("ssgl_qh", ssgl_qh);  
3425 - newMap.put("ssgl_yw", ssgl_yw);  
3426 - newMap.put("ssgl_other", ssgl_other);  
3427 - newMap.put("kfks", kfks);  
3428 - newMap.put("ljyy", ljyy);  
3429 - newMap.put("ljjcc", ljjcc);  
3430 - newMap.put("yhl", yhl);  
3431 - newMap.put("jzl", jzl);  
3432 - newMap.put("hyl", hyl);  
3433 - newMap.put("dhl", dhl);  
3434 - newMap.put("cdl", cdl);  
3435 - lMap.add(newMap);  
3436 - }  
3437 - return lMap;  
3438 - }  
3439 - @Override  
3440 - public List<Map<String, Object>> countDjg(Map<String, Object> map) {  
3441 - // TODO Auto-generated method stub  
3442 - List<Map<String, Object>> lMap=new ArrayList<Map<String,Object>>();  
3443 - String line=map.get("line").toString().trim();  
3444 - String date=map.get("date").toString();  
3445 - String gsbm=map.get("gsbm").toString();  
3446 - String fgsbm=map.get("fgsbm").toString();  
3447 - String type=map.get("type").toString();  
3448 - List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();  
3449 - if(line.equals("")){  
3450 - list=scheduleRealInfoRepository.scheduleByDateAndLineByGs(gsbm, fgsbm, date);  
3451 -  
3452 - }else{  
3453 - list=scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);  
3454 - }  
3455 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");  
3456 -// Collections.sort(listInfo,new ComparableAcuals());  
3457 -  
3458 - List<String> objList = new ArrayList<String>();  
3459 - //查询所有线路  
3460 - String xlSql="select line_code,spac_grade from bsth_c_line ";  
3461 - if(line.equals("")){  
3462 - xlSql +=" where company = ?";  
3463 - objList.add(gsbm);  
3464 - }else{  
3465 - xlSql +=" where line_code = ?";  
3466 - objList.add(line);  
3467 - }  
3468 -  
3469 - List<Map<String, Object>> xlList=jdbcTemplate.query(xlSql, objList.toArray(), new RowMapper<Map<String, Object>>() {  
3470 - @Override  
3471 - public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {  
3472 - Map<String, Object> map=new HashMap<String,Object>();  
3473 - map.put("line",arg0.getString("line_code"));  
3474 - map.put("grade", arg0.getString("spac_grade"));  
3475 - return map;  
3476 - }  
3477 - });  
3478 - //查询大间隔时间  
3479 - String djgSql="select * from bsth_c_interval";  
3480 - List<Interval> djgList=jdbcTemplate.query(djgSql, new RowMapper<Interval>() {  
3481 - @Override  
3482 - public Interval mapRow(ResultSet arg0, int arg1) throws SQLException {  
3483 - Interval m=new Interval();  
3484 - m.setLevel(arg0.getString("level"));  
3485 - m.setPeak(arg0.getInt("peak"));  
3486 - m.setTrough(arg0.getInt("trough"));  
3487 - return m;  
3488 - }  
3489 - });  
3490 -  
3491 - for (int i = 0; i < xlList.size(); i++) {  
3492 - String lineCode=xlList.get(i).get("line").toString();  
3493 - String grade =xlList.get(i).get("grade")==null?"1":xlList.get(i).get("grade").toString();  
3494 - int peak=0;  
3495 - int trough=0;  
3496 - for (int j = 0; j < djgList.size(); j++) {  
3497 - Interval il=djgList.get(j);  
3498 - if(il.getLevel().equals(grade)){  
3499 - peak=il.getPeak();  
3500 - trough=il.getTrough();  
3501 - continue;  
3502 - }  
3503 - }  
3504 - List<ScheduleRealInfo> list_=new ArrayList<ScheduleRealInfo>();  
3505 - List<ScheduleRealInfo> listInfo=new ArrayList<ScheduleRealInfo>();  
3506 - for (int j = 0; j < list.size(); j++) {  
3507 - ScheduleRealInfo sinfo=list.get(j);  
3508 - try {  
3509 - if(sinfo.getXlBm().equals(lineCode)){  
3510 - boolean type_=false;  
3511 - Set<ChildTaskPlan> cts = sinfo.getcTasks();  
3512 - if(cts != null && cts.size() > 0){  
3513 - type_=true;  
3514 - }else{  
3515 - if(sinfo.getZdsjActual()!=null && sinfo.getFcsjActual()!=null){  
3516 - type_=true;  
3517 - }  
3518 - }  
3519 - if(type_){  
3520 - list_.add(sinfo);  
3521 - ScheduleRealInfo s=checkBc(sinfo);  
3522 - String fcsj=s.getFcsjActual()==null?"":s.getFcsjActual();  
3523 - if(!fcsj.equals("")){  
3524 - Long fcsjAcual = sdf.parse(s.getRealExecDate() + " " + s.getFcsjActual()).getTime();  
3525 - s.setFcsjActualTime(fcsjAcual);  
3526 - s.setFcsjActual(fcsj);  
3527 - listInfo.add(s);  
3528 - }  
3529 - }  
3530 -  
3531 - }  
3532 - } catch (ParseException e) {  
3533 - // TODO Auto-generated catch block  
3534 - e.printStackTrace();  
3535 - }  
3536 - }  
3537 -  
3538 - if(listInfo.size()>0){  
3539 - int sjbcs=culateService.culateSjbc(list_, "")+culateService.culateLjbc(list_, "");  
3540 - Map<String, Object> m=listDjg(gsbm,fgsbm,lineCode,sjbcs,peak,trough,listInfo,grade);  
3541 - lMap.add(m);  
3542 - }  
3543 -  
3544 - }  
3545 - if(type.equals("export")){  
3546 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
3547 - Map<String, Object> m = new HashMap<String, Object>();  
3548 - m.put("date", date);  
3549 - ReportUtils ee = new ReportUtils();  
3550 - try {  
3551 - listI.add(lMap.iterator());  
3552 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
3553 - ee.excelReplace(listI, new Object[]{m}, path + "mould/countInterval.xls",  
3554 - path + "export/大间隔统计表.xls");  
3555 - } catch (Exception e) {  
3556 - // TODO: handle exception  
3557 - e.printStackTrace();  
3558 - }  
3559 - }  
3560 - return lMap;  
3561 - }  
3562 -  
3563 - public ScheduleRealInfo checkBc(ScheduleRealInfo s){  
3564 - //如果班次有子任务 且 子任务中有属于营运的。把该子任务的发车时间设置成班次的发车时间  
3565 - String fcsj=s.getFcsjActual()==null?"":s.getFcsjActual();  
3566 - if(fcsj.equals("")){  
3567 - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();  
3568 - if(!childTaskPlans.isEmpty()){  
3569 - List<ChildTaskPlan> listit=new ArrayList<ChildTaskPlan>(childTaskPlans);  
3570 - Collections.sort(listit, new ComparableChild());  
3571 - for (int i = 0; i < listit.size(); i++) {  
3572 - ChildTaskPlan c=listit.get(i);  
3573 - if(!c.isDestroy()){  
3574 - if(c.getMileageType().equals("service")){  
3575 - s.setFcsjActual(c.getStartDate());  
3576 - break;  
3577 - }  
3578 -  
3579 - }  
3580 - }  
3581 - }  
3582 - }  
3583 - return s;  
3584 - }  
3585 -  
3586 - public Map<String, Object> listDjg(String gsdm,String fgsdm,String line,int sjbcs,int peak,int trough,List<ScheduleRealInfo> listInfo,String grade){  
3587 - DecimalFormat df = new DecimalFormat("#0.00");  
3588 - Collections.sort(listInfo,new ComparableAcuals());  
3589 - List<ScheduleRealInfo> listInfo0=new ArrayList<ScheduleRealInfo>();  
3590 - List<ScheduleRealInfo> listInfo1=new ArrayList<ScheduleRealInfo>();  
3591 - for (int i = 0; i < listInfo.size(); i++) {  
3592 - ScheduleRealInfo s=listInfo.get(i);  
3593 - if(s.getXlDir().equals("0")){  
3594 - listInfo0.add(s);  
3595 - }else{  
3596 - listInfo1.add(s);  
3597 - }  
3598 -  
3599 - }  
3600 - Map<String, Object> map=new HashMap<String, Object>();  
3601 - map.put("line", line);  
3602 - map.put("xlName", BasicData.lineCode2NameMap.get(line));  
3603 - map.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
3604 - map.put("bcs", sjbcs);  
3605 - map.put("djgde", grade);  
3606 - int djgcs=0;  
3607 - List<Map<String, Object>> mapList=new ArrayList<Map<String, Object>>();  
3608 - for (int i = 0; i < listInfo0.size(); i++) {  
3609 - ScheduleRealInfo s=listInfo0.get(i);  
3610 - Long fcsjTime=s.getFcsjActualTime();  
3611 - String time=s.getFcsjActual();  
3612 - String[] fcsjStr = time.split(":");  
3613 - long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);  
3614 - if(i<listInfo0.size()-1){  
3615 - Long djg=0l;  
3616 - Long fscjNext=listInfo0.get(i+1).getFcsjActualTime();  
3617 - if((fcsj>=zgf1&&fcsj<=zgf2)||(fcsj>=wgf1&&fcsj<=wgf2)){  
3618 - djg = (long) (peak*60*1000);  
3619 - if(fscjNext-fcsjTime>djg){  
3620 - djgcs ++;  
3621 - Map<String, Object> m=new HashMap<String,Object>();  
3622 - m.put("xlName", BasicData.lineCode2NameMap.get(line));  
3623 - m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
3624 - m.put("djgde", grade);  
3625 - m.put("qJh", s.getFcsj());  
3626 - m.put("qSj", time);  
3627 - m.put("hJh", listInfo0.get(i+1).getFcsj());  
3628 - m.put("hSj", listInfo0.get(i+1).getFcsjActual());  
3629 - m.put("djgsj", peak);  
3630 - m.put("bcjgsj", (fscjNext-fcsjTime)/60000);  
3631 - mapList.add(m);  
3632 - }  
3633 - }else{  
3634 - djg = (long) (trough*60*1000);  
3635 - if(fscjNext-fcsjTime>djg){  
3636 - djgcs ++;  
3637 - Map<String, Object> m=new HashMap<String,Object>();  
3638 - m.put("xlName", BasicData.lineCode2NameMap.get(line));  
3639 - m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
3640 - m.put("djgde", grade);  
3641 - m.put("qJh", s.getFcsj());  
3642 - m.put("qSj", time);  
3643 - m.put("hJh", listInfo0.get(i+1).getFcsj());  
3644 - m.put("hSj", listInfo0.get(i+1).getFcsjActual());  
3645 - m.put("djgsj", trough);  
3646 - m.put("bcjgsj", (fscjNext-fcsjTime)/60000);  
3647 - mapList.add(m);  
3648 - }  
3649 - }  
3650 - }  
3651 - }  
3652 -  
3653 - for (int i = 0; i < listInfo1.size(); i++) {  
3654 - ScheduleRealInfo s=listInfo1.get(i);  
3655 - Long fcsjTime=s.getFcsjActualTime();  
3656 - String time=s.getFcsjActual();  
3657 - String[] fcsjStr = time.split(":");  
3658 - long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);  
3659 - if(i<listInfo1.size()-1){  
3660 - Long djg=0l;  
3661 - Long fscjNext=listInfo1.get(i+1).getFcsjActualTime();  
3662 - if((fcsj>=zgf1&&fcsj<=zgf2)||(fcsj>=wgf1&&fcsj<=wgf2)){  
3663 - djg = (long) (peak*60*1000);  
3664 - if(fscjNext-fcsjTime>djg){  
3665 - djgcs ++;  
3666 - Map<String, Object> m=new HashMap<String,Object>();  
3667 - m.put("xlName", BasicData.lineCode2NameMap.get(line));  
3668 - m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
3669 - m.put("djgde", grade);  
3670 - m.put("qJh", s.getFcsj());  
3671 - m.put("qSj", time);  
3672 - m.put("hJh", listInfo1.get(i+1).getFcsj());  
3673 - m.put("hSj", listInfo1.get(i+1).getFcsjActual());  
3674 - m.put("djgsj", peak);  
3675 - m.put("bcjgsj", (fscjNext-fcsjTime)/60000);  
3676 - mapList.add(m);  
3677 - }  
3678 - }else{  
3679 - djg = (long) (trough*60*1000);  
3680 - if(fscjNext-fcsjTime>djg){  
3681 - djgcs ++;  
3682 - Map<String, Object> m=new HashMap<String,Object>();  
3683 - m.put("xlName", BasicData.lineCode2NameMap.get(line));  
3684 - m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
3685 - m.put("djgde", grade);  
3686 - m.put("qJh", s.getFcsj());  
3687 - m.put("qSj", time);  
3688 - m.put("hJh", listInfo1.get(i+1).getFcsj());  
3689 - m.put("hSj", listInfo1.get(i+1).getFcsjActual());  
3690 - m.put("djgsj", trough);  
3691 - m.put("bcjgsj", (fscjNext-fcsjTime)/60000);  
3692 - mapList.add(m);  
3693 - }  
3694 - }  
3695 - }  
3696 - }  
3697 - double fsl=0.0;  
3698 - if(sjbcs>0){  
3699 - fsl=Arith.div(djgcs,sjbcs, 2)*100;  
3700 - }  
3701 -  
3702 - map.put("djgcs", djgcs);  
3703 - map.put("fsl", df.format(fsl)+"%");  
3704 - map.put("djgxx", mapList);  
3705 - return map;  
3706 - }  
3707 -  
3708 -  
3709 - @Override  
3710 - public Map<String, Object> online(Map<String, Object> map) {  
3711 - String line =map.get("line").toString();  
3712 - String date =map.get("date").toString();  
3713 - String type =map.get("type").toString();  
3714 - DecimalFormat df = new DecimalFormat("#0.00");  
3715 -  
3716 - List<String> objList = new ArrayList<String>();  
3717 - objList.add(date);  
3718 - objList.add(line);  
3719 - String sql="select cl_zbh from bsth_c_s_sp_info_real where "  
3720 - + " schedule_date_str = ? and xl_bm = ? group by cl_zbh";  
3721 - List<String> list= jdbcTemplate.query(sql, objList.toArray(),  
3722 - new RowMapper<String>(){  
3723 - @Override  
3724 - public String mapRow(ResultSet rs, int rowNum) throws SQLException {  
3725 - String clzbh=rs.getString("cl_zbh");  
3726 - return clzbh;  
3727 - }  
3728 - });  
3729 - List<Line> lineList=lineRepository.findLineByCode(line);  
3730 - int qzpcs =0;  
3731 - for (int i = 0; i < lineList.size(); i++) {  
3732 - Line l=lineList.get(i);  
3733 - qzpcs = l.getWarrantCar()==null?0:l.getWarrantCar();  
3734 - }  
3735 -  
3736 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
3737 - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");  
3738 - int zxcl=0;  
3739 - try {  
3740 - Long date1 = simpleDateFormat.parse(date+" 00:00:01").getTime();  
3741 - Long date2=simpleDateFormat.parse(date+" 23:59:59").getTime();  
3742 - Date dates=simpleDateFormat.parse(date+" 00:00:00");  
3743 - List<ArrivalInfo> lists=load_online(line,date1,date2,dates,date);  
3744 - for (int i = 0; i < list.size(); i++) {  
3745 - String nbbm=list.get(i);  
3746 - String sbbb=BasicData.deviceId2NbbmMap.inverse().get(nbbm);  
3747 - for (int j = 0; j < lists.size(); j++) {  
3748 - ArrivalInfo a=lists.get(i);  
3749 - if(a.getDeviceId().equals(sbbb)){  
3750 - zxcl ++;  
3751 - break;  
3752 - }  
3753 - }  
3754 -  
3755 - }  
3756 - } catch (ParseException e) {  
3757 - // TODO Auto-generated catch block  
3758 - e.printStackTrace();  
3759 - }  
3760 - map.put("xlName", BasicData.lineCode2NameMap.get(line));  
3761 - map.put("qzpcs", qzpcs);  
3762 - map.put("ccs", list.size());  
3763 - map.put("zxcl", zxcl);  
3764 - String zxl="0";  
3765 - if(list.size()>0){  
3766 - zxl = df.format(zxcl/list.size());  
3767 - }  
3768 - map.put("zxl", zxl+"%");  
3769 -  
3770 - if(type.equals("export")){  
3771 - List<Map<String, Object>> lMap=new ArrayList<Map<String,Object>>();  
3772 -  
3773 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
3774 - Map<String, Object> m = new HashMap<String, Object>();  
3775 - m.put("date", date);  
3776 - m.put("xlName", BasicData.lineCode2NameMap.get(line));  
3777 - m.put("qzpcs", qzpcs);  
3778 - m.put("ccs", list.size());  
3779 - m.put("zxcl", zxcl);  
3780 - m.put("zxl", zxl+"%");  
3781 - lMap.add(m);  
3782 - ReportUtils ee = new ReportUtils();  
3783 - try {  
3784 - listI.add(lMap.iterator());  
3785 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
3786 - ee.excelReplace(listI, new Object[]{m}, path + "mould/onlinelist.xls",  
3787 - path + "export/车辆在线率统计.xls");  
3788 - } catch (Exception e) {  
3789 - // TODO: handle exception  
3790 - e.printStackTrace();  
3791 - }  
3792 - }  
3793 - return map;  
3794 - }  
3795 -  
3796 - public List<ArrivalInfo> load_online(String line,Long date1,Long date2,Date dates,String date){  
3797 - List<ArrivalInfo> list = null;  
3798 - Calendar cal = Calendar.getInstance();  
3799 - cal.setTime(dates);  
3800 - //周数,表分区字段  
3801 - int weeks_year = cal.get(Calendar.WEEK_OF_YEAR);  
3802 -  
3803 - Connection conn = null;  
3804 - PreparedStatement ps = null;  
3805 - ResultSet rs = null;  
3806 - String year=date.substring(0,4);  
3807 - String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year=? AND line_id=? AND ts > ? AND ts <=? order by ts";  
3808 - try{  
3809 - conn = DBUtils_MS.getConnection();  
3810 - ps = conn.prepareStatement(sql);  
3811 - ps.setInt(1, weeks_year);  
3812 - ps.setString(2,line);  
3813 - ps.setLong(3, date1);  
3814 - ps.setLong(4, date2);  
3815 - rs = ps.executeQuery();  
3816 -  
3817 - list = resultSet2Set(rs);  
3818 - }catch(Exception e){  
3819 - logger.error("", e);  
3820 - }finally {  
3821 - DBUtils_MS.close(rs, ps, conn);  
3822 - }  
3823 - return list;  
3824 - }  
3825 - @Override  
3826 - public List<Singledata> singledatatj(Map<String, Object> map) {  
3827 - String sfyy="";  
3828 - if(map.get("sfyy")!=null){  
3829 - sfyy=map.get("sfyy").toString();  
3830 - }  
3831 - String gsdm="";  
3832 - if(map.get("gsdmSing")!=null){  
3833 - gsdm=map.get("gsdmSing").toString();  
3834 - }  
3835 - String fgsdm="";  
3836 - if(map.get("fgsdmSing")!=null){  
3837 - fgsdm=map.get("fgsdmSing").toString();  
3838 - }  
3839 - String type="";  
3840 - if(map.get("type")!=null){  
3841 - type=map.get("type").toString();  
3842 - }  
3843 - String tjtype=map.get("tjtype").toString();  
3844 - String xlbm=map.get("line").toString().trim();  
3845 - String startDate = map.get("startDate").toString();  
3846 - String endDate = map.get("endDate").toString();  
3847 -  
3848 - List<ScheduleRealInfo> listReal=new ArrayList<ScheduleRealInfo>();  
3849 - if(xlbm.equals("")){  
3850 - listReal=scheduleRealInfoRepository.scheduleByDateAndLineTj(xlbm, startDate, endDate, gsdm, fgsdm);  
3851 - }else{  
3852 - listReal=scheduleRealInfoRepository.scheduleByDateAndLineTj2(xlbm, startDate, endDate);  
3853 - }  
3854 - List<Singledata> list=new ArrayList<Singledata>();  
3855 - List<Singledata> list_=new ArrayList<Singledata>();  
3856 - if(tjtype.equals("jsy")){  
3857 - List<String> objList = new ArrayList<String>();  
3858 - objList.add(startDate);  
3859 - objList.add(endDate);  
3860 - //油统计  
3861 - String sql="select r.j_gh, r.xl_bm,r.cl_zbh,r.fgs_bm"  
3862 - + " from bsth_c_s_sp_info_real r where "  
3863 - + " r.schedule_date_str >= ?"  
3864 - + " and r.schedule_date_str <= ?";  
3865 - if(xlbm.length() != 0){  
3866 - sql += " and r.xl_bm = ?";  
3867 - objList.add(xlbm);  
3868 - }  
3869 - if(gsdm.length() != 0){  
3870 - sql += " and r.gs_bm = ?";  
3871 - objList.add(gsdm);  
3872 - }  
3873 - if(fgsdm.length() != 0){  
3874 - sql += " and r.fgs_bm = ?";  
3875 - objList.add(fgsdm);  
3876 - }  
3877 - sql += " group by r.j_gh,r.xl_bm,r.cl_zbh,r.fgs_bm order by r.xl_bm,r.cl_zbh";  
3878 -  
3879 - list = jdbcTemplate.query(sql, objList.toArray(), new RowMapper<Singledata>() {  
3880 - @Override  
3881 - public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {  
3882 - Singledata sin = new Singledata();  
3883 - sin.setxL(arg0.getString("xl_bm"));  
3884 - sin.setJsy(arg0.getString("j_gh"));  
3885 - sin.setClzbh(arg0.getString("cl_zbh"));  
3886 - sin.setgS(arg0.getString("fgs_bm"));  
3887 - return sin;  
3888 - }  
3889 - });  
3890 -  
3891 - List<String> objList2 = new ArrayList<String>();  
3892 - List<String> tempList2 = new ArrayList<String>();  
3893 - tempList2.add(startDate);  
3894 - tempList2.add(endDate);  
3895 - String linesql="";  
3896 - if(!xlbm.equals("")){  
3897 - linesql +=" and xlbm = ?";  
3898 - tempList2.add(xlbm);  
3899 - }  
3900 - if(!gsdm.equals("")){  
3901 - linesql +=" and ssgsdm = ?";  
3902 - tempList2.add(gsdm);  
3903 - }  
3904 - if(!fgsdm.equals("")){  
3905 - linesql +=" and fgsdm = ?";  
3906 - tempList2.add(fgsdm);  
3907 - }  
3908 -  
3909 - for(int i = 0; i < 2; i++){ // sql中使用两次重复参数  
3910 - for(String s : tempList2){  
3911 - objList2.add(s);  
3912 - }  
3913 - }  
3914 -  
3915 - String nysql="SELECT 'yh' as type,xlbm,nbbm,jsy,sum(jzl*1000)/1000 as jzl,"  
3916 - + " sum(yh*1000)/1000 as yh,"  
3917 - + " sum(sh*1000)/1000 as sh FROM "  
3918 - + "bsth_c_ylb where rq >= ? "  
3919 - + " and rq <= ? " +linesql  
3920 - + " group by xlbm ,nbbm,jsy "  
3921 - + " union SELECT 'dh' as type,xlbm,nbbm,jsy, "  
3922 - + " sum(cdl*1000)/1000 as jzl,sum(hd*1000)/1000 as yh,"  
3923 - + " sum(sh * 1000) / 1000 AS sh"  
3924 - + " FROM bsth_c_dlb where rq >= ? "  
3925 - + " and rq <= ? " +linesql  
3926 - + " group by xlbm ,nbbm,jsy" ;  
3927 -  
3928 - List<Singledata> listNy = jdbcTemplate.query(nysql, objList2.toArray(), new RowMapper<Singledata>() {  
3929 - @Override  
3930 - public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {  
3931 - Singledata sin = new Singledata();  
3932 - sin.setxL(arg0.getString("xlbm"));  
3933 - sin.setJsy(arg0.getString("jsy"));  
3934 - sin.setClzbh(arg0.getString("nbbm"));  
3935 - sin.setJzl(arg0.getString("jzl"));  
3936 - sin.setHyl(arg0.getString("yh"));  
3937 - sin.setUnyyyl(arg0.getString("sh"));  
3938 - return sin;  
3939 - }  
3940 - });  
3941 - //统计油,电表中手动添加的或者有加注没里程的数据  
3942 - for (int i = 0; i < listNy.size(); i++) {  
3943 - Singledata sin_=listNy.get(i);  
3944 - String jsy=sin_.getJsy();  
3945 - String line=sin_.getxL();  
3946 - String clzbh=sin_.getClzbh();  
3947 - boolean fages=true;  
3948 - for (int j = 0; j < list.size(); j++) {  
3949 - Singledata sin=list.get(j);  
3950 - String jsy_=sin.getJsy();  
3951 - String line_=sin.getxL();  
3952 - String clzbh_=sin.getClzbh();  
3953 - if(jsy.equals(jsy_)  
3954 - &&line.equals(line_)  
3955 - &&clzbh.equals(clzbh_)){  
3956 - fages=false;  
3957 - }  
3958 - }  
3959 - if(fages){  
3960 - Singledata s=new Singledata();  
3961 - s.setJsy(jsy);  
3962 - s.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));  
3963 - s.setClzbh(clzbh);  
3964 - s.setSgh("");  
3965 - s.setsName("");  
3966 - s.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
3967 - s.setxL(line);  
3968 - s.setXlmc(BasicData.lineCodeAllNameMap.get(line));  
3969 - s.setJzl(sin_.getJzl());  
3970 - s.setHyl(sin_.getHyl());  
3971 - s.setUnyyyl(sin_.getUnyyyl());  
3972 - s.setJhlc("0.0");  
3973 - s.setEmptMileage("0.0");  
3974 - s.setJhjl("0.0");  
3975 - if(startDate.equals(endDate))  
3976 - s.setrQ(startDate);  
3977 - else  
3978 - s.setrQ(startDate+"-"+endDate);  
3979 -  
3980 - list_.add(s);  
3981 - }  
3982 - }  
3983 - for (int i= 0; i < list.size(); i++) {  
3984 - Singledata sin=list.get(i);  
3985 - String jsy=sin.getJsy();  
3986 - String line=sin.getxL();  
3987 - String clzbh=sin.getClzbh();  
3988 - double jzl=0.0;  
3989 - double yh=0.0;  
3990 - double sh=0.0;  
3991 - for (int j = 0; j < listNy.size(); j++) {  
3992 - Singledata y=listNy.get(j);  
3993 - if(y.getJsy().equals(jsy)  
3994 - &&y.getClzbh().equals(clzbh)  
3995 - &&y.getxL().equals(line)){  
3996 - jzl=Arith.add(jzl, y.getJzl());  
3997 - yh=Arith.add(yh, y.getHyl());  
3998 - sh=Arith.add(sh, y.getUnyyyl());  
3999 - }  
4000 - }  
4001 - sin.setHyl(String.valueOf(yh));  
4002 - sin.setJzl(String.valueOf(jzl));  
4003 - sin.setUnyyyl(String.valueOf(sh));  
4004 -  
4005 - List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();  
4006 - List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();  
4007 - for (int j = 0; j < listReal.size(); j++) {  
4008 - ScheduleRealInfo s=listReal.get(j);  
4009 - if(s.getjGh().equals(jsy)  
4010 - && s.getClZbh().equals(clzbh)  
4011 - &&s.getXlBm().equals(line)){  
4012 - newList.add(s);  
4013 - Set<ChildTaskPlan> cts = s.getcTasks();  
4014 - if(cts != null && cts.size() > 0){  
4015 - newList_.add(s);  
4016 - }else{  
4017 - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){  
4018 - newList_.add(s);  
4019 - }  
4020 - }  
4021 - }  
4022 - }  
4023 - double jhgl=culateMileageService.culateJhgl(newList);  
4024 - double jhjcc=culateMileageService.culateJhJccgl(newList);  
4025 - double yygl=culateMileageService.culateSjgl(newList_);  
4026 - double ljgl=culateMileageService.culateLjgl(newList_);  
4027 - double ksgl=culateMileageService.culateKsgl(newList_);  
4028 - double jcgl=culateMileageService.culateJccgl(newList_);  
4029 -  
4030 - double zyygl=Arith.add(yygl, ljgl);  
4031 - double zksgl=Arith.add(ksgl, jcgl);  
4032 - sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));  
4033 - sin.setEmptMileage(String.valueOf(zksgl));  
4034 - sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));  
4035 - if(newList.size()>0){  
4036 - sin.setXlmc(newList.get(0).getXlName());  
4037 - sin.setjName(newList.get(0).getjName());  
4038 - }else{  
4039 - sin.setXlmc(BasicData.lineCodeAllNameMap.get(line));  
4040 - sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));  
4041 -  
4042 - }  
4043 - if(startDate.equals(endDate))  
4044 - sin.setrQ(startDate);  
4045 - else  
4046 - sin.setrQ(startDate+"-"+endDate);  
4047 -// sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));  
4048 - sin.setSgh("");  
4049 - sin.setsName("");  
4050 - sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
4051 - list_.add(sin);  
4052 -  
4053 - }  
4054 - }else{  
4055 - List<String> objList3 = new ArrayList<String>();  
4056 - objList3.add(startDate);  
4057 - objList3.add(endDate);  
4058 - String sql="select r.s_gh,r.s_name, "  
4059 - + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm"  
4060 - + " from bsth_c_s_sp_info_real r where "  
4061 - + " r.schedule_date_str >= ?"  
4062 - + " schedule_date_str <= ?"  
4063 - + " and r.s_gh !='' and r.s_gh is not null ";  
4064 - if(!xlbm.equals("")){  
4065 - sql += " and r.xl_bm = ?";  
4066 - objList3.add(xlbm);  
4067 - }  
4068 - if(!gsdm.equals("")){  
4069 - sql += " and r.gs_bm = ?";  
4070 - objList3.add(gsdm);  
4071 - }  
4072 - if(!fgsdm.equals("")){  
4073 - sql += " and r.fgs_bm = ?";  
4074 - objList3.add(fgsdm);  
4075 - }  
4076 - sql += " group by r.s_gh,r.s_name,"  
4077 - + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";  
4078 -  
4079 - list = jdbcTemplate.query(sql, objList3.toArray(), new RowMapper<Singledata>() {  
4080 - //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
4081 - @Override  
4082 - public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {  
4083 - Singledata sin = new Singledata();  
4084 -// sin.setrQ(startDate);  
4085 - sin.setxL(arg0.getString("xl_bm"));  
4086 - sin.setClzbh(arg0.getString("cl_zbh"));  
4087 - sin.setSgh(arg0.getString("s_gh"));  
4088 - sin.setsName(arg0.getString("s_name"));  
4089 - sin.setgS(arg0.getString("fgs_bm"));  
4090 - return sin;  
4091 - }  
4092 - });  
4093 -  
4094 - String spy="";  
4095 - if(map.get("map")!=null){  
4096 - spy=map.get("spy").toString();  
4097 - }  
4098 - for (int i = 0; i < list.size(); i++) {  
4099 - Singledata sin=list.get(i);  
4100 - sin.setrQ(startDate+"-"+endDate);  
4101 - String jsy=sin.getSgh();  
4102 - String line=sin.getxL();  
4103 - String clzbh=sin.getClzbh();  
4104 - List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();  
4105 - List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();  
4106 -  
4107 - for (int j = 0; j < listReal.size(); j++) {  
4108 - ScheduleRealInfo s=listReal.get(j);  
4109 - if(s.getsGh().equals(jsy) && s.getClZbh().equals(clzbh)  
4110 - &&s.getXlBm().equals(line)){  
4111 - newList.add(s);  
4112 - Set<ChildTaskPlan> cts = s.getcTasks();  
4113 - if(cts != null && cts.size() > 0){  
4114 - newList_.add(s);  
4115 - }else{  
4116 - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){  
4117 - newList_.add(s);  
4118 - }  
4119 - }  
4120 - }  
4121 - }  
4122 - double jhgl=culateMileageService.culateJhgl(newList);;  
4123 - double jhjcc=culateMileageService.culateJhJccgl(newList);  
4124 - double yygl=0.0;  
4125 - double ljgl=0.0;  
4126 - double zksgl=0.0;  
4127 - if(spy.equals("zrw")){  
4128 - yygl=culateMileageService.culateSjgl_spy(newList_);  
4129 - ljgl=culateMileageService.culateLjgl_spy(newList_);  
4130 - zksgl=culateMileageService.culateSjfyylc_spy(newList_);  
4131 - }else{  
4132 - yygl=culateMileageService.culateSjgl(newList_);  
4133 - ljgl=culateMileageService.culateLjgl(newList_);  
4134 - double ksgl=culateMileageService.culateKsgl(newList_);  
4135 - double jcgl=culateMileageService.culateJccgl(newList_);  
4136 - zksgl=Arith.add(ksgl, jcgl);  
4137 - }  
4138 - double zyygl=Arith.add(yygl, ljgl);  
4139 - sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));  
4140 - sin.setEmptMileage(String.valueOf(zksgl));  
4141 - sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));  
4142 - if(newList.size()>0)  
4143 - sin.setXlmc(newList.get(0).getXlName());  
4144 - else  
4145 - sin.setXlmc(BasicData.lineCodeAllNameMap.get(line));  
4146 - sin.setClzbh(clzbh);  
4147 - sin.setJsy("");  
4148 - sin.setjName("");  
4149 - sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
4150 - sin.setHyl("");  
4151 - sin.setJzl("");  
4152 - sin.setUnyyyl("");  
4153 - list_.add(sin);  
4154 - }  
4155 - }  
4156 -  
4157 -  
4158 -  
4159 - if (type.equals("export")) {  
4160 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
4161 - ReportUtils ee = new ReportUtils();  
4162 -  
4163 - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();  
4164 - int i = 1;  
4165 - for (Singledata l : list_) {  
4166 - Map<String, Object> m = new HashMap<String, Object>();  
4167 - m.put("i", i);  
4168 - m.put("rQ", l.getrQ());  
4169 - m.put("gS", l.getgS());  
4170 - m.put("xL", l.getXlmc());  
4171 - m.put("clzbh", l.getClzbh());  
4172 - m.put("jsy", l.getJsy());  
4173 - m.put("jName", l.getjName());  
4174 - m.put("sgh", l.getSgh());  
4175 - m.put("sName", l.getsName());  
4176 - m.put("jhlc", l.getJhlc());  
4177 - m.put("emptMileage", l.getEmptMileage());  
4178 - m.put("hyl", l.getHyl());  
4179 - m.put("jzl", l.getJzl());  
4180 - m.put("unyyyl", l.getUnyyyl());  
4181 - m.put("jhjl", l.getJhjl());  
4182 - resList.add(m);  
4183 -  
4184 - i++;  
4185 - }  
4186 -  
4187 - listI.add(resList.iterator());  
4188 - try {  
4189 - String exportDate="";  
4190 - if(startDate.equals(endDate)){  
4191 - exportDate =sdfSimple.format(sdfMonth.parse(startDate)) ;  
4192 - }else{  
4193 - exportDate =sdfSimple.format(sdfMonth.parse(startDate))+"-"+sdfSimple.format(sdfMonth.parse(endDate)) ;  
4194 - }  
4195 - String lineName = "";  
4196 - if(map.containsKey("lineName"))  
4197 - lineName = map.get("lineName").toString();  
4198 -  
4199 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
4200 - ee.excelReplace(listI, new Object[] { map }, path + "mould/singledata.xls",  
4201 - path + "export/" +exportDate  
4202 - + "-" + lineName + "-路单统计.xls");  
4203 - } catch (ParseException e) {  
4204 - e.printStackTrace();  
4205 - }  
4206 - }  
4207 - return list_;  
4208 - }  
4209 -  
4210 - @Override  
4211 - public List<Map<String, Object>> singleEnergy(Map<String, Object> map) {  
4212 - // TODO Auto-generated method stub  
4213 - Map<String, Map<String,Object>> mm=new HashMap<String, Map<String,Object>>();  
4214 -  
4215 - String gsdm="";  
4216 - if(map.get("gs")!=null){  
4217 - gsdm=map.get("gs").toString();  
4218 - }  
4219 - String fgsdm="";  
4220 - if(map.get("fgs")!=null){  
4221 - fgsdm=map.get("fgs").toString();  
4222 - }  
4223 - String energy="";  
4224 - if(map.get("energy")!=null){  
4225 - energy=map.get("energy").toString();  
4226 - }  
4227 - String xlbm="";  
4228 - if(map.get("line")!=null){  
4229 - xlbm=map.get("line").toString().trim();  
4230 - }  
4231 - String date = map.get("date").toString();  
4232 -  
4233 - List<ScheduleRealInfo> listReal=new ArrayList<ScheduleRealInfo>();  
4234 - if(xlbm.equals("")){  
4235 - listReal=scheduleRealInfoRepository.scheduleByDateAndLineByGs_(gsdm, fgsdm,date);  
4236 - }else{  
4237 - listReal=scheduleRealInfoRepository.scheduleByDateAndLineQp(xlbm, date);  
4238 - }  
4239 -  
4240 - List<String> objList = new ArrayList<String>();  
4241 - objList.add(date);  
4242 - String sql="select r.j_gh, r.xl_bm,r.cl_zbh,r.lp_name "  
4243 - + " from bsth_c_s_sp_info_real r where "  
4244 - + " r.schedule_date_str = ?";  
4245 - if(xlbm.length() != 0){  
4246 - sql += " and r.xl_bm = ?";  
4247 - objList.add(xlbm);  
4248 - }  
4249 - if(gsdm.length() != 0){  
4250 - sql += " and r.gs_bm = ?";  
4251 - objList.add(gsdm);  
4252 - }  
4253 - if(fgsdm.length() != 0){  
4254 - sql += " and r.fgs_bm = ?";  
4255 - objList.add(fgsdm);  
4256 - }  
4257 - sql += " group by r.j_gh,r.xl_bm,r.cl_zbh,r.lp_name order by r.xl_bm,r.cl_zbh,r.lp_name";  
4258 -  
4259 -  
4260 - List<Map<String, Object>> list = jdbcTemplate.query(sql, objList.toArray(), new RowMapper<Map<String,Object>>() {  
4261 - @Override  
4262 - public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {  
4263 - Map<String, Object> m=new HashMap<String, Object>();  
4264 - m.put("jGh", arg0.getString("j_gh"));  
4265 - m.put("xlBm", arg0.getString("xl_bm"));  
4266 - m.put("clZbh", arg0.getString("cl_zbh"));  
4267 - m.put("lpName", arg0.getString("lp_name"));  
4268 - return m;  
4269 - }  
4270 - });  
4271 -  
4272 - for (int i = 0; i < list.size(); i++) {  
4273 - Map<String, Object> m=list.get(i);  
4274 - String jGh=m.get("jGh").toString();  
4275 - String xlBm=m.get("xlBm").toString();  
4276 - String clZbh=m.get("clZbh").toString();  
4277 - String lpName=m.get("lpName").toString();  
4278 - List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();  
4279 - List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();  
4280 - String sGh="";  
4281 - String sName="";  
4282 - String jName="";  
4283 - String xlName="";  
4284 - for (int j = 0; j < listReal.size(); j++) {  
4285 - ScheduleRealInfo s=listReal.get(j);  
4286 - if(s.getjGh().equals(jGh)  
4287 - && s.getClZbh().equals(clZbh)  
4288 - &&s.getXlBm().equals(xlBm)  
4289 - &&s.getLpName().equals(lpName)){  
4290 - newList.add(s);  
4291 - if(jName.equals("")){  
4292 - jName=s.getjName();  
4293 - xlName=s.getXlName();  
4294 - }  
4295 - if(sGh.equals("")){  
4296 - if(!StringUtils.isEmpty(s.getsGh())){  
4297 - sGh=s.getsGh();  
4298 - sName=s.getsName();  
4299 - }  
4300 - }  
4301 - Set<ChildTaskPlan> cts = s.getcTasks();  
4302 - if(cts != null && cts.size() > 0){  
4303 - newList_.add(s);  
4304 - }else{  
4305 - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){  
4306 - newList_.add(s);  
4307 - }  
4308 - }  
4309 - }  
4310 - }  
4311 - double yygl=culateMileageService.culateSjgl(newList_);  
4312 - double ljgl=culateMileageService.culateLjgl(newList_);  
4313 - double ksgl=culateMileageService.culateKsgl(newList_);  
4314 - double jcgl=culateMileageService.culateJccgl(newList_);  
4315 - double zyygl=Arith.add(yygl, ljgl);  
4316 - double zksgl=Arith.add(ksgl, jcgl);  
4317 - double zlc=Arith.add(zyygl, zksgl);  
4318 - Map<String, Object> m_=new HashMap<String, Object>();  
4319 - m_.put("zlc", zlc);  
4320 - m_.put("zksgl", zksgl);  
4321 - m_.put("sGh", sGh);  
4322 - m_.put("sName", sName);  
4323 - m_.put("jGh", jGh);  
4324 - m_.put("jName", jName);  
4325 - m_.put("xlName", xlName);  
4326 - mm.put(xlBm+jGh+clZbh+lpName, m_);  
4327 - }  
4328 - List<Map<String, Object>> listAll=new ArrayList<Map<String,Object>>();  
4329 - if(energy.equals("1")){  
4330 - List<String> objList1 = new ArrayList<String>();  
4331 - objList1.add(date);  
4332 - //油统计  
4333 - String ylbSql="select ssgsdm,fgsdm,xlbm,nbbm,jsy,ifnull(lp,'') as lp,czlc,"  
4334 - + " czyl,jzl,jzlc,jzyl,yh,sh,shyy,rylx,ns,zlc,linename,jname "  
4335 - + " from bsth_c_ylb where rq = ?";  
4336 -  
4337 - if(xlbm.length() != 0){  
4338 - ylbSql += " and xlbm = ?";  
4339 - objList1.add(xlbm);  
4340 - }  
4341 - if(gsdm.length() != 0){  
4342 - ylbSql += " and ssgsdm = ?";  
4343 - objList1.add(gsdm);  
4344 - }  
4345 - if(fgsdm.length() != 0){  
4346 - ylbSql += " and fgsdm = ?";  
4347 - objList1.add(fgsdm);  
4348 - }  
4349 - ylbSql += " order by xlbm,nbbm,jcsx";  
4350 - listAll = jdbcTemplate.query(ylbSql, objList1.toArray(), new RowMapper<Map<String,Object>>() {  
4351 - @Override  
4352 - public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {  
4353 - Map<String, Object> m=new HashMap<String, Object>();  
4354 - m.put("ssgsdm", arg0.getString("ssgsdm"));  
4355 - m.put("fgsdm", arg0.getString("fgsdm"));  
4356 - m.put("xlbm", arg0.getString("xlbm"));  
4357 - m.put("nbbm", arg0.getString("nbbm"));  
4358 - m.put("jsy", arg0.getString("jsy"));  
4359 - m.put("lp", arg0.getString("lp"));  
4360 - m.put("czlc", arg0.getDouble("czlc"));  
4361 - m.put("czyl", arg0.getDouble("czyl"));  
4362 - m.put("jzl", arg0.getDouble("jzl"));  
4363 - m.put("jzlc", arg0.getDouble("jzlc"));  
4364 - m.put("jzyl", arg0.getDouble("jzyl"));  
4365 - m.put("yh", arg0.getDouble("yh"));  
4366 - m.put("sh", arg0.getDouble("sh"));  
4367 - m.put("shyy", arg0.getString("shyy"));  
4368 - m.put("rylx", arg0.getString("rylx"));  
4369 - m.put("ns", arg0.getDouble("ns"));  
4370 - m.put("zlc", arg0.getDouble("zlc"));  
4371 - m.put("linename", arg0.getString("linename"));  
4372 - m.put("jname", arg0.getString("jname"));  
4373 - if(arg0.getDouble("zlc")==0){  
4374 - m.put("bglyh", "0.000");  
4375 - }else{  
4376 - DecimalFormat df = new DecimalFormat("0.000");  
4377 - m.put("bglyh", df.format(arg0.getDouble("yh")/arg0.getDouble("zlc")*100));  
4378 - }  
4379 - m.put("gsName", BasicData.businessCodeNameMap.get(arg0.getString("ssgsdm")));  
4380 - m.put("fgsName", BasicData.businessFgsCodeNameMap.get(arg0.getString("fgsdm")+"_"+arg0.getString("ssgsdm")));  
4381 - return m;  
4382 - }  
4383 - });  
4384 -  
4385 - }else{  
4386 - List<String> objList2 = new ArrayList<String>();  
4387 - objList2.add(date);  
4388 - //电统计  
4389 - String dlbSql="select ssgsdm,fgsdm,xlbm,nbbm,jsy,ifnull(lp,'') as lp,czlc,"  
4390 - + " czcd,cdl,jzlc,jzcd,hd,sh,shyy,ns,zlc,linename,jname "  
4391 - + " from bsth_c_dlb where rq = ?";  
4392 - if(xlbm.length() != 0){  
4393 - dlbSql += " and xlbm = ?";  
4394 - objList2.add(xlbm);  
4395 - }  
4396 - if(gsdm.length() != 0){  
4397 - dlbSql += " and ssgsdm = ?";  
4398 - objList2.add(gsdm);  
4399 - }  
4400 - if(fgsdm.length() != 0){  
4401 - dlbSql += " and fgsdm = ?";  
4402 - objList2.add(fgsdm);  
4403 - }  
4404 - dlbSql += " order by xlbm,nbbm,jcsx";  
4405 - listAll = jdbcTemplate.query(dlbSql, objList2.toArray(), new RowMapper<Map<String,Object>>() {  
4406 - @Override  
4407 - public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {  
4408 - Map<String, Object> m=new HashMap<String, Object>();  
4409 - m.put("ssgsdm", arg0.getString("ssgsdm"));  
4410 - m.put("fgsdm", arg0.getString("fgsdm"));  
4411 - m.put("xlbm", arg0.getString("xlbm"));  
4412 - m.put("nbbm", arg0.getString("nbbm"));  
4413 - m.put("jsy", arg0.getString("jsy"));  
4414 - m.put("lp", arg0.getString("lp"));  
4415 - m.put("czlc", arg0.getDouble("czlc"));  
4416 - m.put("czcd", arg0.getDouble("czcd"));  
4417 - m.put("cdl", arg0.getDouble("cdl"));  
4418 - m.put("jzlc", arg0.getDouble("jzlc"));  
4419 - m.put("jzcd", arg0.getDouble("jzcd"));  
4420 - m.put("hd", arg0.getDouble("hd"));  
4421 - m.put("sh", arg0.getDouble("sh"));  
4422 - m.put("shyy", arg0.getString("shyy"));  
4423 - m.put("linename", arg0.getString("linename"));  
4424 - m.put("jname", arg0.getString("jname"));  
4425 - m.put("zlc", arg0.getDouble("zlc"));  
4426 - //电量统计中添加默认中 燃油类型,尿素,保证导出模板相同  
4427 - m.put("rylx", "");  
4428 - m.put("ns", "0");  
4429 - if(arg0.getDouble("zlc")==0){  
4430 - m.put("bglyh", "0.000");  
4431 - }else{  
4432 - DecimalFormat df = new DecimalFormat("0.000");  
4433 - m.put("bglyh", df.format(arg0.getDouble("hd")/arg0.getDouble("zlc")*100));  
4434 - }  
4435 - m.put("gsName", BasicData.businessCodeNameMap.get(arg0.getString("ssgsdm")));  
4436 - m.put("fgsName", BasicData.businessFgsCodeNameMap.get(arg0.getString("fgsdm")+"_"+arg0.getString("ssgsdm")));  
4437 - return m;  
4438 - }  
4439 - });  
4440 - }  
4441 -  
4442 - Map<String, Object> dMap=new HashMap<>();  
4443 - dMap.put("dGroup_eq", "oilType");  
4444 - Iterator<Dictionary> it= dictionaryService.list(dMap).iterator();  
4445 - while (it.hasNext()) {  
4446 - Dictionary d=it.next();  
4447 - dMap.put(d.getdCode(), d.getdName());  
4448 - }  
4449 - for (int i = 0; i < listAll.size(); i++) {  
4450 - Map<String, Object> m=listAll.get(i);  
4451 - String jGh=m.get("jsy").toString();  
4452 - String xlBm=m.get("xlbm").toString();  
4453 - String clZbh=m.get("nbbm").toString();  
4454 - String lpName=m.get("lp")==null?"":m.get("lp").toString();  
4455 - String shyy=m.get("shyy")==null?"":m.get("shyy").toString();  
4456 - String rylx=m.get("rylx")==null?"":m.get("rylx").toString();  
4457 - if(dMap.get(rylx)==null){  
4458 - rylx="";  
4459 - }else{  
4460 - rylx=dMap.get(rylx).toString();  
4461 - }  
4462 - m.put("rylx", rylx);  
4463 - m.put("shyy", getShyy(shyy));  
4464 - m.put("date", date);  
4465 -  
4466 - if(mm.get(xlBm+jGh+clZbh+lpName)!=null){  
4467 - Map<String, Object> m_=mm.get(xlBm+jGh+clZbh+lpName);  
4468 - m.put("zlcAll", m_.get("zlc")==null?"":m_.get("zlc").toString());  
4469 - m.put("zksgl", m_.get("zksgl")==null?"":m_.get("zksgl").toString());  
4470 - m.put("sGh", m_.get("sGh")==null?"":m_.get("sGh").toString());  
4471 - m.put("sName", m_.get("sName")==null?"":m_.get("sName").toString());  
4472 - m.put("jname", m_.get("jName")==null?"":m_.get("jName").toString());  
4473 - m.put("linename", m_.get("xlName")==null?"":m_.get("xlName").toString());  
4474 - }else{  
4475 - m.put("zlcAll", "");  
4476 - m.put("zksgl", "");  
4477 - m.put("sGh", "");  
4478 - m.put("sName", "");  
4479 - //油量表中历史数据和手动添加数据没有储存线路名字与驾驶员名字,是null的字段则根据编号查找  
4480 - if(m.get("linename")==null){  
4481 - m.put("linename", BasicData.lineCode2NameMap.get(xlBm));  
4482 - }  
4483 - if(m.get("jname")==null){  
4484 - m.put("jname", BasicData.allPerson.get(m.get("ssgsdm")+"-"+jGh));  
4485 - }  
4486 - }  
4487 - }  
4488 -  
4489 - if(map.get("type").toString().equals("export")){  
4490 - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();  
4491 - Map<String, Object> m = new HashMap<String, Object>();  
4492 - m.put("date", date);  
4493 - ReportUtils ee = new ReportUtils();  
4494 - try {  
4495 - listI.add(listAll.iterator());  
4496 - if(energy.equals("1")){  
4497 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
4498 - ee.excelReplace(listI, new Object[]{m}, path + "mould/energy_ylb.xls",  
4499 - path + "export/"+date+"路单油量统计表.xls");  
4500 - }else{  
4501 - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";  
4502 - ee.excelReplace(listI, new Object[]{m}, path + "mould/energy_dlb.xls",  
4503 - path + "export/"+date+"路单电量统计表.xls");  
4504 - }  
4505 -  
4506 - } catch (Exception e) {  
4507 - // TODO: handle exception  
4508 - e.printStackTrace();  
4509 - }  
4510 - }  
4511 - return listAll;  
4512 - }  
4513 -  
4514 - public Map<String,Object> calcDetailMonthlyE(Map<String, Object> map){  
4515 -  
4516 -// List<List<String>> list = calcWaybillService.calcDetailMonthly(map);  
4517 - List<List<String>> list = calcWaybillService.calcDetailMonthlyNew(map);  
4518 -  
4519 - Map<String, Object> resultMap = new HashMap<String, Object>();  
4520 - try {  
4521 - String name = map.get("name").toString();  
4522 - String type = map.get("statisticalObj").toString();  
4523 - if(list.size()>0){  
4524 - ReportUtils ee = new ReportUtils();  
4525 - ee.createFlie(list,name,type);  
4526 - }  
4527 -  
4528 - resultMap.put("status", ResponseCode.SUCCESS);  
4529 - } catch (Exception e) {  
4530 - resultMap.put("status", ResponseCode.ERROR);  
4531 - logger.error("save erro.", e);  
4532 - }  
4533 - return resultMap;  
4534 - }  
4535 -  
4536 - private String getShyy(String node){  
4537 - String shyy ="无";  
4538 - if(!node.equals("")){  
4539 - if(node.equals("1")){shyy="票务用油";}  
4540 - else if(node.equals("2")){shyy="保养用油";}  
4541 - else if(node.equals("3")){shyy="报废车用油";}  
4542 - else if(node.equals("4")){shyy="其它用油";}  
4543 - else if(node.equals("5")){shyy="人保部";}  
4544 - else if(node.equals("6")){shyy="车队";}  
4545 - else if(node.equals("7")){shyy="车间(高保)";}  
4546 - else if(node.equals("8")){shyy="车间(小修)";}  
4547 - else{shyy ="无";}  
4548 - }  
4549 - return shyy;  
4550 - }  
4551 -  
4552 -}  
4553 -  
4554 -class ComparableAcuals implements Comparator<ScheduleRealInfo>{  
4555 -  
4556 - @Override  
4557 - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {  
4558 - // TODO Auto-generated method stub  
4559 - return o1.getFcsjActualTime().compareTo(o2.getFcsjActualTime());  
4560 - }  
4561 - 1 +package com.bsth.service.report.impl;
  2 +import com.bsth.common.ResponseCode;
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.entity.Business;
  5 +import com.bsth.entity.Line;
  6 +import com.bsth.entity.Personnel;
  7 +import com.bsth.entity.StationRoute;
  8 +import com.bsth.entity.excep.ArrivalInfo;
  9 +import com.bsth.entity.mcy_forms.Singledata;
  10 +import com.bsth.entity.oil.Dlb;
  11 +import com.bsth.entity.oil.Ylb;
  12 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  13 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  14 +import com.bsth.entity.sys.Dictionary;
  15 +import com.bsth.entity.sys.Interval;
  16 +import com.bsth.repository.BusinessRepository;
  17 +import com.bsth.repository.LineRepository;
  18 +import com.bsth.repository.LsStationRouteRepository;
  19 +import com.bsth.repository.StationRouteRepository;
  20 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  21 +import com.bsth.service.LineService;
  22 +import com.bsth.service.calc.CalcWaybillService;
  23 +import com.bsth.service.report.CulateMileageService;
  24 +import com.bsth.service.report.ReportService;
  25 +import com.bsth.service.sys.DictionaryService;
  26 +import com.bsth.util.Arith;
  27 +import com.bsth.util.ComparableChild;
  28 +import com.bsth.util.ComparableJob;
  29 +import com.bsth.util.ReportUtils;
  30 +import com.bsth.util.db.DBUtils_MS;
  31 +
  32 +import org.apache.commons.lang.StringUtils;
  33 +import org.slf4j.Logger;
  34 +import org.slf4j.LoggerFactory;
  35 +import org.springframework.beans.factory.annotation.Autowired;
  36 +import org.springframework.jdbc.core.JdbcTemplate;
  37 +import org.springframework.jdbc.core.RowMapper;
  38 +import org.springframework.stereotype.Service;
  39 +
  40 +import java.math.BigDecimal;
  41 +import java.sql.Connection;
  42 +import java.sql.PreparedStatement;
  43 +import java.sql.ResultSet;
  44 +import java.sql.SQLException;
  45 +import java.text.DecimalFormat;
  46 +import java.text.ParseException;
  47 +import java.text.SimpleDateFormat;
  48 +import java.util.*;
  49 +import java.util.concurrent.atomic.AtomicBoolean;
  50 +
  51 +@Service
  52 +public class ReportServiceImpl implements ReportService{
  53 +
  54 + private static long zgf1 = 6 * 60 + 31,
  55 + zgf2 = 8 * 60 + 30,
  56 + wgf1 = 16 * 60 + 1,
  57 + wgf2 = 18 * 60;
  58 +
  59 + private Logger logger = LoggerFactory.getLogger(this.getClass());
  60 +
  61 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  62 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  63 +
  64 + @Autowired
  65 + JdbcTemplate jdbcTemplate;
  66 +
  67 + @Autowired
  68 + ScheduleRealInfoRepository scheduleRealInfoRepository;
  69 + @Autowired
  70 + StationRouteRepository stationRoutRepository;
  71 + @Autowired
  72 + CulateMileageService culateService;
  73 + @Autowired
  74 + LineService lineService;
  75 + @Autowired
  76 + LineRepository lineRepository;
  77 + @Autowired
  78 + StationRouteRepository stationRouteRepository;
  79 + @Autowired
  80 + LsStationRouteRepository lsStationRouteRepository;
  81 + @Autowired
  82 + CulateMileageService culateMileageService;
  83 + @Autowired
  84 + DictionaryService dictionaryService;
  85 + @Autowired
  86 + CalcWaybillService calcWaybillService;
  87 + @Autowired
  88 + BusinessRepository businessRepository;
  89 +
  90 + /**
  91 + * calcDetailMonthlyE是否正在执行
  92 + */
  93 + private boolean executing = false;
  94 +
  95 + @Override
  96 + public List<ScheduleRealInfo> queryListBczx(String line, String date,String clzbh) {
  97 + // TODO Auto-generated method stub
  98 + List<ScheduleRealInfo> list=scheduleRealInfoRepository.findByDate2(line,date,clzbh);
  99 +
  100 +// jdbcTemplate.query("select * from bsth_c_s_sp_info_real where line=?1 "
  101 +// + "and DATE_FORMAT(schedule_date,'%Y-%m-%d')=?2 and cl_zbl=?3",
  102 +// new Object[]{line,date,clzbh},
  103 +// new RowMapper(){
  104 +// @Override
  105 +// public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
  106 +// ScheduleRealInfo s = new ScheduleRealInfo();
  107 +//// s.
  108 +// return s;
  109 +// }
  110 +// });
  111 +
  112 + return list;
  113 + }
  114 + @Override
  115 + public List<ArrivalInfo> queryListZdxx(String line, String date, String clzbh, String sjfc, String sjdd) {
  116 + // TODO Auto-generated method stub
  117 + List<ArrivalInfo> list=new ArrayList<ArrivalInfo>();
  118 + try {
  119 + String sbbb=BasicData.deviceId2NbbmMap.inverse().get(clzbh);
  120 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  121 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  122 +// Long date1=simpleDateFormat.parse(date+" "+sjfc+":00").getTime();
  123 +// Long date2=simpleDateFormat.parse(date+" "+sjdd+":00").getTime();
  124 + Long date1=simpleDateFormat.parse(sjfc+":00").getTime();
  125 + Long date2=simpleDateFormat.parse(sjdd+":00").getTime();
  126 + Date dates=simpleDateFormat.parse(date+" 00:00:00");
  127 + List<ArrivalInfo> lists=load(line,sbbb,date1,date2,dates,date);
  128 +
  129 + for(int i=0;i<lists.size();i++){
  130 + ArrivalInfo t1=lists.get(i);
  131 + if(t1.getInOut()==0){
  132 + t1.setJzsj(sdf.format(new Date(t1.getTs())));
  133 + for(int j=0;j<lists.size();j++){
  134 + ArrivalInfo t2=lists.get(j);
  135 + if(t2.getInOut()==1 && t2.getDeviceId().equals(t1.getDeviceId()) && t2.getStopNo().equals(t1.getStopNo())){
  136 + t1.setCzsj(sdf.format(new Date(t2.getTs())));
  137 + }
  138 + }
  139 + list.add(t1);
  140 + }
  141 +
  142 + }
  143 +
  144 +
  145 + } catch (ParseException e) {
  146 + // TODO Auto-generated catch block
  147 + e.printStackTrace();
  148 + }
  149 +
  150 + return list;
  151 + }
  152 +
  153 +
  154 + public List<ArrivalInfo> load(String line,String sbbb,Long date1,Long date2,Date dates,String date){
  155 + List<ArrivalInfo> list = null;
  156 + Calendar cal = Calendar.getInstance();
  157 + cal.setTime(dates);
  158 + //周数,表分区字段
  159 + int weeks_year = cal.get(Calendar.WEEK_OF_YEAR);
  160 + int weeks_year_next=weeks_year +1;
  161 + Connection conn = null;
  162 + PreparedStatement ps = null;
  163 + ResultSet rs = null;
  164 + String year=date.substring(0,4);
  165 + String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year in (?, ?) AND line_id=? "
  166 + + " AND ts >= ? AND ts <=? AND device_id=? order by ts";
  167 + try{
  168 + conn = DBUtils_MS.getConnection();
  169 + ps = conn.prepareStatement(sql);
  170 + ps.setInt(1, weeks_year);
  171 + ps.setInt(2, weeks_year_next);
  172 + ps.setString(3,line);
  173 + ps.setLong(4, date1);
  174 + ps.setLong(5, date2);
  175 + ps.setString(6, sbbb);
  176 + rs = ps.executeQuery();
  177 +
  178 + list = resultSet2Set(rs);
  179 + }catch(Exception e){
  180 + logger.error("", e);
  181 + }finally {
  182 + DBUtils_MS.close(rs, ps, conn);
  183 + }
  184 + return list;
  185 + }
  186 +
  187 + public List<ArrivalInfo> resultSet2Set(ResultSet rs) throws SQLException{
  188 + List<ArrivalInfo> list = new ArrayList<>();
  189 +
  190 + ArrivalInfo arr;
  191 + while(rs.next()){
  192 + arr = new ArrivalInfo();
  193 + arr.setDeviceId(rs.getString("device_id"));
  194 + String nbbm=BasicData.deviceId2NbbmMap.get(arr.getDeviceId());
  195 + arr.setNbbm(nbbm);
  196 + arr.setPzh(BasicData.nbbmCompanyPlateMap.get(nbbm));
  197 + if(null == arr.getNbbm()){
  198 + logger.warn("未注册的设备号," + arr.getDeviceId());
  199 + continue;
  200 + }
  201 +
  202 + arr.setTs(rs.getLong("ts"));
  203 + arr.setLineCode(rs.getString("line_id"));
  204 + arr.setUpDown(rs.getInt("up_down"));
  205 + arr.setStopNo(rs.getString("stop_no"));
  206 + arr.setStopName(BasicData.stationCode2NameMap.get(rs.getString("line_id")+"_"+rs.getInt("up_down")+"_"+rs.getString("stop_no")));
  207 + arr.setInOut(rs.getInt("in_out"));
  208 + arr.setCreateDate(rs.getLong("create_timestamp"));
  209 + arr.setWeeksYear(rs.getInt("weeks_year"));
  210 + arr.setEnable(true);
  211 +
  212 + list.add(arr);
  213 + }
  214 + return list;
  215 + }
  216 + @Override
  217 + public List<ArrivalInfo> queryListClzd(String line, String zd, String zdlx, String fcsj, String ddsj) {
  218 + // TODO Auto-generated method stub
  219 + List<ArrivalInfo> list=new ArrayList<ArrivalInfo>();
  220 + try {
  221 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  222 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  223 + Long date1=simpleDateFormat.parse(fcsj+":00").getTime();
  224 + Long date2=simpleDateFormat.parse(ddsj+":00").getTime();
  225 + Date dates1=simpleDateFormat.parse(fcsj+":00");
  226 + Date dates2=simpleDateFormat.parse(ddsj+":00");
  227 + List<ArrivalInfo> lists = new ArrayList<ArrivalInfo>();
  228 + if(zd.contains(",")){
  229 + String[] split = zd.split(",");
  230 + for(String s : split){
  231 + lists.addAll(load2(line,date1,date2,dates1,dates2,s,zdlx,fcsj));
  232 + }
  233 + } else {
  234 + lists.addAll(load2(line,date1,date2,dates1,dates2,zd,zdlx,fcsj));
  235 + }
  236 +
  237 + for(int i=0;i<lists.size();i++){
  238 + ArrivalInfo t1=lists.get(i);
  239 + if(t1.getInOut()==0){
  240 + t1.setJzsj(sdf.format(new Date(t1.getTs())));
  241 + for(int j=0;j<lists.size();j++){
  242 + ArrivalInfo t2=lists.get(j);
  243 + if(t2.getDeviceId().equals(t1.getDeviceId())
  244 + && t2.getStopNo().equals(t1.getStopNo())
  245 + && t2.getTs()>t1.getTs()){
  246 + if(t2.getInOut() == 1){//下一个同站同车是出站信号则获取出站时间
  247 + t1.setCzsj(sdf.format(new Date(t2.getTs())));
  248 + break;//下一个同站同车是进站信号则认为出站信号丢失
  249 + } else if(t2.getInOut() == 0){
  250 + break;
  251 + }
  252 + }
  253 + }
  254 + list.add(t1);
  255 + }
  256 +
  257 + }
  258 +
  259 +
  260 + } catch (ParseException e) {
  261 + // TODO Auto-generated catch block
  262 + e.printStackTrace();
  263 + }
  264 +
  265 + return list;
  266 + }
  267 +
  268 +
  269 + public List<ArrivalInfo> load2(String line,Long date1,Long date2,Date dates1,Date dates2,String zd,String zdlx,String fcsj){
  270 + SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");
  271 + List<ArrivalInfo> list = new ArrayList<ArrivalInfo>();
  272 + Calendar cal = Calendar.getInstance();
  273 + cal.setTime(dates1);
  274 + //周数,表分区字段
  275 + int weeks_year1 = cal.get(Calendar.WEEK_OF_YEAR);
  276 + cal.setTime(dates2);
  277 + int weeks_year2 = cal.get(Calendar.WEEK_OF_YEAR);
  278 + Connection conn = null;
  279 + PreparedStatement ps = null;
  280 + ResultSet rs = null;
  281 + String year=fcsj.substring(0,4);
  282 +
  283 + String year1 = yearFormat.format(dates1);
  284 + String year2 = yearFormat.format(dates2);
  285 + List<Integer> weeksList = new ArrayList<Integer>();
  286 + if(year1.equals(year2)){
  287 + //把每一周的编号加入list,一年最多五十几周。最多循环60次避免意外死循环
  288 + for(int w = 0, weeks_num = weeks_year1; w < 60 && weeks_num <= weeks_year2; w++, weeks_num++){
  289 + weeksList.add(weeks_num);
  290 + }
  291 + } else {
  292 + weeksList.add(weeks_year1);
  293 + weeksList.add(weeks_year2);
  294 + }
  295 +
  296 + String tempStr = "";
  297 + for(int i = 0; i < weeksList.size(); i++){
  298 + tempStr += "?,";
  299 + }
  300 + if(tempStr.length() > 0){
  301 + tempStr = tempStr.substring(0, tempStr.length() - 1);
  302 + }
  303 +
  304 + String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year in ("+tempStr+") "
  305 + + " AND line_id=? AND up_down=? AND stop_no like ? AND ts between ? AND ? order by ts";
  306 + System.out.println(sql);
  307 + try{
  308 + conn = DBUtils_MS.getConnection();
  309 + ps = conn.prepareStatement(sql);
  310 + int no = 1;
  311 + for(;no <= weeksList.size(); no++){
  312 + ps.setInt(no, weeksList.get(no-1));
  313 + }
  314 + ps.setString(no++, line);
  315 + ps.setString(no++, zdlx);
  316 + ps.setString(no++, ""+zd+"%");
  317 + ps.setLong(no++, date1);
  318 + ps.setLong(no++, date2);
  319 + rs = ps.executeQuery();
  320 +
  321 + list = resultSet2Set(rs);
  322 + }catch(Exception e){
  323 + logger.error("", e);
  324 + }finally {
  325 + DBUtils_MS.close(rs, ps, conn);
  326 + }
  327 + return list;
  328 + }
  329 + @Override
  330 + public List<Map<String, String>> sreachZd(String line, int zdlx, String date1, String date2) {
  331 + List<Map<String, String>> list = new ArrayList<>();
  332 + // TODO Auto-generated method stub
  333 + if(date1.length() >= 10 && date1.length() >= 10){
  334 + date1 = date1.substring(0, 10);
  335 + date2 = date2.substring(0, 10);
  336 + List<Object[]> findHistory = lsStationRouteRepository.findHistory(line, zdlx, date1, date2);
  337 + Set<String> tempSet = new HashSet<String>();
  338 + for(Object[] obj : findHistory){
  339 + if(obj[2] != null && obj[2].toString().trim().length() > 0){
  340 + tempSet.add(obj[2].toString().trim());
  341 + }
  342 + }
  343 + for(Object[] obj : findHistory){
  344 + int length = tempSet.toArray().length;
  345 + Map<String, String> reMap = new HashMap<String, String>();
  346 + reMap.put("id", obj[0].toString());
  347 + reMap.put("text", obj[1] + (length > 1 ? (" -版本" + obj[2]) : ""));
  348 + list.add(reMap);
  349 + }
  350 + }
  351 +
  352 + return list;
  353 + }
  354 + @Override
  355 + public List<Object[]> historyMessageCount(String line, String date, String code) {
  356 + // TODO Auto-generated method stub
  357 + List<Object[]> list = scheduleRealInfoRepository.historyMessageCount(line, date, code);
  358 + return list;
  359 + }
  360 + @Override
  361 + public List<Object[]> historyMessageList(String line, String date, String code,String type) {
  362 + // TODO Auto-generated method stub
  363 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  364 +
  365 + List<Object[]> list = scheduleRealInfoRepository.historyMessageList(line, date, code);
  366 + for (Object[] obj : list) {
  367 + if (obj != null) {
  368 + obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));
  369 + }
  370 + }
  371 +
  372 + if (type != null && type.length() != 0 && type.equals("export_msg")) {
  373 + String lineName = BasicData.lineCode2NameMap.get(line);
  374 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  375 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  376 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  377 + Map<String, Object> m = new HashMap<String, Object>();
  378 + ReportUtils ee = new ReportUtils();
  379 + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
  380 + for (int i = 0; i < list.size(); i++) {
  381 + Map<String, Object> map = new HashMap<String, Object>();
  382 + Object[] obj = list.get(i);
  383 + map.put("num", i + 1);
  384 + map.put("line", obj[0]);
  385 + map.put("clZbh", obj[1]);
  386 + map.put("sender", obj[2]);
  387 + map.put("date", obj[3]);
  388 + map.put("text", obj[4]);
  389 + newList.add(map);
  390 + }
  391 + try {
  392 + listI.add(newList.iterator());
  393 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  394 + ee.excelReplace(listI, new Object[]{m}, path + "mould/message.xls",
  395 + path + "export/" + sdfSimple.format(sdfMonth.parse(date))
  396 + + "-" + lineName + "-调度消息分析.xls");
  397 + } catch (Exception e) {
  398 + // TODO: handle exception
  399 + e.printStackTrace();
  400 + }
  401 + }
  402 + return list;
  403 + }
  404 +
  405 + @Override
  406 + public Map<String, Object> tbodyTime1(String line, String ttinfo) {
  407 + DecimalFormat df = new DecimalFormat("#0.00");
  408 + Map<String, Object> map=new HashMap<String,Object>();
  409 + // TODO Auto-generated method stub
  410 +
  411 + List<String> objList = new ArrayList<String>();
  412 + objList.add(ttinfo);
  413 +
  414 + //查询配车
  415 + String sqlPc=" select count(*) from (select lp, count(*) from"
  416 + + " bsth_c_s_ttinfo_detail where ttinfo = ?"
  417 + + " group by lp ) a";
  418 + //配车
  419 + int pcs=jdbcTemplate.queryForObject(sqlPc, objList.toArray(), Integer.class);
  420 +
  421 +
  422 + String sqlPlan=" SELECT jhlc,bc_type,fcsj FROM bsth_c_s_ttinfo_detail "
  423 + +" where ttinfo = ? ";
  424 +
  425 + //查询班次
  426 + List<Map<String, Object>> listPlan= jdbcTemplate.query(sqlPlan, objList.toArray(),
  427 + new RowMapper<Map<String, Object>>(){
  428 + @Override
  429 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  430 + Map<String, Object> m2=new HashMap<String,Object>();
  431 + m2.put("jhlc", rs.getDouble("jhlc"));
  432 + m2.put("bcType", rs.getString("bc_type"));
  433 + m2.put("fcsj", rs.getString("fcsj"));
  434 + return m2;
  435 + }
  436 + });
  437 +
  438 + //班次
  439 + int zgf_0 = 6*60+31,zgf_1 = 8*60+30,wgf_0 = 16*60+1,wgf_1 = 18*60;
  440 + int qcBc=0,qjBc=0,zqcBc=0,zqjBc=0,wqcBc=0,wqjBc=0;
  441 + double zlc = 0 , yylc = 0,kslc=0;
  442 +
  443 + for (int i = 0; i < listPlan.size(); i++) {
  444 + Map<String, Object> m=listPlan.get(i);
  445 + double jhlc=Double.parseDouble(m.get("jhlc").toString());
  446 + String bcType=m.get("bcType").toString();
  447 + String fcsjs[]=m.get("fcsj").toString().split(":");
  448 +
  449 + zlc +=jhlc;
  450 + if(bcType.equals("in") || bcType.equals("out")){
  451 + kslc+=jhlc;
  452 + }
  453 + else if(bcType.equals("region")){
  454 + qjBc++;
  455 + if((Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) > zgf_0
  456 + && (Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) < zgf_1){
  457 + zqjBc++;
  458 + }else if((Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) > wgf_0
  459 + && (Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) < wgf_1){
  460 + wqjBc++;
  461 + }
  462 +
  463 + yylc+=jhlc;
  464 + }else{
  465 + qcBc ++;
  466 + if((Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) > zgf_0
  467 + && (Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) < zgf_1){
  468 + zqcBc++;
  469 + }else if((Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) > wgf_0
  470 + && (Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1])) < wgf_1){
  471 + wqcBc++;
  472 + }
  473 + yylc +=jhlc;
  474 + }
  475 + }
  476 +
  477 + map.put("pcs", pcs);
  478 + map.put("qcbc", qcBc);
  479 + map.put("qjbc", qjBc);
  480 + map.put("zqcbc", zqcBc);
  481 + map.put("zqjbc", zqjBc);
  482 + map.put("wqcbc", wqcBc);
  483 + map.put("wqjbc", wqjBc);
  484 + map.put("zlc", df.format( zlc));
  485 + map.put("yylc", df.format(yylc));
  486 + map.put("kslc",df.format( kslc));
  487 + //查询里程
  488 + return map;
  489 + }
  490 + @Override
  491 + public Map<String, Object> tbodyTime2(String line, String ttinfo) {
  492 + DecimalFormat df = new DecimalFormat("#0.00");
  493 + // TODO Auto-generated method stub
  494 + //最早营运时间 区分夜宵线
  495 + String minfcsj="02:00";
  496 + List<Line> lineList=lineRepository.findLineByCode(line);
  497 + if(lineList.size()>0){
  498 + List<String> objList = new ArrayList<String>();
  499 + objList.add(lineList.get(0).getId() + "");
  500 + String sql = "select count(*) from bsth_c_line_config where line = ? ";
  501 + if(jdbcTemplate.queryForObject(sql, objList.toArray(), Integer.class) > 0){
  502 + String sqlMinYysj="select start_opt from bsth_c_line_config where "
  503 + + " id = ("
  504 + + "select max(id) from bsth_c_line_config where line = ? "
  505 + + ")";
  506 + minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, objList.toArray(), String.class);
  507 + }
  508 + }
  509 + String[] minSjs = minfcsj.split(":");
  510 + int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]);
  511 +
  512 + List<String> objList = new ArrayList<String>();
  513 + objList.add(ttinfo);
  514 + objList.add(minfcsj);
  515 + objList.add(ttinfo);
  516 + objList.add(minfcsj);
  517 + //查询时间里程
  518 + String sqlPc=" (SELECT jhlc,fcsj,bc_type,bcsj,lp,2 as xh, ists FROM bsth_c_s_ttinfo_detail "
  519 + + " where ttinfo = ? and fcsj <= ? ) "
  520 + + " union "
  521 + + " (SELECT jhlc,fcsj,bc_type,bcsj,lp,1 as xh, ists FROM bsth_c_s_ttinfo_detail "
  522 + + " where ttinfo = ? and fcsj > ? ) order by lp,xh,fcsj";
  523 + Map<String, Object> map=new HashMap<String,Object>();
  524 + List<Map<String, Object>> list= jdbcTemplate.query(sqlPc, objList.toArray(),
  525 + new RowMapper<Map<String, Object>>(){
  526 + @Override
  527 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  528 + Map<String, Object> m=new HashMap<String,Object>();
  529 + m.put("fcsj", rs.getString("fcsj"));
  530 + m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc"));
  531 + m.put("bcType", rs.getString("bc_type"));
  532 + m.put("bcsj", rs.getString("bcsj"));
  533 + m.put("lp", rs.getString("lp"));
  534 + m.put("ists", rs.getObject("ists")==null?"0":rs.getString("ists"));
  535 + return m;
  536 + }
  537 + });
  538 +
  539 + int yysj=0;
  540 + double yycs=0 ,yygl=0;
  541 + String lp ="0";
  542 + int sj=0, bcsj = 0;
  543 + int temp = 0;
  544 + for(int i=0;i<list.size();i++){
  545 + Map<String, Object> m=list.get(i);
  546 + String time=m.get("fcsj").toString();
  547 + String[] times = time.split(":");
  548 + int sjT = Integer.parseInt(times[0])*60+Integer.parseInt(times[1]);
  549 + if(lp.equals(m.get("lp").toString())){
  550 + if(sjT <= minSj){
  551 + if(m.get("bcType").equals("in") || m.get("bcType").equals("out")){
  552 + if(m.get("bcType").equals("in")){
  553 + if(sj!=0){
  554 +// yysj += sjT + (24*60) - sj;
  555 + yysj += bcsj;
  556 + bcsj = 0;
  557 + }
  558 + sj=0;
  559 + }
  560 + }else{
  561 + yygl += Double.parseDouble(m.get("yygl").toString());
  562 +
  563 + if(sj==0){
  564 + sj = sjT + (24*60);
  565 + }else{
  566 + yysj += sjT + (24*60) - sj;
  567 + if(m.containsKey("ists") && m.get("ists").equals("1")){
  568 + yysj += Integer.valueOf(m.get("bcsj").toString());
  569 + } else {
  570 + sj = sjT + (24*60);
  571 + }
  572 + }
  573 + }
  574 + }else{
  575 + if(m.get("bcType").equals("in") || m.get("bcType").equals("out")){
  576 + if(m.get("bcType").equals("in")){
  577 + if(sj!=0){
  578 +// yysj += sjT - sj;
  579 + yysj += bcsj;
  580 + bcsj = 0;
  581 + }
  582 + sj=0;
  583 + }
  584 + } else {
  585 + yygl += Double.parseDouble(m.get("yygl").toString());
  586 +
  587 + if(sj==0){
  588 + sj = sjT;
  589 + }else{
  590 + yysj += sjT - sj;
  591 + if(m.containsKey("ists") && m.get("ists").equals("1")){
  592 + yysj += Integer.valueOf(m.get("bcsj").toString());
  593 + } else {
  594 + sj = sjT;
  595 + }
  596 + }
  597 + }
  598 + }
  599 + }else{
  600 + if(sj == 0){
  601 + yysj += bcsj;
  602 + bcsj = 0;
  603 + }
  604 + if( !(m.get("bcType").equals("in") || m.get("bcType").equals("out"))){
  605 + yygl += Double.parseDouble(m.get("yygl").toString());
  606 + sj = sjT;
  607 + }else{
  608 + sj=0;
  609 + }
  610 + lp=m.get("lp").toString();
  611 + }
  612 +
  613 + if(m.containsKey("ists") && m.get("ists").equals("1")){
  614 + sj = 0;
  615 + }
  616 + if( !(m.get("bcType").equals("in") || m.get("bcType").equals("out")))
  617 + bcsj = Integer.valueOf(m.get("bcsj").toString());
  618 + }
  619 +
  620 + if(yysj>0){
  621 + yycs =yygl/(yysj*1.0/60);
  622 + }
  623 + int hh=yysj/60;
  624 + int mm=yysj%60;
  625 +
  626 + map.put("yysj", hh+":"+mm);
  627 + map.put("yycs", df.format(yycs)+"公里/小时");
  628 +// map.put(key, value)
  629 +
  630 + return map;
  631 + }
  632 +
  633 + public static void main(String[] args) {
  634 + System.out.println(609360/60);
  635 + System.out.println(609360%60);
  636 + }
  637 +
  638 + @Override
  639 + public List<Map<String, Object>> tbodyTime3(String line, String ttinfo) {
  640 + // TODO Auto-generated method stub
  641 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  642 + List<Map<String, Object>> list_s=new ArrayList<Map<String,Object>>();
  643 +
  644 + List<String> objList = new ArrayList<String>();
  645 + objList.add(ttinfo);
  646 + String sqlCl="SELECT lp cl_zbh,qdz_name,bc_type,fcsj,bcsj FROM"
  647 + + " bsth_c_s_ttinfo_detail WHERE ttinfo = ? "
  648 + + " AND (bc_type = 'normal' or bc_type='region') order by qdz_name";
  649 +
  650 + List<Map<String, Object>> listj= jdbcTemplate.query(sqlCl, objList.toArray(),
  651 + new RowMapper<Map<String, Object>>(){
  652 + @Override
  653 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  654 + Map<String, Object> m=new HashMap<String,Object>();
  655 + m.put("cl_zbh", rs.getString("cl_zbh"));
  656 + m.put("qdz_name", rs.getString("qdz_name"));
  657 + m.put("bcType", rs.getString("bc_type"));
  658 + m.put("fcsj", rs.getString("fcsj"));
  659 + m.put("bcsj", rs.getString("bcsj"));
  660 + return m;
  661 + }
  662 + });
  663 +
  664 + String sqlZd="select qdz_name,bc_type from bsth_c_s_ttinfo_detail WHERE ttinfo = ? "
  665 + + " AND (bc_type = 'normal' or bc_type='region') group by qdz_name ,bc_type "
  666 + + " order by qdz_name";
  667 + List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd, objList.toArray(),
  668 + new RowMapper<Map<String, Object>>(){
  669 + @Override
  670 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  671 + Map<String, Object> m=new HashMap<String,Object>();
  672 + m.put("zdm", rs.getString("qdz_name"));
  673 + m.put("bcType", rs.getString("bc_type"));
  674 + return m;
  675 + }
  676 + });
  677 +
  678 + for (int i = 0; i < lists.size(); i++) {
  679 + Map<String, Object> z=new HashMap<String,Object>();
  680 + Map<String, Object> w=new HashMap<String,Object>();
  681 + Map<String, Object> p=lists.get(i);
  682 + int zbcs=0;
  683 + int wbcs=0;
  684 + if(p.get("bcType").toString().equals("normal")){
  685 + for (int j = 0; j < listj.size(); j++) {
  686 + if(listj.get(j).get("qdz_name").toString().equals(p.get("zdm").toString()) &&
  687 + listj.get(j).get("bcType").toString().equals("normal")){
  688 + String time=listj.get(j).get("fcsj").toString();
  689 + long bcsj= Long.parseLong(listj.get(j).get("bcsj").toString());
  690 + String clZbh=listj.get(j).get("cl_zbh").toString();
  691 + String[] fcsjStr = time.split(":");
  692 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  693 + long ddsj=fcsj+bcsj;
  694 + if((fcsj>=zgf1 && fcsj<=zgf2) || (ddsj>=zgf1&&ddsj<=zgf2)
  695 + || (fcsj<zgf1&&ddsj>zgf2)){
  696 + if(p.get("z"+clZbh)==null){
  697 + zbcs++;
  698 + p.put("z"+clZbh, clZbh);
  699 + }
  700 + }
  701 +
  702 + if((fcsj>=wgf1 && fcsj<=wgf2) || (ddsj>=wgf1&&ddsj<=wgf2)
  703 + || (fcsj<wgf1&&ddsj>wgf2)){
  704 + if(p.get("w"+clZbh)==null){
  705 + wbcs++;
  706 + p.put("w"+clZbh, clZbh);
  707 + }
  708 + }
  709 + }
  710 +
  711 + }
  712 + if(zbcs>0){
  713 + z.put("zdm", p.get("zdm"));
  714 + z.put("cls", zbcs);
  715 + z.put("lx", "zqc");
  716 + list_s.add(z);
  717 + }
  718 + if(wbcs>0){
  719 + w.put("zdm", p.get("zdm"));
  720 + w.put("cls", zbcs);
  721 + w.put("lx", "wqc");
  722 + list_s.add(w);
  723 + }
  724 +
  725 + }
  726 +
  727 + if(p.get("bcType").equals("region")){
  728 + for (int j = 0; j < listj.size(); j++) {
  729 + if(listj.get(j).get("qdz_name").toString().equals(p.get("zdm").toString()) &&
  730 + listj.get(j).get("bcType").toString().equals("region")){
  731 + String time=listj.get(j).get("fcsj").toString();
  732 + long bcsj= Long.parseLong(listj.get(j).get("bcsj").toString());
  733 + String clZbh=listj.get(j).get("cl_zbh").toString();
  734 + String[] fcsjStr = time.split(":");
  735 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  736 + long ddsj=fcsj+bcsj;
  737 + if((fcsj>=zgf1 && fcsj<=zgf2) || (ddsj>=zgf1&&ddsj<=zgf2)
  738 + || (fcsj<zgf1&&ddsj>zgf2)){
  739 + if(p.get("z"+clZbh)==null){
  740 + zbcs++;
  741 + p.put("z"+clZbh, clZbh);
  742 + }
  743 + }
  744 +
  745 + if((fcsj>=wgf1 && fcsj<=wgf2) || (ddsj>=wgf1&&ddsj<=wgf2)
  746 + || (fcsj<wgf1&&ddsj>wgf2)){
  747 + if(p.get("w"+clZbh)==null){
  748 + wbcs++;
  749 + p.put("w"+clZbh, clZbh);
  750 + }
  751 + }
  752 + }
  753 +
  754 + }
  755 + if(zbcs>0){
  756 + z.put("zdm", p.get("zdm"));
  757 + z.put("cls", zbcs);
  758 + z.put("lx", "zqj");
  759 + list_s.add(z);
  760 + }
  761 + if(wbcs>0){
  762 + w.put("zdm", p.get("zdm"));
  763 + w.put("cls", zbcs);
  764 + w.put("lx", "wqj");
  765 + list_s.add(w);
  766 + }
  767 + }
  768 +
  769 + }
  770 + int a=0;
  771 + int b=0;
  772 + int c=0;
  773 + int d=0;
  774 + for(int i=0;i<list_s.size();i++){
  775 + boolean fage=true;
  776 + Map<String, Object> newMap= new HashMap<String, Object>();
  777 + list.add(newMap);
  778 + Map<String, Object> maps=list_s.get(i);
  779 + if(maps.get("lx").equals("zqc")){
  780 + list.get(a).put("zqcZm", maps.get("zdm"));
  781 + list.get(a).put("zqcCls", maps.get("cls"));
  782 + a++;
  783 + fage=false;
  784 + }else if(maps.get("lx").equals("wqc")){
  785 + list.get(b).put("wqcZm", maps.get("zdm"));
  786 + list.get(b).put("wqcCls", maps.get("cls"));
  787 + b++;
  788 + fage=false;
  789 + }else if(maps.get("lx").equals("zqj")){
  790 + list.get(c).put("zqjZm", maps.get("zdm"));
  791 + list.get(c).put("zqjCls", maps.get("cls"));
  792 + c++;
  793 + fage=false;
  794 + }else if(maps.get("lx").equals("wqj")){
  795 + list.get(d).put("wqjZm", maps.get("zdm"));
  796 + list.get(d).put("wqjCls", maps.get("cls"));
  797 + d++;
  798 + fage=false;
  799 + }
  800 + if(fage){
  801 + break;
  802 + }
  803 + }
  804 + boolean status=true;
  805 + while (status) {
  806 + if(list.size() == 0)
  807 + break;
  808 + for (int i = 0; i < list.size(); i++) {
  809 + if(list.get(i).isEmpty()){
  810 + list.remove(i);
  811 + status=true;
  812 + }else{
  813 + status=false;
  814 + }
  815 + }
  816 + }
  817 +
  818 + return list;
  819 + }
  820 +
  821 + @Override
  822 + public List<Map<String, Object>> tbodyTime4(String line, String ttinfo) {
  823 + List<Map<String, Object>> list =new ArrayList<>();
  824 + // TODO Auto-generated method stub
  825 + //最早营运时间 区分夜宵线
  826 + String minfcsj="02:00";
  827 + List<Line> lineList=lineRepository.findLineByCode(line);
  828 + if(lineList.size()>0){
  829 + List<String> objList = new ArrayList<String>();
  830 + objList.add(lineList.get(0).getId() + "");
  831 + String sql = "select count(*) from bsth_c_line_config where line = ? ";
  832 + if(jdbcTemplate.queryForObject(sql, objList.toArray(), Integer.class) > 0){
  833 + String sqlMinYysj="select start_opt from bsth_c_line_config where "
  834 + + " id = ("
  835 + + "select max(id) from bsth_c_line_config where line = ?"
  836 + + ")";
  837 + minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, objList.toArray(), String.class);
  838 + }
  839 + }
  840 +
  841 + List<String> objList = new ArrayList<String>();
  842 + objList.add(ttinfo);
  843 + objList.add(minfcsj);
  844 + objList.add(ttinfo);
  845 + objList.add(minfcsj);
  846 + //查询全程
  847 + String sqlqc="select t.* from ( "
  848 + + " (SELECT bc_type, fcsj,qdz,2 as xh,xl_dir,qdz_name FROM bsth_c_s_ttinfo_detail "
  849 + + " where ttinfo = ? and (bc_type='normal' || bc_type='region') "
  850 + + " and fcsj <= ?) "
  851 + + " union "
  852 + + " (SELECT bc_type, fcsj,qdz,1 as xh,xl_dir,qdz_name FROM bsth_c_s_ttinfo_detail "
  853 + + " where ttinfo = ? and (bc_type='normal' || bc_type='region') "
  854 + + " and fcsj > ?) "
  855 + + "order by xl_dir,xh,fcsj ) t ";
  856 + List<Map<String, String>> qclist= jdbcTemplate.query(sqlqc, objList.toArray(),
  857 + new RowMapper<Map<String, String>>(){
  858 + @Override
  859 + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
  860 + Map<String, String> m=new HashMap<String,String>();
  861 + m.put("qdz_name", rs.getString("qdz_name"));
  862 + m.put("bcType", rs.getString("bc_type"));
  863 + m.put("fcsj", rs.getString("fcsj"));
  864 + m.put("xl", rs.getString("xl_dir"));
  865 + m.put("xh", rs.getString("xh"));
  866 + return m;
  867 + }
  868 +
  869 + });
  870 +
  871 + List<List<Map<String, String>>> mapList = new ArrayList<List<Map<String,String>>>();
  872 + mapList.add(new ArrayList<Map<String, String>>());
  873 + mapList.add(new ArrayList<Map<String, String>>());
  874 + for(Map<String, String> m : qclist){
  875 + String bcType = m.get("bcType");
  876 + if(bcType.equals("normal")){
  877 + mapList.get(0).add(m);
  878 + } else {
  879 + mapList.get(1).add(m);
  880 + }
  881 + }
  882 +
  883 + for(int i = 0; i < mapList.size(); i++){
  884 + List<Map<String, String>> l = mapList.get(i);
  885 + Map<String, Object> tempMap = new HashMap<String, Object>();
  886 + List<String> upfcsj = new ArrayList<String>();
  887 + List<String> downfcsj = new ArrayList<String>();
  888 + String sxqdz = "", xxqdz = "";
  889 + String sxfcsj = "", xxfcsj = "";
  890 + int sxbc = 0, xxbc = 0;
  891 + for(Map<String, String> m : l){
  892 + if(m.get("xl").equals("0")){
  893 + sxbc++;
  894 + upfcsj.add(m.get("fcsj"));
  895 + if(sxqdz.length() == 0 && m.containsKey("qdz_name"))
  896 + sxqdz = m.get("qdz_name")==null?"":m.get("qdz_name").toString();
  897 + } else {
  898 + xxbc++;
  899 + downfcsj.add(m.get("fcsj"));
  900 + if(xxqdz.length() == 0 && m.containsKey("qdz_name"))
  901 + xxqdz = m.get("qdz_name")==null?"":m.get("qdz_name").toString();
  902 + }
  903 + }
  904 + if(upfcsj.size() != 0)
  905 + sxfcsj = upfcsj.get(0) + "-" + upfcsj.get(upfcsj.size() - 1);
  906 + if(downfcsj.size() != 0)
  907 + xxfcsj = downfcsj.get(0) + "-" + downfcsj.get(downfcsj.size() - 1);
  908 + tempMap.put("sxqdz", sxqdz);
  909 + tempMap.put("sxfcsj", i==0?sxfcsj:"");
  910 + tempMap.put("sxbc", sxbc!=0?sxbc:"");
  911 + tempMap.put("xxqdz", xxqdz);
  912 + tempMap.put("xxfcsj", i==0?xxfcsj:"");
  913 + tempMap.put("xxbc", xxbc!=0?xxbc:"");
  914 + tempMap.put("bcType", i);
  915 + if(sxqdz.length()!=0 || xxqdz.length()!=0)
  916 + list.add(tempMap);
  917 + }
  918 +
  919 + return list;
  920 + }
  921 + @Override
  922 + public List<Map<String, Object>> tbodyTime5(String line, String ttinfo) {
  923 + // TODO Auto-generated method stub
  924 + //最早营运时间 区分夜宵线
  925 + String minfcsj="02:00";
  926 + List<Line> lineList=lineRepository.findLineByCode(line);
  927 + if(lineList.size()>0){
  928 + List<String> objList = new ArrayList<String>();
  929 + objList.add(lineList.get(0).getId() + "");
  930 + String sql = "select count(*) from bsth_c_line_config where line = ? ";
  931 + if(jdbcTemplate.queryForObject(sql, objList.toArray(), Integer.class) > 0){
  932 + String sqlMinYysj="select start_opt from bsth_c_line_config where "
  933 + + " id = ("
  934 + + "select max(id) from bsth_c_line_config where line = ?"
  935 + + ")";
  936 + minfcsj= jdbcTemplate.queryForObject(sqlMinYysj, objList.toArray(), String.class);
  937 + }
  938 + }
  939 + String[] minSjs = minfcsj.split(":");
  940 + int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]);
  941 +
  942 + List<String> objList = new ArrayList<String>();
  943 + objList.add(ttinfo);
  944 + objList.add(minfcsj);
  945 + objList.add(ttinfo);
  946 + objList.add(minfcsj);
  947 + //查询时间里程
  948 + String sqlPc=" (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,2 as xh FROM "
  949 + + " bsth_c_s_ttinfo_detail where ttinfo = ? and "
  950 + + " fcsj <= ? and bc_type!='ldks'"
  951 + + " and bc_type !='region' and bc_type !='venting' and bc_type !='major') "
  952 + + " union "
  953 + + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,1 as xh FROM "
  954 + + " bsth_c_s_ttinfo_detail where ttinfo = ? and "
  955 + + " fcsj > ? and bc_type!='ldks' "
  956 + + " and bc_type !='region' and bc_type !='venting' and bc_type !='major') "
  957 + + " order by xh, lp,fcsj";
  958 + Map<String, Object> map=new HashMap<String,Object>();
  959 + List<Map<String, Object>> list= jdbcTemplate.query(sqlPc, objList.toArray(),
  960 + new RowMapper<Map<String, Object>>(){
  961 + @Override
  962 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  963 + Map<String, Object> m=new HashMap<String,Object>();
  964 + m.put("fcsj", rs.getString("fcsj"));
  965 + m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc"));
  966 + m.put("bcsj", rs.getString("bcsj"));
  967 + m.put("bcType", rs.getString("bc_type"));
  968 + m.put("lp", rs.getString("lp"));
  969 + m.put("dir", rs.getString("xl_dir"));
  970 + m.put("ists", rs.getString("ists")!=null?rs.getString("ists"):"");
  971 + String[] split = m.get("fcsj").toString().split(":");
  972 + if(rs.getString("xh").equals("2")){
  973 + m.put("fcsj", (Integer.valueOf(split[0]) + 24) + ":"+split[1]);
  974 + }
  975 +
  976 + return m;
  977 + }
  978 + });
  979 + List<Map<String, Object>> newList=new ArrayList<Map<String,Object>>();
  980 + int yysxZq=0,yyxxZq=0,tzsxZq=0,tzxxZq=0,minZqcj=0,maxZqcj=0,sxcountZqbc=0,xxcountZqbc=0; //早前
  981 + int yysxZgf=0,yyxxZgf=0,tzsxZgf=0,tzxxZgf=0,minZgfcj=0,maxZgfcj=0,sxcountZgfbc=0,xxcountZgfbc=0;//早高峰
  982 + int yysxZw=0,yyxxZw=0,tzsxZw=0,tzxxZw=0,minZwcj=0,maxZwcj=0,sxcountZwbc=0,xxcountZwbc=0;//中午
  983 + int yysxWgf=0,yyxxWgf=0,tzsxWgf=0,tzxxWgf=0,minWgfcj=0,maxWgfcj=0,sxcountWgfbc=0,xxcountWgfbc=0;//晚高峰
  984 + int yysxWh=0,yyxxWh=0,tzsxWh=0,tzxxWh=0,minWhcj=0,maxWhcj=0,sxcountWhbc=0,xxcountWhbc=0;//晚后
  985 + List<Integer> zqFcsj0=new ArrayList<Integer>();
  986 + List<Integer> zgfFcsj0=new ArrayList<Integer>();
  987 + List<Integer> zwFcsj0=new ArrayList<Integer>();
  988 + List<Integer> wgfFcsj0=new ArrayList<Integer>();
  989 + List<Integer> whFcsj0=new ArrayList<Integer>();
  990 +
  991 + List<Integer> zqFcsj1=new ArrayList<Integer>();
  992 + List<Integer> zgfFcsj1=new ArrayList<Integer>();
  993 + List<Integer> zwFcsj1=new ArrayList<Integer>();
  994 + List<Integer> wgfFcsj1=new ArrayList<Integer>();
  995 + List<Integer> whFcsj1=new ArrayList<Integer>();
  996 + int temp = 48*60+1, zcj = 0;
  997 + boolean ists = true;
  998 + String lpname="";
  999 + int dir =-1;
  1000 + int fcsjT_= 0;
  1001 + for (int i = 0; i < list.size(); i++) {
  1002 + Map<String, Object> m=list.get(i);
  1003 + int xlDir = Integer.valueOf(m.get("dir").toString());
  1004 + String[] split = m.get("fcsj").toString().split(":");
  1005 + int fcsjT = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]);
  1006 + String bcType=m.get("bcType").toString();
  1007 + int bcsj = Integer.valueOf(m.get("bcsj").toString());
  1008 + if(i==0){
  1009 + lpname=m.get("lp").toString();
  1010 + if(temp>fcsjT){
  1011 + temp=fcsjT+bcsj;
  1012 + }
  1013 + dir =xlDir;
  1014 + if(bcType.equals("in") || bcType.equals("out")){
  1015 + ists=false;
  1016 + }
  1017 + }else{
  1018 +// if(temp>fcsjT){
  1019 +// temp=fcsjT;
  1020 +// }
  1021 + if(bcType.equals("in") || bcType.equals("out")){
  1022 + temp = fcsjT+bcsj;
  1023 + lpname=m.get("lp").toString();
  1024 + dir =xlDir;
  1025 + ists=false;
  1026 + }else{
  1027 +// if(xlDir==0){
  1028 + //上行数据
  1029 + if(fcsjT>= minSj && fcsjT <= 6*60+30){
  1030 + //早高峰前
  1031 + if(xlDir==0){
  1032 + yysxZq +=bcsj;
  1033 + sxcountZqbc ++;
  1034 + zqFcsj0.add(fcsjT);
  1035 + }else{
  1036 + yyxxZq +=bcsj;
  1037 + xxcountZqbc ++;
  1038 + zqFcsj1.add(fcsjT);
  1039 + }
  1040 + if(ists){
  1041 + if(lpname.equals(m.get("lp").toString())){
  1042 + if(dir==0)
  1043 + tzsxZq +=fcsjT-temp;
  1044 + else
  1045 + tzxxZq +=fcsjT-temp;
  1046 + }
  1047 + }
  1048 + temp = fcsjT+bcsj;
  1049 +
  1050 + }else if(fcsjT > 6*60+30 && fcsjT <= 8*60+30){
  1051 + //早高峰
  1052 + if(xlDir==0){
  1053 + yysxZgf +=bcsj;
  1054 + sxcountZgfbc ++;
  1055 + zgfFcsj0.add(fcsjT);
  1056 + }else{
  1057 + yyxxZgf +=bcsj;
  1058 + xxcountZgfbc ++;
  1059 + zgfFcsj1.add(fcsjT);
  1060 + }
  1061 +
  1062 + if(ists){
  1063 + if(lpname.equals(m.get("lp").toString())){
  1064 + if(dir==0){
  1065 + if(fcsjT_>= minSj && fcsjT_ <= 6*60+30)
  1066 + tzsxZq +=fcsjT-temp;
  1067 + else
  1068 + tzsxZgf +=fcsjT-temp;
  1069 + }else{
  1070 + if(fcsjT_>= minSj && fcsjT_ <= 6*60+30)
  1071 + tzxxZq +=fcsjT-temp;
  1072 + else
  1073 + tzxxZgf +=fcsjT-temp;
  1074 + }
  1075 + }
  1076 + }
  1077 + temp =fcsjT+bcsj;
  1078 +
  1079 + }else if(fcsjT > 8*60+30 && fcsjT <= 16*60){
  1080 + //中午
  1081 + if(xlDir==0){
  1082 + yysxZw +=bcsj;
  1083 + sxcountZwbc ++;
  1084 + zwFcsj0.add(fcsjT);
  1085 + }else{
  1086 + yyxxZw +=bcsj;
  1087 + xxcountZwbc ++;
  1088 + zwFcsj1.add(fcsjT);
  1089 + }
  1090 + if(ists){
  1091 + if(lpname.equals(m.get("lp").toString())){
  1092 + if(dir==0){
  1093 + if(fcsjT_ > 6*60+30 && fcsjT_ <= 8*60+30)
  1094 + tzsxZgf +=fcsjT-temp;
  1095 + else
  1096 + tzsxZw +=fcsjT-temp;
  1097 + }else{
  1098 + if(fcsjT_ > 6*60+30 && fcsjT_ <= 8*60+30)
  1099 + tzxxZgf +=fcsjT-temp;
  1100 + else
  1101 + tzxxZw +=fcsjT-temp;
  1102 + }
  1103 + }
  1104 + }
  1105 + temp =fcsjT+bcsj;
  1106 + }else if(fcsjT > 16*60 && fcsjT <= 18*60){
  1107 + //晚高峰
  1108 + if(xlDir==0){
  1109 + yysxWgf +=bcsj;
  1110 + sxcountWgfbc ++;
  1111 + wgfFcsj0.add(fcsjT);
  1112 + }else{
  1113 + yyxxWgf +=bcsj;
  1114 + xxcountWgfbc ++;
  1115 + wgfFcsj1.add(fcsjT);
  1116 + }
  1117 +
  1118 + if(ists){
  1119 + if(lpname.equals(m.get("lp").toString())){
  1120 + if(dir==0){
  1121 + if(fcsjT_ > 8*60+30 && fcsjT_ <= 16*60)
  1122 + tzsxZw +=fcsjT-temp;
  1123 + else
  1124 + tzsxWgf +=fcsjT-temp;
  1125 + }else{
  1126 + if(fcsjT_ > 8*60+30 && fcsjT_ <= 16*60)
  1127 + tzxxZw +=fcsjT-temp;
  1128 + else
  1129 + tzxxWgf +=fcsjT-temp;
  1130 + }
  1131 + }
  1132 + }
  1133 + temp =fcsjT+bcsj;
  1134 + }else{
  1135 + //晚高峰后
  1136 + if(xlDir==0){
  1137 + yysxWh +=bcsj;
  1138 + sxcountWhbc ++;
  1139 + whFcsj0.add(fcsjT);
  1140 + }else{
  1141 + yyxxWh +=bcsj;
  1142 + xxcountWhbc ++;
  1143 + whFcsj1.add(fcsjT);
  1144 + }
  1145 + if(ists){
  1146 + if(lpname.equals(m.get("lp").toString())){
  1147 + if(dir==0){
  1148 + if(fcsjT_ > 16*60 && fcsjT_ <= 18*60)
  1149 + tzsxWgf +=fcsjT-temp;
  1150 + else
  1151 + tzsxWh +=fcsjT-temp;
  1152 + }else{
  1153 + if(fcsjT_ > 16*60 && fcsjT_ <= 18*60)
  1154 + tzxxWgf +=fcsjT-temp;
  1155 + else
  1156 + tzxxWh +=fcsjT-temp;
  1157 + }
  1158 + }
  1159 + }
  1160 + temp =fcsjT+bcsj;
  1161 + }
  1162 +
  1163 + /*}else{
  1164 + //下行数据
  1165 + if(fcsjT>= minSj && fcsjT <= 6*60+30){
  1166 + //早高峰前
  1167 + yyxxZq +=bcsj;
  1168 + xxcountZqbc ++;
  1169 + zqFcsj1.add(fcsjT);
  1170 + if(ists){
  1171 + if(lpname.equals(m.get("lp").toString())){
  1172 + tzxxZq +=fcsjT-temp;
  1173 + }
  1174 + }
  1175 + temp =fcsjT+bcsj;
  1176 + }else if(fcsjT > 6*60+30 && fcsjT <= 8*60+30){
  1177 + //早高峰
  1178 + yyxxZgf +=bcsj;
  1179 + xxcountZgfbc ++;
  1180 + zgfFcsj1.add(fcsjT);
  1181 + if(ists){
  1182 + if(lpname.equals(m.get("lp").toString())){
  1183 + if(fcsjT_>= minSj && fcsjT_ <= 6*60+30)
  1184 + tzxxZq +=fcsjT-temp;
  1185 + else
  1186 + tzxxZgf +=fcsjT-temp;
  1187 + }
  1188 + }
  1189 + temp =fcsjT+bcsj;
  1190 + }else if(fcsjT > 8*60+30 && fcsjT <= 16*60){
  1191 + //中午
  1192 + yyxxZw +=bcsj;
  1193 + xxcountZwbc ++;
  1194 + zwFcsj1.add(fcsjT);
  1195 + if(ists){
  1196 + if(lpname.equals(m.get("lp").toString())){
  1197 + if(fcsjT_ > 6*60+30 && fcsjT_ <= 8*60+30)
  1198 + tzxxZgf +=fcsjT-temp;
  1199 + else
  1200 + tzxxZw +=fcsjT-temp;
  1201 + }
  1202 + }
  1203 + temp =fcsjT+bcsj;
  1204 + }else if(fcsjT > 16*60 && fcsjT <= 18*60){
  1205 + //晚高峰
  1206 + yyxxWgf +=bcsj;
  1207 + xxcountWgfbc ++;
  1208 + wgfFcsj1.add(fcsjT);
  1209 + if(ists){
  1210 + if(lpname.equals(m.get("lp").toString())){
  1211 + if(fcsjT_ > 8*60+30 && fcsjT_ <= 16*60)
  1212 + tzxxZw +=fcsjT-temp;
  1213 + else
  1214 + tzxxWgf +=fcsjT-temp;
  1215 + }
  1216 + }
  1217 + temp =fcsjT+bcsj;
  1218 + }else{
  1219 + //晚高峰后
  1220 + yyxxWh +=bcsj;
  1221 + xxcountWhbc ++;
  1222 + whFcsj1.add(fcsjT);
  1223 + if(ists){
  1224 + if(lpname.equals(m.get("lp").toString())){
  1225 + if(fcsjT_ > 16*60 && fcsjT_ <= 18*60)
  1226 + tzxxWgf +=fcsjT-temp;
  1227 + else
  1228 + tzxxWh +=fcsjT-temp;
  1229 + }
  1230 + }
  1231 + temp =fcsjT+bcsj;
  1232 + }
  1233 +// }
  1234 + }*/
  1235 + lpname=m.get("lp").toString();
  1236 + fcsjT_=fcsjT;
  1237 + dir =xlDir;
  1238 + if(m.get("ists").toString().trim().equals("1")){
  1239 + ists=false;
  1240 + }else{
  1241 + ists = true;
  1242 + }
  1243 + }
  1244 + }
  1245 +
  1246 + }
  1247 +
  1248 + //---------------------------------------早前
  1249 + List<Integer> cjs = new ArrayList<Integer>();
  1250 + Collections.sort(zqFcsj0);
  1251 + int fcsjs=0;
  1252 + for (int i = 0; i < zqFcsj0.size(); i++) {
  1253 + if(i==0){
  1254 + fcsjs =zqFcsj0.get(i);
  1255 + }else{
  1256 + cjs.add(zqFcsj0.get(i)-fcsjs);
  1257 + fcsjs=zqFcsj0.get(i);
  1258 + }
  1259 +
  1260 + }
  1261 + Collections.sort(zqFcsj1);
  1262 + int fcsjx=0;
  1263 + for (int i = 0; i < zqFcsj1.size(); i++) {
  1264 + if(i==0){
  1265 + fcsjx =zqFcsj1.get(i);
  1266 + }else{
  1267 + cjs.add(zqFcsj1.get(i)-fcsjx);
  1268 + fcsjx =zqFcsj1.get(i);
  1269 + }
  1270 +
  1271 + }
  1272 + Collections.sort(cjs);
  1273 + for(int i : cjs){
  1274 + zcj += i;
  1275 + }
  1276 + Map<String, Object> tempMap = new HashMap<String, Object>();
  1277 + double sxtszq=0.0;
  1278 + double sxsjzq=0.0;
  1279 + if(sxcountZqbc>0){
  1280 + sxtszq=Arith.div(tzsxZq, sxcountZqbc, 1);
  1281 + sxsjzq=Arith.div(yysxZq, sxcountZqbc,1);
  1282 + }
  1283 +
  1284 + double xxtszq=0.0;
  1285 + double xxsjzq=0.0;
  1286 + if(xxcountZqbc>0){
  1287 + xxtszq=Arith.div(tzxxZq, xxcountZqbc, 1);
  1288 + xxsjzq=Arith.div(yyxxZq, xxcountZqbc,1);
  1289 + }
  1290 + tempMap.put("sjd", "(首)——6:30");
  1291 + tempMap.put("sxsj", sxsjzq);
  1292 + tempMap.put("xxsj", xxsjzq);
  1293 + tempMap.put("sxtssj", sxtszq);
  1294 + tempMap.put("xxtssj", xxtszq);
  1295 + tempMap.put("fqsj", Arith.add(Arith.add(sxtszq, sxsjzq), Arith.add(xxtszq, xxsjzq)));
  1296 + tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");
  1297 + tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");
  1298 + newList.add(tempMap);
  1299 +
  1300 + //----------------------------------早高峰
  1301 + cjs = new ArrayList<Integer>();
  1302 + zcj =0;
  1303 +
  1304 + Collections.sort(zgfFcsj0);
  1305 + fcsjs=0;
  1306 + for (int i = 0; i < zgfFcsj0.size(); i++) {
  1307 + if(i==0){
  1308 + fcsjs =zgfFcsj0.get(i);
  1309 + }else{
  1310 + cjs.add(zgfFcsj0.get(i)-fcsjs);
  1311 + fcsjs=zgfFcsj0.get(i);
  1312 + }
  1313 +
  1314 + }
  1315 + Collections.sort(zgfFcsj1);
  1316 + fcsjx=0;
  1317 + for (int i = 0; i < zgfFcsj1.size(); i++) {
  1318 + if(i==0){
  1319 + fcsjx =zgfFcsj1.get(i);
  1320 + }else{
  1321 + cjs.add(zgfFcsj1.get(i)-fcsjx);
  1322 + fcsjx =zgfFcsj1.get(i);
  1323 + }
  1324 +
  1325 + }
  1326 + Collections.sort(cjs);
  1327 + for(int i : cjs){
  1328 + zcj += i;
  1329 + }
  1330 + double sxtszgf=0.0;
  1331 + double sxsjzgf=0.0;
  1332 + if(sxcountZgfbc>0){
  1333 + sxtszgf=Arith.div(tzsxZgf, sxcountZgfbc, 1);
  1334 + sxsjzgf =Arith.div(yysxZgf, sxcountZgfbc, 1);
  1335 + }
  1336 +
  1337 + double xxtszgf=0.0;
  1338 + double xxsjzgf=0.0;
  1339 + if(xxcountZgfbc>0){
  1340 + xxtszgf=Arith.div(tzxxZgf, xxcountZgfbc, 1);
  1341 + xxsjzgf=Arith.div(yyxxZgf, xxcountZgfbc,1);
  1342 + }
  1343 +
  1344 +
  1345 + tempMap = new HashMap<String, Object>();
  1346 + tempMap.put("sjd", "6:31——8:30");
  1347 + tempMap.put("sxsj", sxsjzgf);
  1348 + tempMap.put("xxsj", xxsjzgf);
  1349 + tempMap.put("sxtssj", sxtszgf);
  1350 + tempMap.put("xxtssj", xxtszgf);
  1351 + tempMap.put("fqsj", Arith.add(Arith.add(sxtszgf, sxsjzgf), Arith.add(xxtszgf, xxsjzgf)));
  1352 + tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");
  1353 + tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");
  1354 + newList.add(tempMap);
  1355 + //----------------------------------------------中午
  1356 + cjs = new ArrayList<Integer>();
  1357 + zcj =0;
  1358 +
  1359 + Collections.sort(zwFcsj0);
  1360 + fcsjs=0;
  1361 + for (int i = 0; i < zwFcsj0.size(); i++) {
  1362 + if(i==0){
  1363 + fcsjs =zwFcsj0.get(i);
  1364 + }else{
  1365 + cjs.add(zwFcsj0.get(i)-fcsjs);
  1366 + fcsjs=zwFcsj0.get(i);
  1367 + }
  1368 +
  1369 + }
  1370 + Collections.sort(zwFcsj1);
  1371 + fcsjx=0;
  1372 + for (int i = 0; i < zwFcsj1.size(); i++) {
  1373 + if(i==0){
  1374 + fcsjx =zwFcsj1.get(i);
  1375 + }else{
  1376 + cjs.add(zwFcsj1.get(i)-fcsjx);
  1377 + fcsjx =zwFcsj1.get(i);
  1378 + }
  1379 +
  1380 + }
  1381 + Collections.sort(cjs);
  1382 + for(int i : cjs){
  1383 + zcj += i;
  1384 + }
  1385 + double sxtzsjzw=0.0;
  1386 + double sxsjsjzw=0.0;
  1387 + if(sxcountZwbc>0){
  1388 + sxtzsjzw=Arith.div(tzsxZw, sxcountZwbc, 1);
  1389 + sxsjsjzw=Arith.div(yysxZw, sxcountZwbc,1);
  1390 + }
  1391 +
  1392 + double xxtzsjzw=0.0;
  1393 + double xxsjsjzw=0.0;
  1394 + if(xxcountZwbc>0){
  1395 + xxtzsjzw=Arith.div(tzxxZw, xxcountZwbc,1);
  1396 + xxsjsjzw=Arith.div(yyxxZw, xxcountZwbc, 1);
  1397 + }
  1398 + tempMap = new HashMap<String, Object>();
  1399 + tempMap.put("sjd", "8:31——16:00");
  1400 + tempMap.put("sxsj", sxsjsjzw);
  1401 + tempMap.put("xxsj", xxsjsjzw);
  1402 + tempMap.put("sxtssj", sxtzsjzw);
  1403 + tempMap.put("xxtssj", xxtzsjzw);
  1404 + tempMap.put("fqsj", Arith.add(Arith.add(sxtzsjzw, sxsjsjzw), Arith.add(xxtzsjzw, xxsjsjzw)));
  1405 + tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");
  1406 + tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");
  1407 + newList.add(tempMap);
  1408 + //-------------------------------------------------晚高峰
  1409 + cjs = new ArrayList<Integer>();
  1410 + zcj =0;
  1411 +
  1412 + Collections.sort(wgfFcsj0);
  1413 + fcsjs=0;
  1414 + for (int i = 0; i < wgfFcsj0.size(); i++) {
  1415 + if(i==0){
  1416 + fcsjs =wgfFcsj0.get(i);
  1417 + }else{
  1418 + cjs.add(wgfFcsj0.get(i)-fcsjs);
  1419 + fcsjs=wgfFcsj0.get(i);
  1420 + }
  1421 +
  1422 + }
  1423 + Collections.sort(wgfFcsj1);
  1424 + fcsjx=0;
  1425 + for (int i = 0; i < wgfFcsj1.size(); i++) {
  1426 + if(i==0){
  1427 + fcsjx =wgfFcsj1.get(i);
  1428 + }else{
  1429 + cjs.add(wgfFcsj1.get(i)-fcsjx);
  1430 + fcsjx =wgfFcsj1.get(i);
  1431 + }
  1432 +
  1433 + }
  1434 + Collections.sort(cjs);
  1435 + for(int i : cjs){
  1436 + zcj += i;
  1437 + }
  1438 +
  1439 + double sxtzsjwgf=0.0;
  1440 + double sxsjsjwgf=0.0;
  1441 + if(sxcountWgfbc>0){
  1442 + sxtzsjwgf=Arith.div(tzsxWgf, sxcountWgfbc, 1);
  1443 + sxsjsjwgf=Arith.div(yysxWgf, sxcountWgfbc,1);
  1444 + }
  1445 +
  1446 + double xxtzsjwgf=0.0;
  1447 + double xxsjsjwgf=0.0;
  1448 + if(xxcountWgfbc>0){
  1449 + xxtzsjwgf=Arith.div(tzxxWgf, xxcountWgfbc, 1);
  1450 + xxsjsjwgf=Arith.div(yyxxWgf, xxcountWgfbc,1);
  1451 + }
  1452 +
  1453 + tempMap = new HashMap<String, Object>();
  1454 + tempMap.put("sjd", "16:01——18:00");
  1455 + tempMap.put("sxsj", sxsjsjwgf);
  1456 + tempMap.put("xxsj", xxsjsjwgf);
  1457 + tempMap.put("sxtssj", sxtzsjwgf);
  1458 + tempMap.put("xxtssj", xxtzsjwgf);
  1459 + tempMap.put("fqsj", Arith.add(Arith.add(sxsjsjwgf, sxtzsjwgf), Arith.add(xxsjsjwgf, xxtzsjwgf)));
  1460 + tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");
  1461 + tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");
  1462 + newList.add(tempMap);
  1463 +
  1464 + //----------------------------------晚后
  1465 + cjs = new ArrayList<Integer>();
  1466 + zcj =0;
  1467 +
  1468 + Collections.sort(whFcsj0);
  1469 + fcsjs=0;
  1470 + for (int i = 0; i < whFcsj0.size(); i++) {
  1471 + if(i==0){
  1472 + fcsjs =whFcsj0.get(i);
  1473 + }else{
  1474 + cjs.add(whFcsj0.get(i)-fcsjs);
  1475 + fcsjs=whFcsj0.get(i);
  1476 + }
  1477 +
  1478 + }
  1479 + Collections.sort(whFcsj1);
  1480 + fcsjx=0;
  1481 + for (int i = 0; i < whFcsj1.size(); i++) {
  1482 + if(i==0){
  1483 + fcsjx =whFcsj1.get(i);
  1484 + }else{
  1485 + cjs.add(whFcsj1.get(i)-fcsjx);
  1486 + fcsjx =whFcsj1.get(i);
  1487 + }
  1488 +
  1489 + }
  1490 + Collections.sort(cjs);
  1491 + for(int i : cjs){
  1492 + zcj += i;
  1493 + }
  1494 + double sxtzsjwh=0.0;
  1495 + double sxsjsjwh=0.0;
  1496 + if(sxcountWhbc>0){
  1497 + sxtzsjwh=Arith.div(tzsxWh,sxcountWhbc,1);
  1498 + sxsjsjwh=Arith.div(yysxWh, sxcountWhbc,1);
  1499 + }
  1500 +
  1501 + double xxtzsjwh=0.0;
  1502 + double xxsjsjwh=0.0;
  1503 + if(xxcountWhbc>0){
  1504 + xxtzsjwh=Arith.div(tzxxWh, xxcountWhbc,1);
  1505 + xxsjsjwh=Arith.div(yyxxWh, xxcountWhbc, 1);
  1506 + }
  1507 + tempMap = new HashMap<String, Object>();
  1508 + tempMap.put("sjd", "18:01——(末)");
  1509 + tempMap.put("sxsj", sxsjsjwh);
  1510 + tempMap.put("xxsj", xxsjsjwh);
  1511 + tempMap.put("sxtssj", sxtzsjwh);
  1512 + tempMap.put("xxtssj", xxtzsjwh);
  1513 + tempMap.put("fqsj", Arith.add(Arith.add(sxsjsjwh, sxtzsjwh), Arith.add(xxsjsjwh,xxtzsjwh)));
  1514 + tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");
  1515 + tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");
  1516 + newList.add(tempMap);
  1517 + /*
  1518 + Map<String, List<Map<String, Object>>> keyMap = new HashMap<String, List<Map<String, Object>>>();
  1519 + Map<String, Map<String, Object>> maps = new HashMap<String, Map<String, Object>>();
  1520 + keyMap.put("(首)——6:30", new ArrayList<Map<String, Object>>());
  1521 + keyMap.put("6:31——8:30", new ArrayList<Map<String, Object>>());
  1522 + keyMap.put("8:31——16:00", new ArrayList<Map<String, Object>>());
  1523 + keyMap.put("16:01——18:00", new ArrayList<Map<String, Object>>());
  1524 + keyMap.put("18:01——(末)", new ArrayList<Map<String, Object>>());
  1525 + for(int i = 0; i < list.size(); i++){
  1526 + Map<String, Object> ttMap = list.get(i);
  1527 + String fcsj = ttMap.get("fcsj").toString();
  1528 + String[] split = fcsj.split(":");
  1529 + int fcsjT = Integer.valueOf(split[0])*60+Integer.valueOf(split[1]);
  1530 + if(fcsjT >= minSj && fcsjT <= 6*60+30){
  1531 + keyMap.get("(首)——6:30").add(ttMap);
  1532 + } else if(fcsjT > 6*60+30 && fcsjT <= 8*60+30){
  1533 + keyMap.get("6:31——8:30").add(ttMap);
  1534 + } else if(fcsjT > 8*60+30 && fcsjT <= 16*60){
  1535 + keyMap.get("8:31——16:00").add(ttMap);
  1536 + } else if(fcsjT > 16*60 && fcsjT <= 18*60){
  1537 + keyMap.get("16:01——18:00").add(ttMap);
  1538 + } else {
  1539 + keyMap.get("18:01——(末)").add(ttMap);
  1540 + }
  1541 + }
  1542 +
  1543 + for(String key : keyMap.keySet()){
  1544 + Map<String, Object> tempMap = new HashMap<String, Object>();
  1545 + List<Map<String, Object>> list2 = keyMap.get(key);
  1546 + List<Integer> cjs = new ArrayList<Integer>();
  1547 + List<Integer> fcsj_s = new ArrayList<Integer>();
  1548 + List<Integer> fcsj_x = new ArrayList<Integer>();
  1549 + int sxsj = 0, xxsj = 0, sxtssj = 0, xxtssj = 0;
  1550 + int sxbc = 0, xxbc = 0, sxtsbc = 0, xxtsbc = 0;
  1551 + int temp = 48*60+1, zcj = 0;
  1552 + boolean ists = false;
  1553 + String lpname="";
  1554 + for(Map<String, Object> m : list2){
  1555 + String bcType=m.get("bcType").toString();
  1556 + if(bcType.equals("in") || bcType.equals("out")){
  1557 + temp=24*60+1;
  1558 + }else{
  1559 + String[] split = m.get("fcsj").toString().split(":");
  1560 + int fcsj = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]);
  1561 +
  1562 + int xlDir = Integer.valueOf(m.get("dir").toString());
  1563 + int bcsj = Integer.valueOf(m.get("bcsj").toString());
  1564 + if(temp >= fcsj){
  1565 + temp = fcsj+bcsj;
  1566 + ists = false;
  1567 + }
  1568 + if(xlDir == 0){
  1569 + fcsj_s.add(fcsj);
  1570 + sxsj += bcsj;
  1571 + sxbc ++;
  1572 + if(!ists){
  1573 + if(lpname.equals("")){
  1574 + lpname=m.get("lp").toString();
  1575 + }else{
  1576 + if(lpname.equals(m.get("lp").toString())){
  1577 + if(fcsj-temp<90){
  1578 + sxtssj += fcsj - temp;
  1579 + }
  1580 + }
  1581 + lpname=m.get("lp").toString();
  1582 +
  1583 + }
  1584 + sxtsbc++;
  1585 + }
  1586 +
  1587 + } else {
  1588 +
  1589 + fcsj_x.add(fcsj);
  1590 + xxsj += bcsj;
  1591 + xxbc ++;
  1592 +
  1593 + if(!ists){
  1594 + if(lpname.equals("")){
  1595 + lpname=m.get("lp").toString();
  1596 + }else{
  1597 + if(lpname.equals(m.get("lp").toString())){
  1598 + if(fcsj-temp<90){
  1599 + xxtssj += fcsj- temp;
  1600 + }
  1601 + }
  1602 + lpname=m.get("lp").toString();
  1603 + }
  1604 + xxtsbc++;
  1605 + }
  1606 +
  1607 + }
  1608 + if(temp < fcsj){
  1609 + cjs.add(fcsj - temp);
  1610 + temp = fcsj;
  1611 + }
  1612 + if(m.get("ists").toString().trim().equals("1")){
  1613 + ists = true;
  1614 + }else{
  1615 + ists=false;
  1616 + }
  1617 + }
  1618 + }
  1619 + Collections.sort(fcsj_s);
  1620 + int fcsjs=0;
  1621 + for (int i = 0; i < fcsj_s.size(); i++) {
  1622 + if(i==0){
  1623 + fcsjs =fcsj_s.get(i);
  1624 + }else{
  1625 + cjs.add(fcsj_s.get(i)-fcsjs);
  1626 + fcsjs=fcsj_s.get(i);
  1627 + }
  1628 +
  1629 + }
  1630 + Collections.sort(fcsj_x);
  1631 + int fcsjx=0;
  1632 + for (int i = 0; i < fcsj_x.size(); i++) {
  1633 + if(i==0){
  1634 + fcsjx =fcsj_x.get(i);
  1635 + }else{
  1636 + cjs.add(fcsj_x.get(i)-fcsjx);
  1637 + fcsjx =fcsj_x.get(i);
  1638 + }
  1639 +
  1640 + }
  1641 + Collections.sort(cjs);
  1642 + for(int i : cjs){
  1643 + zcj += i;
  1644 + }
  1645 + tempMap.put("sjd", key);
  1646 + tempMap.put("sxsj", sxbc != 0 ? sxsj / sxbc : "0");
  1647 + tempMap.put("xxsj", xxbc != 0 ? xxsj / xxbc : "0");
  1648 + tempMap.put("sxtssj", sxtsbc != 0 ? sxtssj / sxtsbc : "0");
  1649 + tempMap.put("xxtssj", xxtsbc != 0 ? xxtssj / xxtsbc : "0");
  1650 + tempMap.put("fqsj", Integer.valueOf(tempMap.get("sxsj").toString()) + Integer.valueOf(tempMap.get("xxsj").toString())
  1651 + + Integer.valueOf(tempMap.get("sxtssj").toString()) + Integer.valueOf(tempMap.get("xxtssj").toString()));
  1652 + tempMap.put("cjqj", cjs.size()>0?cjs.get(0)+"——"+cjs.get(cjs.size()-1):"——");
  1653 + tempMap.put("pjcj", cjs.size()>0?zcj/cjs.size():"/");
  1654 + maps.put(key, tempMap);
  1655 + }
  1656 + newList.add(maps.get("(首)——6:30"));
  1657 + newList.add(maps.get("6:31——8:30"));
  1658 + newList.add(maps.get("8:31——16:00"));
  1659 + newList.add(maps.get("16:01——18:00"));
  1660 + newList.add(maps.get("18:01——(末)"));*/
  1661 +
  1662 + return newList;
  1663 + }
  1664 + @Override
  1665 + public List<Map<String, Object>> getTtinfo(Map<String, Object> map) {
  1666 + // TODO Auto-generated method stub
  1667 + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  1668 + String line = map.get("line").toString();
  1669 + try {
  1670 + List<String> objList = new ArrayList<String>();
  1671 + String sql = "select tt.id, tt.name from bsth_c_s_ttinfo tt"
  1672 + + " left join bsth_c_line cl on cl.id = tt.xl"
  1673 + + " where tt.is_cancel = 0 and tt.is_enable_dis_template = 1";
  1674 + if(line.length() != 0){
  1675 + sql += " and cl.line_code = ?";
  1676 + objList.add(line);
  1677 + }
  1678 + sql += " order by tt.create_date desc";
  1679 +
  1680 + list = jdbcTemplate.query(sql, objList.toArray(),
  1681 + new RowMapper<Map<String, Object>>(){
  1682 + @Override
  1683 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  1684 + Map<String, Object> map = new HashMap<String, Object>();
  1685 + map.put("id", rs.getString("id"));
  1686 + map.put("name", rs.getString("name"));
  1687 + return map;
  1688 + }
  1689 + });
  1690 + }catch (Exception e) {
  1691 + // TODO Auto-generated catch block
  1692 + e.printStackTrace();
  1693 + }
  1694 + return list;
  1695 + }
  1696 +
  1697 + @Override
  1698 + public List<Map<String, Object>> jobFwqk(Map<String, Object> map) {
  1699 + // TODO Auto-generated method stub
  1700 + String[] lblxs = {"配车","保养","故障","肇事","路阻","纠纷","缺人","客稀","缺车","气候","援外","吊慢","抽减","路救抛锚","其他" };
  1701 + Set<String> lblxSet = new HashSet<String>();
  1702 + for(String s : lblxs){
  1703 + lblxSet.add(s);
  1704 + }
  1705 + String line=map.get("line").toString();
  1706 + String date=map.get("date").toString();
  1707 + map.put("bcType", "normal");
  1708 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  1709 + List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  1710 + for (int i = 0; i < sList.size(); i++) {
  1711 + ScheduleRealInfo scheduleRealInfo = sList.get(i);
  1712 + if (!(scheduleRealInfo.getBcType().equals("in")
  1713 + || scheduleRealInfo.getBcType().equals("out")
  1714 + ||scheduleRealInfo.getBcType().equals("ldks"))) {
  1715 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1716 + if (childTaskPlans.isEmpty()) {
  1717 + Map<String, Object> newMap = new HashMap<String, Object>();
  1718 + String adjustExps = "";
  1719 + if (scheduleRealInfo.getAdjustExps() == null) {
  1720 + adjustExps = "其他";
  1721 + } else if(scheduleRealInfo.getAdjustExps().equals("")){
  1722 + adjustExps = "其他";
  1723 + } else if(!(lblxSet.contains(scheduleRealInfo.getAdjustExps()))){
  1724 + adjustExps = "其他";
  1725 + } else {
  1726 + adjustExps = scheduleRealInfo.getAdjustExps();
  1727 + }
  1728 + if (scheduleRealInfo.getStatus() == -1) {
  1729 + newMap.put("nr", adjustExps);
  1730 + newMap.put("lp", scheduleRealInfo.getLpName());
  1731 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1732 + newMap.put("jgh", scheduleRealInfo.getjGh()+scheduleRealInfo.getjName()+"/"+scheduleRealInfo.getsGh()+scheduleRealInfo.getsName());
  1733 + newMap.put("dz", scheduleRealInfo.getQdzName());
  1734 + newMap.put("sj", scheduleRealInfo.getFcsj());
  1735 + newMap.put("lbbc", 1);
  1736 + newMap.put("gzf", " ");
  1737 + newMap.put("lblc", scheduleRealInfo.getJhlcOrig());
  1738 + newMap.put("jyqp", scheduleRealInfo.getRemarks());
  1739 + list.add(newMap);
  1740 + }
  1741 +
  1742 + } else {
  1743 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1744 + if (scheduleRealInfo.getStatus() == -1) {
  1745 + double zlblc=0.0;
  1746 + while (it.hasNext()) {
  1747 + ChildTaskPlan childTaskPlan = it.next();
  1748 + if(childTaskPlan.getMileageType().equals("service")){
  1749 + if (childTaskPlan.isDestroy()) {
  1750 + zlblc=Arith.add(zlblc,childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage());
  1751 + }
  1752 + }
  1753 + }
  1754 + Map<String, Object> newMap = new HashMap<String, Object>();
  1755 + String adjustExps = "";
  1756 + if (scheduleRealInfo.getAdjustExps() == "" || scheduleRealInfo.getAdjustExps() == null) {
  1757 + adjustExps = "其他";
  1758 + } else if(!(lblxSet.contains(scheduleRealInfo.getAdjustExps()))){
  1759 + adjustExps = "其他";
  1760 + } else {
  1761 + adjustExps = scheduleRealInfo.getAdjustExps();
  1762 + }
  1763 + newMap.put("nr", adjustExps);
  1764 + newMap.put("lp", scheduleRealInfo.getLpName());
  1765 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1766 + newMap.put("jgh", scheduleRealInfo.getjGh()+scheduleRealInfo.getjName()+"/"+scheduleRealInfo.getsGh()+scheduleRealInfo.getsName());
  1767 + newMap.put("dz", scheduleRealInfo.getQdzName());
  1768 + newMap.put("sj", scheduleRealInfo.getFcsj());
  1769 + newMap.put("lbbc", 1);
  1770 + newMap.put("lblc", zlblc);
  1771 + newMap.put("jyqp", scheduleRealInfo.getRemarks());
  1772 + list.add(newMap);
  1773 + } else {
  1774 + while (it.hasNext()) {
  1775 + ChildTaskPlan childTaskPlan = it.next();
  1776 + if (childTaskPlan.isDestroy()) {
  1777 + if(childTaskPlan.getMileageType().equals("service")){
  1778 + String destroyReason = "";
  1779 + if (childTaskPlan.getDestroyReason() == null) {
  1780 + destroyReason = "其他";
  1781 + } else if (childTaskPlan.getDestroyReason().equals("")) {
  1782 + destroyReason = "其他";
  1783 + } else if(!(lblxSet.contains(childTaskPlan.getDestroyReason()))){
  1784 + destroyReason = "其他";
  1785 + } else {
  1786 + destroyReason = childTaskPlan.getDestroyReason();
  1787 + }
  1788 + Map<String, Object> newMap = new HashMap<String, Object>();
  1789 + newMap.put("nr", destroyReason);
  1790 + newMap.put("lp", scheduleRealInfo.getLpName());
  1791 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1792 + newMap.put("jgh", scheduleRealInfo.getjGh()+scheduleRealInfo.getjName()+"/"+scheduleRealInfo.getsGh()+scheduleRealInfo.getsName());
  1793 + newMap.put("dz", childTaskPlan.getStartStationName());
  1794 + newMap.put("sj", childTaskPlan.getStartDate());
  1795 + newMap.put("gzf", " ");
  1796 + newMap.put("lbbc", 0);
  1797 + newMap.put("lblc", childTaskPlan.getMileage());
  1798 + newMap.put("jyqp", childTaskPlan.getRemarks());
  1799 + list.add(newMap);
  1800 + }
  1801 + }
  1802 + }
  1803 + }
  1804 +
  1805 + }
  1806 + }
  1807 + }
  1808 + List<Map<String, Object>> listNew=new ArrayList<Map<String,Object>>();
  1809 + for (int i = 0; i < lblxs.length; i++) {
  1810 + String lx=lblxs[i];
  1811 + double lblc=0.0;
  1812 + int lbbc=0;
  1813 + for (int j = 0; j < list.size(); j++) {
  1814 + Map<String, Object> m1=list.get(j);
  1815 + if(lx.equals(m1.get("nr").toString())){
  1816 + m1.put("lx", 0);
  1817 + listNew.add(m1);
  1818 + lblc =Arith.add(lblc,Double.parseDouble(m1.get("lblc").toString()));
  1819 + lbbc += Integer.parseInt(m1.get("lbbc").toString());
  1820 + }
  1821 + }
  1822 + if(lblc>0){
  1823 + Map<String, Object> newMap = new HashMap<String, Object>();
  1824 + newMap.put("lx", 1);
  1825 + newMap.put("nr", lx);
  1826 + newMap.put("lp", "小计");
  1827 + newMap.put("nbbm", "少驶班次");
  1828 + newMap.put("jgh", lbbc);
  1829 + newMap.put("lbbc", "少驶公里");
  1830 + newMap.put("lblc", lblc);
  1831 + newMap.put("dz", " ");
  1832 + newMap.put("sj", " ");
  1833 + newMap.put("gzf", " ");
  1834 + newMap.put("jyqp"," ");
  1835 + listNew.add(newMap);
  1836 + }
  1837 +
  1838 +
  1839 + }
  1840 + Collections.sort(listNew, new ComparableJob());
  1841 + return listNew;
  1842 + }
  1843 +
  1844 + //统计临加班次详细信息
  1845 + @Override
  1846 + public List<Map<String, Object>> jobLjqk(Map<String, Object> map) {
  1847 + // TODO Auto-generated method stub
  1848 + String line=map.get("line").toString();
  1849 + String date=map.get("date").toString();
  1850 + map.put("bcType", "normal");
  1851 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  1852 + List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  1853 + for (int i = 0; i < sList.size(); i++) {
  1854 + ScheduleRealInfo scheduleRealInfo=sList.get(i);
  1855 + if (!(scheduleRealInfo.getBcType().equals("in")
  1856 + || scheduleRealInfo.getBcType().equals("out")
  1857 + || scheduleRealInfo.getBcType().equals("ldks"))) {
  1858 +// Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1859 +// if(childTaskPlans.isEmpty()){
  1860 + if(scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){
  1861 + Map<String, Object> newMap=new HashMap<String,Object>();
  1862 + newMap.put("lp", scheduleRealInfo.getLpName());
  1863 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1864 + newMap.put("jgh", scheduleRealInfo.getjGh());
  1865 + newMap.put("dz", scheduleRealInfo.getQdzName());
  1866 + newMap.put("sj", scheduleRealInfo.getFcsj());
  1867 + newMap.put("ljlc", scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  1868 + newMap.put("jyqp", scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks());
  1869 + list.add(newMap);
  1870 + }
  1871 +// }else{
  1872 +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1873 +// while (it.hasNext()) {
  1874 +// ChildTaskPlan childTaskPlan = it.next();
  1875 +// if (childTaskPlan.isDestroy()) {
  1876 +// }
  1877 +// }
  1878 +// }
  1879 + }
  1880 + }
  1881 + return list;
  1882 + }
  1883 +
  1884 + public static double culateCJLC2(List<ScheduleRealInfo> list, String item) {
  1885 + // TODO Auto-generated method stub
  1886 + double sum = 0;
  1887 + Set<ChildTaskPlan> cts;
  1888 + for(ScheduleRealInfo sch : list){
  1889 + if (sch.isSflj())
  1890 + continue;
  1891 + cts = sch.getcTasks();
  1892 + //有子任务
  1893 + if (cts != null && cts.size() > 0) {
  1894 + for(ChildTaskPlan c : cts){
  1895 + if(c.isDestroy() && c.getDestroyReason().equals(item))
  1896 + sum = Arith.add(sum, c.getMileage());
  1897 + }
  1898 + }
  1899 +// else if(isInOut(sch))
  1900 +// continue;
  1901 + //主任务烂班
  1902 + else if(sch.getStatus() == -1){
  1903 + if(sch.getAdjustExps().equals(item) ||
  1904 + (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){
  1905 + sum = Arith.add(sum, sch.getJhlcOrig());
  1906 + }
  1907 + }
  1908 + else if(item.equals("其他")){
  1909 + double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());
  1910 + if(diff > 0){
  1911 + sum = Arith.add(sum, diff);
  1912 + }
  1913 + }
  1914 + }
  1915 + return sum;
  1916 +
  1917 + }
  1918 + @Override
  1919 + public Map<String, Object> jobHzxx(Map<String, Object> map) {
  1920 + // TODO Auto-generated method stub
  1921 + String line="";
  1922 + if(map.get("line")!=null){
  1923 + line=map.get("line").toString();
  1924 + }
  1925 + String date="";
  1926 + if(map.get("date")!=null){
  1927 + date=map.get("date").toString();
  1928 + }
  1929 +
  1930 + List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  1931 + List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>();
  1932 + for (int i = 0; i < sList.size(); i++) {
  1933 + ScheduleRealInfo s=sList.get(i);
  1934 + Set<ChildTaskPlan> cts = s.getcTasks();
  1935 + if(cts != null && cts.size() > 0){
  1936 + lists.add(s);
  1937 + }else{
  1938 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  1939 + lists.add(s);
  1940 + }
  1941 + }
  1942 + }
  1943 + Map<String, Object> newMap=culateService.culateWdbcs(lists);
  1944 + newMap.put("jhbc", culateService.culateJhbc(sList,""));
  1945 + newMap.put("jhbczgf", culateService.culateJhbc(sList,"zgf"));
  1946 + newMap.put("jhbcwgf", culateService.culateJhbc(sList,"wgf"));
  1947 + newMap.put("jhgl", culateService.culateJhgl(sList));
  1948 + newMap.put("jhglzgf", culateService.culateJhgl_(sList,"zgf"));
  1949 + newMap.put("jhglwgf", culateService.culateJhgl_(sList,"wgf"));
  1950 +
  1951 + newMap.put("lbgl", culateService.culateLbgl(sList));
  1952 + newMap.put("lbbc", culateService.culateLbbc(sList));
  1953 +
  1954 + newMap.put("sjbc", culateService.culateSjbc(lists,""));
  1955 + newMap.put("sjbczgf", culateService.culateSjbc(lists,"zgf"));
  1956 + newMap.put("sjbcwgf", culateService.culateSjbc(lists,"wgf"));
  1957 + newMap.put("sjgl", culateService.culateSjgl(lists));
  1958 + newMap.put("sjglzgf", culateService.culateSjgl_(lists,"zgf"));
  1959 + newMap.put("sjglwgf", culateService.culateSjgl_(lists,"wgf"));
  1960 +
  1961 +
  1962 + newMap.put("ljgl", culateService.culateLjgl(lists));
  1963 + newMap.put("ljglzgf", culateService.culateLjgl_(lists,"zgf"));
  1964 + newMap.put("ljglwgf", culateService.culateLjgl_(lists,"wgf"));
  1965 +
  1966 + newMap.put("ljbc", culateService.culateLjbc(lists,""));
  1967 + newMap.put("ksgl", culateService.culateKsgl(lists));
  1968 +
  1969 + newMap.put("jhfbbc",culateService.culateDtfzbc(lists, "venting", "jh", ""));
  1970 + newMap.put("jhfbbczgf",culateService.culateDtfzbc(lists, "venting", "jh", "zgf"));
  1971 + newMap.put("jhfbbcwgf",culateService.culateDtfzbc(lists, "venting", "jh", "wgf"));
  1972 + newMap.put("sjfbbc",culateService.culateDtfzbc(lists, "venting", "sj", ""));
  1973 + newMap.put("sjfbbczgf",culateService.culateDtfzbc(lists, "venting", "sj", "zgf"));
  1974 + newMap.put("sjfbbcwgf",culateService.culateDtfzbc(lists, "venting", "sj", "wgf"));
  1975 +
  1976 + newMap.put("jhdtbc",culateService.culateDtfzbc(lists, "major", "jh", ""));
  1977 + newMap.put("jhdtbczgf",culateService.culateDtfzbc(lists, "major", "jh", "zgf"));
  1978 + newMap.put("jhdtbcwgf",culateService.culateDtfzbc(lists, "major", "jh", "wgf"));
  1979 + newMap.put("sjdtbc",culateService.culateDtfzbc(lists, "major", "sj", ""));
  1980 + newMap.put("sjdtbczgf",culateService.culateDtfzbc(lists, "major", "sj", "zgf"));
  1981 + newMap.put("sjdtbcwgf",culateService.culateDtfzbc(lists, "major", "sj", "wgf"));
  1982 + return newMap;
  1983 + }
  1984 + @Override
  1985 + public List<Map<String, Object>> lineList() {
  1986 + // TODO Auto-generated method stub
  1987 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  1988 + List<Line> findAllLine = lineRepository.findAllLine();
  1989 + for(Line line : findAllLine){
  1990 + Map<String, Object> map=new HashMap<String,Object>();
  1991 + map.put("gsbm", line.getCompany());
  1992 + map.put("fgsbm", line.getBrancheCompany());
  1993 + map.put("xlbm", line.getLineCode());
  1994 + if(line.getDestroy() == 1){
  1995 + map.put("xlname", line.getName() + "(撤销)");
  1996 + } else {
  1997 + map.put("xlname", line.getName());
  1998 + }
  1999 + list.add(map);
  2000 + }
  2001 + return list;
  2002 + }
  2003 + @Override
  2004 + public List<Map<String, Object>> lineListNotDestroy() {
  2005 + // TODO Auto-generated method stub
  2006 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  2007 + Iterator<Line> iterator = lineRepository.findAllService().iterator();
  2008 + Line line;
  2009 + while (iterator.hasNext()) {
  2010 + line = iterator.next();
  2011 + Map<String, Object> map=new HashMap<String,Object>();
  2012 + map.put("gsbm", line.getCompany());
  2013 + map.put("fgsbm", line.getBrancheCompany());
  2014 + map.put("xlbm", line.getLineCode());
  2015 + map.put("xlname", line.getName());
  2016 + list.add(map);
  2017 + }
  2018 + return list;
  2019 + }
  2020 + @Override
  2021 + public List<Map<String, String>> carList(Map<String, Object> maps) {
  2022 + // TODO Auto-generated method stub
  2023 + // 转大写
  2024 + String nbbm =maps.get("nbbm").toString().toUpperCase();
  2025 + String gsbm="";
  2026 +
  2027 + if(maps.get("gsbm")!=null)
  2028 + gsbm= maps.get("gsbm").toString().trim();
  2029 +// String fgsbm=maps.get("fgsbm").toString().trim();
  2030 + String xlbm=maps.get("xlbm").toString().trim();
  2031 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  2032 + Map<String, String> map;
  2033 + Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();
  2034 +
  2035 + Line line;
  2036 + for (String k : allSet) {
  2037 + if (k.indexOf(nbbm) != -1) {
  2038 + // 所属线路
  2039 + boolean fage=true;
  2040 + map = new HashMap<>();
  2041 + line = BasicData.nbbm2LineMap.get(k);
  2042 + String clgsdm= BasicData.nbbm2CompanyCodeMap.get(k);
  2043 +
  2044 + map.put("id", k);
  2045 + map.put("text", k);
  2046 + if (null != line) {
  2047 + map.put("lineName", line.getName());
  2048 + map.put("lineCode", line.getLineCode());
  2049 + }
  2050 +
  2051 + if(!xlbm.equals("")){
  2052 + if(null!=line){
  2053 + if(!line.getLineCode().equals(xlbm)){
  2054 + fage=false;
  2055 + }
  2056 + }
  2057 +
  2058 + }
  2059 +
  2060 + if(!gsbm.equals("")){
  2061 + if(!clgsdm.equals(gsbm)){
  2062 + fage=false;
  2063 + }
  2064 + }
  2065 +
  2066 + if(fage){
  2067 + list.add(map);
  2068 + }
  2069 +
  2070 + }
  2071 +
  2072 + if (list.size() > 20)
  2073 + break;
  2074 + }
  2075 + return list;
  2076 + }
  2077 + @Override
  2078 + public List<Map<String, String>> carListByHistory(Map<String, Object> maps) {
  2079 + // TODO Auto-generated method stub
  2080 + // 转大写
  2081 + String nbbm = maps.get("nbbm").toString().toUpperCase();
  2082 +
  2083 + String xlbm = maps.get("xlbm").toString().trim();
  2084 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  2085 + Map<String, String> map;
  2086 +
  2087 + List<String> allNbbm = BasicData.lineCodeHistoryNbbmMap.get(xlbm);
  2088 +
  2089 + if(allNbbm != null){
  2090 + for(String n : allNbbm){
  2091 + if(n.indexOf(nbbm) != -1){
  2092 + map = new HashMap<>();
  2093 + map.put("id", n);
  2094 + map.put("text", n);
  2095 +
  2096 + list.add(map);
  2097 + }
  2098 +
  2099 + if (list.size() > 20)
  2100 + break;
  2101 + }
  2102 + }
  2103 +
  2104 + return list;
  2105 + }
  2106 +
  2107 +
  2108 + @Override
  2109 + public List<Map<String, String>> userList(Map<String, Object> maps) {
  2110 + // TODO Auto-generated method stub
  2111 + // 转大写
  2112 + String jsy =maps.get("jsy").toString().toUpperCase();
  2113 + String gsbm="";
  2114 + if(maps.get("gsbm")!=null)
  2115 + gsbm=maps.get("gsbm").toString().trim();
  2116 +// String fgsbm=maps.get("fgsbm").toString().trim();
  2117 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  2118 + Map<String, String> map;
  2119 +// Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();
  2120 + Set<String> allJsy = BasicData.perMap.keySet();
  2121 +
  2122 + Personnel per;
  2123 + for (String k : allJsy) {
  2124 + if (k.indexOf(jsy) != -1) {
  2125 + map = new HashMap<>();
  2126 + // 通过人员查找公司
  2127 + per = BasicData.perMap.get(k);
  2128 + String rygsdm="";
  2129 + if(null != per){
  2130 + if(per.getCompanyCode()!=null){
  2131 + rygsdm = per.getCompanyCode();
  2132 + }
  2133 + String jboCode=per.getJobCode().substring(per.getJobCode().indexOf("-")+1);
  2134 + map.put("id", jboCode);
  2135 + map.put("text", jboCode+"/"+per.getPersonnelName());
  2136 + if(!gsbm.equals("")){
  2137 + if(rygsdm.equals(gsbm)){
  2138 + list.add(map);
  2139 + }
  2140 + }
  2141 + }
  2142 + }
  2143 +
  2144 + if (list.size() > 20)
  2145 + break;
  2146 + }
  2147 + return list;
  2148 + }
  2149 +
  2150 + public List<ArrivalInfo> load4(String line, String date, int zd,String minfcsj){
  2151 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2152 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  2153 + Long date1=0L;
  2154 + Long date2=0L;
  2155 + Calendar cal = Calendar.getInstance();
  2156 + List<ArrivalInfo> list=null;
  2157 + try {
  2158 + Date dates1 = simpleDateFormat.parse(date+" "+minfcsj+":01");
  2159 + String d1=date+" "+minfcsj+":01";
  2160 +// Date dates2=simpleDateFormat.parse(date+" 23:59:59");
  2161 + date1=dates1.getTime();
  2162 +
  2163 + cal.setTime(dates1);
  2164 + int weeks_year1 = cal.get(Calendar.WEEK_OF_YEAR);
  2165 + cal.add(cal.DATE,1);//把日期往后增加一天.整数往后推,负数往前移动
  2166 + int weeks_year2 = cal.get(Calendar.WEEK_OF_YEAR);
  2167 + Date dates2=cal.getTime();
  2168 + date2=dates2.getTime();
  2169 + String d2=simpleDateFormat.format(dates2);
  2170 +
  2171 + Connection conn = null;
  2172 + PreparedStatement ps = null;
  2173 + ResultSet rs = null;
  2174 + String year=date.substring(0,4);
  2175 + String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year=? AND line_id=? "
  2176 + + " AND up_down=? AND ts >= ? AND ts <=? order by device_id,ts";
  2177 + try{
  2178 + conn = DBUtils_MS.getConnection();
  2179 + ps = conn.prepareStatement(sql);
  2180 + ps.setInt(1, weeks_year1);
  2181 + ps.setString(2, line);
  2182 + ps.setInt(3, zd);
  2183 + ps.setLong(4, date1);
  2184 + ps.setLong(5, date2);
  2185 + rs = ps.executeQuery();
  2186 +
  2187 + list = resultSet2Set(rs);
  2188 + }catch(Exception e){
  2189 + logger.error("", e);
  2190 + }finally {
  2191 + DBUtils_MS.close(rs, ps, conn);
  2192 + }
  2193 +
  2194 + } catch (ParseException e1) {
  2195 + // TODO Auto-generated catch block
  2196 + e1.printStackTrace();
  2197 + }
  2198 + return list;
  2199 +
  2200 + }
  2201 +
  2202 + public List<ArrivalInfo> load3(String line, String date, int zd){
  2203 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2204 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  2205 + Long date1=0L;
  2206 + Long date2=0L;
  2207 + Calendar cal = Calendar.getInstance();
  2208 + try {
  2209 + Date dates1 = simpleDateFormat.parse(date+" 00:00:01");
  2210 + Date dates2=simpleDateFormat.parse(date+" 23:59:59");
  2211 + date1=dates1.getTime();
  2212 + date2=dates2.getTime();
  2213 + cal.setTime(dates1);
  2214 + } catch (ParseException e1) {
  2215 + // TODO Auto-generated catch block
  2216 + e1.printStackTrace();
  2217 + }
  2218 + //周数,表分区字段
  2219 + int weeks_year1 = cal.get(Calendar.WEEK_OF_YEAR);
  2220 + List<ArrivalInfo> list = null;
  2221 + Connection conn = null;
  2222 + PreparedStatement ps = null;
  2223 + ResultSet rs = null;
  2224 + String year=date.substring(0,4);
  2225 + String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year=? AND line_id=? "
  2226 + + " AND up_down=? AND ts >= ? AND ts <=? order by device_id,ts";
  2227 + try{
  2228 + conn = DBUtils_MS.getConnection();
  2229 + ps = conn.prepareStatement(sql);
  2230 + ps.setInt(1, weeks_year1);
  2231 + ps.setString(2, line);
  2232 + ps.setInt(3, zd);
  2233 + ps.setLong(4, date1);
  2234 + ps.setLong(5, date2);
  2235 + rs = ps.executeQuery();
  2236 +
  2237 + list = resultSet2Set(rs);
  2238 + }catch(Exception e){
  2239 + logger.error("", e);
  2240 + }finally {
  2241 + DBUtils_MS.close(rs, ps, conn);
  2242 + }
  2243 + return list;
  2244 + }
  2245 +
  2246 + //根据排班查到离站
  2247 + @Override
  2248 + public List<Map<String, Object>> queryInOutStrtion(String line, String date, int zd,String lzsj) {
  2249 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2250 + //查询线路所有的站点
  2251 + List<ArrivalInfo> arrInfoList=this.load3(line, date, zd);
  2252 + List<StationRoute> listStation= stationRouteRepository.findByLine(line,zd);
  2253 + List<Map<String, Object>> inoutList=new ArrayList<Map<String,Object>>();
  2254 + //保存的所以的站点信息
  2255 + Map<String, Object> map1=new HashMap<String,Object>();
  2256 + map1.put("bc", "");
  2257 + map1.put("nbbm", "");
  2258 +
  2259 + //所有的班次信息(实际排班排序)
  2260 + List<ScheduleRealInfo> realList= scheduleRealInfoRepository.scheduleByDateAndLineInOut(line, date,zd+"");
  2261 + for (int i = 0; i < listStation.size(); i++) {
  2262 + map1.put(listStation.get(i).getStationCode()+"in"
  2263 + , listStation.get(i).getStationName());
  2264 + map1.put(listStation.get(i).getStationCode()+"out"
  2265 + , (i+1));
  2266 + }
  2267 + inoutList.add(map1);
  2268 +
  2269 + for (int i = 0; i < realList.size(); i++) {
  2270 + ScheduleRealInfo sinfo=realList.get(i);
  2271 + String devuceId=BasicData.deviceId2NbbmMap.inverse().get(sinfo.getClZbh());
  2272 + String sjfcsj=sinfo.getRealExecDate()+" "+sinfo.getFcsjActual()+":00";
  2273 + String sjddsj=sinfo.getRealExecDate()+" "+sinfo.getZdsjActual()+":59";
  2274 +
  2275 + try {
  2276 + Date dates1 = simpleDateFormat.parse(sjfcsj);
  2277 + Date dates2=simpleDateFormat.parse(sjddsj);
  2278 + Long date1=dates1.getTime();
  2279 + Long date2=dates2.getTime();
  2280 + List<ArrivalInfo> arrList=new ArrayList<ArrivalInfo>();
  2281 + for (int j = 0; j < arrInfoList.size(); j++) {
  2282 + ArrivalInfo a=arrInfoList.get(j);
  2283 + if(a.getDeviceId().equals(devuceId) && a.getTs()>=date1 && a.getTs()<=date2){
  2284 + arrList.add(a);
  2285 + }
  2286 + }
  2287 +
  2288 + Map<String, Object> map2=new HashMap<String,Object>();
  2289 + map2.put("bc", (i+1));
  2290 + map2.put("nbbm", sinfo.getClZbh());
  2291 +
  2292 + for (int j = 0; j < listStation.size(); j++) {
  2293 + StationRoute s=listStation.get(j);
  2294 + List<ArrivalInfo> arrivalList=new ArrayList<ArrivalInfo>();
  2295 + for (int j2 = 0; j2 < arrList.size(); j2++) {
  2296 + ArrivalInfo a=arrList.get(j2);
  2297 + if(s.getStationCode().equals(a.getStopNo())){
  2298 + arrivalList.add(a);
  2299 + }
  2300 + }
  2301 + Map<String, String> m=this.strInOut(arrivalList,lzsj);
  2302 +
  2303 + map2.put(s.getStationCode()+"in", m.get("in"));
  2304 + map2.put(s.getStationCode()+"out", m.get("out"));
  2305 + map2.put(s.getStationCode(), m.get("type"));
  2306 + }
  2307 + inoutList.add(map2);
  2308 + } catch (ParseException e) {
  2309 + // TODO Auto-generated catch block
  2310 + e.printStackTrace();
  2311 + }
  2312 + }
  2313 + return inoutList;
  2314 + }
  2315 +
  2316 + //根据GPS查到离站
  2317 + @Override
  2318 + public List<Map<String, Object>> queryInOutStrtions(String line, String date, int zd,String lzsj) {
  2319 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2320 + String minfcsj="02:00";
  2321 + List<Line> lineList=lineRepository.findLineByCode(line);
  2322 + if(lineList.size()>0){
  2323 + List<String> objList = new ArrayList<String>();
  2324 + objList.add(lineList.get(0).getId() + "");
  2325 + String sqlMinYysj="select start_opt from bsth_c_line_config where "
  2326 + + " id = ("
  2327 + + "select max(id) from bsth_c_line_config where line = ?"
  2328 + + ")";
  2329 + minfcsj= jdbcTemplate.queryForObject(sqlMinYysj, objList.toArray(), String.class);
  2330 + }
  2331 + List<ArrivalInfo> arrInfoList=this.load4(line, date, zd,minfcsj);
  2332 +
  2333 + //查询线路所有的站点
  2334 + List<StationRoute> listStation= stationRouteRepository.findByLine(line,zd);
  2335 + List<Map<String, Object>> inoutList=new ArrayList<Map<String,Object>>();
  2336 + //保存的所以的站点信息
  2337 + Map<String, Object> map1=new HashMap<String,Object>();
  2338 + map1.put("bc", "");
  2339 + map1.put("nbbm", "");
  2340 +
  2341 + for (int i = 0; i < listStation.size(); i++) {
  2342 + map1.put(listStation.get(i).getStationCode()+"in"
  2343 + , listStation.get(i).getStationName());
  2344 + map1.put(listStation.get(i).getStationCode()+"out"
  2345 + , (i+1));
  2346 + }
  2347 + inoutList.add(map1);
  2348 + List<String> list_nbbm=new ArrayList<String>();
  2349 + Map<String, Object> m=new HashMap<String,Object>();
  2350 + for (int i = 0; i < arrInfoList.size(); i++) {
  2351 + arrInfoList.get(i).setRoute(-1);
  2352 + for (int j = 0; j < listStation.size(); j++) {
  2353 + if(arrInfoList.get(i).getStopNo().equals(listStation.get(j).getStationCode())){
  2354 + arrInfoList.get(i).setRoute(listStation.get(j).getStationRouteCode());
  2355 +
  2356 + }
  2357 + }
  2358 + if(m.get(arrInfoList.get(i).getDeviceId())==null){
  2359 + m.put(arrInfoList.get(i).getDeviceId(), arrInfoList.get(i).getDeviceId());
  2360 + list_nbbm.add(arrInfoList.get(i).getDeviceId());
  2361 + }
  2362 + }
  2363 +
  2364 + Map<String, Object> map2=new HashMap<String, Object>();
  2365 + for (int i = 0; i < list_nbbm.size(); i++) {
  2366 + String nbbm=list_nbbm.get(i);
  2367 +
  2368 + int zdbm =0;
  2369 + int inout=-1;
  2370 + List<ArrivalInfo> arrivalList=new ArrayList<ArrivalInfo>();
  2371 + for (int j = 0; j < arrInfoList.size(); j++) {
  2372 + ArrivalInfo aif=arrInfoList.get(j);
  2373 +
  2374 + if(aif.getDeviceId().equals(nbbm)){
  2375 + map2.put("nbbm", BasicData.deviceId2NbbmMap.get(nbbm));
  2376 + if(aif.getRoute()>-1){
  2377 + if(((inout==aif.getInOut() && zdbm==aif.getRoute()) || !(zdbm ==aif.getRoute()))){
  2378 + if(aif.getRoute()<=zdbm ){
  2379 + inoutList.add(map2);
  2380 + map2=new HashMap<String, Object>();
  2381 + arrivalList=new ArrayList<ArrivalInfo>();
  2382 + }
  2383 + }
  2384 + arrivalList.add(aif);
  2385 +// if(!(zdbm ==aif.getRoute())){
  2386 + Map<String, String> m_=this.strInOut(arrivalList,lzsj);
  2387 + map2.put(aif.getStopNo()+"in", m_.get("in"));
  2388 + map2.put(aif.getStopNo()+"out", m_.get("out"));
  2389 + map2.put(aif.getStopNo(), m_.get("type"));
  2390 +// arrivalList=new ArrayList<ArrivalInfo>();
  2391 +// }
  2392 + zdbm =aif.getRoute();
  2393 + inout=aif.getInOut();
  2394 +
  2395 + }
  2396 +
  2397 + }
  2398 +
  2399 + }
  2400 + }
  2401 +
  2402 + return inoutList;
  2403 + }
  2404 +
  2405 + public Map<String, String> strInOut(List<ArrivalInfo> lists,String lzsj){
  2406 + String inout="";
  2407 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  2408 + Long in=0L;
  2409 + Long out=0L;
  2410 + for(int i=0;i<lists.size();i++){
  2411 + ArrivalInfo t1=lists.get(i);
  2412 + if(t1.getInOut()==0){
  2413 + in=t1.getTs();
  2414 + t1.setJzsj(sdf.format(new Date(t1.getTs())));
  2415 + for(int j=0;j<lists.size();j++){
  2416 + ArrivalInfo t2=lists.get(j);
  2417 + if(t2.getInOut()==1 && t2.getDeviceId().equals(t1.getDeviceId())
  2418 + && t2.getStopNo().equals(t1.getStopNo())
  2419 + && t2.getTs()>t1.getTs()){
  2420 + t1.setCzsj(sdf.format(new Date(t2.getTs())));
  2421 + out =t2.getTs();
  2422 + break;
  2423 + }else{
  2424 + t1.setCzsj("");
  2425 + out =0l;
  2426 + }
  2427 + }
  2428 +
  2429 + }else{
  2430 + out =t1.getTs();
  2431 + t1.setCzsj(sdf.format(new Date(t1.getTs())));
  2432 + for(int j=0;j<lists.size();j++){
  2433 + ArrivalInfo t2=lists.get(j);
  2434 + if(t2.getInOut()==0 && t2.getDeviceId().equals(t1.getDeviceId())
  2435 + && t2.getStopNo().equals(t1.getStopNo())
  2436 + && t2.getTs()>t1.getTs()){
  2437 + in =t2.getTs();
  2438 + t1.setJzsj(sdf.format(new Date(t2.getTs())));
  2439 + break;
  2440 + }
  2441 + }
  2442 + }
  2443 + }
  2444 +
  2445 + Map<String, String> map=new HashMap<String,String>();
  2446 + if(in>0 ){
  2447 + map.put("in",sdf.format(new Date(in)));
  2448 +
  2449 + }else{
  2450 + map.put("in", "");
  2451 + }
  2452 + if(out>0){
  2453 + map.put("out", sdf.format(new Date(out)));
  2454 + }else{
  2455 + map.put("out", "");
  2456 + }
  2457 + Long sj=1000000000L;
  2458 + if(!lzsj.trim().equals("")){
  2459 + sj =Long.parseLong(lzsj);
  2460 + }
  2461 + if(in>0 && out >0){
  2462 + if((out-in)/1000>sj){
  2463 + map.put("type", "y");
  2464 + }else{
  2465 + map.put("type", "n");
  2466 + }
  2467 + }
  2468 + return map;
  2469 + }
  2470 + @Override
  2471 + public List<StationRoute> queryStrinon(String line, int zd) {
  2472 + // TODO Auto-generated method stub
  2473 + List<StationRoute> listStation= stationRouteRepository.findByLine(line,zd);
  2474 + return listStation;
  2475 + }
  2476 +
  2477 + @Override
  2478 + public List<Map<String, Object>> countMileageSum(Map<String, Object> map) {
  2479 + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  2480 +
  2481 + String date="", date2="";
  2482 + if(map.get("date")!=null){
  2483 + date=map.get("date").toString();
  2484 + }
  2485 + if(map.get("date2")!=null){
  2486 + date2=map.get("date2").toString();
  2487 + }
  2488 + String nature="0";
  2489 + if(map.get("nature")!=null){
  2490 + nature=map.get("nature").toString();
  2491 + }
  2492 + String type="";
  2493 + if(map.get("type")!=null){
  2494 + type=map.get("type").toString();
  2495 + }
  2496 +
  2497 + List<Map<String, Object>> listAll = calcWaybillService.getLineMileage("", "", "", date, date2, "", "", "", "query");
  2498 + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  2499 + Map<String, Boolean> lineMap=lineService.lineNature();
  2500 + if(nature.equals("0")){
  2501 + list=listAll;
  2502 + }else{
  2503 + for (Map<String, Object> m : listAll) {
  2504 + if(m.get("xl") != null && m.get("xl").toString().trim().length() > 0){
  2505 + String xl = m.get("xl").toString();
  2506 + if(nature.equals("1")){
  2507 + if(lineMap.containsKey(xl) && lineMap.get(xl)){
  2508 + list.add(m);
  2509 + }
  2510 + }else{
  2511 + if(!(lineMap.containsKey(xl) && lineMap.get(xl))){
  2512 + list.add(m);
  2513 + }
  2514 + }
  2515 + }
  2516 + }
  2517 + }
  2518 +
  2519 + List<Business> allBusiness = businessRepository.getOrder();
  2520 + Set<String> gsFgsSet = new HashSet<String>(); // 有排序编号的公司,防止乱序或者合计值出问题。
  2521 + for(Business b : allBusiness){
  2522 + gsFgsSet.add(b.getUpCode() + "_" + b.getBusinessCode());
  2523 + gsFgsSet.add(b.getBusinessCode());
  2524 + }
  2525 +
  2526 + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>();
  2527 + List<String> keyList = new ArrayList<String>();
  2528 +
  2529 + Map<String, Object> hj = new HashMap<String, Object>(); // 合计
  2530 + hj.put("gsName", "合计");
  2531 + hj.put("fgsBm", " ");
  2532 +
  2533 + for(Map<String, Object> m : list){
  2534 + m.put("gsBm", m.get("gsdm"));
  2535 + m.put("fgsBm", m.get("fgsdm"));
  2536 + if(m.get("gsBm") != null && m.get("fgsBm") != null
  2537 + && m.get("gsBm").toString().trim().length() > 0
  2538 + && m.get("fgsBm").toString().trim().length() > 0){
  2539 + String gsBm = m.get("gsBm").toString().trim();
  2540 + String fgsBm = m.get("fgsBm").toString().trim();
  2541 + String key = gsBm + "_" + fgsBm; // 分公司key
  2542 + String key2 = gsBm + "_sum"; // 直属公司key
  2543 + if(!gsFgsSet.contains(key) && !gsFgsSet.contains(gsBm)){
  2544 + continue;
  2545 + }
  2546 + if(!keyMap.containsKey(key)){ // 每个分公司一条
  2547 + Map<String, Object> t = new HashMap<String, Object>();
  2548 + t.put("gsName", m.get("gs"));
  2549 + t.put("fgsName", m.get("fgs"));
  2550 + t.put("key", key);
  2551 + keyMap.put(key, t);
  2552 + keyList.add(key);
  2553 + if(!keyMap.containsKey(key2)){ // 直属公司小计
  2554 + Map<String, Object> t2 = new HashMap<String, Object>();
  2555 + t2.put("gsName", m.get("gs"));
  2556 + t2.put("fgsName", "小计");
  2557 + t2.put("key", key2);
  2558 + keyMap.put(key2, t2);
  2559 + keyList.add(key2);
  2560 + }
  2561 + }
  2562 + Map<String, Object> t = keyMap.get(key);
  2563 + Map<String, Object> t2 = keyMap.get(key2);
  2564 + for(String s : m.keySet()){
  2565 + if("gsName,fgsName,key".contains(s)){
  2566 + continue;
  2567 + }
  2568 + try {
  2569 + if(t.containsKey(s)){ // 分公司
  2570 + t.put(s, new BigDecimal(t.get(s).toString()).add(new BigDecimal(m.get(s).toString())));
  2571 + } else {
  2572 + t.put(s, m.get(s).toString());
  2573 + }
  2574 + if(t2.containsKey(s)){ // 直属公司
  2575 + t2.put(s, new BigDecimal(t2.get(s).toString()).add(new BigDecimal(m.get(s).toString())));
  2576 + } else {
  2577 + t2.put(s, m.get(s).toString());
  2578 + }
  2579 + if(hj.containsKey(s)){ // 合计
  2580 + hj.put(s, new BigDecimal(hj.get(s).toString()).add(new BigDecimal(m.get(s).toString())));
  2581 + } else {
  2582 + hj.put(s, m.get(s).toString());
  2583 + }
  2584 + } catch (Exception e) {
  2585 + // TODO: handle exception
  2586 + continue;
  2587 + }
  2588 + }
  2589 + }
  2590 + }
  2591 +
  2592 + for(Business b : allBusiness){ // 根据公司排序插入返回对象
  2593 + String gs = b.getBusinessCode();
  2594 + String gsfgs = b.getUpCode() + "_" + b.getBusinessCode();
  2595 + for(String key : keyList){
  2596 + if(key.equals(gsfgs)){
  2597 + resList.add(keyMap.get(key));
  2598 + break;
  2599 + } else if(key.replaceAll("_sum", "").equals(gs)){
  2600 + resList.add(keyMap.get(key));
  2601 + break;
  2602 + }
  2603 + }
  2604 + }
  2605 + resList.add(hj);
  2606 +
  2607 + if(type.equals("export")){
  2608 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  2609 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  2610 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  2611 + Map<String, Object> m = new HashMap<String, Object>();
  2612 + String xls="countMileageSum.xls";
  2613 + ReportUtils ee = new ReportUtils();
  2614 + try {
  2615 + String dateTime = "";
  2616 + if(date.equals(date2)){
  2617 + m.put("date", date);
  2618 + dateTime = sdfSimple.format(sdfMonth.parse(date));
  2619 + } else {
  2620 + m.put("date", date + "至" + date2);
  2621 + dateTime = sdfSimple.format(sdfMonth.parse(date))
  2622 + +"-"+sdfSimple.format(sdfMonth.parse(date2));
  2623 + }
  2624 + listI.add(resList.iterator());
  2625 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  2626 + ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls,
  2627 + path + "export/"+dateTime+"-审计公里汇总表.xls");
  2628 + } catch (Exception e) {
  2629 + // TODO: handle exception
  2630 + e.printStackTrace();
  2631 + }
  2632 + }
  2633 +
  2634 + return resList;
  2635 + }
  2636 +
  2637 + @Override
  2638 + public List<Map<String, Object>> countByList(Map<String, Object> map) {
  2639 + // TODO Auto-generated method stub
  2640 +
  2641 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  2642 + String gsdm="";
  2643 + if(map.get("gsdm")!=null){
  2644 + gsdm=map.get("gsdm").toString();
  2645 + }
  2646 + String fgsdm="";
  2647 + if(map.get("fgsdm")!=null){
  2648 + fgsdm=map.get("fgsdm").toString();
  2649 + }
  2650 + String line="";
  2651 + if(map.get("line")!=null){
  2652 + line=map.get("line").toString();
  2653 + }
  2654 + String date="";
  2655 + if(map.get("date")!=null){
  2656 + date=map.get("date").toString();
  2657 + }
  2658 + String date2="";
  2659 + if(map.get("date2")!=null){
  2660 + date2=map.get("date2").toString();
  2661 + }
  2662 + String xlName="";
  2663 + if(map.get("xlName")!=null){
  2664 + xlName=map.get("xlName").toString();
  2665 + }
  2666 + String nature="0";
  2667 + if(map.get("nature")!=null){
  2668 + nature=map.get("nature").toString();
  2669 + }
  2670 + String type="";
  2671 + if(map.get("type")!=null){
  2672 + type=map.get("type").toString();
  2673 + }
  2674 + //所有班次信息
  2675 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  2676 + line =line.trim();
  2677 + if(gsdm.equals("") && fgsdm.equals("") && line.equals("")){
  2678 + list = scheduleRealInfoRepository.scheduleByDateAndLineTj3(date, date2);
  2679 + } else if(line.equals("")){
  2680 + //查询所有线路
  2681 + list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date,date2,gsdm,fgsdm);
  2682 + }else{
  2683 + //查询单条线路
  2684 + list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date,date2);
  2685 + }
  2686 +
  2687 + Map<String, Boolean> lineMap = lineService.lineNature();
  2688 +
  2689 + List<String> objList = new ArrayList<String>();
  2690 + String sql="select r.xl_bm"
  2691 + + " from bsth_c_s_sp_info_real r where"
  2692 + + " r.schedule_date_str BETWEEN ? and ?";
  2693 + objList.add(date);
  2694 + objList.add(date2);
  2695 + if("".equals(gsdm.trim()) && "".equals(fgsdm.trim()) && "".equals(line.trim())){
  2696 +
  2697 + } else if(line.equals("")){
  2698 + sql +=" and r.gs_bm=?"
  2699 + + " and r.fgs_bm like CONCAT('%',?,'%')";
  2700 + objList.add(gsdm);
  2701 + objList.add(fgsdm);
  2702 + }else{
  2703 + sql += " and r.xl_bm = ?";
  2704 + objList.add(line);
  2705 + }
  2706 + sql += " group by r.xl_bm";
  2707 +
  2708 + List<String> listLine=jdbcTemplate.query(sql, objList.toArray(), new RowMapper<String>() {
  2709 + @Override
  2710 + public String mapRow(ResultSet arg0, int arg1) throws SQLException {
  2711 + String ve = arg0.getString("xl_bm");
  2712 + return ve;
  2713 + }
  2714 + });
  2715 + for (int i = 0; i < listLine.size(); i++) {
  2716 + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
  2717 + String lineStr=listLine.get(i);
  2718 + if("0".equals(nature)){ // 全部
  2719 +
  2720 + } else if("1".equals(nature)){ // 营运
  2721 + if(!(lineMap.containsKey(lineStr) && lineMap.get(lineStr))){
  2722 + continue;
  2723 + }
  2724 + } else { // 非营运
  2725 + if(lineMap.containsKey(lineStr) && lineMap.get(lineStr)){
  2726 + continue;
  2727 + }
  2728 + }
  2729 +
  2730 + for (int j = 0; j < list.size(); j++) {
  2731 + ScheduleRealInfo s=list.get(j);
  2732 + if(s.getXlBm().equals(lineStr)){
  2733 + lists.add(s);
  2734 + }
  2735 + }
  2736 +
  2737 + //计算线路的各项公里
  2738 + if(lists.size()>0){
  2739 + Map<String, Object> newMap=staticTj(lists,"z");
  2740 + lMap.add(newMap);
  2741 + }
  2742 + }
  2743 + if(list.size()>0){
  2744 + Map<String, Object> newMap=staticTj(list,"f");
  2745 + lMap.add(newMap);
  2746 + }
  2747 + if(type.equals("export")){
  2748 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  2749 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  2750 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  2751 + Map<String, Object> m = new HashMap<String, Object>();
  2752 + m.put("date", date);
  2753 + m.put("date1", date2);
  2754 + String by=map.get("by").toString();
  2755 + String xls="";
  2756 + if(by.equals("sj")){
  2757 + xls="countByLine.xls";
  2758 + }else{
  2759 + xls="countByLines.xls";
  2760 + }
  2761 + ReportUtils ee = new ReportUtils();
  2762 + try {
  2763 + String dateTime = "";
  2764 + if(date.equals(date2)){
  2765 + dateTime = sdfSimple.format(sdfMonth.parse(date));
  2766 + } else {
  2767 + dateTime = sdfSimple.format(sdfMonth.parse(date))
  2768 + +"-"+sdfSimple.format(sdfMonth.parse(date2));
  2769 + }
  2770 + listI.add(lMap.iterator());
  2771 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  2772 + ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls,
  2773 + path + "export/"+dateTime+"-"+xlName+"-线路公里统计表.xls");
  2774 + } catch (Exception e) {
  2775 + // TODO: handle exception
  2776 + e.printStackTrace();
  2777 + }
  2778 + }
  2779 + return lMap;
  2780 + }
  2781 +
  2782 +
  2783 + @Override
  2784 + public List<Map<String, Object>> countByList2(Map<String, Object> map) {
  2785 + // TODO Auto-generated method stub
  2786 +
  2787 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  2788 + String gsdm="";
  2789 + if(map.get("gsdm")!=null){
  2790 + gsdm=map.get("gsdm").toString();
  2791 + }
  2792 + String fgsdm="";
  2793 + if(map.get("fgsdm")!=null){
  2794 + fgsdm=map.get("fgsdm").toString();
  2795 + }
  2796 + String line="";
  2797 + if(map.get("line")!=null){
  2798 + line=map.get("line").toString();
  2799 + }
  2800 + String date="";
  2801 + if(map.get("date")!=null){
  2802 + date=map.get("date").toString();
  2803 + }
  2804 + String date2="";
  2805 + if(map.get("date2")!=null){
  2806 + date2=map.get("date2").toString();
  2807 + }
  2808 + String xlName="";
  2809 + if(map.get("xlName")!=null){
  2810 + xlName=map.get("xlName").toString();
  2811 + }
  2812 + String type="";
  2813 + if(map.get("type")!=null){
  2814 + type=map.get("type").toString();
  2815 + }
  2816 + //所有班次信息
  2817 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  2818 + line = line.trim();
  2819 +
  2820 + List<String> objList = new ArrayList<String>();
  2821 + objList.add(date);
  2822 + objList.add(date2);
  2823 + String sql="select r.xl_bm"
  2824 + + " from bsth_c_s_sp_info_real r where"
  2825 + + " r.schedule_date_str >= ? and r.schedule_date_str >= ?";
  2826 +
  2827 +
  2828 + if(line.equals("")){
  2829 + sql +=" and r.gs_bm = ?"
  2830 + + " and r.fgs_bm = ?";
  2831 + objList.add(gsdm);
  2832 + objList.add(fgsdm);
  2833 + }else{
  2834 + sql += " and r.xl_bm = ?";
  2835 + objList.add(line);
  2836 + }
  2837 + sql += " group by r.xl_bm";
  2838 +
  2839 + List<String> listLine=jdbcTemplate.query(sql, objList.toArray(), new RowMapper<String>() {
  2840 + @Override
  2841 + public String mapRow(ResultSet arg0, int arg1) throws SQLException {
  2842 + String ve = arg0.getString("xl_bm");
  2843 + return ve;
  2844 + }
  2845 + });
  2846 + for (int i = 0; i < listLine.size(); i++) {
  2847 + List<ScheduleRealInfo> lists =scheduleRealInfoRepository.scheduleByDateAndLineTj2(listLine.get(i), date,date2);
  2848 + list.addAll(lists);
  2849 + //计算线路的各项公里
  2850 + if(lists.size()>0){
  2851 + Map<String, Object> newMap=staticTj(lists,"z");
  2852 + lMap.add(newMap);
  2853 + }
  2854 + }
  2855 + if(list.size()>0){
  2856 + Map<String, Object> newMap=staticTj(list,"f");
  2857 + lMap.add(newMap);
  2858 + }
  2859 + if(type.equals("export")){
  2860 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  2861 + Map<String, Object> m = new HashMap<String, Object>();
  2862 + m.put("date", date);
  2863 + m.put("date1", date2);
  2864 + String by=map.get("by").toString();
  2865 + String xls="";
  2866 + if(by.equals("sj")){
  2867 + xls="countByLine.xls";
  2868 + }else{
  2869 + xls="countByLines.xls";
  2870 + }
  2871 + ReportUtils ee = new ReportUtils();
  2872 + try {
  2873 + listI.add(lMap.iterator());
  2874 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  2875 + ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls,
  2876 + path + "export/线路公里统计表.xls");
  2877 + } catch (Exception e) {
  2878 + // TODO: handle exception
  2879 + e.printStackTrace();
  2880 + }
  2881 + }
  2882 + return lMap;
  2883 + }
  2884 +
  2885 + public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,String status){
  2886 +
  2887 + List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>();
  2888 + for(int i=0;i<list.size();i++){
  2889 + ScheduleRealInfo s=list.get(i);
  2890 + Set<ChildTaskPlan> cts = s.getcTasks();
  2891 + if(cts != null && cts.size() > 0){
  2892 + lists.add(s);
  2893 + }else{
  2894 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  2895 + lists.add(s);
  2896 + }
  2897 + }
  2898 + }
  2899 + Map<String, Object> map = new HashMap<String, Object>();
  2900 + if(list.size()>0){
  2901 + if(status.equals("f")){
  2902 + map.put("xlName","合计");
  2903 + map.put("gs", "");
  2904 + map.put("fgs", "");
  2905 + }else{
  2906 + map.put("xlName", list.get(0).getXlName());
  2907 + map.put("xlBm", list.get(0).getXlBm());
  2908 + map.put("gsBm", list.get(0).getGsBm());
  2909 + map.put("fgsBm", list.get(0).getFgsBm());
  2910 + map.put("gs", list.get(0).getGsName());
  2911 + map.put("fgs", list.get(0).getFgsName());
  2912 + map.put("jGh", list.get(0).getjGh());
  2913 + map.put("sGh", list.get(0).getsGh()==null?"":list.get(0).getsGh());
  2914 + map.put("nbbm",list.get(0).getClZbh());
  2915 + map.put("line", list.get(0).getXlBm());
  2916 + }
  2917 +
  2918 + double jhyygl=culateService.culateJhgl(list);//计划营运公里
  2919 + double jhjcclc= culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)
  2920 + map.put("jhlc", jhyygl);
  2921 + map.put("jcclc", jhjcclc);
  2922 + map.put("jhzlc", Arith.add(jhyygl, jhjcclc));//计划总里程
  2923 +
  2924 + //计划内外营运
  2925 + Map<String, Double> culateSjlcMap=culateService.culateSjlcMap(lists);
  2926 + double jhnlc=culateSjlcMap.get("jhnlc");
  2927 + double jhwlc=culateSjlcMap.get("jhwlc");
  2928 + map.put("jhnlc", jhnlc);
  2929 + map.put("jhwlc", jhwlc);
  2930 + double zyylc=Arith.add(jhnlc, jhwlc);
  2931 +
  2932 + //计划内外进出场
  2933 + Map<String, Double> culateSjJcclcMap=culateService.culateSjJcclcMap(lists);
  2934 + double jhwjcclc=culateSjJcclcMap.get("jhwlc");
  2935 + double jhnjcclc=culateSjJcclcMap.get("jhnlc");
  2936 + map.put("jhwjcclc", jhwjcclc);
  2937 + map.put("jhnjcclc", jhnjcclc);
  2938 + double zjcclc=Arith.add(jhwjcclc, jhnjcclc);
  2939 +
  2940 + //临加公里
  2941 + Map<String, Double> culateLjMile=culateService.culateLjMile(lists);
  2942 + double ljyy=culateLjMile.get("ljyy");
  2943 + double ljjcc=culateLjMile.get("ljjcc");
  2944 + double ljkfks=culateLjMile.get("ljkfks");
  2945 + map.put("ljyy", ljyy);
  2946 + map.put("ljjcc", ljjcc);
  2947 + map.put("ljkfks", ljkfks);
  2948 +
  2949 + double ljlc=Arith.add(Arith.add(ljyy, ljjcc),ljkfks);
  2950 +
  2951 + double lbss=culateService.culateSsMile(list);//烂班少驶
  2952 + map.put("lbss", lbss);
  2953 + map.put("ssgl_lz", culateService.culateSsMileXx(list, "路阻"));
  2954 + map.put("ssgl_dm", culateService.culateSsMileXx(list, "吊慢"));
  2955 + map.put("ssgl_gz", culateService.culateSsMileXx(list, "故障"));
  2956 + map.put("ssgl_jf", culateService.culateSsMileXx(list, "纠纷"));
  2957 + map.put("ssgl_zs", culateService.culateSsMileXx(list, "肇事"));
  2958 + map.put("ssgl_qr", culateService.culateSsMileXx(list, "缺人"));
  2959 + map.put("ssgl_qc", culateService.culateSsMileXx(list, "缺车"));
  2960 + map.put("ssgl_kx", culateService.culateSsMileXx(list, "客稀"));
  2961 + map.put("ssgl_qh", culateService.culateSsMileXx(list, "气候"));
  2962 + map.put("ssgl_yw", culateService.culateSsMileXx(list, "援外"));
  2963 + map.put("ssgl_ljpm", culateService.culateSsMileXx(list, "路救抛锚"));
  2964 + map.put("ssgl_other", culateService.culateSsMileXx(list, "其他"));
  2965 +
  2966 +
  2967 + double zrwjcclc=culateService.culateZrwJccLc(list, "故障");
  2968 + double zrwjcclc1=culateService.culateZrwJccLc(list, "肇事");
  2969 + double zrwjcclc2=culateService.culateZrwJccLc(list, "纠纷");
  2970 + double zrwjcclcqt=Arith.add(culateService.culateZrwJccLc(list, "其他"),culateService.culateZrwJccLc(list, ""));
  2971 + map.put("jhwjcclc_z", Arith.add(jhwjcclc,zrwjcclcqt));
  2972 + map.put("zrwjcclc", zrwjcclc);
  2973 + map.put("zrwjcclc1", zrwjcclc1);
  2974 + map.put("zrwjcclc2", zrwjcclc2);
  2975 + map.put("zrwjcclcqt", zrwjcclcqt);
  2976 + double zrwjcc=Arith.add(Arith.add(Arith.add(zrwjcclc, zrwjcclc1), zrwjcclc2),zrwjcclcqt);
  2977 + double kfks=culateService.culateKfksLc(lists);
  2978 + map.put("kfks", kfks);
  2979 + double zlc=Arith.add(Arith.add(Arith.add(zrwjcc, ljlc),
  2980 + Arith.add(zjcclc, zyylc)),kfks);
  2981 + map.put("zlc", zlc);
  2982 +
  2983 + //备用
  2984 + double ljgl= culateService.culateLjgl(lists);
  2985 + double sjyygl= culateService.culateSjgl(lists);
  2986 + double zyygl= Arith.add(sjyygl,ljgl);
  2987 +
  2988 + double sjjccgl=culateService.culateJccgl(lists);
  2989 + double sjksgl=culateService.culateKsgl(lists);
  2990 + double zksgl=Arith.add(sjjccgl, sjksgl);
  2991 + map.put("sjzgl", Arith.add(zyygl, zksgl));
  2992 + }
  2993 + return map;
  2994 + }
  2995 + @Override
  2996 + public List<Map<String, Object>> countByBusList(Map<String, Object> map) {
  2997 + // TODO Auto-generated method stub
  2998 + SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
  2999 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  3000 + List<Map<String, Object>> lMaps = new ArrayList<Map<String, Object>>();
  3001 + String gsdm="";
  3002 + if(map.get("gsdm")!=null){
  3003 + gsdm=map.get("gsdm").toString();
  3004 + }
  3005 + String fgsdm="";
  3006 + if(map.get("fgsdm")!=null){
  3007 + fgsdm=map.get("fgsdm").toString();
  3008 + }
  3009 + String line="";
  3010 + if(map.get("line")!=null){
  3011 + line=map.get("line").toString();
  3012 + }
  3013 + String date="";
  3014 + if(map.get("date")!=null){
  3015 + date=map.get("date").toString();
  3016 + }
  3017 + String date2="";
  3018 + if(map.get("date2")!=null){
  3019 + date2=map.get("date2").toString();
  3020 + }
  3021 + String xlName="";
  3022 + if(map.get("xlName")!=null){
  3023 + xlName=map.get("xlName").toString();
  3024 + }
  3025 + String zt="";
  3026 + if(map.get("zt")!=null){
  3027 + zt=map.get("zt").toString();
  3028 + }
  3029 + String type="";
  3030 + if(map.get("type")!=null){
  3031 + type=map.get("type").toString();
  3032 + }
  3033 + //所有班次信息
  3034 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  3035 + line =line.trim();
  3036 + if(line.equals("")){
  3037 + //查询所有线路
  3038 + list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date,date2,gsdm,fgsdm);
  3039 + }else{
  3040 + //查询单条线路
  3041 + list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date,date2);
  3042 + }
  3043 +
  3044 + List<String> objList = new ArrayList<String>();
  3045 + objList.add(date);
  3046 + objList.add(date2);
  3047 + String ylbSql=" select * from bsth_c_ylb where rq BETWEEN ? and ?";
  3048 + if(line.equals("")){
  3049 + ylbSql +=" and ssgsdm = ?"
  3050 + + " and fgsdm = ?";
  3051 + objList.add(gsdm);
  3052 + objList.add(fgsdm);
  3053 + }else{
  3054 + ylbSql += " and xlbm = ?";
  3055 + objList.add(line);
  3056 + }
  3057 + List<Ylb> ylbList = ylbList(ylbSql, objList);
  3058 +
  3059 + List<String> objList2 = new ArrayList<String>();
  3060 + objList2.add(date);
  3061 + objList2.add(date2);
  3062 + String dlbSql=" select * from bsth_c_dlb where rq BETWEEN ? and ?";
  3063 + if(line.equals("")){
  3064 + dlbSql +=" and ssgsdm = ?"
  3065 + + " and fgsdm = ?";
  3066 + objList2.add(gsdm);
  3067 + objList2.add(fgsdm);
  3068 + }else{
  3069 + dlbSql += " and xlbm = ?";
  3070 + objList2.add(line);
  3071 + }
  3072 + List<Dlb> dlbList=dlbList(dlbSql, objList2);
  3073 + List<Map<String, Object>> listGroupBy =null;
  3074 + String sql="";
  3075 + if(zt.equals("zbh")){
  3076 + List<String> objList3 = new ArrayList<String>();
  3077 + objList3.add(date);
  3078 + objList3.add(date2);
  3079 + sql+="select r.xl_bm,r.cl_zbh"
  3080 + + " from bsth_c_s_sp_info_real r where"
  3081 + + " r.schedule_date_str BETWEEN ? and ?";
  3082 + if(line.equals("")){
  3083 + sql +=" and r.gs_bm = ?"
  3084 + + " and r.fgs_bm = ?";
  3085 + objList3.add(gsdm);
  3086 + objList3.add(fgsdm);
  3087 + }else{
  3088 + sql += " and r.xl_bm = ?";
  3089 + objList3.add(line);
  3090 + }
  3091 + sql += " group by r.xl_bm,r.cl_zbh";
  3092 + listGroupBy=jdbcTemplate.query(sql, objList3.toArray(), new RowMapper<Map<String, Object>>() {
  3093 + @Override
  3094 + public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {
  3095 + Map<String, Object> map=new HashMap<String,Object>();
  3096 + map.put("line",arg0.getString("xl_bm"));
  3097 + map.put("nbbm", arg0.getString("cl_zbh"));
  3098 + return map;
  3099 + }
  3100 + });
  3101 + }else{
  3102 + List<String> objList4 = new ArrayList<String>();
  3103 + objList4.add(date);
  3104 + objList4.add(date2);
  3105 + sql+="select r.xl_bm,r.cl_zbh,r.j_gh,r.s_gh"
  3106 + + " from bsth_c_s_sp_info_real r where"
  3107 + + " r.schedule_date_str BETWEEN ? and ?";
  3108 + if(line.equals("")){
  3109 + sql +=" and r.gs_bm = ? "
  3110 + + " and r.fgs_bm = ?";
  3111 + objList4.add(gsdm);
  3112 + objList4.add(fgsdm);
  3113 + }else{
  3114 + sql += " and r.xl_bm = ?";
  3115 + objList4.add(line);
  3116 + }
  3117 + sql += " group by r.xl_bm,r.cl_zbh,r.j_gh,r.s_gh";
  3118 + listGroupBy=jdbcTemplate.query(sql, objList4.toArray(), new RowMapper<Map<String, Object>>() {
  3119 + @Override
  3120 + public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {
  3121 + Map<String, Object> map=new HashMap<String,Object>();
  3122 + map.put("line",arg0.getString("xl_bm"));
  3123 + map.put("nbbm", arg0.getString("cl_zbh"));
  3124 + map.put("jGh", arg0.getString("j_gh"));
  3125 + map.put("sGh", arg0.getString("s_gh"));
  3126 +// map.put("jName", arg0.getString("j_name"));
  3127 +// map.put("sName", arg0.getString("s_name"));
  3128 + return map;
  3129 + }
  3130 + });
  3131 + }
  3132 +
  3133 +
  3134 + for (int i = 0; i < listGroupBy.size(); i++) {
  3135 + Map<String, Object> m=listGroupBy.get(i);
  3136 + String xl_bm=m.get("line")==null?"":m.get("line").toString();
  3137 + String nbbm =m.get("nbbm")==null?"":m.get("nbbm").toString();
  3138 + String jGh= m.get("jGh")==null?"":m.get("jGh").toString();
  3139 + String sGh= m.get("sGh")==null?"":m.get("sGh").toString();
  3140 + List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>();
  3141 + for (int j = 0; j < list.size(); j++) {
  3142 + ScheduleRealInfo s=list.get(j);
  3143 + if(zt.equals("zbh")){
  3144 + if(xl_bm.equals(s.getXlBm())
  3145 + && nbbm.equals(s.getClZbh())){
  3146 + lists.add(s);
  3147 + }
  3148 + }else{
  3149 + if(xl_bm.equals(s.getXlBm()) && nbbm.equals(s.getClZbh())
  3150 + && jGh.equals(s.getjGh()) && sGh.equals(s.getsGh())){
  3151 + lists.add(s);
  3152 +
  3153 + if((m.get("jName") == null || m.get("jName").toString().length() == 0)
  3154 + && s.getjName() != null && s.getjName().length() > 0){
  3155 + m.put("jName", s.getjName());
  3156 + }
  3157 + if((m.get("sName") == null || m.get("sName").toString().length() == 0)
  3158 + && s.getsName() != null && s.getsName().length() > 0){
  3159 + m.put("sName", s.getsName());
  3160 + }
  3161 + }
  3162 + }
  3163 + }
  3164 +
  3165 + if(zt.equals("zbh")){
  3166 + Map<String, Object> newMap=staticTj(lists, "");
  3167 + double yhl=0.0;
  3168 + double jzl=0.0;
  3169 + double hyl=0.0;
  3170 + double dhl=0.0;
  3171 + double cdl=0.0;
  3172 + for (int j = 0; j < ylbList.size(); j++) {
  3173 + Ylb y=ylbList.get(j);
  3174 + if(nbbm.equals(y.getNbbm()) && xl_bm.equals(y.getXlbm())){
  3175 + yhl=Arith.add(yhl, y.getYh());
  3176 + jzl=Arith.add(jzl, y.getJzl());
  3177 + hyl=Arith.add(hyl, y.getSh());
  3178 + }
  3179 +
  3180 + }
  3181 + for (int j = 0; j < dlbList.size(); j++) {
  3182 + Dlb d=dlbList.get(j);
  3183 + if(nbbm.equals(d.getNbbm())&&xl_bm.equals(d.getXlbm())){
  3184 + dhl=Arith.add(dhl, d.getHd());
  3185 + cdl=Arith.add(cdl, d.getCdl());
  3186 + }
  3187 + }
  3188 + if(date.equals(date2)){
  3189 + newMap.put("rq",date);
  3190 + }else{
  3191 + newMap.put("rq",date+"至"+date2);
  3192 + }
  3193 + newMap.put("yhl", yhl);
  3194 + newMap.put("jzl", jzl);
  3195 + newMap.put("hyl", hyl);
  3196 + newMap.put("dhl", dhl);
  3197 + newMap.put("cdl", cdl);
  3198 + lMap.add(newMap);
  3199 + }else{
  3200 + Map<String, Object> newMap=staticTj(lists, "");
  3201 + double lc=Double.parseDouble(newMap.get("zlc").toString());
  3202 + double yhl=0.0;
  3203 + double jzl=0.0;
  3204 + double hyl=0.0;
  3205 + double dhl=0.0;
  3206 + double cdl=0.0;
  3207 + double zlc=0.0;
  3208 + for (int j = 0; j < ylbList.size(); j++) {
  3209 + Ylb y=ylbList.get(j);
  3210 + if(nbbm.equals(y.getNbbm()) && xl_bm.equals(y.getXlbm())
  3211 + &&jGh.equals(y.getJsy())){
  3212 + yhl=Arith.add(yhl, y.getYh());
  3213 + jzl=Arith.add(jzl, y.getJzl());
  3214 + hyl=Arith.add(hyl, y.getSh());
  3215 + zlc=Arith.add(zlc, y.getZlc());
  3216 + }
  3217 +
  3218 + }
  3219 +
  3220 + for (int j = 0; j < dlbList.size(); j++) {
  3221 + Dlb d=dlbList.get(j);
  3222 + if(nbbm.equals(d.getNbbm())&&xl_bm.equals(d.getXlbm())
  3223 + &&jGh.equals(d.getJsy())){
  3224 + dhl=Arith.add(dhl, d.getHd());
  3225 + cdl=Arith.add(cdl, d.getCdl());
  3226 + zlc=Arith.add(zlc, d.getZlc());
  3227 + }
  3228 + }
  3229 + double div=0.0;
  3230 + if(lc>0){
  3231 + div=Arith.div(zlc, lc,2);
  3232 + }
  3233 + newMap.put("yhl", yhl*div);
  3234 + newMap.put("jzl", jzl*div);
  3235 + newMap.put("hyl", hyl*div);
  3236 + newMap.put("dhl", dhl*div);
  3237 + newMap.put("cdl", cdl*div);
  3238 + lMaps.add(newMap);
  3239 + }
  3240 +
  3241 + }
  3242 + if(!zt.equals("zbh")){
  3243 + lMap=lists(listGroupBy, lMaps, gsdm, fgsdm, date, date2);
  3244 + }
  3245 + if(type.equals("export")){
  3246 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  3247 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  3248 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  3249 + Map<String, Object> m = new HashMap<String, Object>();
  3250 + m.put("date", date);
  3251 + m.put("date1", date2);
  3252 + String xls="";
  3253 + String by=map.get("by").toString();
  3254 +
  3255 +
  3256 + if(zt.equals("zbh")){
  3257 + if(by.equals("sj")){
  3258 + xls="countByBus1.xls";
  3259 + }else{
  3260 + xls="countByBus1s.xls";
  3261 + }
  3262 + }else{
  3263 +
  3264 + if(by.equals("sj")){
  3265 + xls="countByBus2.xls";
  3266 + }else{
  3267 + xls="countByBus2s.xls";
  3268 + }
  3269 + }
  3270 + ReportUtils ee = new ReportUtils();
  3271 + try {
  3272 + String dateTime = "";
  3273 + if(date.equals(date2)){
  3274 + dateTime = sdfSimple.format(sdfMonth.parse(date));
  3275 + } else {
  3276 + dateTime = sdfSimple.format(sdfMonth.parse(date))
  3277 + +"-"+sdfSimple.format(sdfMonth.parse(date2));
  3278 + }
  3279 + listI.add(lMap.iterator());
  3280 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  3281 + ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls,
  3282 + path + "export/"+dateTime+"-"+xlName+"-路单数据统计表.xls");
  3283 + } catch (Exception e) {
  3284 + // TODO: handle exception
  3285 + e.printStackTrace();
  3286 + }
  3287 + }
  3288 +
  3289 + return lMap;
  3290 + }
  3291 +
  3292 + public final List<Ylb> ylbList(String sql, List<String> objList){
  3293 + List<Ylb> ylbList= jdbcTemplate.query(sql, objList.toArray(), new RowMapper<Ylb>() {
  3294 + @Override
  3295 + public Ylb mapRow(ResultSet arg0, int arg1) throws SQLException {
  3296 + Ylb y = new Ylb();
  3297 + y.setRq(arg0.getDate("rq"));
  3298 + y.setJsy(arg0.getString("jsy"));
  3299 + y.setXlbm(arg0.getString("xlbm"));
  3300 + y.setZlc(arg0.getDouble("zlc"));
  3301 + y.setNbbm(arg0.getString("nbbm"));
  3302 + y.setJzl(arg0.getDouble("jzl"));
  3303 + y.setYh(arg0.getDouble("yh"));
  3304 + y.setSh(arg0.getDouble("sh"));
  3305 + return y;
  3306 + }
  3307 + });
  3308 + return ylbList;
  3309 + }
  3310 +
  3311 + public final List<Dlb> dlbList(String sql, List<String> objList){
  3312 + List<Dlb> dlbList= jdbcTemplate.query(sql, objList.toArray(), new RowMapper<Dlb>() {
  3313 + @Override
  3314 + public Dlb mapRow(ResultSet arg0, int arg1) throws SQLException {
  3315 + Dlb y = new Dlb();
  3316 + y.setRq(arg0.getDate("rq"));
  3317 + y.setXlbm(arg0.getString("xlbm"));
  3318 + y.setJsy(arg0.getString("jsy"));
  3319 + y.setNbbm(arg0.getString("nbbm"));
  3320 + y.setZlc(arg0.getDouble("zlc"));
  3321 + y.setCdl(arg0.getDouble("cdl"));
  3322 + y.setHd(arg0.getDouble("hd"));
  3323 + y.setSh(arg0.getDouble("sh"));
  3324 + return y;
  3325 + }
  3326 + });
  3327 + return dlbList;
  3328 + }
  3329 +
  3330 + public final List<Map<String, Object>> lists(List<Map<String, Object>> listGb,
  3331 + List<Map<String, Object>> listLc,
  3332 + String gsdm,String fgsdm,
  3333 + String date,String date2){
  3334 + List<Map<String, Object>> lMap=new ArrayList<Map<String,Object>>();
  3335 + for (int i = 0; i < listGb.size(); i++) {
  3336 + Map<String, Object> m=listGb.get(i);
  3337 + String xl_bm=m.get("line")==null?"":m.get("line").toString();
  3338 + String nbbm =m.get("nbbm")==null?"":m.get("nbbm").toString();
  3339 + String jGh= m.get("jGh")==null?"":m.get("jGh").toString();
  3340 + String jName=m.get("jName")==null?"":m.get("jName").toString();
  3341 + String sGh= m.get("sGh")==null?"":m.get("sGh").toString();
  3342 + String sName=m.get("sName")==null?"":m.get("sName").toString();
  3343 + double jhzlc = 0.0,jhlc= 0.0,jcclc= 0.0,zlc= 0.0,jhnlc= 0.0,jhwlc= 0.0,
  3344 + jhnjcclc= 0.0,jhwjcclc= 0.0,jhwjcclc_z=0.0,zrwjcclc= 0.0,zrwjcclc1= 0.0,zrwjcclc2= 0.0,
  3345 + zrwjcclcqt=0.0,lbss= 0.0,ssgl_lz= 0.0,
  3346 + ssgl_dm= 0.0,ssgl_gz= 0.0,ssgl_jf= 0.0,ssgl_zs= 0.0,ssgl_qr= 0.0,ssgl_qc= 0.0,
  3347 + ssgl_kx= 0.0,ssgl_qh= 0.0,ssgl_yw= 0.0,ssgl_other= 0.0,ljyy=0.0,ljjcc=0.0,
  3348 + kfks=0.0,yhl=0.0,jzl=0.0,hyl=0.0,dhl=0.0,cdl=0.0;
  3349 +
  3350 + for (int j = 0; j < listLc.size(); j++) {
  3351 + Map<String, Object> map=listLc.get(j);
  3352 + if(xl_bm.equals(map.get("line").toString())
  3353 + && nbbm.equals(map.get("nbbm").toString())
  3354 + && sGh.equals(map.get("sGh")==null?"":map.get("sGh").toString())
  3355 + && jGh.equals(map.get("jGh").toString())){
  3356 + jhzlc=Arith.add(jhzlc, map.get("jhzlc"));
  3357 + jhlc =Arith.add(jhlc, map.get("jhlc"));
  3358 + jcclc=Arith.add(jcclc, map.get("jcclc"));
  3359 + zlc=Arith.add(zlc, map.get("zlc"));
  3360 + jhnlc=Arith.add(jhnlc, map.get("jhnlc"));
  3361 + jhwlc=Arith.add(jhwlc, map.get("jhwlc"));
  3362 + jhnjcclc=Arith.add(jhnjcclc, map.get("jhnjcclc"));
  3363 + jhwjcclc=Arith.add(jhwjcclc, map.get("jhwjcclc"));
  3364 + jhwjcclc_z=Arith.add(jhwjcclc_z, map.get("jhwjcclc_z"));
  3365 + zrwjcclc=Arith.add(zrwjcclc, map.get("zrwjcclc"));
  3366 + zrwjcclc1=Arith.add(zrwjcclc1, map.get("zrwjcclc1"));
  3367 + zrwjcclc2=Arith.add(zrwjcclc2, map.get("zrwjcclc2"));
  3368 + zrwjcclcqt=Arith.add(zrwjcclcqt, map.get("zrwjcclcqt"));
  3369 + lbss=Arith.add(lbss, map.get("lbss"));
  3370 + ssgl_lz=Arith.add(ssgl_lz, map.get("ssgl_lz"));
  3371 + ssgl_dm=Arith.add(ssgl_dm, map.get("ssgl_dm"));
  3372 + ssgl_gz=Arith.add(ssgl_gz, map.get("ssgl_gz"));
  3373 + ssgl_jf=Arith.add(ssgl_jf, map.get("ssgl_jf"));
  3374 + ssgl_zs=Arith.add(ssgl_zs, map.get("ssgl_zs"));
  3375 + ssgl_qr=Arith.add(ssgl_qr, map.get("ssgl_qr"));
  3376 + ssgl_qc=Arith.add(ssgl_qc, map.get("ssgl_qc"));
  3377 + ssgl_kx=Arith.add(ssgl_kx, map.get("ssgl_kx"));
  3378 + ssgl_qh=Arith.add(ssgl_qh, map.get("ssgl_qh"));
  3379 + ssgl_yw=Arith.add(ssgl_yw, map.get("ssgl_yw"));
  3380 + ssgl_other=Arith.add(ssgl_other, map.get("ssgl_other"));
  3381 + kfks=Arith.add(kfks, map.get("kfks"));
  3382 + ljyy=Arith.add(ljyy, map.get("ljyy"));
  3383 + ljjcc=Arith.add(ljjcc, map.get("ljjcc"));
  3384 + yhl=Arith.add(yhl, map.get("yhl"));
  3385 + jzl=Arith.add(jzl, map.get("jzl"));
  3386 + hyl=Arith.add(hyl, map.get("hyl"));
  3387 + dhl=Arith.add(dhl, map.get("dhl"));
  3388 + cdl=Arith.add(cdl, map.get("cdl"));
  3389 +
  3390 +
  3391 + }
  3392 + }
  3393 +
  3394 + Map<String, Object> newMap=new HashMap<String,Object>();
  3395 + if(date.equals(date2)){
  3396 + newMap.put("rq", date);
  3397 + }else{
  3398 + newMap.put("rq", date+"至"+date2);
  3399 + }
  3400 + newMap.put("fgs", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  3401 + newMap.put("xlName", BasicData.lineCode2NameMap.get(xl_bm));
  3402 + newMap.put("xlBm", xl_bm);
  3403 + newMap.put("jGh", jGh);
  3404 + newMap.put("jName", jName);
  3405 + newMap.put("sGh",sGh);
  3406 + newMap.put("sName", sName);
  3407 + newMap.put("nbbm", nbbm);
  3408 + newMap.put("jhzlc", jhzlc);
  3409 + newMap.put("jhlc", jhlc);
  3410 + newMap.put("jcclc", jcclc);
  3411 + newMap.put("zlc", zlc);
  3412 + newMap.put("jhnlc", jhnlc);
  3413 + newMap.put("jhwlc", jhwlc);
  3414 + newMap.put("jhnjcclc", jhnjcclc);
  3415 + newMap.put("jhwjcclc", jhwjcclc);
  3416 + newMap.put("jhwjcclc_z", jhwjcclc_z);
  3417 + newMap.put("zrwjcclc", zrwjcclc);
  3418 + newMap.put("zrwjcclc1", zrwjcclc1);
  3419 + newMap.put("zrwjcclc2", zrwjcclc2);
  3420 + newMap.put("zrwjcclcqt", zrwjcclcqt);
  3421 + newMap.put("lbss", lbss);
  3422 + newMap.put("ssgl_lz", ssgl_lz);
  3423 + newMap.put("ssgl_dm",ssgl_dm);
  3424 + newMap.put("ssgl_gz", ssgl_gz);
  3425 + newMap.put("ssgl_jf", ssgl_jf);
  3426 + newMap.put("ssgl_zs", ssgl_zs);
  3427 + newMap.put("ssgl_qr", ssgl_qr);
  3428 + newMap.put("ssgl_qc", ssgl_qc);
  3429 + newMap.put("ssgl_kx", ssgl_kx);
  3430 + newMap.put("ssgl_qh", ssgl_qh);
  3431 + newMap.put("ssgl_yw", ssgl_yw);
  3432 + newMap.put("ssgl_other", ssgl_other);
  3433 + newMap.put("kfks", kfks);
  3434 + newMap.put("ljyy", ljyy);
  3435 + newMap.put("ljjcc", ljjcc);
  3436 + newMap.put("yhl", yhl);
  3437 + newMap.put("jzl", jzl);
  3438 + newMap.put("hyl", hyl);
  3439 + newMap.put("dhl", dhl);
  3440 + newMap.put("cdl", cdl);
  3441 + lMap.add(newMap);
  3442 + }
  3443 + return lMap;
  3444 + }
  3445 + @Override
  3446 + public List<Map<String, Object>> countDjg(Map<String, Object> map) {
  3447 + // TODO Auto-generated method stub
  3448 + List<Map<String, Object>> lMap=new ArrayList<Map<String,Object>>();
  3449 + String line=map.get("line").toString().trim();
  3450 + String date=map.get("date").toString();
  3451 + String gsbm=map.get("gsbm").toString();
  3452 + String fgsbm=map.get("fgsbm").toString();
  3453 + String type=map.get("type").toString();
  3454 + List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();
  3455 + if(line.equals("")){
  3456 + list=scheduleRealInfoRepository.scheduleByDateAndLineByGs(gsbm, fgsbm, date);
  3457 +
  3458 + }else{
  3459 + list=scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);
  3460 + }
  3461 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
  3462 +// Collections.sort(listInfo,new ComparableAcuals());
  3463 +
  3464 + List<String> objList = new ArrayList<String>();
  3465 + //查询所有线路
  3466 + String xlSql="select line_code,spac_grade from bsth_c_line ";
  3467 + if(line.equals("")){
  3468 + xlSql +=" where company = ?";
  3469 + objList.add(gsbm);
  3470 + }else{
  3471 + xlSql +=" where line_code = ?";
  3472 + objList.add(line);
  3473 + }
  3474 +
  3475 + List<Map<String, Object>> xlList=jdbcTemplate.query(xlSql, objList.toArray(), new RowMapper<Map<String, Object>>() {
  3476 + @Override
  3477 + public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {
  3478 + Map<String, Object> map=new HashMap<String,Object>();
  3479 + map.put("line",arg0.getString("line_code"));
  3480 + map.put("grade", arg0.getString("spac_grade"));
  3481 + return map;
  3482 + }
  3483 + });
  3484 + //查询大间隔时间
  3485 + String djgSql="select * from bsth_c_interval";
  3486 + List<Interval> djgList=jdbcTemplate.query(djgSql, new RowMapper<Interval>() {
  3487 + @Override
  3488 + public Interval mapRow(ResultSet arg0, int arg1) throws SQLException {
  3489 + Interval m=new Interval();
  3490 + m.setLevel(arg0.getString("level"));
  3491 + m.setPeak(arg0.getInt("peak"));
  3492 + m.setTrough(arg0.getInt("trough"));
  3493 + return m;
  3494 + }
  3495 + });
  3496 +
  3497 + for (int i = 0; i < xlList.size(); i++) {
  3498 + String lineCode=xlList.get(i).get("line").toString();
  3499 + String grade =xlList.get(i).get("grade")==null?"1":xlList.get(i).get("grade").toString();
  3500 + int peak=0;
  3501 + int trough=0;
  3502 + for (int j = 0; j < djgList.size(); j++) {
  3503 + Interval il=djgList.get(j);
  3504 + if(il.getLevel().equals(grade)){
  3505 + peak=il.getPeak();
  3506 + trough=il.getTrough();
  3507 + continue;
  3508 + }
  3509 + }
  3510 + List<ScheduleRealInfo> list_=new ArrayList<ScheduleRealInfo>();
  3511 + List<ScheduleRealInfo> listInfo=new ArrayList<ScheduleRealInfo>();
  3512 + for (int j = 0; j < list.size(); j++) {
  3513 + ScheduleRealInfo sinfo=list.get(j);
  3514 + try {
  3515 + if(sinfo.getXlBm().equals(lineCode)){
  3516 + boolean type_=false;
  3517 + Set<ChildTaskPlan> cts = sinfo.getcTasks();
  3518 + if(cts != null && cts.size() > 0){
  3519 + type_=true;
  3520 + }else{
  3521 + if(sinfo.getZdsjActual()!=null && sinfo.getFcsjActual()!=null){
  3522 + type_=true;
  3523 + }
  3524 + }
  3525 + if(type_){
  3526 + list_.add(sinfo);
  3527 + ScheduleRealInfo s=checkBc(sinfo);
  3528 + String fcsj=s.getFcsjActual()==null?"":s.getFcsjActual();
  3529 + if(!fcsj.equals("")){
  3530 + Long fcsjAcual = sdf.parse(s.getRealExecDate() + " " + s.getFcsjActual()).getTime();
  3531 + s.setFcsjActualTime(fcsjAcual);
  3532 + s.setFcsjActual(fcsj);
  3533 + listInfo.add(s);
  3534 + }
  3535 + }
  3536 +
  3537 + }
  3538 + } catch (ParseException e) {
  3539 + // TODO Auto-generated catch block
  3540 + e.printStackTrace();
  3541 + }
  3542 + }
  3543 +
  3544 + if(listInfo.size()>0){
  3545 + int sjbcs=culateService.culateSjbc(list_, "")+culateService.culateLjbc(list_, "");
  3546 + Map<String, Object> m=listDjg(gsbm,fgsbm,lineCode,sjbcs,peak,trough,listInfo,grade);
  3547 + lMap.add(m);
  3548 + }
  3549 +
  3550 + }
  3551 + if(type.equals("export")){
  3552 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  3553 + Map<String, Object> m = new HashMap<String, Object>();
  3554 + m.put("date", date);
  3555 + ReportUtils ee = new ReportUtils();
  3556 + try {
  3557 + listI.add(lMap.iterator());
  3558 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  3559 + ee.excelReplace(listI, new Object[]{m}, path + "mould/countInterval.xls",
  3560 + path + "export/大间隔统计表.xls");
  3561 + } catch (Exception e) {
  3562 + // TODO: handle exception
  3563 + e.printStackTrace();
  3564 + }
  3565 + }
  3566 + return lMap;
  3567 + }
  3568 +
  3569 + public ScheduleRealInfo checkBc(ScheduleRealInfo s){
  3570 + //如果班次有子任务 且 子任务中有属于营运的。把该子任务的发车时间设置成班次的发车时间
  3571 + String fcsj=s.getFcsjActual()==null?"":s.getFcsjActual();
  3572 + if(fcsj.equals("")){
  3573 + Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
  3574 + if(!childTaskPlans.isEmpty()){
  3575 + List<ChildTaskPlan> listit=new ArrayList<ChildTaskPlan>(childTaskPlans);
  3576 + Collections.sort(listit, new ComparableChild());
  3577 + for (int i = 0; i < listit.size(); i++) {
  3578 + ChildTaskPlan c=listit.get(i);
  3579 + if(!c.isDestroy()){
  3580 + if(c.getMileageType().equals("service")){
  3581 + s.setFcsjActual(c.getStartDate());
  3582 + break;
  3583 + }
  3584 +
  3585 + }
  3586 + }
  3587 + }
  3588 + }
  3589 + return s;
  3590 + }
  3591 +
  3592 + public Map<String, Object> listDjg(String gsdm,String fgsdm,String line,int sjbcs,int peak,int trough,List<ScheduleRealInfo> listInfo,String grade){
  3593 + DecimalFormat df = new DecimalFormat("#0.00");
  3594 + Collections.sort(listInfo,new ComparableAcuals());
  3595 + List<ScheduleRealInfo> listInfo0=new ArrayList<ScheduleRealInfo>();
  3596 + List<ScheduleRealInfo> listInfo1=new ArrayList<ScheduleRealInfo>();
  3597 + for (int i = 0; i < listInfo.size(); i++) {
  3598 + ScheduleRealInfo s=listInfo.get(i);
  3599 + if(s.getXlDir().equals("0")){
  3600 + listInfo0.add(s);
  3601 + }else{
  3602 + listInfo1.add(s);
  3603 + }
  3604 +
  3605 + }
  3606 + Map<String, Object> map=new HashMap<String, Object>();
  3607 + map.put("line", line);
  3608 + map.put("xlName", BasicData.lineCode2NameMap.get(line));
  3609 + map.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  3610 + map.put("bcs", sjbcs);
  3611 + map.put("djgde", grade);
  3612 + int djgcs=0;
  3613 + List<Map<String, Object>> mapList=new ArrayList<Map<String, Object>>();
  3614 + for (int i = 0; i < listInfo0.size(); i++) {
  3615 + ScheduleRealInfo s=listInfo0.get(i);
  3616 + Long fcsjTime=s.getFcsjActualTime();
  3617 + String time=s.getFcsjActual();
  3618 + String[] fcsjStr = time.split(":");
  3619 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  3620 + if(i<listInfo0.size()-1){
  3621 + Long djg=0l;
  3622 + Long fscjNext=listInfo0.get(i+1).getFcsjActualTime();
  3623 + if((fcsj>=zgf1&&fcsj<=zgf2)||(fcsj>=wgf1&&fcsj<=wgf2)){
  3624 + djg = (long) (peak*60*1000);
  3625 + if(fscjNext-fcsjTime>djg){
  3626 + djgcs ++;
  3627 + Map<String, Object> m=new HashMap<String,Object>();
  3628 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  3629 + m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  3630 + m.put("djgde", grade);
  3631 + m.put("qJh", s.getFcsj());
  3632 + m.put("qSj", time);
  3633 + m.put("hJh", listInfo0.get(i+1).getFcsj());
  3634 + m.put("hSj", listInfo0.get(i+1).getFcsjActual());
  3635 + m.put("djgsj", peak);
  3636 + m.put("bcjgsj", (fscjNext-fcsjTime)/60000);
  3637 + mapList.add(m);
  3638 + }
  3639 + }else{
  3640 + djg = (long) (trough*60*1000);
  3641 + if(fscjNext-fcsjTime>djg){
  3642 + djgcs ++;
  3643 + Map<String, Object> m=new HashMap<String,Object>();
  3644 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  3645 + m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  3646 + m.put("djgde", grade);
  3647 + m.put("qJh", s.getFcsj());
  3648 + m.put("qSj", time);
  3649 + m.put("hJh", listInfo0.get(i+1).getFcsj());
  3650 + m.put("hSj", listInfo0.get(i+1).getFcsjActual());
  3651 + m.put("djgsj", trough);
  3652 + m.put("bcjgsj", (fscjNext-fcsjTime)/60000);
  3653 + mapList.add(m);
  3654 + }
  3655 + }
  3656 + }
  3657 + }
  3658 +
  3659 + for (int i = 0; i < listInfo1.size(); i++) {
  3660 + ScheduleRealInfo s=listInfo1.get(i);
  3661 + Long fcsjTime=s.getFcsjActualTime();
  3662 + String time=s.getFcsjActual();
  3663 + String[] fcsjStr = time.split(":");
  3664 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  3665 + if(i<listInfo1.size()-1){
  3666 + Long djg=0l;
  3667 + Long fscjNext=listInfo1.get(i+1).getFcsjActualTime();
  3668 + if((fcsj>=zgf1&&fcsj<=zgf2)||(fcsj>=wgf1&&fcsj<=wgf2)){
  3669 + djg = (long) (peak*60*1000);
  3670 + if(fscjNext-fcsjTime>djg){
  3671 + djgcs ++;
  3672 + Map<String, Object> m=new HashMap<String,Object>();
  3673 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  3674 + m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  3675 + m.put("djgde", grade);
  3676 + m.put("qJh", s.getFcsj());
  3677 + m.put("qSj", time);
  3678 + m.put("hJh", listInfo1.get(i+1).getFcsj());
  3679 + m.put("hSj", listInfo1.get(i+1).getFcsjActual());
  3680 + m.put("djgsj", peak);
  3681 + m.put("bcjgsj", (fscjNext-fcsjTime)/60000);
  3682 + mapList.add(m);
  3683 + }
  3684 + }else{
  3685 + djg = (long) (trough*60*1000);
  3686 + if(fscjNext-fcsjTime>djg){
  3687 + djgcs ++;
  3688 + Map<String, Object> m=new HashMap<String,Object>();
  3689 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  3690 + m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  3691 + m.put("djgde", grade);
  3692 + m.put("qJh", s.getFcsj());
  3693 + m.put("qSj", time);
  3694 + m.put("hJh", listInfo1.get(i+1).getFcsj());
  3695 + m.put("hSj", listInfo1.get(i+1).getFcsjActual());
  3696 + m.put("djgsj", trough);
  3697 + m.put("bcjgsj", (fscjNext-fcsjTime)/60000);
  3698 + mapList.add(m);
  3699 + }
  3700 + }
  3701 + }
  3702 + }
  3703 + double fsl=0.0;
  3704 + if(sjbcs>0){
  3705 + fsl=Arith.div(djgcs,sjbcs, 2)*100;
  3706 + }
  3707 +
  3708 + map.put("djgcs", djgcs);
  3709 + map.put("fsl", df.format(fsl)+"%");
  3710 + map.put("djgxx", mapList);
  3711 + return map;
  3712 + }
  3713 +
  3714 +
  3715 + @Override
  3716 + public Map<String, Object> online(Map<String, Object> map) {
  3717 + String line =map.get("line").toString();
  3718 + String date =map.get("date").toString();
  3719 + String type =map.get("type").toString();
  3720 + DecimalFormat df = new DecimalFormat("#0.00");
  3721 +
  3722 + List<String> objList = new ArrayList<String>();
  3723 + objList.add(date);
  3724 + objList.add(line);
  3725 + String sql="select cl_zbh from bsth_c_s_sp_info_real where "
  3726 + + " schedule_date_str = ? and xl_bm = ? group by cl_zbh";
  3727 + List<String> list= jdbcTemplate.query(sql, objList.toArray(),
  3728 + new RowMapper<String>(){
  3729 + @Override
  3730 + public String mapRow(ResultSet rs, int rowNum) throws SQLException {
  3731 + String clzbh=rs.getString("cl_zbh");
  3732 + return clzbh;
  3733 + }
  3734 + });
  3735 + List<Line> lineList=lineRepository.findLineByCode(line);
  3736 + int qzpcs =0;
  3737 + for (int i = 0; i < lineList.size(); i++) {
  3738 + Line l=lineList.get(i);
  3739 + qzpcs = l.getWarrantCar()==null?0:l.getWarrantCar();
  3740 + }
  3741 +
  3742 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  3743 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  3744 + int zxcl=0;
  3745 + try {
  3746 + Long date1 = simpleDateFormat.parse(date+" 00:00:01").getTime();
  3747 + Long date2=simpleDateFormat.parse(date+" 23:59:59").getTime();
  3748 + Date dates=simpleDateFormat.parse(date+" 00:00:00");
  3749 + List<ArrivalInfo> lists=load_online(line,date1,date2,dates,date);
  3750 + for (int i = 0; i < list.size(); i++) {
  3751 + String nbbm=list.get(i);
  3752 + String sbbb=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  3753 + for (int j = 0; j < lists.size(); j++) {
  3754 + ArrivalInfo a=lists.get(i);
  3755 + if(a.getDeviceId().equals(sbbb)){
  3756 + zxcl ++;
  3757 + break;
  3758 + }
  3759 + }
  3760 +
  3761 + }
  3762 + } catch (ParseException e) {
  3763 + // TODO Auto-generated catch block
  3764 + e.printStackTrace();
  3765 + }
  3766 + map.put("xlName", BasicData.lineCode2NameMap.get(line));
  3767 + map.put("qzpcs", qzpcs);
  3768 + map.put("ccs", list.size());
  3769 + map.put("zxcl", zxcl);
  3770 + String zxl="0";
  3771 + if(list.size()>0){
  3772 + zxl = df.format(zxcl/list.size());
  3773 + }
  3774 + map.put("zxl", zxl+"%");
  3775 +
  3776 + if(type.equals("export")){
  3777 + List<Map<String, Object>> lMap=new ArrayList<Map<String,Object>>();
  3778 +
  3779 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  3780 + Map<String, Object> m = new HashMap<String, Object>();
  3781 + m.put("date", date);
  3782 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  3783 + m.put("qzpcs", qzpcs);
  3784 + m.put("ccs", list.size());
  3785 + m.put("zxcl", zxcl);
  3786 + m.put("zxl", zxl+"%");
  3787 + lMap.add(m);
  3788 + ReportUtils ee = new ReportUtils();
  3789 + try {
  3790 + listI.add(lMap.iterator());
  3791 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  3792 + ee.excelReplace(listI, new Object[]{m}, path + "mould/onlinelist.xls",
  3793 + path + "export/车辆在线率统计.xls");
  3794 + } catch (Exception e) {
  3795 + // TODO: handle exception
  3796 + e.printStackTrace();
  3797 + }
  3798 + }
  3799 + return map;
  3800 + }
  3801 +
  3802 + public List<ArrivalInfo> load_online(String line,Long date1,Long date2,Date dates,String date){
  3803 + List<ArrivalInfo> list = null;
  3804 + Calendar cal = Calendar.getInstance();
  3805 + cal.setTime(dates);
  3806 + //周数,表分区字段
  3807 + int weeks_year = cal.get(Calendar.WEEK_OF_YEAR);
  3808 +
  3809 + Connection conn = null;
  3810 + PreparedStatement ps = null;
  3811 + ResultSet rs = null;
  3812 + String year=date.substring(0,4);
  3813 + String sql = "select * from bsth_c_arrival_info_"+year+" where weeks_year=? AND line_id=? AND ts > ? AND ts <=? order by ts";
  3814 + try{
  3815 + conn = DBUtils_MS.getConnection();
  3816 + ps = conn.prepareStatement(sql);
  3817 + ps.setInt(1, weeks_year);
  3818 + ps.setString(2,line);
  3819 + ps.setLong(3, date1);
  3820 + ps.setLong(4, date2);
  3821 + rs = ps.executeQuery();
  3822 +
  3823 + list = resultSet2Set(rs);
  3824 + }catch(Exception e){
  3825 + logger.error("", e);
  3826 + }finally {
  3827 + DBUtils_MS.close(rs, ps, conn);
  3828 + }
  3829 + return list;
  3830 + }
  3831 + @Override
  3832 + public List<Singledata> singledatatj(Map<String, Object> map) {
  3833 + String sfyy="";
  3834 + if(map.get("sfyy")!=null){
  3835 + sfyy=map.get("sfyy").toString();
  3836 + }
  3837 + String gsdm="";
  3838 + if(map.get("gsdmSing")!=null){
  3839 + gsdm=map.get("gsdmSing").toString();
  3840 + }
  3841 + String fgsdm="";
  3842 + if(map.get("fgsdmSing")!=null){
  3843 + fgsdm=map.get("fgsdmSing").toString();
  3844 + }
  3845 + String type="";
  3846 + if(map.get("type")!=null){
  3847 + type=map.get("type").toString();
  3848 + }
  3849 + String tjtype=map.get("tjtype").toString();
  3850 + String xlbm=map.get("line").toString().trim();
  3851 + String startDate = map.get("startDate").toString();
  3852 + String endDate = map.get("endDate").toString();
  3853 +
  3854 + List<ScheduleRealInfo> listReal=new ArrayList<ScheduleRealInfo>();
  3855 + if(xlbm.equals("")){
  3856 + listReal=scheduleRealInfoRepository.scheduleByDateAndLineTj(xlbm, startDate, endDate, gsdm, fgsdm);
  3857 + }else{
  3858 + listReal=scheduleRealInfoRepository.scheduleByDateAndLineTj2(xlbm, startDate, endDate);
  3859 + }
  3860 + List<Singledata> list=new ArrayList<Singledata>();
  3861 + List<Singledata> list_=new ArrayList<Singledata>();
  3862 + if(tjtype.equals("jsy")){
  3863 + List<String> objList = new ArrayList<String>();
  3864 + objList.add(startDate);
  3865 + objList.add(endDate);
  3866 + //油统计
  3867 + String sql="select r.j_gh, r.xl_bm,r.cl_zbh,r.fgs_bm"
  3868 + + " from bsth_c_s_sp_info_real r where "
  3869 + + " r.schedule_date_str >= ?"
  3870 + + " and r.schedule_date_str <= ?";
  3871 + if(xlbm.length() != 0){
  3872 + sql += " and r.xl_bm = ?";
  3873 + objList.add(xlbm);
  3874 + }
  3875 + if(gsdm.length() != 0){
  3876 + sql += " and r.gs_bm = ?";
  3877 + objList.add(gsdm);
  3878 + }
  3879 + if(fgsdm.length() != 0){
  3880 + sql += " and r.fgs_bm = ?";
  3881 + objList.add(fgsdm);
  3882 + }
  3883 + sql += " group by r.j_gh,r.xl_bm,r.cl_zbh,r.fgs_bm order by r.xl_bm,r.cl_zbh";
  3884 +
  3885 + list = jdbcTemplate.query(sql, objList.toArray(), new RowMapper<Singledata>() {
  3886 + @Override
  3887 + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {
  3888 + Singledata sin = new Singledata();
  3889 + sin.setxL(arg0.getString("xl_bm"));
  3890 + sin.setJsy(arg0.getString("j_gh"));
  3891 + sin.setClzbh(arg0.getString("cl_zbh"));
  3892 + sin.setgS(arg0.getString("fgs_bm"));
  3893 + return sin;
  3894 + }
  3895 + });
  3896 +
  3897 + List<String> objList2 = new ArrayList<String>();
  3898 + List<String> tempList2 = new ArrayList<String>();
  3899 + tempList2.add(startDate);
  3900 + tempList2.add(endDate);
  3901 + String linesql="";
  3902 + if(!xlbm.equals("")){
  3903 + linesql +=" and xlbm = ?";
  3904 + tempList2.add(xlbm);
  3905 + }
  3906 + if(!gsdm.equals("")){
  3907 + linesql +=" and ssgsdm = ?";
  3908 + tempList2.add(gsdm);
  3909 + }
  3910 + if(!fgsdm.equals("")){
  3911 + linesql +=" and fgsdm = ?";
  3912 + tempList2.add(fgsdm);
  3913 + }
  3914 +
  3915 + for(int i = 0; i < 2; i++){ // sql中使用两次重复参数
  3916 + for(String s : tempList2){
  3917 + objList2.add(s);
  3918 + }
  3919 + }
  3920 +
  3921 + String nysql="SELECT 'yh' as type,xlbm,nbbm,jsy,sum(jzl*1000)/1000 as jzl,"
  3922 + + " sum(yh*1000)/1000 as yh,"
  3923 + + " sum(sh*1000)/1000 as sh FROM "
  3924 + + "bsth_c_ylb where rq >= ? "
  3925 + + " and rq <= ? " +linesql
  3926 + + " group by xlbm ,nbbm,jsy "
  3927 + + " union SELECT 'dh' as type,xlbm,nbbm,jsy, "
  3928 + + " sum(cdl*1000)/1000 as jzl,sum(hd*1000)/1000 as yh,"
  3929 + + " sum(sh * 1000) / 1000 AS sh"
  3930 + + " FROM bsth_c_dlb where rq >= ? "
  3931 + + " and rq <= ? " +linesql
  3932 + + " group by xlbm ,nbbm,jsy" ;
  3933 +
  3934 + List<Singledata> listNy = jdbcTemplate.query(nysql, objList2.toArray(), new RowMapper<Singledata>() {
  3935 + @Override
  3936 + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {
  3937 + Singledata sin = new Singledata();
  3938 + sin.setxL(arg0.getString("xlbm"));
  3939 + sin.setJsy(arg0.getString("jsy"));
  3940 + sin.setClzbh(arg0.getString("nbbm"));
  3941 + sin.setJzl(arg0.getString("jzl"));
  3942 + sin.setHyl(arg0.getString("yh"));
  3943 + sin.setUnyyyl(arg0.getString("sh"));
  3944 + return sin;
  3945 + }
  3946 + });
  3947 + //统计油,电表中手动添加的或者有加注没里程的数据
  3948 + for (int i = 0; i < listNy.size(); i++) {
  3949 + Singledata sin_=listNy.get(i);
  3950 + String jsy=sin_.getJsy();
  3951 + String line=sin_.getxL();
  3952 + String clzbh=sin_.getClzbh();
  3953 + boolean fages=true;
  3954 + for (int j = 0; j < list.size(); j++) {
  3955 + Singledata sin=list.get(j);
  3956 + String jsy_=sin.getJsy();
  3957 + String line_=sin.getxL();
  3958 + String clzbh_=sin.getClzbh();
  3959 + if(jsy.equals(jsy_)
  3960 + &&line.equals(line_)
  3961 + &&clzbh.equals(clzbh_)){
  3962 + fages=false;
  3963 + }
  3964 + }
  3965 + if(fages){
  3966 + Singledata s=new Singledata();
  3967 + s.setJsy(jsy);
  3968 + s.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));
  3969 + s.setClzbh(clzbh);
  3970 + s.setSgh("");
  3971 + s.setsName("");
  3972 + s.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  3973 + s.setxL(line);
  3974 + s.setXlmc(BasicData.lineCodeAllNameMap.get(line));
  3975 + s.setJzl(sin_.getJzl());
  3976 + s.setHyl(sin_.getHyl());
  3977 + s.setUnyyyl(sin_.getUnyyyl());
  3978 + s.setJhlc("0.0");
  3979 + s.setEmptMileage("0.0");
  3980 + s.setJhjl("0.0");
  3981 + if(startDate.equals(endDate))
  3982 + s.setrQ(startDate);
  3983 + else
  3984 + s.setrQ(startDate+"-"+endDate);
  3985 +
  3986 + list_.add(s);
  3987 + }
  3988 + }
  3989 + for (int i= 0; i < list.size(); i++) {
  3990 + Singledata sin=list.get(i);
  3991 + String jsy=sin.getJsy();
  3992 + String line=sin.getxL();
  3993 + String clzbh=sin.getClzbh();
  3994 + double jzl=0.0;
  3995 + double yh=0.0;
  3996 + double sh=0.0;
  3997 + for (int j = 0; j < listNy.size(); j++) {
  3998 + Singledata y=listNy.get(j);
  3999 + if(y.getJsy().equals(jsy)
  4000 + &&y.getClzbh().equals(clzbh)
  4001 + &&y.getxL().equals(line)){
  4002 + jzl=Arith.add(jzl, y.getJzl());
  4003 + yh=Arith.add(yh, y.getHyl());
  4004 + sh=Arith.add(sh, y.getUnyyyl());
  4005 + }
  4006 + }
  4007 + sin.setHyl(String.valueOf(yh));
  4008 + sin.setJzl(String.valueOf(jzl));
  4009 + sin.setUnyyyl(String.valueOf(sh));
  4010 +
  4011 + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  4012 + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();
  4013 + for (int j = 0; j < listReal.size(); j++) {
  4014 + ScheduleRealInfo s=listReal.get(j);
  4015 + if(s.getjGh().equals(jsy)
  4016 + && s.getClZbh().equals(clzbh)
  4017 + &&s.getXlBm().equals(line)){
  4018 + newList.add(s);
  4019 + Set<ChildTaskPlan> cts = s.getcTasks();
  4020 + if(cts != null && cts.size() > 0){
  4021 + newList_.add(s);
  4022 + }else{
  4023 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  4024 + newList_.add(s);
  4025 + }
  4026 + }
  4027 + }
  4028 + }
  4029 + double jhgl=culateMileageService.culateJhgl(newList);
  4030 + double jhjcc=culateMileageService.culateJhJccgl(newList);
  4031 + double yygl=culateMileageService.culateSjgl(newList_);
  4032 + double ljgl=culateMileageService.culateLjgl(newList_);
  4033 + double ksgl=culateMileageService.culateKsgl(newList_);
  4034 + double jcgl=culateMileageService.culateJccgl(newList_);
  4035 +
  4036 + double zyygl=Arith.add(yygl, ljgl);
  4037 + double zksgl=Arith.add(ksgl, jcgl);
  4038 + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));
  4039 + sin.setEmptMileage(String.valueOf(zksgl));
  4040 + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));
  4041 + if(newList.size()>0){
  4042 + sin.setXlmc(newList.get(0).getXlName());
  4043 + sin.setjName(newList.get(0).getjName());
  4044 + }else{
  4045 + sin.setXlmc(BasicData.lineCodeAllNameMap.get(line));
  4046 + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));
  4047 +
  4048 + }
  4049 + if(startDate.equals(endDate))
  4050 + sin.setrQ(startDate);
  4051 + else
  4052 + sin.setrQ(startDate+"-"+endDate);
  4053 +// sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));
  4054 + sin.setSgh("");
  4055 + sin.setsName("");
  4056 + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  4057 + list_.add(sin);
  4058 +
  4059 + }
  4060 + }else{
  4061 + List<String> objList3 = new ArrayList<String>();
  4062 + objList3.add(startDate);
  4063 + objList3.add(endDate);
  4064 + String sql="select r.s_gh,r.s_name, "
  4065 + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm"
  4066 + + " from bsth_c_s_sp_info_real r where "
  4067 + + " r.schedule_date_str >= ?"
  4068 + + " schedule_date_str <= ?"
  4069 + + " and r.s_gh !='' and r.s_gh is not null ";
  4070 + if(!xlbm.equals("")){
  4071 + sql += " and r.xl_bm = ?";
  4072 + objList3.add(xlbm);
  4073 + }
  4074 + if(!gsdm.equals("")){
  4075 + sql += " and r.gs_bm = ?";
  4076 + objList3.add(gsdm);
  4077 + }
  4078 + if(!fgsdm.equals("")){
  4079 + sql += " and r.fgs_bm = ?";
  4080 + objList3.add(fgsdm);
  4081 + }
  4082 + sql += " group by r.s_gh,r.s_name,"
  4083 + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
  4084 +
  4085 + list = jdbcTemplate.query(sql, objList3.toArray(), new RowMapper<Singledata>() {
  4086 + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  4087 + @Override
  4088 + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {
  4089 + Singledata sin = new Singledata();
  4090 +// sin.setrQ(startDate);
  4091 + sin.setxL(arg0.getString("xl_bm"));
  4092 + sin.setClzbh(arg0.getString("cl_zbh"));
  4093 + sin.setSgh(arg0.getString("s_gh"));
  4094 + sin.setsName(arg0.getString("s_name"));
  4095 + sin.setgS(arg0.getString("fgs_bm"));
  4096 + return sin;
  4097 + }
  4098 + });
  4099 +
  4100 + String spy="";
  4101 + if(map.get("map")!=null){
  4102 + spy=map.get("spy").toString();
  4103 + }
  4104 + for (int i = 0; i < list.size(); i++) {
  4105 + Singledata sin=list.get(i);
  4106 + sin.setrQ(startDate+"-"+endDate);
  4107 + String jsy=sin.getSgh();
  4108 + String line=sin.getxL();
  4109 + String clzbh=sin.getClzbh();
  4110 + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  4111 + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();
  4112 +
  4113 + for (int j = 0; j < listReal.size(); j++) {
  4114 + ScheduleRealInfo s=listReal.get(j);
  4115 + if(s.getsGh().equals(jsy) && s.getClZbh().equals(clzbh)
  4116 + &&s.getXlBm().equals(line)){
  4117 + newList.add(s);
  4118 + Set<ChildTaskPlan> cts = s.getcTasks();
  4119 + if(cts != null && cts.size() > 0){
  4120 + newList_.add(s);
  4121 + }else{
  4122 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  4123 + newList_.add(s);
  4124 + }
  4125 + }
  4126 + }
  4127 + }
  4128 + double jhgl=culateMileageService.culateJhgl(newList);;
  4129 + double jhjcc=culateMileageService.culateJhJccgl(newList);
  4130 + double yygl=0.0;
  4131 + double ljgl=0.0;
  4132 + double zksgl=0.0;
  4133 + if(spy.equals("zrw")){
  4134 + yygl=culateMileageService.culateSjgl_spy(newList_);
  4135 + ljgl=culateMileageService.culateLjgl_spy(newList_);
  4136 + zksgl=culateMileageService.culateSjfyylc_spy(newList_);
  4137 + }else{
  4138 + yygl=culateMileageService.culateSjgl(newList_);
  4139 + ljgl=culateMileageService.culateLjgl(newList_);
  4140 + double ksgl=culateMileageService.culateKsgl(newList_);
  4141 + double jcgl=culateMileageService.culateJccgl(newList_);
  4142 + zksgl=Arith.add(ksgl, jcgl);
  4143 + }
  4144 + double zyygl=Arith.add(yygl, ljgl);
  4145 + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));
  4146 + sin.setEmptMileage(String.valueOf(zksgl));
  4147 + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));
  4148 + if(newList.size()>0)
  4149 + sin.setXlmc(newList.get(0).getXlName());
  4150 + else
  4151 + sin.setXlmc(BasicData.lineCodeAllNameMap.get(line));
  4152 + sin.setClzbh(clzbh);
  4153 + sin.setJsy("");
  4154 + sin.setjName("");
  4155 + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  4156 + sin.setHyl("");
  4157 + sin.setJzl("");
  4158 + sin.setUnyyyl("");
  4159 + list_.add(sin);
  4160 + }
  4161 + }
  4162 +
  4163 +
  4164 +
  4165 + if (type.equals("export")) {
  4166 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  4167 + ReportUtils ee = new ReportUtils();
  4168 +
  4169 + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
  4170 + int i = 1;
  4171 + for (Singledata l : list_) {
  4172 + Map<String, Object> m = new HashMap<String, Object>();
  4173 + m.put("i", i);
  4174 + m.put("rQ", l.getrQ());
  4175 + m.put("gS", l.getgS());
  4176 + m.put("xL", l.getXlmc());
  4177 + m.put("clzbh", l.getClzbh());
  4178 + m.put("jsy", l.getJsy());
  4179 + m.put("jName", l.getjName());
  4180 + m.put("sgh", l.getSgh());
  4181 + m.put("sName", l.getsName());
  4182 + m.put("jhlc", l.getJhlc());
  4183 + m.put("emptMileage", l.getEmptMileage());
  4184 + m.put("hyl", l.getHyl());
  4185 + m.put("jzl", l.getJzl());
  4186 + m.put("unyyyl", l.getUnyyyl());
  4187 + m.put("jhjl", l.getJhjl());
  4188 + resList.add(m);
  4189 +
  4190 + i++;
  4191 + }
  4192 +
  4193 + listI.add(resList.iterator());
  4194 + try {
  4195 + String exportDate="";
  4196 + if(startDate.equals(endDate)){
  4197 + exportDate =sdfSimple.format(sdfMonth.parse(startDate)) ;
  4198 + }else{
  4199 + exportDate =sdfSimple.format(sdfMonth.parse(startDate))+"-"+sdfSimple.format(sdfMonth.parse(endDate)) ;
  4200 + }
  4201 + String lineName = "";
  4202 + if(map.containsKey("lineName"))
  4203 + lineName = map.get("lineName").toString();
  4204 +
  4205 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  4206 + ee.excelReplace(listI, new Object[] { map }, path + "mould/singledata.xls",
  4207 + path + "export/" +exportDate
  4208 + + "-" + lineName + "-路单统计.xls");
  4209 + } catch (ParseException e) {
  4210 + e.printStackTrace();
  4211 + }
  4212 + }
  4213 + return list_;
  4214 + }
  4215 +
  4216 + @Override
  4217 + public List<Map<String, Object>> singleEnergy(Map<String, Object> map) {
  4218 + // TODO Auto-generated method stub
  4219 + Map<String, Map<String,Object>> mm=new HashMap<String, Map<String,Object>>();
  4220 +
  4221 + String gsdm="";
  4222 + if(map.get("gs")!=null){
  4223 + gsdm=map.get("gs").toString();
  4224 + }
  4225 + String fgsdm="";
  4226 + if(map.get("fgs")!=null){
  4227 + fgsdm=map.get("fgs").toString();
  4228 + }
  4229 + String energy="";
  4230 + if(map.get("energy")!=null){
  4231 + energy=map.get("energy").toString();
  4232 + }
  4233 + String xlbm="";
  4234 + if(map.get("line")!=null){
  4235 + xlbm=map.get("line").toString().trim();
  4236 + }
  4237 + String date = map.get("date").toString();
  4238 +
  4239 + List<ScheduleRealInfo> listReal=new ArrayList<ScheduleRealInfo>();
  4240 + if(xlbm.equals("")){
  4241 + listReal=scheduleRealInfoRepository.scheduleByDateAndLineByGs_(gsdm, fgsdm,date);
  4242 + }else{
  4243 + listReal=scheduleRealInfoRepository.scheduleByDateAndLineQp(xlbm, date);
  4244 + }
  4245 +
  4246 + List<String> objList = new ArrayList<String>();
  4247 + objList.add(date);
  4248 + String sql="select r.j_gh, r.xl_bm,r.cl_zbh,r.lp_name "
  4249 + + " from bsth_c_s_sp_info_real r where "
  4250 + + " r.schedule_date_str = ?";
  4251 + if(xlbm.length() != 0){
  4252 + sql += " and r.xl_bm = ?";
  4253 + objList.add(xlbm);
  4254 + }
  4255 + if(gsdm.length() != 0){
  4256 + sql += " and r.gs_bm = ?";
  4257 + objList.add(gsdm);
  4258 + }
  4259 + if(fgsdm.length() != 0){
  4260 + sql += " and r.fgs_bm = ?";
  4261 + objList.add(fgsdm);
  4262 + }
  4263 + sql += " group by r.j_gh,r.xl_bm,r.cl_zbh,r.lp_name order by r.xl_bm,r.cl_zbh,r.lp_name";
  4264 +
  4265 +
  4266 + List<Map<String, Object>> list = jdbcTemplate.query(sql, objList.toArray(), new RowMapper<Map<String,Object>>() {
  4267 + @Override
  4268 + public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {
  4269 + Map<String, Object> m=new HashMap<String, Object>();
  4270 + m.put("jGh", arg0.getString("j_gh"));
  4271 + m.put("xlBm", arg0.getString("xl_bm"));
  4272 + m.put("clZbh", arg0.getString("cl_zbh"));
  4273 + m.put("lpName", arg0.getString("lp_name"));
  4274 + return m;
  4275 + }
  4276 + });
  4277 +
  4278 + for (int i = 0; i < list.size(); i++) {
  4279 + Map<String, Object> m=list.get(i);
  4280 + String jGh=m.get("jGh").toString();
  4281 + String xlBm=m.get("xlBm").toString();
  4282 + String clZbh=m.get("clZbh").toString();
  4283 + String lpName=m.get("lpName").toString();
  4284 + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  4285 + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();
  4286 + String sGh="";
  4287 + String sName="";
  4288 + String jName="";
  4289 + String xlName="";
  4290 + for (int j = 0; j < listReal.size(); j++) {
  4291 + ScheduleRealInfo s=listReal.get(j);
  4292 + if(s.getjGh().equals(jGh)
  4293 + && s.getClZbh().equals(clZbh)
  4294 + &&s.getXlBm().equals(xlBm)
  4295 + &&s.getLpName().equals(lpName)){
  4296 + newList.add(s);
  4297 + if(jName.equals("")){
  4298 + jName=s.getjName();
  4299 + xlName=s.getXlName();
  4300 + }
  4301 + if(sGh.equals("")){
  4302 + if(!StringUtils.isEmpty(s.getsGh())){
  4303 + sGh=s.getsGh();
  4304 + sName=s.getsName();
  4305 + }
  4306 + }
  4307 + Set<ChildTaskPlan> cts = s.getcTasks();
  4308 + if(cts != null && cts.size() > 0){
  4309 + newList_.add(s);
  4310 + }else{
  4311 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  4312 + newList_.add(s);
  4313 + }
  4314 + }
  4315 + }
  4316 + }
  4317 + double yygl=culateMileageService.culateSjgl(newList_);
  4318 + double ljgl=culateMileageService.culateLjgl(newList_);
  4319 + double ksgl=culateMileageService.culateKsgl(newList_);
  4320 + double jcgl=culateMileageService.culateJccgl(newList_);
  4321 + double zyygl=Arith.add(yygl, ljgl);
  4322 + double zksgl=Arith.add(ksgl, jcgl);
  4323 + double zlc=Arith.add(zyygl, zksgl);
  4324 + Map<String, Object> m_=new HashMap<String, Object>();
  4325 + m_.put("zlc", zlc);
  4326 + m_.put("zksgl", zksgl);
  4327 + m_.put("sGh", sGh);
  4328 + m_.put("sName", sName);
  4329 + m_.put("jGh", jGh);
  4330 + m_.put("jName", jName);
  4331 + m_.put("xlName", xlName);
  4332 + mm.put(xlBm+jGh+clZbh+lpName, m_);
  4333 + }
  4334 + List<Map<String, Object>> listAll=new ArrayList<Map<String,Object>>();
  4335 + if(energy.equals("1")){
  4336 + List<String> objList1 = new ArrayList<String>();
  4337 + objList1.add(date);
  4338 + //油统计
  4339 + String ylbSql="select ssgsdm,fgsdm,xlbm,nbbm,jsy,ifnull(lp,'') as lp,czlc,"
  4340 + + " czyl,jzl,jzlc,jzyl,yh,sh,shyy,rylx,ns,zlc,linename,jname "
  4341 + + " from bsth_c_ylb where rq = ?";
  4342 +
  4343 + if(xlbm.length() != 0){
  4344 + ylbSql += " and xlbm = ?";
  4345 + objList1.add(xlbm);
  4346 + }
  4347 + if(gsdm.length() != 0){
  4348 + ylbSql += " and ssgsdm = ?";
  4349 + objList1.add(gsdm);
  4350 + }
  4351 + if(fgsdm.length() != 0){
  4352 + ylbSql += " and fgsdm = ?";
  4353 + objList1.add(fgsdm);
  4354 + }
  4355 + ylbSql += " order by xlbm,nbbm,jcsx";
  4356 + listAll = jdbcTemplate.query(ylbSql, objList1.toArray(), new RowMapper<Map<String,Object>>() {
  4357 + @Override
  4358 + public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {
  4359 + Map<String, Object> m=new HashMap<String, Object>();
  4360 + m.put("ssgsdm", arg0.getString("ssgsdm"));
  4361 + m.put("fgsdm", arg0.getString("fgsdm"));
  4362 + m.put("xlbm", arg0.getString("xlbm"));
  4363 + m.put("nbbm", arg0.getString("nbbm"));
  4364 + m.put("jsy", arg0.getString("jsy"));
  4365 + m.put("lp", arg0.getString("lp"));
  4366 + m.put("czlc", arg0.getDouble("czlc"));
  4367 + m.put("czyl", arg0.getDouble("czyl"));
  4368 + m.put("jzl", arg0.getDouble("jzl"));
  4369 + m.put("jzlc", arg0.getDouble("jzlc"));
  4370 + m.put("jzyl", arg0.getDouble("jzyl"));
  4371 + m.put("yh", arg0.getDouble("yh"));
  4372 + m.put("sh", arg0.getDouble("sh"));
  4373 + m.put("shyy", arg0.getString("shyy"));
  4374 + m.put("rylx", arg0.getString("rylx"));
  4375 + m.put("ns", arg0.getDouble("ns"));
  4376 + m.put("zlc", arg0.getDouble("zlc"));
  4377 + m.put("linename", arg0.getString("linename"));
  4378 + m.put("jname", arg0.getString("jname"));
  4379 + if(arg0.getDouble("zlc")==0){
  4380 + m.put("bglyh", "0.000");
  4381 + }else{
  4382 + DecimalFormat df = new DecimalFormat("0.000");
  4383 + m.put("bglyh", df.format(arg0.getDouble("yh")/arg0.getDouble("zlc")*100));
  4384 + }
  4385 + m.put("gsName", BasicData.businessCodeNameMap.get(arg0.getString("ssgsdm")));
  4386 + m.put("fgsName", BasicData.businessFgsCodeNameMap.get(arg0.getString("fgsdm")+"_"+arg0.getString("ssgsdm")));
  4387 + return m;
  4388 + }
  4389 + });
  4390 +
  4391 + }else{
  4392 + List<String> objList2 = new ArrayList<String>();
  4393 + objList2.add(date);
  4394 + //电统计
  4395 + String dlbSql="select ssgsdm,fgsdm,xlbm,nbbm,jsy,ifnull(lp,'') as lp,czlc,"
  4396 + + " czcd,cdl,jzlc,jzcd,hd,sh,shyy,ns,zlc,linename,jname "
  4397 + + " from bsth_c_dlb where rq = ?";
  4398 + if(xlbm.length() != 0){
  4399 + dlbSql += " and xlbm = ?";
  4400 + objList2.add(xlbm);
  4401 + }
  4402 + if(gsdm.length() != 0){
  4403 + dlbSql += " and ssgsdm = ?";
  4404 + objList2.add(gsdm);
  4405 + }
  4406 + if(fgsdm.length() != 0){
  4407 + dlbSql += " and fgsdm = ?";
  4408 + objList2.add(fgsdm);
  4409 + }
  4410 + dlbSql += " order by xlbm,nbbm,jcsx";
  4411 + listAll = jdbcTemplate.query(dlbSql, objList2.toArray(), new RowMapper<Map<String,Object>>() {
  4412 + @Override
  4413 + public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {
  4414 + Map<String, Object> m=new HashMap<String, Object>();
  4415 + m.put("ssgsdm", arg0.getString("ssgsdm"));
  4416 + m.put("fgsdm", arg0.getString("fgsdm"));
  4417 + m.put("xlbm", arg0.getString("xlbm"));
  4418 + m.put("nbbm", arg0.getString("nbbm"));
  4419 + m.put("jsy", arg0.getString("jsy"));
  4420 + m.put("lp", arg0.getString("lp"));
  4421 + m.put("czlc", arg0.getDouble("czlc"));
  4422 + m.put("czcd", arg0.getDouble("czcd"));
  4423 + m.put("cdl", arg0.getDouble("cdl"));
  4424 + m.put("jzlc", arg0.getDouble("jzlc"));
  4425 + m.put("jzcd", arg0.getDouble("jzcd"));
  4426 + m.put("hd", arg0.getDouble("hd"));
  4427 + m.put("sh", arg0.getDouble("sh"));
  4428 + m.put("shyy", arg0.getString("shyy"));
  4429 + m.put("linename", arg0.getString("linename"));
  4430 + m.put("jname", arg0.getString("jname"));
  4431 + m.put("zlc", arg0.getDouble("zlc"));
  4432 + //电量统计中添加默认中 燃油类型,尿素,保证导出模板相同
  4433 + m.put("rylx", "");
  4434 + m.put("ns", "0");
  4435 + if(arg0.getDouble("zlc")==0){
  4436 + m.put("bglyh", "0.000");
  4437 + }else{
  4438 + DecimalFormat df = new DecimalFormat("0.000");
  4439 + m.put("bglyh", df.format(arg0.getDouble("hd")/arg0.getDouble("zlc")*100));
  4440 + }
  4441 + m.put("gsName", BasicData.businessCodeNameMap.get(arg0.getString("ssgsdm")));
  4442 + m.put("fgsName", BasicData.businessFgsCodeNameMap.get(arg0.getString("fgsdm")+"_"+arg0.getString("ssgsdm")));
  4443 + return m;
  4444 + }
  4445 + });
  4446 + }
  4447 +
  4448 + Map<String, Object> dMap=new HashMap<>();
  4449 + dMap.put("dGroup_eq", "oilType");
  4450 + Iterator<Dictionary> it= dictionaryService.list(dMap).iterator();
  4451 + while (it.hasNext()) {
  4452 + Dictionary d=it.next();
  4453 + dMap.put(d.getdCode(), d.getdName());
  4454 + }
  4455 + for (int i = 0; i < listAll.size(); i++) {
  4456 + Map<String, Object> m=listAll.get(i);
  4457 + String jGh=m.get("jsy").toString();
  4458 + String xlBm=m.get("xlbm").toString();
  4459 + String clZbh=m.get("nbbm").toString();
  4460 + String lpName=m.get("lp")==null?"":m.get("lp").toString();
  4461 + String shyy=m.get("shyy")==null?"":m.get("shyy").toString();
  4462 + String rylx=m.get("rylx")==null?"":m.get("rylx").toString();
  4463 + if(dMap.get(rylx)==null){
  4464 + rylx="";
  4465 + }else{
  4466 + rylx=dMap.get(rylx).toString();
  4467 + }
  4468 + m.put("rylx", rylx);
  4469 + m.put("shyy", getShyy(shyy));
  4470 + m.put("date", date);
  4471 +
  4472 + if(mm.get(xlBm+jGh+clZbh+lpName)!=null){
  4473 + Map<String, Object> m_=mm.get(xlBm+jGh+clZbh+lpName);
  4474 + m.put("zlcAll", m_.get("zlc")==null?"":m_.get("zlc").toString());
  4475 + m.put("zksgl", m_.get("zksgl")==null?"":m_.get("zksgl").toString());
  4476 + m.put("sGh", m_.get("sGh")==null?"":m_.get("sGh").toString());
  4477 + m.put("sName", m_.get("sName")==null?"":m_.get("sName").toString());
  4478 + m.put("jname", m_.get("jName")==null?"":m_.get("jName").toString());
  4479 + m.put("linename", m_.get("xlName")==null?"":m_.get("xlName").toString());
  4480 + }else{
  4481 + m.put("zlcAll", "");
  4482 + m.put("zksgl", "");
  4483 + m.put("sGh", "");
  4484 + m.put("sName", "");
  4485 + //油量表中历史数据和手动添加数据没有储存线路名字与驾驶员名字,是null的字段则根据编号查找
  4486 + if(m.get("linename")==null){
  4487 + m.put("linename", BasicData.lineCode2NameMap.get(xlBm));
  4488 + }
  4489 + if(m.get("jname")==null){
  4490 + m.put("jname", BasicData.allPerson.get(m.get("ssgsdm")+"-"+jGh));
  4491 + }
  4492 + }
  4493 + }
  4494 +
  4495 + if(map.get("type").toString().equals("export")){
  4496 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  4497 + Map<String, Object> m = new HashMap<String, Object>();
  4498 + m.put("date", date);
  4499 + ReportUtils ee = new ReportUtils();
  4500 + try {
  4501 + listI.add(listAll.iterator());
  4502 + if(energy.equals("1")){
  4503 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  4504 + ee.excelReplace(listI, new Object[]{m}, path + "mould/energy_ylb.xls",
  4505 + path + "export/"+date+"路单油量统计表.xls");
  4506 + }else{
  4507 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  4508 + ee.excelReplace(listI, new Object[]{m}, path + "mould/energy_dlb.xls",
  4509 + path + "export/"+date+"路单电量统计表.xls");
  4510 + }
  4511 +
  4512 + } catch (Exception e) {
  4513 + // TODO: handle exception
  4514 + e.printStackTrace();
  4515 + }
  4516 + }
  4517 + return listAll;
  4518 + }
  4519 +
  4520 + public Map<String,Object> calcDetailMonthlyE(Map<String, Object> map){
  4521 +
  4522 + Map<String, Object> resultMap = new HashMap<String, Object>();
  4523 + if (executing) {
  4524 + resultMap.put("status", ResponseCode.ERROR);
  4525 + resultMap.put("msg", "此计算正在处理,请不要重复请求");
  4526 +
  4527 + return resultMap;
  4528 + }
  4529 + executing = true;
  4530 +// List<List<String>> list = calcWaybillService.calcDetailMonthly(map);
  4531 + List<List<String>> list = calcWaybillService.calcDetailMonthlyNew(map);
  4532 +
  4533 + try {
  4534 + String name = map.get("name").toString();
  4535 + String type = map.get("statisticalObj").toString();
  4536 + if(list.size()>0){
  4537 + ReportUtils ee = new ReportUtils();
  4538 + ee.createFlie(list,name,type);
  4539 + }
  4540 +
  4541 + resultMap.put("status", ResponseCode.SUCCESS);
  4542 + } catch (Exception e) {
  4543 + resultMap.put("status", ResponseCode.ERROR);
  4544 + logger.error("save erro.", e);
  4545 + } finally {
  4546 + executing = false;
  4547 + }
  4548 + return resultMap;
  4549 + }
  4550 +
  4551 + private String getShyy(String node){
  4552 + String shyy ="无";
  4553 + if(!node.equals("")){
  4554 + if(node.equals("1")){shyy="票务用油";}
  4555 + else if(node.equals("2")){shyy="保养用油";}
  4556 + else if(node.equals("3")){shyy="报废车用油";}
  4557 + else if(node.equals("4")){shyy="其它用油";}
  4558 + else if(node.equals("5")){shyy="人保部";}
  4559 + else if(node.equals("6")){shyy="车队";}
  4560 + else if(node.equals("7")){shyy="车间(高保)";}
  4561 + else if(node.equals("8")){shyy="车间(小修)";}
  4562 + else{shyy ="无";}
  4563 + }
  4564 + return shyy;
  4565 + }
  4566 +
  4567 +}
  4568 +
  4569 +class ComparableAcuals implements Comparator<ScheduleRealInfo>{
  4570 +
  4571 + @Override
  4572 + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
  4573 + // TODO Auto-generated method stub
  4574 + return o1.getFcsjActualTime().compareTo(o2.getFcsjActualTime());
  4575 + }
  4576 +
4562 } 4577 }
4563 \ No newline at end of file 4578 \ No newline at end of file