Commit 29f78d10b4832ee1a0b27fc4e55e4b9074ad5a39

Authored by 潘钊
1 parent b95b07c2

update

src/main/java/com/bsth/controller/realcontrol/RealMapController.java 0 → 100644
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.bsth.service.realcontrol.RealMapService;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.web.bind.annotation.RequestMapping;
  6 +import org.springframework.web.bind.annotation.RequestParam;
  7 +import org.springframework.web.bind.annotation.RestController;
  8 +
  9 +import java.util.Map;
  10 +
  11 +/**
  12 + * 线调 地图监控相关
  13 + * Created by panzhao on 2016/11/23.
  14 + */
  15 +@RestController
  16 +@RequestMapping("realMap")
  17 +public class RealMapController {
  18 +
  19 + @Autowired
  20 + RealMapService realMapService;
  21 +
  22 + /**
  23 + * 根据线路获取站点路由及空间数据
  24 + */
  25 + @RequestMapping(value = "/stationSpatialData")
  26 + public Map<String, Object> stationSpatialData(@RequestParam String idx){
  27 + return realMapService.stationSpatialData(idx);
  28 + }
  29 +}
... ...
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
3   -import java.io.UnsupportedEncodingException;
4   -import java.net.URLDecoder;
5   -import java.util.*;
6   -
7   -import org.apache.commons.lang3.StringEscapeUtils;
8   -import org.drools.core.runtime.help.impl.XStreamJSon.JSonAbortWorkItemConverter;
9   -import org.joda.time.format.DateTimeFormat;
10   -import org.joda.time.format.DateTimeFormatter;
11   -import org.springframework.beans.factory.annotation.Autowired;
12   -import org.springframework.web.bind.annotation.PathVariable;
13   -import org.springframework.web.bind.annotation.RequestMapping;
14   -import org.springframework.web.bind.annotation.RequestMethod;
15   -import org.springframework.web.bind.annotation.RequestParam;
16   -import org.springframework.web.bind.annotation.RestController;
17   -
18   -import com.alibaba.fastjson.JSON;
19 3 import com.alibaba.fastjson.JSONArray;
20 4 import com.bsth.controller.BaseController;
21 5 import com.bsth.controller.realcontrol.dto.ChangePersonCar;
... ... @@ -23,9 +7,14 @@ import com.bsth.controller.realcontrol.dto.DfsjChange;
23 7 import com.bsth.data.BasicData;
24 8 import com.bsth.data.schedule.DayOfSchedule;
25 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
26   -import com.bsth.security.util.SecurityUtils;
27 10 import com.bsth.service.realcontrol.ScheduleRealInfoService;
28   -import com.google.common.base.Splitter;
  11 +import org.apache.commons.lang3.StringEscapeUtils;
  12 +import org.joda.time.format.DateTimeFormat;
  13 +import org.joda.time.format.DateTimeFormatter;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.web.bind.annotation.*;
  16 +
  17 +import java.util.*;
