Commit 3bd21912d4ed2ccdd127185f68ac3d82872e83f3

Authored by 潘钊
1 parent 0e404f00

update...

src/main/java/com/bsth/StartCommand.java
... ... @@ -43,7 +43,7 @@ public class StartCommand implements CommandLineRunner{
43 43 invocationSecurityMetadataSourceService.loadResourceDefine();
44 44  
45 45 //同步屏 LED 推送服务
46   - //ledHttpPushHandler.start();
  46 + ledHttpPushHandler.start();
47 47  
48 48 //signal、牌照识别、查询一体机数据消费队列
49 49 SignalAndAttConsumeQueue.start();
... ...
src/main/java/com/bsth/data/in_out/RealInoutHandler.java
... ... @@ -3,6 +3,7 @@ package com.bsth.data.in_out;
3 3 import com.bsth.common.ResponseCode;
4 4 import com.bsth.data.basic.bus.BusDataBuffer;
5 5 import com.bsth.data.in_out.buffer.BerthDataBuffer;
  6 +import com.bsth.data.led_http.LedHttpPushHandler;
6 7 import com.bsth.data.schedule.dto.ScheduleInOut;
7 8 import com.bsth.data.schedule.real.ScheduleDataBuffer;
8 9 import com.bsth.entity.Bus;
... ... @@ -79,6 +80,8 @@ public class RealInoutHandler {
79 80 private void busOut(CarInOutEntity cio) {
80 81 car2berthMap.remove(cio.getNbbm());
81 82  
  83 + //led
  84 + LedHttpPushHandler.busOut(cio);
82 85 //通知客户端
83 86 sendUtils.sendCarOut(cio.getNbbm(), cio.getT());
84 87 }
... ... @@ -95,14 +98,15 @@ public class RealInoutHandler {
95 98 Bus bus = BusDataBuffer.findOne(nbbm);
96 99 //非电车,停柴油泊位区
97 100 if(!bus.isSfdc()){
98   - //LedHttpPushHandler.busIn(bus.getCarPlate(), "柴油泊位区");
  101 + LedHttpPushHandler.busIn(bus.getCarPlate(), "柴油泊位区");
99 102 return;
100 103 }
101 104  
102 105 //是否有固定泊位
103 106 String lockBName = BerthDataBuffer.getLockBerthName(nbbm);
104   - if(StringUtils.isNotEmpty(lockBName))
  107 + if(StringUtils.isNotEmpty(lockBName)){
105 108 car2berthMap.put(nbbm, lockBName);
  109 + }
106 110 else{
107 111 //停空闲泊位
108 112 List<RegionBerth> berthList = BerthDataBuffer.allNoLock();
... ... @@ -124,6 +128,9 @@ public class RealInoutHandler {
124 128 logger.info("没有空余泊位了");
125 129 }
126 130  
  131 + if(car2berthMap.containsKey(nbbm))
  132 + LedHttpPushHandler.busIn(bus.getCarPlate(), car2berthMap.get(nbbm));
  133 +
127 134 //通知客户端
128 135 sendUtils.sendCarIn(nbbm, car2berthMap.get(nbbm), cio.getT());
129 136 }
... ... @@ -239,4 +246,8 @@ public class RealInoutHandler {
239 246 public boolean containsBerth(String berthName) {
240 247 return car2berthMap.inverse().containsKey(berthName);
241 248 }
  249 +
  250 + public int size() {
  251 + return car2berthMap.size();
  252 + }
242 253 }
... ...
src/main/java/com/bsth/data/in_out/buffer/ElectricDataBuffer.java
... ... @@ -41,4 +41,16 @@ public class ElectricDataBuffer {
41 41 }
42 42 return rs;
43 43 }
  44 +
  45 + public static Double getSoc(String nbbm){
  46 + try{
  47 + if(!nbbm2ElecMap.containsKey(nbbm))
  48 + return -1d;
  49 +
  50 + return Double.parseDouble(nbbm2ElecMap.get(nbbm).getSoc());
  51 + }catch (Exception e){
  52 + return -1d;
  53 + }
  54 + }
  55 +
44 56 }
... ...
src/main/java/com/bsth/data/led_http/LedHttpPushHandler.java
1 1 package com.bsth.data.led_http;
2 2  
  3 +import com.bsth.data.in_out.RealInoutHandler;
  4 +import com.bsth.data.in_out.buffer.BerthDataBuffer;
  5 +import com.bsth.data.in_out.buffer.ElectricDataBuffer;
  6 +import com.bsth.entity.ac.CarInOutEntity;
  7 +import com.bsth.entity.berth.RegionBerth;
  8 +import com.bsth.service.berth.BerthService;
  9 +import com.bsth.util.ConfigUtil;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.factory.annotation.Autowired;
3 13 import org.springframework.stereotype.Component;
4 14  
  15 +import java.util.LinkedList;
  16 +import java.util.List;
  17 +import java.util.Map;
  18 +import java.util.Set;
  19 +
5 20 /**
6 21 * Created by panzhao on 2017/9/26.
7 22 */
8 23 @Component
9   -public class LedHttpPushHandler {/*
  24 +public class LedHttpPushHandler {
10 25  
11 26 @Autowired
12 27 BerthService berthService;
13 28  
14   - @Autowired
15   - CarParkRealHandler carParkRealHandler;
16   -
17 29 private static String baseUrl;
18 30 //private static String outUrl;
19 31  
  32 + @Autowired
  33 + RealInoutHandler realInoutHandler;
  34 +
20 35 //上次发送停放信息时间戳
21 36 private static long send_tfxx_time=System.currentTimeMillis();
22 37  
... ... @@ -60,26 +75,29 @@ public class LedHttpPushHandler {/*
60 75 dataUrlLinked.add(url);
61 76 }
62 77  
63   - *//**
  78 + /**
64 79 * 场内停放信息
65   - * @return
66   - *//*
  80 + */
67 81 public void sendTfxx(){
68 82 int can=0;//可停车数
69 83 int yet=0;//已停车数
70 84 int now=0;//正充电数
71 85  
72   - List<RegionBerth> list = berthService.all();
  86 + List<RegionBerth> list = BerthDataBuffer.all();
73 87 can = list.size();
74 88  
75   - for(RegionBerth b : list){
76   - if(null != b.getNbbm()){
77   - yet++;
  89 + yet = realInoutHandler.size();
78 90  
79   - if(carParkRealHandler.soc(b.getNbbm()) > 0)
80   - now++;
81   - }
  91 + Map<String, String> map = realInoutHandler.getCar2berthMap();
  92 + Set<String> ks = map.keySet();
  93 +
  94 + Double soc;
  95 + for(String k : ks){
  96 + soc = ElectricDataBuffer.getSoc(k);
  97 + if(soc >= 0 && soc<100)
  98 + now++;
82 99 }
  100 +
83 101 String url = baseUrl + "/tcPlan?can="+can+"&yet="+yet+"&now="+now;
84 102 dataUrlLinked.add(url);
85 103 }
... ... @@ -107,7 +125,7 @@ public class LedHttpPushHandler {/*
107 125 if (null != url) {
108 126 sleepFlag = false;
109 127 logger.info("push led :" + url);
110   - HttpClientUtils_tms.get(url);
  128 + //HttpClientUtils_tms.get(url);
111 129 } else {
112 130 Thread.sleep(500);
113 131 if (!sleepFlag) {
... ... @@ -130,5 +148,5 @@ public class LedHttpPushHandler {/*
130 148  
131 149 log.warn("Led ConsumeQueue is break...");
132 150 }
133   - }*/
  151 + }
134 152 }
... ...