Commit 480095aceeedf1735eee2d6644be66fadab0f116
1 parent
995d98c7
update...
Showing
24 changed files
with
1196 additions
and
225 deletions
src/main/java/com/bsth/CXFConfig.java
| @@ -4,6 +4,7 @@ import com.bsth.server_rs.AuthorizeInterceptor_IN; | @@ -4,6 +4,7 @@ import com.bsth.server_rs.AuthorizeInterceptor_IN; | ||
| 4 | import com.bsth.server_rs.base_info.car.CarRestService; | 4 | import com.bsth.server_rs.base_info.car.CarRestService; |
| 5 | import com.bsth.server_rs.base_info.line.LineRestService; | 5 | import com.bsth.server_rs.base_info.line.LineRestService; |
| 6 | import com.bsth.server_rs.base_info.person.PersonRestService; | 6 | import com.bsth.server_rs.base_info.person.PersonRestService; |
| 7 | +import com.bsth.server_rs.base_info.station.StationRestService; | ||
| 7 | import com.bsth.server_rs.exception.AesExceptionMapper; | 8 | import com.bsth.server_rs.exception.AesExceptionMapper; |
| 8 | import com.bsth.server_rs.gps.GpsRestService; | 9 | import com.bsth.server_rs.gps.GpsRestService; |
| 9 | import com.bsth.server_rs.schedule.real.ScheduleRealService; | 10 | import com.bsth.server_rs.schedule.real.ScheduleRealService; |
| @@ -73,6 +74,9 @@ public class CXFConfig { | @@ -73,6 +74,9 @@ public class CXFConfig { | ||
| 73 | @Autowired | 74 | @Autowired |
| 74 | ScheduleRealService scheduleRealService; | 75 | ScheduleRealService scheduleRealService; |
| 75 | 76 | ||
| 77 | + @Autowired | ||
| 78 | + StationRestService stationRestService; | ||
| 79 | + | ||
| 76 | @Bean | 80 | @Bean |
| 77 | public Server rsServer() { | 81 | public Server rsServer() { |
| 78 | JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); | 82 | JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); |
| @@ -83,7 +87,8 @@ public class CXFConfig { | @@ -83,7 +87,8 @@ public class CXFConfig { | ||
| 83 | new CarRestService(), | 87 | new CarRestService(), |
| 84 | new PersonRestService(), | 88 | new PersonRestService(), |
| 85 | new GpsRestService(), | 89 | new GpsRestService(), |
| 86 | - scheduleRealService)); | 90 | + scheduleRealService, |
| 91 | + stationRestService)); | ||
| 87 | endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper())); | 92 | endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper())); |
| 88 | //endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); | 93 | //endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); |
| 89 | endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN()); | 94 | endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN()); |
src/main/java/com/bsth/common/BasicData.java
| @@ -3,6 +3,7 @@ package com.bsth.common; | @@ -3,6 +3,7 @@ package com.bsth.common; | ||
| 3 | import com.bsth.Application; | 3 | import com.bsth.Application; |
| 4 | import org.springframework.beans.factory.annotation.Autowired; | 4 | import org.springframework.beans.factory.annotation.Autowired; |
| 5 | import org.springframework.boot.CommandLineRunner; | 5 | import org.springframework.boot.CommandLineRunner; |
| 6 | +import org.springframework.core.annotation.Order; | ||
| 6 | import org.springframework.jdbc.core.JdbcTemplate; | 7 | import org.springframework.jdbc.core.JdbcTemplate; |
| 7 | import org.springframework.stereotype.Component; | 8 | import org.springframework.stereotype.Component; |
| 8 | 9 | ||
| @@ -16,6 +17,7 @@ import java.util.concurrent.TimeUnit; | @@ -16,6 +17,7 @@ import java.util.concurrent.TimeUnit; | ||
| 16 | * Created by panzhao on 2017/8/24. | 17 | * Created by panzhao on 2017/8/24. |
| 17 | */ | 18 | */ |
| 18 | @Component | 19 | @Component |
| 20 | +@Order(1) | ||
| 19 | public class BasicData implements CommandLineRunner { | 21 | public class BasicData implements CommandLineRunner { |
| 20 | 22 | ||
| 21 | /** | 23 | /** |
| @@ -24,12 +26,15 @@ public class BasicData implements CommandLineRunner { | @@ -24,12 +26,15 @@ public class BasicData implements CommandLineRunner { | ||
| 24 | */ | 26 | */ |
| 25 | public static Map<String, String> lineDateMap; | 27 | public static Map<String, String> lineDateMap; |
| 26 | 28 | ||
| 29 | + public static Map<String, String> lineStartTimeMap; | ||
| 30 | + | ||
| 27 | @Autowired | 31 | @Autowired |
| 28 | BasicDataLoader basicDataLoader; | 32 | BasicDataLoader basicDataLoader; |
| 29 | 33 | ||
| 30 | @Override | 34 | @Override |
| 31 | public void run(String... strings) throws Exception { | 35 | public void run(String... strings) throws Exception { |
| 32 | - Application.mainServices.scheduleWithFixedDelay(basicDataLoader, 10, 60 * 10, TimeUnit.SECONDS); | 36 | + basicDataLoader.run(); |
| 37 | + Application.mainServices.scheduleWithFixedDelay(basicDataLoader, 60 * 10, 60 * 10, TimeUnit.SECONDS); | ||
| 33 | } | 38 | } |
| 34 | 39 | ||
| 35 | 40 | ||
| @@ -46,17 +51,24 @@ public class BasicData implements CommandLineRunner { | @@ -46,17 +51,24 @@ public class BasicData implements CommandLineRunner { | ||
| 46 | 51 | ||
| 47 | private void loadLineDateMap(){ | 52 | private void loadLineDateMap(){ |
| 48 | Map<String, String> lineDateMapCopy = new HashMap<>(); | 53 | Map<String, String> lineDateMapCopy = new HashMap<>(); |
| 54 | + Map<String, String> lineStartTimeMapCopy = new HashMap<>(); | ||
| 55 | + | ||
| 49 | String sql = "select START_OPT,t2.LINE_CODE from bsth_c_line_config t1 INNER JOIN bsth_c_line t2 on t1.line=t2.id where t2.line_code is not null"; | 56 | String sql = "select START_OPT,t2.LINE_CODE from bsth_c_line_config t1 INNER JOIN bsth_c_line t2 on t1.line=t2.id where t2.line_code is not null"; |
| 50 | 57 | ||
| 51 | List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); | 58 | List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); |
| 59 | + String lineCode, startTime; | ||
| 52 | for(Map<String, Object> map : list){ | 60 | for(Map<String, Object> map : list){ |
| 53 | - lineDateMapCopy.put(map.get("LINE_CODE").toString(), calcScheduleDate(map.get("START_OPT"))); | 61 | + lineCode = map.get("LINE_CODE").toString(); |
| 62 | + startTime = map.get("START_OPT").toString(); | ||
| 63 | + lineDateMapCopy.put(lineCode, calcScheduleDate(startTime)); | ||
| 64 | + lineStartTimeMapCopy.put(lineCode, startTime); | ||
| 54 | } | 65 | } |
| 55 | 66 | ||
| 56 | lineDateMap = lineDateMapCopy; | 67 | lineDateMap = lineDateMapCopy; |
| 68 | + lineStartTimeMap = lineStartTimeMapCopy; | ||
| 57 | } | 69 | } |
| 58 | 70 | ||
| 59 | - private String calcScheduleDate(Object startDate){ | 71 | + private String calcScheduleDate(String startDate){ |
| 60 | return "20170828"; | 72 | return "20170828"; |
| 61 | } | 73 | } |
| 62 | } | 74 | } |
src/main/java/com/bsth/entity/ChildTaskPlan.java
| 1 | package com.bsth.entity; | 1 | package com.bsth.entity; |
| 2 | 2 | ||
| 3 | +import com.bsth.server_rs.adapter.DateTimeAdapter; | ||
| 3 | import com.fasterxml.jackson.annotation.JsonIgnore; | 4 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 4 | 5 | ||
| 5 | import javax.persistence.*; | 6 | import javax.persistence.*; |
| 7 | +import javax.xml.bind.annotation.XmlRootElement; | ||
| 8 | +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | ||
| 6 | import java.io.Serializable; | 9 | import java.io.Serializable; |
| 7 | import java.util.Date; | 10 | import java.util.Date; |
| 8 | 11 | ||
| @@ -15,6 +18,7 @@ import java.util.Date; | @@ -15,6 +18,7 @@ import java.util.Date; | ||
| 15 | * @date 2016年6月20日 上午11:22:22 | 18 | * @date 2016年6月20日 上午11:22:22 |
| 16 | * | 19 | * |
| 17 | */ | 20 | */ |
| 21 | +@XmlRootElement | ||
| 18 | @Entity | 22 | @Entity |
| 19 | @Table(name = "bsth_c_s_child_task") | 23 | @Table(name = "bsth_c_s_child_task") |
| 20 | @NamedEntityGraphs({ | 24 | @NamedEntityGraphs({ |
| @@ -235,6 +239,7 @@ public class ChildTaskPlan implements Serializable { | @@ -235,6 +239,7 @@ public class ChildTaskPlan implements Serializable { | ||
| 235 | return this.id.equals(((ChildTaskPlan)obj).getId()); | 239 | return this.id.equals(((ChildTaskPlan)obj).getId()); |
| 236 | } | 240 | } |
| 237 | 241 | ||
| 242 | + @XmlJavaTypeAdapter(DateTimeAdapter.class) | ||
| 238 | public Date getCreateDate() { | 243 | public Date getCreateDate() { |
| 239 | return createDate; | 244 | return createDate; |
| 240 | } | 245 | } |
src/main/java/com/bsth/entity/ScheduleRealInfo.java
| 1 | package com.bsth.entity; | 1 | package com.bsth.entity; |
| 2 | 2 | ||
| 3 | +import org.joda.time.format.DateTimeFormat; | ||
| 4 | +import org.joda.time.format.DateTimeFormatter; | ||
| 5 | + | ||
| 3 | import javax.persistence.*; | 6 | import javax.persistence.*; |
| 4 | import java.io.Serializable; | 7 | import java.io.Serializable; |
| 5 | import java.util.Date; | 8 | import java.util.Date; |
| @@ -128,7 +131,7 @@ public class ScheduleRealInfo implements Serializable{ | @@ -128,7 +131,7 @@ public class ScheduleRealInfo implements Serializable{ | ||
| 128 | 131 | ||
| 129 | /** 备注*/ | 132 | /** 备注*/ |
| 130 | private String remarks; | 133 | private String remarks; |
| 131 | - | 134 | + |
| 132 | /**待发时间(格式 HH:mm) */ | 135 | /**待发时间(格式 HH:mm) */ |
| 133 | private String dfsj; | 136 | private String dfsj; |
| 134 | 137 | ||
| @@ -138,7 +141,7 @@ public class ScheduleRealInfo implements Serializable{ | @@ -138,7 +141,7 @@ public class ScheduleRealInfo implements Serializable{ | ||
| 138 | 141 | ||
| 139 | /** 指令下发状态 60: 已发送, 100: 设备确认收到, 200:驾驶员确认 0:失败 */ | 142 | /** 指令下发状态 60: 已发送, 100: 设备确认收到, 200:驾驶员确认 0:失败 */ |
| 140 | private Integer directiveState = -1; | 143 | private Integer directiveState = -1; |
| 141 | - | 144 | + |
| 142 | /** 起点站计划到达时间 */ | 145 | /** 起点站计划到达时间 */ |
| 143 | @Transient | 146 | @Transient |
| 144 | private String qdzArrDatejh; | 147 | private String qdzArrDatejh; |
| @@ -603,4 +606,28 @@ public class ScheduleRealInfo implements Serializable{ | @@ -603,4 +606,28 @@ public class ScheduleRealInfo implements Serializable{ | ||
| 603 | public void setJhlcOrig(Double jhlcOrig) { | 606 | public void setJhlcOrig(Double jhlcOrig) { |
| 604 | this.jhlcOrig = jhlcOrig; | 607 | this.jhlcOrig = jhlcOrig; |
| 605 | } | 608 | } |
| 609 | + | ||
| 610 | + @Transient | ||
| 611 | + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | ||
| 612 | + /** | ||
| 613 | + * | ||
| 614 | + * @Title: setFcsjActualAll | ||
| 615 | + * @Description: TODO(设置实际发车时间 时间戳) | ||
| 616 | + * @throws | ||
| 617 | + */ | ||
| 618 | + public void setFcsjActualAll(Long t){ | ||
| 619 | + this.fcsjActualTime = t; | ||
| 620 | + this.fcsjActual = fmtHHmm.print(t); | ||
| 621 | + } | ||
| 622 | + | ||
| 623 | + /** | ||
| 624 | + * | ||
| 625 | + * @Title: setFcsjActualAll | ||
| 626 | + * @Description: TODO(设置实际终点时间) | ||
| 627 | + * @throws | ||
| 628 | + */ | ||
| 629 | + public void setZdsjActualAll(Long t){ | ||
| 630 | + this.zdsjActualTime = t; | ||
| 631 | + this.zdsjActual = fmtHHmm.print(t); | ||
| 632 | + } | ||
| 606 | } | 633 | } |
src/main/java/com/bsth/redis/OilRedisService.java
| 1 | package com.bsth.redis; | 1 | package com.bsth.redis; |
| 2 | 2 | ||
| 3 | -import com.bsth.Application; | ||
| 4 | import com.bsth.entity.OilInfo; | 3 | import com.bsth.entity.OilInfo; |
| 5 | import com.bsth.redis.util.RedisUtils; | 4 | import com.bsth.redis.util.RedisUtils; |
| 6 | import com.bsth.repository.OilInfoRepository; | 5 | import com.bsth.repository.OilInfoRepository; |
| @@ -19,7 +18,6 @@ import org.springframework.stereotype.Component; | @@ -19,7 +18,6 @@ import org.springframework.stereotype.Component; | ||
| 19 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 20 | 19 | ||
| 21 | import java.util.*; | 20 | import java.util.*; |
| 22 | -import java.util.concurrent.TimeUnit; | ||
| 23 | 21 | ||
| 24 | /** | 22 | /** |
| 25 | * 油量数据Redis缓存 | 23 | * 油量数据Redis缓存 |
| @@ -124,7 +122,7 @@ public class OilRedisService implements CommandLineRunner { | @@ -124,7 +122,7 @@ public class OilRedisService implements CommandLineRunner { | ||
| 124 | @Override | 122 | @Override |
| 125 | public void run(String... strings) throws Exception { | 123 | public void run(String... strings) throws Exception { |
| 126 | //定时刷新油耗信息 | 124 | //定时刷新油耗信息 |
| 127 | - Application.mainServices.scheduleWithFixedDelay(oilRefreshThread, 40, 60 * 40, TimeUnit.SECONDS); | 125 | + //Application.mainServices.scheduleWithFixedDelay(oilRefreshThread, 40, 60 * 40, TimeUnit.SECONDS); |
| 128 | } | 126 | } |
| 129 | 127 | ||
| 130 | /** | 128 | /** |
src/main/java/com/bsth/redis/PlanScheduleRedisService.java
| 1 | package com.bsth.redis; | 1 | package com.bsth.redis; |
| 2 | 2 | ||
| 3 | -import com.bsth.Application; | ||
| 4 | import com.bsth.entity.SchedulePlanInfo; | 3 | import com.bsth.entity.SchedulePlanInfo; |
| 5 | -import com.bsth.redis.util.DateUtils; | ||
| 6 | import com.bsth.redis.util.RedisUtils; | 4 | import com.bsth.redis.util.RedisUtils; |
| 7 | import com.bsth.repository.SchedulePlanInfoRepository; | 5 | import com.bsth.repository.SchedulePlanInfoRepository; |
| 8 | import com.bsth.server_rs.base_info.line.Line; | 6 | import com.bsth.server_rs.base_info.line.Line; |
| @@ -18,7 +16,6 @@ import org.springframework.boot.CommandLineRunner; | @@ -18,7 +16,6 @@ import org.springframework.boot.CommandLineRunner; | ||
| 18 | import org.springframework.core.annotation.Order; | 16 | import org.springframework.core.annotation.Order; |
| 19 | import org.springframework.data.redis.core.ListOperations; | 17 | import org.springframework.data.redis.core.ListOperations; |
| 20 | import org.springframework.data.redis.core.RedisTemplate; | 18 | import org.springframework.data.redis.core.RedisTemplate; |
| 21 | -import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
| 22 | import org.springframework.stereotype.Component; | 19 | import org.springframework.stereotype.Component; |
| 23 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 24 | 21 | ||
| @@ -26,7 +23,6 @@ import java.util.ArrayList; | @@ -26,7 +23,6 @@ import java.util.ArrayList; | ||
| 26 | import java.util.Date; | 23 | import java.util.Date; |
| 27 | import java.util.Iterator; | 24 | import java.util.Iterator; |
| 28 | import java.util.List; | 25 | import java.util.List; |
| 29 | -import java.util.concurrent.TimeUnit; | ||
| 30 | 26 | ||
| 31 | /** | 27 | /** |
| 32 | * 计调的 计划排班redis缓存 | 28 | * 计调的 计划排班redis缓存 |
| @@ -124,7 +120,7 @@ public class PlanScheduleRedisService implements CommandLineRunner { | @@ -124,7 +120,7 @@ public class PlanScheduleRedisService implements CommandLineRunner { | ||
| 124 | 120 | ||
| 125 | @Override | 121 | @Override |
| 126 | public void run(String... strings) throws Exception { | 122 | public void run(String... strings) throws Exception { |
| 127 | - int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | 123 | + /*int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); |
| 128 | //设置key 序列化器 | 124 | //设置key 序列化器 |
| 129 | redisTemplate.setKeySerializer(new StringRedisSerializer()); | 125 | redisTemplate.setKeySerializer(new StringRedisSerializer()); |
| 130 | 126 | ||
| @@ -139,7 +135,7 @@ public class PlanScheduleRedisService implements CommandLineRunner { | @@ -139,7 +135,7 @@ public class PlanScheduleRedisService implements CommandLineRunner { | ||
| 139 | long diff = (DateUtils.getTimestamp() + 1000 * 60 * 5) - System.currentTimeMillis(); | 135 | long diff = (DateUtils.getTimestamp() + 1000 * 60 * 5) - System.currentTimeMillis(); |
| 140 | if (diff < 0) | 136 | if (diff < 0) |
| 141 | diff += (1000 * 60 * 60 * 24); | 137 | diff += (1000 * 60 * 60 * 24); |
| 142 | - Application.mainServices.scheduleAtFixedRate(planClearThread, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | 138 | + Application.mainServices.scheduleAtFixedRate(planClearThread, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS);*/ |
| 143 | } | 139 | } |
| 144 | 140 | ||
| 145 | public List<SchedulePlanInfo> findByMultiLine(List<String> lineArray, String rq) { | 141 | public List<SchedulePlanInfo> findByMultiLine(List<String> lineArray, String rq) { |
src/main/java/com/bsth/redis/ScheduleRedisService.java
| 1 | package com.bsth.redis; | 1 | package com.bsth.redis; |
| 2 | 2 | ||
| 3 | import com.bsth.Application; | 3 | import com.bsth.Application; |
| 4 | +import com.bsth.common.BasicData; | ||
| 4 | import com.bsth.entity.ScheduleRealInfo; | 5 | import com.bsth.entity.ScheduleRealInfo; |
| 5 | import com.bsth.redis.util.RedisUtils; | 6 | import com.bsth.redis.util.RedisUtils; |
| 6 | import com.bsth.repository.ScheduleRealInfoRepository; | 7 | import com.bsth.repository.ScheduleRealInfoRepository; |
| @@ -10,7 +11,10 @@ import com.bsth.server_ws.WebServiceProxy; | @@ -10,7 +11,10 @@ import com.bsth.server_ws.WebServiceProxy; | ||
| 10 | import com.bsth.util.ConfigUtil; | 11 | import com.bsth.util.ConfigUtil; |
| 11 | import com.bsth.util.ConvertUtil; | 12 | import com.bsth.util.ConvertUtil; |
| 12 | import com.google.common.collect.ArrayListMultimap; | 13 | import com.google.common.collect.ArrayListMultimap; |
| 14 | +import org.apache.commons.lang3.StringUtils; | ||
| 13 | import org.joda.time.DateTime; | 15 | import org.joda.time.DateTime; |
| 16 | +import org.joda.time.format.DateTimeFormat; | ||
| 17 | +import org.joda.time.format.DateTimeFormatter; | ||
| 14 | import org.slf4j.Logger; | 18 | import org.slf4j.Logger; |
| 15 | import org.slf4j.LoggerFactory; | 19 | import org.slf4j.LoggerFactory; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -51,6 +55,8 @@ public class ScheduleRedisService implements CommandLineRunner { | @@ -51,6 +55,8 @@ public class ScheduleRedisService implements CommandLineRunner { | ||
| 51 | 55 | ||
| 52 | static Logger logger = LoggerFactory.getLogger(ScheduleRedisService.class); | 56 | static Logger logger = LoggerFactory.getLogger(ScheduleRedisService.class); |
| 53 | 57 | ||
| 58 | + private final static long DAY_TIME = 1000 * 60 * 60 * 24L; | ||
| 59 | + | ||
| 54 | /** | 60 | /** |
| 55 | * 将一批班次写入redis | 61 | * 将一批班次写入redis |
| 56 | * | 62 | * |
| @@ -218,6 +224,7 @@ public class ScheduleRedisService implements CommandLineRunner { | @@ -218,6 +224,7 @@ public class ScheduleRedisService implements CommandLineRunner { | ||
| 218 | DateTime dt = new DateTime(); | 224 | DateTime dt = new DateTime(); |
| 219 | dt = dt.minusDays(cacheDays); | 225 | dt = dt.minusDays(cacheDays); |
| 220 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDateLT(dt.toString("yyyy-MM-dd")); | 226 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDateLT(dt.toString("yyyy-MM-dd")); |
| 227 | + calcTime(list); | ||
| 221 | //写入redis | 228 | //写入redis |
| 222 | wirte(list); | 229 | wirte(list); |
| 223 | 230 | ||
| @@ -282,4 +289,62 @@ public class ScheduleRedisService implements CommandLineRunner { | @@ -282,4 +289,62 @@ public class ScheduleRedisService implements CommandLineRunner { | ||
| 282 | } | 289 | } |
| 283 | } | 290 | } |
| 284 | } | 291 | } |
| 292 | + | ||
| 293 | + /** | ||
| 294 | + * ############ 时间戳计算 ########## | ||
| 295 | + */ | ||
| 296 | + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"), | ||
| 297 | + fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | ||
| 298 | + | ||
| 299 | + private void calcTime(List<ScheduleRealInfo> list){ | ||
| 300 | + if(list.size() == 0) | ||
| 301 | + return; | ||
| 302 | + | ||
| 303 | + //计算真实执行日期 和 时间戳 | ||
| 304 | + for(ScheduleRealInfo sch : list){ | ||
| 305 | + calcRealDate(BasicData.lineStartTimeMap.get(sch.getXlBm()), sch); | ||
| 306 | + } | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | + /** | ||
| 310 | + * @Title: calcRealDate | ||
| 311 | + * @Description: TODO(计算班次的真实执行日期) | ||
| 312 | + */ | ||
| 313 | + public void calcRealDate(String startTime, ScheduleRealInfo sch) { | ||
| 314 | + try { | ||
| 315 | + | ||
| 316 | + String rq = sch.getScheduleDateStr(); | ||
| 317 | + //计发时间 | ||
| 318 | + sch.setFcsjT(parseTime(rq, sch.getFcsj(), startTime)); | ||
| 319 | + //待发时间 | ||
| 320 | + sch.setDfsjT(parseTime(rq, sch.getDfsj(), startTime)); | ||
| 321 | + //计划终点时间 | ||
| 322 | + if(StringUtils.isEmpty(sch.getZdsj())){ | ||
| 323 | + sch.setZdsjT(sch.getDfsjT() + (sch.getBcsj() * 60 * 1000)); | ||
| 324 | + sch.setZdsj(fmtHHmm.print(sch.getZdsjT())); | ||
| 325 | + } | ||
| 326 | + else | ||
| 327 | + sch.setZdsjT(sch.getDfsjT() + (sch.getBcsj() * 60 * 1000)); | ||
| 328 | + //实发时间 | ||
| 329 | + if(StringUtils.isEmpty(sch.getFcsjActual())) | ||
| 330 | + sch.setFcsjActualAll(sch.getDfsjT()); | ||
| 331 | + else | ||
| 332 | + sch.setFcsjActualAll(parseTime(rq, sch.getFcsjActual(), startTime)); | ||
| 333 | + //实达时间 | ||
| 334 | + if(StringUtils.isEmpty(sch.getZdsjActual())) | ||
| 335 | + sch.setZdsjActualAll(sch.getZdsjT()); | ||
| 336 | + else | ||
| 337 | + sch.setZdsjActualAll(parseTime(rq, sch.getZdsjActual(), startTime)); | ||
| 338 | + } catch (Exception e) { | ||
| 339 | + logger.error("", e); | ||
| 340 | + } | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + private long parseTime(String rq, String sj, String startTime){ | ||
| 344 | + long t = fmtyyyyMMddHHmm.parseMillis(rq + sj); | ||
| 345 | + if(sj.compareTo(startTime) < 0){ | ||
| 346 | + t += DAY_TIME; | ||
| 347 | + } | ||
| 348 | + return t; | ||
| 349 | + } | ||
| 285 | } | 350 | } |
src/main/java/com/bsth/server_rs/adapter/DateTimeAdapter.java
0 → 100644
| 1 | +package com.bsth.server_rs.adapter; | ||
| 2 | + | ||
| 3 | +import javax.xml.bind.annotation.adapters.XmlAdapter; | ||
| 4 | +import java.util.Date; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 时间格式处理 yyyy-MM-dd | ||
| 8 | + * Created by panzhao on 2017/3/28. | ||
| 9 | + */ | ||
| 10 | +public class DateTimeAdapter extends XmlAdapter<Long, Date> { | ||
| 11 | + | ||
| 12 | + @Override | ||
| 13 | + public Date unmarshal(Long v) throws Exception { | ||
| 14 | + return new Date(v); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + @Override | ||
| 18 | + public Long marshal(Date v) throws Exception { | ||
| 19 | + return v.getTime(); | ||
| 20 | + } | ||
| 21 | +} |
src/main/java/com/bsth/server_rs/base_info/line/Line.java
| 1 | package com.bsth.server_rs.base_info.line; | 1 | package com.bsth.server_rs.base_info.line; |
| 2 | 2 | ||
| 3 | -import com.bsth.server_rs.adapter.DateAdapter_yMdHms; | 3 | +import com.bsth.server_rs.adapter.DateTimeAdapter; |
| 4 | 4 | ||
| 5 | import javax.xml.bind.annotation.XmlRootElement; | 5 | import javax.xml.bind.annotation.XmlRootElement; |
| 6 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | 6 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
| @@ -18,166 +18,86 @@ import java.util.Date; | @@ -18,166 +18,86 @@ import java.util.Date; | ||
| 18 | @XmlRootElement | 18 | @XmlRootElement |
| 19 | public class Line implements Serializable { | 19 | public class Line implements Serializable { |
| 20 | 20 | ||
| 21 | - /** | ||
| 22 | - * 线路ID 主键(唯一标识符) int length(11) | ||
| 23 | - */ | ||
| 24 | - private Integer id; | ||
| 25 | 21 | ||
| 26 | - /** | ||
| 27 | - * 线路名称 varchar length(50) 不能为空 | ||
| 28 | - */ | 22 | + /**线路名称 varchar length(50) 不能为空*/ |
| 29 | private String name; | 23 | private String name; |
| 30 | 24 | ||
| 31 | - /** | ||
| 32 | - * 线路编码 varchar length(50) 不能为空 | ||
| 33 | - */ | 25 | + /** 线路编码 varchar length(50) 不能为空*/ |
| 34 | private String lineCode; | 26 | private String lineCode; |
| 35 | 27 | ||
| 36 | - /** | ||
| 37 | - * 英文名 varchar length(50) | ||
| 38 | - */ | ||
| 39 | - private String es; | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | - * 简称 varchar length(50) | ||
| 43 | - */ | ||
| 44 | - private String shortName; | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * 起始站名称 varchar length(50) 不能为空 | ||
| 48 | - * 该字段值会在规划线路站点操作时会去验证是否有值。如果为空,则用线路规划站点的起点站。默认使用该字段填写值 | ||
| 49 | - */ | 28 | + /** 起始站名称*/ |
| 50 | private String startStationName; | 29 | private String startStationName; |
| 51 | 30 | ||
| 52 | - /** | ||
| 53 | - * 终点站名称 varchar length(50) 不能为空 | ||
| 54 | - * 该字段值会在规划线路站点操作时会去验证是否有值。如果为空,则用线路规划站点的起点站。默认使用该字段填写值 | ||
| 55 | - */ | 31 | + /** 终点站名称*/ |
| 56 | private String endStationName; | 32 | private String endStationName; |
| 57 | 33 | ||
| 58 | - /** | ||
| 59 | - * 起始站首班车时间 00:00 上海公交APP中某个接口所需要的字段值 varchar length(50) 不能为空 | ||
| 60 | - */ | 34 | + /** 起始站首班车时间 00:00 */ |
| 61 | private String startStationFirstTime; | 35 | private String startStationFirstTime; |
| 62 | 36 | ||
| 63 | - /** | ||
| 64 | - * 起始站末班车时间 00:00 上海公交APP中某个接口所需要的字段值 varchar length(50) 不能为空 | ||
| 65 | - */ | 37 | + /** 起始站末班车时间 00:00 */ |
| 66 | private String startStationEndTime; | 38 | private String startStationEndTime; |
| 67 | 39 | ||
| 68 | - /** | ||
| 69 | - * 终点站首班时间 00:00 上海公交APP中某个接口所需要的字段值 varchar length(50) 不能为空 | ||
| 70 | - */ | 40 | + /** 终点站首班时间 00:00 */ |
| 71 | private String endStationFirstTime; | 41 | private String endStationFirstTime; |
| 72 | 42 | ||
| 73 | - /** | ||
| 74 | - * 终点站末班时间 00:00 上海公交APP中某个接口所需要的字段值 | ||
| 75 | - */ | 43 | + /** 终点站末班时间 00:00 */ |
| 76 | private String endStationEndTime; | 44 | private String endStationEndTime; |
| 77 | 45 | ||
| 78 | - /** | ||
| 79 | - * 所属公司 varchar length(50) | ||
| 80 | - */ | 46 | + /** 所属公司 */ |
| 81 | private String company; | 47 | private String company; |
| 82 | 48 | ||
| 83 | - /** | ||
| 84 | - * 分公司 varchar length(50) | ||
| 85 | - */ | 49 | + /** 分公司 */ |
| 86 | private String brancheCompany; | 50 | private String brancheCompany; |
| 87 | 51 | ||
| 88 | - /** | ||
| 89 | - * 性质(线路类型) varchar length(50) | ||
| 90 | - */ | 52 | + /** 性质(线路类型) */ |
| 91 | private String nature; | 53 | private String nature; |
| 92 | 54 | ||
| 93 | - /** | ||
| 94 | - * 线路等级 varchar length(50) | ||
| 95 | - */ | 55 | + /**线路等级 */ |
| 96 | private String level; | 56 | private String level; |
| 97 | 57 | ||
| 98 | - /** | ||
| 99 | - * 线路长度 | ||
| 100 | - */ | ||
| 101 | - private double length; | ||
| 102 | - | ||
| 103 | - /** | ||
| 104 | - * 线路负责人 varchar length(50) | ||
| 105 | - */ | ||
| 106 | - private String chargeName; | ||
| 107 | - | ||
| 108 | - /** | ||
| 109 | - * 负责人电话 varchar length(50) | ||
| 110 | - */ | ||
| 111 | - private String telephone; | ||
| 112 | - | ||
| 113 | - /** | ||
| 114 | - * 是否撤销 <1:是;0:否> bit length(50) | ||
| 115 | - */ | 58 | + /**是否撤销 <1:是;0:否> */ |
| 116 | private Integer destroy; | 59 | private Integer destroy; |
| 117 | 60 | ||
| 118 | - /** | ||
| 119 | - * 是否夜宵线 <1:是;0:否> bit length(50) | ||
| 120 | - */ | 61 | + /** 是否夜宵线 <1:是;0:否> */ |
| 121 | private Integer supperLine; | 62 | private Integer supperLine; |
| 122 | 63 | ||
| 123 | - /** | ||
| 124 | - * 起始调度电话 varchar length(50) | ||
| 125 | - */ | ||
| 126 | - private String startPhone; | 64 | + /** 设备线路编码 */ |
| 65 | + private String eqLinecode; | ||
| 127 | 66 | ||
| 128 | /** | 67 | /** |
| 129 | - * 终点调度电话 varchar length(50) | 68 | + * 创建日期 timestamp |
| 130 | */ | 69 | */ |
| 131 | - private String endPhone; | 70 | + private Date createDate; |
| 132 | 71 | ||
| 133 | - /** | ||
| 134 | - * 开辟日期 date | ||
| 135 | - */ | ||
| 136 | - private Date openDate; | 72 | + //-------------- 标准信息 ----------- |
| 73 | + /** 标准总里程 */ | ||
| 74 | + private Double totalMileage; | ||
| 75 | + /** 早高峰大间隔(分钟) */ | ||
| 76 | + private Double earlyIntervalLg; | ||
| 137 | 77 | ||
| 138 | - /** | ||
| 139 | - * 线路沿革 varchar length(50) | ||
| 140 | - */ | ||
| 141 | - private String history; | 78 | + /** 晚高峰大间隔(分钟) */ |
| 79 | + private Double lateIntervalLg; | ||
| 142 | 80 | ||
| 143 | - /** | ||
| 144 | - * 上海市线路编码 varchar length(50) | ||
| 145 | - */ | ||
| 146 | - private String shanghaiLinecode; | 81 | + /** 平时大间隔(分钟) */ |
| 82 | + private Double intervalLg; | ||
| 147 | 83 | ||
| 148 | - /** | ||
| 149 | - * 设备线路编码 varchar length(50) | ||
| 150 | - */ | ||
| 151 | - private String eqLinecode; | 84 | + /** 限速(平时) */ |
| 85 | + private Double speedLimit; | ||
| 152 | 86 | ||
| 153 | - /** | ||
| 154 | - * 权证车辆数量 报表需要的字段值 | ||
| 155 | - */ | ||
| 156 | - private Integer warrantCar; | 87 | + /** 滞站 */ |
| 88 | + private Integer lagStation; | ||
| 157 | 89 | ||
| 90 | + /** 越站 */ | ||
| 91 | + private Integer skip; | ||
| 158 | 92 | ||
| 159 | - /** | ||
| 160 | - * 线路规划类型 <0:双向;1:环线> int length(11) 运管处接口需要的字段 不能为空 | ||
| 161 | - */ | ||
| 162 | - private Integer linePlayType; | 93 | + /** 超速 */ |
| 94 | + private Integer speeding; | ||
| 163 | 95 | ||
| 164 | - /** | ||
| 165 | - * 描述 varchar length(255) | ||
| 166 | - */ | ||
| 167 | - private String descriptions; | 96 | + /** 串线 */ |
| 97 | + private Integer crossedLine; | ||
| 168 | 98 | ||
| 169 | - /** | ||
| 170 | - * 创建日期 timestamp | ||
| 171 | - */ | ||
| 172 | - private Date createDate; | ||
| 173 | - | ||
| 174 | - public Integer getId() { | ||
| 175 | - return id; | ||
| 176 | - } | ||
| 177 | - | ||
| 178 | - public void setId(Integer id) { | ||
| 179 | - this.id = id; | ||
| 180 | - } | 99 | + /** 越界 */ |
| 100 | + private Integer overflights; | ||
| 181 | 101 | ||
| 182 | public String getName() { | 102 | public String getName() { |
| 183 | return name; | 103 | return name; |
| @@ -195,22 +115,6 @@ public class Line implements Serializable { | @@ -195,22 +115,6 @@ public class Line implements Serializable { | ||
| 195 | this.lineCode = lineCode; | 115 | this.lineCode = lineCode; |
| 196 | } | 116 | } |
| 197 | 117 | ||
| 198 | - public String getEs() { | ||
| 199 | - return es; | ||
| 200 | - } | ||
| 201 | - | ||
| 202 | - public void setEs(String es) { | ||
| 203 | - this.es = es; | ||
| 204 | - } | ||
| 205 | - | ||
| 206 | - public String getShortName() { | ||
| 207 | - return shortName; | ||
| 208 | - } | ||
| 209 | - | ||
| 210 | - public void setShortName(String shortName) { | ||
| 211 | - this.shortName = shortName; | ||
| 212 | - } | ||
| 213 | - | ||
| 214 | public String getStartStationName() { | 118 | public String getStartStationName() { |
| 215 | return startStationName; | 119 | return startStationName; |
| 216 | } | 120 | } |
| @@ -291,30 +195,6 @@ public class Line implements Serializable { | @@ -291,30 +195,6 @@ public class Line implements Serializable { | ||
| 291 | this.level = level; | 195 | this.level = level; |
| 292 | } | 196 | } |
| 293 | 197 | ||
| 294 | - public double getLength() { | ||
| 295 | - return length; | ||
| 296 | - } | ||
| 297 | - | ||
| 298 | - public void setLength(double length) { | ||
| 299 | - this.length = length; | ||
| 300 | - } | ||
| 301 | - | ||
| 302 | - public String getChargeName() { | ||
| 303 | - return chargeName; | ||
| 304 | - } | ||
| 305 | - | ||
| 306 | - public void setChargeName(String chargeName) { | ||
| 307 | - this.chargeName = chargeName; | ||
| 308 | - } | ||
| 309 | - | ||
| 310 | - public String getTelephone() { | ||
| 311 | - return telephone; | ||
| 312 | - } | ||
| 313 | - | ||
| 314 | - public void setTelephone(String telephone) { | ||
| 315 | - this.telephone = telephone; | ||
| 316 | - } | ||
| 317 | - | ||
| 318 | public Integer getDestroy() { | 198 | public Integer getDestroy() { |
| 319 | return destroy; | 199 | return destroy; |
| 320 | } | 200 | } |
| @@ -331,85 +211,100 @@ public class Line implements Serializable { | @@ -331,85 +211,100 @@ public class Line implements Serializable { | ||
| 331 | this.supperLine = supperLine; | 211 | this.supperLine = supperLine; |
| 332 | } | 212 | } |
| 333 | 213 | ||
| 334 | - public String getStartPhone() { | ||
| 335 | - return startPhone; | 214 | + public String getEqLinecode() { |
| 215 | + return eqLinecode; | ||
| 336 | } | 216 | } |
| 337 | 217 | ||
| 338 | - public void setStartPhone(String startPhone) { | ||
| 339 | - this.startPhone = startPhone; | 218 | + public void setEqLinecode(String eqLinecode) { |
| 219 | + this.eqLinecode = eqLinecode; | ||
| 340 | } | 220 | } |
| 341 | 221 | ||
| 342 | - public String getEndPhone() { | ||
| 343 | - return endPhone; | 222 | + @XmlJavaTypeAdapter(DateTimeAdapter.class) |
| 223 | + public Date getCreateDate() { | ||
| 224 | + return createDate; | ||
| 344 | } | 225 | } |
| 345 | 226 | ||
| 346 | - public void setEndPhone(String endPhone) { | ||
| 347 | - this.endPhone = endPhone; | 227 | + public void setCreateDate(Date createDate) { |
| 228 | + this.createDate = createDate; | ||
| 348 | } | 229 | } |
| 349 | 230 | ||
| 350 | - @XmlJavaTypeAdapter(DateAdapter_yMdHms.class) | ||
| 351 | - public Date getOpenDate() { | ||
| 352 | - return openDate; | 231 | + public Double getTotalMileage() { |
| 232 | + return totalMileage; | ||
| 353 | } | 233 | } |
| 354 | 234 | ||
| 355 | - public void setOpenDate(Date openDate) { | ||
| 356 | - this.openDate = openDate; | 235 | + public void setTotalMileage(Double totalMileage) { |
| 236 | + this.totalMileage = totalMileage; | ||
| 357 | } | 237 | } |
| 358 | 238 | ||
| 359 | - public String getHistory() { | ||
| 360 | - return history; | 239 | + public Double getEarlyIntervalLg() { |
| 240 | + return earlyIntervalLg; | ||
| 361 | } | 241 | } |
| 362 | 242 | ||
| 363 | - public void setHistory(String history) { | ||
| 364 | - this.history = history; | 243 | + public void setEarlyIntervalLg(Double earlyIntervalLg) { |
| 244 | + this.earlyIntervalLg = earlyIntervalLg; | ||
| 365 | } | 245 | } |
| 366 | 246 | ||
| 367 | - public String getShanghaiLinecode() { | ||
| 368 | - return shanghaiLinecode; | 247 | + public Double getLateIntervalLg() { |
| 248 | + return lateIntervalLg; | ||
| 369 | } | 249 | } |
| 370 | 250 | ||
| 371 | - public void setShanghaiLinecode(String shanghaiLinecode) { | ||
| 372 | - this.shanghaiLinecode = shanghaiLinecode; | 251 | + public void setLateIntervalLg(Double lateIntervalLg) { |
| 252 | + this.lateIntervalLg = lateIntervalLg; | ||
| 373 | } | 253 | } |
| 374 | 254 | ||
| 375 | - public String getEqLinecode() { | ||
| 376 | - return eqLinecode; | 255 | + public Double getIntervalLg() { |
| 256 | + return intervalLg; | ||
| 377 | } | 257 | } |
| 378 | 258 | ||
| 379 | - public void setEqLinecode(String eqLinecode) { | ||
| 380 | - this.eqLinecode = eqLinecode; | 259 | + public void setIntervalLg(Double intervalLg) { |
| 260 | + this.intervalLg = intervalLg; | ||
| 381 | } | 261 | } |
| 382 | 262 | ||
| 383 | - public Integer getWarrantCar() { | ||
| 384 | - return warrantCar; | 263 | + public Double getSpeedLimit() { |
| 264 | + return speedLimit; | ||
| 385 | } | 265 | } |
| 386 | 266 | ||
| 387 | - public void setWarrantCar(Integer warrantCar) { | ||
| 388 | - this.warrantCar = warrantCar; | 267 | + public void setSpeedLimit(Double speedLimit) { |
| 268 | + this.speedLimit = speedLimit; | ||
| 389 | } | 269 | } |
| 390 | 270 | ||
| 391 | - public Integer getLinePlayType() { | ||
| 392 | - return linePlayType; | 271 | + public Integer getLagStation() { |
| 272 | + return lagStation; | ||
| 393 | } | 273 | } |
| 394 | 274 | ||
| 395 | - public void setLinePlayType(Integer linePlayType) { | ||
| 396 | - this.linePlayType = linePlayType; | 275 | + public void setLagStation(Integer lagStation) { |
| 276 | + this.lagStation = lagStation; | ||
| 397 | } | 277 | } |
| 398 | 278 | ||
| 399 | - public String getDescriptions() { | ||
| 400 | - return descriptions; | 279 | + public Integer getSkip() { |
| 280 | + return skip; | ||
| 401 | } | 281 | } |
| 402 | 282 | ||
| 403 | - public void setDescriptions(String descriptions) { | ||
| 404 | - this.descriptions = descriptions; | 283 | + public void setSkip(Integer skip) { |
| 284 | + this.skip = skip; | ||
| 405 | } | 285 | } |
| 406 | 286 | ||
| 407 | - @XmlJavaTypeAdapter(DateAdapter_yMdHms.class) | ||
| 408 | - public Date getCreateDate() { | ||
| 409 | - return createDate; | 287 | + public Integer getSpeeding() { |
| 288 | + return speeding; | ||
| 410 | } | 289 | } |
| 411 | 290 | ||
| 412 | - public void setCreateDate(Date createDate) { | ||
| 413 | - this.createDate = createDate; | 291 | + public void setSpeeding(Integer speeding) { |
| 292 | + this.speeding = speeding; | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + public Integer getCrossedLine() { | ||
| 296 | + return crossedLine; | ||
| 297 | + } | ||
| 298 | + | ||
| 299 | + public void setCrossedLine(Integer crossedLine) { | ||
| 300 | + this.crossedLine = crossedLine; | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + public Integer getOverflights() { | ||
| 304 | + return overflights; | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + public void setOverflights(Integer overflights) { | ||
| 308 | + this.overflights = overflights; | ||
| 414 | } | 309 | } |
| 415 | } | 310 | } |
src/main/java/com/bsth/server_rs/base_info/line/buffer/LineRefreshThread.java
| @@ -25,7 +25,8 @@ public class LineRefreshThread extends Thread{ | @@ -25,7 +25,8 @@ public class LineRefreshThread extends Thread{ | ||
| 25 | public void run() { | 25 | public void run() { |
| 26 | 26 | ||
| 27 | try { | 27 | try { |
| 28 | - List<Line> list = jdbcTemplate.query("select * from bsth_c_line",BeanPropertyRowMapper.newInstance(Line.class)); | 28 | + List<Line> list = jdbcTemplate.query("SELECT t1. NAME,t1.line_code,t1.start_station_name,t1.end_station_name,t1.start_station_first_time,t1.start_station_end_time,t1.end_station_first_time,t1.end_station_end_time,t1.company,t1.branche_company,t1.nature,t1.`level`,t1.destroy,t1.supper_line,t1.eq_linecode,t1.create_date,t2.total_mileage,t2.early_interval_lg,t2.late_interval_lg,t2.interval_lg,t2.speed_limit,t2.lag_station,t2.skip,t2.speeding,t2.crossed_line,t2.overflights FROM bsth_c_line t1 LEFT JOIN bsth_c_line_information t2 ON t1.id = t2.line", |
| 29 | + BeanPropertyRowMapper.newInstance(Line.class)); | ||
| 29 | if(list != null && list.size() > 0) | 30 | if(list != null && list.size() > 0) |
| 30 | LineBufferData.replaceAll(list); | 31 | LineBufferData.replaceAll(list); |
| 31 | }catch (Exception e){ | 32 | }catch (Exception e){ |
src/main/java/com/bsth/server_rs/base_info/station/StationRestService.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.station; | ||
| 2 | + | ||
| 3 | +import com.bsth.server_rs.base_info.station.buffer.StationBufferData; | ||
| 4 | +import com.bsth.server_rs.base_info.station.entity.StationRotue; | ||
| 5 | +import org.springframework.stereotype.Component; | ||
| 6 | + | ||
| 7 | +import javax.ws.rs.GET; | ||
| 8 | +import javax.ws.rs.Path; | ||
| 9 | +import javax.ws.rs.PathParam; | ||
| 10 | +import javax.ws.rs.Produces; | ||
| 11 | +import javax.ws.rs.core.MediaType; | ||
| 12 | +import java.util.Collection; | ||
| 13 | +import java.util.Map; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * Created by panzhao on 2017/8/31. | ||
| 17 | + */ | ||
| 18 | +@Component | ||
| 19 | +@Path("/station") | ||
| 20 | +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
| 21 | +public class StationRestService { | ||
| 22 | + | ||
| 23 | + @GET | ||
| 24 | + @Path("/{company}") | ||
| 25 | + public Map<String, Collection<StationRotue>> findByCompany(@PathParam("company") String company){ | ||
| 26 | + return StationBufferData.findRouteByCompany(company); | ||
| 27 | + } | ||
| 28 | +} |
src/main/java/com/bsth/server_rs/base_info/station/buffer/StationBufferData.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.station.buffer; | ||
| 2 | + | ||
| 3 | +import com.bsth.Application; | ||
| 4 | +import com.bsth.server_rs.base_info.line.Line; | ||
| 5 | +import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | ||
| 6 | +import com.bsth.server_rs.base_info.station.entity.Station; | ||
| 7 | +import com.bsth.server_rs.base_info.station.entity.StationRotue; | ||
| 8 | +import com.google.common.collect.ArrayListMultimap; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.boot.CommandLineRunner; | ||
| 11 | +import org.springframework.core.annotation.Order; | ||
| 12 | +import org.springframework.stereotype.Component; | ||
| 13 | + | ||
| 14 | +import java.util.*; | ||
| 15 | +import java.util.concurrent.TimeUnit; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * 站点数据缓存(自更新) | ||
| 19 | + * Created by panzhao on 2017/3/27. | ||
| 20 | + */ | ||
| 21 | +@Component | ||
| 22 | +@Order(6) | ||
| 23 | +public class StationBufferData implements CommandLineRunner { | ||
| 24 | + | ||
| 25 | + @Autowired | ||
| 26 | + StationRefreshThread stationRefreshThread; | ||
| 27 | + | ||
| 28 | + private static List<Station> data; | ||
| 29 | + private static Map<String, Station> codeMap; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + 路由缓存 | ||
| 33 | + 线路编码_上下行 ——> 路由集合 | ||
| 34 | + */ | ||
| 35 | + private static ArrayListMultimap<String, StationRotue> routeListMap; | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + public static List<Station> findAll(){ | ||
| 39 | + return data; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public static Map<String, Collection<StationRotue>> findAllRoute(){ | ||
| 43 | + return routeListMap.asMap(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public static Station findOne(String code){ | ||
| 47 | + return codeMap.get(code); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public static void replaceAll(List<Station> newData){ | ||
| 51 | + data = newData; | ||
| 52 | + Map<String, Station> codeMapCopy = new HashMap<>(); | ||
| 53 | + for(Station station : data){ | ||
| 54 | + codeMapCopy.put(station.getStationCode(), station); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + codeMap = codeMapCopy; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public static void replaceRoutes(List<StationRotue> list){ | ||
| 61 | + Collections.sort(list, new Comparator<StationRotue>() { | ||
| 62 | + @Override | ||
| 63 | + public int compare(StationRotue o1, StationRotue o2) { | ||
| 64 | + return o1.getStationRouteCode().compareTo(o2.getStationRouteCode()); | ||
| 65 | + } | ||
| 66 | + }); | ||
| 67 | + | ||
| 68 | + ArrayListMultimap<String, StationRotue> routeListMapCopy = ArrayListMultimap.create(); | ||
| 69 | + for(StationRotue sr : list){ | ||
| 70 | + routeListMapCopy.put(sr.getLineCode()+"_" + sr.getDirections(), sr); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + routeListMap = routeListMapCopy; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public void run(String... strings) throws Exception { | ||
| 78 | + Application.mainServices.scheduleWithFixedDelay(stationRefreshThread, 10, 60 * 60, TimeUnit.SECONDS); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public static Map<String, Collection<StationRotue>> findRouteByCompany(String company) { | ||
| 82 | + List<Line> lines = LineBufferData.findByCompany(company); | ||
| 83 | + | ||
| 84 | + ArrayListMultimap<String, StationRotue> listMap = ArrayListMultimap.create(); | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + Set<String> ks = routeListMap.keySet(); | ||
| 88 | + | ||
| 89 | + for(String k : ks){ | ||
| 90 | + if(include(lines, k)){ | ||
| 91 | + listMap.putAll(k, routeListMap.get(k)); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + return listMap.asMap(); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + private static boolean include(List<Line> lines, String k){ | ||
| 98 | + | ||
| 99 | + for(Line line : lines){ | ||
| 100 | + if(k.startsWith(line.getLineCode() + "_")) | ||
| 101 | + return true; | ||
| 102 | + } | ||
| 103 | + return false; | ||
| 104 | + } | ||
| 105 | +} |
src/main/java/com/bsth/server_rs/base_info/station/buffer/StationRefreshThread.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.station.buffer; | ||
| 2 | + | ||
| 3 | +import com.bsth.server_rs.base_info.station.entity.Station; | ||
| 4 | +import com.bsth.server_rs.base_info.station.entity.StationRotue; | ||
| 5 | +import org.slf4j.Logger; | ||
| 6 | +import org.slf4j.LoggerFactory; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 9 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 10 | +import org.springframework.stereotype.Component; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * Created by panzhao on 2017/3/27. | ||
| 16 | + */ | ||
| 17 | +@Component | ||
| 18 | +public class StationRefreshThread extends Thread{ | ||
| 19 | + | ||
| 20 | + @Autowired | ||
| 21 | + JdbcTemplate jdbcTemplate; | ||
| 22 | + | ||
| 23 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public void run() { | ||
| 27 | + | ||
| 28 | + try { | ||
| 29 | + //站点信息 | ||
| 30 | + List<Station> stationList = jdbcTemplate.query("SELECT station_cod AS station_code,station_name,g_lonx AS lon,g_laty AS lat,shapes_type,radius,g_polygon_grid AS polygon_grid,versions FROM bsth_c_station where destroy=0 ", | ||
| 31 | + BeanPropertyRowMapper.newInstance(Station.class)); | ||
| 32 | + | ||
| 33 | + if(stationList == null || stationList.size() == 0) | ||
| 34 | + return; | ||
| 35 | + StationBufferData.replaceAll(stationList); | ||
| 36 | + | ||
| 37 | + //站点路由信息 | ||
| 38 | + List<StationRotue> routeList = jdbcTemplate.query("select id, line, station_route_code, line_code,station_code,station_mark,distances, to_time,directions from bsth_c_stationroute", | ||
| 39 | + BeanPropertyRowMapper.newInstance(StationRotue.class)); | ||
| 40 | + | ||
| 41 | + for(StationRotue sr : routeList){ | ||
| 42 | + sr.setStation(StationBufferData.findOne(sr.getStationCode())); | ||
| 43 | + } | ||
| 44 | + StationBufferData.replaceRoutes(routeList); | ||
| 45 | + }catch (Exception e){ | ||
| 46 | + logger.error("", e); | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | +} |
src/main/java/com/bsth/server_rs/base_info/station/entity/Station.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.station.entity; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 站点信息 | ||
| 5 | + * Created by panzhao on 2017/8/31. | ||
| 6 | + */ | ||
| 7 | +public class Station { | ||
| 8 | + | ||
| 9 | + /** 站点编码 */ | ||
| 10 | + private String stationCode; | ||
| 11 | + | ||
| 12 | + /** 站点名称 */ | ||
| 13 | + private String stationName; | ||
| 14 | + | ||
| 15 | + /** WGS 经度 */ | ||
| 16 | + private Float lon; | ||
| 17 | + | ||
| 18 | + /** WGS 纬度 */ | ||
| 19 | + private Float lat; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 电子围栏类型 | ||
| 23 | + * | ||
| 24 | + * ------ r:圆形 | ||
| 25 | + * | ||
| 26 | + * ------ d:多边形 | ||
| 27 | + */ | ||
| 28 | + private String shapesType; | ||
| 29 | + | ||
| 30 | + /** 圆形半径 */ | ||
| 31 | + private Integer radius; | ||
| 32 | + | ||
| 33 | + /** 多边形 WGS 坐标 */ | ||
| 34 | + private String polygonGrid; | ||
| 35 | + | ||
| 36 | + /** 版本号 */ | ||
| 37 | + private Integer versions; | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + public String getStationName() { | ||
| 41 | + return stationName; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public void setStationName(String stationName) { | ||
| 45 | + this.stationName = stationName; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public String getShapesType() { | ||
| 49 | + return shapesType; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public void setShapesType(String shapesType) { | ||
| 53 | + this.shapesType = shapesType; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public Integer getRadius() { | ||
| 57 | + return radius; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setRadius(Integer radius) { | ||
| 61 | + this.radius = radius; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + | ||
| 65 | + public Integer getVersions() { | ||
| 66 | + return versions; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public void setVersions(Integer versions) { | ||
| 70 | + this.versions = versions; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public String getStationCode() { | ||
| 74 | + return stationCode; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public void setStationCode(String stationCode) { | ||
| 78 | + this.stationCode = stationCode; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public Float getLon() { | ||
| 82 | + return lon; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public void setLon(Float lon) { | ||
| 86 | + this.lon = lon; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public Float getLat() { | ||
| 90 | + return lat; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public void setLat(Float lat) { | ||
| 94 | + this.lat = lat; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public String getPolygonGrid() { | ||
| 98 | + return polygonGrid; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public void setPolygonGrid(String polygonGrid) { | ||
| 102 | + this.polygonGrid = polygonGrid; | ||
| 103 | + } | ||
| 104 | +} |
src/main/java/com/bsth/server_rs/base_info/station/entity/StationRotue.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.station.entity; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by panzhao on 2017/8/31. | ||
| 5 | + */ | ||
| 6 | +public class StationRotue { | ||
| 7 | + | ||
| 8 | + /** 线路编码 */ | ||
| 9 | + private String lineCode; | ||
| 10 | + | ||
| 11 | + /** 站点路由序号 */ | ||
| 12 | + private Integer stationRouteCode; | ||
| 13 | + | ||
| 14 | + private String stationCode; | ||
| 15 | + | ||
| 16 | + private Station station; | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 站点类型 | ||
| 20 | + * ------ B:起点站 | ||
| 21 | + * ------ Z:中途站 | ||
| 22 | + * ------ E:终点站 | ||
| 23 | + * ------ T:停车场 | ||
| 24 | + */ | ||
| 25 | + private String stationMark; | ||
| 26 | + | ||
| 27 | + /** 站点路由到站距离 */ | ||
| 28 | + private Double distances; | ||
| 29 | + | ||
| 30 | + /** 站点路由到站时间 */ | ||
| 31 | + private Double toTime; | ||
| 32 | + | ||
| 33 | + /** 首班时间 */ | ||
| 34 | + private String firstTime; | ||
| 35 | + | ||
| 36 | + /** 末班时间 */ | ||
| 37 | + private String endTime; | ||
| 38 | + | ||
| 39 | + /** 站点路由方向 */ | ||
| 40 | + private Integer directions; | ||
| 41 | + | ||
| 42 | + /** 版本号 */ | ||
| 43 | + private Integer versions; | ||
| 44 | + | ||
| 45 | + public String getLineCode() { | ||
| 46 | + return lineCode; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setLineCode(String lineCode) { | ||
| 50 | + this.lineCode = lineCode; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public Integer getStationRouteCode() { | ||
| 54 | + return stationRouteCode; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public void setStationRouteCode(Integer stationRouteCode) { | ||
| 58 | + this.stationRouteCode = stationRouteCode; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public Station getStation() { | ||
| 62 | + return station; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setStation(Station station) { | ||
| 66 | + this.station = station; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public String getStationMark() { | ||
| 70 | + return stationMark; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public void setStationMark(String stationMark) { | ||
| 74 | + this.stationMark = stationMark; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public Double getDistances() { | ||
| 78 | + return distances; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void setDistances(Double distances) { | ||
| 82 | + this.distances = distances; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public Double getToTime() { | ||
| 86 | + return toTime; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setToTime(Double toTime) { | ||
| 90 | + this.toTime = toTime; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public String getFirstTime() { | ||
| 94 | + return firstTime; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public void setFirstTime(String firstTime) { | ||
| 98 | + this.firstTime = firstTime; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public String getEndTime() { | ||
| 102 | + return endTime; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void setEndTime(String endTime) { | ||
| 106 | + this.endTime = endTime; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public Integer getDirections() { | ||
| 110 | + return directions; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void setDirections(Integer directions) { | ||
| 114 | + this.directions = directions; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public Integer getVersions() { | ||
| 118 | + return versions; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public void setVersions(Integer versions) { | ||
| 122 | + this.versions = versions; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public String getStationCode() { | ||
| 126 | + return stationCode; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public void setStationCode(String stationCode) { | ||
| 130 | + this.stationCode = stationCode; | ||
| 131 | + } | ||
| 132 | +} |
src/main/java/com/bsth/server_rs/gps/GpsRestService.java
| 1 | package com.bsth.server_rs.gps; | 1 | package com.bsth.server_rs.gps; |
| 2 | 2 | ||
| 3 | import com.bsth.server_rs.gps.buffer.GpsRealDataBuffer; | 3 | import com.bsth.server_rs.gps.buffer.GpsRealDataBuffer; |
| 4 | +import com.bsth.server_rs.gps.entity.GpsEntity; | ||
| 4 | 5 | ||
| 5 | import javax.ws.rs.GET; | 6 | import javax.ws.rs.GET; |
| 6 | import javax.ws.rs.Path; | 7 | import javax.ws.rs.Path; |
src/main/java/com/bsth/server_rs/gps/buffer/GpsRealDataBuffer.java
| 1 | package com.bsth.server_rs.gps.buffer; | 1 | package com.bsth.server_rs.gps.buffer; |
| 2 | 2 | ||
| 3 | import com.bsth.Application; | 3 | import com.bsth.Application; |
| 4 | -import com.bsth.server_rs.gps.GpsEntity; | 4 | +import com.bsth.server_rs.gps.entity.GpsEntity; |
| 5 | import org.springframework.beans.factory.annotation.Autowired; | 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | import org.springframework.boot.CommandLineRunner; | 6 | import org.springframework.boot.CommandLineRunner; |
| 7 | import org.springframework.core.annotation.Order; | 7 | import org.springframework.core.annotation.Order; |
src/main/java/com/bsth/server_rs/gps/buffer/GpsRefreshThread.java
| @@ -2,7 +2,7 @@ package com.bsth.server_rs.gps.buffer; | @@ -2,7 +2,7 @@ package com.bsth.server_rs.gps.buffer; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | -import com.bsth.server_rs.gps.GpsEntity; | 5 | +import com.bsth.server_rs.gps.entity.GpsEntity; |
| 6 | import com.bsth.util.ConfigUtil; | 6 | import com.bsth.util.ConfigUtil; |
| 7 | import org.apache.http.HttpEntity; | 7 | import org.apache.http.HttpEntity; |
| 8 | import org.apache.http.client.config.RequestConfig; | 8 | import org.apache.http.client.config.RequestConfig; |
src/main/java/com/bsth/server_rs/gps/dao/HistoryGpsDao.java
0 → 100644
src/main/java/com/bsth/server_rs/gps/GpsEntity.java renamed to src/main/java/com/bsth/server_rs/gps/entity/GpsEntity.java
src/main/java/com/bsth/server_rs/gps/entity/HistoryGpsEntity.java
0 → 100644
| 1 | +package com.bsth.server_rs.gps.entity; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 历史GPS | ||
| 5 | + * Created by panzhao on 2017/8/31. | ||
| 6 | + */ | ||
| 7 | +public class HistoryGpsEntity { | ||
| 8 | + | ||
| 9 | + /** 车辆自编号 */ | ||
| 10 | + private String nbbm; | ||
| 11 | + | ||
| 12 | + /** 设备号 */ | ||
| 13 | + private String deviceId; | ||
| 14 | + | ||
| 15 | + /** 线路编码 */ | ||
| 16 | + private String lineId; | ||
| 17 | + | ||
| 18 | + /** 上下行 */ | ||
| 19 | + private int upDown; | ||
| 20 | + | ||
| 21 | + /** 角度 */ | ||
| 22 | + private float direction; | ||
| 23 | + | ||
| 24 | + /** 经度 */ | ||
| 25 | + private double lon; | ||
| 26 | + | ||
| 27 | + /** 纬度 */ | ||
| 28 | + private double lat; | ||
| 29 | + | ||
| 30 | + /** gps 时间戳*/ | ||
| 31 | + private long ts; | ||
| 32 | + | ||
| 33 | + /** 站点编码 */ | ||
| 34 | + private String stopNo; | ||
| 35 | + | ||
| 36 | + /** 速度 */ | ||
| 37 | + private float speed; | ||
| 38 | + | ||
| 39 | + /** 进出站状态 */ | ||
| 40 | + private int inout_stop; | ||
| 41 | + | ||
| 42 | + /** 营运状态 */ | ||
| 43 | + private int state; | ||
| 44 | + | ||
| 45 | + public String getNbbm() { | ||
| 46 | + return nbbm; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setNbbm(String nbbm) { | ||
| 50 | + this.nbbm = nbbm; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public String getDeviceId() { | ||
| 54 | + return deviceId; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public void setDeviceId(String deviceId) { | ||
| 58 | + this.deviceId = deviceId; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public String getLineId() { | ||
| 62 | + return lineId; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setLineId(String lineId) { | ||
| 66 | + this.lineId = lineId; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public int getUpDown() { | ||
| 70 | + return upDown; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public void setUpDown(int upDown) { | ||
| 74 | + this.upDown = upDown; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public float getDirection() { | ||
| 78 | + return direction; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void setDirection(float direction) { | ||
| 82 | + this.direction = direction; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public double getLon() { | ||
| 86 | + return lon; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setLon(double lon) { | ||
| 90 | + this.lon = lon; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public double getLat() { | ||
| 94 | + return lat; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public void setLat(double lat) { | ||
| 98 | + this.lat = lat; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public long getTs() { | ||
| 102 | + return ts; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void setTs(long ts) { | ||
| 106 | + this.ts = ts; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public String getStopNo() { | ||
| 110 | + return stopNo; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void setStopNo(String stopNo) { | ||
| 114 | + this.stopNo = stopNo; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public float getSpeed() { | ||
| 118 | + return speed; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public void setSpeed(float speed) { | ||
| 122 | + this.speed = speed; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public int getInout_stop() { | ||
| 126 | + return inout_stop; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public void setInout_stop(int inout_stop) { | ||
| 130 | + this.inout_stop = inout_stop; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public int getState() { | ||
| 134 | + return state; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public void setState(int state) { | ||
| 138 | + this.state = state; | ||
| 139 | + } | ||
| 140 | +} |
src/main/java/com/bsth/server_rs/schedule/dto/ScheduleInOut.java
| @@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON; | @@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON; | ||
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | import com.bsth.entity.ScheduleRealInfo; | 5 | import com.bsth.entity.ScheduleRealInfo; |
| 6 | 6 | ||
| 7 | +import javax.xml.bind.annotation.XmlRootElement; | ||
| 8 | +import java.io.Serializable; | ||
| 7 | import java.util.ArrayList; | 9 | import java.util.ArrayList; |
| 8 | import java.util.List; | 10 | import java.util.List; |
| 9 | 11 | ||
| @@ -11,7 +13,8 @@ import java.util.List; | @@ -11,7 +13,8 @@ import java.util.List; | ||
| 11 | * 进出场班次数据 ---给停车场用的 | 13 | * 进出场班次数据 ---给停车场用的 |
| 12 | * Created by panzhao on 2017/8/24. | 14 | * Created by panzhao on 2017/8/24. |
| 13 | */ | 15 | */ |
| 14 | -public class ScheduleInOut { | 16 | +@XmlRootElement |
| 17 | +public class ScheduleInOut implements Serializable { | ||
| 15 | 18 | ||
| 16 | public static List<ScheduleInOut> getMultiInstance(List<ScheduleRealInfo> list, String tccCode){ | 19 | public static List<ScheduleInOut> getMultiInstance(List<ScheduleRealInfo> list, String tccCode){ |
| 17 | List<ScheduleInOut> rs = new ArrayList<>(); | 20 | List<ScheduleInOut> rs = new ArrayList<>(); |
src/main/java/com/bsth/server_rs/schedule/dto/ScheduleRealInfoDTO_JK.java
0 → 100644
| 1 | +package com.bsth.server_rs.schedule.dto; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.ChildTaskPlan; | ||
| 4 | +import com.bsth.entity.ScheduleRealInfo; | ||
| 5 | + | ||
| 6 | +import javax.xml.bind.annotation.XmlRootElement; | ||
| 7 | +import java.io.Serializable; | ||
| 8 | +import java.util.*; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 输出给监控平台的实际排班 | ||
| 12 | + * Created by panzhao on 2017/8/30. | ||
| 13 | + */ | ||
| 14 | +@XmlRootElement | ||
| 15 | +public class ScheduleRealInfoDTO_JK implements Serializable { | ||
| 16 | + | ||
| 17 | + public static List<ScheduleRealInfoDTO_JK> getMultiInstance(List<ScheduleRealInfo> list){ | ||
| 18 | + Collections.sort(list, new Comparator<ScheduleRealInfo>() { | ||
| 19 | + @Override | ||
| 20 | + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | ||
| 21 | + return o1.getFcsj().compareTo(o2.getFcsj()); | ||
| 22 | + } | ||
| 23 | + }); | ||
| 24 | + | ||
| 25 | + List<ScheduleRealInfoDTO_JK> rs = new ArrayList<>(); | ||
| 26 | + ScheduleRealInfoDTO_JK s; | ||
| 27 | + for(ScheduleRealInfo sch : list){ | ||
| 28 | + s = new ScheduleRealInfoDTO_JK(sch); | ||
| 29 | + if(!s.getId().toString().equals("2740904")) | ||
| 30 | + continue; | ||
| 31 | + rs.add(s); | ||
| 32 | + } | ||
| 33 | + return rs; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + ScheduleRealInfoDTO_JK(){} | ||
| 37 | + | ||
| 38 | + ScheduleRealInfoDTO_JK(ScheduleRealInfo sch){ | ||
| 39 | + this.id = sch.getId(); | ||
| 40 | + this.scheduleDate = sch.getScheduleDateStr(); | ||
| 41 | + this.lineName = sch.getXlName(); | ||
| 42 | + this.lineCode = sch.getXlBm(); | ||
| 43 | + this.lpName = sch.getLpName(); | ||
| 44 | + this.nbbm = sch.getClZbh(); | ||
| 45 | + this.jsy = sch.getjGh() + "/" + sch.getjName(); | ||
| 46 | + this.spy = sch.getsGh() + "/" + sch.getsName(); | ||
| 47 | + this.upDown = Integer.parseInt(sch.getXlDir()); | ||
| 48 | + this.qdzCode = sch.getQdzCode(); | ||
| 49 | + this.qdzName = sch.getQdzName(); | ||
| 50 | + this.zdzCode = sch.getZdzCode(); | ||
| 51 | + this.zdzName = sch.getZdzName(); | ||
| 52 | + this.fcsjT = sch.getFcsjT(); | ||
| 53 | + this.dfsjT = sch.getDfsjT(); | ||
| 54 | + this.zdsjT = sch.getZdsjT(); | ||
| 55 | + this.fcsjActualTime = sch.getFcsjActualTime(); | ||
| 56 | + this.zdsjActualTime = sch.getZdsjActualTime(); | ||
| 57 | + this.jhlc = sch.getJhlc(); | ||
| 58 | + this.jhlcOrig = sch.getJhlcOrig(); | ||
| 59 | + this.bcsj = sch.getBcsj(); | ||
| 60 | + this.bcType = sch.getBcType(); | ||
| 61 | + this.status = sch.getStatus(); | ||
| 62 | + this.adjustExps = sch.getAdjustExps(); | ||
| 63 | + this.sflj = sch.isSflj(); | ||
| 64 | + this.remarks = sch.getRemarks(); | ||
| 65 | + this.cTasks = sch.getcTasks(); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + private Long id; | ||
| 69 | + | ||
| 70 | + private String scheduleDate; | ||
| 71 | + | ||
| 72 | + /** 线路名称 */ | ||
| 73 | + private String lineName; | ||
| 74 | + /** 线路编码 */ | ||
| 75 | + private String lineCode; | ||
| 76 | + | ||
| 77 | + /** 路牌名称 */ | ||
| 78 | + private String lpName; | ||
| 79 | + | ||
| 80 | + /** 车辆自编号 */ | ||
| 81 | + private String nbbm; | ||
| 82 | + | ||
| 83 | + /** 驾驶员工号/名称 */ | ||
| 84 | + private String jsy; | ||
| 85 | + /** 售票员工号/名称 */ | ||
| 86 | + private String spy; | ||
| 87 | + | ||
| 88 | + /** 线路方向 */ | ||
| 89 | + private Integer upDown; | ||
| 90 | + /** 起点站code*/ | ||
| 91 | + private String qdzCode; | ||
| 92 | + /** 起点站名字 */ | ||
| 93 | + private String qdzName; | ||
| 94 | + | ||
| 95 | + /** 终点站code*/ | ||
| 96 | + private String zdzCode; | ||
| 97 | + /** 终点站名字 */ | ||
| 98 | + private String zdzName; | ||
| 99 | + | ||
| 100 | + /** 计划发车时间戳*/ | ||
| 101 | + private Long fcsjT; | ||
| 102 | + /**待发时间戳 */ | ||
| 103 | + private Long dfsjT; | ||
| 104 | + /** 计划终点时间戳*/ | ||
| 105 | + private Long zdsjT; | ||
| 106 | + | ||
| 107 | + /** 实际发车时间戳*/ | ||
| 108 | + private Long fcsjActualTime; | ||
| 109 | + /** 实际终点时间戳*/ | ||
| 110 | + private Long zdsjActualTime; | ||
| 111 | + | ||
| 112 | + /** 实际计划里程 */ | ||
| 113 | + private Double jhlc; | ||
| 114 | + | ||
| 115 | + /** 计划里程 */ | ||
| 116 | + private Double jhlcOrig; | ||
| 117 | + | ||
| 118 | + /** 班次历时 */ | ||
| 119 | + private Integer bcsj; | ||
| 120 | + | ||
| 121 | + /** | ||
| 122 | + * 班次类型 TODO:正常班次、出场、进场、加油、区间班次、放空班次、放大站班次、两点间空驶 | ||
| 123 | + */ | ||
| 124 | + private String bcType; | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + /**班次状态 0 未执行 1 正在执行 2 已执行 -1 已烂班 */ | ||
| 128 | + private int status; | ||
| 129 | + | ||
| 130 | + private String adjustExps; | ||
| 131 | + | ||
| 132 | + /** 是否是临加班次 */ | ||
| 133 | + private boolean sflj; | ||
| 134 | + | ||
| 135 | + /** 备注*/ | ||
| 136 | + private String remarks; | ||
| 137 | + | ||
| 138 | + /** 子任务 */ | ||
| 139 | + private Set<ChildTaskPlan> cTasks; | ||
| 140 | + | ||
| 141 | + public Long getId() { | ||
| 142 | + return id; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public void setId(Long id) { | ||
| 146 | + this.id = id; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + public String getScheduleDate() { | ||
| 150 | + return scheduleDate; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + public void setScheduleDate(String scheduleDate) { | ||
| 154 | + this.scheduleDate = scheduleDate; | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + public String getLineName() { | ||
| 158 | + return lineName; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + public void setLineName(String lineName) { | ||
| 162 | + this.lineName = lineName; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + public String getLineCode() { | ||
| 166 | + return lineCode; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + public void setLineCode(String lineCode) { | ||
| 170 | + this.lineCode = lineCode; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + public String getLpName() { | ||
| 174 | + return lpName; | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + public void setLpName(String lpName) { | ||
| 178 | + this.lpName = lpName; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + public String getNbbm() { | ||
| 182 | + return nbbm; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + public void setNbbm(String nbbm) { | ||
| 186 | + this.nbbm = nbbm; | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + public String getJsy() { | ||
| 190 | + return jsy; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + public void setJsy(String jsy) { | ||
| 194 | + this.jsy = jsy; | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + public String getSpy() { | ||
| 198 | + return spy; | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + public void setSpy(String spy) { | ||
| 202 | + this.spy = spy; | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + public String getQdzCode() { | ||
| 206 | + return qdzCode; | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + public void setQdzCode(String qdzCode) { | ||
| 210 | + this.qdzCode = qdzCode; | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + public String getQdzName() { | ||
| 214 | + return qdzName; | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + public void setQdzName(String qdzName) { | ||
| 218 | + this.qdzName = qdzName; | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + public String getZdzCode() { | ||
| 222 | + return zdzCode; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + public void setZdzCode(String zdzCode) { | ||
| 226 | + this.zdzCode = zdzCode; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + public String getZdzName() { | ||
| 230 | + return zdzName; | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + public void setZdzName(String zdzName) { | ||
| 234 | + this.zdzName = zdzName; | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + public Long getFcsjT() { | ||
| 238 | + return fcsjT; | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + public void setFcsjT(Long fcsjT) { | ||
| 242 | + this.fcsjT = fcsjT; | ||
| 243 | + } | ||
| 244 | + | ||
| 245 | + public Long getDfsjT() { | ||
| 246 | + return dfsjT; | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + public void setDfsjT(Long dfsjT) { | ||
| 250 | + this.dfsjT = dfsjT; | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + public Long getZdsjT() { | ||
| 254 | + return zdsjT; | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + public void setZdsjT(Long zdsjT) { | ||
| 258 | + this.zdsjT = zdsjT; | ||
| 259 | + } | ||
| 260 | + | ||
| 261 | + public Long getFcsjActualTime() { | ||
| 262 | + return fcsjActualTime; | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + public void setFcsjActualTime(Long fcsjActualTime) { | ||
| 266 | + this.fcsjActualTime = fcsjActualTime; | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + public Long getZdsjActualTime() { | ||
| 270 | + return zdsjActualTime; | ||
| 271 | + } | ||
| 272 | + | ||
| 273 | + public void setZdsjActualTime(Long zdsjActualTime) { | ||
| 274 | + this.zdsjActualTime = zdsjActualTime; | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + public Double getJhlc() { | ||
| 278 | + return jhlc; | ||
| 279 | + } | ||
| 280 | + | ||
| 281 | + public void setJhlc(Double jhlc) { | ||
| 282 | + this.jhlc = jhlc; | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | + public Double getJhlcOrig() { | ||
| 286 | + return jhlcOrig; | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + public void setJhlcOrig(Double jhlcOrig) { | ||
| 290 | + this.jhlcOrig = jhlcOrig; | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + public Integer getBcsj() { | ||
| 294 | + return bcsj; | ||
| 295 | + } | ||
| 296 | + | ||
| 297 | + public void setBcsj(Integer bcsj) { | ||
| 298 | + this.bcsj = bcsj; | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + public String getBcType() { | ||
| 302 | + return bcType; | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + public void setBcType(String bcType) { | ||
| 306 | + this.bcType = bcType; | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | + public int getStatus() { | ||
| 310 | + return status; | ||
| 311 | + } | ||
| 312 | + | ||
| 313 | + public void setStatus(int status) { | ||
| 314 | + this.status = status; | ||
| 315 | + } | ||
| 316 | + | ||
| 317 | + public String getAdjustExps() { | ||
| 318 | + return adjustExps; | ||
| 319 | + } | ||
| 320 | + | ||
| 321 | + public void setAdjustExps(String adjustExps) { | ||
| 322 | + this.adjustExps = adjustExps; | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + public boolean isSflj() { | ||
| 326 | + return sflj; | ||
| 327 | + } | ||
| 328 | + | ||
| 329 | + public void setSflj(boolean sflj) { | ||
| 330 | + this.sflj = sflj; | ||
| 331 | + } | ||
| 332 | + | ||
| 333 | + public String getRemarks() { | ||
| 334 | + return remarks; | ||
| 335 | + } | ||
| 336 | + | ||
| 337 | + public void setRemarks(String remarks) { | ||
| 338 | + this.remarks = remarks; | ||
| 339 | + } | ||
| 340 | + | ||
| 341 | + public Set<ChildTaskPlan> getcTasks() { | ||
| 342 | + return cTasks; | ||
| 343 | + } | ||
| 344 | + | ||
| 345 | + public void setcTasks(Set<ChildTaskPlan> cTasks) { | ||
| 346 | + this.cTasks = cTasks; | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + public Integer getUpDown() { | ||
| 350 | + return upDown; | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + public void setUpDown(Integer upDown) { | ||
| 354 | + this.upDown = upDown; | ||
| 355 | + } | ||
| 356 | +} |
src/main/java/com/bsth/server_rs/schedule/real/ScheduleRealService.java
| @@ -2,7 +2,10 @@ package com.bsth.server_rs.schedule.real; | @@ -2,7 +2,10 @@ package com.bsth.server_rs.schedule.real; | ||
| 2 | 2 | ||
| 3 | import com.bsth.common.BasicData; | 3 | import com.bsth.common.BasicData; |
| 4 | import com.bsth.redis.ScheduleRedisService; | 4 | import com.bsth.redis.ScheduleRedisService; |
| 5 | +import com.bsth.server_rs.base_info.line.Line; | ||
| 6 | +import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | ||
| 5 | import com.bsth.server_rs.schedule.dto.ScheduleInOut; | 7 | import com.bsth.server_rs.schedule.dto.ScheduleInOut; |
| 8 | +import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK; | ||
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
| 8 | 11 | ||
| @@ -20,7 +23,7 @@ import java.util.Set; | @@ -20,7 +23,7 @@ import java.util.Set; | ||
| 20 | */ | 23 | */ |
| 21 | @Component | 24 | @Component |
| 22 | @Path("/schedule_real") | 25 | @Path("/schedule_real") |
| 23 | -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | 26 | +@Produces({MediaType.APPLICATION_JSON}) |
| 24 | public class ScheduleRealService { | 27 | public class ScheduleRealService { |
| 25 | 28 | ||
| 26 | @Autowired | 29 | @Autowired |
| @@ -28,17 +31,30 @@ public class ScheduleRealService { | @@ -28,17 +31,30 @@ public class ScheduleRealService { | ||
| 28 | 31 | ||
| 29 | /** | 32 | /** |
| 30 | * 获取当天指定停车场的进出场排班数据 | 33 | * 获取当天指定停车场的进出场排班数据 |
| 34 | + * | ||
| 31 | * @return | 35 | * @return |
| 32 | */ | 36 | */ |
| 33 | @GET | 37 | @GET |
| 34 | @Path("/in_out/{code}") | 38 | @Path("/in_out/{code}") |
| 35 | - public List<ScheduleInOut> findInOut(@PathParam("code") String code){ | 39 | + public List<ScheduleInOut> findInOut(@PathParam("code") String code) { |
| 36 | Set<String> lineArray = BasicData.lineDateMap.keySet(); | 40 | Set<String> lineArray = BasicData.lineDateMap.keySet(); |
| 37 | 41 | ||
| 38 | List<ScheduleInOut> all = new ArrayList<>(); | 42 | List<ScheduleInOut> all = new ArrayList<>(); |
| 39 | - for(String lineCode : lineArray){ | 43 | + for (String lineCode : lineArray) { |
| 40 | all.addAll(ScheduleInOut.getMultiInstance(redisService.read(BasicData.lineDateMap.get(lineCode), lineCode), code)); | 44 | all.addAll(ScheduleInOut.getMultiInstance(redisService.read(BasicData.lineDateMap.get(lineCode), lineCode), code)); |
| 41 | } | 45 | } |
| 42 | return all; | 46 | return all; |
| 43 | } | 47 | } |
| 48 | + | ||
| 49 | + @GET | ||
| 50 | + @Path("/sch_jk/{company}/{rq}") | ||
| 51 | + public List<ScheduleRealInfoDTO_JK> find_JK(@PathParam("company") String company, @PathParam("rq") String rq) { | ||
| 52 | + List<ScheduleRealInfoDTO_JK> all = new ArrayList<>(); | ||
| 53 | + | ||
| 54 | + List<Line> lines = LineBufferData.findByCompany(company); | ||
| 55 | + for(Line line : lines){ | ||
| 56 | + all.addAll(ScheduleRealInfoDTO_JK.getMultiInstance(redisService.read(rq, line.getLineCode()))); | ||
| 57 | + } | ||
| 58 | + return all; | ||
| 59 | + } | ||
| 44 | } | 60 | } |