標籤:pen rac entity type ict frame onclick empty bind
GkycAction.java (掛科預測)
1 package com.bp.gkyc.action; 2 3 import java.io.IOException; 4 import java.util.List; 5 import java.util.Map; 6 7 import org.apache.http.HttpEntity; 8 import org.apache.http.ParseException; 9 import org.apache.http.client.methods.CloseableHttpResponse;10 import org.apache.http.client.methods.HttpPost;11 import org.apache.http.entity.ContentType;12 import org.apache.http.entity.StringEntity;13 import org.apache.http.impl.client.CloseableHttpClient;14 import org.apache.http.impl.client.HttpClients;15 import org.apache.http.util.EntityUtils;16 import org.springframework.stereotype.Controller;17 import org.springframework.ui.ModelMap;18 import org.springframework.web.bind.annotation.RequestMapping;19 import org.springframework.web.bind.annotation.RequestMethod;20 import org.springframework.web.bind.annotation.ResponseBody;21 22 import com.alibaba.fastjson.JSONObject;23 24 @Controller25 @RequestMapping("/bp/gkyc")26 public class GkycAction {27 28 @RequestMapping29 public String index(ModelMap map) {30 return "bp/gkyc/gkyc";31 }32 33 @ResponseBody34 @RequestMapping(value = "gkuser", method = RequestMethod.POST)35 public String getGkUser() {36 String res ="";37 try {38 JSONObject body = new JSONObject();39 String dsl = "es \"stu-model\" --maxevent=1000 | where score==-1 | applymodel \"BpNeural\",\"stuScoreModel\" --inputFields=\"clubtime,schoolAbsent,classAbsent,entertainmentInternet\" --predictField=\"PredictScore\" | keep \"name\",\"PredictScore\" | sort PredictScore";40 JSONObject params = new JSONObject();41 params.put("sync", true);42 body.put("dsl", dsl);43 body.put("params", params);44 String str = body.toJSONString();45 String url = "http://localhost:9000/explorer/query/";46 CloseableHttpClient client = HttpClients.createDefault();47 HttpPost post = new HttpPost(url);48 if (!str.isEmpty()) {49 post.setEntity(new StringEntity(str, ContentType.APPLICATION_JSON));50 }51 CloseableHttpResponse response = client.execute(post);52 HttpEntity entity = response.getEntity();53 54 res = EntityUtils.toString(entity);55 56 if (entity != null) {57 EntityUtils.consume(entity);58 }59 client.close();60 } catch (ParseException e) {61 // TODO Auto-generated catch block62 e.printStackTrace();63 } catch (IOException e) {64 // TODO Auto-generated catch block65 e.printStackTrace();66 }67 return res;68 }69 70 }
js
1 Util.ajax({ 2 url : contextpath + "/bp/gk/gkuser" ,//請求背景路徑 3 success : function(data){ 4 var gkxs = ""; 5 for(var i=1;i<11;i++){ 6 if(i==1){ 7 gkxs += "<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{ 9 gkxs += "<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>";10 }11 }12 $("#gkxs").html(gkxs);13 }14 });
Java 訪問 DataInsight Demo