SignReportController.java
4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.ruoyi.controller.app;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.ResponseResult;
import com.ruoyi.domain.dss.app.vo.SignReportGroupByVo;
import com.ruoyi.domain.dss.app.vo.SignReportVo;
import com.ruoyi.service.SignReportServer;
import com.ruoyi.utils.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Slf4j
@RestController
@RequestMapping("/app/sign/report")
@Api(tags = "【App对接】签到对接")
public class SignReportController extends BaseController {
@Autowired
private SignReportServer signReportServer;
@ApiOperation("签到数据统计(设备状态、检查人数、异常人数、酒驾人数);(dateStr格式为yyyy-MM-dd)")
@ApiParam(name = "dateStr", value = "查询日期(格式为yyyy-MM-dd)", required = true, example = "2024-12-11")
@GetMapping("/equipment/people/num/{dateStr}")
public ResponseResult<SignReportVo> equipmentAndPeopleNumStatistics(@PathVariable String dateStr) {
SignReportVo vo = signReportServer.querySignReportVo(dateStr);
return ResponseResult.success(vo);
}
@ApiOperation("签到每天数据统计(酒驾人数、早签人数、晚签人数、正常签到人数、日期(格式为yyyy-MM-dd));(dateStr格式为yyyy-MM,如2024-03)")
@ApiParam(name = "dateStr", value = "查询日期(格式为yyyy-MM)", required = true, example = "2024-12")
@GetMapping("/sign/report/group/{dateStr}")
public ResponseResult<List<SignReportGroupByVo>> signReportGroupByDateStr(@PathVariable String dateStr) {
List<SignReportGroupByVo> vos = null;
try {
vos = signReportServer.querySignReportGroupByDateStrVo(dateStr);
return ResponseResult.success(vos);
} catch (ParseException e) {
log.error("获取每天签到数据异常", e);
return ResponseResult.error();
}
}
@ApiOperation("签到每月数据统计(酒驾人数、早签人数、晚签人数、正常签到人数、日期(格式为yyyy-MM-dd));(startDateStr和endDateStr格式为yyyy-MM,如2024-03,没有时间请传0,传0后系统会获取当前时间作为endDateStr,向前推12个月作为startDateStr;startDateStr和endDateStr最多间隔1000个月)")
@ApiParam(name = "dateStr", value = "查询日期(格式为yyyy-MM)", required = true, example = "2024-12")
@GetMapping("/sign/report/group/month/{startDateStr}/{endDateStr}")
public ResponseResult<List<SignReportGroupByVo>> signReportGroupMonthByDateStr(@PathVariable String startDateStr, @PathVariable String endDateStr) throws ParseException {
if (StringUtils.equals("0", endDateStr)) {
endDateStr = DateUtil.YYYY_MM_LINK.format(new Date());
}
if (org.apache.commons.lang3.StringUtils.equals("0", startDateStr)) {
startDateStr = DateUtil.YYYY_MM_LINK.format(DateUtils.addMonths(new Date(), -12));
}
Set<String> dateStrs = new HashSet<>();
Date date = DateUtil.YYYY_MM_DD_LINK.parse(startDateStr + "-01");
for (int i = 0; i < 1000; i++) {
String dateStr = DateUtil.YYYY_MM_LINK.format(DateUtils.addMonths(date, i));
dateStrs.add(dateStr);
if (StringUtils.equals(dateStr, endDateStr)) {
break;
}
}
List<SignReportGroupByVo> vos = signReportServer.querySignReportGroupMonthByDateStr(dateStrs);
return ResponseResult.success(vos);
}
}