Commit 10ee41d7 by 熊付

【繁星2.0首页】

1 parent 58d587e3
Showing 31 changed files with 760 additions and 36 deletions
...@@ -16,7 +16,7 @@ buildscript { ...@@ -16,7 +16,7 @@ buildscript {
*/ */
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'war' apply plugin: 'war'
apply plugin: 'idea' //apply plugin: 'idea'
// 使用spring boot // 使用spring boot
apply plugin: "org.springframework.boot" apply plugin: "org.springframework.boot"
// 使用spring boot的自动依赖管理 // 使用spring boot的自动依赖管理
...@@ -29,8 +29,10 @@ sourceCompatibility = 1.8 ...@@ -29,8 +29,10 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked' // Try to turn them all off automatically
options.deprecation = true options.compilerArgs << '-Xlint:none'
options.compilerArgs << '-nowarn' // same as '-Xlint:none'
options.compilerArgs << '-Xlint:-unchecked'
} }
repositories { repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
...@@ -58,20 +60,23 @@ dependencies { ...@@ -58,20 +60,23 @@ dependencies {
compile ("org.springframework.kafka:spring-kafka") compile ("org.springframework.kafka:spring-kafka")
compile ("org.apache.activemq:activemq-pool") compile ("org.apache.activemq:activemq-pool")
compile ('org.springframework.cloud:spring-cloud-starter-openfeign:2.1.3.RELEASE') compile ('org.springframework.cloud:spring-cloud-starter-openfeign:2.1.3.RELEASE')
compile('org.springframework.boot:spring-boot-starter-web-services')
compile('org.springframework.cloud:spring-cloud-starter-openfeign')
//compile('org.springframework.cloud:spring-cloud-starter-config')
// compileOnly('org.springframework.boot:spring-boot-starter-tomcat')s // compileOnly('org.springframework.boot:spring-boot-starter-tomcat')s
// hibernate 集成 // hibernate 集成
compile('org.hibernate:hibernate-core:5.2.12.Final') compile('org.hibernate:hibernate-core:5.2.12.Final')
compile('org.hibernate:hibernate-entitymanager:5.2.12.Final') compile('org.hibernate:hibernate-entitymanager:5.2.12.Final')
compile('org.hibernate:hibernate-ehcache:5.2.12.Final') compile('org.hibernate:hibernate-ehcache:5.2.12.Final')
compile('com.fasterxml.jackson.datatype:jackson-datatype-hibernate5:2.9.4') compile('com.fasterxml.jackson.datatype:jackson-datatype-hibernate5:2.9.4')
compile("org.postgresql:postgresql:9.3-1102-jdbc41") compile("org.postgresql:postgresql:42.2.8")
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5' compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'org.springframework:spring-core' compile 'org.springframework:spring-core'
compile group: 'com.alibaba', name: 'druid', version: '1.0.18' compile group: 'com.alibaba', name: 'druid', version: '1.0.18'
compile group: 'com.alibaba', name: 'fastjson', version: '1.2.47' compile group: 'com.alibaba', name: 'fastjson', version: '1.2.47'
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.4' compile group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
annotationProcessor 'org.projectlombok:lombok'
compile("org.apache.commons:commons-lang3:3.5") compile("org.apache.commons:commons-lang3:3.5")
compile("net.sf.json-lib:json-lib:2.4:jdk15") compile("net.sf.json-lib:json-lib:2.4:jdk15")
} }
\ No newline at end of file \ No newline at end of file
server:
port: 8086
spring:
main:
allow-bean-definition-overriding: true
datasource:
url: jdbc:postgresql://192.168.9.133:5432/event_data_handle
username: postgres
password: authpass
# 使用druid数据源
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.postgresql.Driver
# 下面为连接池的补充设置,应用到上面所有数据源中
# 初始化大小,最小,最大
initialSize: 5
minIdle: 5
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
jpa:
show-sql: true
database: postgresql
hibernate:
ddl-auto: update
#database-platform: org.hibernate.dialect.PostgreSQL9Dialect
database-platform: com.viontech.common.JsonbPostgresDialect
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQL9Dialect
hbm2ddl:
auto: update
temp:
use_jdbc_metadata_defaults: false
format_sql: true
activemq:
user: admin
password: admin
broker-url: tcp://192.168.9.133:61616
jms:
pub-sub-domain: false
message:
audit:
isOpen: true
httpUrl: 127.0.0.1:16060
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,7 @@ package com.viontech; ...@@ -2,6 +2,7 @@ package com.viontech;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -9,13 +10,15 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -9,13 +10,15 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter; import org.springframework.web.filter.CorsFilter;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
@SpringBootApplication(scanBasePackages = {"com.viontech.*"}) @SpringBootApplication(scanBasePackages = {"com.viontech.*"})
@Configuration @Configuration
@EnableScheduling @EnableScheduling
@EnableFeignClients @EnableFeignClients
public class Application { @EnableWebSocket
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Application.class, args); SpringApplication.run(Application.class, args);
} }
...@@ -40,7 +43,7 @@ public class Application { ...@@ -40,7 +43,7 @@ public class Application {
return converter; return converter;
}*/ }*/
@Configuration /*@Configuration
public class CorsConfig { public class CorsConfig {
@Bean @Bean
public CorsFilter corsFilter() { public CorsFilter corsFilter() {
...@@ -54,5 +57,5 @@ public class Application { ...@@ -54,5 +57,5 @@ public class Application {
configSource.registerCorsConfiguration("/**", config); configSource.registerCorsConfiguration("/**", config);
return new CorsFilter(configSource); return new CorsFilter(configSource);
} }
} }*/
} }
package com.viontech.common;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
/**
* @program: event_data_handle
* @description: 通用的 Builder 模式构建器
* @author: authorName
* @create: 2020-03-23 12:06
**/
public class Builder<T> {
private final Supplier<T> instantiator;
private List<Consumer<T>> modifiers = new ArrayList<>();
public Builder(Supplier<T> instantiator) {
this.instantiator = instantiator;
}
public static <T> Builder<T> of(Supplier<T> instantiator) {
return new Builder<>(instantiator);
}
public <P1> Builder<T> with(Consumer1<T, P1> consumer, P1 p1) {
Consumer<T> c = instance -> consumer.accept(instance, p1);
modifiers.add(c);
return this;
}
public <P1, P2> Builder<T> with(Consumer2<T, P1, P2> consumer, P1 p1, P2 p2) {
Consumer<T> c = instance -> consumer.accept(instance, p1, p2);
modifiers.add(c);
return this;
}
public <P1, P2, P3> Builder<T> with(Consumer3<T, P1, P2, P3> consumer, P1 p1, P2 p2, P3 p3) {
Consumer<T> c = instance -> consumer.accept(instance, p1, p2, p3);
modifiers.add(c);
return this;
}
public T build() {
T value = instantiator.get();
modifiers.forEach(modifier -> modifier.accept(value));
modifiers.clear();
return value;
}
/**
* 1 参数 Consumer
*/
@FunctionalInterface
public interface Consumer1<T, P1> {
void accept(T t, P1 p1);
}
/**
* 2 参数 Consumer
*/
@FunctionalInterface
public interface Consumer2<T, P1, P2> {
void accept(T t, P1 p1, P2 p2);
}
/**
* 3 参数 Consumer
*/
@FunctionalInterface
public interface Consumer3<T, P1, P2, P3> {
void accept(T t, P1 p1, P2 p2, P3 p3);
}
}
...@@ -7,7 +7,7 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter; ...@@ -7,7 +7,7 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/*** /***
* 当使用springboot启动时打开即可 不然websocket不起作用 若是使用tomcat启动则必须关闭 * 当使用springboot启动时打开即可 不然websocket不起作用 若是使用tomcat启动则必须关闭
*/ */
@Configuration //@Configuration
public class WebSocketConfig { public class WebSocketConfig {
@Bean @Bean
......
package com.viontech.consumer; package com.viontech.consumer;
import com.viontech.controller.websocket.WebsocketController;
import com.viontech.service.adapter.behavior.IBehaviorEventService; import com.viontech.service.adapter.behavior.IBehaviorEventService;
import com.viontech.util.JavaBean2Json; import com.viontech.util.JavaBean2Json;
import com.viontech.vo.EventDataVo; import com.viontech.vo.EventDataVo;
...@@ -18,6 +19,11 @@ public class BehaviorDataConsumer { ...@@ -18,6 +19,11 @@ public class BehaviorDataConsumer {
@JmsListener(destination = "behavior") @JmsListener(destination = "behavior")
public void reciveDate(String msg){ public void reciveDate(String msg){
try {
WebsocketController.broadcast(msg);
} catch (Exception e) {
e.printStackTrace();
}
iBehaviorService.recvBehaviorData(JavaBean2Json.Json2JavaBean(msg, EventDataVo.class)); iBehaviorService.recvBehaviorData(JavaBean2Json.Json2JavaBean(msg, EventDataVo.class));
} }
} }
package com.viontech.consumer;
import com.viontech.controller.websocket.WebsocketController;
import com.viontech.service.adapter.traffic.ITrafficEventService;
import com.viontech.util.JavaBean2Json;
import com.viontech.vo.EventDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
/**
* @program: event_data_handle
* @description: 交通类型事件消费者
* @author: authorName
* @create: 2019-12-26 14:23
**/
@Component
public class TrafficDataConsumer {
@Autowired
ITrafficEventService iTrafficEventService;
@JmsListener(destination = "traffic")
public void reciveDate(String msg){
try {
WebsocketController.broadcast(msg);
} catch (Exception e) {
e.printStackTrace();
}
iTrafficEventService.recvTrafficData(JavaBean2Json.Json2JavaBean(msg, EventDataVo.class));
}
}
...@@ -11,19 +11,26 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -11,19 +11,26 @@ import org.springframework.web.bind.annotation.RestController;
public class BehaviorStatisticsController extends BaseController { public class BehaviorStatisticsController extends BaseController {
@Autowired @Autowired
IBehaviorStatisticsService iBehaviorStatisticsService; IBehaviorStatisticsService iBehaviorStatisticsService;
@GetMapping("/statistics/type") @GetMapping("/statistics/behavior/type")
@ResponseBody @ResponseBody
public Object statisticsByType(BehaviorStatisticsVo behaviorStatisticsVo){ public Object statisticsByType(BehaviorStatisticsVo behaviorStatisticsVo){
return iBehaviorStatisticsService.statisticsByType(behaviorStatisticsVo); return iBehaviorStatisticsService.statisticsByType(behaviorStatisticsVo);
} }
@GetMapping("/statistics/hour") @GetMapping("/statistics/behavior/hour")
@ResponseBody @ResponseBody
public Object hourChart(BehaviorStatisticsVo behaviorStatisticsVo){ public Object hourChart(BehaviorStatisticsVo behaviorStatisticsVo){
return iBehaviorStatisticsService.hourChart(behaviorStatisticsVo); return iBehaviorStatisticsService.hourChart(behaviorStatisticsVo);
} }
@GetMapping("/statistics/handle")
@GetMapping("/statistics/behavior/handle")
@ResponseBody @ResponseBody
Object statisticsByEventHandle(BehaviorStatisticsVo behaviorStatisticsVo){ Object statisticsByEventHandle(BehaviorStatisticsVo behaviorStatisticsVo){
return iBehaviorStatisticsService.statisticsByEventHandle(behaviorStatisticsVo); return iBehaviorStatisticsService.statisticsByEventHandle(behaviorStatisticsVo);
} }
@GetMapping("/statistics/behavior/snap")
@ResponseBody
Object snapStatistics(BehaviorStatisticsVo behaviorStatisticsVo){
return iBehaviorStatisticsService.snapStatistics(behaviorStatisticsVo);
}
} }
package com.viontech.controller;
import com.viontech.service.adapter.traffic.ITrafficStatisticsService;
import com.viontech.vo.TrafficStatisticsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
* @program: event_data_handle
* @description: 交通事件统计控制层
* @author: authorName
* @create: 2020-01-03 11:13
**/
@RestController
public class TrafficEventStatisticsController extends BaseController{
@Autowired
ITrafficStatisticsService iTrafficStatisticsService;
@GetMapping("/statistics/traffic/type")
@ResponseBody
public Object statisticsByType(TrafficStatisticsVo trafficStatisticsVo){
return iTrafficStatisticsService.statisticsByType(trafficStatisticsVo);
}
@GetMapping("/statistics/traffic/hour")
@ResponseBody
public Object hourChart(TrafficStatisticsVo trafficStatisticsVo){
return iTrafficStatisticsService.hourChart(trafficStatisticsVo);
}
@GetMapping("/statistics/traffic/handle")
@ResponseBody
Object statisticsByEventHandle(TrafficStatisticsVo trafficStatisticsVo){
return iTrafficStatisticsService.statisticsByEventHandle(trafficStatisticsVo);
}
@GetMapping("/statistics/traffic/snap")
@ResponseBody
Object snapStatistics(TrafficStatisticsVo trafficStatisticsVo){
return iTrafficStatisticsService.snapStatistics(trafficStatisticsVo);
}
@GetMapping("/statistics/traffic/key/vehicle")
@ResponseBody
Object keyVehicleStatistics(TrafficStatisticsVo trafficStatisticsVo){
return iTrafficStatisticsService.keyVehicleStatistics(trafficStatisticsVo);
}
}
package com.viontech.controller;
import com.viontech.service.adapter.IVachanConfService;
import com.viontech.vo.VchanConfVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
* @program: event_data_handle
* @description: 视频通道配置
* @author: authorName
* @create: 2020-03-23 13:14
**/
@RestController
public class VchanConfController extends BaseController {
@Autowired
IVachanConfService iVachanConfService;
@PostMapping(value = "/vchan/conf")
@ResponseBody
public Object add(@RequestBody VchanConfVo vchanConfVo){
iVachanConfService.add(vchanConfVo);
Map result = new HashMap<>(2);
result.put("ecode","200");
result.put("enote","OK");
return result;
}
@PostMapping(value = "/vchan/conf/{unid}")
@ResponseBody
public Object update(@RequestBody VchanConfVo vchanConfVo, @PathVariable("unid") Integer unid){
vchanConfVo.setVchanConfUnid(unid);
iVachanConfService.update(vchanConfVo);
Map result = new HashMap<>(2);
result.put("ecode","200");
result.put("enote","OK");
return result;
}
@DeleteMapping(value = "/vchan/conf/{unid}")
@ResponseBody
public Object delete(VchanConfVo vchanConfVo, @PathVariable("unid") Integer unid){
vchanConfVo.setVchanConfUnid(unid);
iVachanConfService.delete(vchanConfVo);
Map result = new HashMap<>(2);
result.put("ecode","200");
result.put("enote","OK");
return result;
}
@GetMapping(value = "/vchan/conf")
@ResponseBody
public Object findAll(VchanConfVo vchanConfVo){
return iVachanConfService.findAll(vchanConfVo);
}
}
...@@ -80,7 +80,7 @@ public class BehaviorArchiveDaoImpl implements IBehaviorArchiveDao { ...@@ -80,7 +80,7 @@ public class BehaviorArchiveDaoImpl implements IBehaviorArchiveDao {
@Override @Override
public BehaviorArchiveVo deleteByUnid(Integer unid) { public BehaviorArchiveVo deleteByUnid(Integer unid) {
jdbcTemplate.execute("delete tb_event_archive_rel where archive_unid="+unid); jdbcTemplate.execute("delete tb_event_archive_rel where archive_unid="+unid);
eventArchiveRepository.deleteById(unid); //eventArchiveRepository.deleteById(unid);
return null; return null;
} }
......
...@@ -59,6 +59,9 @@ public class EventDataEntity { ...@@ -59,6 +59,9 @@ public class EventDataEntity {
private EventArchiveRelEntity eventArchiveRelEntity; private EventArchiveRelEntity eventArchiveRelEntity;
@OneToOne(mappedBy = "eventDataEntity",cascade={CascadeType.ALL,CascadeType.REMOVE})
private TrafficEntity trafficEntity;
@Column(name="is_archive") @Column(name="is_archive")
private Boolean isArchive=false; private Boolean isArchive=false;
...@@ -190,4 +193,12 @@ public class EventDataEntity { ...@@ -190,4 +193,12 @@ public class EventDataEntity {
public void setArchive(Boolean archive) { public void setArchive(Boolean archive) {
isArchive = archive; isArchive = archive;
} }
public TrafficEntity getTrafficEntity() {
return trafficEntity;
}
public void setTrafficEntity(TrafficEntity trafficEntity) {
this.trafficEntity = trafficEntity;
}
} }
package com.viontech.entity;
import lombok.Data;
import javax.persistence.*;
/**
* @program: event_data_handle
* @description: 交通事件信息实体
* @author: authorName
* @create: 2019-12-27 10:07
**/
@Entity
@Table(name = "tb_traffic")
@Data
public class TrafficEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer traffic_unid;
@Column(name ="plate_color_code")
private String plateColorCode;
@Column(name ="plate_text")
private String plateText;
@Column(name ="lane_code")
private String laneCode;
@Column(name ="direction_code")
private String directionCode;
@Column(name="body_type_code")
private String bodyTypeCode;
@Column(name ="illegal_code")
private String illegalCode;
@Column(name ="illegal_state")
private String illegalState;
@Column(name ="body_color_code")
private String bodyColorCode;
@Column(name="body_logo_code")
private String bodyLogoCode;
@Column(name="xcycle_type")
private String xcycleType;
@Column(name="special_type")
private String specialType;
@OneToOne
@JoinColumn(name = "event_unid")
private EventDataEntity eventDataEntity;
}
package com.viontech.entity;
import com.viontech.common.VionTechJsonbType;
import lombok.Data;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import javax.persistence.*;
/**
* @program: event_data_handle
* @description: 视频通道配置实体
* @author: authorName
* @create: 2020-03-23 11:29
**/
@Entity
@Table(name = "tb_vchan_conf")
@TypeDef(name = "json", typeClass = VionTechJsonbType.class)
@Data
public class VchanConfEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer vchan_conf_unid;
@Column(name = "name")
private String name;
@Column(name = "url")
private String url;
@Column(name = "is_active")
private Boolean isActive;
@Column(name = "original_json", nullable = true, columnDefinition = "jsonb")
@Type(type = "json")
private Object conf;
}
...@@ -38,8 +38,17 @@ public enum BehaviorTypeEnum { ...@@ -38,8 +38,17 @@ public enum BehaviorTypeEnum {
BEHAVIOR_lajiyichu("垃圾溢出"), BEHAVIOR_lajiyichu("垃圾溢出"),
BEHAVIOR_jinggaidiushi("井盖丢失"), BEHAVIOR_jinggaidiushi("井盖丢失"),
BEHAVIOR_jinggaiposun("井盖破损"), BEHAVIOR_jinggaiposun("井盖破损"),
BEHAVIOR_daobantingche("道板停车"); BEHAVIOR_daobantingche("道板停车"),
BEHAVIOR_cheliangzhuiwei("车辆追尾"),
BEHAVIOR_weidaimao("未带帽子"),
BEHAVIOR_zhuozhuobuguifan("着装不规范"),
BEHAVIOR_guardraildaodi("护栏倒地"),
BEHAVIOR_bycicleruti("自行车入楼"),
BEHAVIOR_motoruti("电动车入楼"),
BEHAVIOR_handcartruti("手推车入楼"),
BEHAVIOR_hengfu("横幅"),
BEHAVIOR_guanggaopai("移动广告牌"),
BEHAVIOR_yichangtingche("异常停车");
private String name; private String name;
BehaviorTypeEnum(String name){ BehaviorTypeEnum(String name){
this.name = name; this.name = name;
......
package com.viontech.repository;
import com.viontech.entity.TrafficEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface TrafficRepository extends JpaRepository<TrafficEntity, Integer>,
JpaSpecificationExecutor<TrafficEntity> {
}
package com.viontech.repository;
import com.viontech.entity.VchanConfEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @program: event_data_handle
* @description: 通道配置数据访问组件
* @author: authorName
* @create: 2020-03-23 11:35
**/
public interface VchanConfRepository extends JpaRepository<VchanConfEntity, Integer>,
JpaSpecificationExecutor<VchanConfEntity>{
}
package com.viontech.service.adapter;
import com.viontech.entity.VchanConfEntity;
import com.viontech.vo.VchanConfVo;
import java.util.List;
public interface IVachanConfService {
VchanConfVo add(VchanConfVo vchanConfVo);
VchanConfVo update(VchanConfVo vchanConfVo);
VchanConfVo delete(VchanConfVo vchanConfVo);
List<VchanConfEntity> findAll(VchanConfVo vchanConfVo);
}
...@@ -9,4 +9,6 @@ public interface IBehaviorStatisticsService { ...@@ -9,4 +9,6 @@ public interface IBehaviorStatisticsService {
Object hourChart(BehaviorStatisticsVo behaviorStatisticsVo); Object hourChart(BehaviorStatisticsVo behaviorStatisticsVo);
Object statisticsByEventHandle(BehaviorStatisticsVo behaviorStatisticsVo); Object statisticsByEventHandle(BehaviorStatisticsVo behaviorStatisticsVo);
Object snapStatistics(BehaviorStatisticsVo behaviorStatisticsVo);
} }
package com.viontech.service.adapter.traffic;
import com.viontech.vo.EventDataVo;
public interface ITrafficEventService {
Object recvTrafficData(EventDataVo eventDataVo);
}
package com.viontech.service.adapter.traffic;
import com.viontech.vo.TrafficStatisticsVo;
public interface ITrafficStatisticsService {
Object statisticsByType(TrafficStatisticsVo trafficStatisticsVo);
Object hourChart(TrafficStatisticsVo trafficStatisticsVo);
Object statisticsByEventHandle(TrafficStatisticsVo trafficStatisticsVo);
Object snapStatistics(TrafficStatisticsVo trafficStatisticsVo);
Object keyVehicleStatistics(TrafficStatisticsVo trafficStatisticsVo);
}
package com.viontech.service.impl;
import com.viontech.common.Builder;
import com.viontech.entity.VchanConfEntity;
import com.viontech.repository.VchanConfRepository;
import com.viontech.service.adapter.IVachanConfService;
import com.viontech.vo.VchanConfVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @program: event_data_handle
* @description: 通道配置业务类
* @author: authorName
* @create: 2020-03-23 11:47
**/
@Service
@Transactional
public class VchanConfServiceImpl implements IVachanConfService {
@Autowired
VchanConfRepository vchanConfRepository;
@Override
public VchanConfVo add(VchanConfVo vchanConfVo) {
VchanConfEntity vchanConfEntity = Builder.of(VchanConfEntity :: new)
.with(VchanConfEntity::setName,vchanConfVo.getName())
.with(VchanConfEntity:: setUrl,vchanConfVo.getUrl())
.with(VchanConfEntity::setConf,vchanConfVo.getConf())
.build();
vchanConfRepository.save(vchanConfEntity);
vchanConfVo.setVchanConfUnid(vchanConfEntity.getVchan_conf_unid());
return vchanConfVo;
}
@Override
public VchanConfVo update(VchanConfVo vchanConfVo) {
VchanConfEntity vchanConfEntity = Builder.of(VchanConfEntity :: new)
.with(VchanConfEntity::setName,vchanConfVo.getName())
.with(VchanConfEntity:: setUrl,vchanConfVo.getUrl())
.with(VchanConfEntity :: setVchan_conf_unid,vchanConfVo.getVchanConfUnid())
.with(VchanConfEntity::setConf,vchanConfVo.getConf())
.build();
vchanConfRepository.saveAndFlush(vchanConfEntity);
return vchanConfVo;
}
@Override
public VchanConfVo delete(VchanConfVo vchanConfVo) {
VchanConfEntity vchanConfEntity = Builder.of(VchanConfEntity :: new)
.with(VchanConfEntity :: setVchan_conf_unid,vchanConfVo.getVchanConfUnid())
.build();
vchanConfRepository.delete(vchanConfEntity);
return null;
}
@Override
public List<VchanConfEntity> findAll(VchanConfVo vchanConfVo) {
List<VchanConfEntity> VchanConfEntitys = vchanConfRepository.findAll(new Specification<VchanConfEntity>(){
@Override
public Predicate toPredicate(Root<VchanConfEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> predicates = new ArrayList<>();
if (StringUtils.isNotBlank(vchanConfVo.getName())){
predicates.add(cb.like(root.get("name").as(String.class),"'%"+vchanConfVo.getName()+"%'"));
}
if (StringUtils.isNotBlank(vchanConfVo.getUrl())){
predicates.add(cb.equal(root.get("url").as(String.class),vchanConfVo.getUrl()));
}
criteriaQuery.where(predicates.toArray(new Predicate[]{}));
return null;
}
});
return VchanConfEntitys;
}
}
...@@ -19,6 +19,7 @@ import org.springframework.data.domain.Sort; ...@@ -19,6 +19,7 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.persistence.criteria.*; import javax.persistence.criteria.*;
import java.util.List; import java.util.List;
...@@ -35,6 +36,8 @@ import java.util.Map; ...@@ -35,6 +36,8 @@ import java.util.Map;
EventDataRepository eventDataRepository; EventDataRepository eventDataRepository;
@Autowired @Autowired
public JdbcTemplate jdbcTemplate; public JdbcTemplate jdbcTemplate;
//@Autowired
//RestTemplate restTemplate;
@Override @Override
public Object recvBehaviorData(EventDataVo eventDataVo) { public Object recvBehaviorData(EventDataVo eventDataVo) {
...@@ -90,7 +93,7 @@ import java.util.Map; ...@@ -90,7 +93,7 @@ import java.util.Map;
@Override @Override
public Object deleteEventByUnid(Integer unid) { public Object deleteEventByUnid(Integer unid) {
jdbcTemplate.execute("delete from tb_event_archive_rel where event_unid="+unid); jdbcTemplate.execute("delete from tb_event_archive_rel where event_unid="+unid);
eventDataRepository.deleteById(unid); //eventDataRepository.deleteById(unid);
return null; return null;
} }
......
package com.viontech.service.impl.traffic;
import com.viontech.entity.EventDataEntity;
import com.viontech.entity.TrafficEntity;
import com.viontech.repository.EventDataRepository;
import com.viontech.repository.TrafficRepository;
import com.viontech.service.adapter.traffic.ITrafficEventService;
import com.viontech.util.DateUtil;
import com.viontech.util.JavaBean2Json;
import com.viontech.vo.EventDataVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.Map;
/**
* @program: event_data_handle
* @description: 交通业务层
* @author: authorName
* @create: 2019-12-26 14:30
**/
@Service
@Slf4j
public class TrafficEventServiceImpl implements ITrafficEventService {
@Autowired
EventDataRepository eventDataRepository;
@Autowired
TrafficRepository trafficRepository;
@Autowired
public JdbcTemplate jdbcTemplate;
@Override
@Transactional
public Object recvTrafficData(EventDataVo eventDataVo) {
try {
Map event_data = eventDataVo.getEvent_data();
EventDataEntity eventDataEntity = new EventDataEntity();
TrafficEntity trafficEntity = new TrafficEntity();
// 位置
if (event_data.containsKey("location")) {
Map location = (Map) event_data.get("location");
String code = (String) location.get("code");
String name = (String) location.get("name");
eventDataEntity.setLocationCode(code);
eventDataEntity.setLocationName(name);
}
// 车道
if (event_data.containsKey("lane")) {
Map lane = (Map) event_data.get("lane");
String code = (String) lane.get("code");
trafficEntity.setLaneCode(code);
}
//车辆
if (event_data.containsKey("vehicle")) {
Map vehicle = (Map) event_data.get("vehicle");
//车牌
if(vehicle.containsKey("plate")){
Map plate = (Map) vehicle.get("plate");
String plate_color_code = (String) plate.get("color_code");
trafficEntity.setPlateColorCode(plate_color_code);
String plate_text = (String) plate.get("text");
trafficEntity.setPlateText(plate_text);
}
//车身
if(vehicle.containsKey("body")){
Map body = (Map) vehicle.get("body");
Map color = (Map) body.get("color");
if(color != null){
trafficEntity.setBodyColorCode((String) color.get("code"));
}
Map type = (Map) body.get("type");
if(type != null){
trafficEntity.setBodyTypeCode((String) type.get("code"));
trafficEntity.setSpecialType(String.valueOf(type.get("special_type")));
}
Map logo = (Map) body.get("logo");
if(logo != null){
trafficEntity.setBodyLogoCode((String) logo.get("code"));
}
}
}
//车辆违法信息
if (event_data.containsKey("illegal")) {
Map illegal = (Map) event_data.get("illegal");
//违法类型编码
if(illegal.containsKey("code")){
trafficEntity.setIllegalCode((String) illegal.get("code"));
}
//违法信息是否可用
if(illegal.containsKey("state")){
trafficEntity.setIllegalState(String.valueOf(illegal.get("state")));
}
}
eventDataEntity.setEventCate(eventDataVo.getEvent_cate());
eventDataEntity.setEventDt(DateUtil.FORMAT_YYYY_MM_DD_HH_MM_SS_SSS.parse(eventDataVo.getEvent_dt()));
eventDataEntity.setEventRefid(eventDataVo.getEvent_refid());
eventDataEntity.setEventType(eventDataVo.getEvent_type());
eventDataEntity.setSourceType(eventDataVo.getSource_type());
eventDataEntity.setSubtaskId(eventDataVo.getSubtask_id());
eventDataEntity.setTaskId(eventDataVo.getTask_id());
eventDataEntity.setTaskType(eventDataVo.getTask_type());
eventDataEntity.setPics(eventDataVo.getPics());
eventDataEntity.setVideo(eventDataVo.getVideo());
eventDataEntity.setOriginalJson(JavaBean2Json.Json2JavaBean(JavaBean2Json.javaBean2Json(eventDataVo),Map.class));
eventDataEntity.setArchive(false);
eventDataRepository.save(eventDataEntity);
//交通类型
trafficEntity.setEventDataEntity(eventDataEntity);
trafficRepository.save(trafficEntity);
} catch (Exception e) {
log.error("新增behavior事件异常:"+e.getLocalizedMessage(),e);
}
return null;
}
}
package com.viontech.vo;
/**
* @program: event_data_handle
* @description: 报表统计基础类
* @author: authorName
* @create: 2019-12-26 14:38
**/
public class BaseStatisticsVo {
String start_dt;
String end_dt;
String eventType;
public String getStart_dt() {
return start_dt;
}
public void setStart_dt(String start_dt) {
this.start_dt = start_dt;
}
public String getEnd_dt() {
return end_dt;
}
public void setEnd_dt(String end_dt) {
this.end_dt = end_dt;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
}
package com.viontech.vo; package com.viontech.vo;
public class BehaviorStatisticsVo { public class BehaviorStatisticsVo extends BaseStatisticsVo{
String startDt;
String endDt;
public String getStartDt() {
return startDt;
}
public void setStartDt(String startDt) {
this.startDt = startDt;
}
public String getEndDt() {
return endDt;
}
public void setEndDt(String endDt) {
this.endDt = endDt;
}
} }
package com.viontech.vo;
/**
* @program: event_data_handle
* @description: 交通统计vo类
* @author: authorName
* @create: 2019-12-26 14:40
**/
public class TrafficStatisticsVo extends BaseStatisticsVo {
private String illegalType;
private String keyVehicleType;
public String getIllegalType() {
return illegalType;
}
public void setIllegalType(String illegalType) {
this.illegalType = illegalType;
}
public String getKeyVehicleType() {
return keyVehicleType;
}
public void setKeyVehicleType(String keyVehicleType) {
this.keyVehicleType = keyVehicleType;
}
}
package com.viontech.vo;
import lombok.Data;
/**
* @program: event_data_handle
* @description: 通道配置视图类
* @author: authorName
* @create: 2020-03-23 11:43
**/
@Data
public class VchanConfVo {
private Integer vchanConfUnid;
private String name;
private String url;
private Boolean isActive;
private Object conf;
}
...@@ -41,7 +41,7 @@ spring: ...@@ -41,7 +41,7 @@ spring:
password: admin password: admin
broker-url: tcp://192.168.9.133:61616 broker-url: tcp://192.168.9.133:61616
jms: jms:
pub-sub-domain: true pub-sub-domain: false
message: message:
audit: audit:
isOpen: true isOpen: true
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!