SectionRouteServiceImpl.java
5.3 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
package com.bsth.service.impl;
import com.bsth.common.ResponseCode;
import com.bsth.entity.Line;
import com.bsth.entity.LsSectionRoute;
import com.bsth.entity.Section;
import com.bsth.entity.SectionRoute;
import com.bsth.entity.search.CustomerSpecs;
import com.bsth.repository.LineRepository;
import com.bsth.repository.LsSectionRouteRepository;
import com.bsth.repository.SectionRepository;
import com.bsth.repository.SectionRouteRepository;
import com.bsth.service.SectionRouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @ClassName: SectionRouteServiceImpl(路段路由service业务层实现类)
*
* @Extends : BaseService
*
* @Description: TODO(路段路由service业务层)
*
* @Author bsth@lq
*
* @Date 2016年05月03日 上午9:21:17
*
* @Version 公交调度系统BS版 0.1
*
*/
@Service
public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integer> implements SectionRouteService {
@Autowired
SectionRouteRepository sectionRouteRepository;
@Autowired
LsSectionRouteRepository lsSectionRouteRepository;
@Autowired
SectionRepository sectionRepository;
@Autowired
LineRepository lineRepository;
@Override
public Iterable<SectionRoute> list(Map<String, Object> map) {
List<Sort.Order> orders = new ArrayList<>();
orders.add(new Sort.Order(Direction.ASC, "directions"));
orders.add(new Sort.Order(Direction.ASC, "sectionrouteCode"));
return sectionRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(orders));
}
/**
* @Description :TODO(查询路段信息)
*
* @param map <line.id_eq:线路ID; directions_eq:方向>
*
* @return Map<String, Object>
*/
@Override
public List<Map<String, Object>> getSectionRoute(Map<String, Object> map) {
int lineId = map.get("line.id_eq").equals("") ? 0 : Integer.parseInt(map.get("line.id_eq").toString());
int directions = map.get("directions_eq").equals("") ? 0
: Integer.parseInt(map.get("directions_eq").toString());
List<Object[]> listObjArray = sectionRouteRepository.getSectionRoute(lineId, directions);
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
if (listObjArray.size() > 0) {
for (int i = 0; i < listObjArray.size(); i++) {
Map<String, Object> tempM = new HashMap<String, Object>();
tempM.put("sectionrouteId", listObjArray.get(i)[0]);
tempM.put("sectionrouteLine", listObjArray.get(i)[1]);
tempM.put("sectionrouteLineCode", listObjArray.get(i)[2]);
tempM.put("sectionrouteSection", listObjArray.get(i)[3]);
tempM.put("sectionrouteSectionCode", listObjArray.get(i)[4]);
tempM.put("sectionrouteCode", listObjArray.get(i)[5]);
tempM.put("sectionrouteDirections", listObjArray.get(i)[6]);
tempM.put("sectionId", listObjArray.get(i)[7]);
tempM.put("sectionCode", listObjArray.get(i)[8]);
tempM.put("sectionName", listObjArray.get(i)[9]);
tempM.put("sectionCrosesRoad", listObjArray.get(i)[10]);
tempM.put("sectionEndNode", listObjArray.get(i)[11]);
tempM.put("sectionStartNode", listObjArray.get(i)[12]);
tempM.put("sectionMiddleNode", listObjArray.get(i)[13]);
tempM.put("sectionType", listObjArray.get(i)[14]);
tempM.put("sectionCsectionVector", listObjArray.get(i)[15]);
tempM.put("sectionBsectionVector", listObjArray.get(i)[16]);
tempM.put("sectionGsectionVector", listObjArray.get(i)[17]);
tempM.put("sectionRoadCoding", listObjArray.get(i)[18]);
tempM.put("sectionDistance", listObjArray.get(i)[19]);
tempM.put("sectionTime", listObjArray.get(i)[20]);
tempM.put("sectiondbType", listObjArray.get(i)[21]);
tempM.put("sectionSpeedLimit", listObjArray.get(i)[22]);
tempM.put("destroy", listObjArray.get(i)[23]);
tempM.put("versions", listObjArray.get(i)[24]);
tempM.put("descriptions", listObjArray.get(i)[25]);
tempM.put("isRoadeSpeed", listObjArray.get(i)[26]);
resultList.add(tempM);
}
}
return resultList;
}
/**
* @Description :TODO(查询线路某方向下的上一个路段序号)
*
* @param map <lineId:线路ID; direction:方向;sectionRouteCode:路段编码>
*
* @return List<Map<String, Object>>
*/
@Override
public List<Map<String, Object>> findUpSectionRouteCode(Map<String, Object> map) {
Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString());
Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString());
Integer stationRouteCode = map.get("sectionRouteCode").equals("") ? null
: Integer.parseInt(map.get("sectionRouteCode").toString());
List<Object[]> reslutList = sectionRouteRepository.findUpSectionRouteCode(lineId, direction, stationRouteCode);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
if (reslutList.get(0) != null) {
for (int i = 0; i < reslutList.size(); i++) {
Map<String, Object> tempM = new HashMap<String, Object>();
tempM.put("sectionrouteCode", reslutList.get(i));
list.add(tempM);
}
}
return list;
}
}