Commit c599034000d03a67102e052c8ca84c4c0b51b237
1 parent
9743706c
1.青浦调度库损坏迁移至GPS库
2.开放数据库实时路单查询
Showing
6 changed files
with
112 additions
and
61 deletions
src/main/java/com/bsth/redis/ScheduleRedisService.java
| ... | ... | @@ -282,7 +282,7 @@ public class ScheduleRedisService implements CommandLineRunner { |
| 282 | 282 | private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"), |
| 283 | 283 | fmtHHmm = DateTimeFormat.forPattern("HH:mm"); |
| 284 | 284 | |
| 285 | - private void calcTime(List<ScheduleRealInfo> list) { | |
| 285 | + public void calcTime(List<ScheduleRealInfo> list) { | |
| 286 | 286 | if (list.size() == 0) |
| 287 | 287 | return; |
| 288 | 288 | ... | ... |
src/main/java/com/bsth/repository/ScheduleRealInfoRepository.java
| ... | ... | @@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.Query; |
| 6 | 6 | import org.springframework.data.repository.PagingAndSortingRepository; |
| 7 | 7 | import org.springframework.stereotype.Repository; |
| 8 | 8 | |
| 9 | +import java.util.Date; | |
| 9 | 10 | import java.util.List; |
| 10 | 11 | |
| 11 | 12 | @Repository |
| ... | ... | @@ -38,4 +39,24 @@ public interface ScheduleRealInfoRepository extends PagingAndSortingRepository<S |
| 38 | 39 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 39 | 40 | @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr>?1") |
| 40 | 41 | List<ScheduleRealInfo> findByDateLT(String schDate); |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 根据日期和公司编码获取班次信息 | |
| 45 | + * @param schDate | |
| 46 | + * @param companyCode | |
| 47 | + * @return | |
| 48 | + */ | |
| 49 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 50 | + @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1 and s.gsBm=?2") | |
| 51 | + List<ScheduleRealInfo> findByDateAndCompany(String schDate, String companyCode); | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * 根据日期和公司编码获取班次信息 | |
| 55 | + * @param schDate | |
| 56 | + * @param companyCode | |
| 57 | + * @return | |
| 58 | + */ | |
| 59 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 60 | + @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1 and s.gsBm=?2 and s.updateDate>=?3") | |
| 61 | + List<ScheduleRealInfo> findByDateAndCompany(String schDate, String companyCode, Date timestamp); | |
| 41 | 62 | } | ... | ... |
src/main/java/com/bsth/server_rs/schedule/real/ScheduleRealService.java
| ... | ... | @@ -7,6 +7,7 @@ import com.bsth.common.BasicData; |
| 7 | 7 | import com.bsth.common.ResponseCode; |
| 8 | 8 | import com.bsth.entity.ScheduleRealInfo; |
| 9 | 9 | import com.bsth.redis.ScheduleRedisService; |
| 10 | +import com.bsth.repository.ScheduleRealInfoRepository; | |
| 10 | 11 | import com.bsth.server_rs.base_info.line.Line; |
| 11 | 12 | import com.bsth.server_rs.base_info.line.buffer.LineBufferData; |
| 12 | 13 | import com.bsth.server_rs.schedule.dto.ScheduleCcInfoConfig; |
| ... | ... | @@ -16,6 +17,9 @@ import com.bsth.util.ConfigUtil; |
| 16 | 17 | import com.bsth.util.HttpClientUtils; |
| 17 | 18 | import com.google.common.base.Splitter; |
| 18 | 19 | import org.apache.commons.lang3.StringUtils; |
| 20 | +import org.joda.time.DateTime; | |
| 21 | +import org.joda.time.format.DateTimeFormat; | |
| 22 | +import org.joda.time.format.DateTimeFormatter; | |
| 19 | 23 | import org.slf4j.Logger; |
| 20 | 24 | import org.slf4j.LoggerFactory; |
| 21 | 25 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -40,6 +44,9 @@ public class ScheduleRealService { |
| 40 | 44 | @Autowired |
| 41 | 45 | SchRealDataBuffer schRealDataBuffer; |
| 42 | 46 | |
| 47 | + @Autowired | |
| 48 | + private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 49 | + | |
| 43 | 50 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 44 | 51 | |
| 45 | 52 | static String url; |
| ... | ... | @@ -199,6 +206,30 @@ public class ScheduleRealService { |
| 199 | 206 | return all; |
| 200 | 207 | } |
| 201 | 208 | |
| 209 | + @GET | |
| 210 | + @Path("/sch_jk_db/{company}/{rq}") | |
| 211 | + public List<ScheduleRealInfoDTO_JK> sch_jk(@PathParam("company") String company, @PathParam("rq") String rq) { | |
| 212 | + DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyyMMdd"); | |
| 213 | + DateTime dateTime = fmt.parseDateTime(rq); | |
| 214 | + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.findByDateAndCompany(dateTime.toString("yyyy-MM-dd"), company); | |
| 215 | + redisService.calcTime(scheduleRealInfos); | |
| 216 | + List<ScheduleRealInfoDTO_JK> result = ScheduleRealInfoDTO_JK.getMultiInstance(scheduleRealInfos); | |
| 217 | + | |
| 218 | + return result; | |
| 219 | + } | |
| 220 | + | |
| 221 | + @GET | |
| 222 | + @Path("/sch_jk4modify/{company}/{rq}/{timestamp}") | |
| 223 | + public List<ScheduleRealInfoDTO_JK> sch_jk4modify(@PathParam("company") String company, @PathParam("rq") String rq, @PathParam("timestamp") long timestamp) { | |
| 224 | + DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyyMMdd"); | |
| 225 | + DateTime dateTime = fmt.parseDateTime(rq); | |
| 226 | + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.findByDateAndCompany(dateTime.toString("yyyy-MM-dd"), company, new Date(timestamp)); | |
| 227 | + redisService.calcTime(scheduleRealInfos); | |
| 228 | + List<ScheduleRealInfoDTO_JK> result = ScheduleRealInfoDTO_JK.getMultiInstance(scheduleRealInfos); | |
| 229 | + | |
| 230 | + return result; | |
| 231 | + } | |
| 232 | + | |
| 202 | 233 | /** |
| 203 | 234 | * 读取指定日期的redis 数据,计算程序调用 |
| 204 | 235 | * | ... | ... |
src/main/resources/application-prod.properties
| 1 | -server.port=9089 | |
| 2 | -management.port= 9001 | |
| 3 | -management.address= 127.0.0.1 | |
| 4 | - | |
| 5 | -spring.jpa.hibernate.ddl-auto= none | |
| 6 | -spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy | |
| 7 | -#DATABASE | |
| 8 | -spring.jpa.database= MYSQL | |
| 9 | -spring.jpa.show-sql= false | |
| 10 | -spring.datasource.driver-class-name= com.mysql.jdbc.Driver | |
| 11 | -spring.datasource.url= jdbc:mysql://192.168.40.100:3306/qp_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 12 | -spring.datasource.username= root | |
| 13 | -spring.datasource.password= root@JSP2jsp | |
| 14 | -#DATASOURCE | |
| 15 | -spring.datasource.max-active=100 | |
| 16 | -spring.datasource.max-idle=8 | |
| 17 | -spring.datasource.min-idle=8 | |
| 18 | -spring.datasource.initial-size=3 | |
| 19 | - | |
| 20 | -spring.datasource.test-on-borrow=true | |
| 21 | -spring.datasource.test-on-connect=true | |
| 22 | -spring.datasource.test-on-return=true | |
| 23 | -spring.datasource.test-while-idle=true | |
| 24 | -spring.datasource.validation-query=select 1 | |
| 25 | - | |
| 26 | -#REDIS | |
| 27 | -spring.redis.database=0 | |
| 28 | -spring.redis.host=192.168.50.120 | |
| 29 | -spring.redis.password=bsth_control_001 | |
| 30 | -spring.redis.port=28008 | |
| 31 | - | |
| 32 | -http.control.service_data_url= http://192.168.40.82:9088/companyService | |
| 33 | -http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki | |
| 34 | - | |
| 1 | +server.port=9089 | |
| 2 | +management.port= 9001 | |
| 3 | +management.address= 127.0.0.1 | |
| 4 | + | |
| 5 | +spring.jpa.hibernate.ddl-auto= none | |
| 6 | +spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy | |
| 7 | +#DATABASE | |
| 8 | +spring.jpa.database= MYSQL | |
| 9 | +spring.jpa.show-sql= false | |
| 10 | +spring.datasource.driver-class-name= com.mysql.jdbc.Driver | |
| 11 | +spring.datasource.url= jdbc:mysql://192.168.40.82/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 12 | +spring.datasource.username= root | |
| 13 | +spring.datasource.password= 123456 | |
| 14 | +#DATASOURCE | |
| 15 | +spring.datasource.max-active=100 | |
| 16 | +spring.datasource.max-idle=8 | |
| 17 | +spring.datasource.min-idle=8 | |
| 18 | +spring.datasource.initial-size=3 | |
| 19 | + | |
| 20 | +spring.datasource.test-on-borrow=true | |
| 21 | +spring.datasource.test-on-connect=true | |
| 22 | +spring.datasource.test-on-return=true | |
| 23 | +spring.datasource.test-while-idle=true | |
| 24 | +spring.datasource.validation-query=select 1 | |
| 25 | + | |
| 26 | +#REDIS | |
| 27 | +spring.redis.database=0 | |
| 28 | +spring.redis.host=192.168.50.120 | |
| 29 | +spring.redis.password=bsth_control_001 | |
| 30 | +spring.redis.port=28008 | |
| 31 | + | |
| 32 | +http.control.service_data_url= http://192.168.40.82:9088/companyService | |
| 33 | +http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki | |
| 34 | + | |
| 35 | 35 | http.gps.real.url= http://192.168.40.82:8080/transport_server/rtgps/ |
| 36 | 36 | \ No newline at end of file | ... | ... |
src/main/resources/application.properties
| 1 | -spring.profiles: dev,prod | |
| 2 | -spring.profiles.active: prod | |
| 3 | - | |
| 4 | -spring.view.suffix=.html | |
| 5 | -server.session-timeout=-1 | |
| 6 | -security.basic.enabled=false | |
| 7 | - | |
| 8 | -# \u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u9650\u5236\u914D\u7F6E | |
| 9 | -# File size limit | |
| 10 | -multipart.maxFileSize = -1 | |
| 11 | -# Total request size for a multipart/form-data | |
| 12 | -multipart.maxRequestSize = -1 | |
| 13 | - | |
| 14 | -server.compression.enabled=true | |
| 15 | -server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript | |
| 16 | - | |
| 17 | -#redis | |
| 18 | -cache.days=15 | |
| 1 | +spring.profiles.active= prod | |
| 2 | + | |
| 3 | +spring.view.suffix=.html | |
| 4 | +server.session-timeout=-1 | |
| 5 | +security.basic.enabled=false | |
| 6 | + | |
| 7 | +# \u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u9650\u5236\u914D\u7F6E | |
| 8 | +# File size limit | |
| 9 | +multipart.maxFileSize = -1 | |
| 10 | +# Total request size for a multipart/form-data | |
| 11 | +multipart.maxRequestSize = -1 | |
| 12 | + | |
| 13 | +server.compression.enabled=true | |
| 14 | +server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript | |
| 15 | + | |
| 16 | +#redis | |
| 17 | +cache.days=15 | ... | ... |
src/main/resources/ms-jdbc.properties
| 1 | -#ms.mysql.driver= com.mysql.jdbc.Driver | |
| 2 | -#ms.mysql.url= jdbc:mysql://127.0.0.1:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 3 | -#ms.mysql.username= root | |
| 4 | -#ms.mysql.password= panzhao | |
| 5 | - | |
| 6 | -ms.mysql.driver= com.mysql.jdbc.Driver | |
| 7 | -ms.mysql.url= jdbc:mysql://192.168.40.82:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 8 | -ms.mysql.username= root | |
| 1 | +#ms.mysql.driver= com.mysql.jdbc.Driver | |
| 2 | +#ms.mysql.url= jdbc:mysql://127.0.0.1:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 3 | +#ms.mysql.username= root | |
| 4 | +#ms.mysql.password= panzhao | |
| 5 | + | |
| 6 | +ms.mysql.driver= com.mysql.jdbc.Driver | |
| 7 | +ms.mysql.url= jdbc:mysql://192.168.40.82/ms?useUnicode=true&characterEncoding=utf-8 | |
| 8 | +ms.mysql.username= root | |
| 9 | 9 | ms.mysql.password= 123456 |
| 10 | 10 | \ No newline at end of file | ... | ... |