Mijie.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. package com.happy.Until;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.google.gson.Gson;
  4. import com.google.gson.reflect.TypeToken;
  5. import com.happy.Model.Ban.BanSui;
  6. import com.happy.Model.Ban.Detail;
  7. import com.happy.Model.Ban.Items;
  8. import com.happy.Model.Ban.Results;
  9. import com.happy.Model.Common.Follow;
  10. import com.happy.Model.Common.FollowData;
  11. import com.happy.Model.Common.Token;
  12. import com.happy.Model.Common.Trajectory;
  13. import com.happy.Model.User;
  14. import com.happy.common.http.HttpsClient;
  15. import com.happy.service.UserService;
  16. import net.sf.json.JSONArray;
  17. import org.springframework.stereotype.Service;
  18. import javax.annotation.Resource;
  19. import java.util.ArrayList;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. @Service
  24. public class Mijie {
  25. @Resource
  26. public UserService userService;
  27. public JSONObject query(int id) throws Exception {
  28. JSONObject resultJson = new JSONObject();
  29. Gson gson = new Gson();
  30. Map<String, String> req = new HashMap<>();
  31. req.put("client_id", "32f7d83bb4304822b17083ac49a23b15");
  32. req.put("client_secret", "59250fe86b674d8bb859a5ccb7164c22");
  33. req.put("grant_type", "client_credentials");
  34. // http://58.17.73.115:9001
  35. String msg = HttpUtils.post("https://app.jxjaly.com/jingan-epana/api/oauth/token", req);
  36. Token token = gson.fromJson(msg.toString(), new TypeToken<Token>(){}.getType());
  37. String ticket = token.getData().getAccess_token();
  38. Map<String, String> req2 = new HashMap<>();
  39. List<User> list = userService.queryMById(id);
  40. if (list==null){
  41. resultJson.put("code", 500);
  42. resultJson.put("msg", "id参数异常");
  43. return resultJson;
  44. }
  45. User user = list.get(0);
  46. String start_time = user.getSm_time().substring(0, 10)+" 00:00:00";
  47. String end_time = user.getSm_time().substring(0,10)+" 24:60:60";
  48. req2.put("startTime", start_time);
  49. req2.put("endTime", end_time);
  50. req2.put("uuid", user.getUuid());
  51. req2.put("accessToken", ticket);
  52. String mess = HttpUtils.post("https://app.jxjaly.com/jingan-epana/api/streamQuery/selectThirdStreamQuery", req2);
  53. HashMap<String,Object> map = gson.fromJson(mess.toString(), new TypeToken<HashMap<String,Object>>(){}.getType());
  54. String code = map.get("code").toString();
  55. if (code.equals("500.0")){
  56. resultJson.put("code", 502);
  57. resultJson.put("msg", "未查询伴随人员");
  58. return resultJson;
  59. }
  60. Follow follow = gson.fromJson(mess.toString(), new TypeToken<Follow>(){}.getType());
  61. FollowData followData = follow.getFollowData();
  62. ArrayList<Trajectory> at = followData.getAt();
  63. if (at.size()==0 ){
  64. resultJson.put("code", 505);
  65. resultJson.put("msg", "未查询到数据");
  66. return resultJson;
  67. }
  68. resultJson.put("code", 200);
  69. resultJson.put("msg", "成功");
  70. resultJson.put("data", at);
  71. return resultJson;
  72. }
  73. public JSONObject queryByZzM(int id) throws Exception {
  74. Gson gson = new Gson();
  75. JSONObject resultJson = new JSONObject();
  76. List<User> list = userService.queryMById(id);
  77. if (list==null){
  78. resultJson.put("code", 500);
  79. resultJson.put("msg", "id参数异常");
  80. return resultJson;
  81. }
  82. User user = list.get(0);
  83. System.out.println(user.getSm_time());
  84. if (user.getSm_phone().equals("") || user.getSm_phone()==null || user.getSm_phone().indexOf("*")>0){
  85. resultJson.put("code", 502);
  86. resultJson.put("msg", "未获取正确的手机号");
  87. return resultJson;
  88. }
  89. Integer startTime = TimeExchange.StringToTimestamp(TimeExchange.TimeRangeD(user.getSm_time()));
  90. Integer endTime = TimeExchange.StringToTimestamp(TimeExchange.TimeRangeI(user.getSm_time()));
  91. JSONObject json = new JSONObject();
  92. json.put("str", user.getSm_phone());
  93. json.put("type", "2");
  94. json.put("threshold", "50");
  95. json.put("spanTime", "60");
  96. ArrayList<HashMap<String, String>> ah = new ArrayList<>();
  97. HashMap<String, String> hs = new HashMap<>();
  98. hs.put("startTime", String.valueOf(startTime));
  99. hs.put("endTime", String.valueOf(endTime));
  100. ah.add(hs);
  101. JSONArray jsonArray= JSONArray.fromObject(ah);
  102. json.put("timeList", jsonArray);
  103. // http://6.205.66.7:8000/rest/analysis/accompany
  104. // http://58.17.42.179:8000/rest/analysis/accompany
  105. String msg = HttpsClient.sendJson2("http://6.205.66.7:8000/rest/analysis/accompany", json);
  106. BanSui bs = gson.fromJson(msg.toString(), new TypeToken<BanSui>(){}.getType());
  107. List<Detail> ld = new ArrayList<>();
  108. if (bs.getResponseStatus().getStatusCode().equals("0")){
  109. Results results = bs.getResults();
  110. if (results!=null){
  111. ArrayList<Items> items = results.getItems();
  112. if (items.size()>0){
  113. for (int i=0;i<items.size();i++){
  114. ArrayList<Detail> details = items.get(i).getDetail();
  115. if (details.size()>0){
  116. if (details.get(0).getTargetStr().length() == 11){
  117. Detail dt = new Detail();
  118. dt.setName("***");
  119. dt.setTargetStr(details.get(0).getTargetStr());
  120. dt.setFullPath(details.get(0).getFullPath());
  121. dt.setTimestamp(TimeExchange.timestampToString(Integer.parseInt(details.get(0).getTimestamp())));
  122. ld.add(dt);
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. resultJson.put("code", 200);
  130. resultJson.put("data", ld);
  131. return resultJson;
  132. }
  133. public JSONObject queryCarByZzM(int id) throws Exception {
  134. Gson gson = new Gson();
  135. JSONObject resultJson = new JSONObject();
  136. List<User> list = userService.queryMById(id);
  137. if (list==null){
  138. resultJson.put("code", 500);
  139. resultJson.put("msg", "id参数异常");
  140. return resultJson;
  141. }
  142. User user = list.get(0);
  143. System.out.println(user.getSm_time());
  144. if (user.getSm_phone().equals("") || user.getSm_phone()==null || user.getSm_phone().indexOf("*")>0){
  145. resultJson.put("code", 502);
  146. resultJson.put("msg", "未获取正确的手机号");
  147. return resultJson;
  148. }
  149. Integer startTime = TimeExchange.StringToTimestamp(TimeExchange.TimeRangeD(user.getSm_time()));
  150. Integer endTime = TimeExchange.StringToTimestamp(TimeExchange.TimeRangeI(user.getSm_time()));
  151. JSONObject json = new JSONObject();
  152. json.put("str", user.getSm_phone());
  153. System.out.println(user.getSm_phone());
  154. json.put("type", "1");
  155. json.put("threshold", "50");
  156. json.put("spanTime", "60");
  157. ArrayList<HashMap<String, String>> ah = new ArrayList<>();
  158. HashMap<String, String> hs = new HashMap<>();
  159. hs.put("startTime", String.valueOf(startTime));
  160. hs.put("endTime", String.valueOf(endTime));
  161. ah.add(hs);
  162. JSONArray jsonArray= JSONArray.fromObject(ah);
  163. json.put("timeList", jsonArray);
  164. // http://6.205.66.7:8000/rest/analysis/accompany
  165. // http://58.17.42.179:8000/rest/analysis/accompany
  166. String msg = HttpsClient.sendJson2("http://6.205.66.7:8000/rest/analysis/accompany", json);
  167. BanSui bs = gson.fromJson(msg.toString(), new TypeToken<BanSui>(){}.getType());
  168. List<Detail> ld = new ArrayList<>();
  169. if (bs.getResponseStatus().getStatusCode().equals("0")){
  170. Results results = bs.getResults();
  171. if (results!=null){
  172. ArrayList<Items> items = results.getItems();
  173. if (items.size()>0){
  174. for (int i=0;i<items.size();i++){
  175. ArrayList<Detail> details = items.get(i).getDetail();
  176. if (details.size()>0){
  177. if (details.get(0).getTargetStr().length() == 7){
  178. Detail dt = new Detail();
  179. dt.setName("***");
  180. dt.setTargetStr(details.get(0).getTargetStr());
  181. dt.setFullPath(details.get(0).getFullPath());
  182. dt.setTimestamp(TimeExchange.timestampToString(Integer.parseInt(details.get(0).getTimestamp())));
  183. ld.add(dt);
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. resultJson.put("code", 200);
  191. resultJson.put("data", ld);
  192. return resultJson;
  193. }
  194. public static void main(String[] args) throws Exception {
  195. Gson gson = new Gson();
  196. JSONObject json = new JSONObject();
  197. json.put("str", "19198496653");
  198. json.put("type", "1");
  199. json.put("threshold", "50");
  200. json.put("spanTime", "60");
  201. ArrayList<HashMap<String, String>> ah = new ArrayList<>();
  202. HashMap<String, String> hs = new HashMap<>();
  203. hs.put("startTime", "1642751387");
  204. hs.put("endTime", "1642751747");
  205. ah.add(hs);
  206. JSONArray jsonArray= JSONArray.fromObject(ah);
  207. json.put("timeList", jsonArray);
  208. // http://6.205.66.7:8000/rest/analysis/accompany
  209. // http://58.17.42.179:8000/rest/analysis/accompany
  210. String msg = HttpsClient.sendJson2("https://app.jxjaly.com/jingan-epana/rest/analysis/accompany", json);
  211. BanSui bs = gson.fromJson(msg.toString(), new TypeToken<BanSui>(){}.getType());
  212. List<Detail> ld = new ArrayList<>();
  213. if (bs.getResponseStatus().getStatusCode().equals("0")){
  214. Results results = bs.getResults();
  215. if (results!=null){
  216. ArrayList<Items> items = results.getItems();
  217. if (items.size()>0){
  218. for (int i=0;i<items.size();i++){
  219. ArrayList<Detail> details = items.get(i).getDetail();
  220. if (details.size()>0){
  221. if (details.get(0).getTargetStr().length() == 7){
  222. Detail dt = new Detail();
  223. dt.setName("***");
  224. dt.setTargetStr(details.get(0).getTargetStr());
  225. dt.setFullPath(details.get(0).getFullPath());
  226. dt.setTimestamp(TimeExchange.timestampToString(Integer.parseInt(details.get(0).getTimestamp())));
  227. ld.add(dt);
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. System.out.println(ld);
  235. }
  236. }