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