|
|
package com.monitor.other.bigdata.ctrl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.monitor.influxdb.mapper.BigDataKeyInfoMapper;
|
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
...
|
...
|
@@ -11,10 +18,52 @@ import org.springframework.web.bind.annotation.ResponseBody; |
|
|
@Controller
|
|
|
@RequestMapping("/bigdata")
|
|
|
public class BigdataCtrl {
|
|
|
public static final Logger logger = LoggerFactory.getLogger(BigdataCtrl.class);
|
|
|
|
|
|
@Value("${bigdata.web.url}")
|
|
|
private String accessUrl;
|
|
|
|
|
|
@Autowired
|
|
|
private BigDataKeyInfoMapper bigDataKeyInfoMapper;
|
|
|
|
|
|
/**
|
|
|
* 大数据上报的数据
|
|
|
*
|
|
|
{
|
|
|
"name": "搜素用户word2vector特征"
|
|
|
"script": “word-2-vector.sh”
|
|
|
"status" : "success"
|
|
|
"task_id" : 123 //对应任务系统中的id
|
|
|
"count_name": "xxxx" ,//统计项目
|
|
|
"count": 1000; //统计数量
|
|
|
}
|
|
|
*/
|
|
|
@RequestMapping("/bigDataKeyInfoReport")
|
|
|
@ResponseBody
|
|
|
public BaseResponse bigDataKeyInfoReport(@RequestBody JSONObject jsonObject) {
|
|
|
String name=jsonObject.getString("name");
|
|
|
String script=jsonObject.getString("script");
|
|
|
String status=jsonObject.getString("status");
|
|
|
String task_id=jsonObject.getString("task_id");
|
|
|
String count_name=jsonObject.getString("count_name");
|
|
|
double count=0d;
|
|
|
|
|
|
Object countValue=jsonObject.get("count");
|
|
|
if(countValue!=null){
|
|
|
try{
|
|
|
count = Double.parseDouble(""+countValue);
|
|
|
}catch (Exception e){
|
|
|
logger.error("bigDataKeyInfoReport change count error {} ,{}",countValue,e);
|
|
|
}
|
|
|
}else{
|
|
|
logger.error("bigDataKeyInfoReport count is null ");
|
|
|
}
|
|
|
|
|
|
//上报给influxdb
|
|
|
bigDataKeyInfoMapper.write(name,script,status,task_id,count_name,count);
|
|
|
return new BaseResponse();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取访问url
|
|
|
* @return
|
...
|
...
|
|