Commit 53d547bfb8f44b2b22b1af91921568a739d246d6

Authored by 王通
1 parent 27d26c9d

1.2023.03.07系统更新

src/main/java/com/bsth/websocket/handler/RealControlSocketHandler.java
... ... @@ -150,11 +150,11 @@ public class RealControlSocketHandler implements WebSocketHandler {
150 150 * 根据线路推送消息
151 151 */
152 152 public void sendMessageToUser(String userName, String msg) {
153   -
  153 + logger.debug(String.format("userName:%s, msg:%s", userName, msg));
154 154 TextMessage message = new TextMessage(msg.getBytes());
155 155  
156 156 for(WebSocketSession user : users){
157   - if (userName.equals(user.getPrincipal().getName())) {
  157 + if (user != null && user.getPrincipal() != null && userName.equals(user.getPrincipal().getName())) {
158 158 WebSocketPushQueue.put(user, message);
159 159 }
160 160 }
... ...
src/main/resources/static/pages/control/line/js/data.js
1   -/**
2   - * 数据处理模块
3   -*/
4   -var _data = (function(){
5   - var storage = window.localStorage;
6   -
7   - var gpsTimer;
8   -
9   - //实时GPS数据
10   - var allGps = {};
11   - //10秒刷新一次实时GPS
12   - var realGpsT = 1000 * 8;
13   -
14   - var dateStr = moment().format('YYYY-MM-DD');
15   - //实际排班
16   - var schedules = {};
17   -
18   - //站点路由缓存
19   - var stationRoute = {};
20   -
21   - //线路 ——> 路牌 ——> 班次 3层映射
22   - var lineLpMap = {};
23   - //线路标准信息
24   - var lineInformations = {};
25   - //车辆和班次数组映射
26   - //var clSchMap = {};
27   -
28   - //车辆自编号和设备号对照
29   - var carDeviceIdMapp = {};
30   -
31   - var fcsjSort = function(a, b){
32   - return (a.fcno - b.fcno) + (a.fcsjT - b.fcsjT);
33   - }
34   -
35   - var dataObject = {
36   - //根据线路和上下行获取计划排班
37   - findSchByLine: function(xlbm, upDown){
38   - var array = [];
39   - var sch;
40   - for(var id in schedules){
41   - sch = schedules[id];
42   - if(sch.xlBm == xlbm
43   - && sch.xlDir == upDown){
44   - array.push(sch);
45   - }
46   - }
47   - //排序
48   - array.sort(fcsjSort);
49   -
50   - return array;
51   - },
52   - //根据车辆获取班次数组
53   - findByCl: function(nbbm){
54   - var array = [];
55   - for(var id in schedules){
56   - sch = schedules[id];
57   - if(sch.clZbh == nbbm)
58   - array.push(sch);
59   - }
60   -
61   - //排序
62   - array.sort(fcsjSort);
63   - return array;
64   - },
65   - //清理线路下班次
66   - clearByLineCode: function(lineCode){
67   - for(var id in schedules){
68   - if(schedules[id].xlBm == lineCode){
69   - schedules[id] = null;
70   - delete schedules[id];
71   - }
72   - }
73   -
74   - lineLpMap[lineCode] = {};
75   - },
76   - //添加一个班次
77   - pushSchedule: function(sch){
78   - //附加信息
79   - attachInfo(sch);
80   - schedules[sch.id] = sch;
81   -
82   - var xl=sch.xlBm,lp=sch.lpName;
83   - if(!lineLpMap[xl][lp])
84   - lineLpMap[xl][lp] = [];
85   -
86   - lineLpMap[xl][lp].push(sch);
87   - },
88   - //更新班次信息
89   - updateSchedule: function(sch){
90   - //附加信息
91   - attachInfo(sch);
92   - schedules[sch.id] = sch;
93   -
94   - var lpArray = lineLpMap[sch.xlBm][sch.lpName];
95   - $.each(lpArray, function(i){
96   - if(this.id == sch.id){
97   - lpArray.splice(i, 1, sch);
98   - return false;
99   - }
100   - });
101   - },
102   - getLines: function(){
103   - return JSON.parse(storage.getItem('lineControlItems'));
104   - },
105   - getDeviceIdByCar: function(car){
106   - return carDeviceIdMapp[car];
107   - },
108   - //获取线路标准信息
109   - getLineInformation: function(lineCode){
110   - return lineInformations[lineCode];
111   - },
112   - getLineIds: function(){
113   - return JSON.parse(storage.getItem('lineIds'));
114   - },
115   - //获取线路路牌对照数据
116   - getLineLpMap: function(){
117   - return lineLpMap;
118   - },
119   - //根据线路编码获取应发未发班次数量
120   - getYfwfNumByLine: function(lineCode){
121   - var lpMap = lineLpMap[lineCode]
122   - ,arr = [], t = new Date().valueOf(), num = 0;
123   - for(var lp in lpMap){
124   - arr = lpMap[lp];
125   - for(var i = 0, sch; sch=arr[i++];){
126   - if(sch.fcsjT > t)
127   - break;
128   -
129   - if(sch.fcsjActual == null && sch.fcsjActualTime == null && sch.status != -1)
130   - num ++;
131   - }
132   - }
133   - return num;
134   - },
135   - //根据线路编码获取站点路由
136   - getStationRouteByLine: function(lineCode){
137   - return stationRoute[lineCode];
138   - },
139   - //为GPS点附加班次信息
140   - attachSchedulInfo: function(gpsArray){
141   - $.each(gpsArray, function(){
142   - gps = this;
143   - if(gps.schId)
144   - gps.sch = schedules[gps.schId];
145   -
146   - });
147   - }
148   - //查询站点路由
149   - ,queryStationRoute : function(lineId,container, cb, width){
150   - $get('/stationroute/all', {'line.lineCode_eq': lineId, 'destroy_eq': 0}, function(routes){
151   - var svgData = analyData(routes);
152   - cb && cb(lineId, svgData, container, width);
153   - });
154   - },
155   - //实时GPS定时刷新
156   - startRefreshGpsTimer: function(){
157   - var f = arguments.callee;
158   - refreshGpsProxy();
159   - gpsTimer = setTimeout(f, realGpsT);
160   - },
161   - //查询实际排班计划
162   - queryRealSchedule: function(lineArrayStr, cb){
163   - $.get('/realSchedule/lines', {lines: lineArrayStr} ,function(rs){
164   - var list, sm, em, lineName;
165   - for(var lineCode in rs){
166   - list = rs[lineCode];
167   - lineLpMap[lineCode] = {};
168   - $.each(list, function(){
169   - attachInfo(this);
170   - //缓存排班计划
171   - schedules[this.id] = this;
172   - //构造 线路 ——> 路牌 ——> 班次 3层映射
173   - if(!lineLpMap[lineCode][this.lpName])
174   - lineLpMap[lineCode][this.lpName] = [];
175   - lineLpMap[lineCode][this.lpName].push(this);
176   - });
177   -
178   - //按发车时间排序
179   - list.sort(fcsjSort);
180   - }
181   - cb && cb(rs);
182   - });
183   - },
184   - //根据排班ID获取排班
185   - getSchedulById: function(id){
186   - return schedules[id];
187   - },
188   - //根据车辆内部编码获取排班数组
189   - getSchedulByVeh: function(nbbm){
190   - var array = [];
191   - var sch;
192   - for(var id in schedules){
193   - sch = schedules[id];
194   - if(sch.clZbh == nbbm)
195   - array.push(sch);
196   - }
197   -
198   - //排序
199   - array.sort(fcsjSort);
200   - return array;
201   - },
202   - //根据设备号获取GPS
203   - getGpsByDeviceId: function(deviceId){
204   - return allGps[deviceId];
205   - },
206   - //获取所有GPS
207   - findAllGps: function(){
208   - return allGps;
209   - }
210   - };
211   -
212   - //初始化carDeviceIdMapp
213   - $.get('/realSchedule/carDeviceMapp', function(rs){
214   - carDeviceIdMapp = rs;
215   - });
216   -
217   - //初始化lineCodes
218   - $.each(dataObject.getLines(), function(i, obj){
219   - lineCodes += (obj.lineCode + ',');
220   - lineMap[obj.lineCode] = obj;
221   - });
222   - lineCodes = lineCodes.substr(0, lineCodes.length - 1);
223   -
224   - //地图tab页显示时 注入gps数据
225   - $('a[href=#tab_map]').on('shown.bs.tab', function(){
226   - $('#tab_map #mapContainer').trigger('gps_refresh', [allGps]);
227   - });
228   -
229   - //获取线路标准信息
230   - $.get('/lineInformation/line/multi', {lineCodes: lineCodes}
231   - ,function(rs){
232   - $.each(rs, function(){
233   - lineInformations[this.line.lineCode] = this;
234   - delete this['line'];
235   - });
236   - });
237   -
238   - function attachInfo(sch){
239   - //实际发车误差值
240   - if(sch.fcsjActualTime){
241   - var diff = parseInt((sch.fcsjActualTime - sch.dfsjT) / 1000 / 60);
242   - if(diff > 0)
243   - sch.fcsj_diff = '( +' + diff + ' )';
244   - else if(diff < 0)
245   - sch.fcsj_diff = '( ' + diff + ' )';
246   - else
247   - sch.fcsj_diff = '';
248   - }
249   - }
250   -
251   - function refreshGpsProxy(){
252   - refreshGps(function(all){
253   - //触发元素刷新事件
254   - $('#tab_home,#tab_map #mapContainer').trigger('gps_refresh', [all]);
255   - });
256   - }
257   - var upSort = function(a, b){
258   - return a.stationRouteCode - b.stationRouteCode;
259   - }
260   -
261   - var downSort = function(a, b){
262   - return b.stationRouteCode - a.stationRouteCode;
263   - }
264   -
265   - var station_indexof = function(array, station , start){
266   - var res = -1
267   -
268   - for(var i = start, obj; obj = array[i++];){
269   -
270   - if(obj.stationName == station.stationName){
271   - res = i;
272   - break;
273   - }
274   - }
275   -
276   - return res;
277   - }
278   -
279   -
280   - /**
281   - * 刷新GPS车辆信息
282   - */
283   - function refreshGps(cb){
284   - $.ajax({
285   - url: '/gps/real/line',
286   - data: {lineCodes: lineCodes},
287   - timeout: 5000,//5秒超时
288   - success: getGpsSuccess,
289   - error: getGpsError
290   - });
291   -
292   - function getGpsSuccess(gpsList){
293   - if(!gpsList || gpsList.length == 0)
294   - return;
295   -
296   - //var prve = allGps
297   - //,addArray = []
298   - //,upArray = []
299   - // ,oldGps;
300   - for(var i = 0, gps; gps=gpsList[i++];){
301   - /*oldGps = prve[gps.deviceId];
302   - if(!oldGps){
303   - addArray.push(gps);
304   - }
305   - else if(gps.timestamp > oldGps.timestamp){
306   - //更新
307   - upArray.push(gps);
308   - }*/
309   - //addArray.push(gps);
310   -/* if(prve[gps.deviceId] &&
311   - gps.timestamp == prve[gps.deviceId].timestamp)
312   - continue;*/
313   - //异常状态检查
314   - abnormalCheck(gps);
315   - //关联班次信息
316   - if(gps.schId)
317   - gps.sch = schedules[gps.schId];
318   -
319   - allGps[gps.deviceId] = gps;
320   - }
321   - //cb && cb(addArray, upArray);
322   - cb && cb(allGps);
323   - }
324   -
325   - function abnormalCheck(gps){
326   - if(!stationRoute[gps.lineId])
327   - return;
328   - var routes = stationRoute[gps.lineId][gps.upDown]
329   - ,rs;
330   - if(routes){
331   - $.each(routes , function(){
332   - if(this.stationCode == gps.stopNo){
333   - rs = 1;
334   - return false;
335   - }
336   - });
337   - }
338   -
339   - if(!rs){
340   - gps.abnormal = true;
341   - gps.abnormalText = '走向异常?';
342   - }
343   - }
344   -
345   - function getGpsError(jqXHR, textStatus){
346   - if(textStatus === 'error')
347   - layer.alert('获取GPS数据时出现异常,请尝试刷新页面!', {icon: 2});
348   - else if(textStatus === 'timeout')
349   - layer.alert('连接服务器超时', {icon: 2});
350   -
351   - //停止gps刷新
352   - clearTimeout(gpsTimer);
353   - }
354   - }
355   -
356   - /**
357   - * 解析数据成svg想要的格式
358   - */
359   - function analyData(routes){
360   - //按上下行拆分
361   - var up=[],down=[];
362   - for(var i = 0, route; route = routes[i++];){
363   - if(route.directions==0)
364   - up.push(route);
365   - else if(route.directions==1)
366   - down.push(route);
367   - }
368   - //排序
369   - up.sort(upSort);
370   - down.sort(downSort);
371   - //缓存路由
372   - if(routes.length > 0){
373   - stationRoute[routes[0].lineCode] = [up.slice(0), down.slice(0).sort(upSort)];
374   - }
375   -
376   - //合并
377   - var data = [];
378   - for(var j = 0; j < up.length; j ++){
379   - var upS = up[j] == null?{}:up[j]
380   - ,downS = down[j] == null?{}:down[j]
381   - ,op = {name: [upS.stationName], id: [upS.stationCode, downS.stationCode], type: 2, stationMark: upS.stationMark};
382   -
383   - //编码相同
384   - if(upS.stationName != downS.stationName){
385   - var dIndex = station_indexof(down, upS, j);
386   - if(dIndex == -1){
387   - op.type = 0;
388   - op.id = [upS.stationCod, -1];
389   - //占位
390   - down.splice(j, 0, {});
391   - }else{
392   - for(var t = j; t < dIndex - 1; t++){
393   - var temp = down[t];
394   - data.push({name: [temp.stationName], type:1, id: [temp.stationCode]});
395   - }
396   - //delete
397   - down.splice(j, dIndex - 1 - j);
398   - j --;
399   - continue;
400   - }
401   - }
402   - data.push(op);
403   - }
404   -
405   - //将上下行挨着的独立站点合并
406   - var len = data.length - 1, first, sec;
407   - for(var s = 0; s < len; s ++){
408   - first = data[s];
409   - sec = data[s + 1];
410   -
411   - if(first.type == 0
412   - && sec.type == 1){
413   - data.splice(s, 2, {name: [first['name'][0],sec['name'][0]], type:3, id: [first['id'][0],sec['id'][0]]});
414   - len --;
415   - }
416   - else if(first.type == 1 && sec.type == 0){
417   - data.splice(s, 2, {name: [first['name'][0],sec['name'][0]], type:3, id: [first['id'][0],sec['id'][0]]});
418   - len --;
419   - }
420   - }
421   - return data;
422   - }
423   -
424   - countDown('data.js');
425   - //queryStationRoute();
426   - return dataObject;
  1 +/**
  2 + * 数据处理模块
  3 +*/
  4 +var _data = (function(){
  5 + var storage = window.localStorage;
  6 +
  7 + var gpsTimer;
  8 +
  9 + //实时GPS数据
  10 + var allGps = {};
  11 + //10秒刷新一次实时GPS
  12 + var realGpsT = 1000 * 8;
  13 +
  14 + var dateStr = moment().format('YYYY-MM-DD');
  15 + //实际排班
  16 + var schedules = {};
  17 +
  18 + //站点路由缓存
  19 + var stationRoute = {};
  20 +
  21 + //线路 ——> 路牌 ——> 班次 3层映射
  22 + var lineLpMap = {};
  23 + //线路标准信息
  24 + var lineInformations = {};
  25 + //车辆和班次数组映射
  26 + //var clSchMap = {};
  27 +
  28 + //车辆自编号和设备号对照
  29 + var carDeviceIdMapp = {};
  30 +
  31 + var fcsjSort = function(a, b){
  32 + return (a.fcno - b.fcno) + (a.fcsjT - b.fcsjT);
  33 + }
  34 +
  35 + var dataObject = {
  36 + //根据线路和上下行获取计划排班
  37 + findSchByLine: function(xlbm, upDown){
  38 + var array = [];
  39 + var sch;
  40 + for(var id in schedules){
  41 + sch = schedules[id];
  42 + if(sch.xlBm == xlbm
  43 + && sch.xlDir == upDown){
  44 + array.push(sch);
  45 + }
  46 + }
  47 + //排序
  48 + array.sort(fcsjSort);
  49 +
  50 + return array;
  51 + },
  52 + //根据车辆获取班次数组
  53 + findByCl: function(nbbm){
  54 + var array = [];
  55 + for(var id in schedules){
  56 + sch = schedules[id];
  57 + if(sch.clZbh == nbbm)
  58 + array.push(sch);
  59 + }
  60 +
  61 + //排序
  62 + array.sort(fcsjSort);
  63 + return array;
  64 + },
  65 + //清理线路下班次
  66 + clearByLineCode: function(lineCode){
  67 + for(var id in schedules){
  68 + if(schedules[id].xlBm == lineCode){
  69 + schedules[id] = null;
  70 + delete schedules[id];
  71 + }
  72 + }
  73 +
  74 + lineLpMap[lineCode] = {};
  75 + },
  76 + //添加一个班次
  77 + pushSchedule: function(sch){
  78 + //附加信息
  79 + attachInfo(sch);
  80 + schedules[sch.id] = sch;
  81 +
  82 + var xl=sch.xlBm,lp=sch.lpName;
  83 + if(!lineLpMap[xl][lp])
  84 + lineLpMap[xl][lp] = [];
  85 +
  86 + lineLpMap[xl][lp].push(sch);
  87 + },
  88 + //更新班次信息
  89 + updateSchedule: function(sch){
  90 + //附加信息
  91 + attachInfo(sch);
  92 + schedules[sch.id] = sch;
  93 +
  94 + var lpArray = lineLpMap[sch.xlBm][sch.lpName];
  95 + $.each(lpArray, function(i){
  96 + if(this.id == sch.id){
  97 + lpArray.splice(i, 1, sch);
  98 + return false;
  99 + }
  100 + });
  101 + },
  102 + getLines: function(){
  103 + return JSON.parse(storage.getItem('lineControlItems'));
  104 + },
  105 + getDeviceIdByCar: function(car){
  106 + return carDeviceIdMapp[car];
  107 + },
  108 + //获取线路标准信息
  109 + getLineInformation: function(lineCode){
  110 + return lineInformations[lineCode];
  111 + },
  112 + getLineIds: function(){
  113 + return JSON.parse(storage.getItem('lineIds'));
  114 + },
  115 + //获取线路路牌对照数据
  116 + getLineLpMap: function(){
  117 + return lineLpMap;
  118 + },
  119 + //根据线路编码获取应发未发班次数量
  120 + getYfwfNumByLine: function(lineCode){
  121 + var lpMap = lineLpMap[lineCode]
  122 + ,arr = [], t = new Date().valueOf(), num = 0;
  123 + for(var lp in lpMap){
  124 + arr = lpMap[lp];
  125 + for(var i = 0, sch; sch=arr[i++];){
  126 + if(sch.fcsjT > t)
  127 + break;
  128 +
  129 + if(sch.fcsjActual == null && sch.fcsjActualTime == null && sch.status != -1)
  130 + num ++;
  131 + }
  132 + }
  133 + return num;
  134 + },
  135 + //根据线路编码获取站点路由
  136 + getStationRouteByLine: function(lineCode){
  137 + return stationRoute[lineCode];
  138 + },
  139 + //为GPS点附加班次信息
  140 + attachSchedulInfo: function(gpsArray){
  141 + $.each(gpsArray, function(){
  142 + gps = this;
  143 + if(gps.schId)
  144 + gps.sch = schedules[gps.schId];
  145 +
  146 + });
  147 + }
  148 + //查询站点路由
  149 + ,queryStationRoute : function(lineId,container, cb, width){
  150 + $get('/stationroute/all', {'line.lineCode_eq': lineId, 'destroy_eq': 0}, function(routes){
  151 + var svgData = analyData(routes);
  152 + cb && cb(lineId, svgData, container, width);
  153 + });
  154 + },
  155 + //实时GPS定时刷新
  156 + startRefreshGpsTimer: function(){
  157 + var f = arguments.callee;
  158 + refreshGpsProxy();
  159 + gpsTimer = setTimeout(f, realGpsT);
  160 + },
  161 + //查询实际排班计划
  162 + queryRealSchedule: function(lineArrayStr, cb){
  163 + $.get('/realSchedule/lines', {lines: lineArrayStr} ,function(rs){
  164 + var list, sm, em, lineName;
  165 + for(var lineCode in rs){
  166 + list = rs[lineCode];
  167 + lineLpMap[lineCode] = {};
  168 + $.each(list, function(){
  169 + attachInfo(this);
  170 + //缓存排班计划
  171 + schedules[this.id] = this;
  172 + //构造 线路 ——> 路牌 ——> 班次 3层映射
  173 + if(!lineLpMap[lineCode][this.lpName])
  174 + lineLpMap[lineCode][this.lpName] = [];
  175 + lineLpMap[lineCode][this.lpName].push(this);
  176 + });
  177 +
  178 + //按发车时间排序
  179 + list.sort(fcsjSort);
  180 + }
  181 + cb && cb(rs);
  182 + });
  183 + },
  184 + //根据排班ID获取排班
  185 + getSchedulById: function(id){
  186 + return schedules[id];
  187 + },
  188 + //根据车辆内部编码获取排班数组
  189 + getSchedulByVeh: function(nbbm){
  190 + var array = [];
  191 + var sch;
  192 + for(var id in schedules){
  193 + sch = schedules[id];
  194 + if(sch.clZbh == nbbm)
  195 + array.push(sch);
  196 + }
  197 +
  198 + //排序
  199 + array.sort(fcsjSort);
  200 + return array;
  201 + },
  202 + //根据设备号获取GPS
  203 + getGpsByDeviceId: function(deviceId){
  204 + return allGps[deviceId];
  205 + },
  206 + //获取所有GPS
  207 + findAllGps: function(){
  208 + return allGps;
  209 + }
  210 + };
  211 +
  212 + //初始化carDeviceIdMapp
  213 + $.get('/realSchedule/carDeviceMapp', function(rs){
  214 + carDeviceIdMapp = rs;
  215 + });
  216 +
  217 + //初始化lineCodes
  218 + $.each(dataObject.getLines(), function(i, obj){
  219 + lineCodes += (obj.lineCode + ',');
  220 + lineMap[obj.lineCode] = obj;
  221 + });
  222 + lineCodes = lineCodes.substr(0, lineCodes.length - 1);
  223 +
  224 + //地图tab页显示时 注入gps数据
  225 + $('a[href=#tab_map]').on('shown.bs.tab', function(){
  226 + $('#tab_map #mapContainer').trigger('gps_refresh', [allGps]);
  227 + });
  228 +
  229 + //获取线路标准信息
  230 + $.get('/lineInformation/line/multi', {lineCodes: lineCodes}
  231 + ,function(rs){
  232 + $.each(rs, function(){
  233 + lineInformations[this.line.lineCode] = this;
  234 + delete this['line'];
  235 + });
  236 + });
  237 +
  238 + function attachInfo(sch){
  239 + //实际发车误差值
  240 + if(sch.fcsjActualTime){
  241 + var diff = parseInt((sch.fcsjActualTime - sch.dfsjT) / 1000 / 60);
  242 + if(diff > 0)
  243 + sch.fcsj_diff = '( +' + diff + ' )';
  244 + else if(diff < 0)
  245 + sch.fcsj_diff = '( ' + diff + ' )';
  246 + else
  247 + sch.fcsj_diff = '';
  248 + }
  249 +
  250 + if (sch.fcsjActual == null && sch.zdsjActual && sch.status != -1) {
  251 + sch.status = 4;
  252 + }
  253 + }
  254 +
  255 + function refreshGpsProxy(){
  256 + refreshGps(function(all){
  257 + //触发元素刷新事件
  258 + $('#tab_home,#tab_map #mapContainer').trigger('gps_refresh', [all]);
  259 + });
  260 + }
  261 + var upSort = function(a, b){
  262 + return a.stationRouteCode - b.stationRouteCode;
  263 + }
  264 +
  265 + var downSort = function(a, b){
  266 + return b.stationRouteCode - a.stationRouteCode;
  267 + }
  268 +
  269 + var station_indexof = function(array, station , start){
  270 + var res = -1
  271 +
  272 + for(var i = start, obj; obj = array[i++];){
  273 +
  274 + if(obj.stationName == station.stationName){
  275 + res = i;
  276 + break;
  277 + }
  278 + }
  279 +
  280 + return res;
  281 + }
  282 +
  283 +
  284 + /**
  285 + * 刷新GPS车辆信息
  286 + */
  287 + function refreshGps(cb){
  288 + $.ajax({
  289 + url: '/gps/real/line',
  290 + data: {lineCodes: lineCodes},
  291 + timeout: 5000,//5秒超时
  292 + success: getGpsSuccess,
  293 + error: getGpsError
  294 + });
  295 +
  296 + function getGpsSuccess(gpsList){
  297 + if(!gpsList || gpsList.length == 0)
  298 + return;
  299 +
  300 + //var prve = allGps
  301 + //,addArray = []
  302 + //,upArray = []
  303 + // ,oldGps;
  304 + for(var i = 0, gps; gps=gpsList[i++];){
  305 + /*oldGps = prve[gps.deviceId];
  306 + if(!oldGps){
  307 + addArray.push(gps);
  308 + }
  309 + else if(gps.timestamp > oldGps.timestamp){
  310 + //更新
  311 + upArray.push(gps);
  312 + }*/
  313 + //addArray.push(gps);
  314 +/* if(prve[gps.deviceId] &&
  315 + gps.timestamp == prve[gps.deviceId].timestamp)
  316 + continue;*/
  317 + //异常状态检查
  318 + abnormalCheck(gps);
  319 + //关联班次信息
  320 + if(gps.schId)
  321 + gps.sch = schedules[gps.schId];
  322 +
  323 + allGps[gps.deviceId] = gps;
  324 + }
  325 + //cb && cb(addArray, upArray);
  326 + cb && cb(allGps);
  327 + }
  328 +
  329 + function abnormalCheck(gps){
  330 + if(!stationRoute[gps.lineId])
  331 + return;
  332 + var routes = stationRoute[gps.lineId][gps.upDown]
  333 + ,rs;
  334 + if(routes){
  335 + $.each(routes , function(){
  336 + if(this.stationCode == gps.stopNo){
  337 + rs = 1;
  338 + return false;
  339 + }
  340 + });
  341 + }
  342 +
  343 + if(!rs){
  344 + gps.abnormal = true;
  345 + gps.abnormalText = '走向异常?';
  346 + }
  347 + }
  348 +
  349 + function getGpsError(jqXHR, textStatus){
  350 + if(textStatus === 'error')
  351 + layer.alert('获取GPS数据时出现异常,请尝试刷新页面!', {icon: 2});
  352 + else if(textStatus === 'timeout')
  353 + layer.alert('连接服务器超时', {icon: 2});
  354 +
  355 + //停止gps刷新
  356 + clearTimeout(gpsTimer);
  357 + }
  358 + }
  359 +
  360 + /**
  361 + * 解析数据成svg想要的格式
  362 + */
  363 + function analyData(routes){
  364 + //按上下行拆分
  365 + var up=[],down=[];
  366 + for(var i = 0, route; route = routes[i++];){
  367 + if(route.directions==0)
  368 + up.push(route);
  369 + else if(route.directions==1)
  370 + down.push(route);
  371 + }
  372 + //排序
  373 + up.sort(upSort);
  374 + down.sort(downSort);
  375 + //缓存路由
  376 + if(routes.length > 0){
  377 + stationRoute[routes[0].lineCode] = [up.slice(0), down.slice(0).sort(upSort)];
  378 + }
  379 +
  380 + //合并
  381 + var data = [];
  382 + for(var j = 0; j < up.length; j ++){
  383 + var upS = up[j] == null?{}:up[j]
  384 + ,downS = down[j] == null?{}:down[j]
  385 + ,op = {name: [upS.stationName], id: [upS.stationCode, downS.stationCode], type: 2, stationMark: upS.stationMark};
  386 +
  387 + //编码相同
  388 + if(upS.stationName != downS.stationName){
  389 + var dIndex = station_indexof(down, upS, j);
  390 + if(dIndex == -1){
  391 + op.type = 0;
  392 + op.id = [upS.stationCod, -1];
  393 + //占位
  394 + down.splice(j, 0, {});
  395 + }else{
  396 + for(var t = j; t < dIndex - 1; t++){
  397 + var temp = down[t];
  398 + data.push({name: [temp.stationName], type:1, id: [temp.stationCode]});
  399 + }
  400 + //delete
  401 + down.splice(j, dIndex - 1 - j);
  402 + j --;
  403 + continue;
  404 + }
  405 + }
  406 + data.push(op);
  407 + }
  408 +
  409 + //将上下行挨着的独立站点合并
  410 + var len = data.length - 1, first, sec;
  411 + for(var s = 0; s < len; s ++){
  412 + first = data[s];
  413 + sec = data[s + 1];
  414 +
  415 + if(first.type == 0
  416 + && sec.type == 1){
  417 + data.splice(s, 2, {name: [first['name'][0],sec['name'][0]], type:3, id: [first['id'][0],sec['id'][0]]});
  418 + len --;
  419 + }
  420 + else if(first.type == 1 && sec.type == 0){
  421 + data.splice(s, 2, {name: [first['name'][0],sec['name'][0]], type:3, id: [first['id'][0],sec['id'][0]]});
  422 + len --;
  423 + }
  424 + }
  425 + return data;
  426 + }
  427 +
  428 + countDown('data.js');
  429 + //queryStationRoute();
  430 + return dataObject;
427 431 })();
428 432 \ No newline at end of file
... ...
src/main/resources/static/pages/home.html
... ... @@ -59,17 +59,17 @@
59 59 }
60 60 </style>
61 61 <div class="system_change_log">
62   - <h2 style="text-indent: 35px;margin: 10px 0 5px;">2022-10-10 更新说明 Changelog</h2>
  62 + <h2 style="text-indent: 35px;margin: 10px 0 5px;">2023-03-07 更新说明 Changelog</h2>
63 63 <br><br>
64 64 <ul>
  65 + <li class="sub_title"><h6>线调</h6></li>
  66 + <li><span class="label s_c_change">修改</span>1."无发有到"提示色在某些情况下显示异常修正</li>
  67 + <li><span class="label s_c_change">修改</span>2."设备管理"中按GPS时间排序异常修正</li>
65 68 <li class="sub_title"><h6>报表</h6></li>
66   - <li><span class="label s_c_change">修改</span>1.为了应对大批量线路的划转撤销造成历史报表查询问题,
67   - 现将报表中线路的选择扩大到可以选择已撤销线路,撤销线路会标记"(撤销)"</li>
  69 + <li><span class="label s_c_change">修改</span>1."(班次)到离站"报表,查询速度优化</li>
68 70 <li class="sub_title"><h6>系统安全</h6></li>
69   - <li><span class="label s_c_change">修改</span>1.登录密码错误2次加验证码,错4次锁定10分钟,管理员可解锁</li>
70   - <li><span class="label s_c_change">修改</span>2.登录时做弱密码检查,存在弱密码在进入主页面后强制修改密码</li>
71   - <li><span class="label s_c_change">修改</span>3.密码规则加入连续性字符验证,如不能出现123、abc样的连续字符</li>
72   - <li><span class="label s_c_change">修改</span>4.记录最后登录日期</li>
  71 + <li><span class="label s_c_change">修改</span>1.对系统中错误信息提示做调整,避免披露过多信息被攻击</li>
  72 + <li><span class="label s_c_change">修改</span>2.使用CA签发的电子证书,浏览器可以保存用户密码信息</li>
73 73 </ul>
74 74  
75 75 </div>
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/temp_sch/main.html
1   -<div class="uk-modal ct-form-modal ct_move_modal" id="schedule-addsch-modal">
2   - <div class="uk-modal-dialog" style="width: 800px;">
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-grid">
8   - <div class="uk-width-1-4">
9   - <ul data-uk-switcher="{connect:'#tempScheduleContent'}" class="uk-nav uk-nav-side left_tabs_lg">
10   - <li data-handle="normal"><a>1、临加班次</a></li>
11   - <li data-handle="toAndFro"><a>2、往返</a></li>
12   - <li data-handle="parkToPark"><a>3、场到场</a></li>
13   - </ul>
14   - </div>
15   - <div class="uk-width-3-4">
16   - <ul id="tempScheduleContent" class="uk-switcher">
17   - <li class="normalCont"></li>
18   - <li class="toAndFroCont"></li>
19   - <li class="parkToParkCont"></li>
20   - </ul>
21   - </div>
22   - </div>
23   - </div>
24   -
25   - <script>
26   - (function () {
27   - var modal = '#schedule-addsch-modal',
28   - sch, stationRoutes, parks, information, carsArray, st_park_data;
29   -
30   - $(modal).on('init', function (e, data) {
31   - e.stopPropagation();
32   - sch = data.sch;
33   - //站到场数据
34   - st_park_data = gb_data_basic.get_stat_park_data()[sch.xlBm];
35   - //站点路由
36   - stationRoutes = gb_common.groupBy(gb_data_basic.stationRoutes(sch.xlBm).sort(function (a, b) {
37   - return a.stationRouteCode - b.stationRouteCode;
38   - }), 'directions');
39   - //停车场
40   - parks = gb_data_basic.simpleParksArray();
41   - //线路标准
42   - information = gb_data_basic.getLineInformation(sch.xlBm);
43   - //停车场排序,常用的放前面
44   - parks = sort_parks(parks, information, st_park_data);
45   - //车辆信息
46   - carsArray = gb_data_basic.carsArray();
47   -
48   - var st_doms = gb_schedule_context_menu.get_add_sch_doms();
49   - //normal
50   - $('.normalCont', modal).html(st_doms.normal_dom)
51   - .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form});
52   -
53   - //to and fro
54   - $('.toAndFroCont', modal).html(st_doms.two_way_dom)
55   - .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form, stationRoutes: stationRoutes});
56   -
57   - //park to park
58   - $('.parkToParkCont', modal).html(st_doms.park_to_park_dom)
59   - .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form, parks: parks, carsArray: carsArray});
60   - });
61   -
62   - //init-autoCom
63   - $(modal).on('init-autoCom', '.add-sch-form', function () {
64   - //车辆
65   - if(carsArray)
66   - gb_common.carAutocomplete($('.car-autocom', this), carsArray);
67   - //驾驶员
68   - gb_common.personAutocomplete($('.jsy-autocom', this));
69   - //售票员
70   - gb_common.personAutocomplete($('.spy-autocom', this));
71   - //备注补全
72   - gb_common.remarksAutocomplete($('.remarks-autocom', this));
73   - });
74   -
75   - //班次类型 和 上下行 切换事件
76   - $(modal).on('change', '.add-sch-form [name=bcType],.add-sch-form [name=xlDir]', reCalcInputs_type);
77   - //起终点站改变事件
78   - $(modal).on('change', '[name=qdzCode],[name=zdzCode]', reCalcInputs_station);
79   - //开始时间和公里改变
80   - $(modal).on('input', '.add-sch-form [name=fcsj],.add-sch-form [name=jhlc]', reCalcEndTime);
81   -
82   -
83   - function reCalcInputs_type() {
84   - var f = $(this).parents('.add-sch-form');
85   - var bcType_e = $('[name=bcType]', f)
86   - , xlDir_e = $('[name=xlDir]', f);
87   -
88   - var routes = stationRoutes[xlDir_e.val()]
89   - , lastCode = routes[routes.length - 1].stationCode
90   - , opts = '', park_opts = '';
91   - //station options
92   - $.each(routes, function () {
93   - opts += '<option value="' + this.stationCode + '">' + this.stationName + '</option>'
94   - });
95   - //park options
96   - for(var i=0,p;p=parks[i++];)
97   - park_opts += '<option value="' + p.code + '">' + p.name + '</option>';
98   -
99   - var qdz = $('[name=qdzCode]', f), zdz = $('[name=zdzCode]', f);
100   - //var time, mileage;
101   - switch (bcType_e.val()) {
102   - case 'out':
103   - qdz.html(park_opts).val(information.carPark);
104   - zdz.html(opts);
105   - break;
106   - case 'in':
107   - qdz.html(opts);
108   - zdz.html(park_opts).val(information.carPark);
109   - break;
110   - default:
111   - qdz.html(opts);
112   - zdz.html(opts).val(lastCode);
113   - }
114   -
115   - zdz.trigger('change');
116   - f.trigger('ct_callback');
117   - }
118   -
119   - function reCalcInputs_station() {
120   - var f = $(this).parents('form'),
121   - bcType = $('[name=bcType]', f).val(),
122   - qdzCode = $('[name=qdzCode]', f).val(),
123   - zdzCode =$('[name=zdzCode]', f).val(),
124   - startDate = $('[name=fcsj]', f).val(),
125   - upDown = $('[name=xlDir]', f).val(), mileage, time;
126   -
127   - //从站到场里获取数据
128   - var stp = search_st_park(f);
129   - if(stp){
130   - mileage=bcType=='in'?stp['mileage1']:stp['mileage2'];
131   - time=bcType=='in'?stp['time1']:stp['time2'];
132   - }
133   - else{
134   - switch (upDown + '_' + bcType) {
135   - case '0_out'://上行出场
136   - mileage = information.upOutMileage;
137   - time = information.upOutTimer;
138   - break;
139   - case '1_out'://下行出场
140   - mileage = information.downOutMileage;
141   - time = information.downOutTimer;
142   - break;
143   - case '0_in'://上行进场
144   - mileage = information.upInMileage;
145   - time = information.upInTimer;
146   - break;
147   - case '1_in'://下行进场
148   - mileage = information.downInMileage;
149   - time = information.downInTimer;
150   - break;
151   - default:
152   -
153   - var qc_time=upDown==0?information.upTravelTime:information.downTravelTime,
154   - qc_mileage=upDown==0?information.upMileage:information.downMileage, _type;
155   - if(is_normal_sch(f)){
156   - _type='normal';
157   - mileage=qc_mileage;
158   - }
159   - else{
160   - _type='region';
161   - mileage = calcMileage(stationRoutes[upDown], qdzCode, zdzCode);
162   - }
163   -
164   - time = gb_common.mul(gb_common.accDiv(qc_time, qc_mileage), mileage);
165   - if(bcType!='ldks' && bcType!='major' && bcType!='venting')
166   - $('[name=bcType]', f).val(_type);
167   - }
168   - }
169   -
170   - $('[name=jhlc]', f).val(mileage);
171   - var et = moment(startDate, 'HH:mm').add(time, 'minutes');
172   - $f('zdsj', f).val(et.format('HH:mm'));
173   - f.trigger('ct_callback');
174   - }
175   -
176   -
177   - function reCalcEndTime() {
178   - var f = $(this).parents('.add-sch-form')
179   - , startDate = $f('fcsj', f).val()//开始时间
180   - , mileage = $f('jhlc', f).val()//公里
181   - , type2 = $f('bcType', f).val(),//班次类型
182   - upDown = $('[name=xlDir]', f).val();
183   - if (!startDate || !mileage)
184   - return;
185   -
186   - var time;
187   - //从站到场里获取数据
188   - var stp = search_st_park(f);
189   - if(stp){
190   - time=type2=='in'?stp['time1']:stp['time2'];
191   - }
192   - else{
193   - if (type2 == 'in')
194   - time = upDown == 0 ? information.upInTimer : information.downInTimer;
195   - else if (type2 == 'out')
196   - time = upDown == 0 ? information.upOutTimer : information.downOutTimer;
197   - else{
198   - var qc_time=upDown==0?information.upTravelTime:information.downTravelTime,
199   - qc_mileage=upDown==0?information.upMileage:information.downMileage;
200   -
201   - time = gb_common.mul(gb_common.accDiv(qc_time, qc_mileage), mileage);
202   - }
203   - }
204   -
205   - var et = moment(startDate, 'HH:mm').add(time, 'minutes');
206   - $f('zdsj', f).val(et.format('HH:mm'));
207   - f.trigger('ct_callback');
208   - }
209   -
210   - function is_normal_sch(f) {
211   - var qdzCode = $('[name=qdzCode]', f).val(),
212   - zdzCode =$('[name=zdzCode]', f).val(),
213   - upDown = $('[name=xlDir]', f).val(),
214   - rts = stationRoutes[upDown];
215   -
216   - if(rts[0].stationCode == qdzCode
217   - && rts[rts.length - 1].stationCode == zdzCode)
218   - return true;
219   - else
220   - return false;
221   - }
222   -
223   - function isInOut(bcType) {
224   - return bcType=='in' || bcType=='out';
225   - }
226   -
227   - /**
228   - * 计算线路上站点间公里
229   - */
230   - function calcMileage(rts, s, e) {
231   - var mileage = 0, flag, code;
232   - $.each(rts, function () {
233   - code = this['stationCode'];
234   - if (flag)
235   - mileage = gb_common.accAdd(mileage, this.distances);
236   - if (code == s)
237   - flag = true;
238   - if (code == e)
239   - return false;
240   - });
241   - return mileage;
242   - }
243   -
244   - function search_st_park(f) {
245   - if(!st_park_data)
246   - return;
247   - var stp;
248   - var qdSelect=$f('qdzCode', f)[0],zdSelect=$f('zdzCode', f)[0];
249   -
250   - if(qdSelect.options.selectedIndex < 0)
251   - return;
252   - var qdzName=qdSelect.options[qdSelect.options.selectedIndex].text,
253   - zdzName=zdSelect.options[zdSelect.options.selectedIndex].text,
254   - type2 = $f('bcType', f).val();
255   -
256   - if(!isInOut(type2))
257   - return;
258   -
259   - $.each(st_park_data, function () {
260   - if((type2=='in' && this.stationName==qdzName && this.parkName==zdzName)
261   - || (type2=='out' && this.stationName==zdzName && this.parkName==qdzName)){
262   - stp = this;
263   - return false;
264   - }
265   - });
266   -
267   - return stp;
268   - }
269   -
270   - /**
271   - * 停车场排序
272   - * @param parks 停车场 code 2 name
273   - * @param information 线路标准
274   - * @param st_park_data 站到场
275   - */
276   - function sort_parks(parks, information, st_park_data) {
277   - var array = [], names=[];
278   - for(var code in parks){
279   - array.push({code: code, name: parks[code]});
280   - }
281   -
282   - if(st_park_data && st_park_data.length > 0){
283   - $.each(st_park_data, function () {
284   - names.push(this.parkName);
285   - });
286   - }
287   -
288   - //debugger
289   - array.sort(function (a, b) {
290   - if(a.code==information.carPark)
291   - return -1;
292   - if(b.code==information.carPark)
293   - return 1;
294   -
295   - var ai = names.indexOf(a.name),
296   - bi = names.indexOf(b.name);
297   -
298   - if(ai!=-1 && bi==-1)
299   - return -1;
300   - else if(ai==-1 && bi!=-1)
301   - return 1;
302   - else
303   - return $.trim(a.name).localeCompare($.trim(b.name), 'zh-CN');
304   - });
305   - return array;
306   - }
307   -
308   - function $f(name, f) {
309   - return $('[name=' + name + ']', f);
310   - }
311   -
312   - /**
313   - * 提交表单
314   - */
315   - function submit_temp_schedule_form(data, cb, err) {
316   - data.xlBm = sch.xlBm;
317   - data.xlName = sch.xlName;
318   - data.lpName = sch.lpName;
319   - //拆分驾驶员工号和姓名
320   - data.jGh = data.jsy.split('/')[0];
321   - data.jName = data.jsy.split('/')[1];
322   - delete data.jsy;
323   - //拆分售票员工号和姓名
324   - if (data.spy != '') {
325   - data.sGh = data.spy.split('/')[0];
326   - data.sName = data.spy.split('/')[1];
327   - delete data.spy;
328   - }
329   -
330   - //公司信息
331   - var line = gb_data_basic.findLineByCodes([data.xlBm]);
332   - if(line && line.length > 0){
333   - line = line[0];
334   - data.gsBm = line.company;
335   - data.fgsBm = line.brancheCompany;
336   - }
337   -
338   - gb_common.$post('/realSchedule', data, function (rs) {
339   - notify_succ('新增临加班次成功');
340   - cb && cb(rs);
341   - }, err);
342   - }
343   - })();
344   - </script>
  1 +<div class="uk-modal ct-form-modal ct_move_modal" id="schedule-addsch-modal">
  2 + <div class="uk-modal-dialog" style="width: 800px;">
  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-grid">
  8 + <div class="uk-width-1-4">
  9 + <ul data-uk-switcher="{connect:'#tempScheduleContent'}" class="uk-nav uk-nav-side left_tabs_lg">
  10 + <li data-handle="normal"><a>1、临加班次</a></li>
  11 + <li data-handle="toAndFro"><a>2、往返</a></li>
  12 + <li data-handle="parkToPark"><a>3、场到场</a></li>
  13 + </ul>
  14 + </div>
  15 + <div class="uk-width-3-4">
  16 + <ul id="tempScheduleContent" class="uk-switcher">
  17 + <li class="normalCont"></li>
  18 + <li class="toAndFroCont"></li>
  19 + <li class="parkToParkCont"></li>
  20 + </ul>
  21 + </div>
  22 + </div>
  23 + </div>
  24 +
  25 + <script>
  26 + (function () {
  27 + var modal = '#schedule-addsch-modal',
  28 + sch, stationRoutes, parks, information, carsArray, st_park_data;
  29 +
  30 + $(modal).on('init', function (e, data) {
  31 + e.stopPropagation();
  32 + sch = data.sch;
  33 + //站到场数据
  34 + st_park_data = gb_data_basic.get_stat_park_data()[sch.xlBm];
  35 + //站点路由
  36 + stationRoutes = gb_common.groupBy(gb_data_basic.stationRoutes(sch.xlBm).sort(function (a, b) {
  37 + return a.stationRouteCode - b.stationRouteCode;
  38 + }), 'directions');
  39 + //停车场
  40 + parks = gb_data_basic.simpleParksArray();
  41 + //线路标准
  42 + information = gb_data_basic.getLineInformation(sch.xlBm);
  43 + //停车场排序,常用的放前面
  44 + parks = sort_parks(parks, information, st_park_data);
  45 + //车辆信息
  46 + carsArray = gb_data_basic.carsArray();
  47 +
  48 + var st_doms = gb_schedule_context_menu.get_add_sch_doms();
  49 + //normal
  50 + $('.normalCont', modal).html(st_doms.normal_dom)
  51 + .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form});
  52 +
  53 + //to and fro
  54 + $('.toAndFroCont', modal).html(st_doms.two_way_dom)
  55 + .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form, stationRoutes: stationRoutes});
  56 +
  57 + //park to park
  58 + $('.parkToParkCont', modal).html(st_doms.park_to_park_dom)
  59 + .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form, parks: parks, carsArray: carsArray});
  60 + });
  61 +
  62 + //init-autoCom
  63 + $(modal).on('init-autoCom', '.add-sch-form', function () {
  64 + //车辆
  65 + if(carsArray)
  66 + gb_common.carAutocomplete($('.car-autocom', this), carsArray);
  67 + //驾驶员
  68 + gb_common.personAutocomplete($('.jsy-autocom', this));
  69 + //售票员
  70 + gb_common.personAutocomplete($('.spy-autocom', this));
  71 + //备注补全
  72 + gb_common.remarksAutocomplete($('.remarks-autocom', this));
  73 + });
  74 +
  75 + //班次类型 和 上下行 切换事件
  76 + $(modal).on('change', '.add-sch-form [name=bcType],.add-sch-form [name=xlDir]', reCalcInputs_type);
  77 + //起终点站改变事件
  78 + $(modal).on('change', '[name=qdzCode],[name=zdzCode]', reCalcInputs_station);
  79 + //开始时间和公里改变
  80 + $(modal).on('input', '.add-sch-form [name=fcsj],.add-sch-form [name=jhlc]', reCalcEndTime);
  81 +
  82 +
  83 + function reCalcInputs_type() {
  84 + var f = $(this).parents('.add-sch-form');
  85 + var bcType_e = $('[name=bcType]', f)
  86 + , xlDir_e = $('[name=xlDir]', f);
  87 +
  88 + var routes = stationRoutes[xlDir_e.val()]
  89 + , lastCode = routes[routes.length - 1].stationCode
  90 + , opts = '', park_opts = '';
  91 + //station options
  92 + $.each(routes, function () {
  93 + opts += '<option value="' + this.stationCode + '">' + this.stationName + '</option>'
  94 + });
  95 + //park options
  96 + for(var i=0,p;p=parks[i++];)
  97 + park_opts += '<option value="' + p.code + '">' + p.name + '</option>';
  98 +
  99 + var qdz = $('[name=qdzCode]', f), zdz = $('[name=zdzCode]', f);
  100 + //var time, mileage;
  101 + switch (bcType_e.val()) {
  102 + case 'out':
  103 + qdz.html(park_opts).val(information.carPark);
  104 + zdz.html(opts);
  105 + break;
  106 + case 'in':
  107 + qdz.html(opts);
  108 + zdz.html(park_opts).val(information.carPark);
  109 + break;
  110 + default:
  111 + qdz.html(opts);
  112 + zdz.html(opts).val(lastCode);
  113 + }
  114 +
  115 + zdz.trigger('change');
  116 + f.trigger('ct_callback');
  117 + }
  118 +
  119 + function reCalcInputs_station() {
  120 + var f = $(this).parents('form'),
  121 + bcType = $('[name=bcType]', f).val(),
  122 + qdzCode = $('[name=qdzCode]', f).val(),
  123 + zdzCode =$('[name=zdzCode]', f).val(),
  124 + startDate = $('[name=fcsj]', f).val(),
  125 + upDown = $('[name=xlDir]', f).val(), mileage, time;
  126 +
  127 + //从站到场里获取数据
  128 + var stp = search_st_park(f);
  129 + if(stp){
  130 + mileage=bcType=='in'?stp['mileage1']:stp['mileage2'];
  131 + time=bcType=='in'?stp['time1']:stp['time2'];
  132 + }
  133 + else{
  134 + switch (upDown + '_' + bcType) {
  135 + case '0_out'://上行出场
  136 + mileage = information.upOutMileage;
  137 + time = information.upOutTimer;
  138 + break;
  139 + case '1_out'://下行出场
  140 + mileage = information.downOutMileage;
  141 + time = information.downOutTimer;
  142 + break;
  143 + case '0_in'://上行进场
  144 + mileage = information.upInMileage;
  145 + time = information.upInTimer;
  146 + break;
  147 + case '1_in'://下行进场
  148 + mileage = information.downInMileage;
  149 + time = information.downInTimer;
  150 + break;
  151 + default:
  152 +
  153 + var qc_time=upDown==0?information.upTravelTime:information.downTravelTime,
  154 + qc_mileage=upDown==0?information.upMileage:information.downMileage, _type;
  155 + if(is_normal_sch(f)){
  156 + _type='normal';
  157 + mileage=qc_mileage;
  158 + }
  159 + else{
  160 + _type='region';
  161 + mileage = calcMileage(stationRoutes[upDown], qdzCode, zdzCode);
  162 + }
  163 +
  164 + time = gb_common.mul(gb_common.accDiv(qc_time, qc_mileage), mileage);
  165 + if(bcType!='ldks' && bcType!='major' && bcType!='venting')
  166 + $('[name=bcType]', f).val(_type);
  167 + }
  168 + }
  169 +
  170 + $('[name=jhlc]', f).val(mileage);
  171 + var et = moment(startDate, 'HH:mm').add(time, 'minutes');
  172 + $f('zdsj', f).val(et.format('HH:mm'));
  173 + f.trigger('ct_callback');
  174 + }
  175 +
  176 +
  177 + function reCalcEndTime() {
  178 + var f = $(this).parents('.add-sch-form')
  179 + , startDate = $f('fcsj', f).val()//开始时间
  180 + , mileage = $f('jhlc', f).val()//公里
  181 + , type2 = $f('bcType', f).val(),//班次类型
  182 + upDown = $('[name=xlDir]', f).val();
  183 + if (!startDate || !mileage)
  184 + return;
  185 +
  186 + var time;
  187 + //从站到场里获取数据
  188 + var stp = search_st_park(f);
  189 + if(stp){
  190 + time=type2=='in'?stp['time1']:stp['time2'];
  191 + }
  192 + else{
  193 + if (type2 == 'in')
  194 + time = upDown == 0 ? information.upInTimer : information.downInTimer;
  195 + else if (type2 == 'out')
  196 + time = upDown == 0 ? information.upOutTimer : information.downOutTimer;
  197 + else{
  198 + var qc_time=upDown==0?information.upTravelTime:information.downTravelTime,
  199 + qc_mileage=upDown==0?information.upMileage:information.downMileage;
  200 +
  201 + time = gb_common.mul(gb_common.accDiv(qc_time, qc_mileage), mileage);
  202 + }
  203 + }
  204 +
  205 + var et = moment(startDate, 'HH:mm').add(time, 'minutes');
  206 + $f('zdsj', f).val(et.format('HH:mm'));
  207 + f.trigger('ct_callback');
  208 + }
  209 +
  210 + function is_normal_sch(f) {
  211 + var qdzCode = $('[name=qdzCode]', f).val(),
  212 + zdzCode =$('[name=zdzCode]', f).val(),
  213 + upDown = $('[name=xlDir]', f).val(),
  214 + rts = stationRoutes[upDown];
  215 +
  216 + if(rts[0].stationCode == qdzCode
  217 + && rts[rts.length - 1].stationCode == zdzCode)
  218 + return true;
  219 + else
  220 + return false;
  221 + }
  222 +
  223 + function isInOut(bcType) {
  224 + return bcType=='in' || bcType=='out';
  225 + }
  226 +
  227 + /**
  228 + * 计算线路上站点间公里
  229 + */
  230 + function calcMileage(rts, s, e) {
  231 + var mileage = 0, flag, code;
  232 + $.each(rts, function () {
  233 + code = this['stationCode'];
  234 + if (flag)
  235 + mileage = gb_common.accAdd(mileage, this.distances);
  236 + if (code == s)
  237 + flag = true;
  238 + if (code == e)
  239 + return false;
  240 + });
  241 + return mileage;
  242 + }
  243 +
  244 + function search_st_park(f) {
  245 + if(!st_park_data)
  246 + return;
  247 + var stp;
  248 + var qdSelect=$f('qdzCode', f)[0],zdSelect=$f('zdzCode', f)[0];
  249 +
  250 + if(qdSelect.options.selectedIndex < 0 || zdSelect.options.selectedIndex < 0)
  251 + return;
  252 + var qdzName=qdSelect.options[qdSelect.options.selectedIndex].text,
  253 + zdzName=zdSelect.options[zdSelect.options.selectedIndex].text,
  254 + type2 = $f('bcType', f).val();
  255 +
  256 + if(!isInOut(type2))
  257 + return;
  258 +
  259 + $.each(st_park_data, function () {
  260 + if((type2=='in' && this.stationName==qdzName && this.parkName==zdzName)
  261 + || (type2=='out' && this.stationName==zdzName && this.parkName==qdzName)){
  262 + stp = this;
  263 + return false;
  264 + }
  265 + });
  266 +
  267 + return stp;
  268 + }
  269 +
  270 + /**
  271 + * 停车场排序
  272 + * @param parks 停车场 code 2 name
  273 + * @param information 线路标准
  274 + * @param st_park_data 站到场
  275 + */
  276 + function sort_parks(parks, information, st_park_data) {
  277 + var array = [], names=[];
  278 + for(var code in parks){
  279 + array.push({code: code, name: parks[code]});
  280 + }
  281 +
  282 + if(st_park_data && st_park_data.length > 0){
  283 + $.each(st_park_data, function () {
  284 + names.push(this.parkName);
  285 + });
  286 + }
  287 +
  288 + //debugger
  289 + array.sort(function (a, b) {
  290 + if(a.code==information.carPark)
  291 + return -1;
  292 + if(b.code==information.carPark)
  293 + return 1;
  294 +
  295 + var ai = names.indexOf(a.name),
  296 + bi = names.indexOf(b.name);
  297 +
  298 + if(ai!=-1 && bi==-1)
  299 + return -1;
  300 + else if(ai==-1 && bi!=-1)
  301 + return 1;
  302 + else
  303 + return $.trim(a.name).localeCompare($.trim(b.name), 'zh-CN');
  304 + });
  305 + return array;
  306 + }
  307 +
  308 + function $f(name, f) {
  309 + return $('[name=' + name + ']', f);
  310 + }
  311 +
  312 + /**
  313 + * 提交表单
  314 + */
  315 + function submit_temp_schedule_form(data, cb, err) {
  316 + data.xlBm = sch.xlBm;
  317 + data.xlName = sch.xlName;
  318 + data.lpName = sch.lpName;
  319 + //拆分驾驶员工号和姓名
  320 + data.jGh = data.jsy.split('/')[0];
  321 + data.jName = data.jsy.split('/')[1];
  322 + delete data.jsy;
  323 + //拆分售票员工号和姓名
  324 + if (data.spy != '') {
  325 + data.sGh = data.spy.split('/')[0];
  326 + data.sName = data.spy.split('/')[1];
  327 + delete data.spy;
  328 + }
  329 +
  330 + //公司信息
  331 + var line = gb_data_basic.findLineByCodes([data.xlBm]);
  332 + if(line && line.length > 0){
  333 + line = line[0];
  334 + data.gsBm = line.company;
  335 + data.fgsBm = line.brancheCompany;
  336 + }
  337 +
  338 + gb_common.$post('/realSchedule', data, function (rs) {
  339 + notify_succ('新增临加班次成功');
  340 + cb && cb(rs);
  341 + }, err);
  342 + }
  343 + })();
  344 + </script>
345 345 </div>
346 346 \ No newline at end of file
... ...