Commit b0e0ee4f authored by wangjinjing's avatar wangjinjing

init

parent c4754bf5
......@@ -4,8 +4,8 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
<version>2.2.2.RELEASE</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.comsumer.cn</groupId>
......@@ -38,7 +38,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.5</version>
<version>1.1.9</version>
</dependency>
<dependency>
......@@ -97,8 +97,36 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.jdom</groupId>-->
<!--<artifactId>jdom</artifactId>-->
<!--<version>1.1</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>commons-io</groupId>-->
<!--<artifactId>commons-io</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>
......
......@@ -4,7 +4,9 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@SpringBootApplication
public class CXQuartzApplication extends SpringBootServletInitializer {
......
package com.cx.cn.cxquartz.bean;
import com.cx.cn.cxquartz.vo.ImageList;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;
@JsonAutoDetect(fieldVisibility= JsonAutoDetect.Visibility.ANY, getterVisibility= JsonAutoDetect.Visibility.NONE)
public class GoalStructureParam {
@JsonProperty("Output")
private Map Output;
@JsonProperty("Model")
private int Model;
@JsonIgnore
private String apiout;
@JsonProperty("ImageList")
private List<ImageList> ImageList;
public void setModel(int Model) {
this.Model = Model;
}
public int getModel() {
return this.Model;
}
public void setApiout(String apiout) {
this.apiout = apiout;
}
public String getApiout() {
return this.apiout;
}
public Map getOutput() {
return Output;
}
public void setOutput(Map output) {
Output = output;
}
public List<com.cx.cn.cxquartz.vo.ImageList> getImageList() {
return ImageList;
}
public void setImageList(List<ImageList> imageList) {
ImageList = imageList;
}
}
\ No newline at end of file
package com.cx.cn.cxquartz.bean;
public class TaskResult {
private String devicecode;
private String recordtype;
private String timestamp;
private Long x;
private Long y;
private Long w;
private Long h;
private String url;
private String threshold;
private String sendtype;
public String getSendtype() {
return sendtype;
}
public void setSendtype(String sendtype) {
this.sendtype = sendtype;
}
public TaskResult(String devicecode, String recordtype, String timestamp, Long x, Long y, Long w, Long h, String url, String threshold, String sendtype) {
this.devicecode = devicecode;
this.recordtype = recordtype;
this.timestamp = timestamp;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.url = url;
this.threshold = threshold;
this.sendtype = sendtype;
}
public String getUrl() {
return url;
}
public String getThreshold() {
return threshold;
}
public void setThreshold(String threshold) {
this.threshold = threshold;
}
public void setUrl(String url) {
this.url = url;
}
public String getDevicecode() {
return devicecode;
}
public void setDevicecode(String devicecode) {
this.devicecode = devicecode;
}
public String getRecordtype() {
return recordtype;
}
public void setRecordtype(String recordtype) {
this.recordtype = recordtype;
}
public Long getX() {
return x;
}
public void setX(Long x) {
this.x = x;
}
public Long getY() {
return y;
}
public void setY(Long y) {
this.y = y;
}
public Long getW() {
return w;
}
public void setW(Long w) {
this.w = w;
}
public Long getH() {
return h;
}
public void setH(Long h) {
this.h = h;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
}
package com.cx.cn.cxquartz.common;
public class Constants {
//线程数
public final static int THREAD_COUNT = 5;
//处理间隔时间
//mils
public final static int INTERVAL_MILS = 0;
//consumer失败后等待时间(mils)
public static final int ONE_SECOND = 1 * 1000;
//异常sleep时间(mils)
public static final int ONE_MINUTE = 1 * 60 * 1000;
//MQ消息retry时间
public static final int RETRY_TIME_INTERVAL = ONE_MINUTE;
//MQ消息有效时间
public static final int VALID_TIME = ONE_MINUTE;
}
......@@ -4,8 +4,8 @@ import com.cx.cn.cxquartz.helper.MessageHelper;
import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import com.cx.cn.cxquartz.service.quartz.SbtdspsrService;
import com.cx.cn.cxquartz.vo.Sbtdspsr;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.Trigger;
......@@ -43,7 +43,7 @@ public class PerformedTaskCornChange implements SchedulingConfigurer {
scheduledTaskRegistrar.addTriggerTask(new Runnable() {
@Override
public void run() {
//判断最小执行时间, // 如果小于2分钟,立即执行所有设备的获取rtsp与hls 的服务,下次执行时间为间隔2分钟
//判断最小执行时间, 如果小于2分钟,立即执行所有设备的获取rtsp与hls 的服务,下次执行时间为间隔2分钟
// 如果大于2分钟,下次执行时间为间隔1秒
Long time= sbtdspsrService.getPeriodicseconds();
if(time<1200){
......@@ -60,13 +60,6 @@ public class PerformedTaskCornChange implements SchedulingConfigurer {
correlationData);
}
}
else{
//查询所有数据
}
}
else {
setTimer(1000L);
......
package com.cx.cn.cxquartz.config;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.batch.BatchingStrategy;
import org.springframework.amqp.rabbit.batch.SimpleBatchingStrategy;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.rabbit.core.BatchingRabbitTemplate;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
//@Configuration
/***
* 设置配置rabbit批量消费
*/
@Configuration
public class RabbitConfig {
@Bean
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setMessageConverter(new Jackson2JsonMessageConverter());
return template;
@Bean("batchQueueTaskScheduler")
public TaskScheduler batchQueueTaskScheduler(){
TaskScheduler taskScheduler=new ThreadPoolTaskScheduler();
return taskScheduler;
}
//批量处理rabbitTemplate
@Bean("batchQueueRabbitTemplate")
public BatchingRabbitTemplate batchQueueRabbitTemplate(ConnectionFactory connectionFactory,
@Qualifier("batchQueueTaskScheduler") TaskScheduler taskScheduler){
int batchSize=1;
int bufferLimit=1024; //1 K
long timeout=10000;
BatchingStrategy batchingStrategy=new SimpleBatchingStrategy(batchSize,bufferLimit,timeout);
return new BatchingRabbitTemplate(connectionFactory,batchingStrategy,taskScheduler);
}
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
@Bean("batchQueueRabbitListenerContainerFactory")
public SimpleRabbitListenerContainerFactory batchQueueRabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
factory.setMessageConverter(new Jackson2JsonMessageConverter());
factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
//设置批量
factory.setBatchListener(true);
factory.setConsumerBatchEnabled(true);//设置BatchMessageListener生效
factory.setBatchSize(10);//设置监听器一次批量处理的消息数量
return factory;
}
}
......@@ -26,28 +26,18 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
// 配置连接工厂
template.setConnectionFactory(factory);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSeial.setObjectMapper(om);
// 值采用json序列化
template.setValueSerializer(jacksonSeial);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
// 设置hash key 和value序列化模式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(jacksonSeial);
template.afterPropertiesSet();
return template;
}
......@@ -72,15 +62,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForValue();
}
// @Bean
// public JedisConnectionFactory redisConnectionFactory() {
// JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
// jedisConnectionFactory.setHostName("<server-hostname-here>");
// jedisConnectionFactory.setPort(6379);
// jedisConnectionFactory.setPassword("<server-password-here>");
// jedisConnectionFactory.afterPropertiesSet();
// return jedisConnectionFactory;
// }
/**
* 对链表类型的数据操作
*
......
......@@ -8,6 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* redis 消费者初始化
*/
@Configuration
public class RedisPCQueueConfig {
......@@ -17,15 +20,12 @@ public class RedisPCQueueConfig {
// 初始化完毕后调取 init
@Bean(initMethod = "init", destroyMethod = "destroy")
public RedisMQConsumerContainer redisQueueConsumerContainer() {
for(int i=0;i<6;i++) {
for(int i=0;i<2;i++) {
Consumer orderConsumer = new OrderConsumer();
mqContainer.addConsumer(
QueueConfiguration.builder().queue("taskinfo").consumer(orderConsumer).build()
);
}
return mqContainer;
}
}
package com.cx.cn.cxquartz.config;
import com.cx.cn.cxquartz.redis.Consumer;
import com.cx.cn.cxquartz.redis.OrderConsumer;
import com.cx.cn.cxquartz.redis.QueueConfiguration;
import com.cx.cn.cxquartz.redis.container.RedisMQConsumerContainer;
import com.cx.cn.cxquartz.service.quartz.SbtdspsrService;
import com.cx.cn.cxquartz.util.RestUtil;
import com.cx.cn.cxquartz.vo.Sbtdspsr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.List;
@Configuration
......@@ -23,33 +12,7 @@ public class ScheduleTaskConfig {
@Value("${file.getrtspbyurl}")
private String getrtspbyurl;
@Autowired
private SbtdspsrService sbtdspsrService;
//
// @Autowired
// RedisMQConsumerContainer mqContainer;
RestUtil restUtil=new RestUtil();
// /***
// * 每隔20分钟执行一遍判断rtsp 是否变换
// */
//// @Scheduled(cron = "0 0 2 * * ? ")
// private void statis() {
// //查询所有监控设备,更新rtsp 地址
// List<Sbtdspsr> sbtdpsrList= sbtdspsrService.list();
// //调用decice 端口获得新的rtsp 地址,如果与表里的一样无需更新,不一样则立即更新
// for(Sbtdspsr sbtd:sbtdpsrList)
// {
// restUtil.rtspChangeVlue(sbtd.getSbbh(),sbtd.getSqurllj(),getrtspbyurl);
// }
// }
// @Scheduled(cron = "0/5 * * * * ?")
// private void statistoday() {
// Consumer orderConsumer = new OrderConsumer();
// mqContainer.addConsumer(
// QueueConfiguration.builder().queue("taskinfo").consumer(orderConsumer).build()
// );
//
// }
}
......@@ -9,43 +9,22 @@ import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 生产者申明一个direct类型(直连型)交换机,然后发送消息到这个交换机指定路由键。
* 消费者指定消费这个交换机的这个路由键,即可接收到消息,其他消费者收不到。
* 用户登录直连型交换机配置
* 1. 声明Exchange交换器;
* 2. 声明Queue队列;
* 3. 绑定BindingBuilder绑定队列到交换器,并设置路由键;
* 消费者单纯的使用,其实可以不用添加这个配置,直接建后面的监听就好,使用注解来让监听器监听对应的队列即可。
* * 配置上了的话,其实消费者也是生成者的身份,也能推送该消息。
/***
*推送告警信息给第三方
*/
@Configuration
public class SendToDXConfig {
/**
* 创建交换机
*
* @return
*/
@Bean
public DirectExchange sendToDXDirectExchange() {
return new DirectExchange(QueueConstants.QueueSendToDXEnum.QUEUE_SEND_TO_DX_ENUM.getExchange());
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue sendToDXDirectQueue() {
return new Queue(QueueConstants.QueueSendToDXEnum.QUEUE_SEND_TO_DX_ENUM.getQueue(), true);
}
/**
* 将队列和交换机绑定,并设置用于匹配路由键
*
* @return
*/
@Bean
public Binding BindingSendToDXDirect() {
return BindingBuilder.bind(sendToDXDirectQueue()).to(sendToDXDirectExchange()).with(QueueConstants.QueueSendToDXEnum.QUEUE_SEND_TO_DX_ENUM.getRouteKey());
......
......@@ -9,43 +9,22 @@ import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 生产者申明一个direct类型(直连型)交换机,然后发送消息到这个交换机指定路由键。
* 消费者指定消费这个交换机的这个路由键,即可接收到消息,其他消费者收不到。
* 用户登录直连型交换机配置
* 1. 声明Exchange交换器;
* 2. 声明Queue队列;
* 3. 绑定BindingBuilder绑定队列到交换器,并设置路由键;
* 消费者单纯的使用,其实可以不用添加这个配置,直接建后面的监听就好,使用注解来让监听器监听对应的队列即可。
* 配置上了的话,其实消费者也是生成者的身份,也能推送该消息。
/***
* 推送声音告警给第三方
*/
@Configuration
public class SendToVoiceConfig {
/**
* 创建交换机
*
* @return
*/
@Bean
public DirectExchange sendToVoiceDirectExchange() {
return new DirectExchange(QueueConstants.QueueSendToVoiceEnum.QUEUE_SEND_TO_VOICE_ENUM.getExchange());
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue sendToVoiceDirectQueue() {
return new Queue(QueueConstants.QueueSendToVoiceEnum.QUEUE_SEND_TO_VOICE_ENUM.getQueue(), true);
}
/**
* 将队列和交换机绑定,并设置用于匹配路由键
*
* @return
*/
@Bean
public Binding BindingSendToVoiceDirect() {
return BindingBuilder.bind(sendToVoiceDirectQueue()).to(sendToVoiceDirectExchange()).with(QueueConstants.QueueSendToVoiceEnum.QUEUE_SEND_TO_VOICE_ENUM.getRouteKey());
......
package com.cx.cn.cxquartz.config;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class Swagger2Config {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.any())
.paths(Predicates.not(PathSelectors.regex("/error.*"))).paths(Predicates.not(PathSelectors.regex("/info.*")))
.paths(Predicates.not(PathSelectors.regex("/autoconfig.*")))
.paths(Predicates.not(PathSelectors.regex("/health.*")))
.paths(Predicates.not(PathSelectors.regex("/metrics.*")))
.paths(Predicates.not(PathSelectors.regex("/mappings.*")))
.paths(Predicates.not(PathSelectors.regex("/trace.*")))
.paths(Predicates.not(PathSelectors.regex("/configprops.*")))
.paths(Predicates.not(PathSelectors.regex("/beans.*"))).paths(Predicates.not(PathSelectors.regex("/env.*")))
.paths(Predicates.not(PathSelectors.regex("/dump.*")))
.paths(Predicates.not(PathSelectors.regex("/auditevents.*")))
.paths(Predicates.not(PathSelectors.regex("/docs.*"))).paths(Predicates.not(PathSelectors.regex("/archaius.*")))
.paths(Predicates.not(PathSelectors.regex("/features.*")))
.paths(Predicates.not(PathSelectors.regex("/pause.*"))).paths(Predicates.not(PathSelectors.regex("/refresh.*")))
.paths(Predicates.not(PathSelectors.regex("/resume.*")))
.paths(Predicates.not(PathSelectors.regex("/actuator.*")))
.paths(Predicates.not(PathSelectors.regex("/jolokia.*")))
.paths(Predicates.not(PathSelectors.regex("/loggers.*")))
.paths(Predicates.not(PathSelectors.regex("/restart.*")))
.paths(Predicates.not(PathSelectors.regex("/service-registry/instance-status.*")))
.paths(Predicates.not(PathSelectors.regex("/logfile.*")))
.paths(Predicates.not(PathSelectors.regex("/channels.*"))).paths(Predicates.not(PathSelectors.regex("/bus.*")))
.paths(Predicates.not(PathSelectors.regex("/heapdump.*"))).build();
}
/**
* Swagger2主界面信息,描述api的基本信息用于展示
*
* @return
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("video服务接口定义和规范").description("knotvideo服务接口定义和规范")
.termsOfServiceUrl("http://****.com/").contact(new Contact("@****.com", "", "")).version("1.0")
.license("版权所有 ?***").build();
}
}
......@@ -10,12 +10,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 视频图片直连型交换机配置
* 1. 声明Exchange交换器;
* 2. 声明Queue队列;
* 3. 绑定BindingBuilder绑定队列到交换器,并设置路由键;
* 消费者单纯的使用,其实可以不用添加这个配置,直接建后面的监听就好,使用注解来让监听器监听对应的队列即可。
* 配置上了的话,其实消费者也是生成者的身份,也能推送该消息。
*抽帧任务
*/
@Configuration
public class TaskComsumExchangeConfig {
......@@ -26,49 +21,20 @@ public class TaskComsumExchangeConfig {
* @return
*/
@Bean
public DirectExchange OrderCancelDirectExchange() {
public DirectExchange TaskConsumerDirectExchange() {
return new DirectExchange(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getExchange());
}
// /**
// * 创建队列 true表示是否持久
// *
// * @return
// */
// @Bean
// public Queue OrderCancelDirectQueue() {
// return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue(), true);
// }
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model1DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_1", true);
public Queue ModelDXDirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_DX", true);
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model2DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_2", true);
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model3DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_3", true);
}
/**
* 创建队列 true表示是否持久
......@@ -76,28 +42,8 @@ public class TaskComsumExchangeConfig {
* @return
*/
@Bean
public Queue Model4DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_4", true);
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model5DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_5", true);
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model0DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_0", true);
public Queue ModelQSTDirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_QST", true);
}
/**
* 将队列和交换机绑定,并设置用于匹配路由键
......@@ -105,14 +51,12 @@ public class TaskComsumExchangeConfig {
* @return
*/
@Bean
public Binding BindingDirect() {
BindingBuilder.bind(Model1DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_1");
BindingBuilder.bind(Model2DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_2");
BindingBuilder.bind(Model3DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_3");
BindingBuilder.bind(Model4DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_4");
BindingBuilder.bind(Model5DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_5");
return BindingBuilder.bind(Model0DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_0");
public Binding BindingQSTDirect() { return BindingBuilder.bind(ModelQSTDirectQueue()).to(TaskConsumerDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_QST");
}
@Bean
public Binding BindingDXDirect(){
return BindingBuilder.bind(ModelDXDirectQueue()).to(TaskConsumerDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_DX");
}
}
package com.cx.cn.cxquartz.config;
import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 视频图片直连型交换机配置
* 1. 声明Exchange交换器;
* 2. 声明Queue队列;
* 3. 绑定BindingBuilder绑定队列到交换器,并设置路由键;
* 消费者单纯的使用,其实可以不用添加这个配置,直接建后面的监听就好,使用注解来让监听器监听对应的队列即可。
* 配置上了的话,其实消费者也是生成者的身份,也能推送该消息。
*/
public class TaskComsumExchangeConfig_bak {
/**
* 创建交换机
*
* @return
*/
@Bean
public DirectExchange OrderCancelDirectExchange() {
return new DirectExchange(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getExchange());
}
// /**
// * 创建队列 true表示是否持久
// *
// * @return
// */
// @Bean
// public Queue OrderCancelDirectQueue() {
// return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue(), true);
// }
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model1DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_1", true);
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model2DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_2", true);
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model3DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_3", true);
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model4DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_4", true);
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model5DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_5", true);
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue Model0DirectQueue() {
return new Queue(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getQueue()+"_0", true);
}
/**
* 将队列和交换机绑定,并设置用于匹配路由键
*
* @return
*/
@Bean
public Binding BindingDirect() {
BindingBuilder.bind(Model1DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_1");
BindingBuilder.bind(Model2DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_2");
BindingBuilder.bind(Model3DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_3");
BindingBuilder.bind(Model4DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_4");
BindingBuilder.bind(Model5DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_5");
return BindingBuilder.bind(Model0DirectQueue()).to(OrderCancelDirectExchange()).with(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_0");
}
}
......@@ -9,16 +9,6 @@ import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 生产者申明一个direct类型(直连型)交换机,然后发送消息到这个交换机指定路由键。
* 消费者指定消费这个交换机的这个路由键,即可接收到消息,其他消费者收不到。
* 用户登录直连型交换机配置
* 1. 声明Exchange交换器;
* 2. 声明Queue队列;
* 3. 绑定BindingBuilder绑定队列到交换器,并设置路由键;
* 消费者单纯的使用,其实可以不用添加这个配置,直接建后面的监听就好,使用注解来让监听器监听对应的队列即可。
* 配置上了的话,其实消费者也是生成者的身份,也能推送该消息。
*/
@Configuration
public class getSnapShotConfig {
/**
......@@ -27,7 +17,7 @@ public class getSnapShotConfig {
* @return
*/
@Bean
public DirectExchange sendToVoiceDirectExchange() {
public DirectExchange RTSPDirectExchange() {
return new DirectExchange(QueueConstants.QueueRTSPEnum.QUEUE_RTSP_ENUM.getExchange());
}
......@@ -37,7 +27,7 @@ public class getSnapShotConfig {
* @return
*/
@Bean
public Queue sendToVoiceDirectQueue() {
public Queue RTSPDirectQueue() {
return new Queue(QueueConstants.QueueRTSPEnum.QUEUE_RTSP_ENUM.getQueue(), true);
}
......@@ -47,7 +37,7 @@ public class getSnapShotConfig {
* @return
*/
@Bean
public Binding BindingSendToVoiceDirect() {
return BindingBuilder.bind(sendToVoiceDirectQueue()).to(sendToVoiceDirectExchange()).with(QueueConstants.QueueRTSPEnum.QUEUE_RTSP_ENUM.getRouteKey());
public Binding BindingRTSPDirect() {
return BindingBuilder.bind(RTSPDirectQueue()).to(RTSPDirectExchange()).with(QueueConstants.QueueRTSPEnum.QUEUE_RTSP_ENUM.getRouteKey());
}
}
\ No newline at end of file
package com.cx.cn.cxquartz.controller;
import com.cx.cn.cxquartz.helper.MessageHelper;
import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import com.cx.cn.cxquartz.util.*;
import com.cx.cn.cxquartz.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
@RestController
@Api(description ="自动抓拍摄像头结果推送服务接口",tags = "自动抓拍摄像头结果推送服务")
public class AutoSnapController {
private static final Logger logger = LoggerFactory.getLogger(ExtController.class);
@Autowired
RabbitTemplate rabbitTemplate;
@Value("${file.rootpath}")
String rootpath;
@RequestMapping(value = "/AutoSnap", method = RequestMethod.POST)
@ApiOperation(value = "自动抓拍摄像头结果推送服务",notes = "上传xml和jpg文件")
public void AutoSnap(@RequestParam("file") MultipartFile[] file) {
/*如果文件不为空,保存文件*/
if (file != null && file.length>0 && file.length==2) {
//获得xml文件 和jpg文件
MultipartFile filexml=file[0].getName().endsWith(".xml")==true?file[0]:file[1];
MultipartFile filejpg=file[0].getName().endsWith(".jpg")||file[0].getName().endsWith(".jpeg") ==true?file[0]:file[1];
//获得xml文件里信息,获得图片地址,将信息与地址整合成rabbitmq 中的格式进行消费
try {
Document doc= XmlUtils.readDocument(filexml);
Capture vCACapture=new Capture();
XmlUtils.parseDocument(vCACapture,doc);
vCACapture.setDateTime(vCACapture.getDateTime()==null?null:DateUtils.dealDateFormat(vCACapture.getDateTime()));
//获得jpg 文件,将文件存放到某个路径下面
Calendar rightNow = Calendar.getInstance();
String filepath=rootpath+File.separator+rightNow.get(Calendar.YEAR)+File.separator+rightNow.get(Calendar.MONTH)+File.separator+vCACapture.getDeviceId()+File.separator+vCACapture.getDeviceId()+"_"+DateUtils.formatDateToNoSign(vCACapture.getDateTime())+".jpg";
//将文件copy到该路径下
File desfile=new File(filepath);
if (!desfile.getParentFile().exists()) {
desfile.getParentFile().mkdirs();
}
if (!desfile.exists()) {
desfile.createNewFile();
}
filejpg.transferTo(desfile);
//
Map map=new HashMap<>();
map.put("resourcePath",filepath);
map.put("timestamp", vCACapture.getDateTime() );
map.put("devicecode", vCACapture.getDeviceId());
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(QueueConstants.QueueAutoSnapEnum.QUEUE_AUTOSNAP_ENUM.getExchange(),
QueueConstants.QueueAutoSnapEnum.QUEUE_AUTOSNAP_ENUM.getRouteKey(),
MessageHelper.objToMsg(map),
correlationData);
//拼接数据为如下格式
// String result="{\n" +
// " \"ret\": 0,\n" +
// " \"desc\": \"succ!\",\n" +
// " \"url\": \"http://zjh189.ncpoi.cc:7080/download/202109/08/33050300001327599605/33050300001327599605_20210908_134131031.jpg\",\n" +
// " \"resourcePath\": \"/home/ubuntu/pictures/slice/202109/08/33050300001327599605/33050300001327599605_20210908_134131031.jpg\",\n" +
// " \"timestamp\": \"2021-09-08 13:41:31.031\",\n" +
// " \"devicecode\": \"33050300001327599605\"\n" +
// "}";
} catch (IOException e) {
e.printStackTrace();
logger.error("IOException",e);
}
}else{
logger.error("文件数量不是2个");
}
}
}
package com.cx.cn.cxquartz.controller;
import com.cx.cn.cxquartz.service.quartz.SbtdspsrService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/video")
public class SbtdspsrController {
private static final Logger logger = LoggerFactory.getLogger(SbtdspsrController.class);
@Autowired
private SbtdspsrService sbtdspsrService;
//
// @RequestMapping(value = "/getSbtdspsrbyrtsp", method = RequestMethod.GET)
// public String addTaskpage() {
// return "addtask";
// }
// @RequestMapping(value = "/list", method = RequestMethod.GET)
// @ResponseBody
// public List<Sbtdspsr> list() {
// return sbtdspsrService.list();
//
// }
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.Autosnaptaskinfo;
import com.cx.cn.cxquartz.vo.Code;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Mapper
public interface AutoSanpMapper {
int insert(Autosnaptaskinfo taskinfo) ;
List<Autosnaptaskinfo> query(Autosnaptaskinfo taskinfo);
}
......@@ -18,6 +18,7 @@ public interface TraffAlarmRecordMapper {
int updateTraffAlarmRecordUrl(TraffAlarmRecord traffalarmrecord);
List<TraffAlarmRecord> getTraffAlarmRecordByProgress(Map<String, Object> map);
int updateTraffAlarmRecordProcess(TraffAlarmRecord traffalarmrecord);
}
\ No newline at end of file
......@@ -342,8 +342,72 @@ public class QueueConstants {
* 路由键
*/
String ROUTEKEY = "RabbitMQ.RouteKey.EventProcessingConsumer";
}
public enum QueueAutoSnapEnum {
QUEUE_AUTOSNAP_ENUM(QueueConstants.QueueAutoSnapConsumer.EXCHANGE, QueueConstants.QueueAutoSnapConsumer.QUEUE,
QueueConstants.QueueAutoSnapConsumer.ROUTEKEY);
/**
* 交换机名称
*/
private String exchange;
/**
* 队列名称
*/
private String queue;
/**
* 路由键
*/
private String routeKey;
QueueAutoSnapEnum(String exchange, String queue, String routeKey) {
this.exchange = exchange;
this.queue = queue;
this.routeKey = routeKey;
}
public String getExchange() {
return exchange;
}
public void setExchange(String exchange) {
this.exchange = exchange;
}
public String getQueue() {
return queue;
}
public void setQueue(String queue) {
this.queue = queue;
}
public String getRouteKey() {
return routeKey;
}
public void setRouteKey(String routeKey) {
this.routeKey = routeKey;
}
}
/**
* 获得rtsp 或者hls的队列
*/
public interface QueueAutoSnapConsumer{
/**
* 交换机名称
*/
String EXCHANGE = "RabbitMQ.DirectExchange.AutoSnapConsumer";
/**
* 队列名称
*/
String QUEUE = "RabbitMQ.DirectQueue.AutoSnapConsumer";
/**
* 路由键
*/
String ROUTEKEY = "RabbitMQ.RouteKey.AutoSnapConsumer";
}
}
......@@ -13,13 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.lang.reflect.Proxy;
import java.util.Map;
/**
* 在Consumer中, 真正的业务逻辑其实只是保存消息到各自的数据表中, 但我们又不得不在调用consume方法之前校验消费幂等性, 发送后, 还要更新消息状态为"已消费"状态, 并手动ack。
* 实际项目中, 可能还有很多生产者-消费者的应用场景, 如记录日志, 发送短信等等, 都需要rabbitmq, 如果每次都写这些重复的公用代码, 没必要, 也难以维护。
* 所以, 我们可以将公共代码抽离出来, 让核心业务逻辑只关心自己的实现, 而不用做其他操作, 其实就是AOP。
* <p>
* 为达到这个目的, 有很多方法, 可以用spring aop, 可以用拦截器, 可以用静态代理, 也可以用动态代理, 在这里用的是动态代理。
*/
public class BaseConsumerProxy {
private static final Logger logger = LoggerFactory.getLogger(BaseConsumerProxy.class);
/**
......@@ -51,30 +44,14 @@ public class BaseConsumerProxy {
public Object getProxy() {
ClassLoader classLoader = target.getClass().getClassLoader();
Class[] interfaces = target.getClass().getInterfaces();
//Lambda表达式方式实现InvocationHandler接口
return Proxy.newProxyInstance(classLoader, interfaces, (proxy, method, args) -> {
Message message = (Message) args[0];
Channel channel = (Channel) args[1];
//String correlationId = getCorrelationId(message);
// 消费幂等性, 防止消息被重复消费
// 重启服务器, 由于有一条未被ack的消息, 所以重启后监听到消息, 进行消费, 但是由于消费前会判断该消息的状态是否未被消费, 发现status=3, 即已消费,
// 所以, 直接return, 这样就保证了消费端的幂等性, 即使由于网络等原因投递成功而未触发回调, 从而多次投递, 也不会重复消费进而发生业务异常。
// if (isConsumed(correlationId)) {
// logger.info("重复消费, correlationId: {}", correlationId);
// return null;
// }
MessageProperties properties = message.getMessageProperties();
long tag = properties.getDeliveryTag();
try {
// 真正消费的业务逻辑
Object result = method.invoke(target, args);
//traffPictureService.updateStatus(correlationId, QueueConstants.MessageLogStatus.CONSUMED_SUCCESS);
// 消费确认 虽然消息确实被消费了, 但是由于是手动确认模式, 而最后又没手动确认, 所以, 消息仍被rabbitmq保存。
// 所以, 手动ack能够保证消息一定被消费, 但一定要记得basicAck。
// 手动ack
channel.basicAck(tag, false);
return result;
} catch (Exception e) {
......@@ -94,7 +71,6 @@ public class BaseConsumerProxy {
*/
private String getCorrelationId(Message message) {
String correlationId = null;
MessageProperties properties = message.getMessageProperties();
Map<String, Object> headers = properties.getHeaders();
for (Map.Entry entry : headers.entrySet()) {
......@@ -103,22 +79,7 @@ public class BaseConsumerProxy {
if (key.equals("spring_returned_message_correlation")) {
correlationId = value;
}
}
return correlationId;
}
/**
* 消息是否已被消费
*
* @param correlationId
* @return
*/
private boolean isConsumed(String correlationId) {
//查看数据是否入表
return false;
// MessageLog msgLog = msgLogService.selectByMsgId(correlationId);
// return null == msgLog || msgLog.getStatus().equals(QueueConstants.MessageLogStatus.CONSUMED_SUCCESS);
}
}
\ No newline at end of file
......@@ -35,14 +35,8 @@ public class EventProcessingConsumer implements BaseConsumer {
public void consume(Message message, Channel channel) throws IOException {
logger.info("TaskConsumConsumer 收到消息: {}", message.toString());
Map result = MessageHelper.msgToObj(message, Map.class);
if (null !=result) {
resultService.processResult(result);
//if (null !=result) {
// QuartzTaskInformations taskinfo = JsonUtil.strToObj( result.get("task").toString(),QuartzTaskInformations.class);
// if (null != result.get("result")) {
// Map objresult = JsonUtil.strToObj(result.get("result").toString(), Map.class);
//处理消息
// resultService.processResult(taskinfo, objresult);
// }
//}
}
}
}
......@@ -16,15 +16,17 @@ public class SnapShotConsumer implements BaseConsumer{
private static final Logger logger = LoggerFactory.getLogger(SnapShotConsumer.class);
@Autowired
VideoRTSPorURLService videoRTSPorURLService;
@Override
public void consume(Message message, Channel channel) {
logger.info("SnapShotConsumer 收到消息: {}", message.toString());
Sbtdspsr result = MessageHelper.msgToObj(message, Sbtdspsr.class);
if (result.getTdlx()==1) {
//调用rtsp 的服务
String token=videoRTSPorURLService.getRTSPAccessToekenByDeviceCode(result.getSbbh());
videoRTSPorURLService.getRTSPByDeviceCode(token,result.getSbbh());
if(null!=result.getSbbh()&&(!result.getSbbh().startsWith("33") ||
(result.getSbbh().startsWith("33") &&result.getSbbh().length()==18))) {
String token = videoRTSPorURLService.getRTSPAccessToekenByDeviceCode(result.getSbbh());
videoRTSPorURLService.getRTSPByDeviceCode(token, result.getSbbh());
}
}
else{
//调用hls 的服务
......
package com.cx.cn.cxquartz.rabbitmq.comsumer;
import com.cx.cn.cxquartz.common.Constants;
import com.cx.cn.cxquartz.helper.MessageHelper;
import com.cx.cn.cxquartz.service.quartz.TraffAlarmRecordService;
import com.cx.cn.cxquartz.service.quartz.impl.EventWriteService;
import com.cx.cn.cxquartz.service.quartz.impl.TaskRecog;
import com.cx.cn.cxquartz.util.CommonUtil;
import com.rabbitmq.client.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 消息处理并推送第三方
*/
@Component
public class TaskQSTConsumer{
private List<Map> list=new ArrayList<>();
private static final Logger logger = LoggerFactory.getLogger(TaskQSTConsumer.class);
@Autowired
TraffAlarmRecordService traffAlarmRecordService;
@Autowired
TaskRecog taskRecog;
@Value("${voice.unionId}")
private String unionId;
@Value("${voice.appKey}")
private String appKey;
@Value("${voice.corpId}")
private String corpId;
@Value("${voice.eventId}")
private Integer eventId;
/**
* 消息消费入口
*
* @param messageList
* @param channel
* @throws IOException
*/
public void consume(List<Message> messageList, Channel channel) {
list.clear();
for (Message message : messageList) {
Map result = MessageHelper.msgToObj(message, Map.class);
list.add(result);
}
LinkedHashMap<String, List<Map>> maplist = CommonUtil.queryList(list);
for (String key : maplist.keySet()) {
try {
taskRecog.sender(maplist.get(key));
} catch (Exception ex) {
logger.error(ex.toString());
}
}
}
}
......@@ -14,7 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 任务消息监听接受器
* 告警信息结果分析
*/
@Component
public class EventProcessingReceiver {
......@@ -25,17 +25,16 @@ public class EventProcessingReceiver {
@Autowired
private TraffPictureService traffPictureService;
@RabbitListener(queues = QueueConstants.QueueEventProcessingConsumer.QUEUE,containerFactory="rabbitListenerContainerFactory")
@RabbitListener(queues = QueueConstants.QueueEventProcessingConsumer.QUEUE)
public void process(Message message, Channel channel) {
try {
logger.info("consumer->OrderCancelReceiver消费者收到消息 : " + message.toString());
BaseConsumerProxy baseConsumerProxy = new BaseConsumerProxy(eventProcessingConsumer, traffPictureService);
BaseConsumer proxy = (BaseConsumer) baseConsumerProxy.getProxy();
if (null != proxy) {
proxy.consume(message, channel);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("告警信息结果分析 error:{}",e);
}
}
}
......@@ -13,7 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 任务消息监听接受器
* rtsp与hls超时过期更新
*/
@Component
public class RTSPorHLSReceiver {
......@@ -21,17 +21,16 @@ public class RTSPorHLSReceiver {
@Autowired
private SnapShotConsumer snapShotConsumer;
@RabbitListener(queues = QueueConstants.QueueRTSPConsumer.QUEUE,containerFactory="rabbitListenerContainerFactory")
@RabbitListener(queues = QueueConstants.QueueRTSPConsumer.QUEUE)
public void process(Message message, Channel channel) {
try {
logger.info("consumer->RTSPorHLSReceiver消费者收到消息 : " + message.toString());
BaseConsumerProxy baseConsumerProxy = new BaseConsumerProxy(snapShotConsumer);
BaseConsumer proxy = (BaseConsumer) baseConsumerProxy.getProxy();
if (null != proxy) {
proxy.consume(message, channel);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("rtsp与hls超时过期更新 error:{}",e);
}
}
}
package com.cx.cn.cxquartz.rabbitmq.comsumer.listener;
import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumer;
import com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumerProxy;
import com.cx.cn.cxquartz.rabbitmq.comsumer.SendToDXConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.rabbitmq.client.Channel;
import java.io.IOException;
import org.springframework.amqp.core.Message;
/**
* 推送给第三方队列的监听
* 推送告警给第三方
*/
@Component
public class SendtoDXReceiver {
......@@ -24,13 +29,13 @@ public class SendtoDXReceiver {
* @param channel
* @throws IOException
*/
// @RabbitListener(queues = QueueConstants.QueueSendToDXConsumer.QUEUE,containerFactory="rabbitListenerContainerFactory")
// public void consume(Message message, Channel channel) throws IOException {
// logger.info("consumer->QueueSendToDXConsumer 消费者收到消息 : " + message.toString());
// BaseConsumerProxy baseConsumerProxy = new BaseConsumerProxy(sendToDXConsumer);
// BaseConsumer proxy = (BaseConsumer) baseConsumerProxy.getProxy();
// if (null != proxy) {
// proxy.consume(message, channel);
// }
// }
@RabbitListener(queues = QueueConstants.QueueSendToDXConsumer.QUEUE,containerFactory="rabbitListenerContainerFactory")
public void consume(Message message, Channel channel) throws IOException {
logger.info("consumer->推送告警给第三方 消费者收到消息 : " + message.toString());
BaseConsumerProxy baseConsumerProxy = new BaseConsumerProxy(sendToDXConsumer);
BaseConsumer proxy = (BaseConsumer) baseConsumerProxy.getProxy();
if (null != proxy) {
proxy.consume(message, channel);
}
}
}
package com.cx.cn.cxquartz.rabbitmq.comsumer.listener;
import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumer;
import com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumerProxy;
import com.cx.cn.cxquartz.rabbitmq.comsumer.SendToVoiceConsumer;
import com.cx.cn.cxquartz.service.quartz.impl.ResultService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -28,7 +25,7 @@ public class SendtoVoiceAlarmReceiver {
* @param channel
* @throws IOException
*/
@RabbitListener(queues = QueueConstants.QueueSendToVoiceConsumer.QUEUE,containerFactory="rabbitListenerContainerFactory")
// @RabbitListener(queues = QueueConstants.QueueSendToVoiceConsumer.QUEUE)
public void consume(Message message, Channel channel) throws IOException {
BaseConsumerProxy baseConsumerProxy = new BaseConsumerProxy(sendToVoiceConsumer);
BaseConsumer proxy = (BaseConsumer) baseConsumerProxy.getProxy();
......
package com.cx.cn.cxquartz.rabbitmq.comsumer.listener;
import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumer;
import com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumerProxy;
import com.cx.cn.cxquartz.rabbitmq.comsumer.SnapShotConsumer;
import com.cx.cn.cxquartz.service.quartz.TraffPictureService;
import com.rabbitmq.client.Channel;
import com.cx.cn.cxquartz.rabbitmq.comsumer.TaskQSTConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.BatchMessageListener;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 任务消息监听接受器
* 批量分析图片
*/
@Component
public class SnapShotReceiver {
private static final Logger logger = LoggerFactory.getLogger(SnapShotReceiver.class);
public class TaskQSTReceiver implements BatchMessageListener {
private static final Logger logger = LoggerFactory.getLogger(TaskQSTReceiver.class);
@Autowired
private SnapShotConsumer snapShotConsumer;
private TaskQSTConsumer taskQSTConsumer;
@Autowired
private TraffPictureService traffPictureService;
@RabbitListener(queues = QueueConstants.QueueRTSPConsumer.QUEUE)
public void process(Message message, Channel channel) {
@RabbitListener(queues = QueueConstants.QueueTaskConsumer.QUEUE+"_QST",containerFactory = "batchQueueRabbitListenerContainerFactory")
@Override
public void onMessageBatch(List<Message> messages) {
try {
logger.info("consumer->OrderCancelReceiver消费者收到消息 : " + message.toString());
BaseConsumerProxy baseConsumerProxy = new BaseConsumerProxy(snapShotConsumer, traffPictureService);
BaseConsumer proxy = (BaseConsumer) baseConsumerProxy.getProxy();
if (null != proxy) {
proxy.consume(message, channel);
if(messages.size()>0){
taskQSTConsumer.consume(messages,null);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("批量分析图片 error:{}",e);
}
}
}
......@@ -4,8 +4,8 @@ import com.cx.cn.cxquartz.controller.ExtController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -14,9 +14,6 @@ import java.nio.charset.StandardCharsets;
/**
* 消息发送确认的回调
* 实现接口:implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback
* ConfirmCallback:只确认消息是否正确到达交换机中,不管是否到达交换机,该回调都会执行;
* ReturnCallback:如果消息从交换机未正确到达队列中将会执行,正确到达则不执行;
*/
@Component
public class ConsumerConfirmAndReturnCallback implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback {
......@@ -37,14 +34,11 @@ public class ConsumerConfirmAndReturnCallback implements RabbitTemplate.ConfirmC
}
/**
* 消息从交换机成功到达队列,则returnedMessage方法不会执行;
* 消息从交换机未能成功到达队列,则returnedMessage方法会执行;
* 需要开启 return 确认机制
* spring.rabbitmq.publisher-returns=true
* 消息从交换机成功到达队列,spring.rabbitmq.publisher-returns=true
*/
@Override
public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
logger.info("returnedMessage回调方法->" + new String(message.getBody(), StandardCharsets.UTF_8) + ",\n replyCode:" + replyCode
logger.info(" info->" + new String(message.getBody(), StandardCharsets.UTF_8) + ",\n replyCode:" + replyCode
+ "\n replyText:" + replyText + "\n exchange:" + exchange + ",\\n routingKey:" + routingKey);
}
......@@ -58,11 +52,9 @@ public class ConsumerConfirmAndReturnCallback implements RabbitTemplate.ConfirmC
@Override
public void confirm(CorrelationData correlationData, boolean isSendSuccess, String error) {
if (correlationData != null) {
// logger.info("confirm回调方法->回调消息ID为: " + correlationData.getId());
if (isSendSuccess) {
logger.info("confirm回调方法->消息成功发送到交换机!");
} else {
logger.info("confirm回调方法->消息[{}]发送到交换机失败!,原因 : [{}]", correlationData, error);
}
}
......
package com.cx.cn.cxquartz.redis;
import com.alibaba.druid.util.HttpClientUtils;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.helper.MessageHelper;
import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import com.cx.cn.cxquartz.service.quartz.SbtdspsrService;
import com.cx.cn.cxquartz.service.quartz.impl.VideoRTSPorURLService;
import com.cx.cn.cxquartz.util.DateUtils;
import com.cx.cn.cxquartz.util.JsonUtil;
import com.cx.cn.cxquartz.vo.ResultObj;
import com.rabbitmq.tools.json.JSONUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.BatchingRabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.io.File;
import java.util.*;
@Component
......@@ -28,27 +39,34 @@ public class OrderConsumer implements Consumer {
private String recogurl;
@Value("${file.model}")
private String model;
@Autowired
private RabbitTemplate rabbitTemplate;
@Value("${local.czrooturl}")
private String czrooturl;
@Autowired
private VideoRTSPorURLService videoRTSPorURLService;
@Autowired
private SbtdspsrService sbtdspsrService;
@Autowired
BatchingRabbitTemplate batchQueueRabbitTemplate;
private static OrderConsumer orderConsumer;
@Autowired
private RestTemplate restTemplate;
@PostConstruct
public void init() {
orderConsumer = this;
orderConsumer.rabbitTemplate = this.rabbitTemplate;
orderConsumer.batchQueueRabbitTemplate = this.batchQueueRabbitTemplate;
orderConsumer.czurl=this.czurl;
orderConsumer.fxurl=this.fxurl;
orderConsumer.recogurl=this.recogurl;
orderConsumer.model=this.model;
orderConsumer.videoRTSPorURLService=this.videoRTSPorURLService;
orderConsumer.sbtdspsrService=this.sbtdspsrService;
orderConsumer.restTemplate=this.restTemplate;
}
public OrderConsumer(){
}
......@@ -60,37 +78,71 @@ public class OrderConsumer implements Consumer {
try {
//调用抽帧服务
String devicecode=msg.getExecuteparamter();
String rtsporhls="";
log.info("开始消费消息{}", msg.getId());
//如果设备编号是用一次废一次的,此刻需要现场取得rtsp
if(null!=devicecode&&devicecode.startsWith("33") && devicecode.length()==18){
if(null!=devicecode&&devicecode.startsWith("33") && devicecode.length()!=18){
//调用抽帧服务
String token= orderConsumer.videoRTSPorURLService.getRTSPAccessToekenByDeviceCode(devicecode);
orderConsumer.videoRTSPorURLService.getRTSPByDeviceCode(token,devicecode);
rtsporhls=orderConsumer.videoRTSPorURLService.getRTSPByDeviceCode(token,devicecode);
}
else{
//取表里最新的rtsp 或者hls 的值
orderConsumer.sbtdspsrService.getRtspOrHLSByDeviceCode(devicecode);
rtsporhls=orderConsumer.sbtdspsrService.getRtspOrHLSByDeviceCode(devicecode);
}
if(rtsporhls.equals("")){
//尝试重新抽帧一遍
String token= orderConsumer.videoRTSPorURLService.getRTSPAccessToekenByDeviceCode(devicecode);
rtsporhls=orderConsumer.videoRTSPorURLService.getRTSPByDeviceCode(token,devicecode);
if(rtsporhls.equals("")) {
log.error(devicecode + "rtsp 、hls 地址为空");
return;
}
}
//将rtsp 作为参数调用抽帧服务
String result="{\n" +
" \"ret\": 0,\n" +
" \"desc\": \"succ!\",\n" +
" \"url\": \"http://zjh189.ncpoi.cc:7080/download/202109/08/33050300001327599605/33050300001327599605_20210908_134131031.jpg\",\n" +
" \"localuri\": \"/home/ubuntu/pictures/slice/202109/08/33050300001327599605/33050300001327599605_20210908_134131031.jpg\",\n" +
" \"timestamp\": \"2021-09-08 13:41:31.031\",\n" +
" \"devicecode\": \"33050300001327599605\"\n" +
"}";
// String result="{\n" +
// " \"ret\": 0,\n" +
// " \"desc\": \"succ!\",\n" +
// " \"resourcePath\": \"http://zjh189.ncpoi.cc:7080/download/202109/08/33050300001327599605/33050300001327599605_20210908_134131031.jpg\",\n" +
// " \"localuri\": \"/home/ubuntu/pictures/slice/202109/08/33050300001327599605/33050300001327599605_20210908_134131031.jpg\",\n" +
// " \"timestamp\": \"2021-09-08 13:41:31.031\",\n" +
// " \"devicecode\": \"33050300001327599605\"\n" +
// "}";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Map map=new HashMap();
map.put("resourcePath",orderConsumer.czrooturl+"/"+ DateUtils.formatCurrDateYYMM()+"/"+devicecode+"/"+devicecode+"_"+DateUtils.formatCurrDayNoSign()+"_"+DateUtils.formatCurrDateHHmmss()+".jpg");
map.put("deviceID",devicecode);
map.put("resourceParam",rtsporhls);
HttpEntity<Map> requestEntity = new HttpEntity<>(map, headers);
String response= orderConsumer.restTemplate.postForObject(orderConsumer.czurl,requestEntity, String.class);
Map resultmap =JsonUtil.strToObj(response,Map.class);
if(null!=resultmap.get("ret")) {
if (resultmap.get("ret").toString().equals("0")
&& null!=resultmap.get("resourcePath")
&& !resultmap.get("resourcePath").toString().equals("")) {
//抽帧结果放到rabbttmq 中,根据msg 的检测metatype ,分别派发到不同的queue中,方便以后10条10条的去皮皮昂分析
Map m = new HashMap();
m.put("taskparam", JsonUtil.objToStr(msg));
m.put("result", result);
String msgId = UUID.randomUUID().toString();
CorrelationData correlationData = new CorrelationData(msgId);
orderConsumer.rabbitTemplate.convertAndSend(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getExchange(),
QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey()+"_"+msg.getObjectType(),
m.put("task", JsonUtil.objToStr(msg));
m.put("result", response);
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
orderConsumer.batchQueueRabbitTemplate.send(QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getExchange(),
QueueConstants.QueueTaskEnum.QUEUE_TASK_ENUM.getRouteKey() + "_QST",
MessageHelper.objToMsg(m),
correlationData);
}
else{
log.error("抽帧失败",JsonUtil.objToStr(resultmap));
}
}
else{
log.error("返回状态码为null");
}
// String roistr= URLEncoder.encode("[")+msg.getObjectx()+","+msg.getObjecty()+","+msg.getObjectw()+","+msg.getObjecth()+URLEncoder.encode("]");
// String result= CompletableFuture.supplyAsync(() -> HttpClientUtil.doGet(orderConsumer.recogurl + "?deviceCode="+msg.getExecuteparamter()+"&model="+orderConsumer.model+"&roi="+roistr)).get(2, TimeUnit.SECONDS);
......
......@@ -27,7 +27,6 @@ public class QueueListener implements Runnable {
/**
* 使用队列右出获取消息
* 没获取到消息则线程 sleep 一秒,减少资源浪费
* 实现了 Runnable 接口,可以作为线程任务执行
*/
@Override
public void run() {
......@@ -39,11 +38,9 @@ public class QueueListener implements Runnable {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
log.error("RedisMQConsumer:{}",e.toString());
}
}
}
}
}
\ No newline at end of file
......@@ -30,13 +30,9 @@ public class RedisMQConsumerContainer {
}
public void addConsumer(QueueConfiguration configuration) {
// if (consumerMap.containsKey(configuration.getQueue())) {
// log.warn("Key:{} this key already exists, and it will be replaced", configuration.getQueue());
// }
if (configuration.getConsumer() == null) {
log.warn("Key:{} consumer cannot be null, this configuration will be skipped", configuration.getQueue());
}
// consumerMap.put(configuration.getQueue(), configuration);
executor.submit(new QueueListener(redisTemplate,configuration.getQueue(),configuration.getConsumer()));
log.info("队列 {} 提交消息任务",configuration.getQueue());
......@@ -56,9 +52,10 @@ public class RedisMQConsumerContainer {
public void init() {
log.info("消息队列线程池初始化");
RUNNING = true;
this.executor = Executors.newCachedThreadPool(r -> {
final AtomicInteger threadNumber = new AtomicInteger(6);
return new Thread(r, "RedisMQListener-" + threadNumber.getAndIncrement());
});
this.executor= Executors.newCachedThreadPool();
// this.executor = Executors.newCachedThreadPool(r -> {
// final AtomicInteger threadNumber = new AtomicInteger(10);
// return new Thread(r, "RedisMQListener-" + threadNumber.getAndIncrement());
// });
}
}
\ No newline at end of file
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.Autosnaptaskinfo;
import com.cx.cn.cxquartz.vo.TraffAlarmRecord;
import java.util.List;
import java.util.Map;
public interface AutoSnapService {
int insert(Autosnaptaskinfo taskinfo);
List<Autosnaptaskinfo> query(Autosnaptaskinfo taskinfo);
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.util.RedisEnum;
import com.cx.cn.cxquartz.vo.Ftp;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class FtpService {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final Logger logger = LoggerFactory.getLogger(FtpService.class);
@Autowired
private StringRedisTemplate stringRedisTemplate;
private List<Ftp> ftpList;
@Autowired
CacheLoadService cacheLoadService;
@Autowired
public FtpService(StringRedisTemplate stringRedisTemplate) {
// try {
// this.ftpList = getFtpList(stringRedisTemplate.opsForValue().get(RedisEnum.FTPLIST.getValue()));
// }catch (Exception e){
// logger.error("ftpList error:"+e.toString());
// }
}
public Ftp reloadFtp() {
try {
// cacheLoadService.loadFtpCache();
if(null==stringRedisTemplate.opsForValue().get(RedisEnum.FTPLIST.getValue())){
cacheLoadService.loadFtpCache();
}
ftpList = getFtpList(stringRedisTemplate.opsForValue().get(RedisEnum.FTPLIST.getValue()));
}catch (Exception e){
logger.error("ftpListerror:"+e.toString());
}
Long count = null;
try {
count = stringRedisTemplate.opsForValue().increment(RedisEnum.FTPLIST_INDEX.getValue(), 1L);
} catch (Exception e) {
logger.error("redis error" + e.toString());
}
if (count == null) {
count = 0L;
}
long index = count % ftpList.size();
return ftpList.get((int) index);
}
private List<Ftp> getFtpList(String ftpJson) {
try {
JavaType javaType =OBJECT_MAPPER.getTypeFactory().constructParametricType(ArrayList.class, Map.class);
List<Map> jsonArr = OBJECT_MAPPER.readValue(ftpJson, javaType);
List<Ftp> ftpList = new ArrayList<>();
for (int i = 0; i < jsonArr.size(); i++) {
Ftp ftp = new Ftp();
Map jsonObject = jsonArr.get(i);
ftp.setFtpIp(jsonObject.get("serveip").toString());
ftp.setFtpPort(Integer.parseInt(jsonObject.get("serverport")==null?"21":jsonObject.get("serverport").toString()));
ftp.setFtpUsername(jsonObject.get("serveruser").toString());
ftp.setFtpPassword(jsonObject.get("serverpassword").toString());
ftpList.add(ftp);
}
}catch (Exception ex){
logger.error("ftpListerror:"+ex.toString());
}
return ftpList;
}
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.dao.AutoSanpMapper;
import com.cx.cn.cxquartz.dao.CodeMapper;
import com.cx.cn.cxquartz.rabbitmq.comsumer.AutoSnapConsumer;
import com.cx.cn.cxquartz.service.quartz.AutoSnapService;
import com.cx.cn.cxquartz.service.quartz.CodeService;
import com.cx.cn.cxquartz.vo.Autosnaptaskinfo;
import com.cx.cn.cxquartz.vo.Code;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Service
public class AutoSnapServiceImpl implements AutoSnapService {
@Autowired
AutoSanpMapper autoSanpMapper;
@Override
public int insert(Autosnaptaskinfo taskinfo) {
return autoSanpMapper.insert(taskinfo);
}
@Override
public List<Autosnaptaskinfo> query(Autosnaptaskinfo taskinfo) {
return autoSanpMapper.query(taskinfo);
}
}
......@@ -11,8 +11,8 @@ import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.vo.TraffpictureParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -61,18 +61,18 @@ public class ResultService {
public static final Logger logger = LoggerFactory.getLogger(ResultService.class);
public void processResult( Map result) {
if(null==result.get("param"))return;
Map taskinfo= (Map) result.get("param");
String devicecode=(String) taskinfo.get("devicecode");
String recordtype =(String) taskinfo.get("recordtype");
String threshold=(String) taskinfo.get("threshold");
String timestamp=taskinfo.get("timestamp").toString().substring(0,taskinfo.get("timestamp").toString().indexOf("."));
JobTjParam jobTjParam = new JobTjParam();
jobTjParam.setDeviceId(devicecode);
jobTjParam.setDetectType(recordtype);
String imageurl = taskinfo.get("url").toString();
TraffpictureParam traffpictureParamresult=new TraffpictureParam();
try {
// Map maprecogdata = JsonUtil.strToObj(objectList.get("recogdata").toString(), Map.class);
List<Map> points = new ArrayList<>();
//分析结果数据
......@@ -82,51 +82,78 @@ public class ResultService {
logger.info(" objectresult is empty");
} else {
Long[] roiarray = new Long[4];
roiarray[0] = new Long(taskinfo.get("x").toString());
roiarray[1] = new Long(taskinfo.get("y").toString());
roiarray[2] = new Long(taskinfo.get("w").toString());
roiarray[3] = new Long(taskinfo.get("h").toString());
getPoi(taskinfo, roiarray);
//图片划线并上传
String basepath = DateUtils.formatCurrDayYM() + File.separator + DateUtils.formatCurrDayDD() + File.separator + devicecode;
String filename = devicecode + "_" + DateUtils.parseDateToStrNoSign(timestamp) + "_result.jpg";
String filenameurl = File.separator + outpath + File.separator + basepath + File.separator + filename;
jobTjParam.setImageUrl(weburl + filenameurl);
traffpictureParamresult.setImagedata(filenameurl); //获得点位
logger.info("1");
traffpictureParamresult = eventWriteService.getResult(traffpictureParamresult, Integer.parseInt(threshold)
, roiarray, imageurl, objectresult, jobTjParam, points);
if (null == traffpictureParamresult) {
logger.info("人群密度未超或目标未出现");
logger.info("未检测到结果");
} else {
logger.info("2");
//同步上传文件
eventWriteService.uploadPicture(traffpictureParamresult, imageurl, points, basepath, filename);
//判断是否需要自动推送
if(null!=taskinfo.get("sendtype") &&taskinfo.get("sendtype").toString().equals("1"))
{
traffpictureParamresult.setPushstatus(9);
}
else if(null!=taskinfo.get("sendtype") &&taskinfo.get("sendtype").toString().equals("0"))
{
traffpictureParamresult.setPushstatus(1);//手动推送
}
//新增
eventWriteService.setTraffpictureParam(recordtype, devicecode,
timestamp,
traffpictureParamresult);
if(null!=traffpictureParamresult.getPushstatus() && traffpictureParamresult.getPushstatus()==9) {
Map sendtodxmap = new HashMap();
sendtodxmap.put("id", traffpictureParamresult.getId());
sendtodxmap.put("traff", JsonUtil.objToStr(jobTjParam));
sendtodxmap.put("callback", taskinfo.get("url").equals("") ? callbackurl : taskinfo.get("url").toString());
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
// rabbitTemplate.convertAndSend(QueueConstants.QueueSendToDXEnum.QUEUE_SEND_TO_DX_ENUM.getExchange(),
// QueueConstants.QueueSendToDXEnum.QUEUE_SEND_TO_DX_ENUM.getRouteKey(),
// MessageHelper.objToMsg(sendtodxmap),
// correlationData);
//
// rabbitTemplate.convertAndSend(QueueConstants.QueueSendToVoiceEnum.QUEUE_SEND_TO_VOICE_ENUM.getExchange(),
// QueueConstants.QueueSendToVoiceEnum.QUEUE_SEND_TO_VOICE_ENUM.getRouteKey(),
// MessageHelper.objToMsg(sendtodxmap),
// correlationData);
// //回调第三方接口
//// logger.info("send to dianxin data:{}",JSONObject.toJSONString(jobTjParam));
rabbitTemplate.convertAndSend(QueueConstants.QueueSendToDXEnum.QUEUE_SEND_TO_DX_ENUM.getExchange(),
QueueConstants.QueueSendToDXEnum.QUEUE_SEND_TO_DX_ENUM.getRouteKey(),
MessageHelper.objToMsg(sendtodxmap),
correlationData);
rabbitTemplate.convertAndSend(QueueConstants.QueueSendToVoiceEnum.QUEUE_SEND_TO_VOICE_ENUM.getExchange(),
QueueConstants.QueueSendToVoiceEnum.QUEUE_SEND_TO_VOICE_ENUM.getRouteKey(),
MessageHelper.objToMsg(sendtodxmap),
correlationData);
//回调第三方接口
// logger.info("send to dianxin data:{}",JSONObject.toJSONString(jobTjParam));
// eventWriteService.sendEventByCallUrl(traffpictureParamresult, jobTjParam, taskinfo.getUrl().equals("") ? callbackurl : taskinfo.getUrl());
}
}
}
}
// } catch(Exception ex){
// logger.error(" processResult error:{}", ex.toString());
// }
}
} catch(Exception ex){
logger.error(" processResult error:{}", ex.toString());
private void getPoi(Map taskinfo, Long[] roiarray) {
roiarray[0]=0L;roiarray[1]=0L;roiarray[2]=0L;roiarray[3]=0L;
if(null!=taskinfo.get("x") && !taskinfo.get("x").toString().equals("null"))
{
roiarray[0] = new Long(taskinfo.get("x").toString());
}
if(null!=taskinfo.get("y") &&!taskinfo.get("y").toString().equals("null")) {
roiarray[1] = new Long(taskinfo.get("y").toString());
}
if(null!=taskinfo.get("w") && !taskinfo.get("w").toString().equals("null")) {
roiarray[2] = new Long(taskinfo.get("w").toString());
}
if(null!=taskinfo.get("h") && !taskinfo.get("h").toString().equals("null"))
{
roiarray[3] = new Long(taskinfo.get("h").toString());
}
}
......
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.bean.GoalStructureParam;
import com.cx.cn.cxquartz.bean.QuartzTaskInformations;
import com.cx.cn.cxquartz.bean.TaskResult;
import com.cx.cn.cxquartz.helper.MessageHelper;
import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import com.cx.cn.cxquartz.util.JsonUtil;
import com.cx.cn.cxquartz.vo.ImageList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.*;
@Service
@Configuration
public class TaskRecog implements InitializingBean {
private static final Logger logger = LoggerFactory.getLogger(TaskRecog.class);
@Value("${file.recogurl}")
String recogurl;
@Value("${file.recogqsturl}")
String recogqsturl;
RestTemplate restTemplate=new RestTemplate();
@Autowired
private RabbitTemplate rabbitTemplate;
public void sender(List<Map> list) throws Exception {
String result="{\n" +
" \"ret\": 0,\n" +
" \"desc\": \"succ!\",\n" +
" \"url\": \"http://zjh189.ncpoi.cc:7080/download/202109/08/33050300001327599605/33050300001327599605_20210908_134131031.jpg\",\n" +
" \"resourcePath\": \"/home/ubuntu/pictures/slice/202109/08/33050300001327599605/33050300001327599605_20210908_134131031.jpg\",\n" +
" \"timestamp\": \"2021-09-08 13:41:31.031\",\n" +
" \"devicecode\": \"33050300001327599605\"\n" +
"}";
//调用服务,10个一组批量调用分析服务
int i=0;
GoalStructureParam goalSparam=new GoalStructureParam();
List<ImageList> imglist=new ArrayList<>();
int model=1;
Map<Integer, TaskResult> recordtypeMap=new HashMap();
for(Map m:list) {
if (null != m.get("task")) {
QuartzTaskInformations param = JsonUtil.strToObj(m.get("task").toString(), QuartzTaskInformations.class);
Map picture = JsonUtil.strToObj(m.get("result").toString(), Map.class);
//获得roi
ImageList img = new ImageList();
img.setImageID(String.valueOf(i));
img.setFormat(2);
if (null != param.getObjectType()) {
model = Integer.parseInt(param.getObjectType());
}
//判断是否有感兴趣区域
if (null != param.getObjectx() && null != param.getObjecty()
&& null != param.getObjectw() && null != param.getObjecth()) {
img.setRoi(new Long[]{param.getObjectx(),
param.getObjecty(),
param.getObjectw(),
param.getObjecth()
});
}
img.setData(picture.get("resourcePath").toString());
imglist.add(img);
recordtypeMap.put(i,new TaskResult(param.getVideoid(),
param.getRecordtype(),picture.get("timestamp").toString(),param.getObjectx(),param.getObjecty(), param.getObjectw() , param.getObjecth(),
picture.get("resourcePath").toString(), param.getMetatype(), param.getSendtype())
);
i++;
}
}
goalSparam.setImageList(imglist);
goalSparam.setModel(model);
String resultstr = restTemplate.postForObject(recogqsturl, goalSparam, String.class);
// try {
Map resulMap = JsonUtil.strToObj(resultstr, Map.class);
if (null != resulMap.get("ret") && resulMap.get("ret").equals("200")) {
List<Map> resultList = (List<Map>) resulMap.get("ObjectList");
if (resultList.size() < 1) {
logger.info(" objectresult is empty");
return ;
}
for (Integer key : recordtypeMap.keySet()) {
List<Map> senderresult = new ArrayList<>();
//遍历所有返回结果
for (Map resultMap : resultList) {
//放到消息处理 队列中
//根据返回的图片id 获得告警类型
if (null != resultMap.get("ImageID") && resultMap.get("ImageID").toString().equals(String.valueOf(key))) {
senderresult.add(resultMap);
}
}
Map map = new HashMap();
map.put("ObjectList",senderresult);
map.put("param", recordtypeMap.get(key));
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(QueueConstants.QueueEventProcessingEnum.QUEUE_EVENT_PROCESSING_ENUM.getExchange(),
QueueConstants.QueueEventProcessingEnum.QUEUE_EVENT_PROCESSING_ENUM.getRouteKey(),
MessageHelper.objToMsg(map),
correlationData);
}
}
// } catch (Exception ex) {
// logger.error(ex.toString());
// }
}
@Override
public void afterPropertiesSet() throws Exception {
// init();
}
}
\ No newline at end of file
......@@ -159,9 +159,10 @@ public class VideoRTSPorURLService {
return null;
}
public void getRTSPByDeviceCode(String token,String deviceCode) {
public String getRTSPByDeviceCode(String token,String deviceCode) {
String timestamp = String.valueOf(new Date().getTime());
HttpHeaders headers = new HttpHeaders();
String rtsp ="";
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("accessToken", token);
headers.add("timestamp", timestamp);
......@@ -173,9 +174,7 @@ public class VideoRTSPorURLService {
try {
Map result = new ObjectMapper().readValue(body, Map.class);
if (null != result.get("errorCode") && "0".equals(result.get("errorCode").toString())) {
sbtdspsr.setSbbh(deviceCode);
//获得token 成功,更新表数据
Map data = (Map) result.get("data");
// {
......@@ -187,19 +186,18 @@ public class VideoRTSPorURLService {
// "errorCode": "0",
// "errorMsg": "success"
// }
String rtsp = String.valueOf(data.get("rtspUri"));
//省内设备 = 地址只能用一次 ,33开头的18位
rtsp = String.valueOf(data.get("rtspUri"));
//省内设备 = 地址只能用一次 ,33开头的
// //集团设备 = 地址可以用20分钟,15位
sbtdspsr.setSqurllj(rtsp);
}
if (deviceCode.length() == 15) {
// if (deviceCode.length() == 18) {
String serverHlsNextTime = DateUtils.addMin(new Date(), 20);
sbtdspsr.setUrlnexttime(serverHlsNextTime);
} else if (deviceCode.startsWith("33") && deviceCode.length() == 18) {
//无需更新,抽帧的时候再去调用,将设备的rtsp 地址换成null
sbtdspsr.setUrlnexttime(null);
}
// } else if (deviceCode.startsWith("330") && sbtdspsr.getSqurllj().indexOf("token=")>-1 &&deviceCode.length()!=18) {
// //无需更新,抽帧的时候再去调用,将设备的rtsp 地址换成null
// sbtdspsr.setUrlnexttime(null);
// }
//更新表里的数据
if(null!=sbtdspsr.getSbbh() && !"".equals(sbtdspsr.getSbbh()))
sbtdspsrService.updateRTSPorHLSParam(sbtdspsr);
......@@ -209,6 +207,7 @@ public class VideoRTSPorURLService {
logger.error("getRTSPByDeviceCode" + ex.toString());
}
return rtsp;
}
/***
* 根据rtsp 或者hls 去抽帧
......
......@@ -3,6 +3,10 @@ package com.cx.cn.cxquartz.util;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class CommonUtil {
......@@ -22,4 +26,24 @@ public class CommonUtil {
pw.close();
}
}
public static LinkedHashMap<String, List<Map>> queryList(List<Map> list) {
LinkedHashMap<String, List<Map>> map = new LinkedHashMap<>();
for (Map li : list) {
//将需要归类的属性与map中的key进行比较,如果map中有该key则添加bean如果没有则新增key
Map mapresult = JsonUtil.strToObj(li.get("task").toString(), Map.class);
if (map.size() > 0 && null != mapresult.get("objectType") && map.containsKey(mapresult.get("objectType").toString())) {
//取出map中key对应的list并将遍历出的bean放入该key对应的list中
ArrayList<Map> templist = (ArrayList<Map>) map.get(mapresult.get("objectType"));
templist.add(li);
} else {
//创建新的list
ArrayList<Map> temlist = new ArrayList<Map>();
temlist.add(li);
map.put(mapresult.get("objectType").toString(), temlist);
}
}
return map;
}
}
package com.cx.cn.cxquartz.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author aiheng@jd.com
* @date 2014年10月31日 下午6:01:40
* @desc
*/
public class DateDomConvert implements DomConvert {
@Override
public Date convert(Object object) {
String date = null;
if (object instanceof String) {
date = (String) object;
}
if (date == null) {
return null;
}
if (date.contains("T") || date.contains(".")) {
date = date.replace("T", " ");
int index = date.indexOf(".");
date = date.substring(0, index);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
return sdf.parse(date);
} catch (ParseException e) {
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
System.out.println(new DateDomConvert().convert("2014-10-20 15:15:15.024"));
}
}
......@@ -6,7 +6,11 @@ import org.joda.time.Months;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class DateUtils {
private static final DateTimeFormatter YMD_HMS = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
......@@ -15,6 +19,9 @@ public class DateUtils {
private static final DateTimeFormatter Y_M_D = DateTimeFormat.forPattern("yyyy-MM-dd");
private static final DateTimeFormatter YM= DateTimeFormat.forPattern("yyyyMM");
private static final DateTimeFormatter DD= DateTimeFormat.forPattern("dd");
private static final DateTimeFormatter YYMM= DateTimeFormat.forPattern("yyyy/MM");
private static final DateTimeFormatter HHmmss= DateTimeFormat.forPattern("HHmmssSSS");
public static String formatCurrDate(){
return formatCurrDateByType(YMD_HMS);
}
......@@ -22,11 +29,17 @@ public class DateUtils {
public static String formatCurrDateNoSign(){
return formatCurrDateByType(YMDHMS);
}
public static String formatCurrDateHHmmss(){
return formatCurrDateByType(HHmmss);
}
public static String formatCurrDateYMD(){
return formatCurrDateByType(Y_M_D);
}
public static String formatCurrDateYYMM(){
return formatCurrDateByType(YYMM);
}
public static String formatCurrDayNoSign(){
return formatCurrDateByType(YMD);
......@@ -134,4 +147,40 @@ public class DateUtils {
public static String addMin(Date date,int min){
return new DateTime(date).plusMinutes(min).toString(YMD_HMS);
}
public static String dealDateFormat(String oldDateStr) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); //yyyy-MM-dd'T'HH:mm:ss.SSSZ
Date date = null;
try {
date = df.parse(oldDateStr);
} catch (ParseException e) {
return null;
}
SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
Date date1 = null;
try {
date1 = df1.parse(date.toString());
} catch (ParseException e) {
return null;
}
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return df2.format(date1);
}
/**
* 日期格式转换 yyyy-MM-dd HH:mm:ss TO yyyy-MM-dd'T'HH:mm:ss.SSSXXX (yyyy-MM-dd'T'HH:mm:ss.SSSZ)
* 2020-04-09 23:00:00 TO 2020-04-09T23:00:00.000+08:00
* @throws ParseException
*/
public static String dealDateFormatReverse(String oldDateStr){
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date1 = null;
try {
date1 = df2.parse(oldDateStr);
} catch (ParseException e) {
e.printStackTrace();
}
return df.format(date1);
}
}
package com.cx.cn.cxquartz.util;
/**
* @author aiheng@jd.com
* @date 2014年10月31日 下午5:36:34
* @desc 转换器
*/
public interface DomConvert
{
public Object convert(Object object);
}
package com.cx.cn.cxquartz.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author aiheng@jd.com
* @date 2014年10月31日 上午11:46:46
* @desc 此注解用来控制属性别名 和 转换别名使用,用于xml2bean和bean2xml里的<对应别名>值的转换
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface DomField
{
String value() default "";
}
package com.cx.cn.cxquartz.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author aiheng@jd.com
* @date 2014年10月31日 下午5:29:21
* @desc
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface DomFieldConvert
{
Class<? extends DomConvert> value();
}
package com.cx.cn.cxquartz.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author aiheng@jd.com
* @date 2014年10月31日 下午5:25:09
* @desc 此注解用来忽略序列化属性
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface DomFieldIngore
{
}
package com.cx.cn.cxquartz.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author aiheng@jd.com
* @date 2014年10月31日 上午11:46:23
* @desc 此注解用来控制Root别名 或者 解析类中引用自定义类使用,主要用于xml2bean使用,解析xml中代表这个自定义类的属性转换赋值
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface DomFieldRoot
{
Class<?> value();
}
package com.cx.cn.cxquartz.util;
/**
* @author aiheng@jd.com
* @date 2014年11月3日 上午10:18:34
* @desc Dom解析异常
*/
public class DomParseException extends RuntimeException
{
/**
* serialVersionUID
* long
*/
private static final long serialVersionUID = 4964045225307295010L;
public DomParseException()
{
super();
}
public DomParseException(String message)
{
super(message);
}
public DomParseException(String message, Throwable e)
{
super(message, e);
}
}
package com.cx.cn.cxquartz.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author aiheng@jd.com
* @date 2014年10月31日 上午11:46:23
* @desc 此注解用来控制Root别名
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface DomRoot
{
String value();
}
package com.cx.cn.cxquartz.util;
import com.cx.cn.cxquartz.controller.IndexController;
import com.cx.cn.cxquartz.vo.Location;
import com.cx.cn.cxquartz.vo.Point;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -16,7 +14,7 @@ import java.util.*;
import java.util.List;
public class PointUtil {
private static final Logger logger = LoggerFactory.getLogger(IndexController.class);
private static final Logger logger = LoggerFactory.getLogger(PointUtil.class);
public static void getXYWH(List<Point> points, Long[] roiarray){
Map<Integer, Integer> map=new HashMap();
......
This diff is collapsed.
package com.cx.cn.cxquartz.vo;
public class Autosnaptaskinfo {
private String taskid ;
private String taskname;
private String devicenum;
private String starthour;
private String endhour;
private String recordtype;
private String region;
private String spId;
private String status;
private String cjrq;
private String xgrq;
private String objectType;
private String sendurl;
private String threshold;
private String algorithmfrom;
private String sendtype;
public String getSendtype() {
return sendtype;
}
public void setSendtype(String sendtype) {
this.sendtype = sendtype;
}
public Autosnaptaskinfo(String taskid, String taskname, String devicenum, String starthour, String endhour, String recordtype, String region, String spId, String status, String objectType, String sendurl, String threshold, String algorithmfrom,String sendtype) {
this.taskid = taskid;
this.taskname = taskname;
this.devicenum = devicenum;
this.starthour = starthour;
this.endhour = endhour;
this.recordtype = recordtype;
this.region = region;
this.spId = spId;
this.status = status;
this.objectType = objectType;
this.sendurl = sendurl;
this.threshold = threshold;
this.algorithmfrom = algorithmfrom;
this.sendtype=sendtype;
}
public String getTaskid() {
return taskid;
}
public void setTaskid(String taskid) {
this.taskid = taskid;
}
public String getTaskname() {
return taskname;
}
public void setTaskname(String taskname) {
this.taskname = taskname;
}
public String getDevicenum() {
return devicenum;
}
public void setDevicenum(String devicenum) {
this.devicenum = devicenum;
}
public String getStarthour() {
return starthour;
}
public void setStarthour(String starthour) {
this.starthour = starthour;
}
public String getEndhour() {
return endhour;
}
public void setEndhour(String endhour) {
this.endhour = endhour;
}
public String getRecordtype() {
return recordtype;
}
public void setRecordtype(String recordtype) {
this.recordtype = recordtype;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getSpId() {
return spId;
}
public void setSpId(String spId) {
this.spId = spId;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getCjrq() {
return cjrq;
}
public void setCjrq(String cjrq) {
this.cjrq = cjrq;
}
public String getXgrq() {
return xgrq;
}
public void setXgrq(String xgrq) {
this.xgrq = xgrq;
}
public String getObjectType() {
return objectType;
}
public void setObjectType(String objectType) {
this.objectType = objectType;
}
public String getSendurl() {
return sendurl;
}
public void setSendurl(String sendurl) {
this.sendurl = sendurl;
}
public String getThreshold() {
return threshold;
}
public void setThreshold(String threshold) {
this.threshold = threshold;
}
public String getAlgorithmfrom() {
return algorithmfrom;
}
public void setAlgorithmfrom(String algorithmfrom) {
this.algorithmfrom = algorithmfrom;
}
public Autosnaptaskinfo(String devicenum) {
this.devicenum = devicenum;
}
}
package com.cx.cn.cxquartz.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
public class Capture {
private String deviceId;
private String dateTime;
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDateTime() {
return dateTime;
}
public void setDateTime(String dateTime) {
this.dateTime = dateTime;
}
}
......@@ -57,7 +57,7 @@ public class Traffpicture{
private String index;
private Integer targetnum;
private String targetnum;
private String creattime;
......@@ -69,11 +69,11 @@ public class Traffpicture{
this.creattime = creattime;
}
public Integer getTargetnum() {
public String getTargetnum() {
return targetnum;
}
public void setTargetnum(Integer targetnum) {
public void setTargetnum(String targetnum) {
this.targetnum = targetnum;
}
......
......@@ -63,7 +63,8 @@ spring:
# info
local:
job: 0
czurl: http://localhost:8089/ext/getRTSP/1
czurl: http://zjh189.ncpoi.cc:7780/getDeviceSnapshot
czrooturl: /home/ubuntu/pictures/slice
fxurl: http://localhost:8089/ext/getDeviceSnapshotAndRecognize
file:
......@@ -71,6 +72,9 @@ file:
recogurl: http://zjh189.ncpoi.cc:7080/getDeviceSnapshotAndRecognize
uploadurl: http://home2.ncpoi.cc:7080/uploadResultFile
model: 1
recogqsturl: http://zjh189.ncpoi.cc:9098/images/recog
rootpath: D://home/ubuntu/pictures/slice/
outpath: result
countryside:
callbackurl: http://kvideo.51iwifi.com/hesc-mq/hesc
......@@ -83,7 +87,7 @@ rtspurl:
url: http://kvideo.51iwifi.com/home_gw/heschome_api/api/hesc/open/getRtsp
appid: 8e9c7ff0fc6c11eac5efb5371726daaf
appsecret: 8e9ca700fc6c11eac5efb5371726daaf
params: account18888888888deviceCode
params: deviceCode
logging:
level:
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cx.cn.cxquartz.dao.AutoSanpMapper">
<resultMap id="resultMap" type="com.cx.cn.cxquartz.vo.Autosnaptaskinfo">
<id column="taskid" property="taskid"/>
<result column="taskname" property="taskname"/>
<result column="devicenum" property="devicenum"/>
<result column="starthour" property="starthour"/>
<result column="endhour" property="endhour"/>
<result column="recordtype" property="recordtype"/>
<result column="region" property="region"/>
<result column="spId" property="spId"/>
<result column="status" property="status"/>
<result column="objectType" property="objectType"/>
<result column="sendurl" property="sendurl"/>
<result column="threshold" property="threshold"/>
<result column="algorithmfrom" property="algorithmfrom"/>
<result column="sendtype" property="sendtype"/>
</resultMap>
<select id="query" parameterType="com.cx.cn.cxquartz.vo.Autosnaptaskinfo" resultMap="resultMap">
select taskid, taskname, devicenum, starthour, endhour, recordtype, region, spId, status, objectType, sendurl, threshold, algorithmfrom,sendtype from autosnaptaskinfo t where devicenum=#{devicenum} and status!=2
</select>
</mapper>
......@@ -3,7 +3,7 @@
<mapper namespace="com.cx.cn.cxquartz.dao.CodeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.cx.cn.cxquartz.vo.Code">
<resultMap id="CodeBaseResultMap" type="com.cx.cn.cxquartz.vo.Code">
<result column="key" jdbcType="VARCHAR" property="key" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="type" jdbcType="CHAR" property="type" />
......@@ -14,7 +14,7 @@
<result column="maxnumvalue" jdbcType="INTEGER" property="maxnum" />
<result column="alarmnum" jdbcType="INTEGER" property="alarmnum" />
</resultMap>
<select id="selectalarmNum" resultMap="BaseResultMap">
<select id="selectalarmNum" resultMap="CodeBaseResultMap">
select * from t_code t where t.type=2 and t.key=#{key,jdbcType=VARCHAR}
</select>
</mapper>
......@@ -5,7 +5,7 @@
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.cx.cn.cxquartz.vo.Face">
<id column="id" property="id"/>
<result column="facex" property="facex"/>
<result column="facex" property="facex" />
<result column="facey" property="facey"/>
<result column="facew" property="facew"/>
<result column="faceh" property="faceh"/>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.cx.cn.cxquartz.dao.SbtdspsrMapper">
<resultMap id="BaseResultMap" type="com.cx.cn.cxquartz.vo.Sbtdspsr">
<resultMap id="SbtdspsrBaseResultMap" type="com.cx.cn.cxquartz.vo.Sbtdspsr">
<result column="sbbh" jdbcType="VARCHAR" property="sbbh"/>
<result column="tdbh" jdbcType="INTEGER" property="tdbh"/>
<result column="xzbh" jdbcType="VARCHAR" property="xzbh"/>
......
......@@ -67,6 +67,8 @@
<if test="imagedata != null">imagedata,</if>
<if test="processstatus != null">processstatus,</if>
<if test="createtime !=null">createtime ,</if>
<if test="targetnum !=null">targetnum ,</if>
<if test="checkstatus !=null">checkstatus ,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="recordid != null">#{recordid},</if>
......@@ -92,6 +94,8 @@
<if test="imagedata != null">#{imagedata},</if>
<if test="processstatus != null">#{processstatus},</if>
<if test="createtime !=null">str_to_date(#{createtime},'%Y-%m-%d %H:%i:%s') ,</if>
<if test="targetnum !=null">#{targetnum} ,</if>
<if test="checkstatus !=null">#{checkstatus} ,</if>
</trim>
</insert>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment