Commit 0e404f006b52a3b1a6fcfe59f8b29374072b940d

Authored by 潘钊
1 parent 44718ecc

update...

Showing 37 changed files with 1056 additions and 1178 deletions

Too many changes to show.

To preserve performance only 37 of 47 files are displayed.

... ... @@ -4,7 +4,7 @@
4 4 <modelVersion>4.0.0</modelVersion>
5 5 <groupId>com.bsth</groupId>
6 6 <artifactId>bus_park_dispatch</artifactId>
7   - <version>0.0.1-SNAPSHOT</version>
  7 + <version>0.0.2-SNAPSHOT</version>
8 8 <packaging>jar</packaging>
9 9  
10 10 <parent>
... ...
src/main/java/com/bsth/StartCommand.java
1 1 package com.bsth;
2 2  
3 3  
  4 +import com.bsth.data.in_out.buffer.BerthDataBuffer;
  5 +import com.bsth.data.in_out.thread.Car2BerthDataPstThread;
  6 +import com.bsth.data.in_out.thread.SignalPstThread;
4 7 import com.bsth.data.led_http.LedHttpPushHandler;
5 8 import com.bsth.data.msg_queue.SignalAndAttConsumeQueue;
6   -import com.bsth.data.real_park.CarParkRealHandler;
7   -import com.bsth.data.real_park.thread.RealParkDataPersistenceThread;
8   -import com.bsth.data.signal.thread.SignalPstThread;
  9 +import com.bsth.data.msg_queue.WebSocketPushQueue;