29 18  
30 19 @RestController
31 20 @RequestMapping("/realSchedule")
... ...
src/main/java/com/bsth/controller/realcontrol/dto/StationSpatialData.java 0 → 100644
  1 +package com.bsth.controller.realcontrol.dto;
  2 +
  3 +/**
  4 + * Created by panzhao on 2016/11/23.
  5 + */
  6 +public class StationSpatialData {
  7 +
  8 + private String lineCode;
  9 +
  10 + private String stationName;
  11 +
  12 + private String stationCode;
  13 +
  14 + private String stationMark;
  15 +
  16 + private int directions;
  17 +
  18 + private Float distances;
  19 +
  20 + private Float toTime;
  21 +
  22 + private Integer versions;
  23 +
  24 + private Float gLonx;
  25 +
  26 + private Float gLaty;
  27 +
  28 + private Float radius;
  29 +
  30 + private String shapesType;
  31 +
  32 + private String gPolygonGrid;
  33 +
  34 + private Integer stationRouteCode;
  35 +
  36 + public String getLineCode() {
  37 + return lineCode;
  38 + }
  39 +
  40 + public void setLineCode(String lineCode) {
  41 + this.lineCode = lineCode;
  42 + }
  43 +
  44 + public String getStationName() {
  45 + return stationName;
  46 + }
  47 +
  48 + public void setStationName(String stationName) {
  49 + this.stationName = stationName;
  50 + }
  51 +
  52 + public String getStationCode() {
  53 + return stationCode;
  54 + }
  55 +
  56 + public void setStationCode(String stationCode) {
  57 + this.stationCode = stationCode;
  58 + }
  59 +
  60 + public String getStationMark() {
  61 + return stationMark;
  62 + }
  63 +
  64 + public void setStationMark(String stationMark) {
  65 + this.stationMark = stationMark;
  66 + }
  67 +
  68 + public int getDirections() {
  69 + return directions;
  70 + }
  71 +
  72 + public void setDirections(int directions) {
  73 + this.directions = directions;
  74 + }
  75 +
  76 + public Float getDistances() {
  77 + return distances;
  78 + }
  79 +
  80 + public void setDistances(Float distances) {
  81 + this.distances = distances;
  82 + }
  83 +
  84 + public Float getToTime() {
  85 + return toTime;
  86 + }
  87 +
  88 + public void setToTime(Float toTime) {
  89 + this.toTime = toTime;
  90 + }
  91 +
  92 + public Integer getVersions() {
  93 + return versions;
  94 + }
  95 +
  96 + public void setVersions(Integer versions) {
  97 + this.versions = versions;
  98 + }
  99 +
  100 + public Float getgLonx() {
  101 + return gLonx;
  102 + }
  103 +
  104 + public void setgLonx(Float gLonx) {
  105 + this.gLonx = gLonx;
  106 + }
  107 +
  108 + public Float getgLaty() {
  109 + return gLaty;
  110 + }
  111 +
  112 + public void setgLaty(Float gLaty) {
  113 + this.gLaty = gLaty;
  114 + }
  115 +
  116 + public Float getRadius() {
  117 + return radius;
  118 + }
  119 +
  120 + public void setRadius(Float radius) {
  121 + this.radius = radius;
  122 + }
  123 +
  124 + public String getShapesType() {
  125 + return shapesType;
  126 + }
  127 +
  128 + public void setShapesType(String shapesType) {
  129 + this.shapesType = shapesType;
  130 + }
  131 +
  132 + public String getgPolygonGrid() {
  133 + return gPolygonGrid;
  134 + }
  135 +
  136 + public void setgPolygonGrid(String gPolygonGrid) {
  137 + this.gPolygonGrid = gPolygonGrid;
  138 + }
  139 +
  140 + public Integer getStationRouteCode() {
  141 + return stationRouteCode;
  142 + }
  143 +
  144 + public void setStationRouteCode(Integer stationRouteCode) {
  145 + this.stationRouteCode = stationRouteCode;
  146 + }
  147 +}
... ...
src/main/java/com/bsth/service/realcontrol/RealMapService.java 0 → 100644
  1 +package com.bsth.service.realcontrol;
  2 +
  3 +import java.util.Map;
  4 +
  5 +/**
  6 + * Created by panzhao on 2016/11/23.
  7 + */
  8 +public interface RealMapService {
  9 + Map<String, Object> stationSpatialData(String idx);
  10 +}
... ...
src/main/java/com/bsth/service/realcontrol/impl/RealMapServiceImpl.java 0 → 100644
  1 +package com.bsth.service.realcontrol.impl;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.controller.realcontrol.dto.StationSpatialData;
  5 +import com.bsth.service.realcontrol.RealMapService;
  6 +import com.google.common.base.Splitter;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  11 +import org.springframework.jdbc.core.JdbcTemplate;
  12 +import org.springframework.stereotype.Service;
  13 +
  14 +import java.util.HashMap;
  15 +import java.util.List;
  16 +import java.util.Map;
  17 +
  18 +/**
  19 + * Created by panzhao on 2016/11/23.
  20 + */
  21 +@Service
  22 +public class RealMapServiceImpl implements RealMapService {
  23 +
  24 + @Autowired
  25 + JdbcTemplate jdbcTemplate;
  26 +
  27 + Logger logger = LoggerFactory.getLogger(this.getClass());
  28 +
  29 + @Override
  30 + public Map<String, Object> stationSpatialData(String idx) {
  31 + Map<String, Object> rs = new HashMap();
  32 +
  33 + try {
  34 + List<String> idArray = Splitter.on(",").splitToList(idx);
  35 + //拼接in语句
  36 + String inStr = "";
  37 + for (String code : idArray) {
  38 + inStr += (",'" + code+"'");
  39 + }
  40 + inStr = " (" + inStr.substring(1) + ")";
  41 +
  42 + String sql = "select R.LINE_CODE,R.STATION_NAME,R.STATION_CODE,R.STATION_MARK,R.DIRECTIONS,R.DISTANCES,R.TO_TIME, R.VERSIONS,S.G_LONX,S.G_LATY,S.RADIUS,S.SHAPES_TYPE,ST_AsText(S.G_POLYGON_GRID) as G_POLYGON_GRID, R.STATION_ROUTE_CODE from bsth_c_stationroute r inner join bsth_c_station s on r.station=s.id where r.line_code in "+inStr+" and r.destroy=0";
  43 +
  44 + List<StationSpatialData> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(StationSpatialData.class));
  45 + rs.put("status", ResponseCode.SUCCESS);
  46 + rs.put("list", list);
  47 + } catch (Exception e) {
  48 + logger.error("", e);
  49 + rs.put("status", ResponseCode.ERROR);
  50 + rs.put("msg", "查询站点空间数据出现异常!");
  51 + }
  52 +
  53 + return rs;
  54 + }
  55 +}
