1
|
package com.monitor.other.bigdata.ctrl;
|
1
|
package com.monitor.other.bigdata.ctrl;
|
2
|
|
2
|
|
|
|
3
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
4
|
+import com.monitor.influxdb.mapper.BigDataKeyInfoMapper;
|
|
|
5
|
+import com.monitor.model.response.BaseResponse;
|
|
|
6
|
+import org.slf4j.Logger;
|
|
|
7
|
+import org.slf4j.LoggerFactory;
|
|
|
8
|
+import org.springframework.beans.factory.annotation.Autowired;
|
3
|
import org.springframework.beans.factory.annotation.Value;
|
9
|
import org.springframework.beans.factory.annotation.Value;
|
4
|
import org.springframework.stereotype.Controller;
|
10
|
import org.springframework.stereotype.Controller;
|
|
|
11
|
+import org.springframework.web.bind.annotation.RequestBody;
|
5
|
import org.springframework.web.bind.annotation.RequestMapping;
|
12
|
import org.springframework.web.bind.annotation.RequestMapping;
|
6
|
import org.springframework.web.bind.annotation.ResponseBody;
|
13
|
import org.springframework.web.bind.annotation.ResponseBody;
|
7
|
|
14
|
|
|
@@ -11,10 +18,52 @@ import org.springframework.web.bind.annotation.ResponseBody; |
|
@@ -11,10 +18,52 @@ import org.springframework.web.bind.annotation.ResponseBody; |
11
|
@Controller
|
18
|
@Controller
|
12
|
@RequestMapping("/bigdata")
|
19
|
@RequestMapping("/bigdata")
|
13
|
public class BigdataCtrl {
|
20
|
public class BigdataCtrl {
|
|
|
21
|
+ public static final Logger logger = LoggerFactory.getLogger(BigdataCtrl.class);
|
14
|
|
22
|
|
15
|
@Value("${bigdata.web.url}")
|
23
|
@Value("${bigdata.web.url}")
|
16
|
private String accessUrl;
|
24
|
private String accessUrl;
|
17
|
|
25
|
|
|
|
26
|
+ @Autowired
|
|
|
27
|
+ private BigDataKeyInfoMapper bigDataKeyInfoMapper;
|
|
|
28
|
+
|
|
|
29
|
+ /**
|
|
|
30
|
+ * 大数据上报的数据
|
|
|
31
|
+ *
|
|
|
32
|
+ {
|
|
|
33
|
+ "name": "搜素用户word2vector特征"
|
|
|
34
|
+ "script": “word-2-vector.sh”
|
|
|
35
|
+ "status" : "success"
|
|
|
36
|
+ "task_id" : 123 //对应任务系统中的id
|
|
|
37
|
+ "count_name": "xxxx" ,//统计项目
|
|
|
38
|
+ "count": 1000; //统计数量
|
|
|
39
|
+ }
|
|
|
40
|
+ */
|
|
|
41
|
+ @RequestMapping("/bigDataKeyInfoReport")
|
|
|
42
|
+ @ResponseBody
|
|
|
43
|
+ public BaseResponse bigDataKeyInfoReport(@RequestBody JSONObject jsonObject) {
|
|
|
44
|
+ String name=jsonObject.getString("name");
|
|
|
45
|
+ String script=jsonObject.getString("script");
|
|
|
46
|
+ String status=jsonObject.getString("status");
|
|
|
47
|
+ String task_id=jsonObject.getString("task_id");
|
|
|
48
|
+ String count_name=jsonObject.getString("count_name");
|
|
|
49
|
+ double count=0d;
|
|
|
50
|
+
|
|
|
51
|
+ Object countValue=jsonObject.get("count");
|
|
|
52
|
+ if(countValue!=null){
|
|
|
53
|
+ try{
|
|
|
54
|
+ count = Double.parseDouble(""+countValue);
|
|
|
55
|
+ }catch (Exception e){
|
|
|
56
|
+ logger.error("bigDataKeyInfoReport change count error {} ,{}",countValue,e);
|
|
|
57
|
+ }
|
|
|
58
|
+ }else{
|
|
|
59
|
+ logger.error("bigDataKeyInfoReport count is null ");
|
|
|
60
|
+ }
|
|
|
61
|
+
|
|
|
62
|
+ //上报给influxdb
|
|
|
63
|
+ bigDataKeyInfoMapper.write(name,script,status,task_id,count_name,count);
|
|
|
64
|
+ return new BaseResponse();
|
|
|
65
|
+ }
|
|
|
66
|
+
|
18
|
/**
|
67
|
/**
|
19
|
* 获取访问url
|
68
|
* 获取访问url
|
20
|
* @return
|
69
|
* @return
|