Commit 0875b4c403735c0106774af45f425f2410a4fc8b

Authored by 潘钊
1 parent 98ed5abf

update

src/main/java/com/bsth/controller/realcontrol/BasicDataController.java
1 package com.bsth.controller.realcontrol; 1 package com.bsth.controller.realcontrol;
2 2
3 -import java.util.HashMap;  
4 -import java.util.List;  
5 -import java.util.Map;  
6 -  
7 -import org.springframework.web.bind.annotation.RequestMapping;  
8 -import org.springframework.web.bind.annotation.RestController;  
9 -  
10 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
11 import com.alibaba.fastjson.serializer.PropertyFilter; 4 import com.alibaba.fastjson.serializer.PropertyFilter;
12 import com.bsth.data.BasicData; 5 import com.bsth.data.BasicData;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RestController;
  8 +
  9 +import java.util.HashMap;
  10 +import java.util.List;
  11 +import java.util.Map;
13 12
14 @RestController 13 @RestController
15 @RequestMapping("/basic") 14 @RequestMapping("/basic")
src/main/java/com/bsth/entity/realcontrol/ChildTaskPlan.java
1 package com.bsth.entity.realcontrol; 1 package com.bsth.entity.realcontrol;
2 2
3 -import javax.persistence.Entity;  
4 -import javax.persistence.FetchType;  
5 -import javax.persistence.GeneratedValue;  
6 -import javax.persistence.Id;  
7 -import javax.persistence.ManyToOne;  
8 -import javax.persistence.NamedAttributeNode;  
9 -import javax.persistence.NamedEntityGraph;  
10 -import javax.persistence.NamedEntityGraphs;  
11 -import javax.persistence.Table;  
12 -  
13 import com.fasterxml.jackson.annotation.JsonIgnore; 3 import com.fasterxml.jackson.annotation.JsonIgnore;
14 4
  5 +import javax.persistence.*;
  6 +import java.util.Date;
  7 +
15 8
16 /** 9 /**
17 * 10 *
@@ -95,6 +88,10 @@ public class ChildTaskPlan { @@ -95,6 +88,10 @@ public class ChildTaskPlan {
95 */ 88 */
96 private String destroyReason; 89 private String destroyReason;
97 90
  91 + /** 创建日期 */
  92 + @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  93 + private Date createDate;
  94 +
98 /** 95 /**
99 * 主排班计划 96 * 主排班计划
100 */ 97 */
@@ -233,4 +230,12 @@ public class ChildTaskPlan { @@ -233,4 +230,12 @@ public class ChildTaskPlan {
233 public boolean equals(Object obj) { 230 public boolean equals(Object obj) {
234 return this.id.equals(((ChildTaskPlan)obj).getId()); 231 return this.id.equals(((ChildTaskPlan)obj).getId());
235 } 232 }
  233 +
  234 + public Date getCreateDate() {
  235 + return createDate;
  236 + }
  237 +
  238 + public void setCreateDate(Date createDate) {
  239 + this.createDate = createDate;
  240 + }
236 } 241 }
src/main/resources/static/real_control_v2/css/ct_table.css
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 background: #f5f5f5; 18 background: #f5f5f5;
19 width: 100%; 19 width: 100%;
20 line-height: 30px; 20 line-height: 30px;
21 - z-index: 3; 21 + z-index: 1;
22 } 22 }
23 23
24 .ct_table>.ct_table_head dl { 24 .ct_table>.ct_table_head dl {
src/main/resources/static/real_control_v2/css/main.css
@@ -318,13 +318,13 @@ li.map-panel{ @@ -318,13 +318,13 @@ li.map-panel{
318 318
319 .uk-panel-box-danger { 319 .uk-panel-box-danger {
320 background-color: #fff1f0; 320 background-color: #fff1f0;
321 - color: #d85030; 321 + /*color: #d85030;*/
322 border-color: rgba(216,80,48,.3); 322 border-color: rgba(216,80,48,.3);
323 } 323 }
324 324
325 -.uk-panel-box-danger .uk-panel-title { 325 +/*.uk-panel-box-danger .uk-panel-title {
326 color: #d85030; 326 color: #d85030;
327 -} 327 +}*/
328 328
329 .uk-badge-default { 329 .uk-badge-default {
330 background-color: #a09b9c; 330 background-color: #a09b9c;
@@ -353,6 +353,9 @@ li.map-panel{ @@ -353,6 +353,9 @@ li.map-panel{
353 color: #c3c3c3; 353 color: #c3c3c3;
354 width: 20px; 354 width: 20px;
355 line-height: 20px; 355 line-height: 20px;
  356 + background: #fff;
  357 + text-align: center;
  358 + z-index: 99;
356 } 359 }
357 360
358 .ct-bottom-drawer a.ct-bottom-drawer-close:hover{ 361 .ct-bottom-drawer a.ct-bottom-drawer-close:hover{
@@ -396,5 +399,110 @@ li.map-panel{ @@ -396,5 +399,110 @@ li.map-panel{
396 stroke: rgb(62, 80, 179); 399 stroke: rgb(62, 80, 179);
397 fill: rgb(62, 80, 179); 400 fill: rgb(62, 80, 179);
398 width: 30px; 401 width: 30px;
399 - height: 140px;  
400 -}  
401 \ No newline at end of file 402 \ No newline at end of file
  403 + height: 124px;
  404 + rx: 5;
  405 + transform: translate(-15px);
  406 +}
  407 +
  408 +
  409 +#station_route_spacing_chart_drawer svg g._item text{
  410 + writing-mode: tb;
  411 + transform: translate(0, 9px);
  412 + fill: #fff;
  413 +}
  414 +
  415 +#station_route_spacing_chart_drawer svg g._item path{
  416 + stroke-width: 5.4px;
  417 + stroke: #3e50b3;
  418 +}
  419 +
  420 +#station_route_spacing_chart_drawer svg g._item circle{
  421 + r: 3px;
  422 + fill: #ffffff;
  423 +}
  424 +
  425 +#station_route_spacing_chart_drawer svg g._item path.arc_path{
  426 + stroke-width:1.3px;
  427 + stroke:#3e50b3;
  428 + stroke-dasharray: 1000;
  429 + stroke-dashoffset: 1000;
  430 + fill: none;
  431 +
  432 + animation: dash .9s;
  433 + webkit-amimation: dash .9s;
  434 + animation-fill-mode: forwards;
  435 + -webkit-animation-fill-mode: forwards;
  436 +}
  437 +
  438 +@keyframes dash {
  439 + to {
  440 + stroke-dashoffset: 0;
  441 + stroke-dasharray: 4,4;
  442 + }
  443 +}
  444 +
  445 +@-webkit-keyframes dash{
  446 + to {
  447 + stroke-dashoffset: 0;
  448 + stroke-dasharray: 4,4;
  449 + }
  450 +}
  451 +
  452 +#station_route_spacing_chart_drawer svg g._item text.distance_text{
  453 + writing-mode: horizontal-tb;
  454 + fill: #3e50b3;
  455 +}
  456 +
  457 +#station_route_spacing_chart_drawer svg g._item rect.distance_rect{
  458 + height: 20px;
  459 + width: 40px;
  460 + fill: #fff !important;
  461 + stroke-width: 0;
  462 +}
  463 +
  464 +#station_route_spacing_chart_drawer .tl_desc_text{
  465 + position: absolute;
  466 + top: 5px;
  467 + left: 5px;
  468 + font-size: 12px;
  469 + color: #525050;
  470 + font-family: 微软雅黑;
  471 +}
  472 +
  473 +#station_route_spacing_chart_drawer svg g._item:first-child circle{
  474 + fill: #3e50b3;
  475 + r: 6px;
  476 +}
  477 +
  478 +#station_route_spacing_chart_drawer svg g._item:last-child circle{
  479 + fill: #3e50b3;
  480 + r: 6px;
  481 +}
  482 +
  483 +
  484 +/* 下行 */
  485 +#station_route_spacing_chart_drawer svg.down g._item rect{
  486 + stroke: #dd3829;
  487 + fill: #dd3829;
  488 +}
  489 +
  490 +#station_route_spacing_chart_drawer svg.down g._item path{
  491 + stroke: #dd3829;
  492 +}
  493 +
  494 +#station_route_spacing_chart_drawer svg.down g._item:first-child circle{
  495 + fill: #dd3829;
  496 +}
  497 +
  498 +#station_route_spacing_chart_drawer svg.down g._item text.distance_text{
  499 + fill: #dd3829;
  500 +}
  501 +
  502 +#station_route_spacing_chart_drawer svg.down g._item path.arc_path{
  503 + stroke: #dd3829;
  504 +}
  505 +
  506 +#station_route_spacing_chart_drawer svg.down g._item:last-child circle{
  507 + fill: #dd3829;
  508 +}
  509 +
src/main/resources/static/real_control_v2/fragments/geo/calc_station_space.html
1 <!-- 嵌入下抽屉 --> 1 <!-- 嵌入下抽屉 -->
  2 +<a class="ct-bottom-drawer-close"></a>
