Commit f046babbfe881ee1caaff7edbd12d1b385bbed51
1 parent
7d284cfb
提交services
Showing
6 changed files
with
553 additions
and
254 deletions
src/main/java/com/bsth/service/LineVersionsService.java
| ... | ... | @@ -34,6 +34,8 @@ public interface LineVersionsService extends BaseService<LineVersions, Integer> |
| 34 | 34 | |
| 35 | 35 | LineVersions findLineVersionsMax(int lineId); |
| 36 | 36 | |
| 37 | + List<LineVersions> findAllHistroyLineVersionsById(int lineId); | |
| 38 | + | |
| 37 | 39 | // 返回当前线路版本 |
| 38 | 40 | Integer findCurrentVersion(int lineId); |
| 39 | 41 | |
| ... | ... | @@ -41,4 +43,5 @@ public interface LineVersionsService extends BaseService<LineVersions, Integer> |
| 41 | 43 | |
| 42 | 44 | Map<String, Object> issueVersion(int id); |
| 43 | 45 | |
| 46 | + | |
| 44 | 47 | } | ... | ... |
src/main/java/com/bsth/service/SectionRouteService.java
| ... | ... | @@ -68,4 +68,8 @@ public interface SectionRouteService extends BaseService<SectionRoute, Integer> |
| 68 | 68 | void batchUpdate(Integer lineId, String lineCode); |
| 69 | 69 | |
| 70 | 70 | Map<String,Object> destroy(Integer id); |
| 71 | + | |
| 72 | + Map<String, Object> destroyHistory(Integer id); | |
| 73 | + | |
| 74 | + Map pageLs(Map<String, Object> map); | |
| 71 | 75 | } | ... | ... |
src/main/java/com/bsth/service/StationRouteService.java
| ... | ... | @@ -6,6 +6,9 @@ import java.util.Map; |
| 6 | 6 | |
| 7 | 7 | import javax.servlet.http.HttpServletResponse; |
| 8 | 8 | |
| 9 | +import org.springframework.data.domain.Page; | |
| 10 | +import org.springframework.data.domain.PageRequest; | |
| 11 | + | |
| 9 | 12 | import com.bsth.entity.LsStationRoute; |
| 10 | 13 | import com.bsth.entity.StationRoute; |
| 11 | 14 | import com.bsth.entity.StationRouteCache; |
| ... | ... | @@ -135,7 +138,7 @@ public interface StationRouteService extends BaseService<StationRoute, Integer> |
| 135 | 138 | |
| 136 | 139 | Map<String, Object> findByMultiLine(String lineIds); |
| 137 | 140 | |
| 138 | - Map<String, Object> updSwitchDir(String lineIds); | |
| 141 | + Map<String, Object> updSwitchDir(String lineIds,int stauts); | |
| 139 | 142 | |
| 140 | 143 | Map<String, Object> upddis(Map<String, Object> map); |
| 141 | 144 | |
| ... | ... | @@ -164,4 +167,5 @@ public interface StationRouteService extends BaseService<StationRoute, Integer> |
| 164 | 167 | |
| 165 | 168 | Map<String, Object> matchNearbyStation(Map<String, Object> map); |
| 166 | 169 | |
| 170 | + Map pageLs(Map<String, Object> map); | |
| 167 | 171 | } | ... | ... |
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
| ... | ... | @@ -221,6 +221,12 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ |
| 221 | 221 | public LineVersions findLineVersionsMax(int lineId) { |
| 222 | 222 | return repository.findLineVersionsMax(lineId); |
| 223 | 223 | } |
| 224 | + | |
| 225 | + | |
| 226 | + @Override | |
| 227 | + public List<LineVersions> findAllHistroyLineVersionsById(int lineId){ | |
| 228 | + return repository.findAllHistroyLineVersionsById(lineId); | |
| 229 | + } | |
| 224 | 230 | |
| 225 | 231 | /** |
| 226 | 232 | * 线路版本添加 |
| ... | ... | @@ -250,6 +256,73 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ |
| 250 | 256 | LineVersions upLineVersions = repository.findBylineIdAndVersions(line.getId(),versions); |
| 251 | 257 | upLineVersions.setEndDate(new java.sql.Date(startDate.getTime())); |
| 252 | 258 | repository.save(upLineVersions); |
| 259 | + | |
| 260 | + //// 先查询待更新版本 如果有需要就删除 预留.. | |
| 261 | +// List<LsSectionRoute> needDelete = lsSectionRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),versions); | |
| 262 | +// | |
| 263 | +// lsSectionRouteRepository.deleteAll(needDelete); | |
| 264 | +// | |
| 265 | +// List<LsStationRoute> needDelete2 = lsStationRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),versions); | |
| 266 | +// | |
| 267 | +// lsStationRouteRepository.deleteAll(needDelete2); | |
| 268 | + | |
| 269 | + | |
| 270 | + if(map.get("hisVersions") != null && !map.get("hisVersions").toString().isEmpty()) { | |
| 271 | + Integer hisVersion = Integer.valueOf(map.get("hisVersions").toString()); | |
| 272 | + | |
| 273 | + List<LsSectionRoute> sectionList = lsSectionRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),hisVersion); | |
| 274 | + | |
| 275 | + | |
| 276 | + for(int i =0;i<sectionList.size();i++) { | |
| 277 | + LsSectionRoute oldData = sectionList.get(i); | |
| 278 | + | |
| 279 | + LsSectionRoute newData = new LsSectionRoute(); | |
| 280 | + | |
| 281 | + newData.setIsRoadeSpeed(oldData.getIsRoadeSpeed()); | |
| 282 | + newData.setDescriptions(oldData.getDescriptions()); | |
| 283 | + newData.setLine(oldData.getLine()); | |
| 284 | + newData.setLineCode(oldData.getLineCode()); | |
| 285 | + newData.setDirections(oldData.getDirections()); | |
| 286 | + newData.setSection(oldData.getSection()); | |
| 287 | + newData.setSectionCode(oldData.getSectionCode()); | |
| 288 | + newData.setSectionrouteCode(oldData.getSectionrouteCode()); | |
| 289 | + newData.setDestroy(0); | |
| 290 | + newData.setVersions(versions); | |
| 291 | + | |
| 292 | + lsSectionRouteRepository.save(newData); | |
| 293 | + | |
| 294 | + } | |
| 295 | + | |
| 296 | + List<LsStationRoute> stationList = lsStationRouteRepository.findupdated(Integer.valueOf(map.get("lineId").toString()),map.get("lineCode").toString(),hisVersion); | |
| 297 | + | |
| 298 | + for(int i =0;i<stationList.size();i++) { | |
| 299 | + LsStationRoute oldData = stationList.get(i); | |
| 300 | + | |
| 301 | + LsStationRoute newData = new LsStationRoute(); | |
| 302 | + | |
| 303 | + newData.setLine(oldData.getLine()); | |
| 304 | + newData.setStation(oldData.getStation()); | |
| 305 | + newData.setStationName(oldData.getStationName()); | |
| 306 | + newData.setStationRouteCode(oldData.getStationRouteCode()); | |
| 307 | + newData.setLineCode(oldData.getLineCode()); | |
| 308 | + newData.setStationCode(oldData.getStationCode()); | |
| 309 | + newData.setStationMark(oldData.getStationMark()); | |
| 310 | + newData.setOutStationNmber(oldData.getOutStationNmber()); | |
| 311 | + newData.setDirections(oldData.getDirections()); | |
| 312 | + newData.setDistances(oldData.getDistances()); | |
| 313 | + newData.setToTime(oldData.getToTime()); | |
| 314 | + newData.setFirstTime(oldData.getFirstTime()); | |
| 315 | + newData.setEndTime(oldData.getEndTime()); | |
| 316 | + newData.setEndTime(oldData.getEndTime()); | |
| 317 | + newData.setDescriptions(oldData.getDescriptions()); | |
| 318 | + newData.setIndustryCode(oldData.getIndustryCode()); | |
| 319 | + newData.setDestroy(0); | |
| 320 | + newData.setVersions(versions); | |
| 321 | + | |
| 322 | + lsStationRouteRepository.save(newData); | |
| 323 | + } | |
| 324 | + | |
| 325 | + } | |
| 253 | 326 | resultMap.put("status", ResponseCode.SUCCESS); |
| 254 | 327 | } catch (ParseException e) { |
| 255 | 328 | // TODO Auto-generated catch block | ... | ... |
src/main/java/com/bsth/service/impl/SectionRouteServiceImpl.java
| ... | ... | @@ -17,10 +17,12 @@ import org.springframework.web.bind.annotation.RequestParam; |
| 17 | 17 | |
| 18 | 18 | import com.bsth.common.ResponseCode; |
| 19 | 19 | import com.bsth.entity.Line; |
| 20 | +import com.bsth.entity.LsSectionRoute; | |
| 20 | 21 | import com.bsth.entity.Section; |
| 21 | 22 | import com.bsth.entity.SectionRoute; |
| 22 | 23 | import com.bsth.entity.search.CustomerSpecs; |
| 23 | 24 | import com.bsth.repository.LineRepository; |
| 25 | +import com.bsth.repository.LsSectionRouteRepository; | |
| 24 | 26 | import com.bsth.repository.SectionRepository; |
| 25 | 27 | import com.bsth.repository.SectionRouteCacheRepository; |
| 26 | 28 | import com.bsth.repository.SectionRouteRepository; |
| ... | ... | @@ -44,25 +46,58 @@ import com.bsth.util.GetUIDAndCode; |
| 44 | 46 | */ |
| 45 | 47 | |
| 46 | 48 | @Service |
| 47 | -public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integer> implements SectionRouteService{ | |
| 48 | - | |
| 49 | +public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integer> implements SectionRouteService { | |
| 50 | + | |
| 49 | 51 | @Autowired |
| 50 | 52 | SectionRouteRepository repository; |
| 51 | - | |
| 53 | + | |
| 54 | + @Autowired | |
| 55 | + LsSectionRouteRepository lsSectionRouteRepository; | |
| 56 | + | |
| 52 | 57 | @Autowired |
| 53 | 58 | SectionRouteCacheRepository Cacherepository; |
| 54 | - | |
| 59 | + | |
| 55 | 60 | @Autowired |
| 56 | - SectionRepository repository2; | |
| 57 | - | |
| 61 | + SectionRepository repository2; | |
| 62 | + | |
| 58 | 63 | @Autowired |
| 59 | 64 | LineRepository lineRepository; |
| 60 | - | |
| 65 | + | |
| 61 | 66 | @Autowired |
| 62 | - private EntityManager entityManager; | |
| 63 | - | |
| 67 | + private EntityManager entityManager; | |
| 68 | + | |
| 64 | 69 | @Value("${hibernate.jdbc.batch_size}") |
| 65 | - private int batchSize; | |
| 70 | + private int batchSize; | |
| 71 | + | |
| 72 | + public Map pageLs(Map<String, Object> map) { | |
| 73 | + | |
| 74 | + int pageSize = 10; | |
| 75 | + int i = Integer.parseInt(map.get("page").toString()); | |
| 76 | + int line = Integer.parseInt(map.get("lineCode_eq").toString()); | |
| 77 | + int dir = Integer.parseInt(map.get("directions_eq").toString()); | |
| 78 | + int version = Integer.parseInt(map.get("version").toString()); | |
| 79 | + | |
| 80 | + int total = lsSectionRouteRepository.count(line , dir,version); | |
| 81 | + | |
| 82 | + if(total == 0) { | |
| 83 | + map.put("empty",true); | |
| 84 | + map.put("first",true); | |
| 85 | + map.put("last",true); | |
| 86 | + } | |
| 87 | + if(i == 0) { | |
| 88 | + map.put("first",true); | |
| 89 | + } | |
| 90 | + if(i == (total%pageSize == 0 ? total/pageSize : total/pageSize + 1)) { | |
| 91 | + map.put("last",true); | |
| 92 | + } | |
| 93 | + map.put("number",i*pageSize); | |
| 94 | + map.put("numberOfElements",(i+1)*pageSize); | |
| 95 | + map.put("pageSize",pageSize); | |
| 96 | + map.put("totalPages" , total%pageSize == 0 ? total/pageSize : total/pageSize + 1 ); | |
| 97 | + map.put("totalElements",total); | |
| 98 | + map.put("content" , lsSectionRouteRepository.page(i*pageSize, pageSize , line , dir,version)); | |
| 99 | + return map; | |
| 100 | + } | |
| 66 | 101 | |
| 67 | 102 | @Override |
| 68 | 103 | public Iterable<SectionRoute> list(Map<String, Object> map) { |
| ... | ... | @@ -71,62 +106,63 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 71 | 106 | orderList.add(new Sort.Order(Direction.ASC, "sectionrouteCode")); |
| 72 | 107 | return repository.findAll(new CustomerSpecs<SectionRoute>(map), new Sort(orderList)); |
| 73 | 108 | } |
| 74 | - | |
| 109 | + | |
| 75 | 110 | /** |
| 76 | 111 | * @Description :TODO(查询路段信息) |
| 77 | 112 | * |
| 78 | 113 | * @param map <line.id_eq:线路ID; directions_eq:方向> |
| 79 | 114 | * |
| 80 | - * @return Map<String, Object> | |
| 115 | + * @return Map<String, Object> | |
| 81 | 116 | */ |
| 82 | 117 | @Override |
| 83 | 118 | public List<Map<String, Object>> getSectionRoute(Map<String, Object> map) { |
| 84 | 119 | int lineId = map.get("line.id_eq").equals("") ? 0 : Integer.parseInt(map.get("line.id_eq").toString()); |
| 85 | - int directions = map.get("directions_eq").equals("") ? 0 : Integer.parseInt(map.get("directions_eq").toString()); | |
| 120 | + int directions = map.get("directions_eq").equals("") ? 0 | |
| 121 | + : Integer.parseInt(map.get("directions_eq").toString()); | |
| 86 | 122 | List<Object[]> listObjArray = repository.getSectionRoute(lineId, directions); |
| 87 | - List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); | |
| 88 | - if(listObjArray.size()>0) { | |
| 89 | - for(int i = 0 ; i<listObjArray.size() ; i++){ | |
| 123 | + List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>(); | |
| 124 | + if (listObjArray.size() > 0) { | |
| 125 | + for (int i = 0; i < listObjArray.size(); i++) { | |
| 90 | 126 | Map<String, Object> tempM = new HashMap<String, Object>(); |
| 91 | - tempM.put("sectionrouteId",listObjArray.get(i)[0]); | |
| 92 | - tempM.put("sectionrouteLine",listObjArray.get(i)[1]); | |
| 93 | - tempM.put("sectionrouteLineCode",listObjArray.get(i)[2]); | |
| 94 | - tempM.put("sectionrouteSection",listObjArray.get(i)[3]); | |
| 95 | - tempM.put("sectionrouteSectionCode",listObjArray.get(i)[4]); | |
| 96 | - tempM.put("sectionrouteCode",listObjArray.get(i)[5]); | |
| 97 | - tempM.put("sectionrouteDirections",listObjArray.get(i)[6]); | |
| 98 | - tempM.put("sectionId",listObjArray.get(i)[7]); | |
| 99 | - tempM.put("sectionCode",listObjArray.get(i)[8]); | |
| 100 | - tempM.put("sectionName",listObjArray.get(i)[9]); | |
| 101 | - tempM.put("sectionCrosesRoad",listObjArray.get(i)[10]); | |
| 102 | - tempM.put("sectionEndNode",listObjArray.get(i)[11]); | |
| 103 | - tempM.put("sectionStartNode",listObjArray.get(i)[12]); | |
| 104 | - tempM.put("sectionMiddleNode",listObjArray.get(i)[13]); | |
| 105 | - tempM.put("sectionType",listObjArray.get(i)[14]); | |
| 106 | - tempM.put("sectionCsectionVector",listObjArray.get(i)[15]); | |
| 107 | - tempM.put("sectionBsectionVector",listObjArray.get(i)[16]); | |
| 108 | - tempM.put("sectionGsectionVector",listObjArray.get(i)[17]); | |
| 109 | - tempM.put("sectionRoadCoding",listObjArray.get(i)[18]); | |
| 110 | - tempM.put("sectionDistance",listObjArray.get(i)[19]); | |
| 111 | - tempM.put("sectionTime",listObjArray.get(i)[20]); | |
| 112 | - tempM.put("sectiondbType",listObjArray.get(i)[21]); | |
| 113 | - tempM.put("sectionSpeedLimet",listObjArray.get(i)[22]); | |
| 114 | - tempM.put("destroy",listObjArray.get(i)[23]); | |
| 115 | - tempM.put("versions",listObjArray.get(i)[24]); | |
| 116 | - tempM.put("descriptions",listObjArray.get(i)[25]); | |
| 117 | - tempM.put("isRoadeSpeed",listObjArray.get(i)[26]); | |
| 127 | + tempM.put("sectionrouteId", listObjArray.get(i)[0]); | |
| 128 | + tempM.put("sectionrouteLine", listObjArray.get(i)[1]); | |
| 129 | + tempM.put("sectionrouteLineCode", listObjArray.get(i)[2]); | |
| 130 | + tempM.put("sectionrouteSection", listObjArray.get(i)[3]); | |
| 131 | + tempM.put("sectionrouteSectionCode", listObjArray.get(i)[4]); | |
| 132 | + tempM.put("sectionrouteCode", listObjArray.get(i)[5]); | |
| 133 | + tempM.put("sectionrouteDirections", listObjArray.get(i)[6]); | |
| 134 | + tempM.put("sectionId", listObjArray.get(i)[7]); | |
| 135 | + tempM.put("sectionCode", listObjArray.get(i)[8]); | |
| 136 | + tempM.put("sectionName", listObjArray.get(i)[9]); | |
| 137 | + tempM.put("sectionCrosesRoad", listObjArray.get(i)[10]); | |
| 138 | + tempM.put("sectionEndNode", listObjArray.get(i)[11]); | |
| 139 | + tempM.put("sectionStartNode", listObjArray.get(i)[12]); | |
| 140 | + tempM.put("sectionMiddleNode", listObjArray.get(i)[13]); | |
| 141 | + tempM.put("sectionType", listObjArray.get(i)[14]); | |
| 142 | + tempM.put("sectionCsectionVector", listObjArray.get(i)[15]); | |
| 143 | + tempM.put("sectionBsectionVector", listObjArray.get(i)[16]); | |
| 144 | + tempM.put("sectionGsectionVector", listObjArray.get(i)[17]); | |
| 145 | + tempM.put("sectionRoadCoding", listObjArray.get(i)[18]); | |
| 146 | + tempM.put("sectionDistance", listObjArray.get(i)[19]); | |
| 147 | + tempM.put("sectionTime", listObjArray.get(i)[20]); | |
| 148 | + tempM.put("sectiondbType", listObjArray.get(i)[21]); | |
| 149 | + tempM.put("sectionSpeedLimet", listObjArray.get(i)[22]); | |
| 150 | + tempM.put("destroy", listObjArray.get(i)[23]); | |
| 151 | + tempM.put("versions", listObjArray.get(i)[24]); | |
| 152 | + tempM.put("descriptions", listObjArray.get(i)[25]); | |
| 153 | + tempM.put("isRoadeSpeed", listObjArray.get(i)[26]); | |
| 118 | 154 | resultList.add(tempM); |
| 119 | 155 | } |
| 120 | 156 | } |
| 121 | 157 | return resultList; |
| 122 | 158 | } |
| 123 | - | |
| 159 | + | |
| 124 | 160 | /** |
| 125 | 161 | * @Description :TODO(查询缓存路段信息) |
| 126 | 162 | * |
| 127 | 163 | * @param map <line.id_eq:线路ID; directions_eq:方向> |
| 128 | 164 | * |
| 129 | - * @return Map<String, Object> | |
| 165 | + * @return Map<String, Object> | |
| 130 | 166 | */ |
| 131 | 167 | @Transactional |
| 132 | 168 | @Override |
| ... | ... | @@ -134,48 +170,47 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 134 | 170 | int lineId = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString()); |
| 135 | 171 | int directions = map.get("dir").equals("") ? 0 : Integer.parseInt(map.get("dir").toString()); |
| 136 | 172 | List<Object[]> listObjArray = Cacherepository.getSectionRouteCache(lineId, directions); |
| 137 | - List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); | |
| 138 | - if(listObjArray.size()>0) { | |
| 139 | - for(int i = 0 ; i<listObjArray.size() ; i++){ | |
| 173 | + List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>(); | |
| 174 | + if (listObjArray.size() > 0) { | |
| 175 | + for (int i = 0; i < listObjArray.size(); i++) { | |
| 140 | 176 | Map<String, Object> tempM = new HashMap<String, Object>(); |
| 141 | - tempM.put("sectionrouteId",listObjArray.get(i)[0]); | |
| 142 | - tempM.put("sectionrouteLine",listObjArray.get(i)[1]); | |
| 143 | - tempM.put("sectionrouteLineCode",listObjArray.get(i)[2]); | |
| 144 | - tempM.put("sectionrouteSection",listObjArray.get(i)[3]); | |
| 145 | - tempM.put("sectionrouteSectionCode",listObjArray.get(i)[4]); | |
| 146 | - tempM.put("sectionrouteCode",listObjArray.get(i)[5]); | |
| 147 | - tempM.put("sectionrouteDirections",listObjArray.get(i)[6]); | |
| 148 | - tempM.put("sectionId",listObjArray.get(i)[7]); | |
| 149 | - tempM.put("sectionCode",listObjArray.get(i)[8]); | |
| 150 | - tempM.put("sectionName",listObjArray.get(i)[9]); | |
| 151 | - tempM.put("sectionCrosesRoad",listObjArray.get(i)[10]); | |
| 152 | - tempM.put("sectionEndNode",listObjArray.get(i)[11]); | |
| 153 | - tempM.put("sectionStartNode",listObjArray.get(i)[12]); | |
| 154 | - tempM.put("sectionMiddleNode",listObjArray.get(i)[13]); | |
| 155 | - tempM.put("sectionType",listObjArray.get(i)[14]); | |
| 156 | - tempM.put("sectionCsectionVector",listObjArray.get(i)[15]); | |
| 157 | - tempM.put("sectionBsectionVector",listObjArray.get(i)[16]); | |
| 158 | - tempM.put("sectionGsectionVector",listObjArray.get(i)[17]); | |
| 159 | - tempM.put("sectionRoadCoding",listObjArray.get(i)[18]); | |
| 160 | - tempM.put("sectionDistance",listObjArray.get(i)[19]); | |
| 161 | - tempM.put("sectionTime",listObjArray.get(i)[20]); | |
| 162 | - tempM.put("sectiondbType",listObjArray.get(i)[21]); | |
| 163 | - tempM.put("sectionSpeedLimet",listObjArray.get(i)[22]); | |
| 164 | - tempM.put("destroy",listObjArray.get(i)[23]); | |
| 165 | - tempM.put("versions",listObjArray.get(i)[24]); | |
| 166 | - tempM.put("descriptions",listObjArray.get(i)[25]); | |
| 167 | - tempM.put("isRoadeSpeed",listObjArray.get(i)[26]); | |
| 177 | + tempM.put("sectionrouteId", listObjArray.get(i)[0]); | |
| 178 | + tempM.put("sectionrouteLine", listObjArray.get(i)[1]); | |
| 179 | + tempM.put("sectionrouteLineCode", listObjArray.get(i)[2]); | |
| 180 | + tempM.put("sectionrouteSection", listObjArray.get(i)[3]); | |
| 181 | + tempM.put("sectionrouteSectionCode", listObjArray.get(i)[4]); | |
| 182 | + tempM.put("sectionrouteCode", listObjArray.get(i)[5]); | |
| 183 | + tempM.put("sectionrouteDirections", listObjArray.get(i)[6]); | |
| 184 | + tempM.put("sectionId", listObjArray.get(i)[7]); | |
| 185 | + tempM.put("sectionCode", listObjArray.get(i)[8]); | |
| 186 | + tempM.put("sectionName", listObjArray.get(i)[9]); | |
| 187 | + tempM.put("sectionCrosesRoad", listObjArray.get(i)[10]); | |
| 188 | + tempM.put("sectionEndNode", listObjArray.get(i)[11]); | |
| 189 | + tempM.put("sectionStartNode", listObjArray.get(i)[12]); | |
| 190 | + tempM.put("sectionMiddleNode", listObjArray.get(i)[13]); | |
| 191 | + tempM.put("sectionType", listObjArray.get(i)[14]); | |
| 192 | + tempM.put("sectionCsectionVector", listObjArray.get(i)[15]); | |
| 193 | + tempM.put("sectionBsectionVector", listObjArray.get(i)[16]); | |
| 194 | + tempM.put("sectionGsectionVector", listObjArray.get(i)[17]); | |
| 195 | + tempM.put("sectionRoadCoding", listObjArray.get(i)[18]); | |
| 196 | + tempM.put("sectionDistance", listObjArray.get(i)[19]); | |
| 197 | + tempM.put("sectionTime", listObjArray.get(i)[20]); | |
| 198 | + tempM.put("sectiondbType", listObjArray.get(i)[21]); | |
| 199 | + tempM.put("sectionSpeedLimet", listObjArray.get(i)[22]); | |
| 200 | + tempM.put("destroy", listObjArray.get(i)[23]); | |
| 201 | + tempM.put("versions", listObjArray.get(i)[24]); | |
| 202 | + tempM.put("descriptions", listObjArray.get(i)[25]); | |
| 203 | + tempM.put("isRoadeSpeed", listObjArray.get(i)[26]); | |
| 168 | 204 | resultList.add(tempM); |
| 169 | 205 | } |
| 170 | 206 | } |
| 171 | 207 | return resultList; |
| 172 | 208 | } |
| 173 | - | |
| 174 | - | |
| 209 | + | |
| 175 | 210 | /** |
| 176 | 211 | * @Description : TODO(根据路段路由Id查询详情) |
| 177 | 212 | * |
| 178 | - * @param map <id:路段路由ID> | |
| 213 | + * @param map <id:路段路由ID> | |
| 179 | 214 | * |
| 180 | 215 | * @return List<Map<String, Object>> |
| 181 | 216 | */ |
| ... | ... | @@ -183,113 +218,113 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 183 | 218 | public List<Map<String, Object>> findSectionRouteInfoFormId(Map<String, Object> map) { |
| 184 | 219 | |
| 185 | 220 | // 获取线路ID |
| 186 | - Integer id = map.get("id").equals("") ? 0 : Integer.parseInt(map.get("id").toString()); | |
| 187 | - | |
| 188 | - List<Object[]> objects = repository.findSectionRouteInfoFormId(id); | |
| 189 | - | |
| 190 | - List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); | |
| 191 | - | |
| 192 | - int len = objects.size(); | |
| 193 | - | |
| 194 | - if(objects.size()>0) { | |
| 195 | - | |
| 196 | - for(int i = 0 ; i < len; i++) { | |
| 197 | - Map<String, Object> tempM = new HashMap<String,Object>(); | |
| 198 | - | |
| 199 | - tempM.put("sectionRouteId", objects.get(i)[0]); | |
| 200 | - | |
| 201 | - tempM.put("sectionRouteLineCode", objects.get(i)[1]); | |
| 202 | - | |
| 203 | - tempM.put("sectionRouteCode", objects.get(i)[2]); | |
| 204 | - | |
| 205 | - tempM.put("sectionRouteDirections", objects.get(i)[3]); | |
| 206 | - | |
| 207 | - tempM.put("sectionRouteLine", objects.get(i)[4]); | |
| 208 | - | |
| 209 | - tempM.put("sectionRouteSection", objects.get(i)[5]); | |
| 210 | - | |
| 211 | - tempM.put("sectionRouteDescriptions", objects.get(i)[6]); | |
| 212 | - | |
| 213 | - tempM.put("sectionRouteCreateBy", objects.get(i)[7]); | |
| 214 | - | |
| 215 | - tempM.put("sectionRouteCreateDate", objects.get(i)[8]); | |
| 216 | - | |
| 217 | - tempM.put("sectionRouteUpdateBy", objects.get(i)[9]); | |
| 218 | - | |
| 219 | - tempM.put("sectionRouteUpdateDate", objects.get(i)[10]); | |
| 220 | - | |
| 221 | - tempM.put("sectionRouteVersions", objects.get(i)[11]); | |
| 222 | - | |
| 223 | - tempM.put("sectionRouteDestroy", objects.get(i)[12]); | |
| 224 | - | |
| 225 | - tempM.put("sectionId", objects.get(i)[13]); | |
| 226 | - | |
| 227 | - tempM.put("sectionCode", objects.get(i)[14]); | |
| 228 | - | |
| 229 | - tempM.put("sectionName", objects.get(i)[15]); | |
| 230 | - | |
| 231 | - tempM.put("sectionRoadCoding", objects.get(i)[16]); | |
| 232 | - | |
| 233 | - tempM.put("sectionEndCode", objects.get(i)[17]); | |
| 234 | - | |
| 235 | - tempM.put("sectionStartNode", objects.get(i)[18]); | |
| 236 | - | |
| 237 | - tempM.put("sectionMiddleNode", objects.get(i)[19]); | |
| 238 | - | |
| 239 | - tempM.put("sectionType", objects.get(i)[20]); | |
| 240 | - | |
| 241 | - tempM.put("sectionCsectionVector", objects.get(i)[21]); | |
| 242 | - | |
| 243 | - tempM.put("sectionBsectionVector", objects.get(i)[22]); | |
| 244 | - | |
| 245 | - tempM.put("sectionGsectionVector", objects.get(i)[23]); | |
| 246 | - | |
| 247 | - tempM.put("sectionDistance", objects.get(i)[24]); | |
| 248 | - | |
| 249 | - tempM.put("sectionTime", objects.get(i)[25]); | |
| 250 | - | |
| 251 | - tempM.put("sectionDbtype", objects.get(i)[26]); | |
| 252 | - | |
| 253 | - tempM.put("sectionSpeedLimit", objects.get(i)[27]); | |
| 254 | - | |
| 255 | - tempM.put("sectionDescriptions", objects.get(i)[28]); | |
| 256 | - | |
| 257 | - tempM.put("sectionCreateBy", objects.get(i)[29]); | |
| 258 | - | |
| 259 | - tempM.put("sectionCreateDate", objects.get(i)[30]); | |
| 260 | - | |
| 261 | - tempM.put("sectionUpdateBy", objects.get(i)[31]); | |
| 262 | - | |
| 263 | - tempM.put("sectionUpdateDate", objects.get(i)[32]); | |
| 264 | - | |
| 265 | - tempM.put("sectionVersion", objects.get(i)[33]); | |
| 266 | - | |
| 267 | - tempM.put("isRoadeSpeed", objects.get(i)[34]); | |
| 268 | - resultList.add(tempM); | |
| 269 | - } | |
| 270 | - | |
| 271 | - } | |
| 272 | - | |
| 221 | + Integer id = map.get("id").equals("") ? 0 : Integer.parseInt(map.get("id").toString()); | |
| 222 | + | |
| 223 | + List<Object[]> objects = lsSectionRouteRepository.findSectionRouteInfoFormId(id); | |
| 224 | + | |
| 225 | + List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>(); | |
| 226 | + | |
| 227 | + int len = objects.size(); | |
| 228 | + | |
| 229 | + if (objects.size() > 0) { | |
| 230 | + | |
| 231 | + for (int i = 0; i < len; i++) { | |
| 232 | + Map<String, Object> tempM = new HashMap<String, Object>(); | |
| 233 | + | |
| 234 | + tempM.put("sectionRouteId", objects.get(i)[0]); | |
| 235 | + | |
| 236 | + tempM.put("sectionRouteLineCode", objects.get(i)[1]); | |
| 237 | + | |
| 238 | + tempM.put("sectionRouteCode", objects.get(i)[2]); | |
| 239 | + | |
| 240 | + tempM.put("sectionRouteDirections", objects.get(i)[3]); | |
| 241 | + | |
| 242 | + tempM.put("sectionRouteLine", objects.get(i)[4]); | |
| 243 | + | |
| 244 | + tempM.put("sectionRouteSection", objects.get(i)[5]); | |
| 245 | + | |
| 246 | + tempM.put("sectionRouteDescriptions", objects.get(i)[6]); | |
| 247 | + | |
| 248 | + tempM.put("sectionRouteCreateBy", objects.get(i)[7]); | |
| 249 | + | |
| 250 | + tempM.put("sectionRouteCreateDate", objects.get(i)[8]); | |
| 251 | + | |
| 252 | + tempM.put("sectionRouteUpdateBy", objects.get(i)[9]); | |
| 253 | + | |
| 254 | + tempM.put("sectionRouteUpdateDate", objects.get(i)[10]); | |
| 255 | + | |
| 256 | + tempM.put("sectionRouteVersions", objects.get(i)[11]); | |
| 257 | + | |
| 258 | + tempM.put("sectionRouteDestroy", objects.get(i)[12]); | |
| 259 | + | |
| 260 | + tempM.put("sectionId", objects.get(i)[13]); | |
| 261 | + | |
| 262 | + tempM.put("sectionCode", objects.get(i)[14]); | |
| 263 | + | |
| 264 | + tempM.put("sectionName", objects.get(i)[15]); | |
| 265 | + | |
| 266 | + tempM.put("sectionRoadCoding", objects.get(i)[16]); | |
| 267 | + | |
| 268 | + tempM.put("sectionEndCode", objects.get(i)[17]); | |
| 269 | + | |
| 270 | + tempM.put("sectionStartNode", objects.get(i)[18]); | |
| 271 | + | |
| 272 | + tempM.put("sectionMiddleNode", objects.get(i)[19]); | |
| 273 | + | |
| 274 | + tempM.put("sectionType", objects.get(i)[20]); | |
| 275 | + | |
| 276 | + tempM.put("sectionCsectionVector", objects.get(i)[21]); | |
| 277 | + | |
| 278 | + tempM.put("sectionBsectionVector", objects.get(i)[22]); | |
| 279 | + | |
| 280 | + tempM.put("sectionGsectionVector", objects.get(i)[23]); | |
| 281 | + | |
| 282 | + tempM.put("sectionDistance", objects.get(i)[24]); | |
| 283 | + | |
| 284 | + tempM.put("sectionTime", objects.get(i)[25]); | |
| 285 | + | |
| 286 | + tempM.put("sectionDbtype", objects.get(i)[26]); | |
| 287 | + | |
| 288 | + tempM.put("sectionSpeedLimit", objects.get(i)[27]); | |
| 289 | + | |
| 290 | + tempM.put("sectionDescriptions", objects.get(i)[28]); | |
| 291 | + | |
| 292 | + tempM.put("sectionCreateBy", objects.get(i)[29]); | |
| 293 | + | |
| 294 | + tempM.put("sectionCreateDate", objects.get(i)[30]); | |
| 295 | + | |
| 296 | + tempM.put("sectionUpdateBy", objects.get(i)[31]); | |
| 297 | + | |
| 298 | + tempM.put("sectionUpdateDate", objects.get(i)[32]); | |
| 299 | + | |
| 300 | + tempM.put("sectionVersion", objects.get(i)[33]); | |
| 301 | + | |
| 302 | + tempM.put("isRoadeSpeed", objects.get(i)[34]); | |
| 303 | + resultList.add(tempM); | |
| 304 | + } | |
| 305 | + | |
| 306 | + } | |
| 307 | + | |
| 273 | 308 | return resultList; |
| 274 | 309 | } |
| 275 | - | |
| 276 | - | |
| 310 | + | |
| 277 | 311 | /** |
| 278 | 312 | * @Description :TODO(查询线路某方向下的上一个路段序号) |
| 279 | 313 | * |
| 280 | 314 | * @param map <lineId:线路ID; direction:方向;sectionRouteCode:路段编码> |
| 281 | 315 | * |
| 282 | - * @return List<Map<String, Object>> | |
| 316 | + * @return List<Map<String, Object>> | |
| 283 | 317 | */ |
| 284 | 318 | @Override |
| 285 | 319 | public List<Map<String, Object>> findUpSectionRouteCode(Map<String, Object> map) { |
| 286 | 320 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); |
| 287 | 321 | Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); |
| 288 | - Integer stationRouteCode = map.get("sectionRouteCode").equals("") ? null : Integer.parseInt(map.get("sectionRouteCode").toString()); | |
| 322 | + Integer stationRouteCode = map.get("sectionRouteCode").equals("") ? null | |
| 323 | + : Integer.parseInt(map.get("sectionRouteCode").toString()); | |
| 289 | 324 | List<Object[]> reslutList = repository.findUpSectionRouteCode(lineId, direction, stationRouteCode); |
| 290 | - List<Map<String, Object>> list = new ArrayList<Map<String,Object>>(); | |
| 291 | - if(reslutList.get(0)!=null) { | |
| 292 | - for(int i = 0 ; i <reslutList.size() ;i++){ | |
| 325 | + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | |
| 326 | + if (reslutList.get(0) != null) { | |
| 327 | + for (int i = 0; i < reslutList.size(); i++) { | |
| 293 | 328 | Map<String, Object> tempM = new HashMap<String, Object>(); |
| 294 | 329 | tempM.put("sectionrouteCode", reslutList.get(i)); |
| 295 | 330 | list.add(tempM); |
| ... | ... | @@ -297,16 +332,17 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 297 | 332 | } |
| 298 | 333 | return list; |
| 299 | 334 | } |
| 300 | - | |
| 335 | + | |
| 301 | 336 | @Override |
| 302 | 337 | public List<Map<String, Object>> findCacheUpSectionRouteCode(Map<String, Object> map) { |
| 303 | 338 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); |
| 304 | 339 | Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); |
| 305 | - Integer stationRouteCode = map.get("sectionRouteCode").equals("") ? null : Integer.parseInt(map.get("sectionRouteCode").toString()); | |
| 340 | + Integer stationRouteCode = map.get("sectionRouteCode").equals("") ? null | |
| 341 | + : Integer.parseInt(map.get("sectionRouteCode").toString()); | |
| 306 | 342 | List<Object[]> reslutList = Cacherepository.findCacheUpSectionRouteCode(lineId, direction, stationRouteCode); |
| 307 | - List<Map<String, Object>> list = new ArrayList<Map<String,Object>>(); | |
| 308 | - if(reslutList.get(0)!=null) { | |
| 309 | - for(int i = 0 ; i <reslutList.size() ;i++){ | |
| 343 | + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | |
| 344 | + if (reslutList.get(0) != null) { | |
| 345 | + for (int i = 0; i < reslutList.size(); i++) { | |
| 310 | 346 | Map<String, Object> tempM = new HashMap<String, Object>(); |
| 311 | 347 | tempM.put("sectionrouteCode", reslutList.get(i)); |
| 312 | 348 | list.add(tempM); |
| ... | ... | @@ -319,57 +355,121 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 319 | 355 | public Map<String, Object> quoteSection(Map<String, Object> map) { |
| 320 | 356 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 321 | 357 | try { |
| 322 | - Integer line = map.get("lineId") ==null ? null : Integer.parseInt(map.get("lineId").toString()); | |
| 323 | - Integer dir = map.get("dir")==null ? null : Integer.parseInt(map.get("dir").toString()); | |
| 324 | - Integer toDir = map.get("toDir")==null ? null : Integer.parseInt(map.get("toDir").toString()); | |
| 325 | - if(line!=null && dir!=null) { | |
| 326 | - List<Object[]> list = repository.getSectionRoute(line, dir); | |
| 327 | - int src = repository.sectionRouteCodeMaxId(); | |
| 328 | - for(int i = 0 ; i<list.size() ; i++) { | |
| 329 | - /*int sectionId = Integer.parseInt(String.valueOf(repository2.sectionMaxId())) + 1 ;*/ | |
| 330 | - long sectionMaxId = GetUIDAndCode.getSectionId(); | |
| 331 | - String sectionCode = String.valueOf(sectionMaxId); | |
| 332 | - int sectionId = (int)sectionMaxId; | |
| 333 | - String sectionName = list.get(i)[9] == null ? null : list.get(i)[9].toString(); | |
| 334 | - String crosesRoad = list.get(i)[10] == null ? null : list.get(i)[10].toString(); | |
| 335 | - String endNode = list.get(i)[11] == null ? null : list.get(i)[11].toString(); | |
| 336 | - String startNode = list.get(i)[12] == null ? null : list.get(i)[12].toString(); | |
| 337 | - String middleNode = list.get(i)[13] == null ? null : list.get(i)[13].toString(); | |
| 338 | - String sectionType = list.get(i)[14] == null ? null : list.get(i)[14].toString(); | |
| 339 | - String csectionVector = list.get(i)[15] == null ? null : list.get(i)[15].toString(); | |
| 340 | - String bsectionVector = list.get(i)[16] == null ? null : list.get(i)[16].toString(); | |
| 341 | - String gsectionVector = list.get(i)[17] == null ? null : list.get(i)[17].toString(); | |
| 342 | - String roadCoding = list.get(i)[18] == null ? null : list.get(i)[18].toString(); | |
| 343 | - Double sectionDistance = list.get(i)[19] == null ? null : Double.parseDouble(list.get(i)[19].toString()); | |
| 344 | - Double sectionTime = list.get(i)[20] == null ? null : Double.parseDouble(list.get(i)[20].toString()); | |
| 345 | - String dbType = list.get(i)[21] == null ? null : list.get(i)[21].toString(); | |
| 346 | - Double speedLimit = list.get(i)[22] == null ? null : Double.parseDouble(list.get(i)[22].toString()); | |
| 347 | - Integer destroy = list.get(i)[23] == null ? null : Integer.parseInt(list.get(i)[23].toString()); | |
| 348 | - Integer versions = list.get(i)[24] == null ? null : Integer.parseInt(list.get(i)[24].toString()); | |
| 349 | - String descriptions = list.get(i)[25] == null ? null : list.get(i)[25].toString(); | |
| 350 | - repository2.systemSave(sectionCode, | |
| 351 | - sectionName, crosesRoad, endNode, startNode, middleNode, | |
| 352 | - gsectionVector, bsectionVector, | |
| 353 | - sectionType, csectionVector, roadCoding, | |
| 354 | - sectionDistance, sectionTime, dbType, speedLimit, descriptions, versions, sectionId); | |
| 355 | - // int sectionRouteId = Integer.parseInt(String.valueOf(repository.sectionRouteMaxId())) + 1 ; | |
| 356 | - SectionRoute sr = new SectionRoute(); | |
| 357 | - Line lineObject = lineRepository.findById(line).get(); | |
| 358 | - Section section = repository2.findById(sectionId).get(); | |
| 359 | - Integer xh = (src == 0 ? (toDir ==1? (list.size()-i)*10 : (list.size()+i)*10) : toDir==1? (src + (list.size()-i)*10) : (src + (list.size()+i)*10)) ; | |
| 360 | - // sr.setId(sectionRouteId); | |
| 361 | - sr.setSectionrouteCode(xh); | |
| 362 | - sr.setLineCode(lineObject.getLineCode()); | |
| 363 | - sr.setSectionCode(sectionCode); | |
| 364 | - sr.setDirections(toDir); | |
| 365 | - sr.setVersions(versions); | |
| 366 | - sr.setDestroy(destroy); | |
| 367 | - sr.setLine(lineObject); | |
| 368 | - sr.setSection(section); | |
| 369 | - sr.setSectionCode(section.getSectionCode()); | |
| 370 | - sr.setDescriptions(descriptions); | |
| 371 | - sr.setIsRoadeSpeed(1); | |
| 372 | - repository.save(sr); | |
| 358 | + Integer line = map.get("lineId") == null ? null : Integer.parseInt(map.get("lineId").toString()); | |
| 359 | + Integer dir = map.get("dir") == null ? null : Integer.parseInt(map.get("dir").toString()); | |
| 360 | + Integer toDir = map.get("toDir") == null ? null : Integer.parseInt(map.get("toDir").toString()); | |
| 361 | + Integer status = map.get("status") == null ? null : Integer.parseInt(map.get("status").toString()); | |
| 362 | + if (line != null && dir != null) { | |
| 363 | + if (status == null || status == 1) { | |
| 364 | + List<Object[]> list = repository.getSectionRoute(line, dir); | |
| 365 | + int src = repository.sectionRouteCodeMaxId(); | |
| 366 | + for (int i = 0; i < list.size(); i++) { | |
| 367 | + /* | |
| 368 | + * int sectionId = Integer.parseInt(String.valueOf(repository2.sectionMaxId())) | |
| 369 | + * + 1 ; | |
| 370 | + */ | |
| 371 | + long sectionMaxId = GetUIDAndCode.getSectionId(); | |
| 372 | + String sectionCode = String.valueOf(sectionMaxId); | |
| 373 | + int sectionId = (int) sectionMaxId; | |
| 374 | + String sectionName = list.get(i)[9] == null ? null : list.get(i)[9].toString(); | |
| 375 | + String crosesRoad = list.get(i)[10] == null ? null : list.get(i)[10].toString(); | |
| 376 | + String endNode = list.get(i)[11] == null ? null : list.get(i)[11].toString(); | |
| 377 | + String startNode = list.get(i)[12] == null ? null : list.get(i)[12].toString(); | |
| 378 | + String middleNode = list.get(i)[13] == null ? null : list.get(i)[13].toString(); | |
| 379 | + String sectionType = list.get(i)[14] == null ? null : list.get(i)[14].toString(); | |
| 380 | + String csectionVector = list.get(i)[15] == null ? null : list.get(i)[15].toString(); | |
| 381 | + String bsectionVector = list.get(i)[16] == null ? null : list.get(i)[16].toString(); | |
| 382 | + String gsectionVector = list.get(i)[17] == null ? null : list.get(i)[17].toString(); | |
| 383 | + String roadCoding = list.get(i)[18] == null ? null : list.get(i)[18].toString(); | |
| 384 | + Double sectionDistance = list.get(i)[19] == null ? null | |
| 385 | + : Double.parseDouble(list.get(i)[19].toString()); | |
| 386 | + Double sectionTime = list.get(i)[20] == null ? null | |
| 387 | + : Double.parseDouble(list.get(i)[20].toString()); | |
| 388 | + String dbType = list.get(i)[21] == null ? null : list.get(i)[21].toString(); | |
| 389 | + Double speedLimit = list.get(i)[22] == null ? null | |
| 390 | + : Double.parseDouble(list.get(i)[22].toString()); | |
| 391 | + Integer destroy = list.get(i)[23] == null ? null : Integer.parseInt(list.get(i)[23].toString()); | |
| 392 | + Integer versions = list.get(i)[24] == null ? null | |
| 393 | + : Integer.parseInt(list.get(i)[24].toString()); | |
| 394 | + String descriptions = list.get(i)[25] == null ? null : list.get(i)[25].toString(); | |
| 395 | + repository2.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode, middleNode, | |
| 396 | + gsectionVector, bsectionVector, sectionType, csectionVector, roadCoding, | |
| 397 | + sectionDistance, sectionTime, dbType, speedLimit, descriptions, versions, sectionId); | |
| 398 | + int sectionRouteId = Integer.parseInt(String.valueOf(repository.sectionRouteMaxId())) + 1 ; | |
| 399 | + SectionRoute sr = new SectionRoute(); | |
| 400 | + Line lineObject = lineRepository.findById(line).get(); | |
| 401 | + Section section = repository2.findById(sectionId).get(); | |
| 402 | + Integer xh = (src == 0 ? (toDir == 1 ? (list.size() - i) * 10 : (list.size() + i) * 10) | |
| 403 | + : toDir == 1 ? (src + (list.size() - i) * 10) : (src + (list.size() + i) * 10)); | |
| 404 | + sr.setId(sectionRouteId); | |
| 405 | + sr.setSectionrouteCode(xh); | |
| 406 | + sr.setLineCode(lineObject.getLineCode()); | |
| 407 | + sr.setSectionCode(sectionCode); | |
| 408 | + sr.setDirections(toDir); | |
| 409 | + sr.setVersions(versions); | |
| 410 | + sr.setDestroy(destroy); | |
| 411 | + sr.setLine(lineObject); | |
| 412 | + sr.setSection(section); | |
| 413 | + sr.setSectionCode(section.getSectionCode()); | |
| 414 | + sr.setDescriptions(descriptions); | |
| 415 | + sr.setIsRoadeSpeed(1); | |
| 416 | + repository.save(sr); | |
| 417 | + } | |
| 418 | + } else if (status == 2) { | |
| 419 | + List<Object[]> list = lsSectionRouteRepository.getSectionRoute(line, dir); | |
| 420 | + int src = lsSectionRouteRepository.sectionRouteCodeMaxId(); | |
| 421 | + for (int i = 0; i < list.size(); i++) { | |
| 422 | + /* | |
| 423 | + * int sectionId = Integer.parseInt(String.valueOf(repository2.sectionMaxId())) | |
| 424 | + * + 1 ; | |
| 425 | + */ | |
| 426 | + long sectionMaxId = GetUIDAndCode.getSectionId(); | |
| 427 | + String sectionCode = String.valueOf(sectionMaxId); | |
| 428 | + int sectionId = (int) sectionMaxId; | |
| 429 | + String sectionName = list.get(i)[9] == null ? null : list.get(i)[9].toString(); | |
| 430 | + String crosesRoad = list.get(i)[10] == null ? null : list.get(i)[10].toString(); | |
| 431 | + String endNode = list.get(i)[11] == null ? null : list.get(i)[11].toString(); | |
| 432 | + String startNode = list.get(i)[12] == null ? null : list.get(i)[12].toString(); | |
| 433 | + String middleNode = list.get(i)[13] == null ? null : list.get(i)[13].toString(); | |
| 434 | + String sectionType = list.get(i)[14] == null ? null : list.get(i)[14].toString(); | |
| 435 | + String csectionVector = list.get(i)[15] == null ? null : list.get(i)[15].toString(); | |
| 436 | + String bsectionVector = list.get(i)[16] == null ? null : list.get(i)[16].toString(); | |
| 437 | + String gsectionVector = list.get(i)[17] == null ? null : list.get(i)[17].toString(); | |
| 438 | + String roadCoding = list.get(i)[18] == null ? null : list.get(i)[18].toString(); | |
| 439 | + Double sectionDistance = list.get(i)[19] == null ? null | |
| 440 | + : Double.parseDouble(list.get(i)[19].toString()); | |
| 441 | + Double sectionTime = list.get(i)[20] == null ? null | |
| 442 | + : Double.parseDouble(list.get(i)[20].toString()); | |
| 443 | + String dbType = list.get(i)[21] == null ? null : list.get(i)[21].toString(); | |
| 444 | + Double speedLimit = list.get(i)[22] == null ? null | |
| 445 | + : Double.parseDouble(list.get(i)[22].toString()); | |
| 446 | + Integer destroy = list.get(i)[23] == null ? null : Integer.parseInt(list.get(i)[23].toString()); | |
| 447 | + Integer versions = list.get(i)[24] == null ? null | |
| 448 | + : Integer.parseInt(list.get(i)[24].toString()); | |
| 449 | + String descriptions = list.get(i)[25] == null ? null : list.get(i)[25].toString(); | |
| 450 | + repository2.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode, middleNode, | |
| 451 | + gsectionVector, bsectionVector, sectionType, csectionVector, roadCoding, | |
| 452 | + sectionDistance, sectionTime, dbType, speedLimit, descriptions, versions, sectionId); | |
| 453 | + int sectionRouteId = Integer.parseInt(String.valueOf(repository.sectionRouteMaxId())) + 1 ; | |
| 454 | + LsSectionRoute sr = new LsSectionRoute(); | |
| 455 | + Line lineObject = lineRepository.findById(line).get(); | |
| 456 | + Section section = repository2.findById(sectionId).get(); | |
| 457 | + Integer xh = (src == 0 ? (toDir == 1 ? (list.size() - i) * 10 : (list.size() + i) * 10) | |
| 458 | + : toDir == 1 ? (src + (list.size() - i) * 10) : (src + (list.size() + i) * 10)); | |
| 459 | + sr.setId(sectionRouteId); | |
| 460 | + sr.setSectionrouteCode(xh); | |
| 461 | + sr.setLineCode(lineObject.getLineCode()); | |
| 462 | + sr.setSectionCode(sectionCode); | |
| 463 | + sr.setDirections(toDir); | |
| 464 | + sr.setVersions(versions); | |
| 465 | + sr.setDestroy(destroy); | |
| 466 | + sr.setLine(lineObject); | |
| 467 | + sr.setSection(section); | |
| 468 | + sr.setSectionCode(section.getSectionCode()); | |
| 469 | + sr.setDescriptions(descriptions); | |
| 470 | + sr.setIsRoadeSpeed(1); | |
| 471 | + lsSectionRouteRepository.save(sr); | |
| 472 | + } | |
| 373 | 473 | } |
| 374 | 474 | } |
| 375 | 475 | resultMap.put("status", ResponseCode.SUCCESS); |
| ... | ... | @@ -379,22 +479,27 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 379 | 479 | } |
| 380 | 480 | return resultMap; |
| 381 | 481 | } |
| 382 | - | |
| 482 | + | |
| 383 | 483 | /** |
| 384 | 484 | * @Description : TODO(根据路段路由Id批量撤销路段) |
| 385 | 485 | * |
| 386 | - * @param map <id:路段路由ID> | |
| 486 | + * @param map <id:路段路由ID> | |
| 387 | 487 | */ |
| 388 | 488 | @Override |
| 389 | 489 | @Transactional |
| 390 | 490 | public Map<String, Object> updateSectionRouteInfoFormId(Map<String, Object> map) { |
| 391 | 491 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 392 | 492 | try { |
| 393 | - //int i = 0; | |
| 394 | - String[] idsStr = map.get("ids").toString().split(",") ; | |
| 395 | - for (String id : idsStr) { | |
| 396 | - repository.sectionRouteIsDestroyUpdBatch(Integer.parseInt(id)); | |
| 397 | - } | |
| 493 | + // int i = 0; | |
| 494 | + String[] idsStr = map.get("ids").toString().split(","); | |
| 495 | + for (String id : idsStr) { | |
| 496 | + | |
| 497 | + if (map.get("status") == null || Integer.parseInt(map.get("status").toString()) == 1) { | |
| 498 | + repository.sectionRouteIsDestroyUpdBatch(Integer.parseInt(id)); | |
| 499 | + } else if (Integer.parseInt(map.get("status").toString()) == 2) { | |
| 500 | + lsSectionRouteRepository.deleteById(Integer.parseInt(id)); | |
| 501 | + } | |
| 502 | + } | |
| 398 | 503 | resultMap.put("status", ResponseCode.SUCCESS); |
| 399 | 504 | } catch (Exception e) { |
| 400 | 505 | resultMap.put("status", ResponseCode.ERROR); |
| ... | ... | @@ -402,19 +507,31 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 402 | 507 | } |
| 403 | 508 | return resultMap; |
| 404 | 509 | } |
| 405 | - | |
| 510 | + | |
| 406 | 511 | // 更具线路批量撤销 |
| 407 | 512 | @Override |
| 408 | 513 | public void batchUpdate(Integer lineId, String lineCode) { |
| 409 | - repository.batchUpdate(lineId,lineCode); | |
| 514 | + repository.batchUpdate(lineId, lineCode); | |
| 410 | 515 | } |
| 411 | 516 | |
| 412 | - | |
| 517 | + @Override | |
| 518 | + @Transactional | |
| 519 | + public Map<String, Object> destroyHistory(Integer id) { | |
| 520 | + Map<String, Object> resultMap = new HashMap<String, Object>(); | |
| 521 | + try { | |
| 522 | + lsSectionRouteRepository.deleteById(id); | |
| 523 | + resultMap.put("status", ResponseCode.SUCCESS); | |
| 524 | + } catch (Exception e) { | |
| 525 | + resultMap.put("status", ResponseCode.ERROR); | |
| 526 | + logger.error("save erro.", e); | |
| 527 | + } | |
| 528 | + return resultMap; | |
| 529 | + } | |
| 413 | 530 | |
| 414 | 531 | /** |
| 415 | 532 | * @Description : TODO(根据路段路由Id批量撤销路段) |
| 416 | 533 | * |
| 417 | - * @param id <id:路段路由ID> | |
| 534 | + * @param id <id:路段路由ID> | |
| 418 | 535 | */ |
| 419 | 536 | @Override |
| 420 | 537 | @Transactional | ... | ... |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| ... | ... | @@ -9,6 +9,7 @@ import com.bsth.entity.StationRoute; |
| 9 | 9 | import com.bsth.entity.StationRouteCache; |
| 10 | 10 | import com.bsth.entity.search.CustomerSpecs; |
| 11 | 11 | import com.bsth.repository.LineRepository; |
| 12 | +import com.bsth.repository.LsSectionRouteRepository; | |
| 12 | 13 | import com.bsth.repository.LsStationRouteRepository; |
| 13 | 14 | import com.bsth.repository.SectionRouteRepository; |
| 14 | 15 | import com.bsth.repository.StationRepository; |
| ... | ... | @@ -28,6 +29,8 @@ import com.bsth.util.db.DBUtils_station; |
| 28 | 29 | import com.google.common.base.Splitter; |
| 29 | 30 | import org.apache.commons.lang3.StringUtils; |
| 30 | 31 | import org.springframework.beans.factory.annotation.Autowired; |
| 32 | +import org.springframework.data.domain.Page; | |
| 33 | +import org.springframework.data.domain.PageRequest; | |
| 31 | 34 | import org.springframework.data.domain.Sort; |
| 32 | 35 | import org.springframework.data.domain.Sort.Direction; |
| 33 | 36 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -88,12 +91,48 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 88 | 91 | @Autowired |
| 89 | 92 | private LsStationRouteRepository lsStationRouteRepository; |
| 90 | 93 | |
| 94 | + @Autowired | |
| 95 | + private LsSectionRouteRepository lsSectionRouteRepository; | |
| 96 | + | |
| 91 | 97 | public Iterable<LsStationRoute> list_ls(Map<String, Object> map) { |
| 92 | 98 | List<Sort.Order> orderList = new ArrayList<>(); |
| 93 | 99 | orderList.add(new Sort.Order(Direction.ASC, "directions")); |
| 94 | 100 | orderList.add(new Sort.Order(Direction.ASC, "stationRouteCode")); |
| 95 | 101 | return lsStationRouteRepository.findAll(new CustomerSpecs<LsStationRoute>(map), new Sort(orderList)); |
| 96 | 102 | } |
| 103 | + | |
| 104 | + | |
| 105 | + public Map pageLs(Map<String, Object> map) { | |
| 106 | + | |
| 107 | + int pageSize = 10; | |
| 108 | + int i = Integer.parseInt(map.get("page").toString()); | |
| 109 | + int line = Integer.parseInt(map.get("lineCode_eq").toString()); | |
| 110 | + int dir = Integer.parseInt(map.get("directions_eq").toString()); | |
| 111 | + int version = Integer.parseInt(map.get("version").toString()); | |
| 112 | + | |
| 113 | + int total = lsStationRouteRepository.count(line , dir,version); | |
| 114 | + | |
| 115 | + if(total == 0) { | |
| 116 | + map.put("empty",true); | |
| 117 | + map.put("first",true); | |
| 118 | + map.put("last",true); | |
| 119 | + } | |
| 120 | + if(i == 0) { | |
| 121 | + map.put("first",true); | |
| 122 | + } | |
| 123 | + if(i == (total%pageSize == 0 ? total/pageSize : total/pageSize + 1)) { | |
| 124 | + map.put("last",true); | |
| 125 | + } | |
| 126 | + map.put("number",i*pageSize); | |
| 127 | + map.put("numberOfElements",(i+1)*pageSize); | |
| 128 | + map.put("pageSize",pageSize); | |
| 129 | + map.put("totalPages" , total%pageSize == 0 ? total/pageSize : total/pageSize + 1 ); | |
| 130 | + map.put("totalElements",total); | |
| 131 | + map.put("content" , lsStationRouteRepository.page(i*pageSize, pageSize , line , dir,version)); | |
| 132 | + return map; | |
| 133 | + } | |
| 134 | + | |
| 135 | + | |
| 97 | 136 | |
| 98 | 137 | @Override |
| 99 | 138 | public Iterable<StationRoute> list(Map<String, Object> map) { |
| ... | ... | @@ -178,7 +217,11 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 178 | 217 | try { |
| 179 | 218 | String[] idsStr = map.get("ids").toString().split(",") ; |
| 180 | 219 | for (String id : idsStr) { |
| 181 | - repository.stationRouteIsDestroyUpdBatch(Integer.parseInt(id)); | |
| 220 | + if(map.get("status") == null || Integer.parseInt(map.get("status").toString()) == 1) { | |
| 221 | + repository.stationRouteIsDestroyUpdBatch(Integer.parseInt(id)); | |
| 222 | + }else if(Integer.parseInt(map.get("status").toString()) == 2){ | |
| 223 | + lsStationRouteRepository.deleteById(Integer.parseInt(id)); | |
| 224 | + } | |
| 182 | 225 | } |
| 183 | 226 | resultMap.put("status", ResponseCode.SUCCESS); |
| 184 | 227 | } catch (Exception e) { |
| ... | ... | @@ -204,12 +247,26 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 204 | 247 | // 方向 |
| 205 | 248 | Integer directions = map.get("directions_eq").equals("") ? null : Integer.parseInt(map.get("directions_eq").toString()); |
| 206 | 249 | |
| 207 | - // 查询站点 | |
| 208 | - List<Object[]> stationList = repository.findPoints(line, directions); | |
| 250 | + List<Object[]> stationList; | |
| 251 | + List<Object[]> sectionList; | |
| 209 | 252 | |
| 210 | - // 查询路段 | |
| 211 | - List<Object[]> sectionList = routeRepository.getSectionRoute(line, directions); | |
| 212 | 253 | |
| 254 | + if(map.get("version")!= null && !map.get("version").toString().isEmpty()) { | |
| 255 | + | |
| 256 | + Integer versions = Integer.parseInt(map.get("version").toString()); | |
| 257 | + | |
| 258 | + stationList = lsStationRouteRepository.findPoints(line, directions,versions); | |
| 259 | + | |
| 260 | + sectionList = lsSectionRouteRepository.getSectionRoute(line, directions,versions); | |
| 261 | + | |
| 262 | + }else { | |
| 263 | + | |
| 264 | + stationList = repository.findPoints(line, directions); | |
| 265 | + | |
| 266 | + sectionList = routeRepository.getSectionRoute(line, directions); | |
| 267 | + } | |
| 268 | + | |
| 269 | + | |
| 213 | 270 | return treeListMap(stationList,sectionList); |
| 214 | 271 | } |
| 215 | 272 | |
| ... | ... | @@ -674,7 +731,19 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 674 | 731 | public List<Map<String, Object>> getStationRouteList(Map<String, Object> map) { |
| 675 | 732 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); |
| 676 | 733 | Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); |
| 677 | - List<Object[]> objects = repository.getStationRouteList(lineId, direction); | |
| 734 | + List<Object[]> objects; | |
| 735 | + if(map.get("version")!= null && !map.get("version").toString().isEmpty()) { | |
| 736 | + | |
| 737 | + Integer versions = Integer.parseInt(map.get("version").toString()); | |
| 738 | + | |
| 739 | + objects = lsStationRouteRepository.getStationRouteList(lineId, direction,versions); | |
| 740 | + | |
| 741 | + | |
| 742 | + }else { | |
| 743 | + | |
| 744 | + objects = repository.getStationRouteList(lineId, direction); | |
| 745 | + } | |
| 746 | + | |
| 678 | 747 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); |
| 679 | 748 | |
| 680 | 749 | int len = objects.size(); |
| ... | ... | @@ -743,7 +812,14 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 743 | 812 | |
| 744 | 813 | Integer destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString()); |
| 745 | 814 | |
| 746 | - repository.stationRouteIsDestroyUpd(stationRouteId, destroy); | |
| 815 | + if(map.get("status") == null || Integer.parseInt(map.get("status").toString()) == 1) { | |
| 816 | + repository.stationRouteIsDestroyUpd(stationRouteId, destroy); | |
| 817 | + }else if(Integer.parseInt(map.get("status").toString()) == 2){ | |
| 818 | + lsStationRouteRepository.deleteById(stationRouteId); | |
| 819 | + }else { | |
| 820 | + resultMap.put("status", ResponseCode.ERROR); | |
| 821 | + } | |
| 822 | + | |
| 747 | 823 | |
| 748 | 824 | resultMap.put("status", ResponseCode.SUCCESS); |
| 749 | 825 | |
| ... | ... | @@ -1202,7 +1278,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1202 | 1278 | // 获取线路ID |
| 1203 | 1279 | Integer id = map.get("id").equals("") ? 0 : Integer.parseInt(map.get("id").toString()); |
| 1204 | 1280 | |
| 1205 | - List<Object[]> objects = repository.findStationRouteInfo(id); | |
| 1281 | + List<Object[]> objects = lsStationRouteRepository.findStationRouteInfo(id); | |
| 1206 | 1282 | |
| 1207 | 1283 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); |
| 1208 | 1284 | |
| ... | ... | @@ -1261,14 +1337,20 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1261 | 1337 | |
| 1262 | 1338 | @Override |
| 1263 | 1339 | @Transactional |
| 1264 | - public Map<String, Object> updSwitchDir(String lineIds) { | |
| 1340 | + public Map<String, Object> updSwitchDir(String lineIds,int status) { | |
| 1265 | 1341 | Map<String, Object> rs = new HashMap<>(); |
| 1266 | 1342 | try{ |
| 1267 | 1343 | if(lineIds!=null && lineIds !="") { |
| 1268 | 1344 | Integer lineId = Integer.parseInt(lineIds); |
| 1269 | 1345 | // 上行站点切换到下行. |
| 1270 | - repository.stationRouteDir(lineId); | |
| 1271 | - routeRepository.sectionRouteDir(lineId); | |
| 1346 | + | |
| 1347 | + if(status == 0 || status == 1) { | |
| 1348 | + repository.stationRouteDir(lineId); | |
| 1349 | + routeRepository.sectionRouteDir(lineId); | |
| 1350 | + }else if(status == 2) { | |
| 1351 | + lsStationRouteRepository.stationRouteDir(lineId); | |
| 1352 | + lsSectionRouteRepository.sectionRouteDir(lineId); | |
| 1353 | + } | |
| 1272 | 1354 | } |
| 1273 | 1355 | rs.put("status", ResponseCode.SUCCESS); |
| 1274 | 1356 | }catch(Exception e){ |
| ... | ... | @@ -1283,12 +1365,24 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1283 | 1365 | public Map<String, Object> upddis(Map<String, Object> map) { |
| 1284 | 1366 | Map<String, Object> rs = new HashMap<>(); |
| 1285 | 1367 | try{ |
| 1368 | + | |
| 1369 | + Integer status = map.get("status") == null ? null : Integer.parseInt(map.get("status").toString()); | |
| 1370 | + | |
| 1371 | + if(status != null) { | |
| 1372 | + map.remove("status"); | |
| 1373 | + } | |
| 1374 | + | |
| 1286 | 1375 | Iterator it = map.entrySet().iterator(); |
| 1287 | 1376 | while(it.hasNext()){ |
| 1288 | 1377 | java.util.Map.Entry entry = (java.util.Map.Entry)it.next(); |
| 1289 | 1378 | Integer id = Integer.parseInt(entry.getKey().toString().split("_")[1]); //返回对应的键 |
| 1290 | 1379 | Double dis = Double.parseDouble(entry.getValue().toString()) / 1000; //返回对应的值 |
| 1291 | - repository.upddis(id, dis); | |
| 1380 | + | |
| 1381 | + if( status == 1) { | |
| 1382 | + repository.upddis(id, dis); | |
| 1383 | + }else if(status == 2) { | |
| 1384 | + lsStationRouteRepository.upddis(id, dis); | |
| 1385 | + } | |
| 1292 | 1386 | } |
| 1293 | 1387 | rs.put("status", ResponseCode.SUCCESS); |
| 1294 | 1388 | }catch(Exception e){ |
| ... | ... | @@ -1445,7 +1539,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1445 | 1539 | Line line = lineRepository.findById(lineId).get(); |
| 1446 | 1540 | String lineName = line.getName(); |
| 1447 | 1541 | String shanghaiCode = (line.getShanghaiLinecode() == null || line.getShanghaiLinecode().equals(""))?"0":line.getShanghaiLinecode(); |
| 1448 | - List<StationRoute> lists = repository.findByLine(lineId,dir); | |
| 1542 | + List<LsStationRoute> lists = lsStationRouteRepository.findByLine(lineId,dir); | |
| 1449 | 1543 | rsMap.put("station",lists); |
| 1450 | 1544 | |
| 1451 | 1545 | List<StationMatchData> listMD = new ArrayList<>(); |
| ... | ... | @@ -1520,7 +1614,11 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1520 | 1614 | java.util.Map.Entry entry = (java.util.Map.Entry)it.next(); |
| 1521 | 1615 | Integer id = Integer.parseInt(entry.getKey().toString().split("_")[1]); //返回对应的键 |
| 1522 | 1616 | String industryCode = entry.getValue().toString(); //返回对应的值 |
| 1523 | - repository.updIndustryCode(id, industryCode); | |
| 1617 | + if(map.get("status") == null || Integer.parseInt(map.get("status").toString()) == 1) { | |
| 1618 | + repository.updIndustryCode(id, industryCode); | |
| 1619 | + }else if(Integer.parseInt(map.get("status").toString()) == 2) { | |
| 1620 | + lsStationRouteRepository.updIndustryCode(id, industryCode); | |
| 1621 | + } | |
| 1524 | 1622 | } |
| 1525 | 1623 | rs.put("status", ResponseCode.SUCCESS); |
| 1526 | 1624 | }catch(Exception e){ | ... | ... |