Commit df8d79a048467cffb16da2976807929c8a1c5cae

Authored by 徐烜
2 parents 901c1349 c4fecbee

Merge branch 'chengdu' of http://192.168.168.245:8888/panzhaov5/bsth_control into chengdu

Showing 40 changed files with 2509 additions and 866 deletions

Too many changes to show.

To preserve performance only 40 of 76 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/DataSourceConfig.java 0 → 100644
  1 +package com.bsth;
  2 +
  3 +import org.springframework.beans.factory.annotation.Qualifier;
  4 +import org.springframework.boot.context.properties.ConfigurationProperties;
  5 +import org.springframework.boot.jdbc.DataSourceBuilder;
  6 +import org.springframework.context.annotation.Bean;
  7 +import org.springframework.context.annotation.Configuration;
  8 +import org.springframework.context.annotation.Primary;
  9 +import org.springframework.jdbc.core.JdbcTemplate;
  10 +
  11 +import javax.sql.DataSource;
  12 +
  13 +/**
  14 + * @author Hill
  15 + */
  16 +@Configuration
  17 +public class DataSourceConfig {
  18 +
  19 + @Bean(name = "dataSource")
  20 + @Qualifier("dataSource")
  21 + @Primary
  22 + @ConfigurationProperties(prefix = "spring.datasource.control")
  23 + public DataSource dataSource(){
  24 + return DataSourceBuilder.create().build();
  25 + }
  26 +
  27 + @Bean(name = "infoPublishDataSource")
  28 + @Qualifier("infoPublishDataSource")
  29 + @ConfigurationProperties(prefix = "spring.datasource.info-publish")
  30 + public DataSource infoPublishDataSource(){
  31 + return DataSourceBuilder.create().build();
  32 + }
  33 +
  34 + @Bean(name = "jdbcTemplate")
  35 + @Primary
  36 + public JdbcTemplate jdbcTemplate(@Qualifier("dataSource")DataSource dataSource){
  37 + return new JdbcTemplate(dataSource);
  38 + }
  39 +
  40 + @Bean(name = "infoPublishJdbcTemplate")
  41 + public JdbcTemplate infoPublishJdbcTemplate(@Qualifier("infoPublishDataSource")DataSource dataSource){
  42 + return new JdbcTemplate(dataSource);
  43 + }
  44 +}
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/alaram/MinioController.java 0 → 100644
  1 +package com.bsth.controller.alaram;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import io.minio.MinioClient;
  5 +import io.minio.GetPresignedObjectUrlArgs;
  6 +import io.minio.http.Method;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RequestParam;
  12 +import org.springframework.web.bind.annotation.RestController;
  13 +
  14 +import java.util.ArrayList;
  15 +import java.util.HashMap;
  16 +import java.util.List;
  17 +import java.util.Map;
  18 +import java.util.concurrent.TimeUnit;
  19 +
  20 +@RestController
  21 +@RequestMapping("api/minio")
  22 +public class MinioController {
  23 +
  24 + private final static Logger log = LoggerFactory.getLogger(MinioController.class);
  25 +
  26 + @Autowired
  27 + private MinioClient minioClient;
  28 +
  29 + @RequestMapping(value = "/preSignedUrl")
  30 + public Map<String, Object> preSignedUrl(@RequestParam(defaultValue = "dsm") String bucket, @RequestParam(name = "objects[]") String[] objects) {
  31 + Map<String, Object> result = new HashMap<>();
  32 + try {
  33 + List<String> urls = new ArrayList<>();
  34 + for (String object : objects) {
  35 + String url = minioClient.getPresignedObjectUrl(
  36 + GetPresignedObjectUrlArgs.builder()
  37 + .bucket(bucket)
  38 + .object(object)
  39 + .method(Method.GET)
  40 + .expiry(5, TimeUnit.MINUTES)
  41 + .build()
  42 + );
  43 + urls.add(url);
  44 + }
  45 +
  46 + result.put("urls", urls);
  47 + result.put("status", ResponseCode.SUCCESS);
  48 + } catch (Exception e) {
  49 + log.error("minio预签名异常", e);
  50 + result.put("msg", "minio预签名异常");
  51 + result.put("status", ResponseCode.ERROR);
  52 + }
  53 +
  54 + return result;
  55 + }
  56 +}
