Commit 053e7f81 by caoyin

Merge remote-tracking branch 'origin/master' into master_local

parents d0c2e96a 37d55dd9
......@@ -9,10 +9,9 @@ import com.founder.interservice.regionalanalysis.model.RegionalTaskResultDetail;
import com.founder.interservice.regionalanalysis.repository.RegionalTaskRepository;
import com.founder.interservice.regionalanalysis.repository.RegionalTaskResultRepository;
import com.founder.interservice.regionalanalysis.service.RegionalAnalysisService;
import com.founder.interservice.service.IphoneTrackService;
import com.founder.interservice.service.PushWaDataService;
import com.founder.interservice.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -32,19 +31,14 @@ import java.util.*;
@Async
public class ScheduledService {
@Value(value = "${wabigdata.regionalAnalysisTaskStatus.url}")
private String REGIONAL_ANALYSIS_TASK_STATUS; //获取任务状态
@Value(value = "${wabigdata.regionalAnalysisTaskInfo.url}")
private String REGIONAL_ANALYSIS_TASK_INFO; //获取任务结果
@Autowired
private PushWaDataService pushWaDataService;
@Autowired
private RegionalAnalysisService regionalAnalysisService;
@Autowired
private RegionalTaskRepository regionalTaskRepository;
@Autowired
private RegionalTaskResultRepository taskResultRepository;
@Autowired
private IphoneTrackService iphoneTrackService; //调取网安数据接口
/**
*
......@@ -76,17 +70,14 @@ public class ScheduledService {
System.out.println("taskList====================================="+taskList);
if(taskList != null && !taskList.isEmpty()){
String taskId = null,progress=null,state=null,result=null;Map<String,String> taskMap=null;
for (RegionalTask task:taskList) {
taskId = task.getTaskId();
//查询比对结果状态
taskMap = queryTaskStates(taskId);
taskMap = this.queryTaskStates(taskId);
progress = taskMap.get("progress");
state = taskMap.get("state");
if("1".equals(progress) && "FINISHED".equals(state)){
String info_url = REGIONAL_ANALYSIS_TASK_INFO + "&taskId=" + taskId;
String taskInfoResult = HttpUtil.getWaData(info_url);
//String taskInfoResult = "{\"results\":[],\"status\":\"ok\"}";
String taskInfoResult = pushWaDataService.getRegionalTaskInfo(taskId);
//调取结果成功 然后将结果保存入库
if(!taskInfoResult.startsWith("Rate")){
if(null != taskInfoResult && taskInfoResult.startsWith("{")){
......@@ -103,6 +94,30 @@ public class ScheduledService {
}
/**
* 调用新版接口获取任务状态
* @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;
}
/**
* 第二步,调取标识号的关联信息
* 1.将比对碰撞首次调取标识号成功的任务过滤出来即状态位为FINISHED的
* 2.开启新线程调取标识号的关联数据
......@@ -123,9 +138,6 @@ public class ScheduledService {
return criteriaQuery.getRestriction();
}
});
System.out.println("开始查询ddddd============================================================");
System.out.println(taskList);
if(taskList != null && !taskList.isEmpty()){
for (RegionalTask task:taskList) {
List<RegionalTaskResult> taskResults = taskResultRepository.findAllByTaskId(task.getTaskId());
......@@ -138,14 +150,6 @@ public class ScheduledService {
e.printStackTrace();
}
}
/**
* 通过区域碰撞的结果 使用第四个接口调取关联数据
*/
......@@ -159,8 +163,13 @@ public class ScheduledService {
if (objValue != null && !"".equals(objValue)) {
//MAC地址、用户名、淘宝旺旺号不去调取关联数据,其它类型都使用第四个接口调取
if (!Arrays.asList("4329", "4342","45282").contains(objType)) {
JSONObject jsonObj = iphoneTrackService.getObjectRelationAll(objValue);//使用网安第三个接口调取关联数据
if (jsonObj != null && !jsonObj.isEmpty()) { //说明根节点是身份证号
JSONObject jsonObj = null;
String relationAll = pushWaDataService.pushRelationAll(DateUtil.getYYYYMMDDHHMM(), DateUtil.getYYYYMMDDHHMM(), "admin", objValue,3);
if(null != relationAll && relationAll.startsWith("{")){
JSONObject json = JSONObject.parseObject(relationAll);
jsonObj = json.getJSONObject("data");
}
if (jsonObj != null && !jsonObj.isEmpty()) {
RegionalTaskResultDetail detail = new RegionalTaskResultDetail();
detail.setTaskResultId(result.getXXZJBH());
detail.setXXZJBH(KeyUtil.getUniqueKey("EDZ"));
......@@ -235,7 +244,7 @@ public class ScheduledService {
public void getAndSaveInfo(String taskInfoResult, RegionalTask task) throws RuntimeException{
try{
JSONObject o = JSONObject.parseObject(taskInfoResult);
JSONArray jsonArray = o.getJSONArray("results");
JSONArray jsonArray = o.getJSONObject("data").getJSONArray("results");
if(jsonArray != null && jsonArray.size() > 0){
List<RegionalTaskResult> taskResults = jsonArray.toJavaList(RegionalTaskResult.class);
taskResults = removeDuplicate(taskResults);
......@@ -260,33 +269,6 @@ public class ScheduledService {
}
}
/**
* 查询任务状态
* @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 status_url = REGIONAL_ANALYSIS_TASK_STATUS + "&taskId="+taskId;
String result = HttpUtil.getWaData(status_url);
//String statusStr = "{\"progress\":0.8,\"state\":\"TIMEOUT\"}";
if(null != result && result.startsWith("{")){
jsonObject = JSONObject.parseObject(result);
}
if(jsonObject!=null){
progress = jsonObject.getString("progress"); //进度
state = jsonObject.getString("state"); //状态
}
map.put("progress",progress);
map.put("state",state);
return map;
}
/**
* 去除重复数据
* @param list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment