Commit d3a02a96d55c722e04ebf4a8862690eeef511d3a

Authored by 潘钊
2 parents 6cd98b37 38ef3a7c

Merge branch 'minhang' into qingpu

# Conflicts:
#	src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
#	src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
#	src/main/resources/application-dev.properties
#	src/main/resources/static/index.html
#	src/main/resources/static/real_control_v2/css/line_schedule.css
#	src/main/resources/static/real_control_v2/js/data/json/north_toolbar.json
#	src/main/resources/static/real_control_v2/js/main.js
#	src/main/resources/static/real_control_v2/main.html
Showing 70 changed files with 2294 additions and 771 deletions

Too many changes to show.

To preserve performance only 70 of 2345 files are displayed.

.gitignore
... ... @@ -8,9 +8,11 @@ test_junitReport/
8 8 test_coverage/
9 9 .idea
10 10 .DS_Store
  11 +npm-debug.log
11 12 *.iml
12 13 tmp
  14 +E:/
13 15  
14 16 # git忽略空文件夹,按照惯例,空文件夹下放置.gitkeep文件避免文件夹被忽略不上传。
15   -!.gitkeep
16   -/target/
  17 +!.gitkeep
  18 +/target/
... ...
... ... @@ -24,7 +24,12 @@
24 24 <artifactId>spring-boot-starter-tomcat</artifactId>
25 25 <scope>provided</scope>
26 26 </dependency>
27   -
  27 + <dependency>
  28 + <groupId>javax.servlet</groupId>
  29 + <artifactId>javax.servlet-api</artifactId>
  30 + <version>3.1.0</version>
  31 + <scope>provided</scope>
  32 + </dependency>
28 33 <dependency>
29 34 <groupId>org.springframework.boot</groupId>
30 35 <artifactId>spring-boot-starter-security</artifactId>
... ... @@ -101,11 +106,11 @@
101 106 <artifactId>janino</artifactId>
102 107 </dependency>
103 108  
104   - <dependency>
105   - <groupId>org.apache.poi</groupId>
106   - <artifactId>poi</artifactId>
107   - <version>3.13</version>
108   - </dependency>
  109 + <dependency>
  110 + <groupId>org.apache.poi</groupId>
  111 + <artifactId>poi-ooxml</artifactId>
  112 + <version>3.13</version>
  113 + </dependency>
109 114  
110 115 <dependency>
111 116 <groupId>com.google.guava</groupId>
... ... @@ -229,6 +234,23 @@
229 234 <version>1.1</version>
230 235 </dependency>
231 236  
  237 + <dependency>
  238 + <groupId>org.apache.axis2</groupId>
  239 + <artifactId>axis2-adb</artifactId>
  240 + <version>1.7.4</version>
  241 + </dependency>
  242 + <dependency>
  243 + <groupId>org.apache.axis2</groupId>
  244 + <artifactId>axis2-transport-local</artifactId>
  245 + <version>1.7.4</version>
  246 + </dependency>
  247 + <dependency>
  248 + <groupId>org.apache.axis2</groupId>
  249 + <artifactId>axis2-transport-http</artifactId>
  250 + <version>1.7.4</version>
  251 + </dependency>
  252 +
  253 +
232 254 <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId>
233 255 <optional>true</optional> </dependency> -->
234 256 <dependency>
... ... @@ -264,6 +286,24 @@
264 286 <artifactId>ojdbc</artifactId>
265 287 <version>14</version>
266 288 </dependency>
  289 +
  290 + <dependency>
  291 + <groupId>org.apache.mina</groupId>
  292 + <artifactId>mina-core</artifactId>
  293 + <version>2.0.13</version>
  294 + </dependency>
  295 +
  296 + <dependency>
  297 + <groupId>com.google.protobuf</groupId>
  298 + <artifactId>protobuf-java</artifactId>
  299 + <version>3.3.0</version>
  300 + </dependency>
  301 +
  302 + <dependency>
  303 + <groupId>com.github.stuxuhai</groupId>
  304 + <artifactId>jpinyin</artifactId>
  305 + <version>1.1.8</version>
  306 + </dependency>
267 307 </dependencies>
268 308  
269 309 <dependencyManagement>
... ...
src/main/java/com/bsth/Application.java
... ... @@ -8,14 +8,16 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
8 8 import org.springframework.boot.context.web.SpringBootServletInitializer;
9 9 import org.springframework.context.annotation.Bean;
10 10 import org.springframework.context.annotation.Primary;
  11 +import org.springframework.transaction.annotation.EnableTransactionManagement;
11 12  
12 13 import java.util.concurrent.Executors;
13 14 import java.util.concurrent.ScheduledExecutorService;
14 15  
  16 +@EnableTransactionManagement
15 17 @SpringBootApplication
16 18 public class Application extends SpringBootServletInitializer {
17 19  
18   - public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(13);
  20 + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(15);
19 21  
20 22 @Override
21 23 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
... ...
src/main/java/com/bsth/ServiceStateTest.java deleted 100644 → 0
1   -package com.bsth;
2   -
3   -public class ServiceStateTest {
4   -
5   - public static void main(String[] args) {
6   - System.out.println("运营状态:" + getService(603979776));
7   - System.out.println("上下行:" + getUpOrDown(603979776));
8   - }
9   -
10   - /**
11   - * 获取运营状态
12   - *
13   - * @return -1无效 0运营 1未运营
14   - */
15   - public static byte getService(long serviceState) {
16   - if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000)
17   - return -1;
18   - return (byte) (((serviceState & 0x02000000) == 0x02000000) ? 1 : 0);
19   - }
20   -
21   - /**
22   - * 王通 2016/6/29 9:23:24 获取车辆线路上下行
23   - *
24   - * @return -1无效 0上行 1下行
25   - */
26   - public static byte getUpOrDown(long serviceState) {
27   - if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000
28   - || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000)
29   - return -1;
30   - return (byte) (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);
31   - }
32   -}
src/main/java/com/bsth/WebAppConfiguration.java
1 1 package com.bsth;
2 2  
3   -import javax.servlet.Filter;
4   -
5   -import org.springframework.beans.factory.annotation.Autowired;
  3 +import com.bsth.filter.ResourceFilter;
  4 +import com.bsth.websocket.WebSocketHandshakeInterceptor;
  5 +import com.bsth.websocket.handler.RealControlSocketHandler;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
6 8 import org.springframework.boot.context.embedded.FilterRegistrationBean;
7 9 import org.springframework.context.annotation.Bean;
8 10 import org.springframework.context.annotation.ComponentScan;
9 11 import org.springframework.context.annotation.Configuration;
10 12 import org.springframework.web.filter.CharacterEncodingFilter;
11 13 import org.springframework.web.filter.HttpPutFormContentFilter;
12   -import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
13 14 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
14 15 import org.springframework.web.socket.config.annotation.EnableWebSocket;
15 16 import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
16 17 import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
  18 +import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
17 19  
18   -import com.bsth.filter.ResourceFilter;
19   -import com.bsth.oplog.http.HttpOpLogInterceptor;
20   -import com.bsth.websocket.WebSocketHandshakeInterceptor;
21   -import com.bsth.websocket.handler.RealControlSocketHandler;
  20 +import javax.servlet.Filter;
22 21  
23 22 @Configuration
24 23 @EnableWebSocket
... ... @@ -27,6 +26,8 @@ public class WebAppConfiguration extends WebMvcConfigurerAdapter implements WebS
27 26  
28 27 // @Autowired
29 28 // HttpOpLogInterceptor httpOpLogInterceptor;
  29 +
  30 + Logger logger = LoggerFactory.getLogger(this.getClass());
30 31  
31 32 /**
32 33 * @Title: httpPutFormContentFilter
... ... @@ -75,4 +76,17 @@ public class WebAppConfiguration extends WebMvcConfigurerAdapter implements WebS
75 76 registry.addHandler(new RealControlSocketHandler(), "/sockjs/realcontrol").addInterceptors(new WebSocketHandshakeInterceptor())
76 77 .withSockJS();
77 78 }
  79 +
  80 + /**
  81 + * 增加websocket的输出缓冲区
  82 + * @return
  83 + */
  84 + @Bean
  85 + public ServletServerContainerFactoryBean createServletServerContainerFactoryBean() {
  86 + ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
  87 + container.setMaxTextMessageBufferSize(52768);
  88 + container.setMaxBinaryMessageBufferSize(52768);
  89 + logger.info("Websocket factory returned");
  90 + return container;
  91 + }
78 92 }
... ...
src/main/java/com/bsth/XDApplication.java 0 → 100644
  1 +package com.bsth;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.ThreadMonotor;
  5 +import com.bsth.data.car_out_info.UpdateDBThread;
  6 +import com.bsth.data.directive.DirectivesPstThread;
  7 +import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
  8 +import com.bsth.data.gpsdata.thread.OfflineMonitorThread;
  9 +import com.bsth.data.schedule.edit_logs.SeiPstThread;
  10 +import com.bsth.data.schedule.late_adjust.ScheduleLateThread;
  11 +import com.bsth.data.schedule.thread.CalcOilThread;
  12 +import com.bsth.data.schedule.thread.SchedulePstThread;
  13 +import com.bsth.data.schedule.thread.ScheduleRefreshThread;
  14 +import com.bsth.data.schedule.thread.SubmitToTrafficManage;
  15 +import com.bsth.util.DateUtils;
  16 +import com.bsth.util.Tools;
  17 +import org.slf4j.Logger;
  18 +import org.slf4j.LoggerFactory;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.boot.CommandLineRunner;
  21 +import org.springframework.stereotype.Component;
  22 +
  23 +import java.util.concurrent.ScheduledExecutorService;
  24 +import java.util.concurrent.TimeUnit;
  25 +
  26 +/**
  27 + * 线调大部分服务都在这里启动
  28 + * Created by panzhao on 2017/5/14.
  29 + */
  30 +@Component
  31 +public class XDApplication implements CommandLineRunner {
  32 +
  33 + Logger log = LoggerFactory.getLogger(this.getClass());
  34 +
  35 + @Autowired
  36 + BasicData.BasicDataLoader basicDataLoader;
  37 + @Autowired
  38 + UpdateDBThread fcxxUpdateThread;
  39 + @Autowired
  40 + GpsDataLoaderThread gpsDataLoader;
  41 + @Autowired
  42 + OfflineMonitorThread offlineMonitorThread;
  43 + @Autowired
  44 + ScheduleRefreshThread scheduleRefreshThread;
  45 + @Autowired
  46 + SchedulePstThread schedulePstThread;
  47 + @Autowired
  48 + ScheduleLateThread scheduleLateThread;
  49 + @Autowired
  50 + SubmitToTrafficManage submitToTrafficManage;
  51 + @Autowired
  52 + CalcOilThread calcOilThread;
  53 + @Autowired
  54 + DirectivesPstThread directivesPstThread;
  55 + @Autowired
  56 + ThreadMonotor threadMonotor;
  57 + @Autowired
  58 + SeiPstThread seiPstThread;
  59 +
  60 + private static long timeDiff;
  61 + private static long timeDiffTraffic;
  62 +
  63 + static {
  64 + // 早上2:20
  65 + timeDiff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis();
  66 + if (timeDiff < 0)
  67 + timeDiff += (1000 * 60 * 60 * 24);
  68 + // 早上07:00
  69 + timeDiffTraffic = (DateUtils.getTimestamp() + 1000 * 60 * 60 * 7) - System.currentTimeMillis();
  70 + if (timeDiffTraffic < 0)
  71 + timeDiffTraffic += (1000 * 60 * 60 * 24);
  72 + }
  73 +
  74 + @Override
  75 + public void run(String... strings) throws Exception {
  76 + try {
  77 + Tools tools = new Tools("application.properties");
  78 + String environment = tools.getValue("spring.profiles.active");
  79 + //预先加载基础的对照数据
  80 + basicDataLoader.loadAllData();
  81 + switch (environment){
  82 + case "dev":
  83 + devInit();
  84 + break;
  85 + case "prod":
  86 + prodInit();
  87 + break;
  88 + }
  89 + }catch (Exception e){
  90 + log.error("线调后台启动出现异常!!", e);
  91 + System.exit(1);
  92 + }
  93 + }
  94 +
  95 + //@Autowired
  96 + //DayOfSchedule dayOfSchedule;
  97 + public void devInit(){
  98 + log.info("devInit...");
  99 + ScheduledExecutorService sexec = Application.mainServices;
  100 + //抓取GPS数据
  101 + gpsDataLoader.setFlag(-1);
  102 + //dayOfSchedule.dataRecovery();
  103 + //sexec.scheduleWithFixedDelay(gpsDataLoader, 30, 2, TimeUnit.SECONDS);
  104 + //实际排班更新线程
  105 + //sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
  106 + //实际排班延迟入库线程
  107 + //sexec.scheduleWithFixedDelay(schedulePstThread, 60, 15, TimeUnit.SECONDS);
  108 + //班次修正日志延迟入库
  109 + //sexec.scheduleWithFixedDelay(seiPstThread, 60, 30, TimeUnit.SECONDS);
  110 + //调度指令延迟入库
  111 + //sexec.scheduleWithFixedDelay(directivesPstThread, 180, 180, TimeUnit.SECONDS);
  112 + //线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
  113 + //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);
  114 + }
  115 +
  116 + public void prodInit(){
  117 + log.info("prodInit...");
  118 + ScheduledExecutorService sexec = Application.mainServices;
  119 + //发车信息
  120 + sexec.scheduleWithFixedDelay(fcxxUpdateThread, 60, 40, TimeUnit.SECONDS);
  121 + //抓取GPS数据
  122 + sexec.scheduleWithFixedDelay(gpsDataLoader, 30, 2, TimeUnit.SECONDS);
  123 + //GPS设备掉离线
  124 + sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);
  125 + //班次更新线程
  126 + sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
  127 + //班次延迟入库线程
  128 + sexec.scheduleWithFixedDelay(schedulePstThread, 60, 10, TimeUnit.SECONDS);
  129 + //班次修正日志入库
  130 + sexec.scheduleWithFixedDelay(seiPstThread, 60, 60, TimeUnit.SECONDS);
  131 + //检查班次误点
  132 + sexec.scheduleWithFixedDelay(scheduleLateThread, 60, 30, TimeUnit.SECONDS);
  133 + //调度指令延迟入库
  134 + sexec.scheduleWithFixedDelay(directivesPstThread, 180, 100, TimeUnit.SECONDS);
  135 +
  136 + //运管处静态数据提交
  137 + log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处");
  138 + sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
  139 + //计算油、公里加注
  140 + sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
  141 +
  142 + //线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
  143 + sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);
  144 + }
  145 +}
... ...
src/main/java/com/bsth/controller/CarParkController.java
... ... @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
15 15 @RestController
16 16 @RequestMapping("carpark")
17 17 public class CarParkController extends BaseController<CarPark, Integer> {
18   -
19 18 @Autowired
20 19 CarParkService service;
21 20  
... ... @@ -26,16 +25,10 @@ public class CarParkController extends BaseController&lt;CarPark, Integer&gt; {
26 25 */
27 26 @RequestMapping(value="getCarParkCode" , method = RequestMethod.GET)
28 27 public Map<String, Object> getStationCode() {
29   -
30 28 Map<String, Object> resultMap = new HashMap<String, Object>();
31   -
32   - resultMap.put("carParkCode", "FFFF" + GetUIDAndCode.getCarParkId());
33   -
  29 + resultMap.put("carParkCode", "FFFFFF" + GetUIDAndCode.getCarParkId());
34 30 return resultMap;
35   -
36 31 }
37   -
38   -
39 32 /**
40 33 * 新增停车场信息
41 34 *
... ... @@ -53,21 +46,14 @@ public class CarParkController extends BaseController&lt;CarPark, Integer&gt; {
53 46 */
54 47 @RequestMapping(value="carParkSave" , method = RequestMethod.POST)
55 48 public Map<String, Object> stationSave(@RequestParam Map<String, Object> map) {
56   -
57 49 map.put("createBy", "");
58   -
59 50 map.put("updateBy", "");
60   -
61 51 return service.carParkSave(map);
62   -
63 52 }
64   -
65 53 @RequestMapping(value = "findCarParkInfoFormId",method = RequestMethod.GET)
66 54 public List<Map<String, Object>> findCarParkInfoFormId(@RequestParam Map<String, Object> map) {
67   -
68 55 return service.findCarParkInfoFormId(map);
69 56 }
70   -
71 57 /**
72 58 * 修改停车场信息
73 59 *
... ... @@ -85,11 +71,12 @@ public class CarParkController extends BaseController&lt;CarPark, Integer&gt; {
85 71 */
86 72 @RequestMapping(value="carParkUpdate" , method = RequestMethod.POST)
87 73 public Map<String, Object> carParkUpdate(@RequestParam Map<String, Object> map) {
88   -
89 74 map.put("updateBy", "");
90   -
91 75 return service.carParkUpdate(map);
92   -
93 76 }
94 77  
  78 + @RequestMapping(value="isHaveParkCode",method=RequestMethod.GET)
  79 + public boolean isHaveParkCode(@RequestParam Map<String,Object> map) {
  80 + return service.selectTccInfoByCode(map);
  81 + }
95 82 }
... ...
src/main/java/com/bsth/controller/PersonnelController.java
1 1 package com.bsth.controller;
2 2  
  3 +import com.bsth.common.Constants;
  4 +import com.bsth.data.pinyin.PersionPinYin;
  5 +import com.bsth.data.pinyin.PersionPinYinBuffer;
3 6 import com.bsth.entity.Personnel;
  7 +import com.bsth.entity.sys.CompanyAuthority;
4 8 import com.bsth.service.PersonnelService;
5 9 import org.springframework.beans.factory.annotation.Autowired;
6 10 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -8,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
8 12 import org.springframework.web.bind.annotation.RequestParam;
9 13 import org.springframework.web.bind.annotation.RestController;
10 14  
  15 +import javax.servlet.http.HttpServletRequest;
11 16 import java.util.List;
12 17 import java.util.Map;
13 18  
... ... @@ -21,8 +26,23 @@ public class PersonnelController extends BaseController&lt;Personnel, Integer&gt; {
21 26 @Autowired
22 27 private PersonnelService service;
23 28  
  29 + @Autowired
  30 + PersionPinYinBuffer persionPinYinBuffer;
  31 +
24 32 @RequestMapping(value = "/sreachPersonnel", method = RequestMethod.GET)
25 33 public List<Map<String, String>> sreachPersonnel(@RequestParam String jobCode) {
26 34 return service.sreachPersonnel(jobCode);
27 35 }
  36 +
  37 + @RequestMapping(value = "/all_py", method = RequestMethod.GET)
  38 + public List<PersionPinYin> findAll_PY(){
  39 + persionPinYinBuffer.refresh();
  40 + return persionPinYinBuffer.getAll();
  41 + }
  42 +
  43 + @RequestMapping(value = "/list_py", method = RequestMethod.GET)
  44 + public List<PersionPinYin> findByCurrUser_PY(HttpServletRequest request){
  45 + List<CompanyAuthority> auths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS);
  46 + return persionPinYinBuffer.getAll(auths);
  47 + }
28 48 }
... ...
src/main/java/com/bsth/controller/SectionController.java
... ... @@ -60,6 +60,26 @@ public class SectionController extends BaseController&lt;Section, Integer&gt; {
60 60 *
61 61 * @return Map<String, Object> <SUCCESS ; ERROR>
62 62 */
  63 + @RequestMapping(value="sectionCut" , method = RequestMethod.POST)
  64 + public Map<String, Object> sectionCut(@RequestParam Map<String, Object> map) {
  65 +
  66 + map.put("updateBy", "");
  67 +
  68 + map.put("createBy", "");
  69 +
  70 + map.put("createDate", "");
  71 +
  72 + return service.sectionCut(map);
  73 +
  74 + }
  75 +
  76 + /**
  77 + * @Description :TODO(编辑线路走向)
  78 + *
  79 + * @param map <sectionId:路段ID; sectionJSON:路段信息>
  80 + *
  81 + * @return Map<String, Object> <SUCCESS ; ERROR>
  82 + */
63 83 @RequestMapping(value="sectionUpdate" , method = RequestMethod.POST)
64 84 public Map<String, Object> sectionUpdate(@RequestParam Map<String, Object> map) {
65 85  
... ... @@ -74,6 +94,22 @@ public class SectionController extends BaseController&lt;Section, Integer&gt; {
74 94 }
75 95  
76 96 /**
  97 + * @Description :TODO(编辑缓存线路走向)
  98 + */
  99 + @RequestMapping(value="sectionCacheUpdate" , method = RequestMethod.POST)
  100 + public Map<String, Object> sectionCacheUpdate(@RequestParam Map<String, Object> map) {
  101 +
  102 + map.put("updateBy", "");
  103 +
  104 + map.put("createBy", "");
  105 +
  106 + map.put("createDate", "");
  107 +
  108 + return service.sectionCacheUpdate(map);
  109 +
  110 + }
  111 +
  112 + /**
77 113 * @Description :TODO(查询路段编码)
78 114 *
79 115 * @return int <sectionCode路段编码>
... ...
src/main/java/com/bsth/controller/SectionRouteController.java
... ... @@ -35,6 +35,16 @@ public class SectionRouteController extends BaseController&lt;SectionRoute, Integer
35 35 @Autowired
36 36 SectionRouteService routeService;
37 37  
  38 + /**
  39 + * @param String
  40 + * @throws
  41 + * @Description: TODO(批量撤销路段)
  42 + */
  43 + @RequestMapping(value = "/batchDestroy", method = RequestMethod.GET)
  44 + public Map<String, Object> updateBatch(@RequestParam Map<String, Object> map) {
  45 + return routeService.updateSectionRouteInfoFormId(map);
  46 + }
  47 +
38 48 /**
39 49 * @param @param map
40 50 * @throws
... ... @@ -60,6 +70,18 @@ public class SectionRouteController extends BaseController&lt;SectionRoute, Integer
60 70  
61 71  
62 72 /**
  73 + * @Description :TODO(查询路段信息)
  74 + *
  75 + * @param map <line.id_eq:线路ID; directions_eq:方向>
  76 + *
  77 + * @return Map<String, Object>
  78 + */
  79 + @RequestMapping(value = "/findSectionCache" , method = RequestMethod.GET)
  80 + public List<Map<String, Object>> findPointsCache(@RequestParam Map<String, Object> map) {
  81 + return routeService.getSectionRouteCache(map);
  82 + }
  83 +
  84 + /**
63 85 * @Description : TODO(根据路段路由Id查询详情)
64 86 *
65 87 * @param map <id:路段路由ID>
... ... @@ -78,7 +100,7 @@ public class SectionRouteController extends BaseController&lt;SectionRoute, Integer
78 100 *
79 101 * @return List<Map<String, Object>>
80 102 */
81   - @RequestMapping(value = "/findUpStationRouteCode" , method = RequestMethod.GET)
  103 + @RequestMapping(value = "/findUpSectionRouteCode" , method = RequestMethod.GET)
82 104 public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) {
83 105 return routeService.findUpSectionRouteCode(map);
84 106 }
... ...
src/main/java/com/bsth/controller/StationController.java
... ... @@ -8,6 +8,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
8 8 import org.springframework.web.bind.annotation.RequestParam;
9 9 import org.springframework.web.bind.annotation.RestController;
10 10  
  11 +import antlr.collections.List;
  12 +
11 13 import com.bsth.entity.Station;
12 14 import com.bsth.service.StationService;
13 15 import com.bsth.util.GetUIDAndCode;
... ... @@ -36,6 +38,17 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
36 38 private StationService service;
37 39  
38 40 /**
  41 + * @Description :TODO(根据坐标点匹配数据库中的站点)
  42 + *
  43 + * @param map: <point:坐标点; name:站点名>
  44 + *
  45 + */
  46 + @RequestMapping(value="matchStation" , method = RequestMethod.GET)
  47 + public Map<String, Object> matchStation(@RequestParam Map<String, Object> map) {
  48 + return service.matchStation(map);
  49 + }
  50 +
  51 + /**
39 52 * @Description :TODO(系统规划保存数据)
40 53 *
41 54 * @param map <stationJSON:站点信息;
... ... @@ -68,6 +81,11 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
68 81 return service.manualSave(map);
69 82 }
70 83  
  84 + @RequestMapping(value="cacheSave" , method = RequestMethod.POST)
  85 + public Map<String, Object> cacheSave(@RequestParam Map<String, Object> map) {
  86 + return service.cacheSave(map);
  87 + }
  88 +
71 89 /**
72 90 * @Description :TODO(新增站点保存)
73 91 *
... ... @@ -107,13 +125,9 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
107 125 */
108 126 @RequestMapping(value="stationUpdate" , method = RequestMethod.POST)
109 127 public Map<String, Object> stationUpdate(@RequestParam Map<String, Object> map) {
110   -
111 128 map.put("updateBy", "");
112   -
113 129 return service.stationUpdate(map);
114   -
115 130 }
116   -
117 131 /**
118 132 * @Description :TODO(查询站点编码)
119 133 *
... ...
src/main/java/com/bsth/controller/StationRouteController.java
... ... @@ -47,6 +47,16 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
47 47 return service.list(map);
48 48 }
49 49  
  50 + /**
  51 + * @param String
  52 + * @throws
  53 + * @Description: TODO(批量撤销站点)
  54 + */
  55 + @RequestMapping(value = "/batchDestroy", method = RequestMethod.GET)
  56 + public Map<String, Object> updateBatch(@RequestParam Map<String, Object> map) {
  57 + return service.updateStationRouteInfoFormId(map);
  58 + }
  59 +
50 60 /**
51 61 * @Description :TODO(查询树站点与路段数据)
52 62 *
... ... @@ -89,6 +99,18 @@ public class StationRouteController extends BaseController&lt;StationRoute, Integer
89 99 }
90 100  
91 101 /**
  102 + * @Description :TODO(查询线路某方向下所有站点的中心百度坐标)
  103 + *
  104 + * @param map <lineId:线路ID; direction:方向>
  105 + *
  106 + * @return List<Map<String, Object>>
  107 + */
  108 + @RequestMapping(value = "/getStationRouteCacheCenterPoints" , method = RequestMethod.GET)
  109 + public List<Map<String, Object>> getStationRouteCacheCenterPoints(@RequestParam Map<String, Object> map) {
  110 + return service.getStationRouteCacheCenterPoints(map);
  111 + }
  112 +
  113 + /**
92 114 * @Description :TODO(撤销站点)
93 115 *
94 116 * @param map <lineId:线路ID; destroy:是否撤销(0:否;1:是)>
... ...
src/main/java/com/bsth/controller/directive/DirectiveController.java
... ... @@ -31,7 +31,7 @@ public class DirectiveController {
31 31  
32 32 @Autowired
33 33 DirectiveService directiveService;
34   -
  34 +
35 35 /**
36 36 *
37 37 * @Title: send60
... ... @@ -106,7 +106,7 @@ public class DirectiveController {
106 106 @RequestMapping(value = "/upDownChange", method = RequestMethod.POST)
107 107 public int upDownChange(@RequestParam String nbbm, @RequestParam Integer upDown){
108 108 SysUser user = SecurityUtils.getCurrentUser();
109   - return directiveService.upDownChange(nbbm, upDown, user.getUserName());
  109 + return directiveService.send60Operation(nbbm, 0, upDown, user.getUserName());
110 110 }
111 111  
112 112 /**
... ... @@ -120,7 +120,7 @@ public class DirectiveController {
120 120 @RequestMapping(value = "/stateChange", method = RequestMethod.POST)
121 121 public int stateChange(@RequestParam String nbbm, @RequestParam Integer upDown, @RequestParam Integer state){
122 122 SysUser user = SecurityUtils.getCurrentUser();
123   - return directiveService.stateChange(nbbm, upDown, state, user.getUserName());
  123 + return directiveService.send60Operation(nbbm, state, upDown, user.getUserName());
124 124 }
125 125  
126 126 /**
... ... @@ -173,15 +173,10 @@ public class DirectiveController {
173 173 }
174 174  
175 175 @RequestMapping(value = "/c0a4", method = RequestMethod.POST)
176   - public int c0a4(@RequestParam String nbbm){
  176 + public Map<String, Object> c0a4(@RequestParam String nbbm){
177 177 return directiveService.sendC0A4(nbbm);
178 178 }
179 179  
180   -// @RequestMapping(value = "/c0a3", method = RequestMethod.POST)
181   -// public int c0a3(@RequestParam DC0_A4 c0a4){
182   -// return directiveService.sendC0A3(c0a4);
183   -// }
184   -
185 180 @RequestMapping(value = "/c0a3", method = RequestMethod.POST)
186 181 public int c0a3(String json){
187 182 json = StringEscapeUtils.unescapeHtml4(json);
... ... @@ -192,7 +187,18 @@ public class DirectiveController {
192 187 @RequestMapping(value = "/c0a5", method = RequestMethod.POST)
193 188 public int c0a5(String json){
194 189 json = StringEscapeUtils.unescapeHtml4(json);
195   - //DC0_A3 c0a3 = JSON.toJavaObject(JSONObject.parseObject(json), DC0_A3.class);
196 190 return directiveService.sendC0A5(json);
197 191 }
  192 +
  193 + /**
  194 + * 设备参数查询
  195 + * @return
  196 + */
  197 + @RequestMapping(value = "/deviceCofigList", method = RequestMethod.GET)
  198 + public Map<String, Object> deviceCofigList(
  199 + @RequestParam Map<String, String> map,
  200 + @RequestParam(defaultValue = "0") int page,
  201 + @RequestParam(defaultValue = "10") int size){
  202 + return directiveService.deviceCofigList(map, page, size);
  203 + }
198 204 }
... ...
src/main/java/com/bsth/controller/directive/UpstreamEntrance.java
1 1 package com.bsth.controller.directive;
2 2  
  3 +import org.apache.commons.lang3.StringUtils;
