Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hzjtpushdateService
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
建金
hzjtpushdateService
Commits
fa1f3566
Commit
fa1f3566
authored
Dec 20, 2020
by
高飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
根据videoid 查询对应的flv 地址
parent
db5b0ce3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
1 deletion
+116
-1
src/main/java/com/hzjt/controller/TraffController.java
src/main/java/com/hzjt/controller/TraffController.java
+40
-0
src/main/java/com/hzjt/listener/MyApplicationStartingEventListener.java
...com/hzjt/listener/MyApplicationStartingEventListener.java
+8
-1
src/main/java/com/hzjt/mapper/TraffFlowMapper.java
src/main/java/com/hzjt/mapper/TraffFlowMapper.java
+1
-0
src/main/java/com/hzjt/service/FLVCacheService.java
src/main/java/com/hzjt/service/FLVCacheService.java
+56
-0
src/main/java/com/hzjt/service/TraffFlowService.java
src/main/java/com/hzjt/service/TraffFlowService.java
+6
-0
src/main/resources/mapper/TraffFlow.xml
src/main/resources/mapper/TraffFlow.xml
+5
-0
No files found.
src/main/java/com/hzjt/controller/TraffController.java
View file @
fa1f3566
package
com
.
hzjt
.
controller
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.util.concurrent.RateLimiter
;
import
com.hzjt.domain.*
;
import
com.hzjt.handler.WebSocket
;
...
...
@@ -8,12 +10,14 @@ import com.hzjt.service.ImportService;
import
com.hzjt.service.TraffFlowService
;
import
com.hzjt.util.DateUtils
;
import
com.hzjt.util.JsonUtil
;
import
com.hzjt.util.RedisEnum
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.web.bind.annotation.*
;
import
java.math.BigDecimal
;
...
...
@@ -39,6 +43,12 @@ public class TraffController {
@Autowired
TraffFlowService
traffFlowService
;
@Value
(
"${flv.resisvalue}"
)
private
String
resisvalue
;
@Autowired
private
StringRedisTemplate
stringRedisTemplate
;
...
...
@@ -184,6 +194,36 @@ public class TraffController {
webSocket
.
AppointSending
(
rules
.
getVideo_id
(),
JsonUtil
.
beanToString
(
map
));
return
ResultObj
.
ok
();
}
//获取flv地址
@GetMapping
(
"/getflv/{videoid}"
)
public
String
getflv
(
@PathVariable
(
"videoid"
)
String
videoid
)
{
//根据id查询对应的rtsp
String
rtsp
=
traffFlowService
.
selectSbtddspsrRtspByVideoid
(
videoid
);
//huode resid 中值、
if
(
null
!=
rtsp
&&
null
!=
stringRedisTemplate
.
opsForValue
().
get
(
resisvalue
))
{
JSONArray
jsonArr
=
JSONObject
.
parseArray
(
stringRedisTemplate
.
opsForValue
().
get
(
resisvalue
));
log
.
info
(
"jsonArr"
+
jsonArr
.
size
());
for
(
int
i
=
0
;
i
<
jsonArr
.
size
();
i
++)
{
JSONObject
jsonObject
=
jsonArr
.
getJSONObject
(
i
);
if
(
jsonObject
.
getString
(
"source"
).
equalsIgnoreCase
(
rtsp
))
{
if
(
null
!=
jsonObject
.
getJSONArray
(
"play_uris"
)
&&
jsonObject
.
getJSONArray
(
"play_uris"
).
size
()
>
3
)
{
return
String
.
valueOf
(
jsonObject
.
getJSONArray
(
"play_uris"
).
get
(
2
));
}
}
}
}
return
null
;
}
//获取自动规则
@GetMapping
(
"/test"
)
...
...
src/main/java/com/hzjt/listener/MyApplicationStartingEventListener.java
View file @
fa1f3566
package
com
.
hzjt
.
listener
;
import
com.hzjt.service.CacheLoadService
;
import
com.hzjt.service.FLVCacheService
;
import
com.hzjt.service.FtpService
;
import
com.hzjt.service.QingZhiLoginCacheService
;
import
com.hzjt.util.ThreadPoolUtil
;
...
...
@@ -38,7 +39,7 @@ public class MyApplicationStartingEventListener implements ApplicationListener<S
ThreadPoolUtil
.
getSchedulePool
().
scheduleWithFixedDelay
(()
->
{
CacheLoadService
cacheLoadService
=
applicationContext
.
getBean
(
CacheLoadService
.
class
);
cacheLoadService
.
loadFtpCache
();
},
200
,
60
000
,
TimeUnit
.
MILLI
SECONDS
);
},
200
,
60
,
TimeUnit
.
SECONDS
);
//判断第三方登录是否有效
ThreadPoolUtil
.
getSchedulePool
().
scheduleWithFixedDelay
(()
->
{
...
...
@@ -46,6 +47,12 @@ public class MyApplicationStartingEventListener implements ApplicationListener<S
qingZhiLoginCacheService
.
keepAlive
();
},
3
,
60
,
TimeUnit
.
SECONDS
);
//查询flv值
ThreadPoolUtil
.
getSchedulePool
().
scheduleWithFixedDelay
(()
->
{
FLVCacheService
flvservice
=
applicationContext
.
getBean
(
FLVCacheService
.
class
);
flvservice
.
getvalue
();
},
3
,
300
,
TimeUnit
.
SECONDS
);
}
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/hzjt/mapper/TraffFlowMapper.java
View file @
fa1f3566
...
...
@@ -21,4 +21,5 @@ public interface TraffFlowMapper {
Integer
deleteBeforeTwoMonthVehiclesDetails
(
String
startime
);
Integer
deleteVehiclesByDay
();
Integer
insertOrUpdatevehicleTodaystatistic
();
String
selectSbtddspsrRtspByVideoid
(
String
videoid
);
}
src/main/java/com/hzjt/service/FLVCacheService.java
0 → 100644
View file @
fa1f3566
package
com
.
hzjt
.
service
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.concurrent.TimeUnit
;
@Service
@Slf4j
public
class
FLVCacheService
{
@Autowired
private
StringRedisTemplate
stringRedisTemplate
;
@Value
(
"${flv.resisvalue}"
)
private
String
resisvalue
;
@Value
(
"${flv.url}"
)
private
String
url
;
public
void
getvalue
()
{
try
{
HttpHeaders
headers
=
getHttpHeaders
();
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
null
,
headers
);
RestTemplate
client
=
new
RestTemplate
();
ResponseEntity
<
String
>
request
=
client
.
exchange
((
url
),
HttpMethod
.
GET
,
requestEntity
,
String
.
class
);
//解析返回结果
if
(
request
.
getBody
()
!=
null
)
{
log
.
info
(
"flv response success"
);
stringRedisTemplate
.
opsForValue
().
set
(
resisvalue
,
request
.
getBody
(),
2
,
TimeUnit
.
MINUTES
);
}
else
{
log
.
error
(
"flv response "
+
"empty..."
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
toString
());
log
.
error
(
e
.
getMessage
());
}
}
private
HttpHeaders
getHttpHeaders
()
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8
);
return
headers
;
}
}
src/main/java/com/hzjt/service/TraffFlowService.java
View file @
fa1f3566
...
...
@@ -48,7 +48,13 @@ public class TraffFlowService {
return
traffFlowMapper
.
insertOrUpdatevehicleTodaystatistic
();
}
public
String
selectSbtddspsrRtspByVideoid
(
String
videoid
){
return
traffFlowMapper
.
selectSbtddspsrRtspByVideoid
(
videoid
);
}
...
...
src/main/resources/mapper/TraffFlow.xml
View file @
fa1f3566
...
...
@@ -160,4 +160,9 @@
)
</insert>
<select
id=
"selectSbtddspsrRtspByVideoid"
resultType=
"string"
>
select squrllj from sbtdspsr where sbbh||'_'||tdbh =#{videoid} and rownum=1
</select>
</mapper>
\ No newline at end of file
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