yusm hai 3 días
pai
achega
02f8cc4114

+ 19 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/ReportController.java

@@ -3135,6 +3135,25 @@ public class ReportController {
     }
 
 
+    /**
+     * 工作计划待审核
+     * @param startDate
+     * @param endDate
+     * @param request
+     * @return
+     */
+    @RequestMapping("/getTaskPlanNeedCheckStatistics")
+    public HttpRespMsg getTaskPlanNeedCheckStatistics(String startDate,String endDate,String userId,Integer pageIndex,Integer pageSize, HttpServletRequest request) {
+        return reportService.getTaskPlanNeedCheckStatistics(userId,pageIndex,pageSize,startDate,endDate,request);
+    }
+
+
+    @RequestMapping("/exportTaskPlanNeedCheckStatistics")
+    public HttpRespMsg exportTaskPlanNeedCheckStatistics(String startDate,String endDate,String userId, HttpServletRequest request) {
+        return reportService.exportTaskPlanNeedCheckStatistics(userId,startDate,endDate,request);
+    }
+
+
 
 }
 

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/TaskController.java

@@ -1452,7 +1452,7 @@ public class TaskController {
     public HttpRespMsg importUser(@RequestParam(required = false,defaultValue = "0")Integer isMultiProject, Integer projectId, Integer groupId, @RequestParam MultipartFile file) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
-            httpRespMsg = taskService.importTask(isMultiProject, projectId, groupId, file, request);
+            httpRespMsg = taskService.importTaskNew(isMultiProject, projectId, groupId, file, request);
             return httpRespMsg;
         } catch (NullPointerException e) {
             e.printStackTrace();

+ 4 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/mapper/ReportMapper.java

@@ -263,4 +263,8 @@ public interface ReportMapper extends BaseMapper<Report> {
     List<Report> getReportProjectAssistTime(@Param("companyId") Integer companyId,@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, @Param("groupNameList") List<String> groupNameList);
 
 
+    List<HashMap<String, Object>> getTaskPlanNeedCheckStatisticsList(@Param("userId")String userId,@Param("page") Integer page,@Param("size") Integer size, @Param("startDate")String startDate,@Param("endDate") String endDate,@Param("companyId") Integer companyId);
+
+    int getTaskPlanNeedCheckStatisticsCount(@Param("userId")String userId, @Param("startDate")String startDate,@Param("endDate") String endDate,@Param("companyId") Integer companyId);
+
 }

+ 5 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/ReportService.java

@@ -177,4 +177,9 @@ public interface ReportService extends IService<Report> {
 
     void checkAndAlertFVReportTimeLessThanCardTimeList(LocalDate startDate, LocalDate endDate, Integer companyId);
 
+
+    HttpRespMsg getTaskPlanNeedCheckStatistics(String userId, Integer pageIndex, Integer pageSize, String startDate, String endDate, HttpServletRequest request);
+
+    HttpRespMsg exportTaskPlanNeedCheckStatistics(String userId, String startDate, String endDate, HttpServletRequest request);
+
 }

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/TaskService.java

@@ -70,4 +70,6 @@ public interface TaskService extends IService<Task> {
     HttpRespMsg cancelByManager(Integer id, HttpServletRequest request);
 
     HttpRespMsg viewUserTaskSchedule(Integer taskId, String userId, String startDate, String endDate, HttpServletRequest request);
+
+    HttpRespMsg importTaskNew(Integer isMultiProject, Integer projectId, Integer groupId, MultipartFile file, HttpServletRequest request) throws Exception;
 }

+ 52 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -70,6 +70,7 @@ import java.util.stream.Collectors;
  */
 @Service
 public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
+    String pathPrefix = "/upload/";
     @Value("${configEnv.isPrivateDeploy}")
     private boolean isPrivateDeploy;
     @Value("${privateDeployURL.pcUrl}")
@@ -10889,6 +10890,57 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         }
     }
 