3 4 import org.slf4j.Logger;
4 5 import org.slf4j.LoggerFactory;
5 6 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -59,7 +60,8 @@ public class UpstreamEntrance {
59 60 case 0x26:
60 61 // 驾驶员上报
61 62 D80 d80 = JSON.toJavaObject(jsonParam, D80.class);
62   - pilotReport.report(d80);
  63 + if(d80!=null && StringUtils.isNotEmpty(d80.getDeviceId()))
  64 + pilotReport.report(d80);
63 65 break;
64 66  
65 67 case 0xA4:
... ... @@ -67,9 +69,9 @@ public class UpstreamEntrance {
67 69 data.put("posPort", data.getString("posPort").trim());
68 70 data.put("posIpAddress", data.getString("posIpAddress").trim());
69 71 data.put("ipAddress", data.getString("ipAddress").trim());
70   -
  72 +
71 73 DC0_A4 c0a4 = JSON.toJavaObject(jsonParam, DC0_A4.class);
72   - System.out.println(c0a4);
  74 + pilotReport.report(c0a4);
73 75 break;
74 76 }
75 77  
... ...
src/main/java/com/bsth/controller/excep/NowAbnormalController.java 0 → 100644
  1 +package com.bsth.controller.excep;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.Map;
  5 +
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import com.bsth.controller.BaseController;
  13 +import com.bsth.entity.excep.Abnormal;
  14 +import com.bsth.entity.sys.SysUser;
  15 +import com.bsth.service.excep.NowAbnormalService;
  16 +import com.bsth.util.PageObject;
  17 +
  18 +@RestController
  19 +@RequestMapping("nowabnormal")
  20 +public class NowAbnormalController extends BaseController<SysUser, Integer>{
  21 + @Autowired
  22 + private NowAbnormalService nowAbnormalService;
  23 +
  24 + @RequestMapping(value = "/pagequery",method = RequestMethod.GET)
  25 + public PageObject<Abnormal> pagequery(@RequestParam Map<String, Object> map){
  26 + PageObject<Abnormal> pageObject = null;
  27 + map.put("curPage", map.get("page").toString());
  28 + map.put("pageData","10");
  29 + pageObject=nowAbnormalService.Pagequery(map);
  30 + return pageObject;
  31 +
  32 + }
  33 +
  34 +
  35 + @RequestMapping(value = "/getReport", method = RequestMethod.POST)
  36 + public Map<String, Object> getReport(@RequestParam Map<String, Object> map) {
  37 + Map<String, Object> modelMap = new HashMap<String, Object>();
  38 + try {
  39 + map.put("isShow", 1);
  40 +// modelMap = offlineService.getReport(map);
  41 + } catch (Exception e) {
  42 + e.printStackTrace();
  43 + }
  44 + return modelMap;
  45 + }
  46 +
  47 +
  48 +}
... ...
src/main/java/com/bsth/controller/excep/NowOfflineController.java 0 → 100644
  1 +package com.bsth.controller.excep;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.Map;
  5 +
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import com.bsth.controller.BaseController;
  13 +import com.bsth.entity.excep.Offline;
  14 +import com.bsth.entity.sys.SysUser;
  15 +import com.bsth.service.excep.NowOfflineService;
  16 +import com.bsth.util.PageObject;
  17 +
  18 +@RestController
  19 +@RequestMapping("nowoffline")
  20 +public class NowOfflineController extends BaseController<SysUser, Integer>{
  21 + @Autowired
  22 + private NowOfflineService nowOfflineService;
  23 +
  24 + @RequestMapping(value = "/pagequery",method = RequestMethod.GET)
  25 + public PageObject<Offline> pagequery(@RequestParam Map<String, Object> map){
  26 + PageObject<Offline> pageObject = null;
  27 + map.put("curPage", map.get("page").toString());
  28 + map.put("pageData","10");
  29 + pageObject=nowOfflineService.Pagequery(map);
  30 + return pageObject;
  31 +
  32 + }
  33 +
  34 +
  35 + @RequestMapping(value = "/getReport", method = RequestMethod.POST)
  36 + public Map<String, Object> getReport(@RequestParam Map<String, Object> map) {
  37 + Map<String, Object> modelMap = new HashMap<String, Object>();
  38 + try {
  39 + map.put("isShow", 1);
  40 + modelMap = nowOfflineService.getReport(map);
  41 + } catch (Exception e) {
  42 + e.printStackTrace();
  43 + }
  44 + return modelMap;
  45 + }
  46 +
  47 +
  48 +}
... ...
src/main/java/com/bsth/controller/excep/NowOutboundController.java 0 → 100644
  1 +package com.bsth.controller.excep;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.Map;
  5 +
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import com.bsth.controller.BaseController;
  13 +import com.bsth.entity.excep.Outbound;
  14 +import com.bsth.entity.sys.SysUser;
  15 +import com.bsth.service.excep.NowOutboundService;
  16 +import com.bsth.util.PageObject;
  17 +
  18 +@RestController
  19 +@RequestMapping("nowbound")
  20 +public class NowOutboundController extends BaseController<SysUser, Integer>{
  21 + @Autowired
  22 + private NowOutboundService nowOutboundService;
  23 +
  24 + @RequestMapping(value = "/pagequery",method = RequestMethod.GET)
  25 + public PageObject<Outbound> pagequery(@RequestParam Map<String, Object> map){
  26 + PageObject<Outbound> pageObject = null;
  27 + map.put("curPage", map.get("page").toString());
  28 + map.put("pageData","10");
  29 + pageObject=nowOutboundService.Pagequery(map);
  30 + return pageObject;
  31 +
  32 + }
  33 +
  34 +
  35 + @RequestMapping(value = "/getReport", method = RequestMethod.POST)
  36 + public Map<String, Object> getReport(@RequestParam Map<String, Object> map) {
  37 + Map<String, Object> modelMap = new HashMap<String, Object>();
  38 + try {
  39 + map.put("isShow", 1);
  40 + modelMap = nowOutboundService.getReport(map);
  41 + } catch (Exception e) {
  42 + e.printStackTrace();
  43 + }
  44 + return modelMap;
  45 + }
  46 +
  47 +
  48 +}
... ...
src/main/java/com/bsth/controller/excep/NowSpeedingController.java 0 → 100644
  1 +package com.bsth.controller.excep;
  2 +
  3 +import java.text.ParseException;
  4 +import java.util.HashMap;
  5 +import java.util.List;
  6 +import java.util.Map;
  7 +
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestMethod;
  11 +import org.springframework.web.bind.annotation.RequestParam;
  12 +import org.springframework.web.bind.annotation.RestController;
  13 +
  14 +import com.bsth.controller.BaseController;
  15 +import com.bsth.data.BasicData;
  16 +import com.bsth.entity.excep.Speeding;
  17 +import com.bsth.entity.sys.SysUser;
  18 +import com.bsth.service.excep.NowSpeedingService;
  19 +import com.bsth.util.PageObject;
  20 +
  21 +@RestController
  22 +@RequestMapping("nowspeeding")
  23 +public class NowSpeedingController extends BaseController<SysUser, Integer>{
  24 +
  25 + @Autowired
  26 + private NowSpeedingService nowSpeedingService;
  27 +
  28 + @RequestMapping(value = "/pagequery",method = RequestMethod.GET)
  29 + public PageObject<Speeding> pagequery(@RequestParam Map<String, Object> map){
  30 + PageObject<Speeding> pageObject = null;
  31 + map.put("curPage", map.get("page").toString());
  32 + map.put("pageData","10");
  33 + pageObject=nowSpeedingService.Pagequery(map);
  34 + return pageObject;
  35 + }
  36 +
  37 + @RequestMapping(value = "/getReport", method = RequestMethod.POST)
  38 + public Map<String, Object> getReport(@RequestParam Map<String, Object> map) {
  39 + Map<String, Object> modelMap = new HashMap<String, Object>();
  40 + try {
  41 + map.put("isShow", 1);
  42 + modelMap = nowSpeedingService.getReport(map);
  43 + } catch (Exception e) {
  44 + e.printStackTrace();
  45 + }
  46 + return modelMap;
  47 + }
  48 +
  49 + @RequestMapping(value = "/findPosition", method = RequestMethod.GET)
  50 + public List<Speeding> findPosition(@RequestParam String vehicle,@RequestParam String startdate,@RequestParam String enddate) throws ParseException {
  51 + String deviceid = BasicData.deviceId2NbbmMap.inverse().get(vehicle);
  52 + List<Speeding> listSpeeding = nowSpeedingService.findPosition(deviceid,startdate,enddate);
  53 + return listSpeeding;
  54 + }
  55 +
  56 +}
... ...
src/main/java/com/bsth/controller/excep/SpeedingController.java
1 1 package com.bsth.controller.excep;
2 2  
  3 +import java.text.ParseException;
3 4 import java.util.HashMap;
  5 +import java.util.List;
4 6 import java.util.Map;
5 7  
6 8 import org.springframework.beans.factory.annotation.Autowired;
7 9 import org.springframework.web.bind.annotation.RequestMapping;
8 10 import org.springframework.web.bind.annotation.RequestMethod;
9 11 import org.springframework.web.bind.annotation.RequestParam;
10   -import org.springframework.web.bind.annotation.ResponseBody;
11 12 import org.springframework.web.bind.annotation.RestController;
12 13  
13 14 import com.bsth.controller.BaseController;
14   -import com.bsth.entity.excep.Offline;
  15 +import com.bsth.data.BasicData;
15 16 import com.bsth.entity.excep.Speeding;
16 17 import com.bsth.entity.sys.SysUser;
17   -import com.bsth.service.excep.OfflineService;
18 18 import com.bsth.service.excep.SpeedingService;
19 19 import com.bsth.util.PageObject;
20 20  
... ... @@ -31,10 +31,8 @@ public class SpeedingController extends BaseController&lt;SysUser, Integer&gt;{
31 31 map.put("pageData","10");
32 32 pageObject=speedingService.Pagequery(map);
33 33 return pageObject;
34   -
35 34 }
36 35  
37   -
38 36 @RequestMapping(value = "/getReport", method = RequestMethod.POST)
39 37 public Map<String, Object> getReport(@RequestParam Map<String, Object> map) {
40 38 Map<String, Object> modelMap = new HashMap<String, Object>();
... ... @@ -47,5 +45,11 @@ public class SpeedingController extends BaseController&lt;SysUser, Integer&gt;{
47 45 return modelMap;
48 46 }
49 47  
  48 + @RequestMapping(value = "/findPosition", method = RequestMethod.GET)
  49 + public List<Speeding> findPosition(@RequestParam String vehicle,@RequestParam String startdate,@RequestParam String enddate) throws ParseException {
  50 + String deviceid = BasicData.deviceId2NbbmMap.inverse().get(vehicle);
  51 + List<Speeding> listSpeeding = speedingService.findPosition(deviceid,startdate,enddate);
  52 + return listSpeeding;
  53 + }
50 54  
51 55 }
... ...
src/main/java/com/bsth/controller/forms/ExportController.java
... ... @@ -87,6 +87,7 @@ public class ExportController {
87 87 public List<Map<String, Object>> shifdayExport(@RequestParam Map<String, Object> map) {
88 88 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd");
89 89 List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  90 + Map<String, Object> map2 = new HashMap<String, Object>();
90 91 ReportUtils ee = new ReportUtils();
91 92 List<Shifday> shifday = formsService.shifday(map);
92 93 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
... ... @@ -110,11 +111,15 @@ public class ExportController {
110 111 m.put("sjbc", l.getSjbc());
111 112 resList.add(m);
112 113 }
  114 + if(resList.size() > 0){
  115 + map2 = resList.get(resList.size() - 1);
  116 + resList.remove(map2);
  117 + }
113 118  
114 119 try {
115 120 listI.add(resList.iterator());
116 121 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
117   - ee.excelReplace(listI, new Object[] { map }, path + "mould/shifday.xls",
  122 + ee.excelReplace(listI, new Object[] { map2 }, path + "mould/shifday.xls",
118 123 path + "export/班次车辆人员日报表" + sdfSimple.format(sdfMonth.parse(map.get("date").toString())) + ".xls");
119 124 } catch (Exception e) {
120 125 e.printStackTrace();
... ... @@ -303,12 +308,10 @@ public class ExportController {
303 308 m.put("fssj", l.getFssj());
304 309 m.put("xgsj", l.getXgsj());
305 310 m.put("pcch", l.getPcch());
306   - m.put("pcry", l.getPcry());
307   - m.put("jhch", l.getJhch());
308   - m.put("jhgh", l.getJhgh());
309 311 m.put("sjch", l.getSjch());
  312 + m.put("fcgh", l.getPcry());
310 313 m.put("sjgh", l.getSjgh());
311   - m.put("yy", l.getYy());
  314 + m.put("yy", l.getYy()==null?"":l.getYy());
312 315 m.put("xgr", l.getXgr());
313 316 resList.add(m);
314 317 }
... ... @@ -330,69 +333,22 @@ public class ExportController {
330 333 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd");
331 334 List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
332 335 ReportUtils ee = new ReportUtils();
333   - List<Turnoutrate> turnoutrate = formsService.turnoutrate(map);
334 336 Map<String, Object> map1 = new HashMap<String, Object>();
335   - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
336   - String xlts="";
337   - String zsgs="";
338   - String jh="";
339   - Float j=0f;
340   - Float sj=0f;
341   - Float qz=0f;
342   - Float ccl=0f;
343   - Float bcjh=0f;
344   - String bcsj="";
345   - Float bczxl=0f;
346   - String gs="";
347   - String zhgs="";
348 337  
349   - for (Turnoutrate l : turnoutrate) {
350   - Map<String, Object> m = new HashMap<String, Object>();
351   -
352   - xlts +=l.getGsgs()==""?0:String.valueOf(l.getGsgs());
353   - zsgs +=l.getFgsgs()==""?0:String.valueOf(l.getFgsgs());
354   - jh +=l.getXl()==""?0:String.valueOf(l.getXl());
355   - sj +=l.getCchjh()==""?0f:Float.valueOf(l.getCchjh());
356   - ccl +=l.getCchsj()==""?0f:Float.valueOf(l.getCchsj());
357   - bcjh +=l.getCchqz()==""?0f:Float.valueOf(l.getCchqz());
358   - bcsj +=l.getChl()==""?0:String.valueOf(l.getChl());
359   - bczxl +=l.getBcjh()==""?0f:Float.valueOf(l.getBcjh());
360   - gs +=l.getBcsj()==""?0:String.valueOf(l.getBcsj());
361   - zhgs +=l.getBbzxl()==""?0:String.valueOf(l.getBbzxl());
362   -
363   -
364   - m.put("rq", l.getRq());
365   - m.put("gs", l.getGs());
366   - m.put("zhgs", l.getZhgs());
367   - m.put("xl", l.getXl());
368   - m.put("cchjh", l.getCchjh());
369   - m.put("cchsj", l.getCchsj());
370   - m.put("cchqz", l.getCchqz());
371   - m.put("chl", l.getChl());
372   - m.put("bcjh", l.getBcjh());
373   - m.put("bcsj", l.getBcsj());
374   - m.put("bbzxl", l.getBbzxl());
375   - m.put("sm", l.getSm());
376   - resList.add(m);
377   -
378   -
379   -
380   - m=new HashMap<String,Object>();
381   - m.put("total_xlts", xlts);
382   - m.put("total_zhgs", zsgs);
383   - m.put("total_jh", jh);
384   - m.put("total_sj", sj);
385   - m.put("total_qz", ccl);
386   - m.put("total_ccl", bcjh);
387   - m.put("total_bcjh",bcsj);
388   - m.put("total_bcsj", bczxl);
389   - m.put("total_bczxl", bczxl);
390   - m.put("total_gs", zhgs);
391   -
392   -
393   - map1 = m;
394   - }
395   -
  338 + List<Map<String, Object>> resList = formsService.turnoutrate(map);
  339 + Map<String, Object> m = resList.get(resList.size() - 1);
  340 + map1.put("line", m.get("line"));
  341 + map1.put("jhcc", m.get("jhcc"));
  342 + map1.put("sjcc", m.get("sjcc"));
  343 + map1.put("jhbc", m.get("jhbc"));
  344 + map1.put("sjbc", m.get("sjbc"));
  345 + map1.put("ccl", m.get("ccl"));
  346 + map1.put("zxl", m.get("zxl"));
  347 + map1.put("qz", m.get("qz"));
  348 + map1.put("sm", m.get("sm"));
  349 +
  350 + resList.remove(m);
  351 +
396 352 try {
397 353 listI.add(resList.iterator());
398 354 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
... ...
src/main/java/com/bsth/controller/forms/MCY_FormsController.java
... ... @@ -66,7 +66,7 @@ public class MCY_FormsController {
66 66 }
67 67  
68 68 // 换人换车情况统计表
69   - @RequestMapping(value = "/changetochange", method = RequestMethod.POST)
  69 + @RequestMapping(value = "/changetochange", method = RequestMethod.GET)
70 70 public List<Changetochange> changetochange(@RequestParam Map<String, Object> map) {
71 71  
72 72 return formsService.changetochange(map);
... ... @@ -94,7 +94,7 @@ public class MCY_FormsController {
94 94  
95 95 // 营运线路出车率统计表
96 96 @RequestMapping(value = "/turnoutrate", method = RequestMethod.POST)
97   - public List<Turnoutrate> turnoutrate(@RequestParam Map<String, Object> map) {
  97 + public List<Map<String, Object>> turnoutrate(@RequestParam Map<String, Object> map) {
98 98  
99 99 return formsService.turnoutrate(map);
100 100 }
... ...
src/main/java/com/bsth/controller/gps/GpsController.java
... ... @@ -3,11 +3,18 @@ package com.bsth.controller.gps;
3 3 import com.bsth.data.BasicData;
4 4 import com.bsth.data.gpsdata.GpsEntity;
5 5 import com.bsth.data.gpsdata.GpsRealData;
  6 +import com.bsth.entity.excep.Speeding;
6 7 import com.bsth.service.gps.GpsService;
  8 +import com.bsth.service.gps.entity.GpsSpeed;
  9 +import com.bsth.util.PageObject;
7 10 import com.google.common.base.Splitter;
8 11 import org.springframework.beans.factory.annotation.Autowired;
9 12 import org.springframework.web.bind.annotation.*;
10 13  
  14 +import javax.servlet.http.HttpServletResponse;
  15 +
  16 +import java.text.ParseException;
  17 +import java.util.ArrayList;
11 18 import java.util.List;
12 19 import java.util.Map;
13 20  
... ... @@ -90,11 +97,12 @@ public class GpsController {
90 97  
91 98 /**
92 99 * gps补全
  100 + * type 0 : 实时GPS 1:走补传
93 101 * @return
94 102 */
95 103 @RequestMapping(value = "/gpsCompletion", method = RequestMethod.POST)
96   - public Map<String, Object> gpsCompletion(@RequestParam long schId) {
97   - return gpsService.gpsCompletion(schId);
  104 + public Map<String, Object> gpsCompletion(@RequestParam long schId, @RequestParam int type) {
  105 + return gpsService.gpsCompletion(schId, type);
98 106 }
99 107  
100 108 /**
... ... @@ -110,6 +118,57 @@ public class GpsController {
110 118 }
111 119  
112 120 /**
  121 + * 历史GPS查询 ,第三版轨迹回放用
  122 + * @param nbbm
  123 + * @param st
  124 + * @param et
  125 + * @return
  126 + */
  127 + @RequestMapping(value = "/history_v3/{nbbm}")
  128 + public Map<String, Object> history_v3(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et){
  129 + return gpsService.history_v3(nbbm, st, et);
  130 + }
  131 +
  132 + /**
  133 + * 轨迹导出
  134 + * @param nbbm
  135 + * @param st
  136 + * @param et
  137 + * @return
  138 + */
  139 + @RequestMapping(value = "/history_v3/excel/{nbbm}")
  140 + public void trailExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
  141 + gpsService.trailExcel(nbbm, st, et, resp);
  142 + }
  143 +
  144 + /**
  145 + * 轨迹异常数据导出
  146 + * @param nbbm
  147 + * @param st
  148 + * @param et
  149 + * @return
  150 + */
  151 + @RequestMapping(value = "/history_v3/excel_abnormal/{nbbm}")
  152 + public void abnormalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
  153 + gpsService.abnormalExcel(nbbm, st, et, resp);
  154 + }
  155 +
  156 + /**
  157 + * 到离站数据导出
  158 + * @param nbbm
  159 + * @param st
  160 + * @param et
  161 + * @return
  162 + */
  163 + @RequestMapping(value = "/history_v3/excel_arrival/{nbbm}")
  164 + public void arrivalExcel(@PathVariable("nbbm") String nbbm, @RequestParam long st, @RequestParam long et, HttpServletResponse resp){
  165 + gpsService.arrivalExcel(nbbm, st, et, resp);
  166 + }
  167 +
  168 +
  169 +
  170 +
  171 + /**
113 172 * 安全驾驶数据 分页查询
114 173 * @param map
115 174 * @param page
... ... @@ -126,4 +185,20 @@ public class GpsController {
126 185 @RequestParam(defaultValue = "DESC") String direction){
127 186 return gpsService.safeDrivList(map , page, size, order, direction);
128 187 }
  188 +
  189 + @RequestMapping(value = "/findPosition", method = RequestMethod.GET)
  190 + public List<GpsSpeed> findPosition(@RequestParam String vehicle,@RequestParam String startdate,@RequestParam String enddate) throws ParseException {
  191 + String deviceid = BasicData.deviceId2NbbmMap.inverse().get(vehicle);
  192 + List<GpsSpeed> listGpsSpeed = new ArrayList<GpsSpeed>();
  193 + listGpsSpeed = gpsService.findPosition(deviceid,startdate,enddate);
  194 + return listGpsSpeed;
  195 + }
  196 +
  197 + @RequestMapping(value = "/pagequery",method = RequestMethod.GET)
  198 + public Map<String, Object> pagequery(@RequestParam Map<String, Object> map){
  199 + map.put("curPage", map.get("page").toString());
  200 + map.put("pageData","10");
  201 + return gpsService.Pagequery(map);
  202 + }
  203 +
129 204 }
... ...
src/main/java/com/bsth/controller/oil/CwjyController.java
... ... @@ -33,6 +33,11 @@ public class CwjyController extends BaseController&lt;Cwjy, Integer&gt;{
33 33 return service.save(t);
34 34 }
35 35  
  36 + @RequestMapping(value = "/checkNbbm",method = RequestMethod.GET)
  37 + public int checkNbbm(Cwjy t){
  38 + return service.checkNbbm(t.getNbbm().trim());
  39 + }
  40 +
36 41 @RequestMapping(value = "/queryList",method = RequestMethod.GET)
37 42 public List<Ylxxb> queryList(@RequestParam Map<String, Object> map){
38 43 List<Ylxxb> pagequery=null;
... ...
src/main/java/com/bsth/controller/oil/DlbController.java
... ... @@ -143,13 +143,17 @@ public class DlbController extends BaseController&lt;Dlb, Integer&gt;{
143 143 Map<String, Object> m = new HashMap<String, Object>();
144 144 m.put("rq", y.getRq());
145 145 m.put("gsname",y.getGsname() );
  146 + m.put("fgsname", y.getFgsname());
146 147 m.put("xlname", y.getXlname());
147 148 m.put("nbbm", y.getNbbm());
148 149 m.put("jsy", y.getJsy());
149   - m.put("cdl", y.getCdl());
150   - m.put("czcd", y.getCzcd()+"%");
151   - m.put("jzcd", y.getJzcd()+"%");
152   - m.put("hd", y.getHd());
  150 + m.put("name", y.getName());
  151 + m.put("cdl", y.getCdl()<=0?"0":y.getCdl());
  152 + m.put("czcd", y.getCzcd()<=0?"0":y.getCzcd()+"%");
  153 + m.put("jzcd", y.getJzcd()<=0?"0":y.getJzcd()+"%");
  154 + m.put("czlc", y.getCzlc()<=0?"0":y.getCzlc());
  155 + m.put("jzlc", y.getJzlc()<=0?"0":y.getJzlc());
  156 + m.put("hd", y.getHd()<=0?"0":y.getHd());
153 157 String shyy ="无";
154 158 if(y.getShyy()!=null){
155 159 if(shyy.equals("1")){shyy="票务用油";}
... ... @@ -162,20 +166,23 @@ public class DlbController extends BaseController&lt;Dlb, Integer&gt;{
162 166 else if(shyy.equals("8")){shyy="车间(小修)";}
163 167 else{shyy ="无";}
164 168 }
  169 + m.put("ns", y.getNs()<=0?"0":y.getNs());
165 170 m.put("shyy", shyy);
166   - m.put("sh", y.getSh());
167   - m.put("zlc", y.getZlc());
  171 + m.put("sh", y.getSh()<=0?"0":y.getSh());
  172 + m.put("zlc", y.getZlc()<=0?"0":y.getZlc());
  173 + m.put("rdlx", "");
168 174 m.put("bglyh", y.getBglyh());
169 175 resList.add(m);
170 176 }
171 177 try {
  178 + map.put("sheetName", map.get("rq"));
172 179 listI.add(resList.iterator());
173 180 String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";
174 181 ee.excelReplace(listI, new Object[] { map }, path+"mould/listDl.xls",
175 182 path+"export/"+map.get("rq").toString()+ "进出场存电量.xls");
176 183 } catch (Exception e) {
177 184 e.printStackTrace();
178   - }
  185 + }
179 186  
180 187 return resList;
181 188  
... ...
src/main/java/com/bsth/controller/oil/YlbController.java
... ... @@ -209,8 +209,8 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
209 209 return maps;
210 210 }
211 211 @RequestMapping(value="/oilListMonth")
212   - public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date){
213   - return yblService.oilListMonth(line, date);
  212 + public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date,@RequestParam String type){
  213 + return yblService.oilListMonth(line, date, type);
214 214 }
215 215  
216 216 @RequestMapping(value = "/checkJsy",method = RequestMethod.GET)
... ... @@ -236,28 +236,29 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
236 236 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
237 237 for (Ylb y : ylb) {
238 238 Map<String, Object> m = new HashMap<String, Object>();
239   - m.put("rq", y.getRq());
  239 + m.put("rq", sdfMonth.format(y.getRq()));
240 240 m.put("gsname",y.getGsname() );
241 241 m.put("fgsname", y.getFgsname());
242   - m.put("xlname", y.getXlname());
  242 + m.put("xlname", y.getXlname()==null?"":y.getXlname());
243 243 m.put("nbbm", y.getNbbm());
244 244 m.put("jsy", y.getJsy());
245 245 m.put("name", y.getName());
246   - m.put("jzl", y.getJzl());
247   - m.put("czlc", y.getCzlc());
248   - m.put("jzlc", y.getJzlc());
249   - m.put("czyl", y.getCzyl());
250   - m.put("jzyl", y.getJzyl());
251   - m.put("yh", y.getYh());
  246 + m.put("jzl", y.getJzl()<=0?"0":y.getJzl());
  247 + m.put("czlc", "0");
  248 + m.put("jzlc", "0");
  249 + m.put("czyl", y.getCzyl()<=0?"0":y.getCzyl());
  250 + m.put("jzyl", y.getJzyl()<=0?"0":y.getJzyl());
  251 + m.put("yh", y.getYh()<=0?"0":y.getYh());
252 252 String rylx="";
253 253 if(y.getRylx()!=null){
254 254 if(y.getRylx().equals("0")){rylx="0号柴油";}
255 255 if(y.getRylx().equals("1")){rylx="负10号柴油";}
256 256 }
257 257 m.put("rylx", rylx);
258   - m.put("ns", y.getNs());
  258 + m.put("ns", y.getNs()==null?"0":y.getNs());
259 259 String shyy ="无";
260 260 if(y.getShyy()!=null){
  261 + shyy=y.getShyy();
261 262 if(shyy.equals("1")){shyy="票务用油";}
262 263 else if(shyy.equals("2")){shyy="保养用油";}
263 264 else if(shyy.equals("3")){shyy="报废车用油";}
... ... @@ -269,12 +270,13 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
269 270 else{shyy ="无";}
270 271 }
271 272 m.put("shyy", shyy);
272   - m.put("sh", y.getSh());
273   - m.put("zlc", y.getZlc());
  273 + m.put("sh", y.getSh()<=0?"0":y.getSh());
  274 + m.put("zlc", y.getZlc()<=0?"0":y.getZlc());
274 275 m.put("bglyh", y.getBglyh());
275 276 resList.add(m);
276 277 }
277 278 try {
  279 + map.put("sheetName", map.get("rq"));
278 280 listI.add(resList.iterator());
279 281 String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";
280 282 ee.excelReplace(listI, new Object[] { map }, path+"mould/list.xls",
... ...
src/main/java/com/bsth/controller/realcontrol/BasicDataController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
3   -import com.alibaba.fastjson.JSON;
4 3 import com.alibaba.fastjson.serializer.PropertyFilter;
5 4 import com.bsth.common.ResponseCode;
6 5 import com.bsth.data.BasicData;
  6 +import com.bsth.data.Station2ParkBuffer;
7 7 import com.bsth.entity.Line;
  8 +import com.bsth.entity.realcontrol.StationToPark;
  9 +import com.google.common.base.Splitter;
8 10 import com.google.common.collect.ArrayListMultimap;
  11 +import com.google.common.collect.BiMap;
9 12 import org.slf4j.Logger;
10 13 import org.slf4j.LoggerFactory;
11 14 import org.springframework.beans.factory.annotation.Autowired;
12 15 import org.springframework.web.bind.annotation.RequestMapping;
13 16 import org.springframework.web.bind.annotation.RequestMethod;
  17 +import org.springframework.web.bind.annotation.RequestParam;
14 18 import org.springframework.web.bind.annotation.RestController;
15 19  
16 20 import java.util.*;
... ... @@ -26,6 +30,9 @@ public class BasicDataController {
26 30 BasicData basicData;
27 31  
28 32 Logger logger = LoggerFactory.getLogger(this.getClass());
  33 +
  34 + @Autowired
  35 + Station2ParkBuffer station2ParkBuffer;
29 36  
30 37 @RequestMapping("/cars")
31 38 public Iterable<String> findAllNbbm(Map<String, Object> map){
... ... @@ -52,16 +59,16 @@ public class BasicDataController {
52 59 return rs;
53 60 }
54 61  
55   - @RequestMapping("/personnel")
  62 + /*@RequestMapping("/personnel")
56 63 public Map<String, Object> findPersonnelInfo(){
57 64 Map<String, Object> rs = new HashMap<>();
58 65 PersonnelFieldFilter filter=new PersonnelFieldFilter();
59 66 //驾驶员
60 67 rs.put("jsy", JSON.parse(JSON.toJSONString(BasicData.jsyMap.values(), filter)));
61 68 //售票员
62   - rs.put("spy", JSON.parse(JSON.toJSONString(BasicData.spyMap.values(), filter)));
  69 + rs.put("spy", JSON.parse(JSON.toJSONString(BasicData.spyMap.values(), filter)));*//*
63 70 return rs;
64   - }
  71 + }*/
65 72  
66 73 @RequestMapping("/all_personnel")
67 74 public Map<String, String> all_personnel(){
... ... @@ -145,4 +152,54 @@ public class BasicDataController {
145 152 }
146 153 return listMultimap.asMap();
147 154 }
  155 +
  156 + /**
  157 + * 获取车辆信息
  158 + * @return
  159 + */
  160 + @RequestMapping("/ccInfo/lineArray")
  161 + public List<Map<String, String>> ccInfoByLine(@RequestParam String idx){
  162 + List<String> lines = Splitter.on(",").splitToList(idx);
  163 + List<Map<String, String>> rs = new ArrayList<>();
  164 + Map<String, String> map;
  165 +
  166 + //ArrayListMultimap<String, String> listMultimap = ArrayListMultimap.create();
  167 + Set<String> ks = BasicData.nbbm2LineMap.keySet();
  168 + BiMap<String,String> nbbm2deviceMap = BasicData.deviceId2NbbmMap.inverse();
  169 +
  170 + Line line;
  171 + for(String nbbm : ks){
  172 + line = BasicData.nbbm2LineMap.get(nbbm);
  173 + if(lines.contains(line.getLineCode())){
  174 + map = new HashMap<>();
  175 + map.put("nbbm", nbbm);
  176 + map.put("deviceId", nbbm2deviceMap.get(nbbm));
  177 + map.put("lineName", line.getName());
  178 + map.put("lineCode", line.getLineCode());
  179 + rs.add(map);
  180 + }
  181 + }
  182 + return rs;
  183 + }
  184 +
  185 + /**
  186 + * 获取站点和停车场历时公里对照表
  187 + * @param idx
  188 + * @return
  189 + */
  190 + @RequestMapping("/station2ParkData")
  191 + public Map<String, Collection<StationToPark>> findStation2ParkData(@RequestParam String idx){
  192 + List<String> lines = Splitter.on(",").splitToList(idx);
  193 + ArrayListMultimap<String, StationToPark> rs = ArrayListMultimap.create();
  194 +
  195 + for(String lineCode : lines){
  196 + rs.putAll(lineCode, Station2ParkBuffer.get(lineCode));
  197 + }
  198 + return rs.asMap();
  199 + }
  200 +
  201 + @RequestMapping(value = "/deleteStation2Park", method = RequestMethod.POST)
  202 + public Map<String, Object> deleteStation2Park(@RequestParam String lineCode,@RequestParam Integer id){
  203 + return station2ParkBuffer.delete(lineCode, id);
  204 + }
148 205 }
... ...
src/main/java/com/bsth/controller/realcontrol/ChildTaskPlanController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  5 +import com.bsth.service.realcontrol.ChildTaskPlanService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.PathVariable;
3 8 import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestMethod;
4 10 import org.springframework.web.bind.annotation.RestController;
5 11  
6   -import com.bsth.controller.BaseController;
7   -import com.bsth.entity.realcontrol.ChildTaskPlan;
  12 +import java.util.Map;
8 13  
9 14 @RestController
10 15 @RequestMapping("/childTask")
11 16 public class ChildTaskPlanController extends BaseController<ChildTaskPlan, Long>{
12 17  
  18 + @Autowired
  19 + ChildTaskPlanService childTaskPlanService;
  20 +
  21 + @RequestMapping(value = "history", method = RequestMethod.POST)
  22 + public Map<String, Object> saveHistory(ChildTaskPlan childTask){
  23 + return childTaskPlanService.saveHistory(childTask);
  24 + }
  25 +
  26 + @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE)
  27 + public Map<String, Object> delHistory(@PathVariable("id") Long id){
  28 + return childTaskPlanService.delHistory(id);
  29 + }
13 30 }
... ...
src/main/java/com/bsth/controller/realcontrol/LineConfigController.java
... ... @@ -101,4 +101,14 @@ public class LineConfigController extends BaseController&lt;LineConfig, Integer&gt;{
101 101 //System.out.println(map);
102 102 return lineConfigService.yjtkSet(map);
103 103 }
  104 +
  105 + /**
  106 + * 修改场既是站的 停车场 和 站点
  107 + * @param map
  108 + * @return
  109 + */
  110 + @RequestMapping(value = "/parkAndStationSet", method = RequestMethod.POST)
  111 + public Map<String, Object> parkAndStationSet(@RequestParam Map<String, String> map){
  112 + return lineConfigService.parkAndStationSet(map);
  113 + }
104 114 }
... ...
src/main/java/com/bsth/controller/realcontrol/RealMapController.java
... ... @@ -45,8 +45,8 @@ public class RealMapController {
45 45 * @Description: TODO(获取线路的站点,路段路由)
46 46 */
47 47 @RequestMapping(value = "/findRouteByLine")
48   - public Map<String, Object> findRouteByLine(@RequestParam String lineCode) {
49   - return realMapService.findRouteByLine(lineCode);
  48 + public Map<String, Object> findRouteByLine(@RequestParam String idx) {
  49 + return realMapService.findRouteByLine(idx);
50 50 }
51 51  
52 52 @RequestMapping(value = "/multiRouteByLine")
... ...
src/main/java/com/bsth/controller/realcontrol/SchEditInfoController.java 0 → 100644
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.data.schedule.edit_logs.entity.SchEditInfo;
  5 +import com.bsth.data.schedule.edit_logs.service.SchEditInfoService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import java.util.Map;
  13 +
  14 +/**
  15 + * 班次修正记录
  16 + * Created by panzhao on 2017/5/22.
  17 + */
  18 +@RestController
  19 +@RequestMapping("schEditInfo")
  20 +public class SchEditInfoController extends BaseController<SchEditInfo, Long>{
  21 +
  22 + @Autowired
  23 + SchEditInfoService editInfoService;
  24 +
  25 + @RequestMapping(value = "/_list", method = RequestMethod.GET)
  26 + public Map<String, Object> _list(@RequestParam String rq, @RequestParam String lineCode,@RequestParam Map<String, String> map) {
  27 + return editInfoService._list(rq, lineCode, map);
  28 + }
  29 +}
... ...
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -7,6 +7,7 @@ import com.bsth.controller.realcontrol.dto.ChangePersonCar;
7 7 import com.bsth.controller.realcontrol.dto.DfsjChange;
8 8 import com.bsth.data.BasicData;
9 9 import com.bsth.data.schedule.DayOfSchedule;
  10 +import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
10 11 import com.bsth.entity.realcontrol.ScheduleRealInfo;
11 12 import com.bsth.entity.schedule.SchedulePlanInfo;
12 13 import com.bsth.service.realcontrol.ScheduleRealInfoService;
... ... @@ -24,10 +25,10 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
24 25  
25 26 /*@Autowired
26 27 GetSchedulePlanThread getSchedulePlanThread;*/
27   -
  28 +
28 29 @Autowired
29 30 ScheduleRealInfoService scheduleRealInfoService;
30   -
  31 +
31 32 @Autowired
32 33 DayOfSchedule dayOfSchedule;
33 34  
... ... @@ -42,29 +43,30 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
42 43 }
43 44  
44 45 /**
45   - *
  46 + *
46 47 * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id
47 48 * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws
48 49 */
49 50 @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST)
50 51 public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks,
51   - @RequestParam String dfsj,String bcType) {
52   - return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType);
  52 + @RequestParam String dfsj,String bcType,
  53 + @RequestParam(defaultValue = "") String opType) {
  54 + return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType, opType);
53 55 }
54 56  
55 57 /**
56   - *
  58 + *
57 59 * @Title: destroy @Description: TODO(销毁,烂班) @param @param idsStr 要烂掉的班次ID ,分隔
58 60 */
59 61 @RequestMapping(value = "/destroy", method = RequestMethod.POST)
60 62 public Map<String, Object> destroy(@RequestParam String idsStr
61 63 /*, @RequestParam(defaultValue = "-1") int spaceAdjust*/,
62   - @RequestParam String remarks, @RequestParam String adjustExps/*, @RequestParam(defaultValue = "0") int spaceNum*/) {
  64 + @RequestParam String remarks, @RequestParam String adjustExps/*, @RequestParam(defaultValue = "0") int spaceNum*/) {
63 65 return scheduleRealInfoService.destroy(idsStr/*, spaceAdjust*/, remarks, adjustExps/*, spaceNum*/);
64 66 }
65 67  
66 68 /**
67   - *
  69 + *
68 70 * @Title: carDeviceMapp @Description: TODO(获取车辆自编号和设备号对照,从缓存取) @throws
69 71 */
70 72 @RequestMapping(value = "/carDeviceMapp", method = RequestMethod.GET)
... ... @@ -73,7 +75,7 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
73 75 }
74 76  
75 77 /**
76   - *
  78 + *
77 79 * @Title: findPersionByLine @Description: TODO(根据线路主键获取驾驶员) @param @param
78 80 * lineId @throws
79 81 */
... ... @@ -83,7 +85,7 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
83 85 }
84 86  
85 87 /**
86   - *
  88 + *
87 89 * @Title: findPersionByLine @Description: TODO(根据线路主键获取售票员) @param @param
88 90 * lineId @throws
89 91 */
... ... @@ -93,7 +95,7 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
93 95 }
94 96  
95 97 /**
96   - *
  98 + *
97 99 * @Title: findPersionByLine @Description: TODO(根据线路主键获取车辆) @param @param
98 100 * lineId @throws
99 101 */
... ... @@ -103,7 +105,7 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
103 105 }
104 106  
105 107 /**
106   - *
  108 + *
107 109 * @Title: sreachNbbm @Description: TODO(搜索车辆内部编码) @throws
108 110 */
109 111 @RequestMapping(value = "/sreachVehic", method = RequestMethod.GET)
... ... @@ -111,9 +113,9 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
111 113 return scheduleRealInfoService.sreachVehic(nbbm);
112 114 }
113 115 /**
114   - *
115   - * @Title: realOutAdjust
116   - * @Description: TODO(实发调整)
  116 + *
  117 + * @Title: realOutAdjust
  118 + * @Description: TODO(实发调整)
117 119 * @param @param id 班次ID
118 120 * @param @param fcsjActual 实际发车时间 HH:mm
119 121 * @param @param remarks 备注
... ... @@ -121,14 +123,14 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
121 123 */
122 124 @RequestMapping(value = "/realOutAdjust", method = RequestMethod.POST)
123 125 public Map<String, Object> realOutAdjust(@RequestParam Long id, @RequestParam String fcsjActual,
124   - @RequestParam String remarks) {
  126 + @RequestParam String remarks) {
125 127 return scheduleRealInfoService.realOutAdjust(id, fcsjActual, remarks);
126 128 }
127   -
  129 +
