Commit 8b2cb3e44948ab71ad559366ad43fa83eb90dbe4

Authored by yiming
1 parent 6c3e08a4

线调客流显示

src/main/java/com/bsth/controller/gps/GpsController.java
... ... @@ -5,6 +5,7 @@ import com.bsth.data.gpsdata_v2.GpsRealData;
5 5 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6 6 import com.bsth.data.gpsdata_v2.handlers.overspeed.GpsOverspeed;
7 7 import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
  8 +import com.bsth.data.kl.KlData;
8 9 import com.bsth.data.schedule.e_state_check.ScheduleStationCodeChecker;
9 10 import com.bsth.data.schedule.e_state_check.entity.SCodeInfo;
10 11 import com.bsth.service.gps.GpsService;
... ... @@ -62,6 +63,9 @@ public class GpsController {
62 63 //班次站点检查信息
63 64 List<SCodeInfo> scis = ScheduleStationCodeChecker.findByLineIdx(lineArray);
64 65  
  66 + for (GpsEntity gpsEntity : gpsList) {
  67 + gpsEntity.setKl(KlData.getKl(gpsEntity.getDeviceId()));
  68 + }
65 69 rs.put("gpsList", gpsList);
66 70 rs.put("overspeedList", overspeedList);
67 71 rs.put("scis", scis);
... ...
src/main/java/com/bsth/data/gpsdata_v2/entity/GpsEntity.java
1 1 package com.bsth.data.gpsdata_v2.entity;
2 2  
  3 +import com.bsth.entity.Kl;
3 4 import com.fasterxml.jackson.annotation.JsonIgnore;
4 5  
5 6 /**
... ... @@ -113,6 +114,8 @@ public class GpsEntity implements Cloneable{
113 114  
114 115 private String dvrcode;
115 116  
  117 + private Kl kl;
  118 +
116 119 /**
117 120 * 电量 单位:%
118 121 */
... ... @@ -418,4 +421,12 @@ public class GpsEntity implements Cloneable{
418 421 public void setEnergy(int energy) {
419 422 this.energy = energy;
420 423 }
  424 +
  425 + public Kl getKl() {
  426 + return kl;
  427 + }
  428 +
  429 + public void setKl(Kl kl) {
  430 + this.kl = kl;
  431 + }
421 432 }
... ...
src/main/java/com/bsth/data/kl/KlData.java 0 → 100644
  1 +package com.bsth.data.kl;
  2 +
  3 +import com.bsth.entity.Kl;
  4 +import com.bsth.service.Kl.KlService;
  5 +import org.slf4j.Logger;
  6 +import org.slf4j.LoggerFactory;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.beans.factory.annotation.Value;
  9 +import org.springframework.scheduling.annotation.Scheduled;
  10 +import org.springframework.stereotype.Component;
  11 +import java.util.*;
  12 +
  13 +/**
  14 + * @author ym
  15 + * @ClassName: KlData
  16 + * @Description: TODO(客流数据加载定时器)
  17 + * @date 2024年7月18日09:59:40
  18 + */
  19 +@Component
  20 +public class KlData {
  21 +
  22 + static Logger logger = LoggerFactory.getLogger(KlData.class);
  23 +
  24 + //客流数据
  25 + private static Map<String, Kl> KlData = new HashMap<>();
  26 +
  27 + @Autowired
  28 + private KlService klService;
  29 +
  30 + @Value("${passengerFlow.url}")
  31 + private String url;
  32 +
  33 + @Scheduled(cron = "0/10 * * * * ?")
  34 + public void loadKl() {
  35 + Map<String,Kl> map= new HashMap<>();
  36 + List<Kl> list = klService.loadKl();
  37 + for (Kl kl : list) {
  38 + String photo=kl.getPhoto();
  39 + kl.setPhoto(url+photo);
  40 + map.put(kl.getDeviceId(),kl);
  41 + }
  42 + KlData =map;
  43 + }
  44 +
  45 + public static Kl getKl(String deviceId){
  46 + //return KlData.get( KlData.keySet().toArray()[0]);
  47 + return KlData.get(deviceId);
  48 + }
  49 +
  50 +
  51 +}
0 52 \ No newline at end of file
... ...
src/main/java/com/bsth/entity/Kl.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +public class Kl {
  4 +
  5 + private String lineCode;
  6 + private String lineName;
  7 + private String deviceId;
  8 + private String stopNo;
  9 + private String stationName;
  10 + private String upDown;
  11 + private String photo;
  12 + private String num;
  13 + private String createDate;
  14 +
  15 + public String getLineCode() {
  16 + return lineCode;
  17 + }
  18 +
  19 + public void setLineCode(String lineCode) {
  20 + this.lineCode = lineCode;
  21 + }
  22 +
  23 + public String getDeviceId() {
  24 + return deviceId;
  25 + }
  26 +
  27 + public void setDeviceId(String deviceId) {
  28 + this.deviceId = deviceId;
  29 + }
  30 +
  31 + public String getStopNo() {
  32 + return stopNo;
  33 + }
  34 +
  35 + public void setStopNo(String stopNo) {
  36 + this.stopNo = stopNo;
  37 + }
  38 +
  39 + public String getUpDown() {
  40 + return upDown;
  41 + }
  42 +
  43 + public void setUpDown(String upDown) {
  44 + this.upDown = upDown;
  45 + }
  46 +
  47 + public String getPhoto() {
  48 + return photo;
  49 + }
  50 +
  51 + public void setPhoto(String photo) {
  52 + this.photo = photo;
  53 + }
  54 +
  55 + public String getNum() {
  56 + return num;
  57 + }
  58 +
  59 + public void setNum(String num) {
  60 + this.num = num;
  61 + }
  62 +
  63 + public String getCreateDate() {
  64 + return createDate;
  65 + }
  66 +
  67 + public void setCreateDate(String createDate) {
  68 + this.createDate = createDate;
  69 + }
  70 +
  71 + public String getLineName() {
  72 + return lineName;
  73 + }
  74 +
  75 + public void setLineName(String lineName) {
  76 + this.lineName = lineName;
  77 + }
  78 +
  79 + public String getStationName() {
  80 + return stationName;
  81 + }
  82 +
  83 + public void setStationName(String stationName) {
  84 + this.stationName = stationName;
  85 + }
  86 +}
... ...
src/main/java/com/bsth/service/Kl/KlService.java
1 1 package com.bsth.service.Kl;
2 2  
  3 +import com.bsth.entity.Kl;
3 4 import com.bsth.entity.logger.Logger_MileModify;
4 5 import com.bsth.service.BaseService;
5 6  
  7 +import java.util.List;
6 8 import java.util.Map;
7 9  
8 10  
9 11 public interface KlService {
10 12 Map<String, Object> query(Map<String, Object> map);
  13 +
  14 + List<Kl> loadKl();
11 15 }
... ...
src/main/java/com/bsth/service/Kl/impl/KlServiceImpl.java
... ... @@ -2,14 +2,17 @@ package com.bsth.service.Kl.impl;
2 2  
3 3  
4 4  
  5 +import com.bsth.entity.Kl;
5 6 import com.bsth.service.Kl.KlService;
6 7 import org.slf4j.Logger;
7 8 import org.slf4j.LoggerFactory;
8 9 import org.springframework.beans.factory.annotation.Autowired;
9 10 import org.springframework.beans.factory.annotation.Value;
  11 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
10 12 import org.springframework.jdbc.core.JdbcTemplate;
11 13 import org.springframework.stereotype.Service;
12 14 import java.time.LocalDate;
  15 +import java.time.LocalDateTime;
13 16 import java.time.format.DateTimeFormatter;
14 17 import java.util.*;
15 18  
... ... @@ -26,6 +29,8 @@ public class KlServiceImpl implements KlService {
26 29 @Value("${passengerFlow.url}")
27 30 private String url;
28 31  
  32 + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  33 +
29 34 @Override
30 35 public Map<String, Object> query(Map<String, Object> map) {
31 36 Map<String, Object> modelMap = new HashMap<>();
... ... @@ -62,5 +67,20 @@ public class KlServiceImpl implements KlService {
62 67 }
63 68 }
64 69  
  70 + @Override
  71 + public List<Kl> loadKl() {
  72 + List<Kl> list = new ArrayList<>();
  73 + try {
  74 + LocalDateTime localDateTime = LocalDateTime.now().minusMinutes(3);
  75 + String time = localDateTime.format(dateTimeFormatter);
  76 + StringBuffer sql=new StringBuffer("select * from bsth_c_kl where createDate>='" +time+
  77 + "' and id in(SELECT max(id) from bsth_c_kl GROUP BY deviceId)");
  78 + list = jdbcTemplate.query(sql.toString(), BeanPropertyRowMapper.newInstance(Kl.class));
  79 + } catch (Exception e) {
  80 + logger.error("客流信息加载异常", e);
  81 + }
  82 + return list;
  83 + }
  84 +
65 85  
66 86 }
... ...
src/main/resources/static/assets/img/ss.jpg 0 → 100644

8.34 KB

src/main/resources/static/assets/img/ss.png 0 → 100644

2.03 KB

src/main/resources/static/assets/img/yb.jpg 0 → 100644

8.96 KB

src/main/resources/static/assets/img/yb.png 0 → 100644

3.21 KB

src/main/resources/static/assets/img/yj.jpg 0 → 100644

8.99 KB

src/main/resources/static/assets/img/yj.png 0 → 100644

2.74 KB

src/main/resources/static/pages/permission/authorize_all/user_auth.html
... ... @@ -77,6 +77,7 @@
77 77 <li><label><input class="uk-checkbox" type="checkbox" data-event="fbzdzx_config"> 翻班与自动执行</label></li>
78 78 <li><label><input class="uk-checkbox" type="checkbox" data-event="tts_config"> TTS</label></li>
79 79 <li><label><input class="uk-checkbox" type="checkbox" data-event="signal_state"> 信号标记</label></li>
  80 + <li><label><input class="uk-checkbox" type="checkbox" data-event="kl_config"> 客流信息</label></li>
80 81 </ul>
81 82 </div>
82 83 <div>
... ... @@ -189,7 +190,9 @@
189 190 '24_1': '一车队',
190 191 '24_2': '二车队',
191 192 '24_3': '三车队',
192   - '77_1': '临港公交'
  193 + '77_1': '临港公交',
  194 + '05_12': '二分公司',
  195 + '05_11': '一分公司'
193 196 };
194 197  
195 198 var defauleConfig;
... ...
src/main/resources/static/real_control_v2/css/main.css
... ... @@ -213,6 +213,15 @@ svg.line-chart g.gps-wrap &gt; rect {
213 213 cursor: pointer;
214 214 }
215 215  
  216 +svg.line-chart g.gps-wrap > image[updown="0"] {
  217 + width:17px;
  218 + height:15px;
  219 + z-index: 0;
  220 +}
  221 +svg.line-chart g.gps-wrap > image[updown="1"] {
  222 + width:17px;
  223 + height:15px;
  224 +}
