ScheduleRealInfo.java
17.9 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
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
package com.bsth.entity.realcontrol;
import com.bsth.entity.sys.SysUser;
import com.bsth.vehicle.gpsdata.arrival.entity.RealTimeModel;
import com.fasterxml.jackson.annotation.JsonIgnore;
import javax.persistence.*;
import org.apache.commons.lang3.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
/**
* 实际排班计划明细。
*/
@Entity
@Table(name = "bsth_c_s_sp_info_real")
@NamedEntityGraphs({
@NamedEntityGraph(name = "scheduleRealInfo_cTasks", attributeNodes = {
@NamedAttributeNode("cTasks"),
@NamedAttributeNode("sjfcModel"),
@NamedAttributeNode("sjddModel")
})
})
public class ScheduleRealInfo {
/** 主键Id */
@Id
@GeneratedValue
private Long id;
/** 计划ID */
private Long spId;
/** 排班计划日期 */
private Date scheduleDate;
private String scheduleDateStr;
/** 真实执行时间 yyyy-MM-dd */
private String realExecDate;
/** 线路名称 */
private String xlName;
/** 线路编码 */
private String xlBm;
/** 路牌名称 */
private String lpName;
/** 车辆自编号 */
private String clZbh;
/** 报道时间(格式 HH:mm)
private String bdTime; */
/** 出场时间(格式 HH:mm)
private String ccTime;*/
/** 驾驶员工号 */
private String jGh;
/** 驾驶员名字 */
private String jName;
/** 售票员工号 */
private String sGh;
/** 售票员名字 */
private String sName;
/** 线路方向 */
private String xlDir;
/** 起点站code*/
private String qdzCode;
/** 起点站名字 */
private String qdzName;
/** 终点站code*/
private String zdzCode;
/** 终点站名字 */
private String zdzName;
/** 计划发车时间(格式 HH:mm) */
private String fcsj;
/** 计划发车时间戳*/
@Transient
private Long fcsjT;
/** 计划终点时间(格式 HH:mm) */
private String zdsj;
/** 计划终点时间戳*/
@Transient
private Long zdsjT;
/** 发车顺序号 */
private Integer fcno;
/** 对应班次数 */
private Integer bcs;
/** 计划里程 */
private Double jhlc;
/** 班次历时 */
private Integer bcsj;
/**
* 班次类型 TODO:正常班次、出场、进场、加油、区间班次、放空班次、放大站班次、两点间空驶
*/
private String bcType;
/** 停车场既首发站 */
@Transient
private boolean parkIsFirstStation;
/** 首发站既停车场 */
@Transient
private boolean firstStationIsPark;
/** 与其共享发车时间的进出场班次 */
@JsonIgnore
@Transient
private ScheduleRealInfo twins;
/** 创建人 */
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
private SysUser createBy;
/** 修改人 */
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
private SysUser updateBy;
/** 创建日期 */
@Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
private Date createDate;
/** 修改日期 */
@Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private Date updateDate;
/** 实际发车时间*/
private String fcsjActual;
/** 实际发车时间戳*/
@Transient
private Long fcsjActualTime;
/**实际终点时间 */
private String zdsjActual;
/** 实际终点时间戳*/
@Transient
private Long zdsjActualTime;
/**班次状态 0 未执行 1 正在执行 2 已执行 -1 已烂班 */
private int status;
/** 是否是临加班次 */
private boolean sflj;
/** 是否误点*/
private boolean isLate;
/**实际里程*/
private Float realMileage;
/** 增加公里 */
private Float addMileage;
/** 抽减公里 */
private Float remMileage;
/** 备注*/
private String remarks;
/**待发时间(格式 HH:mm) */
private String dfsj;
/**待发时间戳 */
@Transient
private Long dfsjT;
/** 指令下发状态 60: 已发送, 100: 设备确认收到, 200:驾驶员确认 0:失败 */
private Integer directiveState = -1;
/** 起点站计划到达时间 */
private String qdzArrDatejh;
/** 起点站实际到达时间 */
private String qdzArrDatesj;
/** 子任务 */
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<ChildTaskPlan> cTasks = new HashSet<>();
/** ---------------- */
/** 实际发出 */
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private RealTimeModel sjfcModel;
/** 实际到达 */
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private RealTimeModel sjddModel;
public void addRemarks(String remark){
if(StringUtils.isBlank(remark))
return;
String old = this.getRemarks();
if(StringUtils.isBlank(old))
old = "";
old += remark + ";";
this.setRemarks(old);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Date getScheduleDate() {
return scheduleDate;
}
public void setScheduleDate(Date scheduleDate) {
this.scheduleDate = scheduleDate;
}
public String getXlName() {
return xlName;
}
public void setXlName(String xlName) {
this.xlName = xlName;
}
public String getXlBm() {
return xlBm;
}
public void setXlBm(String xlBm) {
this.xlBm = xlBm;
}
public String getLpName() {
return lpName;
}
public void setLpName(String lpName) {
this.lpName = lpName;
}
public String getClZbh() {
return clZbh;
}
public void setClZbh(String clZbh) {
this.clZbh = clZbh;
}
public String getjGh() {
return jGh;
}
public void setjGh(String jGh) {
this.jGh = jGh;
}
public String getjName() {
return jName;
}
public void setjName(String jName) {
this.jName = jName;
}
public String getsGh() {
return sGh;
}
public void setsGh(String sGh) {
this.sGh = sGh;
}
public String getsName() {
return sName;
}
public void setsName(String sName) {
this.sName = sName;
}
public String getXlDir() {
return xlDir;
}
public void setXlDir(String xlDir) {
this.xlDir = xlDir;
}
public String getQdzCode() {
return qdzCode;
}
public void setQdzCode(String qdzCode) {
this.qdzCode = qdzCode;
}
public String getQdzName() {
return qdzName;
}
public void setQdzName(String qdzName) {
this.qdzName = qdzName;
}
public String getZdzCode() {
return zdzCode;
}
public void setZdzCode(String zdzCode) {
this.zdzCode = zdzCode;
}
public String getZdzName() {
return zdzName;
}
public void setZdzName(String zdzName) {
this.zdzName = zdzName;
}
public String getFcsj() {
return fcsj;
}
public void setFcsj(String fcsj) {
this.fcsj = fcsj;
}
public Long getFcsjT() {
return fcsjT;
}
public void setFcsjT(Long fcsjT) {
this.fcsjT = fcsjT;
}
public String getZdsj() {
return zdsj;
}
public void setZdsj(String zdsj) {
this.zdsj = zdsj;
}
public Long getZdsjT() {
return zdsjT;
}
public void setZdsjT(Long zdsjT) {
this.zdsjT = zdsjT;
}
public Integer getFcno() {
return fcno;
}
public void setFcno(Integer fcno) {
this.fcno = fcno;
}
public Integer getBcs() {
return bcs;
}
public void setBcs(Integer bcs) {
this.bcs = bcs;
}
public Double getJhlc() {
return jhlc;
}
public void setJhlc(Double jhlc) {
this.jhlc = jhlc;
}
public Integer getBcsj() {
return bcsj;
}
public void setBcsj(Integer bcsj) {
this.bcsj = bcsj;
}
public String getBcType() {
return bcType;
}
public void setBcType(String bcType) {
this.bcType = bcType;
}
public SysUser getCreateBy() {
return createBy;
}
public void setCreateBy(SysUser createBy) {
this.createBy = createBy;
}
public SysUser getUpdateBy() {
return updateBy;
}
public void setUpdateBy(SysUser updateBy) {
this.updateBy = updateBy;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getFcsjActual() {
return fcsjActual;
}
public void setFcsjActual(String fcsjActual) {
this.fcsjActual = fcsjActual;
}
public Long getFcsjActualTime() {
return fcsjActualTime;
}
public void setFcsjActualTime(Long fcsjActualTime) {
this.fcsjActualTime = fcsjActualTime;
}
public String getZdsjActual() {
return zdsjActual;
}
public void setZdsjActual(String zdsjActual) {
this.zdsjActual = zdsjActual;
}
public Long getZdsjActualTime() {
return zdsjActualTime;
}
public void setZdsjActualTime(Long zdsjActualTime) {
this.zdsjActualTime = zdsjActualTime;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public boolean isLate() {
return isLate;
}
public void setLate(boolean isLate) {
this.isLate = isLate;
}
public Float getRealMileage() {
return realMileage;
}
public void setRealMileage(Float realMileage) {
this.realMileage = realMileage;
}
public Float getAddMileage() {
return addMileage;
}
public void setAddMileage(Float addMileage) {
this.addMileage = addMileage;
}
public Float getRemMileage() {
return remMileage;
}
public void setRemMileage(Float remMileage) {
this.remMileage = remMileage;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getDfsj() {
return dfsj;
}
public void setDfsj(String dfsj) {
this.dfsj = dfsj;
}
public Long getDfsjT() {
return dfsjT;
}
public void setDfsjT(Long dfsjT) {
this.dfsjT = dfsjT;
}
public void setDfsjAll(Long dfsjT) {
this.dfsjT = dfsjT;
this.dfsj = sdfHHmm.format(new Date(this.dfsjT));
}
public void setDfsjAll(String dfsj) {
try {
String dfsjFull = this.realExecDate + " " + dfsj;
this.dfsjT = sdfyyyyMMddHHmm.parse(dfsjFull).getTime();
this.dfsj = dfsj;
} catch (ParseException e) {
e.printStackTrace();
}
}
@Transient
static SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
@Transient
static SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@Transient
static SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm");
/**
* @throws ParseException
*
* @Title: syncTime
* @Description: TODO(根据计发时间,计算待发时间和终点时间)
* @param 设定文件
* @return void 返回类型
* @throws
*/
public void syncTime(){
try{
this.setDfsj(this.getFcsj());
//发车时间戳
this.setFcsjT(sdfyyyyMMddHHmm.parse(this.realExecDate + " " + this.getFcsj()).getTime());
//待发时间戳
this.setDfsjT(this.getFcsjT());
//计划终点时间
if(this.getBcsj() != null){
Date zdDate = new Date(this.getFcsjT() + (this.getBcsj() * 60 * 1000));
this.setZdsjT(zdDate.getTime());
this.setZdsj(sdfHHmm.format(zdDate));
}
if(this.fcsjActual != null)
this.setFcsjActualAll(this.fcsjActual);
if(this.zdsjActual != null)
this.setZdsjActualAll(this.zdsjActual);
}catch(Exception e){
e.printStackTrace();
}
}
public Integer getDirectiveState() {
return directiveState;
}
public void setDirectiveState(Integer directiveState) {
this.directiveState = directiveState;
}
@Override
public boolean equals(Object obj) {
return this.id.equals(((ScheduleRealInfo)obj).getId());
}
public String getQdzArrDateJH() {
return qdzArrDatejh;
}
public void setQdzArrDateJH(String qdzArrDateJH) {
this.qdzArrDatejh = qdzArrDateJH;
}
public String getQdzArrDateSJ() {
return qdzArrDatesj;
}
public void setQdzArrDateSJ(String qdzArrDateSJ) {
this.qdzArrDatesj = qdzArrDateSJ;
}
public boolean isSflj() {
return sflj;
}
public void setSflj(boolean sflj) {
this.sflj = sflj;
}
/**
*
* @Title: setFcsjAll
* @Description: TODO(设置计划发车时间)
* @throws
*/
public void setFcsjAll(String fcsj){
try {
this.fcsjT = sdfyyyyMMddHHmm.parse(this.realExecDate + " " + fcsj).getTime();
this.fcsj = fcsj;
} catch (ParseException e) {
e.printStackTrace();
}
}
/**
*
* @Title: setFcsjAll
* @Description: TODO(设置计划发车时间)
* @throws
*/
public void setFcsjAll(Long fcsjT){
this.fcsjT = fcsjT;
this.fcsj = sdfHHmm.format(new Date(fcsjT));
}
/**
*
* @Title: setFcsjActualAll
* @Description: TODO(设置实际发车时间 字符串)
* @throws
*/
public void setFcsjActualAll(String fcsjActual){
try {
this.fcsjActualTime = sdfyyyyMMddHHmm.parse(this.realExecDate + " " + fcsjActual).getTime();
this.fcsjActual = fcsjActual;
this.synchroFcsj();
} catch (ParseException e) {
e.printStackTrace();
}
}
/**
*
* @Title: setFcsjActualAll
* @Description: TODO(设置实际发车时间 时间戳)
* @throws
*/
public void setFcsjActualAll(Long t){
this.fcsjActualTime = t;
this.fcsjActual = sdfHHmm.format(new Date(t));
this.synchroFcsj();
}
//和依赖班次同步发车时间
public void synchroFcsj(){
if(this.isFirstStationIsPark() || this.isParkIsFirstStation()){
ScheduleRealInfo twinsSch = this.twins;
if(null != twinsSch){
//有关联的出场班次
twinsSch.setFcsjActual(this.fcsjActual);
twinsSch.setFcsjActualTime(this.fcsjActualTime);
if(null != twinsSch.getSjfcModel())
twinsSch.getSjfcModel().setPersonTime(this.fcsjActualTime);
twinsSch.calcStatus();
}
}
}
/**
*
* @Title: setFcsjActualAll
* @Description: TODO(设置实际终点时间)
* @throws
*/
public void setZdsjActualAll(Long t){
this.zdsjActualTime = t;
this.zdsjActual = sdfHHmm.format(new Date(t));
this.synchroZdsj();
}
/**
*
* @Title: setFcsjActualAll
* @Description: TODO(设置实际终点时间)
* @throws
*/
public void setZdsjActualAll(String zdsjActual){
try {
this.zdsjActualTime = sdfyyyyMMddHHmm.parse(sdfyyyyMMdd.format(this.scheduleDate) + " " + zdsjActual).getTime();
this.zdsjActual = zdsjActual;
this.synchroZdsj();
} catch (ParseException e) {
e.printStackTrace();
}
}
//和依赖的进场班次同步终点时间
public void synchroZdsj(){
if(this.isFirstStationIsPark()){
ScheduleRealInfo twinsSch = this.twins;
if(null != twinsSch && twinsSch.getBcType().equals("in")){
//有关联的进场班次
twinsSch.setFcsjActual(this.zdsjActual);
twinsSch.setFcsjActualTime(this.zdsjActualTime);
twinsSch.calcStatus();
}
}
}
public Long getSpId() {
return spId;
}
public void setSpId(Long spId) {
this.spId = spId;
}
public String getRealExecDate() {
return realExecDate;
}
public void setRealExecDate(String realExecDate) {
this.realExecDate = realExecDate;
}
public void calcStatus() {
if(this.status == -1)
return;
this.status = 0;
if(StringUtils.isNotBlank(this.fcsjActual)){
this.status = 1;
//进出场班次并且没有终点时间的
if((this.bcType.equals("out") || this.bcType.equals("in"))
&& this.zdsj == null){
this.status = 2;
}
}
if(StringUtils.isNotBlank(this.zdsjActual))
this.status = 2;
}
public void destroy(){
this.status = -1;
}
public boolean isDestroy(){
return this.status == -1;
}
public boolean isNotDestroy(){
return this.status != -1;
}
public RealTimeModel getSjfcModel() {
return sjfcModel;
}
public void setSjfcModel(RealTimeModel sjfcModel) {
this.sjfcModel = sjfcModel;
}
public RealTimeModel getSjddModel() {
return sjddModel;
}
public void setSjddModel(RealTimeModel sjddModel) {
this.sjddModel = sjddModel;
}
public Set<ChildTaskPlan> getcTasks() {
return cTasks;
}
public void setcTasks(Set<ChildTaskPlan> cTasks) {
this.cTasks = cTasks;
}
public String getScheduleDateStr() {
return scheduleDateStr;
}
public void setScheduleDateStr(String scheduleDateStr) {
this.scheduleDateStr = scheduleDateStr;
}
public boolean isParkIsFirstStation() {
return parkIsFirstStation;
}
public void setParkIsFirstStation(boolean parkIsFirstStation) {
this.parkIsFirstStation = parkIsFirstStation;
}
public ScheduleRealInfo getTwins() {
return twins;
}
public void setTwins(ScheduleRealInfo twins) {
this.twins = twins;
}
public boolean isFirstStationIsPark() {
return firstStationIsPark;
}
public void setFirstStationIsPark(boolean firstStationIsPark) {
this.firstStationIsPark = firstStationIsPark;
}
public boolean statusTostart(){
return this.getFcsjActual() == null
&& this.getSjfcModel().getTime() != null;
}
public boolean statusToEnd(){
return this.getZdsjActual() == null
&& this.getSjddModel().getTime() != null;
}
public void revokeRealOutgo() {
//this.setStatus(0);
this.setFcsjActual(null);
this.setFcsjActualTime(null);
if(null != this.getSjfcModel())
this.getSjfcModel().resetNull();
this.calcStatus();
}
public boolean existDependent() {
return this.isFirstStationIsPark() || this.parkIsFirstStation;
}
//清除实际终点时间
public void clearZdsjActual(){
this.setZdsjActual(null);
this.setZdsjActualTime(null);
if(null != this.getSjddModel())
this.getSjddModel().resetNull();
//依赖班次
if(this.existDependent()){
ScheduleRealInfo twins = this.getTwins();
twins.setZdsjActual(null);
twins.setZdsjActualTime(null);
if(null != twins.getSjddModel())
twins.getSjddModel().resetNull();
}
}
}