IndexController.java 4.7 KB
package com.glsx.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.com.glsx.openplatform.service.ApiCallMgrService;
import cn.com.glsx.openplatform.service.AppDownloadMgrService;
import cn.com.glsx.openplatform.service.CustomerMgrService;
import cn.com.glsx.openplatform.service.DeviceMgrService;
import cn.com.glsx.openplatform.service.IndexService;
import cn.com.glsx.openplatform.service.UserMgrService;
import cn.com.glsx.openplatform.vo.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author deployer name
 * @version V1.0
 * @Title: IndexController.java
 * @Description:
 * @Company: Didihu.com.cn
 * @Copyright Copyright (c) 2017
 */
//@Api
@RestController
@RequestMapping(value = "/index")
public class IndexController {
    /**
     * 日志
     */
    private final static Logger LOGGER = LoggerFactory.getLogger(IndexController.class);

    @Autowired
    private CustomerMgrService customerMgrService;

    @Autowired
    private DeviceMgrService deviceMgrService;

    @Autowired
    private UserMgrService userMgrService;

    @Autowired
    private ApiCallMgrService apiCallMgrService;

    @Autowired
    private AppDownloadMgrService appDownloadMgrService;

    @Autowired
    private IndexService indexService;

    @RequestMapping(value = "/getStatisticData", method = RequestMethod.GET)
    @ResponseBody
    public R getStatisticData() {
        Map<String, Integer> hashMap = new HashMap<>();
        int customerCount = customerMgrService.getCustomerCount();

        int deviceCount = deviceMgrService.getDeviceCount();

        int userCount = userMgrService.getUserCount();

        int apiCallCount = apiCallMgrService.getApiCallCount();

        hashMap.put("customerCount", customerCount);
        hashMap.put("deviceCount", deviceCount);
        hashMap.put("userCount", userCount);
        hashMap.put("apiCallCount", apiCallCount);

        return R.ok().data(hashMap);
    }


    @RequestMapping(value = "/getGraphData", method = RequestMethod.GET)
    @ResponseBody
    public R getGraphData() {
        Map<String, List<Map<String, Integer>>> hashMap = new HashMap<>();
        List<Map<String, Integer>> deviceGraphData = deviceMgrService.getDeviceGraphData();

        List<Map<String, Integer>> apiCallGraphData = apiCallMgrService.getApiCallGraphData();

        hashMap.put("deviceGraphData", deviceGraphData);
        hashMap.put("apiCallGraphData", apiCallGraphData);
        return R.ok().data(hashMap);
    }

    @RequestMapping(value = "/getPolylineData", method = RequestMethod.GET)
    @ResponseBody
    public R getPolylineData() {
        HashMap<String, List<Map<String, Integer>>> hashMap = new HashMap<>();
        List<Map<String, Integer>> deviceAccessTrendList = deviceMgrService.getDeviceAccessTrendList();
        List<Map<String, Integer>> apiCallTrendList = apiCallMgrService.getApiCallTrendList();

        hashMap.put("deviceAccessTrendList", deviceAccessTrendList);
        hashMap.put("apiCallTrendList", apiCallTrendList);
        return R.ok().data(hashMap);
    }




    @RequestMapping(value = "/getUcSummaryStatistic", method = RequestMethod.GET)
    @ResponseBody
    public R getUcSummaryStatistic(@RequestParam String customerName) {
        Map<String, Integer> statisticMap = this.indexService.getUcSummaryStatistic(customerName);

        return R.ok().data(statisticMap);
    }

    @RequestMapping(value = "/getUcDeviceActivationStatistic", method = RequestMethod.GET)
    public R getUcDeviceActivationStatistic(@RequestParam String customerName) {
        Map<String, Integer> statisticMap = this.indexService
                .getUcDeviceActivationStatistic(customerName);
        return R.ok().data(statisticMap);
    }

    @RequestMapping(value = "/getUcUserActivityStatistic", method = RequestMethod.GET)
    public R getUcUserActivityStatistic(@RequestParam String customerName) {
        Map<String, Integer> statisticMap = this.indexService
                .getUcUserActivityStatistic(customerName);
        return R.ok().data(statisticMap);
    }

    @RequestMapping(value = "/getUcAppDownloadStatistic", method = RequestMethod.GET)
    public R getUcAppDownloadStatistic(@RequestParam String customerName) {
        Map<String, Integer> statisticMap = this.indexService
                .getUcAppDownloadStatistic(customerName);
        return R.ok().data(statisticMap);
    }
}