src/main/java/com/bsth/controller/publish/InfoPublishController.java 0 → 100644
  1 +package com.bsth.controller.publish;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.publish.ScanStatictic;
  5 +import com.bsth.message.entity.AlarmADASVo;
  6 +import com.bsth.service.alarm.AlarmAdasService;
  7 +import com.bsth.service.publish.InfoPublishService;
  8 +import com.bsth.util.ReportUtils;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RequestParam;
  14 +import org.springframework.web.bind.annotation.RestController;
  15 +
  16 +import java.util.*;
  17 +
  18 +@RestController
  19 +@RequestMapping("api/info_publish")
  20 +public class InfoPublishController {
  21 +
  22 + private final static Logger log = LoggerFactory.getLogger(InfoPublishController.class);
  23 +
  24 + @Autowired
  25 + private InfoPublishService infoPublishService;
  26 +
  27 + @RequestMapping(value = "/scan_statistic/list")
  28 + public Map<String, Object> list(@RequestParam Map<String, String> param,
  29 + @RequestParam(defaultValue = "0") int page,
  30 + @RequestParam(defaultValue = "15") int size,
  31 + @RequestParam(defaultValue = "timestamp") String order,
  32 + @RequestParam(defaultValue = "0") int direction) {
  33 + Map<String, Object> result = new HashMap<>();
  34 + try {
  35 + Map<String, Object> results = infoPublishService.list(param, page, size, order, direction);
  36 +
  37 + result.putAll(results);
  38 + result.put("page", page);
  39 + result.put("status", ResponseCode.SUCCESS);
  40 + } catch (Exception e) {
  41 + result.put("status", ResponseCode.ERROR);
  42 + log.error(e.getMessage(), e);
  43 + }
  44 +
  45 + return result;
  46 + }
  47 +
  48 + @RequestMapping(value = "/scan_statistic/list_export")
  49 + public Map<String, Object> list(@RequestParam Map<String, String> param) {
  50 + Map<String, Object> result = new HashMap<>();
  51 + try {
  52 + Map<String, Object> results = infoPublishService.export(param);
  53 + ReportUtils util = new ReportUtils();
  54 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms", rq = param.get("rq");
  55 + util.excelReplace((List<Iterator<?>>) results.get("list"), new Object[]{}, String.format("%s/mould/scanStatistic.xls", path), String.format("%s/export/一站一码扫码情况%s.xls", path, rq));
  56 +
  57 + result.put("status", ResponseCode.SUCCESS);
  58 + } catch (Exception e) {
  59 + result.put("status", ResponseCode.ERROR);
  60 + log.error(e.getMessage(), e);
  61 + }
  62 +
  63 + return result;
  64 + }
  65 +}
