Commit 6f68ee6f13abc0f550229e4481fc0d6f2fe5d33b

Authored by guzijian
1 parent e2edbcbe

feat: 新增获取签到报表接口给人事系统提供

Bsth-admin/src/main/java/com/ruoyi/common/global/Result.java
... ... @@ -81,7 +81,7 @@ public class Result<T extends Object> {
81 81 Result r = new Result();
82 82 r.setSuccess(false);
83 83 r.setCode(code.getCode());
84   - r.setMsg("失败");
  84 + r.setMsg(msg);
85 85 return r;
86 86 }
87 87  
... ...
Bsth-admin/src/main/java/com/ruoyi/controller/ReportController.java
... ... @@ -16,6 +16,7 @@ import org.springframework.validation.annotation.Validated;
16 16 import org.springframework.web.bind.annotation.*;
17 17  
18 18 import javax.annotation.Resource;
  19 +import javax.servlet.http.HttpServletRequest;
19 20 import javax.servlet.http.HttpServletResponse;
20 21 import java.util.List;
21 22  
... ... @@ -65,14 +66,14 @@ public class ReportController {
65 66  
66 67 @ApiOperation("告警通知")
67 68 @GetMapping("/alarm/notice")
68   - public Result<?> getAlarmNotice(@RequestParam(value = "type",required = false) Integer type){
  69 + public Result<?> getAlarmNotice(@RequestParam(value = "type", required = false) Integer type) {
69 70 return Result.OK(reportService.getAlarmNoticeByType(type));
70 71 }
71 72  
72 73  
73 74 @ApiOperation("确认通知")
74 75 @PostMapping("/sureNotice")
75   - public Result<?> sureNotice(@Validated @RequestBody SysNotice notice){
  76 + public Result<?> sureNotice(@Validated @RequestBody SysNotice notice) {
76 77 return Result.OK(reportService.sureNotice(notice));
77 78 }
78 79  
... ... @@ -83,4 +84,11 @@ public class ReportController {
83 84 ExcelUtil<ReportErrorResponseVo> util = new ExcelUtil<ReportErrorResponseVo>(ReportErrorResponseVo.class);
84 85 util.exportEasyExcel(response, list, "异常报表");
85 86 }
  87 +
  88 +
  89 + @ApiOperation("提供给人事用接口(获取当月所有签到记录)")
  90 + @GetMapping("/list/{month}")
  91 + public Result<?> listReportMonth(@PathVariable("month") String month, HttpServletRequest request) {
  92 + return reportService.listReportMonth(month, request);
  93 + }
86 94 }
... ...
Bsth-admin/src/main/java/com/ruoyi/pojo/response/ExportReportViewResponseVo.java
... ... @@ -25,13 +25,17 @@ import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
25 25 @HeadRowHeight(25)
26 26 @HeadFontStyle(fontHeightInPoints = 10,fontName = "黑体")
27 27 public class ExportReportViewResponseVo {
  28 + @ApiModelProperty("工号")
28 29 @ExcelProperty(value = "工号")
29 30 private String jobCode;
  31 + @ApiModelProperty("姓名")
30 32 @ExcelProperty(value = "姓名")
31 33 private String name;
  34 + @ApiModelProperty("工种")
32 35 @ExcelProperty(value = "工种")
33 36 private String posts;
34 37  
  38 + @ApiModelProperty("线路")
35 39 @ExcelProperty(value = "线路")
36 40 private String lineName;
37 41  
... ... @@ -40,76 +44,113 @@ public class ExportReportViewResponseVo {
40 44 @ColumnWidth(12)
41 45 private String fleetName;
42 46  
  47 + @ApiModelProperty("车辆自编号")
43 48 @ExcelProperty(value = "车辆自编号")
44 49 @ColumnWidth(12)
45 50 private String nbbm;
46 51  
  52 + @ApiModelProperty("计划签到时间")
47 53 @ExcelProperty(value = "计划签到时间")
48 54 @ColumnWidth(20)
49 55 private Date planSignInTime;
  56 +
  57 + @ApiModelProperty("实际签到时间")
50 58 @ExcelProperty(value = "实际签到时间")
51 59 @ColumnWidth(20)
52 60 private Date actualSignInTime;
  61 +
  62 + @ApiModelProperty("是否酒精测试")
53 63 @ExcelProperty(value = "是否酒精测试")
54 64 @ColumnWidth(12)
55 65 private String alcoholStringIn;
  66 +
  67 + @ApiModelProperty("酒精测试含量")
56 68 @ExcelProperty(value = "酒精测试含量")
57 69 @ColumnWidth(12)
58 70 private BigDecimal alcoholIntakeIn;
  71 +
  72 + @ApiModelProperty("签到结果")
59 73 @ExcelProperty(value = "签到结果")
60 74 @ColumnWidth(12)
61 75 private String signInResultString;
  76 + @ApiModelProperty("计划签退时间")
62 77 @ExcelProperty(value = "计划签退时间")
63 78 @ColumnWidth(20)
64 79 private Date planSignOutTime;
  80 + @ApiModelProperty("实际签退时间")
65 81 @ExcelProperty(value = "实际签退时间")
66 82 @ColumnWidth(20)
67 83 private Date actualSignOutTime;
  84 +
  85 + @ApiModelProperty("是否酒精测试")
68 86 @ExcelProperty(value = "是否酒精测试")
69 87 @ColumnWidth(12)
70 88 private String alcoholStringOut;
  89 +
  90 + @ApiModelProperty("酒精测试含量")
71 91 @ExcelProperty(value = "酒精测试含量")
72 92 @ColumnWidth(12)
73 93 private BigDecimal alcoholIntakeOut;
  94 +
  95 + @ApiModelProperty("签退结果")
74 96 @ExcelProperty(value = "签退结果")
75 97 private String signOutResultString;
76 98  
  99 + @ApiModelProperty("有无分班")
77 100 @ExcelProperty(value = "有无分班")
78 101 private String haveSecondFlagString;
79 102  
  103 + @ApiModelProperty("分班计划签到时间")
80 104 @ExcelProperty(value = "分班计划签到时间")
81 105 @ColumnWidth(20)
82 106 private Date secondPlanSignInTime;
  107 +
  108 + @ApiModelProperty("分班实际签到时间")
83 109 @ExcelProperty(value = "分班实际签到时间")
84 110 @ColumnWidth(20)
85 111 private Date secondActualSignInTime;
86 112  
  113 + @ApiModelProperty("是否酒精测试")
87 114 @ExcelProperty(value = "是否酒精测试")
88 115 @ColumnWidth(12)
89 116 private String secondAlcoholStringIn;
  117 +
  118 + @ApiModelProperty("酒精测试含量")
90 119 @ExcelProperty(value = "酒精测试含量")
91 120 @ColumnWidth(12)
92 121 private BigDecimal secondAlcoholIntakeIn;
  122 +
  123 + @ApiModelProperty("分班签到结果")
93 124 @ExcelProperty(value = "分班签到结果")
94 125 @ColumnWidth(12)
95 126 private String secondSignInResultString;
  127 +
  128 + @ApiModelProperty("分班计划签退时间")
96 129 @ExcelProperty(value = "分班计划签退时间")
97 130 @ColumnWidth(20)
98 131 private Date secondPlanSignOutTime;
  132 +
  133 + @ApiModelProperty("分班实际签退时间")
99 134 @ExcelProperty(value = "分班实际签退时间")
100 135 @ColumnWidth(20)
101 136 private Date secondActualSignOutTime;
102 137  
  138 + @ApiModelProperty("是否酒精测试")
103 139 @ExcelProperty(value = "是否酒精测试")
104 140 @ColumnWidth(12)
105 141 private String secondAlcoholStringOut;
  142 +
  143 + @ApiModelProperty("酒精测试含量")
106 144 @ExcelProperty(value = "酒精测试含量")
107 145 @ColumnWidth(12)
108 146 private BigDecimal secondAlcoholIntakeOut;
  147 +
  148 + @ApiModelProperty("分班签退结果")
109 149 @ExcelProperty(value = "分班签退结果")
110 150 @ColumnWidth(12)
111 151 private String secondSignOutResultString;
112 152  
  153 + @ApiModelProperty("排班日期")
113 154 @ExcelProperty(value = "排班日期")
114 155 @ColumnWidth(20)
115 156 private Date scheduleDate;
... ...
Bsth-admin/src/main/java/com/ruoyi/service/ReportService.java
1 1 package com.ruoyi.service;
2 2  
  3 +import cn.hutool.core.collection.CollectionUtil;
  4 +import com.ruoyi.common.global.Result;
  5 +import com.ruoyi.common.global.ResultCode;
3 6 import com.ruoyi.common.utils.SecurityUtils;
4 7 import com.ruoyi.driver.mapper.DriverMapper;
5 8 import com.ruoyi.driver.mapper.DriverSchedulingMapper;
... ... @@ -11,19 +14,24 @@ import com.ruoyi.pojo.request.ReportErrorRequestVo;
11 14 import com.ruoyi.pojo.response.*;
12 15 import com.ruoyi.system.domain.SysNotice;
13 16 import com.ruoyi.system.service.ISysNoticeService;
  17 +import com.ruoyi.utils.ConstDateUtil;
14 18 import org.springframework.beans.BeanUtils;
15 19 import org.springframework.beans.factory.annotation.Autowired;
16 20 import org.springframework.stereotype.Service;
17 21  
18 22 import javax.annotation.Resource;
  23 +import javax.servlet.http.HttpServletRequest;
19 24 import javax.servlet.http.HttpServletResponse;
20 25 import javax.validation.constraints.NotBlank;
21 26 import java.time.LocalDate;
22 27 import java.time.YearMonth;
23 28 import java.time.format.DateTimeFormatter;
24 29 import java.util.*;
  30 +import java.util.regex.Matcher;
  31 +import java.util.regex.Pattern;
25 32 import java.util.stream.Collectors;
26 33  
  34 +import static com.ruoyi.common.ApiProperties.PERSONNEL_API_KEY;
27 35 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
28 36 import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
29 37 import static com.ruoyi.common.ReportProperties.DAY;
... ... @@ -86,16 +94,16 @@ public class ReportService {
86 94 public List<ExportReportViewResponseVo> exportReportList(ReportViewRequestVo requestVo, HttpServletResponse response) {
87 95 // 处理天
88 96 if (requestVo.getExportFlag().equals(DAY)) {
89   - return getDayReportTableResponseVo(requestVo.getDate(), response);
  97 + return getDayReportTableResponseVo(requestVo.getDate());
90 98 }
91 99 // 处理月
92 100 else if (requestVo.getExportFlag().equals(MONTH)) {
93   - return getMonthReportTableResponseVo(requestVo, response);
  101 + return getMonthReportTableResponseVo(requestVo);
94 102 }
95 103 return null;
96 104 }
97 105  
98   - private List<ExportReportViewResponseVo> getDayReportTableResponseVo(String date, HttpServletResponse response) {
  106 + private List<ExportReportViewResponseVo> getDayReportTableResponseVo(String date) {
99 107 List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date, null, null, null);
100 108 Map<String, List<DriverScheduling>> resultMap = new HashMap<>(800);
101 109 List<ExportReportViewResponseVo> vo = new ArrayList<>(800);
... ... @@ -122,11 +130,11 @@ public class ReportService {
122 130 }
123 131 }
124 132  
125   - private List<ExportReportViewResponseVo> getMonthReportTableResponseVo(ReportViewRequestVo requestVo, HttpServletResponse response) {
  133 + private List<ExportReportViewResponseVo> getMonthReportTableResponseVo(ReportViewRequestVo requestVo) {
126 134 List<ExportReportViewResponseVo> responseVos = new ArrayList<>(10000);
127 135 List<String> days = getNowMonthAllDay(requestVo.getDate());
128 136 for (String day : days) {
129   - List<ExportReportViewResponseVo> dayReportTableResponseVo = getDayReportTableResponseVo(day, response);
  137 + List<ExportReportViewResponseVo> dayReportTableResponseVo = getDayReportTableResponseVo(day);
130 138 responseVos.addAll(dayReportTableResponseVo);
131 139 }
132 140 return responseVos;
... ... @@ -197,7 +205,7 @@ public class ReportService {
197 205  
198 206 public SysNotice getAlarmNoticeByType(Integer type) {
199 207 String username = SecurityUtils.getUsername();
200   - return noticeService.getAlarmNotice(username,type);
  208 + return noticeService.getAlarmNotice(username, type);
201 209 }
202 210  
203 211 public Object sureNotice(SysNotice notice) {
... ... @@ -206,4 +214,45 @@ public class ReportService {
206 214 noticeService.updateNotice(notice);
207 215 return null;
208 216 }
  217 +
  218 + public Result listReportMonth(String month, HttpServletRequest request) {
  219 + boolean validateDate = validateDate(month);
  220 + String header = request.getHeader("X-TOKEN-AUTHORIZATION");
  221 + if (!PERSONNEL_API_KEY.equals(header)) {
  222 + return Result.ERROR(ResultCode.CODE_401, "X-TOKEN-AUTHORIZATION value error");
  223 + }
  224 + if (!validateDate) {
  225 + return Result.ERROR(ResultCode.CODE_400, "Parameter format error");
  226 + }
  227 + ReportViewRequestVo vo = new ReportViewRequestVo();
  228 + vo.setDate(month + "-01");
  229 + List<ExportReportViewResponseVo> responseVoList = getMonthReportTableResponseVo(vo);
  230 + Map<String, List<ExportReportViewResponseVo>> map = new HashMap<>(responseVoList.size() / 30);
  231 + handleResponseByDay(responseVoList, map, vo.getDate());
  232 + return Result.OK(map);
  233 + }
  234 +
  235 + private void handleResponseByDay(List<ExportReportViewResponseVo> responseVoList, Map<String, List<ExportReportViewResponseVo>> map, @NotBlank String date) {
  236 + for (ExportReportViewResponseVo vo : responseVoList) {
  237 + String key = ConstDateUtil.formatDate("yyyy-MM-dd", vo.getScheduleDate());
  238 + List<ExportReportViewResponseVo> vos = map.get(key);
  239 + if (CollectionUtil.isEmpty(vos)){
  240 + map.put(key,new ArrayList<>(Arrays.asList(vo)));
  241 + }else {
  242 + map.get(key).add(vo);
  243 + }
  244 + }
  245 + }
  246 +
  247 + /**
  248 + * yyyy-MM 格式的正则表达式
  249 + */
  250 + public static boolean validateDate(String input) {
  251 + String regex = "^(\\d{4})-(0[1-9]|1[0-2])$";
  252 +
  253 + Pattern pattern = Pattern.compile(regex);
  254 + Matcher matcher = pattern.matcher(input);
  255 +
  256 + return matcher.matches();
  257 + }
209 258 }
... ...
Bsth-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
... ... @@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
111 111 // 过滤请求
112 112 .authorizeRequests()
113 113 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
114   - .antMatchers("/system/dict/data/**","/app/version/check/**","/app/checkDeviceHeart","/app/download","/driver/**","/in/**","/eexception/**","/equipment/**","/report/**","/login", "/register", "/captchaImage").permitAll()
  114 + .antMatchers("/report/list/**","/system/dict/data/**","/app/version/check/**","/app/checkDeviceHeart","/app/download","/driver/**","/in/**","/eexception/**","/equipment/**","/report/**","/login", "/register", "/captchaImage").permitAll()
115 115 // 静态资源,可匿名访问
116 116 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
117 117 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
... ...