128 130 /**
129   - *
130   - * @Title: revokeDestroy
131   - * @Description: TODO(撤销烂班)
  131 + *
  132 + * @Title: revokeDestroy
  133 + * @Description: TODO(撤销烂班)
132 134 * @param @param id
133 135 * @throws
134 136 */
... ... @@ -136,11 +138,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
136 138 public Map<String, Object> revokeDestroy(@RequestParam Long id){
137 139 return scheduleRealInfoService.revokeDestroy(id);
138 140 }
139   -
  141 +
140 142 /**
141   - *
142   - * @Title: revokeRealOutgo
143   - * @Description: TODO(撤销实发)
  143 + *
  144 + * @Title: revokeRealOutgo
  145 + * @Description: TODO(撤销实发)
144 146 * @param @param id
145 147 * @throws
146 148 */
... ... @@ -160,9 +162,9 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
160 162 }
161 163  
162 164 /**
163   - *
164   - * @Title: spaceAdjust
165   - * @Description: TODO(间隔调整)
  165 + *
  166 + * @Title: spaceAdjust
  167 + * @Description: TODO(间隔调整)
166 168 * @param @param ids 要调整的班次数组ID
167 169 * @param @param space 间隔
168 170 * @throws
... ... @@ -171,11 +173,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
171 173 public Map<String, Object> spaceAdjust(Long[] ids, Integer space){
172 174 return scheduleRealInfoService.spaceAdjust(ids, space);
173 175 }
174   -
  176 +
175 177 /**
176   - *
177   - * @Title: schInfoFineTune
178   - * @Description: TODO(发车信息微调)
  178 + *
  179 + * @Title: schInfoFineTune
  180 + * @Description: TODO(发车信息微调)
179 181 * @param @param map
180 182 * @throws
181 183 */
... ... @@ -183,11 +185,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
183 185 public Map<String, Object> schInfoFineTune(@RequestParam Map<String, String> map){
184 186 return scheduleRealInfoService.schInfoFineTune(map);
185 187 }
186   -
  188 +
187 189 /**
188   - *
189   - * @Title: outgoAdjustAll
190   - * @Description: TODO(批量待发调整)
  190 + *
  191 + * @Title: outgoAdjustAll
  192 + * @Description: TODO(批量待发调整)
191 193 * @param @param list
192 194 * @throws
193 195 */
... ... @@ -197,11 +199,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
197 199 params = StringEscapeUtils.unescapeHtml4(params);
198 200 return scheduleRealInfoService.outgoAdjustAll(params);
199 201 }
200   -
  202 +
201 203 /**
202   - *
203   - * @Title: findByLineAndUpDown
204   - * @Description: TODO(根据线路和走向获取班次)
  204 + *
  205 + * @Title: findByLineAndUpDown
  206 + * @Description: TODO(根据线路和走向获取班次)
205 207 * @param @param line
206 208 * @param @param upDown
207 209 */
... ... @@ -209,11 +211,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
209 211 public List<ScheduleRealInfo> findByLineAndUpDown(@RequestParam String line,@RequestParam Integer upDown){
210 212 return dayOfSchedule.findByLineAndUpDown(line, upDown);
211 213 }
212   -
  214 +
213 215 /**
214   - *
215   - * @Title: findRouteByLine
216   - * @Description: TODO(获取线路的站点,路段路由)
  216 + *
  217 + * @Title: findRouteByLine
  218 + * @Description: TODO(获取线路的站点,路段路由)
217 219 * @param @param lineCode
218 220 * @throws
219 221 */
... ... @@ -221,11 +223,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
221 223 public Map<String, Object> findRouteByLine(@RequestParam String lineCode){
222 224 return scheduleRealInfoService.findRouteByLine(lineCode);
223 225 }
224   -
  226 +
225 227 /**
226   - *
227   - * @Title: removeChildTask
228   - * @Description: TODO(删除子任务)
  228 + *
  229 + * @Title: removeChildTask
  230 + * @Description: TODO(删除子任务)
229 231 * @param @param taskId 子任务ID
230 232 * @throws
231 233 */
... ... @@ -235,9 +237,9 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
235 237 }
236 238  
237 239 /**
238   - *
239   - * @Title: findByLineCode
240   - * @Description: TODO(根据线路获取班次信息)
  240 + *
  241 + * @Title: findByLineCode
  242 + * @Description: TODO(根据线路获取班次信息)
241 243 * @param @param lineCode
242 244 */
243 245 @RequestMapping(value = "/lineCode/{lineCode}")
... ... @@ -247,29 +249,29 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
247 249  
248 250 @RequestMapping(value = "/queryUserInfo")
249 251 public List<ScheduleRealInfo> queryUserInfo(@RequestParam String line,
250   - @RequestParam String date,@RequestParam String state) {
  252 + @RequestParam String date,@RequestParam String state) {
251 253 return scheduleRealInfoService.queryUserInfo(line, date,state);
252 254 }
253   -
  255 +
254 256 @RequestMapping(value = "/queryUserInfoPx")
255 257 public List<ScheduleRealInfo> queryUserInfoPx(@RequestParam String line,
256   - @RequestParam String date,@RequestParam String state,@RequestParam String type) {
  258 + @RequestParam String date,@RequestParam String state,@RequestParam String type) {
257 259 return scheduleRealInfoService.queryUserInfoPx(line, date,state,type);
258 260 }
259 261  
260 262 @RequestMapping(value = "/exportWaybill",method = RequestMethod.GET)
261 263 public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName, @RequestParam String clZbh,
262   - @RequestParam String lpName,@RequestParam String date,@RequestParam String line) {
  264 + @RequestParam String lpName,@RequestParam String date,@RequestParam String line) {
263 265 return scheduleRealInfoService.exportWaybill(jName, clZbh, lpName,date,line);
264 266 }
265   -
  267 +
266 268 @RequestMapping(value = "/exportWaybillQp",method = RequestMethod.GET)
267 269 public List<ScheduleRealInfo> exportWaybillQp(@RequestParam String clZbh
268 270 ,@RequestParam String date,@RequestParam String line) {
269 271 return scheduleRealInfoService.exportWaybillQp( clZbh, date,line);
270 272 }
271 273  
272   -
  274 +
273 275 @RequestMapping(value = "/dailyInfo")
274 276 public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) {
275 277 return scheduleRealInfoService.dailyInfo(line, date, type);
... ... @@ -277,42 +279,65 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
277 279  
278 280 @RequestMapping(value = "/historyMessage")
279 281 public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date,
280   - @RequestParam String code, @RequestParam String type) {
  282 + @RequestParam String code, @RequestParam String type) {
281 283 return scheduleRealInfoService.historyMessage(line, date, code, type);
282 284 }
283   -
  285 +
284 286 @RequestMapping(value="/findLine")
285 287 public List<Map<String,String>> findLine(@RequestParam String line){
286 288 return scheduleRealInfoService.findLine(line);
287 289 }
288   -
  290 +
289 291 @RequestMapping(value="/findKMBC",method = RequestMethod.GET)
290 292 public Map<String,Object> findKMBC(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
291 293 ,@RequestParam String date,@RequestParam String line){
292 294 return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line);
293 295 }
294   -
  296 +
  297 + /**
  298 + * 路单公里统计 (闵行审计专用)
  299 + * @param jGh
  300 + * @param clZbh
  301 + * @param lpName
  302 + * @param date
  303 + * @param line
  304 + * @return
  305 + */
  306 + @RequestMapping(value="/findKMBC_mh_2",method = RequestMethod.GET)
  307 + public Map<String,Object> findKMBC_mh_2(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  308 + ,@RequestParam String date,@RequestParam String line){
  309 + return scheduleRealInfoService.findKMBC_mh_2(jGh, clZbh,lpName,date,line);
  310 + }
  311 +
295 312 @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)
296 313 public Map<String,Object> findKMBCQp(@RequestParam String clZbh
297 314 ,@RequestParam String date,@RequestParam String line){
298 315 return scheduleRealInfoService.findKMBCQp(clZbh,date,line);
299 316 }
300   -
  317 +
301 318 @RequestMapping(value="/findLpName")
302 319 public List<Map<String,String>> findLpName(@RequestParam String lpName){
303 320 return scheduleRealInfoService.findLpName(lpName);
304 321 }
305   -
  322 +
306 323 @RequestMapping(value = "/account")
307 324 public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date,
308   - @RequestParam String code,@RequestParam String xlName, @RequestParam String type) {
  325 + @RequestParam String code,@RequestParam String xlName, @RequestParam String type) {
309 326 return scheduleRealInfoService.account(line, date, code, xlName, type);
310 327 }
311 328  
  329 + @RequestMapping(value = "/accountPx")
  330 + public List<Map<String,Object>> accountPx(@RequestParam String line, @RequestParam String date,
  331 + @RequestParam String code,@RequestParam String xlName, @RequestParam String px) {
  332 + return scheduleRealInfoService.accountPx(line, date, code, xlName, px);
  333 + }
  334 +
312 335 @RequestMapping(value = "/correctForm")
313   - public List<ScheduleRealInfo> correctForm(@RequestParam String line, @RequestParam String startDate,
314   - @RequestParam String endDate, @RequestParam String lpName, @RequestParam String code, @RequestParam String type) {
315   - return scheduleRealInfoService.correctForm(line, startDate, endDate, lpName, code, type);
  336 + public List<SchEditInfoDto> correctForm(@RequestParam String line, @RequestParam String date,
  337 + @RequestParam String endDate,
  338 + @RequestParam String lpName, @RequestParam String code,
  339 + @RequestParam String type,@RequestParam String changType) {
  340 + return scheduleRealInfoService.correctForm(line, date, endDate, lpName, code, type,changType);
316 341 }
317 342 /**
318 343 * @Title queryListWaybill
... ... @@ -327,19 +352,39 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
327 352 ,@RequestParam String date,@RequestParam String line){
328 353 return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName,date,line);
329 354 }
330   -
  355 +
  356 + /**
  357 + * @Title queryListWaybill
  358 + * @Description 查询行车路单列表(闵行审计专用路单)
  359 + * @param jName 驾驶员名字
  360 + * @param clZbh 车辆自编号(内部编号)
  361 + * @param lpName 路牌
  362 + * @return
  363 + */
  364 + @RequestMapping(value="/queryListWaybill_mh_2",method = RequestMethod.GET)
  365 + public List<ScheduleRealInfo> queryListWaybill_mh_2(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName
  366 + ,@RequestParam String date,@RequestParam String line){
  367 + return scheduleRealInfoService.queryListWaybill2(jName, clZbh,lpName,date,line);
  368 + }
  369 +
331 370 @RequestMapping(value="/queryListWaybillQp",method = RequestMethod.GET)
332 371 public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh,
333   - @RequestParam String date,@RequestParam String line){
  372 + @RequestParam String date,@RequestParam String line){
334 373 return scheduleRealInfoService.queryListWaybillQp(clZbh,date,line);
335 374 }
336   -
  375 +
337 376 @RequestMapping(value="/statisticsDaily")
338 377 public List<Map<String,Object>> statisticsDaily(@RequestParam String line, @RequestParam String date,
339   - @RequestParam String xlName, @RequestParam String type){
  378 + @RequestParam String xlName, @RequestParam String type){
340 379 return scheduleRealInfoService.statisticsDaily(line, date, xlName, type);
341 380 }
342   -
  381 +
  382 + @RequestMapping(value="/statisticsDaily_mh_2")
  383 + public List<Map<String,Object>> statisticsDaily_mh_2(@RequestParam String line, @RequestParam String date,
  384 + @RequestParam String xlName, @RequestParam String type){
  385 + return scheduleRealInfoService.statisticsDaily_mh_2(line, date, xlName, type);
  386 + }
  387 +
343 388 @RequestMapping(value="/statisticsDailyTj")
344 389 public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){
345 390 String gsdm="";
... ... @@ -372,41 +417,46 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
372 417 }
373 418 return scheduleRealInfoService.statisticsDailyTj(gsdm,fgsdm,line, date,date2, xlName, type);
374 419 }
375   -
  420 +
376 421 @RequestMapping(value="/MapById",method = RequestMethod.GET)
377 422 public Map<String, Object> MapById(@RequestParam("id") Long id){
378 423 return scheduleRealInfoService.MapById(id);
379 424 }
380   -
  425 +
381 426 /**
382   - * @Title: scheduleDaily
383   - * @Description: TODO(调度日报表)
  427 + * @Title: scheduleDaily
  428 + * @Description: TODO(调度日报表)
384 429 * @param line 线路
385 430 * @param date 时间
386   - * @return
  431 + * @return
387 432 */
388 433 @RequestMapping(value="/scheduleDaily")
389 434 public Map<String,Object> scheduleDaily(@RequestParam String line,@RequestParam String date){
390 435 return scheduleRealInfoService.scheduleDaily(line,date);
391 436 }
392   -
  437 +
393 438 @RequestMapping(value="/realScheduleList")
394 439 public List<ScheduleRealInfo> realScheduleList(@RequestParam String line,@RequestParam String date){
395 440 return scheduleRealInfoService.realScheduleList(line,date);
396 441 }
397   -
  442 +
  443 + @RequestMapping(value="/realScheduleList_mh_2")
  444 + public List<ScheduleRealInfo> realScheduleList_mh_2(@RequestParam String line,@RequestParam String date){
  445 + return scheduleRealInfoService.realScheduleList_mh_2(line,date);
  446 + }
  447 +
398 448 @RequestMapping(value="/realScheduleListQp")
399 449 public List<ScheduleRealInfo> realScheduleListQp(@RequestParam String line,@RequestParam String date){
400 450 return scheduleRealInfoService.realScheduleListQp(line,date);
401 451 }
402   -
  452 +
403 453 @RequestMapping(value="/multi_tzrc", method=RequestMethod.POST)
404 454 public Map<String, Object> multi_tzrc(@RequestParam String cpcsJson){
405 455 cpcsJson = StringEscapeUtils.unescapeHtml4(cpcsJson);
406 456 List<ChangePersonCar> cpcs = JSONArray.parseArray(cpcsJson, ChangePersonCar.class);
407 457 return scheduleRealInfoService.multi_tzrc(cpcs);
408 458 }
409   -
  459 +
410 460 @RequestMapping(value="/multi_dftz", method=RequestMethod.POST)
411 461 public Map<String, Object> multi_dftz(@RequestParam String dcsJson){
412 462 dcsJson = StringEscapeUtils.unescapeHtml4(dcsJson);
... ... @@ -419,10 +469,10 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
419 469 return scheduleRealInfoService.changeBcType(id, bcType, remarks);
420 470 }
421 471  
422   -/* @RequestMapping(value="/history", method=RequestMethod.POST)
  472 + @RequestMapping(value="/history", method=RequestMethod.POST)
423 473 public Map<String,Object> historySave(ScheduleRealInfo sch){
424 474 return scheduleRealInfoService.historySave(sch);
425   - }*/
  475 + }