src/main/java/com/bsth/controller/realcontrol/DataManagerController.java
1 -package com.bsth.controller.realcontrol;  
2 -  
3 -import com.bsth.service.realcontrol.DataManagerService;  
4 -import org.apache.commons.lang3.StringEscapeUtils;  
5 -import org.springframework.beans.factory.annotation.Autowired;  
6 -import org.springframework.web.bind.annotation.RequestMapping;  
7 -import org.springframework.web.bind.annotation.RequestParam;  
8 -import org.springframework.web.bind.annotation.RestController;  
9 -  
10 -import java.util.Map;  
11 -  
12 -/**  
13 - * 数据管理,包括从老系统的数据迁移。新系统的数据校验等  
14 - * Created by panzhao on 2017/4/17.  
15 - */  
16 -@RestController  
17 -@RequestMapping("dataManager")  
18 -public class DataManagerController {  
19 -  
20 - @Autowired  
21 - DataManagerService dataManagerService;  
22 -  
23 - @RequestMapping("cars/old_now")  
24 - public Map<String, Object> carInfos(@RequestParam Integer lineId){  
25 - return dataManagerService.carInfos(lineId);  
26 - }  
27 -  
28 - @RequestMapping("car/updateDevices")  
29 - public Map<String, Object> updateDevices(@RequestParam String jsonStr){  
30 - jsonStr = StringEscapeUtils.unescapeHtml4(jsonStr);  
31 - return dataManagerService.updateDevices(jsonStr);  
32 - }  
33 -} 1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.bsth.service.realcontrol.DataManagerService;
  4 +import org.apache.commons.lang3.StringEscapeUtils;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestParam;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +import java.util.Map;
  11 +
  12 +/**
  13 + * 数据管理,包括从老系统的数据迁移。新系统的数据校验等
  14 + * Created by panzhao on 2017/4/17.
  15 + */
  16 +//@RestController
  17 +@RequestMapping("dataManager")
  18 +public class DataManagerController {
  19 +
  20 + @Autowired
  21 + DataManagerService dataManagerService;
  22 +
  23 + @RequestMapping("cars/old_now")
  24 + public Map<String, Object> carInfos(@RequestParam Integer lineId){
  25 + return dataManagerService.carInfos(lineId);
  26 + }
  27 +
  28 + @RequestMapping("car/updateDevices")
  29 + public Map<String, Object> updateDevices(@RequestParam String jsonStr){
  30 + jsonStr = StringEscapeUtils.unescapeHtml4(jsonStr);
  31 + return dataManagerService.updateDevices(jsonStr);
  32 + }
  33 +}
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/entity/publish/ScanStatictic.java 0 → 100644
  1 +package com.bsth.entity.publish;
  2 +
  3 +public class ScanStatictic {
  4 +
  5 + private String rq;
  6 +
  7 + private String physicalCode;
  8 +
  9 + private String stationName;
  10 +
  11 + private int count;
  12 +
  13 + public String getRq() {
  14 + return rq;
  15 + }
  16 +
  17 + public void setRq(String rq) {
  18 + this.rq = rq;
  19 + }
  20 +
  21 + public String getPhysicalCode() {
  22 + return physicalCode;
  23 + }
  24 +
  25 + public void setPhysicalCode(String physicalCode) {
  26 + this.physicalCode = physicalCode;
  27 + }
  28 +
  29 + public String getStationName() {
  30 + return stationName;
  31 + }
  32 +
  33 + public void setStationName(String stationName) {
  34 + this.stationName = stationName;
  35 + }
  36 +
  37 + public int getCount() {
  38 + return count;
  39 + }
  40 +
  41 + public void setCount(int count) {
  42 + this.count = count;
  43 + }
  44 +}
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 + /**
  107 + * 限速值(0.01km/h)
  108 + */
  109 + private int speedLimit;
  110 +
  111 + /**
  112 + * 超速速度峰值(0.01km/h)
  113 + */
  114 + private int speedPeak;
  115 +
  116 + /**
  117 + * 超速持续时长(S)
  118 + */
  119 + private int duration;
  120 +
  121 + public String getClientId() {
  122 + return clientId;
  123 + }
  124 +
  125 + public void setClientId(String clientId) {
  126 + this.clientId = clientId;
  127 + }
  128 +
  129 + public String getVehicleCode() {
  130 + return vehicleCode;
  131 + }
  132 +
  133 + public void setVehicleCode(String vehicleCode) {
  134 + this.vehicleCode = vehicleCode;
  135 + }
  136 +
  137 + public String getDeviceId() {
  138 + return deviceId;
  139 + }
  140 +
  141 + public void setDeviceId(String deviceId) {
  142 + this.deviceId = deviceId;
  143 + }
  144 +
  145 + public String getVehiclePlate() {
  146 + return vehiclePlate;
  147 + }
  148 +
  149 + public void setVehiclePlate(String vehiclePlate) {
  150 + this.vehiclePlate = vehiclePlate;
  151 + }
  152 +
  153 + public List<String> getPaths() {
  154 + return paths;
  155 + }
  156 +
  157 + public void setPaths(List<String> paths) {
  158 + this.paths = paths;
  159 + }
  160 +
  161 + public String getAlarmId() {
  162 + return alarmId;
  163 + }
  164 +
  165 + public void setAlarmId(String alarmId) {
  166 + this.alarmId = alarmId;
  167 + }
  168 +
  169 + public int getType() {
  170 + return type;
  171 + }
  172 +
  173 + public void setType(int type) {
  174 + this.type = type;
  175 + }
  176 +
  177 + public int getLevel() {
  178 + return level;
  179 + }
  180 +
  181 + public void setLevel(int level) {
  182 + this.level = level;
  183 + }
  184 +
  185 + public int getFatigueDegree() {
  186 + return fatigueDegree;
  187 + }
  188 +
  189 + public void setFatigueDegree(int fatigueDegree) {
  190 + this.fatigueDegree = fatigueDegree;
  191 + }
  192 +
  193 + public int getReserves() {
  194 + return reserves;
  195 + }
  196 +
  197 + public void setReserves(int reserves) {
  198 + this.reserves = reserves;
  199 + }
  200 +
  201 + public int getSpeed() {
  202 + return speed;
  203 + }
  204 +
  205 + public void setSpeed(int speed) {
  206 + this.speed = speed;
  207 + }
  208 +
  209 + public int getAltitude() {
  210 + return altitude;
  211 + }
  212 +
  213 + public void setAltitude(int altitude) {
  214 + this.altitude = altitude;
  215 + }
  216 +
  217 + public int getLatitude() {
  218 + return latitude;
  219 + }
  220 +
  221 + public void setLatitude(int latitude) {
  222 + this.latitude = latitude;
  223 + }
  224 +
  225 + public int getLongitude() {
  226 + return longitude;
  227 + }
  228 +
  229 + public void setLongitude(int longitude) {
  230 + this.longitude = longitude;
  231 + }
  232 +
  233 + public long getAlarmTimeBegin() {
  234 + return alarmTimeBegin;
  235 + }
  236 +
  237 + public void setAlarmTimeBegin(long alarmTimeBegin) {
  238 + this.alarmTimeBegin = alarmTimeBegin;
  239 + }
  240 +
  241 + public long getAlarmTimeEnd() {
  242 + return alarmTimeEnd;
  243 + }
  244 +
  245 + public void setAlarmTimeEnd(long alarmTimeEnd) {
  246 + this.alarmTimeEnd = alarmTimeEnd;
  247 + }
  248 +
  249 + public int getStatusBit() {
  250 + return statusBit;
  251 + }
  252 +
  253 + public void setStatusBit(int statusBit) {
  254 + this.statusBit = statusBit;
  255 + }
  256 +
  257 + public String getAlarmType() {
  258 + return "dsm";
  259 + }
  260 +
  261 + public String getLineCode() {
  262 + return lineCode;
  263 + }
  264 +
  265 + @Override
  266 + public void setLineCode(String lineCode) {
  267 + this.lineCode = lineCode;
  268 + }
  269 +
  270 + public int getSpeedLimit() {
  271 + return speedLimit;
  272 + }
  273 +
  274 + public void setSpeedLimit(int speedLimit) {
  275 + this.speedLimit = speedLimit;
  276 + }
  277 +
  278 + public int getSpeedPeak() {
  279 + return speedPeak;
  280 + }
  281 +
  282 + public void setSpeedPeak(int speedPeak) {
  283 + this.speedPeak = speedPeak;
  284 + }
  285 +
  286 + public int getDuration() {
  287 + return duration;
  288 + }
  289 +
  290 + public void setDuration(int duration) {
  291 + this.duration = duration;
  292 + }
  293 +
  294 + public String getAttach() {
  295 + return String.format("峰值(km/h):%d[%d],持续(s):%d", speedPeak / 100, speedLimit/ 100, duration);
  296 + }
  297 +
  298 + @Override
  299 + public int hashCode() {
  300 + return String.format("%s_%d_%d", this.clientId, this.alarmTimeBegin, this.type).hashCode();
  301 + }
  302 +
  303 + @Override
  304 + public boolean equals(Object obj) {
  305 + AlarmDSMVo other = (AlarmDSMVo) obj;
  306 +
  307 + return this.clientId.equals(other.getClientId()) && this.alarmTimeBegin == other.getAlarmTimeBegin() && this.type == other.getType();
  308 + }
  309 +
  310 + @Override
  311 + public String toString() {
  312 + return "AlarmDSMVo{" +
  313 + "clientId='" + clientId + '\'' +
  314 + ", vehicleCode='" + vehicleCode + '\'' +
  315 + ", deviceId='" + deviceId + '\'' +
  316 + ", vehiclePlate='" + vehiclePlate + '\'' +
  317 + ", alarmId='" + alarmId + '\'' +
  318 + ", type=" + type +
  319 + ", level=" + level +
  320 + ", fatigueDegree=" + fatigueDegree +
  321 + ", reserves=" + reserves +
  322 + ", speed=" + speed +
  323 + ", altitude=" + altitude +
  324 + ", latitude=" + latitude +
  325 + ", longitude=" + longitude +
  326 + ", alarmTimeBegin=" + alarmTimeBegin +
  327 + ", alarmTimeEnd=" + alarmTimeEnd +
  328 + ", statusBit=" + statusBit +
  329 + ", paths=" + paths +
  330 + '}';
  331 + }
  332 +}
