Commit 908d8513cfd0d77c2ed7c52d61f6e7475bedc647
1 parent
c7d6a2a7
fix: 修改签到报表接口
Showing
4 changed files
with
69 additions
and
2 deletions
ruoyi-admin/src/main/java/com/ruoyi/controller/ReportController.java
| ... | ... | @@ -33,6 +33,12 @@ public class ReportController { |
| 33 | 33 | @ApiOperation("签到报表集合查询") |
| 34 | 34 | @GetMapping("/list") |
| 35 | 35 | public AjaxResult getList(@ApiParam @ModelAttribute ReportViewRequestVo requestVo) { |
| 36 | + return AjaxResult.success(reportService.handlerList(reportService.getReportScrollViewTable(requestVo))); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @ApiOperation("签到报表集合查询") | |
| 40 | + @GetMapping("/bigView") | |
| 41 | + public AjaxResult bigView(@ApiParam @ModelAttribute ReportViewRequestVo requestVo) { | |
| 36 | 42 | return AjaxResult.success(reportService.getReportScrollViewTable(requestVo)); |
| 37 | 43 | } |
| 38 | 44 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ReportSignInResponseVo.java
0 → 100644
| 1 | +package com.ruoyi.pojo.response; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +import java.util.ArrayList; | |
| 6 | +import java.util.List; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * @author 20412 | |
| 10 | + */ | |
| 11 | +@Data | |
| 12 | +public class ReportSignInResponseVo extends ReportViewResponseVo{ | |
| 13 | + /** | |
| 14 | + * 签到次数 | |
| 15 | + */ | |
| 16 | + Integer count; | |
| 17 | + /** | |
| 18 | + * 子集 | |
| 19 | + */ | |
| 20 | + List<ReportSignInResponseVo> children; | |
| 21 | + public ReportSignInResponseVo(ReportViewResponseVo vo){ | |
| 22 | + this.count = 1; | |
| 23 | + this.children = new ArrayList<>(); | |
| 24 | + this.setCreateTime(vo.getCreateTime()); | |
| 25 | + this.setId(vo.getId()); | |
| 26 | + this.setImage(vo.getImage()); | |
| 27 | + this.setAlcoholFlag(vo.getAlcoholFlag()); | |
| 28 | + this.setType(vo.getType()); | |
| 29 | + this.setJobCode(vo.getJobCode()); | |
| 30 | + this.setAlcoholIntake(vo.getAlcoholIntake()); | |
| 31 | + this.setName(vo.getName()); | |
| 32 | + this.setRemark(vo.getRemark()); | |
| 33 | + this.setStatus(vo.getStatus()); | |
| 34 | + this.setSingnIn(vo.getSingnIn()); | |
| 35 | + } | |
| 36 | + public ReportSignInResponseVo(){ | |
| 37 | + | |
| 38 | + } | |
| 39 | +} | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ReportViewResponseVo.java
| ... | ... | @@ -46,8 +46,8 @@ public class ReportViewResponseVo { |
| 46 | 46 | |
| 47 | 47 | @ExcelProperty(value = "签到时间") |
| 48 | 48 | @ApiModelProperty("签到时间") |
| 49 | - @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") | |
| 50 | - @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") | |
| 49 | + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
| 50 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
| 51 | 51 | private Date createTime; |
| 52 | 52 | |
| 53 | 53 | @ExcelProperty(value = "签到状态", converter = SignInStatusConverter.class) | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/service/ReportService.java
| ... | ... | @@ -9,10 +9,12 @@ import com.ruoyi.in.mapper.SignInMapper; |
| 9 | 9 | import com.ruoyi.pojo.request.ReportViewRequestVo; |
| 10 | 10 | import com.ruoyi.pojo.request.ReportErrorRequestVo; |
| 11 | 11 | import com.ruoyi.pojo.response.ReportErrorResponseVo; |
| 12 | +import com.ruoyi.pojo.response.ReportSignInResponseVo; | |
| 12 | 13 | import com.ruoyi.pojo.response.ReportViewResponseVo; |
| 13 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | 15 | import org.springframework.stereotype.Service; |
| 15 | 16 | |
| 17 | +import java.text.SimpleDateFormat; | |
| 16 | 18 | import java.util.*; |
| 17 | 19 | import java.util.stream.Collectors; |
| 18 | 20 | |
| ... | ... | @@ -105,4 +107,24 @@ public class ReportService { |
| 105 | 107 | responses.add(vo); |
| 106 | 108 | }); |
| 107 | 109 | } |
| 110 | + | |
| 111 | + public List<ReportSignInResponseVo> handlerList(List<ReportViewResponseVo> reportScrollViewTable) { | |
| 112 | + Map<String, ReportSignInResponseVo> responseMapVo = new HashMap<>(30); | |
| 113 | + for (ReportViewResponseVo originVo : reportScrollViewTable) { | |
| 114 | + String dayKey = getDateDay(originVo.getCreateTime()) + originVo.getJobCode(); | |
| 115 | + if (Objects.isNull(responseMapVo.get(dayKey))) { | |
| 116 | + responseMapVo.put(dayKey, new ReportSignInResponseVo(originVo)); | |
| 117 | + } else { | |
| 118 | + ReportSignInResponseVo responseVo = responseMapVo.get(dayKey); | |
| 119 | + responseVo.getChildren().add(new ReportSignInResponseVo(originVo)); | |
| 120 | + responseVo.setCount(responseVo.getCount() + 1); | |
| 121 | + } | |
| 122 | + } | |
| 123 | + return new ArrayList<>(responseMapVo.values()); | |
| 124 | + } | |
| 125 | + | |
| 126 | + public String getDateDay(Date createTime) { | |
| 127 | + SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd"); | |
| 128 | + return simple.format(createTime); | |
| 129 | + } | |
| 108 | 130 | } | ... | ... |