Gkycaction.java (Hang Ke forecast)
1 Packagecom.bp.gkyc.action;2 3 Importjava.io.IOException;4 Importjava.util.List;5 ImportJava.util.Map;6 7 Importorg.apache.http.HttpEntity;8 Importorg.apache.http.ParseException;9 ImportOrg.apache.http.client.methods.CloseableHttpResponse;Ten ImportOrg.apache.http.client.methods.HttpPost; One ImportOrg.apache.http.entity.ContentType; A Importorg.apache.http.entity.StringEntity; - Importorg.apache.http.impl.client.CloseableHttpClient; - Importorg.apache.http.impl.client.HttpClients; the Importorg.apache.http.util.EntityUtils; - ImportOrg.springframework.stereotype.Controller; - ImportOrg.springframework.ui.ModelMap; - Importorg.springframework.web.bind.annotation.RequestMapping; + ImportOrg.springframework.web.bind.annotation.RequestMethod; - ImportOrg.springframework.web.bind.annotation.ResponseBody; + A ImportCom.alibaba.fastjson.JSONObject; at - @Controller -@RequestMapping ("/BP/GKYC") - Public classgkycaction { - - @RequestMapping in PublicString Index (Modelmap map) { - return"BP/GKYC/GKYC"; to } + - @ResponseBody the@RequestMapping (value = "Gkuser", method =requestmethod.post) * PublicString Getgkuser () { $String res = "";Panax Notoginseng Try { -Jsonobject BODY =NewJsonobject (); theString DSL = "es \" stu-model\ "--maxevent=1000 | where Score==-1 | Applymodel \ "Bpneural\", \ "stuscoremodel\"--inputfields=\ "clubtime,schoolabsent,classabsent, Entertainmentinternet\ "--predictfield=\" predictscore\ "| Keep \ "Name\", \ "Predictscore\" | Sort Predictscore "; +Jsonobject params =NewJsonobject (); AParams.put ("Sync",true); theBody.put ("DSL", DSL); +Body.put ("params", params); -String str =body.tojsonstring (); $String url = "http://localhost:9000/explorer/query/"; $Closeablehttpclient client =Httpclients.createdefault (); -HttpPost post =Newhttppost (URL); - if(!Str.isempty ()) { thePost.setentity (Newstringentity (str, contenttype.application_json)); - }WuyiCloseablehttpresponse response =Client.execute (POST); thehttpentity entity =response.getentity (); - Wures =entityutils.tostring (entity); - About if(Entity! =NULL) { $ Entityutils.consume (entity); - } - client.close (); -}Catch(ParseException e) { A //TODO auto-generated Catch block + e.printstacktrace (); the}Catch(IOException e) { - //TODO auto-generated Catch block $ e.printstacktrace (); the } the returnRes; the } the -}
Js
1 Util.ajax ({2Url:contextpath + "/bp/gk/gkuser",//the path to the request background3Success:function(data) {4 varGkxs = "";5 for(vari=1;i<11;i++){6 if(i==1){7Gkxs + = "<a href=\" #\ "name=\" xslb\ "id=\" xs "+i+" \ "onclick=\" Clickxs ("+i+") \ "class=\" List-group-item active\ "> "+data.content.data[i+1].values[0]+" <span class=\ "badge badge-primary\" > "+i+" </span></a> ";8}Else{9Gkxs + = "<a href=\" #\ "name=\" xslb\ "id=\" xs "+i+" \ "onclick=\" Clickxs ("+i+") \ "class=\" list-group-item\ ">" + data.content.data[i+1].values[0]+ "<span class=\" badge badge-primary\ ">" +i+ "</span></a>";Ten } One } A$ ("#gkxs"). HTML (GKXS); - } -});
Java Access Datainsight Demo