+    @Override
+    public HttpRespMsg getTaskPlanNeedCheckStatistics(String userId, Integer pageIndex, Integer pageSize, String startDate, String endDate, HttpServletRequest request) {
+        HttpRespMsg msg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        int size=pageSize==null?20:pageSize;
+        int page=pageIndex==null?0:(pageIndex-1)*size;
+        List<HashMap<String,Object>> list =reportMapper.getTaskPlanNeedCheckStatisticsList(userId,page,size,startDate,endDate,companyId);
+        int total =reportMapper.getTaskPlanNeedCheckStatisticsCount(userId,startDate,endDate,companyId);
+        HashMap<String ,Object> map=new HashMap<>();
+        map.put("total",total);
+        map.put("result",list);
+        msg.data=map;
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg exportTaskPlanNeedCheckStatistics(String userId, String startDate, String endDate, HttpServletRequest request) {
+        HttpRespMsg msg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+
+        List<HashMap<String,Object>> list =reportMapper.getTaskPlanNeedCheckStatisticsList(userId,null,null,startDate,endDate,companyId);
+        List<List<String>> dataList=new ArrayList<>();
+        List<String> titleList=new ArrayList<>();
+        List<String> subtitle=new ArrayList<>();
+
+        titleList.add("序号");
+        titleList.add("审核人");
+        titleList.add("所属部门");
+        titleList.add("待审核条数");
+        dataList.add(titleList);
+
+        for (int i = 0; i < list.size(); i++) {
+            List<String> item=new ArrayList<>();
+            item.add((i+1)+"");
+            item.add(list.get(i).get("name")==null?"":list.get(i).get("name").toString());
+            item.add(list.get(i).get("department_name")==null?"":list.get(i).get("department_name").toString());
+            item.add(list.get(i).get("total")==null?"":list.get(i).get("total").toString());
+            dataList.add(item);
+        }
+
+        String fileName = "工作计划待审批统计"+System.currentTimeMillis();
+        try {
+            return excelExportService.exportGeneralExcelByTitleAndList(null,null,fileName, dataList, path);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        msg.data =  pathPrefix + fileName+".xlsx";
+        return msg;
+    }
+
+
     @Override
     public List<Map<String, Object>> getReportTimeLessThanCardTimeList(LocalDate firstDay, LocalDate lastDay, Integer deptId, String userId, Integer companyId, boolean getAll) {
         //获取自己的考勤未填满的记录

+ 311 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -104,6 +104,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     private TaskCommentMapper taskCommentMapper;
     @Autowired
     private InformationMapper informationMapper;
+    @Autowired
+    private TaskTypeMapper taskTypeMapper;
+    @Resource
+    CustomerInfoMapper customerInfoMapper;
+
+    @Resource
+    private InformationService informationService;
+    @Autowired
+    private ReportExtraDegreeMapper reportExtraDegreeMapper;
 
     @Override
     public HttpRespMsg getExecutorPanel(Integer projectId) {
@@ -581,6 +590,308 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         return httpRespMsg;
     }
 
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public HttpRespMsg importTaskNew(Integer isMultiProject, Integer projectId, Integer groupId, MultipartFile multipartFile, HttpServletRequest request) throws Exception {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        //首先先搞到公司id
+        String userId = request.getHeader("Token");
+        User creator = userMapper.selectById(userId);
+        Integer companyId = creator.getCompanyId();
+        List<Project> allProjectList = null;
+        List<TaskGroup> allGroupList = null;
+        List<Stages> stagesList =new ArrayList<>();
+        if (isMultiProject == 1) {
+            allProjectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
+            //全部任务分组
+            allGroupList = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", allProjectList.stream().map(Project::getId).collect(Collectors.toList())));
+
+            stagesList = stagesMapper.selectList(new QueryWrapper<Stages>().in("group_id", allGroupList.stream().map(TaskGroup::getId).collect(Collectors.toList())));
+        }
+        List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
+        //类型
+        List<TaskType> taskTypeList = taskTypeMapper.selectList(new QueryWrapper<TaskType>().eq("company_id", companyId));
+
+        List<ReportExtraDegree> customerInfoList = reportExtraDegreeMapper.getAll(companyId);
+        List<Department> departmentList = departmentService.list(new QueryWrapper<Department>().eq("company_id", companyId));
+
+        //然后处理文件
+        String fileName = multipartFile.getOriginalFilename();
+        File file = new File(fileName == null ? "file" : fileName);
+        InputStream inputStream = null;
+        OutputStream outputStream = null;
+        try {
+            inputStream = multipartFile.getInputStream();
+            outputStream = new FileOutputStream(file);
+            byte[] buffer = new byte[4096];
+            int temp = 0;
+            while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
+                outputStream.write(buffer, 0, temp);
+            }
+            inputStream.close();
+            outputStream.close();
+            //然后解析表格
+            XSSFWorkbook workbook = new XSSFWorkbook(file);
+            //我们只需要第一个sheet
+            XSSFSheet sheet = workbook.getSheetAt(0);
+
+            HttpRespMsg respMsg=new HttpRespMsg();
+
+
+            //由于第一行需要指明列对应的标题
+            int lastRowNum = sheet.getLastRowNum();
+            System.out.println("lastRowNum==>"+lastRowNum);
+            for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
+                ArrayList<TaskExecutor> taskExecutors = new ArrayList<>();
+                XSSFRow row = sheet.getRow(rowIndex);
+                Task task = new Task();
+                if (row == null) {
+                    continue;
+                }
+                for (int i = 0; i < 5; i++) {
+                    XSSFCell cell = row.getCell(0);
+                    if (cell!=null) {
+                        cell.setCellType(CellType.STRING);
+                    }
+                }
+                XSSFCell typeCell = row.getCell(0);
+                if (typeCell == null||StringUtils.isEmpty(typeCell.getStringCellValue())) {
+                    throw  new Exception("第"+(rowIndex+1)+"行,类型为空");
+                }else {
+                    Optional<TaskType> first = taskTypeList.stream().filter(t -> t.getName().equals(typeCell.getStringCellValue())).findFirst();
+                    if (first.isPresent()){
+                        task.setTaskPlanType(first.get().getId());
+                    }else {
+                        throw  new Exception("第"+(rowIndex+1)+"行,类型填写有误");
+                    }
+                }
+                //类型不为请假
+                if (task.getTaskPlanType()!=3){
+                    XSSFCell projectCell = row.getCell(1);
+                    if (projectCell == null||StringUtils.isEmpty(projectCell.getStringCellValue())) {
+                        throw  new Exception("第"+(rowIndex+1)+"行,项目为空");
+                    }else {
+                        Optional<Project> first = allProjectList.stream().filter(t -> t.getProjectName().equals(projectCell.getStringCellValue())).findFirst();
+                        if (first.isPresent()){
+                            task.setProjectId(first.get().getId());
+                        }else {
+                            throw  new Exception("第"+(rowIndex+1)+"行,项目名称填写有误");
+                        }
+                    }
+
+                    XSSFCell researchCell = row.getCell(2);//研究中心
+                    if (researchCell != null||StringUtils.isNotEmpty(researchCell.getStringCellValue())) {
+                        Optional<ReportExtraDegree> first = customerInfoList.stream().filter(c -> c.getName().equals(researchCell.getStringCellValue().trim())).findFirst();
+                        if (first.isPresent()){
+                            task.setCenterId(first.get().getId());
+                            task.setCenterName(first.get().getName());
+                        }else {
+                            throw  new Exception("第"+(rowIndex+1)+"行,研究中心填写有误");
+                        }
+                    }
+
+                    XSSFCell taskGroupCell = row.getCell(3);//所属任务分组
+                    if (taskGroupCell == null||StringUtils.isEmpty(taskGroupCell.getStringCellValue())) {
+                        throw  new Exception("第"+(rowIndex+1)+"行,任务分组为空");
+                    }else {
+                        Optional<TaskGroup> first = allGroupList.stream().filter(t -> t.getProjectId().equals(task.getProjectId())&&t.getName().equals(taskGroupCell.getStringCellValue())).findFirst();
+                        if (first.isPresent()){
+                            task.setGroupId(first.get().getId());
+                        }else {
+                            throw  new Exception("第"+(rowIndex+1)+"行,任务分组填写有误");
+                        }
+                    }
+
+                    XSSFCell taskStageCell = row.getCell(4);//所属任务列表
+                    if (taskStageCell == null||StringUtils.isEmpty(taskStageCell.getStringCellValue())) {
+                        throw  new Exception("第"+(rowIndex+1)+"行,任务列表为空");
+                    }else {
+                        Optional<Stages> first = stagesList.stream().filter(t -> t.getGroupId().equals(task.getGroupId())&&t.getStagesName().equals(taskStageCell.getStringCellValue())).findFirst();
+                        if (first.isPresent()){
+                            task.setStagesId(first.get().getId());
+                        }else {
+                            throw  new Exception("第"+(rowIndex+1)+"行,任务列表填写有误");
+                        }
+                    }
+
+                    XSSFCell taskContentCell = row.getCell(5);//任务内容
+                    if (taskContentCell == null||StringUtils.isEmpty(taskContentCell.getStringCellValue())) {
+                        throw  new Exception("第"+(rowIndex+1)+"行,任务内容为空");
+                    }else {
+                        task.setName(taskContentCell.getStringCellValue());
+                    }
+
+                    XSSFCell planHoursCell = row.getCell(9);//计划工时
+                    if(planHoursCell!=null){
+                        planHoursCell.setCellType(CellType.STRING);
+                        task.setPlanHours(Integer.parseInt(planHoursCell.getStringCellValue()));
+                    }
+
+                    XSSFCell priorityCell = row.getCell(10);//优先级
+                    if(priorityCell!=null){
+                        priorityCell.setCellType(CellType.STRING);
+                        String stringCellValue = priorityCell.getStringCellValue();
+                        if(StringUtils.isNotEmpty(stringCellValue)){
+                            switch (stringCellValue){
+                                case "一般":
+                                    task.setTaskLevel(0);
+                                    break;
+                                case "重要":
+                                    task.setTaskLevel(1);
+                                    break;
+                                case "紧急":
+                                    task.setTaskLevel(2);
+                                    break;
+                            }
+                        }else {
+                            task.setTaskLevel(0);
+                        }
+                    }else {
+                        task.setTaskLevel(0);
+                    }
+
+                    XSSFCell descCell = row.getCell(11);//详细描述
+                    if(descCell!=null){
+                        descCell.setCellType(CellType.STRING);
+                        String stringCellValue = descCell.getStringCellValue();
+                        task.setTaskDesc(stringCellValue);
+                    }
+                }
+
+
+
+                XSSFCell startDateCell = row.getCell(6);//开始时间
+                if (startDateCell != null) {
+                    startDateCell.setCellType(CellType.NUMERIC);
+                }else {
+                    throw  new Exception("第"+(rowIndex+1)+"行,开始时间为空");
+                }
+                if(startDateCell.getDateCellValue() != null){
+                    Date dateCellValue = startDateCell.getDateCellValue();
+                    System.out.println("开始日期=="+dateCellValue.toString());
+                    String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
+                    LocalDateTime startDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+                    task.setStartDate(startDate);
+                }
+
+                XSSFCell endDateCell = row.getCell(7);//结束时间
+                if (endDateCell != null) {
+                    endDateCell.setCellType(CellType.NUMERIC);
+                }else {
+                    throw  new Exception("第"+(rowIndex+1)+"行,截止时间为空");
+                }
+                if(endDateCell.getDateCellValue() != null){
+                    Date dateCellValue = endDateCell.getDateCellValue();
+                    System.out.println("开始日期=="+dateCellValue.toString());
+                    String formatValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateCellValue);
+                    LocalDateTime endDate = LocalDateTime.parse(formatValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+                    task.setEndDate(endDate);
+                }
+
+                XSSFCell executorCell = row.getCell(8);//执行人
+                if (executorCell!=null){
+                    executorCell.setCellType(CellType.STRING);
+                    if (executorCell.getStringCellValue().isEmpty()){
+                        throw  new Exception("第"+(rowIndex+1)+"行,执行人为空");
+                    }
+                }else {
+                    throw  new Exception("第"+(rowIndex+1)+"行,执行人为空");
+                }
+
+
+                task.setCompanyId(companyId);
+                task.setCreaterId(userId);
+                task.setCreaterName(creator.getName());
+                task.setCreatorColor(creator.getColor());
+                task.setCreateDate(LocalDate.now());
+                task.setIndate(LocalDateTime.now());
+                taskMapper.insert(task);
+
+
+                executorCell.setCellType(CellType.STRING);
+                String executorStr = executorCell.getStringCellValue();
+
+                String[] strings = executorStr.split(",");
+
+                StringJoiner exectorIds = new StringJoiner(",");
+                StringJoiner exectorColors = new StringJoiner(",");
+                for (int i = 0; i < strings.length; i++) {
+                    TaskExecutor taskExecutor = new TaskExecutor();
+                    String string = strings[i];
+                    Optional<User> first = allUserList.stream().filter(u -> u.getName().equals(string)).findFirst();
+                    if (!first.isPresent()) {
+                        throw  new Exception("第"+(rowIndex+1)+"行,执行人填写有误");
+                    }
+                    taskExecutor.setTaskId(task.getId());
+                    User user = first.get();
+                    taskExecutor.setExecutorId(user.getId());
+                    taskExecutor.setExecutorName(user.getName());
+                    taskExecutor.setExecutorColor(user.getColor());
+                    taskExecutor.setPlanHours(task.getPlanHours());
+                    taskExecutor.setProjectId(task.getProjectId());
+
+                    Integer count = taskMapper.getUserConflitTaskCount(user.getId(), task.getId(), task.getStartDate(), task.getEndDate());
+                    if (count > 0) {
+                        throw  new Exception("第"+(rowIndex+1)+"行,执行人"+user.getName()+"在其他任务上有时间冲突");
+                    }
+
+                    Optional<Project> projectFirst = allProjectList.stream().filter(t -> t.getId().equals(task.getProjectId())).findFirst();
+                    projectFirst.ifPresent(project -> taskExecutor.setFirstAuditorId(project.getInchargerId()));
+                    Optional<Department> departmentOptional = departmentList.stream().filter(t -> t.getDepartmentId().equals(user.getDepartmentId())).findFirst();
+                    departmentOptional.ifPresent(department -> taskExecutor.setSecondAuditorId(department.getManagerId()));
+                    taskExecutor.setAuditStatus(TaskController.STATUS_FIRST_CHECK);
+                    taskExecutors.add(taskExecutor);
+
+                    exectorIds.add(user.getId());
+                    exectorColors.add(user.getColor());
+                }
+                task.setExecutorName(executorStr);
+                task.setExecutorId(exectorIds.toString());
+                task.setExecutorColor(exectorColors.toString());
+
+                taskMapper.updateById(task);
+                taskExecutorService.saveBatch(taskExecutors);
+
+                //给第一审核人发送信息提醒
+                log.info("添加工作计划,给第一审核人发送信息提醒");
+                Optional<Project> projectFirst = allProjectList.stream().filter(t -> t.getId().equals(task.getProjectId())).findFirst();
+                if (projectFirst.isPresent()) {
+                    Project project = projectFirst.get();
+                    Information information = new Information();
+                    information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
+                    information.setTaskId(task.getId());
+                    information.setType(11);
+                    information.setTime(LocalDateTime.now());
+                    Optional<User> first = allUserList.stream().filter(u -> u.getId().equals(project.getInchargerId())).findFirst();
+                    if (first.isPresent()) {
+                        User owner = first.get();
+                        information.setUserId(owner.getId());
+                    }
+                    informationService.save(information);
+                }
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            //httpRespMsg.setError("文件处理出错");
+            httpRespMsg.setError(MessageUtils.message("file.error"));
+            return httpRespMsg;
+        } finally {
+            //关闭流
+            try {
+                if (outputStream != null && inputStream != null) {
+                    outputStream.close();
+                    inputStream.close();
+                    System.out.println("流已关闭");
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            System.out.println(file.delete());
+        }
+        return httpRespMsg;
+    }
+
     @Override
     public HttpRespMsg delete(TaskGroup item) {
         HttpRespMsg msg = new HttpRespMsg();

+ 115 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/resources/mapper/ReportMapper.xml

@@ -1569,5 +1569,120 @@
         </foreach>
         group by project_id, extra_field4,extra_field5
     </select>
+    <select id="getTaskPlanNeedCheckStatisticsList" resultType="java.util.HashMap">
+        SELECT
+            u.id,
+            u.name,
+            d.department_name,
+            COUNT(*) AS total
+        FROM
+            user u
+                JOIN
+            department d ON u.department_id = d.department_id
+                JOIN (
+                SELECT
+                    te.first_auditor_id,
+                    te.second_auditor_id,
+                    te.audit_status
+                FROM
+                    task t
+                        JOIN
+                    task_executor te ON t.id = te.task_id
+                WHERE
+                    t.company_id = #{companyId}
+                  AND te.first_auditor_id IS NOT NULL
+                  AND te.second_auditor_id IS NOT NULL
+                  AND te.audit_status IN (3, 4)
+
+                    <if test="startDate != null and endDate != null">
+                        AND (
+
+                        ((t.start_date IS NULL OR t.start_date &lt;= #{endDate}) AND (t.end_date &gt;= #{startDate}))
+                        OR
+
+                        ((t.end_date IS NULL OR t.end_date &gt;= #{startDate}) AND (t.start_date &lt;= #{endDate}))
+                        OR
+
+                        (t.start_date &gt;= #{startDate} AND t.end_date &lt;= #{endDate})
+                        OR
+
+                        (t.start_date &lt;= #{startDate} AND t.end_date &gt;= #{endDate})
+                        )
+                    </if>
+                    <if test="startDate != null and endDate == null">
+                        AND (t.end_date IS NOT NULL AND t.end_date &gt;= #{startDate})
+                    </if>
+                    <if test="startDate == null and endDate != null">
+                        AND (t.start_date IS NOT NULL AND t.start_date &lt;= #{endDate})
+                    </if>
+
+                GROUP BY
+                    t.id
+            ) b ON (u.id = b.first_auditor_id AND b.audit_status = 3)
+                OR (u.id = b.second_auditor_id AND b.audit_status = 4)
+        <where>
+            <if test="userId!=null and userId!=''">
+                and u.id =#{userId}
+            </if>
+        </where>
+        GROUP BY
+            u.id, u.name, d.department_name
+        ORDER BY
+            u.id
+        <if test="page !=null and size !=null">
+            LIMIT #{page},#{size}
+        </if>
+    </select>
+    <select id="getTaskPlanNeedCheckStatisticsCount" resultType="java.lang.Integer">
+        SELECT
+            COUNT(DISTINCT u.id) AS total_count
+        FROM
+            user u
+                JOIN
+            department d ON u.department_id = d.department_id
+                JOIN (
+                SELECT
+                    DISTINCT
+                    te.first_auditor_id,
+                    te.second_auditor_id,
+                    te.audit_status
+                FROM
+                    task t
+                        JOIN
+                    task_executor te ON t.id = te.task_id
+                WHERE
+                    t.company_id = #{companyId}
+                  AND te.first_auditor_id IS NOT NULL
+                  AND te.second_auditor_id IS NOT NULL
+                  AND te.audit_status IN (3, 4)
+                <if test="startDate != null and endDate != null">
+                    AND (
+
+                    ((t.start_date IS NULL OR t.start_date &lt;= #{endDate}) AND (t.end_date &gt;= #{startDate}))
+                    OR
+
+                    ((t.end_date IS NULL OR t.end_date &gt;= #{startDate}) AND (t.start_date &lt;= #{endDate}))
+                    OR
+
+                    (t.start_date &gt;= #{startDate} AND t.end_date &lt;= #{endDate})
+                    OR
+
+                    (t.start_date &lt;= #{startDate} AND t.end_date &gt;= #{endDate})
+                    )
+                </if>
+                <if test="startDate != null and endDate == null">
+                    AND (t.end_date IS NOT NULL AND t.end_date &gt;= #{startDate})
+                </if>
+                <if test="startDate == null and endDate != null">
+                    AND (t.start_date IS NOT NULL AND t.start_date &lt;= #{endDate})
+                </if>
+            ) b ON (u.id = b.first_auditor_id AND b.audit_status = 3)
+                OR (u.id = b.second_auditor_id AND b.audit_status = 4)
+        <where>
+            <if test="userId!=null and userId!=''">
+                and u.id =#{userId}
+            </if>
+        </where>
+    </select>
 
 </mapper>