Commit cbfe66b5bccea25aa5504ebe3efd786c8d3661da

Authored by 潘钊
1 parent ffe8c7f0

update....

Showing 60 changed files with 27726 additions and 525 deletions
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>
src/main/resources/static/real_control_v2/assets/echarts-3/echarts.js 0 → 100644
No preview for this file type
src/main/resources/static/real_control_v2/css/ct_table.css
@@ -79,7 +79,8 @@ @@ -79,7 +79,8 @@
79 .ct_table dl dd, .ct_table dl dt { 79 .ct_table dl dd, .ct_table dl dt {
80 border-right-color: #dedede; 80 border-right-color: #dedede;
81 font-size: 13px; 81 font-size: 13px;
82 - border-bottom: 1px solid #dedede; 82 + /*border-bottom: 1px solid #dedede;*/
  83 + border-top: 1px solid #dedede;
83 } 84 }
84 85
85 dl.ct_row_active, .ct_table>.ct_table_body dl.ct_row_active:hover { 86 dl.ct_row_active, .ct_table>.ct_table_body dl.ct_row_active:hover {
src/main/resources/static/real_control_v2/css/line_schedule.css
@@ -238,10 +238,51 @@ span.fcsj-diff { @@ -238,10 +238,51 @@ span.fcsj-diff {
238 238
239 dd.tl-yzx { 239 dd.tl-yzx {
240 background: #c1ddf0; 240 background: #c1ddf0;
241 - border-bottom: 0 !important;  
242 - border-top: 1px solid #f5f5f5; 241 + border-top: 1px solid #ebebeb !important;
243 } 242 }
244 243
  244 +dd.tl-xxfc{
  245 + background: #ff7878;
  246 + color: #f1f1f1;
  247 +}
  248 +
  249 +/*dd.tl-xxfc:before{
  250 + font-family: FontAwesome;
  251 + content: "\f0a1";
  252 + position: absolute;
  253 + top: -10px;
  254 + left: 3px;
  255 + font-size: 11px;
  256 + color: #fbfbfb;
  257 +}*/
  258 +
  259 +dd.tl-xxsd{
  260 + background: #e2de94;
  261 +}
  262 +
  263 +/*dd.tl-xxsd:before{
  264 + font-family: FontAwesome;
  265 + content: "\f0a1";
  266 + position: absolute;
  267 + top: -10px;
  268 + left: 3px;
  269 + font-size: 11px;
  270 +}*/
  271 +
  272 +dd.tl-xxrd{
  273 + background: #c1ddf0;
  274 + border-top: 1px solid #ebebeb !important;
  275 +}
  276 +/*
  277 +dd.tl-xxrd:before{
  278 + font-family: FontAwesome;
  279 + content: "\f00c";
  280 + position: absolute;
  281 + top: -10px;
  282 + left: 3px;
  283 + font-size: 11px;
  284 +}*/
  285 +
245 dd.tl-qrlb { 286 dd.tl-qrlb {
246 background: #7B6B24; 287 background: #7B6B24;
247 color: #EAEBEC; 288 color: #EAEBEC;
@@ -760,3 +801,8 @@ input.i-cbox[type=checkbox]{ @@ -760,3 +801,8 @@ input.i-cbox[type=checkbox]{
760 font-size: 12px; 801 font-size: 12px;
761 color: #cecece; 802 color: #cecece;
762 } 803 }
  804 +.device_event_str{
  805 + font-size: 10px;
  806 + color: #bdbdbd;
  807 + margin-left: 3px;
  808 +}
763 \ No newline at end of file 809 \ No newline at end of file
src/main/resources/static/real_control_v2/css/main.css
@@ -70,6 +70,10 @@ table.ct-fixed-table { @@ -70,6 +70,10 @@ table.ct-fixed-table {
70 table-layout: fixed; 70 table-layout: fixed;
71 } 71 }
72 72
  73 +table.ct-fixed-table tr.context-menu-active{
  74 + background: #f0f0f0;
  75 +}
  76 +
73 table.ct-fixed-table.uk-table tr td { 77 table.ct-fixed-table.uk-table tr td {
74 white-space: nowrap; 78 white-space: nowrap;
75 overflow: hidden; 79 overflow: hidden;
src/main/resources/static/real_control_v2/css/north.css
@@ -70,3 +70,13 @@ @@ -70,3 +70,13 @@
70 #north_toolbar_panel li.disabled a{ 70 #north_toolbar_panel li.disabled a{
71 cursor: no-drop !important; 71 cursor: no-drop !important;
72 } 72 }
  73 +
  74 +.load-panel{
  75 + position: absolute;
  76 + top: 50%;
  77 + left: 50%;
  78 + margin-top: -20px;
  79 + margin-left: -76px;
  80 + font-size: 18px;
  81 + display: none;
  82 +}
73 \ No newline at end of file 83 \ No newline at end of file
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/add_temp_sch.html
@@ -90,7 +90,7 @@ @@ -90,7 +90,7 @@
90 <div class="uk-grid"> 90 <div class="uk-grid">
91 <div class="uk-width-1-2"> 91 <div class="uk-width-1-2">
92 <div class="uk-form-row"> 92 <div class="uk-form-row">
93 - <label class="uk-form-label">驾驶员 <i class="uk-icon-question-circle" data-uk-tooltip title="如果有驾驶员未提示,请至后台“基础信息 -人员信息”里纠正该员工的“工种”类别 "></i></label> 93 + <label class="uk-form-label">驾驶员 <!--<i class="uk-icon-question-circle" data-uk-tooltip title="如果有驾驶员未提示,请至后台“基础信息 -人员信息”里纠正该员工的“工种”类别 "></i>--></label>
94 <div class="uk-form-controls"> 94 <div class="uk-form-controls">
95 <div class="uk-autocomplete uk-form jsy-autocom"> 95 <div class="uk-autocomplete uk-form jsy-autocom">
96 <input type="text" value="{{jGh}}/{{jName}}" name="jsy" required> 96 <input type="text" value="{{jGh}}/{{jName}}" name="jsy" required>
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/jhlb.html
@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
61 <div class="uk-width-1-1"> 61 <div class="uk-width-1-1">
62 <div class="uk-form-row ct-stacked"> 62 <div class="uk-form-row ct-stacked">
63 <div class="uk-form-controls" style="margin-top: 5px;"> 63 <div class="uk-form-controls" style="margin-top: 5px;">
64 - <textarea id="form-s-t" cols="30" rows="5" name="remarks" data-fv-notempty data-fv-stringlength="true" data-fv-stringlength-max="20" placeholder="烂班说明,不超过20个字符"></textarea> 64 + <textarea id="form-s-t" cols="30" rows="5" name="remarks" data-fv-stringlength="true" data-fv-stringlength-max="20" placeholder="烂班说明,不超过20个字符。非必填"></textarea>
65 </div> 65 </div>
66 </div> 66 </div>
67 </div> 67 </div>
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sftz.html
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 <div class="uk-form-row ct-stacked"> 54 <div class="uk-form-row ct-stacked">
55 <label class="uk-form-label" for="form-s-t">调整说明<small class="font-danger">(不超过20个字符)</small></label> 55 <label class="uk-form-label" for="form-s-t">调整说明<small class="font-danger">(不超过20个字符)</small></label>
56 <div class="uk-form-controls"> 56 <div class="uk-form-controls">
57 - <textarea id="form-s-t" cols="30" rows="5" name="remarks" data-fv-notempty data-fv-stringlength="true" data-fv-stringlength-max="20"></textarea> 57 + <textarea id="form-s-t" cols="30" rows="5" name="remarks" data-fv-stringlength="true" data-fv-stringlength-max="20" placeholder="不超过20个字符。非必填"></textarea>
58 </div> 58 </div>
59 </div> 59 </div>
60 </div> 60 </div>
src/main/resources/static/real_control_v2/fragments/line_schedule/sch_table.html
@@ -40,7 +40,10 @@ @@ -40,7 +40,10 @@
40 <dl data-id="{{sch.id}}" > 40 <dl data-id="{{sch.id}}" >
41 <dd class="seq_no">{{i + 1}}</dd> 41 <dd class="seq_no">{{i + 1}}</dd>
42 <dd class="lpName"><a>{{sch.lpName}}</a></dd> 42 <dd class="lpName"><a>{{sch.lpName}}</a></dd>
43 - <dd data-nbbm="{{sch.clZbh}}">{{sch.clZbh}}</dd> 43 + <dd data-nbbm="{{sch.clZbh}}"
  44 + class="{{if sch.directiveState == 60}}tl-xxfc{{else if sch.directiveState == 100}}tl-xxsd{{else if sch.directiveState == 200}}tl-xxrd{{/if}}">
  45 + {{sch.clZbh}}
  46 + </dd>
44 <dd>{{sch.qdzArrDateJH}}</dd> 47 <dd>{{sch.qdzArrDateJH}}</dd>
45 <dd>{{sch.qdzArrDateSJ}}</dd> 48 <dd>{{sch.qdzArrDateSJ}}</dd>
46 <dd data-sort-val={{sch.fcsjT}}> 49 <dd data-sort-val={{sch.fcsjT}}>
@@ -109,4 +112,11 @@ @@ -109,4 +112,11 @@
109 {{fcsjActual}}<span class="fcsj-diff">{{fcsj_diff}}</span> 112 {{fcsjActual}}<span class="fcsj-diff">{{fcsj_diff}}</span>
110 </dd> 113 </dd>
111 </script> 114 </script>
  115 +
  116 + <script id="line-schedule-nbbm-temp" type="text/html">
  117 + <dd data-nbbm="{{clZbh}}"
  118 + class="{{if directiveState == 60}}tl-xxfc{{else if directiveState == 100}}tl-xxsd{{else if directiveState == 200}}tl-xxrd{{/if}}">
  119 + {{clZbh}}
  120 + </dd>
  121 + </script>
112 </div> 122 </div>
src/main/resources/static/real_control_v2/fragments/line_schedule/sys_mailbox.html
1 <div> 1 <div>
2 <script id="sys-note-80-temp" type="text/html"> 2 <script id="sys-note-80-temp" type="text/html">
3 - <div class="uk-width-medium-1-1 sys-note-80" data-id={{id}}> 3 + <div class="uk-width-medium-1-1 sys-note-80 sys-mail-item" data-id={{id}}>
4 <div class="uk-panel uk-panel-box uk-panel-box-primary"> 4 <div class="uk-panel uk-panel-box uk-panel-box-primary">
5 <h4 class="uk-panel-title">{{data.nbbm}} {{text}}</h4> 5 <h4 class="uk-panel-title">{{data.nbbm}} {{text}}</h4>
6 <code>{{dateStr}}</code> 6 <code>{{dateStr}}</code>
7 <div class="uk-button-group"> 7 <div class="uk-button-group">
8 <a class="uk-button uk-button-mini uk-button-primary">同意</a> 8 <a class="uk-button uk-button-mini uk-button-primary">同意</a>
9 - <a class="uk-button uk-button-mini">不同意</a> 9 + <a class="uk-button uk-button-mini reject">不同意</a>
10 </div> 10 </div>
11 </div> 11 </div>
12 </div> 12 </div>
13 </script> 13 </script>
14 14
15 <script id="sys-note-42-temp" type="text/html"> 15 <script id="sys-note-42-temp" type="text/html">
16 - <div class="uk-width-medium-1-1 sys-note-42" id="{{domId}}"> 16 + <div class="uk-width-medium-1-1 sys-note-42 sys-mail-item" id="{{domId}}" >
17 <div class="uk-panel uk-panel-box uk-panel-box-secondary"> 17 <div class="uk-panel uk-panel-box uk-panel-box-secondary">
18 <h5 class="title"> 18 <h5 class="title">
19 {{t.fcsjActual}} {{t.clZbh}} 已由 {{t.qdzName}} 发出,执行班次 {{t.dfsj}} 19 {{t.fcsjActual}} {{t.clZbh}} 已由 {{t.qdzName}} 发出,执行班次 {{t.dfsj}}
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 </script> 26 </script>
27 27
28 <script id="sys-note-42_1-temp" type="text/html"> 28 <script id="sys-note-42_1-temp" type="text/html">
29 - <div class="uk-width-medium-1-1 sys-note-42" id="{{domId}}"> 29 + <div class="uk-width-medium-1-1 sys-note-42 sys-mail-item" id="{{domId}}">
30 <div class="uk-panel uk-panel-box uk-panel-box-secondary"> 30 <div class="uk-panel uk-panel-box uk-panel-box-secondary">
31 <h5 class="title"> 31 <h5 class="title">
32 {{t.zdsjActual}} {{t.clZbh}} 到达 {{t.zdzName}};已完成 {{finish}} 个班次; 32 {{t.zdsjActual}} {{t.clZbh}} 到达 {{t.zdzName}};已完成 {{finish}} 个班次;
src/main/resources/static/real_control_v2/fragments/north/nav/all_devices.html 0 → 100644
  1 +<div class="uk-modal" id="all-devices-modal">
  2 + <div class="uk-modal-dialog" style="width: 1100px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div class="uk-modal-header">
  5 + <h2>所有接入平台的设备</h2></div>
  6 +
  7 + <div class="uk-panel uk-panel-box uk-panel-box-primary">
  8 + <form class="uk-form search-form">
  9 + <fieldset data-uk-margin>
  10 + <legend>
  11 + 数据检索
  12 + <!-- <div class="legend-tools">
  13 + <a class="uk-icon-small uk-icon-hover uk-icon-file-excel-o" data-uk-tooltip title="导出excel"></a>
  14 + </div> -->
  15 + </legend>
  16 + <span class="horizontal-field">线路</span>
  17 + <div class="uk-autocomplete uk-form autocomplete-line" >
  18 + <input type="text" name="lineId" placeholder="线路">
  19 + </div>
  20 + <span class="horizontal-field">车辆</span>
  21 + <div class="uk-autocomplete uk-form autocomplete-cars" >
  22 + <input type="text" name="nbbm" placeholder="车辆自编号">
  23 + </div>
  24 + <span class="horizontal-field">设备号</span>
  25 + <div class="uk-autocomplete uk-form autocomplete-device" >
  26 + <input type="text" name="deviceId" placeholder="设备号">
  27 + </div>
  28 + <button class="uk-button">检索</button>
  29 + </fieldset>
  30 + </form>
  31 + </div>
  32 + <div style="height: 495px;margin:5px 0 -18px;">
  33 + <table class="ct-fixed-table uk-table uk-table-hover">
  34 + <thead>
  35 + <tr>
  36 + <th style="width: 14%;">线路</th>
  37 + <th style="width: 14%;">站点</th>
  38 + <th style="width: 13%;">车辆</th>
  39 + <th style="width: 13%;">设备号</th>
  40 + <th style="width: 10%;">速度</th>
  41 + <th style="width: 10%;">上下行</th>
  42 + <th style="width: 10%;">程序版本</th>
  43 + <th>最后GPS时间</th>
  44 + </tr>
  45 + </thead>
  46 + <tbody>
  47 + </tbody>
  48 + </table>
  49 + </div>
  50 + <div class="uk-modal-footer uk-text-right pagination-wrap">
  51 + </div>
  52 + </div>
  53 +
  54 + <script id="all-devices-table-temp" type="text/html">
  55 + {{each list as gps i}}
  56 + <tr data-device="{{gps.deviceId}}">
  57 + <td>{{gps.lineId}}/{{gps.lineName}}</td>
  58 + <td>{{gps.stationName}}</td>
  59 + <td>{{gps.nbbm}}</td>
  60 + <td>{{gps.deviceId}}</td>
  61 + <td>{{gps.speed}}</td>
  62 + <td>{{gps.upDown}}</td>
  63 + <td>{{gps.version}}</td>
  64 + <td>{{gps.timeStr}}</td>
  65 + </tr>
  66 + {{/each}}
  67 + </script>
  68 +
  69 + <script id="device-line-change-modal-temp" type="text/html">
  70 + <div class="uk-modal" id="device-line-change-modal">
  71 + <div class="uk-modal-dialog">
  72 + <a href="" class="uk-modal-close uk-close"></a>
  73 +
  74 + <form class="uk-form fv-form">
  75 + <input type="hidden" name="deviceId" value="{{device}}" />
  76 + <fieldset data-uk-margin>
  77 + <strong style="color: red;font-size: 16px;">{{device}}</strong> 切换至线路
  78 +
  79 + <div class="uk-autocomplete uk-form" id="uk-autocomplete-line">
  80 + <input type="text" placeholder="搜索线路" name="line" />
  81 + </div>
  82 +
  83 + <label style="margin-left: 15px;font-size: 12px;color: grey;">
  84 + <input type="checkbox" style="vertical-align: middle" checked disabled> 强制刷新线路文件!
  85 + </label>
  86 + </fieldset>
  87 +
  88 + <div class="uk-modal-footer uk-text-right">
  89 + <button type="button" class="uk-button uk-modal-close">取消</button>
  90 + <button type="submit" class="uk-button uk-button-primary"><i class="uk-icon-send"></i> &nbsp;发送</button>
  91 + </div>
  92 + </form>
  93 + </div>
  94 + </div>
  95 + </script>
  96 + <script>
  97 + (function() {
  98 + var modal = '#all-devices-modal';
  99 + var form = $('.search-form', modal);
  100 + var page = 0;
  101 + var pageSize = 12;
  102 +
  103 + $(modal).on('init', function(e, data) {
  104 + //车辆 autocomplete
  105 + $.get('/basic/cars', function(rs) {
  106 + gb_common.carAutocomplete($('.autocomplete-cars', modal), rs);
  107 + });
  108 + //线路 autocomplete
  109 + gb_common.lineAutocomplete($('.autocomplete-line', modal));
  110 + //设备号autocomplete
  111 + $.get('/gps/allDevices', function(rs){
  112 + var data=[];
  113 + $.each(rs, function(){
  114 + data.push({value: this});
  115 + });
  116 + gb_common.init_autocomplete($('.autocomplete-device', modal), data);
  117 + });
  118 + query();
  119 + });
  120 +
  121 + //sumit event
  122 + form.on('submit', function(e) {
  123 + e.preventDefault();
  124 + resetPagination = true;
  125 + query();
  126 + });
  127 +
  128 + var query = function() {
  129 + var data = form.serializeJSON();
  130 + data.page = page;
  131 + data.size = pageSize;
  132 + //线路转换成编码
  133 + if(data.lineId){
  134 + var lineCode = gb_data_basic.findCodeByLinename(data.lineId);
  135 + if(lineCode)
  136 + data.lineId=lineCode;
  137 + }
  138 + $.get('/gps/real/all', data, function(rs) {
  139 + //数据转换
  140 + var code2Name=gb_data_basic.lineCode2NameAll();
  141 + $.each(rs.list, function(){
  142 + this.lineName=code2Name[this.lineId];
  143 + this.timeStr = moment(this.timestamp).format('YYYY-MM-DD HH:mm:ss');
  144 + });
  145 + var bodyHtml = template('all-devices-table-temp', {
  146 + list: rs.list
  147 + });
  148 + $('table tbody', modal).html(bodyHtml);
  149 +
  150 + //pagination
  151 + if (resetPagination)
  152 + pagination(rs.totalPages + 1, rs.page);
  153 + })
  154 + }
  155 +
  156 + var resetPagination = true;
  157 + var pagination = function(pages, currentPage) {
  158 + var wrap = $('.pagination-wrap', modal).empty()
  159 + ,e = $('<ul class="uk-pagination"></ul>').appendTo(wrap);
  160 +
  161 + var pagination = UIkit.pagination(e, {
  162 + pages: pages,
  163 + currentPage: currentPage
  164 + });
  165 +
  166 + e.on('select.uk.pagination', function(e, pageIndex){
  167 + page = pageIndex;
  168 + query();
  169 + });
  170 +
  171 + resetPagination = false;
  172 + }
  173 +
  174 + var callbackHandler={
  175 + change_line: function(device){
  176 + var htmlStr=template('device-line-change-modal-temp', {device: device})
  177 + ,lcModal='#device-line-change-modal';
  178 + $(document.body).append(htmlStr);
  179 + var elem = UIkit.modal(lcModal, {bgclose: false,modal:false}).show();
  180 +
  181 + //line autocomplete
  182 + gb_common.lineAutocomplete(lcModal + ' #uk-autocomplete-line');
  183 +
  184 + $('form', lcModal).on('submit', function(e) {
  185 + e.preventDefault();
  186 + var data = $(this).serializeJSON();
  187 + data.line = $.trim(data.line);
  188 +
  189 + var lineCode = gb_data_basic.findCodeByLinename(data.line);
  190 + if (data.line == '' || !lineCode)
  191 + notify_err('无效的线路输入!');
  192 + else {
  193 + data.lineId = lineCode;
  194 + $.post('/directive/lineChangeByDevice', data, function(rs){
  195 + if(rs == 0)
  196 + notify_succ('指令已发出!');
  197 + else
  198 + notify_err('指令发送失败!');
  199 +
  200 + elem.hide();
  201 + });
  202 + }
  203 + });
  204 + },
  205 + refresh_line_file: function(device){
  206 + $.post('/directive/refreshLineFile',{deviceId: device}, function(rs){
  207 + if(rs == 0)
  208 + notify_succ('线路文件刷新指令已发出!');
  209 + else
  210 + notify_err('线路文件刷新指令发送失败!');
  211 + });
  212 + },
  213 + delete: function(device){
  214 + alt_confirm('从清册删除【<strong style="color: red;">'+device+'</strong>】?如果该设备继续向平台发送数据,仍会被收录。', function(){
  215 + gb_common.$post('/gps/removeRealGps', {device: device}, function(){
  216 + notify_succ('操作成功!');
  217 + query();
  218 + });
  219 + }, '确定从清册中移除');
  220 + }
  221 + }
  222 +
  223 + $.contextMenu({
  224 + selector: '#all-devices-modal table>tbody>tr',
  225 + className: 'schedule-ct-menu',
  226 + callback: function(key, options) {
  227 + var device = $('.context-menu-active', modal).data('device');
  228 + callbackHandler[key] && callbackHandler[key](device);
  229 + },
  230 + items: {
  231 + 'change_line': {
  232 + name: '切换线路'
  233 + },
  234 + 'refresh_line_file':{
  235 + name: '刷新线路文件'
  236 + },
  237 + 'delete': {
  238 + name: '删除'
  239 + }
  240 + }
  241 + });
  242 +
  243 + })();
  244 + </script>
  245 +</div>
src/main/resources/static/real_control_v2/fragments/north/nav/charts/car_out_rate.html 0 → 100644
  1 +<div class="uk-modal" id="car-out-rate-modal">
  2 + <div class="uk-modal-dialog" style="width: 1200px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div class="uk-modal-header">
  5 + <h2>出车率</h2></div>
  6 +
  7 + <div class="uk-panel uk-panel-box uk-panel-box-primary" style="margin-bottom: 10px;">
  8 + <form class="uk-form search-form">
  9 + <fieldset data-uk-margin>
  10 + <div class="uk-form-icon">
  11 + <i class="uk-icon-calendar"></i>
  12 + <input type="month" id="monthInput">
  13 + </div>
  14 + <button class="uk-button" id="countBtn" >统计</button>
  15 + </fieldset>
  16 + </form>
  17 + </div>
  18 +
  19 + <div class="chart-wrap" style="height: 570px;">
  20 +
  21 + </div>
  22 +
  23 + <div class="load-panel">
  24 + <i class="uk-icon-spinner uk-icon-spin"></i>
  25 + 正在汇总数据
  26 + </div>
  27 + </div>
  28 +
  29 + <script>
  30 + (function () {
  31 +
  32 + var modal = '#car-out-rate-modal';
  33 + var chartObj;
  34 +
  35 +
  36 + var gb_option = {
  37 + timeline: {
  38 + axisType: 'category',
  39 + label: {
  40 + formatter: function (s, a) {
  41 + return s.slice(8).length==1?'0'+s.slice(8):s.slice(8);
  42 + }
  43 + },
  44 + x: 20,
  45 + x2: 5
  46 + }
  47 + };
  48 +
  49 +
  50 + $(modal).on('init', function (e, data) {
  51 + //默认当前月
  52 + var m = moment().format('YYYY-MM');
  53 + $('#monthInput', modal).val(m);
  54 +
  55 + chartObj = echarts.init($('.chart-wrap', modal)[0]);
  56 + chartObj.on('click', chartObjClickHandler);
  57 + renderChart();
  58 +
  59 + });
  60 +
  61 +
  62 + //计算上线率
  63 + function calcOutRate(data){
  64 + var line2Reate={}, eff;
  65 + for(var lineCode in data){
  66 + eff=0;
  67 + $.each(data[lineCode], function(){
  68 + if(this.firstOut)
  69 + eff++;
  70 + });
  71 +
  72 + line2Reate[lineCode]=(eff/data[lineCode].length*100).toFixed(2);
  73 + }
  74 +
  75 + return line2Reate;
  76 + }
  77 +
  78 + $('#countBtn', modal).on('click', renderChart);
  79 +
  80 + var renderData;
  81 + function renderChart(){
  82 + //时间轴数据
  83 + var lastdate = moment().format('DD')
  84 + ,month = $('#monthInput', modal).val();
  85 + if(month!=moment().format('YYYY-MM')){
  86 + //不是当前月
  87 + lastdate = new Date(month.split('-')[0],month.split('-')[1],0).getDate();
  88 + }
  89 +
  90 + var timeData = [];
  91 + for (var i = 0; i < lastdate; i++)
  92 + timeData.push(month + '-' + (i + 1));
  93 + //时间轴
  94 + gb_option.timeline.data = timeData;
  95 + gb_option.timeline.currentIndex=timeData.length-1;
  96 +
  97 + //xAxis
  98 + var xAxisData=[],lineCodeArr=[];
  99 + $.each(gb_data_basic.activeLines, function(){
  100 + xAxisData.push(this.name);
  101 + lineCodeArr.push(this.lineCode);
  102 + });
  103 +
  104 +
  105 + $('.load-panel', modal).show();
  106 + $('#countBtn', modal).attr('disabled', 'disabled');
  107 + //统计数据
  108 + gb_common.$get('/realCharts/carOutRate', {idx: gb_data_basic.line_idx, month: $('#monthInput', modal).val()}, function (rs) {
  109 + if(!rs || rs.length==0){
  110 + notify_err("缺少" + month + "的数据");
  111 + $('.load-panel', modal).hide();
  112 + $('#countBtn', modal).removeAttr('disabled');
  113 + return;
  114 + }
  115 +
  116 + //日期分组数据
  117 + var groupList=gb_common.groupBy(rs, 'dateStr')
  118 + ,data=[], opt={};
  119 +
  120 + renderData=groupList;
  121 + var subData;
  122 + for(var date in groupList){
  123 + //lineCode再次分组,计算发车率
  124 + var line2Reate=calcOutRate(gb_common.groupBy(groupList[date],'lineCode'));
  125 +
  126 + subData=[];
  127 + $.each(lineCodeArr, function(i, code){
  128 + subData.push({
  129 + value: line2Reate[code]==null?0:line2Reate[code],
  130 + date:date,
  131 + lineCode: code
  132 + });
  133 + });
  134 +
  135 + data.push({
  136 + grid: {x: 30, x2: 5, height: 390, y: 94, y2: 50},
  137 + tooltip: {'trigger': 'axis'},
  138 + toolbox: {'show': false},
  139 + calculable: true,
  140 + xAxis: [{
  141 + 'type': 'category',
  142 + 'data': xAxisData
  143 + }],
  144 + yAxis: {
  145 + 'type': 'value',
  146 + 'name': '发车率',
  147 + },
  148 + title: {
  149 + text: date + '发车率',
  150 + subtext: '实际排班车辆的实发数据'
  151 + },
  152 + text: date + '发车率',
  153 + series: [{
  154 + type: 'bar',
  155 + data: subData
  156 + }]
  157 + });
  158 + }
  159 +
  160 + $('.load-panel', modal).hide();
  161 + $('#countBtn', modal).removeAttr('disabled');
  162 + gb_option.options=data;
  163 + console.log(gb_option);
  164 + chartObj.setOption(gb_option);
  165 + });
  166 + }
  167 +
  168 + function chartObjClickHandler(obj) {
  169 + if(obj.componentType!='series' || obj.componentSubType!='bar')
  170 + return;
  171 +
  172 + var lineGroupData=gb_common.groupBy(renderData[obj.data.date],'lineCode');
  173 + var list=lineGroupData[obj.data.lineCode];
  174 + //console.log('show list', list);
  175 +
  176 + $.get('/real_control_v2/fragments/north/nav/charts/car_out_rate_detail.html', function(htmlStr){
  177 + $(document.body).append(htmlStr);
  178 + var detailModal='#car-out-rate-detail-modal';
  179 + var elem = UIkit.modal(detailModal, {bgclose: true,modal:false}).show();
  180 + $(detailModal).trigger('init', {list: list});
  181 + })
  182 + }
  183 + })();
  184 + </script>
  185 +</div>
src/main/resources/static/real_control_v2/fragments/north/nav/charts/car_out_rate_detail.html 0 → 100644
  1 +<div class="uk-modal" id="car-out-rate-detail-modal">
  2 + <div class="uk-modal-dialog" style="width: 450px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div style="margin:5px 0 -18px;">
  5 + <table class="ct-fixed-table uk-table uk-table-hover">
  6 + <thead>
  7 + <tr>
  8 + <th style="width: 25%;">日期</th>
  9 + <th style="width: 25%;">线路</th>
  10 + <th style="width: 25%;">车辆</th>
  11 + <th style="width: 25%;">首个实际发车</th>
  12 + </tr>
  13 + </thead>
  14 + <tbody>
  15 + </tbody>
  16 + </table>
  17 + </div>
  18 + </div>
  19 +
  20 + <script id="car-out-rate-detail-table-temp" type="text/html">
  21 + {{each list as obj i}}
  22 + <tr>
  23 + <td>{{obj.dateStr}}</td>
  24 + <td>{{obj.lineName}}</td>
  25 + <td>{{obj.nbbm}}</td>
  26 + <td>
  27 + {{if obj.firstOut!=null}}
  28 + {{obj.firstOut}}
  29 + {{else}}
  30 + <div class="uk-badge uk-badge-danger">未出车</div>
  31 + {{/if}}
  32 + </td>
  33 + </tr>
  34 + {{/each}}
  35 + </script>
  36 +
  37 + <script>
  38 + (function() {
  39 + var modal = '#car-out-rate-detail-modal';
  40 +
  41 + $(modal).on('init', function(e, data) {
  42 + //console.log(data.list);
  43 + var code2Name = gb_data_basic.lineCode2NameAll();
  44 + $.each(data.list, function(){
  45 + this.lineName=code2Name[this.lineCode];
  46 + });
  47 +
  48 + data.list.sort(function(a, b){
  49 + if(!a.firstOut)
  50 + return -1;
  51 + if(!b.firstOut)
  52 + return 1;
  53 + return a.firstOut.localeCompare(b.firstOut);
  54 + });
  55 +
  56 + var tbodys=template('car-out-rate-detail-table-temp', {list: data.list});
  57 + $('table tbody', modal).html(tbodys);
  58 + });
  59 + })();
  60 + </script>
  61 +</div>
src/main/resources/static/real_control_v2/fragments/north/nav/charts/device_online_rate.html 0 → 100644
  1 +<div class="uk-modal" id="device-online-rate-modal">
  2 + <div class="uk-modal-dialog" style="width: 1200px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div class="uk-modal-header">
  5 + <h2>设备上线率</h2></div>
  6 +
  7 + <div class="uk-panel uk-panel-box uk-panel-box-primary" style="margin-bottom: 10px;">
  8 + <form class="uk-form search-form">
  9 + <fieldset data-uk-margin>
  10 + <div class="uk-form-icon">
  11 + <i class="uk-icon-calendar"></i>
  12 + <input type="month" id="monthInput">
  13 + </div>
  14 + <button class="uk-button" id="countBtn" >统计</button>
  15 + </fieldset>
  16 + </form>
  17 + </div>
  18 +
  19 + <div class="chart-wrap" style="height: 570px;">
  20 +
  21 + </div>
  22 +
  23 + <div class="load-panel">
  24 + <i class="uk-icon-spinner uk-icon-spin"></i>
  25 + 正在汇总数据
  26 + </div>
  27 + </div>
  28 +
  29 + <script>
  30 + (function () {
  31 +
  32 + var modal = '#device-online-rate-modal';
  33 + var chartObj;
  34 +
  35 +
  36 + var gb_option = {
  37 + timeline: {
  38 + axisType: 'category',
  39 + label: {
  40 + formatter: function (s, a) {
  41 + return s.slice(8).length==1?'0'+s.slice(8):s.slice(8);
  42 + }
  43 + },
  44 + x: 20,
  45 + x2: 5
  46 + }
  47 + };
  48 +
  49 +
  50 + $(modal).on('init', function (e, data) {
  51 + //默认当前月
  52 + var m = moment().format('YYYY-MM')
  53 + $('#monthInput', modal).val(m);
  54 +
  55 + chartObj = echarts.init($('.chart-wrap', modal)[0]);
  56 + chartObj.on('click', chartObjClickHandler);
  57 + renderChart();
  58 +
  59 + });
  60 +
  61 +
  62 + //计算上线率
  63 + function calcOnlineRate(data){
  64 + var line2Reate={}, eff;
  65 + for(var lineCode in data){
  66 + eff=0;
  67 + $.each(data[lineCode], function(){
  68 + if(this.online)
  69 + eff++;
  70 + });
  71 +
  72 + line2Reate[lineCode]=(eff/data[lineCode].length*100).toFixed(2);
  73 + }
  74 +
  75 + return line2Reate;
  76 + }
  77 +
  78 + $('#countBtn', modal).on('click', renderChart);
  79 +
  80 + var renderData;
  81 + function renderChart(){
  82 + //时间轴数据
  83 + var lastdate = moment().format('DD')
  84 + ,month = $('#monthInput', modal).val();
  85 + if(month!=moment().format('YYYY-MM')){
  86 + //不是当前月
  87 + lastdate = new Date(month.split('-')[0],month.split('-')[1],0).getDate();
  88 + }
  89 +
  90 + var timeData = [];
  91 + for (var i = 0; i < lastdate; i++)
  92 + timeData.push(month + '-' + (i + 1));
  93 + //时间轴
  94 + gb_option.timeline.data = timeData;
  95 + gb_option.timeline.currentIndex=timeData.length-1;
  96 +
  97 + //xAxis
  98 + var xAxisData=[],lineCodeArr=[];
  99 + $.each(gb_data_basic.activeLines, function(){
  100 + xAxisData.push(this.name);
  101 + lineCodeArr.push(this.lineCode);
  102 + });
  103 +
  104 +
  105 + $('.load-panel', modal).show();
  106 + $('#countBtn', modal).attr('disabled', 'disabled');
  107 + //统计数据
  108 + gb_common.$get('/realCharts/deviceOnlineRate', {idx: gb_data_basic.line_idx, month: $('#monthInput', modal).val()}, function (rs) {
  109 + if(!rs || rs.length==0){
  110 + notify_err("缺少" + month + "的数据");
  111 + $('.load-panel', modal).hide();
  112 + $('#countBtn', modal).removeAttr('disabled');
  113 + return;
  114 + }
  115 +
  116 + //分组数据,统计上线率
  117 + var groupList=gb_common.groupBy(rs, 'dateStr')
  118 + ,data=[], opt={};
  119 +
  120 + renderData=groupList;
  121 + var subData;
  122 + for(var date in groupList){
  123 + //lineCode再次分组,计算上线率
  124 + var line2Reate=calcOnlineRate(gb_common.groupBy(groupList[date],'lineCode'));
  125 +
  126 + subData=[];
  127 + $.each(lineCodeArr, function(i, str){
  128 + subData.push({
  129 + value: line2Reate[str]==null?0:line2Reate[str],
  130 + date:date,
  131 + lineCode: str
  132 + });
  133 + });
  134 +
  135 + data.push({
  136 + grid: {x: 30, x2: 5, height: 390, y: 94, y2: 50},
  137 + tooltip: {'trigger': 'axis'},
  138 + toolbox: {'show': false},
  139 + calculable: true,
  140 + xAxis: [{
  141 + 'type': 'category',
  142 + 'data': xAxisData
  143 + }],
  144 + yAxis: {
  145 + 'type': 'value',
  146 + 'name': '上线率',
  147 + },
  148 + title: {
  149 + text: date + '设备上线率',
  150 + subtext: '实际排班结合GPS历史信号源'
  151 + },
  152 + text: date + '设备上线率',
  153 + series: [{
  154 + type: 'bar',
  155 + data: subData
  156 + }]
  157 + });
  158 + }
  159 +
  160 + $('.load-panel', modal).hide();
  161 + $('#countBtn', modal).removeAttr('disabled');
  162 + gb_option.options=data;
  163 +
  164 + chartObj.setOption(gb_option);
  165 + });
  166 + }
  167 +
  168 + function chartObjClickHandler(obj) {
  169 + if(obj.componentType!='series' || obj.componentSubType!='bar')
  170 + return;
  171 +
  172 + var lineGroupData=gb_common.groupBy(renderData[obj.data.date],'lineCode');
  173 + var list=lineGroupData[obj.data.lineCode];
  174 + //console.log('show list', list);
  175 +
  176 + $.get('/real_control_v2/fragments/north/nav/charts/device_online_rate_detail.html', function(htmlStr){
  177 + $(document.body).append(htmlStr);
  178 + var detailModal='#device-online-rate-detail-modal';
  179 + var elem = UIkit.modal(detailModal, {bgclose: true,modal:false}).show();
  180 + $(detailModal).trigger('init', {list: list});
  181 + })
  182 + }
  183 + })();
  184 + </script>
  185 +</div>
src/main/resources/static/real_control_v2/fragments/north/nav/charts/device_online_rate_detail.html 0 → 100644
  1 +<div class="uk-modal" id="device-online-rate-detail-modal">
  2 + <div class="uk-modal-dialog" style="width: 450px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div style="margin:5px 0 -18px;">
  5 + <table class="ct-fixed-table uk-table uk-table-hover">
  6 + <thead>
  7 + <tr>
  8 + <th style="width: 25%;">日期</th>
  9 + <th style="width: 25%;">线路</th>
  10 + <th style="width: 25%;">车辆</th>
  11 + <th style="width: 25%;">是否上线</th>
  12 + </tr>
  13 + </thead>
  14 + <tbody>
  15 + </tbody>
  16 + </table>
  17 + </div>
  18 + </div>
  19 +
  20 + <script id="device-online-rate-detail-table-temp" type="text/html">
  21 + {{each list as obj i}}
  22 + <tr>
  23 + <td>{{obj.dateStr}}</td>
  24 + <td>{{obj.lineName}}</td>
  25 + <td>{{obj.nbbm}}</td>
  26 + <td>
  27 + {{if obj.online}}
  28 + <div class="uk-badge">上线</div>
  29 + {{else}}
  30 + <div class="uk-badge uk-badge-danger">未上线</div>
  31 + {{/if}}
  32 + </td>
  33 + </tr>
  34 + {{/each}}
  35 + </script>
  36 +
  37 + <script>
  38 + (function() {
  39 + var modal = '#device-online-rate-detail-modal';
  40 +
  41 + $(modal).on('init', function(e, data) {
  42 + //console.log(data.list);
  43 + var code2Name = gb_data_basic.lineCode2NameAll();
  44 + $.each(data.list, function(){
  45 + this.lineName=code2Name[this.lineCode];
  46 + });
  47 +
  48 + var tbodys=template('device-online-rate-detail-table-temp', {list: data.list});
  49 + $('table tbody', modal).html(tbodys);
  50 + });
  51 + })();
  52 + </script>
  53 +</div>
src/main/resources/static/real_control_v2/fragments/north/nav/directive_history.html
1 <div class="uk-modal" id="directive-history-modal"> 1 <div class="uk-modal" id="directive-history-modal">
2 - <div class="uk-modal-dialog" style="width: 940px;"> 2 + <div class="uk-modal-dialog" style="width: 1040px;">
3 <a href="" class="uk-modal-close uk-close"></a> 3 <a href="" class="uk-modal-close uk-close"></a>
4 <div class="uk-modal-header"> 4 <div class="uk-modal-header">
5 <h2>指令下发记录</h2></div> 5 <h2>指令下发记录</h2></div>
@@ -34,9 +34,9 @@ @@ -34,9 +34,9 @@
34 <table class="ct-fixed-table uk-table uk-table-hover"> 34 <table class="ct-fixed-table uk-table uk-table-hover">
35 <thead> 35 <thead>
36 <tr> 36 <tr>
37 - <th style="width: 7%;">时间</th>  
38 - <th style="width: 10%;">车辆</th>  
39 - <th style="width: 39%;">指令内容</th> 37 + <th style="width: 6%;">时间</th>
  38 + <th style="width: 8%;">车辆</th>
  39 + <th style="width: 44%;">指令内容</th>
40 <th style="width: 7%;">发送人</th> 40 <th style="width: 7%;">发送人</th>
41 <th style="width: 15%;">状态</th> 41 <th style="width: 15%;">状态</th>
42 </tr> 42 </tr>
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 <td> 57 <td>
58 <span title="{{obj.data.txtContent}}">{{obj.data.txtContent}}</span> 58 <span title="{{obj.data.txtContent}}">{{obj.data.txtContent}}</span>
59 </td> 59 </td>
60 - <td>{{obj.sender}}</td> 60 + <td>{{obj.sender}}{{if obj.event != null}}<span class="device_event_str">{{obj.event}}</span>{{/if}}</td>
61 <td> 61 <td>
62 {{if obj.errorText != null}} 62 {{if obj.errorText != null}}
63 <div class="uk-badge uk-badge-danger"> {{obj.errorText}}</div> 63 <div class="uk-badge uk-badge-danger"> {{obj.errorText}}</div>
@@ -133,6 +133,13 @@ @@ -133,6 +133,13 @@
133 data.size = pageSize; 133 data.size = pageSize;
134 134
135 $.get('/directive/list', data, function(rs) { 135 $.get('/directive/list', data, function(rs) {
  136 + $.each(rs.list, function(i, e){
  137 + if(e.sender && e.sender.indexOf('@') != -1){
  138 + var ss = e.sender.split('@');
  139 + e.sender = ss[1];
  140 + e.event = ss[0];
  141 + }
  142 + });
136 var bodyHtml = template('directive-history-table-temp', { 143 var bodyHtml = template('directive-history-table-temp', {
137 list: rs.list 144 list: rs.list
138 }); 145 });
src/main/resources/static/real_control_v2/fragments/north/nav/report_80.html 0 → 100644
  1 +<div class="uk-modal" id="report-80-modal">
  2 + <div class="uk-modal-dialog" style="width: 960px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div class="uk-modal-header">
  5 + <h2>设备消息上报记录</h2></div>
  6 +
  7 + <div class="uk-panel uk-panel-box uk-panel-box-primary">
  8 + <form class="uk-form search-form">
  9 + <fieldset data-uk-margin>
  10 + <legend>
  11 + 数据检索
  12 + </legend>
  13 + <span class="horizontal-field">请求代码</span>
  14 + <select name="requestCode">
  15 + <option value="-1">全部</option>
  16 + </select>
  17 + <span class="horizontal-field">车辆</span>
  18 + <div class="uk-autocomplete uk-form autocomplete-cars" >
  19 + <input type="text" name="nbbm" placeholder="车辆自编号">
  20 + </div>
  21 +
  22 + <button class="uk-button">检索</button>
  23 + </fieldset>
  24 + </form>
  25 + </div>
  26 + <div style="height: 495px;margin:5px 0 -18px;">
  27 + <table class="ct-fixed-table uk-table uk-table-hover">
  28 + <thead>
  29 + <tr>
  30 + <th style="width: 15%;">线路</th>
  31 + <th style="width: 15%;">车辆</th>
  32 + <th style="width: 12%;">时间</th>
  33 + <th style="width: 24%;">请求代码</th>
  34 + <th style="width: 12%;">处理人</th>
  35 + <th style="width: 12%;">处理时间</th>
  36 + <th style="width: 10%;">处理结果</th>
  37 + </tr>
  38 + </thead>
  39 + <tbody>
  40 + </tbody>
  41 + </table>
  42 + </div>
  43 + <div class="uk-modal-footer uk-text-right pagination-wrap">
  44 + </div>
  45 + </div>
  46 +
  47 + <script id="report-80-modal-table-temp" type="text/html">
  48 + {{each list as obj i}}
  49 + <tr>
  50 + <td>{{obj.lineName}}</td>
  51 + <td>{{obj.data.nbbm}}</td>
  52 + <td>{{obj.timeStr}}</td>
  53 + <td>{{obj.text}}</td>
  54 + <td>{{obj.handleUser}}</td>
  55 + {{if obj.c0 != null && obj.c0.data != null}}
  56 + <td>{{obj.handleTimeStr}}</td>
  57 + <td>
  58 + {{if obj.c0.data.requestAck==6 }}
  59 + <span class="label label-sm label-success"> 同意</span>
  60 + {{else if obj.c0.data.requestAck==21 }}
  61 + <span class="label label-sm label-danger"> 不同意</span>
  62 + {{/if}}
  63 + </td>
  64 + {{else}}
  65 + <td></td>
  66 + <td><span class="label label-sm label-warning"> 未处理</span></td>
  67 + {{/if}}
  68 + </tr>
  69 + {{/each}}
  70 + </script>
  71 +
  72 + <script>
  73 + (function() {
  74 + var modal = '#report-80-modal';
  75 + var form = $('.search-form', modal);
  76 + var page = 0;
  77 + var pageSize = 12;
  78 +
  79 + $(modal).on('init', function(e, data) {
  80 + var opt='';
  81 + for(var code in gb_common.reqCode80){
  82 + opt+='<option value="'+code+'">'+gb_common.reqCode80[code]+'</option>';
  83 + }
  84 + $('[name=requestCode]', modal).append(opt);
  85 + //车辆 autocomplete
  86 + $.get('/basic/cars', function(rs) {
  87 + gb_common.carAutocomplete($('.autocomplete-cars', modal), rs);
  88 + });
  89 + query();
  90 + });
  91 +
  92 + //sumit event
  93 + form.on('submit', function(e) {
  94 + e.preventDefault();
  95 + resetPagination = true;
  96 + query();
  97 + });
  98 +
  99 + var query = function() {
  100 + var data = form.serializeJSON();
  101 + data.page = page;
  102 + data.size = pageSize;
  103 + $.get('/directive/findAll80', data, function(rs) {
  104 + $.each(rs.list, function(){
  105 + //命令字转中文
  106 + this.text = gb_common.reqCode80[this.data.requestCode];
  107 + if(!this.text)
  108 + this.text='未知的请求码('+this.data.requestCode+')';
  109 + if(this.handleTime)
  110 + this.handleTimeStr = moment(this.handleTime).format('HH:mm');
  111 + //线路名转换
  112 + this.lineName = this.data.lineId+'/'+gb_data_basic.lineCode2NameAll()[this.data.lineId];
  113 + });
  114 + var bodyHtml = template('report-80-modal-table-temp', {
  115 + list: rs.list
  116 + });
  117 + $('table tbody', modal).html(bodyHtml);
  118 +
  119 + //pagination
  120 + if (resetPagination)
  121 + pagination(rs.totalPages + 1, rs.page);
  122 + })
  123 + }
  124 +
  125 + var resetPagination = true;
  126 + var pagination = function(pages, currentPage) {
  127 + var wrap = $('.pagination-wrap', modal).empty()
  128 + ,e = $('<ul class="uk-pagination"></ul>').appendTo(wrap);
  129 +
  130 + var pagination = UIkit.pagination(e, {
  131 + pages: pages,
  132 + currentPage: currentPage
  133 + });
  134 +
  135 + e.on('select.uk.pagination', function(e, pageIndex){
  136 + page = pageIndex;
  137 + query();
  138 + });
  139 +
  140 + resetPagination = false;
  141 + }
  142 +
  143 + })();
  144 + </script>
  145 +</div>
src/main/resources/static/real_control_v2/fragments/north/tabs.html
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <li class="uk-active" ><a>主页</a></li> 4 <li class="uk-active" ><a>主页</a></li>
5 <li class=""><a>地图</a></li> 5 <li class=""><a>地图</a></li>
6 {{each list as line i}} 6 {{each list as line i}}
7 - <li class="tab-line"><a>{{line.name}}(0, <span id="badge_yfwf_num_{{line.lineCode}}">0</span>)</a></li> 7 + <li class="tab-line"><a>{{line.name}}(<span id="badge_untreated_num_{{line.lineCode}}">0</span>, <span id="badge_yfwf_num_{{line.lineCode}}">0</span>)</a></li>
8 {{/each}} 8 {{/each}}
9 </ul> 9 </ul>
10 </script> 10 </script>
src/main/resources/static/real_control_v2/js/common.js
@@ -178,16 +178,6 @@ var gb_common = (function() { @@ -178,16 +178,6 @@ var gb_common = (function() {
178 178
179 var personAutocomplete = function(element, personMaps) { 179 var personAutocomplete = function(element, personMaps) {
180 var data = [],name; 180 var data = [],name;
181 - // $.each(personList, function(){  
182 - // name=this.personnelName;  
183 - // data.push({  
184 - // value: this.jobCode+'/'+name,  
185 - // fullChars: pinyin.getFullChars(name).toUpperCase(),  
186 - // camelChars: pinyin.getCamelChars(name),  
187 - // brancheCompany: this.brancheCompany  
188 - // });  
189 - // });  
190 - // console.log('data', data);  
191 for(var jobCode in personMaps){ 181 for(var jobCode in personMaps){
192 name=personMaps[jobCode]; 182 name=personMaps[jobCode];
193 data.push({ 183 data.push({
@@ -284,7 +274,8 @@ var gb_common = (function() { @@ -284,7 +274,8 @@ var gb_common = (function() {
284 get_device_tree_data: get_device_tree_data, 274 get_device_tree_data: get_device_tree_data,
285 lineAutocomplete: lineAutocomplete, 275 lineAutocomplete: lineAutocomplete,
286 personAutocomplete: personAutocomplete, 276 personAutocomplete: personAutocomplete,
287 - carAutocomplete: carAutocomplete 277 + carAutocomplete: carAutocomplete,
  278 + init_autocomplete: init_autocomplete
288 279
289 //whichTransitionEvent:whichTransitionEvent 280 //whichTransitionEvent:whichTransitionEvent
290 }; 281 };
src/main/resources/static/real_control_v2/js/data/json/back
1 -[{  
2 - "id": 1,  
3 - "text": "基础数据",  
4 - "children": [{  
5 - "id": 1.1,  
6 - "text": "线路",  
7 - "event": ""  
8 - }, {  
9 - "id": 1.2,  
10 - "text": "人员",  
11 - "event": ""  
12 - }, {  
13 - "id": 1.3,  
14 - "text": "车辆",  
15 - "event": ""  
16 - }, {  
17 - "id": 1.4,  
18 - "text": "线路配置",  
19 - "header": true  
20 - }, {  
21 - "id": 1.5,  
22 - "text": "人员配置",  
23 - "event": "" 1 +[ {
  2 + "id": 1,
  3 + "text": "数据&统计",
  4 + "children": [
  5 + {
  6 + "id": 1.1,
  7 + "text": "统计分析",
  8 + "header": 1
  9 + },
  10 + {
  11 + "id": 1.2,
  12 + "text": "出车率",
  13 + "event": "turnout_rate"
  14 + },
  15 + {
  16 + "id": 1.3,
  17 + "text": "设备上线率",
  18 + "event": "device_online_rate"
  19 + },
  20 + {
  21 + "id": 1.4,
  22 + "text": "首末班次准点率",
  23 + "event": "s_e_punctuality_rate"
  24 + },{
  25 + "id": 1.5,
  26 + "text": "班次执行率",
  27 + "event": "sch_execution_rate"
  28 + }
  29 + ]
24 }, { 30 }, {
25 - "id": 1.6,  
26 - "text": "车辆配置",  
27 - "event": ""  
28 - }, {  
29 - "id": 1.7,  
30 - "divider": true  
31 - }, {  
32 - "id": 1.8,  
33 - "text": "计划排班",  
34 - "event": ""  
35 - }]  
36 -}, {  
37 "id": 2, 31 "id": 2,
38 "text": "车载设备", 32 "text": "车载设备",
39 "children": [{ 33 "children": [{
src/main/resources/static/real_control_v2/js/data/json/north_toolbar.json
1 -[{ 1 +[
  2 + {
2 "id": 1, 3 "id": 1,
3 - "text": "基础数据"  
4 -}, { 4 + "text": "数据&统计",
  5 + "children": [
  6 + {
  7 + "id": 1.1,
  8 + "text": "统计分析",
  9 + "header": 1
  10 + },
  11 + {
  12 + "id": 1.2,
  13 + "text": "出车率",
  14 + "event": "turnout_rate"
  15 + },
  16 + {
  17 + "id": 1.3,
  18 + "text": "设备上线率",
  19 + "event": "device_online_rate"
  20 + }
  21 + ]
  22 + },
  23 + {
5 "id": 2, 24 "id": 2,
6 "text": "车载设备", 25 "text": "车载设备",
7 "children": [ 26 "children": [
8 { 27 {
  28 + "id": 2.1,
  29 + "text": "设备管理",
  30 + "event": "all_devices"
  31 + },
  32 + {
9 "id": 2.3, 33 "id": 2.3,
10 "text": "指令下发记录", 34 "text": "指令下发记录",
11 "event": "directive_history" 35 "event": "directive_history"
12 - }]  
13 -}, { 36 + },
  37 + {
  38 + "id": 2.2,
  39 + "text": "设备上报记录",
  40 + "event": "device_report"
  41 + }
  42 + ]
  43 + },
  44 + {
14 "id": 3, 45 "id": 3,
15 "text": "系统设置", 46 "text": "系统设置",
16 - "children": [{ 47 + "children": [
  48 + {
17 "id": 3.1, 49 "id": 3.1,
18 "text": "TTS", 50 "text": "TTS",
19 "event": "tts_config" 51 "event": "tts_config"
20 - }]  
21 -}] 52 + }
  53 + ]
  54 + }
  55 +]
src/main/resources/static/real_control_v2/js/home/context_menu.js
@@ -144,7 +144,7 @@ var gb_home_context_menu = (function() { @@ -144,7 +144,7 @@ var gb_home_context_menu = (function() {
144 144
145 var state_down_0 = function() { 145 var state_down_0 = function() {
146 changeUpDown(active_car, 1); 146 changeUpDown(active_car, 1);
147 - } 147 + };
148 148
149 var line_change = function() { 149 var line_change = function() {
150 var dom = temps['line-change-modal-temp']({ 150 var dom = temps['line-change-modal-temp']({
@@ -169,15 +169,16 @@ var gb_home_context_menu = (function() { @@ -169,15 +169,16 @@ var gb_home_context_menu = (function() {
169 data.lineId = lineCode; 169 data.lineId = lineCode;
170 $.post('/directive/lineChnage', data, function(rs){ 170 $.post('/directive/lineChnage', data, function(rs){
171 if(rs == 0) 171 if(rs == 0)
172 - notify_succ('指令已发出!'); 172 + notify_succ('指令已发出!');
173 else 173 else
174 - notify_err('指令发送失败!'); 174 + notify_err('指令发送失败!');
175 175
176 elem.hide(); 176 elem.hide();
177 }); 177 });
178 } 178 }
179 - })  
180 - } 179 + });
  180 + };
  181 +
181 182
182 var C0_A3 = function(){ 183 var C0_A3 = function(){
183 open_modal('/real_control_v2/fragments/home/c0_a3.html', {}, {center: false, bgclose: false}); 184 open_modal('/real_control_v2/fragments/home/c0_a3.html', {}, {center: false, bgclose: false});
@@ -231,4 +232,6 @@ var gb_home_context_menu = (function() { @@ -231,4 +232,6 @@ var gb_home_context_menu = (function() {
231 } 232 }
232 } 233 }
233 }); 234 });
  235 +
  236 + return {line_change: line_change}
234 })(); 237 })();
src/main/resources/static/real_control_v2/js/line_schedule/sch_table.js
@@ -121,6 +121,8 @@ var gb_schedule_table = (function() { @@ -121,6 +121,8 @@ var gb_schedule_table = (function() {
121 $('.schedule-wrap .card-panel:eq(' + upDown + ')', tabCont).html(htmlStr); 121 $('.schedule-wrap .card-panel:eq(' + upDown + ')', tabCont).html(htmlStr);
122 } 122 }
123 calc_yfwf_num(sch.xlBm); 123 calc_yfwf_num(sch.xlBm);
  124 + //重新固定表头
  125 + gb_ct_table.fixedHead($('.line_schedule .ct_table_wrap'));
124 //定位到新添加的班次 126 //定位到新添加的班次
125 scroToDl(sch); 127 scroToDl(sch);
126 } 128 }
@@ -155,7 +157,9 @@ var gb_schedule_table = (function() { @@ -155,7 +157,9 @@ var gb_schedule_table = (function() {
155 var dl = $('li.line_schedule[data-id=' + sch.xlBm + '] .ct_table_body dl[data-id=' + sch.id + ']'); 157 var dl = $('li.line_schedule[data-id=' + sch.xlBm + '] .ct_table_body dl[data-id=' + sch.id + ']');
156 var dds = $('dd', dl); 158 var dds = $('dd', dl);
157 $(dds[1]).find('a').text(sch.lpName); 159 $(dds[1]).find('a').text(sch.lpName);
158 - $(dds[2]).data('nbbm', sch.clZbh).text(sch.clZbh); 160 +
  161 + //车辆自编号
  162 + $(dds[2]).replaceWith(temps['line-schedule-nbbm-temp'](sch));
159 if (sch.qdzArrDateJH) 163 if (sch.qdzArrDateJH)
160 $(dds[3]).text(sch.qdzArrDateJH); 164 $(dds[3]).text(sch.qdzArrDateJH);
161 165
src/main/resources/static/real_control_v2/js/main.js
1 /* main js */ 1 /* main js */
2 -  
3 var gb_main_ep = new EventProxy(), 2 var gb_main_ep = new EventProxy(),
4 res_load_ep = EventProxy.create('load_data_basic', 'load_tab', 'load_home_layout', 'load_home_line_panel', function() { 3 res_load_ep = EventProxy.create('load_data_basic', 'load_tab', 'load_home_layout', 'load_home_line_panel', function() {
5 var eq = gb_main_ep; 4 var eq = gb_main_ep;
@@ -105,8 +104,8 @@ var alt_confirm = function(content, succ, okBtn) { @@ -105,8 +104,8 @@ var alt_confirm = function(content, succ, okBtn) {
105 labels: { 104 labels: {
106 Ok: okBtn, 105 Ok: okBtn,
107 Cancel: '取消' 106 Cancel: '取消'
108 - },  
109 - center: true 107 + }
  108 + ,center: true
110 }); 109 });
111 } 110 }
112 111
src/main/resources/static/real_control_v2/js/north/toolbar.js
@@ -40,15 +40,25 @@ var gb_northToolbar = (function() { @@ -40,15 +40,25 @@ var gb_northToolbar = (function() {
40 var handler = { 40 var handler = {
41 // device report list 41 // device report list
42 device_report: function(){ 42 device_report: function(){
43 - $.get('/directive/findAll80', {requestCode: -1}, function(rs){ 43 + /*$.get('/directive/findAll80', {requestCode: -1}, function(rs){
44 console.log(rs); 44 console.log(rs);
45 - }); 45 + });*/
  46 + open_modal('/real_control_v2/fragments/north/nav/report_80.html', {}, modal_opts);
46 }, 47 },
47 directive_history: function(){ 48 directive_history: function(){
48 open_modal('/real_control_v2/fragments/north/nav/directive_history.html', {}, modal_opts); 49 open_modal('/real_control_v2/fragments/north/nav/directive_history.html', {}, modal_opts);
49 }, 50 },
50 tts_config: function(){ 51 tts_config: function(){
51 open_modal('/real_control_v2/fragments/north/nav/tts_config.html', {}, modal_opts); 52 open_modal('/real_control_v2/fragments/north/nav/tts_config.html', {}, modal_opts);
  53 + },
  54 + all_devices: function(){
  55 + open_modal('/real_control_v2/fragments/north/nav/all_devices.html', {}, modal_opts);
  56 + },
  57 + device_online_rate: function(){
  58 + open_modal('/real_control_v2/fragments/north/nav/charts/device_online_rate.html', {}, modal_opts);
  59 + },
  60 + turnout_rate: function () {
  61 + open_modal('/real_control_v2/fragments/north/nav/charts/car_out_rate.html', {}, modal_opts);
52 } 62 }
53 } 63 }
54 })(); 64 })();
src/main/resources/static/real_control_v2/js/utils/ct_table.js
1 var gb_ct_table = (function() { 1 var gb_ct_table = (function() {
2 function fixedHead($wrap) { 2 function fixedHead($wrap) {
  3 +
3 $wrap.off('scroll').on('scroll', function() { 4 $wrap.off('scroll').on('scroll', function() {
4 var top = $(this).scrollTop(); 5 var top = $(this).scrollTop();
5 //fixed head 6 //fixed head
src/main/resources/static/real_control_v2/js/utils/tts.js
@@ -32,7 +32,13 @@ var gb_tts = (function() { @@ -32,7 +32,13 @@ var gb_tts = (function() {
32 if (defaultConfig.queueModel == 1) 32 if (defaultConfig.queueModel == 1)
33 synth.cancel(); 33 synth.cancel();
34 34
35 - t = gb_data_basic.codeToLine[lineCode].name + t; 35 + var lineName=gb_data_basic.codeToLine[lineCode].name;
  36 + try {
  37 + if (lineName)
  38 + lineName.replace('行', '航');
  39 + } catch (e) {}
  40 +
  41 + t = lineName + t;
36 //延迟100毫秒,防止中断旧语音时 将新的语音也中断 42 //延迟100毫秒,防止中断旧语音时 将新的语音也中断
37 setTimeout(function() { 43 setTimeout(function() {
38 var msg = new SpeechSynthesisUtterance(t); 44 var msg = new SpeechSynthesisUtterance(t);
src/main/resources/static/real_control_v2/js/websocket/sch_websocket.js
1 -var gb_sch_websocket = (function() { 1 +var gb_sch_websocket = (function () {
2 2
3 var temps; 3 var temps;
4 - $.get('/real_control_v2/fragments/line_schedule/sys_mailbox.html', function(dom) { 4 + $.get('/real_control_v2/fragments/line_schedule/sys_mailbox.html', function (dom) {
5 temps = gb_common.compileTempByDom(dom); 5 temps = gb_common.compileTempByDom(dom);
6 }); 6 });
7 7
8 var schSock = new SockJS('/sockjs/realcontrol'); 8 var schSock = new SockJS('/sockjs/realcontrol');
9 9
10 - schSock.onopen = function(e) { 10 + schSock.onopen = function (e) {
11 console.log('webSocket[realcontrol] onopen'); 11 console.log('webSocket[realcontrol] onopen');
12 setTimeout(regListen, 500); 12 setTimeout(regListen, 500);
13 }; 13 };
14 //接收消息 14 //接收消息
15 - schSock.onmessage = function(e) { 15 + schSock.onmessage = function (e) {
16 try { 16 try {
17 var jsonMsg = $.parseJSON(e.data); 17 var jsonMsg = $.parseJSON(e.data);
18 msgHandle[jsonMsg.fn](jsonMsg); 18 msgHandle[jsonMsg.fn](jsonMsg);
@@ -21,8 +21,8 @@ var gb_sch_websocket = (function() { @@ -21,8 +21,8 @@ var gb_sch_websocket = (function() {
21 } 21 }
22 }; 22 };
23 23
24 - function regListen (){  
25 - //注册线路监听 24 + function regListen() {
  25 + //注册线路监听
26 var data = { 26 var data = {
27 operCode: 'register_line', 27 operCode: 'register_line',
28 idx: gb_data_basic.line_idx 28 idx: gb_data_basic.line_idx
@@ -32,32 +32,52 @@ var gb_sch_websocket = (function() { @@ -32,32 +32,52 @@ var gb_sch_websocket = (function() {
32 } 32 }
33 33
34 //断开 34 //断开
35 - schSock.onclose = function(e) { 35 + schSock.onclose = function (e) {
36 alert('和服务器连接断开....'); 36 alert('和服务器连接断开....');
37 console.log('和服务器连接断开....'); 37 console.log('和服务器连接断开....');
38 regListen(); 38 regListen();
39 39
40 }; 40 };
41 41
  42 +
  43 + /**
  44 + * 计算未处理消息
  45 + */
  46 + var calcUntreated = function (lineCode) {
  47 + var size = $('li.line_schedule[data-id=' + lineCode + '] .sys-mailbox .sys-mail-item').length;
  48 + $('#badge_untreated_num_' + lineCode).text(size);
  49 + }
  50 +
  51 + var calcUntreatedAll = function () {
  52 + $('#main-tab-content li.line_schedule').each(function () {
  53 + calcUntreated($(this).data('id'));
  54 + });
  55 + }
  56 +
  57 +
42 //80协议上报 58 //80协议上报
43 - var report80 = function(msg) {  
44 - msg.dateStr = moment(msg.timestamp).format('HH:mm');  
45 - msg.text = gb_common.reqCode80[msg.data.requestCode];  
46 -  
47 - var $item=$(temps['sys-note-80-temp'](msg));  
48 - findMailBox(msg.data.lineId).prepend($item);  
49 - //tts  
50 - var ttsMsg=$item.find('.uk-panel-title').text();  
51 - gb_tts.speak(ttsMsg, msg.data.lineId); 59 + var report80 = function (msg) {
  60 + msg.dateStr = moment(msg.timestamp).format('HH:mm');
  61 + msg.text = gb_common.reqCode80[msg.data.requestCode];
  62 + if(!msg.text)
  63 + msg.text='(未知的请求码 '+msg.data.requestCode+')';
  64 +
  65 + var $item = $(temps['sys-note-80-temp'](msg));
  66 + findMailBox(msg.data.lineId).prepend($item);
  67 + //tts
  68 + var ttsMsg = $item.find('.uk-panel-title').text();
  69 + gb_tts.speak(ttsMsg, msg.data.lineId);
  70 +
  71 + calcUntreated(msg.data.lineId);
52 } 72 }
53 73
54 var waitRemoves = []; 74 var waitRemoves = [];
55 //车辆发出 75 //车辆发出
56 - var faChe = function(msg) { 76 + var faChe = function (msg) {
57 gb_schedule_table.updateSchedule(msg.t); 77 gb_schedule_table.updateSchedule(msg.t);
58 msg.domId = 'fache_' + msg.t.id + '_' + parseInt(Math.random() * 10000); 78 msg.domId = 'fache_' + msg.t.id + '_' + parseInt(Math.random() * 10000);
59 79
60 - var $item=$(temps['sys-note-42-temp'](msg)); 80 + var $item = $(temps['sys-note-42-temp'](msg));
61 findMailBox(msg.t.xlBm).prepend($item); 81 findMailBox(msg.t.xlBm).prepend($item);
62 waitRemoves.push({ 82 waitRemoves.push({
63 t: currentSecond(), 83 t: currentSecond(),
@@ -65,37 +85,65 @@ var gb_sch_websocket = (function() { @@ -65,37 +85,65 @@ var gb_sch_websocket = (function() {
65 }); 85 });
66 86
67 //tts 87 //tts
68 - var ttsMsg=$item.find('.title').text(); 88 + var ttsMsg = $item.find('.title').text();
69 gb_tts.speak(ttsMsg, msg.t.xlBm); 89 gb_tts.speak(ttsMsg, msg.t.xlBm);
70 gb_schedule_table.calc_yfwf_num(msg.t.xlBm); 90 gb_schedule_table.calc_yfwf_num(msg.t.xlBm);
  91 +
  92 + calcUntreated(msg.t.xlBm);
71 } 93 }
72 94
73 //到达终点 95 //到达终点
74 - var zhongDian = function(msg) { 96 + var zhongDian = function (msg) {
75 gb_schedule_table.updateSchedule(msg.t); 97 gb_schedule_table.updateSchedule(msg.t);
76 msg.domId = 'zhongDian_' + msg.t.id + '_' + parseInt(Math.random() * 10000); 98 msg.domId = 'zhongDian_' + msg.t.id + '_' + parseInt(Math.random() * 10000);
77 99
78 - var $item=$(temps['sys-note-42_1-temp'](msg)); 100 + var $item = $(temps['sys-note-42_1-temp'](msg));
79 findMailBox(msg.t.xlBm).prepend($item); 101 findMailBox(msg.t.xlBm).prepend($item);
80 waitRemoves.push({ 102 waitRemoves.push({
81 t: currentSecond(), 103 t: currentSecond(),
82 dom: msg.domId 104 dom: msg.domId
83 }); 105 });
84 //tts 106 //tts
85 - var ttsMsg=$item.find('.title').text(); 107 + var ttsMsg = $item.find('.title').text();
86 gb_tts.speak(ttsMsg, msg.t.xlBm); 108 gb_tts.speak(ttsMsg, msg.t.xlBm);
  109 +
  110 + calcUntreated(msg.t.xlBm);
87 } 111 }
88 112
89 //服务器通知刷新班次 113 //服务器通知刷新班次
90 - var refreshSch = function(msg) { 114 + var refreshSch = function (msg) {
91 gb_schedule_table.updateSchedule(msg.ts); 115 gb_schedule_table.updateSchedule(msg.ts);
  116 + /*//重新计算应发未发
  117 + var idx={};
  118 + $.each(msg.ts, function(i, t){
  119 + if(idx[t.xlBm])
  120 + return true;
  121 + gb_schedule_table.calc_yfwf_num(t.xlBm);
  122 + idx[t.xlBm]=1;
  123 + });*/
  124 + }
  125 +
  126 + //80消息确认
  127 + var d80Confirm = function (msg) {
  128 + $('.sys-mailbox .sys-note-80[data-id=' + msg.id + ']').remove();
  129 + //重新计算未读消息
  130 + calcUntreated(msg.lineId);
  131 + //重新计算应发未发
  132 + gb_schedule_table.calc_yfwf_num(msg.lineId);
  133 + }
  134 +
  135 + //指令状态改变
  136 + var directiveStatus = function(msg){
  137 + gb_schedule_table.updateSchedule(msg.t);
92 } 138 }
93 139
94 var msgHandle = { 140 var msgHandle = {
95 report80: report80, 141 report80: report80,
96 faChe: faChe, 142 faChe: faChe,
97 zhongDian: zhongDian, 143 zhongDian: zhongDian,
98 - refreshSch: refreshSch 144 + refreshSch: refreshSch,
  145 + d80Confirm: d80Confirm,
  146 + directive: directiveStatus
99 } 147 }
100 148
101 function currentSecond() { 149 function currentSecond() {
@@ -113,11 +161,47 @@ var gb_sch_websocket = (function() { @@ -113,11 +161,47 @@ var gb_sch_websocket = (function() {
113 return mbox; 161 return mbox;
114 } 162 }
115 163
  164 +
  165 + //42确定
  166 + $(document).on('click', '.sys-mailbox .sys-note-42 .uk-button-primary', function () {
  167 + $(this).parents('.sys-note-42').remove();
  168 +
  169 + var size = $(this).parents('.sys-mailbox').find('.sys-mail-item').length
  170 + ,lineCode = $(this).parents('li.line_schedule').data('id');
  171 +
  172 + $('#badge_untreated_num_' + lineCode).text(size);
  173 + });
  174 +
  175 + //80同意
  176 + $(document).on('click', '.sys-mailbox .sys-note-80 .uk-button-primary', function () {
  177 + var panel = $(this).parents('.sys-note-80')
  178 + , id = panel.data('id');
  179 +
  180 + reply80({id: id, reply: 0});
  181 + });
  182 +
  183 + //80不同意
  184 + $(document).on('click', '.sys-mailbox .sys-note-80 .uk-button.reject', function () {
  185 + var panel = $(this).parents('.sys-note-80')
  186 + , id = panel.data('id');
  187 +
  188 + reply80({id: id, reply: -1});
  189 + });
  190 +
  191 + var reply80 = function (data, cb) {
  192 + gb_common.$post('/directive/reply80', data, function (rs) {
  193 + if (rs.msg)
  194 + notify_succ(rs.msg);
  195 + cb && cb();
  196 + });
  197 + }
  198 +
  199 +
116 //定时到离站信使清理掉 200 //定时到离站信使清理掉
117 - ! function() { 201 + !function () {
118 var f = arguments.callee, 202 var f = arguments.callee,
119 ct = Date.parse(new Date()) / 1000, 203 ct = Date.parse(new Date()) / 1000,
120 - item; 204 + item, elem;
121 try { 205 try {
122 for (var i = 0; i < 1000; i++) { 206 for (var i = 0; i < 1000; i++) {
123 if (waitRemoves.length == 0) 207 if (waitRemoves.length == 0)
@@ -125,12 +209,17 @@ var gb_sch_websocket = (function() { @@ -125,12 +209,17 @@ var gb_sch_websocket = (function() {
125 item = waitRemoves[0]; 209 item = waitRemoves[0];
126 if (ct - item.t >= 30) { 210 if (ct - item.t >= 30) {
127 waitRemoves.shift(); 211 waitRemoves.shift();
128 - $('#' + item.dom).remove(); 212 + elem = $('#' + item.dom);
  213 + if (elem)
  214 + elem.remove();
129 } 215 }
130 } 216 }
131 } catch (e) { 217 } catch (e) {
132 console.log(e); 218 console.log(e);
133 } 219 }
  220 +
  221 + //计算未读消息
  222 + calcUntreatedAll();
134 setTimeout(f, 5000); 223 setTimeout(f, 5000);
135 }(); 224 }();
136 225
src/main/resources/static/real_control_v2/main.html
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 <div class="uk-width-4-10"> 38 <div class="uk-width-4-10">
39 <div class="uk-panel"> 39 <div class="uk-panel">
40 <h2 class="north-logo"> 40 <h2 class="north-logo">
41 - <i class="uk-icon-life-ring"></i> 青浦公交线路调度 41 + <i class="uk-icon-life-ring"></i> 闵行公交线路调度
42 </h2> 42 </h2>
43 </div> 43 </div>
44 </div> 44 </div>
@@ -128,6 +128,9 @@ @@ -128,6 +128,9 @@
128 <script src="/real_control_v2/js/websocket/sch_websocket.js"></script> 128 <script src="/real_control_v2/js/websocket/sch_websocket.js"></script>
129 <!-- tts --> 129 <!-- tts -->
130 <script src="/real_control_v2/js/utils/tts.js"></script> 130 <script src="/real_control_v2/js/utils/tts.js"></script>
  131 +
  132 + <!-- echart -->
  133 + <script src="/real_control_v2/assets/echarts-3/echarts.js"></script>
131 </body> 134 </body>
132 135
133 </html> 136 </html>