无关风月
7 天以前 53d014edd19f57125c355abe71ec5b478500e610
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TInspectorServiceImpl.java
@@ -38,44 +38,87 @@
    private TTaskMapper taskMapper;
    @Autowired
    private SysUserMapper sysUserMapper;
    @Autowired
    private TLocationMapper locationMapper;
    @Override
    public PageInfo<InspectorListVO> pageList(InsepectorListQuery query) {
        List<SysUser> sysUsers = sysUserMapper.selectAllList();
        PageInfo<InspectorListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<InspectorListVO> list = this.baseMapper.pageList(query,pageInfo);
        List<TTaskDetail> tTaskDetails = taskDetailMapper.selectList(new LambdaQueryWrapper<TTaskDetail>()
                .orderByDesc(BaseModel::getCreateTime)
                .in(TTaskDetail::getHandleType, Arrays.asList(1,4)));
        List<TTask> tTasks = taskMapper.selectList(null);
        List<TLocation> locations = locationMapper.selectList(null);
        for (InspectorListVO taskListVO : list) {
            TTask tTask = tTasks.stream().filter(e -> e.getId().equals(taskListVO.getTaskId())).findFirst().orElse(null);
            if (tTask!=null){
                SysUser sysUser = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(tTask.getPatrolInspector()))).findFirst().orElse(null);
                if (sysUser!=null){
                    if (sysUser.getDeptType()==2){
                        TDept tDept = deptMapper.selectById(tTask.getPatrolInspectorDept());
                        if (tDept!=null){
                            taskListVO.setDeptName(tDept.getDeptName());
                        }
                    }else{
                        TProjectDept tProjectDept = projectDeptMapper.selectById(tTask.getPatrolInspectorDept());
                        if (tProjectDept!=null){
//            TTask tTask = tTasks.stream().filter(e -> e.getId().equals(taskListVO.getTaskId())).findFirst().orElse(null);
//            if (tTask!=null){
//                taskListVO.setTaskType(tTask.getTaskType());
//
//            }
            TLocation tLocation = locations.stream().filter(e -> e.getId().equals(taskListVO.getLocationId())).findFirst()
                    .orElse(null);
            if (tLocation == null){
                continue;
            }
            SysUser sysUser = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(tLocation.getLocationLeader()))).findFirst().orElse(null);
            if (sysUser!=null){
                if (sysUser.getDeptType()==2){
                    TDept tDept = deptMapper.selectById(sysUser.getDeptId());
                    if (tDept!=null){
                        taskListVO.setDeptName(tDept.getDeptName());
                    }
                }else{
                    TProjectDept tProjectDept = projectDeptMapper.selectById(sysUser.getDeptId());
                    if (tProjectDept != null) {
                        if (!tProjectDept.getParentId().equals("0")) {
                            TProjectDept tProjectDept1 = projectDeptMapper.selectById(tProjectDept.getParentId());
                            if (tProjectDept1 != null) {
                                taskListVO.setDeptName(tProjectDept1.getProjectName() + ">" + tProjectDept.getProjectName());
                            }
                        } else {
                            taskListVO.setDeptName(tProjectDept.getProjectName());
                        }
                    }
                }
                TTaskDetail tTaskDetail = tTaskDetails.stream().filter(e -> e.getTaskId().equals(taskListVO.getId())).findFirst().orElse(null);
                if (tTaskDetail!=null){
                    taskListVO.setPicture(tTaskDetail.getPicture());
                    taskListVO.setClearStatus(tTaskDetail.getClearStatus());
                }
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
    public List<InspectorListVO> pageListExport(InsepectorListQuery query) {
        List<SysUser> sysUsers = sysUserMapper.selectAllList();
        PageInfo<InspectorListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<InspectorListVO> list = this.baseMapper.pageListExport(query,pageInfo);
        List<TLocation> locations = locationMapper.selectList(null);
        for (InspectorListVO taskListVO : list) {
            TLocation tLocation = locations.stream().filter(e -> e.getId().equals(taskListVO.getLocationId())).findFirst()
                    .orElse(null);
            if (tLocation == null){
                continue;
            }
            SysUser sysUser = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(tLocation.getLocationLeader()))).findFirst().orElse(null);
            if (sysUser!=null){
                if (sysUser.getDeptType()==2){
                    TDept tDept = deptMapper.selectById(sysUser.getDeptId());
                    if (tDept!=null){
                        taskListVO.setDeptName(tDept.getDeptName());
                    }
                }else{
                    TProjectDept tProjectDept = projectDeptMapper.selectById(sysUser.getDeptId());
                    if (tProjectDept != null) {
                        if (!tProjectDept.getParentId().equals("0")) {
                            TProjectDept tProjectDept1 = projectDeptMapper.selectById(tProjectDept.getParentId());
                            if (tProjectDept1 != null) {
                                taskListVO.setDeptName(tProjectDept1.getProjectName() + ">" + tProjectDept.getProjectName());
                            }
                        } else {
                            taskListVO.setDeptName(tProjectDept.getProjectName());
                        }
                    }
                }
            }
        }
        pageInfo.setRecords(list);
        return list;
    }
}