package main.java.com.zte.controller.ems;

import java.util.HashMap;
import java.util.List;
import java.util.Map; import javax.annotation.Resource; import net.sf.json.JSONArray;
import net.sf.json.JSONObject; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView; import main.java.com.zte.controller.base.BaseController;
import main.java.com.zte.entity.Page;
import main.java.com.zte.service.ems.OperationService;
import main.java.com.zte.util.DateUtil;
import main.java.com.zte.util.PageData;
import main.java.com.zte.util.Tools; /**
* EMS上用户操作日志处理类
*
* @author 10183302
*
*/
@Controller
@RequestMapping(value = "/ems/operation")
public class OperationController extends BaseController {
private static final String FAILD = "Failed";
private static final String OPERATION_RESULT = "operationResult";
private static final String OPER_COUNT = "OPER_COUNT";
private static final String EMS_USER_OPERATION_CHARTS = "ems/user_operation_charts";
private static final String USER_OPERATION_FAILED_COUNT = "userOperationFailedCount";
private static final String USER_OPERATION_NAME_COUNT = "userOperationNameCount";
private static final String USER_COUNT = "userCount";
private static final String OPERATION_NAME_LIST = "operationNameList";
private static final String IP_LIST = "ipList";
private static final String START_TIME = "START_TIME";
private static final String TASK_ID_STR = "taskId";
private static final String TASK_ID_NUM_STR = "1470880530369";
private static final String HOST_STR_UPPER = "HOST";
private static final String HOST_STR_LOWER = "ip";
private static final String OPERATION_NAME_STR_LOWER = "operationName";
private static final String LOG_NAME_STR_UPPER = "OPERATION_NAME"; @Resource(name = "operationService")
private OperationService operationService; @RequestMapping(value = "/to_user_operation_charts")
public ModelAndView toUserOperationCharts(Page page,
@RequestParam(value = TASK_ID_STR, required = false) String taskId)
throws Exception {
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
List<PageData> ipList = null;
List<PageData> operationNameList = null;
List<PageData> userCount = null;
List<PageData> userOperationNameCount = null;
List<PageData> userOperationFailedCount = null;
try {
pd = this.getPageData();
if (!Tools.notEmpty(taskId)) {
taskId = TASK_ID_NUM_STR;
}
pd.put(TASK_ID_STR, taskId);
ipList = operationService.getOperationIp(pd);
if (null != ipList) {
pd.put(HOST_STR_LOWER, ipList.get(0).get(HOST_STR_UPPER));
operationNameList = operationService.getOperationName(pd);
pd.put(OPERATION_NAME_STR_LOWER,
operationNameList.get(0).get(LOG_NAME_STR_UPPER));
page.setPd(pd);
userCount = operationService.userCount(pd);
userOperationNameCount = operationService
.userOperationNameCount(pd);
pd.put(OPERATION_RESULT, FAILD);
userOperationFailedCount = operationService
.userOperationFailedCount(pd);
}
} catch (Exception e) {
logger.error(e.toString(), e);
}
mv.addObject(IP_LIST, ipList);
mv.addObject(OPERATION_NAME_LIST, operationNameList);
mv.addObject(USER_COUNT, userCount);
mv.addObject(USER_OPERATION_NAME_COUNT, userOperationNameCount);
mv.addObject(USER_OPERATION_FAILED_COUNT, userOperationFailedCount);
mv.setViewName(EMS_USER_OPERATION_CHARTS);
return mv;
} @RequestMapping(value = "/user_operation_charts")
@ResponseBody
public Map userOperationCharts(Page page,
@RequestParam(value = TASK_ID_STR, required = false) String taskId) {
PageData pd = new PageData();
List<PageData> userOperDatas = null;
JSONObject chartsUserOperJson = new JSONObject();
Map<String, Double> userOperDataMap = new HashMap<String, Double>();
try {
pd = this.getPageData();
if (!Tools.notEmpty(taskId)) {
taskId = TASK_ID_NUM_STR;
}
pd.put(TASK_ID_STR, taskId);
/*
* pd.put(HOST_STR_LOWER, ip); pd.put(OPERATION_NAME_STR_LOWER,
* operationName);
*/
userOperDatas = operationService.userOperationCharts(pd);
// 存放一个图表OPER_COUNT,START_TIME
if (!userOperDatas.isEmpty()) {
String time = "";
double operCount = 0;
for (PageData userOperData : userOperDatas) {
time = DateUtil.convertUTCTimeMillis(userOperData.get(
START_TIME).toString());
operCount = Double.valueOf(userOperData.get(OPER_COUNT)
.toString());
userOperDataMap.put(time, operCount);
}
chartsUserOperJson = JSONObject.fromObject(userOperDataMap);
}
} catch (Exception e) {
logger.error(e.toString(), e);
} Map<String, Double> map = new HashMap<String, Double>();
map.put("1", 21.1);
map.put("2", 33.3);
map.put("3", 44.4);
JSONObject jsonObject = JSONObject.fromObject(map);
return userOperDataMap;
} @RequestMapping(value = "/get_operation_name")
@ResponseBody
public String getOperationName(
@RequestParam(value = HOST_STR_LOWER, required = false) String ip) {
PageData pd = new PageData();
List<PageData> operationNameList = null;
try {
pd = this.getPageData();
pd.put(HOST_STR_LOWER, ip);
operationNameList = operationService.getOperationName(pd);
} catch (Exception e) {
logger.error(e.toString(), e);
}
return JSONArray.fromObject(operationNameList).toString();
}
}

最新文章

  1. 几个常见的布局的多种实现方式及margin负值总结
  2. hdu 1303 Doubles
  3. 细说:Unicode, UTF-8, UTF-16, UTF-32, UCS-2, UCS-4
  4. eclipse android重新安装遇到各种问题
  5. su 切换用户
  6. Android UI开发神兵利器之Android Asset Studio
  7. iOS开发Embedded dylibs/frameworks are only supported on iOS 8.0 and later for architecture armv7的解决方法
  8. MapReduce中一次reduce方法的调用中key的值不断变化分析及源码解析
  9. kvm之十二:虚拟机迁移
  10. Vue状态管理之Vuex
  11. nginx 长连接keeplive
  12. CPU对指令长度的判断
  13. VMware上centos系统忘记账号和密码解决
  14. Lua程序设计(三)面向对象实现一个简单的类
  15. SHOI2019旅游记
  16. Copying and Cloning Objects
  17. 使用MyEclipse 2014创建项目
  18. MySQL 储存过程-原理、语法、函数详细说明
  19. PHP实现双向链表、栈
  20. C#中使用lockbits方法处理图像

热门文章

  1. python接口自动化6-重定向(Location)
  2. shader内置变量
  3. JAVA常见算法题(三十三)---求子串在字符串中出现的次数
  4. [PHP] ubuntu16.04配置Lamp环境(搭建linux+apache+mysql+php7环境)
  5. NLP知识结构概述
  6. Asp.Net Core App 部署故障示例 2
  7. Java学习之路(转)
  8. 数据库实例: STOREBOOK &gt; 表空间 &gt; 编辑 表空间: SYSAUX
  9. freetds简介、安装、配置及使用介绍
  10. 附1 hystrix详述(1)