9 10 import com.bsth.security.SecurityMetadataSourceService;
10   -import com.bsth.service.berth.impl.BerthServiceImpl;
11 11 import org.springframework.beans.factory.annotation.Autowired;
12 12 import org.springframework.boot.CommandLineRunner;
13 13 import org.springframework.stereotype.Component;
... ... @@ -27,17 +27,13 @@ public class StartCommand implements CommandLineRunner{
27 27 @Autowired
28 28 SecurityMetadataSourceService invocationSecurityMetadataSourceService;
29 29 @Autowired
30   - SignalPstThread signalPstThread;
31   - @Autowired
32   - RealParkDataPersistenceThread realParkDataPersistenceThread;
33   -
34   - @Autowired
35   - CarParkRealHandler carParkRealHandler;
  30 + SignalPstThread signalPstThread;
36 31 @Autowired
37 32 LedHttpPushHandler ledHttpPushHandler;
38   -
39 33 @Autowired
40   - BerthServiceImpl.BerthCacheRefreshThread berthCacheRefreshThread;
  34 + BerthDataBuffer berthDataBuffer;
  35 + @Autowired
  36 + Car2BerthDataPstThread car2BerthDataPstThread;
41 37  
42 38 @Override
43 39 public void run(String... arg0){
... ... @@ -47,23 +43,22 @@ public class StartCommand implements CommandLineRunner{
47 43 invocationSecurityMetadataSourceService.loadResourceDefine();
48 44  
49 45 //同步屏 LED 推送服务
50   - ledHttpPushHandler.start();
  46 + //ledHttpPushHandler.start();
51 47  
52 48 //signal、牌照识别、查询一体机数据消费队列
53 49 SignalAndAttConsumeQueue.start();
  50 + //websocket 消费队列
  51 + WebSocketPushQueue.start();
  52 +
  53 + //初始化泊位信息
  54 + berthDataBuffer.init();
54 55  
55 56 ScheduledExecutorService sexec = Application.mainServices;
56 57 //进出场数据入库线程
57   - sexec.scheduleWithFixedDelay(signalPstThread, 30, 10, TimeUnit.SECONDS);
58   -
59   - //从数据库恢复场内实时停放数据
60   - berthCacheRefreshThread.run();
61   - carParkRealHandler.recovery();
62   - //实时场内停放数据入库
63   - sexec.scheduleWithFixedDelay(realParkDataPersistenceThread, 40, 30, TimeUnit.SECONDS);
  58 + sexec.scheduleWithFixedDelay(signalPstThread, 30, 100, TimeUnit.SECONDS);
  59 + //实时车辆泊位数据入库
  60 + sexec.scheduleWithFixedDelay(car2BerthDataPstThread, 20, 20, TimeUnit.SECONDS);
64 61  
65   - //泊位数据刷新
66   - sexec.scheduleWithFixedDelay(berthCacheRefreshThread, 60 * 15, 60 * 15, TimeUnit.SECONDS);
67 62 } catch (Exception e) {
68 63 e.printStackTrace();
69 64 }
... ...
src/main/java/com/bsth/WebAppConfiguration.java
1 1 package com.bsth;
2 2  
  3 +import com.bsth.websocket.WebSocketHandshakeInterceptor;
  4 +import com.bsth.websocket.handler.RealInoutSocketHandler;
3 5 import org.slf4j.Logger;
4 6 import org.slf4j.LoggerFactory;
5 7 import org.springframework.context.annotation.Bean;
... ... @@ -46,9 +48,9 @@ public class WebAppConfiguration extends WebMvcConfigurerAdapter implements WebS
46 48  
47 49 @Override
48 50 public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
49   - //线调webSocket
50   - //registry.addHandler(new RealControlSocketHandler(), "/sockjs/").addInterceptors(new WebSocketHandshakeInterceptor())
51   - // .withSockJS();
  51 + //webSocket
  52 + registry.addHandler(new RealInoutSocketHandler(), "/sockjs/inout").addInterceptors(new WebSocketHandshakeInterceptor())
  53 + .withSockJS();
52 54 }
53 55  
54 56 /**
... ...
src/main/java/com/bsth/controller/UpstreamEntrance.java
1 1 package com.bsth.controller;
2 2  
  3 +import com.alibaba.fastjson.JSON;
3 4 import com.bsth.data.attendance.AttendaceDataBuffer;
4 5 import com.bsth.data.attendance.dto.RemoteAttendaceDTO;
5   -import com.bsth.data.electric.CarElectricBuffer;
6   -import com.bsth.data.signal.RFIDInParkDataBuffer;
7   -import com.bsth.data.signal.dto.RfidInOutDto;
8   -import com.bsth.entity.electric.BusElectric;
9   -import org.springframework.beans.factory.annotation.Autowired;
  6 +import com.bsth.data.in_out.buffer.ElectricDataBuffer;
  7 +import com.bsth.data.in_out.entity.Electric;
  8 +import com.bsth.data.in_out.entity.RfidInOutDto;
  9 +import com.bsth.data.msg_queue.SignalAndAttConsumeQueue;
  10 +import com.bsth.entity.ac.CarInOutEntity;
  11 +import org.apache.commons.lang3.StringUtils;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
10 14 import org.springframework.web.bind.annotation.*;
11 15  
12 16 import java.util.List;
... ... @@ -19,8 +23,7 @@ import java.util.List;
19 23 @RequestMapping("bus_park_dispatch")
20 24 public class UpstreamEntrance {
21 25  
22   - @Autowired
23   - CarElectricBuffer carElectricBuffer;
  26 + Logger logger = LoggerFactory.getLogger(this.getClass());
24 27  
25 28 /**
26 29 * 查询一体机实时签到
... ... @@ -37,7 +40,17 @@ public class UpstreamEntrance {
37 40 */
38 41 @RequestMapping(value = "inout_rfid", method = RequestMethod.POST)
39 42 public void inOut_rfid(@RequestBody RfidInOutDto rfidInOut){
40   - RFIDInParkDataBuffer.put(rfidInOut);
  43 + logger.info("RFID 进出场 : " + JSON.toJSONString(rfidInOut));
  44 + if(null == rfidInOut)
  45 + return;
  46 + if(StringUtils.isEmpty(rfidInOut.getCarCard()))
  47 + return;
  48 +
  49 + if(null == rfidInOut.getReportTime())
  50 + return;
  51 +
  52 + CarInOutEntity cio = CarInOutEntity.getInstance(rfidInOut);
  53 + SignalAndAttConsumeQueue.put(cio);
41 54 }
42 55  
43 56 /**
... ... @@ -46,7 +59,7 @@ public class UpstreamEntrance {
46 59 */
47 60 @RequestMapping(value = "electric", method = RequestMethod.POST)
48 61 @ResponseBody
49   - public void electric(@RequestBody List<BusElectric> list){
50   - carElectricBuffer.putAll(list);
  62 + public void electric(@RequestBody List<Electric> list){
  63 + ElectricDataBuffer.put(list);
51 64 }
52 65 }
... ...
src/main/java/com/bsth/controller/basic/BusController.java
1 1 package com.bsth.controller.basic;
2 2  
3   -import com.bsth.data.electric.CarElectricBuffer;
4 3 import com.bsth.entity.Bus;
5   -import com.bsth.entity.electric.BusElectric;
6 4 import com.bsth.service.basic.BusService;
7 5 import org.springframework.beans.factory.annotation.Autowired;
8 6 import org.springframework.web.bind.annotation.*;
9 7  
10   -import java.util.Collection;
11 8 import java.util.Map;
12 9  
13 10 /**
... ... @@ -61,10 +58,12 @@ public class BusController {
61 58 return busService.save(b);
62 59 }
63 60  
  61 +/*
64 62 @RequestMapping("real_elec_info")
65 63 public Collection<BusElectric> realElecInfo(){
66 64 return CarElectricBuffer.all();
67 65 }
  66 +*/
68 67  
69 68 @RequestMapping("all")
70 69 public Map<String, Object> all(){
... ...
src/main/java/com/bsth/controller/berth/BerthController.java
1 1 package com.bsth.controller.berth;
2 2  
3 3 import com.bsth.controller.BaseController;
  4 +import com.bsth.controller.berth.dto.Car2Berth;
  5 +import com.bsth.data.in_out.RealInoutHandler;
  6 +import com.bsth.data.in_out.buffer.BerthDataBuffer;
  7 +import com.bsth.data.in_out.buffer.ElectricDataBuffer;
4 8 import com.bsth.entity.berth.RegionBerth;
5 9 import com.bsth.service.berth.BerthService;
6 10 import org.springframework.beans.factory.annotation.Autowired;
7 11 import org.springframework.web.bind.annotation.RequestMapping;
  12 +import org.springframework.web.bind.annotation.RequestParam;
8 13 import org.springframework.web.bind.annotation.RestController;
9 14  
  15 +import java.util.List;
  16 +import java.util.Map;
  17 +
10 18 /**
11 19 * Created by panzhao on 2017/8/22.
12 20 */
... ... @@ -14,12 +22,61 @@ import org.springframework.web.bind.annotation.RestController;
14 22 @RequestMapping("/berth")
15 23 public class BerthController extends BaseController<RegionBerth, Integer> {
16 24  
17   - @Autowired
  25 +/* @Autowired
18 26 BerthService berthService;
19 27  
20 28 @RequestMapping("max_order_no")
21 29 public String maxOrderNo() {
22 30 String rs = berthService.maxOrderNo();
23 31 return rs==null?"0":rs;
  32 + }*/
  33 +
  34 + @Autowired
  35 + BerthService berthService;
  36 +
  37 + @Autowired
  38 + RealInoutHandler realInoutHandler;
  39 +
  40 + @Autowired
  41 + BerthDataBuffer berthDataBuffer;
  42 +
  43 + @RequestMapping("findCar2Berths")
  44 + public List<Car2Berth> findCar2Berths(){
  45 + return berthService.car2Berths();
  46 + }
  47 +
  48 + @RequestMapping("all_list")
  49 + public List<RegionBerth> all(){
  50 + return BerthDataBuffer.all();
  51 + }
  52 +
  53 + @RequestMapping("addCar")
  54 + public Map<String, Object> addCar(@RequestParam String berthName,@RequestParam String nbbm){
  55 + return realInoutHandler.addCar2Berth(nbbm, berthName);
  56 + }
  57 +
  58 + @RequestMapping("removeCar")
  59 + public Map<String, Object> removeCar(@RequestParam String b){
  60 + return realInoutHandler.removeCar2Berth(b);
  61 + }
  62 +
  63 + @RequestMapping("changeCar2Berth")
  64 + public Map<String, Object> changeCar2Berth(@RequestParam String s,@RequestParam String d){
  65 + return RealInoutHandler.changeCar2Berth(s, d);
  66 + }
  67 +
  68 + @RequestMapping("lockBerth")
  69 + public Map<String, Object> lockBerth(@RequestParam String berthName){
  70 + return berthDataBuffer.lockBerth(berthName);
  71 + }
  72 +
  73 + @RequestMapping("unlockBerth")
  74 + public Map<String, Object> unlockBerth(@RequestParam String berthName){
  75 + return berthDataBuffer.unlockBerth(berthName);
  76 + }
  77 +
  78 + @RequestMapping("elecs")
  79 + public Map<String, Double> elecs(){
  80 + return ElectricDataBuffer.elecs();
24 81 }
25 82 }
... ...
src/main/java/com/bsth/controller/berth/dto/Car2Berth.java 0 → 100644
  1 +package com.bsth.controller.berth.dto;
  2 +
  3 +import com.bsth.entity.Bus;
  4 +
  5 +/**
  6 + * 车辆和泊位 DTO
  7 + * Created by panzhao on 2017/11/4.
  8 + */
  9 +public class Car2Berth {
  10 +
  11 + //车
  12 + private Bus bus;
  13 +
  14 + //泊位名称
  15 + private String berth;
  16 +
  17 + //电
  18 + //private Electric elec;
  19 +
  20 +
  21 + public Bus getBus() {
  22 + return bus;
  23 + }
  24 +
  25 + public void setBus(Bus bus) {
  26 + this.bus = bus;
  27 + }
  28 +
  29 + public String getBerth() {
  30 + return berth;
  31 + }
  32 +
  33 + public void setBerth(String berth) {
  34 + this.berth = berth;
  35 + }
  36 +}
... ...
src/main/java/com/bsth/controller/real/CarParkRealController.java deleted 100644 → 0
1   -package com.bsth.controller.real;
2   -
3   -import com.bsth.data.real_park.CarParkRealHandler;
4   -import com.bsth.entity.real.RealCarPark;
5   -import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.web.bind.annotation.RequestMapping;
7   -import org.springframework.web.bind.annotation.RequestMethod;
8   -import org.springframework.web.bind.annotation.RequestParam;
9   -import org.springframework.web.bind.annotation.RestController;
10   -
11   -import java.util.Collection;
12   -import java.util.Map;
13   -
14   -/**
15   - * Created by panzhao on 2017/9/14.
16   - */
17   -@RestController
18   -@RequestMapping("car_park_real")
19   -public class CarParkRealController {
20   -
21   - @Autowired
22   - CarParkRealHandler carParkRealHandler;
23   -
24   - @RequestMapping("bus")
25   - public Collection<RealCarPark> busAll(){
26   - return CarParkRealHandler.allBus();
27   - }
28   -
29   - @RequestMapping(value = "real_change", method = RequestMethod.POST)
30   - public Map<String, Object> realChange(@RequestParam String s, @RequestParam String d){
31   - return carParkRealHandler.realChange(s, d);
32   - }
33   -
34   - @RequestMapping(value = "add_car2berth", method = RequestMethod.POST)
35   - public Map<String, Object> addCar2Berth(@RequestParam String berthName, @RequestParam String nbbm){
36   - return carParkRealHandler.addCar2Berth(berthName, nbbm);
37   - }
38   -
39   - @RequestMapping(value = "clear_berth", method = RequestMethod.POST)
40   - public Map<String, Object> clear_berth(@RequestParam String b){
41   - return carParkRealHandler.clear_berth(b);
42   - }
43   -}
src/main/java/com/bsth/controller/schedule/InOutScheduleController.java
1 1 package com.bsth.controller.schedule;
2 2  
3 3 import com.bsth.data.schedule.dto.ScheduleInOut;
4   -import com.bsth.service.schedule.InOutScheduleService;
  4 +import com.bsth.service.schedule.ScheduleService;
5 5 import org.springframework.beans.factory.annotation.Autowired;
6 6 import org.springframework.web.bind.annotation.RequestMapping;
7 7 import org.springframework.web.bind.annotation.RestController;
... ... @@ -17,7 +17,7 @@ import java.util.List;
17 17 public class InOutScheduleController {
18 18  
19 19 @Autowired
20   - InOutScheduleService inOutScheduleService;
  20 + ScheduleService inOutScheduleService;
21 21  
22 22 @RequestMapping("all")
23 23 public Collection<ScheduleInOut> all(){
... ...
src/main/java/com/bsth/data/electric/CarElectricBuffer.java deleted 100644 → 0
1   -package com.bsth.data.electric;
2   -
3   -import com.bsth.data.real_park.CarParkRealHandler;
4   -import com.bsth.entity.electric.BusElectric;
5   -import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.stereotype.Component;
7   -
8   -import java.util.Collection;
9   -import java.util.HashMap;
10   -import java.util.List;
11   -import java.util.Map;
12   -
13   -/**
14   - * 车辆电量信息
15   - * Created by panzhao on 2017/9/11.
16   - */
17   -@Component
18   -public class CarElectricBuffer {
19   -
20   - public static Map<String, BusElectric> carElecMap = new HashMap<>();
21   -
22   - @Autowired
23   - CarParkRealHandler carParkRealHandler;
24   -
25   - public void putAll(List<BusElectric> list){
26   - for(BusElectric be : list){
27   - carElecMap.put(be.getNbbm(), be);
28   - carParkRealHandler.putElec(be);
29   - }
30   - }
31   -
32   - public static Collection<BusElectric> all(){
33   - return carElecMap.values();
34   - }
35   -}
src/main/java/com/bsth/data/in_out/DataRecoveryUtil.java 0 → 100644
  1 +package com.bsth.data.in_out;
  2 +
  3 +import com.bsth.data.in_out.buffer.BerthDataBuffer;
  4 +import com.bsth.entity.berth.RegionBerth;
  5 +import com.bsth.repository.berth.BerthRepository;
  6 +import com.google.common.collect.BiMap;
  7 +import com.google.common.collect.HashBiMap;
  8 +import org.apache.commons.lang3.StringUtils;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * 启动的时候恢复数据
  17 + * Created by panzhao on 2017/11/5.
  18 + */
  19 +@Component
  20 +public class DataRecoveryUtil {
  21 +
  22 + @Autowired
  23 + BerthRepository berthRepository;
  24 +
  25 + @Autowired
  26 + RealInoutHandler realInoutHandler;
  27 +
  28 + @Autowired
  29 + BerthDataBuffer berthDataBuffer;
  30 +
  31 + public void recovery(){
  32 + List<RegionBerth> list = (List<RegionBerth>) berthRepository.findAll();
  33 +
  34 + //被禁用的泊位
  35 + List<String> locks = new ArrayList<>();
  36 + //车辆和停放泊位对照
  37 + BiMap<String, String> car2berth = HashBiMap.create();
  38 +
  39 + for(RegionBerth b : list){
  40 + if(b.getStatus()==-1)
  41 + locks.add(b.getName());
  42 +
  43 + if(StringUtils.isNotEmpty(b.getCar()))
  44 + car2berth.put(b.getCar(), b.getName());
  45 + }
  46 +
  47 + realInoutHandler.init(car2berth);
  48 + berthDataBuffer.putLocks(locks);
  49 + }
  50 +}
... ...
src/main/java/com/bsth/data/in_out/RealInoutHandler.java 0 → 100644
  1 +package com.bsth.data.in_out;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.data.basic.bus.BusDataBuffer;
  5 +import com.bsth.data.in_out.buffer.BerthDataBuffer;
  6 +import com.bsth.data.schedule.dto.ScheduleInOut;
  7 +import com.bsth.data.schedule.real.ScheduleDataBuffer;
  8 +import com.bsth.entity.Bus;
  9 +import com.bsth.entity.ac.CarInOutEntity;
  10 +import com.bsth.entity.berth.RegionBerth;
  11 +import com.bsth.websocket.handler.SendUtils;
  12 +import com.google.common.collect.BiMap;
  13 +import com.google.common.collect.HashBiMap;
  14 +import org.apache.commons.lang3.StringUtils;
  15 +import org.slf4j.Logger;
  16 +import org.slf4j.LoggerFactory;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.stereotype.Component;
  19 +
  20 +import java.util.HashMap;
  21 +import java.util.LinkedList;
  22 +import java.util.List;
  23 +import java.util.Map;
  24 +
  25 +/**
  26 + * 实时进出场数据处理程序
  27 + * Created by panzhao on 2017/11/4.
  28 + */
  29 +@Component
  30 +public class RealInoutHandler {
  31 +
  32 + static Logger logger = LoggerFactory.getLogger(RealInoutHandler.class);
  33 +
  34 + /**
  35 + * 车辆自编号和停放泊位号对照
  36 + */
  37 + private static BiMap<String, String> car2berthMap;
  38 +
  39 + //待入库数据
  40 + public static LinkedList<CarInOutEntity> psts;
  41 +
  42 + @Autowired
  43 + SendUtils sendUtils;
  44 +
  45 + static {
  46 + car2berthMap = HashBiMap.create();
  47 + psts = new LinkedList();
  48 + }
  49 +
  50 + public void init(BiMap<String, String> map){
  51 + car2berthMap = map;
  52 + }
  53 +
  54 + /**
  55 + * 进出场
  56 + * @param cio
  57 + */
  58 + public void inOut(CarInOutEntity cio) {
  59 + //公交车
  60 + if(0 == cio.getCarType()){
  61 + //获取对应的计划排班
  62 + ScheduleInOut sch = ScheduleDataBuffer.get(cio);
  63 +
  64 + //rfid进出场时附加排班信息
  65 + if(sch != null && cio.getSignalType()==0)
  66 + addPlanFiled(cio, sch);
  67 +
  68 + //入库 -只存实进和实出
  69 + if(cio.getType() == 2 || cio.getType() == 4)
  70 + psts.add(cio);
  71 +
  72 + if (cio.getType() == 2)
  73 + busIn(cio); //公交车进场
  74 + else if (cio.getType() == 4)
  75 + busOut(cio); //公交车出场
  76 + }
  77 + }
  78 +
  79 + private void busOut(CarInOutEntity cio) {
  80 + car2berthMap.remove(cio.getNbbm());
  81 +
  82 + //通知客户端
  83 + sendUtils.sendCarOut(cio.getNbbm(), cio.getT());
  84 + }
  85 +
  86 + private void busIn(CarInOutEntity cio) {
  87 + String nbbm = cio.getNbbm();
  88 + if (StringUtils.isEmpty(nbbm))
  89 + return;
  90 +
  91 + //车辆已经在泊位上,先移除(可能没有出场信号)
  92 + if(car2berthMap.containsKey(nbbm)){
  93 + car2berthMap.remove(nbbm);
  94 + }
  95 + Bus bus = BusDataBuffer.findOne(nbbm);
  96 + //非电车,停柴油泊位区
  97 + if(!bus.isSfdc()){
  98 + //LedHttpPushHandler.busIn(bus.getCarPlate(), "柴油泊位区");
  99 + return;
  100 + }
  101 +
  102 + //是否有固定泊位
  103 + String lockBName = BerthDataBuffer.getLockBerthName(nbbm);
  104 + if(StringUtils.isNotEmpty(lockBName))
  105 + car2berthMap.put(nbbm, lockBName);
  106 + else{
  107 + //停空闲泊位
  108 + List<RegionBerth> berthList = BerthDataBuffer.allNoLock();
  109 + RegionBerth free = null;
  110 + for(RegionBerth b : berthList){
  111 + //被占用的泊位
  112 + if(car2berthMap.inverse().containsKey(b.getName()))
  113 + continue;
  114 + //被禁用的泊位
  115 + if(BerthDataBuffer.isLock(b.getName()))
  116 + continue;
  117 + free = b;
  118 + break;
  119 + }
  120 + if(null != free){
  121 + car2berthMap.put(nbbm, free.getName());
  122 + }
  123 + else
  124 + logger.info("没有空余泊位了");
  125 + }
  126 +
  127 + //通知客户端
  128 + sendUtils.sendCarIn(nbbm, car2berthMap.get(nbbm), cio.getT());
  129 + }
  130 +
  131 + private void addPlanFiled(CarInOutEntity cio, ScheduleInOut sch) {
  132 + if(null == sch.getOutTimeRfid())
  133 + sch.setOutTimeRfid(cio.getT());
  134 + //计划时间
  135 + cio.setPt(sch.getDfsjT());
  136 + cio.setLineCode(sch.getLineCode());
  137 + cio.setLineName(sch.getLineName());
  138 + cio.setCompany(sch.getGsbm());
  139 + cio.setFgsCompany(sch.getFgsbm());
  140 + cio.setTaskStatus(1);
  141 + cio.setpJsy(sch.getjGh());
  142 +
  143 + /**
  144 + * 人车是否相符
  145 + */
  146 + if(StringUtils.isNotEmpty(cio.getJsy())){
  147 + String sjGh = cio.getJsy().split("/")[0];
  148 +
  149 + if(sch.getjGh().equals(sjGh)){
  150 + cio.setPcMatch(true);
  151 + }
  152 + }
  153 + }
  154 +
  155 + public static Map<String, String> getCar2berthMap(){
  156 + return car2berthMap;
  157 + }
  158 +
  159 + /**
  160 + * 添加车辆和泊位对照
  161 + * @param nbbm
  162 + * @param berthName
  163 + * @return
  164 + */
  165 + public Map<String, Object> addCar2Berth(String nbbm, String berthName) {
  166 + Map<String, Object> rs = new HashMap<>();
  167 +
  168 + try{
  169 + if(car2berthMap.containsKey(nbbm))
  170 + car2berthMap.remove(nbbm);
  171 +
  172 + if(car2berthMap.inverse().containsKey(berthName))
  173 + car2berthMap.inverse().remove(berthName);
  174 +
  175 + car2berthMap.put(nbbm, berthName);
  176 + rs.put("status", ResponseCode.SUCCESS);
  177 + }catch (Exception e){
  178 + logger.error("", e);
  179 + rs.put("status", ResponseCode.ERROR);
  180 + }
  181 + return rs;
  182 + }
  183 +
  184 + /**
  185 + * 删除指定泊位上的车辆
  186 + * @param berthName
  187 + * @return
  188 + */
  189 + public Map<String, Object> removeCar2Berth(String berthName) {
  190 + Map<String, Object> rs = new HashMap<>();
  191 +
  192 + try{
  193 +
  194 + if(car2berthMap.inverse().containsKey(berthName))
  195 + car2berthMap.inverse().remove(berthName);
  196 +
  197 + rs.put("status", ResponseCode.SUCCESS);
  198 + }catch (Exception e){
  199 + logger.error("", e);
  200 + rs.put("status", ResponseCode.ERROR);
  201 + }
  202 + return rs;
  203 + }
  204 +
  205 + /**
  206 + * 对换指定2个泊位上的车辆
  207 + * @param s
  208 + * @param d
  209 + * @return
  210 + */
  211 + public static Map<String, Object> changeCar2Berth(String s, String d) {
  212 + Map<String, Object> rs = new HashMap<>();
  213 +
  214 + try{
  215 +
  216 + Map<String, String> inverseMap = car2berthMap.inverse();
  217 +
  218 + String sv = inverseMap.get(s);
  219 + String dv = inverseMap.get(d);
  220 +
  221 + if(sv != null){
  222 + inverseMap.remove(s);
  223 + inverseMap.put(d, sv);
  224 + }
  225 + else
  226 + inverseMap.remove(d);
  227 +
  228 + if(dv != null)
  229 + inverseMap.put(s, dv);
  230 +
  231 + rs.put("status", ResponseCode.SUCCESS);
  232 + }catch (Exception e){
  233 + logger.error("", e);
  234 + rs.put("status", ResponseCode.ERROR);
  235 + }
  236 + return rs;
  237 + }
  238 +
  239 + public boolean containsBerth(String berthName) {
  240 + return car2berthMap.inverse().containsKey(berthName);
  241 + }
  242 +}
... ...
src/main/java/com/bsth/data/in_out/buffer/BerthDataBuffer.java 0 → 100644
  1 +package com.bsth.data.in_out.buffer;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.data.in_out.RealInoutHandler;
  5 +import com.bsth.entity.berth.RegionBerth;
  6 +import com.bsth.repository.berth.BerthRepository;
  7 +import com.google.common.collect.BiMap;
  8 +import com.google.common.collect.HashBiMap;
  9 +import org.apache.commons.lang3.StringUtils;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.jdbc.core.JdbcTemplate;
  14 +import org.springframework.stereotype.Component;
  15 +
  16 +import java.util.*;
  17 +
  18 +/**
  19 + * 泊位数据
  20 + * Created by panzhao on 2017/11/4.
  21 + */
  22 +@Component
  23 +public class BerthDataBuffer {
  24 +
  25 + @Autowired
  26 + JdbcTemplate jdbcTemplate;
  27 +
  28 + static Logger logger = LoggerFactory.getLogger(BerthDataBuffer.class);
  29 +
  30 + //按顺序排列的泊位集合
  31 + private static List<RegionBerth> berthList;
  32 +
  33 + private static Map<String, RegionBerth> nameMap;
  34 +
  35 + //被禁用的泊位
  36 + private static List<String> lockList;
  37 +
  38 + /**
  39 + * 固定泊位
  40 + * 32 ~ 43 号泊位 固定停放 31~42号车。 W0E-031
  41 + */
  42 + private static BiMap<String, String> lockBerthMap;
  43 +
  44 + @Autowired
  45 + RealInoutHandler realInoutHandler;
  46 +
  47 + @Autowired
  48 + private BerthComp comp;
  49 +
  50 + static {
  51 + lockBerthMap = HashBiMap.create();
  52 + lockBerthMap.put("W0E-031", "32");
  53 + lockBerthMap.put("W0E-032", "33");
  54 + lockBerthMap.put("W0E-033", "34");
  55 + lockBerthMap.put("W0E-034", "35");
  56 + lockBerthMap.put("W0E-035", "36");
  57 + lockBerthMap.put("W0E-036", "37");
  58 + lockBerthMap.put("W0E-037", "38");
  59 + lockBerthMap.put("W0E-038", "39");
  60 + lockBerthMap.put("W0E-039", "40");
  61 + lockBerthMap.put("W0E-040", "41");
  62 + lockBerthMap.put("W0E-041", "42");
  63 + lockBerthMap.put("W0E-042", "43");
  64 + lockList = new ArrayList<>();
  65 + }
  66 +
  67 + public void putLocks(List<String> list){
  68 + lockList = list;
  69 + }
  70 +
  71 + public static boolean isLock(String name){
  72 + return lockList.contains(name);
  73 + }
  74 + /**
  75 + * 所有非固定泊位
  76 + * @return
  77 + */
  78 + public static List<RegionBerth> allNoLock(){
  79 + List<RegionBerth> rs = new ArrayList<>();
  80 + for(RegionBerth b : berthList){
  81 + if(lockBerthMap.inverse().containsKey(b.getName()))
  82 + continue;
  83 + rs.add(b);
  84 + }
  85 + return rs;
  86 + }
  87 +
  88 + public static List<RegionBerth> all(){
  89 + return berthList;
  90 + }
  91 +
  92 + public static String getLockBerthName(String nbbm){
  93 + return lockBerthMap.get(nbbm);
  94 + }
  95 +
  96 + public static RegionBerth findOne(String name){
  97 + return nameMap.get(name);
  98 + }
  99 +
  100 + @Autowired
  101 + BerthRepository berthRepository;
  102 +
  103 + public void init(){
  104 +
  105 + //加载数据库的泊位数据
  106 + berthList = (List<RegionBerth>) berthRepository.findAll();
  107 +
  108 + //排序
  109 + Collections.sort(berthList, comp);
  110 + //泊位名称对照
  111 + Map<String, RegionBerth> nameMapCopy = new HashMap<>();
  112 + //被禁用的泊位
  113 + List<String> locks = new ArrayList<>();
  114 + //车辆和停放泊位对照
  115 + BiMap<String, String> car2berth = HashBiMap.create();
  116 +
  117 + for(RegionBerth berth : berthList){
  118 + nameMapCopy.put(berth.getName(), berth);
  119 +
  120 + if(berth.getStatus()==-1)
  121 + locks.add(berth.getName());
  122 +
  123 + if(StringUtils.isNotEmpty(berth.getCar()))
  124 + car2berth.put(berth.getCar(), berth.getName());
  125 + }
  126 + nameMap = nameMapCopy;
  127 + realInoutHandler.init(car2berth);
  128 + putLocks(locks);
  129 + }
  130 +
  131 + public Map<String, Object> lockBerth(String berthName) {
  132 + Map<String, Object> rs = new HashMap<>();
  133 + try{
  134 + if(realInoutHandler.containsBerth(berthName)){
  135 + rs.put("status", ResponseCode.ERROR);
  136 + rs.put("msg", "请先清除泊位上的车辆,再尝试禁用泊位");
  137 + }
  138 + else{
  139 + //修改数据库
  140 + jdbcTemplate.update("update bsth_p_berth set status=-1 where name=?", berthName);
  141 + findOne(berthName).setStatus(-1);
  142 + lockList.add(berthName);
  143 +
  144 + rs.put("status", ResponseCode.SUCCESS);
  145 + }
  146 + }catch (Exception e){
  147 + logger.error("", e);
  148 + }
  149 + return rs;
  150 + }
  151 +
  152 + public Map<String, Object> unlockBerth(String berthName) {
  153 + Map<String, Object> rs = new HashMap<>();
  154 + try{
  155 + //修改数据库
  156 + jdbcTemplate.update("update bsth_p_berth set status=0 where name=?", berthName);
  157 + findOne(berthName).setStatus(0);
  158 + lockList.remove(berthName);
  159 + rs.put("status", ResponseCode.SUCCESS);
  160 + }catch (Exception e){
  161 + logger.error("", e);
  162 + rs.put("status", ResponseCode.ERROR);
  163 + }
  164 + return rs;
  165 + }
  166 +
  167 +
  168 + @Component
  169 + public static class BerthComp implements Comparator<RegionBerth>{
  170 +
  171 + @Override
  172 + public int compare(RegionBerth b1, RegionBerth b2) {
  173 + return b1.getOrderNo().compareTo(b2.getOrderNo());
  174 + }
  175 + }
  176 +}
... ...
src/main/java/com/bsth/data/in_out/buffer/ElectricDataBuffer.java 0 → 100644
  1 +package com.bsth.data.in_out.buffer;
  2 +
  3 +import com.bsth.data.in_out.entity.Electric;
  4 +
  5 +import java.util.HashMap;
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +import java.util.Set;
  9 +
  10 +/**
  11 + * 电量数据
  12 + * Created by panzhao on 2017/11/4.
  13 + */
  14 +public class ElectricDataBuffer {
  15 +
  16 + /**
  17 + * 车辆自编号和电量信息对照
  18 + */
  19 + private static Map<String, Electric> nbbm2ElecMap;
  20 +
  21 + static {
  22 + nbbm2ElecMap = new HashMap<>();
  23 + }
  24 +
  25 + public static void put(List<Electric> list) {
  26 + for(Electric be : list){
  27 + nbbm2ElecMap.put(be.getNbbm(), be);
  28 + }
  29 + }
  30 +
  31 + public static Electric findOne(String nbbm){
  32 + return nbbm2ElecMap.get(nbbm);
  33 + }
  34 +
  35 + public static Map<String, Double> elecs(){
  36 + Map<String, Double> rs = new HashMap<>();
  37 +
  38 + Set<String> ks = nbbm2ElecMap.keySet();
  39 + for(String k : ks){
  40 + rs.put(k, Double.parseDouble(nbbm2ElecMap.get(k).getSoc()));
  41 + }
  42 + return rs;
  43 + }
  44 +}
... ...
src/main/java/com/bsth/entity/electric/BusElectric.java renamed to src/main/java/com/bsth/data/in_out/entity/Electric.java
1   -package com.bsth.entity.electric;
  1 +package com.bsth.data.in_out.entity;
2 2  
3 3 /**
4 4 * 公交车电量信息
5 5 * Created by panzhao on 2017/9/13.
6 6 */
7   -public class BusElectric {
  7 +public class Electric {
8 8  
9 9 /**
10 10 * 车辆自编号
... ...
src/main/java/com/bsth/data/signal/dto/RfidInOutDto.java renamed to src/main/java/com/bsth/data/in_out/entity/RfidInOutDto.java
1   -package com.bsth.data.signal.dto;
  1 +package com.bsth.data.in_out.entity;
2 2  
3 3 /**
4 4 * rfid 进出场
... ...
src/main/java/com/bsth/data/real_park/thread/RealParkDataPersistenceThread.java renamed to src/main/java/com/bsth/data/in_out/thread/Car2BerthDataPstThread.java
1   -package com.bsth.data.real_park.thread;
  1 +package com.bsth.data.in_out.thread;
2 2  
3   -import com.bsth.data.real_park.CarParkRealHandler;
4   -import com.bsth.entity.real.RealCarPark;
  3 +import com.bsth.data.in_out.RealInoutHandler;
5 4 import org.slf4j.Logger;
6 5 import org.slf4j.LoggerFactory;
7 6 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -15,25 +14,27 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
15 14  
16 15 import java.sql.PreparedStatement;
17 16 import java.sql.SQLException;
18   -import java.util.Date;
  17 +import java.util.ArrayList;
19 18 import java.util.List;
  19 +import java.util.Map;
20 20  
21 21 /**
22   - * 实时停放信息入库线程
23   - * Created by panzhao on 2017/9/14.
  22 + * 车辆停放泊位信息入库线程
  23 + * Created by panzhao on 2017/11/5.
24 24 */
25 25 @Component
26   -public class RealParkDataPersistenceThread extends Thread {
  26 +public class Car2BerthDataPstThread extends Thread {
  27 +
  28 + Logger logger = LoggerFactory.getLogger(this.getClass());
27 29  
28 30 @Autowired
29 31 JdbcTemplate jdbcTemplate;
30 32  
31   - Logger logger = LoggerFactory.getLogger(this.getClass());
32   -
33 33 @Override
34 34 public void run() {
35 35 try {
36   - final List<RealCarPark> list = CarParkRealHandler.allData();
  36 + final Map<String, String> map = RealInoutHandler.getCar2berthMap();
  37 + final List<String> ks = new ArrayList<>(map.keySet());
37 38  
38 39 //编程式事务
39 40 DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
... ... @@ -41,34 +42,27 @@ public class RealParkDataPersistenceThread extends Thread {
41 42 def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
42 43 TransactionStatus status = tran.getTransaction(def);
43 44  
44   - try {
45   - final java.sql.Date d = new java.sql.Date(new Date().getTime());
46   - //删除
47   - jdbcTemplate.update("delete from bsth_real_carpark");
  45 + try{
48 46 //重新写入
49   - jdbcTemplate.batchUpdate("insert into bsth_real_carpark(type, nbbm, plate_no, in_time, berth_name, soc, create_time)" +
50   - " VALUES (?, ?, ?, ?, ?, ?, SYSDATE())", new BatchPreparedStatementSetter() {
  47 + jdbcTemplate.batchUpdate("update bsth_p_berth set car=? where name=?", new BatchPreparedStatementSetter() {
51 48 @Override
52 49 public void setValues(PreparedStatement ps, int i) throws SQLException {
53   - RealCarPark rcp = list.get(i);
54   - ps.setInt(1, rcp.getType());
55   - ps.setString(2, rcp.getNbbm());
56   - ps.setString(3, rcp.getPlateNo());
57   - ps.setLong(4, rcp.getInTime());
58   - ps.setString(5, rcp.getBerthName());
59   - ps.setString(6, rcp.getSoc());
  50 + String car = ks.get(i);
  51 + String name = map.get(car);
  52 +
  53 + ps.setString(1, car);
  54 + ps.setString(2, name);
60 55 }
61 56  
62 57 @Override
63 58 public int getBatchSize() {
64   - return list.size();
  59 + return ks.size();
65 60 }
66 61 });
67 62  
68 63 tran.commit(status);
69   - } catch (Exception e) {
  64 + }catch (Exception e){
70 65 tran.rollback(status);
71   - logger.error("", e);
72 66 }
73 67 } catch (Exception e) {
74 68 logger.error("", e);
... ...
src/main/java/com/bsth/data/signal/thread/SignalPstThread.java renamed to src/main/java/com/bsth/data/in_out/thread/SignalPstThread.java
1   -package com.bsth.data.signal.thread;
  1 +package com.bsth.data.in_out.thread;
2 2  
  3 +import com.bsth.data.in_out.RealInoutHandler;
3 4 import com.bsth.entity.ac.CarInOutEntity;
4 5 import com.bsth.repository.ac.CarInOutRepository;
5 6 import org.springframework.beans.factory.annotation.Autowired;
6 7 import org.springframework.stereotype.Component;
7 8  
8 9 import java.util.ArrayList;
9   -import java.util.LinkedList;
10 10 import java.util.List;
11 11  
12 12 /**
... ... @@ -19,19 +19,13 @@ public class SignalPstThread extends Thread{
19 19 @Autowired
20 20 CarInOutRepository carInOutRepository;
21 21  
22   - public static LinkedList<CarInOutEntity> psts;
23   -
24   - static {
25   - psts = new LinkedList<>();
26   - }
27   -
28 22 @Override
29 23 public void run() {
30 24  
31 25 List<CarInOutEntity> list = new ArrayList<>();
32 26 CarInOutEntity cio;
33 27 for(int i = 0; i < 1000; i ++){
34   - cio = psts.poll();
  28 + cio = RealInoutHandler.psts.poll();
35 29 if(null == cio)
36 30 break;
37 31  
... ...
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.real_park.CarParkRealHandler;
4   -import com.bsth.data.utils.HttpClientUtils_tms;
5   -import com.bsth.entity.ac.CarInOutEntity;
6   -import com.bsth.entity.berth.RegionBerth;
7   -import com.bsth.service.berth.BerthService;
8   -import com.bsth.util.ConfigUtil;
9   -import org.slf4j.Logger;
10   -import org.slf4j.LoggerFactory;
11   -import org.springframework.beans.factory.annotation.Autowired;
12 3 import org.springframework.stereotype.Component;
13 4  
14   -import java.util.LinkedList;
15   -import java.util.List;
16   -
17 5 /**
18 6 * Created by panzhao on 2017/9/26.
19 7 */
20 8 @Component
21   -public class LedHttpPushHandler {
  9 +public class LedHttpPushHandler {/*
22 10  
23 11 @Autowired
24 12 BerthService berthService;
... ... @@ -72,10 +60,10 @@ public class LedHttpPushHandler {
72 60 dataUrlLinked.add(url);
73 61 }
74 62  
75   - /**
  63 + *//**
76 64 * 场内停放信息
77 65 * @return
78   - */
  66 + *//*
79 67 public void sendTfxx(){
80 68 int can=0;//可停车数
81 69 int yet=0;//已停车数
... ... @@ -142,5 +130,5 @@ public class LedHttpPushHandler {
142 130  
143 131 log.warn("Led ConsumeQueue is break...");
144 132 }
145   - }
  133 + }*/
146 134 }
... ...
src/main/java/com/bsth/data/msg_queue/QueueData.java 0 → 100644
  1 +package com.bsth.data.msg_queue;
  2 +
  3 +import org.springframework.web.socket.TextMessage;
  4 +import org.springframework.web.socket.WebSocketSession;
  5 +
  6 +/**
  7 + * Created by panzhao on 2017/5/11.
  8 + */
  9 +public class QueueData {
  10 +
  11 + private TextMessage message;
  12 +
  13 + private WebSocketSession session;
  14 +
  15 +
  16 + public WebSocketSession getSession() {
  17 + return session;
  18 + }
  19 +
  20 + public void setSession(WebSocketSession session) {
  21 + this.session = session;
  22 + }
  23 +
  24 + public TextMessage getMessage() {
  25 + return message;
  26 + }
  27 +
  28 + public void setMessage(TextMessage message) {
  29 + this.message = message;
  30 + }
  31 +}
... ...
src/main/java/com/bsth/data/msg_queue/SignalAndAttConsumeQueue.java
1 1 package com.bsth.data.msg_queue;
2 2  
3 3 import com.bsth.data.attendance.entity.JsyAttendance;
  4 +import com.bsth.data.in_out.RealInoutHandler;
4 5 import com.bsth.entity.ac.CarInOutEntity;
5   -import com.bsth.service.schedule.InOutScheduleService;
  6 +import com.bsth.service.schedule.ScheduleService;
6 7 import org.slf4j.Logger;
7 8 import org.slf4j.LoggerFactory;
8 9 import org.springframework.beans.BeansException;
... ... @@ -23,7 +24,8 @@ public class SignalAndAttConsumeQueue implements ApplicationContextAware {
23 24  
24 25 private static List<Class> clazzs;
25 26 private static LinkedList<Object> linkedList;
26   - static InOutScheduleService outScheduleService;
  27 + static ScheduleService outScheduleService;
  28 + static RealInoutHandler realInoutHandler;
27 29 static ConsumeThread thread;
28 30 static long t;
29 31 static final int IDLE_TIME = 1000 * 30;
... ... @@ -57,10 +59,10 @@ public class SignalAndAttConsumeQueue implements ApplicationContextAware {
57 59  
58 60 @Override
59 61 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
60   - outScheduleService = applicationContext.getBean(InOutScheduleService.class);
  62 + outScheduleService = applicationContext.getBean(ScheduleService.class);
  63 + realInoutHandler = applicationContext.getBean(RealInoutHandler.class);
61 64 }
62 65  
63   - @Component
64 66 public static class ConsumeThread extends Thread {
65 67  
66 68 Logger log = LoggerFactory.getLogger(this.getClass());
... ... @@ -80,7 +82,7 @@ public class SignalAndAttConsumeQueue implements ApplicationContextAware {
80 82 outScheduleService.jsyReport((JsyAttendance) obj);
81 83 //车辆进出场
82 84 else if(obj instanceof CarInOutEntity)
83   - outScheduleService.inOut((CarInOutEntity)obj);
  85 + realInoutHandler.inOut((CarInOutEntity)obj);
84 86 } else {
85 87 Thread.sleep(500);
86 88 if (!sleepFlag) {
... ...
src/main/java/com/bsth/data/msg_queue/WebSocketPushQueue.java 0 → 100644
  1 +package com.bsth.data.msg_queue;
  2 +
  3 +import com.bsth.common.Constants;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +import org.springframework.stereotype.Component;
  7 +import org.springframework.web.socket.TextMessage;
  8 +import org.springframework.web.socket.WebSocketSession;
  9 +
  10 +import java.util.concurrent.ConcurrentLinkedQueue;
  11 +
  12 +/**
  13 + * 线调web socket 推送队列
  14 + * Created by panzhao on 2017/5/11.
  15 + */
  16 +@Component
  17 +public class WebSocketPushQueue {
  18 +
  19 + static ConcurrentLinkedQueue<QueueData> linkedList;
  20 + static DataPushThread thread;
  21 + static Logger log = LoggerFactory.getLogger(WebSocketPushQueue.class);
  22 + static long t;
  23 + static final int IDLE_TIME = 1000 * 30;
  24 +
  25 + static {
  26 + linkedList = new ConcurrentLinkedQueue();
  27 + }
  28 +
  29 + public static boolean isIdle() {
  30 + return System.currentTimeMillis() - t > IDLE_TIME;
  31 + }
  32 +
  33 + public static void put(WebSocketSession session, TextMessage msg) {
  34 + QueueData qd = new QueueData();
  35 + qd.setMessage(msg);
  36 + qd.setSession(session);
  37 +
  38 +
  39 + log.info("put、[" + session.getAttributes().get(Constants.SESSION_USERNAME) + "] 、" + msg.getPayload());
  40 + linkedList.add(qd);
  41 + }
  42 +
  43 + public static void start() {
  44 + if (thread != null) {
  45 + thread.interrupt();
  46 + }
  47 + linkedList.clear();
  48 + thread = new DataPushThread();
  49 + thread.start();
  50 + }
  51 +
  52 + public static int size(){
  53 + return linkedList.size();
  54 + }
  55 +
  56 +
  57 + public static class DataPushThread extends Thread {
  58 +
  59 + Logger log = LoggerFactory.getLogger(this.getClass());
  60 +
  61 + @Override
  62 + public void run() {
  63 + QueueData qd;
  64 + WebSocketSession session;
  65 +
  66 + boolean sleepFlag = false;
  67 + while (true) {
  68 + try {
  69 + qd = linkedList.poll();
  70 + if (qd != null) {
  71 + sleepFlag = false;
  72 + session = qd.getSession();
  73 + if (session.isOpen()) {
  74 + log.info("push start、"+session.getRemoteAddress().getHostString()+"[" + session.getAttributes().get(Constants.SESSION_USERNAME) + "] 、" + qd.getMessage().getPayload());
  75 + session.sendMessage(qd.getMessage());
  76 + log.info("push end..");
  77 + }
  78 + } else {
  79 + Thread.sleep(500);
  80 + if (!sleepFlag) {
  81 + log.info("sleep...");
  82 + sleepFlag = true;
  83 + }
  84 + }
  85 + t = System.currentTimeMillis();
  86 + } catch (InterruptedException e) {
  87 + log.error("", e);
  88 + break;
  89 + } catch (Exception e) {
  90 + log.error("", e);
  91 + }
  92 + }
  93 +
  94 + log.warn("WebSocketPushQueue is break...");
  95 + }
  96 + }
  97 +}
... ...
src/main/java/com/bsth/data/real_park/CarParkRealHandler.java deleted 100644 → 0
1   -package com.bsth.data.real_park;
2   -
3   -import com.bsth.common.ResponseCode;
4   -import com.bsth.data.basic.bus.BusDataBuffer;
5   -import com.bsth.data.electric.CarElectricBuffer;
6   -import com.bsth.data.led_http.LedHttpPushHandler;
7   -import com.bsth.entity.Bus;
8   -import com.bsth.entity.ac.CarInOutEntity;
9   -import com.bsth.entity.berth.RegionBerth;
10   -import com.bsth.entity.electric.BusElectric;
11   -import com.bsth.entity.real.RealCarPark;
12   -import com.bsth.service.berth.BerthService;
13   -import org.apache.commons.lang3.StringUtils;
14   -import org.slf4j.Logger;
15   -import org.slf4j.LoggerFactory;
16   -import org.springframework.beans.factory.annotation.Autowired;
17   -import org.springframework.jdbc.core.BeanPropertyRowMapper;
18   -import org.springframework.jdbc.core.JdbcTemplate;
19   -import org.springframework.stereotype.Component;
20   -
21   -import java.util.*;
22   -import java.util.concurrent.ConcurrentHashMap;
23   -import java.util.concurrent.ConcurrentMap;
24   -
25   -/**
26   - * 实时场内车辆停放数据
27   - * Created by panzhao on 2017/9/14.
28   - */
29   -@Component
30   -public class CarParkRealHandler {
31   -
32   - @Autowired
33   - BerthService berthService;
34   -
35   - /**
36   - * 公交车
37   - * K: 自编号
38   - */
39   - private static ConcurrentMap<String, RealCarPark> busRcps;
40   -
41   - /**
42   - * 非公交车
43   - * K: 车牌号
44   - */
45   - private static ConcurrentMap<String, RealCarPark> carRcps;
46   -
47   - static Logger logger = LoggerFactory.getLogger(CarParkRealHandler.class);
48   -
49   - static {
50   - busRcps = new ConcurrentHashMap<>();
51   - carRcps = new ConcurrentHashMap<>();
52   - }
53   -
54   - /**
55   - * 公交车电量信息
56   - *
57   - * @param be
58   - */
59   - public void putElec(BusElectric be) {
60   - RealCarPark rcp = busRcps.get(be.getNbbm());
61   - if (null != rcp) {
62   - rcp.setSoc(be.getSoc());
63   - }
64   - }
65   -
66   - /**
67   - * 最大电量的泊位名称
68   - * @return
69   -
70   - public String getMaxElecBerth(){
71   - String name = null;
72   - double maxSoc=0.0;
73   - Collection<RealCarPark> vs = allBus();
74   -
75   - for(RealCarPark rcp : vs){
76   - if(Double.parseDouble(rcp.getSoc()) > maxSoc)
77   - name = rcp.getBerthName();
78   - }
79   - return name;
80   - }*/
81   -
82   - public static Collection<RealCarPark> allBus() {
83   - return busRcps.values();
84   - }
85   -
86   - public static List<RealCarPark> allData(){
87   - List<RealCarPark> all = new ArrayList<>();
88   - all.addAll(busRcps.values());
89   - all.addAll(carRcps.values());
90   - return all;
91   - }
92   -
93   - public void carInOut(CarInOutEntity cio) {
94   - if (cio.getType() == 2)
95   - carIn(cio);
96   - else if (cio.getType() == 4)
97   - carOut(cio);
98   - }
99   -
100   - /**
101   - * 车辆进场
102   - *
103   - * @param cio
104   - */
105   - private void carIn(CarInOutEntity cio) {
106   - if (cio.getCarType() == 0)
107   - busIn(cio);
108   - else {
109   -
110   - }
111   - }
112   -
113   - /**
114   - * 公交车进场
115   - *
116   - * @param cio
117   - */
118   - private void busIn(CarInOutEntity cio) {
119   - String nbbm = cio.getNbbm();
120   - if (StringUtils.isEmpty(nbbm))
121   - return;
122   -
123   - Bus bus = BusDataBuffer.findOne(nbbm);
124   - if(!bus.isSfdc()){
125   - LedHttpPushHandler.busIn(bus.getCarPlate(), "柴油泊位区");//柴油车
126   - return;
127   - }
128   -
129   - RealCarPark rcp = new RealCarPark();
130   -
131   - RegionBerth b;
132   - //固定泊位
133   - String lockBerthName = berthService.getLockBerthName(nbbm);
134   - if(StringUtils.isNotEmpty(lockBerthName)){
135   - b = berthService.get(lockBerthName);
136   - }
137   - else{
138   - //泊位信息
139   - b = berthService.next();
140   - }
141   -
142   - if(null == b){
143   - logger.info(nbbm + " 无空余泊位");
144   - return;
145   - }
146   -
147   - rcp.setPlateNo(bus.getCarPlate());
148   - rcp.setBerthName(b.getName());
149   - rcp.setNbbm(nbbm);
150   - rcp.setInTime(System.currentTimeMillis());
151   - rcp.setType(0);
152   -
153   - //车辆已经在场内
154   - if(!busRcps.containsKey(nbbm) || StringUtils.isNotEmpty(busRcps.get(nbbm).getBerthName())){
155   - //电量信息
156   - BusElectric be = CarElectricBuffer.carElecMap.get(nbbm);
157   - if(null != be)
158   - rcp.setSoc(be.getSoc());
159   - busRcps.put(nbbm, rcp);
160   - //泊位设置车辆
161   - berthService.set(b, nbbm);
162   - }
163   -
164   - //push led
165   - LedHttpPushHandler.busIn(rcp.getPlateNo(), rcp.getBerthName());
166   - }
167   -
168   - /**
169   - * 公交车出场
170   - *
171   - * @param cio
172   - */
173   - private void carOut(CarInOutEntity cio) {
174   - String nbbm = cio.getNbbm();
175   - if (StringUtils.isEmpty(nbbm))
176   - return;
177   -
178   - if(busRcps.containsKey(nbbm)){
179   - String bName = busRcps.get(nbbm).getBerthName();
180   - if(null != bName)
181   - clear_berth(bName);
182   - }
183   - LedHttpPushHandler.busOut(cio);
184   - }
185   -
186   - /**
187   - * 泊位交换
188   - *
189   - * @param sName 泊位名称 源
190   - * @param dName 泊位名称 目标
191   - * @return
192   - */
193   - public Map<String, Object> realChange(String sName, String dName) {
194   - Map<String, Object> rs = new HashMap();
195   - try {
196   - RealCarPark rcp1 = getByBerthName(sName);
197   - RealCarPark rcp2 = getByBerthName(dName);
198   -
199   - //校验泊位是否存在
200   - if(!berthService.berthNameIsExist(sName)){
201   - rs.put("status", ResponseCode.ERROR);
202   - rs.put("msg", "失败,不存在泊位 " + sName);
203   - return rs;
204   - }
205   - if(!berthService.berthNameIsExist(dName)){
206   - rs.put("status", ResponseCode.ERROR);
207   - rs.put("msg", "失败,不存在泊位 " + dName);
208   - return rs;
209   - }
210   -
211   - if(null != rcp1){
212   - rcp1.setBerthName(dName);
213   - berthService.set(berthService.get(dName), rcp1.getNbbm());
214   - }
215   - else
216   - clear_berth2(dName);
217   -
218   - if(null != rcp2){
219   - rcp2.setBerthName(sName);
220   - berthService.set(berthService.get(sName), rcp2.getNbbm());
221   - }
222   - else{
223   - clear_berth2(sName);
224   - }
225   -
226   - //重新计算可用枪
227   - berthService.reCalc();
228   - rs.put("status", ResponseCode.SUCCESS);
229   - rs.put("list", allBus());
230   - } catch (Exception e) {
231   - logger.error("", e);
232   - rs.put("status", ResponseCode.ERROR);
233   - }
234   - return rs;
235   - }
236   -
237   - /**
238   - * 移除泊位上的车辆
239   - * @param b
240   - * @return
241   - */
242   - public Map<String, Object> clear_berth(String b) {
243   - Map<String, Object> rs = new HashMap();
244   - try {
245   - RealCarPark rcp1 = getByBerthName(b);
246   -
247   - RegionBerth berth = berthService.get(b);
248   - if(null != berth)
249   - berth.setNbbm(null);
250   - if(null != rcp1)
251   - busRcps.remove(rcp1.getNbbm());
252   -
253   - //重新计算可用枪
254   - berthService.reCalc();
255   - rs.put("status", ResponseCode.SUCCESS);
256   - rs.put("list", allBus());
257   - } catch (Exception e) {
258   - logger.error("", e);
259   - rs.put("status", ResponseCode.ERROR);
260   - }
261   - return rs;
262   - }
263   -
264   - public void clear_berth2(String b) {
265   - RegionBerth berth = berthService.get(b);
266   - if(null != berth)
267   - berth.setNbbm(null);
268   - }
269   -
270   - private static RealCarPark getByBerthName(String sName) {
271   - for (RealCarPark rcp : busRcps.values()) {
272   - if (sName.equals(rcp.getBerthName()))
273   - return rcp;
274   - }
275   - return null;
276   - }
277   -
278   - public Double soc(String nbbm){
279   - RealCarPark rcp = busRcps.get(nbbm);
280   - if(null==rcp || null==rcp.getSoc())
281   - return 0.0;
282   - return Double.parseDouble(rcp.getSoc());
283   - }
284   -
285   - @Autowired
286   - JdbcTemplate jdbcTemplate;
287   -
288   - /**
289   - * 从数据库恢复
290   - */
291   - public void recovery() {
292   - String sql = "select type, nbbm, plate_no,in_time,berth_name,soc from bsth_real_carpark";
293   - List<RealCarPark> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(RealCarPark.class));
294   -
295   - for(RealCarPark rcp : list){
296   - if(rcp.getType() == 0)
297   - busRcps.put(rcp.getNbbm(), rcp);
298   - else
299   - carRcps.put(rcp.getPlateNo(), rcp);
300   - }
301   -
302   - //泊位数据
303   - RegionBerth b;
304   - for(RealCarPark rcp : busRcps.values()){
305   - if(StringUtils.isEmpty(rcp.getBerthName()))
306   - continue;
307   -
308   - b = berthService.get(rcp.getBerthName());
309   - berthService.set(b, rcp.getNbbm());
310   - }
311   - }
312   -
313   - /**
314   - * 车辆添加至泊位
315   - * @param berthName
316   - * @param nbbm
317   - * @return
318   - */
319   - public Map<String,Object> addCar2Berth(String berthName, String nbbm) {
320   - Map<String,Object> rs = new HashMap<>();
321   -
322   - try{
323   - if(busRcps.containsKey(nbbm)){
324   - RealCarPark rcp = busRcps.get(nbbm);
325   - //交换泊位
326   - if(StringUtils.isNotEmpty(rcp.getBerthName()))
327   - realChange(berthName, rcp.getBerthName());
328   - }
329   - else{
330   - //让车辆进场,并停放泊位
331   - RealCarPark rcp = new RealCarPark();
332   - rcp.setBerthName(berthName);
333   - rcp.setNbbm(nbbm);
334   - rcp.setType(0);
335   - //车牌号
336   - Bus bus = BusDataBuffer.findOne(nbbm);
337   - if(null != bus)
338   - rcp.setPlateNo(bus.getCarPlate());
339   - //电量信息
340   - BusElectric be = CarElectricBuffer.carElecMap.get(nbbm);
341   - if(null != be)
342   - rcp.setSoc(be.getSoc());
343   - busRcps.put(nbbm, rcp);
344   - }
345   -
346   - //重新计算可用枪
347   - berthService.reCalc();
348   - rs.put("status", ResponseCode.SUCCESS);
349   - }catch (Exception e){
350   - logger.error("", e);
351   - rs.put("status", ResponseCode.ERROR);
352   - }
353   - return rs;
354   - }
355   -}
src/main/java/com/bsth/data/schedule/real/InOutScheduleDataBuffer.java renamed to src/main/java/com/bsth/data/schedule/real/ScheduleDataBuffer.java
... ... @@ -7,6 +7,7 @@ import com.bsth.data.schedule.dto.ScheduleInOut;
7 7 import com.bsth.data.utils.HttpClientUtils;
8 8 import com.bsth.data.utils.RsRequestUtils;
9 9 import com.bsth.entity.Line;
  10 +import com.bsth.entity.ac.CarInOutEntity;
10 11 import com.bsth.util.ConfigUtil;
11 12 import com.google.common.collect.ArrayListMultimap;
12 13 import org.slf4j.Logger;
... ... @@ -27,7 +28,7 @@ import java.util.concurrent.TimeUnit;
27 28 * Created by panzhao on 2017/8/24.
28 29 */
29 30 @Component
30   -public class InOutScheduleDataBuffer implements CommandLineRunner {
  31 +public class ScheduleDataBuffer implements CommandLineRunner {
31 32  
32 33 private static String tccCode;
33 34 private static String dataUrl;
... ... @@ -43,7 +44,7 @@ public class InOutScheduleDataBuffer implements CommandLineRunner {
43 44  
44 45 static final int SPACE_THRESHOLD = 1000 * 60 * 60 * 2;
45 46  
46   - static Logger logger = LoggerFactory.getLogger(InOutScheduleDataBuffer.class);
  47 + static Logger logger = LoggerFactory.getLogger(ScheduleDataBuffer.class);
47 48 @Autowired
48 49 InoutSchFixedRefreshThread fixedRefreshThread;
49 50  
... ... @@ -251,6 +252,22 @@ public class InOutScheduleDataBuffer implements CommandLineRunner {
251 252 return rs;
252 253 }
253 254  
  255 + /**
  256 + * 根据进出场信息 获取对应排班
  257 + * @param cio
  258 + * @return
  259 + */
  260 + public static ScheduleInOut get(CarInOutEntity cio) {
  261 + ScheduleInOut rs = null;
  262 + if(cio.getType() == 2){
  263 + rs = getCurrExecIn(cio.getNbbm(), cio.getT());
  264 + }
  265 + else if(cio.getType() == 4){
  266 + rs = getCurrExecOut(cio.getNbbm(), cio.getT());
  267 + }
  268 + return rs;
  269 + }
  270 +
254 271 @Component
255 272 public class InoutSchFixedRefreshThread extends Thread {
256 273  
... ... @@ -289,7 +306,7 @@ public class InOutScheduleDataBuffer implements CommandLineRunner {
289 306 }
290 307  
291 308 logger.info("同步进出场班数量 " + listCopy.size());
292   - InOutScheduleDataBuffer.putAll(listCopy);
  309 + ScheduleDataBuffer.putAll(listCopy);
293 310  
294 311 } catch (Exception e) {
295 312 e.printStackTrace();
... ...
src/main/java/com/bsth/data/signal/RFIDInParkDataBuffer.java deleted 100644 → 0
1   -package com.bsth.data.signal;
2   -
3   -import com.bsth.data.signal.dto.RfidInOutDto;
4   -import com.bsth.data.msg_queue.SignalAndAttConsumeQueue;
5   -import com.bsth.entity.ac.CarInOutEntity;
6   -import org.apache.commons.lang3.StringUtils;
7   -import org.slf4j.Logger;
8   -import org.slf4j.LoggerFactory;
9   -
10   -import java.util.LinkedList;
11   -
12   -/**
13   - * 场内 RFID 数据缓存
14   - * Created by panzhao on 2017/9/5.
15   - */
16   -public class RFIDInParkDataBuffer {
17   -
18   - static Logger logger = LoggerFactory.getLogger(RFIDInParkDataBuffer.class);
19   -
20   - private static LinkedList<RfidInOutDto> list;
21   -
22   - static{
23   - list = new LinkedList<>();
24   - }
25   -
26   - public static void put(RfidInOutDto rfidInOut){
27   - if(null == rfidInOut)
28   - return;
29   - if(StringUtils.isEmpty(rfidInOut.getCarCard()))
30   - return;
31   -
32   - if(null == rfidInOut.getReportTime())
33   - return;
34   -
35   - list.add(rfidInOut);
36   - CarInOutEntity cio = CarInOutEntity.getInstance(rfidInOut);
37   - SignalAndAttConsumeQueue.put(cio);
38   - }
39   -}
src/main/java/com/bsth/entity/ac/CarInOutEntity.java
... ... @@ -2,7 +2,7 @@ package com.bsth.entity.ac;
2 2  
3 3 import com.bsth.data.basic.bus.BusDataBuffer;
4 4 import com.bsth.data.basic.person.PersonDataBuffer;
5   -import com.bsth.data.signal.dto.RfidInOutDto;
  5 +import com.bsth.data.in_out.entity.RfidInOutDto;
6 6 import com.bsth.entity.Bus;
7 7 import com.bsth.entity.Person;
8 8 import com.bsth.util.HexCardTransform;
... ...
src/main/java/com/bsth/entity/berth/RegionBerth.java
1 1 package com.bsth.entity.berth;
2 2  
3   -import com.bsth.entity.electric.BusElectric;
4   -
5 3 import javax.persistence.*;
6 4 import java.util.Date;
7 5  
... ... @@ -66,11 +64,9 @@ public class RegionBerth implements Cloneable{
66 64 */
67 65 private int status;
68 66  
69   - private String remark;
70   -
71   - @Transient
72   - private BusElectric be;
  67 + private String car;
73 68  
  69 + private String remark;
74 70  
75 71 @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
76 72 private Date createDate;
... ... @@ -78,12 +74,6 @@ public class RegionBerth implements Cloneable{
78 74 @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
79 75 private Date updateDate;
80 76  
81   - /**
82   - * 停放车辆
83   - */
84   - @Transient
85   - private String nbbm;
86   -
87 77 @Override
88 78 public int hashCode() {
89 79 return this.toString().hashCode();
... ... @@ -163,14 +153,6 @@ public class RegionBerth implements Cloneable{
163 153 this.remark = remark;
164 154 }
165 155  
166   - public BusElectric getBe() {
167   - return be;
168   - }
169   -
170   - public void setBe(BusElectric be) {
171   - this.be = be;
172   - }
173   -
174 156 public String getSt() {
175 157 return st;
176 158 }
... ... @@ -203,11 +185,11 @@ public class RegionBerth implements Cloneable{
203 185 this.chargePile = chargePile;
204 186 }
205 187  
206   - public String getNbbm() {
207   - return nbbm;
  188 + public String getCar() {
  189 + return car;
208 190 }
209 191  
210   - public void setNbbm(String nbbm) {
211   - this.nbbm = nbbm;
  192 + public void setCar(String car) {
  193 + this.car = car;
212 194 }
213 195 }
... ...
src/main/java/com/bsth/entity/real/RealCarPark.java deleted 100644 → 0
1   -package com.bsth.entity.real;
2   -
3   -/**
4   - * 实时场内车辆停放情况
5   - * Created by panzhao on 2017/9/14.
6   - */
7   -public class RealCarPark {
8   -
9   - /**
10   - * 车辆类型
11   - * 0 公交车
12   - * 1 小车
13   - * 2 其他
14   - */
15   - private int type;
16   -
17   - /**
18   - * 公交车车辆自编号
19   - */
20   - private String nbbm;
21   -
22   - /**
23   - * 车牌号
24   - */
25   - private String plateNo;
26   -
27   - /**
28   - * 进场时间
29   - */
30   - private Long inTime;
31   -
32   - /**
33   - * 停放泊位名称
34   - */
35   - private String berthName;
36   -
37   - /**
38   - * 实时电量
39   - */
40   - private String soc;
41   -
42   -
43   - public String getNbbm() {
44   - return nbbm;
45   - }
46   -
47   - public void setNbbm(String nbbm) {
48   - this.nbbm = nbbm;
49   - }
50   -
51   - public String getPlateNo() {
52   - return plateNo;
53   - }
54   -
55   - public void setPlateNo(String plateNo) {
56   - this.plateNo = plateNo;
57   - }
58   -
59   - public Long getInTime() {
60   - return inTime;
61   - }
62   -
63   - public void setInTime(Long inTime) {
64   - this.inTime = inTime;
65   - }
66   -
67   - public String getBerthName() {
68   - return berthName;
69   - }
70   -
71   - public void setBerthName(String berthName) {
72   - this.berthName = berthName;
73   - }
74   -
75   - public String getSoc() {
76   - return soc;
77   - }
78   -
79   - public void setSoc(String soc) {
80   - this.soc = soc;
81   - }
82   -
83   - public int getType() {
84   - return type;
85   - }
86   -
87   - public void setType(int type) {
88   - this.type = type;
89   - }
90   -
91   - @Override
92   - public int hashCode() {
93   - return toString().hashCode();
94   - }
95   -
96   - @Override
97   - public boolean equals(Object obj) {
98   - RealCarPark rcp = (RealCarPark) obj;
99   - if(this.getType() != rcp.getType())
100   - return false;
101   - else{
102   - if(this.getNbbm().equals(rcp.getNbbm()) || this.getPlateNo().equals(rcp.getPlateNo()))
103   - return true;
104   - }
105   - return super.equals(obj);
106   - }
107   -
108   - @Override
109   - public String toString() {
110   - return this.getType() + "_" + this.getNbbm() + "_" + this.getPlateNo();
111   - }
112   -}
src/main/java/com/bsth/service/berth/BerthService.java
1 1 package com.bsth.service.berth;
2 2  
  3 +import com.bsth.controller.berth.dto.Car2Berth;
3 4 import com.bsth.entity.berth.RegionBerth;
4 5 import com.bsth.service.BaseService;
5 6  
... ... @@ -9,7 +10,8 @@ import java.util.List;
9 10 * Created by panzhao on 2017/8/22.
10 11 */
11 12 public interface BerthService extends BaseService<RegionBerth, Integer>{
12   - RegionBerth next();
  13 + List<Car2Berth> car2Berths();
  14 + /*RegionBerth next();
13 15  
14 16 String getLockBerthName(String nbbm);
15 17  
... ... @@ -23,7 +25,7 @@ public interface BerthService extends BaseService&lt;RegionBerth, Integer&gt;{
23 25  
24 26 void set(RegionBerth b, String nbbm);
25 27  
26   - void reCalc();
  28 + void reCalc();*/
27 29  
28 30 //void berthInOut(Bus bus);
29 31  
... ...
src/main/java/com/bsth/service/berth/impl/BerthServiceImpl.java
1 1 package com.bsth.service.berth.impl;
2 2  
3   -import com.bsth.data.real_park.CarParkRealHandler;
  3 +import com.bsth.controller.berth.dto.Car2Berth;
  4 +import com.bsth.data.basic.bus.BusDataBuffer;
  5 +import com.bsth.data.in_out.RealInoutHandler;
4 6 import com.bsth.entity.berth.RegionBerth;
5   -import com.bsth.repository.berth.BerthRepository;
6 7 import com.bsth.service.berth.BerthService;
7 8 import com.bsth.service.impl.BaseServiceImpl;
8   -import com.bsth.util.ConvertUtil;
9   -import com.google.common.collect.ArrayListMultimap;
10   -import com.google.common.collect.BiMap;
11   -import com.google.common.collect.HashBiMap;
12   -import org.apache.commons.lang3.StringUtils;
13   -import org.slf4j.Logger;
14   -import org.slf4j.LoggerFactory;
15   -import org.springframework.beans.factory.annotation.Autowired;
16   -import org.springframework.stereotype.Component;
17 9 import org.springframework.stereotype.Service;
18 10  
19   -import java.util.*;
  11 +import java.util.ArrayList;
  12 +import java.util.List;
  13 +import java.util.Map;
  14 +import java.util.Set;
20 15  
21 16 /**
22 17 * Created by panzhao on 2017/8/22.
... ... @@ -24,300 +19,20 @@ import java.util.*;
24 19 @Service
25 20 public class BerthServiceImpl extends BaseServiceImpl<RegionBerth, Integer> implements BerthService {
26 21  
27   - //泊位集合
28   - private static List<RegionBerth> berthList;
29   -
30   - @Autowired
31   - CarParkRealHandler carParkRealHandler;
32   -
33   - @Autowired
34   - BerthRepository berthRepository;
35   -
36   - /**
37   - * 固定泊位
38   - * 32 ~ 43 号泊位 固定停放 31~42号车。 W0E-031
39   - */
40   - private static BiMap<String, String> lockBerthMap;
41   -
42   - static {
43   - lockBerthMap = HashBiMap.create();
44   - lockBerthMap.put("W0E-031", "32");
45   - lockBerthMap.put("W0E-032", "33");
46   - lockBerthMap.put("W0E-033", "34");
47   - lockBerthMap.put("W0E-034", "35");
48   - lockBerthMap.put("W0E-035", "36");
49   - lockBerthMap.put("W0E-036", "37");
50   - lockBerthMap.put("W0E-037", "38");
51   - lockBerthMap.put("W0E-038", "39");
52   - lockBerthMap.put("W0E-039", "40");
53   - lockBerthMap.put("W0E-040", "41");
54   - lockBerthMap.put("W0E-041", "42");
55   - lockBerthMap.put("W0E-042", "43");
56   - }
57   -
58   - @Override
59   - public String getLockBerthName(String nbbm){
60   - return lockBerthMap.get(nbbm);
61   - }
62   -
63   - @Override
64   - public String maxOrderNo() {
65   - return berthRepository.maxOrderNo();
66   - }
67   -
68   - /**
69   - * 充电枪状态 K: 枪号 V: 1 充电中
70   - */
71   - private static Map<Integer, Integer> chargeMap;
72   - Logger logger = LoggerFactory.getLogger(this.getClass());
73   -
74   -
75   - static {
76   - berthList = new ArrayList<>();
77   - chargeMap = new HashMap<>();
78   - }
79   -
80   - /**
81   - * 获取下一个可用泊位
82   - *
83   - * @return
84   - */
85 22 @Override
86   - public RegionBerth next() {
87   - RegionBerth b = null;
88   -
89   - try {
90   - /*b = nextChargeBerth();
91   - if (null != b)
92   - return b;
93   -
94   - //最快充电完成枪的空余泊位
95   - b = maxElecBerth();*/
96   -
97   - //获取按顺序排列的下一个泊位
98   - b = nextByOrder();
99   - } catch (Exception e) {
100   - logger.error("", e);
101   - }
102   - return b;
103   - }
104   -
105   - @Override
106   - public boolean berthNameIsExist(String berthName){
107   - for(RegionBerth b : berthList){
108   - if(b.getName().equals(berthName))
109   - return true;
110   - }
111   - return false;
112   - }
113   -
114   - @Override
115   - public List<RegionBerth> all(){
116   - return berthList;
117   - }
118   -
119   - /**
120   - * 根据名称获取泊位
121   - * @param lockBerthName
122   - * @return
123   - */
124   - @Override
125   - public RegionBerth get(String name) {
126   - for(RegionBerth b : berthList){
127   - if(b.getName().equals(name))
128   - return b;
129   - }
130   - return null;
131   - }
132   -
133   - @Override
134   - public void set(RegionBerth b, String nbbm) {
135   - b.setNbbm(nbbm);
136   - chargeMap.put(b.getChargePile(), 1);
137   - }
138   -
139   - private RegionBerth maxElecBerth() {
140   - RegionBerth near = null;
141   - //按充电桩分组
142   - try {
143   - //跳过固定泊位
144   - List<RegionBerth> templist = new ArrayList<>();
145   - for(RegionBerth b : berthList){
146   - if(!lockBerthMap.inverse().containsKey(b.getName()))
147   - templist.add(b);
148   - }
149   -
150   - ArrayListMultimap<String, RegionBerth> multimap = new ConvertUtil<RegionBerth>()
151   - .groupMultiList(templist, "", RegionBerth.class.getDeclaredField("chargePile"));
152   -
153   - Set<String> ks = multimap.keySet();
154   - //排序
155   - List<String> cps = new ArrayList<>(ks);
156   - Collections.sort(cps, new Comparator<String>() {
157   - @Override
158   - public int compare(String s1, String s2) {
159   - return Integer.parseInt(s1) - Integer.parseInt(s2);
160   - }
161   - });
162   -
163   - int status;
164   - double maxSoc = -1;
165   - List<RegionBerth> list;
166   - for (String cp : cps) {
167   - list = multimap.get(cp);
168   - //充电枪状态
169   - status = calcCpStatus(list);
170   - if (status == 1) {
171   - double soc = calcCpMaxSoc(list);
172   - RegionBerth tempBerth = nearBerthByCp(list);
173   -
174   - if (soc > maxSoc) {
175   - maxSoc = soc;
176   - near = tempBerth;
177   - }
178   - }
179   - }
180   - } catch (NoSuchFieldException e) {
181   - logger.error("", e);
182   - }
183   - return near;
184   - }
185   -
186   - private RegionBerth nextByOrder(){
187   - //跳过固定泊位
188   - List<RegionBerth> templist = new ArrayList<>();
189   - for(RegionBerth b : berthList){
190   - if(!lockBerthMap.inverse().containsKey(b.getName()))
191   - templist.add(b);
192   - }
193   -
194   - Collections.sort(templist, new Comparator<RegionBerth>() {
195   - @Override
196   - public int compare(RegionBerth b1, RegionBerth b2) {
197   - return Integer.parseInt(b1.getOrderNo()) - Integer.parseInt(b2.getOrderNo());
198   - }
199   - });
200   -
201   - for(RegionBerth b : templist){
202   - if(StringUtils.isEmpty(b.getNbbm()))
203   - return b;
204   - }
205   - return null;
206   - }
207   -
208   - private RegionBerth nearBerthByCp(List<RegionBerth> list) {
209   - Collections.sort(list, new Comparator<RegionBerth>() {
210   - @Override
211   - public int compare(RegionBerth b1, RegionBerth b2) {
212   - return b1.getOrderNo().compareTo(b2.getOrderNo());
213   - }
214   - });
215   - for (RegionBerth b : list) {
216   - if (null == b.getNbbm())
217   - return b;
218   - }
219   - return null;
220   - }
221   -
222   - private double calcCpMaxSoc(List<RegionBerth> list) {
223   - Double maxSoc = 0.0, soc;
224   - for (RegionBerth b : list) {
225   - if(StringUtils.isEmpty(b.getNbbm()))
226   - continue;
227   - soc = carParkRealHandler.soc(b.getNbbm());
228   - if (null != soc && soc > maxSoc)
229   - maxSoc = soc;
230   - }
231   - return maxSoc;
232   - }
233   -
234   - /**
235   - * 充电桩状态
236   - * 0:枪空闲(2个泊位都空闲)
237   - * 1:有车充电且有空余泊位
238   - * 2:无空余泊位
239   - *
240   - * @param regionBerths
241   - * @return
242   - */
243   - private int calcCpStatus(List<RegionBerth> list) {
244   - int count = 0;
245   - for (RegionBerth b : list) {
246   - if (null != b.getNbbm())
247   - count++;
248   - }
249   -
250   - if (count == 0)
251   - return 0;
252   -
253   - if (count >= list.size())
254   - return 2;
255   - return 1;
256   - }
257   -
258   - /**
259   - * 获取下一个可充电的泊位
260   - *
261   - * @return
262   - */
263   - private RegionBerth nextChargeBerth() {
264   - for (RegionBerth b : berthList) {
265   - //跳过固定泊位
266   - if(lockBerthMap.inverse().containsKey(b.getName()))
267   - continue;
268   -
269   - if (null == b.getNbbm()
270   - && (!chargeMap.containsKey(b.getChargePile()) || chargeMap.get(b.getChargePile())!=1))
271   - return b;
272   -
273   - }
274   - return null;
275   - }
276   -
277   - /**
278   - * 重新计算可用枪
279   - */
280   - @Override
281   - public void reCalc(){
282   - Map<Integer, Integer> map = new HashMap<>();
283   - for(RegionBerth b : berthList ){
284   - if(StringUtils.isNotEmpty(b.getNbbm()))
285   - map.put(b.getChargePile(), 1);
286   - }
287   -
288   - chargeMap = map;
289   - }
290   -
291   - /**
292   - * 定时将泊位数据load 到内存
293   - */
294   - @Component
295   - public static class BerthCacheRefreshThread extends Thread {
296   -
297   - @Autowired
298   - BerthRepository berthRepository;
299   -
300   - @Override
301   - public void run() {
302   - List<RegionBerth> list = (List<RegionBerth>) berthRepository.findAll();
303   -
304   - List<RegionBerth> listCopy = new ArrayList<>();
305   - Collections.copy(listCopy, berthList);
306   -
307   - for (RegionBerth b : list) {
308   - if (!listCopy.contains(b))
309   - listCopy.add(b);
310   - }
311   -
312   - //排序
313   - Collections.sort(listCopy, new Comparator<RegionBerth>() {
314   - @Override
315   - public int compare(RegionBerth b1, RegionBerth b2) {
316   - return b1.getOrderNo().compareTo(b2.getOrderNo());
317   - }
318   - });
319   -
320   - berthList = listCopy;
321   - }
  23 + public List<Car2Berth> car2Berths() {
  24 + List<Car2Berth> list = new ArrayList<>();
  25 + //车辆自编号和停放泊位名称对照
  26 + Map<String, String> map = RealInoutHandler.getCar2berthMap();
  27 + Car2Berth c2b;
  28 + Set<String> ks = map.keySet();
  29 + for(String nbbm : ks){
  30 + c2b = new Car2Berth();
  31 + c2b.setBus(BusDataBuffer.findOne(nbbm));
  32 + c2b.setBerth(map.get(nbbm));
  33 + //c2b.setElec(ElectricDataBuffer.findOne(nbbm));
  34 + list.add(c2b);
  35 + }
  36 + return list;
322 37 }
323 38 }
... ...
src/main/java/com/bsth/service/schedule/InOutScheduleService.java renamed to src/main/java/com/bsth/service/schedule/ScheduleService.java
... ... @@ -2,7 +2,6 @@ package com.bsth.service.schedule;
2 2  
3 3 import com.bsth.data.attendance.entity.JsyAttendance;
4 4 import com.bsth.data.schedule.dto.ScheduleInOut;
5   -import com.bsth.entity.ac.CarInOutEntity;
6 5  
7 6 import java.util.Collection;
8 7 import java.util.List;
... ... @@ -10,7 +9,7 @@ import java.util.List;
10 9 /**
11 10 * Created by panzhao on 2017/8/30.
12 11 */
13   -public interface InOutScheduleService {
  12 +public interface ScheduleService {
14 13  
15 14 List<ScheduleInOut> findByCurrentTime();
16 15  
... ... @@ -24,9 +23,9 @@ public interface InOutScheduleService {
24 23 */
25 24 void jsyReport(JsyAttendance att);
26 25  
27   - void inOut(CarInOutEntity obj);
  26 + //void inOut(CarInOutEntity obj);
28 27  
29   - void busInOut(CarInOutEntity obj);
  28 + //void busInOut(CarInOutEntity obj);
30 29  
31   - void busInOutRfid(CarInOutEntity cio, ScheduleInOut sio);
  30 + //void busInOutRfid(CarInOutEntity cio, ScheduleInOut sio);
32 31 }
... ...
src/main/java/com/bsth/service/schedule/impl/InOutScheduleServiceImpl.java renamed to src/main/java/com/bsth/service/schedule/impl/ScheduleServiceImpl.java
1 1 package com.bsth.service.schedule.impl;
2 2  
3 3 import com.bsth.data.attendance.entity.JsyAttendance;
4   -import com.bsth.data.real_park.CarParkRealHandler;
5 4 import com.bsth.data.schedule.dto.ScheduleInOut;
6   -import com.bsth.data.schedule.real.InOutScheduleDataBuffer;
7   -import com.bsth.data.signal.thread.SignalPstThread;
8   -import com.bsth.entity.ac.CarInOutEntity;
9   -import com.bsth.service.schedule.InOutScheduleService;
10   -import org.apache.commons.lang3.StringUtils;
11   -import org.springframework.beans.factory.annotation.Autowired;
  5 +import com.bsth.data.schedule.real.ScheduleDataBuffer;
  6 +import com.bsth.service.schedule.ScheduleService;
12 7 import org.springframework.stereotype.Service;
13 8  
14 9 import java.util.Collection;
... ... @@ -18,15 +13,12 @@ import java.util.List;
18 13 * Created by panzhao on 2017/9/4.
19 14 */
20 15 @Service
21   -public class InOutScheduleServiceImpl implements InOutScheduleService {
  16 +public class ScheduleServiceImpl implements ScheduleService {
22 17  
23 18  
24 19 /* @Autowired
25 20 BerthService berthService;*/
26 21  
27   - @Autowired
28   - CarParkRealHandler carParkRealHandler;
29   -
30 22 @Override
31 23 public List<ScheduleInOut> findByCurrentTime() {
32 24 return null;
... ... @@ -34,12 +26,12 @@ public class InOutScheduleServiceImpl implements InOutScheduleService {
34 26  
35 27 @Override
36 28 public Collection<ScheduleInOut> findAll() {
37   - return InOutScheduleDataBuffer.all();
  29 + return ScheduleDataBuffer.all();
38 30 }
39 31  
40 32 @Override
41 33 public List<ScheduleInOut> all_out() {
42   - return InOutScheduleDataBuffer.all_out();
  34 + return ScheduleDataBuffer.all_out();
43 35 }
44 36  
45 37 /**
... ... @@ -50,7 +42,7 @@ public class InOutScheduleServiceImpl implements InOutScheduleService {
50 42 @Override
51 43 public void jsyReport(JsyAttendance att) {
52 44 //驾驶员的出场计划
53   - ScheduleInOut sio = InOutScheduleDataBuffer.getCurrExecOut(att.getCompany(), att.getUserId(), att.getAt());
  45 + ScheduleInOut sio = ScheduleDataBuffer.getCurrExecOut(att.getCompany(), att.getUserId(), att.getAt());
54 46  
55 47 //报到时间不覆盖
56 48 if(sio.getAttSjTime() != null)
... ... @@ -60,65 +52,4 @@ public class InOutScheduleServiceImpl implements InOutScheduleService {
60 52 //通知页面
61 53  
62 54 }
63   -
64   - @Override
65   - public void inOut(CarInOutEntity cio) {
66   - if(0 == cio.getCarType())
67   - busInOut(cio);
68   -
69   - //准备入库 -只存实进和实出
70   - if(cio.getType() == 2 || cio.getType() == 4)
71   - SignalPstThread.psts.add(cio);
72   - }
73   -
74   - @Override
75   - public void busInOut(CarInOutEntity cio) {
76   - //车辆的出场计划
77   - ScheduleInOut sio = null;
78   - if(cio.getType() == 2){
79   - sio = InOutScheduleDataBuffer.getCurrExecIn(cio.getNbbm(), cio.getT());
80   - }
81   - else if(cio.getType() == 4){
82   - sio = InOutScheduleDataBuffer.getCurrExecOut(cio.getNbbm(), cio.getT());
83   - }
84   -
85   -
86   - //实时车辆进出场处理程序
87   - carParkRealHandler.carInOut(cio);
88   - if(null == sio)
89   - return;
90   -
91   - switch (cio.getSignalType()){
92   - case 0:
93   - busInOutRfid(cio, sio);
94   - break;
95   - }
96   - }
97   -
98   - @Override
99   - public void busInOutRfid(CarInOutEntity cio, ScheduleInOut sch) {
100   - /*if(sch.getOutTimeRfid() != null)
101   - return;*/
102   - if(null == sch.getOutTimeRfid())
103   - sch.setOutTimeRfid(cio.getT());
104   - //计划时间
105   - cio.setPt(sch.getDfsjT());
106   - cio.setLineCode(sch.getLineCode());
107   - cio.setLineName(sch.getLineName());
108   - cio.setCompany(sch.getGsbm());
109   - cio.setFgsCompany(sch.getFgsbm());
110   - cio.setTaskStatus(1);
111   - cio.setpJsy(sch.getjGh());
112   -
113   - /**
114   - * 人车是否相符
115   - */
116   - if(StringUtils.isNotEmpty(cio.getJsy())){
117   - String sjGh = cio.getJsy().split("/")[0];
118   -
119   - if(sch.getjGh().equals(sjGh)){
120   - cio.setPcMatch(true);
121   - }
122   - }
123   - }
124 55 }
... ...
src/main/java/com/bsth/websocket/handler/SocketHandler.java renamed to src/main/java/com/bsth/websocket/handler/RealInoutSocketHandler.java
1 1 package com.bsth.websocket.handler;
2 2  
  3 +import com.bsth.data.msg_queue.WebSocketPushQueue;
3 4 import org.slf4j.Logger;
4 5 import org.slf4j.LoggerFactory;
5 6 import org.springframework.stereotype.Component;
6 7 import org.springframework.web.socket.*;
7 8  
8 9 import java.util.ArrayList;
9   -import java.util.Collection;
10 10 import java.util.Iterator;
11   -import java.util.List;
12 11 import java.util.concurrent.ConcurrentHashMap;
13 12 import java.util.concurrent.CopyOnWriteArrayList;
14 13  
... ... @@ -16,7 +15,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
16 15 * @author PanZhao
17 16 */
18 17 @Component
19   -public class SocketHandler implements WebSocketHandler {
  18 +public class RealInoutSocketHandler implements WebSocketHandler {
20 19  
21 20 Logger logger = LoggerFactory.getLogger(this.getClass());
22 21  
... ... @@ -32,15 +31,6 @@ public class SocketHandler implements WebSocketHandler {
32 31 public void afterConnectionClosed(WebSocketSession session, CloseStatus arg1)
33 32 throws Exception {
34 33 users.remove(session);
35   - //清理监听
36   - int vsCount=0;
37   - Collection<CopyOnWriteArrayList<WebSocketSession>> vs = listenMap.values();
38   - for(CopyOnWriteArrayList<WebSocketSession> list : vs){
39   - list.remove(session);
40   -
41   - vsCount += list.size();
42   - }
43   - logger.info("listen values size: " + vsCount + " -CloseStatus:" + arg1 + "conn: " + users.size());
44 34 }
45 35  
46 36 @Override
... ... @@ -52,24 +42,6 @@ public class SocketHandler implements WebSocketHandler {
52 42 @Override
53 43 public void handleMessage(WebSocketSession session, WebSocketMessage<?> msg)
54 44 throws Exception {
55   - /*JSONObject jsonObj = JSONObject.parseObject(msg.getPayload().toString());
56   - switch (jsonObj.getString("operCode")) {
57   - case "register_line":
58   - //注册线路监听
59   - List<String> idx = Splitter.on(",").splitToList(jsonObj.getString("idx"));
60   - for(String lineCode : idx){
61   - if(BasicData.lineCode2NameMap.containsKey(lineCode)){
62   - if(!listenMap.containsKey(lineCode)){
63   - listenMap.put(lineCode, new CopyOnWriteArrayList<WebSocketSession>());
64   - }
65   - listenMap.get(lineCode).add(session);
66   - }
67   - }
68   - break;
69   -
70   - default:
71   - break;
72   - }*/
73 45 logger.info(msg.getPayload().toString());
74 46 }
75 47  
... ... @@ -89,23 +61,6 @@ public class SocketHandler implements WebSocketHandler {
89 61  
90 62  
91 63 /**
92   - * 根据线路推送消息
93   - */
94   - public void sendMessageToLine(String lineCode, String msg) {
95   -
96   - TextMessage message = new TextMessage(msg.getBytes());
97   - List<WebSocketSession> list = listenMap.get(lineCode);
98   - if(list == null || list.size() == 0)
99   - return;
100   -
101   - for(WebSocketSession user : list){
102   - //WebSocketPushQueue.put(user, message);
103   - }
104   - }
105   -
106   -
107   -
108   - /**
109 64 * 全局推送
110 65 */
111 66 public void sendMessage(String msg) {
... ... @@ -117,7 +72,7 @@ public class SocketHandler implements WebSocketHandler {
117 72 WebSocketSession user;
118 73 while(iterator.hasNext()){
119 74 user = iterator.next();
120   - //WebSocketPushQueue.put(user, message);
  75 + WebSocketPushQueue.put(user, message);
121 76 }
122 77 }
123 78 }
... ...
src/main/java/com/bsth/websocket/handler/SendUtils.java 0 → 100644
  1 +package com.bsth.websocket.handler;
  2 +
  3 +import com.fasterxml.jackson.databind.ObjectMapper;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import java.text.SimpleDateFormat;
  10 +import java.util.Date;
  11 +import java.util.HashMap;
  12 +import java.util.Map;
  13 +
  14 +@Component
  15 +public class SendUtils{
  16 +
  17 + @Autowired
  18 + private RealInoutSocketHandler socketHandler;
  19 +
  20 + private static Logger logger = LoggerFactory.getLogger(SendUtils.class);
  21 +
  22 + private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  23 +
  24 + public void sendCarIn(String nbbm, String berthName, Long t){
  25 + Map<String, Object> map = new HashMap<>();
  26 + map.put("fn", "carIn");
  27 + map.put("nbbm", nbbm);
  28 + map.put("berthName", berthName);
  29 + map.put("dataStr", sdf.format(new Date(t)));
  30 +
  31 + ObjectMapper mapper = new ObjectMapper();
  32 +
  33 + try {
  34 + socketHandler.sendMessage(mapper.writeValueAsString(map));
  35 + } catch (Exception e) {
  36 + logger.error("", e);
  37 + }
  38 + }
  39 +
  40 + public void sendCarOut(String nbbm, Long t){
  41 + Map<String, Object> map = new HashMap<>();
  42 + map.put("fn", "carOut");
  43 + map.put("nbbm", nbbm);
  44 + map.put("dataStr", sdf.format(new Date(t)));
  45 +
  46 + ObjectMapper mapper = new ObjectMapper();
  47 +
  48 + try {
  49 + socketHandler.sendMessage(mapper.writeValueAsString(map));
  50 + } catch (Exception e) {
  51 + logger.error("", e);
  52 + }
  53 + }
  54 +}
... ...
src/main/resources/static/assets/css/main.css
... ... @@ -24,6 +24,10 @@ input::-webkit-input-placeholder {
24 24 margin-top: -2px;
25 25 }
26 26  
  27 +.top_tools.scok-colse{
  28 + background: #f4b7b7;
  29 +}
  30 +
27 31 .top_tools .ct-btn-list {
28 32 display: inline-block;
29 33 width: calc(100% - 180px);
... ... @@ -618,33 +622,33 @@ table tr th, table tr td{
618 622 padding: 25px;
619 623 overflow-x: hidden;
620 624 overflow-y: auto;
621   -
622 625 -webkit-user-select: none;
623 626 user-select: none;
624 627 overflow: auto;
625   - height: calc(100% - 50px);
  628 + height: calc(100% - 68px);
626 629 position: relative;
  630 + padding-top: 10px;
627 631 }
628 632  
629   -.berth_card_list>.berth_card{
  633 +.berth_card_list .berth_card{
630 634 display: inline-block;
631 635 width: 160px;
632 636 height: 160px;
633 637 background: #fff;
634 638 color: #666;
635 639 box-shadow: 0 5px 15px rgba(0,0,0,0.08);
636   - margin: 11px;
  640 + margin: 0;
637 641 }
638 642  
639   -.berth_card_list>.berth_card>.car_blank{
  643 +.berth_card_list .berth_card>.car_blank{
640 644 height: 70%;
641 645 }
642 646  
643   -.berth_card_list>.berth_card>.car_blank.free{
  647 +.berth_card_list .berth_card>.car_blank.free{
644 648 background: #f9f9f9;
645 649 }
646 650  
647   -.berth_card_list>.berth_card>.car_blank.free:before{
  651 +.berth_card_list .berth_card>.car_blank.free:before{
648 652 content: '空闲';
649 653 width: 100%;
650 654 height: 70%;
... ... @@ -657,7 +661,23 @@ table tr th, table tr td{
657 661 padding-left: 44%;
658 662 }
659 663  
660   -.berth_card_list>.berth_card>.berth_info{
  664 +.berth_card_list .berth_card>.car_blank.free.lock:before{
  665 + content: '';
  666 + width: 100%;
  667 + height: 70%;
  668 + display: block;
  669 + padding-top: 29%;
  670 + color: #a1a0a0;
  671 + background: url(/assets/icon/lock.png);
  672 + background-repeat: no-repeat;
  673 + background-position: 32% 46%;
  674 +}
  675 +
  676 +/*.berth_card_list .berth_card>.car_blank.free.lock {
  677 + background: #bababa;
  678 +}*/
  679 +
  680 +.berth_card_list .berth_card>.berth_info{
661 681 height: calc(30% - 11px);
662 682 font-size: 18px;
663 683 font-family: 微软雅黑;
... ... @@ -668,11 +688,11 @@ table tr th, table tr td{
668 688 position: relative;
669 689 }
670 690  
671   -.berth_card_list>.berth_card>.car_blank.charging{
  691 +.berth_card_list .berth_card>.car_blank.charging{
672 692 background: rgb(223, 167, 85);
673 693 }
674 694  
675   -.berth_card_list>.berth_card>.car_blank.charging:before{
  695 +.berth_card_list .berth_card>.car_blank.charging:before{
676 696 content: "正在充电...";
677 697 width: 100%;
678 698 height: 20px;
... ... @@ -686,23 +706,16 @@ table tr th, table tr td{
686 706 background-position: 42px 11px;
687 707 }
688 708  
689   -.berth_card_list>.berth_card>.car_blank.no_elec{
  709 +.berth_card_list .berth_card>.car_blank.no_elec{
690 710 background: #9f9f9f;
691 711 }
692 712  
693   -.berth_card_list>.berth_card>.car_blank.draging{
  713 +.berth_card_list .berth_card>.car_blank.draging{
694 714 box-shadow: inset 0px 0px 15px 3px rgba(86, 84, 84, 0.59);
695 715 }
696 716  
697   -/*.berth_card_list>.berth_card>.car_blank.draging:before{
698   - visibility: hidden !important;
699   -}*/
700 717  
701   -/*.berth_card_list>.berth_card .draging .car_name{
702   - color: #adadad;
703   -}*/
704   -
705   -.berth_card_list>.berth_card>.car_blank.no_elec:before{
  718 +.berth_card_list .berth_card>.car_blank.no_elec:before{
706 719 content: "无电量信息";
707 720 width: 100%;
708 721 height: 20px;
... ... @@ -717,7 +730,7 @@ table tr th, table tr td{
717 730 }
718 731  
719 732  
720   -.berth_card_list>.berth_card .car_name{
  733 +.berth_card_list .berth_card .car_name{
721 734 height: calc(100% - 20px);
722 735 text-align: center;
723 736 color: #2a2a2a;
... ... @@ -728,7 +741,7 @@ table tr th, table tr td{
728 741 font-family: 微软雅黑;
729 742 }
730 743  
731   -.berth_card_list>.berth_card .car_name>.elec_perc{
  744 +.berth_card_list .berth_card .car_name>.elec_perc{
732 745 position: absolute;
733 746 bottom: 15px;
734 747 text-align: center;
... ... @@ -739,11 +752,11 @@ table tr th, table tr td{
739 752 }
740 753  
741 754  
742   -.berth_card_list>.berth_card>.car_blank.over{
  755 +.berth_card_list .berth_card>.car_blank.over{
743 756 background: #3db6ed;
744 757 }
745 758  
746   -.berth_card_list>.berth_card>.car_blank.over:before{
  759 +.berth_card_list .berth_card>.car_blank.over:before{
747 760 content: "";
748 761 width: 100%;
749 762 height: 20px;
... ... @@ -912,15 +925,31 @@ table tr th, table tr td{
912 925 }
913 926  
914 927 .charge_pile{
915   - position: absolute;
916   - top: 11px;
917   - left: 4px;
918 928 color: #FFFFFF;
919 929 font-weight: 600;
920 930 font-size: 14px;
921   - background: #E04343;
922   - border-radius: 50%;
  931 + background: #7676e8;
923 932 width: 25px;
924 933 height: 25px;
925 934 line-height: 25px;
  935 + display: block;
  936 + text-align: center;
  937 + position: absolute;
  938 + left: 0;
  939 + top: 0;
  940 +}
  941 +
  942 +.charge_pile_wrap{
  943 + display: inline-block;
  944 + background: #efefef;
  945 + margin: 5px 5px 11px;
  946 + padding: 32px 7px 7px;
  947 + position: relative;
  948 + border: 1px solid #cfcfcf;
  949 + box-shadow: 0 5px 12px rgba(0, 0, 0, 0.05);
  950 + border-radius: 5px;
  951 +}
  952 +
  953 +.charge_pile_wrap>.berth_card:nth-of-type(1){
  954 + margin-right: 4px;
926 955 }
927 956 \ No newline at end of file
... ...
src/main/resources/static/assets/icon/lock.png 0 → 100644

849 Bytes

src/main/resources/static/assets/js/tts.js 0 → 100644
  1 +var gb_tts = (function() {
  2 +
  3 + var storage = window.localStorage;
  4 + var defaultConfig = {
  5 + //发音速度 1 ~ 10
  6 + rate: 1.2,
  7 + //播放队列 1:覆盖式(总是播放最新) -1:完整的按顺序播报
  8 + queueModel: 1,
  9 + enable: 1
  10 + };
  11 +
  12 + var readLocal = function() {
  13 + //从本地客户端读取配置信息
  14 + var cofig = storage.getItem('tts_cofig');
  15 + if (cofig) {
  16 + cofig = JSON.parse(cofig);
  17 + defaultConfig = cofig;
  18 + }
  19 + };
  20 +
  21 + var writeConfig = function(newConfig) {
  22 + storage.setItem('tts_cofig', JSON.stringify(newConfig));
  23 + defaultConfig = newConfig;
  24 + };
  25 +
  26 + var synth = window.speechSynthesis;
  27 + readLocal();
  28 +
  29 + var speak = function(t) {
  30 + if (defaultConfig.enable != 1)
  31 + return;
  32 + if (defaultConfig.queueModel == 1)
  33 + synth.cancel();
  34 +
  35 + //延迟100毫秒,防止中断旧语音时 将新的语音也中断
  36 + setTimeout(function() {
  37 + var msg = new SpeechSynthesisUtterance(t);
  38 + msg.rate = defaultConfig.rate;
  39 + synth.speak(msg);
  40 + }, 100);
  41 + };
  42 +
  43 + var audition = function(t, rate) {
  44 + var msg = new SpeechSynthesisUtterance(t);
  45 + msg.rate = rate;
  46 + synth.speak(msg);
  47 + };
  48 +
  49 + return {
  50 + readLocal: readLocal,
  51 + writeConfig: writeConfig,
  52 + defaultConfig: function() {
  53 + return defaultConfig
  54 + },
  55 + speak: speak,
  56 + audition: audition
  57 + };
  58 +})();
0 59 \ No newline at end of file
... ...