Java 訪問 DataInsight Demo

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.