Commit cbfe66b5bccea25aa5504ebe3efd786c8d3661da

Authored by 潘钊
1 parent ffe8c7f0

update....

Showing 31 changed files with 907 additions and 414 deletions

Too many changes to show.

To preserve performance only 31 of 60 files are displayed.

src/main/java/com/bsth/controller/directive/DirectiveController.java
@@ -71,6 +71,30 @@ public class DirectiveController { @@ -71,6 +71,30 @@ public class DirectiveController {
71 SysUser user = SecurityUtils.getCurrentUser(); 71 SysUser user = SecurityUtils.getCurrentUser();
72 return directiveService.lineChange(nbbm, lineId, user.getUserName()); 72 return directiveService.lineChange(nbbm, lineId, user.getUserName());
73 } 73 }
  74 +
  75 + /**
  76 + *
  77 + * @Title: lineChangeByDevice
  78 + * @Description: TODO(切换线路)
  79 + * @param @param deviceId 设备编码
  80 + * @param @param lineId 新线路编码
  81 + * @throws
  82 + */
  83 + @RequestMapping(value = "/lineChangeByDevice", method = RequestMethod.POST)
  84 + public int lineChangeByDevice(@RequestParam String deviceId, @RequestParam String lineId){
  85 + SysUser user = SecurityUtils.getCurrentUser();
  86 + return directiveService.lineChangeByDeviceId(deviceId, lineId, user.getUserName());
  87 + }
  88 +
  89 + /**
  90 + * 刷新线路文件
  91 + * @param deviceId 设备号
  92 + * @return
  93 + */
  94 + @RequestMapping(value = "/refreshLineFile", method = RequestMethod.POST)
  95 + public int refreshLineFile(@RequestParam String deviceId){
  96 + return directiveService.refreshLineFile(deviceId);
  97 + }
74 98
75 /** 99 /**
76 * 100 *
src/main/java/com/bsth/controller/gps/GpsController.java
@@ -4,10 +4,7 @@ import java.util.List; @@ -4,10 +4,7 @@ import java.util.List;
4 import java.util.Map; 4 import java.util.Map;
5 5
6 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
7 -import org.springframework.web.bind.annotation.PathVariable;  
8 -import org.springframework.web.bind.annotation.RequestMapping;  
9 -import org.springframework.web.bind.annotation.RequestParam;  
10 -import org.springframework.web.bind.annotation.RestController; 7 +import org.springframework.web.bind.annotation.*;
11 8
12 import com.bsth.data.BasicData; 9 import com.bsth.data.BasicData;
13 import com.bsth.data.gpsdata.GpsEntity; 10 import com.bsth.data.gpsdata.GpsEntity;
@@ -46,6 +43,16 @@ public class GpsController { @@ -46,6 +43,16 @@ public class GpsController {
46 return gpsRealData.get(Splitter.on(",").splitToList(lineCodes)); 43 return gpsRealData.get(Splitter.on(",").splitToList(lineCodes));
47 } 44 }
48 45
  46 + @RequestMapping(value = "/allDevices")
  47 + public Iterable<String> allDevices(){
  48 + return gpsRealData.allDevices();
  49 + }
  50 +
  51 + @RequestMapping(value = "/removeRealGps", method = RequestMethod.POST)
  52 + public Map<String, Object> removeRealGps(@RequestParam String device){
  53 + return gpsService.removeRealGps(device);
  54 + }
  55 +
49 /** 56 /**
50 * 57 *
51 * @Title: history @Description: TODO(这个方法给测试页面用) @throws 58 * @Title: history @Description: TODO(这个方法给测试页面用) @throws
src/main/java/com/bsth/controller/realcontrol/LineConfigController.java
@@ -21,13 +21,13 @@ public class LineConfigController extends BaseController&lt;LineConfig, Integer&gt;{ @@ -21,13 +21,13 @@ public class LineConfigController extends BaseController&lt;LineConfig, Integer&gt;{
21 LineConfigService lineConfigService; 21 LineConfigService lineConfigService;
22 22
23 @RequestMapping("/check") 23 @RequestMapping("/check")
24 - public Map<String, Object> check(@RequestParam Integer[] codeArray){ 24 + public Map<String, Object> check(@RequestParam String[] codeArray){
25 return lineConfigService.check(codeArray); 25 return lineConfigService.check(codeArray);
26 } 26 }
27 27
28 @RequestMapping("/init/{lineCode}") 28 @RequestMapping("/init/{lineCode}")
29 - public Integer init(@PathVariable("lineCode") Integer lineCode) throws Exception{  
30 - return lineConfigService.inti(lineCode); 29 + public Integer init(@PathVariable("lineCode") String lineCode) throws Exception{
  30 + return lineConfigService.init(lineCode);
31 } 31 }
32 32
33 @RequestMapping(value = "/editTime", method = RequestMethod.POST) 33 @RequestMapping(value = "/editTime", method = RequestMethod.POST)
src/main/java/com/bsth/controller/realcontrol/RealChartsController.java 0 → 100644
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.bsth.service.realcontrol.RealChartsService;
  4 +import com.bsth.service.realcontrol.dto.CarOutRate;
  5 +import com.bsth.service.realcontrol.dto.DeviceOnlineRate;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 线路调度统计图
  15 + * Created by panzhao on 2016/11/9.
  16 + */
  17 +@RestController
  18 +@RequestMapping("realCharts")
  19 +public class RealChartsController {
  20 +
  21 + @Autowired
  22 + RealChartsService realChartsService;
  23 +
  24 + @RequestMapping("deviceOnlineRate")
  25 + public List<DeviceOnlineRate> deviceOnlineRate(@RequestParam String idx, @RequestParam String month){
  26 + return realChartsService.deviceOnlineRate(month, idx);
  27 + }
  28 +
  29 + @RequestMapping("carOutRate")
  30 + public List<CarOutRate> carOutRate(@RequestParam String idx, @RequestParam String month){
  31 + return realChartsService.carOutRate(month, idx);
  32 + }
  33 +}
