LoggerZnddServiceImpl.java
30.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
package com.bsth.service.zndd.impl;
import com.alibaba.fastjson.JSON;
import com.bsth.common.ResponseCode;
import com.bsth.controller.realcontrol.dto.DfsjChange;
import com.bsth.data.BasicData;
import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
import com.bsth.data.gpsdata_v2.entity.StationRoute;
import com.bsth.data.schedule.DayOfSchedule;
import com.bsth.data.schedule.SchAttrCalculator;
import com.bsth.data.schedule.ScheduleComparator;
import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
import com.bsth.data.zndd.dify.BusCongestionChecker;
import com.bsth.entity.Line;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import com.bsth.entity.sys.RealControAuthority;
import com.bsth.entity.zndd.LoggerZndd;
import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
import com.bsth.repository.zndd.LoggerZnddRepository;
import com.bsth.service.BusIntervalService;
import com.bsth.service.LineService;
import com.bsth.service.impl.BaseServiceImpl;
import com.bsth.service.realcontrol.ScheduleRealInfoService;
import com.bsth.service.report.ReportService;
import com.bsth.service.sys.RealControAuthorityService;
import com.bsth.service.zndd.LoggerZnddService;
import com.bsth.util.CoordinateConverter;
import com.bsth.util.DateUtils;
import com.bsth.util.IpUtils;
import com.bsth.util.ReportUtils;
import com.google.gson.Gson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@Service
public class LoggerZnddServiceImpl extends BaseServiceImpl<LoggerZndd, Integer> implements LoggerZnddService {
@Autowired
LoggerZnddRepository loggerZnddRepository;
@Autowired
DayOfSchedule dayOfSchedule;
@Autowired
ScheduleRealInfoService scheduleRealInfoService;
@Autowired
ScheduleRealInfoRepository scheduleRealInfoRepository;
@Autowired
LineService lineService;
@Autowired
ReportService reportService;
@Autowired
SchAttrCalculator schAttrCalculator;
@Autowired
RealControAuthorityService realControAuthorityService;
@Autowired
BusIntervalService busIntervalService;
@Autowired
JdbcTemplate jdbcTemplate;
Logger logger = LoggerFactory.getLogger(this.getClass());
private static SimpleDateFormat sdfMonth = new SimpleDateFormat("HH:mm");
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private static SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
public List<Map<String, Object>> listAll(Map<String, Object> map){
loggerZnddRepository.findAll((Sort) map);
return null;
}
@Override
public ScheduleRealInfo schlist(String lineCode,Integer dir){
List<ScheduleRealInfo> list = dayOfSchedule.findByLineAndUpDown(lineCode,dir);
if (!list.isEmpty() ){
for (ScheduleRealInfo sr : list){
if(sr.getBcType().equals("normal")){
return sr;
}
}
}
return null;
};
@Override
@Transactional //发车间隔 误点
public Map<String, Object> znddConfig(Map<String, Object> map){
//查出离触发时间最近的一次路单 修改部分值
//包装好路单添加如临加班次
List<DfsjChange> dfsjcs = new ArrayList<>();//返回的数据
try {
String lineCode = map.get("lineCode") != null ? map.get("lineCode").toString() : null;
String xlDir = map.get("xlDir") != null ? map.get("xlDir").toString() : null;
String rq = map.get("rq") != null ? map.get("rq").toString() : null;
List<ScheduleRealInfo> upoldSchDateList = new ArrayList<>(), //上行
dnoldSchDateList = new ArrayList<>(); //下行
List<ScheduleRealInfo> listReal = new ArrayList<>();
Boolean typeReal = false;
//排班依次往后
List<ScheduleRealInfo> list = dayOfSchedule.findByLineCode(lineCode);
//区分上下行
for (ScheduleRealInfo t : list){
if (t.getXlDir().equals("0")){
upoldSchDateList.add(t);
}else {
dnoldSchDateList.add(t);
}
}
if (xlDir.equals("0")){
Collections.sort(upoldSchDateList, new ScheduleComparator.FCSJ());//排序
list = upoldSchDateList;
}else {
Collections.sort(upoldSchDateList, new ScheduleComparator.FCSJ());//排序
list = upoldSchDateList;
}
for (ScheduleRealInfo info : list) {
//从相等开始
if (info.getFcsjActual() != null && !info.getFcsjActual().equals("")) {
if (info.getFcsjActual().equals(rq))
typeReal = true;
continue;
}
if (typeReal && (info.getBcType().equals("normal")|| info.getBcType().equals("region")))
listReal.add(info);
if (listReal.size() >= 5) //或者不满5条结束 listReal.size()从1开始
break;
}
//处理listReal 5条数据或5条一下
for (int i = 0; i < listReal.size() ;i++){
DfsjChange cl = new DfsjChange();
Integer[] mis = {3,2,2,1,1}; //往后5个班次分别延后3 2 2 1 1
ScheduleRealInfo info = listReal.get(i);
int ms = mis[i];
//未发车时 才可改变
if (info.getFcsjActual() == null || info.getFcsjActual().equals("")){
String dfsj = sdfMonth.format(sdf.parse(info.getScheduleDateStr()+ " " + info.getDfsj()).getTime() - (ms * 60 * 1000)); //延后几分钟
cl.setSchId(info.getId());
cl.setOld_dfsj(info.getDfsj());
cl.setNew_dfsj(dfsj);
dfsjcs.add(cl);
}
}
return scheduleRealInfoService.multi_dftz(dfsjcs);
}catch (Exception e){
logger.info("--",e);
}
return null;
}
public ScheduleRealInfo thissch(Integer ids){
ScheduleRealInfo sch2=dayOfSchedule.get(ids);
ScheduleRealInfo sch= null;
try {
sch = sch2.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
Line line = lineService.findByLineCode(sch.getXlBm());
List<Map<String, Object>> lineList=reportService.lineList();
Set<String> lines = new HashSet<>();
for (Map<String, Object> map : lineList) {
if(line.getBrancheCompany().equals(map.get("fgsbm").toString())){
lines.add(map.get("xlbm").toString());
}
}
List<Map<String,String>> schs=new ArrayList<>();
LocalTime localTime=LocalTime.now().plusHours(1);
LocalTime now=LocalTime.now();
DateTimeFormatter dtf=DateTimeFormatter.ofPattern("HH:mm");
for (String lineCode : lines) {
Set<String> set = dayOfSchedule.findCarByLineCode(lineCode);
for (String nbbm : set) {
ScheduleRealInfo s=dayOfSchedule.executeCurr(nbbm);//当前执行班次
if(s==null){//当日班次执行完毕
List<ScheduleRealInfo> list=dayOfSchedule.findByNbbm(nbbm);
if(list.size()>0){
ScheduleRealInfo s2=list.get(list.size()-1);//最后一个班次\
if(s2.getZdsjActual()!=null && LocalTime.parse(s2.getZdsjActual(),dtf).isBefore(now)){
Map<String,String> schMap = new HashMap<>();
schMap.put("nbbm",s2.getClZbh());
schMap.put("jgh",s2.getjGh());
schMap.put("jName",s2.getjName());
schMap.put("zdsjActual",s2.getZdsjActual());
System.out.println(s2.getClZbh()+s2.getZdsjActual()+lineCode);
schs.add(schMap);
}
}
}else {//1小时内是否有待执行班次
LocalTime fcsj=LocalTime.parse(s.getFcsj(),dtf);
if(fcsj.isAfter(localTime)){
//查询上一个班次
ScheduleRealInfo s2=dayOfSchedule.prev(s);
if(s.getZdsjActual()!=null && LocalTime.parse(s2.getZdsjActual(),dtf).isBefore(now)){
Map<String,String> schMap = new HashMap<>();
schMap.put("nbbm",s2.getClZbh());
schMap.put("jgh",s2.getjGh());
schMap.put("jName",s2.getjName());
schMap.put("zdsjActual",s2.getZdsjActual());
System.out.println(s2.getClZbh()+s2.getZdsjActual()+lineCode);
schs.add(schMap);
}
}
}
}
}
Collections.sort(schs, new Comparator<Map<String, String>>(){
public int compare(Map<String, String> o1, Map<String, String> o2) {
String zdsjActual1 = o1.get("zdsjActual");
String zdsjActual2 = o2.get("zdsjActual");
return zdsjActual2.compareTo(zdsjActual1);
}
});
StringBuffer sb=new StringBuffer();
String kscl="";
List<Map<String, String>> schs2 = new ArrayList<>();
// 创建用于去重的 Set<Map>
Set<Map<String, String>> set = new HashSet<>();
// 遍历原始的 List<Map>
for (Map<String, String> map : schs) {
// 创建一个新的 Map 用于存储合并去重后的结果
Map<String, String> newMap = new HashMap<>(map);
// 如果新的 Map 成功添加到 Set 中,说明是一个新的 Map,将其添加到结果 List<Map> 中
if (set.add(newMap)) {
schs2.add(newMap);
}
}
if(schs2.size()>0){
sch.setClZbh(schs2.get(0).get("nbbm"));
sch.setjGh(schs2.get(0).get("jgh"));
sch.setjName(schs2.get(0).get("jName"));
int size =schs2.size()>8?8:schs2.size();
for (int i = 0; i < size; i++) {
sb.append(schs2.get(i).get("nbbm")+"/");
sb.append(schs2.get(i).get("jName")+"/");
sb.append(schs2.get(i).get("zdsjActual")+",");
}
kscl=sb.toString().substring(0,sb.length()-1);
}
sch.setKxcl(kscl);
return sch;
}
//退出线调提示
public String LineUserAll(@RequestParam Integer userId){
String xlNames ="";
RealControAuthority rcay = realControAuthorityService.findByUserId(userId);
String lineCodeStr = rcay.getLineCodeStr();
String[] lineArray = lineCodeStr.split(",");
for(String line : lineArray){
List<ScheduleRealInfo> schList = dayOfSchedule.findByLineCode(line);
for(ScheduleRealInfo sc : schList){
//去除烂班、发车时间和实到时间都为null的时候
if (sc.getStatus() != -1 && (sc.getFcsjActual() == null || sc.getZdsjActual() == null)){
xlNames += sc.getXlName()+",";
break;
}
}
}
return xlNames;
}
public Map<String, Object> schTZSF(String line,String date,String endDate,String changType,String type){
Map<String, Object> rs = new HashMap();
try {
String cont = "";
if (line != null && !line.equals("")){
cont = " and line_code ="+line;
}
String bcType ="";
if (changType.equals("0")){
bcType = " and bc_type not in ('in','out','venting')";
}else {
bcType =" and bc_type in ('out')";
}
//拼接除rq、lineCode 外的其他where 条件
String sql = "select t1.*, t2.fcsj,t2.lp_name,t2.cl_zbh,t2.j_gh,t2.j_name,t2.xl_dir,t2.real_exec_date,t2.xl_name from (select * from logger_sch_modify where rq >=? and rq <=? and type in('SFTZ','FCXXWT') and remarks !='自动调度实发未发-车辆掉线'"+cont+" ) t1 INNER JOIN bsth_c_s_sp_info_real t2 on t1.sch_id=t2.id where 1=1 " +bcType;
List<SchEditInfoDto> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(SchEditInfoDto.class), date,endDate);
rs.put("status", ResponseCode.SUCCESS);
List<SchEditInfoDto> listnew = new ArrayList<>();
for(SchEditInfoDto item : list){
List<Map> lists = (List) JSON.parse(item.getJsonArray());
for(Map its : lists){
if (item.getType().equals("FCXXWT")) {
if (its.get("old") != null && its.get("title").equals("调整实发时间")) {
String text = "调整前:" + its.get("old") + ",调整后:" + its.get("now");
item.setText(text);
listnew.add(item);
break;
}
}else {
if(its.get("old") != null){
String text = "调整前:" + its.get("old") + ",调整后:" + its.get("now");
item.setText(text);
break;
}
}
};
};
rs.put("list", listnew);
if(type.equals("export")){
List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
Map<String, Object> m = new HashMap<String, Object>();
ReportUtils ee = new ReportUtils();
List list1 = new ArrayList();
for(SchEditInfoDto sed : listnew){
Map map = JSON.parseObject(JSON.toJSONString(sed), Map.class);
list1.add(map);
}
try {
listI.add(list1.iterator());
String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
ee.excelReplace(listI, new Object[]{m}, path + "mould/" + "sch_tzsf.xls",
path + "export/"+date+"-"+endDate+"-异常调整实发.xls");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}catch (Exception e){
logger.error("", e);
rs.put("status", ResponseCode.ERROR);
rs.put("msg", e.getMessage());
}
return rs;
}
public ScheduleRealInfo nextSch(Long id){
return dayOfSchedule.next(dayOfSchedule.get(id));
}
public Map schDeepSeep(String message){
Map m = new HashMap<>();
String xl = null; //线路编码
String xlName = null;
//获取所有线路
Map<String, String> lineMap = BasicData.lineCode2NameMap;
for (Map.Entry<String, String> t : lineMap.entrySet()){
if (message.contains(t.getValue()) || t.getValue().contains(message)){
xl = t.getKey();
xlName = t.getValue();
}
}
if (xl != null){
//总班次、进场班次、出场班次、临加班次、正常班次、区间班次。0 未执行 1 正在执行 2 已执行 -1 已烂班
Integer inbcs = 0,outbcs = 0,ljbcs = 0,normalbcs = 0,regionbcs =0,wzxbcs = 0 ,zzxbcs = 0,yzxbcs = 0,lbbcs = 0;
List<ScheduleRealInfo> srList = dayOfSchedule.findByLineCode(xl);//当日所有班次
for(ScheduleRealInfo sc : srList) {
if (sc.getBcType().equals("in"))
inbcs = inbcs + 1;
if (sc.getBcType().equals("out"))
outbcs = outbcs + 1;
if (sc.isSflj())
ljbcs = ljbcs + 1;
if (sc.getBcType().equals("normal"))
normalbcs = normalbcs + 1;
if (sc.getBcType().equals("region"))
regionbcs = regionbcs + 1;
if (sc.getStatus() == 0)
wzxbcs = wzxbcs + 1;
if (sc.getStatus() == 1)
zzxbcs = zzxbcs + 1;
if (sc.getStatus() == 2)
yzxbcs = yzxbcs + 1;
if (sc.getStatus() == -1)
lbbcs = lbbcs + 1;
}
m.put("code","200");
m.put("进场班次数",inbcs);
m.put("出场班次数",outbcs);
m.put("临加班次数",ljbcs);
m.put("正常班次数",normalbcs);
m.put("区间班次数",regionbcs);
m.put("未执行班次数",wzxbcs);
m.put("正在执行班次数",zzxbcs);
m.put("已执行班次数",yzxbcs);
m.put("烂班班次数",lbbcs);
m.put("总班次数",srList.size());
m.put("线路名称",xlName);
}else {
m.put("code","100");
m.put("message","无法找到线路");
}
return m;
}
public List<ScheduleRealInfo> schQbc(String xl){
//获取前一天的班次
List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLineTjrb(xl, DateUtils.qyt_date());
return list;
}
//获取道路是否拥堵
public String line_yd(String message) {
String fyString = "";
String xl = null; //线路编码
String xlName = null; //查询出线路
Line line = null;
//起点坐标 ,终点坐标,起点名称,终点名称
String ORIGIN = "", DESTINATION = "",orStationName = null,descStationName= null;
//获取所有线路
Map<String, String> lineMap = BasicData.lineCode2NameMap;
for (Map.Entry<String, String> t : lineMap.entrySet()) {
if (message.contains(t.getValue()) || t.getValue().contains(message)) {
xl = t.getKey();
xlName = t.getValue();
}
}
if (xl != null) {
List<StationRoute> list = GeoCacheData.getStationRoute(xl, 0);
for (StationRoute sr :list){
CoordinateConverter.Location location;
location = CoordinateConverter.LocationMake(sr.getPoint().getLon(), sr.getPoint().getLat());
location = CoordinateConverter.bd_encrypt(CoordinateConverter.transformFromWGSToGCJ(location));
if(sr.getMark().equals("B")) {
ORIGIN = location.getLat() + "," + location.getLng();
orStationName = sr.getName();
}
if(sr.getMark().equals("E")) {
DESTINATION = location.getLat() + "," + location.getLng();
descStationName = sr.getName();
}
}
fyString = BusCongestionChecker.DL_YDQK(ORIGIN,DESTINATION,"上海",xlName) + " " +orStationName + "开往" + descStationName + "方向";
fyString += "\n";
fyString += BusCongestionChecker.DL_YDQK(DESTINATION,ORIGIN,"上海",xlName) + " " +descStationName + "开往" + orStationName + "方向";;
}
return fyString;
}
//线路准点
public List line_zd(Integer status){
return getScheduleStatistic_lg(DateUtils.qyt_date(),status);
}
//查询出线路不准点的原因
public String line_zd_remark(String message){
String fyString = "";
String xl = null; //线路编码
String xlName = null; //查询出线路
Line line = null;
//获取所有线路
Map<String, String> lineMap = BasicData.lineCode2NameMap;
for (Map.Entry<String, String> t : lineMap.entrySet()) {
if (message.contains(t.getValue()) || t.getValue().contains(message)) {
xl = t.getKey();
xlName = t.getValue();
}
}
List<ScheduleRealInfo> srList = scheduleRealInfoService.findByLineCodeAndDate(xl, DateUtils.qyt_date());
for (ScheduleRealInfo sc : srList){
schAttrCalculator
.calcRealDate(sc)
.calcAllTimeByFcsj(sc);
if (sc.getStatus() == -1)
continue;
long sjc = sc.getFcsjActualTime() - sc.getDfsjT();
if (sc.getZdsjActual() !=null && sc.getFcsjActual() != null && (sc.getBcType().equals("normal")||sc.getBcType().equals("region"))){
//快1慢3
if (sjc >= -1 * 60 * 1000 && sjc <= 3 * 60 * 1000) {
continue;
} else {
fyString += sc.getXlName()+"---实际发车时间:" + sc.getFcsjActual() + "---待发时间:" + sc.getDfsj() + "---原因:" + sc.getRemarks() +"。<br/>";
}
}
}
return fyString;
}
public String exportWaybillAll(String message) {
String fyString = "";
String xl = null,xlName = null;//线路编码 //查询出线路
//获取所有线路
Map<String, String> lineMap = BasicData.lineCode2NameMap;
for (Map.Entry<String, String> t : lineMap.entrySet()) {
if (message.contains(t.getValue()) || t.getValue().contains(message)) {
xl = t.getKey(); xlName = t.getValue();
}
}
String date = yyyyMMdd.format(new Date());
List<ScheduleRealInfo> srList = scheduleRealInfoService.queryUserInfo(xl,date,"2");
List<String[]> strs = new ArrayList<>();
for (ScheduleRealInfo info : srList) {
String[] row = {info.getjName(), info.getClZbh(), info.getLpName(), info.getjGh()};
strs.add(row);
}
// 将 strs 转换为 JSON 格式的字符串
Gson gson = new Gson();
String resultStr = gson.toJson(strs);
Map<String,Object> map = new HashMap<>();
map.put("date",date);
map.put("line",xl);
map.put("lineName",xlName);
map.put("strs",resultStr);
Map<String, Object> resMap =busIntervalService.exportWaybillMore(map);
return "http://"+IpUtils.getLocalIpAddress()+":9088/downloadFile/download?fileName="+ resMap.get("fileName");
//单人导出
/* String jName= "沈秋林",jGh= "007423" ,clZbh= "W2L-021" ,lpName= "3", date= "2025-06-23", line= "11067";
scheduleRealInfoService.exportWaybill(jName,jGh, clZbh, lpName,date,line);
return "http://"+IpUtils.getLocalIpAddress()+":9088/downloadFile/download?fileName="+ date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls";*/
}
public List getScheduleStatistic_lg(String date,Integer status){
Map<String, Object> resMap = new HashMap<String, Object>();
String gpLineSql = "select * from bsth_c_line_plate";
List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql,
new RowMapper<Map<String, Object>>(){
@Override
public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
Map<String, Object> m=new HashMap<String,Object>();
m.put("lineName", rs.getString("line_name"));
m.put("lineCode", rs.getString("line_code"));
return m;
}
});
Set<String> gpSet = new HashSet<String>();
for(Map<String, Object> t : gpLineList){
if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){
gpSet.add(t.get("lineCode").toString().trim());
}
}
String yyxlSql="SELECT line_code from bsth_c_line "
+ " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')";
List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql,
new RowMapper<Map<String, Object>>(){
@Override
public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
Map<String, Object> m=new HashMap<String,Object>();
m.put("lineCode", rs.getString("line_code"));
return m;
}
});
Set<String> yyLine = new HashSet<String>();
for(Map<String, Object> t : yyxlList){
if(t.get("lineCode") != null){
yyLine.add(t.get("lineCode").toString());
}
}
String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,"
+ " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz,"
+ " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz,"
+ " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz,"
+ " jhszfcs,sjszfczds,szfczdl,create_date"
+ " from bsth_c_calc_count "
+ " where date = ? ";
List<Map<String, Object>> list=jdbcTemplate.query(sql, new Object[]{date},
new RowMapper<Map<String, Object>>(){
@Override
public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
Map<String, Object> m=new HashMap<String,Object>();
m.put("lineCode",rs.getString("xl"));
m.put("lineName", rs.getString("xl_name"));
m.put("date", rs.getString("date"));
m.put("jhbc", rs.getString("jhbc"));
m.put("sjbc", rs.getString("sjbc"));
m.put("bczxl", rs.getString("bczxl"));
m.put("jhbcz", rs.getString("jhbcz"));
m.put("jhcc", rs.getString("jhcc"));
m.put("sjcc", rs.getString("sjcc"));
m.put("ccl", rs.getString("ccl"));
m.put("jhyylc", rs.getString("jhyylc"));
m.put("sjyylc", rs.getString("sjyylc"));
m.put("jhyylcz", rs.getString("jhyylcz"));
m.put("jhkslc", rs.getString("jhkslc"));
m.put("sjkslc", rs.getString("sjkslc"));
m.put("jhkslcz", rs.getString("jhkslcz"));
m.put("jhgfbcs", rs.getString("jhssgfbcs"));
m.put("sjgfbcs", rs.getString("sjgfbcs"));
m.put("jhgfbcsz", rs.getString("jhgfbcsz"));
m.put("jhdgbcs", rs.getString("jhssdgbcs"));
m.put("sjdgbcs", rs.getString("sjdgbcs"));
m.put("jhdgbcsz", rs.getString("jhdgbcsz"));
m.put("jhsmbcs", rs.getString("jhsmbcs"));
m.put("sjsmbczds", rs.getString("sjsmbczds"));
m.put("smbczdl", rs.getString("smbczdl"));
m.put("jhsmbcsz", rs.getString("jhsmbcsz"));
m.put("sjsmbczdsz", rs.getString("sjsmbczdsz"));
m.put("smbczdlz", rs.getString("smbczdlz"));
m.put("jhszfcs", rs.getString("jhszfcs"));
m.put("sjszfczds", rs.getString("sjszfczds"));
m.put("szfczdl", rs.getString("szfczdl"));
Date date = new Date();
date.setTime(rs.getTimestamp("create_date").getTime());
m.put("createDate", sdf.format(date));
return m;
}
});
List<Map<String, Object>> bcDetail = new ArrayList<Map<String,Object>>();
List<Map<String, Object>> smDetail = new ArrayList<Map<String,Object>>();
List<Map<String, Object>> qqDetail = new ArrayList<Map<String,Object>>();
BigDecimal yygl_z = new BigDecimal(0);//实时总营运里程
for(Map<String, Object> t : list){
if(yyLine.contains(t.get("lineCode").toString())){
yygl_z = yygl_z.add(new BigDecimal(t.get("sjyylc").toString()));
Map<String, Object> bc = new HashMap<String, Object>();
bc.put("type", "班次执行详情");
bc.put("lineName", t.get("lineName").toString());
//bc.put("jh", t.get("jhbc").toString());
//bc.put("sj", t.get("sjbc").toString());
Double bfbbc = Double.valueOf(t.get("sjbc").toString()) / Double.valueOf(t.get("jhbc").toString());
bc.put("bfb", String.format("%.2f", bfbbc * 100));
bc.put("date",date);
bcDetail.add(bc);
Map<String, Object> sm = new HashMap<String, Object>();
sm.put("type", "首末班准点详情");
sm.put("lineName", t.get("lineName").toString());
// sm.put("jh", t.get("jhsmbcs").toString());
// sm.put("sj", t.get("sjsmbczds").toString());
Double bfbsm = Double.valueOf(t.get("sjsmbczds").toString()) / Double.valueOf(t.get("jhsmbcs").toString());
sm.put("bfb", String.format("%.2f", bfbsm * 100));
sm.put("date",date);
smDetail.add(sm);
Map<String, Object> qq = new HashMap<String, Object>();
qq.put("type", "班次准点详情");
qq.put("lineName", t.get("lineName").toString());
//qq.put("jh", t.get("jhszfcs").toString());
//qq.put("sj", t.get("sjszfczds").toString());
Double bfbqq = Double.valueOf(t.get("sjszfczds").toString()) / Double.valueOf(t.get("jhszfcs").toString());
qq.put("bfb", String.format("%.2f", bfbqq * 100));
qq.put("date",date);
qqDetail.add(qq);
}
}
List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>();
if (status == 0)
detailsList.addAll(smDetail);
if (status == 1)
detailsList.addAll(qqDetail);
if (status == 2)
detailsList.addAll(bcDetail);
return detailsList;
}
}