... ...
src/main/resources/static/real_control_v2/js/data/data_gps.js
... ... @@ -3,7 +3,7 @@
3 3 var gb_data_gps = (function() {
4 4  
5 5 //fixed time refresh delay
6   - var delay = 1000 * 80;
  6 + var delay = 1000 * 7;
7 7 //deviceId ——> gps
8 8 var realData = {};
9 9 //refresh after callback
... ...
src/main/resources/static/real_control_v2/js/main.js
... ... @@ -58,7 +58,7 @@ var gb_main_ep = new EventProxy(),
58 58 });
59 59  
60 60 //嵌入地图页面
61   - $('li.map-panel','#main-tab-content').load('/real_control_v2/mapmonitor/real.html');
  61 + $('li.map-panel','#main-tab-content').load('/real_control_v2/mapmonitor/real.html');
62 62 });
63 63  
64 64 function g_emit(id) {
... ...
src/main/resources/static/real_control_v2/mapmonitor/css/real.css
... ... @@ -309,4 +309,15 @@
309 309  
310 310 #tcWrap.maplibTc{
311 311 display: none;
  312 +}
  313 +
  314 +.real_spatial_panel{
  315 + position: absolute;
  316 + width: 300px;
  317 + height: 500px;
  318 + top: 5px;
  319 + left: 5px;
  320 + background: rgba(255, 255, 255, 0.98);
  321 + box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  322 + display: none;
312 323 }
313 324 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/mapmonitor/fragments/map_config.html
... ... @@ -13,7 +13,7 @@
13 13 <div class="uk-form-row">
14 14 <span class="uk-form-label">空间数据</span>
15 15 <div class="uk-form-controls">
16   - <label><input type="checkbox" {{if spatialData.station}}checked{{/if}}> 站点</label>
  16 + <label><input type="checkbox" name="spatial_data_station" {{if spatialData.station}}checked{{/if}}> 站点</label>
17 17 <label><input type="checkbox" {{if spatialData.electronicFence}}checked{{/if}}> 电子围栏</label>
18 18 <label><input type="checkbox" {{if spatialData.carPark}}checked{{/if}}> 停车场</label>
19 19 </div>
... ...
src/main/resources/static/real_control_v2/mapmonitor/js/config.js
1 1 /** 地图配置信息 */
2 2  
3   -var gb_map_config=(function () {
  3 +var gb_map_config = (function () {
4 4  
5   - var defaultConfig={
  5 + var defaultConfig = {
6 6  
7 7 //地图类型
8 8 map_type: 'baidu',
... ... @@ -27,7 +27,7 @@ var gb_map_config=(function () {
27 27 nonOperation: 'rgba(136, 133, 133, 1)'
28 28 }
29 29 },
30   - section:{
  30 + section: {
31 31 color: {
32 32 up: 'blue',
33 33 down: 'red'
... ... @@ -42,12 +42,12 @@ var gb_map_config=(function () {
42 42 temps = gb_common.compileTempByDom(dom, {compress: true});
43 43  
44 44 //渲染表单
45   - var formHtml=temps['map-config-form-temp'](defaultConfig);
  45 + var formHtml = temps['map-config-form-temp'](defaultConfig);
46 46 $('.map_config_wrap').html(formHtml);
47 47  
48 48 //颜色选择器
49 49 $('.map_config_wrap .color_block .sp-placeholder .sp-placeholder-color').each(function () {
50   - var c=$(this).css('background-color');
  50 + var c = $(this).css('background-color');
51 51 $(this).spectrum({
52 52 color: c,
53 53 showInput: true,
... ... @@ -73,17 +73,18 @@ var gb_map_config=(function () {
73 73 var configChangeHandler = function () {
74 74 //console.log('configChangeHandler..',this);
75 75 var name = $(this).attr('name')
76   - ,val = $(this).attr('value');
  76 + , val = $(this).attr('value');
77 77  
78   - if(!name)
  78 + if (!name)
79 79 return;
80 80  
81 81 handler[name] && handler[name].call(this, val);
82 82 };
83 83  
84   - var handler={
  84 + var handler = {
85 85 map_type: changeMapType,
86   - traffic: trafficSwitch
  86 + traffic: trafficSwitch,
  87 + spatial_data_station: spatial_data_station
87 88 };
88 89  
89 90 //切换地图类型
... ... @@ -96,12 +97,12 @@ var gb_map_config=(function () {
96 97 gb_map_overlay_mge.reDraw();
97 98 setTimeout(function () {
98 99 //实时路况为打开状态
99   - if(defaultConfig.traffic)
  100 + if (defaultConfig.traffic)
100 101 gb_map_imap.call('traffic', true);
101 102 }, 1000);
102 103 });
103 104 }
104   -
  105 +
105 106 //实时路况
106 107 function trafficSwitch(val) {
107 108 //修改配置项
... ... @@ -109,40 +110,46 @@ var gb_map_config=(function () {
109 110 gb_map_imap.call('traffic', this.checked);
110 111 }
111 112  
112   - function recursion_get_attr(data, attr){
  113 + //空间数据 站点
  114 + function spatial_data_station(val) {
  115 + defaultConfig.spatialData.station=this.checked;
  116 + gb_map_spatial_data.refresh();
  117 + }
  118 +
  119 + function recursion_get_attr(data, attr) {
113 120 var ats = attr.split('.'),
114 121 val = data;
115 122  
116 123 $.each(ats, function (i, a) {
117   - val=val[a];
  124 + val = val[a];
118 125  
119   - if(!val)
  126 + if (!val)
120 127 return false;
121 128 });
122 129  
123 130 return val;
124 131 }
125   -
  132 +
126 133 function recursion_set_attr(data, attr, value) {
127 134 var ats = attr.split('.'),
128 135 tempVal = data
129   - ,len = ats.length;
  136 + , len = ats.length;
130 137  
131 138 $.each(ats, function (i, a) {
132   - if(i == len -1){
  139 + if (i == len - 1) {
133 140 tempVal[a] = value;
134 141 return false;
135 142 }
136 143 else
137   - tempVal=tempVal[a];
  144 + tempVal = tempVal[a];
138 145  
139   - if(!tempVal)
  146 + if (!tempVal)
140 147 return false;
141 148 });
142 149 }
143 150  
144   - function set(name, val){
145   - defaultConfig[name]=val;
  151 + function set(name, val) {
  152 + defaultConfig[name] = val;
146 153 }
147 154  
148 155 return {
... ...
src/main/resources/static/real_control_v2/mapmonitor/js/map_overlay_manager.js
... ... @@ -76,7 +76,7 @@ var gb_map_overlay_mge = (function () {
76 76  
77 77 showOverlayByChecks();
78 78 //显示路段
79   - showSection(gb_map_gps_tree.getChecked().filter(deviceFilter));
  79 + showSection(getCheckedDevice());
80 80  
81 81 reDrawing = false;
82 82 }
... ... @@ -89,7 +89,7 @@ var gb_map_overlay_mge = (function () {
89 89  
90 90  
91 91 var showOverlayByChecks = function () {
92   - var chs = gb_map_gps_tree.getChecked().filter(deviceFilter),chsMap={};
  92 + var chs = getCheckedDevice(),chsMap={};
93 93 $.each(chs, function () {
94 94 chsMap[this.a_attr.device]=true;
95 95 });
... ... @@ -106,6 +106,10 @@ var gb_map_overlay_mge = (function () {
106 106 //打开信息窗口
107 107 gb_map_imap.call('openWindow',{deviceId: deviceId});
108 108 };
  109 +
  110 + function getCheckedDevice() {
  111 + return gb_map_gps_tree.getChecked().filter(deviceFilter);
  112 + }
109 113 return {
110 114 init: init,
111 115 refresh: showOverlayByChecks,
... ... @@ -113,6 +117,7 @@ var gb_map_overlay_mge = (function () {
113 117 map_gps_win_temp: function (data) {
114 118 return temps['map-win-gps-detail-temp'](data);
115 119 },
116   - reDraw: reDraw
  120 + reDraw: reDraw,
  121 + getCheckedDevice: getCheckedDevice
117 122 };
118 123 })();
119 124 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/mapmonitor/js/real.js
... ... @@ -9,7 +9,10 @@ var mapmonitor_load_ep = EventProxy.create(&#39;load_iMap&#39;, &#39;load_baidu&#39;, &#39;load_gaod
9 9 gb_map_config.init();
10 10  
11 11 //init tree
12   - gb_map_gps_tree.init(gb_map_overlay_mge.init);
  12 + gb_map_gps_tree.init(function () {
  13 + gb_map_overlay_mge.init();
  14 + gb_map_spatial_data.init();
  15 + });
13 16  
14 17 $(".real_bottom_panel").resizable({
15 18 handles: {
... ...
src/main/resources/static/real_control_v2/mapmonitor/js/spatial_data.js 0 → 100644
  1 +/** 空间数据 */
  2 +
  3 +var gb_map_spatial_data = (function () {
  4 +
  5 + var storage = window.localStorage;
  6 +
  7 + var activeLines = JSON.parse(storage.getItem('lineControlItems'));
  8 + var line_idx = (function () {
  9 + var str = '';
  10 + for (var i = 0, item; item = activeLines[i++];) {
  11 + str += (',' + item.lineCode);
  12 + }
  13 + return str.substr(1);
  14 + })();
  15 +
  16 + //线路站点路由数据
  17 + var lineStationArr;
  18 +
  19 +
  20 + var init = function () {
  21 + gb_common.$get('/realMap/stationSpatialData', {idx: line_idx}, function (rs) {
  22 + var list = rs.list;
  23 + //排序
  24 + list.sort(function (a, b) {
  25 + return a.stationRouteCode - b.stationRouteCode;
  26 + });
  27 + //按线路分组
  28 + var lineStationArr = gb_common.groupBy(list, 'lineCode');
  29 + //再按上下行分组
  30 + for (var lineCode in lineStationArr) {
  31 + lineStationArr[lineCode] = gb_common.groupBy(lineStationArr[lineCode], 'directions');
  32 + }
  33 +
  34 + refresh();
  35 + });
  36 + }
  37 +
  38 + var refresh = function () {
  39 + if(!triggerElem())
  40 + return;
  41 +
  42 + var chs = gb_map_overlay_mge.getCheckedDevice();
  43 + //要绘制的站点路由
  44 + var routes = {};
  45 + $.each(chs, function () {
  46 + routes[this.data.lineId+'_'+this.data.upDown]=1;
  47 + });
  48 +
  49 + console.log('chs', chs);
  50 + }
  51 +
  52 + var triggerElem = function () {
  53 + var config = gb_map_config.getConfig().spatialData
  54 + , elem = $('.real_spatial_panel');
  55 +
  56 + for (var att in config) {
  57 + if (config[att]) {
  58 + elem.show();
  59 + return true;
  60 + }
  61 + }
  62 + elem.hide();
  63 + return false;
  64 + }
  65 +
  66 + return {
  67 + refresh: refresh,
  68 + init: init
  69 + };
  70 +})();
0 71 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/mapmonitor/real.html
... ... @@ -29,9 +29,13 @@
29 29 </div>
30 30 </div>
31 31  
  32 +<div class="real_spatial_panel uk-animation-scale">
  33 +
  34 +</div>
32 35  
33 36 <script src="/real_control_v2/mapmonitor/js/config.js"></script>
34 37 <script src="/real_control_v2/mapmonitor/js/gps_tree.js"></script>
  38 +<script src="/real_control_v2/mapmonitor/js/spatial_data.js"></script>
35 39 <script src="/real_control_v2/mapmonitor/js/map_overlay_manager.js"></script>
36 40 <script src="/real_control_v2/mapmonitor/js/real.js"></script>
37 41 <script src="/real_control_v2/mapmonitor/js/map/iMap.js"></script>
... ...