Commit 44400cdd authored by wangjinjing's avatar wangjinjing

发布版本

parent 50cef139
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;
/***
* 自动抓拍队列
*/
@Configuration
public class AutoSnapConfig {
/**
* 创建交换机
*
* @return
*/
@Bean
public DirectExchange AutoSnapDirectExchange() {
return new DirectExchange(QueueConstants.QueueAutoSnapEnum.QUEUE_AUTOSNAP_ENUM.getExchange());
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue AutoSnapDirectQueue() {
return new Queue(QueueConstants.QueueAutoSnapEnum.QUEUE_AUTOSNAP_ENUM.getQueue(), true);
}
/**
* 将队列和交换机绑定,并设置用于匹配路由键
*
* @return
*/
@Bean
public Binding BindingAutoSnapDirect() {
return BindingBuilder.bind(AutoSnapDirectQueue()).to(AutoSnapDirectExchange()).with(QueueConstants.QueueAutoSnapEnum.QUEUE_AUTOSNAP_ENUM.getRouteKey());
}
}
\ No newline at end of file
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;
/***
* 自动抓拍队列
*/
@Configuration
public class SnapTaskConfig {
/**
* 创建交换机
*
* @return
*/
@Bean
public DirectExchange SnapTaskDirectExchange() {
return new DirectExchange(QueueConstants.QueueSnapTaskEnum.QUEUE_SNAP_TASK_ENUM.getExchange());
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public Queue SnapTaskDirectQueue() {
return new Queue(QueueConstants.QueueSnapTaskEnum.QUEUE_SNAP_TASK_ENUM.getQueue(), true);
}
/**
* 将队列和交换机绑定,并设置用于匹配路由键
*
* @return
*/
@Bean
public Binding BindingSnapTaskDirect() {
return BindingBuilder.bind(SnapTaskDirectQueue()).to(SnapTaskDirectExchange()).with(QueueConstants.QueueSnapTaskEnum.QUEUE_SNAP_TASK_ENUM.getRouteKey());
}
}
\ No newline at end of file
package com.cx.cn.cxquartz.controller;
import com.cx.cn.cxquartz.service.quartz.LJTMyjcResultService;
import com.cx.cn.cxquartz.vo.LJTMyjcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/***
* 垃圾桶溢出检测等任务解析结果回调方法
*/
@RestController
@RequestMapping("/algorithm")
public class LJTController {
private static final Logger logger = LoggerFactory.getLogger(LJTController.class);
@Autowired
LJTMyjcResultService lJTMYJCResultService;
/***
* 垃圾桶识别结果推送
* @param result
*/
@RequestMapping(value = "/CallBackResult", method = RequestMethod.POST)
public void LJTMYJCResult(@RequestBody String result) {
logger.info("LJTMYJCResult receive data:",result);
//将数据添加到表中,直接先存储json
LJTMyjcResult lJTMyjcResult=new LJTMyjcResult();
lJTMyjcResult.setData(result);
lJTMYJCResultService.insert(lJTMyjcResult);
}
}
package com.cx.cn.cxquartz.dao;
import com.cx.cn.cxquartz.vo.LJTMyjcResult;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Mapper
public interface LJTMyjcResultMapper {
Integer insert (LJTMyjcResult data);
}
package com.cx.cn.cxquartz.rabbitmq.comsumer;
import com.cx.cn.cxquartz.bean.GoalStructureParam;
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.redis.Consumer;
import com.cx.cn.cxquartz.service.quartz.AutoSnapService;
import com.cx.cn.cxquartz.service.quartz.impl.TaskRecog;
import com.cx.cn.cxquartz.util.JsonUtil;
import com.cx.cn.cxquartz.vo.Autosnaptaskinfo;
import com.cx.cn.cxquartz.vo.ImageList;
import com.rabbitmq.client.Channel;
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.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.io.File;
import java.io.IOException;
import java.util.*;
/**
* 消息处理并推送第三方
*/
@Component
public class AutoSnapConsumer implements BaseConsumer{
private List<Map> list=new ArrayList<>();
private static final Logger logger = LoggerFactory.getLogger(AutoSnapConsumer.class);
@Autowired
AutoSnapService autoSnapService;
@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;
@Autowired
private RestTemplate restTemplate;
@Value("${file.recogqsturl}")
String recogqsturl;
@Autowired
private RabbitTemplate rabbitTemplate;
@Value("${snapnote.note1}")
String note1;
/**
* 消息消费入口
*
* @param message
* @throws IOException
*/
@Override
public void consume(Message message,Channel channel) {
//将取到的信息解析出来,根据xml中提取的设备编号和jpg地址去查询任务将图片存储到任务对应的服务器上,然后进行调用抽帧分析,产生告警
//获取chanel 中数据,暂定数据类型为jpg地址与xml中提取的设备编号
Map result = MessageHelper.msgToObj(message, Map.class);
logger.info("note1 data:{}",JsonUtil.objToStr(result));
if(null!=result.get("devicecode") && null!=result.get("timestamp") && null!=result.get("resourcePath")) {
String devicecode = result.get("devicecode").toString();
String timestamp = result.get("timestamp").toString();
String resourcePath = note1+ File.separator + result.get("resourcePath").toString();
//当前消费者是note1 节点的消费者,需要访问note1 路径下
//根据设备id查询表中需要分析的任务(根据通道类型不同新建的不同任务,然后状态为开始自动抓拍的任务 ),获得设备编号,告警类别,检测对象,告警时间,图片相对地址,整合之后调用分析算法
List<Autosnaptaskinfo> taskinfolist = autoSnapService.query(new Autosnaptaskinfo(devicecode));
//根据算法来源决定放到哪个队列中进行消费
for (Autosnaptaskinfo info : taskinfolist) {
if (null!=info.getAlgorithmfrom() && info.getAlgorithmfrom().equals("1")) {
//调用视通算法服务
GoalStructureParam goalSparam = new GoalStructureParam();
ImageList img = new ImageList();
img.setImageID("1");
img.setFormat(2);
if (null != info.getRegionx() && !info.getRegionx().equals("")
&&null != info.getRegiony() && !info.getRegiony().equals("")
&&null != info.getRegionw() && !info.getRegionw().equals("")
&&null != info.getRegionh() && !info.getRegionh().equals("")
) {
img.setRoi(new Long[]{Long.parseLong(info.getRegionx()),
Long.parseLong(info.getRegiony()),
Long.parseLong(info.getRegionw()),
Long.parseLong(info.getRegionh())
});
}
img.setData(resourcePath);
List<ImageList> imgList = new ArrayList<>();
imgList.add(img);
goalSparam.setImageList(imgList);
goalSparam.setModel(info.getObjectType() == null ? 1 : Integer.parseInt(info.getObjectType()));
try {
String resultstr = restTemplate.postForObject(recogqsturl, goalSparam, String.class);
logger.info("resultstr===={}",resultstr);
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");
}
TaskResult taskResult = new TaskResult(info.getDevicenum(),
info.getRecordtype(), timestamp, img.getRoi() == null ? null : img.getRoi()[0], img.getRoi() == null ? null : img.getRoi()[1], img.getRoi() == null ? null : img.getRoi()[2], img.getRoi() == null ? null : img.getRoi()[3],
resourcePath, info.getObjectType(), info.getSendtype(),info.getSendurl());
Map map = new HashMap();
map.put("ObjectList", resultList);
map.put("param", taskResult);
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(devicecode+recogqsturl+" error :{}",ex.toString());
}
}
}
}
}
}
package com.cx.cn.cxquartz.rabbitmq.comsumer.listener;
import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import com.cx.cn.cxquartz.rabbitmq.comsumer.AutoSnapConsumer;
import com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumer;
import com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumerProxy;
import com.cx.cn.cxquartz.service.quartz.TraffPictureService;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
/**
* 告警信息结果分析
*/
@Component
public class AutoSnapReceiver {
private static final Logger logger = LoggerFactory.getLogger(AutoSnapReceiver.class);
@Autowired
private AutoSnapConsumer autoSnapConsumer;
@RabbitListener(queues = QueueConstants.QueueAutoSnapConsumer.QUEUE)
public void process(Message message, Channel channel) {
try {
BaseConsumerProxy baseConsumerProxy = new BaseConsumerProxy(autoSnapConsumer);
BaseConsumer proxy = (BaseConsumer) baseConsumerProxy.getProxy();
if (null != proxy) {
proxy.consume(message, channel);
}
} catch (Exception e) {
logger.error("告警信息结果分析 error:{}",e);
}
}
}
package com.cx.cn.cxquartz.service.quartz;
import com.cx.cn.cxquartz.vo.LJTMyjcResult;
public interface LJTMyjcResultService {
Integer insert(LJTMyjcResult data);
}
package com.cx.cn.cxquartz.service.quartz.impl;
import com.cx.cn.cxquartz.dao.LJTMyjcResultMapper;
import com.cx.cn.cxquartz.service.quartz.LJTMyjcResultService;
import com.cx.cn.cxquartz.vo.LJTMyjcResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author wjj
* @since 2021-04-29
*/
@Service
public class LJTMyjcResultServiceImpl implements LJTMyjcResultService {
@Autowired
private LJTMyjcResultMapper lJTMyjcResultMapper;
@Override
public Integer insert(LJTMyjcResult data) {
return lJTMyjcResultMapper.insert(data);
}
}
package com.cx.cn.cxquartz.vo;
public class JobLJTParam {
private String taskid;
private String taskname;
private String devicenum;
private Integer starthour;
private Integer endhour;
private Integer intervals;
private String interfaceCode;
private String region;
private String spId;
private Integer status;
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 Integer getStarthour() {
return starthour;
}
public void setStarthour(Integer starthour) {
this.starthour = starthour;
}
public Integer getEndhour() {
return endhour;
}
public void setEndhour(Integer endhour) {
this.endhour = endhour;
}
public Integer getIntervals() {
return intervals;
}
public void setIntervals(Integer intervals) {
this.intervals = intervals;
}
public String getInterfaceCode() {
return interfaceCode;
}
public void setInterfaceCode(String interfaceCode) {
this.interfaceCode = interfaceCode;
}
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 Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
package com.cx.cn.cxquartz.vo;
public class LJTMyjcResult {
private Integer id;
private String data;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
\ No newline at end of file
server:
port: 8083
spring:
datasource:
url: jdbc:mysql://192.168.78.31:3307/hzdxtest?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=GMT%2B8
username: hzdxtest
password: 1qaz@wsx
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
rabbitmq:
host: 192.168.78.31
port: 5672
username: admin
password: admin
virtual-host: /
#消息发送到交换机确认机制,是否确认回调
publisher-confirms: true
##消息发送到交换机确认机制,是否返回回调
publisher-returns: true
#启用强制信息;默认false
template.mandatory: true
#设置为 true 后 消费者在消息没有被路由到合适队列情况下会被return监听,而不会自动删除
listener:
simple:
#设置手动确认(ack)
acknowledge-mode: manual
concurrency: 5
max-concurrency: 10
prefetch: 10
#开启消费者重试
retry:
enabled: true
#重试时间间隔
initial-interval: 30000
#最大重试次数
max-attempts: 3
redis:
database: 0
host: 192.168.78.31
port: 6379
pool:
max-active: 5 #连接池最大连接数(负值表示没有限制)
max-wait: 60000 #连接池最大阻塞等待时间(负值表示没有限制)
max-idle: 1 #连接池最大空闭连接数
min-idle: 1 #连接汉最小空闲连接数
timeout: 60000 #连接超时时间(毫秒)
countryside:
callbackurl: http://kvideo.51iwifi.com
file:
# rootpath: /home/ubuntu/pictures
rtspurl: http://172.16.24.29:7180/getDeviceSnapshot #旧版抽帧服务地址
uploadurl: http://172.16.24.29:7080/uploadResultFile
recogqsturl: http://172.16.24.29:9098/images/recog #分析
rootpath: /home/ubuntu/pictures/slice #测试环境抽帧地址
local:
czurl: http://172.16.24.29:7780/getDeviceSnapshot #新版抽帧服务地址
fxurl: http://localhost:8083/ext/getDeviceSnapshotAndRecognize #本地抽帧分析一体服务
hlsurl:
token: http://183.131.122.215:85/appApi/authenticate/getToken
url: http://183.131.122.215:85/appApi/forward/byCode/57240035916824
rtspurl:
token: http://kvideo.51iwifi.com/home_gw/getAccessToken
url: http://kvideo.51iwifi.com/home_gw/heschome_api/api/hesc/open/getRtsp
appid: 8e9c7ff0fc6c11eac5efb5371726daaf
appsecret: 8e9ca700fc6c11eac5efb5371726daaf
params: deviceCode
logging:
level:
com.cx.cn.cxquartz.dao:
debug
server:
port: 8083
spring:
datasource:
url: jdbc:mysql://192.168.78.31:3307/hzdxtest?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=GMT%2B8
username: hzdxtest
password: 1qaz@wsx
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
rabbitmq:
host: 192.168.78.31
port: 5672
username: admin
password: admin
virtual-host: /
#消息发送到交换机确认机制,是否确认回调
publisher-confirms: true
##消息发送到交换机确认机制,是否返回回调
publisher-returns: true
#启用强制信息;默认false
template.mandatory: true
#设置为 true 后 消费者在消息没有被路由到合适队列情况下会被return监听,而不会自动删除
listener:
simple:
#设置手动确认(ack)
acknowledge-mode: manual
concurrency: 5
max-concurrency: 10
prefetch: 10
#开启消费者重试
retry:
enabled: true
#重试时间间隔
initial-interval: 3000
#最大重试次数
max-attempts: 3
redis:
database: 0
host: 192.168.78.31
port: 6379
pool:
max-active: 100 #连接池最大连接数(负值表示没有限制)
max-wait: 3000 #连接池最大阻塞等待时间(负值表示没有限制)
max-idle: 200 #连接池最大空闭连接数
min-idle: 50 #连接汉最小空闲连接数
timeout: 60000 #连接超时时间(毫秒)
countryside:
callbackurl: http://kvideo.51iwifi.com
file:
# rootpath: /home/ubuntu/pictures
rtspurl: http://172.16.24.29:7180/getDeviceSnapshot #旧版抽帧服务地址
uploadurl: http://home2.ncpoi.cc:7080/uploadResultFile
recogqsturl: http://172.16.24.29:9098/images/recog #分析
rootpath: /home/prod/pictures/snapshot #生产环境抽帧地址
local:
czurl: http://172.16.24.29:7780/getDeviceSnapshot #新版抽帧服务地址
fxurl: http://localhost:8083/ext/getDeviceSnapshotAndRecognize #抽帧分析一体服务
hlsurl:
token: http://183.131.122.215:85/appApi/authenticate/getToken
url: http://183.131.122.215:85/appApi/forward/byCode/57240035916824
rtspurl:
token: http://kvideo.51iwifi.com/home_gw/getAccessToken
url: http://kvideo.51iwifi.com/home_gw/heschome_api/api/hesc/open/getRtsp
appid: 8e9c7ff0fc6c11eac5efb5371726daaf
appsecret: 8e9ca700fc6c11eac5efb5371726daaf
params: deviceCode
logging:
level:
com.cx.cn.cxquartz.dao:
debug
<?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.CodeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" 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" />
<result column="alarmlevel" jdbcType="VARCHAR" property="alarmlevel" />
<result column="rectifytime" jdbcType="INTEGER" property="rectifytime" />
<result column="manualchecktime" jdbcType="INTEGER" property="manualchecktime" />
<result column="pushchecktime" jdbcType="INTEGER" property="pushchecktime" />
<result column="maxnumvalue" jdbcType="INTEGER" property="maxnum" />
<result column="alarmnum" jdbcType="INTEGER" property="alarmnum" />
</resultMap>
<select id="queryLJTMyjcResult" resultMap="BaseResultMap">
select * from LJTMyjcResult
</select>
<insert id="insert" parameterType="com.cx.cn.cxquartz.vo.LJTMyjcResult">
insert into LJTMyjcResult(data) values (#{data})
</insert>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<capture>
<protocol>HTTP</protocol>
<IPAddr>192.168.78.50</IPAddr>
<macAddress>3c:da:6d:91:83:6a</macAddress>
<deviceName>NVS</deviceName>
<deviceId>ID0602181091451311060769</deviceId>
<Description>VCACapture</Description>
<channelID>0</channelID>
<eventtype>2</eventtype>
<ruleID>0</ruleID>
<targetID>187</targetID>
<targettype>1</targettype>
<targetspeed>0</targetspeed>
<targetdirection>0</targetdirection>
<targetrect>
<lefttop-x>156</lefttop-x>
<lefttop-x>369</lefttop-x>
<rightbtm-x>165</rightbtm-x>
<rightbtm-y>720</rightbtm-y>
</targetrect>
<presentNO>0</presentNO>
<captureNum>1</captureNum>
<VCACapture>
<image>
<pid>V20211102202541080G65I00TV</pid>
<dateTime>2021-11-02T20:25:41+80</dateTime>
<contentID>vcaimage</contentID>
<picturerect>
<width>192</width>
<height>108</height>
</picturerect>
</image>
</VCACapture>
</capture>
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