426 476  
427 477  
428 478 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
... ... @@ -432,11 +482,13 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
432 482 * @return
433 483 */
434 484 @RequestMapping("dateArray")
435   - public List<String> dateArray(){
  485 + public List<String> dateArray(@RequestParam(defaultValue = "0") int c){
436 486 List<String> rs = new ArrayList<>();
437 487  
438   - long t = new Date().getTime() - ONE_DAY;
439   - for(int i = 0; i < 5; i ++){
  488 + long t = new Date().getTime();
  489 + if(c != 1)
  490 + t -= ONE_DAY - (1000 * 60 * 60 * 2);
  491 + for(int i = 0; i < 3; i ++){
440 492 rs.add(fmtyyyyMMdd.print(t));
441 493 t -= ONE_DAY;
442 494 }
... ... @@ -467,7 +519,7 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
467 519 public List<Map<String, Object>> scheduleDailyExport(@RequestParam Map<String, Object> map){
468 520 return scheduleRealInfoService.scheduleDailyExport(map);
469 521 }
470   -
  522 +
471 523 @RequestMapping(value = "exportWaybillMore", method = RequestMethod.GET)
472 524 public Map<String, Object> exportWaybillMore(@RequestParam Map<String, Object> map){
473 525 return scheduleRealInfoService.exportWaybillMore(map);
... ... @@ -536,4 +588,24 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
536 588 public List<ScheduleRealInfo> allLate2(@RequestParam String idx){
537 589 return scheduleRealInfoService.allLate2(idx);
538 590 }
  591 +
  592 + /**
  593 + * 添加一个临加到历史库
  594 + * @param sch
  595 + * @return
  596 + */
  597 + @RequestMapping(value = "history/add", method = RequestMethod.POST)
  598 + public Map<String, Object> addToHistory(ScheduleRealInfo sch){
  599 + return scheduleRealInfoService.addToHistory(sch);
  600 + }
  601 +
  602 + /**
  603 + * 从历史库里删除临加班次
  604 + * @param sch
  605 + * @return
  606 + */
  607 + @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE)
  608 + public Map<String, Object> deleteToHistory(@PathVariable("id") Long id){
  609 + return scheduleRealInfoService.deleteToHistory(id);
  610 + }
539 611 }
... ...
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
  3 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  4 +import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
  5 +import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
  6 +import com.bsth.data.msg_queue.DirectivePushQueue;
  7 +import com.bsth.data.msg_queue.WebSocketPushQueue;
3 8 import com.bsth.data.schedule.DayOfSchedule;
4 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
5 10 import org.slf4j.Logger;
... ... @@ -10,12 +15,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
10 15 import org.springframework.web.bind.annotation.RequestParam;
11 16 import org.springframework.web.bind.annotation.RestController;
12 17  
13   -import java.util.HashSet;
  18 +import java.util.HashMap;
14 19 import java.util.List;
15   -import java.util.Set;
  20 +import java.util.Map;
16 21  
17 22 /**
18   - * 相关数据异常检测
19 23 * Created by panzhao on 2017/4/14.
20 24 */
21 25 @RestController
... ... @@ -27,6 +31,10 @@ public class anomalyCheckController {
27 31  
28 32 @Autowired
29 33 DayOfSchedule dayOfSchedule;
  34 +
  35 + @Autowired
  36 + GeoCacheData geoCacheData;
  37 +
30 38 /**
31 39 * 出现重复班次的车辆
32 40 * @param nbbm
... ... @@ -35,16 +43,56 @@ public class anomalyCheckController {
35 43 public void schRepeat(@RequestParam String nbbm){
36 44 logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");
37 45 List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);
  46 + logger.info("检测前,车辆班次数量:" + list.size());
38 47  
39   - Set<ScheduleRealInfo> set = new HashSet<>();
  48 + Map<Long, ScheduleRealInfo> map = new HashMap<>();
40 49 for(ScheduleRealInfo sch : list){
41   - if(!set.add(sch)){
42   - logger.info("出现一次重复班次,班次ID:" + sch.getId());
  50 + if(map.containsKey(sch.getId())){
  51 + logger.info("检测到重复ID: " + sch.getId());
43 52 }
  53 + map.put(sch.getId(), sch);
44 54 }
45 55  
46   - if(set.size() > 0){
47   - dayOfSchedule.replaceByNbbm(nbbm, set);
  56 + logger.info("检测后,车辆班次数量:" + list.size());
  57 + if(map.values().size() > 0){
  58 + dayOfSchedule.replaceByNbbm(nbbm, map.values());
48 59 }
49 60 }
  61 +
  62 + @RequestMapping(value = "/shutdownThreadPool")
  63 + public void shutdownThreadPool(){
  64 + GpsRealAnalyse.shutdown();
  65 + }
  66 +
  67 + @RequestMapping(value = "/directivePushQueue")
  68 + public void directivePushQueue(){
  69 + DirectivePushQueue.start();
  70 + }
  71 +
  72 + @RequestMapping(value = "/directiveQueueSize")
  73 + public void directiveQueueSize(){
  74 + DirectivePushQueue.size();
  75 + }
  76 +
  77 + @RequestMapping(value = "/webSocketPushQueue")
  78 + public void webSocketPushQueue(){
  79 + WebSocketPushQueue.start();
  80 + }
  81 +
  82 + @RequestMapping(value = "/webSocketQueueSize")
  83 + public void webSocketQueueSize(){
  84 + WebSocketPushQueue.size();
  85 + }
  86 +
  87 + @RequestMapping(value = "/setHttpFlag")
  88 + public void setHttpFlag(@RequestParam int flag){
  89 + if(flag != 0 && flag != -1)
  90 + return;
  91 + GpsDataLoaderThread.setFlag(flag);
  92 + }
  93 +
  94 + @RequestMapping(value = "/updateCacheBuff")
  95 + public void updateCacheBuff(){
  96 + geoCacheData.loadData();
  97 + }
50 98 }
... ...
src/main/java/com/bsth/controller/realcontrol/summary/HoursController.java 0 → 100644
  1 +package com.bsth.controller.realcontrol.summary;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.data.summary.entity.Hours_jsy;
  5 +import org.springframework.web.bind.annotation.RequestMapping;
  6 +import org.springframework.web.bind.annotation.RestController;
  7 +
  8 +/**
  9 + * 汇总数据 -工时
  10 + * Created by panzhao on 2017/7/27.
  11 + */
  12 +@RestController
  13 +@RequestMapping("/summary/hours")
  14 +public class HoursController extends BaseController<Hours_jsy, Long>{
  15 +}
... ...
src/main/java/com/bsth/controller/report/ReportController.java
... ... @@ -6,12 +6,16 @@ import java.util.Iterator;
6 6 import java.util.List;
7 7 import java.util.Map;
8 8  
  9 +import org.apache.commons.lang3.StringEscapeUtils;
9 10 import org.springframework.beans.factory.annotation.Autowired;
10 11 import org.springframework.web.bind.annotation.RequestMapping;
11 12 import org.springframework.web.bind.annotation.RequestMethod;
12 13 import org.springframework.web.bind.annotation.RequestParam;
13 14 import org.springframework.web.bind.annotation.RestController;
14 15  
  16 +import com.alibaba.fastjson.JSONArray;
  17 +import com.alibaba.fastjson.JSONObject;
  18 +import com.bsth.entity.StationRoute;
15 19 import com.bsth.entity.excep.ArrivalInfo;
16 20 import com.bsth.entity.realcontrol.ScheduleRealInfo;
17 21 import com.bsth.service.report.ReportService;
... ... @@ -75,6 +79,17 @@ public class ReportController {
75 79 }
76 80  
77 81  
  82 + @RequestMapping(value="/queryStrinon" ,method = RequestMethod.GET)
  83 + public List<StationRoute> queryStrinon(@RequestParam String line,
  84 + @RequestParam int zd){
  85 + return service.queryStrinon(line,zd);
  86 + }
  87 + @RequestMapping(value="/queryInOutStrtion" ,method = RequestMethod.GET)
  88 + public List<Map<String, Object>> queryInOutStrtion(@RequestParam String line,
  89 + @RequestParam String date,@RequestParam int zd,@RequestParam String lzsj){
  90 + return service.queryInOutStrtion(line,date,zd,lzsj);
  91 + }
  92 +
78 93 @RequestMapping(value="/queryListClzd" ,method = RequestMethod.GET)
79 94 public List<ArrivalInfo> queryListClzd(@RequestParam String zd,@RequestParam String line,
80 95 @RequestParam String zdlx,@RequestParam String fcsj,@RequestParam String ddsj){
... ... @@ -84,6 +99,8 @@ public class ReportController {
84 99  
85 100  
86 101  
  102 +
  103 +
87 104 @RequestMapping(value="/exportQueryListClzd" ,method = RequestMethod.GET)
88 105 public List<Map<String, Object>> exportQueryListClzd(@RequestParam String zd,@RequestParam String line,
89 106 @RequestParam String zdlx,@RequestParam String fcsj,@RequestParam String ddsj){
... ... @@ -96,6 +113,7 @@ public class ReportController {
96 113 Map<String, Object> m = new HashMap<String, Object>();
97 114 m.put("i", i);
98 115 m.put("nbbm", a.getNbbm());
  116 + m.put("pzh", a.getPzh());
99 117 m.put("stopName", a.getStopName());
100 118 m.put("jzsj", a.getJzsj());
101 119 m.put("czsj", a.getCzsj());
... ... @@ -171,8 +189,8 @@ public class ReportController {
171 189 return new ArrayList<Map<String, Object>>();
172 190 }
173 191 @RequestMapping(value = "/sreachZd", method = RequestMethod.GET)
174   - public List<Map<String, String>> sreachPersonnel(@RequestParam String line,@RequestParam int zdlx,@RequestParam String zd) {
175   - return service.sreachZd(line,zdlx, zd);
  192 + public List<Map<String, String>> sreachPersonnel(@RequestParam String line,@RequestParam int zdlx) {
  193 + return service.sreachZd(line,zdlx);
176 194 }
177 195  
178 196  
... ... @@ -246,4 +264,57 @@ public class ReportController {
246 264 return service.userList(map);
247 265 }
248 266  
  267 + @RequestMapping(value="/countLineMileage")
  268 + public List<Map<String,Object>> countLineMileage(@RequestParam Map<String, Object> map){
  269 +
  270 + return service.countByList(map);
  271 + }
  272 +
  273 + @RequestMapping(value="/countBusMileage")
  274 + public List<Map<String,Object>> countBusMileage(@RequestParam Map<String, Object> map){
  275 + return service.countByBusList(map);
  276 + }
  277 +
  278 + @RequestMapping(value="/countDjg")
  279 + public List<Map<String, Object>> countDjg(@RequestParam Map<String, Object> map){
  280 + return service.countDjg(map);
  281 + }
  282 +
  283 +
  284 + @RequestMapping(value="/countDjgXx")
  285 + public List<Map<String, Object>> countDjgXx(@RequestParam Map<String, Object> map){
  286 + List<Map<String, Object>> lMap=new ArrayList<Map<String, Object>>();
  287 + String json =StringEscapeUtils.unescapeHtml4(map.get("listXx").toString());
  288 + JSONArray jsonArray=JSONArray.parseArray(json);
  289 + JSONObject jsonObject;
  290 + for (int x = 0; x < jsonArray.size(); x++) {
  291 + jsonObject=jsonArray.getJSONObject(x);
  292 + Map<String, Object> m_=new HashMap<String,Object>();
  293 + m_.put("fgsname", jsonObject.getString("fgsname"));
  294 + m_.put("xlName", jsonObject.getString("xlName"));
  295 + m_.put("djgde", jsonObject.getString("djgde"));
  296 + m_.put("qJh", jsonObject.getString("qJh"));
  297 + m_.put("qSj", jsonObject.getString("qSj"));
  298 + m_.put("hJh", jsonObject.getString("hJh"));
  299 + m_.put("hSj", jsonObject.getString("hSj"));
  300 + m_.put("djgsj", jsonObject.getString("djgsj"));
  301 + m_.put("bcjgsj", jsonObject.getString("bcjgsj"));
  302 + lMap.add(m_);
  303 + }
  304 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  305 + Map<String, Object> m = new HashMap<String, Object>();
  306 + m.put("date", map.get("date").toString());
  307 + ReportUtils ee = new ReportUtils();
  308 + try {
  309 + listI.add(lMap.iterator());
  310 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  311 + ee.excelReplace(listI, new Object[]{m}, path + "mould/countIntervalXx.xls",
  312 + path + "export/大间隔统计表详细.xls");
  313 + } catch (Exception e) {
  314 + // TODO: handle exception
  315 + e.printStackTrace();
  316 + }
  317 +
  318 + return lMap;
  319 + }
249 320 }
... ...
src/main/java/com/bsth/controller/report/SheetController.java 0 → 100644
  1 +package com.bsth.controller.report;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import com.bsth.controller.BaseController;
  13 +import com.bsth.entity.sheet.Sheet;
  14 +import com.bsth.service.report.SheetService;
  15 +
  16 +@RestController
  17 +@RequestMapping("sheet")
  18 +public class SheetController extends BaseController<Sheet, Integer>{
  19 + @Autowired
  20 + SheetService sheetService;
  21 + @RequestMapping(value = "/saveListSheet",method = RequestMethod.POST)
  22 + public String saveListSheet(@RequestParam String date){
  23 + String result="";
  24 + try {
  25 + result = sheetService.saveSheetList(date);
  26 + } catch (Exception e) {
  27 + // TODO Auto-generated catch block
  28 + e.printStackTrace();
  29 + }
  30 + return result;
  31 + }
  32 +
  33 +
  34 + @RequestMapping(value = "/sheetList",method = RequestMethod.GET)
  35 + public List<Sheet> sheetList(@RequestParam Integer id){
  36 + List<Sheet> list=sheetService.sheetList(id);
  37 + return list;
  38 + }
  39 + @RequestMapping(value = "/exportList",method = RequestMethod.GET)
  40 + public List<Sheet> exportList(@RequestParam Integer id){
  41 + List<Sheet> list=sheetService.exportList(id);
  42 + return list;
  43 + }
  44 +
  45 + @RequestMapping(value = "/countList",method = RequestMethod.GET)
  46 + public List<Map<String, Object>> countList(@RequestParam Map<String, Object> map){
  47 + List<Map<String, Object>> list=sheetService.countList(map);
  48 + return list;
  49 + }
  50 +
  51 + @RequestMapping(value = "/listSheet",method = RequestMethod.GET)
  52 + public List<Map<String, Object>> listSheet(@RequestParam Map<String, Object> map){
  53 + List<Map<String, Object>> list=sheetService.listSheet(map);
  54 + return list;
  55 + }
  56 +}
... ...
src/main/java/com/bsth/controller/schedule/BController.java
... ... @@ -6,11 +6,11 @@ import com.bsth.entity.schedule.BEntity;
6 6 import com.bsth.entity.sys.SysUser;
7 7 import com.bsth.service.schedule.BService;
8 8 import com.bsth.service.schedule.exception.ScheduleException;
  9 +import com.bsth.service.schedule.utils.DataToolsFile;
9 10 import com.bsth.service.sys.SysUserService;
10 11 import com.google.common.base.Splitter;
11   -import jxl.Sheet;
12   -import jxl.Workbook;
13 12 import org.apache.commons.lang3.StringUtils;
  13 +import org.apache.poi.ss.usermodel.Workbook;
14 14 import org.springframework.beans.factory.annotation.Autowired;
15 15 import org.springframework.data.domain.PageRequest;
16 16 import org.springframework.data.domain.Sort;
... ... @@ -154,20 +154,24 @@ public class BController&lt;T, ID extends Serializable&gt; {
154 154 public Map<String, Object> uploadFile(MultipartFile file) {
155 155 Map<String, Object> rtn = new HashMap<>();
156 156 try {
157   - File file1 = bService.uploadFile(file.getOriginalFilename(), file.getBytes());
  157 + DataToolsFile dataToolsFile = bService.uploadFile(file.getOriginalFilename(), file.getBytes());
158 158 // excel文件名
159   - String fileName = file1.getAbsolutePath();
  159 + String fileName = dataToolsFile.getFile().getAbsolutePath();
  160 + Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile());
  161 +
160 162 // excel文件sheet
161 163 List<String> sheetnames = new ArrayList<>();
162   - Workbook book = Workbook.getWorkbook(file1);
163   - for (Sheet sheet : book.getSheets()) {
164   - sheetnames.add(sheet.getName());
  164 + for (int i = 0; i < wb.getNumberOfSheets(); i ++) {
  165 + sheetnames.add(wb.getSheetAt(i).getSheetName());
165 166 }
166 167  
  168 + wb.close();
  169 +
167 170 rtn.put("status", ResponseCode.SUCCESS);
168 171 rtn.put("filename", fileName);
169 172 rtn.put("sheetnames", StringUtils.join(sheetnames, ","));
170 173 } catch (Exception exp) {
  174 + exp.printStackTrace();
171 175 rtn.put("status", ResponseCode.ERROR);
172 176 rtn.put("msg", exp.getMessage());
173 177 }
... ... @@ -202,13 +206,14 @@ public class BController&lt;T, ID extends Serializable&gt; {
202 206 Map<String, Object> rtn = new HashMap<>();
203 207  
204 208 try {
205   - File file1 = bService.uploadFile(file.getOriginalFilename(), file.getBytes());
  209 + DataToolsFile dataToolsFile = bService.uploadFile(file.getOriginalFilename(), file.getBytes());
206 210 Map<String, Object> params = new HashMap<>();
207   - bService.importData(file1, params);
  211 + bService.importData(dataToolsFile.getFile(), params);
208 212  
209 213 rtn.put("status", ResponseCode.SUCCESS);
210 214 rtn.put("msg", "上传&导入文件成功");
211 215 } catch (Exception exp) {
  216 + exp.printStackTrace();
212 217 rtn.put("status", ResponseCode.ERROR);
213 218 rtn.put("msg", exp.getMessage());
214 219 }
... ... @@ -220,16 +225,16 @@ public class BController&lt;T, ID extends Serializable&gt; {
220 225 @RequestMapping(value = "/exportFile", method = RequestMethod.GET)
221 226 public void exportFile(HttpServletResponse response,
222 227 @RequestParam Map<String, Object> params) throws Exception {
223   - File file = bService.exportData(params);
  228 + DataToolsFile dataToolsFile = bService.exportData(params);
224 229 // 流输出导出文件
225 230 response.setHeader("content-type", "application/octet-stream");
226   - response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
  231 + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName());
227 232 response.setContentType("application/octet-stream");
228 233  
229 234 OutputStream os = response.getOutputStream();
230 235 BufferedOutputStream bos = new BufferedOutputStream(os);
231 236  
232   - InputStream is = new FileInputStream(file);
  237 + InputStream is = new FileInputStream(dataToolsFile.getFile());
233 238 BufferedInputStream bis = new BufferedInputStream(is);
234 239  
235 240 int length = 0;
... ...
src/main/java/com/bsth/controller/schedule/PeopleCarPlanController.java
... ... @@ -33,6 +33,11 @@ public class PeopleCarPlanController {
33 33 public Map<String, Object> scheduleAnaly(@RequestParam Map<String, Object> map){
34 34 return peopleCarPlanService.scheduleAnaly(map);
35 35 }
  36 +
  37 + @RequestMapping(value="/scheduleAnaly_sum", method = RequestMethod.GET)
  38 + public Map<String, Object> scheduleAnaly_sum(@RequestParam Map<String, Object> map){
  39 + return peopleCarPlanService.scheduleAnaly_sum(map);
  40 + }
36 41  
37 42 @RequestMapping(value="/getModel", method = RequestMethod.GET)
38 43 public List<Map<String,Object>> getModel(@RequestParam Map<String, Object> map){
... ... @@ -44,9 +49,25 @@ public class PeopleCarPlanController {
44 49 return peopleCarPlanService.firstAndLastBus(map);
45 50 }
46 51  
  52 + @RequestMapping(value="/firstAndLastBus_sum", method = RequestMethod.GET)
  53 + public List<Map<String,Object>> firstAndLastBus_sum(@RequestParam Map<String, Object> map){
  54 + return peopleCarPlanService.firstAndLastBus_sum(map);
  55 + }
  56 +
47 57 @RequestMapping(value="/commandState", method = RequestMethod.GET)
48 58 public List<Map<String,Object>> commandState(@RequestParam Map<String, Object> map){
49 59 return peopleCarPlanService.commandState(map);
50 60 }
51 61  
  62 + @RequestMapping(value="/commandByLineList", method = RequestMethod.GET)
  63 + public List<Map<String,Object>> commandByLineList(@RequestParam Map<String, Object> map){
  64 + return peopleCarPlanService.commandByLineList(map);
  65 + }
  66 +
  67 + @RequestMapping(value="/commandByJghList", method = RequestMethod.GET)
  68 + public List<Map<String,Object>> commandByJghList(@RequestParam Map<String, Object> map){
  69 + return peopleCarPlanService.commandByJghList(map);
  70 + }
  71 +
  72 +
52 73 }
... ...
src/main/java/com/bsth/controller/schedule/TrafficManageController.java
... ... @@ -22,9 +22,9 @@ public class TrafficManageController {
22 22  
23 23  
24 24 @RequestMapping(value = "/setXL", method = RequestMethod.GET)
25   - public String setXL() throws Exception {
  25 + public String setXL(@RequestParam("ids") String ids) throws Exception {
26 26 try {
27   - return trManageService.setXL();
  27 + return trManageService.setXL(ids);
28 28 } catch (Exception exp) {
29 29 throw new Exception(exp.getCause());
30 30 }
... ... @@ -57,6 +57,15 @@ public class TrafficManageController {
57 57 }
58 58 }
59 59  
  60 + @RequestMapping(value = "/setLDFile", method = RequestMethod.GET)
  61 + public String setLDFile() throws Exception {
  62 + try {
  63 + return trManageService.setLDFile();
  64 + } catch (Exception exp) {
  65 + throw new Exception(exp.getCause());
  66 + }
  67 + }
  68 +
60 69 @RequestMapping(value = "/setLCYH", method = RequestMethod.GET)
61 70 public String setLCYH() throws Exception {
62 71 try {
... ...
src/main/java/com/bsth/controller/schedule/core/EmployeeConfigInfoController.java
... ... @@ -7,10 +7,7 @@ import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
7 7 import com.bsth.service.schedule.EmployeeConfigInfoService;
8 8 import com.bsth.service.schedule.exception.ScheduleException;
9 9 import org.springframework.beans.factory.annotation.Autowired;
10   -import org.springframework.web.bind.annotation.RequestMapping;
11   -import org.springframework.web.bind.annotation.RequestMethod;
12   -import org.springframework.web.bind.annotation.RequestParam;
13   -import org.springframework.web.bind.annotation.RestController;
  10 +import org.springframework.web.bind.annotation.*;
14 11  
15 12 import java.util.HashMap;
16 13 import java.util.List;
... ... @@ -38,6 +35,19 @@ public class EmployeeConfigInfoController extends BController&lt;EmployeeConfigInfo
38 35 }
39 36  
40 37  
  38 + @RequestMapping(value = "/dbbm/{xlid}", method = RequestMethod.GET)
  39 + public Map<String, Object> getDbbm(@PathVariable("xlid") Integer xl) {
  40 + Map<String, Object> rtn = new HashMap<>();
  41 + try {
  42 + rtn.put("data", employeeConfigInfoService.getMaxDbbm(xl));
  43 + rtn.put("status", ResponseCode.SUCCESS);
  44 + } catch (Exception exp) {
  45 + exp.printStackTrace();
  46 + rtn.put("status", ResponseCode.ERROR);
  47 + rtn.put("msg", exp.getMessage());
  48 + }
  49 + return rtn;
  50 + }
41 51  
42 52 @RequestMapping(value = "/validate_jsy", method = RequestMethod.GET)
43 53 public Map<String, Object> validate_jsy(@RequestParam Map<String, Object> param) {
... ...
src/main/java/com/bsth/controller/schedule/core/GuideboardInfoController.java
... ... @@ -6,13 +6,8 @@ import com.bsth.entity.schedule.GuideboardInfo;
6 6 import com.bsth.repository.schedule.GuideboardInfoRepository;
7 7 import com.bsth.service.schedule.GuideboardInfoService;
8 8 import com.bsth.service.schedule.exception.ScheduleException;
9   -import com.bsth.service.schedule.utils.DataToolsProperties;
10 9 import org.springframework.beans.factory.annotation.Autowired;
11   -import org.springframework.boot.context.properties.EnableConfigurationProperties;
12   -import org.springframework.web.bind.annotation.RequestMapping;
13   -import org.springframework.web.bind.annotation.RequestMethod;
14   -import org.springframework.web.bind.annotation.RequestParam;
15   -import org.springframework.web.bind.annotation.RestController;
  10 +import org.springframework.web.bind.annotation.*;
16 11  
17 12 import java.util.HashMap;
18 13 import java.util.List;
... ... @@ -23,7 +18,6 @@ import java.util.Map;
23 18 */
24 19 @RestController
25 20 @RequestMapping("gic")
26   -@EnableConfigurationProperties(DataToolsProperties.class)
27 21 public class GuideboardInfoController extends BController<GuideboardInfo, Long> {
28 22 @Autowired
29 23 private GuideboardInfoService guideboardInfoService;
... ... @@ -36,6 +30,21 @@ public class GuideboardInfoController extends BController&lt;GuideboardInfo, Long&gt;
36 30 return guideboardInfoRepository.findLpName(ttid);
37 31 }
38 32  
  33 + @RequestMapping(value = "lpno/{xlid}", method = RequestMethod.GET)
  34 + public Map<String, Object> getLpNo(@PathVariable("xlid") Integer xl) {
  35 + Map<String, Object> rtn = new HashMap<>();
  36 + try {
  37 + rtn.put("data", guideboardInfoService.getMaxLpno(xl));
  38 + rtn.put("status", ResponseCode.SUCCESS);
  39 + } catch (Exception exp) {
  40 + exp.printStackTrace();
  41 + rtn.put("status", ResponseCode.ERROR);
  42 + rtn.put("msg", exp.getMessage());
  43 + }
  44 +
  45 + return rtn;
  46 + }
  47 +
39 48 @RequestMapping(value = "/validate_lpno", method = RequestMethod.GET)
40 49 public Map<String, Object> validate_lpno(@RequestParam Map<String, Object> param) {
41 50 Map<String, Object> rtn = new HashMap<>();
... ...
src/main/java/com/bsth/controller/schedule/SchedulePlanInfoController.java renamed to src/main/java/com/bsth/controller/schedule/core/SchedulePlanInfoController.java
1   -package com.bsth.controller.schedule;
  1 +package com.bsth.controller.schedule.core;
2 2  
3 3 import com.bsth.common.ResponseCode;
4   -import com.bsth.controller.BaseController;
  4 +import com.bsth.controller.schedule.BController;
5 5 import com.bsth.entity.schedule.SchedulePlanInfo;
6 6 import com.bsth.service.schedule.SchedulePlanInfoService;
7 7 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -13,14 +13,51 @@ import java.util.List;
13 13 import java.util.Map;
14 14  
15 15 /**
16   - * Created by xu on 16/6/16.
  16 + * Created by xu on 17/5/1.
17 17 */
18 18 @RestController
19 19 @RequestMapping("spic")
20   -public class SchedulePlanInfoController extends BaseController<SchedulePlanInfo, Long> {
  20 +public class SchedulePlanInfoController extends BController<SchedulePlanInfo, Long> {
21 21 @Autowired
22 22 private SchedulePlanInfoService schedulePlanInfoService;
23 23  
  24 + @RequestMapping(value = "/groupextinfos/{xlid}/{date}", method = RequestMethod.GET)
  25 + public Map<String, Object> findGroupInfoExt(
  26 + @PathVariable(value = "xlid") Integer xlid,
  27 + @PathVariable(value = "date") Date scheduleDate) {
  28 + Map<String, Object> resultMap = new HashMap<>();
  29 + try {
  30 + resultMap.put("status", ResponseCode.SUCCESS);
  31 + resultMap.put("data", schedulePlanInfoService.findSchedulePlanGroupInfo(xlid, scheduleDate));
  32 +
  33 + } catch (Exception exp) {
  34 + exp.printStackTrace();
  35 + resultMap.put("status", ResponseCode.ERROR);
  36 + resultMap.put("msg", exp.getLocalizedMessage());
  37 + }
  38 +
  39 + return resultMap;
  40 + }
  41 +
  42 + @RequestMapping(value = "/lastestsd/{xlid}", method = RequestMethod.GET)
  43 + public Map<String, Object> findLastestPlanDate(
  44 + @PathVariable(value = "xlid") Integer xlid) {
  45 + Map<String, Object> resultMap = new HashMap<>();
  46 + try {
  47 + resultMap.put("status", ResponseCode.SUCCESS);
  48 + resultMap.put("data", schedulePlanInfoService.findLastestPlanDate(xlid));
  49 +
  50 + } catch (Exception exp) {
  51 + exp.printStackTrace();
  52 + resultMap.put("status", ResponseCode.ERROR);
  53 + resultMap.put("msg", exp.getLocalizedMessage());
  54 + }
  55 +
  56 + return resultMap;
  57 + }
  58 +
  59 +
  60 +// ------------------------ 老版本 ----------------------//
24 61 @RequestMapping(value = "/groupinfos/{xlid}/{date}", method = RequestMethod.GET)
25 62 public List<SchedulePlanInfoService.GroupInfo> findGroupInfo(
26 63 @PathVariable(value = "xlid") Integer xlid,
... ...
src/main/java/com/bsth/controller/schedule/core/TTInfoController.java
... ... @@ -3,13 +3,10 @@ package com.bsth.controller.schedule.core;
3 3 import com.bsth.common.ResponseCode;
4 4 import com.bsth.controller.schedule.BController;
5 5 import com.bsth.entity.schedule.TTInfo;
6   -import com.bsth.service.schedule.exception.ScheduleException;
7 6 import com.bsth.service.schedule.TTInfoService;
  7 +import com.bsth.service.schedule.exception.ScheduleException;
8 8 import org.springframework.beans.factory.annotation.Autowired;
9   -import org.springframework.web.bind.annotation.RequestMapping;
10   -import org.springframework.web.bind.annotation.RequestMethod;
11   -import org.springframework.web.bind.annotation.RequestParam;
12   -import org.springframework.web.bind.annotation.RestController;
  9 +import org.springframework.web.bind.annotation.*;
13 10  
14 11 import java.util.HashMap;
15 12 import java.util.Map;
... ... @@ -87,4 +84,18 @@ public class TTInfoController extends BController&lt;TTInfo, Long&gt; {
87 84 return rtn;
88 85 }
89 86  
  87 + @RequestMapping(value = "/backup/{ttinfo}", method = RequestMethod.GET)
  88 + public Map<String, Object> backup(@PathVariable(value = "ttinfo") Long ttInfoId) {
  89 + Map<String, Object> rtn = new HashMap<>();
  90 + try {
  91 + // 备份时刻表
  92 + this.ttInfoService.backUp(ttInfoId);
  93 + } catch (ScheduleException exp) {
  94 + rtn.put("status", ResponseCode.ERROR);
  95 + rtn.put("msg", exp.getMessage());
  96 + }
  97 +
  98 + return rtn;
  99 + }
  100 +
90 101 }
91 102 \ No newline at end of file
... ...
src/main/java/com/bsth/controller/schedule/core/TTInfoDetailController.java
... ... @@ -4,6 +4,7 @@ import com.bsth.common.ResponseCode;
4 4 import com.bsth.controller.schedule.BController;
5 5 import com.bsth.entity.schedule.TTInfoDetail;
6 6 import com.bsth.service.schedule.TTInfoDetailService;
  7 +import com.bsth.service.schedule.datatools.TTInfoDetailForEdit;
7 8 import org.springframework.beans.factory.annotation.Autowired;
8 9 import org.springframework.web.bind.annotation.*;
9 10  
... ... @@ -73,9 +74,13 @@ public class TTInfoDetailController extends BController&lt;TTInfoDetail, Long&gt; {
73 74 @RequestMapping(value = "/edit/{xlid}/{ttid}", method = RequestMethod.GET)
74 75 public Map<String, Object> getEditInfo(@PathVariable("xlid") Integer xlid,
75 76 @PathVariable("ttid") Long ttid) {
  77 +
  78 + // 获取最大的发车数,用于输出数据的数量
  79 + Long maxfcno = ttInfoDetailService.findMaxFcno(xlid, ttid);
  80 +
76 81 Map<String, Object> rtn = new HashMap<>();
77 82 try {
78   - TTInfoDetailService.EditInfo editInfo = ttInfoDetailService.getEditInfo(xlid, ttid);
  83 + TTInfoDetailForEdit.EditInfo editInfo = ttInfoDetailService.getEditInfo(xlid, ttid, maxfcno);
79 84 rtn.put("status", ResponseCode.SUCCESS);
80 85 rtn.put("data", editInfo);
81 86 } catch (Exception exp) {
... ...
src/main/java/com/bsth/controller/sys/IntervalController.java 0 → 100644
  1 +package com.bsth.controller.sys;
  2 +
  3 +import java.util.Map;
  4 +
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestMethod;
  8 +import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
  10 +
  11 +import com.alibaba.fastjson.JSON;
  12 +import com.bsth.entity.sys.Interval;
  13 +import com.bsth.service.sys.IntervalService;
  14 +
  15 +@RestController
  16 +@RequestMapping("interval")
  17 +public class IntervalController {
  18 +
  19 + @Autowired
  20 + IntervalService intervalService;
  21 +
  22 + @RequestMapping(value = "/save", method = RequestMethod.POST)
  23 + public Map<String, Object> save(@RequestParam String array){
  24 + return intervalService.saveList(JSON.parseArray(array, Interval.class));
  25 + }
  26 +}
... ...
src/main/java/com/bsth/controller/sys/ModuleController.java
1 1 package com.bsth.controller.sys;
2 2  
3   -import java.util.List;
4   -
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.entity.sys.Module;
  5 +import com.bsth.service.sys.ModuleService;
5 6 import org.springframework.beans.factory.annotation.Autowired;
6 7 import org.springframework.web.bind.annotation.RequestMapping;
7 8 import org.springframework.web.bind.annotation.RequestParam;
8 9 import org.springframework.web.bind.annotation.RestController;
9 10  
10   -import com.bsth.controller.BaseController;
11   -import com.bsth.entity.sys.Module;
12   -import com.bsth.service.sys.ModuleService;
  11 +import java.util.List;
13 12  
14 13 @RestController
15 14 @RequestMapping("module")
... ... @@ -34,4 +33,9 @@ public class ModuleController extends BaseController&lt;Module, Integer&gt;{
34 33 public List<Module> findByCurrentUser(){
35 34 return moduleService.findByCurrentUser();
36 35 }
  36 +
  37 + @RequestMapping(value = "/all_distinct")
  38 + public List<Module> findAll_distinct(){
  39 + return moduleService.findAll_distinct();
  40 + }
37 41 }
... ...
src/main/java/com/bsth/controller/sys/UserController.java
... ... @@ -242,4 +242,9 @@ public class UserController extends BaseController&lt;SysUser, Integer&gt; {
242 242 public Map<String, Object> register(SysUser u){
243 243 return sysUserService.register(u);
244 244 }
  245 +
  246 + @RequestMapping(value = "/all_distinct")
  247 + public List<SysUser> findAll_distinct(){
  248 + return sysUserService.findAll_distinct();
  249 + }
245 250 }
... ...
src/main/java/com/bsth/controller/traffic/SKBUploadLoggerController.java 0 → 100644
  1 +package com.bsth.controller.traffic;
  2 +
  3 +import com.bsth.controller.BaseController;
  4 +import com.bsth.entity.traffic.SKBUploadLogger;
  5 +import com.bsth.service.traffic.SKBUploadLoggerService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +/**
  11 + *
  12 + * @author BSTH
  13 + *
  14 + */
  15 +@RestController
  16 +@RequestMapping("skb_log")
  17 +public class SKBUploadLoggerController extends BaseController<SKBUploadLogger,Integer> {
  18 +
  19 + @Autowired
  20 + private SKBUploadLoggerService skbUploadLoggerService;
  21 +
  22 +}
... ...
src/main/java/com/bsth/data/BasicData.java
... ... @@ -2,6 +2,7 @@ package com.bsth.data;
2 2  
3 3 import com.bsth.Application;
4 4 import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.pinyin.PersionPinYinBuffer;
5 6 import com.bsth.entity.*;
6 7 import com.bsth.entity.schedule.CarConfigInfo;
7 8 import com.bsth.repository.*;
... ... @@ -39,13 +40,13 @@ public class BasicData implements CommandLineRunner {
39 40  
40 41 //车辆自编号和公司代码对照 (K: 车辆自编号 ,V:公司代码)
41 42 public static Map<String, String> nbbm2CompanyCodeMap;
  43 +
  44 + //车辆自编号和牌照号对照 (K: 车辆自编号 ,V:牌照号)
  45 + public static Map<String, String> nbbmCompanyPlateMap;
42 46  
43 47 //站点编码和名称对照,包括停车场 (K: lineCode_updown_stationCode ,V:站点名称)
44 48 public static Map<String, String> stationCode2NameMap;
45 49  
46   - //线路起终点对照(线路编码_上下行_起终点) 1024_0_B (1024上行起点)
47   - //public static Map<String, String> lineSEPointMap;
48   -
49 50 //车辆和线路对照
50 51 public static Map<String, Line> nbbm2LineMap;
51 52  
... ... @@ -64,10 +65,10 @@ public class BasicData implements CommandLineRunner {
64 65 //线路Code和shangHaiLinecode 对照
65 66 public static Map<String, String> lineCode2ShangHaiCodeMap;
66 67  
67   - //驾驶员工号 和 personnel 对象映射
  68 + /*//驾驶员工号 和 personnel 对象映射
68 69 public static Map<String, Personnel> jsyMap;
69 70 //售票员工号 和 personnel 对象映射
70   - public static Map<String, Personnel> spyMap;
  71 + public static Map<String, Personnel> spyMap;*/
71 72 //所以员工和personnerl 对象映射
72 73 public static Map<String, Personnel> perMap;
73 74 //全量员工 工号和姓名对照
... ... @@ -134,6 +135,12 @@ public class BasicData implements CommandLineRunner {
134 135 @Autowired
135 136 GeoCacheData geoCacheData;
136 137  
  138 + @Autowired
  139 + Station2ParkBuffer station2ParkBuffer;
  140 +
  141 + @Autowired
  142 + PersionPinYinBuffer persionPinYinBuffer;
  143 +
137 144  
138 145 @Override
139 146 public void run() {
... ... @@ -154,14 +161,13 @@ public class BasicData implements CommandLineRunner {
154 161 loadLineInfo();
155 162 //车辆和线路映射信息
156 163 loadNbbm2LineInfo();
157   - //站点路由信息
158   - //loadStationRouteInfo();
159 164 //人员信息
160 165 loadPersonnelInfo();
161 166 //公司信息
162 167 loadBusinessInfo();
163 168  
164 169 geoCacheData.loadData();
  170 + station2ParkBuffer.saveAll();
165 171 logger.info("加载基础数据成功!,");
166 172 } catch (Exception e) {
167 173 logger.error("加载基础数据时出现异常,", e);
... ... @@ -195,16 +201,22 @@ public class BasicData implements CommandLineRunner {
195 201 BiMap<String, String> deviceId2Nbbm = HashBiMap.create();
196 202 //车辆和公司代码对照
197 203 Map<String, String> nbbm2CompanyCode = new HashMap<>();
  204 +
  205 + //车辆自编号和拍照号对照
  206 + Map<String, String> nbbmCompanyPlate = new HashMap<>();
  207 +
198 208 Iterator<Cars> carIterator = carsRepository.findAll().iterator();
199 209 Cars car;
200 210 while (carIterator.hasNext()) {
201 211 car = carIterator.next();
202 212 deviceId2Nbbm.put(car.getEquipmentCode(), car.getInsideCode());
203 213 nbbm2CompanyCode.put(car.getInsideCode(), car.getBusinessCode());
  214 + nbbmCompanyPlate.put(car.getInsideCode(), car.getCarPlate());
204 215 }
205 216  
206 217 deviceId2NbbmMap = deviceId2Nbbm;
207 218 nbbm2CompanyCodeMap = nbbm2CompanyCode;
  219 + nbbmCompanyPlateMap =nbbmCompanyPlate;
208 220 }
209 221  
210 222 /**
... ... @@ -266,36 +278,37 @@ public class BasicData implements CommandLineRunner {
266 278 Map<String, String> code2SHcode = new HashMap<String, String>();
267 279 Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>();
268 280  
  281 + /**
  282 + * 加载运管处的站点及序号
  283 + * 上行从1开始,下行顺序续编
  284 + */
  285 + List<Map<String, String>> ygcLines = stationRouteRepository.findAllLineWithYgc();
  286 + if(ygcLines != null && ygcLines.size() > 0){
  287 + int size = ygcLines.size();
  288 + Map<String, String> tempMap ;
  289 + int num = 1;
  290 + String key;
  291 + String lineCode = "";
  292 + for (int i = 0; i < size; i ++){
  293 + tempMap = ygcLines.get(i);
  294 + if(lineCode.equals("")){
  295 + lineCode = tempMap.get("lineCode");
  296 + }else if(!lineCode.equals(tempMap.get("lineCode"))){
  297 + num = 1;
  298 + lineCode = tempMap.get("lineCode");
  299 + }
  300 + key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions"))
  301 + + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark");
  302 + tempStationName2YgcNumber.put(key,num++);
  303 + }
  304 + }
  305 +
269 306 while (iterator.hasNext()) {
270 307 line = iterator.next();
271 308 biMap.put(line.getId(), line.getLineCode());
272 309 code2name.put(line.getLineCode(), line.getName());
273 310 id2SHcode.put(line.getId(), line.getShanghaiLinecode());
274 311 code2SHcode.put(line.getLineCode(), line.getShanghaiLinecode());
275   -
276   - /**
277   - * 加载运管处的站点及序号
278   - * 上行从1开始,下行顺序续编
279   - */
280   - List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc();
281   - if(ygcLines != null && ygcLines.size() > 0){
282   - int size = ygcLines.size();
283   - Object[] tempArray ;
284   - int num = 1;
285   - String key;
286   - String lineCode = "";
287   - for (int i = 0; i < size; i ++){
288   - tempArray = ygcLines.get(i);
289   - if(lineCode.equals("")){
290   - lineCode = tempArray[0]+"";
291   - }else if(!lineCode.equals(tempArray[0]+"")){
292   - num = 1;
293   - lineCode = tempArray[0]+"";
294   - }
295   - key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2];
296   - tempStationName2YgcNumber.put(key,num++);
297   - }
298   - }
299 312 }
300 313  
301 314 lineId2CodeMap = biMap;
... ... @@ -312,7 +325,7 @@ public class BasicData implements CommandLineRunner {
312 325 public void loadPersonnelInfo() {
313 326 Iterator<Personnel> iterator = personnelRepository.findAll().iterator();
314 327  
315   - Map<String, Personnel> jsyTempMap = new HashMap<>(), spyTempMap = new HashMap<>(),perTempMap=new HashMap<>();
  328 + Map<String, Personnel> /*jsyTempMap = new HashMap<>(), spyTempMap = new HashMap<>(),*/perTempMap=new HashMap<>();
316 329 Map<String, String> allPersonMap = new HashMap<>();
317 330  
318 331 Personnel p;
... ... @@ -324,22 +337,25 @@ public class BasicData implements CommandLineRunner {
324 337 if (StringUtils.isEmpty(jobCode))
325 338 continue;
326 339  
327   - if (p.getPosts() != null) {
  340 + /*if (p.getPosts() != null) {
328 341 if (p.getPosts().equals("1"))
329 342 jsyTempMap.put(jobCode, p);
330 343 else if (p.getPosts().equals("2"))
331 344 spyTempMap.put(jobCode, p);
332   - }
  345 + }*/
333 346  
334 347 perTempMap.put(jobCode, p);
335 348  
336 349 allPersonMap.put(jobCode, p.getPersonnelName());
337 350 }
338 351  
339   - jsyMap = jsyTempMap;
340   - spyMap = spyTempMap;
  352 + //jsyMap = jsyTempMap;
  353 + //spyMap = spyTempMap;
341 354 allPerson = allPersonMap;
342 355 perMap = perTempMap;
  356 +
  357 + //人员拼音转换
  358 + persionPinYinBuffer.refresh();
343 359 }
344 360 }
345 361 }
... ...
src/main/java/com/bsth/data/LineConfigData.java
... ... @@ -64,7 +64,7 @@ public class LineConfigData implements CommandLineRunner {
64 64 */
65 65 public long applyOut(ScheduleRealInfo sch, Long timestamp) {
66 66 LineConfig config = lineConfMap.get(sch.getXlBm());
67   - int diff = sch.getXlDir()=="0"?config.getUpOutDiff():config.getDownOutDiff();
  67 + int diff = sch.getXlDir().equals("0")?config.getUpOutDiff():config.getDownOutDiff();
68 68 return timestamp - (diff * 1000);
69 69 }
70 70  
... ... @@ -76,7 +76,7 @@ public class LineConfigData implements CommandLineRunner {
76 76 */
77 77 public long applyIn(ScheduleRealInfo sch, Long timestamp){
78 78 LineConfig config = lineConfMap.get(sch.getXlBm());
79   - int diff = sch.getXlDir()=="0"?config.getUpInDiff():config.getDownInDiff();
  79 + int diff = sch.getXlDir().equals("0")?config.getUpInDiff():config.getDownInDiff();
80 80 return timestamp - (diff * 1000);
81 81 }
82 82  
... ...
src/main/java/com/bsth/data/Station2ParkBuffer.java 0 → 100644
  1 +package com.bsth.data;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  5 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import com.bsth.entity.realcontrol.StationToPark;
  7 +import com.bsth.repository.realcontrol.StationToParkRepository;
  8 +import com.bsth.util.Arith;
  9 +import com.google.common.collect.ArrayListMultimap;
  10 +import org.joda.time.format.DateTimeFormat;
  11 +import org.joda.time.format.DateTimeFormatter;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.boot.CommandLineRunner;
  16 +import org.springframework.stereotype.Component;
  17 +
  18 +import java.util.*;
  19 +
  20 +/**
  21 + * 站到场 历时、公里 数据缓存
  22 + * Created by panzhao on 2017/7/10.
  23 + */
  24 +@Component
  25 +public class Station2ParkBuffer implements CommandLineRunner {
  26 +
  27 + @Autowired
  28 + StationToParkRepository stationToParkRepository;
  29 +
  30 + private static ArrayListMultimap listMultimap;
  31 +
  32 + private static Set<StationToPark> pstBuff = new HashSet<>();
  33 +
  34 + static Logger log = LoggerFactory.getLogger(Station2ParkBuffer.class);
  35 +
  36 + @Override
  37 + public void run(String... strings) throws Exception {
  38 + listMultimap = ArrayListMultimap.create();
  39 + Iterator<StationToPark> iterator = stationToParkRepository.findAll().iterator();
  40 + StationToPark stp;
  41 + while (iterator.hasNext()) {
  42 + stp = iterator.next();
  43 + listMultimap.put(stp.getLineCode(), stp);
  44 + }
  45 + }
  46 +
  47 + public static List<StationToPark> get(String lineCode) {
  48 + return listMultimap.get(lineCode);
  49 + }
  50 +
  51 + public static StationToPark get(String lineCode, String sName, String eName) {
  52 + List<StationToPark> list = get(lineCode);
  53 + StationToPark stp = null;
  54 + for (StationToPark s : list) {
  55 + if (s.getStationName().equals(sName) && s.getParkName().equals(eName)) {
  56 + stp = s;
  57 + break;
  58 + }
  59 + }
  60 + return stp;
  61 + }
  62 +
  63 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
  64 +
  65 + public static void put(ChildTaskPlan ctask) {
  66 + try{
  67 + String type2 = ctask.getType2();
  68 + String lineCode = ctask.getSchedule().getXlBm(), sName, eName;
  69 +
  70 + if (type2.equals("2")) {
  71 + sName = ctask.getStartStationName();
  72 + eName = ctask.getEndStationName();
  73 + } else if (type2.equals("3")) {
  74 + eName = ctask.getStartStationName();
  75 + sName = ctask.getEndStationName();
  76 + } else
  77 + return;
  78 +
  79 + Float time = calcMinute(ctask);
  80 + Float mileage = ctask.getMileage();
  81 +
  82 + StationToPark stp = get(lineCode, sName, eName);
  83 + if (stp == null) {
  84 + stp = new StationToPark();
  85 + stp.setLineCode(lineCode);
  86 + stp.setStationName(sName);
  87 + stp.setParkName(eName);
  88 + listMultimap.put(lineCode, stp);
  89 + }
  90 +
  91 + if (type2.equals("2")) {
  92 + stp.setTime1(time);
  93 + stp.setMileage1(mileage);
  94 + } else {
  95 + stp.setTime2(time);
  96 + stp.setMileage2(mileage);
  97 + }
  98 +
  99 + pstBuff.add(stp);
  100 + }catch (Exception e){
  101 + log.error("", e);
  102 + }
  103 + }
  104 +
  105 + public static void put(ScheduleRealInfo sch){
  106 + try{
  107 + String type = sch.getBcType();
  108 + String lineCode = sch.getXlBm(), sName, eName;
  109 +
  110 + if (type.equals("in")) {
  111 + sName = sch.getQdzName();
  112 + eName = sch.getZdzName();
  113 + } else if (type.equals("out")) {
  114 + eName = sch.getQdzName();
  115 + sName = sch.getZdzName();
  116 + } else
  117 + return;
  118 +
  119 + long dt = sch.getZdsjT() - sch.getDfsjT();
  120 + Float time = Float.parseFloat(String.valueOf(Arith.div(Arith.div(dt, 1000), 60)));
  121 + Float mileage = Float.parseFloat(sch.getJhlc().toString());
  122 +
  123 + StationToPark stp = get(lineCode, sName, eName);
  124 + if (stp == null) {
  125 + stp = new StationToPark();
  126 + stp.setLineCode(lineCode);
  127 + stp.setStationName(sName);
  128 + stp.setParkName(eName);
  129 + listMultimap.put(lineCode, stp);
  130 + }
  131 +
  132 + if (type.equals("in")) {
  133 + stp.setTime1(time);
  134 + stp.setMileage1(mileage);
  135 + } else {
  136 + stp.setTime2(time);
  137 + stp.setMileage2(mileage);
  138 + }
  139 +
  140 + pstBuff.add(stp);
  141 + }catch (Exception e){
  142 + log.error("", e);
  143 + }
  144 + }
  145 +
  146 + public static Float calcMinute(ChildTaskPlan ctask) {
  147 + long t = 0;
  148 +
  149 + try {
  150 + long st = fmtHHmm.parseMillis(ctask.getStartDate());
  151 + long et = fmtHHmm.parseMillis(ctask.getEndDate());
  152 +
  153 + t = et - st;
  154 + } catch (Exception e) {
  155 + e.printStackTrace();
  156 + }
  157 + return Float.parseFloat(String.valueOf(Arith.div(Arith.div(t, 1000), 60)));
  158 + }
  159 +
  160 + public void saveAll(){
  161 + if(pstBuff.size()==0)
  162 + return;
  163 + Set<StationToPark> pstBuffCopy = pstBuff;
  164 + pstBuff = new HashSet<>();
  165 + //持久化到数据库
  166 + stationToParkRepository.save(pstBuffCopy);
  167 + }
  168 +
  169 + public Map<String, Object> delete(String lineCode, Integer id) {
  170 + Map<String, Object> rs = new HashMap<>();
  171 + try {
  172 + List<StationToPark> list = listMultimap.get(lineCode);
  173 +
  174 + StationToPark stp = null;
  175 + for(StationToPark temp : list){
  176 + if(temp.getId().equals(id)){
  177 + stp=temp;
  178 + break;
  179 + }
  180 + }
  181 +
  182 + if(stp != null){
  183 + listMultimap.remove(lineCode, stp);
  184 + stationToParkRepository.delete(id);
  185 + rs.put("status", ResponseCode.SUCCESS);
  186 + }
  187 + else{
  188 + rs.put("status", ResponseCode.SUCCESS);
  189 + rs.put("msg", "操作失败,可能数据已经被删除!");
  190 + }
  191 +
  192 + }catch (Exception e){
  193 + rs.put("status", ResponseCode.ERROR);
  194 + rs.put("msg", e.getMessage());
  195 + log.error("", e);
  196 + }
  197 + return rs;
  198 + }
  199 +}
... ...
src/main/java/com/bsth/data/ThreadMonotor.java 0 → 100644
  1 +package com.bsth.data;
  2 +
  3 +import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
  4 +import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
  5 +import com.bsth.data.msg_queue.DirectivePushQueue;
  6 +import com.bsth.data.msg_queue.WebSocketPushQueue;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +/**
  12 + * Created by panzhao on 2017/5/11.
  13 + */
  14 +@Component
  15 +public class ThreadMonotor extends Thread{
  16 +
  17 + Logger log = LoggerFactory.getLogger(this.getClass());
  18 +
  19 + @Override
  20 + public void run() {
  21 +
  22 + //线调GPS分析主线程
  23 + if(GpsRealAnalyse.isBlock()){
  24 + log.warn("GpsRealAnalyse isBlock true !!!!");
  25 + GpsRealAnalyse.shutdown();
  26 + }
  27 +
  28 + if(GpsRealAnalyse.isIdle()){
  29 + //切换到备用的网关实时GPS对照数据
  30 + GpsDataLoaderThread.setFlag(-1);
  31 + }
  32 +
  33 + //webSocket 消息推送队列
  34 + if(WebSocketPushQueue.isIdle()){
  35 + log.warn("WebSocketPushQueue isIdle true !!!!");
  36 + WebSocketPushQueue.start();
  37 + }
  38 +
  39 + //网关指令推送队列(系统自动发送的)
  40 + if(DirectivePushQueue.isIdle()){
  41 + log.warn("DirectivePushQueue isIdle true !!!!");
  42 + DirectivePushQueue.start();
  43 + }
  44 + }
  45 +}
0 46 \ No newline at end of file
... ...
src/main/java/com/bsth/data/arrival/AnalyseData.java deleted 100644 → 0
1   -package com.bsth.data.arrival;
2   -
3   -import org.slf4j.Logger;
4   -import org.slf4j.LoggerFactory;
5   -import org.springframework.stereotype.Component;
6   -
7   -import java.util.ArrayList;
8   -import java.util.Collections;
9   -import java.util.List;
10   -import java.util.Set;
11   -
12   -/**
13   - *
14   - * @ClassName: AnalyseArrivalData
15   - * @Description: TODO(分析一下进出站场数据)
16   - * @author PanZhao
17   - * @date 2016年8月24日 上午11:09:37
18   - *
19   - */
20   -@Component
21   -public class AnalyseData {
22   -
23   - Logger logger = LoggerFactory.getLogger(AnalyseData.class);
24   -
25   - public void analyse(Set<String> cars){
26   - try{
27   - List<ArrivalEntity> list, clearList;
28   - for(String car : cars){
29   - list = ArrivalData_GPS.findByNbbm(car);
30   - analyse(list);
31   -
32   - //清理掉无效的点
33   - clearList = new ArrayList<>();
34   - for(ArrivalEntity arr : list){
35   - if(!arr.isEnable())
36   - clearList.add(arr);
37   - }
38   - list.removeAll(clearList);
39   - }
40   - }catch(Exception e){
41   - logger.error("", e);
42   - }
43   - }
44   -
45   - private final static int SHIFT_TIME = 1000 * 60 * 5,
46   - SCH_TIME = 1000 * 60 * 10;
47   -
48   - static ArrivalComparator comp = new ArrivalComparator();
49   -
50   - public void analyse(List<ArrivalEntity> list){
51   - if(list.size() <= 1)
52   - return;
53   -
54   - //排序
55   - Collections.sort(list, comp);
56   - ArrivalEntity prve = list.get(0)
57   - ,curr;
58   - for(int i = 1; i < list.size(); i ++){
59   - curr = list.get(i);
60   - //如果第一个点无效
61   - if(!effective(prve)){
62   - prve.setEnable(false);
63   - prve = curr;
64   - continue;
65   - }
66   - //如果第二个点无效
67   - else if(!effective(curr)){
68   - curr.setEnable(false);
69   - continue;
70   - }
71   - else if(curr.getTs() - prve.getTs() < SCH_TIME){
72   - if(prve.getUpDown() == curr.getUpDown()){
73   - //信号漂移,出站无效
74   - if(curr.getStopNo().equals(prve.getStopNo())
75   - && prve.getInOut() == 1 && curr.getInOut() == 0
76   - && curr.getTs() - prve.getTs() < SHIFT_TIME){
77   - prve.setEnable(false);
78   - }
79   -// else if(curr.getInOut()){
80   -// //curr.getTs() - prve.getTs() < 30000
81   -// }
82   - }
83   - else{
84   - //上下行的同名站,新走向的第一个出站信号开始有效
85   - if(prve.getStopName().equals(curr.getStopName())){
86   - if(curr.getInOut() == 0)
87   - curr.setEnable(false);
88   - else
89   - prve = curr;
90   - }
91   - }
92   - }
93   - else
94   - prve = curr;
95   - }
96   - }
97   -
98   - private boolean effective(ArrivalEntity arr){
99   - /*//停车场
100   - if(BasicData.parkCodeList.contains(arr.getStopNo())){
101   - arr.setTcc(true);
102   - return true;
103   - }
104   -
105   - Integer upDown = BasicData.lineStationUpDownMap.get(arr.getLineCode() + "_" + arr.getStopNo());
106   -
107   - return arr.getUpDown() == upDown || BasicData.parkCodeList.contains(arr.getStopNo());*/
108   - return false;
109   - }
110   -}
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java deleted 100644 → 0
1   -package com.bsth.data.arrival;
2   -
3   -import com.bsth.data.schedule.DayOfSchedule;
4   -import com.google.common.collect.ArrayListMultimap;
5   -import com.google.common.collect.ListMultimap;
6   -import org.slf4j.Logger;
7   -import org.slf4j.LoggerFactory;
8   -import org.springframework.beans.factory.annotation.Autowired;
9   -import org.springframework.boot.CommandLineRunner;
10   -import org.springframework.stereotype.Component;
11   -
12   -import java.util.*;
13   -
14   -/**
15   - *
16   - * @ClassName: ArrivalData_GPS
17   - * @Description: TODO(GPS到离站数据)
18   - * @author PanZhao
19   - * @date 2016年8月18日 下午10:05:27
20   - *
21   - */
22   -@Component
23   -public class ArrivalData_GPS implements CommandLineRunner{
24   -
25   - // 起终点站进出数据 K:车辆编码
26   - private static ListMultimap<String, ArrivalEntity> startAndEndMaps;
27   -
28   - private static Map<String, Integer> carIndexMap;
29   -
30   - static{
31   - startAndEndMaps = ArrayListMultimap.create();
32   -
33   - carIndexMap = new HashMap<>();
34   - }
35   -
36   - @Autowired
37   - DataLoaderThread dataLoaderThread;
38   -
39   - static Logger logger = LoggerFactory.getLogger(ArrivalData_GPS.class);
40   -
41   - @Override
42   - public void run(String... arg0) throws Exception {
43   - logger.info("ArrivalData_GPS,30,06");
44   - //Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 40, 6, TimeUnit.SECONDS);
45   - }
46   -
47   - @Component
48   - public static class DataLoaderThread extends Thread {
49   -
50   - @Autowired
51   - DataLoader dataLoader;
52   -
53   - @Autowired
54   - DayOfSchedule dayOfSchedule;
55   -
56   - @Autowired
57   - AnalyseData analyseData;
58   -
59   - @Override
60   - public void run() {
61   - /*try{
62   - logger.info("开始加载到离站数据, " + System.currentTimeMillis());
63   - List<ArrivalEntity> arrSets = dataLoader.load();
64   - if(null == arrSets || arrSets.size() == 0)
65   - return;
66   -
67   - //有起终点进出的车辆
68   - Set<String> carSet = new TreeSet<>();
69   - //按车辆起终点站过滤数据
70   - String nbbm;
71   - Set<String> seList;
72   - for(ArrivalEntity arr : arrSets){
73   - nbbm = arr.getNbbm();
74   -
75   - seList = dayOfSchedule.getSEStationList(nbbm);
76   - if(seList.contains(arr.getStopNo())){
77   - startAndEndMaps.put(nbbm, arr);
78   - carSet.add(nbbm);
79   - }
80   - }
81   - //从专业的角度分析一下数据
82   - analyseData.analyse(carSet);
83   -
84   - //开始匹配
85   - Arrival2Schedule.start(carSet);
86   - }catch(Exception e){
87   - logger.error("", e);
88   - }*/
89   - }
90   - }
91   -
92   - /**
93   - *
94   - * @Title: clearRAMData
95   - * @Description: TODO(清理内存数据)
96   - */
97   - public void clearRAMData(String lineCode){
98   -
99   - List<ArrivalEntity> remList = new ArrayList<>();
100   -
101   - //车辆映射的进出站数据,遍历删除对应线路数据。
102   - Collection<ArrivalEntity> seList = startAndEndMaps.values();
103   - for(ArrivalEntity arr : seList){
104   - if(arr.getLineCode().equals(lineCode))
105   - remList.add(arr);
106   - }
107   -
108   - //删除数据
109   - int count = 0;
110   - for(ArrivalEntity arr : remList){
111   - startAndEndMaps.remove(arr.getNbbm(), arr);
112   - count ++;
113   - }
114   -
115   - logger.info(lineCode + " 清除到离站数据 ," + count);
116   - }
117   -
118   - public synchronized static List<ArrivalEntity> findByNbbm(String nbbm){
119   - return startAndEndMaps.get(nbbm);
120   - }
121   -
122   - public static List<ArrivalEntity> getIncrement(String nbbm){
123   - Integer mark = null;
124   - if (!carIndexMap.containsKey(nbbm))
125   - mark = 0;
126   - else
127   - mark = carIndexMap.get(nbbm);
128   -
129   - List<ArrivalEntity> all = startAndEndMaps.get(nbbm);
130   - int size = all.size();
131   - if(size == 0)
132   - return new ArrayList<>(0);
133   -
134   - List<ArrivalEntity> rs = all.subList(mark, size);
135   - carIndexMap.put(nbbm, size);
136   - return rs;
137   - }
138   -}
139 0 \ No newline at end of file
src/main/java/com/bsth/data/car_out_info/CarOutInfoHandler.java 0 → 100644
  1 +package com.bsth.data.car_out_info;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.schedule.DayOfSchedule;
  5 +import com.bsth.data.schedule.ScheduleComparator;
  6 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  7 +import com.google.common.collect.ArrayListMultimap;
  8 +import org.apache.commons.lang3.StringUtils;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  13 +import org.springframework.jdbc.core.JdbcTemplate;
  14 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
  15 +import org.springframework.stereotype.Component;
  16 +import org.springframework.transaction.TransactionDefinition;
  17 +import org.springframework.transaction.TransactionStatus;
  18 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  19 +
  20 +import java.sql.PreparedStatement;
  21 +import java.sql.SQLException;
  22 +import java.util.*;
  23 +
  24 +/**
  25 + * 发车信息表处理程序
  26 + * Created by panzhao on 2017/5/5.
  27 + */
  28 +@Component
  29 +public class CarOutInfoHandler {
  30 +
  31 + @Autowired
  32 + DayOfSchedule dayOfSchedule;
  33 +
  34 + //班次类型对照表
  35 + static Map<String, String> bcTypeMap;
  36 +
  37 + static{
  38 + bcTypeMap = new HashMap<>();
  39 + bcTypeMap.put("normal", "正常班次");
  40 + bcTypeMap.put("region", "区间");
  41 + bcTypeMap.put("venting", "直放");
  42 + bcTypeMap.put("major", "放站");
  43 + bcTypeMap.put("ldks", "两点间空驶");
  44 + }
  45 +
  46 + private static ScheduleComparator.DFSJ schDFSJComparator = new ScheduleComparator.DFSJ();
  47 +
  48 + @Autowired
  49 + JdbcTemplate jdbcTemplate;
  50 +
  51 + Logger logger = LoggerFactory.getLogger(this.getClass());
  52 +
  53 + /**
  54 + * 全量更新发车信息表
  55 + */
  56 + public void updateAll() {
  57 + Set<String> ks = BasicData.lineCode2NameMap.keySet();
  58 + for (String lineCode : ks) {
  59 + update(lineCode);
  60 + }
  61 + }
  62 +
  63 + public void update(String lineCode) {
  64 + try {
  65 + ArrayListMultimap<String, ScheduleRealInfo> lpScheduleMap = dayOfSchedule.getLpScheduleMap();
  66 + List<ScheduleRealInfo> list = new ArrayList<>();
  67 +
  68 + Set<String> ks = lpScheduleMap.keySet();
  69 + String prefix = lineCode + "_";
  70 + for (String k : ks) {
  71 + if (k.startsWith(prefix)) {
  72 + list.addAll(lpScheduleMap.get(k));
  73 + }
  74 + }
  75 +
  76 + update(list);
  77 + } catch (Exception e) {
  78 + logger.error("", e);
  79 + }
  80 + }
  81 +
  82 + public void update(List<ScheduleRealInfo> list) {
  83 + if (list.size() == 0)
  84 + return;
  85 + String lineCode = list.get(0).getXlBm();
  86 + //按上下行分组
  87 + List<ScheduleRealInfo> ups = new ArrayList<>(), downs = new ArrayList<>();
  88 + for (ScheduleRealInfo sch : list) {
  89 + if (sch.getXlDir().equals("0"))
  90 + ups.add(sch);
  91 + else
  92 + downs.add(sch);
  93 + }
  94 +
  95 + ScheduleRealInfo[] upArray = nexts(ups),
  96 + downArray = nexts(downs);
  97 +
  98 + final List<ScheduleRealInfo> pstArray = mergeArray(upArray, downArray);
  99 + //编程式事务
  100 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  101 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  102 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  103 + TransactionStatus status = tran.getTransaction(def);
  104 +
  105 + try{
  106 + //删除
  107 + jdbcTemplate.update("delete from bsth_t_clfcxxb where line_code=?", lineCode);
  108 + //重新写入
  109 + jdbcTemplate.batchUpdate("insert into bsth_t_clfcxxb(rq, line_code, line_name, lp_name, lp_sn, dfsj, nbbm, cph, bc_type, end_station_name, updown, jGh, jName, remarks, sn)" +
  110 + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() {
  111 + @Override
  112 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  113 + ScheduleRealInfo sch = pstArray.get(i);
  114 + ps.setString(1, sch.getScheduleDateStr());
  115 + ps.setString(2, sch.getXlBm());
  116 + ps.setString(3, sch.getXlName());
  117 + ps.setString(4, /*sch.getLpName()*/"0");
  118 + ps.setInt(5, sch.getFcno()==null?-1:sch.getFcno());
  119 + ps.setString(6, sch.getDfsj().replace(":", ""));
  120 + ps.setString(7, sch.getClZbh().replace("-", ""));
  121 + ps.setString(8, BasicData.nbbmCompanyPlateMap.get(sch.getClZbh()));
  122 + ps.setString(9, bcTypeMap.containsKey(sch.getBcType()) ? bcTypeMap.get(sch.getBcType()) : sch.getBcType());
  123 + ps.setString(10, sch.getZdzName());
  124 + ps.setInt(11, Integer.parseInt(sch.getXlDir()));
  125 + ps.setString(12, sch.getjGh());
  126 + ps.setString(13, sch.getjName());
  127 + ps.setString(14, sch.getRemarks());
  128 + ps.setInt(15, sch.getFcpSn());
  129 + }
  130 +
  131 + @Override
  132 + public int getBatchSize() {
  133 + return pstArray.size();
  134 + }
  135 + });
  136 +
  137 + tran.commit(status);
  138 + }catch (Exception e){
  139 + tran.rollback(status);
  140 + }
  141 + }
  142 +
  143 + private List<ScheduleRealInfo> mergeArray(ScheduleRealInfo[] upArray, ScheduleRealInfo[] downArray) {
  144 + List<ScheduleRealInfo> list = new ArrayList<>();
  145 + for (int i = 0; i < upArray.length; i++) {
  146 + if (upArray[i] != null) {
  147 + upArray[i].setFcpSn(i + 1);
  148 + list.add(upArray[i]);
  149 + }
  150 + }
  151 + for (int i = 0; i < downArray.length; i++) {
  152 + if (downArray[i] != null) {
  153 + downArray[i].setFcpSn(i + 1);
  154 + list.add(downArray[i]);
  155 + }
  156 + }
  157 + return list;
  158 + }
  159 +
  160 + /**
  161 + * 接下来要执行的3个班次
  162 + *
  163 + * @param list
  164 + * @return
  165 + */
  166 + private ScheduleRealInfo[] nexts(List<ScheduleRealInfo> list) {
  167 + ScheduleRealInfo[] array = new ScheduleRealInfo[3];
  168 + Collections.sort(list, schDFSJComparator);
  169 +
  170 + int count = 0, threshold = 1000 * 60 * 60;
  171 + long t = System.currentTimeMillis();
  172 + for (ScheduleRealInfo sch : list) {
  173 + if (count == 3)
  174 + break;
  175 +
  176 + //烂班
  177 + if (sch.isDestroy())
  178 + continue;
  179 +
  180 + //进场、出场、2点间空驶
  181 + if (sch.getBcType().equals("in")
  182 + || sch.getBcType().equals("out")
  183 + || sch.getBcType().equals("ldks"))
  184 + continue;
  185 +
  186 + //有实发实达时间的
  187 + if (StringUtils.isNotEmpty(sch.getFcsjActual())
  188 + || StringUtils.isNotEmpty(sch.getZdsjActual()))
  189 + continue;
  190 +
  191 + if (t - sch.getDfsjT() > threshold)
  192 + continue;
  193 +
  194 + array[count] = sch;
  195 + count++;
  196 + }
  197 + return array;
  198 + }
  199 +}
... ...
src/main/java/com/bsth/data/car_out_info/UpdateDBThread.java 0 → 100644
  1 +package com.bsth.data.car_out_info;
  2 +
  3 +import org.springframework.beans.factory.annotation.Autowired;
  4 +import org.springframework.stereotype.Component;
  5 +
  6 +/**
  7 + * 数据库发车信息表更新线程
  8 + * Created by panzhao on 2017/5/14.
  9 + */
  10 +@Component
  11 +public class UpdateDBThread extends Thread{
  12 +
  13 + @Autowired
  14 + CarOutInfoHandler carOutInfoHandler;
  15 +
  16 + @Override
  17 + public void run() {
  18 + carOutInfoHandler.updateAll();
  19 + }
  20 +}
... ...
src/main/java/com/bsth/data/directive/DayOfDirectives.java
... ... @@ -57,10 +57,11 @@ public class DayOfDirectives {
57 57 pstDirectives = new LinkedList<>();
58 58 }
59 59  
60   - public void put60(D60 d60) {
  60 + public void put60(D60 d60, boolean pst) {
61 61 d60Map.put(d60.getMsgId(), d60);
62 62 //等待持久化
63   - pstDirectives.add(d60);
  63 + if(pst)
  64 + pstDirectives.add(d60);
64 65 }
65 66  
66 67 public void put64(D64 d64) {
... ... @@ -165,7 +166,8 @@ public class DayOfDirectives {
165 166 if(null != d60Map.remove(d60.getMsgId()))
166 167 c60 ++;
167 168 }
168   - logger.info("清除60数据 ," + c60);
  169 + if(c60 > 0)
  170 + logger.info("清除60数据 ," + c60);
169 171  
170 172 //找到该设备的64数据
171 173 Collection<D64> d64s = d64Map.values();
... ... @@ -183,8 +185,9 @@ public class DayOfDirectives {
183 185 if(null != d64Map.remove(d64.getKey()))
184 186 c64 ++;
185 187 }
186   -
187   - logger.info("清除64数据 ," + c64);
  188 +
  189 + if(c64 > 0)
  190 + logger.info("清除64数据 ," + c64);
188 191 }
189 192  
190 193 public Collection<D60> all60(){
... ...
src/main/java/com/bsth/data/directive/DirectiveCreator.java
1 1 package com.bsth.data.directive;
2 2  
3   -import java.text.SimpleDateFormat;
4   -import java.util.Date;
5   -import java.util.HashMap;
6   -import java.util.Map;
7   -
8   -import org.slf4j.Logger;
9   -import org.slf4j.LoggerFactory;
10   -
11 3 import com.alibaba.fastjson.JSON;
12 4 import com.bsth.data.BasicData;
13 5 import com.bsth.entity.directive.D60;
14 6 import com.bsth.entity.directive.D60.D60Data;
15 7 import com.bsth.entity.directive.D64;
16 8 import com.bsth.entity.directive.D64.D64Data;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +
  12 +import java.text.SimpleDateFormat;
  13 +import java.util.Date;
  14 +import java.util.HashMap;
  15 +import java.util.Map;
17 16  
18 17 /**
19 18 *
... ... @@ -43,7 +42,7 @@ public class DirectiveCreator {
43 42 * @return Directive60 返回类型
44 43 * @throws
45 44 */
46   - public D60 createD60(String nbbm, String text, Short dispatchInstruct, int upDown, int state) {
  45 + public D60 createD60(String nbbm, String text, Short dispatchInstruct, int upDown, int state,String lineCode) {
47 46 Long timestamp = System.currentTimeMillis();
48 47  
49 48 Short company = Short.parseShort(BasicData.nbbm2CompanyCodeMap.get(nbbm));
... ... @@ -67,6 +66,7 @@ public class DirectiveCreator {
67 66 data.setCompanyCode(company);
68 67 data.setMsgId(msgId);
69 68 directive.setData(data);
  69 + directive.setLineCode(lineCode);
70 70 long serviceState;
71 71 try {
72 72 serviceState = Consts.SERVICE_STATE[upDown][state];
... ... @@ -81,7 +81,7 @@ public class DirectiveCreator {
81 81 }
82 82  
83 83  
84   - public D60 createD60_02(String nbbm, String text, int upDown, int state, Date alarmTime){
  84 + public D60 createD60_01(String nbbm, String text, int upDown, int state, Date alarmTime){
85 85 SimpleDateFormat sdfMMddHHmm = new SimpleDateFormat("MMddHHmm");
86 86  
87 87 Long timestamp = System.currentTimeMillis();
... ... @@ -102,7 +102,7 @@ public class DirectiveCreator {
102 102 directive.setMsgId(msgId);
103 103 // 构造数据
104 104 data.setDeviceId(deviceId);
105   - data.setDispatchInstruct((short) 0x02);
  105 + data.setDispatchInstruct((short) 0x01);
106 106 data.setTimestamp(timestamp);
107 107 data.setCompanyCode(company);
108 108 data.setMsgId(msgId);
... ...
src/main/java/com/bsth/data/directive/DirectivesPstThread.java
1 1 package com.bsth.data.directive;
2 2  
  3 +import com.bsth.data.schedule.DayOfSchedule;
3 4 import com.bsth.entity.directive.D60;
4 5 import com.bsth.entity.directive.D64;
5 6 import com.bsth.entity.directive.Directive;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
6 8 import com.bsth.repository.directive.D60Repository;
7 9 import com.bsth.repository.directive.D64Repository;
8 10 import org.slf4j.Logger;
... ... @@ -27,8 +29,12 @@ public class DirectivesPstThread extends Thread {
27 29 @Autowired
28 30 D64Repository d64Repository;
29 31  
  32 + @Autowired
  33 + DayOfSchedule dayOfSchedule;
  34 +
30 35 @Override
31 36 public void run() {
  37 +
32 38 LinkedList<Directive> list = DayOfDirectives.pstDirectives;
33 39  
34 40 Directive directive;
... ... @@ -37,7 +43,20 @@ public class DirectivesPstThread extends Thread {
37 43 directive = list.poll();
38 44  
39 45 if (directive instanceof D60) {
40   - d60Repository.save((D60) directive);
  46 + D60 d60 = (D60) directive;
  47 + if(d60.isDispatch()){
  48 + ScheduleRealInfo sch = d60.getSch();
  49 + //如果关联的班次已经不存在了,放弃入库
  50 + if(sch.isDeleted()){
  51 + logger.warn("save 指令,发现 deleted=true 的班次,id=" + sch.getId());
  52 + continue;
  53 + }
  54 + if(dayOfSchedule.get(sch.getId()) == null){
  55 + logger.warn("班次:" + sch.getId() + "不存在了,调度指令放弃入库。");
  56 + continue;
  57 + }
  58 + }
  59 + d60Repository.save(d60);
41 60 }
42 61  
43 62 if (directive instanceof D64) {
... ...
src/main/java/com/bsth/data/directive/GatewayHttpUtils.java
1 1 package com.bsth.data.directive;
2 2  
3   -import java.io.IOException;
4   -
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.bsth.util.ConfigUtil;
5 5 import org.apache.http.client.config.RequestConfig;
6 6 import org.apache.http.client.methods.CloseableHttpResponse;
7 7 import org.apache.http.client.methods.HttpPost;
... ... @@ -12,8 +12,7 @@ import org.apache.http.util.EntityUtils;
12 12 import org.slf4j.Logger;
13 13 import org.slf4j.LoggerFactory;
14 14  
15   -import com.alibaba.fastjson.JSONObject;
16   -import com.bsth.util.ConfigUtil;
  15 +import java.io.IOException;
17 16  
18 17 /**
19 18 *
... ... @@ -42,8 +41,8 @@ public class GatewayHttpUtils {
42 41  
43 42 //超时时间
44 43 RequestConfig requestConfig = RequestConfig.custom()
45   - .setConnectTimeout(3000).setConnectionRequestTimeout(1000)
46   - .setSocketTimeout(3000).build();
  44 + .setConnectTimeout(1500).setConnectionRequestTimeout(1000)
  45 + .setSocketTimeout(1500).build();
47 46  
48 47 HttpPost post = new HttpPost(url);
49 48  
... ...
src/main/java/com/bsth/data/arrival/ArrivalComparator.java renamed to src/main/java/com/bsth/data/forecast/ArrivalComparator.java
1   -package com.bsth.data.arrival;
  1 +package com.bsth.data.forecast;
  2 +
  3 +import com.bsth.data.forecast.entity.ArrivalEntity;
2 4  
3 5 import java.util.Comparator;
4 6  
... ...
src/main/java/com/bsth/data/arrival/DataLoader.java renamed to src/main/java/com/bsth/data/forecast/ArrivalDataLoader.java
1   -package com.bsth.data.arrival;
  1 +package com.bsth.data.forecast;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.LineConfigData;
  5 +import com.bsth.data.forecast.entity.ArrivalEntity;
  6 +import com.bsth.entity.realcontrol.LineConfig;
  7 +import com.bsth.util.db.DBUtils_MS;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Component;
2 12  
3 13 import java.sql.Connection;
4 14 import java.sql.PreparedStatement;
... ... @@ -9,16 +19,6 @@ import java.util.Calendar;
9 19 import java.util.Collection;
10 20 import java.util.List;
11 21  
12   -import org.slf4j.Logger;
13   -import org.slf4j.LoggerFactory;
14   -import org.springframework.beans.factory.annotation.Autowired;
15   -import org.springframework.stereotype.Component;
16   -
17   -import com.bsth.data.BasicData;
18   -import com.bsth.data.LineConfigData;
19   -import com.bsth.entity.realcontrol.LineConfig;
20   -import com.bsth.util.db.DBUtils_MS;
21   -
22 22 /**
23 23 *
24 24 * @ClassName: DataLoader
... ... @@ -28,7 +28,7 @@ import com.bsth.util.db.DBUtils_MS;
28 28 *
29 29 */
30 30 @Component
31   -public class DataLoader {
  31 +public class ArrivalDataLoader {
32 32  
33 33 private static Long prveLoadTime;
34 34  
... ...
src/main/java/com/bsth/data/forecast/ForecastRealServer.java
... ... @@ -47,7 +47,7 @@ public class ForecastRealServer implements CommandLineRunner {
47 47  
48 48 //车辆 ——> 预测终点时间
49 49 //static Map<String, Float> forecastMap = new HashMap<>();
50   - //线路_上下行 ——> 封装耗时数据的路由链
  50 + //线路_上下行 ——> 耗时数据的路由链
51 51 public static ArrayListMultimap<String, SimpleRoute> lineSampleMap;
52 52 //车辆 ——> 预测结果
53 53 public static Map<String, ForecastResult> forecastMap;
... ...
src/main/java/com/bsth/data/arrival/ArrivalEntity.java renamed to src/main/java/com/bsth/data/forecast/entity/ArrivalEntity.java
1   -package com.bsth.data.arrival;
  1 +package com.bsth.data.forecast.entity;
  2 +
  3 +import com.bsth.data.BasicData;
2 4  
3 5 import java.text.SimpleDateFormat;
4 6 import java.util.Date;
5 7  
6   -import com.bsth.data.BasicData;
7   -
8 8 /**
9 9 *
10 10 * @ClassName: ArrivalEntity
... ...
src/main/java/com/bsth/data/gpsdata/GpsEntity.java
... ... @@ -11,10 +11,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
11 11 * @date 2016年5月11日 下午4:32:07
12 12 *
13 13 */
14   -public class GpsEntity {
  14 +public class GpsEntity implements Cloneable{
15 15  
16 16 /** 公司代码 */
17   - private Integer companyCode;
  17 + private Short companyCode;
18 18  
19 19 /** 线路编码 */
20 20 private String lineId;
... ... @@ -40,30 +40,30 @@ public class GpsEntity {
40 40 /** 纬度 */
41 41 private Float lat;
42 42  
43   - /** 发送时间戳 */
  43 + /** GPS发送时间戳 */
44 44 private Long timestamp;
45 45  
  46 + /** 网关收到时间 */
  47 + private Long serverTimestamp;
  48 +
46 49 /** 速度 */
47 50 private Float speed;
48 51  
49 52 /** 方向(角度) */
50   - private Float direction;
  53 + private float direction;
51 54  
52 55 /** 营运状态( 0 营运 ,1 非营运, -1 无效) */
53 56 private Integer state;
54 57  
55 58 /** 上下行(0 上行 , 1 下行 , -1 无效) */
56   - private Integer upDown;
  59 + private Byte upDown;
57 60  
58 61 /** 车辆内部编码 */
59 62 private String nbbm;
60 63  
61 64 /** 预计到达终点时间 */
62 65 private Float expectStopTime;
63   -
64   - /** 设备是否在线
65   - private boolean online;
66   - */
  66 +
67 67 /** 当前执行班次ID */
68 68 private Long schId;
69 69  
... ... @@ -91,12 +91,19 @@ public class GpsEntity {
91 91 /** gps是否有效 设备端发送的状态 */
92 92 private int valid;
93 93  
94   - public Integer getCompanyCode() {
95   - return companyCode;
96   - }
  94 + /**
  95 + * 数据来源
  96 + * 1:网关
  97 + * 0:转发
  98 + */
  99 + private int source = -1;
97 100  
98   - public void setCompanyCode(Integer companyCode) {
99   - this.companyCode = companyCode;
  101 + public Object clone() {
  102 + try {
  103 + return super.clone();
  104 + } catch (CloneNotSupportedException e) {
  105 + return null;
  106 + }
100 107 }
101 108  
102 109 public String getDeviceId() {
... ... @@ -147,21 +154,6 @@ public class GpsEntity {
147 154 this.timestamp = timestamp;
148 155 }
149 156  
150   - public Float getSpeed() {
151   - return speed;
152   - }
153   -
154   - public void setSpeed(Float speed) {
155   - this.speed = speed;
156   - }
157   -
158   - public Float getDirection() {
159   - return direction;
160   - }
161   -
162   - public void setDirection(Float direction) {
163   - this.direction = direction;
164   - }
165 157  
166 158 public Integer getState() {
167 159 return state;
... ... @@ -171,14 +163,6 @@ public class GpsEntity {
171 163 this.state = state;
172 164 }
173 165  
174   - public Integer getUpDown() {
175   - return upDown;
176   - }
177   -
178   - public void setUpDown(Integer upDown) {
179   - this.upDown = upDown;
180   - }
181   -
182 166 public String getNbbm() {
183 167 return nbbm;
184 168 }
... ... @@ -291,4 +275,87 @@ public class GpsEntity {
291 275 public void setValid(int valid) {
292 276 this.valid = valid;
293 277 }
  278 +
  279 +
  280 +
  281 + public short getCompanyCode() {
  282 + return companyCode;
  283 + }
  284 +
  285 + public void setCompanyCode(short companyCode) {
  286 + this.companyCode = companyCode;
  287 + }
  288 +
  289 + public Byte getUpDown() {
  290 + return upDown;
  291 + }
  292 +
  293 + public void setUpDown(Byte upDown) {
  294 + this.upDown = upDown;
  295 + }
  296 +
  297 +
  298 + public float getDirection() {
  299 + return direction;
  300 + }
  301 +
  302 + public void setDirection(float direction) {
  303 + this.direction = direction;
  304 + }
  305 +
  306 + public Float getSpeed() {
  307 + return speed;
  308 + }
  309 +
  310 + public void setSpeed(Float speed) {
  311 + this.speed = speed;
  312 + }
  313 +
  314 + public int getSource() {
  315 + return source;
  316 + }
  317 +
  318 + public void setSource(int source) {
  319 + this.source = source;
  320 + }
  321 +
  322 + public void offline(){
  323 + this.setAbnormalStatus("offline");
  324 + }
  325 +
  326 +/* public boolean isOnline(){
  327 + if(isOffline())
  328 + return false;
  329 +
  330 + long t = System.currentTimeMillis();
  331 +
  332 + if((t - this.getServerTimestamp()) > 1000 * 60 * 2){
  333 + return false;
  334 + }
  335 +
  336 + if((this.getServerTimestamp() - t) > 1000 * 60 * 3){
  337 + return false;
  338 + }
  339 + return true;
  340 + }*/
  341 +
  342 + /**
  343 + * 是否营运
  344 + * @return
  345 + */
  346 + public boolean isService(){
  347 + return state!=null && state==0;
  348 + }
  349 +
  350 + public boolean isOffline(){
  351 + return this.getAbnormalStatus() != null && this.getAbnormalStatus().equals("offline");
  352 + }
  353 +
  354 + public Long getServerTimestamp() {
  355 + return serverTimestamp;
  356 + }
  357 +
  358 + public void setServerTimestamp(Long serverTimestamp) {
  359 + this.serverTimestamp = serverTimestamp;
  360 + }
294 361 }
... ...
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
... ... @@ -2,8 +2,6 @@ package com.bsth.data.gpsdata;
2 2  
3 3 import com.bsth.data.BasicData;
4 4 import com.bsth.data.forecast.ForecastRealServer;
5   -import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
6   -import com.bsth.data.gpsdata.thread.OfflineMonitorThread;
7 5 import com.bsth.data.schedule.DayOfSchedule;
8 6 import com.bsth.entity.realcontrol.ScheduleRealInfo;
9 7 import com.google.common.collect.TreeMultimap;
... ... @@ -11,10 +9,11 @@ import org.apache.commons.lang3.StringUtils;
11 9 import org.slf4j.Logger;
12 10 import org.slf4j.LoggerFactory;
13 11 import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.boot.CommandLineRunner;
15 12 import org.springframework.stereotype.Component;
16 13  
17 14 import java.util.*;
  15 +import java.util.concurrent.ConcurrentHashMap;
  16 +import java.util.concurrent.ConcurrentMap;
18 17  
19 18 /**
20 19 * @author PanZhao
... ... @@ -23,22 +22,16 @@ import java.util.*;
23 22 * @date 2016年8月12日 下午2:04:41
24 23 */
25 24 @Component
26   -public class GpsRealData implements CommandLineRunner {
  25 +public class GpsRealData {
27 26  
28 27 static Logger logger = LoggerFactory.getLogger(GpsRealData.class);
29 28  
30   - private static Map<String, GpsEntity> gpsMap;
  29 + private static ConcurrentMap<String, GpsEntity> gpsMap;
31 30  
32 31 //按线路分组设备号
33 32 private static TreeMultimap<String, String> lineCode2Devices;
34 33  
35 34 @Autowired
36   - GpsDataLoaderThread gpsDataLoader;
37   -
38   - @Autowired
39   - OfflineMonitorThread offlineMonitorThread;
40   -
41   - @Autowired
42 35 DayOfSchedule dayOfSchedule;
43 36  
44 37 @Autowired
... ... @@ -48,19 +41,10 @@ public class GpsRealData implements CommandLineRunner {
48 41 * 构造函数
49 42 */
50 43 public GpsRealData() {
51   - gpsMap = new HashMap<>();
  44 + gpsMap = new ConcurrentHashMap<>();
52 45 lineCode2Devices = TreeMultimap.create();
53 46 }
54 47  
55   - @Override
56   - public void run(String... arg0) throws Exception {
57   - logger.info("gpsDataLoader,20,3");
58   - //定时从网关获取GPS数据
59   - //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 3, TimeUnit.SECONDS);
60   - //定时扫描掉离线
61   - //Application.mainServices.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);
62   - }
63   -
64 48  
65 49 public void put(GpsEntity gps) {
66 50 String device = gps.getDeviceId();
... ... @@ -79,19 +63,29 @@ public class GpsRealData implements CommandLineRunner {
79 63 gps.setExpectStopTime(forecastRealServer.expectStopTime(gps.getNbbm()));
80 64 }
81 65 }
82   - } catch (Exception e) {
83   - logger.error("", e);
84   - }
85 66  
86   - //刷新对照
87   - gpsMap.put(device, gps);
88   - if (StringUtils.isNotBlank(gps.getLineId())) {
89   - //站点名称
90   - gps.setStationName(getStationName(gps));
91   - lineCode2Devices.put(gps.getLineId(), device);
  67 + //刷新对照
  68 + gpsMap.put(device, gps);
  69 + if (StringUtils.isNotBlank(gps.getLineId())) {
  70 + //站点名称
  71 + gps.setStationName(getStationName(gps));
  72 + lineCode2Devices.put(gps.getLineId(), device);
  73 +
  74 + if(old != null && !gps.getLineId().equals(old.getLineId()))
  75 + lineCode2Devices.remove(old.getLineId(), device);
  76 + }
92 77  
93   - if(old != null && !gps.getLineId().equals(old.getLineId()))
94   - lineCode2Devices.remove(old.getLineId(), device);
  78 + //车辆换设备了
  79 + String nbbm = gps.getNbbm();
  80 + if(old != null && StringUtils.isNotEmpty(nbbm) && !nbbm.equals(old.getNbbm())){
  81 + List<GpsEntity> list = findByNbbm(nbbm);
  82 + for(GpsEntity g : list){
  83 + if(!g.getDeviceId().equals(device))
  84 + gpsMap.remove(g.getDeviceId());
  85 + }
  86 + }
  87 + } catch (Exception e) {
  88 + logger.error("", e);
95 89 }
96 90 }
97 91  
... ... @@ -106,6 +100,24 @@ public class GpsRealData implements CommandLineRunner {
106 100 return gpsMap.get(deviceId);
107 101 }
108 102  
  103 + public List<GpsEntity> findByNbbm(String nbbm){
  104 + Collection<GpsEntity> arr = gpsMap.values();
  105 + List<GpsEntity> rs = new ArrayList<>();
  106 + for(GpsEntity g : arr){
  107 + if(nbbm.equals(g.getNbbm()))
  108 + rs.add(g);
  109 + }
  110 + return rs;
  111 + }
  112 +
  113 + public GpsEntity getByNbbm(String nbbm){
  114 + String device = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  115 + if(StringUtils.isNotBlank(device))
  116 + return get(device);
  117 + else
  118 + return null;
  119 + }
  120 +
109 121 /**
110 122 * @Title: get @Description: TODO(线路编码获取GPS集合) @throws
111 123 */
... ...
src/main/java/com/bsth/data/gpsdata/SignalStateData.java
... ... @@ -23,9 +23,9 @@ public class SignalStateData {
23 23 private static ArrayListMultimap<String, SignalState> listMultimap = ArrayListMultimap.create();
24 24  
25 25 public void put(SignalState state){
26   - listMultimap.put(state.getLineCode(), state);
  26 + //listMultimap.put(state.getLineCode(), state);
27 27 //推送到客户端
28   - sendUtils.sendSignalState(state);
  28 + //sendUtils.sendSignalState(state);
29 29 }
30 30  
31 31 public List<SignalState> get(String idx){
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
... ... @@ -36,6 +36,9 @@ public class GeoCacheData {
36 36 //线路路段走向
37 37 private static ArrayListMultimap<String, LineString> sectionCacheMap;
38 38  
  39 + //路段编码和名称对照
  40 + private static Map<String, String> sectionCode2Name;
  41 +
39 42 //线路站点路由
40 43 private static ArrayListMultimap<String, StationRoute> stationCacheMap;
41 44  
... ... @@ -44,6 +47,8 @@ public class GeoCacheData {
44 47  
45 48 //停车场
46 49 public static Map<String, Polygon> tccMap;
  50 + //停车场
  51 + public static Map<String, com.bsth.util.Geo.Polygon> tccMap2;
47 52  
48 53 //线路限速信息
49 54 private static Map<String, Double> speedLimitMap;
... ... @@ -78,6 +83,10 @@ public class GeoCacheData {
78 83 }
79 84 }
80 85  
  86 + public static Map<String, String> sectionCode2NameMap(){
  87 + return sectionCode2Name;
  88 + }
  89 +
81 90 public static StationRoute getRouteCode(GpsEntity gps) {
82 91 return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
83 92 }
... ... @@ -135,17 +144,18 @@ public class GeoCacheData {
135 144 }
136 145  
137 146 private void loadRoadsData() {
138   - String sql = "select r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) as GSECTION_VECTOR, r.DIRECTIONS from bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section=s.id where r.destroy=0 and GSECTION_VECTOR is not null order by line_code,directions,sectionroute_code";
  147 + //加载线路下路段空间数据
  148 + String sql = "select r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) as GSECTION_VECTOR, r.DIRECTIONS, s.CROSES_ROAD from bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section=s.id where r.destroy=0 and GSECTION_VECTOR is not null order by line_code,directions,sectionroute_code";
139 149 List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql);
140 150  
141 151 String polygonStr, key;
142 152 String[] coords;
143 153 int i, len;
144   -
145 154 ArrayListMultimap<String, LineString> sectionCacheTempMap = ArrayListMultimap.create();
146 155 Coordinate[] cds;
147 156 String[] temps1, temps2;
148 157 for (Map<String, Object> tMap : secList) {
  158 + //空间数据映射
149 159 polygonStr = tMap.get("GSECTION_VECTOR").toString();
150 160 key = tMap.get("LINE_CODE") + "_" + tMap.get("DIRECTIONS");
151 161  
... ... @@ -166,6 +176,24 @@ public class GeoCacheData {
166 176  
167 177 if(sectionCacheTempMap.size() > 0)
168 178 sectionCacheMap = sectionCacheTempMap;
  179 +
  180 + Map<String, String> sectionCode2NameTemp = new HashMap<>();
  181 +
  182 + //加载全量路段编码和名称对照
  183 + sql = "select SECTION_CODE,SECTION_NAME,CROSES_ROAD from bsth_c_section";
  184 + secList = jdbcTemplate.queryForList(sql);
  185 + String name = null, code;
  186 + for (Map<String, Object> tMap : secList) {
  187 + if(tMap.get("CROSES_ROAD") != null && StringUtils.isNotEmpty(tMap.get("CROSES_ROAD").toString()))
  188 + name = tMap.get("CROSES_ROAD").toString();
  189 + else if(tMap.get("SECTION_NAME") != null && StringUtils.isNotEmpty(tMap.get("SECTION_NAME").toString()))
  190 + name = tMap.get("SECTION_NAME").toString();
  191 +
  192 + code = tMap.get("SECTION_CODE").toString();
  193 + sectionCode2NameTemp.put(code, name);
  194 + }
  195 + if(sectionCode2NameTemp.size() > 0)
  196 + sectionCode2Name = sectionCode2NameTemp;
169 197 }
170 198  
171 199 private void loadTccMapData(){
... ... @@ -185,8 +213,31 @@ public class GeoCacheData {
185 213 logger.error("停车场:" + tMap.get("PARK_CODE"), e);
186 214 }
187 215 }
188   - if (tccTempMap.size() > 0)
  216 + if (tccTempMap.size() > 0){
189 217 tccMap = tccTempMap;
  218 + tccMap2 = convertPolygonMap(tccMap);
  219 + }
  220 + }
  221 +
  222 + private Map<String, com.bsth.util.Geo.Polygon> convertPolygonMap(Map<String, Polygon> tccMap) {
  223 + Map<String, com.bsth.util.Geo.Polygon> rsMap = new HashMap<>();
  224 + Set<String> ks = tccMap.keySet();
  225 + for(String k : ks){
  226 + rsMap.put(k, convertPolygon(tccMap.get(k)));
  227 + }
  228 + return rsMap;
  229 + }
  230 +
  231 + public static com.bsth.util.Geo.Polygon convertPolygon(Polygon polygon) {
  232 + List<com.bsth.util.Geo.Point> ps = new ArrayList<>();
  233 + com.bsth.util.Geo.Point p;
  234 +
  235 + Coordinate[] cs = polygon.getCoordinates();
  236 + for(int i = 0; i < cs.length;i ++){
  237 + p = new com.bsth.util.Geo.Point(cs[i].y, cs[i].x);
  238 + ps.add(p);
  239 + }
  240 + return new com.bsth.util.Geo.Polygon(ps);
190 241 }
191 242  
192 243 private void loadStationRoutesData(){
... ... @@ -285,7 +336,7 @@ public class GeoCacheData {
285 336 * @param stationCode
286 337 * @return
287 338 */
288   - public static boolean isEndStation(String lineId, Integer upDown, String stationCode) {
  339 + public static boolean isEndStation(String lineId, Byte upDown, String stationCode) {
289 340 StationRoute station = routeCodeMap.get(lineId + "_" + upDown + "_" + stationCode);
290 341 return station != null && station.getMark().equals("E");
291 342 }
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.java
... ... @@ -4,12 +4,14 @@ import com.bsth.data.gpsdata.GpsEntity;
4 4 import com.bsth.data.gpsdata.GpsRealData;
5 5 import com.bsth.data.gpsdata.arrival.handlers.*;
6 6 import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  7 +import com.bsth.data.gpsdata.recovery.GpsDataRecovery;
  8 +import com.google.common.collect.ArrayListMultimap;
7 9 import org.slf4j.Logger;
8 10 import org.slf4j.LoggerFactory;
9 11 import org.springframework.beans.factory.annotation.Autowired;
10 12 import org.springframework.stereotype.Component;
11 13  
12   -import java.util.List;
  14 +import java.util.*;
13 15 import java.util.concurrent.CountDownLatch;
14 16 import java.util.concurrent.ExecutorService;
15 17 import java.util.concurrent.Executors;
... ... @@ -21,7 +23,7 @@ import java.util.concurrent.Executors;
21 23 @Component
22 24 public class GpsRealAnalyse {
23 25  
24   - Logger logger = LoggerFactory.getLogger(this.getClass());
  26 + static Logger logger = LoggerFactory.getLogger(GpsRealAnalyse.class);
25 27  
26 28 @Autowired
27 29 OfflineSignalHandle offlineSignalHandle;
... ... @@ -39,34 +41,73 @@ public class GpsRealAnalyse {
39 41 @Autowired
40 42 GpsRealData gpsRealData;
41 43  
42   - //50个线程
43   - static ExecutorService threadPool = Executors.newFixedThreadPool(50);
  44 + static ExecutorService threadPool = Executors.newFixedThreadPool(25);
44 45  
45   - public void analyse(List<GpsEntity> list) {
46   - CountDownLatch count = new CountDownLatch(list.size());
  46 + public static long st;
  47 + public static CountDownLatch count;
  48 +
  49 + public static boolean isBlock() {
  50 + return System.currentTimeMillis() - st > 1000 * 20;
  51 + }
47 52  
48   - for(GpsEntity gps : list)
49   - threadPool.execute(new SignalHandleThread(gps, count));
  53 + public static boolean isIdle(){
  54 + return System.currentTimeMillis() - st > 1000 * 60;
  55 + }
50 56  
  57 + public void analyse(List<GpsEntity> list) {
51 58 try {
  59 + if(list.size() == 0 || GpsDataRecovery.run)
  60 + return;
  61 + st = System.currentTimeMillis();
  62 +
  63 + //按线路分组gps
  64 + ArrayListMultimap multimap = ArrayListMultimap.create();
  65 + for (GpsEntity gps : list) {
  66 + multimap.put(gps.getLineId(), gps);
  67 + }
  68 +
  69 + Set<String> ks = multimap.keySet();
  70 +
  71 + logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size());
  72 + count = new CountDownLatch(ks.size());
  73 +
  74 + for (String lineCode : ks) {
  75 + threadPool.execute(new SignalHandleThread(multimap.get(lineCode), count));
  76 + }
  77 +
52 78 //等待子线程结束
53 79 count.await();
54 80  
55 81 //加入实时gps对照
56   - for(GpsEntity gps: list)
  82 + for (GpsEntity gps : list)
57 83 gpsRealData.put(gps);
58   - } catch (InterruptedException e) {
  84 +
  85 + logger.info("time , " + (System.currentTimeMillis() - st));
  86 + } catch (Exception e) {
59 87 logger.error("", e);
60 88 }
61 89 }
62 90  
  91 + public static void shutdown() {
  92 + logger.warn("GpsRealAnalyse shutdown!!");
  93 + threadPool.shutdownNow();
  94 + long len = count.getCount();
  95 + for (int i = 0; i < len; i++) {
  96 + count.countDown();
  97 + }
  98 +
  99 + threadPool = Executors.newFixedThreadPool(100);
  100 + }
  101 +
  102 + static GpsComp comp = new GpsComp();
  103 +
63 104 public class SignalHandleThread implements Runnable {
64 105  
65   - GpsEntity gps;
  106 + List<GpsEntity> list;
66 107 CountDownLatch count;
67 108  
68   - SignalHandleThread(GpsEntity gps, CountDownLatch count) {
69   - this.gps = gps;
  109 + SignalHandleThread(List<GpsEntity> gpsList, CountDownLatch count) {
  110 + this.list = gpsList;
70 111 this.count = count;
71 112 }
72 113  
... ... @@ -74,32 +115,45 @@ public class GpsRealAnalyse {
74 115 public void run() {
75 116  
76 117 try {
77   - //是否有任务
78   - boolean task;
79   - CircleQueue<GpsEntity> prevs = GeoCacheData.getGps(gps.getNbbm());
80   - //掉线处理
81   - offlineSignalHandle.handle(gps, prevs);
82   - //状态处理
83   - task = correctSignalHandle.handle(gps, prevs);
84   - //场,站内外判断
85   - stationInsideHandle.handle(gps, prevs);
86   - //异常判定(越界/超速)
87   - abnormalStateHandle.handle(gps, prevs);
88   -
89   - if(!task)
90   - return; //无任务的,到这里就结束
91   -
92   - //反向处理
93   - reverseSignalHandle.handle(gps, prevs);
94   - //进出站动作处理
95   - inOutStationSignalHandle.handle(gps, prevs);
96   - GeoCacheData.putGps(gps);
97   -
98   - } catch (Exception e) {
99   - logger.error("", e);
  118 + Collections.sort(list, comp);
  119 + for (GpsEntity gps : list) {
  120 + try {
  121 + //是否有任务
  122 + boolean task;
  123 + CircleQueue<GpsEntity> prevs = GeoCacheData.getGps(gps.getNbbm());
  124 + //掉线处理
  125 + offlineSignalHandle.handle(gps, prevs);
  126 + //状态处理
  127 + task = correctSignalHandle.handle(gps, prevs);
  128 + //场,站内外判断
  129 + stationInsideHandle.handle(gps, prevs);
  130 + //异常判定(越界/超速)
  131 + abnormalStateHandle.handle(gps, prevs);
  132 +
  133 + if (!task)
  134 + continue; //无任务的,到这里就结束
  135 +
  136 + //反向处理
  137 + reverseSignalHandle.handle(gps, prevs);
  138 + //进出站动作处理
  139 + inOutStationSignalHandle.handle(gps, prevs);
  140 + GeoCacheData.putGps(gps);
  141 + }catch (Exception e){
  142 + logger.error("", e);
  143 + }
  144 + }
100 145 } finally {
101   - count.countDown();
  146 + if (count != null)
  147 + count.countDown();
102 148 }
103 149 }
104 150 }
  151 +
  152 + public static class GpsComp implements Comparator<GpsEntity> {
  153 +
  154 + @Override
  155 + public int compare(GpsEntity g1, GpsEntity g2) {
  156 + return g1.getTimestamp().compareTo(g2.getTimestamp());
  157 + }
  158 + }
105 159 }
... ...
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java
... ... @@ -75,7 +75,7 @@ public abstract class SignalHandle {
75 75 Logger logger = LoggerFactory.getLogger(this.getClass());
76 76 private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
77 77 protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) {
78   - int updown = Integer.parseInt(sch.getXlDir());
  78 + byte updown = Byte.parseByte(sch.getXlDir());
79 79 //gps 切换走向
80 80 gps.setUpDown(updown);
81 81  
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java
... ... @@ -3,8 +3,8 @@ package com.bsth.data.gpsdata.arrival.handlers;
3 3 import com.bsth.data.gpsdata.GpsEntity;
4 4 import com.bsth.data.gpsdata.arrival.SignalHandle;
5 5 import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.gpsdata.status_manager.GpsStatusManager;
6 7 import com.bsth.data.schedule.DayOfSchedule;
7   -import com.bsth.entity.realcontrol.ChildTaskPlan;
8 8 import com.bsth.entity.realcontrol.ScheduleRealInfo;
9 9 import com.bsth.service.directive.DirectiveService;
10 10 import org.slf4j.Logger;
... ... @@ -24,30 +24,47 @@ public class CorrectSignalHandle extends SignalHandle {
24 24 @Autowired
25 25 DirectiveService directiveService;
26 26  
  27 + @Autowired
  28 + GpsStatusManager gpsStatusManager;
  29 +
27 30 Logger logger = LoggerFactory.getLogger(this.getClass());
28 31  
29 32 @Override
30 33 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
31   - Object task = dayOfSchedule.executeCurr(gps.getNbbm());
  34 + ScheduleRealInfo task = dayOfSchedule.executeCurr(gps.getNbbm());
32 35 if(task == null)
33 36 return false;
34   - ScheduleRealInfo sch;
  37 + //ScheduleRealInfo sch;
35 38  
36 39 //子任务
37   - if(task.getClass().isAssignableFrom(ChildTaskPlan.class)){
  40 + /*if(task.getClass().isAssignableFrom(ChildTaskPlan.class)){
38 41 ChildTaskPlan childTask = (ChildTaskPlan) task;
39 42 sch = childTask.getSchedule();
40 43 }
41 44 else
42   - sch = (ScheduleRealInfo) task;
  45 + sch = (ScheduleRealInfo) task;*/
43 46  
44   - int updown = Integer.parseInt(sch.getXlDir());
  47 + byte updown = Byte.parseByte(task.getXlDir());
45 48 //走向
46 49 if(gps.getUpDown() != updown){
47 50 gps.setUpDown(updown);
48   - gps.setState(0);
  51 + //gps.setState(0);
  52 + }
  53 +
  54 + //(转发的数据不管)
  55 + if(gps.getSource() != 0){
  56 + //gps=非营运 或走向不对 && 班次=非空驶 ;切换到营运状态
  57 + if((!gps.isService() || gps.getUpDown() != updown) &&
  58 + !dayOfSchedule.emptyService(task)){
  59 + gpsStatusManager.changeServiceState(gps.getNbbm(), updown, 0, "同步@系统");
  60 + }
  61 +
  62 + //需要切换线路
  63 + if(!task.getXlBm().equals(gps.getLineId())){
  64 + gpsStatusManager.changeLine(gps.getNbbm(), task.getXlBm(), "同步@系统");
  65 + }
49 66 }
50 67  
51 68 return true;
52 69 }
53   -}
  70 +}
54 71 \ No newline at end of file
... ...