Bläddra i källkod

工作报告统计接口的修改

zhangjq 1 år sedan
förälder
incheckning
73d0af1de5

+ 9 - 0
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/constants/DictConstants.java

@@ -0,0 +1,9 @@
+package com.zjugis.module.adm.constants;
+
+/**
+ * @Author:zjq
+ * @Date:2024-02-23
+ */
+public class DictConstants {
+    public static final String WF_LEAVE_TYPE = "WF_LEAVE_TYPE";
+}

+ 2 - 4
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/controller/admin/report/vo/statistics/ReportStatisticRespVO.java

@@ -1,6 +1,5 @@
 package com.zjugis.module.adm.controller.admin.report.vo.statistics;
 
-import com.zjugis.module.adm.controller.admin.workday.vo.WorkdayBaseVO;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -21,12 +20,11 @@ public class ReportStatisticRespVO {
     @Schema(description = "用户昵称")
     private String nickName;
 
-
     @Schema(description = "年份")
-    private Short reportYear;
+    private String reportYear;
 
     @Schema(description = "月份")
-    private Short reportMonth;
+    private String reportMonth;
 
     @Schema(description = "工作报告填写情况")
     private List<ReportFillSituationVO> reportFillSituation;

+ 0 - 22
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/convert/report/ReportStatisticConvert.java

@@ -1,22 +0,0 @@
-package com.zjugis.module.adm.convert.report;
-
-import com.zjugis.module.adm.controller.admin.report.vo.statistics.ReportFillSituationVO;
-import com.zjugis.module.adm.dal.dataobject.workday.WorkdayDO;
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-
-import java.util.List;
-
-/**
- * @Author:zjq
- * @Date:2024-02-20
- */
-@Mapper
-public interface ReportStatisticConvert {
-    ReportStatisticConvert INSTANCE = Mappers.getMapper(ReportStatisticConvert.class);
-
-
-    List<ReportFillSituationVO> convertList(List<WorkdayDO> list);
-
-    ReportFillSituationVO convert(WorkdayDO bean);
-}

+ 2 - 1
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/service/attendance/AttendanceSheetServiceImpl.java

@@ -7,6 +7,7 @@ import cn.hutool.core.date.LocalDateTimeUtil;
 import com.zjugis.framework.common.util.date.LocalDateTimeUtils;
 import com.zjugis.module.adm.api.attendance.dto.AttendanceSheetUpdateReqDTO;
 import com.zjugis.module.adm.api.attendance.dto.AttendanceTimeDto;
+import com.zjugis.module.adm.constants.DictConstants;
 import com.zjugis.module.adm.controller.admin.attendance.dto.AttendanceSheetQueryDTO;
 import com.zjugis.module.adm.controller.admin.attendance.vo.sheet.*;
 import com.zjugis.module.adm.convert.attendance.AttendanceSheetConvert;
@@ -190,7 +191,7 @@ public class AttendanceSheetServiceImpl implements AttendanceSheetService {
      * @return
      */
     public List<StatisticAttendanceSheetData>  statisticAttendanceData(AttendanceSheetQueryDTO listReqVO, String type) {
-        List<DictDataRespDTO> wfLeaveType = dictDataApi.getDictDataList("WF_LEAVE_TYPE").getData();//请假类型字典值
+        List<DictDataRespDTO> wfLeaveType = dictDataApi.getDictDataList(DictConstants.WF_LEAVE_TYPE).getData();//请假类型字典值
         List<Integer> wfLeaveTypeValue = wfLeaveType.stream().map(DictDataRespDTO::getValue).map(Integer::parseInt).collect(Collectors.toList());
         String wfLeaveTypeValueStr = wfLeaveTypeValue.stream()
                 .map(Object::toString)

+ 25 - 20
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/service/report/ReportServiceImpl.java

@@ -22,6 +22,7 @@ import com.zjugis.module.adm.service.reportcomment.ReportCommentService;
 import com.zjugis.module.adm.service.reportreceive.ReportReceiveService;
 import com.zjugis.module.adm.service.reportworkload.ReportWorkloadService;
 import com.zjugis.module.adm.service.workday.WorkdayService;
+import com.zjugis.module.adm.util.PageUtil;
 import com.zjugis.module.system.api.dept.DeptApi;
 import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
 import com.zjugis.module.system.api.user.AdminUserApi;
@@ -169,6 +170,7 @@ 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());
 
@@ -209,34 +211,30 @@ public class ReportServiceImpl implements ReportService {
         //返回结果
         List<ReportStatisticRespVO> resultList = new ArrayList<>();
         for (String key : allReportMap.keySet()) {
-            Map<String, List<ReportDO>> reportMap= allReportMap.get(key);
-
             String[] keyArr = key.split("/");
-            ReportStatisticRespVO statisticRespVO = new ReportStatisticRespVO();
-            statisticRespVO.setReportYear(Short.valueOf(keyArr[0]));
-            statisticRespVO.setReportMonth(Short.valueOf(keyArr[1]));
-            statisticRespVO.setDeptId(keyArr[2]);
-            statisticRespVO.setDeptName(deptMap.get(statisticRespVO.getDeptId()).getName());
-            statisticRespVO.setUserId(keyArr[3]);
-            statisticRespVO.setNickName(userMap.get(statisticRespVO.getUserId()).getNickname());
-
-            //各日期周/日报情况
-            List<ReportFillSituationVO> reportFillUnitList = new ArrayList<>();
-            Map<String, List<WorkdayDO>> workDayOrWeekMap = allWorkDayOrWeekMap.get(statisticRespVO.getReportYear() + "/" + statisticRespVO.getReportMonth());
-            Map<String, List<StatisticAttendanceSheetData>> attendanceStatisticMap = allAttendanceStatisticMap.get(statisticRespVO.getUserId() + "/" + statisticRespVO.getReportYear() + "/" + statisticRespVO.getReportMonth());
+            String year = keyArr[0];
+            String month = keyArr[1];
+            String deptId = keyArr[2];
+            String userId = keyArr[3];
 
+            Map<String, List<ReportDO>> reportMap= allReportMap.get(key);
+            Map<String, List<WorkdayDO>> workDayOrWeekMap = allWorkDayOrWeekMap.get(year + "/" + month);
+            Map<String, List<StatisticAttendanceSheetData>> attendanceStatisticMap = allAttendanceStatisticMap.get(userId + "/" + year + "/" + month);
             Integer fillCount = reportMap.size(); //已填报告数量
             Integer shouldFillCount = workDayOrWeekMap.size(); //默认应填报告数量
+
+            //各日期周/日报情况
+            List<ReportFillSituationVO> reportFillUnitList = new ArrayList<>();
             for (String dateUnit : workDayOrWeekMap.keySet()) {
                 ReportFillSituationVO reportUnit = new ReportFillSituationVO();
                 //工作报告
                 List<ReportDO> reports = reportMap.get(dateUnit);
                 reportUnit.setReport(CollectionUtils.isNotEmpty(reports) ? reports.get(0) : null);
                 reportFillUnitList.add(reportUnit);
+                reportUnit.setDate(dateUnit);
 
+                //是否工作日/周
                 List<WorkdayDO> list = workDayOrWeekMap.get(dateUnit);
-
-                reportUnit.setDate(dateUnit);
                 boolean isWorkWeek = list.stream().anyMatch(c -> "1".equals(c.getIsworkday()));
                 reportUnit.setIsworkday(isWorkWeek ? 1 : 0);
 
@@ -248,17 +246,24 @@ public class ReportServiceImpl implements ReportService {
                     reportUnit.setIsAskForLeave(statisticAttendanceSheet.getAskForLeaveCount() > 0 ? 1 : 0);
                     shouldFillCount = statisticAttendanceSheet.getWorkdayCount() == statisticAttendanceSheet.getAskForLeaveCount() ? shouldFillCount - 1 : shouldFillCount;
                 }
+
             }
+            ReportStatisticRespVO statisticRespVO = new ReportStatisticRespVO();
+            statisticRespVO.setReportYear(year);
+            statisticRespVO.setReportMonth(month);
+            statisticRespVO.setDeptId(deptId);
+            statisticRespVO.setDeptName(deptMap.get(statisticRespVO.getDeptId()).getName());
+            statisticRespVO.setUserId(userId);
+            statisticRespVO.setNickName(userMap.get(statisticRespVO.getUserId()).getNickname());
             statisticRespVO.setReportFillSituation(reportFillUnitList);
-            statisticRespVO.setFilledCount(fillCount);
             statisticRespVO.setShouldFilledCount(shouldFillCount);
             statisticRespVO.setNotFilledCount(shouldFillCount - fillCount);
+            statisticRespVO.setFilledCount(fillCount);
             statisticRespVO.setFillRate(fillCount * 1.0 / shouldFillCount);
             resultList.add(statisticRespVO);
         }
-
-        Page<ReportStatisticRespVO> pages = PageUtil.getPages(reportStatisticReqDTO.getPageNo(), reportStatisticReqDTO.getPageNo(), resultList);
-        return new PageResult<>(pages.getRecords(), pages.getTotal());
+        PageResult<ReportStatisticRespVO> pages = PageUtil.getPages(reportStatisticReqDTO.getPageNo(), reportStatisticReqDTO.getPageSize(), resultList);
+        return pages;
     }
 
 

+ 5 - 5
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/service/report/PageUtil.java → zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/util/PageUtil.java

@@ -1,6 +1,7 @@
-package com.zjugis.module.adm.service.report;
+package com.zjugis.module.adm.util;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zjugis.framework.common.pojo.PageResult;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -8,8 +9,8 @@ import java.util.List;
 
 public class PageUtil {
 
-    public static <T> Page<T> getPages(Integer currentPage, Integer pageSize, List<T> list) {
-        Page<T> page = new Page<>();
+    public static <T> PageResult<T> getPages(Integer currentPage, Integer pageSize, List<T> list) {
+
         if (list == null) {
             return null;
         }
@@ -35,8 +36,7 @@ public class PageUtil {
         for (int i = 0; i < pageSize && curIdx + i < size; i++) {
             pageList.add(list.get(curIdx + i));
         }
-
-        page.setCurrent(currentPage).setSize(pageSize).setTotal(list.size()).setRecords(pageList);
+        PageResult page = new PageResult<>(pageList,Long.valueOf(list.size()));
         return page;
     }