Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bigdatainterservice
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
曹鹏
bigdatainterservice
Commits
19d09eb2
Commit
19d09eb2
authored
May 16, 2019
by
chang_chao@founder.com.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改伴随定时任务获取资源方法
parent
8b52cd4a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
28 deletions
+53
-28
src/main/java/com/founder/interservice/tracktraveltogether/service/impl/TogetherScheduledService.java
+53
-28
No files found.
src/main/java/com/founder/interservice/tracktraveltogether/service/impl/TogetherScheduledService.java
View file @
19d09eb2
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.founder.interservice.model.AutoTbStRy
;
import
com.founder.interservice.model.AutoTbStRy
;
import
com.founder.interservice.regionalanalysis.model.RegionalTaskResultDetail
;
import
com.founder.interservice.regionalanalysis.model.RegionalTaskResultDetail
;
import
com.founder.interservice.service.IphoneTrackService
;
import
com.founder.interservice.service.IphoneTrackService
;
import
com.founder.interservice.service.PushWaDataService
;
import
com.founder.interservice.tracktraveltogether.model.TogetherTaskResult
;
import
com.founder.interservice.tracktraveltogether.model.TogetherTaskResult
;
import
com.founder.interservice.tracktraveltogether.model.TrackTogetherTask
;
import
com.founder.interservice.tracktraveltogether.model.TrackTogetherTask
;
import
com.founder.interservice.tracktraveltogether.repository.TogetherTaskResultRepository
;
import
com.founder.interservice.tracktraveltogether.repository.TogetherTaskResultRepository
;
...
@@ -21,10 +22,7 @@ import org.springframework.stereotype.Component;
...
@@ -21,10 +22,7 @@ import org.springframework.stereotype.Component;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.criteria.*
;
import
javax.persistence.criteria.*
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
/**
/**
* @ClassName: TogetherScheduledService
* @ClassName: TogetherScheduledService
...
@@ -38,10 +36,6 @@ import java.util.List;
...
@@ -38,10 +36,6 @@ import java.util.List;
@Async
@Async
public
class
TogetherScheduledService
{
public
class
TogetherScheduledService
{
@Value
(
value
=
"${wabigdata.trackTravelTogetherForPhoneTaskStatus.url}"
)
private
String
TOGETHER_STATUS_URL
;
//获取任务状态
@Value
(
value
=
"${wabigdata.trackTravelTogetherForPhoneTaskInfo.url}"
)
private
String
TOGETHER_INFO_URL
;
//获取任务结果
@Autowired
@Autowired
private
TrackTogetherTaskRepository
taskRepository
;
private
TrackTogetherTaskRepository
taskRepository
;
@Autowired
@Autowired
...
@@ -51,6 +45,8 @@ public class TogetherScheduledService {
...
@@ -51,6 +45,8 @@ public class TogetherScheduledService {
private
IphoneTrackService
iphoneTrackService
;
//调取网安数据接口
private
IphoneTrackService
iphoneTrackService
;
//调取网安数据接口
@Autowired
@Autowired
private
TrackTogetherService
togetherService
;
//调取网安数据接口
private
TrackTogetherService
togetherService
;
//调取网安数据接口
@Autowired
private
PushWaDataService
pushWaDataService
;
/**
/**
*
*
* @Description: 查取任务结果的定时方法
* @Description: 查取任务结果的定时方法
...
@@ -78,17 +74,11 @@ public class TogetherScheduledService {
...
@@ -78,17 +74,11 @@ public class TogetherScheduledService {
});
});
if
(
taskList
!=
null
&&
!
taskList
.
isEmpty
()){
if
(
taskList
!=
null
&&
!
taskList
.
isEmpty
()){
for
(
TrackTogetherTask
task:
taskList
)
{
for
(
TrackTogetherTask
task:
taskList
)
{
String
status_url
=
TOGETHER_STATUS_URL
+
"&taskId="
+
task
.
getTaskId
();
Map
<
String
,
String
>
taskStatusMap
=
this
.
queryTaskStates
(
task
.
getTaskId
());
String
statusStr
=
HttpUtil
.
getWaData
(
status_url
);
String
progress
=
taskStatusMap
.
get
(
"progress"
);
//String statusStr = "{\"progress\":0.8,\"state\":\"TIMEOUT\"}";
String
state
=
taskStatusMap
.
get
(
"state"
);
System
.
out
.
println
(
"statusStr ======================== "
+
statusStr
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
statusStr
);
String
progress
=
jsonObject
.
getString
(
"progress"
);
String
state
=
jsonObject
.
getString
(
"state"
);
if
(
"1"
.
equals
(
progress
)
&&
"FINISHED"
.
equals
(
state
)){
if
(
"1"
.
equals
(
progress
)
&&
"FINISHED"
.
equals
(
state
)){
String
info_url
=
TOGETHER_INFO_URL
+
"&taskId="
+
task
.
getTaskId
();
String
taskInfoResult
=
pushWaDataService
.
getTogetherTaskInfo
(
task
.
getTaskId
());
String
taskInfoResult
=
HttpUtil
.
getWaData
(
info_url
);
//String taskInfoResult = "{\"items\":[{\"count\":75,\"objectType\":4394,\"objectTypeName\":\"电话号码\",\"objectValue\":\"460013088311061\"},{\"count\":70,\"objectType\":4394,\"objectTypeName\":\"电话号码\",\"objectValue\":\"460029233464484\"},{\"count\":65,\"objectType\":4394,\"objectTypeName\":\"电话号码\",\"objectValue\":\"460013022609934\"},{\"count\":63,\"objectType\":4394,\"objectTypeName\":\"电话号码\",\"objectValue\":\"460013312607010\"},{\"count\":57,\"objectType\":4394,\"objectTypeName\":\"电话号码\",\"objectValue\":\"460018669002987\"},{\"count\":53,\"objectType\":4394,\"objectTypeName\":\"电话号码\",\"objectValue\":\"460008397079525\"},{\"count\":53,\"objectType\":4394,\"objectTypeName\":\"电话号码\",\"objectValue\":\"460020523597601\"},{\"count\":53,\"objectType\":4394,\"objectTypeName\":\"电话号码\",\"objectValue\":\"460003164872839\"}],\"taskId\":\"98f6bcd4621d373cade4e832627b4f6-540-xzxt-api-3-1536231954767\"}";
getAndSaveInfo
(
taskInfoResult
,
task
);
getAndSaveInfo
(
taskInfoResult
,
task
);
}
}
if
(!
state
.
equals
(
task
.
getState
())){
if
(!
state
.
equals
(
task
.
getState
())){
...
@@ -103,13 +93,16 @@ public class TogetherScheduledService {
...
@@ -103,13 +93,16 @@ public class TogetherScheduledService {
public
void
getAndSaveInfo
(
String
taskInfoResult
,
TrackTogetherTask
task
)
throws
RuntimeException
{
public
void
getAndSaveInfo
(
String
taskInfoResult
,
TrackTogetherTask
task
)
throws
RuntimeException
{
try
{
try
{
if
(
null
!=
taskInfoResult
&&
taskInfoResult
.
startsWith
(
"{"
))
{
JSONObject
o
=
JSONObject
.
parseObject
(
taskInfoResult
);
JSONObject
o
=
JSONObject
.
parseObject
(
taskInfoResult
);
JSONArray
jsonArray
=
o
.
getJSONArray
(
"items"
);
JSONObject
jsonObject
=
o
.
getJSONObject
(
"data"
);
if
(
jsonArray
!=
null
&&
jsonArray
.
size
()
>
0
){
if
(
null
!=
jsonObject
)
{
List
<
TogetherTaskResult
>
taskResults
=
jsonArray
.
toJavaList
(
TogetherTaskResult
.
class
);
JSONArray
childrens
=
jsonObject
.
getJSONArray
(
"results"
);
if
(
childrens
!=
null
&&
childrens
.
size
()
>
0
)
{
List
<
TogetherTaskResult
>
taskResults
=
childrens
.
toJavaList
(
TogetherTaskResult
.
class
);
taskResults
=
removeDuplicate
(
taskResults
);
taskResults
=
removeDuplicate
(
taskResults
);
if
(
taskResults
!=
null
&&
!
taskResults
.
isEmpty
())
{
if
(
taskResults
!=
null
&&
!
taskResults
.
isEmpty
())
{
for
(
TogetherTaskResult
r:
taskResults
)
{
for
(
TogetherTaskResult
r
:
taskResults
)
{
r
.
setTaskId
(
task
.
getTaskId
());
r
.
setTaskId
(
task
.
getTaskId
());
r
.
setXXZJBH
(
KeyUtil
.
getUniqueKey
(
"TT"
));
r
.
setXXZJBH
(
KeyUtil
.
getUniqueKey
(
"TT"
));
r
.
setDjsj
(
new
Date
());
r
.
setDjsj
(
new
Date
());
...
@@ -118,12 +111,14 @@ public class TogetherScheduledService {
...
@@ -118,12 +111,14 @@ public class TogetherScheduledService {
param
.
setTaskId
(
task
.
getTaskId
());
param
.
setTaskId
(
task
.
getTaskId
());
Example
<
TogetherTaskResult
>
example
=
Example
.
of
(
param
);
Example
<
TogetherTaskResult
>
example
=
Example
.
of
(
param
);
List
<
TogetherTaskResult
>
results
=
taskResultRepository
.
findAll
(
example
);
List
<
TogetherTaskResult
>
results
=
taskResultRepository
.
findAll
(
example
);
if
(
results
==
null
||
results
.
isEmpty
())
{
if
(
results
==
null
||
results
.
isEmpty
())
{
taskResultRepository
.
save
(
taskResults
);
taskResultRepository
.
save
(
taskResults
);
getAndSaveRydetail
(
taskResults
);
getAndSaveRydetail
(
taskResults
);
}
}
}
}
}
}
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
@@ -142,16 +137,22 @@ public class TogetherScheduledService {
...
@@ -142,16 +137,22 @@ public class TogetherScheduledService {
if
(
objValue
!=
null
&&
!
""
.
equals
(
objValue
))
{
if
(
objValue
!=
null
&&
!
""
.
equals
(
objValue
))
{
//MAC地址、用户名、淘宝旺旺号不去调取关联数据,其它类型都使用第四个接口调取
//MAC地址、用户名、淘宝旺旺号不去调取关联数据,其它类型都使用第四个接口调取
if
(!
Arrays
.
asList
(
"4329"
,
"4342"
,
"45282"
).
contains
(
objType
))
{
if
(!
Arrays
.
asList
(
"4329"
,
"4342"
,
"45282"
).
contains
(
objType
))
{
JSONObject
jsonObj
=
iphoneTrackService
.
getObjectRelationAll
(
objValue
);
//使用网安第三个接口调取关联数据
String
results
=
pushWaDataService
.
pushRelationAll
(
DateUtil
.
getYYYYMMDD
(),
DateUtil
.
getYYYYMMDDHHMM
(),
"admin"
,
objValue
,
3
);
if
(
jsonObj
!=
null
&&
!
jsonObj
.
isEmpty
())
{
//说明根节点是身份证号
JSONObject
jsonObj
=
new
JSONObject
();
if
(
null
!=
results
&&
results
.
startsWith
(
"{"
)){
jsonObj
=
JSONObject
.
parseObject
(
results
);
}
if
(
jsonObj
!=
null
&&
!
jsonObj
.
isEmpty
())
{
JSONObject
dataObj
=
jsonObj
.
getJSONObject
(
"data"
);
RegionalTaskResultDetail
detail
=
new
RegionalTaskResultDetail
();
RegionalTaskResultDetail
detail
=
new
RegionalTaskResultDetail
();
detail
.
setTaskResultId
(
result
.
getXXZJBH
());
detail
.
setTaskResultId
(
result
.
getXXZJBH
());
detail
.
setXXZJBH
(
KeyUtil
.
getUniqueKey
(
"EDZ"
));
detail
.
setXXZJBH
(
KeyUtil
.
getUniqueKey
(
"EDZ"
));
detail
.
setObjectType
(
objType
);
detail
.
setObjectType
(
objType
);
detail
.
setObjectValue
(
objValue
);
detail
.
setObjectValue
(
objValue
);
detail
.
setObjectTypeName
(
objName
);
detail
.
setObjectTypeName
(
objName
);
String
objType2
=
jsonObj
.
getString
(
"objType"
);
if
(
null
!=
dataObj
){
String
objValue2
=
jsonObj
.
getString
(
"objValue"
);
String
objType2
=
dataObj
.
getString
(
"objType"
);
String
objValue2
=
dataObj
.
getString
(
"objValue"
);
if
(
"1"
.
equals
(
objType2
)
&&
!
objValue2
.
isEmpty
()){
if
(
"1"
.
equals
(
objType2
)
&&
!
objValue2
.
isEmpty
()){
detail
.
setZjlxCode
(
"004"
);
detail
.
setZjlxCode
(
"004"
);
detail
.
setZjlx
(
"身份证号"
);
detail
.
setZjlx
(
"身份证号"
);
...
@@ -185,6 +186,7 @@ public class TogetherScheduledService {
...
@@ -185,6 +186,7 @@ public class TogetherScheduledService {
}
}
}
}
}
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -242,4 +244,27 @@ public class TogetherScheduledService {
...
@@ -242,4 +244,27 @@ public class TogetherScheduledService {
}
}
return
list
;
return
list
;
}
}
/**
* 调用新版接口获取任务状态
* @param taskId
* @return
*/
public
Map
<
String
,
String
>
queryTaskStates
(
String
taskId
){
JSONObject
jsonObject
=
null
;
String
progress
=
null
,
state
=
null
;
Map
<
String
,
String
>
map
=
new
HashMap
();
String
result
=
pushWaDataService
.
pushTaskStatus
(
taskId
,
0
);
if
(
null
!=
result
&&
result
.
startsWith
(
"{"
)){
jsonObject
=
JSONObject
.
parseObject
(
result
);
}
if
(
jsonObject
!=
null
){
JSONObject
JSONObjectData
=
jsonObject
.
getJSONObject
(
"data"
);
progress
=
JSONObjectData
.
getString
(
"progress"
);
//进度
state
=
JSONObjectData
.
getString
(
"state"
);
//状态
}
map
.
put
(
"progress"
,
progress
);
map
.
put
(
"state"
,
state
);
return
map
;
}
}
}
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