216 225 svg.line-chart g.gps-wrap > rect[updown="0"] {
217 226 stroke: rgb(62, 80, 179);
218 227 fill: rgb(62, 80, 179);
... ...
src/main/resources/static/real_control_v2/fragments/home/tooltip.html
... ... @@ -57,6 +57,18 @@
57 57 <div>
58 58 预计 {{expectStopTime}} 分钟到达终点</div>
59 59 {{/if}}
  60 + {{if kl !=null}}
  61 + <div><span class="field">人数:</span>{{kl.num}}</div>
  62 + {{/if}}
  63 + {{if kl !=null && kl.num <= 5}}
  64 + <div><span class="field">状态:</span><a href="javascript:;" style="color:green" onclick="javascript:gb_map_play_back.showPhoto('{{kl.photo}}');">舒适</a></div>
  65 + {{/if}}
  66 + {{if kl !=null && kl.num > 5 && kl.num <= 10}}
  67 + <div><span class="field">状态:</span><a href="javascript:;" style="color:chocolate" onclick="javascript:gb_map_play_back.showPhoto('{{kl.photo}}');">一般</a></div>
  68 + {{/if}}
  69 + {{if kl !=null && kl.num > 10}}
  70 + <div><span class="field">状态:</span><a href="javascript:;" style="color:red" onclick="javascript:gb_map_play_back.showPhoto('{{kl.photo}}');">拥挤</a></div>
  71 + {{/if}}
60 72 </div>
61 73  
62 74 <div class="tip_map_wrap"></div>
... ...
src/main/resources/static/real_control_v2/fragments/north/nav/kl_config.html 0 → 100644
  1 +<div class="uk-modal ct-form-modal" id="kl_config-modal">
  2 + <div class="uk-modal-dialog" style="width: 530px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div class="uk-modal-header">
  5 + <h2>客流显示设置</h2></div>
  6 +
  7 + <p style="border-bottom: 1px solid #efefef;color: grey;padding-bottom: 9px;">
  8 + <small>
  9 + <i class="uk-icon-question-circle"> </i>
  10 + 设置项将会保存在本地客户端,清理缓存和更换电脑会重置.</small>
  11 + </p>
  12 + <form class="uk-form uk-form-horizontal">
  13 + <div class="uk-grid">
  14 + <div class="uk-width-2-3 uk-container-center">
  15 + <div class="uk-form-row">
  16 + <label class="uk-form-label">是否启用</label>
  17 + <div class="uk-form-controls">
  18 + <select name="enable">
  19 + <option value="1">启用</option>
  20 + <option value="0">禁用</option>
  21 + </select>
  22 + </div>
  23 + </div>
  24 + </div>
  25 + </div>
  26 +
  27 + <div class="uk-modal-footer uk-text-right" style="margin-bottom: -20px;">
  28 + <button type="button" class="uk-button uk-modal-close">取消</button>
  29 + <button type="submit" class="uk-button uk-button-primary"><i class="uk-icon-check"></i> &nbsp;保存</button>
  30 + </div>
  31 + </form>
  32 + </div>
  33 +
  34 + <script>
  35 + var storage = window.localStorage;
  36 + (function() {
  37 + var modal = '#kl_config-modal';
  38 + var f = $('form', modal);
  39 +
  40 + $(modal).on('init', function(e, data) {
  41 + e.stopPropagation();
  42 + var locStatus=0;
  43 + if( storage.getItem("kl_state_enable")==1){
  44 + locStatus=1;
  45 + }
  46 + $('[name=enable]', f).val(locStatus);
  47 + });
  48 +
  49 + f.formValidation(gb_form_validation_opts);
  50 + f.on('success.form.fv', function(e) {
  51 + e.preventDefault();
  52 + var data = $(this).serializeJSON();
  53 + storage.setItem("kl_state_enable", data.enable);
  54 + UIkit.modal(modal).hide();
  55 + });
  56 +
  57 + })();
  58 + </script>
  59 +</div>
0 60 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/js/data/json/north_toolbar.json
... ... @@ -185,6 +185,11 @@
185 185 "id": 4.4,
186 186 "text": "翻班与自动执行",
187 187 "event": "fbzdzx_config"
  188 + },
  189 + {
  190 + "id": 4.5,
  191 + "text": "客流信息",
  192 + "event": "kl_config"
188 193 }
189 194  
190 195 ]
... ...
src/main/resources/static/real_control_v2/js/north/toolbar.js
... ... @@ -122,6 +122,9 @@ var gb_northToolbar = (function () {
122 122 line_config: function () {
123 123 open_modal('/real_control_v2/fragments/north/nav/line_config/line_config.html', {}, modal_opts);
124 124 },
  125 + kl_config: function () {
  126 + open_modal('/real_control_v2/fragments/north/nav/kl_config.html', {}, modal_opts);
  127 + },
125 128 // bcgxsj_config: function () {
126 129 // open_modal('/real_control_v2/fragments/north/nav/line_config/bcgxsj_config.html', {}, modal_opts);
127 130 // },
... ...
src/main/resources/static/real_control_v2/js/utils/svg_chart.js
... ... @@ -220,6 +220,23 @@ var gb_svg_chart = (function () {
220 220  
221 221 return gps.upDown == 0 ? cy - 22 - (index * 17) : cy + 6 + (index * 19);
222 222 },
  223 + gx2 = function (gps, svg, wrapId) {
  224 + var circle = get_circle(gps.stopNo + '_' + gps.upDown, svg);
  225 + if (!circle) return -100;
  226 +
  227 + var x = circle.attr('cx') - 16.5,
  228 + s = circle_spaces[wrapId] / 2;
  229 + // console.log('ss', gps.lineId + '=' + s);
  230 + //s = 5;
  231 + if(gps['instation']==0)
  232 + x = (gps['upDown']==0?x+s:x-s);
  233 + if(gps['abnormalClaszz']==false){//为越速掉设置偏移
  234 + x+=30;
  235 + }else {
  236 + x+=41;
  237 + }
  238 + return x;
  239 + },
223 240 ups_gps = function (d) {
224 241 return d.gpsUps;
225 242 },
... ... @@ -276,11 +293,54 @@ var gb_svg_chart = (function () {
276 293 //update tip position
277 294 gb_svg_tooltip.update(e);
278 295 },
  296 + gps_update_point2 = function (e, svg, wrapId,state) {
  297 + var x,e1;
  298 + e1 = e;
  299 + if(animation)
  300 + e1 = e.transition();
  301 + e1.attr('x', function (d) {
  302 + x = gx2(d, svg, wrapId);
  303 + if(x == -100)
  304 + $(this).css('transition-duration', 0).hide();
  305 + else
  306 + $(this).show();//找不到停靠点,直接隐藏
  307 + if(state==0)
  308 + $(this).css('transition-duration', 0).hide();
  309 + return x;
  310 + })
  311 + .attr('y', function (d) {
  312 + return gy(d, svg);
  313 + })
  314 + .attr('updown', function (d) {
  315 + return d.upDown;
  316 + })
  317 + .attr('xlink:href', function (d) {
  318 + var img ='';
  319 + if(d['kl'] != undefined && d['kl']['num']<=5){
  320 + img ='/assets/img/ss.png';
  321 + }else if(d['kl'] != undefined && d['kl']['num']>5 && d['kl']['num']<=10){
  322 + img ='/assets/img/yb.png';
  323 + }else if(d['kl'] != undefined && d['kl']['num']>10){
  324 + img ='/assets/img/yj.png';
  325 + }
  326 + return img;
  327 + });
  328 + e.classed({'abnormal': function (d) {
  329 + return d.abnormalClaszz;
  330 + }, 'offline': function (d) {
  331 + return d['abnormalStatus']=='offline';
  332 + }});
  333 + //update tip position
  334 + gb_svg_tooltip.update(e);
  335 + },
279 336 rct_id = function (d) {
280 337 return 'rct_' + d.deviceId;
281 338 },
282 339 tx_id = function (d) {
283 340 return 'tx_' + d.deviceId;
  341 + },
  342 + img_id = function (d) {
  343 + return 'img_' + d.deviceId;
284 344 };
285 345  
286 346 var setGps = function (lineCode) {
... ... @@ -347,6 +407,14 @@ var gb_svg_chart = (function () {
347 407 ts.enter().append('text').attr('_id', tx_id);
348 408 ts.text(g_text)
349 409 gps_update_point(ts, svg, wrapId);
  410 +
  411 + var imageState=0;
  412 + if(window.localStorage.getItem("kl_state_enable") == 1){
  413 + imageState=1;
  414 + }
  415 + var imgs = gps_cont.selectAll('image').data(data, gps_key);
  416 + imgs.enter().append('image').attr('_id', img_id);
  417 + gps_update_point2(imgs, svg, wrapId,imageState);
350 418 };
351 419  
352 420 var marker_clusterer = function (svg, lineCode) {
... ... @@ -375,7 +443,7 @@ var gb_svg_chart = (function () {
375 443 var svg = d3.select(svg);
376 444 //hide old element
377 445 $.each(gpsArr, function (i, d) {
378   - $('rect[_id=rct_' + d + '],text[_id=tx_' + d + ']').attr('class', 'merge_hide');
  446 + $('rect[_id=rct_' + d + '],text[_id=tx_' + d + '],image[_id=img_' + d + ']').attr('class', 'merge_hide');
379 447 });
380 448  
381 449 var mergerG = svg.selectAll('g.marker-clusterer').append('g').attr('_id', 'merger_' + stopNo)
... ...
src/main/resources/static/real_control_v2/mapmonitor/fragments/map_infowindow.html
... ... @@ -32,17 +32,17 @@
32 32 <p>角度:{{direction}}</p>
33 33 <p>经度:{{lon}}</p>
34 34 <p>纬度:{{lat}}</p>
35   - {{if num !=null}}
36   - <p>人数:{{num}}</p>
  35 + {{if kl !=null}}
  36 + <p>人数:{{kl.num}}</p>
37 37 {{/if}}
38   - {{if num !=null && num <= 5}}
39   - <p>状态:<a href="javascript:;" style="color:green" onclick="javascript:gb_map_play_back.showPhoto('{{photo}}');">舒适</a></p>
  38 + {{if kl !=null && kl.num <= 5}}
  39 + <p>状态:<a href="javascript:;" style="color:green" onclick="javascript:gb_map_play_back.showPhoto('{{kl.photo}}');">舒适</a></p>
40 40 {{/if}}
41   - {{if num > 5 && num <= 10}}
42   - <p>状态:<a href="javascript:;" style="color:chocolate" onclick="javascript:gb_map_play_back.showPhoto('{{photo}}');">一般</a></p>
  41 + {{if kl !=null && kl.num > 5 && kl.num <= 10}}
  42 + <p>状态:<a href="javascript:;" style="color:chocolate" onclick="javascript:gb_map_play_back.showPhoto('{{kl.photo}}');">一般</a></p>
43 43 {{/if}}
44   - {{if num > 10}}
45   - <p>状态:<a href="javascript:;" style="color:red" onclick="javascript:gb_map_play_back.showPhoto('{{photo}}');">拥挤</a></p>
  44 + {{if kl !=null && kl.num > 10}}
  45 + <p>状态:<a href="javascript:;" style="color:red" onclick="javascript:gb_map_play_back.showPhoto('{{kl.photo}}');">拥挤</a></p>
46 46 {{/if}}
47 47 {{if energy == 0}}
48 48 <div><span class="field">电量:</span><span style="color: red;">{{energy}}%&nbsp;(异常)</span></div>
... ...
src/main/resources/static/real_control_v2/mapmonitor/js/map_overlay_manager.js
... ... @@ -257,14 +257,6 @@ var gb_map_overlay_mge = (function () {
257 257 _focus_station: _focus_station,
258 258 _focus_carpark: _focus_carpark,
259 259 map_gps_win_temp: function (data) {
260   - var url='http://58.247.254.118:9999/pf/getPassengerFlow?deviceId='+data.deviceId;
261   - console.log(url);
262   - $.ajax({async:false,url:url, success:function(res) {
263   - console.log(res);
264   - data.num=res.num;
265   - data.photo=res.photo;
266   - }})
267   - console.log("数据回显");
268 260 return temps['map-win-gps-detail-temp'](data);
269 261 },
270 262 map_station_win_temp: function (data) {
... ...