Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
VideoAIBatchTaskConsumerService
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VideoAIService
VideoAIBatchTaskConsumerService
Commits
cb5db7cd
Commit
cb5db7cd
authored
Oct 08, 2021
by
wangjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉不用的jar
parent
2fb71bd3
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
355 additions
and
970 deletions
+355
-970
pom.xml
pom.xml
+3
-84
src/main/java/com/cx/cn/cxquartz/config/EventProcessingConfig.java
...java/com/cx/cn/cxquartz/config/EventProcessingConfig.java
+46
-0
src/main/java/com/cx/cn/cxquartz/config/RedisConfig.java
src/main/java/com/cx/cn/cxquartz/config/RedisConfig.java
+1
-1
src/main/java/com/cx/cn/cxquartz/controller/ExtController.java
...ain/java/com/cx/cn/cxquartz/controller/ExtController.java
+117
-117
src/main/java/com/cx/cn/cxquartz/rabbitmq/QueueConstants.java
...main/java/com/cx/cn/cxquartz/rabbitmq/QueueConstants.java
+62
-0
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/EventProcessingConsumer.java
...n/cxquartz/rabbitmq/comsumer/EventProcessingConsumer.java
+12
-11
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/SnapShotConsumer.java
...om/cx/cn/cxquartz/rabbitmq/comsumer/SnapShotConsumer.java
+3
-9
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/listener/EventProcessingReceiver.java
...z/rabbitmq/comsumer/listener/EventProcessingReceiver.java
+7
-7
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/listener/RTSPorHLSReceiver.java
...xquartz/rabbitmq/comsumer/listener/RTSPorHLSReceiver.java
+0
-3
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/listener/SendtoDXReceiver.java
...cxquartz/rabbitmq/comsumer/listener/SendtoDXReceiver.java
+0
-8
src/main/java/com/cx/cn/cxquartz/redis/OrderConsumer.java
src/main/java/com/cx/cn/cxquartz/redis/OrderConsumer.java
+2
-3
src/main/java/com/cx/cn/cxquartz/service/quartz/impl/EventWriteService.java
...cx/cn/cxquartz/service/quartz/impl/EventWriteService.java
+17
-19
src/main/java/com/cx/cn/cxquartz/service/quartz/impl/ResultService.java
...com/cx/cn/cxquartz/service/quartz/impl/ResultService.java
+28
-24
src/main/java/com/cx/cn/cxquartz/service/quartz/impl/VideoRTSPorURLService.java
...n/cxquartz/service/quartz/impl/VideoRTSPorURLService.java
+16
-13
src/main/java/com/cx/cn/cxquartz/util/DateUtils.java
src/main/java/com/cx/cn/cxquartz/util/DateUtils.java
+4
-0
src/main/java/com/cx/cn/cxquartz/util/FTPUtil.java
src/main/java/com/cx/cn/cxquartz/util/FTPUtil.java
+0
-375
src/main/java/com/cx/cn/cxquartz/util/FileTransferManager.java
...ain/java/com/cx/cn/cxquartz/util/FileTransferManager.java
+0
-177
src/main/java/com/cx/cn/cxquartz/util/HttpClientUtil.java
src/main/java/com/cx/cn/cxquartz/util/HttpClientUtil.java
+0
-97
src/main/java/com/cx/cn/cxquartz/util/RestUtil.java
src/main/java/com/cx/cn/cxquartz/util/RestUtil.java
+0
-1
src/main/java/com/cx/cn/cxquartz/vo/Sbtdspsr.java
src/main/java/com/cx/cn/cxquartz/vo/Sbtdspsr.java
+3
-3
src/main/resources/application-local.yml
src/main/resources/application-local.yml
+13
-7
src/main/resources/mapper/SbtdspsrMapper.xml
src/main/resources/mapper/SbtdspsrMapper.xml
+20
-0
src/test/java/com/quartz/cn/com/cx/cn/cxquartz/CXQuartzApplicationTests.java
...uartz/cn/com/cx/cn/cxquartz/CXQuartzApplicationTests.java
+1
-11
No files found.
pom.xml
View file @
cb5db7cd
...
@@ -8,8 +8,8 @@
...
@@ -8,8 +8,8 @@
<relativePath/>
<!-- lookup parent from repository -->
<relativePath/>
<!-- lookup parent from repository -->
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.
quartz
.cn
</groupId>
<groupId>
com.
comsumer
.cn
</groupId>
<artifactId>
VideoofCultural
</artifactId>
<artifactId>
TaskConsumption
</artifactId>
<version>
1.0
</version>
<version>
1.0
</version>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<description></description>
<description></description>
...
@@ -27,12 +27,6 @@
...
@@ -27,12 +27,6 @@
<artifactId>
spring-boot-starter-web
</artifactId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<!--mybatis-->
<!--mybatis-->
<dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<groupId>
org.mybatis.spring.boot
</groupId>
...
@@ -52,35 +46,6 @@
...
@@ -52,35 +46,6 @@
<artifactId>
mysql-connector-java
</artifactId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-tomcat
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.6
</version>
</dependency>
<dependency>
<groupId>
net.sf.json-lib
</groupId>
<artifactId>
json-lib
</artifactId>
<version>
2.4
</version>
<classifier>
jdk15
</classifier>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
3.15-beta2
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
@@ -88,23 +53,11 @@
...
@@ -88,23 +53,11 @@
</dependency>
</dependency>
<dependency>
<groupId>
commons-codec
</groupId>
<artifactId>
commons-codec
</artifactId>
<version>
1.9
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<artifactId>
commons-lang3
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<artifactId>
gson
</artifactId>
...
@@ -115,47 +68,13 @@
...
@@ -115,47 +68,13 @@
<artifactId>
jackson-datatype-joda
</artifactId>
<artifactId>
jackson-datatype-joda
</artifactId>
<version>
2.9.6
</version>
<version>
2.9.6
</version>
</dependency>
</dependency>
<!--quartz依赖-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-quartz
</artifactId>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.6
</version>
</dependency>
<dependency>
<groupId>
commons-net
</groupId>
<artifactId>
commons-net
</artifactId>
<version>
3.6
</version>
</dependency>
<dependency>
<groupId>
org.java-websocket
</groupId>
<artifactId>
Java-WebSocket
</artifactId>
<version>
1.3.8
</version>
</dependency>
<!-- redis -->
<!-- redis -->
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
</dependency>
<!--kafka依赖-->
<dependency>
<groupId>
org.springframework.kafka
</groupId>
<artifactId>
spring-kafka
</artifactId>
</dependency>
<!-- HttpClient依赖 -->
<dependency>
<groupId>
commons-httpclient
</groupId>
<artifactId>
commons-httpclient
</artifactId>
<version>
3.1
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-mail
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
<artifactId>
logback-classic
</artifactId>
...
...
src/main/java/com/cx/cn/cxquartz/config/EventProcessingConfig.java
0 → 100644
View file @
cb5db7cd
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
EventProcessingConfig
{
/**
* 创建交换机
*
* @return
*/
@Bean
public
DirectExchange
EventProcessingDirectExchange
()
{
return
new
DirectExchange
(
QueueConstants
.
QueueEventProcessingEnum
.
QUEUE_EVENT_PROCESSING_ENUM
.
getExchange
());
}
/**
* 创建队列 true表示是否持久
*
* @return
*/
@Bean
public
Queue
EventProcessingDirectQueue
()
{
return
new
Queue
(
QueueConstants
.
QueueEventProcessingEnum
.
QUEUE_EVENT_PROCESSING_ENUM
.
getQueue
(),
true
);
}
/**
* 将队列和交换机绑定,并设置用于匹配路由键
*
* @return
*/
@Bean
public
Binding
EventProcessingDirect
()
{
return
BindingBuilder
.
bind
(
EventProcessingDirectQueue
()).
to
(
EventProcessingDirectExchange
()).
with
(
QueueConstants
.
QueueEventProcessingEnum
.
QUEUE_EVENT_PROCESSING_ENUM
.
getRouteKey
());
}
}
\ No newline at end of file
src/main/java/com/cx/cn/cxquartz/config/RedisConfig.java
View file @
cb5db7cd
...
@@ -12,7 +12,7 @@ import org.springframework.data.redis.core.*;
...
@@ -12,7 +12,7 @@ import org.springframework.data.redis.core.*;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
//
@Configuration
@Configuration
@EnableCaching
//开启注解
@EnableCaching
//开启注解
public
class
RedisConfig
extends
CachingConfigurerSupport
{
public
class
RedisConfig
extends
CachingConfigurerSupport
{
...
...
src/main/java/com/cx/cn/cxquartz/controller/ExtController.java
View file @
cb5db7cd
...
@@ -155,123 +155,123 @@ public class ExtController {
...
@@ -155,123 +155,123 @@ public class ExtController {
return
ResultUtil
.
success
();
return
ResultUtil
.
success
();
}
}
//
@RequestMapping
(
value
=
"/getDeviceSnapshotAndRecognize"
,
method
=
RequestMethod
.
POST
)
//
@RequestMapping(value = "/getDeviceSnapshotAndRecognize", method = RequestMethod.POST)
public
String
getDeviceSnapshotAndRecognize
(
@RequestBody
String
taskno
)
{
//
public String getDeviceSnapshotAndRecognize(@RequestBody String taskno) {
//根据判断监控是否存在,该监控检测的事件是什么
//
//根据判断监控是否存在,该监控检测的事件是什么
List
<
QuartzTaskInformations
>
mapList
=
sbtdspsrService
.
selectRecogByRtsp
(
taskno
);
//
List<QuartzTaskInformations> mapList = sbtdspsrService.selectRecogByRtsp(taskno);
String
model
=
"1"
;
//
String model = "1";
//图片框选出来的范围
//
//图片框选出来的范围
Long
[]
roiarray
;
//
Long[] roiarray;
HttpEntity
<
GoalStructureParam
>
requestEntity
=
null
;
//
HttpEntity<GoalStructureParam> requestEntity = null;
if
(
null
!=
mapList
&&
!
mapList
.
equals
(
""
)
&&
mapList
.
size
()
>
0
)
{
//
if (null != mapList && !mapList.equals("") && mapList.size() > 0) {
//
HttpHeaders
headers
=
new
HttpHeaders
();
//
HttpHeaders headers = new HttpHeaders();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
//
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
Map
<
String
,
Object
>
mapparam
=
new
HashMap
<>();
//
Map<String, Object> mapparam = new HashMap<>();
roiarray
=
new
Long
[
4
];
//
roiarray = new Long[4];
//
//获得该监控的检测业务与检测范围
//
//获得该监控的检测业务与检测范围
for
(
QuartzTaskInformations
taskinfo
:
mapList
)
{
//
for (QuartzTaskInformations taskinfo : mapList) {
roiarray
[
0
]
=
new
Long
(
taskinfo
.
getObjectx
());
//
roiarray[0] = new Long(taskinfo.getObjectx());
roiarray
[
1
]
=
new
Long
(
taskinfo
.
getObjecty
());
//
roiarray[1] = new Long(taskinfo.getObjecty());
roiarray
[
2
]
=
new
Long
(
taskinfo
.
getObjectw
());
//
roiarray[2] = new Long(taskinfo.getObjectw());
roiarray
[
3
]
=
new
Long
(
taskinfo
.
getObjecth
());
//
roiarray[3] = new Long(taskinfo.getObjecth());
String
devicecode
=
taskinfo
.
getExecuteparamter
();
//
String devicecode=taskinfo.getExecuteparamter();
//查询该监控下面还没有经过分析的数据
//
//查询该监控下面还没有经过分析的数据
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
//
Map<String, Object> map = new HashMap<>();
map
.
put
(
"sbbh"
,
devicecode
);
//
map.put("sbbh", devicecode);
map
.
put
(
"recordtype"
,
taskinfo
.
getRecordtype
());
//
map.put("recordtype", taskinfo.getRecordtype());
//
List
<
TraffAlarmRecord
>
traffalarmrecordlist
=
traffAlarmRecordService
.
getTraffAlarmRecordByProgress
(
map
);
//
List<TraffAlarmRecord> traffalarmrecordlist=traffAlarmRecordService.getTraffAlarmRecordByProgress(map);
if
(
traffalarmrecordlist
.
size
()<
1
)
{
//
if(traffalarmrecordlist.size()<1) {
return
ResultUtil
.
success
();
//
return ResultUtil.success();
}
//
}
for
(
TraffAlarmRecord
transferRecord
:
traffalarmrecordlist
)
{
//
for (TraffAlarmRecord transferRecord : traffalarmrecordlist) {
GoalStructureParam
param
=
FileTransferManager
.
getGoalStructureParam
(
roiarray
,
//
GoalStructureParam param = FileTransferManager.getGoalStructureParam(roiarray,
Integer
.
parseInt
(
model
==
null
?
"1"
:
""
.
equals
(
model
)
?
"1"
:
model
),
2
,
transferRecord
);
//
Integer.parseInt(model == null ? "1" : "".equals(model) ? "1" : model),2, transferRecord);
if
(
param
.
getImageList
().
size
()
<
1
)
{
//
if (param.getImageList().size() < 1) {
logger
.
info
(
" no imagelist "
);
//
logger.info(" no imagelist ");
continue
;
//
continue;
}
//
}
String
maprecogdata
=
restTemplate
.
postForObject
(
recogurl
,
param
,
String
.
class
);
//
String maprecogdata = restTemplate.postForObject(recogurl, param, String.class);
try
{
//
try {
Map
result
=
new
ObjectMapper
().
readValue
(
maprecogdata
,
Map
.
class
);
//
Map result = new ObjectMapper().readValue(maprecogdata, Map.class);
if
(
null
!=
result
.
get
(
"ret"
)
&&
result
.
get
(
"ret"
).
equals
(
"200"
))
{
//
if (null != result.get("ret") && result.get("ret").equals("200")) {
//变成为已分析
//
//变成为已分析
transferRecord
.
setProcessstatus
(
"-1"
);
//
transferRecord.setProcessstatus("-1");
traffAlarmRecordService
.
updateTraffAlarmRecordProcess
(
transferRecord
);
//
traffAlarmRecordService.updateTraffAlarmRecordProcess(transferRecord);
String
recordtype
=
taskinfo
.
getRecordtype
();
//
String recordtype = taskinfo.getRecordtype();
JobTjParam
jobTjParam
=
new
JobTjParam
();
//
JobTjParam jobTjParam = new JobTjParam();
jobTjParam
.
setDeviceId
(
devicecode
);
//
jobTjParam.setDeviceId(devicecode);
jobTjParam
.
setDetectType
(
recordtype
);
//
jobTjParam.setDetectType(recordtype);
String
imageurl
=
transferRecord
.
getImg1path
();
//
String imageurl = transferRecord.getImg1path();
List
<
Map
>
points
=
new
ArrayList
<>();
//
List<Map> points = new ArrayList<>();
//分析结果数据
//
//分析结果数据
List
<
Map
>
objectresult
=
(
List
<
Map
>)
result
.
get
(
"ObjectList"
);
//
List<Map> objectresult = (List<Map>) result.get("ObjectList");
if
(
objectresult
.
size
()
<
1
)
{
//
if (objectresult.size() < 1) {
logger
.
info
(
" objectresult is empty"
);
//
logger.info(" objectresult is empty");
continue
;
//
continue;
}
//
}
//获得点位
//
//获得点位
logger
.
info
(
"获得点位"
);
//
logger.info("获得点位");
TraffpictureParam
traffpictureParamresult
=
new
TraffpictureParam
();
//
TraffpictureParam traffpictureParamresult = new TraffpictureParam();
traffpictureParamresult
=
eventWriteService
.
getResult
(
traffpictureParamresult
,
Integer
.
parseInt
(
taskinfo
.
getMetatype
())
//
traffpictureParamresult = eventWriteService.getResult(traffpictureParamresult,Integer.parseInt(taskinfo.getMetatype())
,
roiarray
,
imageurl
,
objectresult
,
jobTjParam
,
points
);
//
, roiarray, imageurl, objectresult, jobTjParam, points);
if
(
null
==
traffpictureParamresult
){
//
if(null==traffpictureParamresult){
logger
.
info
(
"人群密度未超或目标未出现"
);
//
logger.info("人群密度未超或目标未出现");
continue
;
//
continue;
}
//
}
eventWriteService
.
setTraffpictureParam
(
recordtype
,
devicecode
,
//
eventWriteService.setTraffpictureParam(recordtype, devicecode,
transferRecord
.
getCreatetime
(),
//
transferRecord.getCreatetime(),
traffpictureParamresult
);
//
traffpictureParamresult);
//图片划线并上传
//
//图片划线并上传
logger
.
info
(
"图片划线并上传"
);
//
logger.info("图片划线并上传");
String
basepath
=
DateUtils
.
formatCurrDayYM
()
+
//
String basepath = DateUtils.formatCurrDayYM() +
File
.
separator
+
DateUtils
.
formatCurrDayDD
()
+
File
.
separator
+
//
File.separator + DateUtils.formatCurrDayDD() + File.separator +
devicecode
;
//
devicecode;
String
filename
=
devicecode
+
"_"
+
DateUtils
.
parseDateToStrNoSign
(
transferRecord
.
getRecordtime
())
+
"_"
+
recordtype
+
"_result.jpg"
;
//
String filename = devicecode + "_" + DateUtils.parseDateToStrNoSign(transferRecord.getRecordtime()) +"_"+ recordtype+"_result.jpg";
eventWriteService
.
uploadPicture
(
traffpictureParamresult
,
transferRecord
.
getImg1urlfrom
(),
points
,
basepath
,
filename
);
//
eventWriteService.uploadPicture(traffpictureParamresult, transferRecord.getImg1urlfrom(), points, basepath, filename);
String
filenameurl
=
File
.
separator
+
outpath
+
File
.
separator
+
basepath
+
File
.
separator
+
filename
;
//
String filenameurl = File.separator + outpath + File.separator + basepath + File.separator + filename;
jobTjParam
.
setImageUrl
(
weburl
+
filenameurl
);
//
jobTjParam.setImageUrl(weburl + filenameurl);
logger
.
info
(
"file path:{}"
,
filenameurl
);
//
logger.info("file path:{}",filenameurl);
traffpictureParamresult
.
setImagedata
(
filenameurl
);
//
traffpictureParamresult.setImagedata(filenameurl);
traffpictureParamresult
.
setProcessstatus
(
"-1"
);
//
traffpictureParamresult.setProcessstatus("-1");
traffPictureService
.
updateTraffpicture
(
traffpictureParamresult
);
//
traffPictureService.updateTraffpicture(traffpictureParamresult);
//
//回调
//
//回调
logger
.
info
(
"send to dianxin data:{}"
,
jobTjParam
.
toString
());
//
logger.info("send to dianxin data:{}",jobTjParam.toString());
eventWriteService
.
sendEventByCallUrl
(
traffpictureParamresult
,
jobTjParam
,
taskinfo
.
getUrl
().
equals
(
""
)
?
callbackurl
:
taskinfo
.
getUrl
());
//
eventWriteService.sendEventByCallUrl(traffpictureParamresult, jobTjParam, taskinfo.getUrl().equals("") ? callbackurl : taskinfo.getUrl());
//
if
(
unionId
.
contains
(
devicecode
))
{
//
if (unionId.contains(devicecode)) {
VoiceData
voicedata
=
new
VoiceData
();
//
VoiceData voicedata = new VoiceData();
voicedata
.
setAppKey
(
appKey
);
//
voicedata.setAppKey(appKey);
voicedata
.
setCorpId
(
corpId
);
//
voicedata.setCorpId(corpId);
Voice
voice
=
new
Voice
();
//
Voice voice = new Voice();
voice
.
setEventId
(
eventId
);
//
voice.setEventId(eventId);
voice
.
setUnionId
(
unionId
);
//
voice.setUnionId(unionId);
voicedata
.
setRequestData
(
voice
);
//
voicedata.setRequestData(voice);
// logger.info(" send to voice: {}", new ObjectMapper().writeValueAsString(voicedata));
//
// logger.info(" send to voice: {}", new ObjectMapper().writeValueAsString(voicedata));
eventWriteService
.
sendVoice
(
voicedata
);
//
eventWriteService.sendVoice(voicedata);
}
//
}
//推送告警到前端
//
//推送告警到前端
webSocket
.
GroupSending
(
new
ObjectMapper
().
writeValueAsString
(
traffpictureParamresult
));
//
webSocket.GroupSending(new ObjectMapper().writeValueAsString(traffpictureParamresult));
}
//
}
}
catch
(
Exception
ex
)
{
//
} catch (Exception ex) {
logger
.
error
(
ex
.
toString
());
//
logger.error(ex.toString());
}
//
}
//其他数据如表
//
//其他数据如表
//getMetaData( objectresult );
//
//getMetaData( objectresult );
}
//
}
}
//
}
return
ResultUtil
.
success
();
//
return ResultUtil.success();
}
else
{
//
} else {
logger
.
info
(
"监控不属于该范围"
);
//
logger.info("监控不属于该范围");
}
//
}
//更新record 表Progress 字段,0为 未检测,-2 为检测失败,将检测
//
//更新record 表Progress 字段,0为 未检测,-2 为检测失败,将检测
//结果进行额外封装入表
//
//结果进行额外封装入表
return
ResultUtil
.
success
();
//
return ResultUtil.success();
}
//
}
// @RequestMapping(value = "/getDeviceSnapshotAndRecognize", method = RequestMethod.POST)
// @RequestMapping(value = "/getDeviceSnapshotAndRecognize", method = RequestMethod.POST)
// public String getDeviceSnapshotAndRecognize(@RequestBody String taskno) {
// public String getDeviceSnapshotAndRecognize(@RequestBody String taskno) {
// //根据判断监控是否存在,该监控检测的事件是什么
// //根据判断监控是否存在,该监控检测的事件是什么
...
...
src/main/java/com/cx/cn/cxquartz/rabbitmq/QueueConstants.java
View file @
cb5db7cd
...
@@ -279,8 +279,70 @@ public class QueueConstants {
...
@@ -279,8 +279,70 @@ public class QueueConstants {
this
.
routeKey
=
routeKey
;
this
.
routeKey
=
routeKey
;
}
}
}
}
public
enum
QueueEventProcessingEnum
{
QUEUE_EVENT_PROCESSING_ENUM
(
QueueConstants
.
QueueEventProcessingConsumer
.
EXCHANGE
,
QueueConstants
.
QueueEventProcessingConsumer
.
QUEUE
,
QueueConstants
.
QueueEventProcessingConsumer
.
ROUTEKEY
);
/**
* 交换机名称
*/
private
String
exchange
;
/**
* 队列名称
*/
private
String
queue
;
/**
* 路由键
*/
private
String
routeKey
;
QueueEventProcessingEnum
(
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
QueueEventProcessingConsumer
{
/**
* 交换机名称
*/
String
EXCHANGE
=
"RabbitMQ.DirectExchange.EventProcessingConsumer"
;
/**
* 队列名称
*/
String
QUEUE
=
"RabbitMQ.DirectQueue.EventProcessingConsumer"
;
/**
* 路由键
*/
String
ROUTEKEY
=
"RabbitMQ.RouteKey.EventProcessingConsumer"
;
}
...
...
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/
TaskConsum
Consumer.java
→
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/
EventProcessing
Consumer.java
View file @
cb5db7cd
...
@@ -4,21 +4,21 @@ import com.cx.cn.cxquartz.helper.MessageHelper;
...
@@ -4,21 +4,21 @@ import com.cx.cn.cxquartz.helper.MessageHelper;
import
com.cx.cn.cxquartz.service.quartz.TraffAlarmRecordService
;
import
com.cx.cn.cxquartz.service.quartz.TraffAlarmRecordService
;
import
com.cx.cn.cxquartz.service.quartz.impl.ResultService
;
import
com.cx.cn.cxquartz.service.quartz.impl.ResultService
;
import
com.cx.cn.cxquartz.util.JsonUtil
;
import
com.cx.cn.cxquartz.util.JsonUtil
;
import
com.cx.cn.cxquartz.bean.QuartzTaskInformations
;
import
com.rabbitmq.client.Channel
;
import
com.rabbitmq.client.Channel
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
* 消息处理并推送第三方
* 消息处理并推送第三方
*/
*/
//
@Component
@Component
public
class
TaskConsum
Consumer
implements
BaseConsumer
{
public
class
EventProcessing
Consumer
implements
BaseConsumer
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TaskConsum
Consumer
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EventProcessing
Consumer
.
class
);
@Autowired
@Autowired
TraffAlarmRecordService
traffAlarmRecordService
;
TraffAlarmRecordService
traffAlarmRecordService
;
...
@@ -35,13 +35,14 @@ public class TaskConsumConsumer implements BaseConsumer {
...
@@ -35,13 +35,14 @@ public class TaskConsumConsumer implements BaseConsumer {
public
void
consume
(
Message
message
,
Channel
channel
)
throws
IOException
{
public
void
consume
(
Message
message
,
Channel
channel
)
throws
IOException
{
logger
.
info
(
"TaskConsumConsumer 收到消息: {}"
,
message
.
toString
());
logger
.
info
(
"TaskConsumConsumer 收到消息: {}"
,
message
.
toString
());
Map
result
=
MessageHelper
.
msgToObj
(
message
,
Map
.
class
);
Map
result
=
MessageHelper
.
msgToObj
(
message
,
Map
.
class
);
if
(
null
!=
result
.
get
(
"task"
))
{
resultService
.
processResult
(
result
);
QuartzTaskInformations
taskinfo
=
JsonUtil
.
strToObj
(
result
.
get
(
"task"
).
toString
(),
QuartzTaskInformations
.
class
);
//if (null !=result) {
if
(
null
!=
result
.
get
(
"result"
))
{
// QuartzTaskInformations taskinfo = JsonUtil.strToObj( result.get("task").toString(),QuartzTaskInformations.class);
Map
objresult
=
JsonUtil
.
strToObj
(
result
.
get
(
"result"
).
toString
(),
Map
.
class
);
// if (null != result.get("result")) {
// Map objresult = JsonUtil.strToObj(result.get("result").toString(), Map.class);
//处理消息
//处理消息
resultService
.
processResult
(
taskinfo
,
objresult
);
//
resultService.processResult(taskinfo, objresult);
}
//
}
}
//
}
}
}
}
}
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/SnapShotConsumer.java
View file @
cb5db7cd
package
com
.
cx
.
cn
.
cxquartz
.
rabbitmq
.
comsumer
;
package
com
.
cx
.
cn
.
cxquartz
.
rabbitmq
.
comsumer
;
import
com.cx.cn.cxquartz.bean.QuartzTaskInformations
;
import
com.cx.cn.cxquartz.helper.MessageHelper
;
import
com.cx.cn.cxquartz.helper.MessageHelper
;
import
com.cx.cn.cxquartz.service.quartz.TraffAlarmRecordService
;
import
com.cx.cn.cxquartz.service.quartz.impl.ResultService
;
import
com.cx.cn.cxquartz.service.quartz.impl.VideoRTSPorURLService
;
import
com.cx.cn.cxquartz.service.quartz.impl.VideoRTSPorURLService
;
import
com.cx.cn.cxquartz.util.JsonUtil
;
import
com.cx.cn.cxquartz.vo.Sbtdspsr
;
import
com.cx.cn.cxquartz.vo.Sbtdspsr
;
import
com.rabbitmq.client.Channel
;
import
com.rabbitmq.client.Channel
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -14,20 +10,18 @@ import org.springframework.amqp.core.Message;
...
@@ -14,20 +10,18 @@ import org.springframework.amqp.core.Message;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.util.Map
;
@Component
@Component
public
class
SnapShotConsumer
implements
BaseConsumer
{
public
class
SnapShotConsumer
implements
BaseConsumer
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TaskConsum
Consumer
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SnapShot
Consumer
.
class
);
@Autowired
@Autowired
VideoRTSPorURLService
videoRTSPorURLService
;
VideoRTSPorURLService
videoRTSPorURLService
;
@Override
@Override
public
void
consume
(
Message
message
,
Channel
channel
)
throws
IOException
{
public
void
consume
(
Message
message
,
Channel
channel
)
{
logger
.
info
(
"SnapShotConsumer 收到消息: {}"
,
message
.
toString
());
logger
.
info
(
"SnapShotConsumer 收到消息: {}"
,
message
.
toString
());
Sbtdspsr
result
=
MessageHelper
.
msgToObj
(
message
,
Sbtdspsr
.
class
);
Sbtdspsr
result
=
MessageHelper
.
msgToObj
(
message
,
Sbtdspsr
.
class
);
if
(
result
.
getTdlx
()
.
equals
(
"1"
)
)
{
if
(
result
.
getTdlx
()
==
1
)
{
//调用rtsp 的服务
//调用rtsp 的服务
String
token
=
videoRTSPorURLService
.
getRTSPAccessToekenByDeviceCode
(
result
.
getSbbh
());
String
token
=
videoRTSPorURLService
.
getRTSPAccessToekenByDeviceCode
(
result
.
getSbbh
());
videoRTSPorURLService
.
getRTSPByDeviceCode
(
token
,
result
.
getSbbh
());
videoRTSPorURLService
.
getRTSPByDeviceCode
(
token
,
result
.
getSbbh
());
...
...
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/listener/
OrderCancel
Receiver.java
→
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/listener/
EventProcessing
Receiver.java
View file @
cb5db7cd
...
@@ -3,7 +3,7 @@ package com.cx.cn.cxquartz.rabbitmq.comsumer.listener;
...
@@ -3,7 +3,7 @@ package com.cx.cn.cxquartz.rabbitmq.comsumer.listener;
import
com.cx.cn.cxquartz.rabbitmq.QueueConstants
;
import
com.cx.cn.cxquartz.rabbitmq.QueueConstants
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumer
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumer
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumerProxy
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumerProxy
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.
TaskConsum
Consumer
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.
EventProcessing
Consumer
;
import
com.cx.cn.cxquartz.service.quartz.TraffPictureService
;
import
com.cx.cn.cxquartz.service.quartz.TraffPictureService
;
import
com.rabbitmq.client.Channel
;
import
com.rabbitmq.client.Channel
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -16,20 +16,20 @@ import org.springframework.stereotype.Component;
...
@@ -16,20 +16,20 @@ import org.springframework.stereotype.Component;
/**
/**
* 任务消息监听接受器
* 任务消息监听接受器
*/
*/
//
@Component
@Component
public
class
OrderCancel
Receiver
{
public
class
EventProcessing
Receiver
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OrderCancel
Receiver
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EventProcessing
Receiver
.
class
);
@Autowired
@Autowired
private
TaskConsumConsumer
taskConsum
Consumer
;
private
EventProcessingConsumer
eventProcessing
Consumer
;
@Autowired
@Autowired
private
TraffPictureService
traffPictureService
;
private
TraffPictureService
traffPictureService
;
@RabbitListener
(
queues
=
QueueConstants
.
Queue
Task
Consumer
.
QUEUE
,
containerFactory
=
"rabbitListenerContainerFactory"
)
@RabbitListener
(
queues
=
QueueConstants
.
Queue
EventProcessing
Consumer
.
QUEUE
,
containerFactory
=
"rabbitListenerContainerFactory"
)
public
void
process
(
Message
message
,
Channel
channel
)
{
public
void
process
(
Message
message
,
Channel
channel
)
{
try
{
try
{
logger
.
info
(
"consumer->OrderCancelReceiver消费者收到消息 : "
+
message
.
toString
());
logger
.
info
(
"consumer->OrderCancelReceiver消费者收到消息 : "
+
message
.
toString
());
BaseConsumerProxy
baseConsumerProxy
=
new
BaseConsumerProxy
(
taskConsum
Consumer
,
traffPictureService
);
BaseConsumerProxy
baseConsumerProxy
=
new
BaseConsumerProxy
(
eventProcessing
Consumer
,
traffPictureService
);
BaseConsumer
proxy
=
(
BaseConsumer
)
baseConsumerProxy
.
getProxy
();
BaseConsumer
proxy
=
(
BaseConsumer
)
baseConsumerProxy
.
getProxy
();
if
(
null
!=
proxy
)
{
if
(
null
!=
proxy
)
{
proxy
.
consume
(
message
,
channel
);
proxy
.
consume
(
message
,
channel
);
...
...
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/listener/RTSPorHLSReceiver.java
View file @
cb5db7cd
...
@@ -4,9 +4,6 @@ import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
...
@@ -4,9 +4,6 @@ import com.cx.cn.cxquartz.rabbitmq.QueueConstants;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumer
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumer
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumerProxy
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.BaseConsumerProxy
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.SnapShotConsumer
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.SnapShotConsumer
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.TaskConsumConsumer
;
import
com.cx.cn.cxquartz.service.quartz.TraffAlarmRecordService
;
import
com.cx.cn.cxquartz.service.quartz.TraffPictureService
;
import
com.rabbitmq.client.Channel
;
import
com.rabbitmq.client.Channel
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
...
src/main/java/com/cx/cn/cxquartz/rabbitmq/comsumer/listener/SendtoDXReceiver.java
View file @
cb5db7cd
package
com
.
cx
.
cn
.
cxquartz
.
rabbitmq
.
comsumer
.
listener
;
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
com.cx.cn.cxquartz.rabbitmq.comsumer.SendToDXConsumer
;
import
com.cx.cn.cxquartz.rabbitmq.comsumer.TaskConsumConsumer
;
import
com.cx.cn.cxquartz.service.quartz.impl.ResultService
;
import
com.rabbitmq.client.Channel
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
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.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
...
src/main/java/com/cx/cn/cxquartz/redis/OrderConsumer.java
View file @
cb5db7cd
...
@@ -5,7 +5,6 @@ import com.cx.cn.cxquartz.helper.MessageHelper;
...
@@ -5,7 +5,6 @@ import com.cx.cn.cxquartz.helper.MessageHelper;
import
com.cx.cn.cxquartz.rabbitmq.QueueConstants
;
import
com.cx.cn.cxquartz.rabbitmq.QueueConstants
;
import
com.cx.cn.cxquartz.service.quartz.SbtdspsrService
;
import
com.cx.cn.cxquartz.service.quartz.SbtdspsrService
;
import
com.cx.cn.cxquartz.service.quartz.impl.VideoRTSPorURLService
;
import
com.cx.cn.cxquartz.service.quartz.impl.VideoRTSPorURLService
;
import
com.cx.cn.cxquartz.util.HttpClientUtil
;
import
com.cx.cn.cxquartz.util.JsonUtil
;
import
com.cx.cn.cxquartz.util.JsonUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -66,11 +65,11 @@ public class OrderConsumer implements Consumer {
...
@@ -66,11 +65,11 @@ public class OrderConsumer implements Consumer {
if
(
null
!=
devicecode
&&
devicecode
.
startsWith
(
"33"
)
&&
devicecode
.
length
()==
18
){
if
(
null
!=
devicecode
&&
devicecode
.
startsWith
(
"33"
)
&&
devicecode
.
length
()==
18
){
//调用抽帧服务
//调用抽帧服务
String
token
=
orderConsumer
.
videoRTSPorURLService
.
getRTSPAccessToekenByDeviceCode
(
devicecode
);
String
token
=
orderConsumer
.
videoRTSPorURLService
.
getRTSPAccessToekenByDeviceCode
(
devicecode
);
String
rtsp
=
orderConsumer
.
videoRTSPorURLService
.
getRTSPByDeviceCode
(
token
,
devicecode
);
orderConsumer
.
videoRTSPorURLService
.
getRTSPByDeviceCode
(
token
,
devicecode
);
}
}
else
{
else
{
//取表里最新的rtsp 或者hls 的值
//取表里最新的rtsp 或者hls 的值
String
rtsp
=
orderConsumer
.
sbtdspsrService
.
getRtspOrHLSByDeviceCode
(
devicecode
);
orderConsumer
.
sbtdspsrService
.
getRtspOrHLSByDeviceCode
(
devicecode
);
}
}
//将rtsp 作为参数调用抽帧服务
//将rtsp 作为参数调用抽帧服务
String
result
=
"{\n"
+
String
result
=
"{\n"
+
...
...
src/main/java/com/cx/cn/cxquartz/service/quartz/impl/EventWriteService.java
View file @
cb5db7cd
...
@@ -5,23 +5,16 @@ import com.cx.cn.cxquartz.service.quartz.FtpService;
...
@@ -5,23 +5,16 @@ import com.cx.cn.cxquartz.service.quartz.FtpService;
import
com.cx.cn.cxquartz.service.quartz.TraffPictureService
;
import
com.cx.cn.cxquartz.service.quartz.TraffPictureService
;
import
com.cx.cn.cxquartz.util.*
;
import
com.cx.cn.cxquartz.util.*
;
import
com.cx.cn.cxquartz.vo.*
;
import
com.cx.cn.cxquartz.vo.*
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.quartz.JobKey
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.ByteArrayResource
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
sun.misc.BASE64Encoder
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.File
;
...
@@ -217,18 +210,6 @@ public class EventWriteService {
...
@@ -217,18 +210,6 @@ public class EventWriteService {
return
restTemplate
.
postForObject
(
voiceurl
,
requestEntity
,
VoiceResultObj
.
class
);
return
restTemplate
.
postForObject
(
voiceurl
,
requestEntity
,
VoiceResultObj
.
class
);
}
}
public
String
sendToService
(
JobKey
jobKey
,
String
jsondata
)
{
try
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
jsondata
,
headers
);
return
CompletableFuture
.
supplyAsync
(()
->
restTemplate
.
postForObject
(
jobKey
.
getName
().
contains
(
"cz_"
)
?
czurl
:
fxurl
,
requestEntity
,
String
.
class
)).
get
(
timeout
,
TimeUnit
.
SECONDS
);
}
catch
(
Exception
ex
)
{
log
.
info
(
"getRtspJob->executeInternal error:{}"
,
ex
.
toString
());
return
null
;
}
}
public
TraffpictureParam
getResult
(
TraffpictureParam
traffpictureParamresult
,
int
tarnum
,
Long
[]
roiarray
,
String
imgurl
,
public
TraffpictureParam
getResult
(
TraffpictureParam
traffpictureParamresult
,
int
tarnum
,
Long
[]
roiarray
,
String
imgurl
,
List
<
Map
>
objectList
,
List
<
Map
>
objectList
,
...
@@ -248,6 +229,23 @@ public class EventWriteService {
...
@@ -248,6 +229,23 @@ public class EventWriteService {
return
null
;
return
null
;
}
}
}
}
//人群总数和戴口罩统计
else
if
(
"60"
.
equals
(
recordtype
)){
int
larmnum
=
getManNumber
(
objectList
);
obj
.
put
(
"alarmNum"
,
tarnum
);
if
(
tarnum
<
larmnum
)
{
obj
.
put
(
"objectCount"
,
larmnum
);
traffpictureParamresult
.
setTargetnum
(
larmnum
);
//判断戴口罩多少人
}
else
{
return
null
;
}
}
//获得所有对象的坐标
//获得所有对象的坐标
for
(
Map
traffpictureParam
:
objectList
)
{
for
(
Map
traffpictureParam
:
objectList
)
{
//根据imageid 获得 base64图片
//根据imageid 获得 base64图片
...
...
src/main/java/com/cx/cn/cxquartz/service/quartz/impl/ResultService.java
View file @
cb5db7cd
...
@@ -60,35 +60,39 @@ public class ResultService {
...
@@ -60,35 +60,39 @@ public class ResultService {
RabbitTemplate
rabbitTemplate
;
RabbitTemplate
rabbitTemplate
;
public
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ResultService
.
class
);
public
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ResultService
.
class
);
public
void
processResult
(
QuartzTaskInformations
taskinfo
,
Map
objectList
)
{
public
void
processResult
(
Map
result
)
{
String
devicecode
=
taskinfo
.
getExecuteparamter
();
Map
taskinfo
=
(
Map
)
result
.
get
(
"param"
);
String
recordtype
=
taskinfo
.
getRecordtype
();
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
jobTjParam
=
new
JobTjParam
();
jobTjParam
.
setDeviceId
(
devicecode
);
jobTjParam
.
setDeviceId
(
devicecode
);
jobTjParam
.
setDetectType
(
recordtype
);
jobTjParam
.
setDetectType
(
recordtype
);
String
imageurl
=
objectList
.
get
(
"url"
).
toString
();
String
imageurl
=
taskinfo
.
get
(
"url"
).
toString
();
TraffpictureParam
traffpictureParamresult
=
new
TraffpictureParam
();
TraffpictureParam
traffpictureParamresult
=
new
TraffpictureParam
();
try
{
try
{
Map
maprecogdata
=
JsonUtil
.
strToObj
(
objectList
.
get
(
"recogdata"
).
toString
(),
Map
.
class
);
//
Map maprecogdata = JsonUtil.strToObj(objectList.get("recogdata").toString(), Map.class);
List
<
Map
>
points
=
new
ArrayList
<>();
List
<
Map
>
points
=
new
ArrayList
<>();
//分析结果数据
//分析结果数据
if
(
null
!=
maprecogdata
)
{
if
(
null
!=
result
)
{
List
<
Map
>
objectresult
=
(
List
<
Map
>)
maprecogdata
.
get
(
"ObjectList"
);
List
<
Map
>
objectresult
=
(
List
<
Map
>)
result
.
get
(
"ObjectList"
);
if
(
objectresult
.
size
()
<
1
)
{
if
(
objectresult
.
size
()
<
1
)
{
logger
.
info
(
" objectresult is empty"
);
logger
.
info
(
" objectresult is empty"
);
}
else
{
}
else
{
Long
[]
roiarray
=
new
Long
[
4
];
Long
[]
roiarray
=
new
Long
[
4
];
roiarray
[
0
]
=
new
Long
(
taskinfo
.
get
Objectx
());
roiarray
[
0
]
=
new
Long
(
taskinfo
.
get
(
"x"
).
toString
());
roiarray
[
1
]
=
new
Long
(
taskinfo
.
get
Objecty
());
roiarray
[
1
]
=
new
Long
(
taskinfo
.
get
(
"y"
).
toString
());
roiarray
[
2
]
=
new
Long
(
taskinfo
.
get
Objectw
());
roiarray
[
2
]
=
new
Long
(
taskinfo
.
get
(
"w"
).
toString
());
roiarray
[
3
]
=
new
Long
(
taskinfo
.
get
Objecth
());
roiarray
[
3
]
=
new
Long
(
taskinfo
.
get
(
"h"
).
toString
());
//图片划线并上传
//图片划线并上传
String
basepath
=
DateUtils
.
formatCurrDayYM
()
+
File
.
separator
+
DateUtils
.
formatCurrDayDD
()
+
File
.
separator
+
devicecode
;
String
basepath
=
DateUtils
.
formatCurrDayYM
()
+
File
.
separator
+
DateUtils
.
formatCurrDayDD
()
+
File
.
separator
+
devicecode
;
String
filename
=
devicecode
+
"_"
+
DateUtils
.
parseDateToStrNoSign
(
objectList
.
get
(
"timestamp"
).
toString
()
)
+
"_result.jpg"
;
String
filename
=
devicecode
+
"_"
+
DateUtils
.
parseDateToStrNoSign
(
timestamp
)
+
"_result.jpg"
;
String
filenameurl
=
File
.
separator
+
outpath
+
File
.
separator
+
basepath
+
File
.
separator
+
filename
;
String
filenameurl
=
File
.
separator
+
outpath
+
File
.
separator
+
basepath
+
File
.
separator
+
filename
;
jobTjParam
.
setImageUrl
(
weburl
+
filenameurl
);
jobTjParam
.
setImageUrl
(
weburl
+
filenameurl
);
traffpictureParamresult
.
setImagedata
(
filenameurl
);
//获得点位
traffpictureParamresult
.
setImagedata
(
filenameurl
);
//获得点位
traffpictureParamresult
=
eventWriteService
.
getResult
(
traffpictureParamresult
,
Integer
.
parseInt
(
t
askinfo
.
getMetatype
()
)
traffpictureParamresult
=
eventWriteService
.
getResult
(
traffpictureParamresult
,
Integer
.
parseInt
(
t
hreshold
)
,
roiarray
,
imageurl
,
objectresult
,
jobTjParam
,
points
);
,
roiarray
,
imageurl
,
objectresult
,
jobTjParam
,
points
);
if
(
null
==
traffpictureParamresult
)
{
if
(
null
==
traffpictureParamresult
)
{
logger
.
info
(
"人群密度未超或目标未出现"
);
logger
.
info
(
"人群密度未超或目标未出现"
);
...
@@ -97,22 +101,22 @@ public class ResultService {
...
@@ -97,22 +101,22 @@ public class ResultService {
eventWriteService
.
uploadPicture
(
traffpictureParamresult
,
imageurl
,
points
,
basepath
,
filename
);
eventWriteService
.
uploadPicture
(
traffpictureParamresult
,
imageurl
,
points
,
basepath
,
filename
);
//新增
//新增
eventWriteService
.
setTraffpictureParam
(
recordtype
,
devicecode
,
eventWriteService
.
setTraffpictureParam
(
recordtype
,
devicecode
,
objectList
.
get
(
"timestamp"
).
toString
()
,
timestamp
,
traffpictureParamresult
);
traffpictureParamresult
);
Map
sendtodxmap
=
new
HashMap
();
Map
sendtodxmap
=
new
HashMap
();
sendtodxmap
.
put
(
"id"
,
traffpictureParamresult
.
getId
());
sendtodxmap
.
put
(
"id"
,
traffpictureParamresult
.
getId
());
sendtodxmap
.
put
(
"traff"
,
JsonUtil
.
objToStr
(
jobTjParam
));
sendtodxmap
.
put
(
"traff"
,
JsonUtil
.
objToStr
(
jobTjParam
));
sendtodxmap
.
put
(
"callback"
,
taskinfo
.
get
Url
().
equals
(
""
)
?
callbackurl
:
taskinfo
.
getUrl
());
sendtodxmap
.
put
(
"callback"
,
taskinfo
.
get
(
"url"
).
equals
(
""
)
?
callbackurl
:
taskinfo
.
get
(
"url"
).
toString
());
CorrelationData
correlationData
=
new
CorrelationData
(
UUID
.
randomUUID
().
toString
());
CorrelationData
correlationData
=
new
CorrelationData
(
UUID
.
randomUUID
().
toString
());
rabbitTemplate
.
convertAndSend
(
QueueConstants
.
QueueSendToDXEnum
.
QUEUE_SEND_TO_DX_ENUM
.
getExchange
(),
//
rabbitTemplate.convertAndSend(QueueConstants.QueueSendToDXEnum.QUEUE_SEND_TO_DX_ENUM.getExchange(),
QueueConstants
.
QueueSendToDXEnum
.
QUEUE_SEND_TO_DX_ENUM
.
getRouteKey
(),
//
QueueConstants.QueueSendToDXEnum.QUEUE_SEND_TO_DX_ENUM.getRouteKey(),
MessageHelper
.
objToMsg
(
sendtodxmap
),
//
MessageHelper.objToMsg(sendtodxmap),
correlationData
);
//
correlationData);
//
rabbitTemplate
.
convertAndSend
(
QueueConstants
.
QueueSendToVoiceEnum
.
QUEUE_SEND_TO_VOICE_ENUM
.
getExchange
(),
//
rabbitTemplate.convertAndSend(QueueConstants.QueueSendToVoiceEnum.QUEUE_SEND_TO_VOICE_ENUM.getExchange(),
QueueConstants
.
QueueSendToVoiceEnum
.
QUEUE_SEND_TO_VOICE_ENUM
.
getRouteKey
(),
//
QueueConstants.QueueSendToVoiceEnum.QUEUE_SEND_TO_VOICE_ENUM.getRouteKey(),
MessageHelper
.
objToMsg
(
sendtodxmap
),
//
MessageHelper.objToMsg(sendtodxmap),
correlationData
);
//
correlationData);
// //回调第三方接口
// //回调第三方接口
//// logger.info("send to dianxin data:{}",JSONObject.toJSONString(jobTjParam));
//// logger.info("send to dianxin data:{}",JSONObject.toJSONString(jobTjParam));
// eventWriteService.sendEventByCallUrl(traffpictureParamresult, jobTjParam, taskinfo.getUrl().equals("") ? callbackurl : taskinfo.getUrl());
// eventWriteService.sendEventByCallUrl(traffpictureParamresult, jobTjParam, taskinfo.getUrl().equals("") ? callbackurl : taskinfo.getUrl());
...
...
src/main/java/com/cx/cn/cxquartz/service/quartz/impl/VideoRTSPorURLService.java
View file @
cb5db7cd
...
@@ -66,7 +66,8 @@ public class VideoRTSPorURLService {
...
@@ -66,7 +66,8 @@ public class VideoRTSPorURLService {
{
{
//获得token 成功,更新表数据
//获得token 成功,更新表数据
String
token
=
String
.
valueOf
(
result
.
get
(
"obj"
));
String
token
=
String
.
valueOf
(
result
.
get
(
"obj"
));
String
serverHlsTokenNextTime
=
DateUtils
.
addMin
(
String
.
valueOf
(
result
.
get
(
"serverTime"
)),
5
);
Long
serverTime
=
Long
.
parseLong
(
result
.
get
(
"serverTime"
).
toString
());
String
serverHlsTokenNextTime
=
DateUtils
.
addMin
(
new
Date
(
serverTime
),
5
);
//根据设备编号更新token 及token 过期数据
//根据设备编号更新token 及token 过期数据
Sbtdspsr
sbtdspsr
=
new
Sbtdspsr
();
Sbtdspsr
sbtdspsr
=
new
Sbtdspsr
();
sbtdspsr
.
setSbbh
(
deviceCode
);
sbtdspsr
.
setSbbh
(
deviceCode
);
...
@@ -88,7 +89,7 @@ public class VideoRTSPorURLService {
...
@@ -88,7 +89,7 @@ public class VideoRTSPorURLService {
public
String
getHLSByDeviceCode
(
String
token
,
String
devicecode
){
public
String
getHLSByDeviceCode
(
String
token
,
String
devicecode
){
//token 保活
//token 保活
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
_UTF8
);
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
headers
.
add
(
"token"
,
token
);
headers
.
add
(
"token"
,
token
);
HttpEntity
<
String
>
httpEntity
=
new
HttpEntity
(
headers
);
HttpEntity
<
String
>
httpEntity
=
new
HttpEntity
(
headers
);
ResponseEntity
<
String
>
exchange
=
restTemplate
.
exchange
(
hlsurl
+
"?cameraIndexCode="
+
devicecode
,
HttpMethod
.
GET
,
httpEntity
,
String
.
class
);
ResponseEntity
<
String
>
exchange
=
restTemplate
.
exchange
(
hlsurl
+
"?cameraIndexCode="
+
devicecode
,
HttpMethod
.
GET
,
httpEntity
,
String
.
class
);
...
@@ -105,7 +106,8 @@ public class VideoRTSPorURLService {
...
@@ -105,7 +106,8 @@ public class VideoRTSPorURLService {
// "serverTime": "2021-07-21 12:40:06",
// "serverTime": "2021-07-21 12:40:06",
// "resultMsg": "成功"
// "resultMsg": "成功"
//根据设备编号更新hls和下次执行时间 数据,hls 有效期是5分钟
//根据设备编号更新hls和下次执行时间 数据,hls 有效期是5分钟
String
serverHlsNextTime
=
DateUtils
.
addMin
(
String
.
valueOf
(
result
.
get
(
"serverTime"
)),
5
);
Long
expire
=
Long
.
parseLong
(
result
.
get
(
"serverTime"
).
toString
());
String
serverHlsNextTime
=
DateUtils
.
addMin
(
new
Date
(
expire
),
5
);
Sbtdspsr
sbtdspsr
=
new
Sbtdspsr
();
Sbtdspsr
sbtdspsr
=
new
Sbtdspsr
();
sbtdspsr
.
setSbbh
(
devicecode
);
sbtdspsr
.
setSbbh
(
devicecode
);
sbtdspsr
.
setUrlnexttime
(
serverHlsNextTime
);
sbtdspsr
.
setUrlnexttime
(
serverHlsNextTime
);
...
@@ -130,7 +132,7 @@ public class VideoRTSPorURLService {
...
@@ -130,7 +132,7 @@ public class VideoRTSPorURLService {
public
String
getRTSPAccessToekenByDeviceCode
(
String
deviceCode
){
public
String
getRTSPAccessToekenByDeviceCode
(
String
deviceCode
){
//token 保活
//token 保活
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
_UTF8
);
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
Map
result
=
restTemplate
.
getForObject
(
rtspurltoken
+
"?appid="
+
appid
+
"&appsecret="
+
appsecret
,
Map
.
class
);
Map
result
=
restTemplate
.
getForObject
(
rtspurltoken
+
"?appid="
+
appid
+
"&appsecret="
+
appsecret
,
Map
.
class
);
if
(
null
!=
result
.
get
(
"code"
)
&&
"0"
.
equals
(
result
.
get
(
"code"
).
toString
())){
if
(
null
!=
result
.
get
(
"code"
)
&&
"0"
.
equals
(
result
.
get
(
"code"
).
toString
())){
// {
// {
...
@@ -143,7 +145,8 @@ public class VideoRTSPorURLService {
...
@@ -143,7 +145,8 @@ public class VideoRTSPorURLService {
//获得token 成功,更新表数据
//获得token 成功,更新表数据
Map
obj
=(
Map
)
result
.
get
(
"obj"
);
Map
obj
=(
Map
)
result
.
get
(
"obj"
);
String
token
=
String
.
valueOf
(
obj
.
get
(
"accessToken"
));
String
token
=
String
.
valueOf
(
obj
.
get
(
"accessToken"
));
String
serverRTSPTokenNextTime
=
DateUtils
.
formatDate
(
new
Date
(
String
.
valueOf
(
obj
.
get
(
"expire"
))));
Long
expire
=
Long
.
parseLong
(
obj
.
get
(
"expire"
).
toString
());
String
serverRTSPTokenNextTime
=
DateUtils
.
formatDate
(
new
Date
(
expire
));
//根据设备编号更新token 及token 过期数据
//根据设备编号更新token 及token 过期数据
Sbtdspsr
sbtdspsr
=
new
Sbtdspsr
();
Sbtdspsr
sbtdspsr
=
new
Sbtdspsr
();
sbtdspsr
.
setSbbh
(
deviceCode
);
sbtdspsr
.
setSbbh
(
deviceCode
);
...
@@ -156,20 +159,23 @@ public class VideoRTSPorURLService {
...
@@ -156,20 +159,23 @@ public class VideoRTSPorURLService {
return
null
;
return
null
;
}
}
public
String
getRTSPByDeviceCode
(
String
token
,
String
deviceCode
)
{
public
void
getRTSPByDeviceCode
(
String
token
,
String
deviceCode
)
{
String
timestamp
=
String
.
valueOf
(
new
Date
().
getTime
());
String
timestamp
=
String
.
valueOf
(
new
Date
().
getTime
());
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
_UTF8
);
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
headers
.
add
(
"accessToken"
,
token
);
headers
.
add
(
"accessToken"
,
token
);
headers
.
add
(
"timestamp"
,
timestamp
);
headers
.
add
(
"timestamp"
,
timestamp
);
headers
.
add
(
"sign"
,
DigestUtils
.
md5DigestAsHex
((
params
+
deviceCode
+
"key"
+
timestamp
).
getBytes
()));
headers
.
add
(
"sign"
,
DigestUtils
.
md5DigestAsHex
((
params
+
deviceCode
+
"key"
+
timestamp
).
getBytes
()));
HttpEntity
<
String
>
httpEntity
=
new
HttpEntity
(
headers
);
HttpEntity
<
String
>
httpEntity
=
new
HttpEntity
(
headers
);
ResponseEntity
<
String
>
exchange
=
restTemplate
.
exchange
(
rtspurl
+
"?deviceCode="
+
deviceCode
,
HttpMethod
.
GET
,
httpEntity
,
String
.
class
);
ResponseEntity
<
String
>
exchange
=
restTemplate
.
exchange
(
rtspurl
+
"?deviceCode="
+
deviceCode
,
HttpMethod
.
GET
,
httpEntity
,
String
.
class
);
String
body
=
exchange
.
getBody
();
String
body
=
exchange
.
getBody
();
Sbtdspsr
sbtdspsr
=
new
Sbtdspsr
();
try
{
try
{
Map
result
=
new
ObjectMapper
().
readValue
(
body
,
Map
.
class
);
Map
result
=
new
ObjectMapper
().
readValue
(
body
,
Map
.
class
);
if
(
null
!=
result
.
get
(
"errorCode"
)
&&
"0"
.
equals
(
result
.
get
(
"errorCode"
).
toString
()))
{
if
(
null
!=
result
.
get
(
"errorCode"
)
&&
"0"
.
equals
(
result
.
get
(
"errorCode"
).
toString
()))
{
sbtdspsr
.
setSbbh
(
deviceCode
);
//获得token 成功,更新表数据
//获得token 成功,更新表数据
Map
data
=
(
Map
)
result
.
get
(
"data"
);
Map
data
=
(
Map
)
result
.
get
(
"data"
);
// {
// {
...
@@ -185,9 +191,8 @@ public class VideoRTSPorURLService {
...
@@ -185,9 +191,8 @@ public class VideoRTSPorURLService {
//省内设备 = 地址只能用一次 ,33开头的18位
//省内设备 = 地址只能用一次 ,33开头的18位
// //集团设备 = 地址可以用20分钟,15位
// //集团设备 = 地址可以用20分钟,15位
Sbtdspsr
sbtdspsr
=
new
Sbtdspsr
();
sbtdspsr
.
setSqurllj
(
rtsp
);
sbtdspsr
.
setSqurllj
(
rtsp
);
sbtdspsr
.
setSbbh
(
deviceCode
);
}
if
(
deviceCode
.
length
()
==
15
)
{
if
(
deviceCode
.
length
()
==
15
)
{
String
serverHlsNextTime
=
DateUtils
.
addMin
(
new
Date
(),
20
);
String
serverHlsNextTime
=
DateUtils
.
addMin
(
new
Date
(),
20
);
sbtdspsr
.
setUrlnexttime
(
serverHlsNextTime
);
sbtdspsr
.
setUrlnexttime
(
serverHlsNextTime
);
...
@@ -196,16 +201,14 @@ public class VideoRTSPorURLService {
...
@@ -196,16 +201,14 @@ public class VideoRTSPorURLService {
sbtdspsr
.
setUrlnexttime
(
null
);
sbtdspsr
.
setUrlnexttime
(
null
);
}
}
//更新表里的数据
//更新表里的数据
if
(
null
!=
sbtdspsr
.
getSbbh
()
&&
!
""
.
equals
(
sbtdspsr
.
getSbbh
()))
sbtdspsrService
.
updateRTSPorHLSParam
(
sbtdspsr
);
sbtdspsrService
.
updateRTSPorHLSParam
(
sbtdspsr
);
return
rtsp
;
//根据token获得rtsp 地址
//根据token获得rtsp 地址
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
logger
.
error
(
"getRTSPByDeviceCode"
+
ex
.
toString
());
logger
.
error
(
"getRTSPByDeviceCode"
+
ex
.
toString
());
}
}
return
null
;
}
}
/***
/***
* 根据rtsp 或者hls 去抽帧
* 根据rtsp 或者hls 去抽帧
...
...
src/main/java/com/cx/cn/cxquartz/util/DateUtils.java
View file @
cb5db7cd
...
@@ -41,6 +41,10 @@ public class DateUtils {
...
@@ -41,6 +41,10 @@ public class DateUtils {
public
static
Date
parseDate
(
String
date
){
public
static
Date
parseDate
(
String
date
){
return
DateTime
.
parse
(
date
,
YMD_HMS
).
toDate
();
return
DateTime
.
parse
(
date
,
YMD_HMS
).
toDate
();
}
}
public
static
Date
parseMilisecondsToDate
(
Long
time
){
return
new
Date
(
time
);
}
public
static
Date
parseDateNoSign
(
String
date
){
public
static
Date
parseDateNoSign
(
String
date
){
return
DateTime
.
parse
(
date
,
YMDHMS
).
toDate
();
return
DateTime
.
parse
(
date
,
YMDHMS
).
toDate
();
...
...
src/main/java/com/cx/cn/cxquartz/util/FTPUtil.java
deleted
100644 → 0
View file @
2fb71bd3
package
com
.
cx
.
cn
.
cxquartz
.
util
;
import
com.cx.cn.cxquartz.controller.ExtController
;
import
com.cx.cn.cxquartz.vo.Ftp
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.net.ftp.FTP
;
import
org.apache.commons.net.ftp.FTPClient
;
import
org.apache.commons.net.ftp.FTPReply
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
sun.misc.BASE64Decoder
;
import
javax.annotation.PostConstruct
;
import
java.io.*
;
import
java.net.MalformedURLException
;
import
java.net.SocketException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@SuppressWarnings
(
"all"
)
@Component
public
class
FTPUtil
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ExtController
.
class
);
// @Value("${ftp.host}")
// private String ftpHost ;
private
List
<
Ftp
>
ftps
=
new
ArrayList
<
Ftp
>();
// @PostConstruct
// private void initHostMap(){
// if(ftpHost==null){
// log.error("ftp�洢��δ���ã���������");
// log.error("ftp�洢��δ���ã���������");
// return;
// }
//
//
//
// }
public
static
void
downLoadFile
(
String
path
,
OutputStream
toClient
)
{
BufferedInputStream
bis
=
null
;
InputStream
is
=
null
;
try
{
if
(
path
.
toUpperCase
().
indexOf
(
"FTP"
)
!=
-
1
)
{
String
tempUrl
=
path
;
tempUrl
=
tempUrl
.
replaceAll
(
"\\\\"
,
"/"
);
URL
url
=
new
URL
(
tempUrl
);
is
=
url
.
openStream
();
bis
=
new
BufferedInputStream
(
is
);
IOUtils
.
copy
(
bis
,
toClient
);
return
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"FTP����ͼƬ����"
,
e
);
}
finally
{
IOUtils
.
closeQuietly
(
toClient
);
IOUtils
.
closeQuietly
(
is
);
IOUtils
.
closeQuietly
(
bis
);
}
}
public
static
byte
[]
getFtpPicBytes
(
String
path
)
{
URL
url
=
null
;
byte
[]
buffer
=
null
;
try
{
url
=
new
URL
(
path
);
}
catch
(
MalformedURLException
e
)
{
log
.
error
(
"FTP URL·������"
+
e
.
toString
());
return
buffer
;
}
try
(
InputStream
is
=
url
.
openStream
();
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
(
1000
)){
byte
[]
b
=
new
byte
[
1000
];
int
n
;
while
((
n
=
is
.
read
(
b
))
!=
-
1
)
{
bos
.
write
(
b
,
0
,
n
);
}
buffer
=
bos
.
toByteArray
();
}
catch
(
Exception
e
)
{
log
.
error
(
"FTP����ͼƬ����"
,
e
);
return
buffer
;
}
return
buffer
;
}
//ftpͼƬ�ϴ���ͼƬ����Ϊbase64��װ��String
public
static
boolean
uploadFile
(
Ftp
ftpUrl
,
String
path
,
String
filename
,
String
inputImg
)
{
boolean
flag
=
true
;
FTPClient
ftpClient
=
null
;
ByteArrayInputStream
input
=
null
;
try
{
if
(
inputImg
==
null
)
{
return
false
;
}
BASE64Decoder
decoder
=
new
BASE64Decoder
();
byte
[]
b_img
=
decoder
.
decodeBuffer
(
inputImg
);
input
=
new
ByteArrayInputStream
(
b_img
);
ftpClient
=
connectServer
(
ftpUrl
);
if
(
ftpClient
.
isConnected
())
{
changeWorkingDirectory
(
ftpClient
,
path
);
flag
=
ftpClient
.
storeFile
(
filename
,
input
);
if
(
flag
)
{
// log.info("FTP�ϴ��ļ��ɹ���");
}
else
{
flag
=
false
;
log
.
info
(
"FTP�ϴ��ļ�ʧ�ܣ�"
);
}
}
}
catch
(
Exception
e
)
{
flag
=
false
;
log
.
error
(
"FTP�ļ��ϴ�ʧ�ܣ�"
,
e
.
toString
());
}
finally
{
IOUtils
.
closeQuietly
(
input
);
closeConnect
(
ftpClient
);
}
return
flag
;
}
public
static
boolean
uploadFile
(
Ftp
ftpUrl
,
String
path
,
String
filename
,
InputStream
input
){
boolean
flag
=
true
;
FTPClient
ftpClient
=
null
;
try
{
ftpClient
=
connectServer
(
ftpUrl
);
if
(
ftpClient
.
isConnected
())
{
changeWorkingDirectory
(
ftpClient
,
path
);
flag
=
ftpClient
.
storeFile
(
filename
,
input
);
if
(
flag
)
{
// log.info("FTP upload success��");
}
else
{
log
.
info
(
"FTP upload fail��"
);
}
}
else
{
flag
=
false
;
// log.info("FTP server refused connection ��");
}
}
catch
(
IOException
e
)
{
flag
=
false
;
log
.
error
(
"FTP upload fail��"
,
e
);
}
catch
(
Exception
e
)
{
flag
=
false
;
log
.
error
(
"FTP upload fail��"
,
e
);
}
finally
{
IOUtils
.
closeQuietly
(
input
);
closeConnect
(
ftpClient
);
}
return
flag
;
}
/*
* �õ������ļ��е�FTP��������ַ
*/
public
static
String
getFtpUrl
(
Ftp
ftpUrl
)
{
StringBuffer
buffer
=
new
StringBuffer
();
buffer
.
append
(
"ftp://"
);
String
ftpUsername
=
ftpUrl
.
getFtpUsername
();
if
(
ftpUsername
!=
null
&&
ftpUsername
.
trim
().
length
()
>
0
)
{
buffer
.
append
(
ftpUsername
);
buffer
.
append
(
":"
);
buffer
.
append
(
ftpUrl
.
getFtpPassword
());
buffer
.
append
(
"@"
);
}
buffer
.
append
(
ftpUrl
.
getFtpIp
());
if
(
ftpUrl
.
getFtpPort
()
!=
null
)
{
buffer
.
append
(
":"
);
buffer
.
append
(
ftpUrl
.
getFtpPort
());
}
buffer
.
append
(
"/"
);
return
buffer
.
toString
();
}
/**
* @param ftpUrl
* @return
* @throws Exception
* @description ɾ��ftp�ϵ��ļ�
* @author sunw
*/
public
static
boolean
deleteFileFromFtpUrl
(
String
ftpUrl
)
throws
Exception
{
boolean
flag
=
false
;
if
(
null
==
ftpUrl
||
StringUtils
.
isBlank
(
ftpUrl
))
{
throw
new
Exception
(
"ftpUrl����"
);
}
Map
<
String
,
String
>
result
=
getFtpInfoMapByFullPath
(
ftpUrl
);
String
ftpUser
=
result
.
get
(
"ftpUser"
);
String
ftpPassword
=
result
.
get
(
"ftpPassword"
);
String
ftpIp
=
result
.
get
(
"ftpIp"
);
String
ftpPort
=
result
.
get
(
"ftpPort"
);
String
fileName
=
result
.
get
(
"fileName"
);
String
path
=
result
.
get
(
"path"
);
Ftp
ftp
=
FTPUtil
.
getFtpUrlObj
(
ftpIp
,
ftpPort
,
ftpUser
,
ftpPassword
);
FTPClient
ftpClient
=
connectServer
(
ftp
);
if
(
null
==
ftpClient
)
{
throw
new
Exception
(
"ftp��¼ʧ�� "
);
}
else
{
String
fullPath
=
(
null
==
path
||
""
.
equals
(
path
.
trim
()))
?
fileName
:
(
path
+
"/"
+
fileName
);
try
{
flag
=
ftpClient
.
deleteFile
(
fullPath
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
flag
;
}
/**
* @param ftpUrlStr
* @return
* @throws Exception
* @author sunw ͨ��ͼƬ·��
* ���ftpuser,ftppassword,ftpip,ftpport,��fpt�ϵ��ļ�·��,�ļ�realname
*/
private
static
Map
<
String
,
String
>
getFtpInfoMapByFullPath
(
String
ftpUrlStr
)
throws
Exception
{
if
(
null
==
ftpUrlStr
||
""
.
equals
(
ftpUrlStr
.
trim
()))
{
throw
new
Exception
(
"ftpstr����"
);
}
ftpUrlStr
=
ftpUrlStr
.
replaceAll
(
"\\\\"
,
"/"
);
ftpUrlStr
=
changeUrlCharater
(
ftpUrlStr
);
String
array
[]
=
ftpUrlStr
.
split
(
"/"
);
String
[]
ftpUserPasswordAndIpPort
=
array
[
2
].
split
(
"@"
);
String
[]
ftpUserAndPassword
=
ftpUserPasswordAndIpPort
[
0
].
split
(
":"
);
String
[]
ftpIpAndPort
=
ftpUserPasswordAndIpPort
[
1
].
split
(
":"
);
String
ftpUser
=
ftpUserAndPassword
[
0
];
String
ftpPassword
=
ftpUserAndPassword
[
1
];
String
ftpIp
=
ftpIpAndPort
[
0
];
String
ftpPort
=
ftpIpAndPort
.
length
>
1
?
ftpIpAndPort
[
1
]
:
""
;
String
fileName
=
array
[
array
.
length
-
1
];
// ������
Map
<
String
,
String
>
resultMap
=
new
HashMap
<
String
,
String
>();
resultMap
.
put
(
"ftpUser"
,
ftpUser
);
resultMap
.
put
(
"ftpPassword"
,
ftpPassword
);
resultMap
.
put
(
"ftpIp"
,
ftpIp
);
resultMap
.
put
(
"ftpPort"
,
ftpPort
);
resultMap
.
put
(
"fileName"
,
fileName
);
String
path
=
""
;
for
(
int
i
=
3
;
i
<
array
.
length
-
1
;
i
++)
{
if
(
i
!=
array
.
length
-
2
)
{
path
+=
array
[
i
]
+
"/"
;
}
else
{
path
+=
array
[
i
];
}
}
resultMap
.
put
(
"path"
,
path
);
return
resultMap
;
}
public
static
void
main
(
String
[]
args
)
{
String
temp
=
"ftp://vpftp:zn7070@10.10.10.207:21/2018/0101.jpg"
;
try
{
boolean
flag
=
deleteFileFromFtpUrl
(
temp
);
System
.
out
.
println
(
flag
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"ɾ���ļ�ʧ��"
);
}
// String [] strSplit = temp.split("/");
// for(int i = 0 ; i < strSplit.length ; i++) {
// System.out.println(i+" = " + strSplit[i]);
// }
}
public
static
String
changeUrlCharater
(
String
tempUrl
)
{
tempUrl
=
tempUrl
.
replaceAll
(
"%"
,
"%25"
).
replaceAll
(
"#"
,
"%23"
).
replaceAll
(
"\\+"
,
"%2B"
).
replaceAll
(
"&"
,
"%26"
);
tempUrl
=
tempUrl
.
replaceAll
(
"="
,
"%3D"
).
replaceAll
(
"\\?"
,
"%3F"
);
return
tempUrl
;
}
/**
* ���ӵ�������
*/
private
static
FTPClient
connectServer
(
Ftp
ftpUrl
)
{
FTPClient
ftpClient
=
null
;
try
{
ftpClient
=
new
FTPClient
();
ftpClient
.
setControlEncoding
(
"utf-8"
);
if
(
ftpUrl
.
getFtpPort
()
!=
null
)
{
ftpClient
.
setDefaultPort
(
ftpUrl
.
getFtpPort
());
}
ftpClient
.
connect
(
ftpUrl
.
getFtpIp
());
ftpClient
.
login
(
ftpUrl
.
getFtpUsername
(),
ftpUrl
.
getFtpPassword
());
ftpClient
.
setFileType
(
FTP
.
BINARY_FILE_TYPE
);
ftpClient
.
enterLocalPassiveMode
();
// ftpClient.setFileTransferMode(FTP.STREAM_TRANSFER_MODE);
ftpClient
.
setBufferSize
(
10240
);
int
reply
=
ftpClient
.
getReplyCode
();
if
(!
FTPReply
.
isPositiveCompletion
(
reply
))
{
ftpClient
.
disconnect
();
System
.
err
.
println
(
"FTP server refused connection."
);
log
.
info
(
"FTP ����ܾ����ӣ�"
);
}
}
catch
(
SocketException
e
)
{
log
.
error
(
"��¼ftp������ "
+
ftpUrl
.
getFtpIp
()
+
" ʧ��,���ӳ�ʱ��"
,
e
);
}
catch
(
IOException
e
)
{
log
.
error
(
"��¼ftp������ "
+
ftpUrl
.
getFtpIp
()
+
" ʧ�ܣ�FTP����������"
,
e
);
}
return
ftpClient
;
}
/**
* �ر�����
*/
private
static
void
closeConnect
(
FTPClient
ftpClient
)
{
try
{
if
(
ftpClient
!=
null
)
{
if
(
ftpClient
.
isConnected
()
==
true
)
{
ftpClient
.
logout
();
}
ftpClient
.
disconnect
();
}
}
catch
(
Exception
e
)
{
log
.
error
(
"�ر�ftp����ʧ��"
,
e
);
}
}
/**
* ���뵽��������ij��Ŀ¼��
*
* @param directory
*/
private
static
void
changeWorkingDirectory
(
FTPClient
ftpClient
,
String
directory
)
throws
Exception
{
try
{
if
(
directory
.
contains
(
"\\"
)){
directory
=
directory
.
replaceAll
(
"\\\\"
,
"/"
);
}
String
splitType
=
"/"
;
ftpClient
.
changeWorkingDirectory
(
splitType
);
String
[]
subPathArray
=
directory
.
split
(
splitType
);
for
(
String
subPath
:
subPathArray
)
{
ftpClient
.
makeDirectory
(
subPath
);
ftpClient
.
changeWorkingDirectory
(
subPath
);
}
}
catch
(
IOException
ioe
)
{
log
.
error
(
"�ı�ftp����·��ʧ��"
,
ioe
);
}
}
/**
* ת��[ISO-8859-1 -> GBK] ��ͬ��ƽ̨��Ҫ��ͬ��ת��
*
* @param obj
* @return ""
*/
private
static
String
iso8859togbk
(
Object
obj
)
{
try
{
if
(
obj
==
null
)
{
return
""
;
}
return
new
String
(
obj
.
toString
().
getBytes
(
"iso-8859-1"
),
"GBK"
);
}
catch
(
Exception
e
)
{
return
""
;
}
}
public
static
Ftp
getFtpUrlObj
(
String
ftpIp
,
String
ftpPort
,
String
ftpUser
,
String
ftpPassword
)
{
Ftp
ftpUrl
=
new
Ftp
();
ftpUrl
.
setFtpIp
(
ftpIp
);
if
(
ftpPort
!=
null
)
{
ftpUrl
.
setFtpPort
(
Integer
.
parseInt
(
ftpPort
));
}
ftpUrl
.
setFtpUsername
(
ftpUser
);
ftpUrl
.
setFtpPassword
(
ftpPassword
);
return
ftpUrl
;
}
}
src/main/java/com/cx/cn/cxquartz/util/FileTransferManager.java
deleted
100644 → 0
View file @
2fb71bd3
package
com
.
cx
.
cn
.
cxquartz
.
util
;
import
com.cx.cn.cxquartz.controller.ExtController
;
import
com.cx.cn.cxquartz.vo.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
sun.misc.BASE64Encoder
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CompletionService
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorCompletionService
;
import
java.util.concurrent.TimeUnit
;
public
class
FileTransferManager
{
private
static
CompletionService
<
String
>
completionService
=
new
ExecutorCompletionService
<
String
>(
ThreadPoolUtil
.
getPool
());
private
static
CompletionService
<
String
>
threadService
=
new
ExecutorCompletionService
<
String
>(
ThreadPoolUtil
.
getPool
());
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ExtController
.
class
);
/**
* @param ftp
* @param basePath
* @return
* @throws Exception
*/
public
static
void
transferFile
(
final
TraffAlarmRecord
traffAlarmRecord
,
final
Ftp
ftp
,
final
String
basePath
)
throws
Exception
{
final
Long
recordid
=
traffAlarmRecord
.
getRecordid
();
String
fileName
=
DateUtils
.
formatCurrDayNoSign
()
+
"_"
+
recordid
+
"_img1.jpg"
;
String
ftputl
=
FTPUtil
.
getFtpUrl
(
ftp
)
+
basePath
+
"/"
+
fileName
;
traffAlarmRecord
.
setImg1path
(
ftputl
);
completionService
.
submit
(()
->
{
try
{
HttpURLConnection
connection
=
(
HttpURLConnection
)
new
URL
(
traffAlarmRecord
.
getImg1urlfrom
()).
openConnection
();
connection
.
setReadTimeout
(
2000
);
//延迟连接
connection
.
setConnectTimeout
(
3000
);
connection
.
setRequestMethod
(
"GET"
);
if
(
connection
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_OK
||
connection
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_NOT_MODIFIED
)
{
InputStream
inputStream
=
connection
.
getInputStream
();
boolean
r
=
FTPUtil
.
uploadFile
(
ftp
,
basePath
,
fileName
,
inputStream
);
if
(
r
)
{
log
.
info
(
" ftpupload success:{}"
,
ftputl
);
}
}
else
{
log
.
error
(
"connection code: "
+
connection
.
getResponseCode
());
}
}
catch
(
IOException
e
)
{
log
.
error
(
"ftputl connection error:{}"
,
e
.
toString
());
return
"0"
;
}
return
"1"
;
}
);
}
public
static
void
fetchUrlsFromRecord
(
TraffAlarmRecord
record
,
Map
<
String
,
Object
>
transferRecord
)
{
if
(
record
==
null
||
record
.
getRecordid
()
==
null
)
{
return
;
}
transferRecord
.
put
(
"recordid"
,
record
.
getRecordid
());
if
(
record
.
getImg1path
()
==
null
&&
record
.
getImg1urlfrom
()
!=
null
)
{
transferRecord
.
put
(
"img1path"
,
record
.
getImg1urlfrom
());
}
}
public
static
TraffAlarmRecord
traffAlarmRecordUrlUpdate
(
List
<
TransferResult
>
results
)
throws
Exception
{
TraffAlarmRecord
record
=
new
TraffAlarmRecord
();
for
(
TransferResult
result
:
results
)
{
record
.
setRecordid
(
result
.
getRecordid
());
if
(
result
.
getResult
())
{
switch
(
result
.
getPathvalue
())
{
case
"img1path"
:
record
.
setImg1path
(
result
.
getImgpath
());
break
;
case
"videopath"
:
record
.
setVideopath
(
result
.
getImgpath
());
break
;
default
:
break
;
}
}
}
return
record
;
}
// public static GoalStructureParam getGoalStructureParam(Long[] roiarray, int model, BASE64Encoder base64Encoder, TraffAlarmRecord transferRecord) {
// //获得图片进行分析
// GoalStructureParam param = new GoalStructureParam();
// param.setOutput(new Output(1));
// param.setModel(model);
// param.setApiout("1");////打开1400标准输出,默认可以不填
// List<ImageList> list = new ArrayList<>();
// getImageList("1", roiarray, base64Encoder, list, transferRecord.getImg1path());
// param.setImageList(list);
// return param;
//
// }
public
static
GoalStructureParam
getGoalStructureParam
(
Long
[]
roiarray
,
int
model
,
int
format
,
TraffAlarmRecord
transferRecord
)
{
//获得图片进行分析
GoalStructureParam
param
=
new
GoalStructureParam
();
Map
outmap
=
new
HashMap
();
outmap
.
put
(
"SubClass"
,
1
);
param
.
setOutput
(
outmap
);
param
.
setModel
(
model
);
param
.
setApiout
(
"1"
);
////打开1400标准输出,默认可以不填
List
<
Map
>
list
=
new
ArrayList
<>();
Map
imgmap
=
new
HashMap
();
imgmap
.
put
(
"ImageID"
,
"1"
);
imgmap
.
put
(
"Roi"
,
roiarray
);
imgmap
.
put
(
"apiout"
,
"1"
);
imgmap
.
put
(
"Format"
,
format
);
imgmap
.
put
(
"Data"
,
transferRecord
.
getImg1path
());
imgmap
.
put
(
"RoiPadding"
,
0
);
imgmap
.
put
(
"CropObjectImage"
,
1
);
imgmap
.
put
(
"CropObjectImagePadding"
,
20
);
imgmap
.
put
(
"CropObjectImageQuality"
,
100
);
list
.
add
(
imgmap
);
// new ImageList("1", roiarray, format,10, 1, 20, 100, transferRecord.getImg1urlfrom())
// getImageList("1", roiarray,format, list, transferRecord.getImg1urlfrom());
param
.
setImageList
(
list
);
return
param
;
}
// private static void getImageList(String id, Long[] roiarray, BASE64Encoder base64Encoder, List<ImageList> list, String img1path) {
// if (null != img1path && !"".equals(img1path)) {
//
// byte[] Img = FTPUtil.getFtpPicBytes(img1path);
// if (Img != null) {
// list.add(new ImageList(id, roiarray, 10, 1, 20, 100, base64Encoder.encode(Img).replaceAll("\r|\n", "")));
//
// }
// }
// }
public
static
String
urlTransToFtp
(
String
url
,
final
Ftp
ftp
,
final
String
basePath
)
{
threadService
.
submit
(()
->
{
try
{
HttpURLConnection
connection
=
(
HttpURLConnection
)
new
URL
(
url
).
openConnection
();
connection
.
setReadTimeout
(
2000
);
//延迟连接
connection
.
setConnectTimeout
(
3000
);
connection
.
setRequestMethod
(
"GET"
);
if
(
connection
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_OK
||
connection
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_NOT_MODIFIED
)
{
InputStream
inputStream
=
connection
.
getInputStream
();
String
pname
=
DateUtils
.
formatCurrDayNoSign
()
+
".jpg"
;
String
ftputl
=
FTPUtil
.
getFtpUrl
(
ftp
)
+
basePath
+
pname
;
boolean
r
=
FTPUtil
.
uploadFile
(
ftp
,
basePath
,
pname
,
inputStream
);
if
(
r
)
{
return
ftputl
;
}
}
else
{
log
.
error
(
"connection code: "
+
connection
.
getResponseCode
());
}
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
toString
());
log
.
error
(
e
.
toString
());
}
return
url
;
});
try
{
return
threadService
.
poll
(
10
,
TimeUnit
.
SECONDS
).
get
();
}
catch
(
Exception
ex
)
{
return
url
;
}
}
}
src/main/java/com/cx/cn/cxquartz/util/HttpClientUtil.java
deleted
100644 → 0
View file @
2fb71bd3
package
com
.
cx
.
cn
.
cxquartz
.
util
;
import
org.apache.commons.httpclient.*
;
import
org.apache.commons.httpclient.cookie.CookiePolicy
;
import
org.apache.commons.httpclient.methods.ByteArrayRequestEntity
;
import
org.apache.commons.httpclient.methods.GetMethod
;
import
org.apache.commons.httpclient.methods.PostMethod
;
import
org.apache.commons.httpclient.params.HttpConnectionManagerParams
;
import
org.apache.commons.httpclient.params.HttpMethodParams
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
HttpClientUtil
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
HttpClientUtil
.
class
);
private
static
final
String
ENCODING
=
"UTF-8"
;
private
static
final
int
CONNECTION_TIME_OUT
=
3000
;
private
static
final
int
SO_TIME_OUT
=
100000
;
private
static
final
boolean
STALE_CHECK_ENABLED
=
true
;
private
static
final
boolean
TCP_NO_DELAY
=
true
;
private
static
final
int
DEFAULT_MAX_CONNECTIONS_PER_HOST
=
100
;
private
static
final
int
MAX_TOTAL_CONNECTIONS
=
1000
;
private
static
final
HttpConnectionManager
connectionManager
;
public
static
final
HttpClient
client
;
static
{
HttpConnectionManagerParams
params
=
loadHttpConfFromFile
();
connectionManager
=
new
MultiThreadedHttpConnectionManager
();
connectionManager
.
setParams
(
params
);
client
=
new
HttpClient
(
connectionManager
);
}
private
static
HttpConnectionManagerParams
loadHttpConfFromFile
()
{
HttpConnectionManagerParams
params
=
new
HttpConnectionManagerParams
();
params
.
setConnectionTimeout
(
CONNECTION_TIME_OUT
);
params
.
setStaleCheckingEnabled
(
STALE_CHECK_ENABLED
);
params
.
setTcpNoDelay
(
TCP_NO_DELAY
);
params
.
setSoTimeout
(
SO_TIME_OUT
);
params
.
setDefaultMaxConnectionsPerHost
(
DEFAULT_MAX_CONNECTIONS_PER_HOST
);
params
.
setMaxTotalConnections
(
MAX_TOTAL_CONNECTIONS
);
params
.
setParameter
(
HttpMethodParams
.
RETRY_HANDLER
,
new
DefaultHttpMethodRetryHandler
(
0
,
false
));
return
params
;
}
/**
* get请求
*
* @param url
* @return
*/
public
static
String
doGet
(
String
url
)
{
String
result
=
null
;
try
{
GetMethod
getMethod
=
new
GetMethod
(
url
);
client
.
executeMethod
(
getMethod
);
result
=
getMethod
.
getResponseBodyAsString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"httpclient get request url="
+
url
+
",exception="
+
e
);
}
return
result
;
}
public
static
String
doPost
(
String
url
,
String
contentType
,
String
content
)
throws
Exception
{
PostMethod
method
=
new
PostMethod
(
url
);
method
.
addRequestHeader
(
"Connection"
,
"Keep-Alive"
);
method
.
getParams
().
setCookiePolicy
(
CookiePolicy
.
IGNORE_COOKIES
);
method
.
getParams
().
setParameter
(
HttpMethodParams
.
RETRY_HANDLER
,
new
DefaultHttpMethodRetryHandler
(
0
,
false
));
try
{
method
.
setRequestEntity
(
new
ByteArrayRequestEntity
(
content
.
getBytes
(
ENCODING
)));
method
.
addRequestHeader
(
"Content-Type"
,
contentType
);
int
statusCode
=
client
.
executeMethod
(
method
);
if
(
statusCode
!=
HttpStatus
.
SC_OK
)
{
return
null
;
}
byte
[]
ret
=
method
.
getResponseBody
();
if
(
ret
==
null
)
return
null
;
return
new
String
(
ret
,
ENCODING
);
}
finally
{
method
.
releaseConnection
();
}
}
}
src/main/java/com/cx/cn/cxquartz/util/RestUtil.java
View file @
cb5db7cd
...
@@ -2,7 +2,6 @@ package com.cx.cn.cxquartz.util;
...
@@ -2,7 +2,6 @@ package com.cx.cn.cxquartz.util;
import
com.cx.cn.cxquartz.service.quartz.SbtdspsrService
;
import
com.cx.cn.cxquartz.service.quartz.SbtdspsrService
;
import
com.cx.cn.cxquartz.vo.TraffAlarmRecord
;
import
com.cx.cn.cxquartz.vo.TraffAlarmRecord
;
import
net.sf.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
src/main/java/com/cx/cn/cxquartz/vo/Sbtdspsr.java
View file @
cb5db7cd
...
@@ -8,7 +8,7 @@ public class Sbtdspsr {
...
@@ -8,7 +8,7 @@ public class Sbtdspsr {
private
Integer
tdbh
;
private
Integer
tdbh
;
private
Long
tdlx
;
private
int
tdlx
;
private
String
wbbh
;
private
String
wbbh
;
...
@@ -206,11 +206,11 @@ public class Sbtdspsr {
...
@@ -206,11 +206,11 @@ public class Sbtdspsr {
this
.
tdbh
=
tdbh
;
this
.
tdbh
=
tdbh
;
}
}
public
Long
getTdlx
()
{
public
int
getTdlx
()
{
return
tdlx
;
return
tdlx
;
}
}
public
void
setTdlx
(
Long
tdlx
)
{
public
void
setTdlx
(
int
tdlx
)
{
this
.
tdlx
=
tdlx
;
this
.
tdlx
=
tdlx
;
}
}
...
...
src/main/resources/application-local.yml
View file @
cb5db7cd
...
@@ -20,11 +20,11 @@ spring:
...
@@ -20,11 +20,11 @@ spring:
poolPreparedStatements
:
true
poolPreparedStatements
:
true
maxOpenPreparedStatements
:
20
maxOpenPreparedStatements
:
20
rabbitmq
:
rabbitmq
:
host
:
1
27.0.0.1
host
:
1
92.168.168.110
port
:
5672
port
:
5672
username
:
guest
username
:
admin
password
:
guest
password
:
admin
virtual-host
:
/
virtual-host
:
my_vhost
#消息发送到交换机确认机制,是否确认回调
#消息发送到交换机确认机制,是否确认回调
publisher-confirms
:
true
publisher-confirms
:
true
##消息发送到交换机确认机制,是否返回回调
##消息发送到交换机确认机制,是否返回回调
...
@@ -46,10 +46,16 @@ spring:
...
@@ -46,10 +46,16 @@ spring:
initial-interval
:
3000
initial-interval
:
3000
#最大重试次数
#最大重试次数
max-attempts
:
3
max-attempts
:
3
redis
:
redis
:
database
:
0
database
:
0
host
:
1
27.0.0.1
host
:
1
92.168.168.110
port
:
6379
port
:
6379
pool
:
max-active
:
100
#连接池最大连接数(负值表示没有限制)
max-wait
:
3000
#连接池最大阻塞等待时间(负值表示没有限制)
max-idle
:
200
#连接池最大空闭连接数
min-idle
:
50
#连接汉最小空闲连接数
timeout
:
600
#连接超时时间(毫秒)
#logging:
#logging:
# level:
# level:
...
...
src/main/resources/mapper/SbtdspsrMapper.xml
View file @
cb5db7cd
...
@@ -41,5 +41,25 @@
...
@@ -41,5 +41,25 @@
<select
id=
"getRtspOrHLSByDeviceCode"
parameterType=
"java.lang.String"
resultType=
"java.lang.String"
>
<select
id=
"getRtspOrHLSByDeviceCode"
parameterType=
"java.lang.String"
resultType=
"java.lang.String"
>
select squrllj from sbtdspsr where sbbh=#{deviceCode}
select squrllj from sbtdspsr where sbbh=#{deviceCode}
</select>
</select>
<update
id=
"updateRTSPorHLSParam"
>
update sbtdspsr
<trim
prefix=
"set"
suffixOverrides=
","
>
<if
test=
"squrllj != null and squrllj !=''"
>
squrllj =#{squrllj},
</if>
<if
test=
"token != null and token !=''"
>
token =#{token},
</if>
<if
test=
"tokennexttime != null and tokennexttime !=''"
>
tokennexttime =#{tokennexttime},
</if>
<if
test=
"urlnexttime != null and urlnexttime !=''"
>
urlnexttime =#{urlnexttime},
</if>
</trim>
where sbbh=#{sbbh}
</update>
</mapper>
</mapper>
src/test/java/com/quartz/cn/com/cx/cn/cxquartz/CXQuartzApplicationTests.java
View file @
cb5db7cd
package
com
.
quartz
.
cn
.
com
.
cx
.
cn
.
cxquartz
;
package
com
.
quartz
.
cn
.
com
.
cx
.
cn
.
cxquartz
;
import
com.cx.cn.cxquartz.service.quartz.impl.SbtdspsrImpl
;
import
com.cx.cn.cxquartz.vo.Sbtdspsr
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.autoconfigure.data.redis.RedisProperties
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
@SpringBootTest
public
class
CXQuartzApplicationTests
{
public
class
CXQuartzApplicationTests
{
//
//
// @Test
// @Test
...
@@ -30,8 +21,7 @@ import org.springframework.test.context.junit4.SpringRunner;
...
@@ -30,8 +21,7 @@ import org.springframework.test.context.junit4.SpringRunner;
// }
// }
// }
//
@Test
public
void
testfilepath
(){
public
void
testfilepath
(){
String
ftpfilepath
=
"ftp://jiuling:9ling.cn@172.16.24.29:21/gstraff/picturedemo/20210625.jpg"
;
String
ftpfilepath
=
"ftp://jiuling:9ling.cn@172.16.24.29:21/gstraff/picturedemo/20210625.jpg"
;
String
ftppath
=
"jiuling:9ling.cn@172.16.24.29:21"
;
String
ftppath
=
"jiuling:9ling.cn@172.16.24.29:21"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment