|
@@ -1,71 +0,0 @@
|
|
|
-package cn.com.qmth.examcloud.logic.reports.controller;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import com.google.common.collect.Lists;
|
|
|
-import com.google.common.collect.Maps;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.common.support.ControllerSupport;
|
|
|
-import cn.com.qmth.examcloud.common.support.helpers.KeyValuePair;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.DemoCloudService;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.GetXxxReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.GetXxxResp;
|
|
|
-import cn.com.qmth.examcloud.logic.reports.service.OnLineService;
|
|
|
-import cn.com.qmth.examcloud.logic.reports.service.bean.GlobalOnLineData;
|
|
|
-import cn.com.qmth.examcloud.logic.reports.service.bean.SchoolOnLineData;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-
|
|
|
-@RestController
|
|
|
-@RequestMapping("${app.api.root}/online")
|
|
|
-public class OnLineController extends ControllerSupport {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private OnLineService onLineService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private DemoCloudService demoCloudService;
|
|
|
-
|
|
|
- @ApiOperation(value = "查询在线数据", notes = "查询在线数据")
|
|
|
- @GetMapping
|
|
|
- public ResponseEntity<Map<String, Object>> getOnLineData() {
|
|
|
- GetXxxReq req = new GetXxxReq();
|
|
|
- req.setF1("wangwei");
|
|
|
- req.setF2(100);
|
|
|
- GetXxxResp resp = demoCloudService.getXxx(req);
|
|
|
- System.out.println(resp);
|
|
|
-
|
|
|
- GlobalOnLineData globalDataInfo = onLineService.getGlobalOnLineData();
|
|
|
- List<SchoolOnLineData> schoolDataList = onLineService.getAllSchoolOnLineDataList();
|
|
|
- List<KeyValuePair<String, Long>> latestGlobalOnLineDataList = onLineService.getLatestGlobalOnLineDataList();
|
|
|
-
|
|
|
- List<Object> globalData = Lists.newArrayList();
|
|
|
- globalData.add(new KeyValuePair<String, Long>("注册用户", globalDataInfo.getRegisterCount()).toJsonObject("type",
|
|
|
- "count"));
|
|
|
- globalData.add(
|
|
|
- new KeyValuePair<String, Long>("在线用户", globalDataInfo.getOnlineCount()).toJsonObject("type", "count"));
|
|
|
- globalData.add(
|
|
|
- new KeyValuePair<String, Long>("在线考试", globalDataInfo.getExamCount()).toJsonObject("type", "count"));
|
|
|
- globalData.add(new KeyValuePair<String, Long>("在线练习", globalDataInfo.getExercisesCount()).toJsonObject("type",
|
|
|
- "count"));
|
|
|
-
|
|
|
- List<Object> latestDataList = Lists.newArrayList();
|
|
|
- for (KeyValuePair<String, Long> keyValuePair : latestGlobalOnLineDataList) {
|
|
|
- latestDataList.add(keyValuePair.toJsonObject("name", "value"));
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, Object> ret = Maps.newHashMap();
|
|
|
- ret.put("globalData", globalData);
|
|
|
- ret.put("schoolDataList", schoolDataList);
|
|
|
- ret.put("latestDataList", latestDataList);
|
|
|
-
|
|
|
- return new ResponseEntity<Map<String, Object>>(ret, HttpStatus.OK);
|
|
|
- }
|
|
|
-}
|