0 \ No newline at end of file 333 \ 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.fasterxml.jackson.databind.ObjectMapper;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.amqp.rabbit.annotation.RabbitHandler;
  12 +import org.springframework.amqp.rabbit.annotation.RabbitListener;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +import java.util.HashMap;
  18 +import java.util.Map;
  19 +
  20 +/**
  21 + * @author Hill
  22 + */
  23 +@Component
  24 +@ConditionalOnProperty("rabbit.use")
  25 +public class RabbitMessageHandler {
  26 +
  27 + private final static Logger log = LoggerFactory.getLogger(RabbitMessageHandler.class);
  28 +
  29 + @Autowired
  30 + private ObjectMapper mapper;
  31 +
  32 + @Autowired
  33 + GpsRealData gpsRealData;
  34 +
  35 + @RabbitHandler
  36 + @RabbitListener(queues = RabbitConfig.QUEUE_ALARM_SCHEDULE)
  37 + public void onAlarmScheduleMessage(String message) {
  38 + try {
  39 + AlarmVo alarmVo = null;
  40 + Map<String, Object> data = mapper.readValue(message, mapper.getTypeFactory().constructMapType(HashMap.class, String.class, Object.class));
  41 + if ("dsm".equals(data.get("alarmType"))) {
  42 + alarmVo = mapper.readValue(message, AlarmDSMVo.class);
  43 + } else if ("adas".equals(data.get("alarmType"))) {
  44 + alarmVo = mapper.readValue(message, AlarmADASVo.class);
  45 + } else if ("over-speed".equals(data.get("alarmType"))) {
  46 + alarmVo = mapper.readValue(message, AlarmDSMVo.class);
  47 + ((AlarmDSMVo)alarmVo).setType(17);
  48 + }
  49 + if (alarmVo != null) {
  50 + if (alarmVo.getVehicleCode() == null) {
  51 + log.warn("报警未匹配到车辆,alarmVo: {}", alarmVo);
  52 + return;
  53 + }
  54 + GpsEntity gps = gpsRealData.getByNbbm(alarmVo.getVehicleCode());
  55 + if (gps == null || gps.getLineId() == null) {
  56 + alarmVo.setLineCode("249231");
  57 + log.warn("报警未匹配到线路,alarmVo: {}", alarmVo);
  58 + } else {
  59 + alarmVo.setLineCode(gps.getLineId());
  60 + }
  61 + AlarmCenter.put(alarmVo);
  62 + }
  63 + } catch (Exception e) {
  64 + log.error("报警监听异常,message: {}", message, e);
  65 + }
  66 + }
  67 +}
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/service/gps/GpsServiceImpl.java
@@ -559,6 +559,22 @@ public class GpsServiceImpl implements GpsService { @@ -559,6 +559,22 @@ public class GpsServiceImpl implements GpsService {
559 public Map<String, ArrivalEntity> findArrivalByTs(Long st, Long et, List<DeviceChange> dcs) { 559 public Map<String, ArrivalEntity> findArrivalByTs(Long st, Long et, List<DeviceChange> dcs) {
560 Map<String, ArrivalEntity> map = new HashMap<>(); 560 Map<String, ArrivalEntity> map = new HashMap<>();
561 561
  562 + List<ArrivalEntity> list = findArrivalListByTs(st, et, dcs);
  563 +
  564 + String stationName, prefix;
  565 + for(ArrivalEntity arr : list){
  566 + prefix = arr.getLineCode() + "_" + arr.getUpDown() + "_";
  567 + stationName = BasicData.getStationNameByCode(arr.getStopNo(), prefix);
  568 +
  569 + arr.setStopName(stationName);
  570 +
  571 + // 反转进出状态
  572 + map.put(arr.getDeviceId() + "_" + arr.getTs(), arr);
  573 + }
  574 + return map;
  575 + }
  576 +
  577 + private List<ArrivalEntity> findArrivalListByTs(Long st, Long et, List<DeviceChange> dcs) {
562 // weeks_year 分区字段 578 // weeks_year 分区字段
563 Calendar sCal = Calendar.getInstance(); 579 Calendar sCal = Calendar.getInstance();
564 sCal.setTime(new Date(st)); 580 sCal.setTime(new Date(st));
@@ -591,21 +607,10 @@ public class GpsServiceImpl implements GpsService { @@ -591,21 +607,10 @@ public class GpsServiceImpl implements GpsService {
591 sql.append(" UNION "); 607 sql.append(" UNION ");
592 } 608 }
593 609
594 - logger.info("arrivl sql : " + sql.toString()); 610 + logger.info("arrival sql : " + sql.toString());
595 JdbcTemplate jdbcTemplate_ms = new JdbcTemplate(DBUtils_MS.getDataSource()); 611 JdbcTemplate jdbcTemplate_ms = new JdbcTemplate(DBUtils_MS.getDataSource());
596 - List<ArrivalEntity> list = jdbcTemplate_ms.query(sql.toString(), BeanPropertyRowMapper.newInstance(ArrivalEntity.class));  
597 -  
598 - String stationName, prefix;  
599 - for(ArrivalEntity arr : list){  
600 - prefix = arr.getLineCode() + "_" + arr.getUpDown() + "_";  
601 - stationName = BasicData.getStationNameByCode(arr.getStopNo(), prefix);  
602 612
603 - arr.setStopName(stationName);  
604 -  
605 - // 反转进出状态  
606 - map.put(arr.getDeviceId() + "_" + arr.getTs(), arr);  
607 - }  
608 - return map; 613 + return jdbcTemplate_ms.query(sql.toString(), BeanPropertyRowMapper.newInstance(ArrivalEntity.class));
609 } 614 }
610 615
611 616
@@ -1074,7 +1079,55 @@ public class GpsServiceImpl implements GpsService { @@ -1074,7 +1079,55 @@ public class GpsServiceImpl implements GpsService {
1074 1079
1075 @Override 1080 @Override
1076 public void arrivalExcel(String nbbm, long st, long et, HttpServletResponse resp) { 1081 public void arrivalExcel(String nbbm, long st, long et, HttpServletResponse resp) {
  1082 + st = st * 1000;
  1083 + et = et * 1000;
  1084 + List<DeviceChange> dcs = findDeviceChangeLogs(nbbm, et, st);
  1085 + // 查询到离站数据
  1086 + List<ArrivalEntity> list = findArrivalListByTs(st, et, dcs);
1077 1087
  1088 + //创建excel工作簿
  1089 + Workbook wb = new HSSFWorkbook();
  1090 + Sheet sheet = wb.createSheet("到离站信息");
  1091 + //表头
  1092 + Row row = sheet.createRow(0);
  1093 + row.setHeight((short) (1.5 * 256));
  1094 + row.createCell(0).setCellValue("序号");
  1095 + row.createCell(1).setCellValue("车辆");
  1096 + row.createCell(2).setCellValue("牌照号");
  1097 + row.createCell(3).setCellValue("站名");
  1098 + row.createCell(4).setCellValue("时间");
  1099 + row.createCell(5).setCellValue("进/出站");
  1100 + //数据
  1101 + DateTimeFormatter fmtHHmmss = DateTimeFormat.forPattern("HH:mm.ss"), fmt = DateTimeFormat.forPattern("yyyyMMddHHmm");
  1102 + ArrivalEntity arrival;
  1103 + String prefix, stationName;
  1104 + for(int i = 0; i < list.size(); i ++){
  1105 + arrival = list.get(i);
  1106 + prefix = arrival.getLineCode() + "_" + arrival.getUpDown() + "_";
  1107 + stationName = BasicData.getStationNameByCode(arrival.getStopNo(), prefix);
  1108 + row = sheet.createRow(i + 1);
  1109 + row.createCell(0).setCellValue(i + 1);
  1110 + row.createCell(1).setCellValue(nbbm);
  1111 + row.createCell(2).setCellValue(BasicData.nbbmCompanyPlateMap.get(nbbm));
  1112 + row.createCell(3).setCellValue(stationName);
  1113 + row.createCell(4).setCellValue(fmtHHmmss.print(arrival.getTs()));
  1114 + row.createCell(5).setCellValue(arrival.getInOut() == 0 ? "进站" : "出站");
  1115 + }
  1116 +
  1117 + String filename = nbbm + "到离站数据" + fmt.print(st) + "至" + fmt.print(et) + ".xls";
  1118 + try {
  1119 + resp.setContentType("application/x-msdownload");
  1120 + resp.addHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
  1121 +
  1122 + OutputStream out=resp.getOutputStream();
  1123 + wb.write(out);
  1124 + out.flush();
  1125 + out.close();
  1126 + } catch (UnsupportedEncodingException e) {
  1127 + logger.error("", e);
  1128 + } catch (IOException e) {
  1129 + logger.error("", e);
  1130 + }
1078 } 1131 }
1079 1132
1080 @Override 1133 @Override
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
@@ -710,6 +710,9 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -710,6 +710,9 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
710 String sleepStr = ""; 710 String sleepStr = "";
711 // 方向 711 // 方向
712 int directions = objects.get(i)[8]==null ? null : Integer.valueOf(objects.get(i)[8].toString()); 712 int directions = objects.get(i)[8]==null ? null : Integer.valueOf(objects.get(i)[8].toString());
  713 + if (directions == 1) {
  714 + stationName = stationName.replaceAll("\\(起点站\\)", "").replaceAll("\\(终点站\\)", "").replaceAll("(起点站)", "").replaceAll("(终点站)", "");
  715 + }
713 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */ 716 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */
714 List<Object[]> sobje = sectionRouteRepository.sectionRouteVector(lineId,directions); 717 List<Object[]> sobje = sectionRouteRepository.sectionRouteVector(lineId,directions);
715 if(sobje.size()==1) { 718 if(sobje.size()==1) {
@@ -799,6 +802,9 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -799,6 +802,9 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
799 String sleepStr = ""; 802 String sleepStr = "";
800 // 方向 803 // 方向
801 int directions = objects.get(i)[8]==null ? null : Integer.valueOf(objects.get(i)[8].toString()); 804 int directions = objects.get(i)[8]==null ? null : Integer.valueOf(objects.get(i)[8].toString());
  805 + if (directions == 1) {
  806 + stationName = stationName.replaceAll("\\(起点站\\)", "").replaceAll("\\(终点站\\)", "").replaceAll("(起点站)", "").replaceAll("(终点站)", "");
  807 + }
802 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */ 808 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */
803 List<Object[]> sobje = sectionRouteRepository.sectionRouteVector(lineId,directions); 809 List<Object[]> sobje = sectionRouteRepository.sectionRouteVector(lineId,directions);
804 if(sobje.size()==1) { 810 if(sobje.size()==1) {
src/main/java/com/bsth/service/publish/InfoPublishService.java 0 → 100644
  1 +package com.bsth.service.publish;
  2 +
  3 +import java.util.Map;
  4 +
  5 +public interface InfoPublishService {
  6 +
  7 + Map<String, Object> list(Map<String, String> map, int page, int size, String order, int direction);
  8 +
  9 + Map<String, Object> export(Map<String, String> map);
  10 +}
src/main/java/com/bsth/service/publish/impl/InfoPublishServiceImpl.java 0 → 100644
  1 +package com.bsth.service.publish.impl;
  2 +
  3 +import com.bsth.entity.publish.ScanStatictic;
  4 +import com.bsth.service.publish.InfoPublishService;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.beans.factory.annotation.Qualifier;
  7 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  8 +import org.springframework.jdbc.core.JdbcTemplate;
  9 +import org.springframework.stereotype.Service;
  10 +import org.springframework.util.StringUtils;
  11 +
  12 +import java.util.*;
  13 +
  14 +@Service
  15 +public class InfoPublishServiceImpl implements InfoPublishService {
  16 +
  17 + @Autowired
  18 + @Qualifier("infoPublishJdbcTemplate")
  19 + private JdbcTemplate infoPublishJdbcTemplate;
  20 +
  21 + @Override
  22 + public Map<String, Object> list(Map<String, String> map, int page, int size, String order, int direction) {
  23 + Map<String, Object> result = new HashMap<>();
  24 + StringBuilder query = new StringBuilder("SELECT ? rq, physicalCode physical_code, stationName station_name,count(1) `count` FROM bsth_h_scan where 1 = 1");
  25 + List<Object> params = new ArrayList<>();
  26 + params.add(map.get("rq"));
  27 + for (Map.Entry<String, String> entry : map.entrySet()) {
  28 + String key = entry.getKey(), value = entry.getValue();
  29 + if (StringUtils.isEmpty(key) || ",page,size,order,direction,".indexOf(String.format(",%s,", key)) > -1) {
  30 + continue;
  31 + }
  32 + if ("rq".equals(key)) {
  33 + query.append(" and rq between ? and ?");
  34 + String[] rqs = value.split("-");
  35 + if (rqs.length != 2) {
  36 + throw new RuntimeException("异常的起止日期");
  37 + }
  38 + for (String rq : rqs) {
  39 + params.add(rq);
  40 + }
  41 + } else {
  42 + query.append(" and ").append(key).append(" like concat(?, '%')");
  43 + params.add(value);
  44 + }
  45 + }
  46 + query.append(" GROUP BY physicalCode, stationName");
  47 + StringBuilder count = new StringBuilder("SELECT COUNT(*) FROM (").append(query).append(") t");
  48 + Integer total = infoPublishJdbcTemplate.queryForObject(count.toString(), params.toArray(), Integer.class);
  49 + query.append(" ORDER BY physicalCode LIMIT ").append(page * size).append(",").append(size);
  50 + List<ScanStatictic> data = infoPublishJdbcTemplate.query(query.toString(), params.toArray(), BeanPropertyRowMapper.newInstance(ScanStatictic.class));
  51 + result.put("list", data);
  52 + result.put("totalPages", total % size == 0 ? total / size - 1 : total / size);
  53 +
  54 + return result;
  55 + }
  56 +
  57 + @Override
  58 + public Map<String, Object> export(Map<String, String> map) {
  59 + Map<String, Object> result = new HashMap<>();
  60 + StringBuilder query = new StringBuilder("SELECT ? rq, physicalCode, stationName,count(1) `count` FROM bsth_h_scan where 1 = 1");
  61 + List<Object> params = new ArrayList<>();
  62 + params.add(map.get("rq"));
  63 + for (Map.Entry<String, String> entry : map.entrySet()) {
  64 + String key = entry.getKey(), value = entry.getValue();
  65 + if ("rq".equals(key)) {
  66 + query.append(" and rq between ? and ?");
  67 + String[] rqs = value.split("-");
  68 + if (rqs.length != 2) {
  69 + throw new RuntimeException("异常的起止日期");
  70 + }
  71 + for (String rq : rqs) {
  72 + params.add(rq);
  73 + }
  74 + } else {
  75 + query.append(" and ").append(key).append(" like concat(?, '%')");
  76 + params.add(value);
  77 + }
  78 + }
  79 + query.append(" GROUP BY physicalCode, stationName");
  80 + query.append(" ORDER BY physicalCode");
  81 + List<Iterator<?>> iterators = new ArrayList<>();
  82 + iterators.add(infoPublishJdbcTemplate.queryForList(query.toString(), params.toArray()).iterator());
  83 + result.put("list", iterators);
  84 +
  85 + return result;
  86 + }
  87 +}
src/main/java/com/bsth/service/realcontrol/impl/DataManagerServiceImpl.java
1 -package com.bsth.service.realcontrol.impl;  
2 -  
3 -import com.alibaba.fastjson.JSONArray;  
4 -import com.alibaba.fastjson.JSONObject;  
5 -import com.bsth.common.ResponseCode;  
6 -import com.bsth.data.BasicData;  
7 -import com.bsth.entity.Cars;  
8 -import com.bsth.repository.CarsRepository;  
9 -import com.bsth.service.realcontrol.DataManagerService;  
10 -import com.bsth.util.db.DBUtils_oldSystem;  
11 -import org.slf4j.Logger;  
12 -import org.slf4j.LoggerFactory;  
13 -import org.springframework.beans.factory.annotation.Autowired;  
14 -import org.springframework.jdbc.core.JdbcTemplate;  
15 -import org.springframework.stereotype.Service;  
16 -  
17 -import java.util.ArrayList;  
18 -import java.util.HashMap;  
19 -import java.util.List;  
20 -import java.util.Map;  
21 -  
22 -/**  
23 - * Created by panzhao on 2017/4/18.  
24 - */  
25 -@Service  
26 -public class DataManagerServiceImpl implements DataManagerService{  
27 -  
28 - @Autowired  
29 - CarsRepository carsRepository;  
30 -  
31 - @Autowired  
32 - JdbcTemplate controlJdbcTemp;  
33 -  
34 - @Autowired  
35 - BasicData.BasicDataLoader dataLoader;  
36 -  
37 - Logger logger = LoggerFactory.getLogger(this.getClass());  
38 -  
39 - @Override  
40 - public Map<String, Object> carInfos(Integer lineId) {  
41 -  
42 - Map<String, Object> rs = new HashMap<>();  
43 - try {  
44 - List<Map<String, String>> nowData = new ArrayList<>();  
45 - List<Map<String, String>> oldData = new ArrayList<>();  
46 - Map<String, String> map;  
47 -  
48 - //查询新系统车辆信息  
49 - List<Cars> list = carsRepository.findCarsByLineId(lineId);  
50 - for(Cars c : list){  
51 - map = new HashMap<>();  
52 - map.put("nbbm", c.getInsideCode());  
53 - map.put("device", c.getEquipmentCode());  
54 - nowData.add(map);  
55 - }  
56 -  
57 - //获取老系统数据  
58 - JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_oldSystem.getDataSource());  
59 - List<Map<String, Object>> oyList = jdbcTemplate.queryForList("select NBBM,SBBH from JJWGPS_T_CLXXB t where xlbm=?", BasicData.lineId2CodeMap.get(lineId));  
60 - for(Map<String, Object> tempMap : oyList){  
61 - map = new HashMap<>();  
62 - map.put("nbbm", tempMap.get("NBBM").toString());  
63 - map.put("device", tempMap.get("SBBH").toString());  
64 - oldData.add(map);  
65 - }  
66 -  
67 - rs.put("status", ResponseCode.SUCCESS);  
68 - rs.put("nows", nowData);  
69 - rs.put("olds", oldData);  
70 - }catch (Exception e){  
71 - logger.error("", e);  
72 - rs.put("status", ResponseCode.ERROR);  
73 - rs.put("msg", e.getMessage());  
74 - }  
75 -  
76 - return rs;  
77 - }  
78 -  
79 - /**  
80 - * 更新设备号  
81 - * @param jsonStr  
82 - * @return  
83 - */  
84 - @Override  
85 - public Map<String, Object> updateDevices(String jsonStr) {  
86 - Map<String, Object> rs = new HashMap<>();  
87 - try {  
88 - int count=0;  
89 - JSONArray array = JSONArray.parseArray(jsonStr);  
90 - JSONObject jObj;  
91 - for(int i = 0; i < array.size(); i ++){  
92 - jObj = array.getJSONObject(i);  
93 - count += controlJdbcTemp.update("update bsth_c_cars set equipment_code=? where inside_code=?"  
94 - , jObj.getString("device"), jObj.getString("nbbm"));  
95 - }  
96 -  
97 - //刷新缓存  
98 - dataLoader.loadDeviceInfo();  
99 - rs.put("status", ResponseCode.SUCCESS);  
100 - rs.put("count", count);  
101 - }catch (Exception e){  
102 - logger.error("", e);  
103 - rs.put("status", ResponseCode.ERROR);  
104 - rs.put("msg", e.getMessage());  
105 - }  
106 - return rs;  
107 - }  
108 -} 1 +package com.bsth.service.realcontrol.impl;
  2 +
  3 +import com.alibaba.fastjson.JSONArray;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.bsth.common.ResponseCode;
  6 +import com.bsth.data.BasicData;
  7 +import com.bsth.entity.Cars;
  8 +import com.bsth.repository.CarsRepository;
  9 +import com.bsth.service.realcontrol.DataManagerService;
  10 +import com.bsth.util.db.DBUtils_oldSystem;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.jdbc.core.JdbcTemplate;
  15 +import org.springframework.stereotype.Service;
  16 +
  17 +import java.util.ArrayList;
  18 +import java.util.HashMap;
  19 +import java.util.List;
  20 +import java.util.Map;
  21 +
  22 +/**
  23 + * Created by panzhao on 2017/4/18.
  24 + */
  25 +//@Service
  26 +public class DataManagerServiceImpl implements DataManagerService{
  27 +
  28 + @Autowired
  29 + CarsRepository carsRepository;
  30 +
  31 + @Autowired
  32 + JdbcTemplate controlJdbcTemp;
  33 +
  34 + @Autowired
  35 + BasicData.BasicDataLoader dataLoader;
  36 +
  37 + Logger logger = LoggerFactory.getLogger(this.getClass());
  38 +
  39 + @Override
  40 + public Map<String, Object> carInfos(Integer lineId) {
  41 +
  42 + Map<String, Object> rs = new HashMap<>();
  43 + try {
  44 + List<Map<String, String>> nowData = new ArrayList<>();
  45 + List<Map<String, String>> oldData = new ArrayList<>();
  46 + Map<String, String> map;
  47 +
  48 + //查询新系统车辆信息
  49 + List<Cars> list = carsRepository.findCarsByLineId(lineId);
  50 + for(Cars c : list){
  51 + map = new HashMap<>();
  52 + map.put("nbbm", c.getInsideCode());
  53 + map.put("device", c.getEquipmentCode());
  54 + nowData.add(map);
  55 + }
  56 +
  57 + //获取老系统数据
  58 + JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_oldSystem.getDataSource());
  59 + List<Map<String, Object>> oyList = jdbcTemplate.queryForList("select NBBM,SBBH from JJWGPS_T_CLXXB t where xlbm=?", BasicData.lineId2CodeMap.get(lineId));
  60 + for(Map<String, Object> tempMap : oyList){
  61 + map = new HashMap<>();
  62 + map.put("nbbm", tempMap.get("NBBM").toString());
  63 + map.put("device", tempMap.get("SBBH").toString());
  64 + oldData.add(map);
  65 + }
  66 +
  67 + rs.put("status", ResponseCode.SUCCESS);
  68 + rs.put("nows", nowData);
  69 + rs.put("olds", oldData);
  70 + }catch (Exception e){
  71 + logger.error("", e);
  72 + rs.put("status", ResponseCode.ERROR);
  73 + rs.put("msg", e.getMessage());
  74 + }
  75 +
  76 + return rs;
  77 + }
  78 +
  79 + /**
  80 + * 更新设备号
  81 + * @param jsonStr
  82 + * @return
  83 + */
  84 + @Override
  85 + public Map<String, Object> updateDevices(String jsonStr) {
  86 + Map<String, Object> rs = new HashMap<>();
  87 + try {
  88 + int count=0;
  89 + JSONArray array = JSONArray.parseArray(jsonStr);
  90 + JSONObject jObj;
  91 + for(int i = 0; i < array.size(); i ++){
  92 + jObj = array.getJSONObject(i);
  93 + count += controlJdbcTemp.update("update bsth_c_cars set equipment_code=? where inside_code=?"
  94 + , jObj.getString("device"), jObj.getString("nbbm"));
  95 + }
  96 +
  97 + //刷新缓存
  98 + dataLoader.loadDeviceInfo();
  99 + rs.put("status", ResponseCode.SUCCESS);
  100 + rs.put("count", count);
  101 + }catch (Exception e){
  102 + logger.error("", e);
  103 + rs.put("status", ResponseCode.ERROR);
  104 + rs.put("msg", e.getMessage());
  105 + }
  106 + return rs;
  107 + }
  108 +}
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")));