浏览代码

工作报告统计接口的优化

zhangjq 1 年之前
父节点
当前提交
213441c6b8

+ 1 - 1
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/controller/admin/report/vo/statistics/ReportFillSituationVO.java

@@ -10,7 +10,7 @@ public class ReportFillSituationVO {
     private String date;
 
     @Schema(description = "工作报告")
-    private ReportDO report;
+    private Long reportId;
 
     @Schema(description = "是否工作日")
     private Integer isworkday;

+ 22 - 8
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/service/report/ReportServiceImpl.java

@@ -170,9 +170,8 @@ public class ReportServiceImpl implements ReportService {
      */
     @Override
     public PageResult<ReportStatisticRespVO> getReportStatistics(ReportStatisticReqDTO reportStatisticReqDTO) {
-
         //工作日/周map 2024/2 -> value
-        Map<String, Map<String, List<WorkdayDO>>> allWorkDayOrWeekMap = workdayService.getReportWorkMap(reportStatisticReqDTO.getYear(), reportStatisticReqDTO.getMonth(), reportStatisticReqDTO.getReportType());
+        LinkedHashMap<String, LinkedHashMap<String, List<WorkdayDO>>> allWorkDayOrWeekMap = workdayService.getReportWorkMap(reportStatisticReqDTO.getYear(), reportStatisticReqDTO.getMonth(), reportStatisticReqDTO.getReportType());
 
         //部门id及子部门id
         Set<String> deptIds = null;
@@ -183,15 +182,23 @@ public class ReportServiceImpl implements ReportService {
         }
 
         //统计考勤请假数据
-        String reportType = reportStatisticReqDTO.getReportType();
         AttendanceSheetQueryDTO attendanceSheetListReq = new AttendanceSheetQueryDTO();
         attendanceSheetListReq.setDeptIdList(deptIds);
         attendanceSheetListReq.setUserId(attendanceSheetListReq.getUserId());
         LocalDateTime[] dateTimeRange = new LocalDateTime[]{getStartDateTime(reportStatisticReqDTO.getYear(), reportStatisticReqDTO.getMonth()), getEndDateTime(reportStatisticReqDTO.getYear(), reportStatisticReqDTO.getMonth())};
         attendanceSheetListReq.setAttendanceDate(dateTimeRange);
         List<StatisticAttendanceSheetData> statisticAttendanceSheetData = attendanceSheetService.statisticAttendanceData(attendanceSheetListReq, reportStatisticReqDTO.getReportType());
-        Map<String, Map<String, List<StatisticAttendanceSheetData>>> allAttendanceStatisticMap = statisticAttendanceSheetData.stream().collect(Collectors.groupingBy(c -> c.getUserId() + "/" + c.getYear() + "/" + c.getMonth(),
-                Collectors.groupingBy(c -> "daily".equals(reportType) ? c.getAttendanceDate().toString() : c.getWeek().toString()))); //考勤统计map 111/2024/2 -> value
+        Map<String, Map<String, List<StatisticAttendanceSheetData>>> allAttendanceStatisticMap = new HashMap<>();
+        if("daily".equals(reportStatisticReqDTO.getReportType())){
+            allAttendanceStatisticMap = statisticAttendanceSheetData.stream().collect(
+                    Collectors.groupingBy(c -> c.getUserId() + "/" + c.getAttendanceDate().getYear() + "/" + c.getAttendanceDate().getMonthValue(),
+                            Collectors.groupingBy(c->c.getAttendanceDate().toLocalDate().toString()))); //考勤统计map 111/2024/2 -> value
+
+        }else{
+            allAttendanceStatisticMap = statisticAttendanceSheetData.stream().collect(
+                    Collectors.groupingBy(c -> c.getUserId() + "/" + c.getYear() + "/" + c.getMonth(),
+                            Collectors.groupingBy(c->c.getWeek().toString()))); //考勤统计map 111/2024/2 -> value
+        }
 
         //获取工作报告
         ReportReqDTO reportReqDTO = new ReportReqDTO();
@@ -200,8 +207,15 @@ public class ReportServiceImpl implements ReportService {
         reportReqDTO.setReportMonth(reportStatisticReqDTO.getMonth());
         reportReqDTO.setUserId(reportStatisticReqDTO.getUserId());
         List<ReportDO> reportList = reportMapper.selectList(reportReqDTO, deptIds);
-        Map<String,  Map<String, List<ReportDO>>> allReportMap = reportList.stream().collect(Collectors.groupingBy(c -> c.getReportYear() + "/" + c.getReportMonth() + "/" + c.getDeptId() + "/" + c.getUserId(),
-                Collectors.groupingBy(c -> "daily".equals(reportType) ? c.getReportStartDate().toString() : c.getReportWeek().toString())));
+        Map<String,  Map<String, List<ReportDO>>> allReportMap = new HashMap<>();
+        if("daily".equals(reportStatisticReqDTO.getReportType())){
+            allReportMap = reportList.stream().collect(Collectors.groupingBy(c -> c.getReportStartDate().getYear() + "/" +c.getReportStartDate().getMonthValue() + "/" + c.getDeptId() + "/" + c.getUserId(),
+                    Collectors.groupingBy(c-> c.getReportStartDate().toLocalDate().toString(),Collectors.toList())));
+        }else{
+            allReportMap = reportList.stream().collect(Collectors.groupingBy(c -> c.getReportYear() + "/" + c.getReportMonth() + "/" + c.getDeptId() + "/" + c.getUserId(),
+                    Collectors.groupingBy(c-> c.getReportWeek().toString(),Collectors.toList())));
+        }
+
 
         List<String> userIds = reportList.stream().map(ReportDO::getUserId).distinct().collect(Collectors.toList());
         Map<String, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
@@ -229,7 +243,7 @@ public class ReportServiceImpl implements ReportService {
                 ReportFillSituationVO reportUnit = new ReportFillSituationVO();
                 //工作报告
                 List<ReportDO> reports = reportMap.get(dateUnit);
-                reportUnit.setReport(CollectionUtils.isNotEmpty(reports) ? reports.get(0) : null);
+                reportUnit.setReportId(CollectionUtils.isNotEmpty(reports) ? reports.get(0).getId() : null);
                 reportFillUnitList.add(reportUnit);
                 reportUnit.setDate(dateUnit);
 

+ 2 - 4
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/service/workday/WorkdayService.java

@@ -7,9 +7,7 @@ import com.zjugis.module.adm.controller.admin.workday.vo.WorkdayUpdateReqVO;
 import com.zjugis.module.adm.dal.dataobject.workday.WorkdayDO;
 
 import javax.validation.Valid;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 行政管理_工作日 Service 接口
@@ -73,7 +71,7 @@ public interface WorkdayService {
      * @param reportType 报告类型:daily日报 week周报
      * @return
      */
-    Map<String, Map<String, List<WorkdayDO>>> getReportWorkMap(Short year,Short month,String reportType) ;
+    LinkedHashMap<String, LinkedHashMap<String, List<WorkdayDO>>> getReportWorkMap(Short year, Short month, String reportType) ;
 
 
 }

+ 9 - 2
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/service/workday/WorkdayServiceImpl.java

@@ -68,12 +68,19 @@ public class WorkdayServiceImpl implements WorkdayService {
      * @param reportType 报告类型:daily日报 week周报
      * @return
      */
-    public Map<String, Map<String, List<WorkdayDO>>> getReportWorkMap(Short year, Short month, String reportType) {
+    public  LinkedHashMap<String, LinkedHashMap<String, List<WorkdayDO>>> getReportWorkMap(Short year, Short month, String reportType) {
         WorkdayListReqVO workdayListReqVO = new WorkdayListReqVO();
         workdayListReqVO.setYear(year);
         workdayListReqVO.setMonth(month);
         List<WorkdayDO> workdayList = this.getWorkdayList(workdayListReqVO);
-        Map<String, Map<String, List<WorkdayDO>>> workdayMap = workdayList.stream().collect(Collectors.groupingBy(c -> c.getYear() + "/" + c.getMonth(), Collectors.groupingBy(c -> "daily".equals(reportType) ? c.getDateDay().toString() : c.getWeek().toString())));
+        LinkedHashMap<String, LinkedHashMap<String, List<WorkdayDO>>> workdayMap = new LinkedHashMap<>();
+        if("daily".equals(reportType)){
+            workdayMap = workdayList.stream().collect(Collectors.groupingBy(c -> c.getDateDay().getYear() + "/" + c.getDateDay().getMonthValue(),LinkedHashMap::new,
+                    Collectors.groupingBy(c ->  c.getDateDay().toLocalDate().toString(),LinkedHashMap::new,Collectors.toList())));
+        }else{
+            workdayMap = workdayList.stream().collect(Collectors.groupingBy(c -> c.getYear() + "/" + c.getMonth(),LinkedHashMap::new,
+                    Collectors.groupingBy(c ->  c.getWeek().toString(), LinkedHashMap::new,Collectors.toList())));
+        }
         return workdayMap;
     }