src/main/java/com/bsth/data/LineConfigData.java
@@ -77,7 +77,7 @@ public class LineConfigData implements CommandLineRunner { @@ -77,7 +77,7 @@ public class LineConfigData implements CommandLineRunner {
77 * @Title: init 77 * @Title: init
78 * @Description: TODO(初始化配置信息) 78 * @Description: TODO(初始化配置信息)
79 */ 79 */
80 - public void init(Integer lineCode) throws Exception{ 80 + public void init(String lineCode) throws Exception{
81 LineConfig conf = new LineConfig(); 81 LineConfig conf = new LineConfig();
82 //线路 82 //线路
83 Line line = lineService.findByLineCode(lineCode); 83 Line line = lineService.findByLineCode(lineCode);
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
@@ -50,8 +50,8 @@ public class ArrivalData_GPS implements CommandLineRunner{ @@ -50,8 +50,8 @@ public class ArrivalData_GPS implements CommandLineRunner{
50 50
51 @Override 51 @Override
52 public void run(String... arg0) throws Exception { 52 public void run(String... arg0) throws Exception {
53 - logger.info("ArrivalData_GPS,30,10");  
54 - //Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 40, 10, TimeUnit.SECONDS); 53 + logger.info("ArrivalData_GPS,100,10");
  54 + //Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 100, 10, TimeUnit.SECONDS);
55 } 55 }
56 56
57 @Component 57 @Component
src/main/java/com/bsth/data/directive/DayOfDirectives.java
@@ -91,9 +91,11 @@ public class DayOfDirectives { @@ -91,9 +91,11 @@ public class DayOfDirectives {
91 break; 91 break;
92 case 1: 92 case 1:
93 d60.setReply46((short) 0);// 发送成功 93 d60.setReply46((short) 0);// 发送成功
  94 + d60.setReply46Time(System.currentTimeMillis());
94 break; 95 break;
95 case 2: 96 case 2:
96 d60.setReply47((short) 0);// 驾驶员阅读 97 d60.setReply47((short) 0);// 驾驶员阅读
  98 + d60.setReply47Time(System.currentTimeMillis());
97 break; 99 break;
98 } 100 }
99 // 入库 101 // 入库
src/main/java/com/bsth/data/directive/DirectiveCreator.java
@@ -122,30 +122,33 @@ public class DirectiveCreator { @@ -122,30 +122,33 @@ public class DirectiveCreator {
122 122
123 /** 123 /**
124 * 124 *
125 - * @Title: createDirective64 125 + * @Title: createD64
126 * @Description: TODO(创建线路切换指令 64) 126 * @Description: TODO(创建线路切换指令 64)
127 * @param @param nbbm 车辆内部编码 127 * @param @param nbbm 车辆内部编码
128 * @param @param lineId 线路编码 128 * @param @param lineId 线路编码
129 * @param @param t 时间戳 129 * @param @param t 时间戳
130 * @throws 130 * @throws
131 - */ 131 +
132 public D64 createD64(String nbbm, String lineCode, long t){ 132 public D64 createD64(String nbbm, String lineCode, long t){
133 String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm); 133 String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  134 + return create64(deviceId, lineCode, t);
  135 + }*/
134 136
  137 + public D64 create64(String deviceId, String lineCode, long t){
135 D64 change = new D64(); 138 D64 change = new D64();
136 D64Data data = new D64Data(); 139 D64Data data = new D64Data();
137 data.setCityCode(cityCode); 140 data.setCityCode(cityCode);
138 data.setDeviceId(deviceId); 141 data.setDeviceId(deviceId);
139 - 142 +
140 //线路编码补满6位数 143 //线路编码补满6位数
141 String lineCodeStr = padLeft(lineCode, 6, '0'); 144 String lineCodeStr = padLeft(lineCode, 6, '0');
142 data.setLineId(lineCodeStr); 145 data.setLineId(lineCodeStr);
143 - 146 +
144 change.setDeviceId(deviceId); 147 change.setDeviceId(deviceId);
145 change.setOperCode((short) 0X64); 148 change.setOperCode((short) 0X64);
146 change.setTimestamp(t); 149 change.setTimestamp(t);
147 change.setData(data); 150 change.setData(data);
148 - 151 +
149 return change; 152 return change;
150 } 153 }
151 154
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
@@ -2,12 +2,7 @@ package com.bsth.data.gpsdata; @@ -2,12 +2,7 @@ package com.bsth.data.gpsdata;
2 2
3 import java.io.BufferedReader; 3 import java.io.BufferedReader;
4 import java.io.InputStreamReader; 4 import java.io.InputStreamReader;
5 -import java.util.ArrayList;  
6 -import java.util.Collection;  
7 -import java.util.HashMap;  
8 -import java.util.List;  
9 -import java.util.Map;  
10 -import java.util.NavigableSet; 5 +import java.util.*;
11 import java.util.concurrent.TimeUnit; 6 import java.util.concurrent.TimeUnit;
12 7
13 import org.apache.commons.lang3.StringUtils; 8 import org.apache.commons.lang3.StringUtils;
@@ -137,6 +132,10 @@ public class GpsRealData implements CommandLineRunner{ @@ -137,6 +132,10 @@ public class GpsRealData implements CommandLineRunner{
137 list.addAll(getByLine(code)); 132 list.addAll(getByLine(code));
138 return list; 133 return list;
139 } 134 }
  135 +
  136 + public Set<String> allDevices(){
  137 + return gpsMap.keySet();
  138 + }
140 139
141 public GpsEntity findByDeviceId(String deviceId) { 140 public GpsEntity findByDeviceId(String deviceId) {
142 return gpsMap.get(deviceId); 141 return gpsMap.get(deviceId);
@@ -145,7 +144,10 @@ public class GpsRealData implements CommandLineRunner{ @@ -145,7 +144,10 @@ public class GpsRealData implements CommandLineRunner{
145 public Collection<GpsEntity> all(){ 144 public Collection<GpsEntity> all(){
146 return gpsMap.values(); 145 return gpsMap.values();
147 } 146 }
148 - 147 +
  148 + public void remove(String device){
  149 + gpsMap.remove(device);
  150 + }
149 @Component 151 @Component
150 public static class GpsDataLoader extends Thread{ 152 public static class GpsDataLoader extends Thread{
151 153
src/main/java/com/bsth/data/pilot80/PilotReport.java
@@ -85,13 +85,13 @@ public class PilotReport { @@ -85,13 +85,13 @@ public class PilotReport {
85 85
86 //下发调度指令 86 //下发调度指令
87 directiveService.send60Dispatch(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统"); 87 directiveService.send60Dispatch(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统");
88 - d80.setRemarks("计划出场时间:" + outSch.getDfsj()); 88 +/* d80.setRemarks("计划出场时间:" + outSch.getDfsj());
89 //当前GPS位置 89 //当前GPS位置
90 GpsEntity gps = gpsRealData.get(d80.getDeviceId()); 90 GpsEntity gps = gpsRealData.get(d80.getDeviceId());
91 if(null != gps) 91 if(null != gps)
92 - d80.addRemarks("<br> 位置:" + coordHtmlStr(gps)); 92 + d80.addRemarks("<br> 位置:" + coordHtmlStr(gps));*/
93 93
94 - sendUtils.refreshSch(outSch); 94 + //sendUtils.refreshSch(outSch);
95 }else 95 }else
96 d80.setRemarks("没有出场计划"); 96 d80.setRemarks("没有出场计划");
97 97
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
@@ -13,6 +13,8 @@ import java.util.Map; @@ -13,6 +13,8 @@ import java.util.Map;
13 import java.util.Set; 13 import java.util.Set;
14 import java.util.concurrent.TimeUnit; 14 import java.util.concurrent.TimeUnit;
15 15
  16 +import com.bsth.data.schedule.thread.SubmitToTrafficManage;
  17 +import org.joda.time.DateTime;
16 import org.joda.time.format.DateTimeFormat; 18 import org.joda.time.format.DateTimeFormat;
17 import org.joda.time.format.DateTimeFormatter; 19 import org.joda.time.format.DateTimeFormatter;
18 import org.slf4j.Logger; 20 import org.slf4j.Logger;
@@ -115,6 +117,9 @@ public class DayOfSchedule implements CommandLineRunner { @@ -115,6 +117,9 @@ public class DayOfSchedule implements CommandLineRunner {
115 @Autowired 117 @Autowired
116 ScheduleLateThread scheduleLateThread; 118 ScheduleLateThread scheduleLateThread;
117 119
  120 + @Autowired
  121 + SubmitToTrafficManage submitToTrafficManage;
  122 +
118 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd") 123 private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd")
119 ,fmtHHmm = DateTimeFormat.forPattern("HH:mm"); 124 ,fmtHHmm = DateTimeFormat.forPattern("HH:mm");
120 125
@@ -128,6 +133,14 @@ public class DayOfSchedule implements CommandLineRunner { @@ -128,6 +133,14 @@ public class DayOfSchedule implements CommandLineRunner {
128 Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS); 133 Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS);
129 //班次误点扫描 134 //班次误点扫描
130 //Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS); 135 //Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS);
  136 +
  137 + //每天凌晨1点40提交数据到运管处
  138 + long diff = (DateUtils.getTimestamp() + 1000*60*100) - System.currentTimeMillis();
  139 + if(diff < 0)
  140 + diff+=(1000*60*60*24);
  141 +
  142 + logger.info(diff/1000/60 + "分钟之后提交到运管处");
  143 + Application.mainServices.scheduleWithFixedDelay(submitToTrafficManage, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
131 } 144 }
132 145
133 public Map<String, String> getCurrSchDate() { 146 public Map<String, String> getCurrSchDate() {
src/main/java/com/bsth/data/schedule/thread/SubmitToTrafficManage.java 0 → 100644
  1 +package com.bsth.data.schedule.thread;
  2 +
  3 +import com.bsth.service.TrafficManageService;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * 运营数据提交到运管处
  11 + * Created by panzhao on 2016/11/9.
  12 + */
  13 +@Component
  14 +public class SubmitToTrafficManage extends Thread{
  15 +
  16 + Logger logger = LoggerFactory.getLogger(this.getClass());
  17 +
  18 + @Autowired
  19 + TrafficManageService trafficManageService;
  20 +
  21 + @Override
  22 + public void run() {
  23 + logger.info("开始提交数据到运管处...");
  24 + try {
  25 + //路单
  26 + trafficManageService.setLD();
  27 + } catch (Exception e) {
  28 + logger.error("提交路单到运管处失败", e);
  29 + }
  30 + try {
  31 + //车辆里程、油耗
  32 + trafficManageService.setLCYH();
  33 + } catch (Exception e) {
  34 + logger.error("提交车辆里程、油耗到运管处失败", e);
  35 + }
  36 + try {
  37 + //线路调度日报
  38 + trafficManageService.setDDRB();
  39 + } catch (Exception e) {
  40 + logger.error("提交线路调度日报到运管处失败", e);
  41 + }
  42 + try {
  43 + //线路计划班次表
  44 + trafficManageService.setJHBC();
  45 + } catch (Exception e) {
  46 + logger.error("提交线路计划班次表到运管处失败", e);
  47 + }
  48 + logger.info("提交数据到运管处结束!");
  49 + }
  50 +}
src/main/java/com/bsth/oplog/db/DBHelper.java
@@ -43,6 +43,6 @@ public class DBHelper implements CommandLineRunner{ @@ -43,6 +43,6 @@ public class DBHelper implements CommandLineRunner{
43 43
44 @Override 44 @Override
45 public void run(String... arg0) throws Exception { 45 public void run(String... arg0) throws Exception {
46 - Application.mainServices.scheduleWithFixedDelay(fixedTimeThread, fixedMinute, fixedMinute, TimeUnit.MINUTES); 46 + //Application.mainServices.scheduleWithFixedDelay(fixedTimeThread, fixedMinute, fixedMinute, TimeUnit.MINUTES);
47 } 47 }
48 } 48 }
src/main/java/com/bsth/service/LineService.java
@@ -26,5 +26,5 @@ public interface LineService extends BaseService&lt;Line, Integer&gt; { @@ -26,5 +26,5 @@ public interface LineService extends BaseService&lt;Line, Integer&gt; {
26 */ 26 */
27 long selectMaxIdToLineCode(); 27 long selectMaxIdToLineCode();
28 28
29 - Line findByLineCode(Integer lineCode); 29 + Line findByLineCode(String lineCode);
30 } 30 }
src/main/java/com/bsth/service/directive/DirectiveService.java
@@ -55,8 +55,10 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{ @@ -55,8 +55,10 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{
55 * @throws 55 * @throws
56 */ 56 */
57 int lineChange(String nbbm, String lineId, String sender); 57 int lineChange(String nbbm, String lineId, String sender);
58 -  
59 - /** 58 +
  59 + int lineChangeByDeviceId(String deviceId, String lineCode, String sender);
  60 +
  61 + /**
60 * 62 *
61 * @Title: upDownChange 63 * @Title: upDownChange
62 * @Description: TODO(切换上下行) 64 * @Description: TODO(切换上下行)
@@ -89,4 +91,6 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{ @@ -89,4 +91,6 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{
89 int sendC0A3(DC0_A3 c0a4); 91 int sendC0A3(DC0_A3 c0a4);
90 92
91 int sendC0A5(String json); 93 int sendC0A5(String json);
  94 +
  95 + int refreshLineFile(String deviceId);
92 } 96 }
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
@@ -222,18 +222,23 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen @@ -222,18 +222,23 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
222 */ 222 */
223 @Override 223 @Override
224 public int lineChange(String nbbm, String lineCode, String sender) { 224 public int lineChange(String nbbm, String lineCode, String sender) {
  225 + return lineChangeByDeviceId(BasicData.deviceId2NbbmMap.inverse().get(nbbm), lineCode, sender);
  226 + }
  227 +
  228 +
  229 + @Override
  230 + public int lineChangeByDeviceId(String deviceId, String lineCode, String sender){
225 DirectiveCreator crt = new DirectiveCreator(); 231 DirectiveCreator crt = new DirectiveCreator();
226 -  
227 Long t = System.currentTimeMillis(); 232 Long t = System.currentTimeMillis();
228 //生成64数据包 233 //生成64数据包
229 - D64 d64 = crt.createD64(nbbm, lineCode, t);  
230 - 234 + D64 d64 = crt.create64(deviceId, lineCode, t);
  235 +
231 if(null != sender) 236 if(null != sender)
232 d64.setSender(sender); 237 d64.setSender(sender);
233 else 238 else
234 d64.setSender("系统"); 239 d64.setSender("系统");
235 240
236 - String deviceId = d64.getDeviceId(); 241 + //String deviceId = d64.getDeviceId();
237 int code = GatewayHttpUtils.postJson(JSON.toJSONString(d64)); 242 int code = GatewayHttpUtils.postJson(JSON.toJSONString(d64));
238 // 入库 243 // 入库
239 d64.setHttpCode(code); 244 d64.setHttpCode(code);
@@ -332,6 +337,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen @@ -332,6 +337,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
332 Map<String, Object> sockMap = new HashMap<>(); 337 Map<String, Object> sockMap = new HashMap<>();
333 sockMap.put("fn", "d80Confirm"); 338 sockMap.put("fn", "d80Confirm");
334 sockMap.put("id", d80.getId()); 339 sockMap.put("id", d80.getId());
  340 + sockMap.put("lineId", d80.getData().getLineId());
335 socketHandler.sendMessageToLine(d80.getData().getLineId().toString(), JSON.toJSONString(sockMap)); 341 socketHandler.sendMessageToLine(d80.getData().getLineId().toString(), JSON.toJSONString(sockMap));
336 } 342 }
337 343
@@ -463,7 +469,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen @@ -463,7 +469,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
463 469
464 Map<String, Object> rsMap = new HashMap<>(); 470 Map<String, Object> rsMap = new HashMap<>();
465 rsMap.put("list", rs); 471 rsMap.put("list", rs);
466 - rsMap.put("totalPages", count % size == 0 ? count / size : count / size + 1); 472 + rsMap.put("totalPages", count % size == 0 ? count / size -1 : count / size);
467 rsMap.put("page", page); 473 rsMap.put("page", page);
468 474
469 return rsMap; 475 return rsMap;
@@ -501,4 +507,13 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen @@ -501,4 +507,13 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
501 public int sendC0A5(String json) { 507 public int sendC0A5(String json) {
502 return GatewayHttpUtils.postJson(json); 508 return GatewayHttpUtils.postJson(json);
503 } 509 }
  510 +
  511 + @Override
  512 + public int refreshLineFile(String deviceId) {
  513 + GpsEntity gps = gpsRealDataBuffer.get(deviceId);
  514 + if(gps == null)
  515 + return -1;
  516 +
  517 + return GatewayHttpUtils.postJson(new DirectiveCreator().createDeviceRefreshData(deviceId, gps.getLineId()));
  518 + }
504 } 519 }
src/main/java/com/bsth/service/gps/GpsService.java
@@ -12,4 +12,6 @@ public interface GpsService { @@ -12,4 +12,6 @@ public interface GpsService {
12 Map<String, Object> findBuffAeraByCode(String code, String type); 12 Map<String, Object> findBuffAeraByCode(String code, String type);
13 13
14 Map<String, Object> search(Map<String, Object> map, int page, int size, String order, String direction); 14 Map<String, Object> search(Map<String, Object> map, int page, int size, String order, String direction);
  15 +
  16 + Map<String,Object> removeRealGps(String device);
15 } 17 }
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
@@ -14,6 +14,7 @@ import java.util.HashMap; @@ -14,6 +14,7 @@ import java.util.HashMap;
14 import java.util.List; 14 import java.util.List;
15 import java.util.Map; 15 import java.util.Map;
16 16
  17 +import org.apache.commons.lang3.StringUtils;
17 import org.slf4j.Logger; 18 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory; 19 import org.slf4j.LoggerFactory;
19 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,372 +33,398 @@ import com.bsth.util.TransGPS.Location; @@ -32,372 +33,398 @@ import com.bsth.util.TransGPS.Location;
32 import com.bsth.util.db.DBUtils_MS; 33 import com.bsth.util.db.DBUtils_MS;
33 34
34 @Service 35 @Service
35 -public class GpsServiceImpl implements GpsService{  
36 - /** 历史gps查询最大范围 24小时 */  
37 - final static Long GPS_RANGE = 60 * 60 * 24L;  
38 -  
39 - /** jdbc */  
40 - Connection conn = null;  
41 - PreparedStatement ps = null;  
42 - ResultSet rs = null;  
43 -  
44 - Logger logger = LoggerFactory.getLogger(this.getClass());  
45 -  
46 - @Autowired  
47 - GpsRealData gpsRealData;  
48 -  
49 - // 历史gps查询  
50 - @Override  
51 - public List<Map<String, Object>> history(String device, Long startTime, Long endTime, int directions) {  
52 - Calendar sCal = Calendar.getInstance();  
53 - sCal.setTime(new Date(startTime));  
54 -  
55 - Calendar eCal = Calendar.getInstance();  
56 - eCal.setTime(new Date(endTime));  
57 -  
58 - int dayOfYear = sCal.get(Calendar.DAY_OF_YEAR);  
59 - /* 36 +public class GpsServiceImpl implements GpsService {
  37 + /**
  38 + * 历史gps查询最大范围 24小时
  39 + */
  40 + final static Long GPS_RANGE = 60 * 60 * 24L;
  41 +
  42 + /**
  43 + * jdbc
  44 + */
  45 + Connection conn = null;
  46 + PreparedStatement ps = null;
  47 + ResultSet rs = null;
  48 +
  49 + Logger logger = LoggerFactory.getLogger(this.getClass());
  50 +
  51 + @Autowired
  52 + GpsRealData gpsRealData;
  53 +
  54 + // 历史gps查询
  55 + @Override
  56 + public List<Map<String, Object>> history(String device, Long startTime, Long endTime, int directions) {
  57 + Calendar sCal = Calendar.getInstance();
  58 + sCal.setTime(new Date(startTime));
  59 +
  60 + Calendar eCal = Calendar.getInstance();
  61 + eCal.setTime(new Date(endTime));
  62 +
  63 + int dayOfYear = sCal.get(Calendar.DAY_OF_YEAR);
  64 + /*
60 * if(dayOfYear != eCal.get(Calendar.DAY_OF_YEAR)){ 65 * if(dayOfYear != eCal.get(Calendar.DAY_OF_YEAR)){
61 * System.out.println("暂时不支持跨天查询..."); return null; } 66 * System.out.println("暂时不支持跨天查询..."); return null; }
62 */ 67 */
63 68
64 - String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO from bsth_c_gps_info where days_year=? and device_id=? and ts > ? and ts < ?";  
65 - Connection conn = null;  
66 - PreparedStatement ps = null;  
67 - ResultSet rs = null;  
68 - List<Map<String, Object>> list = new ArrayList<>();  
69 - Map<String, Object> map = null;  
70 - try {  
71 - conn = DBUtils_MS.getConnection();  
72 - ps = conn.prepareStatement(sql);  
73 - ps.setInt(1, dayOfYear);  
74 - ps.setString(2, device);  
75 - ps.setLong(3, startTime);  
76 - ps.setLong(4, endTime);  
77 -  
78 - rs = ps.executeQuery();  
79 - Float lon, lat;  
80 - Location location;  
81 - int upDown;  
82 - while (rs.next()) {  
83 - upDown = getUpOrDown(rs.getLong("SERVICE_STATE"));  
84 - if (upDown != directions)  
85 - continue;  
86 -  
87 - // to 百度坐标  
88 - lon = rs.getFloat("LON");  
89 - lat = rs.getFloat("LAT");  
90 - location = TransGPS.LocationMake(lon, lat);  
91 - location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location));  
92 -  
93 - map = new HashMap<>();  
94 - map.put("device", rs.getString("DEVICE_ID"));  
95 - map.put("lon", location.getLng());  
96 - map.put("lat", location.getLat());  
97 - map.put("ts", rs.getLong("TS"));  
98 - map.put("stopNo", rs.getString("STOP_NO"));  
99 - map.put("inout_stop", rs.getInt("INOUT_STOP"));  
100 - // 上下行  
101 - map.put("upDown", upDown);  
102 - list.add(map);  
103 - }  
104 - } catch (Exception e) {  
105 - e.printStackTrace();  
106 - } finally {  
107 - DBUtils_MS.close(rs, ps, conn);  
108 - }  
109 - return list;  
110 - }  
111 -  
112 - /**  
113 - * 王通 2016/6/29 9:23:24 获取车辆线路上下行  
114 - *  
115 - * @return -1无效 0上行 1下行  
116 - */  
117 - public static byte getUpOrDown(long serviceState) {  
118 - if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000  
119 - || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000)  
120 - return -1;  
121 - return (byte) (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);  
122 - }  
123 -  
124 - @Override  
125 - public List<Map<String, Object>> history(String[] nbbmArray, Long st, Long et) {  
126 - List<Map<String, Object>> list = new ArrayList<>();  
127 - // 超过最大查询范围,直接忽略  
128 - if (et - st > GPS_RANGE)  
129 - return list;  
130 -  
131 - // 车辆编码转换成设备号  
132 - String[] devices = new String[nbbmArray.length];  
133 - for (int i = 0; i < nbbmArray.length; i++) {  
134 - devices[i] = BasicData.deviceId2NbbmMap.inverse().get(nbbmArray[i]);  
135 - }  
136 - // day_of_year  
137 - Calendar sCal = Calendar.getInstance();  
138 - sCal.setTime(new Date(st * 1000));  
139 - int sDayOfYear = sCal.get(Calendar.DAY_OF_YEAR)/* 200 */;  
140 -  
141 - Calendar eCal = Calendar.getInstance();  
142 - eCal.setTime(new Date(et * 1000));  
143 - int eDayOfYear = eCal.get(Calendar.DAY_OF_YEAR)/* 200 */;  
144 -  
145 - Calendar weekCal = Calendar.getInstance();  
146 -  
147 - // 如果是同一天  
148 - if (sDayOfYear == eDayOfYear) {  
149 - weekCal.setTimeInMillis(st * 1000);  
150 - list = findByTs(weekCal.get(Calendar.WEEK_OF_YEAR), sDayOfYear, st, et, devices);  
151 - } else {  
152 - // 跨天  
153 - Long tempSt = 0L, tempEt = 0L;  
154 - for (int i = sDayOfYear; i <= eDayOfYear; i++) {  
155 -  
156 - if (i == sDayOfYear) {  
157 - tempSt = st;  
158 - tempEt = DateUtils.getTimesnight(sCal);  
159 - } else if (i == eDayOfYear) {  
160 - tempSt = DateUtils.getTimesmorning(sCal);  
161 - tempEt = et;  
162 - } else {  
163 - tempSt = DateUtils.getTimesmorning(sCal);  
164 - tempEt = DateUtils.getTimesnight(sCal);  
165 - }  
166 -  
167 - weekCal.setTimeInMillis(tempSt * 1000);  
168 - list.addAll(findByTs(weekCal.get(Calendar.WEEK_OF_YEAR), i, tempSt, tempEt, devices));  
169 - // 加一天  
170 - sCal.add(Calendar.DATE, 1);  
171 - }  
172 - }  
173 -  
174 - // 按时间排序  
175 - Collections.sort(list, new Comparator<Map<String, Object>>() {  
176 -  
177 - @Override  
178 - public int compare(Map<String, Object> o1, Map<String, Object> o2) {  
179 - return (int) (Long.parseLong(o1.get("ts").toString()) - Long.parseLong(o2.get("ts").toString()));  
180 - }  
181 - });  
182 - ;  
183 - return list;  
184 - }  
185 -  
186 - public List<Map<String, Object>> findByTs(int weekOfYear, int dayOfYear, Long st, Long et, String[] devices) {  
187 - List<Map<String, Object>> list = new ArrayList<>();  
188 - Map<String, Object> map = null;  
189 -  
190 - // setArray 不好用,直接拼 in 语句  
191 - String inv = "";  
192 - for (String device : devices)  
193 - inv += ("'" + device + "',");  
194 - inv = inv.substring(0, inv.length() - 1);  
195 -  
196 - // 查询到离站数据  
197 - Map<String, ArrivalEntity> arrivalMap = findArrivalByTs(weekOfYear/* 30 */, st, et, inv);  
198 -  
199 - String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO from bsth_c_gps_info where days_year=? and device_id in ("  
200 - + inv + ") and ts > ? and ts < ?";  
201 - try {  
202 - conn = DBUtils_MS.getConnection();  
203 - ps = conn.prepareStatement(sql);  
204 - ps.setInt(1, dayOfYear); 69 + String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO from bsth_c_gps_info where days_year=? and device_id=? and ts > ? and ts < ?";
  70 + Connection conn = null;
  71 + PreparedStatement ps = null;
  72 + ResultSet rs = null;
  73 + List<Map<String, Object>> list = new ArrayList<>();
  74 + Map<String, Object> map = null;
  75 + try {
  76 + conn = DBUtils_MS.getConnection();
  77 + ps = conn.prepareStatement(sql);
  78 + ps.setInt(1, dayOfYear);
  79 + ps.setString(2, device);
  80 + ps.setLong(3, startTime);
  81 + ps.setLong(4, endTime);
  82 +
  83 + rs = ps.executeQuery();
  84 + Float lon, lat;
  85 + Location location;
  86 + int upDown;
  87 + while (rs.next()) {
  88 + upDown = getUpOrDown(rs.getLong("SERVICE_STATE"));
  89 + if (upDown != directions)
  90 + continue;
  91 +
  92 + // to 百度坐标
  93 + lon = rs.getFloat("LON");
  94 + lat = rs.getFloat("LAT");
  95 + location = TransGPS.LocationMake(lon, lat);
  96 + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location));
  97 +
  98 + map = new HashMap<>();
  99 + map.put("device", rs.getString("DEVICE_ID"));
  100 + map.put("lon", location.getLng());
  101 + map.put("lat", location.getLat());
  102 + map.put("ts", rs.getLong("TS"));
  103 + map.put("stopNo", rs.getString("STOP_NO"));
  104 + map.put("inout_stop", rs.getInt("INOUT_STOP"));
  105 + // 上下行
  106 + map.put("upDown", upDown);
  107 + list.add(map);
  108 + }
  109 + } catch (Exception e) {
  110 + e.printStackTrace();
  111 + } finally {
  112 + DBUtils_MS.close(rs, ps, conn);
  113 + }
  114 + return list;
  115 + }
  116 +
  117 + /**
  118 + * 王通 2016/6/29 9:23:24 获取车辆线路上下行
  119 + *
  120 + * @return -1无效 0上行 1下行
  121 + */
  122 + public static byte getUpOrDown(long serviceState) {
  123 + if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000
  124 + || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000)
  125 + return -1;
  126 + return (byte) (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);
  127 + }
  128 +
  129 + @Override
  130 + public List<Map<String, Object>> history(String[] nbbmArray, Long st, Long et) {
  131 + List<Map<String, Object>> list = new ArrayList<>();
  132 + // 超过最大查询范围,直接忽略
  133 + if (et - st > GPS_RANGE)
  134 + return list;
  135 +
  136 + // 车辆编码转换成设备号
  137 + String[] devices = new String[nbbmArray.length];
  138 + for (int i = 0; i < nbbmArray.length; i++) {
  139 + devices[i] = BasicData.deviceId2NbbmMap.inverse().get(nbbmArray[i]);
  140 + }
  141 + // day_of_year
  142 + Calendar sCal = Calendar.getInstance();
  143 + sCal.setTime(new Date(st * 1000));
  144 + int sDayOfYear = sCal.get(Calendar.DAY_OF_YEAR)/* 200 */;
  145 +
  146 + Calendar eCal = Calendar.getInstance();
  147 + eCal.setTime(new Date(et * 1000));
  148 + int eDayOfYear = eCal.get(Calendar.DAY_OF_YEAR)/* 200 */;
  149 +
  150 + Calendar weekCal = Calendar.getInstance();
  151 +
  152 + // 如果是同一天
  153 + if (sDayOfYear == eDayOfYear) {
  154 + weekCal.setTimeInMillis(st * 1000);
  155 + list = findByTs(weekCal.get(Calendar.WEEK_OF_YEAR), sDayOfYear, st, et, devices);
  156 + } else {
  157 + // 跨天
  158 + Long tempSt = 0L, tempEt = 0L;
  159 + for (int i = sDayOfYear; i <= eDayOfYear; i++) {
  160 +
  161 + if (i == sDayOfYear) {
  162 + tempSt = st;
  163 + tempEt = DateUtils.getTimesnight(sCal);
  164 + } else if (i == eDayOfYear) {
  165 + tempSt = DateUtils.getTimesmorning(sCal);
  166 + tempEt = et;
  167 + } else {
  168 + tempSt = DateUtils.getTimesmorning(sCal);
  169 + tempEt = DateUtils.getTimesnight(sCal);
  170 + }
  171 +
  172 + weekCal.setTimeInMillis(tempSt * 1000);
  173 + list.addAll(findByTs(weekCal.get(Calendar.WEEK_OF_YEAR), i, tempSt, tempEt, devices));
  174 + // 加一天
  175 + sCal.add(Calendar.DATE, 1);
  176 + }
  177 + }
  178 +
  179 + // 按时间排序
  180 + Collections.sort(list, new Comparator<Map<String, Object>>() {
  181 +
  182 + @Override
  183 + public int compare(Map<String, Object> o1, Map<String, Object> o2) {
  184 + return (int) (Long.parseLong(o1.get("ts").toString()) - Long.parseLong(o2.get("ts").toString()));
  185 + }
  186 + });
  187 + ;
  188 + return list;
  189 + }
  190 +
  191 + public List<Map<String, Object>> findByTs(int weekOfYear, int dayOfYear, Long st, Long et, String[] devices) {
  192 + List<Map<String, Object>> list = new ArrayList<>();
  193 + Map<String, Object> map = null;
  194 +
  195 + // 直接拼 in 语句
  196 + String inv = "";
  197 + for (String device : devices)
  198 + inv += ("'" + device + "',");
  199 + inv = inv.substring(0, inv.length() - 1);
  200 +
  201 + // 查询到离站数据
  202 + Map<String, ArrivalEntity> arrivalMap = findArrivalByTs(weekOfYear/* 30 */, st, et, inv);
  203 +
  204 + String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO from bsth_c_gps_info where days_year=? and device_id in ("
  205 + + inv + ") and ts > ? and ts < ?";
  206 + try {
  207 + conn = DBUtils_MS.getConnection();
  208 + ps = conn.prepareStatement(sql);
  209 + ps.setInt(1, dayOfYear);
205 /* ps.setArray(2, conn.createArrayOf("VARCHAR", devices)); */ 210 /* ps.setArray(2, conn.createArrayOf("VARCHAR", devices)); */
206 - ps.setLong(2, st * 1000);  
207 - ps.setLong(3, et * 1000);  
208 -  
209 - rs = ps.executeQuery();  
210 - Float lon, lat;  
211 - Location bdLoc, gdLoc;  
212 - int upDown, inOutStop;  
213 - ArrivalEntity arrival;  
214 - while (rs.next()) {  
215 - upDown = getUpOrDown(rs.getLong("SERVICE_STATE"));  
216 - map = new HashMap<>();  
217 -  
218 - lon = rs.getFloat("LON");  
219 - lat = rs.getFloat("LAT");  
220 - // 高德坐标  
221 - gdLoc = TransGPS.transformFromWGSToGCJ(TransGPS.LocationMake(lon, lat));  
222 - map.put("gcj_lon", gdLoc.getLng());  
223 - map.put("gcj_lat", gdLoc.getLat());  
224 - // 百度坐标  
225 - bdLoc = TransGPS.bd_encrypt(gdLoc);  
226 - map.put("bd_lon", bdLoc.getLng());  
227 - map.put("bd_lat", bdLoc.getLat());  
228 -  
229 - map.put("deviceId", rs.getString("DEVICE_ID"));  
230 - map.put("ts", rs.getLong("TS"));  
231 - map.put("timestamp", rs.getLong("TS"));  
232 - map.put("stopNo", rs.getString("STOP_NO"));  
233 -  
234 - inOutStop = rs.getInt("INOUT_STOP");  
235 - map.put("inout_stop", inOutStop);  
236 -  
237 - arrival = arrivalMap.get(rs.getString("DEVICE_ID") + "_" + rs.getLong("TS"));  
238 - if (arrival != null) {  
239 - map.put("inout_stop_info",arrival);  
240 - map.put("inout_stop", arrival.getInOut());  
241 - }  
242 - map.put("nbbm", BasicData.deviceId2NbbmMap.get(rs.getString("DEVICE_ID")));  
243 - map.put("state", 0);  
244 - // 上下行  
245 - map.put("upDown", upDown);  
246 - list.add(map);  
247 - }  
248 - } catch (Exception e) {  
249 - logger.error("", e);  
250 - } finally {  
251 - DBUtils_MS.close(rs, ps, conn);  
252 - }  
253 - return list;  
254 - }  
255 -  
256 - public Map<String, ArrivalEntity> findArrivalByTs(int weekOfYear, Long st, Long et, String devicesInSql) {  
257 - Map<String, ArrivalEntity> map = new HashMap<>();  
258 -  
259 - String sql = "SELECT DEVICE_ID,LINE_ID,STOP_NO,TS,UP_DOWN,IN_OUT,WEEKS_YEAR,CREATE_DATE FROM bsth_c_arrival_info where weeks_year=? and device_id in ("  
260 - + devicesInSql + ") and ts > ? and ts < ?";  
261 - try {  
262 - conn = DBUtils_MS.getConnection();  
263 - ps = conn.prepareStatement(sql);  
264 - ps.setInt(1, weekOfYear);  
265 - ps.setLong(2, st * 1000);  
266 - ps.setLong(3, et * 1000);  
267 -  
268 - rs = ps.executeQuery();  
269 - ArrivalEntity arr;  
270 - int inOut;  
271 - while (rs.next()) {  
272 - arr = new ArrivalEntity(rs.getString("DEVICE_ID"), rs.getLong("TS"), rs.getString("LINE_ID"),  
273 - rs.getInt("UP_DOWN"), rs.getString("STOP_NO"), rs.getInt("IN_OUT"), rs.getLong("CREATE_DATE"),  
274 - rs.getInt("WEEKS_YEAR"), BasicData.stationCode2NameMap.get(rs.getString("STOP_NO")));  
275 -  
276 - // 设备号_时间戳_进出状态 为key  
277 - // 反转进出状态  
278 - inOut = arr.getInOut() == 0 ? 1 : 0;  
279 - map.put(arr.getDeviceId() + "_" + arr.getTs(), arr);  
280 - }  
281 - } catch (Exception e) {  
282 - logger.error("", e);  
283 - } finally {  
284 - DBUtils_MS.close(rs, ps, conn);  
285 - }  
286 - return map;  
287 - }  
288 -  
289 -  
290 - @Autowired  
291 - StationRepository stationRepository;  
292 -  
293 - @Autowired  
294 - CarParkRepository carParkRepository;  
295 -  
296 - @Override  
297 - public Map<String, Object> findBuffAeraByCode(String code, String type) {  
298 - Object[][] obj = null;  
299 - if(type.equals("station"))  
300 - obj = stationRepository.bufferAera(code);  
301 - else if(type.equals("park"))  
302 - obj = carParkRepository.bufferAera(code);  
303 -  
304 - Map<String, Object> rs = new HashMap<>();  
305 -  
306 - Object[] subObj = obj[0];  
307 - if(subObj != null && subObj.length == 6){  
308 - rs.put("polygon", subObj[0]);  
309 - rs.put("type", subObj[1]);  
310 - rs.put("cPoint", subObj[2]);  
311 - rs.put("radius", subObj[3]);  
312 - rs.put("code", subObj[4]);  
313 - rs.put("text", subObj[5]);  
314 - }  
315 -  
316 - return rs;  
317 - }  
318 -  
319 - @Override  
320 - public Map<String, Object> search(Map<String, Object> map, int page, int size, String order, String direction) {  
321 - Map<String, Object> rsMap = new HashMap<>();  
322 - try{  
323 - //全量  
324 - Collection<GpsEntity> list = gpsRealData.all();  
325 - //过滤后的  
326 - List<GpsEntity> rs = new ArrayList<>();  
327 - Field[] fields = GpsEntity.class.getDeclaredFields();  
328 - //排序字段  
329 - Field orderField = null;  
330 - //参与过滤的字段  
331 - List<Field> fs = new ArrayList<>();  
332 - for(Field f : fields){  
333 - f.setAccessible(true);  
334 - if(map.containsKey(f.getName()))  
335 - fs.add(f);  
336 -  
337 - if(f.getName().equals(order))  
338 - orderField = f;  
339 - }  
340 - //过滤数据  
341 - for(GpsEntity gps : list){  
342 - if(fieldEquals(fs, gps, map))  
343 - rs.add(gps);  
344 - }  
345 -  
346 - //排序  
347 - if(null != orderField)  
348 - sortGpsList(orderField, rs);  
349 -  
350 - //分页  
351 - int count = rs.size()  
352 - ,s = page * size, e = s + size;  
353 - if (e > count)  
354 - e = count;  
355 -  
356 - rsMap.put("list", rs.subList(s, e));  
357 - rsMap.put("totalPages", count % size == 0 ? count / size : count / size + 1);  
358 - rsMap.put("page", page);  
359 - rsMap.put("status", ResponseCode.SUCCESS);  
360 - }catch(Exception e){  
361 - logger.error("", e);  
362 - rsMap.put("status", ResponseCode.ERROR);  
363 - }  
364 - return rsMap;  
365 - }  
366 -  
367 - private void sortGpsList(final Field f, List<GpsEntity> rs) {  
368 - Collections.sort(rs, new Comparator<GpsEntity>() {  
369 -  
370 - @Override  
371 - public int compare(GpsEntity o1, GpsEntity o2) {  
372 - try {  
373 - if(f.get(o1) == f.get(o2))  
374 - return 0;  
375 -  
376 - if(null == f.get(o1))  
377 - return 1;  
378 -  
379 - if(null == f.get(o2))  
380 - return -1;  
381 -  
382 - return f.get(o1).toString().compareTo(f.get(o2).toString());  
383 - } catch (Exception e) {  
384 - logger.error("", e);  
385 - return -1;  
386 - }  
387 - }  
388 - });  
389 - }  
390 -  
391 - public boolean fieldEquals(List<Field> fs, Object obj, Map<String, Object> map){  
392 - try{  
393 - for(Field f : fs){  
394 - if(f.get(obj).toString().indexOf(map.get(f.getName()).toString()) == -1)  
395 - return false;  
396 - }  
397 - }catch(Exception e){  
398 - logger.error("", e);  
399 - return false;  
400 - }  
401 - return true;  
402 - } 211 + ps.setLong(2, st * 1000);
  212 + ps.setLong(3, et * 1000);
  213 +
  214 + rs = ps.executeQuery();
  215 + Float lon, lat;
  216 + Location bdLoc, gdLoc;
  217 + int upDown, inOutStop;
  218 + ArrivalEntity arrival;
  219 + while (rs.next()) {
  220 + upDown = getUpOrDown(rs.getLong("SERVICE_STATE"));
  221 + map = new HashMap<>();
  222 +
  223 + lon = rs.getFloat("LON");
  224 + lat = rs.getFloat("LAT");
  225 + // 高德坐标
  226 + gdLoc = TransGPS.transformFromWGSToGCJ(TransGPS.LocationMake(lon, lat));
  227 + map.put("gcj_lon", gdLoc.getLng());
  228 + map.put("gcj_lat", gdLoc.getLat());
  229 + // 百度坐标
  230 + bdLoc = TransGPS.bd_encrypt(gdLoc);
  231 + map.put("bd_lon", bdLoc.getLng());
  232 + map.put("bd_lat", bdLoc.getLat());
  233 +
  234 + map.put("deviceId", rs.getString("DEVICE_ID"));
  235 + map.put("ts", rs.getLong("TS"));
  236 + map.put("timestamp", rs.getLong("TS"));
  237 + map.put("stopNo", rs.getString("STOP_NO"));
  238 +
  239 + inOutStop = rs.getInt("INOUT_STOP");
  240 + map.put("inout_stop", inOutStop);
  241 +
  242 + arrival = arrivalMap.get(rs.getString("DEVICE_ID") + "_" + rs.getLong("TS"));
  243 + if (arrival != null) {
  244 + map.put("inout_stop_info", arrival);
  245 + map.put("inout_stop", arrival.getInOut());
  246 + }
  247 + map.put("nbbm", BasicData.deviceId2NbbmMap.get(rs.getString("DEVICE_ID")));
  248 + map.put("state", 0);
  249 + // 上下行
  250 + map.put("upDown", upDown);
  251 + list.add(map);
  252 + }
  253 + } catch (Exception e) {
  254 + logger.error("", e);
  255 + } finally {
  256 + DBUtils_MS.close(rs, ps, conn);
  257 + }
  258 + return list;
  259 + }
  260 +
  261 + public Map<String, ArrivalEntity> findArrivalByTs(int weekOfYear, Long st, Long et, String devicesInSql) {
  262 + Map<String, ArrivalEntity> map = new HashMap<>();
  263 +
  264 + String sql = "SELECT DEVICE_ID,LINE_ID,STOP_NO,TS,UP_DOWN,IN_OUT,WEEKS_YEAR,CREATE_DATE FROM bsth_c_arrival_info where weeks_year=? and device_id in ("
  265 + + devicesInSql + ") and ts > ? and ts < ?";
  266 + try {
  267 + conn = DBUtils_MS.getConnection();
  268 + ps = conn.prepareStatement(sql);
  269 + ps.setInt(1, weekOfYear);
  270 + ps.setLong(2, st * 1000);
  271 + ps.setLong(3, et * 1000);
  272 +
  273 + rs = ps.executeQuery();
  274 + ArrivalEntity arr;
  275 + int inOut;
  276 + while (rs.next()) {
  277 + arr = new ArrivalEntity(rs.getString("DEVICE_ID"), rs.getLong("TS"), rs.getString("LINE_ID"),
  278 + rs.getInt("UP_DOWN"), rs.getString("STOP_NO"), rs.getInt("IN_OUT"), rs.getLong("CREATE_DATE"),
  279 + rs.getInt("WEEKS_YEAR"), BasicData.stationCode2NameMap.get(rs.getString("STOP_NO")));
  280 +
  281 + // 设备号_时间戳_进出状态 为key
  282 + // 反转进出状态
  283 + inOut = arr.getInOut() == 0 ? 1 : 0;
  284 + map.put(arr.getDeviceId() + "_" + arr.getTs(), arr);
  285 + }
  286 + } catch (Exception e) {
  287 + logger.error("", e);
  288 + } finally {
  289 + DBUtils_MS.close(rs, ps, conn);
  290 + }
  291 + return map;
  292 + }
  293 +
  294 +
  295 + @Autowired
  296 + StationRepository stationRepository;
  297 +
  298 + @Autowired
  299 + CarParkRepository carParkRepository;
  300 +
  301 + @Override
  302 + public Map<String, Object> findBuffAeraByCode(String code, String type) {
  303 + Object[][] obj = null;
  304 + if (type.equals("station"))
  305 + obj = stationRepository.bufferAera(code);
  306 + else if (type.equals("park"))
  307 + obj = carParkRepository.bufferAera(code);
  308 +
  309 + Map<String, Object> rs = new HashMap<>();
  310 +
  311 + Object[] subObj = obj[0];
  312 + if (subObj != null && subObj.length == 6) {
  313 + rs.put("polygon", subObj[0]);
  314 + rs.put("type", subObj[1]);
  315 + rs.put("cPoint", subObj[2]);
  316 + rs.put("radius", subObj[3]);
  317 + rs.put("code", subObj[4]);
  318 + rs.put("text", subObj[5]);
  319 + }
  320 +
  321 + return rs;
  322 + }
  323 +
  324 + @Override
  325 + public Map<String, Object> search(Map<String, Object> map, int page, int size, String order, String direction) {
  326 + Map<String, Object> rsMap = new HashMap<>();
  327 + try {
  328 + //全量
  329 + List<GpsEntity> list = new ArrayList<>(gpsRealData.all());
  330 + //过滤后的
  331 + List<GpsEntity> rs = new ArrayList<>();
  332 + Field[] fields = GpsEntity.class.getDeclaredFields();
  333 + //排序字段
  334 + Field orderField = null;
  335 + //参与过滤的字段
  336 + List<Field> fs = new ArrayList<>();
  337 + for (Field f : fields) {
  338 + f.setAccessible(true);
  339 + if (map.containsKey(f.getName()))
  340 + fs.add(f);
  341 +
  342 + if (f.getName().equals(order))
  343 + orderField = f;
  344 + }
  345 + //过滤数据
  346 + for (GpsEntity gps : list) {
  347 + if (fieldEquals(fs, gps, map))
  348 + rs.add(gps);
  349 + }
  350 +
  351 + //排序
  352 +/* if (null != orderField)
  353 + sortGpsList(orderField, rs);*/
  354 + //时间戳排序
  355 + Collections.sort(rs, new Comparator<GpsEntity>() {
  356 + @Override
  357 + public int compare(GpsEntity o1, GpsEntity o2) {
  358 + return o2.getTimestamp().intValue() - o1.getTimestamp().intValue();
  359 + }
  360 + });
  361 +
  362 + //分页
  363 + int count = rs.size(), s = page * size, e = s + size;
  364 + if (e > count)
  365 + e = count;
  366 +
  367 + rsMap.put("list", rs.subList(s, e));
  368 + rsMap.put("totalPages", count % size == 0 ? count / size - 1 : count / size);
  369 + rsMap.put("page", page);
  370 + rsMap.put("status", ResponseCode.SUCCESS);
  371 + } catch (Exception e) {
  372 + logger.error("", e);
  373 + rsMap.put("status", ResponseCode.ERROR);
  374 + }
  375 + return rsMap;
  376 + }
  377 +
  378 + @Override
  379 + public Map<String, Object> removeRealGps(String device) {
  380 + Map<String, Object> rs = new HashMap<>();
  381 + try {
  382 +
  383 + gpsRealData.remove(device);
  384 + rs.put("status", ResponseCode.SUCCESS);
  385 + }catch (Exception e){
  386 + rs.put("status", ResponseCode.ERROR);
  387 + }
  388 + return rs;
  389 + }
  390 +
  391 + private void sortGpsList(final Field f, List<GpsEntity> rs) {
  392 + Collections.sort(rs, new Comparator<GpsEntity>() {
  393 +
  394 + @Override
  395 + public int compare(GpsEntity o1, GpsEntity o2) {
  396 + try {
  397 + if (f.get(o1) == f.get(o2))
  398 + return 0;
  399 +
  400 + if (null == f.get(o1))
  401 + return 1;
  402 +
  403 + if (null == f.get(o2))
  404 + return -1;
  405 +
  406 + return f.get(o1).toString().compareTo(f.get(o2).toString());
  407 + } catch (Exception e) {
  408 + logger.error("", e);
  409 + return -1;
  410 + }
  411 + }
  412 + });
  413 + }
  414 +
  415 + public boolean fieldEquals(List<Field> fs, Object obj, Map<String, Object> map) {
  416 + try {
  417 + for (Field f : fs) {
  418 + if (StringUtils.isEmpty(map.get(f.getName()).toString()))
  419 + continue;
  420 +
  421 + if (f.get(obj) == null || f.get(obj).toString().indexOf(map.get(f.getName()).toString()) == -1)
  422 + return false;
  423 + }
  424 + } catch (Exception e) {
  425 + logger.error("", e);
  426 + return false;
  427 + }
  428 + return true;
  429 + }
403 } 430 }
src/main/java/com/bsth/service/impl/LineServiceImpl.java
@@ -40,8 +40,8 @@ public class LineServiceImpl extends BaseServiceImpl&lt;Line, Integer&gt; implements L @@ -40,8 +40,8 @@ public class LineServiceImpl extends BaseServiceImpl&lt;Line, Integer&gt; implements L
40 } 40 }
41 41
42 @Override 42 @Override
43 - public Line findByLineCode(Integer lineCode) {  
44 - return repository.findByLineCode(lineCode + ""); 43 + public Line findByLineCode(String lineCode) {
  44 + return repository.findByLineCode(lineCode);
45 } 45 }
46 46
47 } 47 }
src/main/java/com/bsth/service/realcontrol/LineConfigService.java
@@ -7,9 +7,9 @@ import com.bsth.service.BaseService; @@ -7,9 +7,9 @@ import com.bsth.service.BaseService;
7 7
8 public interface LineConfigService extends BaseService<LineConfig, Integer>{ 8 public interface LineConfigService extends BaseService<LineConfig, Integer>{
9 9
10 - Map<String, Object> check(Integer[] codeArray); 10 + Map<String, Object> check(String[] codeArray);
11 11
12 - Integer inti(Integer lineCode) throws Exception; 12 + Integer init(String lineCode) throws Exception;
13 13
14 Map<String, Object> editStartOptTime(String time, String lineCode); 14 Map<String, Object> editStartOptTime(String time, String lineCode);
15 15
src/main/java/com/bsth/service/realcontrol/RealChartsService.java 0 → 100644
  1 +package com.bsth.service.realcontrol;
  2 +
  3 +import com.bsth.service.realcontrol.dto.CarOutRate;
  4 +import com.bsth.service.realcontrol.dto.DeviceOnlineRate;
  5 +
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +
  9 +/**线调图表
  10 + * Created by panzhao on 2016/11/9.
  11 + */
  12 +public interface RealChartsService {
  13 + List<DeviceOnlineRate> deviceOnlineRate(String month, String idx);
  14 +
  15 + List<CarOutRate> carOutRate(String month, String idx);
  16 +}
src/main/java/com/bsth/service/realcontrol/dto/CarOutRate.java 0 → 100644
  1 +package com.bsth.service.realcontrol.dto;
  2 +
  3 +/**
  4 + * 出车率
  5 + * Created by panzhao on 2016/11/9.
  6 + */
  7 +public class CarOutRate {
  8 +
  9 + private String dateStr;
  10 +
  11 + private String lineCode;
  12 +
  13 + private String nbbm;
  14 +
  15 + private String firstOut;
  16 +
  17 +
  18 + public String getNbbm() {
  19 + return nbbm;
  20 + }
  21 +
  22 + public void setNbbm(String nbbm) {
  23 + this.nbbm = nbbm;
  24 + }
  25 +
  26 + public String getLineCode() {
  27 + return lineCode;
  28 + }
  29 +
  30 + public void setLineCode(String lineCode) {
  31 + this.lineCode = lineCode;
  32 + }
  33 +
  34 + public String getDateStr() {
  35 + return dateStr;
  36 + }
  37 +
  38 + public void setDateStr(String dateStr) {
  39 + this.dateStr = dateStr;
  40 + }
  41 +
  42 + public String getFirstOut() {
  43 + return firstOut;
  44 + }
  45 +
  46 + public void setFirstOut(String firstOut) {
  47 + this.firstOut = firstOut;
  48 + }
  49 +}
src/main/java/com/bsth/service/realcontrol/dto/DeviceOnlineRate.java 0 → 100644
  1 +package com.bsth.service.realcontrol.dto;
  2 +
  3 +/**
  4 + * 设备上线率dto
  5 + * Created by panzhao on 2016/11/9.
  6 + */
  7 +public class DeviceOnlineRate {
  8 +
  9 + private String lineCode;
  10 +
  11 + private String dateStr;
  12 +
  13 + private Integer dayOfYear;
  14 +
  15 + private String nbbm;
  16 +
  17 + private boolean online;
  18 +
  19 + public boolean isOnline() {
  20 + return online;
  21 + }
  22 +
  23 + public void setOnline(boolean online) {
  24 + this.online = online;
  25 + }
  26 +
  27 + public String getNbbm() {
  28 + return nbbm;
  29 + }
  30 +
  31 + public void setNbbm(String nbbm) {
  32 + this.nbbm = nbbm;
  33 + }
  34 +
  35 + public String getDateStr() {
  36 + return dateStr;
  37 + }
  38 +
  39 + public void setDateStr(String dateStr) {
  40 + this.dateStr = dateStr;
  41 + }
  42 +
  43 + public String getLineCode() {
  44 + return lineCode;
  45 + }
  46 +
  47 + public void setLineCode(String lineCode) {
  48 + this.lineCode = lineCode;
  49 + }
  50 +
  51 + public Integer getDayOfYear() {
  52 + return dayOfYear;
  53 + }
  54 +
  55 + public void setDayOfYear(Integer dayOfYear) {
  56 + this.dayOfYear = dayOfYear;
  57 + }
  58 +}
src/main/java/com/bsth/service/realcontrol/dto/RealOnline.java 0 → 100644
  1 +package com.bsth.service.realcontrol.dto;
  2 +
  3 +/**
  4 + * 实际上线设备
  5 + * Created by panzhao on 2016/11/9.
  6 + */
  7 +public class RealOnline {
  8 +
  9 + private Integer dayOfYear;
  10 +
  11 + private String nbbm;
  12 +
  13 + private String device;
  14 +
  15 +
  16 + public Integer getDayOfYear() {
  17 + return dayOfYear;
  18 + }
  19 +
  20 + public void setDayOfYear(Integer dayOfYear) {
  21 + this.dayOfYear = dayOfYear;
  22 + }
  23 +
  24 + public String getNbbm() {
  25 + return nbbm;
  26 + }
  27 +
  28 + public void setNbbm(String nbbm) {
  29 + this.nbbm = nbbm;
  30 + }
  31 +
  32 + public String getDevice() {
  33 + return device;
  34 + }
  35 +
  36 + public void setDevice(String device) {
  37 + this.device = device;
  38 + }
  39 +}
src/main/java/com/bsth/service/realcontrol/impl/LineConfigServiceImpl.java
@@ -25,11 +25,11 @@ public class LineConfigServiceImpl extends BaseServiceImpl&lt;LineConfig, Integer&gt; @@ -25,11 +25,11 @@ public class LineConfigServiceImpl extends BaseServiceImpl&lt;LineConfig, Integer&gt;
25 LineConfigData lineConfigData; 25 LineConfigData lineConfigData;
26 26
27 @Override 27 @Override
28 - public Map<String, Object> check(Integer[] codeArray) { 28 + public Map<String, Object> check(String[] codeArray) {
29 Map<String, Object> rs = new HashMap<>(); 29 Map<String, Object> rs = new HashMap<>();
30 - List<Integer> notArr = new ArrayList<>(); 30 + List<String> notArr = new ArrayList<>();
31 31
32 - for(Integer lineCode : codeArray){ 32 + for(String lineCode : codeArray){
33 if(null == lineConfigData.get(lineCode + "")) 33 if(null == lineConfigData.get(lineCode + ""))
34 notArr.add(lineCode); 34 notArr.add(lineCode);
35 } 35 }
@@ -44,8 +44,8 @@ public class LineConfigServiceImpl extends BaseServiceImpl&lt;LineConfig, Integer&gt; @@ -44,8 +44,8 @@ public class LineConfigServiceImpl extends BaseServiceImpl&lt;LineConfig, Integer&gt;
44 } 44 }
45 45
46 @Override 46 @Override
47 - public Integer inti(Integer lineCode) throws Exception{  
48 - LineConfig conf = lineConfigData.get(lineCode + ""); 47 + public Integer init(String lineCode) throws Exception{
  48 + LineConfig conf = lineConfigData.get(lineCode );
49 49
50 if(conf == null) 50 if(conf == null)
51 lineConfigData.init(lineCode); 51 lineConfigData.init(lineCode);
src/main/java/com/bsth/service/realcontrol/impl/RealChartsServiceImpl.java 0 → 100644
  1 +package com.bsth.service.realcontrol.impl;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.service.realcontrol.RealChartsService;
  5 +import com.bsth.service.realcontrol.dto.CarOutRate;
  6 +import com.bsth.service.realcontrol.dto.DeviceOnlineRate;
  7 +import com.bsth.service.realcontrol.dto.RealOnline;
  8 +import com.bsth.util.db.DBUtils_MS;
  9 +import com.google.common.base.Splitter;
  10 +import org.apache.commons.lang3.StringUtils;
  11 +import org.joda.time.format.DateTimeFormat;
  12 +import org.joda.time.format.DateTimeFormatter;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.jdbc.core.JdbcTemplate;
  15 +import org.springframework.jdbc.core.RowMapper;
  16 +import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
  17 +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
  18 +import org.springframework.stereotype.Service;
  19 +
  20 +import java.sql.ResultSet;
  21 +import java.sql.SQLException;
  22 +import java.util.*;
  23 +
  24 +/**
  25 + * Created by panzhao on 2016/11/9.
  26 + */
  27 +@Service
  28 +public class RealChartsServiceImpl implements RealChartsService {
  29 +
  30 + @Autowired
  31 + NamedParameterJdbcTemplate jdbcTemplate;
  32 +
  33 + /**
  34 + * 设备上线率
  35 + *
  36 + * @param
  37 + * @param idx 线路id字符串
  38 + * @return
  39 + */
  40 + @Override
  41 + public List<DeviceOnlineRate> deviceOnlineRate(String month, String idx) {
  42 + List<String> idArray = Splitter.on(",").splitToList(idx);
  43 + //拼接in语句
  44 + String inStr = "";
  45 + for (String code : idArray) {
  46 + inStr += (",'" + code+"'");
  47 + }
  48 + inStr = " (" + inStr.substring(1) + ")";
  49 +
  50 + String sql = "select DISTINCT XL_BM,SCHEDULE_DATE_STR, CL_ZBH from bsth_c_s_sp_info_real s where s.schedule_date_str like :month and xl_bm in " + inStr;
  51 + MapSqlParameterSource parameters = new MapSqlParameterSource();
  52 + parameters.addValue("month", month+"-%");
  53 +
  54 + final DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  55 + //应该上线的设备
  56 + List<DeviceOnlineRate> mustList = jdbcTemplate.query(sql, parameters, new RowMapper<DeviceOnlineRate>() {
  57 + @Override
  58 + public DeviceOnlineRate mapRow(ResultSet rs, int rowNum) throws SQLException {
  59 + DeviceOnlineRate obj = new DeviceOnlineRate();
  60 + obj.setLineCode(rs.getString("XL_BM"));
  61 + obj.setDateStr(rs.getString("SCHEDULE_DATE_STR"));
  62 + obj.setNbbm(rs.getString("CL_ZBH"));
  63 + obj.setDayOfYear(fmtyyyyMMdd.parseDateTime(obj.getDateStr()).getDayOfYear());
  64 + return obj;
  65 + }
  66 + });
  67 +
  68 + if(mustList.size() == 0)
  69 + return mustList;
  70 +
  71 + //查询ms 库 gps信息
  72 + JdbcTemplate msJdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource());
  73 + //要in的 days_year ,gps表分区字段
  74 + Set<Integer> daysSet = new HashSet<>();
  75 +
  76 + Map<String, DeviceOnlineRate> groupData = new HashMap<>();
  77 + for(DeviceOnlineRate obj : mustList){
  78 + daysSet.add(obj.getDayOfYear());
  79 + //分组数据
  80 + groupData.put(obj.getDayOfYear()+"_"+obj.getNbbm(), obj);
  81 + }
  82 +
  83 +
  84 + //拼接 days_year in 语句
  85 + inStr="";
  86 + for(Integer daysOfYear : daysSet){
  87 + inStr += (",'" + daysOfYear+"'");
  88 + }
  89 + inStr = " (" + inStr.substring(1) + ")";
  90 + //查询gps表,获取实际上线设备
  91 + sql = "select DISTINCT DEVICE_ID, DAYS_YEAR from bsth_c_gps_info where days_year in " + inStr;
  92 + List<RealOnline> realList = msJdbcTemplate.query(sql, new RowMapper<RealOnline>() {
  93 + @Override
  94 + public RealOnline mapRow(ResultSet rs, int rowNum) throws SQLException {
  95 + RealOnline obj = new RealOnline();
  96 + obj.setDayOfYear(rs.getInt("DAYS_YEAR"));
  97 + obj.setDevice(rs.getString("DEVICE_ID"));
  98 + obj.setNbbm(BasicData.deviceId2NbbmMap.get(obj.getDevice()));
  99 + return obj;
  100 + }
  101 + });
  102 + DeviceOnlineRate donline;
  103 + for(RealOnline obj : realList){
  104 + if(StringUtils.isEmpty(obj.getNbbm()))
  105 + continue;
  106 +
  107 + donline = groupData.get(obj.getDayOfYear() + "_" + obj.getNbbm());
  108 + if(donline != null)
  109 + donline.setOnline(true);
  110 + }
  111 +
  112 + return mustList;
  113 + }
  114 +
  115 + @Override
  116 + public List<CarOutRate> carOutRate(String month, String idx) {
  117 + List<String> idArray = Splitter.on(",").splitToList(idx);
  118 + //拼接in语句
  119 + String inStr = "";
  120 + for (String code : idArray) {
  121 + inStr += (",'" + code+"'");
  122 + }
  123 + inStr = " (" + inStr.substring(1) + ")";
  124 +
  125 + String sql = "SELECT DISTINCT XL_BM,SCHEDULE_DATE_STR,CL_ZBH,right(min(concat(REAL_EXEC_DATE,fcsj_actual)),5) as FIRST_OUT FROM bsth_c_s_sp_info_real s WHERE s.schedule_date_str LIKE :month AND xl_bm IN "+inStr+" group by XL_BM,SCHEDULE_DATE_STR,CL_ZBH";
  126 +
  127 + MapSqlParameterSource parameters = new MapSqlParameterSource();
  128 + parameters.addValue("month", month+"-%");
  129 +
  130 + List<CarOutRate> list = jdbcTemplate.query(sql, parameters, new RowMapper<CarOutRate>() {
  131 + @Override
  132 + public CarOutRate mapRow(ResultSet rs, int rowNum) throws SQLException {
  133 + CarOutRate obj = new CarOutRate();
  134 + obj.setDateStr(rs.getString("SCHEDULE_DATE_STR"));
  135 + obj.setNbbm(rs.getString("CL_ZBH"));
  136 + obj.setLineCode(rs.getString("XL_BM"));
  137 + obj.setFirstOut(rs.getString("FIRST_OUT"));
  138 + return obj;
  139 + }
  140 + });
  141 +
  142 + return list;
  143 + }
  144 +}
src/main/java/com/bsth/util/db/DBUtils_MS.java
@@ -132,4 +132,8 @@ public class DBUtils_MS { @@ -132,4 +132,8 @@ public class DBUtils_MS {
132 } 132 }
133 } 133 }
134 } 134 }
  135 +
  136 + public static DataSource getDataSource(){
  137 + return ds_pooled;
  138 + }
135 } 139 }
src/main/resources/datatools/config-prod.properties
@@ -3,14 +3,15 @@ @@ -3,14 +3,15 @@
3 # 1、kettle配置文件路径(类路径) 3 # 1、kettle配置文件路径(类路径)
4 datatools.kettle_properties=/datatools/kettle.properties 4 datatools.kettle_properties=/datatools/kettle.properties
5 # 2、ktr文件通用配置变量(数据库连接,根据不同的环境需要修正) 5 # 2、ktr文件通用配置变量(数据库连接,根据不同的环境需要修正)
  6 +
6 #数据库ip地址 7 #数据库ip地址
7 -datatools.kvars_dbip=192.168.40.100 8 +datatools.kvars_dbip=192.168.168.171
8 #数据库用户名 9 #数据库用户名
9 datatools.kvars_dbuname=root 10 datatools.kvars_dbuname=root
10 #数据库密码 11 #数据库密码
11 -datatools.kvars_dbpwd=root@JSP2jsp 12 +datatools.kvars_dbpwd=root2jsp
12 #数据库库名 13 #数据库库名
13 -datatools.kvars_dbdname=qp_control 14 +datatools.kvars_dbdname=control
14 15
15 # 3、上传数据配置信息 16 # 3、上传数据配置信息
16 # 上传文件目录配置(根据不同的环境需要修正) 17 # 上传文件目录配置(根据不同的环境需要修正)
src/main/resources/static/index.html
@@ -145,7 +145,7 @@ tr.row-active td { @@ -145,7 +145,7 @@ tr.row-active td {
145 <div class="page-header-inner "> 145 <div class="page-header-inner ">
146 <!-- LOGO --> 146 <!-- LOGO -->
147 <div class="page-logo"> 147 <div class="page-logo">
148 - <a href="index.html" class="logo-default logo-default-text" > 青浦公交调度系统 </a> 148 + <a href="index.html" class="logo-default logo-default-text" > 闵行公交调度系统 </a>
149 <div class="menu-toggler sidebar-toggler"> 149 <div class="menu-toggler sidebar-toggler">
150 </div> 150 </div>
151 </div> 151 </div>
@@ -314,8 +314,8 @@ tr.row-active td { @@ -314,8 +314,8 @@ tr.row-active td {
314 <script src="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js" ></script> 314 <script src="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js" ></script>
315 <!-- 表格控件 --> 315 <!-- 表格控件 -->
316 <!-- 统计图控件 --> 316 <!-- 统计图控件 -->
317 -<script src="/assets/global/getEchart.js"></script>  
318 -<script src="/assets/global/echarts.js"></script> 317 +<!--<script src="/assets/global/getEchart.js"></script>
  318 +<script src="/assets/global/echarts.js"></script> -->
319 <script src="/assets/js/common.js"></script> 319 <script src="/assets/js/common.js"></script>
320 <script src="/assets/js/dictionary.js"></script> 320 <script src="/assets/js/dictionary.js"></script>
321 321
src/main/resources/static/login.html
@@ -180,7 +180,7 @@ h3.logo-text{ @@ -180,7 +180,7 @@ h3.logo-text{
180 <div class="wrapper ng-scope"> 180 <div class="wrapper ng-scope">
181 <div id="loginPanel" class="dialog dialog-shadow"> 181 <div id="loginPanel" class="dialog dialog-shadow">
182 <br> 182 <br>
183 - <h3 class="logo-text">青浦公交调度系统 </h3> 183 + <h3 class="logo-text">闵行公交调度系统 </h3>
184 <hr> 184 <hr>
185 <form style="padding: 0px 35px;"> 185 <form style="padding: 0px 35px;">
186 <div class="form-group" style="margin-bottom: 0"> 186 <div class="form-group" style="margin-bottom: 0">
src/main/resources/static/pages/control/line/index.html
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 <div class="portlet-title banner" > 18 <div class="portlet-title banner" >
19 <div class="caption col_hide_1280" style="color: #FFF;"> 19 <div class="caption col_hide_1280" style="color: #FFF;">
20 <i class="fa fa-life-ring" style="font-size: 22px;color: #FFF;"></i> <span 20 <i class="fa fa-life-ring" style="font-size: 22px;color: #FFF;"></i> <span
21 - class="caption-subject bold" style="font-size: 24px;">青浦公交线路调度系统</span> 21 + class="caption-subject bold" style="font-size: 24px;">闵行公交线路调度系统</span>
22 </div> 22 </div>
23 <div class="col_hide_1440" style="color: white;font-size: 18px;position: absolute;right: 25px;top: 75px;"> 23 <div class="col_hide_1440" style="color: white;font-size: 18px;position: absolute;right: 25px;top: 75px;">
24 <span class="top_username"></span> <span class="operation_mode_text animated" ></span> 24 <span class="top_username"></span> <span class="operation_mode_text animated" ></span>