Commit 78e80e173bb2247a5b9737e847bd5225b2eb1d12

Authored by 王通
1 parent 80a9a8f4

1.线调加入视频监控、ADAS、DSM内容

Showing 42 changed files with 2601 additions and 1308 deletions

Too many changes to show.

To preserve performance only 42 of 59 files are displayed.

@@ -61,6 +61,10 @@ @@ -61,6 +61,10 @@
61 <artifactId>spring-kafka</artifactId> 61 <artifactId>spring-kafka</artifactId>
62 </dependency> 62 </dependency>
63 <dependency> 63 <dependency>
  64 + <groupId>org.springframework.boot</groupId>
  65 + <artifactId>spring-boot-starter-amqp</artifactId>
  66 + </dependency>
  67 + <dependency>
64 <groupId>mysql</groupId> 68 <groupId>mysql</groupId>
65 <artifactId>mysql-connector-java</artifactId> 69 <artifactId>mysql-connector-java</artifactId>
66 <version>5.1.38</version> 70 <version>5.1.38</version>
@@ -412,6 +416,23 @@ @@ -412,6 +416,23 @@
412 <groupId>org.hibernate</groupId> 416 <groupId>org.hibernate</groupId>
413 <artifactId>hibernate-spatial</artifactId> 417 <artifactId>hibernate-spatial</artifactId>
414 </dependency> 418 </dependency>
  419 +
  420 + <dependency>
  421 + <groupId>io.minio</groupId>
  422 + <artifactId>minio</artifactId>
  423 + <version>8.5.14</version>
  424 + <exclusions>
  425 + <exclusion>
  426 + <groupId>org.jetbrains.kotlin</groupId>
  427 + <artifactId>kotlin-stdlib</artifactId>
  428 + </exclusion>
  429 + </exclusions>
  430 + </dependency>
  431 + <dependency>
  432 + <groupId>org.jetbrains.kotlin</groupId>
  433 + <artifactId>kotlin-stdlib</artifactId>
  434 + <version>1.3.72</version>
  435 + </dependency>
415 </dependencies> 436 </dependencies>
416 437
417 <dependencyManagement> 438 <dependencyManagement>
src/main/java/com/bsth/Application.java
1 package com.bsth; 1 package com.bsth;
2 2
  3 +import com.bsth.data.BasicData;
3 import com.bsth.data.SystemParamCache; 4 import com.bsth.data.SystemParamCache;
4 import com.fasterxml.jackson.annotation.JsonInclude; 5 import com.fasterxml.jackson.annotation.JsonInclude;
5 import com.fasterxml.jackson.databind.ObjectMapper; 6 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -27,6 +28,9 @@ public class Application extends SpringBootServletInitializer { @@ -27,6 +28,9 @@ public class Application extends SpringBootServletInitializer {
27 @Autowired 28 @Autowired
28 private SystemParamCache systemParamCache; 29 private SystemParamCache systemParamCache;
29 30
  31 + @Autowired
  32 + private BasicData.BasicDataLoader basicDataLoader;
  33 +
30 @Override 34 @Override
31 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 35 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
32 return application.sources(Application.class); 36 return application.sources(Application.class);
src/main/java/com/bsth/XDApplication.java
@@ -28,6 +28,7 @@ import com.bsth.util.Tools; @@ -28,6 +28,7 @@ import com.bsth.util.Tools;
28 import org.slf4j.Logger; 28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory; 29 import org.slf4j.LoggerFactory;
30 import org.springframework.beans.factory.annotation.Autowired; 30 import org.springframework.beans.factory.annotation.Autowired;
  31 +import org.springframework.beans.factory.annotation.Value;
31 import org.springframework.boot.CommandLineRunner; 32 import org.springframework.boot.CommandLineRunner;
32 import org.springframework.stereotype.Component; 33 import org.springframework.stereotype.Component;
33 34
@@ -43,6 +44,9 @@ public class XDApplication implements CommandLineRunner { @@ -43,6 +44,9 @@ public class XDApplication implements CommandLineRunner {
43 44
44 Logger log = LoggerFactory.getLogger(this.getClass()); 45 Logger log = LoggerFactory.getLogger(this.getClass());
45 46
  47 + @Value("${spring.profiles.active}")
  48 + private String active;
  49 +
46 @Autowired 50 @Autowired
47 BasicData.BasicDataLoader basicDataLoader; 51 BasicData.BasicDataLoader basicDataLoader;
48 @Autowired 52 @Autowired
@@ -110,11 +114,7 @@ public class XDApplication implements CommandLineRunner { @@ -110,11 +114,7 @@ public class XDApplication implements CommandLineRunner {
110 @Override 114 @Override
111 public void run(String... strings) throws Exception { 115 public void run(String... strings) throws Exception {
112 try { 116 try {
113 - Tools tools = new Tools("application.properties");  
114 - String environment = tools.getValue("spring.profiles.active");  
115 - //预先加载基础的对照数据  
116 - basicDataLoader.loadAllData();  
117 - switch (environment){ 117 + switch (active){
118 case "dev": 118 case "dev":
119 devInit(); 119 devInit();
120 break; 120 break;
src/main/java/com/bsth/common/SystemParamKeys.java
@@ -48,4 +48,8 @@ public class SystemParamKeys { @@ -48,4 +48,8 @@ public class SystemParamKeys {
48 public static final String ENABLED_WHITE_IP = "enabled.white.ip"; 48 public static final String ENABLED_WHITE_IP = "enabled.white.ip";
49 49
50 public static final String ENABLED_FILTER_AUTHORITY = "enabled.filter.authority"; 50 public static final String ENABLED_FILTER_AUTHORITY = "enabled.filter.authority";
  51 +
  52 + public static final String URL_HTTP_WVP_PLAY = "url.http.wvp.play";
  53 +
  54 + public static final String TOKEN_HTTP_WVP = "token.http.wvp";
51 } 55 }
src/main/java/com/bsth/config/MinioConfig.java 0 → 100644
  1 +package com.bsth.config;
  2 +
  3 +import io.minio.MinioClient;
  4 +import org.springframework.beans.factory.annotation.Value;
  5 +import org.springframework.context.annotation.Bean;
  6 +import org.springframework.context.annotation.Configuration;
  7 +
  8 +@Configuration
  9 +public class MinioConfig {
  10 +
  11 + /**
  12 + * 访问地址
  13 + */
  14 + @Value("${minio.url}")
  15 + private String endpoint;
  16 +
  17 + /**
  18 + * accessKey类似于用户ID,用于唯一标识你的账户
  19 + */
  20 + @Value("${minio.accessKey}")
  21 + private String accessKey;
  22 +
  23 + /**
  24 + * secretKey是你账户的密码
  25 + */
  26 + @Value("${minio.secretKey}")
  27 + private String secretKey;
  28 +
  29 + @Bean
  30 + public MinioClient minioClient() {
  31 + MinioClient minioClient = MinioClient.builder()
  32 + .endpoint(endpoint)
  33 + .credentials(accessKey, secretKey)
  34 + .build();
  35 +
  36 + return minioClient;
  37 + }
  38 +}
src/main/java/com/bsth/config/RabbitConfig.java 0 → 100644
  1 +package com.bsth.config;
  2 +
  3 +import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
  4 +import org.springframework.amqp.support.converter.MessageConverter;
  5 +import org.springframework.context.annotation.Bean;
  6 +import org.springframework.context.annotation.Configuration;
  7 +
  8 +/**
  9 + * @author hill
  10 + * @date
  11 + */
  12 +@Configuration
  13 +public class RabbitConfig {
  14 +
  15 + /**
  16 + * 报警队列名(调度系统)
  17 + */
  18 + public final static String QUEUE_ALARM_SCHEDULE = "schedule";
  19 +
  20 + @Bean
  21 + public MessageConverter messageConverter(){
  22 + return new Jackson2JsonMessageConverter();
  23 + }
  24 +}
  25 +
  26 +
src/main/java/com/bsth/controller/DvrController.java 0 → 100644
  1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.data.SystemParamCache;
  5 +import com.bsth.util.HttpClientUtils;
  6 +import com.fasterxml.jackson.databind.ObjectMapper;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.util.StringUtils;
  11 +import org.springframework.web.bind.annotation.RequestMapping;
  12 +import org.springframework.web.bind.annotation.RequestParam;
  13 +import org.springframework.web.bind.annotation.RestController;
  14 +
  15 +import java.util.*;
  16 +
  17 +@RestController
  18 +@RequestMapping("dvr")
  19 +public class DvrController {
  20 +
  21 + private final static Logger log = LoggerFactory.getLogger(DvrController.class);
  22 +
  23 + @Autowired
  24 + private ObjectMapper mapper;
  25 +
  26 + @RequestMapping(value = "/jt1078")
  27 + public Map<String, Object> jt1078(@RequestParam("sim") String sim, @RequestParam("channel") int channel) {
  28 + Map<String, Object> result = new HashMap<>();
  29 + result.put("status", ResponseCode.ERROR);
  30 + result.put("msg", "未获取到视频播放地址");
  31 + try {
  32 + if (StringUtils.isEmpty(sim)) {
  33 + result.put("msg", "sim为空");
  34 + throw new IllegalArgumentException("无效的sim");
  35 + }
  36 + if (channel < 1 || channel > 10) {
  37 + result.put("msg", "无效的通道号");
  38 + throw new IllegalArgumentException("无效的通道号");
  39 + }
  40 + sim = sim.replaceAll("^0*", "");
  41 + String url = SystemParamCache.getUrlHttpWvpPlay();
  42 + url = String.format(url, sim, channel);
  43 + Map<String, Object> header = new HashMap<>();
  44 + header.put("access-token", SystemParamCache.getTokenHttpWvp());
  45 + StringBuilder sb = HttpClientUtils.post(url, "{}", header);
  46 + if (sb != null) {
  47 + Map<String, Object> response = mapper.readValue(sb.toString(), Map.class);
  48 + if ((Integer) response.get("code") == 0) {
  49 + Map<String, Object> data = mapper.readValue(mapper.writeValueAsString(response.get("data")), Map.class);
  50 + result.put("status", ResponseCode.SUCCESS);
  51 + result.put("data", data);
  52 + }
  53 + result.put("msg", response.get("msg"));
  54 + }
  55 + } catch (Exception e) {
  56 + result.put("status", ResponseCode.ERROR);
  57 + if (result.get("msg") == null) {
  58 + result.put("msg", "捕获到异常,检查日志信息");
  59 + }
  60 + log.error(e.getMessage(), e);
  61 + }
  62 +
  63 + return result;
  64 + }
  65 +}
src/main/java/com/bsth/controller/alaram/AlarmAdasController.java 0 → 100644
  1 +package com.bsth.controller.alaram;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.message.entity.AlarmADASVo;
  5 +import com.bsth.service.alarm.AlarmAdasService;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +import java.util.*;
  14 +
  15 +@RestController
  16 +@RequestMapping("alarm_adas")
  17 +public class AlarmAdasController {
  18 +
  19 + private final static Logger log = LoggerFactory.getLogger(AlarmAdasController.class);
  20 +
  21 + @Autowired
  22 + private AlarmAdasService alarmAdasService;
  23 +
  24 + @RequestMapping(value = "/list")
  25 + public Map<String, Object> list(@RequestParam Map<String, String> param,
  26 + @RequestParam(defaultValue = "0") int page,
  27 + @RequestParam(defaultValue = "15") int size,
  28 + @RequestParam(defaultValue = "timestamp") String order,
  29 + @RequestParam(defaultValue = "0") int direction) {
  30 + Map<String, Object> result = new HashMap<>();
  31 + try {
  32 + List<AlarmADASVo> alarmADASVoList = alarmAdasService.list(param, page, size, order, direction);
  33 + Collections.sort(alarmADASVoList, new Comparator<AlarmADASVo>() {
  34 + @Override
  35 + public int compare(AlarmADASVo o1, AlarmADASVo o2) {
  36 + return (int) (o2.getAlarmTimeBegin() - o1.getAlarmTimeBegin());
  37 + }
  38 + });
  39 + int total = alarmADASVoList.size(), start = page * size, end = start + size;
  40 + if (end > total) {
  41 + end = total;
  42 + }
  43 + result.put("list", alarmADASVoList.subList(start, end));
  44 + result.put("totalPages", total % size == 0 ? total / size - 1 : total / size);
  45 + result.put("page", page);
  46 + result.put("status", ResponseCode.SUCCESS);
  47 + } catch (Exception e) {
  48 + result.put("status", ResponseCode.ERROR);
  49 + log.error(e.getMessage(), e);
  50 + }
  51 +
  52 + return result;
  53 + }
  54 +}
src/main/java/com/bsth/controller/alaram/AlarmDsmController.java 0 → 100644
  1 +package com.bsth.controller.alaram;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.message.entity.AlarmDSMVo;
  5 +import com.bsth.service.alarm.AlarmDsmService;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +import java.util.*;
  14 +
  15 +@RestController
  16 +@RequestMapping("alarm_dsm")
  17 +public class AlarmDsmController {
  18 +
  19 + private final static Logger log = LoggerFactory.getLogger(AlarmDsmController.class);
  20 +
  21 + @Autowired
  22 + private AlarmDsmService alarmDsmService;
  23 +
  24 + @RequestMapping(value = "/list")
  25 + public Map<String, Object> list(@RequestParam Map<String, String> param,
  26 + @RequestParam(defaultValue = "0") int page,
  27 + @RequestParam(defaultValue = "15") int size,
  28 + @RequestParam(defaultValue = "timestamp") String order,
  29 + @RequestParam(defaultValue = "0") int direction) {
  30 + Map<String, Object> result = new HashMap<>();
  31 + try {
  32 + List<AlarmDSMVo> alarmDSMVoList = alarmDsmService.list(param, page, size, order, direction);
  33 + Collections.sort(alarmDSMVoList, new Comparator<AlarmDSMVo>() {
  34 + @Override
  35 + public int compare(AlarmDSMVo o1, AlarmDSMVo o2) {
  36 + return (int) (o2.getAlarmTimeBegin() - o1.getAlarmTimeBegin());
  37 + }
  38 + });
  39 + int total = alarmDSMVoList.size(), start = page * size, end = start + size;
  40 + if (end > total) {
  41 + end = total;
  42 + }
  43 + result.put("list", alarmDSMVoList.subList(start, end));
  44 + result.put("totalPages", total % size == 0 ? total / size - 1 : total / size);
  45 + result.put("page", page);
  46 + result.put("status", ResponseCode.SUCCESS);
  47 + } catch (Exception e) {
  48 + result.put("status", ResponseCode.ERROR);
  49 + log.error(e.getMessage(), e);
  50 + }
  51 +
  52 + return result;
  53 + }
  54 +}
src/main/java/com/bsth/controller/realcontrol/ServiceDataInterface.java
@@ -87,6 +87,7 @@ public class ServiceDataInterface { @@ -87,6 +87,7 @@ public class ServiceDataInterface {
87 if (null == sch) 87 if (null == sch)
88 continue; 88 continue;
89 map = new HashMap<>(); 89 map = new HashMap<>();
  90 + map.put("id", sch.getId());
90 map.put("clZbh", sch.getClZbh()); 91 map.put("clZbh", sch.getClZbh());
91 map.put("jGh", sch.getjGh()); 92 map.put("jGh", sch.getjGh());
92 map.put("jName", sch.getjName()); 93 map.put("jName", sch.getjName());
src/main/java/com/bsth/data/BasicData.java
@@ -17,6 +17,7 @@ import com.bsth.repository.*; @@ -17,6 +17,7 @@ import com.bsth.repository.*;
17 import org.apache.commons.lang3.StringUtils; 17 import org.apache.commons.lang3.StringUtils;
18 import org.slf4j.Logger; 18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory; 19 import org.slf4j.LoggerFactory;
  20 +import org.springframework.beans.factory.InitializingBean;
20 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
21 import org.springframework.jdbc.core.BeanPropertyRowMapper; 22 import org.springframework.jdbc.core.BeanPropertyRowMapper;
22 import org.springframework.jdbc.core.JdbcTemplate; 23 import org.springframework.jdbc.core.JdbcTemplate;
@@ -58,6 +59,9 @@ public class BasicData { @@ -58,6 +59,9 @@ public class BasicData {
58 //车辆自编号和牌照号对照 (K: 车辆自编号 ,V:牌照号) 59 //车辆自编号和牌照号对照 (K: 车辆自编号 ,V:牌照号)
59 public static Map<String, String> nbbmCompanyPlateMap; 60 public static Map<String, String> nbbmCompanyPlateMap;
60 61
  62 + //车辆自编号和sim号对照 (K:车辆自编号 V: sim号)
  63 + public static Map<String, String> nbbm2SimMap;
  64 +
61 //站点编码和名称对照,包括停车场 (K: lineCode_updown_stationCode ,V:站点名称) 65 //站点编码和名称对照,包括停车场 (K: lineCode_updown_stationCode ,V:站点名称)
62 public static Map<String, String> stationCode2NameMap; 66 public static Map<String, String> stationCode2NameMap;
63 67
@@ -121,7 +125,7 @@ public class BasicData { @@ -121,7 +125,7 @@ public class BasicData {
121 }*/ 125 }*/
122 126
123 @Component 127 @Component
124 - public static class BasicDataLoader extends Thread { 128 + public static class BasicDataLoader extends Thread implements InitializingBean {
125 129
126 @Autowired 130 @Autowired
127 CarsRepository carsRepository; 131 CarsRepository carsRepository;
@@ -164,6 +168,11 @@ public class BasicData { @@ -164,6 +168,11 @@ public class BasicData {
164 loadAllData(); 168 loadAllData();
165 } 169 }
166 170
  171 + @Override
  172 + public void afterPropertiesSet() throws Exception {
  173 + loadAllData();
  174 + }
  175 +
167 /** 176 /**
168 * @Title: loadAllData 177 * @Title: loadAllData
169 * @Description: TODO(加载所有数据) 178 * @Description: TODO(加载所有数据)
@@ -225,9 +234,10 @@ public class BasicData { @@ -225,9 +234,10 @@ public class BasicData {
225 Map<String, String> nbbm2CompanyCode = new HashMap<>(); 234 Map<String, String> nbbm2CompanyCode = new HashMap<>();
226 //车辆和分公司代码对照 235 //车辆和分公司代码对照
227 Map<String, String> nbbm2FgsCompanyCode = new HashMap<>(); 236 Map<String, String> nbbm2FgsCompanyCode = new HashMap<>();
228 -  
229 //车辆自编号和拍照号对照 237 //车辆自编号和拍照号对照
230 Map<String, String> nbbmCompanyPlate = new HashMap<>(); 238 Map<String, String> nbbmCompanyPlate = new HashMap<>();
  239 + // 车辆自编号和sim对照
  240 + Map<String, String> nbbm2Sim = new HashMap<>();
231 241
232 Iterator<Cars> carIterator = carsRepository.findAll().iterator(); 242 Iterator<Cars> carIterator = carsRepository.findAll().iterator();
233 Cars car; 243 Cars car;
@@ -237,12 +247,14 @@ public class BasicData { @@ -237,12 +247,14 @@ public class BasicData {
237 nbbm2CompanyCode.put(car.getInsideCode(), car.getBusinessCode()); 247 nbbm2CompanyCode.put(car.getInsideCode(), car.getBusinessCode());
238 nbbm2FgsCompanyCode.put(car.getInsideCode(), car.getBrancheCompanyCode() + "_" + car.getBusinessCode() ); 248 nbbm2FgsCompanyCode.put(car.getInsideCode(), car.getBrancheCompanyCode() + "_" + car.getBusinessCode() );
239 nbbmCompanyPlate.put(car.getInsideCode(), car.getCarPlate()); 249 nbbmCompanyPlate.put(car.getInsideCode(), car.getCarPlate());
  250 + nbbm2Sim.put(car.getInsideCode(), car.getSim());
240 } 251 }
241 252
242 deviceId2NbbmMap = deviceId2Nbbm; 253 deviceId2NbbmMap = deviceId2Nbbm;
243 nbbm2CompanyCodeMap = nbbm2CompanyCode; 254 nbbm2CompanyCodeMap = nbbm2CompanyCode;
244 nbbm2FgsCompanyCodeMap = nbbm2FgsCompanyCode; 255 nbbm2FgsCompanyCodeMap = nbbm2FgsCompanyCode;
245 - nbbmCompanyPlateMap =nbbmCompanyPlate; 256 + nbbmCompanyPlateMap = nbbmCompanyPlate;
  257 + nbbm2SimMap = nbbm2Sim;
246 } 258 }
247 259
248 /** 260 /**
src/main/java/com/bsth/data/SystemParamCache.java
@@ -105,6 +105,14 @@ public class SystemParamCache implements InitializingBean { @@ -105,6 +105,14 @@ public class SystemParamCache implements InitializingBean {
105 return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_FILTER_AUTHORITY)); 105 return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_FILTER_AUTHORITY));
106 } 106 }
107 107
  108 + public static String getUrlHttpWvpPlay() {
  109 + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_WVP_PLAY);
  110 + }
  111 +
  112 + public static String getTokenHttpWvp() {
  113 + return systemParamService1.getValue(SystemParamKeys.TOKEN_HTTP_WVP);
  114 + }
  115 +
108 @Override 116 @Override
109 public void afterPropertiesSet() throws Exception { 117 public void afterPropertiesSet() throws Exception {
110 systemParamService1 = systemParamService; 118 systemParamService1 = systemParamService;
src/main/java/com/bsth/data/alarm/AlarmCenter.java 0 → 100644
  1 +package com.bsth.data.alarm;
  2 +
  3 +import com.bsth.message.entity.AlarmADASVo;
  4 +import com.bsth.message.entity.AlarmDSMVo;
  5 +import com.bsth.message.entity.AlarmVo;
  6 +import com.bsth.websocket.handler.SendUtils;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.BeansException;
  10 +import org.springframework.context.ApplicationContext;
  11 +import org.springframework.context.ApplicationContextAware;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.HashSet;
  15 +import java.util.Set;
  16 +
  17 +@Component
  18 +public class AlarmCenter implements ApplicationContextAware {
  19 +
  20 + private static Set<AlarmDSMVo> dsmVoSet = new HashSet<>();
  21 +
  22 + private static Set<AlarmADASVo> adasVoSet = new HashSet<>();
  23 +
  24 + private static SendUtils sendUtils;
  25 +
  26 + private static Logger logger = LoggerFactory.getLogger(AlarmCenter.class);
  27 +
  28 + public static void put(AlarmVo alarmVo){
  29 + if (alarmVo instanceof AlarmDSMVo) {
  30 + dsmVoSet.add((AlarmDSMVo) alarmVo);
  31 + sendUtils.sendAlarm(alarmVo);
  32 + } else if (alarmVo instanceof AlarmADASVo) {
  33 + adasVoSet.add((AlarmADASVo) alarmVo);
  34 + sendUtils.sendAlarm(alarmVo);
  35 + }
  36 + }
  37 +
  38 + public static Set<AlarmDSMVo> findAllDsm(){
  39 + return new HashSet<>(dsmVoSet);
  40 + }
  41 +
  42 + public static Set<AlarmADASVo> findAllAdas(){
  43 + return new HashSet<>(adasVoSet);
  44 + }
  45 +
  46 + public static void clear(){
  47 + dsmVoSet.clear();
  48 + adasVoSet.clear();
  49 + logger.info("清除报警数据...");
  50 + }
  51 +
  52 + @Override
  53 + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  54 + sendUtils = applicationContext.getBean(SendUtils.class);
  55 + }
  56 +}
src/main/java/com/bsth/data/gpsdata_v2/entity/GpsEntity.java
@@ -123,6 +123,11 @@ public class GpsEntity implements Cloneable{ @@ -123,6 +123,11 @@ public class GpsEntity implements Cloneable{
123 */ 123 */
124 private int inOrOutStation; 124 private int inOrOutStation;
125 125
  126 + /**
  127 + * sim号
  128 + */
  129 + private String sim;
  130 +
126 public Object clone() { 131 public Object clone() {
127 try { 132 try {
128 return super.clone(); 133 return super.clone();
@@ -431,4 +436,12 @@ public class GpsEntity implements Cloneable{ @@ -431,4 +436,12 @@ public class GpsEntity implements Cloneable{
431 public void setInOrOutStation(int inOrOutStation) { 436 public void setInOrOutStation(int inOrOutStation) {
432 this.inOrOutStation = inOrOutStation; 437 this.inOrOutStation = inOrOutStation;
433 } 438 }
  439 +
  440 + public String getSim() {
  441 + return sim;
  442 + }
  443 +
  444 + public void setSim(String sim) {
  445 + this.sim = sim;
  446 + }
434 } 447 }
src/main/java/com/bsth/data/gpsdata_v2/handlers/GpsStateProcess.java
1 -package com.bsth.data.gpsdata_v2.handlers;  
2 -  
3 -import com.bsth.data.gpsdata_v2.entity.GpsEntity;  
4 -import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager;  
5 -import com.bsth.data.schedule.DayOfSchedule;  
6 -import com.bsth.entity.realcontrol.ScheduleRealInfo;  
7 -import org.springframework.beans.factory.annotation.Autowired;  
8 -import org.springframework.stereotype.Component;  
9 -  
10 -import java.util.concurrent.ConcurrentHashMap;  
11 -import java.util.concurrent.ConcurrentMap;  
12 -  
13 -/**  
14 - * GPS 状态处理  
15 - * Created by panzhao on 2017/11/15.  
16 - */  
17 -@Component  
18 -public class GpsStateProcess {  
19 -  
20 - @Autowired  
21 - DayOfSchedule dayOfSchedule;  
22 -  
23 - @Autowired  
24 - GpsStatusManager gpsStatusManager;  
25 -  
26 - /**  
27 - * 设置状态差异连续次数  
28 - */  
29 - private static ConcurrentMap<String, Integer> stateDiffMap = new ConcurrentHashMap<>();  
30 -  
31 - private final static int CHANGE_THRESHOLD = 2;  
32 -  
33 - public void process(GpsEntity gps) {  
34 - //在执行的任务  
35 - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());  
36 -  
37 - if (null == sch)  
38 - return;  
39 -  
40 - int upDown = Integer.parseInt(sch.getXlDir());  
41 - int schState = dayOfSchedule.emptyService(sch)?1:0;  
42 - String device = gps.getDeviceId();  
43 - /**  
44 - * 网关在进终点的时候,会直接将当前点位状态改变  
45 - * 为避免出现单个点的状态跳动,设置一下切换阈值  
46 - */  
47 - if(gps.getState() != schState || gps.getUpDown() != upDown){  
48 - Integer count = 0;  
49 - if(stateDiffMap.containsKey(device))  
50 - count = stateDiffMap.get(device);  
51 -  
52 - count ++;  
53 -  
54 - if(count >= CHANGE_THRESHOLD){  
55 - //下发指令纠正车载的 营运状态 和 走向  
56 - gpsStatusManager.changeServiceState(gps.getNbbm(), upDown, schState, "同步@系统");  
57 - count = 0;  
58 - }  
59 -  
60 - stateDiffMap.put(device, count);  
61 -  
62 - //记录原始设备状态  
63 - gps.setOrigStateStr(gps.getUpDown() + "_" + gps.getState());  
64 - }  
65 - else  
66 - stateDiffMap.put(device, 0);  
67 -  
68 - if (gps.getUpDown() != upDown) {  
69 - gps.setUpDown((byte) upDown);//修正走向  
70 - }  
71 -  
72 - if(gps.getState() != schState){  
73 - gps.setState(schState);//修正营运状态  
74 - }  
75 -  
76 - if (!sch.getXlBm().equals(gps.getLineId())) {  
77 - //切换车载的 线路编码  
78 - gpsStatusManager.changeLine(gps.getNbbm(), sch.getXlBm(), "同步@系统");  
79 - }  
80 - }  
81 -} 1 +package com.bsth.data.gpsdata_v2.handlers;
  2 +
  3 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  4 +import com.bsth.data.gpsdata_v2.status_manager.GpsStatusManager;
  5 +import com.bsth.data.schedule.DayOfSchedule;
  6 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +import java.util.concurrent.ConcurrentHashMap;
  11 +import java.util.concurrent.ConcurrentMap;
  12 +
  13 +/**
  14 + * GPS 状态处理
  15 + * Created by panzhao on 2017/11/15.
  16 + */
  17 +@Component
  18 +public class GpsStateProcess {
  19 +
  20 + @Autowired
  21 + DayOfSchedule dayOfSchedule;
  22 +
  23 + @Autowired
  24 + GpsStatusManager gpsStatusManager;
  25 +
  26 + /**
  27 + * 设置状态差异连续次数
  28 + */
  29 + private static ConcurrentMap<String, Integer> stateDiffMap = new ConcurrentHashMap<>();
  30 +
  31 + private final static int CHANGE_THRESHOLD = 2;
  32 +
  33 + public void process(GpsEntity gps) {
  34 + //在执行的任务
  35 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  36 +
  37 + if (null == sch)
  38 + return;
  39 +
  40 + int upDown = Integer.parseInt(sch.getXlDir());
  41 + int schState = dayOfSchedule.emptyService(sch)?1:0;
  42 + String device = gps.getDeviceId();
  43 + /**
  44 + * 网关在进终点的时候,会直接将当前点位状态改变
  45 + * 为避免出现单个点的状态跳动,设置一下切换阈值
  46 + */
  47 + if(gps.getState() != schState || gps.getUpDown() != upDown){
  48 + Integer count = 0;
  49 + if(stateDiffMap.containsKey(device))
  50 + count = stateDiffMap.get(device);
  51 +
  52 + count ++;
  53 +
  54 + if(count >= CHANGE_THRESHOLD){
  55 + //下发指令纠正车载的 营运状态 和 走向
  56 + gpsStatusManager.changeServiceState(gps.getNbbm(), upDown, schState, "同步@系统");
  57 + count = 0;
  58 + }
  59 +
  60 + stateDiffMap.put(device, count);
  61 +
  62 + //记录原始设备状态
  63 + gps.setOrigStateStr(gps.getUpDown() + "_" + gps.getState());
  64 + }
  65 + else
  66 + stateDiffMap.put(device, 0);
  67 +
  68 +// if (gps.getUpDown() != upDown) {
  69 +// gps.setUpDown((byte) upDown);//修正走向
  70 +// }
  71 +
  72 + if(gps.getState() != schState){
  73 + gps.setState(schState);//修正营运状态
  74 + }
  75 +
  76 + if (!sch.getXlBm().equals(gps.getLineId())) {
  77 + //切换车载的 线路编码
  78 + gpsStatusManager.changeLine(gps.getNbbm(), sch.getXlBm(), "同步@系统");
  79 + }
  80 + }
  81 +}
src/main/java/com/bsth/data/gpsdata_v2/handlers/StationInsideProcess.java
@@ -5,7 +5,6 @@ import com.bsth.data.gpsdata_v2.cache.GpsCacheData; @@ -5,7 +5,6 @@ import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
5 import com.bsth.data.gpsdata_v2.entity.GpsEntity; 5 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6 import com.bsth.data.gpsdata_v2.entity.StationRoute; 6 import com.bsth.data.gpsdata_v2.entity.StationRoute;
7 import com.bsth.data.gpsdata_v2.utils.GeoUtils; 7 import com.bsth.data.gpsdata_v2.utils.GeoUtils;
8 -import com.bsth.entity.Station;  
9 import org.springframework.stereotype.Component; 8 import org.springframework.stereotype.Component;
10 9
11 import java.util.List; 10 import java.util.List;
@@ -52,9 +51,9 @@ public class StationInsideProcess { @@ -52,9 +51,9 @@ public class StationInsideProcess {
52 gps.setPremiseCode(prev.getPremiseCode()); 51 gps.setPremiseCode(prev.getPremiseCode());
53 52
54 //在场,站外 53 //在场,站外
55 - if (gps.getInstation() == 0) {  
56 - gps.setStopNo(prev.getStopNo());//继承上一个点的站点编码  
57 - } 54 +// if (gps.getInstation() == 0) {
  55 +// gps.setStopNo(prev.getStopNo());//继承上一个点的站点编码
  56 +// }
58 } 57 }
59 } 58 }
60 } 59 }
src/main/java/com/bsth/data/gpsdata_v2/load/GatewayHttpLoader.java
@@ -71,7 +71,7 @@ public class GatewayHttpLoader implements ApplicationContextAware, InitializingB @@ -71,7 +71,7 @@ public class GatewayHttpLoader implements ApplicationContextAware, InitializingB
71 list = GpsDataUtils.clearInvalid(list); 71 list = GpsDataUtils.clearInvalid(list);
72 72
73 List<GpsEntity> ups = new ArrayList<>(); 73 List<GpsEntity> ups = new ArrayList<>();
74 - String nbbm; 74 + String nbbm, sim;
75 for (GpsEntity gps : list) { 75 for (GpsEntity gps : list) {
76 if (StringUtils.isBlank(gps.getDeviceId())) 76 if (StringUtils.isBlank(gps.getDeviceId()))
77 continue; 77 continue;
@@ -80,6 +80,10 @@ public class GatewayHttpLoader implements ApplicationContextAware, InitializingB @@ -80,6 +80,10 @@ public class GatewayHttpLoader implements ApplicationContextAware, InitializingB
80 continue; 80 continue;
81 81
82 nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId()); 82 nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
  83 + if (!StringUtils.isBlank(nbbm)) {
  84 + sim = BasicData.nbbm2SimMap.get(nbbm);
  85 + gps.setSim(sim);
  86 + }
83 gps.setNbbm(nbbm); 87 gps.setNbbm(nbbm);
84 ups.add(gps); 88 ups.add(gps);
85 } 89 }
src/main/java/com/bsth/data/safe_driv/SafeDrivCenter.java
1 -package com.bsth.data.safe_driv;  
2 -  
3 -import com.bsth.websocket.handler.SendUtils;  
4 -import org.joda.time.format.DateTimeFormat;  
5 -import org.joda.time.format.DateTimeFormatter;  
6 -import org.slf4j.Logger;  
7 -import org.slf4j.LoggerFactory;  
8 -import org.springframework.beans.BeansException;  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.context.ApplicationContext;  
11 -import org.springframework.context.ApplicationContextAware;  
12 -import org.springframework.stereotype.Component;  
13 -  
14 -import java.util.HashMap;  
15 -import java.util.HashSet;  
16 -import java.util.Map;  
17 -import java.util.Set;  
18 -  
19 -/**  
20 - * 安全驾驶  
21 - * Created by panzhao on 2017/4/6.  
22 - */  
23 -@Component  
24 -public class SafeDrivCenter implements ApplicationContextAware {  
25 -  
26 - private static Set<SafeDriv> data;  
27 -  
28 - @Autowired  
29 - SafeDrivDataLoadThread safeDrivDataLoadThread;  
30 -  
31 - static SendUtils sendUtils;  
32 -  
33 - /**  
34 - * 车辆自编号 和 最新一条数据对照  
35 - */  
36 - private static Map<String, SafeDriv> safeMap;  
37 -  
38 - static Logger logger = LoggerFactory.getLogger(SafeDrivCenter.class);  
39 -  
40 - static {  
41 - data = new HashSet<>();  
42 - safeMap = new HashMap<>();  
43 - }  
44 -  
45 - private static DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS");  
46 - public static void put(SafeDriv sd){  
47 - sd.setTs(fmt.parseMillis(sd.getStartime()));  
48 - if(Integer.parseInt(sd.getYczltype()) == 5 && Integer.parseInt(sd.getJctype()) == 4  
49 - || Integer.parseInt(sd.getYczltype()) == 6 && Integer.parseInt(sd.getJctype()) == 4)  
50 - sd.setJctype("B" + sd.getJctype());  
51 - else if(sd.getYczltype().indexOf("A") == -1)  
52 - sd.setYczltype("A" + sd.getYczltype());  
53 -  
54 - //SafeDriv old = safeMap.get(sd.getClzbh());  
55 - if(!data.contains(sd)){  
56 - //通知客户端  
57 - sendUtils.sendSafeDriv(sd);  
58 - data.add(sd);  
59 - safeMap.put(sd.getClzbh(), sd);  
60 - }  
61 - }  
62 -  
63 - public static Set<SafeDriv> findAll(){  
64 - return data;  
65 - }  
66 -  
67 - public static void clear(){  
68 - data = new HashSet<>();  
69 - safeMap = new HashMap<>();  
70 - logger.info("清除安全驾驶数据,,,");  
71 - }  
72 -  
73 - @Override  
74 - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {  
75 - sendUtils = applicationContext.getBean(SendUtils.class);  
76 - }  
77 -} 1 +package com.bsth.data.safe_driv;
  2 +
  3 +import com.bsth.websocket.handler.SendUtils;
  4 +import org.joda.time.format.DateTimeFormat;
  5 +import org.joda.time.format.DateTimeFormatter;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.BeansException;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.context.ApplicationContext;
  11 +import org.springframework.context.ApplicationContextAware;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.HashMap;
  15 +import java.util.HashSet;
  16 +import java.util.Map;
  17 +import java.util.Set;
  18 +
  19 +/**
  20 + * 安全驾驶
  21 + * Created by panzhao on 2017/4/6.
  22 + */
  23 +@Component
  24 +public class SafeDrivCenter implements ApplicationContextAware {
  25 +
  26 + private static Set<SafeDriv> data;
  27 +
  28 + @Autowired
  29 + SafeDrivDataLoadThread safeDrivDataLoadThread;
  30 +
  31 + static SendUtils sendUtils;
  32 +
  33 + /**
  34 + * 车辆自编号 和 最新一条数据对照
  35 + */
  36 + private static Map<String, SafeDriv> safeMap;
  37 +
  38 + static Logger logger = LoggerFactory.getLogger(SafeDrivCenter.class);
  39 +
  40 + static {
  41 + data = new HashSet<>();
  42 + safeMap = new HashMap<>();
  43 + }
  44 +
  45 + private static DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS");
  46 + public static void put(SafeDriv sd){
  47 + sd.setTs(fmt.parseMillis(sd.getStartime()));
  48 + if(Integer.parseInt(sd.getYczltype()) == 5 && Integer.parseInt(sd.getJctype()) == 4
  49 + || Integer.parseInt(sd.getYczltype()) == 6 && Integer.parseInt(sd.getJctype()) == 4)
  50 + sd.setJctype("B" + sd.getJctype());
  51 + else if(sd.getYczltype().indexOf("A") == -1)
  52 + sd.setYczltype("A" + sd.getYczltype());
  53 +
  54 + //SafeDriv old = safeMap.get(sd.getClzbh());
  55 + if(!data.contains(sd)){
  56 + //通知客户端
  57 + sendUtils.sendSafeDriv(sd);
  58 + data.add(sd);
  59 + safeMap.put(sd.getClzbh(), sd);
  60 + }
  61 + }
  62 +
  63 + public static Set<SafeDriv> findAll(){
  64 + return data;
  65 + }
  66 +
  67 + public static void clear(){
  68 + data = new HashSet<>();
  69 + safeMap = new HashMap<>();
  70 + logger.info("清除安全驾驶数据...");
  71 + }
  72 +
  73 + @Override
  74 + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  75 + sendUtils = applicationContext.getBean(SendUtils.class);
  76 + }
  77 +}
src/main/java/com/bsth/data/schedule/thread/CalcOilThread.java
1 package com.bsth.data.schedule.thread; 1 package com.bsth.data.schedule.thread;
2 2
  3 +import com.bsth.data.alarm.AlarmCenter;
3 import com.bsth.data.directive.DayOfDirectives; 4 import com.bsth.data.directive.DayOfDirectives;
4 import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; 5 import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
5 import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; 6 import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
@@ -84,6 +85,8 @@ public class CalcOilThread extends Thread{ @@ -84,6 +85,8 @@ public class CalcOilThread extends Thread{
84 dayOfDirectives.clearAll(); 85 dayOfDirectives.clearAll();
85 //清除安全驾驶数据 86 //清除安全驾驶数据
86 SafeDrivCenter.clear(); 87 SafeDrivCenter.clear();
  88 + //清除报警数据
  89 + AlarmCenter.clear();
87 //清除保养计划数据 90 //清除保养计划数据
88 MtPlanCenter.clear(); 91 MtPlanCenter.clear();
89 //清除超速缓存数据 92 //清除超速缓存数据
src/main/java/com/bsth/entity/Cars.java
1 -package com.bsth.entity;  
2 -  
3 -import com.bsth.entity.schedule.BEntity;  
4 -import com.fasterxml.jackson.annotation.JsonIgnoreProperties;  
5 -import org.hibernate.annotations.Formula;  
6 -  
7 -import javax.persistence.*;  
8 -import java.io.Serializable;  
9 -import java.util.Date;  
10 -  
11 -/**  
12 - *  
13 - * @ClassName : Cars(车实体类)  
14 - *  
15 - * @Author : bsth@lq  
16 - *  
17 - * @Description : TODO(车辆基本信息)  
18 - *  
19 - * @Data : 2016-04-27  
20 - *  
21 - * @Version 公交调度系统BS版 0.1  
22 - *  
23 - */  
24 -  
25 -@Entity  
26 -@Table(name = "bsth_c_cars")  
27 -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})  
28 -public class Cars extends BEntity implements Serializable {  
29 -  
30 - /** 主键Id */  
31 - @Id  
32 - @GeneratedValue(strategy = GenerationType.IDENTITY)  
33 - private Integer id;  
34 -  
35 - /** 自编号/内部编号 */  
36 - @Column(nullable = false, length = 20, unique = true)  
37 - private String insideCode;  
38 -  
39 - // 公司、分公司暂时不用关联实体  
40 - /** 公司代码 */  
41 - @Column(nullable = false)  
42 - private String businessCode;  
43 - /** 公司名称 */  
44 - @Column(nullable = false)  
45 - private String company;  
46 - /** 分公司编码 */  
47 - private String brancheCompanyCode;  
48 - /** 分公司 */  
49 - private String brancheCompany;  
50 -  
51 - /** 组合公司分公司编码 */  
52 - @Formula(" concat(business_code, '_', branche_company_code) ")  
53 - private String cgsbm;  
54 -  
55 - /** 车辆编码(TODO:在原系统里没有,这里暂时留着) */  
56 - @Column(nullable = false)  
57 - private String carCode;  
58 - /** 车牌号 */  
59 - @Column(nullable = false)  
60 - private String carPlate;  
61 - /** 供应商名称 */  
62 - @Column(nullable = false)  
63 - private String supplierName;  
64 - /** 设备终端号 */  
65 - @Column(nullable = false)  
66 - private String equipmentCode;  
67 -  
68 - // 以下信息来自总公司的业务系统,可能需要调用相关接口  
69 - /** 车型类别 */  
70 - private String carClass ;  
71 - /** 技术速度 */  
72 - private Double speed;  
73 - /** 座位数 */  
74 - private Integer carSeatnNumber;  
75 - /** 载客标准 */  
76 - private String carStandard;  
77 - /** 标准油耗(开空调) */  
78 - private Double kburnStandard;  
79 - /** 标准油耗(关空调) */  
80 - private Double gburnStandard;  
81 - /** 报废号 */  
82 - private String scrapCode;  
83 - /** 报废日期 */  
84 - private Date scrapDate;  
85 - /** 厂牌型号1 */  
86 - private String makeCodeOne;  
87 - /** 厂牌型号2 */  
88 - private String makeCodeTwo;  
89 - /** 车辆等级标准 */  
90 - private String carGride;  
91 - /** 出厂排放标准 */  
92 - private String emissionsStandard;  
93 - /** 发动机号码1 */  
94 - private String engineCodeOne;  
95 - /** 发动机号码2 */  
96 - private String engineCodeTwo;  
97 - /** 车架号码1 */  
98 - private String carNumberOne;  
99 - /** 车架号码2 */  
100 - private String carNumberTwo;  
101 - /** 启用日期(2008-10-10)*/  
102 - private Date openDate;  
103 - /** 取消日期 */  
104 - private Date closeDate;  
105 -  
106 - /** 是否空调车 */  
107 - @Column(nullable = true)  
108 - private Boolean hvacCar;  
109 - /** 有无人售票 */  
110 - @Column(nullable = true)  
111 - private Boolean ticketType;  
112 - /** 是否有LED服务屏 */  
113 - @Column(nullable = true)  
114 - private Boolean ledScreen;  
115 - /** 是否有TV视频 */  
116 - @Column(nullable = true)  
117 - private Boolean tvVideoType;  
118 -  
119 - /** 车辆类型 */  
120 - private String carType;  
121 - /** 是否机动车(机动车类型选择)*/  
122 - private String vehicleStats;  
123 - /** 营运状态 */  
124 - private String operatorsState;  
125 - /** 营运证编码 */  
126 - private String serviceNo;  
127 - /** 是否电车(TODO:在原系统里没有,这里暂时留着) */  
128 - private Boolean sfdc;  
129 - /** 是否混合动力(TODO:在原系统里没有,这里暂时留着) */  
130 - private Boolean sfmix;  
131 - /** 是否氢能源车 */  
132 - private Boolean hydrogen;  
133 - /** 备注/描述 */  
134 - private String descriptions;  
135 -  
136 - /** 车辆序号(TODO:在原系统里没有,这里暂时留着) */  
137 - private String carOrdinal;  
138 - /** 视频编号 */  
139 - private String videoCode;  
140 - /** 是否报废 */  
141 - @Column(nullable = true)  
142 - private Boolean scrapState;  
143 - /** 是否切换(TODO:在原系统里没有,这里暂时留着)*/  
144 - private Integer isSwitch;  
145 - /** 线路名称(TODO:在原系统里没有,这里暂时留着,并且不做线路关联,只保留个名字) */  
146 - private String xlmc;  
147 -  
148 - public Cars() {}  
149 -  
150 - public Cars(Object id, Object nbbh, Object clbh, Object cph, Object sbbh) {  
151 - if (id != null) {  
152 - this.id = Integer.valueOf(id.toString());  
153 - }  
154 - if (nbbh != null) {  
155 - this.insideCode = nbbh.toString();  
156 - }  
157 - if (clbh != null) {  
158 - this.carCode = clbh.toString();  
159 - }  
160 - if (cph != null) {  
161 - this.carPlate = cph.toString();  
162 - }  
163 - if (sbbh != null) {  
164 - this.equipmentCode = sbbh.toString();  
165 - }  
166 - }  
167 -  
168 - public String getServiceNo() {  
169 - return serviceNo;  
170 - }  
171 -  
172 - public void setServiceNo(String serviceNo) {  
173 - this.serviceNo = serviceNo;  
174 - }  
175 -  
176 - public Integer getId() {  
177 - return id;  
178 - }  
179 -  
180 - public void setId(Integer id) {  
181 - this.id = id;  
182 - }  
183 -  
184 - public String getInsideCode() {  
185 - return insideCode;  
186 - }  
187 -  
188 - public void setInsideCode(String insideCode) {  
189 - this.insideCode = insideCode;  
190 - }  
191 -  
192 - public String getBusinessCode() {  
193 - return businessCode;  
194 - }  
195 -  
196 - public void setBusinessCode(String businessCode) {  
197 - this.businessCode = businessCode;  
198 - }  
199 -  
200 - public String getCompany() {  
201 - return company;  
202 - }  
203 -  
204 - public void setCompany(String company) {  
205 - this.company = company;  
206 - }  
207 -  
208 - public String getBrancheCompanyCode() {  
209 - return brancheCompanyCode;  
210 - }  
211 -  
212 - public void setBrancheCompanyCode(String brancheCompanyCode) {  
213 - this.brancheCompanyCode = brancheCompanyCode;  
214 - }  
215 -  
216 - public String getBrancheCompany() {  
217 - return brancheCompany;  
218 - }  
219 -  
220 - public void setBrancheCompany(String brancheCompany) {  
221 - this.brancheCompany = brancheCompany;  
222 - }  
223 -  
224 - public String getCarCode() {  
225 - return carCode;  
226 - }  
227 -  
228 - public void setCarCode(String carCode) {  
229 - this.carCode = carCode;  
230 - }  
231 -  
232 - public String getCarPlate() {  
233 - return carPlate;  
234 - }  
235 -  
236 - public void setCarPlate(String carPlate) {  
237 - this.carPlate = carPlate;  
238 - }  
239 -  
240 - public String getSupplierName() {  
241 - return supplierName;  
242 - }  
243 -  
244 - public void setSupplierName(String supplierName) {  
245 - this.supplierName = supplierName;  
246 - }  
247 -  
248 - public String getEquipmentCode() {  
249 - return equipmentCode;  
250 - }  
251 -  
252 - public void setEquipmentCode(String equipmentCode) {  
253 - this.equipmentCode = equipmentCode;  
254 - }  
255 -  
256 - public String getCarClass() {  
257 - return carClass;  
258 - }  
259 -  
260 - public void setCarClass(String carClass) {  
261 - this.carClass = carClass;  
262 - }  
263 -  
264 - public Double getSpeed() {  
265 - return speed;  
266 - }  
267 -  
268 - public void setSpeed(Double speed) {  
269 - this.speed = speed;  
270 - }  
271 -  
272 - public Integer getCarSeatnNumber() {  
273 - return carSeatnNumber;  
274 - }  
275 -  
276 - public void setCarSeatnNumber(Integer carSeatnNumber) {  
277 - this.carSeatnNumber = carSeatnNumber;  
278 - }  
279 -  
280 - public String getCarStandard() {  
281 - return carStandard;  
282 - }  
283 -  
284 - public void setCarStandard(String carStandard) {  
285 - this.carStandard = carStandard;  
286 - }  
287 -  
288 - public Double getKburnStandard() {  
289 - return kburnStandard;  
290 - }  
291 -  
292 - public void setKburnStandard(Double kburnStandard) {  
293 - this.kburnStandard = kburnStandard;  
294 - }  
295 -  
296 - public Double getGburnStandard() {  
297 - return gburnStandard;  
298 - }  
299 -  
300 - public void setGburnStandard(Double gburnStandard) {  
301 - this.gburnStandard = gburnStandard;  
302 - }  
303 -  
304 - public String getScrapCode() {  
305 - return scrapCode;  
306 - }  
307 -  
308 - public void setScrapCode(String scrapCode) {  
309 - this.scrapCode = scrapCode;  
310 - }  
311 -  
312 - public Date getScrapDate() {  
313 - return scrapDate;  
314 - }  
315 -  
316 - public void setScrapDate(Date scrapDate) {  
317 - this.scrapDate = scrapDate;  
318 - }  
319 -  
320 - public String getMakeCodeOne() {  
321 - return makeCodeOne;  
322 - }  
323 -  
324 - public void setMakeCodeOne(String makeCodeOne) {  
325 - this.makeCodeOne = makeCodeOne;  
326 - }  
327 -  
328 - public String getMakeCodeTwo() {  
329 - return makeCodeTwo;  
330 - }  
331 -  
332 - public void setMakeCodeTwo(String makeCodeTwo) {  
333 - this.makeCodeTwo = makeCodeTwo;  
334 - }  
335 -  
336 - public String getCarGride() {  
337 - return carGride;  
338 - }  
339 -  
340 - public void setCarGride(String carGride) {  
341 - this.carGride = carGride;  
342 - }  
343 -  
344 - public String getEmissionsStandard() {  
345 - return emissionsStandard;  
346 - }  
347 -  
348 - public void setEmissionsStandard(String emissionsStandard) {  
349 - this.emissionsStandard = emissionsStandard;  
350 - }  
351 -  
352 - public String getEngineCodeOne() {  
353 - return engineCodeOne;  
354 - }  
355 -  
356 - public void setEngineCodeOne(String engineCodeOne) {  
357 - this.engineCodeOne = engineCodeOne;  
358 - }  
359 -  
360 - public String getEngineCodeTwo() {  
361 - return engineCodeTwo;  
362 - }  
363 -  
364 - public void setEngineCodeTwo(String engineCodeTwo) {  
365 - this.engineCodeTwo = engineCodeTwo;  
366 - }  
367 -  
368 - public String getCarNumberOne() {  
369 - return carNumberOne;  
370 - }  
371 -  
372 - public void setCarNumberOne(String carNumberOne) {  
373 - this.carNumberOne = carNumberOne;  
374 - }  
375 -  
376 - public String getCarNumberTwo() {  
377 - return carNumberTwo;  
378 - }  
379 -  
380 - public void setCarNumberTwo(String carNumberTwo) {  
381 - this.carNumberTwo = carNumberTwo;  
382 - }  
383 -  
384 - public Date getOpenDate() {  
385 - return openDate;  
386 - }  
387 -  
388 - public void setOpenDate(Date openDate) {  
389 - this.openDate = openDate;  
390 - }  
391 -  
392 - public Date getCloseDate() {  
393 - return closeDate;  
394 - }  
395 -  
396 - public void setCloseDate(Date closeDate) {  
397 - this.closeDate = closeDate;  
398 - }  
399 -  
400 - public Boolean getHvacCar() {  
401 - return hvacCar;  
402 - }  
403 -  
404 - public void setHvacCar(Boolean hvacCar) {  
405 - this.hvacCar = hvacCar;  
406 - }  
407 -  
408 - public Boolean getTicketType() {  
409 - return ticketType;  
410 - }  
411 -  
412 - public void setTicketType(Boolean ticketType) {  
413 - this.ticketType = ticketType;  
414 - }  
415 -  
416 - public Boolean getLedScreen() {  
417 - return ledScreen;  
418 - }  
419 -  
420 - public void setLedScreen(Boolean ledScreen) {  
421 - this.ledScreen = ledScreen;  
422 - }  
423 -  
424 - public Boolean getTvVideoType() {  
425 - return tvVideoType;  
426 - }  
427 -  
428 - public void setTvVideoType(Boolean tvVideoType) {  
429 - this.tvVideoType = tvVideoType;  
430 - }  
431 -  
432 - public String getCarType() {  
433 - return carType;  
434 - }  
435 -  
436 - public void setCarType(String carType) {  
437 - this.carType = carType;  
438 - }  
439 -  
440 - public String getVehicleStats() {  
441 - return vehicleStats;  
442 - }  
443 -  
444 - public void setVehicleStats(String vehicleStats) {  
445 - this.vehicleStats = vehicleStats;  
446 - }  
447 -  
448 - public String getOperatorsState() {  
449 - return operatorsState;  
450 - }  
451 -  
452 - public void setOperatorsState(String operatorsState) {  
453 - this.operatorsState = operatorsState;  
454 - }  
455 -  
456 - public Boolean getSfdc() {  
457 - return sfdc;  
458 - }  
459 -  
460 - public void setSfdc(Boolean sfdc) {  
461 - this.sfdc = sfdc;  
462 - }  
463 -  
464 - public String getDescriptions() {  
465 - return descriptions;  
466 - }  
467 -  
468 - public void setDescriptions(String descriptions) {  
469 - this.descriptions = descriptions;  
470 - }  
471 -  
472 - public String getCarOrdinal() {  
473 - return carOrdinal;  
474 - }  
475 -  
476 - public void setCarOrdinal(String carOrdinal) {  
477 - this.carOrdinal = carOrdinal;  
478 - }  
479 -  
480 - public String getVideoCode() {  
481 - return videoCode;  
482 - }  
483 -  
484 - public void setVideoCode(String videoCode) {  
485 - this.videoCode = videoCode;  
486 - }  
487 -  
488 - public Boolean getScrapState() {  
489 - return scrapState;  
490 - }  
491 -  
492 - public void setScrapState(Boolean scrapState) {  
493 - this.scrapState = scrapState;  
494 - }  
495 -  
496 - public Integer getIsSwitch() {  
497 - return isSwitch;  
498 - }  
499 -  
500 - public void setIsSwitch(Integer isSwitch) {  
501 - this.isSwitch = isSwitch;  
502 - }  
503 -  
504 - public String getXlmc() {  
505 - return xlmc;  
506 - }  
507 -  
508 - public void setXlmc(String xlmc) {  
509 - this.xlmc = xlmc;  
510 - }  
511 -  
512 - public String getCgsbm() {  
513 - return cgsbm;  
514 - }  
515 -  
516 - public void setCgsbm(String cgsbm) {  
517 - this.cgsbm = cgsbm;  
518 - }  
519 -  
520 - public Boolean getSfmix() {  
521 - return sfmix;  
522 - }  
523 -  
524 - public void setSfmix(Boolean sfmix) {  
525 - this.sfmix = sfmix;  
526 - }  
527 -  
528 - public Boolean getHydrogen() {  
529 - return hydrogen;  
530 - }  
531 -  
532 - public void setHydrogen(Boolean hydrogen) {  
533 - this.hydrogen = hydrogen;  
534 - }  
535 -} 1 +package com.bsth.entity;
  2 +
  3 +import com.bsth.entity.schedule.BEntity;
  4 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  5 +import org.hibernate.annotations.Formula;
  6 +
  7 +import javax.persistence.*;
  8 +import java.io.Serializable;
  9 +import java.util.Date;
  10 +
  11 +/**
  12 + *
  13 + * @ClassName : Cars(车实体类)
  14 + *
  15 + * @Author : bsth@lq
  16 + *
  17 + * @Description : TODO(车辆基本信息)
  18 + *
  19 + * @Data : 2016-04-27
  20 + *
  21 + * @Version 公交调度系统BS版 0.1
  22 + *
  23 + */
  24 +
  25 +@Entity
  26 +@Table(name = "bsth_c_cars")
  27 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  28 +public class Cars extends BEntity implements Serializable {
  29 +
  30 + /** 主键Id */
  31 + @Id
  32 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  33 + private Integer id;
  34 +
  35 + /** 自编号/内部编号 */
  36 + @Column(nullable = false, length = 20, unique = true)
  37 + private String insideCode;
  38 +
  39 + // 公司、分公司暂时不用关联实体
  40 + /** 公司代码 */
  41 + @Column(nullable = false)
  42 + private String businessCode;
  43 + /** 公司名称 */
  44 + @Column(nullable = false)
  45 + private String company;
  46 + /** 分公司编码 */
  47 + private String brancheCompanyCode;
  48 + /** 分公司 */
  49 + private String brancheCompany;
  50 +
  51 + /** 组合公司分公司编码 */
  52 + @Formula(" concat(business_code, '_', branche_company_code) ")
  53 + private String cgsbm;
  54 +
  55 + /** 车辆编码(TODO:在原系统里没有,这里暂时留着) */
  56 + @Column(nullable = false)
  57 + private String carCode;
  58 + /** 车牌号 */
  59 + @Column(nullable = false)
  60 + private String carPlate;
  61 + /** 供应商名称 */
  62 + @Column(nullable = false)
  63 + private String supplierName;
  64 + /** 设备终端号 */
  65 + @Column(nullable = false)
  66 + private String equipmentCode;
  67 +
  68 + // 以下信息来自总公司的业务系统,可能需要调用相关接口
  69 + /** 车型类别 */
  70 + private String carClass ;
  71 + /** 技术速度 */
  72 + private Double speed;
  73 + /** 座位数 */
  74 + private Integer carSeatnNumber;
  75 + /** 载客标准 */
  76 + private String carStandard;
  77 + /** 标准油耗(开空调) */
  78 + private Double kburnStandard;
  79 + /** 标准油耗(关空调) */
  80 + private Double gburnStandard;
  81 + /** 报废号 */
  82 + private String scrapCode;
  83 + /** 报废日期 */
  84 + private Date scrapDate;
  85 + /** 厂牌型号1 */
  86 + private String makeCodeOne;
  87 + /** 厂牌型号2 */
  88 + private String makeCodeTwo;
  89 + /** 车辆等级标准 */
  90 + private String carGride;
  91 + /** 出厂排放标准 */
  92 + private String emissionsStandard;
  93 + /** 发动机号码1 */
  94 + private String engineCodeOne;
  95 + /** 发动机号码2 */
  96 + private String engineCodeTwo;
  97 + /** 车架号码1 */
  98 + private String carNumberOne;
  99 + /** 车架号码2 */
  100 + private String carNumberTwo;
  101 + /** 启用日期(2008-10-10)*/
  102 + private Date openDate;
  103 + /** 取消日期 */
  104 + private Date closeDate;
  105 +
  106 + /** 是否空调车 */
  107 + @Column(nullable = true)
  108 + private Boolean hvacCar;
  109 + /** 有无人售票 */
  110 + @Column(nullable = true)
  111 + private Boolean ticketType;
  112 + /** 是否有LED服务屏 */
  113 + @Column(nullable = true)
  114 + private Boolean ledScreen;
  115 + /** 是否有TV视频 */
  116 + @Column(nullable = true)
  117 + private Boolean tvVideoType;
  118 +
  119 + /** 车辆类型 */
  120 + private String carType;
  121 + /** 是否机动车(机动车类型选择)*/
  122 + private String vehicleStats;
  123 + /** 营运状态 */
  124 + private String operatorsState;
  125 + /** 营运证编码 */
  126 + private String serviceNo;
  127 + /** 是否电车(TODO:在原系统里没有,这里暂时留着) */
  128 + private Boolean sfdc;
  129 + /** 是否混合动力(TODO:在原系统里没有,这里暂时留着) */
  130 + private Boolean sfmix;
  131 + /** 是否氢能源车 */
  132 + private Boolean hydrogen;
  133 + /** 备注/描述 */
  134 + private String descriptions;
  135 +
  136 + /** 车辆序号(TODO:在原系统里没有,这里暂时留着) */
  137 + private String carOrdinal;
  138 + /** 视频编号 */
  139 + private String videoCode;
  140 + /** 是否报废 */
  141 + @Column(nullable = true)
  142 + private Boolean scrapState;
  143 + /** 是否切换(TODO:在原系统里没有,这里暂时留着)*/
  144 + private Integer isSwitch;
  145 + /** 线路名称(TODO:在原系统里没有,这里暂时留着,并且不做线路关联,只保留个名字) */
  146 + private String xlmc;
  147 +
  148 + /**
  149 + * 终端sim号
  150 + */
  151 + private String sim;
  152 +
  153 + public Cars() {}
  154 +
  155 + public Cars(Object id, Object nbbh, Object clbh, Object cph, Object sbbh) {
  156 + if (id != null) {
  157 + this.id = Integer.valueOf(id.toString());
  158 + }
  159 + if (nbbh != null) {
  160 + this.insideCode = nbbh.toString();
  161 + }
  162 + if (clbh != null) {
  163 + this.carCode = clbh.toString();
  164 + }
  165 + if (cph != null) {
  166 + this.carPlate = cph.toString();
  167 + }
  168 + if (sbbh != null) {
  169 + this.equipmentCode = sbbh.toString();
  170 + }
  171 + }
  172 +
  173 + public String getServiceNo() {
  174 + return serviceNo;
  175 + }
  176 +
  177 + public void setServiceNo(String serviceNo) {
  178 + this.serviceNo = serviceNo;
  179 + }
  180 +
  181 + public Integer getId() {
  182 + return id;
  183 + }
  184 +
  185 + public void setId(Integer id) {
  186 + this.id = id;
  187 + }
  188 +
  189 + public String getInsideCode() {
  190 + return insideCode;
  191 + }
  192 +
  193 + public void setInsideCode(String insideCode) {
  194 + this.insideCode = insideCode;
  195 + }
  196 +
  197 + public String getBusinessCode() {
  198 + return businessCode;
  199 + }
  200 +
  201 + public void setBusinessCode(String businessCode) {
  202 + this.businessCode = businessCode;
  203 + }
  204 +
  205 + public String getCompany() {
  206 + return company;
  207 + }
  208 +
  209 + public void setCompany(String company) {
  210 + this.company = company;
  211 + }
  212 +
  213 + public String getBrancheCompanyCode() {
  214 + return brancheCompanyCode;
  215 + }
  216 +
  217 + public void setBrancheCompanyCode(String brancheCompanyCode) {
  218 + this.brancheCompanyCode = brancheCompanyCode;
  219 + }
  220 +
  221 + public String getBrancheCompany() {
  222 + return brancheCompany;
  223 + }
  224 +
  225 + public void setBrancheCompany(String brancheCompany) {
  226 + this.brancheCompany = brancheCompany;
  227 + }
  228 +
  229 + public String getCarCode() {
  230 + return carCode;
  231 + }
  232 +
  233 + public void setCarCode(String carCode) {
  234 + this.carCode = carCode;
  235 + }
  236 +
  237 + public String getCarPlate() {
  238 + return carPlate;
  239 + }
  240 +
  241 + public void setCarPlate(String carPlate) {
  242 + this.carPlate = carPlate;
  243 + }
  244 +
  245 + public String getSupplierName() {
  246 + return supplierName;
  247 + }
  248 +
  249 + public void setSupplierName(String supplierName) {
  250 + this.supplierName = supplierName;
  251 + }
  252 +
  253 + public String getEquipmentCode() {
  254 + return equipmentCode;
  255 + }
  256 +
  257 + public void setEquipmentCode(String equipmentCode) {
  258 + this.equipmentCode = equipmentCode;
  259 + }
  260 +
  261 + public String getCarClass() {
  262 + return carClass;
  263 + }
  264 +
  265 + public void setCarClass(String carClass) {
  266 + this.carClass = carClass;
  267 + }
  268 +
  269 + public Double getSpeed() {
  270 + return speed;
  271 + }
  272 +
  273 + public void setSpeed(Double speed) {
  274 + this.speed = speed;
  275 + }
  276 +
  277 + public Integer getCarSeatnNumber() {
  278 + return carSeatnNumber;
  279 + }
  280 +
  281 + public void setCarSeatnNumber(Integer carSeatnNumber) {
  282 + this.carSeatnNumber = carSeatnNumber;
  283 + }
  284 +
  285 + public String getCarStandard() {
  286 + return carStandard;
  287 + }
  288 +
  289 + public void setCarStandard(String carStandard) {
  290 + this.carStandard = carStandard;
  291 + }
  292 +
  293 + public Double getKburnStandard() {
  294 + return kburnStandard;
  295 + }
  296 +
  297 + public void setKburnStandard(Double kburnStandard) {
  298 + this.kburnStandard = kburnStandard;
  299 + }
  300 +
  301 + public Double getGburnStandard() {
  302 + return gburnStandard;
  303 + }
  304 +
  305 + public void setGburnStandard(Double gburnStandard) {
  306 + this.gburnStandard = gburnStandard;
  307 + }
  308 +
  309 + public String getScrapCode() {
  310 + return scrapCode;
  311 + }
  312 +
  313 + public void setScrapCode(String scrapCode) {
  314 + this.scrapCode = scrapCode;
  315 + }
  316 +
  317 + public Date getScrapDate() {
  318 + return scrapDate;
  319 + }
  320 +
  321 + public void setScrapDate(Date scrapDate) {
  322 + this.scrapDate = scrapDate;
  323 + }
  324 +
  325 + public String getMakeCodeOne() {
  326 + return makeCodeOne;
  327 + }
  328 +
  329 + public void setMakeCodeOne(String makeCodeOne) {
  330 + this.makeCodeOne = makeCodeOne;
  331 + }
  332 +
  333 + public String getMakeCodeTwo() {
  334 + return makeCodeTwo;
  335 + }
  336 +
  337 + public void setMakeCodeTwo(String makeCodeTwo) {
  338 + this.makeCodeTwo = makeCodeTwo;
  339 + }
  340 +
  341 + public String getCarGride() {
  342 + return carGride;
  343 + }
  344 +
  345 + public void setCarGride(String carGride) {
  346 + this.carGride = carGride;
  347 + }
  348 +
  349 + public String getEmissionsStandard() {
  350 + return emissionsStandard;
  351 + }
  352 +
  353 + public void setEmissionsStandard(String emissionsStandard) {
  354 + this.emissionsStandard = emissionsStandard;
  355 + }
  356 +
  357 + public String getEngineCodeOne() {
  358 + return engineCodeOne;
  359 + }
  360 +
  361 + public void setEngineCodeOne(String engineCodeOne) {
  362 + this.engineCodeOne = engineCodeOne;
  363 + }
  364 +
  365 + public String getEngineCodeTwo() {
  366 + return engineCodeTwo;
  367 + }
  368 +
  369 + public void setEngineCodeTwo(String engineCodeTwo) {
  370 + this.engineCodeTwo = engineCodeTwo;
  371 + }
  372 +
  373 + public String getCarNumberOne() {
  374 + return carNumberOne;
  375 + }
  376 +
  377 + public void setCarNumberOne(String carNumberOne) {
  378 + this.carNumberOne = carNumberOne;
  379 + }
  380 +
  381 + public String getCarNumberTwo() {
  382 + return carNumberTwo;
  383 + }
  384 +
  385 + public void setCarNumberTwo(String carNumberTwo) {
  386 + this.carNumberTwo = carNumberTwo;
  387 + }
  388 +
  389 + public Date getOpenDate() {
  390 + return openDate;
  391 + }
  392 +
  393 + public void setOpenDate(Date openDate) {
  394 + this.openDate = openDate;
  395 + }
  396 +
  397 + public Date getCloseDate() {
  398 + return closeDate;
  399 + }
  400 +
  401 + public void setCloseDate(Date closeDate) {
  402 + this.closeDate = closeDate;
  403 + }
  404 +
  405 + public Boolean getHvacCar() {
  406 + return hvacCar;
  407 + }
  408 +
  409 + public void setHvacCar(Boolean hvacCar) {
  410 + this.hvacCar = hvacCar;
  411 + }
  412 +
  413 + public Boolean getTicketType() {
  414 + return ticketType;
  415 + }
  416 +
  417 + public void setTicketType(Boolean ticketType) {
  418 + this.ticketType = ticketType;
  419 + }
  420 +
  421 + public Boolean getLedScreen() {
  422 + return ledScreen;
  423 + }
  424 +
  425 + public void setLedScreen(Boolean ledScreen) {
  426 + this.ledScreen = ledScreen;
  427 + }
  428 +
  429 + public Boolean getTvVideoType() {
  430 + return tvVideoType;
  431 + }
  432 +
  433 + public void setTvVideoType(Boolean tvVideoType) {
  434 + this.tvVideoType = tvVideoType;
  435 + }
  436 +
  437 + public String getCarType() {
  438 + return carType;
  439 + }
  440 +
  441 + public void setCarType(String carType) {
  442 + this.carType = carType;
  443 + }
  444 +
  445 + public String getVehicleStats() {
  446 + return vehicleStats;
  447 + }
  448 +
  449 + public void setVehicleStats(String vehicleStats) {
  450 + this.vehicleStats = vehicleStats;
  451 + }
  452 +
  453 + public String getOperatorsState() {
  454 + return operatorsState;
  455 + }
  456 +
  457 + public void setOperatorsState(String operatorsState) {
  458 + this.operatorsState = operatorsState;
  459 + }
  460 +
  461 + public Boolean getSfdc() {
  462 + return sfdc;
  463 + }
  464 +
  465 + public void setSfdc(Boolean sfdc) {
  466 + this.sfdc = sfdc;
  467 + }
  468 +
  469 + public String getDescriptions() {
  470 + return descriptions;
  471 + }
  472 +
  473 + public void setDescriptions(String descriptions) {
  474 + this.descriptions = descriptions;
  475 + }
  476 +
  477 + public String getCarOrdinal() {
  478 + return carOrdinal;
  479 + }
  480 +
  481 + public void setCarOrdinal(String carOrdinal) {
  482 + this.carOrdinal = carOrdinal;
  483 + }
  484 +
  485 + public String getVideoCode() {
  486 + return videoCode;
  487 + }
  488 +
  489 + public void setVideoCode(String videoCode) {
  490 + this.videoCode = videoCode;
  491 + }
  492 +
  493 + public Boolean getScrapState() {
  494 + return scrapState;
  495 + }
  496 +
  497 + public void setScrapState(Boolean scrapState) {
  498 + this.scrapState = scrapState;
  499 + }
  500 +
  501 + public Integer getIsSwitch() {
  502 + return isSwitch;
  503 + }
  504 +
  505 + public void setIsSwitch(Integer isSwitch) {
  506 + this.isSwitch = isSwitch;
  507 + }
  508 +
  509 + public String getXlmc() {
  510 + return xlmc;
  511 + }
  512 +
  513 + public void setXlmc(String xlmc) {
  514 + this.xlmc = xlmc;
  515 + }
  516 +
  517 + public String getCgsbm() {
  518 + return cgsbm;
  519 + }
  520 +
  521 + public void setCgsbm(String cgsbm) {
  522 + this.cgsbm = cgsbm;
  523 + }
  524 +
  525 + public Boolean getSfmix() {
  526 + return sfmix;
  527 + }
  528 +
  529 + public void setSfmix(Boolean sfmix) {
  530 + this.sfmix = sfmix;
  531 + }
  532 +
  533 + public Boolean getHydrogen() {
  534 + return hydrogen;
  535 + }
  536 +
  537 + public void setHydrogen(Boolean hydrogen) {
  538 + this.hydrogen = hydrogen;
  539 + }
  540 +
  541 + public String getSim() {
  542 + return sim;
  543 + }
  544 +
  545 + public void setSim(String sim) {
  546 + this.sim = sim;
  547 + }
  548 +}
src/main/java/com/bsth/message/entity/AlarmADASVo.java 0 → 100644
  1 +package com.bsth.message.entity;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +
  5 +import java.util.ArrayList;
  6 +import java.util.List;
  7 +
  8 +@JsonIgnoreProperties(ignoreUnknown = true)
  9 +public class AlarmADASVo implements AlarmVo {
  10 +
  11 + private String clientId;
  12 +
  13 + /**
  14 + * 车辆编码(内部编码)
  15 + */
  16 + private String vehicleCode;
  17 +
  18 + /**
  19 + * 设备号
  20 + */
  21 + private String deviceId;
  22 +
  23 + /**
  24 + * 车牌号
  25 + */
  26 + private String vehiclePlate;
  27 +
  28 + /**
  29 + * 报警ID
  30 + */
  31 + private String alarmId;
  32 +
  33 + /**
  34 + * 报警/事件类型
  35 + * 0x01:前向碰撞报警
  36 + * 0x02:车道偏离报警
  37 + * 0x03:车距过近报警
  38 + * 0x04:行人碰撞报警
  39 + * 0x05:频繁变道报警
  40 + * 0x06:道路标识超限报警
  41 + * 0x07:障碍物报警
  42 + * 0x08~0x0F:用户自定义
  43 + * 0x10:道路标志识别事件
  44 + * 0x11:主动抓拍事件
  45 + * 0x12~0x1F:用户自定义
  46 + */
  47 + private int type;
  48 +
  49 + /**
  50 + * 报警级别
  51 + * 0x01 一级报警
  52 + * 0x02 二级报警
  53 + */
  54 + private int level;
  55 +
  56 + /**
  57 + * 前车车速(Km/h)范围0~250,仅报警类型为1和2时有效
  58 + */
  59 + private int frontSpeed;
  60 +
  61 + /**
  62 + * 前车/行人距离(100ms),范围0~100,仅报警类型为1、2和4时有效
  63 + */
  64 + private int frontDistance;
  65 +
  66 + /**
  67 + * 偏离类型:1.左侧偏离 2.右侧偏离(报警类型为2时有效)
  68 + */
  69 + private int deviateType;
  70 +
  71 + /**
  72 + * 道路标志识别类型:1.限速标志 2.限高标志 3.限重标志(报警类型为6和10时有效)
  73 + */
  74 + private int roadSign;
  75 +
  76 + /**
  77 + * 道路标志识别数据
  78 + */
  79 + private int roadSignValue;
  80 +
  81 + /**
  82 + * 车速
  83 + */
  84 + private int speed;
  85 +
  86 + /**
  87 + * 高程
  88 + */
  89 + private int altitude;
  90 +
  91 + /**
  92 + * 纬度
  93 + */
  94 + private int latitude;
  95 +
  96 + /**
  97 + * 经度
  98 + */
  99 + private int longitude;
  100 +
  101 + /**
  102 + * 日期时间(ms)
  103 + */
  104 + private long alarmTimeBegin;
  105 +
  106 + /**
  107 + * 日期时间(ms)
  108 + */
  109 + private long alarmTimeEnd;
  110 +
  111 + /**
  112 + * 车辆状态
  113 + */
  114 + private int statusBit;
  115 +
  116 + /**
  117 + * 附件path
  118 + */
  119 + private List<String> paths = new ArrayList<>();
  120 +
  121 + private String lineCode;
  122 +
  123 + public String getClientId() {
  124 + return clientId;
  125 + }
  126 +
  127 + public void setClientId(String clientId) {
  128 + this.clientId = clientId;
  129 + }
  130 +
  131 + public String getVehicleCode() {
  132 + return vehicleCode;
  133 + }
  134 +
  135 + public void setVehicleCode(String vehicleCode) {
  136 + this.vehicleCode = vehicleCode;
  137 + }
  138 +
  139 + public String getDeviceId() {
  140 + return deviceId;
  141 + }
  142 +
  143 + public void setDeviceId(String deviceId) {
  144 + this.deviceId = deviceId;
  145 + }
  146 +
  147 + public String getVehiclePlate() {
  148 + return vehiclePlate;
  149 + }
  150 +
  151 + public void setVehiclePlate(String vehiclePlate) {
  152 + this.vehiclePlate = vehiclePlate;
  153 + }
  154 +
  155 + public String getAlarmId() {
  156 + return alarmId;
  157 + }
  158 +
  159 + public void setAlarmId(String alarmId) {
  160 + this.alarmId = alarmId;
  161 + }
  162 +
  163 + public int getType() {
  164 + return type;
  165 + }
  166 +
  167 + public void setType(int type) {
  168 + this.type = type;
  169 + }
  170 +
  171 + public int getLevel() {
  172 + return level;
  173 + }
  174 +
  175 + public void setLevel(int level) {
  176 + this.level = level;
  177 + }
  178 +
  179 + public int getFrontSpeed() {
  180 + return frontSpeed;
  181 + }
  182 +
  183 + public void setFrontSpeed(int frontSpeed) {
  184 + this.frontSpeed = frontSpeed;
  185 + }
  186 +
  187 + public int getFrontDistance() {
  188 + return frontDistance;
  189 + }
  190 +
  191 + public void setFrontDistance(int frontDistance) {
  192 + this.frontDistance = frontDistance;
  193 + }
  194 +
  195 + public int getDeviateType() {
  196 + return deviateType;
  197 + }
  198 +
  199 + public void setDeviateType(int deviateType) {
  200 + this.deviateType = deviateType;
  201 + }
  202 +
  203 + public int getRoadSign() {
  204 + return roadSign;
  205 + }
  206 +
  207 + public void setRoadSign(int roadSign) {
  208 + this.roadSign = roadSign;
  209 + }
  210 +
  211 + public int getRoadSignValue() {
  212 + return roadSignValue;
  213 + }
  214 +
  215 + public void setRoadSignValue(int roadSignValue) {
  216 + this.roadSignValue = roadSignValue;
  217 + }
  218 +
  219 + public int getSpeed() {
  220 + return speed;
  221 + }
  222 +
  223 + public void setSpeed(int speed) {
  224 + this.speed = speed;
  225 + }
  226 +
  227 + public int getAltitude() {
  228 + return altitude;
  229 + }
  230 +
  231 + public void setAltitude(int altitude) {
  232 + this.altitude = altitude;
  233 + }
  234 +
  235 + public int getLatitude() {
  236 + return latitude;
  237 + }
  238 +
  239 + public void setLatitude(int latitude) {
  240 + this.latitude = latitude;
  241 + }
  242 +
  243 + public int getLongitude() {
  244 + return longitude;
  245 + }
  246 +
  247 + public void setLongitude(int longitude) {
  248 + this.longitude = longitude;
  249 + }
  250 +
  251 + public long getAlarmTimeBegin() {
  252 + return alarmTimeBegin;
  253 + }
  254 +
  255 + public void setAlarmTimeBegin(long alarmTimeBegin) {
  256 + this.alarmTimeBegin = alarmTimeBegin;
  257 + }
  258 +
  259 + public long getAlarmTimeEnd() {
  260 + return alarmTimeEnd;
  261 + }
  262 +
  263 + public void setAlarmTimeEnd(long alarmTimeEnd) {
  264 + this.alarmTimeEnd = alarmTimeEnd;
  265 + }
  266 +
  267 + public int getStatusBit() {
  268 + return statusBit;
  269 + }
  270 +
  271 + public void setStatusBit(int statusBit) {
  272 + this.statusBit = statusBit;
  273 + }
  274 +
  275 + public List<String> getPaths() {
  276 + return paths;
  277 + }
  278 +
  279 + public void setPaths(List<String> paths) {
  280 + this.paths = paths;
  281 + }
  282 +
  283 + public String getAlarmType() {
  284 + return "adas";
  285 + }
  286 +
  287 + public String getLineCode() {
  288 + return lineCode;
  289 + }
  290 +
  291 + @Override
  292 + public void setLineCode(String lineCode) {
  293 + this.lineCode = lineCode;
  294 + }
  295 +
  296 + @Override
  297 + public int hashCode() {
  298 + return String.format("%s_%d_%d", this.clientId, this.alarmTimeBegin, this.type).hashCode();
  299 + }
  300 +
  301 + @Override
  302 + public boolean equals(Object obj) {
  303 + AlarmADASVo other = (AlarmADASVo) obj;
  304 +
  305 + return this.clientId.equals(other.getClientId()) && this.alarmTimeBegin == other.getAlarmTimeBegin() && this.type == other.getType();
  306 + }
  307 +
  308 + @Override
  309 + public String toString() {
  310 + return "AlarmADASVo{" +
  311 + "clientId='" + clientId + '\'' +
  312 + ", vehicleCode='" + vehicleCode + '\'' +
  313 + ", deviceId='" + deviceId + '\'' +
  314 + ", vehiclePlate='" + vehiclePlate + '\'' +
  315 + ", alarmId='" + alarmId + '\'' +
  316 + ", type=" + type +
  317 + ", level=" + level +
  318 + ", frontSpeed=" + frontSpeed +
  319 + ", frontDistance=" + frontDistance +
  320 + ", deviateType=" + deviateType +
  321 + ", roadSign=" + roadSign +
  322 + ", roadSignValue=" + roadSignValue +
  323 + ", speed=" + speed +
  324 + ", altitude=" + altitude +
  325 + ", latitude=" + latitude +
  326 + ", longitude=" + longitude +
  327 + ", alarmTimeBegin=" + alarmTimeBegin +
  328 + ", alarmTimeEnd=" + alarmTimeEnd +
  329 + ", statusBit=" + statusBit +
  330 + ", paths=" + paths +
  331 + '}';
  332 + }
  333 +}
0 \ No newline at end of file 334 \ No newline at end of file
src/main/java/com/bsth/message/entity/AlarmDSMVo.java 0 → 100644
  1 +package com.bsth.message.entity;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +
  5 +import java.util.ArrayList;
  6 +import java.util.List;
  7 +
  8 +@JsonIgnoreProperties(ignoreUnknown = true)
  9 +public class AlarmDSMVo implements AlarmVo {
  10 +
  11 + private String clientId;
  12 +
  13 + /**
  14 + * 车辆编码(内部编码)
  15 + */
  16 + private String vehicleCode;
  17 +
  18 + /**
  19 + * 设备号
  20 + */
  21 + private String deviceId;
  22 +
  23 + /**
  24 + * 车牌号
  25 + */
  26 + private String vehiclePlate;
  27 +
  28 + /**
  29 + * 报警ID
  30 + */
  31 + private String alarmId;
  32 +
  33 + /**
  34 + * 报警/事件类型
  35 + * 0x01:疲劳驾驶报警
  36 + * 0x02:接打电话报警
  37 + * 0x03:抽烟报警
  38 + * 0x04:分神驾驶报警
  39 + * 0x05:驾驶员异常报警
  40 + * 0x06~0x0F:用户自定义
  41 + * 0x10:自动抓拍事件
  42 + * 0x11:驾驶员变更事件
  43 + * 0x12~0x1F:用户自定义
  44 + */
  45 + private int type;
  46 +
  47 + /**
  48 + * 报警级别
  49 + * 0x01 一级报警
  50 + * 0x02 二级报警
  51 + */
  52 + private int level;
  53 +
  54 + /**
  55 + * 疲劳程度
  56 + */
  57 + private int fatigueDegree;
  58 +
  59 + /**
  60 + * 预留
  61 + */
  62 + private int reserves;
  63 +
  64 + /**
  65 + * 车速
  66 + */
  67 + private int speed;
  68 +
  69 + /**
  70 + * 高程
  71 + */
  72 + private int altitude;
  73 +
  74 + /**
  75 + * 纬度
  76 + */
  77 + private int latitude;
  78 +
  79 + /**
  80 + * 经度
  81 + */
  82 + private int longitude;
  83 +
  84 + /**
  85 + * 警报开始时间
  86 + */
  87 + private long alarmTimeBegin;
  88 +
  89 + /**
  90 + * 警报结束时间
  91 + */
  92 + private long alarmTimeEnd;
  93 +
  94 + /**
  95 + * 车辆状态
  96 + */
  97 + private int statusBit;
  98 +
  99 + /**
  100 + * 附件path
  101 + */
  102 + private List<String> paths = new ArrayList<>();
  103 +
  104 + private String lineCode;
  105 +
  106 + public String getClientId() {
  107 + return clientId;
  108 + }
  109 +
  110 + public void setClientId(String clientId) {
  111 + this.clientId = clientId;
  112 + }
  113 +
  114 + public String getVehicleCode() {
  115 + return vehicleCode;
  116 + }
  117 +
  118 + public void setVehicleCode(String vehicleCode) {
  119 + this.vehicleCode = vehicleCode;
  120 + }
  121 +
  122 + public String getDeviceId() {
  123 + return deviceId;
  124 + }
  125 +
  126 + public void setDeviceId(String deviceId) {
  127 + this.deviceId = deviceId;
  128 + }
  129 +
  130 + public String getVehiclePlate() {
  131 + return vehiclePlate;
  132 + }
  133 +
  134 + public void setVehiclePlate(String vehiclePlate) {
  135 + this.vehiclePlate = vehiclePlate;
  136 + }
  137 +
  138 + public List<String> getPaths() {
  139 + return paths;
  140 + }
  141 +
  142 + public void setPaths(List<String> paths) {
  143 + this.paths = paths;
  144 + }
  145 +
  146 + public String getAlarmId() {
  147 + return alarmId;
  148 + }
  149 +
  150 + public void setAlarmId(String alarmId) {
  151 + this.alarmId = alarmId;
  152 + }
  153 +
  154 + public int getType() {
  155 + return type;
  156 + }
  157 +
  158 + public void setType(int type) {
  159 + this.type = type;
  160 + }
  161 +
  162 + public int getLevel() {
  163 + return level;
  164 + }
  165 +
  166 + public void setLevel(int level) {
  167 + this.level = level;
  168 + }
  169 +
  170 + public int getFatigueDegree() {
  171 + return fatigueDegree;
  172 + }
  173 +
  174 + public void setFatigueDegree(int fatigueDegree) {
  175 + this.fatigueDegree = fatigueDegree;
  176 + }
  177 +
  178 + public int getReserves() {
  179 + return reserves;
  180 + }
  181 +
  182 + public void setReserves(int reserves) {
  183 + this.reserves = reserves;
  184 + }
  185 +
  186 + public int getSpeed() {
  187 + return speed;
  188 + }
  189 +
  190 + public void setSpeed(int speed) {
  191 + this.speed = speed;
  192 + }
  193 +
  194 + public int getAltitude() {
  195 + return altitude;
  196 + }
  197 +
  198 + public void setAltitude(int altitude) {
  199 + this.altitude = altitude;
  200 + }
  201 +
  202 + public int getLatitude() {
  203 + return latitude;
  204 + }
  205 +
  206 + public void setLatitude(int latitude) {
  207 + this.latitude = latitude;
  208 + }
  209 +
  210 + public int getLongitude() {
  211 + return longitude;
  212 + }
  213 +
  214 + public void setLongitude(int longitude) {
  215 + this.longitude = longitude;
  216 + }
  217 +
  218 + public long getAlarmTimeBegin() {
  219 + return alarmTimeBegin;
  220 + }
  221 +
  222 + public void setAlarmTimeBegin(long alarmTimeBegin) {
  223 + this.alarmTimeBegin = alarmTimeBegin;
  224 + }
  225 +
  226 + public long getAlarmTimeEnd() {
  227 + return alarmTimeEnd;
  228 + }
  229 +
  230 + public void setAlarmTimeEnd(long alarmTimeEnd) {
  231 + this.alarmTimeEnd = alarmTimeEnd;
  232 + }
  233 +
  234 + public int getStatusBit() {
  235 + return statusBit;
  236 + }
  237 +
  238 + public void setStatusBit(int statusBit) {
  239 + this.statusBit = statusBit;
  240 + }
  241 +
  242 + public String getAlarmType() {
  243 + return "dsm";
  244 + }
  245 +
  246 + public String getLineCode() {
  247 + return lineCode;
  248 + }
  249 +
  250 + @Override
  251 + public void setLineCode(String lineCode) {
  252 + this.lineCode = lineCode;
  253 + }
  254 +
  255 + @Override
  256 + public int hashCode() {
  257 + return String.format("%s_%d_%d", this.clientId, this.alarmTimeBegin, this.type).hashCode();
  258 + }
  259 +
  260 + @Override
  261 + public boolean equals(Object obj) {
  262 + AlarmDSMVo other = (AlarmDSMVo) obj;
  263 +
  264 + return this.clientId.equals(other.getClientId()) && this.alarmTimeBegin == other.getAlarmTimeBegin() && this.type == other.getType();
  265 + }
  266 +
  267 + @Override
  268 + public String toString() {
  269 + return "AlarmDSMVo{" +
  270 + "clientId='" + clientId + '\'' +
  271 + ", vehicleCode='" + vehicleCode + '\'' +
  272 + ", deviceId='" + deviceId + '\'' +
  273 + ", vehiclePlate='" + vehiclePlate + '\'' +
  274 + ", alarmId='" + alarmId + '\'' +
  275 + ", type=" + type +
  276 + ", level=" + level +
  277 + ", fatigueDegree=" + fatigueDegree +
  278 + ", reserves=" + reserves +
  279 + ", speed=" + speed +
  280 + ", altitude=" + altitude +
  281 + ", latitude=" + latitude +
  282 + ", longitude=" + longitude +
  283 + ", alarmTimeBegin=" + alarmTimeBegin +
  284 + ", alarmTimeEnd=" + alarmTimeEnd +
  285 + ", statusBit=" + statusBit +
  286 + ", paths=" + paths +
  287 + '}';
  288 + }
  289 +}
0 \ No newline at end of file 290 \ No newline at end of file
src/main/java/com/bsth/message/entity/AlarmVo.java 0 → 100644
  1 +package com.bsth.message.entity;
  2 +
  3 +public interface AlarmVo {
  4 +
  5 + String getVehicleCode();
  6 +
  7 + String getAlarmType();
  8 +
  9 + String getAlarmId();
  10 +
  11 + String getLineCode();
  12 +
  13 + void setLineCode(String lineCode);
  14 +}
src/main/java/com/bsth/message/handler/MessageHandler.java renamed to src/main/java/com/bsth/message/handler/KafkaMessageHandler.java
1 package com.bsth.message.handler; 1 package com.bsth.message.handler;
2 2
  3 +import com.bsth.data.gpsdata_v2.GpsRealData;
3 import com.bsth.message.buffer.CarEnergyBuffer; 4 import com.bsth.message.buffer.CarEnergyBuffer;
4 -import com.bsth.message.entity.CarEnergy;  
5 -import com.bsth.message.entity.CarErrorStop;  
6 -import com.bsth.message.entity.InoutPark; 5 +import com.bsth.message.entity.*;
7 import com.bsth.websocket.handler.SendUtils; 6 import com.bsth.websocket.handler.SendUtils;
8 import com.fasterxml.jackson.databind.ObjectMapper; 7 import com.fasterxml.jackson.databind.ObjectMapper;
9 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,7 +19,7 @@ import java.util.List; @@ -20,7 +19,7 @@ import java.util.List;
20 */ 19 */
21 @Component 20 @Component
22 @ConditionalOnProperty("kafka.use") 21 @ConditionalOnProperty("kafka.use")
23 -public class MessageHandler { 22 +public class KafkaMessageHandler {
24 23
25 @Autowired 24 @Autowired
26 private SendUtils sendUtils; 25 private SendUtils sendUtils;
@@ -28,6 +27,9 @@ public class MessageHandler { @@ -28,6 +27,9 @@ public class MessageHandler {
28 @Autowired 27 @Autowired
29 private ObjectMapper mapper; 28 private ObjectMapper mapper;
30 29
  30 + @Autowired
  31 + GpsRealData gpsRealData;
  32 +
31 @KafkaListener(topics="schedule-main-carerrorstop") 33 @KafkaListener(topics="schedule-main-carerrorstop")
32 public void receivedCarErrorStop(Message<String> message) { 34 public void receivedCarErrorStop(Message<String> message) {
33 try { 35 try {
src/main/java/com/bsth/message/handler/RabbitMessageHandler.java 0 → 100644
  1 +package com.bsth.message.handler;
  2 +
  3 +import com.bsth.config.RabbitConfig;
  4 +import com.bsth.data.alarm.AlarmCenter;
  5 +import com.bsth.data.gpsdata_v2.GpsRealData;
  6 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  7 +import com.bsth.message.entity.*;
  8 +import com.bsth.websocket.handler.SendUtils;
  9 +import com.fasterxml.jackson.databind.ObjectMapper;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.amqp.rabbit.annotation.RabbitHandler;
  13 +import org.springframework.amqp.rabbit.annotation.RabbitListener;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  16 +import org.springframework.stereotype.Component;
  17 +
  18 +import java.util.HashMap;
  19 +import java.util.Map;
  20 +
  21 +/**
  22 + * @author Hill
  23 + */
  24 +@Component
  25 +@ConditionalOnProperty("rabbit.use")
  26 +public class RabbitMessageHandler {
  27 +
  28 + private final static Logger log = LoggerFactory.getLogger(RabbitMessageHandler.class);
  29 +
  30 + @Autowired
  31 + private SendUtils sendUtils;
  32 +
  33 + @Autowired
  34 + private ObjectMapper mapper;
  35 +
  36 + @Autowired
  37 + GpsRealData gpsRealData;
  38 +
  39 + @RabbitHandler
  40 + @RabbitListener(queues = RabbitConfig.QUEUE_ALARM_SCHEDULE)
  41 + public void onAlarmScheduleMessage(String message) {
  42 + try {
  43 + AlarmVo alarmVo = null;
  44 + Map<String, Object> data = mapper.readValue(message, mapper.getTypeFactory().constructMapType(HashMap.class, String.class, Object.class));
  45 + if ("dsm".equals(data.get("alarmType"))) {
  46 + alarmVo = mapper.readValue(message, AlarmDSMVo.class);
  47 + } else if ("adas".equals(data.get("alarmType"))) {
  48 + alarmVo = mapper.readValue(message, AlarmADASVo.class);
  49 + }
  50 + if (alarmVo != null) {
  51 + GpsEntity gps = gpsRealData.getByNbbm(alarmVo.getVehicleCode());
  52 + if (gps == null || gps.getLineId() == null) {
  53 + alarmVo.setLineCode("249231");
  54 + } else {
  55 + alarmVo.setLineCode(gps.getLineId());
  56 + }
  57 + AlarmCenter.put(alarmVo);
  58 + }
  59 + } catch (Exception e) {
  60 + log.error("报警监听异常,message: {}", message, e);
  61 + }
  62 + }
  63 +}
src/main/java/com/bsth/service/alarm/AlarmAdasService.java 0 → 100644
  1 +package com.bsth.service.alarm;
  2 +
  3 +import com.bsth.message.entity.AlarmADASVo;
  4 +
  5 +import java.util.List;
  6 +import java.util.Map;
  7 +
  8 +public interface AlarmAdasService {
  9 +
  10 + List<AlarmADASVo> list(Map<String, String> map, int page, int size, String order, int direction);
  11 +}
src/main/java/com/bsth/service/alarm/AlarmDsmService.java 0 → 100644
  1 +package com.bsth.service.alarm;
  2 +
  3 +import com.bsth.message.entity.AlarmDSMVo;
  4 +
  5 +import java.util.List;
  6 +import java.util.Map;
  7 +
  8 +public interface AlarmDsmService {
  9 +
  10 + List<AlarmDSMVo> list(Map<String, String> map, int page, int size, String order, int direction);
  11 +}
src/main/java/com/bsth/service/alarm/impl/AlarmAdasServiceImpl.java 0 → 100644
  1 +package com.bsth.service.alarm.impl;
  2 +
  3 +import com.bsth.data.alarm.AlarmCenter;
  4 +import com.bsth.message.entity.AlarmADASVo;
  5 +import com.bsth.service.alarm.AlarmAdasService;
  6 +import com.fasterxml.jackson.databind.ObjectMapper;
  7 +import org.springframework.stereotype.Service;
  8 +import org.springframework.util.StringUtils;
  9 +
  10 +import java.lang.reflect.Field;
  11 +import java.util.ArrayList;
  12 +import java.util.List;
  13 +import java.util.Map;
  14 +
  15 +@Service
  16 +public class AlarmAdasServiceImpl implements AlarmAdasService {
  17 + @Override
  18 + public List<AlarmADASVo> list(Map<String, String> map, int page, int size, String order, int direction) {
  19 + List<AlarmADASVo> alarmAdasVoList = new ArrayList<>();
  20 + for (AlarmADASVo alarmADASVo : AlarmCenter.findAllAdas()) {
  21 + try {
  22 + if (filter(alarmADASVo, map)) {
  23 + alarmAdasVoList.add(alarmADASVo);
  24 + }
  25 + } catch (NoSuchFieldException e) {
  26 + throw new RuntimeException(e);
  27 + } catch (IllegalAccessException e) {
  28 + throw new RuntimeException(e);
  29 + }
  30 + }
  31 +
  32 + return alarmAdasVoList;
  33 + }
  34 +
  35 + private boolean filter(Object obj, Map<String, String> param) throws NoSuchFieldException, IllegalAccessException {
  36 + boolean result = true;
  37 + ObjectMapper mapper = new ObjectMapper();
  38 + if (param.get("lines") != null) {
  39 + AlarmADASVo alarmADASVo = (AlarmADASVo) obj;
  40 + if (param.get("lines").toString().indexOf(String.format("%s,", alarmADASVo.getLineCode())) < 0) {
  41 + return false;
  42 + }
  43 +
  44 + AlarmADASVo other = mapper.convertValue(param, AlarmADASVo.class);
  45 + Field[] fields = obj.getClass().getDeclaredFields();
  46 + for (Map.Entry<String, String> entry : param.entrySet()) {
  47 + String key = entry.getKey(), val = entry.getValue();
  48 + if (StringUtils.isEmpty(val)) {
  49 + continue;
  50 + }
  51 +
  52 + for (Field field : fields) {
  53 + if (field.getName().equals(key)) {
  54 + field.setAccessible(true);
  55 + Object fv1 = field.get(obj), fv2 = field.get(other);
  56 + if (!fv2.equals(fv1)) {
  57 + return false;
  58 + }
  59 + }
  60 + }
  61 + }
  62 + } else {
  63 + result = false;
  64 + }
  65 +
  66 + return result;
  67 + }
  68 +}
src/main/java/com/bsth/service/alarm/impl/AlarmDsmServiceImpl.java 0 → 100644
  1 +package com.bsth.service.alarm.impl;
  2 +
  3 +import com.bsth.data.alarm.AlarmCenter;
  4 +import com.bsth.message.entity.AlarmADASVo;
  5 +import com.bsth.message.entity.AlarmDSMVo;
  6 +import com.bsth.service.alarm.AlarmDsmService;
  7 +import com.fasterxml.jackson.databind.ObjectMapper;
  8 +import org.springframework.stereotype.Service;
  9 +import org.springframework.util.StringUtils;
  10 +
  11 +import java.lang.reflect.Field;
  12 +import java.util.*;
  13 +
  14 +@Service
  15 +public class AlarmDsmServiceImpl implements AlarmDsmService {
  16 + @Override
  17 + public List<AlarmDSMVo> list(Map<String, String> map, int page, int size, String order, int direction) {
  18 + List<AlarmDSMVo> alarmDSMVoList = new ArrayList<>();
  19 + for (AlarmDSMVo alarmDSMVo : AlarmCenter.findAllDsm()) {
  20 + try {
  21 + if (filter(alarmDSMVo, map)) {
  22 + alarmDSMVoList.add(alarmDSMVo);
  23 + }
  24 + } catch (NoSuchFieldException e) {
  25 + throw new RuntimeException(e);
  26 + } catch (IllegalAccessException e) {
  27 + throw new RuntimeException(e);
  28 + }
  29 + }
  30 +
  31 + return alarmDSMVoList;
  32 + }
  33 +
  34 + private boolean filter(Object obj, Map<String, String> param) throws NoSuchFieldException, IllegalAccessException {
  35 + boolean result = true;
  36 + ObjectMapper mapper = new ObjectMapper();
  37 + if (param.get("lines") != null) {
  38 + AlarmDSMVo alarmDSMVo = (AlarmDSMVo) obj;
  39 + if (param.get("lines").toString().indexOf(String.format("%s,", alarmDSMVo.getLineCode())) < 0) {
  40 + return false;
  41 + }
  42 + }
  43 +
  44 + AlarmDSMVo other = mapper.convertValue(param, AlarmDSMVo.class);
  45 + Field[] fields = obj.getClass().getDeclaredFields();
  46 + for (Map.Entry<String, String> entry : param.entrySet()) {
  47 + String key = entry.getKey(), val = entry.getValue();
  48 + if (StringUtils.isEmpty(val)) {
  49 + continue;
  50 + }
  51 +
  52 + for (Field field : fields) {
  53 + if (field.getName().equals(key)) {
  54 + field.setAccessible(true);
  55 + Object fv1 = field.get(obj), fv2 = field.get(other);
  56 + if (!fv2.equals(fv1)) {
  57 + return false;
  58 + }
  59 + }
  60 + }
  61 + }
  62 +
  63 + return result;
  64 + }
  65 +}
src/main/java/com/bsth/util/HttpClientUtils.java
@@ -126,8 +126,8 @@ public class HttpClientUtils { @@ -126,8 +126,8 @@ public class HttpClientUtils {
126 } 126 }
127 //超时时间 127 //超时时间
128 RequestConfig requestConfig = RequestConfig.custom() 128 RequestConfig requestConfig = RequestConfig.custom()
129 - .setConnectTimeout(2500).setConnectionRequestTimeout(2000)  
130 - .setSocketTimeout(3500).build(); 129 + .setConnectTimeout(15000).setConnectionRequestTimeout(15000)
  130 + .setSocketTimeout(15000).build();
131 post.setConfig(requestConfig); 131 post.setConfig(requestConfig);
132 if (data != null) { 132 if (data != null) {
133 post.setEntity((new StringEntity(data, "UTF-8"))); 133 post.setEntity((new StringEntity(data, "UTF-8")));
src/main/java/com/bsth/websocket/handler/SendUtils.java
@@ -6,8 +6,10 @@ import com.bsth.data.LineConfigData; @@ -6,8 +6,10 @@ import com.bsth.data.LineConfigData;
6 import com.bsth.data.gpsdata_v2.entity.GpsEntity; 6 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
7 import com.bsth.data.maintenance_plan.MaintenancePlan; 7 import com.bsth.data.maintenance_plan.MaintenancePlan;
8 import com.bsth.data.safe_driv.SafeDriv; 8 import com.bsth.data.safe_driv.SafeDriv;
  9 +import com.bsth.data.schedule.DayOfSchedule;
9 import com.bsth.entity.directive.D80; 10 import com.bsth.entity.directive.D80;
10 import com.bsth.entity.realcontrol.ScheduleRealInfo; 11 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  12 +import com.bsth.message.entity.AlarmVo;
11 import com.bsth.message.entity.CarErrorStop; 13 import com.bsth.message.entity.CarErrorStop;
12 import com.bsth.message.entity.InoutPark; 14 import com.bsth.message.entity.InoutPark;
13 import com.bsth.websocket.dto.WsScheduleRealInfo; 15 import com.bsth.websocket.dto.WsScheduleRealInfo;
@@ -34,6 +36,8 @@ public class SendUtils{ @@ -34,6 +36,8 @@ public class SendUtils{
34 private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); 36 private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
35 37
36 private static Logger logger = LoggerFactory.getLogger(SendUtils.class); 38 private static Logger logger = LoggerFactory.getLogger(SendUtils.class);
  39 + @Autowired
  40 + private DayOfSchedule dayOfSchedule;
37 41
38 /** 42 /**
39 * @throws JsonProcessingException 43 * @throws JsonProcessingException
@@ -306,4 +310,20 @@ public class SendUtils{ @@ -306,4 +310,20 @@ public class SendUtils{
306 logger.error("sendInoutPark", e); 310 logger.error("sendInoutPark", e);
307 } 311 }
308 } 312 }
  313 +
  314 + /**
  315 + * 推送报警信息至线调页面
  316 + */
  317 + public void sendAlarm(AlarmVo alarmVo) {
  318 + Map<String, Object> map = new HashMap<>();
  319 + map.put("fn", "alarm");
  320 + map.put("data", alarmVo);
  321 + ObjectMapper mapper = new ObjectMapper();
  322 +
  323 + try {
  324 + socketHandler.sendMessageToLine(alarmVo.getLineCode(), mapper.writeValueAsString(map));
  325 + } catch (JsonProcessingException e) {
  326 + logger.error("sendAlarm", e);
  327 + }
  328 + }
309 } 329 }
src/main/resources/application-cloud.properties
@@ -40,6 +40,18 @@ spring.kafka.producer.acks= all @@ -40,6 +40,18 @@ spring.kafka.producer.acks= all
40 spring.kafka.consumer.group-id= schedule-system 40 spring.kafka.consumer.group-id= schedule-system
41 spring.kafka.consumer.auto-offset-reset= latest 41 spring.kafka.consumer.auto-offset-reset= latest
42 42
  43 +rabbit.use= true
  44 +spring.rabbitmq.host= 10.10.2.21
  45 +spring.rabbitmq.port= 5672
  46 +spring.rabbitmq.username= bsth
  47 +spring.rabbitmq.password= bsth001
  48 +spring.rabbitmq.virtual-host= /dsm
  49 +
  50 +minio.url= http://10.10.2.21:9008
  51 +minio.accessKey= umupRhEzO9EiVhLnJ7b9
  52 +minio.secretKey= VzjQUTN6c8p70HyX8AryRrB6ZjEsF2K28ndctHQh
  53 +minio.bucket= dsm
  54 +
43 sso.enabled= false 55 sso.enabled= false
44 sso.systemcode = SYS0023 56 sso.systemcode = SYS0023
45 sso.http.url.login= https://127.0.0.1/portal/index.html#/login 57 sso.http.url.login= https://127.0.0.1/portal/index.html#/login
src/main/resources/application-dev.properties
@@ -45,6 +45,18 @@ spring.kafka.consumer.auto-offset-reset= latest @@ -45,6 +45,18 @@ spring.kafka.consumer.auto-offset-reset= latest
45 spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer 45 spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer
46 spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer 46 spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer
47 47
  48 +rabbit.use= true
  49 +spring.rabbitmq.host= 10.10.2.21
  50 +spring.rabbitmq.port= 5672
  51 +spring.rabbitmq.username= bsth
  52 +spring.rabbitmq.password= bsth001
  53 +spring.rabbitmq.virtual-host= /dsm
  54 +
  55 +minio.url= http://10.10.2.21:9008
  56 +minio.accessKey= umupRhEzO9EiVhLnJ7b9
  57 +minio.secretKey= VzjQUTN6c8p70HyX8AryRrB6ZjEsF2K28ndctHQh
  58 +minio.bucket= dsm
  59 +
48 sso.enabled= false 60 sso.enabled= false
49 sso.systemcode = SYS0019 61 sso.systemcode = SYS0019
50 sso.http.url.login= http://180.169.154.251:28090/portal/index.html#/login 62 sso.http.url.login= http://180.169.154.251:28090/portal/index.html#/login
src/main/resources/application-test.properties
@@ -38,6 +38,18 @@ spring.kafka.consumer.auto-offset-reset= latest @@ -38,6 +38,18 @@ spring.kafka.consumer.auto-offset-reset= latest
38 spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer 38 spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer
39 spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer 39 spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer
40 40
  41 +rabbit.use= true
  42 +spring.rabbitmq.host= 10.10.2.21
  43 +spring.rabbitmq.port= 5672
  44 +spring.rabbitmq.username= bsth
  45 +spring.rabbitmq.password= bsth001
  46 +spring.rabbitmq.virtual-host= /dsm
  47 +
  48 +minio.url= http://10.10.2.21:9008
  49 +minio.accessKey= umupRhEzO9EiVhLnJ7b9
  50 +minio.secretKey= VzjQUTN6c8p70HyX8AryRrB6ZjEsF2K28ndctHQh
  51 +minio.bucket= dsm
  52 +
41 sso.enabled= false 53 sso.enabled= false
42 sso.systemcode = SYS0023 54 sso.systemcode = SYS0023
43 sso.http.url.login= https://112.64.45.51/portal/index.html#/login 55 sso.http.url.login= https://112.64.45.51/portal/index.html#/login
src/main/resources/static/index.html
@@ -653,5 +653,9 @@ @@ -653,5 +653,9 @@
653 <!-- RSA加密 --> 653 <!-- RSA加密 -->
654 <script src="/assets/plugins/jsencrypt.min.js"></script> 654 <script src="/assets/plugins/jsencrypt.min.js"></script>
655 <script src="/assets/js/eventproxy.js"></script> 655 <script src="/assets/js/eventproxy.js"></script>
  656 +<!-- 线路路由信息操作 -->
  657 +<script src="/pages/base/stationroute/js/routes-operation.js"></script>
  658 +<script src="/pages/base/stationroute/js/routes-service.js"></script>
  659 +<script src="/assets/js/CoordinateConverter.js"></script>
656 </body> 660 </body>
657 </html> 661 </html>
658 \ No newline at end of file 662 \ No newline at end of file
src/main/resources/static/pages/base/stationroute/add_stationroute_step2.html
@@ -122,7 +122,7 @@ @@ -122,7 +122,7 @@
122 <div class="form-group"> 122 <div class="form-group">
123 <label class="col-md-3 control-label"><span class="required"> * </span>经纬度坐标点:</label> 123 <label class="col-md-3 control-label"><span class="required"> * </span>经纬度坐标点:</label>
124 <div class="col-md-6"> 124 <div class="col-md-6">
125 - <input type="text" class="form-control" name="station.centerPointWkt" id="bJwpointsInput" readonly> 125 + <input type="text" class="form-control" name="station.centerPointWkt" id="bJwpointsInput">
126 </div> 126 </div>
127 </div> 127 </div>
128 </div> 128 </div>
src/main/resources/static/pages/base/stationroute/addstationstemplate.html
@@ -136,28 +136,17 @@ $(&#39;#add_station_template_modal&#39;).on(&#39;modal.show&#39;, function(event) { @@ -136,28 +136,17 @@ $(&#39;#add_station_template_modal&#39;).on(&#39;modal.show&#39;, function(event) {
136 var arrayFormat = inputStationValueFormat(array); 136 var arrayFormat = inputStationValueFormat(array);
137 // 根据站点名称获取百度坐标 137 // 根据站点名称获取百度坐标
138 RoutesOperation.stationsNameToPoints(arrayFormat, function(resultJson) { 138 RoutesOperation.stationsNameToPoints(arrayFormat, function(resultJson) {
139 - // 根据坐标点获取两点之间的时间与距离  
140 - RoutesOperation.getDistanceAndTotime(resultJson, function(stationdataList) {  
141 - var params = {};  
142 - params.lineId = properties.lineId;  
143 - params.versions = properties.versions;  
144 - params.directions = properties.directions;  
145 - params.stationJSON = resultJson;  
146 - RoutesOperation.lineInfoPanl(lineNameV, directionData, function(BusLine) {  
147 - if (BusLine && Polygon){  
148 - var Polygon = BusLine.getPolyline();  
149 - var polyGonArray = Polygon.getPath();  
150 - var jsonArray = [{sectionName: lineNameV+dirStr, points: polyGonArray}];  
151 - params.sectionJSON = jsonArray;  
152 - addSave(params, properties.lineId, directionData);  
153 - } else {  
154 - RoutesOperation.getSectionListPlonly(stationdataList,function(sectiondata) {  
155 - params.sectionJSON = sectiondata;  
156 - addSave(params, properties.lineId, directionData);  
157 - });  
158 - }  
159 - });  
160 - }); 139 + resultJson.forEach(function (item) {
  140 + item.distance = 0;
  141 + item.duration = 0;
  142 + })
  143 + var params = {};
  144 + params.lineId = properties.lineId;
  145 + params.versions = properties.versions;
  146 + params.directions = properties.directions;
  147 + params.stationJSON = resultJson;
  148 +
  149 + addSave(params, properties.lineId, directionData);
161 }); 150 });
162 } 151 }
163 }); 152 });
@@ -205,14 +194,14 @@ $(&#39;#add_station_template_modal&#39;).on(&#39;modal.show&#39;, function(event) { @@ -205,14 +194,14 @@ $(&#39;#add_station_template_modal&#39;).on(&#39;modal.show&#39;, function(event) {
205 params.stationJSON.forEach(function(item) { 194 params.stationJSON.forEach(function(item) {
206 stationRoutes.push({stationName: item.name, shapedType: 'r', radius: 80, destroy: 0, distances: 0, toTime: 0, station: {stationName: item.name, centerPointWkt: 'POINT(' + item.potion.lng + ' ' + item.potion.lat + ')'}}); 195 stationRoutes.push({stationName: item.name, shapedType: 'r', radius: 80, destroy: 0, distances: 0, toTime: 0, station: {stationName: item.name, centerPointWkt: 'POINT(' + item.potion.lng + ' ' + item.potion.lat + ')'}});
207 }) 196 })
208 - params.sectionJSON.forEach(function(item) {  
209 - var centerPointWkt = [];  
210 - item.points.forEach(function(item1) {  
211 - centerPointWkt.push(item1.lng + ' ' + item1.lat);  
212 - })  
213 - sectionRoutes.push({sectionrouteCode: sectionRouteCode, destroy: 0, section: {sectionName: item.sectionName, bsectionVectorWkt: 'LINESTRING(' + centerPointWkt.join(',') + ')'}});  
214 - sectionRouteCode++;  
215 - }) 197 + // params.sectionJSON.forEach(function(item) {
  198 + // var centerPointWkt = [];
  199 + // item.points.forEach(function(item1) {
  200 + // centerPointWkt.push(item1.lng + ' ' + item1.lat);
  201 + // })
  202 + // sectionRoutes.push({sectionrouteCode: sectionRouteCode, destroy: 0, section: {sectionName: item.sectionName, bsectionVectorWkt: 'LINESTRING(' + centerPointWkt.join(',') + ')'}});
  203 + // sectionRouteCode++;
  204 + // })
216 params.stationRoutes = stationRoutes; 205 params.stationRoutes = stationRoutes;
217 params.sectionRoutes = sectionRoutes; 206 params.sectionRoutes = sectionRoutes;
218 } 207 }
src/main/resources/static/pages/base/stationroute/js/routes-operation.js
@@ -716,6 +716,25 @@ var RoutesOperation = (function () { @@ -716,6 +716,25 @@ var RoutesOperation = (function () {
716 // 获取长度 716 // 获取长度
717 var len = arra.length; 717 var len = arra.length;
718 var stationList = []; 718 var stationList = [];
  719 + // 是否为 站点\t经度\t纬度
  720 + var standard = true;
  721 + for (var i = 0; i < arra.length;i++) {
  722 + var item = arra[i];
  723 + if (!item.wgs.x || !item.wgs.y) {
  724 + standard = false;
  725 + stationList = [];
  726 + break;
  727 + }
  728 + stationList.push({
  729 + name: item.name.replace('公交车站', ''),
  730 + wgs: item.wgs,
  731 + potion: CoordinateConverter.transformFromWGSToBaidu(CoordinateConverter.locationMake(item.wgs.x, item.wgs.y))
  732 + });
  733 + }
  734 + if (standard) {
  735 + callback && callback(stationList);
  736 + return;
  737 + }
719 (function () { 738 (function () {
720 if (!arguments.callee.count) { 739 if (!arguments.callee.count) {
721 arguments.callee.count = 0; 740 arguments.callee.count = 0;
@@ -2825,5 +2844,3 @@ var RoutesOperation = (function () { @@ -2825,5 +2844,3 @@ var RoutesOperation = (function () {
2825 2844
2826 return operation; 2845 return operation;
2827 })() 2846 })()
2828 -  
2829 -proxy.emit('routes-operation-loaded');  
src/main/resources/static/pages/base/stationroute/js/routes-service.js
@@ -414,6 +414,4 @@ var RoutesService = (function(){ @@ -414,6 +414,4 @@ var RoutesService = (function(){
414 }; 414 };
415 415
416 return service; 416 return service;
417 -})();  
418 -  
419 -proxy.emit('routes-service-loaded');  
420 \ No newline at end of file 417 \ No newline at end of file
  418 +})();
421 \ No newline at end of file 419 \ No newline at end of file
src/main/resources/static/pages/base/stationroute/list.html
@@ -408,9 +408,6 @@ @@ -408,9 +408,6 @@
408 </div> 408 </div>
409 </div> 409 </div>
410 </div> 410 </div>
411 -<script src="/pages/base/stationroute/js/routes-operation.js"></script>  
412 -<script src="/pages/base/stationroute/js/routes-service.js"></script>  
413 -  
414 411
415 <script id="add_draw_polyline-temp" type="text/html"> 412 <script id="add_draw_polyline-temp" type="text/html">
416 <div class="add_road_search_point_wrap "> 413 <div class="add_road_search_point_wrap ">
@@ -491,7 +488,7 @@ @@ -491,7 +488,7 @@
491 {{/if}} 488 {{/if}}
492 </script> 489 </script>
493 <script type="text/javascript"> 490 <script type="text/javascript">
494 - var proxy = EventProxy.create('routes-operation-loaded', 'routes-service-loaded', function() { 491 + $(document).ready(function () {
495 RoutesOperation.initPage(); 492 RoutesOperation.initPage();
496 RoutesOperation.initMap(); 493 RoutesOperation.initMap();
497 RoutesOperation.initStationDrawingManager(); 494 RoutesOperation.initStationDrawingManager();
src/main/resources/static/pages/permission/authorize_all/user_auth.html
@@ -66,7 +66,8 @@ @@ -66,7 +66,8 @@
66 <li><label><input class="uk-checkbox" type="checkbox" data-event="directive_history"> 指令下发记录</label></li> 66 <li><label><input class="uk-checkbox" type="checkbox" data-event="directive_history"> 指令下发记录</label></li>
67 <li><label><input class="uk-checkbox" type="checkbox" data-event="device_report"> 设备上报记录</label></li> 67 <li><label><input class="uk-checkbox" type="checkbox" data-event="device_report"> 设备上报记录</label></li>
68 <li><label><input class="uk-checkbox" type="checkbox" data-event="gps_play_back"> 轨迹回放</label></li> 68 <li><label><input class="uk-checkbox" type="checkbox" data-event="gps_play_back"> 轨迹回放</label></li>
69 - <li><label><input class="uk-checkbox" type="checkbox" data-event="safe_driving"> 安全驾驶(图像)</label></li> 69 + <li><label><input class="uk-checkbox" type="checkbox" data-event="safe_driving"> DSM</label></li>
  70 + <li><label><input class="uk-checkbox" type="checkbox" data-event="adas"> ADAS</label></li>
70 </ul> 71 </ul>
71 </div> 72 </div>
72 73
src/main/resources/static/real_control_v2/assets/plugins/uikit-2.27.1/components/lightbox.js
1 -/*! UIkit 2.25.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */  
2 -(function(addon) {  
3 -  
4 - var component;  
5 -  
6 - if (window.UIkit) {  
7 - component = addon(UIkit);  
8 - }  
9 -  
10 - if (typeof define == "function" && define.amd) { // AMD  
11 - define("uikit-lightbox", ["uikit"], function(){  
12 - return component || addon(UIkit);  
13 - });  
14 - }  
15 -  
16 -})(function(UI){  
17 -  
18 - "use strict";  
19 -  
20 - var modal, cache = {};  
21 -  
22 - UI.component('lightbox', {  
23 -  
24 - defaults: {  
25 - "group" : false,  
26 - "duration" : 400,  
27 - "keyboard" : true  
28 - },  
29 -  
30 - index : 0,  
31 - items : false,  
32 -  
33 - boot: function() {  
34 -  
35 - UI.$html.on('click', '[data-uk-lightbox]', function(e){  
36 -  
37 - e.preventDefault();  
38 -  
39 - var link = UI.$(this);  
40 -  
41 - if (!link.data("lightbox")) {  
42 -  
43 - UI.lightbox(link, UI.Utils.options(link.attr("data-uk-lightbox")));  
44 - }  
45 -  
46 - link.data("lightbox").show(link);  
47 - });  
48 -  
49 - // keyboard navigation  
50 - UI.$doc.on('keyup', function(e) {  
51 -  
52 - if (modal && modal.is(':visible') && modal.lightbox.options.keyboard) {  
53 -  
54 - e.preventDefault();  
55 -  
56 - switch(e.keyCode) {  
57 - case 37:  
58 - modal.lightbox.previous();  
59 - break;  
60 - case 39:  
61 - modal.lightbox.next();  
62 - break;  
63 - }  
64 - }  
65 - });  
66 - },  
67 -  
68 - init: function() {  
69 -  
70 - var siblings = [];  
71 -  
72 - this.index = 0;  
73 - this.siblings = [];  
74 -  
75 - if (this.element && this.element.length) {  
76 -  
77 - var domSiblings = this.options.group ? UI.$([  
78 - '[data-uk-lightbox*="'+this.options.group+'"]',  
79 - "[data-uk-lightbox*='"+this.options.group+"']"  
80 - ].join(',')) : this.element;  
81 -  
82 - domSiblings.each(function() {  
83 -  
84 - var ele = UI.$(this);  
85 -  
86 - siblings.push({  
87 - 'source': ele.attr('href'),  
88 - 'title' : ele.attr('data-title') || ele.attr('title'),  
89 - 'type' : ele.attr("data-lightbox-type") || 'auto',  
90 - 'link' : ele  
91 - });  
92 - });  
93 -  
94 - this.index = domSiblings.index(this.element);  
95 - this.siblings = siblings;  
96 -  
97 - } else if (this.options.group && this.options.group.length) {  
98 - this.siblings = this.options.group;  
99 - }  
100 -  
101 - this.trigger('lightbox-init', [this]);  
102 - },  
103 -  
104 - show: function(index) {  
105 -  
106 - this.modal = getModal(this);  
107 -  
108 - // stop previous animation  
109 - this.modal.dialog.stop();  
110 - this.modal.content.stop();  
111 -  
112 - var $this = this, promise = UI.$.Deferred(), data, item;  
113 -  
114 - index = index || 0;  
115 -  
116 - // index is a jQuery object or DOM element  
117 - if (typeof(index) == 'object') {  
118 -  
119 - this.siblings.forEach(function(s, idx){  
120 -  
121 - if (index[0] === s.link[0]) {  
122 - index = idx;  
123 - }  
124 - });  
125 - }  
126 -  
127 - // fix index if needed  
128 - if ( index < 0 ) {  
129 - index = this.siblings.length - index;  
130 - } else if (!this.siblings[index]) {  
131 - index = 0;  
132 - }  
133 -  
134 - item = this.siblings[index];  
135 -  
136 - data = {  
137 - "lightbox" : $this,  
138 - "source" : item.source,  
139 - "type" : item.type,  
140 - "index" : index,  
141 - "promise" : promise,  
142 - "title" : item.title,  
143 - "item" : item,  
144 - "meta" : {  
145 - "content" : '',  
146 - "width" : null,  
147 - "height" : null  
148 - }  
149 - };  
150 -  
151 - this.index = index;  
152 -  
153 - this.modal.content.empty();  
154 -  
155 - if (!this.modal.is(':visible')) {  
156 - this.modal.content.css({width:'', height:''}).empty();  
157 - this.modal.modal.show();  
158 - }  
159 -  
160 - this.modal.loader.removeClass('uk-hidden');  
161 -  
162 - promise.promise().done(function() {  
163 -  
164 - $this.data = data;  
165 - $this.fitSize(data);  
166 -  
167 - }).fail(function(){  
168 -  
169 - data.meta.content = '<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>';  
170 - data.meta.width = 400;  
171 - data.meta.height = 300;  
172 -  
173 - $this.data = data;  
174 - $this.fitSize(data);  
175 - });  
176 -  
177 - $this.trigger('showitem.uk.lightbox', [data]);  
178 - },  
179 -  
180 - fitSize: function() {  
181 -  
182 - var $this = this,  
183 - data = this.data,  
184 - pad = this.modal.dialog.outerWidth() - this.modal.dialog.width(),  
185 - dpadTop = parseInt(this.modal.dialog.css('margin-top'), 10),  
186 - dpadBot = parseInt(this.modal.dialog.css('margin-bottom'), 10),  
187 - dpad = dpadTop + dpadBot,  
188 - content = data.meta.content,  
189 - duration = $this.options.duration;  
190 -  
191 - if (this.siblings.length > 1) {  
192 -  
193 - content = [  
194 - content,  
195 - '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>',  
196 - '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>'  
197 - ].join('');  
198 - }  
199 -  
200 - // calculate width  
201 - var tmp = UI.$('<div>&nbsp;</div>').css({  
202 - 'opacity' : 0,  
203 - 'position' : 'absolute',  
204 - 'top' : 0,  
205 - 'left' : 0,  
206 - 'width' : '100%',  
207 - 'max-width' : $this.modal.dialog.css('max-width'),  
208 - 'padding' : $this.modal.dialog.css('padding'),  
209 - 'margin' : $this.modal.dialog.css('margin')  
210 - }), maxwidth, maxheight, w = data.meta.width, h = data.meta.height;  
211 -  
212 - tmp.appendTo('body').width();  
213 -  
214 - maxwidth = tmp.width();  
215 - maxheight = window.innerHeight - dpad;  
216 -  
217 - tmp.remove();  
218 -  
219 - this.modal.dialog.find('.uk-modal-caption').remove();  
220 -  
221 - if (data.title) {  
222 - this.modal.dialog.append('<div class="uk-modal-caption">'+data.title+'</div>');  
223 - maxheight -= this.modal.dialog.find('.uk-modal-caption').outerHeight();  
224 - }  
225 -  
226 - if (maxwidth < data.meta.width) {  
227 -  
228 - h = Math.floor( h * (maxwidth / w) );  
229 - w = maxwidth;  
230 - }  
231 -  
232 - if (maxheight < h) {  
233 -  
234 - h = Math.floor(maxheight);  
235 - w = Math.ceil(data.meta.width * (maxheight/data.meta.height));  
236 - }  
237 -  
238 - this.modal.content.css('opacity', 0).width(w).html(content);  
239 -  
240 - if (data.type == 'iframe') {  
241 - this.modal.content.find('iframe:first').height(h);  
242 - }  
243 -  
244 - var dh = h + pad,  
245 - t = Math.floor(window.innerHeight/2 - dh/2) - dpad;  
246 -  
247 - if (t < 0) { t = 0; }  
248 -  
249 - this.modal.closer.addClass('uk-hidden');  
250 -  
251 - if ($this.modal.data('mwidth') == w && $this.modal.data('mheight') == h) {  
252 - duration = 0;  
253 - }  
254 -  
255 - this.modal.dialog.animate({width: w + pad, height: h + pad, top: t }, duration, 'swing', function() {  
256 - $this.modal.loader.addClass('uk-hidden');  
257 - $this.modal.content.css({width:''}).animate({'opacity': 1}, function() {  
258 - $this.modal.closer.removeClass('uk-hidden');  
259 - });  
260 -  
261 - $this.modal.data({'mwidth': w, 'mheight': h});  
262 - });  
263 - },  
264 -  
265 - next: function() {  
266 - this.show(this.siblings[(this.index+1)] ? (this.index+1) : 0);  
267 - },  
268 -  
269 - previous: function() {  
270 - this.show(this.siblings[(this.index-1)] ? (this.index-1) : this.siblings.length-1);  
271 - }  
272 - });  
273 -  
274 -  
275 - // Plugins  
276 -  
277 - UI.plugin('lightbox', 'image', {  
278 -  
279 - init: function(lightbox) {  
280 -  
281 - lightbox.on("showitem.uk.lightbox", function(e, data){  
282 -  
283 - if (data.type == 'image' || data.source && data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)) {  
284 -  
285 - var resolve = function(source, width, height) {  
286 -  
287 - data.meta = {  
288 - "content" : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',  
289 - "width" : width,  
290 - "height" : height  
291 - };  
292 -  
293 - data.type = 'image';  
294 -  
295 - data.promise.resolve();  
296 - };  
297 -  
298 - if (!cache[data.source]) {  
299 -  
300 - var img = new Image();  
301 -  
302 - img.onerror = function(){  
303 - data.promise.reject('Loading image failed');  
304 - };  
305 -  
306 - img.onload = function(){  
307 - cache[data.source] = {width: img.width, height: img.height};  
308 - resolve(data.source, cache[data.source].width, cache[data.source].height);  
309 - };  
310 -  
311 - img.src = data.source;  
312 -  
313 - } else {  
314 - resolve(data.source, cache[data.source].width, cache[data.source].height);  
315 - }  
316 - }  
317 - });  
318 - }  
319 - });  
320 -  
321 - UI.plugin("lightbox", "youtube", {  
322 -  
323 - init: function(lightbox) {  
324 -  
325 - var youtubeRegExp = /(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,  
326 - youtubeRegExpShort = /youtu\.be\/(.*)/;  
327 -  
328 -  
329 - lightbox.on("showitem.uk.lightbox", function(e, data){  
330 -  
331 - var id, matches, resolve = function(id, width, height) {  
332 -  
333 - data.meta = {  
334 - 'content': '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"></iframe>',  
335 - 'width': width,  
336 - 'height': height  
337 - };  
338 -  
339 - data.type = 'iframe';  
340 -  
341 - data.promise.resolve();  
342 - };  
343 -  
344 - if (matches = data.source.match(youtubeRegExp)) {  
345 - id = matches[2];  
346 - }  
347 -  
348 - if (matches = data.source.match(youtubeRegExpShort)) {  
349 - id = matches[1];  
350 - }  
351 -  
352 - if (id) {  
353 -  
354 - if(!cache[id]) {  
355 -  
356 - var img = new Image(), lowres = false;  
357 -  
358 - img.onerror = function(){  
359 - cache[id] = {width:640, height:320};  
360 - resolve(id, cache[id].width, cache[id].height);  
361 - };  
362 -  
363 - img.onload = function(){  
364 - //youtube default 404 thumb, fall back to lowres  
365 - if (img.width == 120 && img.height == 90) {  
366 - if (!lowres) {  
367 - lowres = true;  
368 - img.src = '//img.youtube.com/vi/' + id + '/0.jpg';  
369 - } else {  
370 - cache[id] = {width: 640, height: 320};  
371 - resolve(id, cache[id].width, cache[id].height);  
372 - }  
373 - } else {  
374 - cache[id] = {width: img.width, height: img.height};  
375 - resolve(id, img.width, img.height);  
376 - }  
377 - };  
378 -  
379 - img.src = '//img.youtube.com/vi/'+id+'/maxresdefault.jpg';  
380 -  
381 - } else {  
382 - resolve(id, cache[id].width, cache[id].height);  
383 - }  
384 -  
385 - e.stopImmediatePropagation();  
386 - }  
387 - });  
388 - }  
389 - });  
390 -  
391 -  
392 - UI.plugin("lightbox", "vimeo", {  
393 -  
394 - init: function(lightbox) {  
395 -  
396 - var regex = /(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/, matches;  
397 -  
398 -  
399 - lightbox.on("showitem.uk.lightbox", function(e, data){  
400 -  
401 - var id, resolve = function(id, width, height) {  
402 -  
403 - data.meta = {  
404 - 'content': '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"></iframe>',  
405 - 'width': width,  
406 - 'height': height  
407 - };  
408 -  
409 - data.type = 'iframe';  
410 -  
411 - data.promise.resolve();  
412 - };  
413 -  
414 - if (matches = data.source.match(regex)) {  
415 -  
416 - id = matches[2];  
417 -  
418 - if(!cache[id]) {  
419 -  
420 - UI.$.ajax({  
421 - type : 'GET',  
422 - url : 'http://vimeo.com/api/oembed.json?url=' + encodeURI(data.source),  
423 - jsonp : 'callback',  
424 - dataType : 'jsonp',  
425 - success : function(data) {  
426 - cache[id] = {width:data.width, height:data.height};  
427 - resolve(id, cache[id].width, cache[id].height);  
428 - }  
429 - });  
430 -  
431 - } else {  
432 - resolve(id, cache[id].width, cache[id].height);  
433 - }  
434 -  
435 - e.stopImmediatePropagation();  
436 - }  
437 - });  
438 - }  
439 - });  
440 -  
441 - UI.plugin("lightbox", "video", {  
442 -  
443 - init: function(lightbox) {  
444 -  
445 - lightbox.on("showitem.uk.lightbox", function(e, data){  
446 -  
447 -  
448 - var resolve = function(source, width, height) {  
449 -  
450 - data.meta = {  
451 - 'content': '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>',  
452 - 'width': width,  
453 - 'height': height  
454 - };  
455 -  
456 - data.type = 'video';  
457 -  
458 - data.promise.resolve();  
459 - };  
460 -  
461 - if (data.type == 'video' || data.source.match(/\.(mp4|webm|ogv)$/i)) {  
462 -  
463 - if (!cache[data.source]) {  
464 -  
465 - var vid = UI.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr('src', data.source).appendTo('body');  
466 -  
467 - var idle = setInterval(function() {  
468 -  
469 - if (vid[0].videoWidth) {  
470 - clearInterval(idle);  
471 - cache[data.source] = {width: vid[0].videoWidth, height: vid[0].videoHeight};  
472 - resolve(data.source, cache[data.source].width, cache[data.source].height);  
473 - vid.remove();  
474 - }  
475 -  
476 - }, 20);  
477 -  
478 - } else {  
479 - resolve(data.source, cache[data.source].width, cache[data.source].height);  
480 - }  
481 - }  
482 - });  
483 - }  
484 - });  
485 -  
486 -  
487 - function getModal(lightbox) {  
488 -  
489 - if (modal) {  
490 - modal.lightbox = lightbox;  
491 - return modal;  
492 - }  
493 -  
494 - // init lightbox container  
495 - modal = UI.$([  
496 - '<div class="uk-modal">',  
497 - '<div class="uk-modal-dialog uk-modal-dialog-lightbox uk-slidenav-position" style="margin-left:auto;margin-right:auto;width:200px;height:200px;top:'+Math.abs(window.innerHeight/2 - 200)+'px;">',  
498 - '<a href="#" class="uk-modal-close uk-close uk-close-alt"></a>',  
499 - '<div class="uk-lightbox-content"></div>',  
500 - '<div class="uk-modal-spinner uk-hidden"></div>',  
501 - '</div>',  
502 - '</div>'  
503 - ].join('')).appendTo('body');  
504 -  
505 - modal.dialog = modal.find('.uk-modal-dialog:first');  
506 - modal.content = modal.find('.uk-lightbox-content:first');  
507 - modal.loader = modal.find('.uk-modal-spinner:first');  
508 - modal.closer = modal.find('.uk-close.uk-close-alt');  
509 - modal.modal = UI.modal(modal, {modal:false, bgclose: false});  
510 -  
511 - // next / previous  
512 -/* modal.on("swipeRight swipeLeft", function(e) {  
513 - modal.lightbox[e.type=='swipeLeft' ? 'next':'previous']();  
514 - }).on("click", "[data-lightbox-previous], [data-lightbox-next]", function(e){  
515 - e.preventDefault();  
516 - modal.lightbox[UI.$(this).is('[data-lightbox-next]') ? 'next':'previous']();  
517 - });*/  
518 -  
519 - // destroy content on modal hide  
520 - modal.on("hide.uk.modal", function(e) {  
521 - modal.content.html('');  
522 - });  
523 -  
524 - UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(e){  
525 - if (modal.is(':visible') && !UI.Utils.isFullscreen()) modal.lightbox.fitSize();  
526 - }.bind(this), 100));  
527 -  
528 - modal.lightbox = lightbox;  
529 -  
530 - return modal;  
531 - }  
532 -  
533 - UI.lightbox.create = function(items, options) {  
534 -  
535 - if (!items) return;  
536 -  
537 - var group = [], o;  
538 -  
539 - items.forEach(function(item) {  
540 -  
541 - group.push(UI.$.extend({  
542 - 'source' : '',  
543 - 'title' : '',  
544 - 'type' : 'auto',  
545 - 'link' : false  
546 - }, (typeof(item) == 'string' ? {'source': item} : item)));  
547 - });  
548 -  
549 - o = UI.lightbox(UI.$.extend({}, options, {'group':group}));  
550 -  
551 - return o;  
552 - };  
553 -  
554 - return UI.lightbox;  
555 -}); 1 +/*! UIkit 2.25.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
  2 +(function(addon) {
  3 +
  4 + var component;
  5 +
  6 + if (window.UIkit) {
  7 + component = addon(UIkit);
  8 + }
  9 +
  10 + if (typeof define == "function" && define.amd) { // AMD
  11 + define("uikit-lightbox", ["uikit"], function(){
  12 + return component || addon(UIkit);
  13 + });
  14 + }
  15 +
  16 +})(function(UI){
  17 +
  18 + "use strict";
  19 +
  20 + var modal, cache = {};
  21 +
  22 + UI.component('lightbox', {
  23 +
  24 + defaults: {
  25 + "group" : false,
  26 + "duration" : 400,
  27 + "keyboard" : true
  28 + },
  29 +
  30 + index : 0,
  31 + items : false,
  32 +
  33 + boot: function() {
  34 +
  35 + UI.$html.on('click', '[data-uk-lightbox]', function(e){
  36 +
  37 + e.preventDefault();
  38 +
  39 + var link = UI.$(this);
  40 +
  41 + if (!link.data("lightbox")) {
  42 +
  43 + UI.lightbox(link, UI.Utils.options(link.attr("data-uk-lightbox")));
  44 + }
  45 +
  46 + link.data("lightbox").show(link);
  47 + });
  48 +
  49 + // keyboard navigation
  50 + UI.$doc.on('keyup', function(e) {
  51 +
  52 + if (modal && modal.is(':visible') && modal.lightbox.options.keyboard) {
  53 +
  54 + e.preventDefault();
  55 +
  56 + switch(e.keyCode) {
  57 + case 37:
  58 + modal.lightbox.previous();
  59 + break;
  60 + case 39:
  61 + modal.lightbox.next();
  62 + break;
  63 + }
  64 + }
  65 + });
  66 + },
  67 +
  68 + init: function() {
  69 +
  70 + var siblings = [];
  71 +
  72 + this.index = 0;
  73 + this.siblings = [];
  74 +
  75 + if (this.element && this.element.length) {
  76 +
  77 + var domSiblings = this.options.group ? UI.$([
  78 + '[data-uk-lightbox*="'+this.options.group+'"]',
  79 + "[data-uk-lightbox*='"+this.options.group+"']"
  80 + ].join(',')) : this.element;
  81 +
  82 + domSiblings.each(function() {
  83 +
  84 + var ele = UI.$(this);
  85 +
  86 + siblings.push({
  87 + 'source': ele.attr('href'),
  88 + 'title' : ele.attr('data-title') || ele.attr('title'),
  89 + 'type' : ele.attr("data-lightbox-type") || 'auto',
  90 + 'link' : ele
  91 + });
  92 + });
  93 +
  94 + this.index = domSiblings.index(this.element);
  95 + this.siblings = siblings;
  96 +
  97 + } else if (this.options.group && this.options.group.length) {
  98 + this.siblings = this.options.group;
  99 + }
  100 +
  101 + this.trigger('lightbox-init', [this]);
  102 + },
  103 +
  104 + show: function(index) {
  105 +
  106 + this.modal = getModal(this);
  107 +
  108 + // stop previous animation
  109 + this.modal.dialog.stop();
  110 + this.modal.content.stop();
  111 +
  112 + var $this = this, promise = UI.$.Deferred(), data, item;
  113 +
  114 + index = index || 0;
  115 +
  116 + // index is a jQuery object or DOM element
  117 + if (typeof(index) == 'object') {
  118 +
  119 + this.siblings.forEach(function(s, idx){
  120 +
  121 + if (index[0] === s.link[0]) {
  122 + index = idx;
  123 + }
  124 + });
  125 + }
  126 +
  127 + // fix index if needed
  128 + if ( index < 0 ) {
  129 + index = this.siblings.length - index;
  130 + } else if (!this.siblings[index]) {
  131 + index = 0;
  132 + }
  133 +
  134 + item = this.siblings[index];
  135 +
  136 + data = {
  137 + "lightbox" : $this,
  138 + "source" : item.source,
  139 + "type" : item.type,
  140 + "index" : index,
  141 + "promise" : promise,
  142 + "title" : item.title,
  143 + "item" : item,
  144 + "meta" : {
  145 + "content" : '',
  146 + "width" : null,
  147 + "height" : null
  148 + }
  149 + };
  150 +
  151 + this.index = index;
  152 +
  153 + this.modal.content.empty();
  154 +
  155 + if (!this.modal.is(':visible')) {
  156 + this.modal.content.css({width:'', height:''}).empty();
  157 + this.modal.modal.show();
  158 + }
  159 +
  160 + this.modal.loader.removeClass('uk-hidden');
  161 +
  162 + promise.promise().done(function() {
  163 +
  164 + $this.data = data;
  165 + $this.fitSize(data);
  166 +
  167 + }).fail(function(){
  168 +
  169 + data.meta.content = '<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>';
  170 + data.meta.width = 400;
  171 + data.meta.height = 300;
  172 +
  173 + $this.data = data;
  174 + $this.fitSize(data);
  175 + });
  176 +
  177 + $this.trigger('showitem.uk.lightbox', [data]);
  178 + },
  179 +
  180 + fitSize: function() {
  181 +
  182 + var $this = this,
  183 + data = this.data,
  184 + pad = this.modal.dialog.outerWidth() - this.modal.dialog.width(),
  185 + dpadTop = parseInt(this.modal.dialog.css('margin-top'), 10),
  186 + dpadBot = parseInt(this.modal.dialog.css('margin-bottom'), 10),
  187 + dpad = dpadTop + dpadBot,
  188 + content = data.meta.content,
  189 + duration = $this.options.duration;
  190 +
  191 + if (this.siblings.length > 1) {
  192 +
  193 + content = [
  194 + content,
  195 + '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>',
  196 + '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>'
  197 + ].join('');
  198 + }
  199 +
  200 + // calculate width
  201 + var tmp = UI.$('<div>&nbsp;</div>').css({
  202 + 'opacity' : 0,
  203 + 'position' : 'absolute',
  204 + 'top' : 0,
  205 + 'left' : 0,
  206 + 'width' : '100%',
  207 + 'max-width' : $this.modal.dialog.css('max-width'),
  208 + 'padding' : $this.modal.dialog.css('padding'),
  209 + 'margin' : $this.modal.dialog.css('margin')
  210 + }), maxwidth, maxheight, w = data.meta.width, h = data.meta.height;
  211 +
  212 + tmp.appendTo('body').width();
  213 +
  214 + maxwidth = tmp.width();
  215 + maxheight = window.innerHeight - dpad;
  216 +
  217 + tmp.remove();
  218 +
  219 + this.modal.dialog.find('.uk-modal-caption').remove();
  220 +
  221 + if (data.title) {
  222 + this.modal.dialog.append('<div class="uk-modal-caption">'+data.title+'</div>');
  223 + maxheight -= this.modal.dialog.find('.uk-modal-caption').outerHeight();
  224 + }
  225 +
  226 + if (maxwidth < data.meta.width) {
  227 +
  228 + h = Math.floor( h * (maxwidth / w) );
  229 + w = maxwidth;
  230 + }
  231 +
  232 + if (maxheight < h) {
  233 +
  234 + h = Math.floor(maxheight);
  235 + w = Math.ceil(data.meta.width * (maxheight/data.meta.height));
  236 + }
  237 +
  238 + this.modal.content.css('opacity', 0).width(w).html(content);
  239 +
  240 + if (data.type == 'iframe') {
  241 + this.modal.content.find('iframe:first').height(h);
  242 + }
  243 +
  244 + var dh = h + pad,
  245 + t = Math.floor(window.innerHeight/2 - dh/2) - dpad;
  246 +
  247 + if (t < 0) { t = 0; }
  248 +
  249 + this.modal.closer.addClass('uk-hidden');
  250 +
  251 + if ($this.modal.data('mwidth') == w && $this.modal.data('mheight') == h) {
  252 + duration = 0;
  253 + }
  254 +
  255 + this.modal.dialog.animate({width: w + pad, height: h + pad, top: t }, duration, 'swing', function() {
  256 + $this.modal.loader.addClass('uk-hidden');
  257 + $this.modal.content.css({width:''}).animate({'opacity': 1}, function() {
  258 + $this.modal.closer.removeClass('uk-hidden');
  259 + });
  260 +
  261 + $this.modal.data({'mwidth': w, 'mheight': h});
  262 + });
  263 + },
  264 +
  265 + next: function() {
  266 + this.show(this.siblings[(this.index+1)] ? (this.index+1) : 0);
  267 + },
  268 +
  269 + previous: function() {
  270 + this.show(this.siblings[(this.index-1)] ? (this.index-1) : this.siblings.length-1);
  271 + }
  272 + });
  273 +
  274 +
  275 + // Plugins
  276 +
  277 + UI.plugin('lightbox', 'image', {
  278 +
  279 + init: function(lightbox) {
  280 +
  281 + lightbox.on("showitem.uk.lightbox", function(e, data){
  282 +
  283 + if (data.type == 'image' || data.source && data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)) {
  284 +
  285 + var resolve = function(source, width, height) {
  286 +
  287 + data.meta = {
  288 + "content" : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',
  289 + "width" : width,
  290 + "height" : height
  291 + };
  292 +
  293 + data.type = 'image';
  294 +
  295 + data.promise.resolve();
  296 + };
  297 +
  298 + if (!cache[data.source]) {
  299 +
  300 + var img = new Image();
  301 +
  302 + img.onerror = function(){
  303 + data.promise.reject('Loading image failed');
  304 + };
  305 +
  306 + img.onload = function(){
  307 + cache[data.source] = {width: img.width, height: img.height};
  308 + resolve(data.source, cache[data.source].width, cache[data.source].height);
  309 + };
  310 +
  311 + img.src = data.source;
  312 +
  313 + } else {
  314 + resolve(data.source, cache[data.source].width, cache[data.source].height);
  315 + }
  316 + }
  317 + });
  318 + }
  319 + });
  320 +
  321 + UI.plugin("lightbox", "youtube", {
  322 +
  323 + init: function(lightbox) {
  324 +
  325 + var youtubeRegExp = /(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,
  326 + youtubeRegExpShort = /youtu\.be\/(.*)/;
  327 +
  328 +
  329 + lightbox.on("showitem.uk.lightbox", function(e, data){
  330 +
  331 + var id, matches, resolve = function(id, width, height) {
  332 +
  333 + data.meta = {
  334 + 'content': '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"></iframe>',
  335 + 'width': width,
  336 + 'height': height
  337 + };
  338 +
  339 + data.type = 'iframe';
  340 +
  341 + data.promise.resolve();
  342 + };
  343 +
  344 + if (matches = data.source.match(youtubeRegExp)) {
  345 + id = matches[2];
  346 + }
  347 +
  348 + if (matches = data.source.match(youtubeRegExpShort)) {
  349 + id = matches[1];
  350 + }
  351 +
  352 + if (id) {
  353 +
  354 + if(!cache[id]) {
  355 +
  356 + var img = new Image(), lowres = false;
  357 +
  358 + img.onerror = function(){
  359 + cache[id] = {width:640, height:320};
  360 + resolve(id, cache[id].width, cache[id].height);
  361 + };
  362 +
  363 + img.onload = function(){
  364 + //youtube default 404 thumb, fall back to lowres
  365 + if (img.width == 120 && img.height == 90) {
  366 + if (!lowres) {
  367 + lowres = true;
  368 + img.src = '//img.youtube.com/vi/' + id + '/0.jpg';
  369 + } else {
  370 + cache[id] = {width: 640, height: 320};
  371 + resolve(id, cache[id].width, cache[id].height);
  372 + }
  373 + } else {
  374 + cache[id] = {width: img.width, height: img.height};
  375 + resolve(id, img.width, img.height);
  376 + }
  377 + };
  378 +
  379 + img.src = '//img.youtube.com/vi/'+id+'/maxresdefault.jpg';
  380 +
  381 + } else {
  382 + resolve(id, cache[id].width, cache[id].height);
  383 + }
  384 +
  385 + e.stopImmediatePropagation();
  386 + }
  387 + });
  388 + }
  389 + });
  390 +
  391 +
  392 + UI.plugin("lightbox", "vimeo", {
  393 +
  394 + init: function(lightbox) {
  395 +
  396 + var regex = /(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/, matches;
  397 +
  398 +
  399 + lightbox.on("showitem.uk.lightbox", function(e, data){
  400 +
  401 + var id, resolve = function(id, width, height) {
  402 +
  403 + data.meta = {
  404 + 'content': '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"></iframe>',
  405 + 'width': width,
  406 + 'height': height
  407 + };
  408 +
  409 + data.type = 'iframe';
  410 +
  411 + data.promise.resolve();
  412 + };
  413 +
  414 + if (matches = data.source.match(regex)) {
  415 +
  416 + id = matches[2];
  417 +
  418 + if(!cache[id]) {
  419 +
  420 + UI.$.ajax({
  421 + type : 'GET',
  422 + url : 'http://vimeo.com/api/oembed.json?url=' + encodeURI(data.source),
  423 + jsonp : 'callback',
  424 + dataType : 'jsonp',
  425 + success : function(data) {
  426 + cache[id] = {width:data.width, height:data.height};
  427 + resolve(id, cache[id].width, cache[id].height);
  428 + }
  429 + });
  430 +
  431 + } else {
  432 + resolve(id, cache[id].width, cache[id].height);
  433 + }
  434 +
  435 + e.stopImmediatePropagation();
  436 + }
  437 + });
  438 + }
  439 + });
  440 +
  441 + UI.plugin("lightbox", "video", {
  442 +
  443 + init: function(lightbox) {
  444 +
  445 + lightbox.on("showitem.uk.lightbox", function(e, data){
  446 +
  447 +
  448 + var resolve = function(source, width, height) {
  449 +
  450 + data.meta = {
  451 + 'content': '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>',
  452 + 'width': width,
  453 + 'height': height
  454 + };
  455 +
  456 + data.type = 'video';
  457 +
  458 + data.promise.resolve();
  459 + };
  460 +
  461 + if (data.type == 'video' || data.source.match(/\.(mp4|webm|ogv)$/i)) {
  462 +
  463 + if (!cache[data.source]) {
  464 +
  465 + var vid = UI.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr('src', data.source).appendTo('body');
  466 +
  467 + var idle = setInterval(function() {
  468 +
  469 + if (vid[0].videoWidth) {
  470 + clearInterval(idle);
  471 + cache[data.source] = {width: vid[0].videoWidth, height: vid[0].videoHeight};
  472 + resolve(data.source, cache[data.source].width, cache[data.source].height);
  473 + vid.remove();
  474 + }
  475 +
  476 + }, 20);
  477 +
  478 + } else {
  479 + resolve(data.source, cache[data.source].width, cache[data.source].height);
  480 + }
  481 + }
  482 + });
  483 + }
  484 + });
  485 +
  486 +
  487 + function getModal(lightbox) {
  488 +
  489 + if (modal) {
  490 + modal.lightbox = lightbox;
  491 + return modal;
  492 + }
  493 +
  494 + // init lightbox container
  495 + modal = UI.$([
  496 + '<div class="uk-modal">',
  497 + '<div class="uk-modal-dialog uk-modal-dialog-lightbox uk-slidenav-position" style="margin-left:auto;margin-right:auto;width:200px;height:200px;top:'+Math.abs(window.innerHeight/2 - 200)+'px;">',
  498 + '<a href="#" class="uk-modal-close uk-close uk-close-alt"></a>',
  499 + '<div class="uk-lightbox-content"></div>',
  500 + '<div class="uk-modal-spinner uk-hidden"></div>',
  501 + '</div>',
  502 + '</div>'
  503 + ].join('')).appendTo('body');
  504 +
  505 + modal.dialog = modal.find('.uk-modal-dialog:first');
  506 + modal.content = modal.find('.uk-lightbox-content:first');
  507 + modal.loader = modal.find('.uk-modal-spinner:first');
  508 + modal.closer = modal.find('.uk-close.uk-close-alt');
  509 + modal.modal = UI.modal(modal, {modal:false, bgclose: false});
  510 +
  511 + // next / previous
  512 + modal.on("swipeRight swipeLeft", function(e) {
  513 + modal.lightbox[e.type=='swipeLeft' ? 'next':'previous']();
  514 + }).on("click", "[data-lightbox-previous], [data-lightbox-next]", function(e){
  515 + e.preventDefault();
  516 + modal.lightbox[UI.$(this).is('[data-lightbox-next]') ? 'next':'previous']();
  517 + });
  518 +
  519 + // destroy content on modal hide
  520 + modal.on("hide.uk.modal", function(e) {
  521 + modal.content.html('');
  522 + });
  523 +
  524 + UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(e){
  525 + if (modal.is(':visible') && !UI.Utils.isFullscreen()) modal.lightbox.fitSize();
  526 + }.bind(this), 100));
  527 +
  528 + modal.lightbox = lightbox;
  529 +
  530 + return modal;
  531 + }
  532 +
  533 + UI.lightbox.create = function(items, options) {
  534 +
  535 + if (!items) return;
  536 +
  537 + var group = [], o;
  538 +
  539 + items.forEach(function(item) {
  540 +
  541 + group.push(UI.$.extend({
  542 + 'source' : '',
  543 + 'title' : '',
  544 + 'type' : 'auto',
  545 + 'link' : false
  546 + }, (typeof(item) == 'string' ? {'source': item} : item)));
  547 + });
  548 +
  549 + o = UI.lightbox(UI.$.extend({}, options, {'group':group}));
  550 +
  551 + return o;
  552 + };
  553 +
  554 + return UI.lightbox;
  555 +});