Commit 1389ef6b4054b43dd92b5c96034800472a676452
1 parent
2565ec3d
1.新增按公司获取营运线路的接口
Showing
1 changed file
with
55 additions
and
37 deletions
src/main/java/com/bsth/server_rs/base_info/line/LineRestService.java
| 1 | -package com.bsth.server_rs.base_info.line; | ||
| 2 | - | ||
| 3 | -import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | ||
| 4 | - | ||
| 5 | -import javax.ws.rs.GET; | ||
| 6 | -import javax.ws.rs.Path; | ||
| 7 | -import javax.ws.rs.PathParam; | ||
| 8 | -import javax.ws.rs.Produces; | ||
| 9 | -import javax.ws.rs.core.MediaType; | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 线路 Rest Service | ||
| 14 | - * Created by panzhao on 2017/3/27. | ||
| 15 | - */ | ||
| 16 | -@Path("/line") | ||
| 17 | -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
| 18 | -public class LineRestService { | ||
| 19 | - | ||
| 20 | - @GET | ||
| 21 | - @Path("/all") | ||
| 22 | - public List<Line> findAll(){ | ||
| 23 | - return LineBufferData.findAll(); | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - @GET | ||
| 27 | - @Path("/company/{companyId}") | ||
| 28 | - public List<Line> findByCompany(@PathParam("companyId") String companyId) { | ||
| 29 | - return companyId.equals("-9999") ? LineBufferData.findAll() : LineBufferData.findByCompany(companyId); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - @GET | ||
| 33 | - @Path("/{lineCode}") | ||
| 34 | - public Line findOne(@PathParam("lineCode") String lineCode) { | ||
| 35 | - return LineBufferData.findOne(lineCode); | ||
| 36 | - } | ||
| 37 | -} | 1 | +package com.bsth.server_rs.base_info.line; |
| 2 | + | ||
| 3 | +import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | ||
| 4 | + | ||
| 5 | +import javax.ws.rs.GET; | ||
| 6 | +import javax.ws.rs.Path; | ||
| 7 | +import javax.ws.rs.PathParam; | ||
| 8 | +import javax.ws.rs.Produces; | ||
| 9 | +import javax.ws.rs.core.MediaType; | ||
| 10 | +import java.util.ArrayList; | ||
| 11 | +import java.util.Arrays; | ||
| 12 | +import java.util.List; | ||
| 13 | +import java.util.stream.Collectors; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * 线路 Rest Service | ||
| 17 | + * Created by panzhao on 2017/3/27. | ||
| 18 | + */ | ||
| 19 | +@Path("/line") | ||
| 20 | +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
| 21 | +public class LineRestService { | ||
| 22 | + | ||
| 23 | + @GET | ||
| 24 | + @Path("/all") | ||
| 25 | + public List<Line> findAll(){ | ||
| 26 | + return LineBufferData.findAll(); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @GET | ||
| 30 | + @Path("/company/{companyId}") | ||
| 31 | + public List<Line> findByCompany(@PathParam("companyId") String companyId) { | ||
| 32 | + return companyId.equals("-9999") ? LineBufferData.findAll() : LineBufferData.findByCompany(companyId); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @GET | ||
| 36 | + @Path("/company/service/{companyId}") | ||
| 37 | + public List<Line> findServiceByCompany(@PathParam("companyId") String companyId) { | ||
| 38 | + List<Line> result = new ArrayList<>(); | ||
| 39 | + List<String> natureCodes = Arrays.asList("yxl","cgxl","gjxl","csbs","cctxl"); | ||
| 40 | + List<Line> lines = companyId.equals("-9999") ? LineBufferData.findAll() : LineBufferData.findByCompany(companyId); | ||
| 41 | + for (Line line : lines) { | ||
| 42 | + if (natureCodes.contains(line.getNature())) { | ||
| 43 | + result.add(line); | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + return result; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @GET | ||
| 51 | + @Path("/{lineCode}") | ||
| 52 | + public Line findOne(@PathParam("lineCode") String lineCode) { | ||
| 53 | + return LineBufferData.findOne(lineCode); | ||
| 54 | + } | ||
| 55 | +} |