SchedulePlanInfoServiceImpl.java
6.12 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
package com.bsth.service.schedule;
import com.bsth.entity.schedule.SchedulePlanInfo;
import com.bsth.repository.schedule.SchedulePlanInfoRepository;
import com.bsth.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* Created by xu on 16/6/16.
*/
@Service
public class SchedulePlanInfoServiceImpl extends BaseServiceImpl<SchedulePlanInfo, Long> implements SchedulePlanInfoService {
@Autowired
private SchedulePlanInfoRepository schedulePlanInfoRepository;
@Override
public List<GroupInfo> findGroupInfo(Integer xlid, Date scheduleDate) {
List<Object[]> groupInfos = schedulePlanInfoRepository.findGroupInfo(xlid, scheduleDate);
List<GroupInfo> groupInfoList = new ArrayList<>();
for (Object[] groupInfo : groupInfos) {
groupInfoList.add(new GroupInfo(groupInfo));
}
return groupInfoList;
}
@Override
@Transactional
public int updateGroupInfo(GroupInfoUpdate groupInfoUpdate) {
int type = groupInfoUpdate.getType();
int result = 0;
if (type == 1) {
// 换车
if (groupInfoUpdate.getUpdate().getClId() != groupInfoUpdate.getSrc().getClId()) {
result = this.schedulePlanInfoRepository.updateGroupInfo_type_1(
groupInfoUpdate.getUpdate().getClId(),
groupInfoUpdate.getUpdate().getClZbh(),
groupInfoUpdate.getSrc().getXlId(),
groupInfoUpdate.getSrc().getScheduleDate(),
groupInfoUpdate.getSrc().getLpName()
);
}
} else if (type == 2) {
// 更改出场班次1的时间
if (!groupInfoUpdate.getUpdate().getCcsj1().equals(groupInfoUpdate.getSrc().getCcsj1())) {
result = this.schedulePlanInfoRepository.updateGroupInfo_type_2_4(
groupInfoUpdate.getUpdate().getCcsj1(),
groupInfoUpdate.getSrc().getXlId(),
groupInfoUpdate.getUpdate().getScheduleDate(),
groupInfoUpdate.getSrc().getLpName(),
groupInfoUpdate.getSrc().getCcsj1(),
"out"
);
}
} else if (type == 3) {
// 更改驾驶员1
if (groupInfoUpdate.getUpdate().getJsy1Id() != groupInfoUpdate.getSrc().getJsy1Id()) {
result = this.schedulePlanInfoRepository.updateGroupInfo_type_3_5_jsy(
groupInfoUpdate.getUpdate().getJsy1Id(),
groupInfoUpdate.getUpdate().getJsy1Gh(),
groupInfoUpdate.getUpdate().getJsy1Name(),
groupInfoUpdate.getSrc().getXlId(),
groupInfoUpdate.getSrc().getScheduleDate(),
groupInfoUpdate.getSrc().getLpName(),
groupInfoUpdate.getSrc().getJsy1Id()
);
}
// 更改售票员1
if (groupInfoUpdate.getUpdate().getSpy1Id() != groupInfoUpdate.getSrc().getSpy1Id()) {
result = this.schedulePlanInfoRepository.updateGroupInfo_type_3_5_spy(
groupInfoUpdate.getUpdate().getSpy1Id(),
groupInfoUpdate.getUpdate().getSpy1Gh(),
groupInfoUpdate.getUpdate().getSpy1Name(),
groupInfoUpdate.getSrc().getXlId(),
groupInfoUpdate.getSrc().getScheduleDate(),
groupInfoUpdate.getSrc().getLpName(),
groupInfoUpdate.getSrc().getSpy1Id()
);
}
} else if (type == 4) {
// 更改出场班次2的时间
if (!groupInfoUpdate.getUpdate().getCcsj2().equals(groupInfoUpdate.getSrc().getCcsj2())) {
result = this.schedulePlanInfoRepository.updateGroupInfo_type_2_4(
groupInfoUpdate.getUpdate().getCcsj2(),
groupInfoUpdate.getSrc().getXlId(),
groupInfoUpdate.getUpdate().getScheduleDate(),
groupInfoUpdate.getSrc().getLpName(),
groupInfoUpdate.getSrc().getCcsj2(),
"out"
);
}
} else if (type == 5) {
// 更改驾驶员2
if (groupInfoUpdate.getUpdate().getJsy2Id() != groupInfoUpdate.getSrc().getJsy2Id()) {
result = this.schedulePlanInfoRepository.updateGroupInfo_type_3_5_jsy(
groupInfoUpdate.getUpdate().getJsy2Id(),
groupInfoUpdate.getUpdate().getJsy2Gh(),
groupInfoUpdate.getUpdate().getJsy2Name(),
groupInfoUpdate.getSrc().getXlId(),
groupInfoUpdate.getSrc().getScheduleDate(),
groupInfoUpdate.getSrc().getLpName(),
groupInfoUpdate.getSrc().getJsy2Id()
);
}
// 更改售票员2
if (groupInfoUpdate.getUpdate().getSpy2Id() != groupInfoUpdate.getSrc().getSpy2Id()) {
result = this.schedulePlanInfoRepository.updateGroupInfo_type_3_5_spy(
groupInfoUpdate.getUpdate().getSpy2Id(),
groupInfoUpdate.getUpdate().getSpy2Gh(),
groupInfoUpdate.getUpdate().getSpy2Name(),
groupInfoUpdate.getSrc().getXlId(),
groupInfoUpdate.getSrc().getScheduleDate(),
groupInfoUpdate.getSrc().getLpName(),
groupInfoUpdate.getSrc().getSpy2Id()
);
}
} else {
throw new RuntimeException("未知的更新类型,type=" + type);
}
return result;
}
}