2 <div id="cal_station_space_drawer" style="width: 100%;height: 100%;"> 3 <div id="cal_station_space_drawer" style="width: 100%;height: 100%;">
3 4
4 <div style="text-align: center;padding-top: 30px;" class="calcBeforePanel"> 5 <div style="text-align: center;padding-top: 30px;" class="calcBeforePanel">
@@ -10,7 +11,7 @@ @@ -10,7 +11,7 @@
10 <span style="color: grey;font-size: 12px;">该操作会借用本地计算能力进行,如果你同意,请点击下方按钮!</span> 11 <span style="color: grey;font-size: 12px;">该操作会借用本地计算能力进行,如果你同意,请点击下方按钮!</span>
11 </p> 12 </p>
12 <p style="margin: 9px 0 9px 0;"> 13 <p style="margin: 9px 0 9px 0;">
13 - <button class="uk-button uk-button-large uk-button-primary" type="button" id="startCalcBtn">开始计算</button> 14 + <button class="uk-button uk-button-large uk-button-primary" type="button" id="startCalcBtn">开始计算站距</button>
14 </p> 15 </p>
15 </div> 16 </div>
16 17
@@ -46,13 +47,17 @@ @@ -46,13 +47,17 @@
46 $('.calcBeforePanel', drawer).hide(); 47 $('.calcBeforePanel', drawer).hide();
47 $('.pace', drawer).show(); 48 $('.pace', drawer).show();
48 49
49 - startGeoCalc(spatialData); 50 + if(!spatialData.section || spatialData.section.length==0){
  51 + alert('线路编码无法对查到路段信息,请通知系统管理员');
  52 + notify_err('线路编码无法对查到路段信息,请通知系统管理员');
  53 + }
  54 + else
  55 + startGeoCalc(spatialData);
