| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- 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<String, String> 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<Token>(){}.getType());
- String ticket = token.getData().getAccess_token();
- Map<String, String> req2 = new HashMap<>();
- List<User> 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<String,Object> map = gson.fromJson(mess.toString(), new TypeToken<HashMap<String,Object>>(){}.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<Follow>(){}.getType());
- FollowData followData = follow.getFollowData();
- ArrayList<Trajectory> 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<User> 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<HashMap<String, String>> ah = new ArrayList<>();
- HashMap<String, String> 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<BanSui>(){}.getType());
- List<Detail> ld = new ArrayList<>();
- if (bs.getResponseStatus().getStatusCode().equals("0")){
- Results results = bs.getResults();
- if (results!=null){
- ArrayList<Items> items = results.getItems();
- if (items.size()>0){
- for (int i=0;i<items.size();i++){
- ArrayList<Detail> 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<User> 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<HashMap<String, String>> ah = new ArrayList<>();
- HashMap<String, String> 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<BanSui>(){}.getType());
- List<Detail> ld = new ArrayList<>();
- if (bs.getResponseStatus().getStatusCode().equals("0")){
- Results results = bs.getResults();
- if (results!=null){
- ArrayList<Items> items = results.getItems();
- if (items.size()>0){
- for (int i=0;i<items.size();i++){
- ArrayList<Detail> 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<HashMap<String, String>> ah = new ArrayList<>();
- HashMap<String, String> 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<BanSui>(){}.getType());
- List<Detail> ld = new ArrayList<>();
- if (bs.getResponseStatus().getStatusCode().equals("0")){
- Results results = bs.getResults();
- if (results!=null){
- ArrayList<Items> items = results.getItems();
- if (items.size()>0){
- for (int i=0;i<items.size();i++){
- ArrayList<Detail> 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);
- }
- }
|