瀏覽代碼

时间统计测试

wangliang 2 年之前
父節點
當前提交
0312223f54

+ 13 - 5
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeReportController.java

@@ -1,14 +1,10 @@
 package com.qmth.themis.admin.api;
 
-import cn.hutool.core.date.DateUtil;
 import com.qmth.themis.business.bean.admin.InvigilateListPatrolReportBean;
-import com.qmth.themis.business.bean.result.TimeScaleDataResult;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.service.TIeReportService;
-import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.ServletUtil;
-import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
@@ -23,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
-import java.util.*;
+import java.util.Objects;
 
 /**
  * 监考报表
@@ -242,6 +238,18 @@ public class TIeReportController {
         return ResultUtil.ok(reportService.warnTrend());
     }
 
+//    @ApiOperation(value = "考情监控-在线人数/预警时间趋势test")
+//    @RequestMapping(value = "/examination_monitor/warn_trend_test", method = RequestMethod.POST)
+//    @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
+//    public void warnTrendTest() {
+//        List<TimeScaleDataResult> timeScaleDataResultList = reportService.warnTrend();
+//        try {
+//            ExportUtils.exportEXCEL("在线人数/预警时间趋势", TimeScaleDataResult.class, timeScaleDataResultList, ServletUtil.getResponse());
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//    }
+
     @ApiOperation(value = "考情监控-预警消息")
     @RequestMapping(value = "/examination_monitor/warn_msg", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})

+ 4 - 0
themis-business/src/main/java/com/qmth/themis/business/bean/result/TimeScaleDataResult.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.business.bean.result;
 
+import com.qmth.themis.business.excel.ExcelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -14,12 +15,15 @@ import java.io.Serializable;
 public class TimeScaleDataResult implements Serializable {
 
     @ApiModelProperty(value = "日期格式=小时:分")
+    @ExcelProperty(name = "日期格式=小时:分", width = 30, index = 1)
     private String hour;
 
     @ApiModelProperty(value = "在线人数")
+    @ExcelProperty(name = "在线人数", width = 30, index = 2)
     private Integer onlineCount = 0;
 
     @ApiModelProperty(value = "预警人数")
+    @ExcelProperty(name = "预警人数", width = 30, index = 3)
     private Integer warnCount = 0;
 
     public String getHour() {

+ 6 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TIeReportServiceImpl.java

@@ -381,12 +381,16 @@ public class TIeReportServiceImpl implements TIeReportService {
         return tOeExamRecordMapper.getWarnDistribution(tbUser.getOrgId());
     }
 
+    @Resource
+    TBUserService tbUserService;
+
     /**
      * 考情监控-预警时间趋势
      */
     @Override
     public List<TimeScaleDataResult> warnTrend() {
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+//        TBUser tbUser = tbUserService.getById(321565832042266624L);//测试用
         SysConfig onlineWarnScaleSize = cacheService.addSysConfigCache(SystemConstant.ONLINE_WARN_SCALESIZE);
         Optional.ofNullable(onlineWarnScaleSize).orElseThrow(() -> new BusinessException("在线人数/预警时间趋势统计格数未配置"));
 
@@ -394,6 +398,7 @@ public class TIeReportServiceImpl implements TIeReportService {
         Optional.ofNullable(onlineWarnInterval).orElseThrow(() -> new BusinessException("在线人数/预警时间趋势统计间隔未配置"));
 
         int scaleSize = Integer.parseInt(onlineWarnScaleSize.getConfigValue()), interval = Integer.parseInt(onlineWarnInterval.getConfigValue());
+//        scaleSize = 90;//测试用
         List<Integer> timeSize = new ArrayList<>(scaleSize);
         for (int i = interval; i <= scaleSize * interval; i = i + interval) {
             timeSize.add(i);
@@ -404,6 +409,7 @@ public class TIeReportServiceImpl implements TIeReportService {
         LocalDateTime minusMinutes = now.minusMinutes(scaleSize);
 
         String currentDate = DateUtil.format(date, Constants.DEFAULT_DATE_PATTERN);
+//        currentDate = "2022-11-06 16:31:00";//测试用
         Map<String, String> map = this.getTimeScale(timeSize, currentDate);
 
         Long longtimestamp = now.toInstant(ZoneOffset.ofHours(8)).toEpochMilli();