50 }); 56 });
51 } 57 }
52 58
53 function startGeoCalc(spatialData) { 59 function startGeoCalc(spatialData) {
54 setCalcText('初始化数据'); 60 setCalcText('初始化数据');
55 - //console.log('spatialData', spatialData);  
56 //路段上下行分组排序 61 //路段上下行分组排序
57 var sections = gb_common.groupBy(spatialData.section, 'DIRECTIONS'); 62 var sections = gb_common.groupBy(spatialData.section, 'DIRECTIONS');
58 sections[0].sort(sectionArrSort); 63 sections[0].sort(sectionArrSort);
@@ -71,25 +76,107 @@ @@ -71,25 +76,107 @@
71 76
72 setCalcText('计算上行数据'); 77 setCalcText('计算上行数据');
73 var upCalcRs = calcStationSpace(stations[0], fullSections[0]); 78 var upCalcRs = calcStationSpace(stations[0], fullSections[0]);
  79 + /*var upReverse = checkReverse(upCalcRs);
  80 + if(upReverse){
  81 +
  82 + }*/
74 83
75 setCalcText('计算下行数据'); 84 setCalcText('计算下行数据');
76 var downCalcRs = calcStationSpace(stations[1], fullSections[1]); 85 var downCalcRs = calcStationSpace(stations[1], fullSections[1]);
77 86
  87 + var upSum = sumMileage(upCalcRs) / 1000
  88 + , downSum = sumMileage(downCalcRs) / 1000;
  89 + //线路标准
  90 + var info = gb_data_basic.getLineInformation(sch.xlBm);
  91 +
  92 + //计算误差值
  93 + var upDiff = (info.upMileage - upSum).toFixed(2),
  94 + downDiff = (info.downMileage - downSum).toFixed(2);
  95 +
  96 + //均摊误差值,统一数据
  97 + var upPlus = calcAvgDiff(upDiff, upCalcRs, info.upMileage);
  98 + var downPlus = calcAvgDiff(downDiff, downCalcRs, info.downMileage);
  99 +
  100 + //写入localStorage
78 var locData = { 101 var locData = {
79 stations: {up: upCalcRs, down: downCalcRs}, 102 stations: {up: upCalcRs, down: downCalcRs},
80 sections: {up: fullSections[0], down: fullSections[1]} 103 sections: {up: fullSections[0], down: fullSections[1]}
81 }; 104 };
82 105
83 - window.localStorage.setItem('control_route_distance_' + sch.xlBm, JSON.stringify(locData));  
84 - //console.log('结果', locData); 106 + //误差小于3公里才接受
  107 + upSuccess = Math.abs(upDiff) <= 3;
  108 + downSuccess = Math.abs(downDiff) <= 3;
  109 + if(upSuccess && downSuccess){
  110 + window.localStorage.setItem('control_route_distance_' + sch.xlBm, JSON.stringify(locData));
  111 + //刷新父页面
  112 + console.log('$(drawer).parents', $(drawer).parents('.uk-modal'));
  113 + $(drawer).parents('.uk-modal').trigger('refresh_station_space');
  114 + }
  115 +
  116 + //线路信息
  117 + var line = gb_data_basic.codeToLine[sch.xlBm];
  118 + var data = {
  119 + upSum: upSum,
  120 + downSum: downSum,
  121 + upMileage: info.upMileage,
  122 + downMileage: info.downMileage,
  123 + upDiff: upDiff,
  124 + downDiff: downDiff,
  125 + upSuccess: upSuccess,
  126 + downSuccess: downSuccess,
  127 + lineId: line.id,
  128 + upStationCount: upCalcRs.length,
  129 + downStationCount: downCalcRs.length,
  130 + upPlus: upPlus,
  131 + downPlus : downPlus
  132 + };
  133 + open_modal('/real_control_v2/fragments/geo/calc_station_space_rs.html' ,data, {bgclose:false, keyboard:false, modal:false});
  134 + //UIkit.modal.alert(template('cal_station_space_result-temp', data), {labels: {Ok: '我明白了'}});
  135 +
  136 + //跳转
  137 + drawerLoadPage('/real_control_v2/fragments/line_schedule/context_menu/sub_task/station_route_spacing_chart.html'
  138 + , 'station_route_spacing_chart_drawer');
  139 + }
  140 +
  141 +
  142 + //均摊差值
  143 + function calcAvgDiff(diff, array, validate) {
  144 + //余数扔在第一个站距上
  145 + var more = (diff * 1000) % (array.length - 1);
  146 + if(more > 0)
  147 + array[1].toDistance = gb_common.accAdd(array[1].toDistance, more);
  148 +
  149 + var t = parseInt((diff * 1000) / (array.length - 1));
  150 + for(var i = 1; i < array.length; i++){
  151 + array[i].toDistance = gb_common.accAdd(array[i].toDistance, t);
  152 + }
  153 +
  154 + var sumGl=0;
  155 + $.each(array, function () {
  156 + this.toDistanceGl = parseFloat((this.toDistance / 1000).toFixed(2));
  157 + sumGl = gb_common.accAdd(sumGl, this.toDistanceGl);
  158 + });
  159 +
  160 + //丢失的精度
  161 + diff = ((validate * 1000) - (sumGl * 1000)) / 1000;
  162 + array[1].toDistanceGl = gb_common.accAdd(array[1].toDistanceGl, diff);
  163 + return t;
  164 + }
  165 +
  166 + function sumMileage(array) {
  167 + var sum = 0;
  168 + $.each(array, function () {
  169 + sum += this.toDistance;
  170 + });
  171 + return sum;
85 } 172 }
86 173
87 function sectionArrSort(s1, s2) { 174 function sectionArrSort(s1, s2) {
88 - return s1.SECTIONROUTE_CODE - s2.SECTIONROUTE_CODE; 175 + return s1['SECTIONROUTE_CODE'] - s2['SECTIONROUTE_CODE'];
89 } 176 }
90 177
91 function stationArrSort(s1, s2) { 178 function stationArrSort(s1, s2) {
92 - return s1.STATION_ROUTE_CODE - s2.STATION_ROUTE_CODE; 179 + return s1['STATION_ROUTE_CODE'] - s2['STATION_ROUTE_CODE'];
93 } 180 }
94 181
95 function setCalcText(t) { 182 function setCalcText(t) {
@@ -102,7 +189,7 @@ @@ -102,7 +189,7 @@
102 189
103 var vs, temps; 190 var vs, temps;
104 for (var i = 0, section; section = sectionArray[i++];) { 191 for (var i = 0, section; section = sectionArray[i++];) {
105 - vs = section.GSECTION_VECTOR; 192 + vs = section['GSECTION_VECTOR'];
106 temps = vs.substr(11, vs.length - 2).split(','); 193 temps = vs.substr(11, vs.length - 2).split(',');
107 194
108 connectCoords(coords, temps); 195 connectCoords(coords, temps);
@@ -111,6 +198,34 @@ @@ -111,6 +198,34 @@
111 } 198 }
112 199
113 function connectCoords(all, subArr) { 200 function connectCoords(all, subArr) {
  201 +/* var point, len = all.length, inLine, overlap;
  202 +
  203 + var array = [];
  204 + $.each(subArr, function (i, p) {
  205 + var ts = p.split(' ');
  206 + array.push({latitude: parseFloat(ts[1]), longitude: parseFloat(ts[0])});
  207 + });
  208 +
  209 + //all 最后一个位于subArr 上的点位
  210 + for(var i = 0; i < len; i ++){
  211 + point = all[i];
  212 + for(var j = 1; j < array.length; j ++){
  213 + inLine = geolib.isPointInLine(point, array[j - 1], array[j]);
  214 + if(inLine)
  215 + overlap = {s1: i,s2: j};
  216 + }
  217 + }
  218 +
  219 + //拼接
  220 + if(overlap){
  221 + all = all.slice(0, overlap.s1 + 1);
  222 + array = array.slice(overlap.s2);
  223 + }
  224 +
  225 + for(var z = 0; z < array.length; z++){
  226 + all.push(array[z]);
  227 + }
  228 + return all;*/
114 229
115 var point, ts, len = all.length, inLine, sIndex = 0; 230 var point, ts, len = all.length, inLine, sIndex = 0;
116 if (len > 0) { 231 if (len > 0) {
@@ -141,14 +256,21 @@ @@ -141,14 +256,21 @@
141 256
142 //计算站点间距 257 //计算站点间距
143 function calcStationSpace(stations, coords) { 258 function calcStationSpace(stations, coords) {
  259 + //起始路段坐标点
  260 + var sei = calcPointToLineNearPoint({latitude: stations[0]['G_LATY'],longitude: stations[0]['G_LONX']
  261 + }, coords).index;
144 262
145 var nearArray = []; 263 var nearArray = [];
146 - for (var i = 1; i < stations.length; i++) { 264 + if(sei > coords.length - 5){
  265 + //路段路由反向
  266 + coords.reverse();
  267 + }
147 268
  269 + for (var i = 1; i < stations.length; i++) {
148 //点到线的最短距离 并计算交点坐标 270 //点到线的最短距离 并计算交点坐标
149 var rs = calcPointToLineNearPoint({ 271 var rs = calcPointToLineNearPoint({
150 - latitude: stations[i].G_LATY,  
151 - longitude: stations[i].G_LONX 272 + latitude: stations[i]['G_LATY'],
  273 + longitude: stations[i]['G_LONX']
152 }, coords); 274 }, coords);
153 rs.station = stations[i]; 275 rs.station = stations[i];
154 276
@@ -156,7 +278,6 @@ @@ -156,7 +278,6 @@
156 coords.splice(rs.index, 0, rs.intersection); 278 coords.splice(rs.index, 0, rs.intersection);
157 279
158 nearArray.push(rs); 280 nearArray.push(rs);
159 - //console.log('站点' + i + '计算结果', rs.intersection, rs);  
160 } 281 }
161 282
162 //根据交点截断line,并计算距离 283 //根据交点截断line,并计算距离
@@ -167,8 +288,7 @@ @@ -167,8 +288,7 @@
167 for (; s < e; s++) { 288 for (; s < e; s++) {
168 distance += geolib.getDistance(coords[s], coords[s + 1]); 289 distance += geolib.getDistance(coords[s], coords[s + 1]);
169 } 290 }
170 -  
171 - this.toDistance = distance; 291 + this.toDistance = parseFloat(distance.toFixed(2));
172 s = e; 292 s = e;
173 }); 293 });
174 294
@@ -225,6 +345,13 @@ @@ -225,6 +345,13 @@
225 return {longitude: lon, latitude: lat}; 345 return {longitude: lon, latitude: lat};
226 } 346 }
227 347
  348 + //页面切换
  349 + function drawerLoadPage(url, id) {
  350 + $(drawer).parent('.ct-bottom-drawer-body').load(url, function () {
  351 + $('#' + id).trigger('drawer-init', {sch: sch});
  352 + });
  353 + }
  354 +
228 })(); 355 })();
229 </script> 356 </script>
230 </div> 357 </div>
231 \ No newline at end of file 358 \ No newline at end of file
src/main/resources/static/real_control_v2/fragments/geo/calc_station_space_rs.html 0 → 100644
  1 +<div class="uk-modal ct-form-modal" id="calc_station_space_rs-modal">
  2 + <div class="uk-modal-dialog" style="width: 900px;">
  3 + <div class="uk-modal-header">
  4 + <h2>计算完成</h2></div>
  5 +
  6 + <div class="_modal_body">
  7 +
  8 + </div>
  9 +
  10 + <div class="uk-modal-footer uk-text-right" >
  11 + <button type="button" class="uk-button uk-button-primary uk-modal-close" autofocus>我明白了</button>
  12 + </div>
  13 + </div>
  14 +
  15 +
  16 + <script id="cal_station_space_result-temp" type="text/html">
  17 + <div>
  18 + <div>
  19 + <table class="uk-table">
  20 + <tr>
  21 + <th>走向</th>
  22 + <th>
  23 + 计算结果(总里程)
  24 + </th>
  25 + <th>
  26 + 线路标准(总里程)
  27 + </th>
  28 + <th>
  29 + 误差(公里)
  30 + </th>
  31 + <th>
  32 + 站点数
  33 + </th>
  34 + <th>
  35 + 处理
  36 + </th>
  37 + </tr>
  38 + <tr>
  39 + <td>
  40 + 上行
  41 + </td>
  42 + <td>
  43 + {{upSum}}
  44 + </td>
  45 + <td>
  46 + <a href="/pages/base/lineinformation/list.html?no={{lineId}}" target="_blank">
  47 + {{upMileage}}
  48 + </a>
  49 + </td>
  50 + <td>
  51 + {{upDiff}}
  52 + </td>
  53 + <td>
  54 + {{upStationCount}}
  55 + </td>
  56 + <td>
  57 + {{if upSuccess}}
  58 + <div> 每站{{if upPlus>0}}加{{else}}减{{/if}} {{upPlusAbs}} 米 </div>
  59 + {{else}}
  60 + <div style="color: red">误差过大,请确认基础数据的准确性!</div>
  61 + {{/if}}
  62 + </td>
  63 + </tr>
  64 +
  65 + <tr>
  66 + <td>
  67 + 下行
  68 + </td>
  69 + <td>
  70 + {{downSum}}
  71 + </td>
  72 + <td>
  73 + <a href="/pages/base/lineinformation/list.html?no={{lineId}}" target="_blank">
  74 + {{downMileage}}
  75 + </a>
  76 + </td>
  77 + <td>
  78 + {{downDiff}}
  79 + </td>
  80 + <td>
  81 + {{downStationCount}}
  82 + </td>
  83 + <td>
  84 + {{if downSuccess}}
  85 + <div>每站{{if downPlus>0}}加{{else}}减{{/if}} {{downPlusAbs}} 米 </div>
  86 + {{else}}
  87 + <div style="color: red">误差过大,请确认基础数据的准确性!</div>
  88 + {{/if}}
  89 + </td>
  90 + </tr>
  91 + </table>
  92 + </div>
  93 + <h6 style="color: #808080">如果希望计算结果更精准,请检查线路和站点走向,并确认站点准确的点在路段上</h6>
  94 + </div>
  95 + </script>
  96 +
  97 + <script>
  98 + (function () {
  99 + var modal = '#calc_station_space_rs-modal';
  100 +
  101 + $(modal).on('init', function (e,data) {
  102 + data.upPlusAbs = Math.abs(data.upPlus);
  103 + data.downPlusAbs = Math.abs(data.downPlus);
  104 +
  105 + var htmlStr = template('cal_station_space_result-temp', data);
  106 + $('._modal_body', modal).html(htmlStr);
  107 + });
  108 + })();
  109 + </script>
  110 +</div>
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/lj_zrw.html
@@ -291,10 +291,12 @@ @@ -291,10 +291,12 @@
291 gb_common.$del('/childTask/' + id, function (rs) { 291 gb_common.$del('/childTask/' + id, function (rs) {
292 gb_schedule_table.updateSchedule(rs.t); 292 gb_schedule_table.updateSchedule(rs.t);
293 notify_succ('删除子任务成功!'); 293 notify_succ('删除子任务成功!');
294 - //刷新班次列表  
295 - m_s_table_update();  
296 - //选中班次  
297 - selectedDl(rs.t); 294 + setTimeout(function () {
  295 + //刷新班次列表
  296 + m_s_table_update();
  297 + //选中班次
  298 + selectedDl(rs.t);
  299 + }, 300);
298 }); 300 });
299 }, '确定删除'); 301 }, '确定删除');
300 }; 302 };
@@ -322,8 +324,7 @@ @@ -322,8 +324,7 @@
322 name: "添加子任务", 324 name: "添加子任务",
323 items: { 325 items: {
324 'add_sub_task_in': { 326 'add_sub_task_in': {
325 - name: '回场',  
326 - disabled: true 327 + name: '回场'
327 }, 328 },
328 'add_sub_task_out': { 329 'add_sub_task_out': {
329 name: '出场', 330 name: '出场',
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task/add_sub_task_inpark.html
@@ -9,7 +9,22 @@ @@ -9,7 +9,22 @@
9 <div class="uk-panel uk-panel-box uk-panel-box-primary"> 9 <div class="uk-panel uk-panel-box uk-panel-box-primary">
10 <div class="uk-panel-badge uk-badge">营运</div> 10 <div class="uk-panel-badge uk-badge">营运</div>
11 <h3 class="uk-panel-title">线路上站点间</h3> 11 <h3 class="uk-panel-title">线路上站点间</h3>
12 - <form class="uk-form uk-form-horizontal" service_form> 12 + <form class="uk-form uk-form-horizontal inpark_form" service_form>
  13 + <input type="hidden" name="type2" value="1">
  14 + <input type="hidden" name="mileageType" value="service">
  15 + <div class="uk-grid">
  16 + <div class="uk-width-3-10">
  17 + <div class="uk-form-row">
  18 + <label class="uk-form-label">班次类型 </label>
  19 + </div>
  20 + </div>
  21 + <div class="uk-width-7-10 pl5">
  22 + <select name="type1" class="ct_focus" disabled>
  23 + <option value="正常">正常</option>
  24 + <option value="临加">临加</option>
  25 + </select>
  26 + </div>
  27 + </div>
13 <div class="uk-grid"> 28 <div class="uk-grid">
14 <div class="uk-width-3-10"> 29 <div class="uk-width-3-10">
15 <div class="uk-form-row"> 30 <div class="uk-form-row">
@@ -37,7 +52,7 @@ @@ -37,7 +52,7 @@
37 </div> 52 </div>
38 </div> 53 </div>
39 <div class="uk-width-7-10 pl5"> 54 <div class="uk-width-7-10 pl5">
40 - <input type="text" name="mileageType" required> 55 + <input type="text" name="mileage" required>
41 </div> 56 </div>
42 </div> 57 </div>
43 <div class="uk-grid"> 58 <div class="uk-grid">
@@ -67,7 +82,22 @@ @@ -67,7 +82,22 @@
67 <div class="uk-panel uk-panel-box uk-panel-box-secondary"> 82 <div class="uk-panel uk-panel-box uk-panel-box-secondary">
68 <div class="uk-panel-badge uk-badge uk-badge-default">空驶</div> 83 <div class="uk-panel-badge uk-badge uk-badge-default">空驶</div>
69 <h3 class="uk-panel-title">进场</h3> 84 <h3 class="uk-panel-title">进场</h3>
70 - <form class="uk-form uk-form-horizontal" empty_form> 85 + <form class="uk-form uk-form-horizontal inpark_form" empty_form>
  86 + <input type="hidden" name="type2" value="2">
  87 + <input type="hidden" name="mileageType" value="empty">
  88 + <div class="uk-grid">
  89 + <div class="uk-width-3-10">
  90 + <div class="uk-form-row">
  91 + <label class="uk-form-label">班次类型 </label>
  92 + </div>
  93 + </div>
  94 + <div class="uk-width-7-10 pl5">
  95 + <select name="type1" class="ct_focus">
  96 + <option value="正常">正常</option>
  97 + <option value="临加">临加</option>
  98 + </select>
  99 + </div>
  100 + </div>
71 <div class="uk-grid"> 101 <div class="uk-grid">
72 <div class="uk-width-3-10"> 102 <div class="uk-width-3-10">
73 <div class="uk-form-row"> 103 <div class="uk-form-row">
@@ -95,8 +125,8 @@ @@ -95,8 +125,8 @@
95 </div> 125 </div>
96 </div> 126 </div>
97 <div class="uk-width-7-10 pl5"> 127 <div class="uk-width-7-10 pl5">
98 - <input type="text" name="mileageType" required style="width: calc(100% - 62px);">  
99 - <a style="font-size: 12px;">路径(3)</a> 128 + <input type="text" name="mileage" required style="width: calc(100% - 62px);">
  129 + <a style="font-size: 12px;color: grey;cursor: default;" data-uk-tooltip title="可选择回场路径,设置途径点位。暂不开放" id="inpark_paths_link">路径(<span>0</span>)</a>
100 </div> 130 </div>
101 </div> 131 </div>
102 <div class="uk-grid"> 132 <div class="uk-grid">
@@ -126,7 +156,13 @@ @@ -126,7 +156,13 @@
126 <div class="uk-panel uk-panel-box uk-panel-box-danger"> 156 <div class="uk-panel uk-panel-box uk-panel-box-danger">
127 <div class="uk-panel-badge uk-badge uk-badge-danger">烂班</div> 157 <div class="uk-panel-badge uk-badge uk-badge-danger">烂班</div>
128 <h3 class="uk-panel-title">线路上站点间</h3> 158 <h3 class="uk-panel-title">线路上站点间</h3>
129 - <form class="uk-form uk-form-horizontal" destroy_form> 159 + <form class="uk-form uk-form-horizontal inpark_form" destroy_form>
  160 + <input type="hidden" value="正常" name="type1">
  161 + <input type="hidden" value="1" name="type2">
  162 + <input type="hidden" name="mileageType" value="service">
  163 + <input type="hidden" name="destroy" value="true">
  164 + <div class="uk-grid" style="height: 30px;">
  165 + </div>
130 <div class="uk-grid"> 166 <div class="uk-grid">
131 <div class="uk-width-3-10"> 167 <div class="uk-width-3-10">
132 <div class="uk-form-row"> 168 <div class="uk-form-row">
@@ -154,7 +190,7 @@ @@ -154,7 +190,7 @@
154 </div> 190 </div>
155 </div> 191 </div>
156 <div class="uk-width-7-10 pl5"> 192 <div class="uk-width-7-10 pl5">
157 - <input type="text" name="mileageType" required> 193 + <input type="text" name="mileage" required>
158 </div> 194 </div>
159 </div> 195 </div>
160 <div class="uk-grid"> 196 <div class="uk-grid">
@@ -182,13 +218,13 @@ @@ -182,13 +218,13 @@
182 </div> 218 </div>
183 219
184 <form class="uk-form" style="margin-top: 15px; padding: 0 10px 0 0;"> 220 <form class="uk-form" style="margin-top: 15px; padding: 0 10px 0 0;">
185 - <textarea placeholder="备注" style="width: 100%;height: 70px;"></textarea> 221 + <textarea placeholder="备注" style="width: 100%;height: 70px;" id="globalRemarks"></textarea>
186 </form> 222 </form>
187 </div> 223 </div>
188 224
189 <div class="uk-modal-footer uk-text-right"> 225 <div class="uk-modal-footer uk-text-right">
190 <button type="button" class="uk-button uk-modal-close">取消</button> 226 <button type="button" class="uk-button uk-modal-close">取消</button>
191 - <button type="button" class="uk-button uk-button-primary">提交子任务</button> 227 + <button type="button" class="uk-button uk-button-primary" id="submitChildTaskBtn">提交子任务</button>
192 228
193 <div class="ct-footer-left"> 229 <div class="ct-footer-left">
194 <a id="betweenStationRangeCalc" data-drawer-id="station_route_spacing_chart_drawer">站点间公里不准?</a> 230 <a id="betweenStationRangeCalc" data-drawer-id="station_route_spacing_chart_drawer">站点间公里不准?</a>
@@ -197,8 +233,6 @@ @@ -197,8 +233,6 @@
197 </div> 233 </div>
198 234
199 <div class="ct-bottom-drawer"> 235 <div class="ct-bottom-drawer">
200 - <a class="ct-bottom-drawer-close"></a>  
201 -  
202 <div class="ct-bottom-drawer-body"></div> 236 <div class="ct-bottom-drawer-body"></div>
203 </div> 237 </div>
204 238
@@ -215,34 +249,26 @@ @@ -215,34 +249,26 @@
215 var adjustExps = ['配车', '保养', '故障', '肇事', '路阻', '纠纷', '缺人', '客稀', '缺车', '气候', '援外', '吊慢', '抽减', '其他']; 249 var adjustExps = ['配车', '保养', '故障', '肇事', '路阻', '纠纷', '缺人', '客稀', '缺车', '气候', '援外', '吊慢', '抽减', '其他'];
216 $(modal).on('init', function (e, data) { 250 $(modal).on('init', function (e, data) {
217 sch = data.sch; 251 sch = data.sch;
218 - //var formHtml = template('sub-task-inpark-form-temp', {sch:sch, adjustExps: adjustExps});  
219 - //$('form', modal).html(formHtml);  
220 - //字典转换  
221 - //dictionaryUtils.transformDom($('.nt-dictionary', modal));  
222 252
223 //站点路由 253 //站点路由
224 stationRoutes = gb_common.groupBy(gb_data_basic.stationRoutes(sch.xlBm).sort(function (a, b) { 254 stationRoutes = gb_common.groupBy(gb_data_basic.stationRoutes(sch.xlBm).sort(function (a, b) {
225 return a.stationRouteCode - b.stationRouteCode; 255 return a.stationRouteCode - b.stationRouteCode;
226 }), 'directions')[sch.xlDir]; 256 }), 'directions')[sch.xlDir];
227 //空驶终点(停车场) 257 //空驶终点(停车场)
  258 + //切换进场终点
  259 + $('select[name=endStation]', emptyForm).on('change', inparkNavigation);
228 $.get('/basic/parks', function (rs) { 260 $.get('/basic/parks', function (rs) {
229 parks = rs; 261 parks = rs;
230 var opts = ''; 262 var opts = '';
231 for (var code in parks) { 263 for (var code in parks) {
232 opts += '<option value="' + code + '">' + parks[code] + '</option>'; 264 opts += '<option value="' + code + '">' + parks[code] + '</option>';
233 } 265 }
234 - $('select[name=endStation]', emptyForm).html(opts).val(information.carPark); 266 + $('select[name=endStation]', emptyForm).html(opts).val(information.carPark).trigger('change');
235 }); 267 });
236 //线路标准 268 //线路标准
237 information = gb_data_basic.getLineInformation(sch.xlBm); 269 information = gb_data_basic.getLineInformation(sch.xlBm);
238 //本地存储的站点耗时 270 //本地存储的站点耗时
239 - try {  
240 - timeLocStations = window.localStorage.getItem('control_route_distance_' + sch.xlBm);  
241 - if (timeLocStations)  
242 - timeLocStations = JSON.parse(timeLocStations).stations[sch.xlDir == 0 ? 'up' : 'down'];  
243 - } catch (e) {  
244 - console.log(e);  
245 - } 271 + getLocStationsSpace();
246 272
247 //设置默认值 273 //设置默认值
248 setDefaultVal(); 274 setDefaultVal();
@@ -263,18 +289,81 @@ @@ -263,18 +289,81 @@
263 }).trigger('change'); 289 }).trigger('change');
264 290
265 291
  292 + var dataArray = [];
  293 + var fs = $('form.inpark_form', modal).formValidation({
  294 + framework: 'uikit',
  295 + locale: 'zh_CN'
  296 + });
  297 + fs.on('success.form.fv', function(e) {
  298 + e.preventDefault();
  299 + if($(this).is(':hidden'))
  300 + return;
  301 + dataArray.push($.extend($(this).serializeJSON(), getDisabledVal(this)
  302 + , {remarks: $('#globalRemarks',modal).val(), 'schedule.id': sch.id}));
  303 + $(this).data('valid', true);
  304 +
  305 + if(allValidSuccess()){
  306 + var i = 0;
  307 + (function () {
  308 + var f = arguments.callee;
  309 + if(i >= dataArray.length){
  310 + UIkit.modal(modal).hide();
  311 + $('#schedule-lj_zrw-modal .main-schedule-table').trigger('refresh', {sch: sch});
  312 + return;
  313 + }
  314 + var data = dataArray[i];
  315 + gb_common.$post('/childTask', data, function (rs) {
  316 + notify_succ('子任务添加成功');
  317 + gb_schedule_table.updateSchedule(rs.t);
  318 + i++;
  319 + f();
  320 + });
  321 + })();
  322 + }
  323 + });
  324 +
  325 + //校验不过
  326 + fs.on('err.field.fv', function () {
  327 + $('#submitChildTaskBtn', modal).removeClass('disabled').removeAttr('disabled');
  328 + });
  329 +
266 //submit 330 //submit
267 - /*var f = $('form', modal).formValidation({  
268 - framework: 'uikit',  
269 - locale: 'zh_CN',  
270 - });  
271 - f.on('success.form.fv', function(e) {  
272 - disabled_submit_btn(this);  
273 - e.preventDefault();  
274 - var data = $(this).serializeJSON();  
275 -  
276 - });*/ 331 + $('#submitChildTaskBtn', modal).on('click', function () {
  332 + $(this).addClass('disabled').attr('disabled','disabled');
  333 + dataArray = [];
  334 + fs.data('valid', false);
  335 + fs.formValidation('validate');
  336 + //fs.submit();
  337 + });
  338 +
  339 + //选择烂班原因
  340 + $('select[name=destroyReason]', destroyForm).on('change', function () {
  341 + var e =$('#globalRemarks', modal);
  342 + e.val(e.val() + $(this).val() + ',');
  343 + });
277 }); 344 });
  345 +
  346 + function allValidSuccess() {
  347 + var flag = true;
  348 + $('form.inpark_form:visible', modal).each(function (i, f) {
  349 + if(!$(f).data('valid')){
  350 + flag = false;
  351 + return false;
  352 + }
  353 + });
  354 + return flag;
  355 + }
  356 +
  357 + //获取表单disabled 项的值
  358 + function getDisabledVal(f) {
  359 + var rs = {};
  360 + $('input,select', f).each(function () {
  361 + if($(this).attr('disabled')){
  362 + rs[$(this).attr('name')]=$(this).val();
  363 + }
  364 + });
  365 + return rs;
  366 + }
278 367
279 function setDefaultVal() { 368 function setDefaultVal() {
280 var routeOpts = ''; 369 var routeOpts = '';
@@ -299,6 +388,70 @@ @@ -299,6 +388,70 @@
299 388
300 //营运开始时间 389 //营运开始时间
301 $('input[name=startDate]', serviceForm).val(sch.dfsj); 390 $('input[name=startDate]', serviceForm).val(sch.dfsj);
  391 + //营运班次类型
  392 + $('input[name=type1]', serviceForm).val(sch['sflj']?'临加':'正常');
  393 + }
  394 +
  395 + //点击 路径
  396 + $('#inpark_paths_link', modal).on('click', function () {
  397 +
  398 + });
  399 +
  400 + //进场导航
  401 + var drivingRouteResult;
  402 + function inparkNavigation() {
  403 + var start = $('select[name=startStation]', emptyForm).val()
  404 + ,end = $('select[name=endStation]', emptyForm).val();
  405 +
  406 + if(!end) return;
  407 +
  408 + var station = getStationByCode(start).station
  409 + ,park = gb_data_basic.getCarparkByCode(end);
  410 +
  411 + if(!park){
  412 + notify_err('无法找到停车场的坐标对照!!!');
  413 + return;
  414 + }
  415 + var tArray = park['gCenterPoint'].split(' ');
  416 + var sCoord = TransGPS.wgsToBD(station['gLaty'], station['gLonx'])
  417 + ,eCoord = TransGPS.wgsToBD(parseFloat(tArray[1]), parseFloat(tArray[0]));
  418 +
  419 + var sp = new BMap.Point(sCoord.lng,sCoord.lat);
  420 + var ep = new BMap.Point(eCoord.lng,eCoord.lat);
  421 +
  422 + var driving = new BMap.DrivingRoute('上海', {
  423 + onSearchComplete: function (rs) {
  424 + drivingRouteResult = rs;
  425 + calcInparkMileage(0);
  426 + }
  427 + });
  428 + driving.search(sp,ep);
  429 + }
  430 +
  431 + function calcInparkMileage(index) {
  432 + var count = drivingRouteResult.getNumPlans();
  433 +
  434 + //选择方案
  435 + var routePlan = drivingRouteResult.getPlan(index);
  436 + //里程
  437 + var mileage = routePlan.getDistance(false);
  438 + $('input[name=mileage]', emptyForm).val(mileage / 1000);
  439 + //结束时间
  440 + var duratio = routePlan.getDuration(false);
  441 + var st = $('input[name=startDate]', emptyForm).val();
  442 + var ets = moment(st, 'HH:mm').add(duratio, 'seconds').format('HH:mm');
  443 + $('input[name=endDate]', emptyForm).val(ets);
  444 +
  445 +
  446 + $('#inpark_paths_link span', modal).text(count);
  447 + }
  448 +
  449 + function getStationByCode(code) {
  450 + for(var i = 0; i < stationRoutes.length; i++){
  451 + if(stationRoutes[i]['stationCode']==code)
  452 + return stationRoutes[i];
  453 + }
  454 + return null;
302 } 455 }
303 456
304 function reClac() { 457 function reClac() {
@@ -311,33 +464,78 @@ @@ -311,33 +464,78 @@
311 e = $('select[name=endStation]', serviceForm).val(); 464 e = $('select[name=endStation]', serviceForm).val();
312 var sMileage = calcMileage(s, e); 465 var sMileage = calcMileage(s, e);
313 if(sMileage >= 0) 466 if(sMileage >= 0)
314 - $('input[name=mileageType]', serviceForm).val(sMileage); 467 + $('input[name=mileage]', serviceForm).val(sMileage);
315 468
  469 + //营运结束时间
  470 + var et = sch.dfsjT + (parseInt(sMileage / sch.jhlc * sch.bcsj) * 60 * 1000)
  471 + ,ets = et > sch.zdsjT?sch.zdsj:moment(et).format('HH:mm');
  472 + $('input[name=endDate]', serviceForm).val(ets);
  473 +
  474 + //有烂班
316 if (serviceEnd != esCode) { 475 if (serviceEnd != esCode) {
317 //烂班起点 == 营运终点 476 //烂班起点 == 营运终点
318 $('select[name=startStation]', destroyForm).val(serviceEnd); 477 $('select[name=startStation]', destroyForm).val(serviceEnd);
  478 + //计算烂班公里
  479 + s = $('select[name=startStation]', destroyForm).val();
  480 + e = $('select[name=endStation]', destroyForm).val();
  481 + var dMileage = calcMileage(s, e);
  482 + $('input[name=mileage]', destroyForm).val(dMileage);
  483 + //烂班开始时间
  484 + $('input[name=startDate]', destroyForm).val(ets);
319 } 485 }
  486 +
  487 + //进场开始时间
  488 + $('input[name=startDate]', emptyForm).val(ets);
  489 +
  490 + //重新导航
  491 + inparkNavigation();
320 } 492 }
321 493
322 function calcMileage(s, e) { 494 function calcMileage(s, e) {
323 var mileage = 0, flag, code; 495 var mileage = 0, flag, code;
324 if (timeLocStations) { 496 if (timeLocStations) {
  497 + //空间坐标计算的站距
325 $.each(timeLocStations, function () { 498 $.each(timeLocStations, function () {
326 - code = this.station.STATION_CODE;  
327 - if (code == s) { 499 + code = this.station['STATION_CODE'];
  500 + if (flag)
  501 + mileage = gb_common.accAdd(mileage, this.toDistanceGl);
  502 + if (code == s)
328 flag = true; 503 flag = true;
329 - }  
330 - 504 + if (code == e)
  505 + return false;
  506 + });
  507 + }
  508 + else{
  509 + //从原始站点路由字段里取值
  510 + $.each(stationRoutes, function () {
  511 + code = this['stationCode'];
331 if (flag) 512 if (flag)
332 - mileage += this.toDistance;  
333 - 513 + mileage = gb_common.accAdd(mileage, this.distances);
  514 + if (code == s)
  515 + flag = true;
334 if (code == e) 516 if (code == e)
335 return false; 517 return false;
336 }); 518 });
337 } 519 }
338 - return mileage / 1000; 520 + return mileage;
339 } 521 }
340 522
  523 + //从本地localStorage获取站间距数据
  524 + function getLocStationsSpace() {
  525 + try {
  526 + timeLocStations = window.localStorage.getItem('control_route_distance_' + sch.xlBm);
  527 + if (timeLocStations)
  528 + timeLocStations = JSON.parse(timeLocStations).stations[sch.xlDir == 0 ? 'up' : 'down'];
  529 + } catch (e) {
  530 + console.log(e);
  531 + }
  532 + }
  533 +
  534 + //站间距计算后刷新
  535 + $(modal).on('refresh_station_space', function () {
  536 + getLocStationsSpace();
  537 + reClac();
  538 + });
341 539
342 //------ 下抽屉 ------ 540 //------ 下抽屉 ------
343 $('#betweenStationRangeCalc', modal).on('click', function () { 541 $('#betweenStationRangeCalc', modal).on('click', function () {
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task/add_sub_task_other.html
@@ -175,19 +175,23 @@ @@ -175,19 +175,23 @@
175 for (var code in parks) 175 for (var code in parks)
176 park_opts += '<option value="' + code + '">' + parks[code] + '</option>'; 176 park_opts += '<option value="' + code + '">' + parks[code] + '</option>';
177 177
178 - var qdz = $('[name=startStation]', f), zdz = $('[name=endStation]', f); 178 + var qdz = $('[name=startStation]', f), zdz = $('[name=endStation]', f), mType = $('[name=mileageType]', f);
179 switch ($(this).val()) { 179 switch ($(this).val()) {
180 case '3'://出场 180 case '3'://出场
181 qdz.html(park_opts).val(information.carPark); 181 qdz.html(park_opts).val(information.carPark);
182 zdz.html(opts); 182 zdz.html(opts);
  183 + mType.val('empty');
183 break; 184 break;
184 case '2'://进场 185 case '2'://进场
185 qdz.html(opts); 186 qdz.html(opts);
186 zdz.html(park_opts).val(information.carPark); 187 zdz.html(park_opts).val(information.carPark);
  188 + mType.val('empty');
187 break; 189 break;
188 default: 190 default:
189 qdz.html(opts); 191 qdz.html(opts);
190 zdz.html(opts).val(lastCode); 192 zdz.html(opts).val(lastCode);
  193 + mType.val('service');
  194 +
191 } 195 }
192 }); 196 });
193 197
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task/station_route_spacing_chart.html
1 <!-- 站点路由间距图 --> 1 <!-- 站点路由间距图 -->
  2 +<a class="ct-bottom-drawer-close" style="right: calc(20% + 10px);"></a>
