Browse Source

增加审核人的排序

QuYueTing 12 giờ trước cách đây
mục cha
commit
695f557992

+ 4 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -302,7 +302,7 @@ public class ReportController {
                                               Integer departmentId,
                                               @RequestParam(defaultValue = "1") Integer pageIndex,
                                               @RequestParam(defaultValue = "20") Integer pageSize,
-                                              String userId) {
+                                              String userId, String orderBy) {
         //startDate和endDate间隔不得超过1年
         DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate start = LocalDate.parse(startDate, dateTimeFormatter);
@@ -312,7 +312,7 @@ public class ReportController {
             httpRespMsg.setError("查询日报时间间隔不得超过1年");
             return httpRespMsg;
         }
-        return reportService.getReportListForExport(startDate, endDate, projectId, state, departmentId, pageIndex, pageSize, userId, request);
+        return reportService.getReportListForExport(startDate, endDate, projectId, state, departmentId, pageIndex, pageSize, userId,orderBy, request);
     }
 
     /**
@@ -341,7 +341,7 @@ public class ReportController {
     }
 
     @RequestMapping("/getReportGroupByDay")
-    public HttpRespMsg getReportGroupByDay(String startDate, String endDate,String userId, Integer departmentId, Integer projectId, Integer state) {
+    public HttpRespMsg getReportGroupByDay(String startDate, String endDate,String userId, Integer departmentId, Integer projectId, Integer state, String orderBy) {
         //startDate和endDate间隔不得超过1年
         DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate start = LocalDate.parse(startDate, dateTimeFormatter);
@@ -351,7 +351,7 @@ public class ReportController {
             httpRespMsg.setError("日报时间间隔不得超过1年");
             return httpRespMsg;
         }
-        return reportService.getReportGroupByDay(startDate, endDate,userId, departmentId, projectId, state, request);
+        return reportService.getReportGroupByDay(startDate, endDate,userId, departmentId, projectId, state, orderBy, request);
     }
 
     @RequestMapping("/exportReportGroupByDay")

+ 9 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java

@@ -32,8 +32,14 @@ public interface ReportMapper extends BaseMapper<Report> {
                                                      @Param("endDate") String endDate,
                                                      @Param("projectId") Integer projectId,
                                                      @Param("state") Integer state,
-                                                     @Param("branchDepartment")List<Integer> branchDepartment
-    );
+                                                     @Param("branchDepartment")List<Integer> branchDepartment, Integer start, Integer size, String orderBy);
+    int getAllReportByDateForExportCount(@Param("startDate") String startDate,
+                                                              @Param("companyId") Integer companyId,
+                                                              @Param("userId") String userId,
+                                                              @Param("endDate") String endDate,
+                                                              @Param("projectId") Integer projectId,
+                                                              @Param("state") Integer state,
+                                                              @Param("branchDepartment")List<Integer> branchDepartment);
     List<HashMap<String, Object>> getAllReportByDate(@Param("startDate") String startDate,
                                                      @Param("companyId") Integer companyId,
                                                      @Param("userId") String userId,
@@ -299,18 +305,16 @@ public interface ReportMapper extends BaseMapper<Report> {
                                                    @Param("startDate") String startDate,
                                                    @Param("endDate") String endDate,
                                                    @Param("userId") String userId,
-                                                   @Param("departmentId") Integer departmentId,
                                                    @Param("projectId") Integer projectId,
                                                    @Param("state") Integer state,
                                                    @Param("deptIds") List<Integer> deptIds,
                                                    @Param("pageStart") Integer pageStart,
-                                                   @Param("pageSize") Integer pageSize);
+                                                   @Param("pageSize") Integer pageSize, String orderBy);
 
     Integer getReportGroupByDayCount(@Param("companyId") Integer companyId,
                                       @Param("startDate") String startDate,
                                       @Param("endDate") String endDate,
                                       @Param("userId") String userId,
-                                      @Param("departmentId") Integer departmentId,
                                       @Param("projectId") Integer projectId,
                                      @Param("state") Integer state,
                                       @Param("deptIds") List<Integer> deptIds);

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -28,7 +28,7 @@ public interface ReportService extends IService<Report> {
 
     HttpRespMsg exportReport(@RequestParam String startDate, @RequestParam String endDate,Integer exportType, Integer projectId,Integer stateKey,String departmentIds,String plate, HttpServletRequest request);
 
-    HttpRespMsg getReportListForExport(String startDate, String endDate, Integer projectId, Integer state, Integer departmentId, Integer pageIndex, Integer pageSize, String targetUserId, HttpServletRequest request);
+    HttpRespMsg getReportListForExport(String startDate, String endDate, Integer projectId, Integer state, Integer departmentId, Integer pageIndex, Integer pageSize, String targetUserId, String orderBy, HttpServletRequest request);
 
     HttpRespMsg exportReportListForExport(String startDate, String endDate, Integer projectId, Integer state, Integer departmentId, String targetUserId, HttpServletRequest request);
 
@@ -216,7 +216,7 @@ public interface ReportService extends IService<Report> {
 
     HttpRespMsg exportMissingCardTimeUserList(String startDate, String endDate, Integer departmentId, HttpServletRequest request);
 
-    HttpRespMsg getReportGroupByDay(String startDate, String endDate, String userId, Integer departmentId, Integer projectId, Integer state, HttpServletRequest request);
+    HttpRespMsg getReportGroupByDay(String startDate, String endDate, String userId, Integer departmentId, Integer projectId, Integer state, String orderBy, HttpServletRequest request);
 
     HttpRespMsg exportReportGroupByDay(String startDate, String endDate, String userId, Integer departmentId, Integer projectId, Integer state, HttpServletRequest request);
 

+ 131 - 56
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -14580,7 +14580,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     }
 
     @Override
-    public HttpRespMsg getReportListForExport(String startDate, String endDate, Integer projectId, Integer state, Integer departmentId, Integer pageIndex, Integer pageSize, String targetUserId, HttpServletRequest request) {
+    public HttpRespMsg getReportListForExport(String startDate, String endDate, Integer projectId, Integer state, Integer departmentId, Integer pageIndex, Integer pageSize, String targetUserId, String orderBy, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             String userId = request.getHeader("Token");
@@ -14595,50 +14595,49 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             if (!StringUtils.isEmpty(departmentId)) {
                 branchDepartment = departmentService.getDeptIncludeSubDeptIds(departmentId, departments);
             }
-            
-
-//            List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全公司工时");
-
-//            if (functionList.size() == 0) {
-//                // 检查是否是部门负责人
-//                List<Integer> allVisibleDeptIdList = getAllVisibleDeptIdList(user, null);
-//                if (allVisibleDeptIdList.size() > 0) {
-//                    allReportByDate = reportMapper.getDeptMembReportByDate(startDate, null, allVisibleDeptIdList, endDate, projectId, stateKey, branchDepartment, user.getId(), field, fieldValue);
-//                }
-//
-//                if (allReportByDate == null) {
-//                    allReportByDate = new ArrayList<>();
-//                }
-//            } else {
-//                }
             // 有查看全公司工时权限
-            List<HashMap<String, Object>> allReportByDate = reportMapper.getAllReportByDateForExport(startDate, companyId, targetUserId, endDate, projectId, state, branchDepartment);
-
-            // 分页处理
-            int total = allReportByDate.size();
             int startIndex = (pageIndex - 1) * pageSize;
-            int endIndex = Math.min(startIndex + pageSize, total);
-            
-            List<HashMap<String, Object>> pagedData = new ArrayList<>();
-            if (startIndex < total) {
-                pagedData = new ArrayList<>(allReportByDate.subList(startIndex, endIndex));
-                //处理日期显示
-                for (int i = 0; i < pagedData.size(); i++) {
-                    HashMap mapItem = pagedData.get(i);
-                    String createDate = new SimpleDateFormat("yyyy-MM-dd")
-                            .format((java.sql.Date) mapItem.get("createDate"));
-                    mapItem.put("createDate", createDate);
-                    //计算非加班工时
-                    double workingTime = (Double) mapItem.get("duration");
-                    double overtime = (Double) mapItem.get("overtimeHours");
-                    mapItem.put("normalWorkingTime", workingTime - overtime);
-                    //处理部门审核人
-                    String deptAuditorId = (String)mapItem.get("deptAuditorName");
-                    if (deptAuditorId != null) {
-                        User targetUser = allUserList.stream().filter(us->us.getId().equals(deptAuditorId)).findFirst().orElse(null);
-                        if (targetUser != null) {
-                            mapItem.put("deptAuditorName", targetUser.getName());
+            List<HashMap<String, Object>> allReportByDate = reportMapper.getAllReportByDateForExport(startDate, companyId, targetUserId, endDate, projectId, state, branchDepartment, startIndex, pageSize, orderBy);
+            // 处理数据
+            // 分页处理
+            int total = reportMapper.getAllReportByDateForExportCount(startDate, companyId, targetUserId, endDate, projectId, state, branchDepartment);
+            DateTimeFormatter hmDtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
+            //处理日期显示
+            for (int i = 0; i < allReportByDate.size(); i++) {
+                HashMap mapItem = allReportByDate.get(i);
+                String createDate = new SimpleDateFormat("yyyy-MM-dd")
+                        .format((java.sql.Date) mapItem.get("createDate"));
+                mapItem.put("createDate", createDate);
+                //计算非加班工时
+                double workingTime = (Double) mapItem.get("duration");
+                double overtime = (Double) mapItem.get("overtimeHours");
+                mapItem.put("normalWorkingTime", workingTime - overtime);
+                //处理部门审核人
+                String deptAuditorId = (String)mapItem.get("deptAuditorName");
+                if (deptAuditorId != null) {
+                    User targetUser = allUserList.stream().filter(us->us.getId().equals(deptAuditorId)).findFirst().orElse(null);
+                    if (targetUser != null) {
+                        mapItem.put("deptAuditorName", targetUser.getName());
+                    }
+                }
+                String lastOperateTime = mapItem.get("lastOperateTime") == null ? "" : mapItem.get("lastOperateTime").toString();
+                //计算时间
+                if (lastOperateTime != null && !lastOperateTime.equals("")) {
+                    LocalDateTime time = LocalDateTime.parse(lastOperateTime, hmDtf);
+                    //计算与当前时间的间隔
+                    Duration duration = Duration.between(time, LocalDateTime.now());
+                    long days = duration.toDays();
+                    long hours = duration.toHours() % 24;
+                    long minutes = duration.toMinutes() % 60;
+                    //时间格式化
+                    if (days == 0) {
+                        if (hours == 0) {
+                            mapItem.put("timeText", minutes + "分");
+                        } else {
+                            mapItem.put("timeText", hours + "小时" + minutes + "分");
                         }
+                    } else {
+                        mapItem.put("timeText", days + "天" + hours + "小时" + minutes + "分");
                     }
                 }
             }
@@ -14649,7 +14648,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             resultMap.put("pageIndex", pageIndex);
             resultMap.put("pageSize", pageSize);
             resultMap.put("totalPages", (int) Math.ceil((double) total / pageSize));
-            resultMap.put("list", pagedData);
+            resultMap.put("list", allReportByDate);
             
             httpRespMsg.setData(resultMap);
         } catch (Exception e) {
@@ -14664,7 +14663,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             // 调用getReportListForExport获取全部数据(不分页)
-            HttpRespMsg queryResult = getReportListForExport(startDate, endDate, projectId, state, departmentId, 1, Integer.MAX_VALUE, targetUserId, request);
+            HttpRespMsg queryResult = getReportListForExport(startDate, endDate, projectId, state, departmentId, null, null, targetUserId,null, request);
             
             if (queryResult.code != null && !queryResult.code.equals("ok")) {
                 return queryResult; // 返回错误信息
@@ -14698,6 +14697,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             titles.add("加班时长(h)");
             titles.add("工作内容");
             titles.add("当前审核人");
+            titles.add("审核滞留时长");
             titles.add("审核状态");
             
             dataList.add(titles);
@@ -14705,15 +14705,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             // 填充数据
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
             DecimalFormat df = new DecimalFormat("0.0");
-            
+            DateTimeFormatter hmDtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
             for (HashMap<String, Object> map : allReportByDate) {
                 List<String> item = new ArrayList<>();
                 
                 // 员工
                 if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
                     item.add("$userName=" + (map.get("corpwxUserId") == null ? "" : map.get("corpwxUserId")) + "$");
-                } else if (dingding != null && dingding.getContactNeedTranslate() == 1) {
-                    item.add("$userName=" + (map.get("name") == null ? "" : map.get("name")) + "$");
                 } else {
                     item.add((String) map.get("name"));
                 }
@@ -14724,8 +14722,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 // 所属部门
                 if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
                     item.add("$departmentName=" + (map.get("corpwxDeptId") == null ? "" : map.get("corpwxDeptId")) + "$");
-                } else if (dingding != null && dingding.getContactNeedTranslate() == 1) {
-                    item.add("$departmentName=" + (map.get("departmentName") == null ? "" : map.get("departmentName")) + "$");
                 } else {
                     item.add(map.get("departmentName") != null ? (String) map.get("departmentName") : "");
                 }
@@ -14775,6 +14771,28 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 // 工作内容
                 item.add(map.get("content") != null ? (String) map.get("content") : "");
 
+                String lastOperateTime = map.get("lastOperateTime") == null ? "" : map.get("lastOperateTime").toString();
+                //计算时间
+                String timeText = "";
+                if (lastOperateTime != null && !lastOperateTime.equals("")) {
+                    LocalDateTime time = LocalDateTime.parse(lastOperateTime, hmDtf);
+                    //计算与当前时间的间隔
+                    Duration duration = Duration.between(time, LocalDateTime.now());
+                    long days = duration.toDays();
+                    long hours = duration.toHours() % 24;
+                    long minutes = duration.toMinutes() % 60;
+                    //时间格式化
+                    if (days == 0) {
+                        if (hours == 0) {
+                            timeText =  minutes + "分";
+                        } else {
+                            timeText = hours + "小时" + minutes + "分";
+                        }
+                    } else {
+                        timeText = days + "天" + hours + "小时" + minutes + "分";
+                    }
+                }
+
                 // 审核状态
                 Integer stateValue = (Integer) map.get("state");
                 String auditStatus = "";
@@ -14802,6 +14820,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 } else {
                     item.add("-");
                 }
+                item.add(timeText);
+
                 item.add(auditStatus);
                 
                 dataList.add(item);
@@ -14819,7 +14839,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     }
 
     @Override
-    public HttpRespMsg getReportGroupByDay(String startDate, String endDate, String userId, Integer departmentId, Integer projectId, Integer state, HttpServletRequest request) {
+    public HttpRespMsg getReportGroupByDay(String startDate, String endDate, String userId, Integer departmentId, Integer projectId, Integer state, String orderBy, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             String token = request.getHeader("Token");
@@ -14877,14 +14897,15 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             
             // 查询按人按天汇总的数据
             List<Map<String, Object>> groupedReportList = reportMapper.getReportGroupByDay(
-                companyId, startDate, endDate, userId, departmentId, projectId, state, visibleDeptIds, pageStart, pageSize);
+                companyId, startDate, endDate, userId, projectId, state, visibleDeptIds, pageStart, pageSize, orderBy);
 
             // 获取总数
             Integer totalCount = reportMapper.getReportGroupByDayCount(
-                companyId, startDate, endDate, userId, departmentId, projectId, state, visibleDeptIds);
+                companyId, startDate, endDate, userId, projectId, state, visibleDeptIds);
             
             // 获取考勤数据
             DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            DateTimeFormatter hmDtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
             if (groupedReportList.size() > 0 && (timeType.getShowCorpwxCardtime() == 1 || timeType.getShowDdCardtime() == 1 || timeType.getSyncFanwei() == 1)) {
                 List<String> dateList = groupedReportList.stream().map(m -> (String)m.get("reportDate")).distinct().collect(Collectors.toList());
                 String minDate = dateList.stream().min(Comparator.comparing(String::toString)).get();
@@ -14983,8 +15004,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     map.put("cardRecord", "");
                 }
 
-                // 13. 审核流程 - auditWorkflow已在SQL中拼接
-                
+
                 // 14. 审核状态
                 Integer auditState = (Integer)map.get("auditState");
                 String auditStatusText = "";
@@ -15010,6 +15030,32 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     }
                 }
                 map.put("auditStatusText", auditStatusText);
+
+                //计算审核滞留时长
+                String auditWorkflow = (String)map.get("auditWorkflow");
+                if (auditWorkflow != null) {
+                    String[] array = auditWorkflow.split("->");
+                    String lastOperate = array[array.length - 1];
+                    String[] array2 = lastOperate.split(" ");
+                    String lastOperateTime = array2[0] + " " + array2[1];//最后一次操作时间
+                    // 日期格式化
+                    LocalDateTime lastOperateDate = LocalDateTime.parse(lastOperateTime, hmDtf);
+                    //计算距离现在的时间间隔
+                    Duration duration = Duration.between(lastOperateDate, LocalDateTime.now());
+                    long days = duration.toDays();
+                    long hours = duration.toHours() % 24;
+                    long minutes = duration.toMinutes() % 60;
+                    //时间格式化
+                    if (days == 0) {
+                        if (hours == 0) {
+                            map.put("timeText", minutes + "分");
+                        } else {
+                            map.put("timeText", hours + "小时" + minutes + "分");
+                        }
+                    } else {
+                        map.put("timeText", days + "天" + hours + "小时" + minutes + "分");
+                    }
+                }
             }
             //处理加班申请
             List<Overtime> overtimeList = userIds.size() > 0?overtimeMapper.selectList(new QueryWrapper<Overtime>().eq("company_id", companyId)
@@ -15100,10 +15146,11 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             }
             // 查询按人按天汇总的数据
             List<Map<String, Object>> groupedReportList = reportMapper.getReportGroupByDay(
-                    companyId, startDate, endDate, userId, departmentId, projectId, state, visibleDeptIds, null, null);
+                    companyId, startDate, endDate, userId, projectId, state, visibleDeptIds, null, null, null);
 
             // 获取考勤数据
             DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            DateTimeFormatter hmDtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
             if (groupedReportList.size() > 0 && (timeType.getShowCorpwxCardtime() == 1 || timeType.getShowDdCardtime() == 1 || timeType.getSyncFanwei() == 1)) {
                 List<String> dateList = groupedReportList.stream().map(m -> (String)m.get("reportDate")).distinct().collect(Collectors.toList());
                 String minDate = dateList.stream().min(Comparator.comparing(String::toString)).get();
@@ -15229,7 +15276,34 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     }
                 }
                 map.put("auditStatusText", auditStatusText);
+
+                String auditWorkflow = (String)map.get("auditWorkflow");
+                //计算时间
+                if (auditWorkflow != null) {
+                    String[] array = auditWorkflow.split("->");
+                    String lastOperate = array[array.length - 1];
+                    String[] array2 = lastOperate.split(" ");
+                    String lastOperateTime = array2[0] + " " + array2[1];//最后一次操作时间
+                    // 日期格式化
+                    LocalDateTime lastOperateDate = LocalDateTime.parse(lastOperateTime, hmDtf);
+                    //计算距离现在的时间间隔
+                    Duration duration = Duration.between(lastOperateDate, LocalDateTime.now());
+                    long days = duration.toDays();
+                    long hours = duration.toHours() % 24;
+                    long minutes = duration.toMinutes() % 60;
+                    //时间格式化
+                    if (days == 0) {
+                        if (hours == 0) {
+                            map.put("timeText", minutes + "分");
+                        } else {
+                            map.put("timeText", hours + "小时" + minutes + "分");
+                        }
+                    } else {
+                        map.put("timeText", days + "天" + hours + "小时" + minutes + "分");
+                    }
+                }
             }
+
             //处理加班申请
             List<Overtime> overtimeList = userIds.size() > 0?overtimeMapper.selectList(new QueryWrapper<Overtime>().eq("company_id", companyId)
                     .between("date", startDate, endDate).in("user_id", userIds)): new ArrayList<>();
@@ -15261,6 +15335,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             titles.add("[加班工时]明细条数");
             titles.add("审核流程");
             titles.add("当前审核人");
+            titles.add("审核滞留时长");
             titles.add("审核状态");
 
             dataList.add(titles);
@@ -15358,6 +15433,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 } else {
                     item.add("-");
                 }
+                item.add((String)map.get("timeText"));
                 // 审核状态
                 item.add(map.get("auditStatusText") != null ? (String) map.get("auditStatusText") : "");
 
@@ -15366,7 +15442,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
 
             // 生成Excel文件导出
             String fileName = "工时日报列表_" + startDate + "至" + endDate + "_" + System.currentTimeMillis();
-            System.out.println("到处日报文件==>" + fileName);
             return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, dingding, fileName, dataList, path);
 
         } catch (Exception e) {

+ 45 - 9
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -71,10 +71,12 @@
         a.end_time  as endTime, d.name as subProjectName,d.code as subProjectCode,a.task_id as taskId, task.name as taskName, a.is_overtime as isOvertime,a.progress as progress,
         a.department_audit_state as departmentAuditState, a.stage, a.pic_str as picStr, multi_worktime as multiWorktime,a.is_dept_audit as isDeptAudit,a.group_audit_state as groupAuditState,task_group.incharger_id as inchargerId,a.project_audit_state as projectAuditState,a.audit_dept_managerid as deptAuditorName
         ,c.plate1 as plate1,c.plate2 as plate2,c.plate3 as plate3,c.plate4 as plate4,c.plate5 as plate5
-        , reject_reason as rejectReason, reject_username as rejectUsername, reject_userid as rejectUserid, degree_id as degree_id,report_extra_degree.name as degreeName,task_group.name as groupName,a.group_id as groupId,a.custom_data as customData
+        , degree_id as degree_id,report_extra_degree.name as degreeName,task_group.name as groupName,a.group_id as groupId,a.custom_data as customData
         ,u.name as projectAuditorName,u.corpwx_userid as projectAuditorCorpwxUserId, a.project_auditor_id as projectAuditorId, department.department_name as departmentName,dp2.department_name as buDepartmentName,department.department_id as departmentId, a.overtime_hours as overtimeHours, a.custom_text as customText,a.project_audit_time  as projectAuditTime,project_main.name as projectMainName,
         a.extra_field1 as extraField1,a.extra_field2 as extraField2,a.extra_field3 as extraField3, a.batch_id as batchId,a.sap_service_id as sapServiceId,b.status as projectStatus,DATE_FORMAT(b.finish_date,'%Y-%m-%d') as finishDate,ps.project_category_sub as projectCategorySub
         ,u2.name as projectManagerName,u2.corpwx_userid as projectManagerCorpwxUserId, multi_degr_id as multiDegrId,b.current_stage_name as stageName, extra_field4 as extraField4,extra_field5 as extraField5
+        ,(select DATE_FORMAT(max(rlog.operate_date), '%Y-%m-%d %H:%i')
+        from report_log rlog where rlog.creator_id = a.creator_id AND rlog.create_date = a.create_date)  AS lastOperateTime
         FROM report AS a
         JOIN project AS b ON a.project_id=b.id
         LEFT JOIN project_separate AS ps on b.id=ps.id
@@ -111,7 +113,42 @@
                 #{deptId}
             </foreach>
         </if>
-        ORDER BY a.creator_id, a.create_date desc
+        <if test="orderBy != null">
+            ORDER BY #{orderBy}
+        </if>
+        <if test="orderBy == null">
+            ORDER BY a.creator_id, a.create_date desc
+        </if>
+        <if test="start != null and size != null">
+        limit #{start}, #{size}
+        </if>
+    </select>
+    <select id="getAllReportByDateForExportCount" resultType="java.lang.Integer">
+        SELECT count(1)
+        FROM report AS a
+        left join department on department.department_id = a.dept_id
+        WHERE a.company_id = #{companyId}
+        <if test="state == null">
+            and (a.state = 0 or a.state = 1 or a.state = 2)
+        </if>
+        <if test="state != null">
+            and a.state = #{state}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            AND a.create_date between #{startDate} and #{endDate}
+        </if>
+        <if test="projectId != null">
+            AND a.project_id = #{projectId}
+        </if>
+        <if test="userId != null">
+            AND a.creator_id = #{userId}
+        </if>
+        <if test="branchDepartment != null and branchDepartment.size()>0">
+            AND department.department_id in
+            <foreach collection="branchDepartment" item="deptId" separator="," close=")" open="(" index="index">
+                #{deptId}
+            </foreach>
+        </if>
     </select>
     <!--根据日期获取全部报告信息-->
     <select id="getAllReportByDate" resultType="java.util.Map">
@@ -1940,9 +1977,6 @@
         <if test="userId != null and userId != ''">
             AND r.creator_id = #{userId}
         </if>
-        <if test="departmentId != null">
-            AND u.department_id = #{departmentId}
-        </if>
         <if test="projectId != null">
             AND r.project_id = #{projectId}
         </if>
@@ -1953,7 +1987,12 @@
             </foreach>
         </if>
         GROUP BY u.id, r.create_date
-        ORDER BY r.create_date DESC, u.name
+        <if test="orderBy != null">
+            ORDER BY #{orderBy}
+        </if>
+        <if test="orderBy == null">
+            ORDER BY r.create_date DESC, u.name
+        </if>
         <if test="pageStart != null and pageSize != null">
             LIMIT #{pageStart}, #{pageSize}
         </if>
@@ -1980,9 +2019,6 @@
         <if test="userId != null and userId != ''">
             AND r.creator_id = #{userId}
         </if>
-        <if test="departmentId != null">
-            AND u.department_id = #{departmentId}
-        </if>
         <if test="projectId != null">
             AND r.project_id = #{projectId}
         </if>

+ 92 - 4
fhKeeper/formulahousekeeper/timesheet/src/views/corpreport/list.vue

@@ -5846,9 +5846,23 @@
                 <el-table-column
                   prop="auditorName"
                   align="center"
-                  label="当前审核人"
-                  width="120"
+                  width="140"
                 >
+                  <template slot="header">
+                    <span>当前审核人</span>
+                    <span style="margin-left: 4px; cursor: pointer; display: inline-flex; flex-direction: column; vertical-align: middle;">
+                      <i
+                        class="el-icon-caret-top"
+                        :style="{ color: dailyWorkHoursOrderBy === 'audit_dept_managerid asc' ? '#409EFF' : '#C0C4CC', fontSize: '12px', lineHeight: '1' }"
+                        @click="sortDailyWorkHours('asc')"
+                      ></i>
+                      <i
+                        class="el-icon-caret-bottom"
+                        :style="{ color: dailyWorkHoursOrderBy === 'audit_dept_managerid desc' ? '#409EFF' : '#C0C4CC', fontSize: '12px', lineHeight: '1' }"
+                        @click="sortDailyWorkHours('desc')"
+                      ></i>
+                    </span>
+                  </template>
                   <template slot-scope="scope">
                     <span v-if="scope.row.auditStatusText == '待审核'">
                       <TranslationOpenDataText
@@ -5861,6 +5875,19 @@
                     <span v-else>-</span>
                   </template>
                 </el-table-column>
+                <el-table-column
+                  prop="auditorName"
+                  align="center"
+                  label="审核滞留时长"
+                  width="120"
+                >
+                  <template slot-scope="scope">
+                    <span v-if="scope.row.auditStatusText == '待审核'">
+                      {{ scope.row.timeText }}
+                    </span>
+                    <span v-else>-</span>
+                  </template>
+                </el-table-column>
                 <el-table-column
                   prop="auditStatusText"
                   align="center"
@@ -6009,9 +6036,23 @@
                 <el-table-column
                   prop="auditorName"
                   align="center"
-                  label="当前审核人"
-                  width="120"
+                  width="140"
                 >
+                  <template slot="header">
+                    <span>当前审核人</span>
+                    <span style="margin-left: 4px; cursor: pointer; display: inline-flex; flex-direction: column; vertical-align: middle;">
+                      <i
+                        class="el-icon-caret-top"
+                        :style="{ color: dailyDetailOrderBy === 'audit_dept_managerid asc' ? '#409EFF' : '#C0C4CC', fontSize: '12px', lineHeight: '1' }"
+                        @click="sortDailyDetail('asc')"
+                      ></i>
+                      <i
+                        class="el-icon-caret-bottom"
+                        :style="{ color: dailyDetailOrderBy === 'audit_dept_managerid desc' ? '#409EFF' : '#C0C4CC', fontSize: '12px', lineHeight: '1' }"
+                        @click="sortDailyDetail('desc')"
+                      ></i>
+                    </span>
+                  </template>
                   <template slot-scope="scope">
                     <span v-if="scope.row.state == 0">
                       <TranslationOpenDataText
@@ -6024,6 +6065,19 @@
                     <span v-else>-</span>
                   </template>
                 </el-table-column>
+                <el-table-column
+                  prop="auditorName"
+                  align="center"
+                  label="审核滞留时长"
+                  width="120"
+                >
+                  <template slot-scope="scope">
+                    <span v-if="scope.row.auditStatusText == '待审核'">
+                      {{ scope.row.timeText }}
+                    </span>
+                    <span v-else>-</span>
+                  </template>
+                </el-table-column>
                 <el-table-column
                   prop="auditStatus"
                   align="center"
@@ -7882,10 +7936,12 @@ export default {
       // 工时日报表
       dailyWorkHoursList: [],
       dailyWorkHoursLoading: false,
+      dailyWorkHoursOrderBy: '', // 工时日报表排序字段,如 'audit_dept_managerid asc' 或 'audit_dept_managerid desc'
 
       // 日报明细表
       dailyDetailList: [],
       dailyDetailLoading: false,
+      dailyDetailOrderBy: '', // 日报明细表排序字段,如 'audit_dept_managerid asc' 或 'audit_dept_managerid desc'
 
       // 工时日报表/日报明细表状态筛选
       dailyState: "",
@@ -10789,6 +10845,19 @@ export default {
       }
     },
 
+    // 日报明细表按审核人排序
+    sortDailyDetail(direction) {
+      const newOrderBy = `audit_dept_managerid ${direction}`;
+      if (this.dailyDetailOrderBy === newOrderBy) {
+        // 再次点击同一方向,取消排序
+        this.dailyDetailOrderBy = '';
+      } else {
+        this.dailyDetailOrderBy = newOrderBy;
+      }
+      this.page = 1;
+      this.getDailyDetail();
+    },
+
     // 获取日报明细表
     getDailyDetail() {
       this.dailyDetailLoading = true;
@@ -10811,6 +10880,9 @@ export default {
       if (this.dailyState !== "" && this.dailyState !== null) {
         parameter.state = this.dailyState;
       }
+      if (this.dailyDetailOrderBy) {
+        parameter.orderBy = this.dailyDetailOrderBy;
+      }
       this.postData(`/report/getReportListForExport`, parameter)
         .then((res) => {
           this.dailyDetailList = res.data.list || [];
@@ -11977,6 +12049,19 @@ export default {
         });
     },
 
+    // 工时日报表按审核人排序
+    sortDailyWorkHours(direction) {
+      const newOrderBy = `audit_dept_managerid ${direction}`;
+      if (this.dailyWorkHoursOrderBy === newOrderBy) {
+        // 再次点击同一方向,取消排序
+        this.dailyWorkHoursOrderBy = '';
+      } else {
+        this.dailyWorkHoursOrderBy = newOrderBy;
+      }
+      this.page = 1;
+      this.getDailyWorkHours();
+    },
+
     // 获取工时日报表
     getDailyWorkHours() {
       this.dailyWorkHoursLoading = true;
@@ -11999,6 +12084,9 @@ export default {
       if (this.dailyState !== "" && this.dailyState !== null) {
         parameter.state = this.dailyState;
       }
+      if (this.dailyWorkHoursOrderBy) {
+        parameter.orderBy = this.dailyWorkHoursOrderBy;
+      }
       this.postData(`/report/getReportGroupByDay`, parameter)
         .then((res) => {
           this.dailyWorkHoursList = res.data.data || [];