package http; import java.net.InetAddress; import java.util.LinkedHashMap; import java.util.Vector; import Method.BaoWenShow; import PbuliClass.ShowMessage; import VectroData.ForwardDatas; import cn.hutool.http.Header; import cn.hutool.http.HttpRequest; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import tbDataModel.Tb_forward_data; public class HTTP_Post implements Runnable{ static Vector> displayvc=new Vector>(); static int sleeptime=1; static Object lock=new Object(); /**Æô¶¯Ï̵߳ķ½·¨*/ public void startThread() { Thread t=new Thread(this); t.start(); } public void run() { while(true) { try { synchronized (lock) { lock.wait(sleeptime); zhuanfa_display(); } } catch (InterruptedException e) { e.printStackTrace(); } } } /**ת·¢Î»ÖÃÊý¾Ý*/ public static void zhuanfa_display() { if(displayvc.size()>10000) { displayvc.removeAllElements(); }else { if(displayvc.size()==0) { sleeptime=100; }else { sleeptime=1; LinkedHashMap displayh= displayvc.get(0); HTTP_Post.display("", "", displayh); displayvc.removeElement(displayh); } } } /**µÇÂ¼Ò³Ãæ*/ public static String login(String url,String admin,String password) { String paramJson = "{\r\n" + "\"password\": \""+password+"\",\r\n" + "\"account\": \""+admin+"\"\r\n" + "}"; //µ÷ÓõǼ»ñÈ¡µÄtoken String token =""; //ÇëÇó½Ó¿Ú»ñÈ¡½á¹û String result = HttpRequest.post(url) .header("token",token) .body(paramJson) .execute().body(); JSONObject jo = JSONUtil.parseObj(result); JSONObject jo1 = JSONUtil.parseObj(jo.get("data")); String tokens=(String) jo1.get("token"); return tokens; } /** * ´«ÈëÐèÒªÁ¬½ÓµÄIP£¬·µ»ØÊÇ·ñÁ¬½Ó³É¹¦ * @param remoteInetAddr * @return */ public static boolean isReachable(String remoteInetAddr) { boolean reachable = false; try { InetAddress address = InetAddress.getByName(remoteInetAddr); reachable = address.isReachable(5000); } catch (Exception e) { e.printStackTrace(); } return reachable; } /**HTTPת·¢Î»ÖÃÊý¾Ý * /**ת·¢ÊµÊ±Î»ÖÃÊý¾Ý * { * {"type": "display", "tagid": "8252", "x":"200", "y": "585", "z": "150", "floor": "0" ,"biaozhi": "23", "timestamp": "2021-05-31 23:14:14.063"}, * {"type": "display", "tagid": "8354", "x":"175", "y": "369", "z": "175", "floor": "1", "biaozhi": "23", "timestamp": "2021-05-31 23:14:14.063"}, * {"type": "display", "tagid": "8680", "x":"857", "y": "814", "z": "163", "floor": "0", "biaozhi": "23", "timestamp": "2021-05-31 23:14:14.063"} * }**/ public static void display( String admin, String password, LinkedHashMap display) { int size=ForwardDatas.get_mou_tb_forword("HTTP-Client", "λÖÃÊý¾Ý").size(); for(int i=0;i display) { int size=ForwardDatas.get_mou_tb_forword("HTTP-Client", "λÖÃÊý¾Ý").size(); for(int i=0;i message) { Vector vc=ForwardDatas.get_mou_tb_forword("HTTP-Client", "¸æ¾¯Êý¾Ý"); int size=vc.size(); for(int i=0;i> getDisplayvc() { return displayvc; } public static void setDisplayvc(Vector> display) { HTTP_Post.displayvc = display; } }