2 <div id="station_route_spacing_chart_drawer" style="width: 100%;height: 100%;font-size: 0;"> 3 <div id="station_route_spacing_chart_drawer" style="width: 100%;height: 100%;font-size: 0;">
  4 + <div class="tl_desc_text" style="z-index: 999;">
  5 + (鼠标滚轮滚动)单位:米 | <a class="delete_route_spacing_link" style="color: red;">删除</a>
  6 + </div>
3 <div class="svg_wrap"></div> 7 <div class="svg_wrap"></div>
4 8
5 <div class="drawer_right_map" > 9 <div class="drawer_right_map" >
@@ -10,19 +14,75 @@ @@ -10,19 +14,75 @@
10 14
11 (function () { 15 (function () {
12 var drawer = '#station_route_spacing_chart_drawer' 16 var drawer = '#station_route_spacing_chart_drawer'
13 - , sch, locData, stationArr; 17 + , sch, locData, stationArr, len;
  18 + var cy = 120;
  19 + var tCy = cy - 15;
  20 + //站点marker对照
  21 + var map, markers = {};
  22 +
  23 + $('.delete_route_spacing_link', drawer).on('click', function () {
  24 + alt_confirm('确定要删除【'+sch.xlName+'】基于空间坐标计算的站间距数据?', function () {
  25 + window.localStorage.removeItem('control_route_distance_' + sch.xlBm);
  26 + toGeoCalcPage();
  27 + }, '确定删除');
  28 + });
14 29
15 - //var xScale;  
16 $(drawer).on('drawer-init', function (e, data) { 30 $(drawer).on('drawer-init', function (e, data) {
17 sch = data.sch; 31 sch = data.sch;
18 locData = window.localStorage.getItem('control_route_distance_' + sch.xlBm); 32 locData = window.localStorage.getItem('control_route_distance_' + sch.xlBm);
19 33
20 if(locData) 34 if(locData)
21 drawCharts(); 35 drawCharts();
22 - else  
23 - drawerLoadPage('/real_control_v2/fragments/geo/calc_station_space.html','cal_station_space_drawer'); 36 + else{
  37 + toGeoCalcPage();
  38 + return;
  39 + }
  40 +
  41 + setTimeout(initMap, 800);
24 }); 42 });
25 43
  44 + function initMap() {
  45 + //初始化地图
  46 + map = new BMap.Map($('.drawer_right_map', drawer)[0]);
  47 + //中心点和缩放级别
  48 + map.centerAndZoom(new BMap.Point(121.544336, 31.221315), 15);
  49 + map.enableScrollWheelZoom();
  50 +
  51 + //绘制线路
  52 + var routes = JSON.parse(locData).sections[sch.xlDir==0?'up':'down'];
  53 +
  54 + var pos = [], bdCoord;
  55 + $.each(routes, function () {
  56 + bdCoord = TransGPS.wgsToBD(this.latitude, this.longitude);
  57 + pos.push(new BMap.Point(bdCoord.lng, bdCoord.lat));
  58 + });
  59 +
  60 + var polyline = new BMap.Polyline(pos, {strokeWeight:6, strokeColor: 'blue'});
  61 + map.addOverlay(polyline);
  62 +
  63 + //绘制站点
  64 + var station;
  65 + $.each(stationArr, function () {
  66 + station=this.station;
  67 + bdCoord = TransGPS.wgsToBD(station.G_LATY, station.G_LONX);
  68 +
  69 + var point = new BMap.Point(bdCoord.lng, bdCoord.lat);
  70 + var marker = new BMap.Marker(point);
  71 +
  72 + //根据站点名称 计算marker 宽度
  73 + var w = station.STATION_NAME.length * 12 + 4;
  74 + station.stationName = station.STATION_NAME;
  75 + station.directions = station.DIRECTIONS;
  76 + var icon = new BMap.Icon(gb_map_imap.createStationIcon(station, w), new BMap.Size(w-2,24), {anchor: new BMap.Size((w-2)/2,24)})
  77 + marker.setIcon(icon);
  78 +
  79 + map.addOverlay(marker);
  80 + markers[station.STATION_CODE] = marker;
  81 + });
  82 +
  83 + autoPosition();
  84 + }
  85 +
26 function drawCharts() { 86 function drawCharts() {
27 try { 87 try {
28 stationArr = JSON.parse(locData).stations[sch.xlDir == 0 ? 'up' : 'down']; 88 stationArr = JSON.parse(locData).stations[sch.xlDir == 0 ? 'up' : 'down'];
@@ -31,9 +91,11 @@ @@ -31,9 +91,11 @@
31 return; 91 return;
32 } 92 }
33 93
34 - var width = 1500; 94 + //console.log('locData...', JSON.parse(locData));
  95 + len = stationArr.length;
  96 + var width = cx(len - 1) + 20;
35 var svgCont = $('<div style="width: '+width+'px;" class="svg_cont_body"></div>'); 97 var svgCont = $('<div style="width: '+width+'px;" class="svg_cont_body"></div>');
36 - var svg = d3.select(svgCont[0]).append('svg'); 98 + var svg = d3.select(svgCont[0]).append('svg').classed({down: sch.xlDir==0?false:true});
37 99
38 //初始化 X 比例尺 100 //初始化 X 比例尺
39 var sum=0; 101 var sum=0;
@@ -41,31 +103,149 @@ @@ -41,31 +103,149 @@
41 sum += this.toDistance; 103 sum += this.toDistance;
42 }); 104 });
43 105
44 - console.log('stations', stationArr);  
45 var items = svg.selectAll('g._item').data(stationArr) 106 var items = svg.selectAll('g._item').data(stationArr)
46 .enter() 107 .enter()
47 .append('g') 108 .append('g')
  109 + .attr('data-code', function (d) {
  110 + return d.station.STATION_CODE;
  111 + })
48 .classed({_item: true}); 112 .classed({_item: true});
49 113
50 //rect 114 //rect
51 - items.append('rect').attr('x', xScale).attr('y', 40); 115 + items.append('rect').attr('x', xScale).attr('y', cy);
  116 + //text
  117 + items.append('text').attr('x', xScale).attr('y', cy)
  118 + .text(stationText).attr('title', stationText);
  119 +
  120 + //path
  121 + items.append('path').attr('d', function (d, i) {
  122 + return i>=len-1?'':line([i , i + 1]);
  123 + });
  124 +
  125 + //上弧线
  126 + items.append('path').classed({arc_path: true}).attr('d', route_arc_path);
  127 +
  128 + //path circle
  129 + items.append('circle').attr('cx', function (d, i) {
  130 + return cx(i);
  131 + }).attr('cy', tCy);
  132 +
  133 + //站距
  134 + items.filter(secFilter).append('rect')
  135 + .attr('x', function (d, i) {
  136 + return cx(i) - 6;
  137 + })
  138 + .attr('y', tCy - 42)
  139 + .classed({distance_rect: true})
  140 + .style('transform', distTranslate);
  141 +
  142 + items.filter(secFilter).append('text')
  143 + .attr('x', xScale)
  144 + .attr('y', tCy - 26)
  145 + .text(function (d, i) {
  146 + return d.toDistance;
  147 + })
  148 + .classed({distance_text: true})
  149 + .style('transform', distTranslate);
  150 +
52 $('.svg_wrap', drawer).append(svgCont); 151 $('.svg_wrap', drawer).append(svgCont);
53 } 152 }
54 153
  154 + var xpdd = 20;
  155 + //var halfWidth = 15;
