package com.happy.Until; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.happy.Model.Ban.BanSui; import com.happy.Model.Ban.Detail; import com.happy.Model.Ban.Items; import com.happy.Model.Ban.Results; import com.happy.Model.Common.Follow; import com.happy.Model.Common.FollowData; import com.happy.Model.Common.Token; import com.happy.Model.Common.Trajectory; import com.happy.Model.User; import com.happy.common.http.HttpsClient; import com.happy.service.UserService; import net.sf.json.JSONArray; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @Service public class Mijie { @Resource public UserService userService; public JSONObject query(int id) throws Exception { JSONObject resultJson = new JSONObject(); Gson gson = new Gson(); Map req = new HashMap<>(); req.put("client_id", "32f7d83bb4304822b17083ac49a23b15"); req.put("client_secret", "59250fe86b674d8bb859a5ccb7164c22"); req.put("grant_type", "client_credentials"); // http://58.17.73.115:9001 String msg = HttpUtils.post("https://app.jxjaly.com/jingan-epana/api/oauth/token", req); Token token = gson.fromJson(msg.toString(), new TypeToken(){}.getType()); String ticket = token.getData().getAccess_token(); Map req2 = new HashMap<>(); List list = userService.queryMById(id); if (list==null){ resultJson.put("code", 500); resultJson.put("msg", "id参数异常"); return resultJson; } User user = list.get(0); String start_time = user.getSm_time().substring(0, 10)+" 00:00:00"; String end_time = user.getSm_time().substring(0,10)+" 24:60:60"; req2.put("startTime", start_time); req2.put("endTime", end_time); req2.put("uuid", user.getUuid()); req2.put("accessToken", ticket); String mess = HttpUtils.post("https://app.jxjaly.com/jingan-epana/api/streamQuery/selectThirdStreamQuery", req2); HashMap map = gson.fromJson(mess.toString(), new TypeToken>(){}.getType()); String code = map.get("code").toString(); if (code.equals("500.0")){ resultJson.put("code", 502); resultJson.put("msg", "未查询伴随人员"); return resultJson; } Follow follow = gson.fromJson(mess.toString(), new TypeToken(){}.getType()); FollowData followData = follow.getFollowData(); ArrayList at = followData.getAt(); if (at.size()==0 ){ resultJson.put("code", 505); resultJson.put("msg", "未查询到数据"); return resultJson; } resultJson.put("code", 200); resultJson.put("msg", "成功"); resultJson.put("data", at); return resultJson; } public JSONObject queryByZzM(int id) throws Exception { Gson gson = new Gson(); JSONObject resultJson = new JSONObject(); List list = userService.queryMById(id); if (list==null){ resultJson.put("code", 500); resultJson.put("msg", "id参数异常"); return resultJson; } User user = list.get(0); System.out.println(user.getSm_time()); if (user.getSm_phone().equals("") || user.getSm_phone()==null || user.getSm_phone().indexOf("*")>0){ resultJson.put("code", 502); resultJson.put("msg", "未获取正确的手机号"); return resultJson; } Integer startTime = TimeExchange.StringToTimestamp(TimeExchange.TimeRangeD(user.getSm_time())); Integer endTime = TimeExchange.StringToTimestamp(TimeExchange.TimeRangeI(user.getSm_time())); JSONObject json = new JSONObject(); json.put("str", user.getSm_phone()); json.put("type", "2"); json.put("threshold", "50"); json.put("spanTime", "60"); ArrayList> ah = new ArrayList<>(); HashMap hs = new HashMap<>(); hs.put("startTime", String.valueOf(startTime)); hs.put("endTime", String.valueOf(endTime)); ah.add(hs); JSONArray jsonArray= JSONArray.fromObject(ah); json.put("timeList", jsonArray); // http://6.205.66.7:8000/rest/analysis/accompany // http://58.17.42.179:8000/rest/analysis/accompany String msg = HttpsClient.sendJson2("http://6.205.66.7:8000/rest/analysis/accompany", json); BanSui bs = gson.fromJson(msg.toString(), new TypeToken(){}.getType()); List ld = new ArrayList<>(); if (bs.getResponseStatus().getStatusCode().equals("0")){ Results results = bs.getResults(); if (results!=null){ ArrayList items = results.getItems(); if (items.size()>0){ for (int i=0;i details = items.get(i).getDetail(); if (details.size()>0){ if (details.get(0).getTargetStr().length() == 11){ Detail dt = new Detail(); dt.setName("***"); dt.setTargetStr(details.get(0).getTargetStr()); dt.setFullPath(details.get(0).getFullPath()); dt.setTimestamp(TimeExchange.timestampToString(Integer.parseInt(details.get(0).getTimestamp()))); ld.add(dt); } } } } } } resultJson.put("code", 200); resultJson.put("data", ld); return resultJson; } public JSONObject queryCarByZzM(int id) throws Exception { Gson gson = new Gson(); JSONObject resultJson = new JSONObject(); List list = userService.queryMById(id); if (list==null){ resultJson.put("code", 500); resultJson.put("msg", "id参数异常"); return resultJson; } User user = list.get(0); System.out.println(user.getSm_time()); if (user.getSm_phone().equals("") || user.getSm_phone()==null || user.getSm_phone().indexOf("*")>0){ resultJson.put("code", 502); resultJson.put("msg", "未获取正确的手机号"); return resultJson; } Integer startTime = TimeExchange.StringToTimestamp(TimeExchange.TimeRangeD(user.getSm_time())); Integer endTime = TimeExchange.StringToTimestamp(TimeExchange.TimeRangeI(user.getSm_time())); JSONObject json = new JSONObject(); json.put("str", user.getSm_phone()); System.out.println(user.getSm_phone()); json.put("type", "1"); json.put("threshold", "50"); json.put("spanTime", "60"); ArrayList> ah = new ArrayList<>(); HashMap hs = new HashMap<>(); hs.put("startTime", String.valueOf(startTime)); hs.put("endTime", String.valueOf(endTime)); ah.add(hs); JSONArray jsonArray= JSONArray.fromObject(ah); json.put("timeList", jsonArray); // http://6.205.66.7:8000/rest/analysis/accompany // http://58.17.42.179:8000/rest/analysis/accompany String msg = HttpsClient.sendJson2("http://6.205.66.7:8000/rest/analysis/accompany", json); BanSui bs = gson.fromJson(msg.toString(), new TypeToken(){}.getType()); List ld = new ArrayList<>(); if (bs.getResponseStatus().getStatusCode().equals("0")){ Results results = bs.getResults(); if (results!=null){ ArrayList items = results.getItems(); if (items.size()>0){ for (int i=0;i details = items.get(i).getDetail(); if (details.size()>0){ if (details.get(0).getTargetStr().length() == 7){ Detail dt = new Detail(); dt.setName("***"); dt.setTargetStr(details.get(0).getTargetStr()); dt.setFullPath(details.get(0).getFullPath()); dt.setTimestamp(TimeExchange.timestampToString(Integer.parseInt(details.get(0).getTimestamp()))); ld.add(dt); } } } } } } resultJson.put("code", 200); resultJson.put("data", ld); return resultJson; } public static void main(String[] args) throws Exception { Gson gson = new Gson(); JSONObject json = new JSONObject(); json.put("str", "19198496653"); json.put("type", "1"); json.put("threshold", "50"); json.put("spanTime", "60"); ArrayList> ah = new ArrayList<>(); HashMap hs = new HashMap<>(); hs.put("startTime", "1642751387"); hs.put("endTime", "1642751747"); ah.add(hs); JSONArray jsonArray= JSONArray.fromObject(ah); json.put("timeList", jsonArray); // http://6.205.66.7:8000/rest/analysis/accompany // http://58.17.42.179:8000/rest/analysis/accompany String msg = HttpsClient.sendJson2("https://app.jxjaly.com/jingan-epana/rest/analysis/accompany", json); BanSui bs = gson.fromJson(msg.toString(), new TypeToken(){}.getType()); List ld = new ArrayList<>(); if (bs.getResponseStatus().getStatusCode().equals("0")){ Results results = bs.getResults(); if (results!=null){ ArrayList items = results.getItems(); if (items.size()>0){ for (int i=0;i details = items.get(i).getDetail(); if (details.size()>0){ if (details.get(0).getTargetStr().length() == 7){ Detail dt = new Detail(); dt.setName("***"); dt.setTargetStr(details.get(0).getTargetStr()); dt.setFullPath(details.get(0).getFullPath()); dt.setTimestamp(TimeExchange.timestampToString(Integer.parseInt(details.get(0).getTimestamp()))); ld.add(dt); } } } } } } System.out.println(ld); } }