55 var xScale = function (d, i) { 156 var xScale = function (d, i) {
  157 + return cx(i);
  158 + };
  159 +
  160 + var cx = function (i) {
56 var sum=0; 161 var sum=0;
57 for(var j = 0; j <= i; j++){ 162 for(var j = 0; j <= i; j++){
58 sum+=stationArr[j].toDistance; 163 sum+=stationArr[j].toDistance;
59 } 164 }
60 - return sum / 5; 165 + return sum / 2.5 + xpdd;
  166 + };
  167 +
  168 + var stationText = function (d) {
  169 + return d.station['STATION_NAME'];
61 }; 170 };
62 171
  172 + var line = d3.svg.line().x(cx).y(tCy);
  173 +
  174 + var route_arc_path = function (d, i) {
  175 + if(i >= len - 1) return;
  176 + var x1 = cx(i);
  177 + var x2 = cx(i + 1);
  178 +
  179 + var c1 = (x1 + (x2 - x1) / 3) + ' ' + (tCy - 40);
  180 + var c2 = (x2 - (x2 - x1) / 3) +' '+ (tCy - 40);
  181 +
  182 + return 'M'+x1+' '+tCy+' C '+ c1 +', '+ c2 +', '+ x2 +' '+tCy;
  183 + };
  184 +
  185 + var secFilter = function (d, i) {
  186 + return i > 0;
  187 + };
  188 +
  189 + //地图定位
  190 + var posMarker, posing=false;
  191 + function autoPosition() {
  192 + var left = Math.abs(parseInt($('.svg_cont_body', drawer).css('left').replace('px', '')));
  193 +
  194 + var g;
  195 + $('svg g._item text', drawer).each(function () {
  196 + if($(this).attr('x') > left){
  197 + g = $(this).parent();
  198 + return false;
  199 + }
  200 + });
  201 + posMarker = markers[g.data('code')];
  202 +
  203 + if(posing) return;
  204 + posing = true;
  205 + setTimeout(function () {
  206 + map.panTo(posMarker.point/*, {noAnimation: true}*/);
  207 + posing = false;
  208 + }, 500);
  209 + }
  210 +
  211 + var distTranslate = function (d, i) {
  212 + return 'translate('+(d.toDistance / 2.5 / 2 - 16)+'px, 0px)';
  213 + };
  214 +
  215 + function toGeoCalcPage() {
  216 + drawerLoadPage('/real_control_v2/fragments/geo/calc_station_space.html','cal_station_space_drawer');
  217 + }
  218 +
63 //页面切换 219 //页面切换
64 function drawerLoadPage(url, id) { 220 function drawerLoadPage(url, id) {
65 $(drawer).parent('.ct-bottom-drawer-body').load(url, function () { 221 $(drawer).parent('.ct-bottom-drawer-body').load(url, function () {
66 $('#' + id).trigger('drawer-init', {sch: sch}); 222 $('#' + id).trigger('drawer-init', {sch: sch});
67 }); 223 });
68 } 224 }
  225 +
  226 + var threshold = 30;
  227 + $(drawer).on('mousewheel', '.svg_cont_body', function (e) {
  228 + var event = e.originalEvent;
  229 + var code = delta = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
  230 +
  231 + var left = parseInt($(this).css('left').replace('px',''))
  232 + ,width = $(this).width()
  233 + ,max = width - $(this).parent().width();
  234 + if(code > 0){
  235 + left += threshold;
  236 + if(left >= 0)
  237 + left = 0;
  238 + $(this).css('left', left + 'px');
  239 + }
  240 + else{
  241 + left -= threshold;
  242 + if(Math.abs(left) >= max)
  243 + left = -max;
  244 + $(this).css('left', left + 'px');
  245 + }
  246 +
  247 + autoPosition();
  248 + });
69 })(); 249 })();
70 </script> 250 </script>
71 </div> 251 </div>
72 \ No newline at end of file 252 \ No newline at end of file
src/main/resources/static/real_control_v2/js/common.js
@@ -215,7 +215,7 @@ var gb_common = (function () { @@ -215,7 +215,7 @@ var gb_common = (function () {
215 data.push({value: this}); 215 data.push({value: this});
216 }); 216 });
217 init_autocomplete(element, data); 217 init_autocomplete(element, data);
218 - } 218 + };
219 219
220 var init_autocom_pinyin = function (element, data) { 220 var init_autocom_pinyin = function (element, data) {
221 // init autocomplete 221 // init autocomplete
@@ -240,7 +240,7 @@ var gb_common = (function () { @@ -240,7 +240,7 @@ var gb_common = (function () {
240 release && release(rs); 240 release && release(rs);
241 } 241 }
242 }); 242 });
243 - } 243 + };
244 244
245 var init_autocomplete = function (element, data) { 245 var init_autocomplete = function (element, data) {
246 var autocomplete = UIkit.autocomplete(element, { 246 var autocomplete = UIkit.autocomplete(element, {
@@ -262,7 +262,7 @@ var gb_common = (function () { @@ -262,7 +262,7 @@ var gb_common = (function () {
262 release && release(rs); 262 release && release(rs);
263 } 263 }
264 }); 264 });
265 - } 265 + };
266 266
267 // function whichTransitionEvent() { 267 // function whichTransitionEvent() {
268 // var t; 268 // var t;
@@ -281,6 +281,49 @@ var gb_common = (function () { @@ -281,6 +281,49 @@ var gb_common = (function () {
281 // } 281 // }
282 // } 282 // }
283 283
  284 + var accAdd = function(a, b) {
  285 + var c, d, e;
  286 + try {
  287 + c = a.toString().split(".")[1].length;
  288 + } catch (f) {
  289 + c = 0;
  290 + }
  291 + try {
  292 + d = b.toString().split(".")[1].length;
  293 + } catch (f) {
  294 + d = 0;
  295 + }
  296 + return e = Math.pow(10, Math.max(c, d)), (mul(a, e) + mul(b, e)) / e;
  297 + };
  298 +
  299 + function mul(a, b) {
  300 + var c = 0,
  301 + d = a.toString(),
  302 + e = b.toString();
  303 + try {
  304 + c += d.split(".")[1].length;
  305 + } catch (f) {}
  306 + try {
  307 + c += e.split(".")[1].length;
  308 + } catch (f) {}
  309 + return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c);
  310 + }
  311 +
  312 + var numSubtr = function (a, b) {
  313 + var c, d, e;
  314 + try {
  315 + c = a.toString().split(".")[1].length;
  316 + } catch (f) {
  317 + c = 0;
  318 + }
  319 + try {
  320 + d = b.toString().split(".")[1].length;
  321 + } catch (f) {
  322 + d = 0;
  323 + }
  324 + return e = Math.pow(10, Math.max(c, d)), (a * e - b * e) / e;
  325 + };
  326 +
284 return { 327 return {
285 reqCode80: reqCode80, 328 reqCode80: reqCode80,
286 groupBy: groupBy, 329 groupBy: groupBy,
@@ -295,7 +338,9 @@ var gb_common = (function () { @@ -295,7 +338,9 @@ var gb_common = (function () {
295 lineAutocomplete: lineAutocomplete, 338 lineAutocomplete: lineAutocomplete,
296 personAutocomplete: personAutocomplete, 339 personAutocomplete: personAutocomplete,
297 carAutocomplete: carAutocomplete, 340 carAutocomplete: carAutocomplete,
298 - init_autocomplete: init_autocomplete 341 + init_autocomplete: init_autocomplete,
  342 + accAdd : accAdd,
  343 + numSubtr: numSubtr
299 344
300 //whichTransitionEvent:whichTransitionEvent 345 //whichTransitionEvent:whichTransitionEvent
301 }; 346 };
src/main/resources/static/real_control_v2/js/data/data_basic.js
@@ -44,7 +44,6 @@ var gb_data_basic = (function () { @@ -44,7 +44,6 @@ var gb_data_basic = (function () {
44 ep.emit('lineInformations', informations); 44 ep.emit('lineInformations', informations);
45 }); 45 });
46 46
47 -  
48 //人员信息 47 //人员信息
49 $.get('/basic/all_personnel', function (rs) { 48 $.get('/basic/all_personnel', function (rs) {
50 //转换成自动补全组件需要的数据 49 //转换成自动补全组件需要的数据
@@ -62,6 +61,18 @@ var gb_data_basic = (function () { @@ -62,6 +61,18 @@ var gb_data_basic = (function () {
62 ep.emit('all_personnel', data); 61 ep.emit('all_personnel', data);
63 }); 62 });
64 63
  64 + var carparks={};
  65 + //停车场数据
  66 + gb_common.$get('/realMap/carParkSpatialData', {}, function (rs) {
  67 + $.each(rs.list, function () {
  68 + carparks[this.parkCode] = this;
  69 + });
  70 + });
  71 +
  72 + var getCarparkByCode = function (code) {
  73 + return carparks[code];
  74 + }
  75 +
65 //line code to name 76 //line code to name
66 $.get('/basic/lineCode2Name', function (rs) { 77 $.get('/basic/lineCode2Name', function (rs) {
67 ep.emit('lineCode2Name', rs); 78 ep.emit('lineCode2Name', rs);
@@ -113,6 +124,7 @@ var gb_data_basic = (function () { @@ -113,6 +124,7 @@ var gb_data_basic = (function () {
113 allPersonnel: function () { 124 allPersonnel: function () {
114 return allPersonnel; 125 return allPersonnel;
115 }, 126 },
116 - findCodeByLinename: findCodeByLinename 127 + findCodeByLinename: findCodeByLinename,
  128 + getCarparkByCode: getCarparkByCode
117 }; 129 };
118 })(); 130 })();
src/main/resources/static/real_control_v2/js/main.js
@@ -75,17 +75,10 @@ var gb_main_ep = new EventProxy(), @@ -75,17 +75,10 @@ var gb_main_ep = new EventProxy(),
75 //modal hide remove dom 75 //modal hide remove dom
76 $(document).on('hide.uk.modal', '.uk-modal', function() { 76 $(document).on('hide.uk.modal', '.uk-modal', function() {
77 $(this).remove(); 77 $(this).remove();
78 -/* //如果modal内部存在context-menu,则注销  
79 - var ctx = $('.context-menu-item', this);  
80 - debugger  
81 - if(ctx.length > 0){  
82 - //ctx.contextMenu('destroy');  
83 - $.contextMenu('destroy', ctx);  
84 - }*/  
85 }); 78 });
86 79
87 $(document).on('click', '.ct-bottom-drawer-close', function () { 80 $(document).on('click', '.ct-bottom-drawer-close', function () {
88 - $(this).parent().removeClass('open'); 81 + $(this).parents('.ct-bottom-drawer').removeClass('open');
89 }); 82 });
90 83
91 function connectArr(arr, separator, transFun) { 84 function connectArr(arr, separator, transFun) {
@@ -113,19 +106,19 @@ var notify_wait = function(t) { @@ -113,19 +106,19 @@ var notify_wait = function(t) {
113 UIkit.notify("<i class='uk-icon-spinner uk-icon-spin'></i> " + t, { 106 UIkit.notify("<i class='uk-icon-spinner uk-icon-spin'></i> " + t, {
114 status: 'info' 107 status: 'info'
115 }); 108 });
116 -} 109 +};
117 110
118 var notify_succ = function(t) { 111 var notify_succ = function(t) {
119 UIkit.notify("<i class='uk-icon-check'></i> " + t, { 112 UIkit.notify("<i class='uk-icon-check'></i> " + t, {
120 status: 'success' 113 status: 'success'
121 }); 114 });
122 -} 115 +};
123 116
124 var notify_err = function(t) { 117 var notify_err = function(t) {
125 UIkit.notify("<i class='uk-icon-times'></i> " + t, { 118 UIkit.notify("<i class='uk-icon-times'></i> " + t, {
126 status: 'danger' 119 status: 'danger'
127 }); 120 });
128 -} 121 +};
129 122
130 var alt_confirm = function(content, succ, okBtn) { 123 var alt_confirm = function(content, succ, okBtn) {
131 var modalEl = UIkit.modal.confirm(content, function() { 124 var modalEl = UIkit.modal.confirm(content, function() {
@@ -138,11 +131,11 @@ var alt_confirm = function(content, succ, okBtn) { @@ -138,11 +131,11 @@ var alt_confirm = function(content, succ, okBtn) {
138 } 131 }
139 ,center: true 132 ,center: true
140 }); 133 });
141 -} 134 +};
142 135
143 var isArray = function(obj) { 136 var isArray = function(obj) {
144 return Object.prototype.toString.call(obj) === '[object Array]'; 137 return Object.prototype.toString.call(obj) === '[object Array]';
145 -} 138 +};
146 139
147 var notify_err_form = function(t, form) { 140 var notify_err_form = function(t, form) {
148 $('.uk-alert-danger', form).remove(); 141 $('.uk-alert-danger', form).remove();
@@ -152,7 +145,7 @@ var notify_err_form = function(t, form) { @@ -152,7 +145,7 @@ var notify_err_form = function(t, form) {
152 '</div>'); 145 '</div>');
153 146
154 enable_submit_btn(form); 147 enable_submit_btn(form);
155 -} 148 +};
156 149
157 var enable_submit_btn = function(form) { 150 var enable_submit_btn = function(form) {
158 var subBtn = $('button[type=submit]', form); 151 var subBtn = $('button[type=submit]', form);
@@ -166,14 +159,14 @@ var disabled_submit_btn = function(form) { @@ -166,14 +159,14 @@ var disabled_submit_btn = function(form) {
166 if (subBtn) { 159 if (subBtn) {
167 subBtn.addClass('disabled').attr('disabled','disabled'); 160 subBtn.addClass('disabled').attr('disabled','disabled');
168 } 161 }
169 -} 162 +};
170 163
171 var show_modal = function(id, dom) { 164 var show_modal = function(id, dom) {
172 $(document.body).append(dom); 165 $(document.body).append(dom);
173 return UIkit.modal(id, { 166 return UIkit.modal(id, {
174 bgclose: false 167 bgclose: false
175 }).show(); 168 }).show();
176 -} 169 +};
177 170
178 var open_modal = function(pageUrl, data, opt) { 171 var open_modal = function(pageUrl, data, opt) {
179 $.get(pageUrl, function(dom) { 172 $.get(pageUrl, function(dom) {