| | |
| | | import com.estate.expert.admin.domain.business.device.usage.DeviceUsage; |
| | | import com.estate.expert.admin.domain.common.request.PageReq; |
| | | import com.estate.expert.admin.domain.common.response.PageResp; |
| | | import com.estate.expert.admin.domain.exam.task.check.CheckTask; |
| | | import com.estate.expert.admin.domain.exam.task.check.CheckTaskRepository; |
| | | import com.estate.expert.admin.domain.plan.Plan; |
| | | import com.estate.expert.admin.domain.project.Project; |
| | | import com.estate.expert.admin.domain.project.ProjectDto; |
| | | import com.estate.expert.admin.domain.project.ProjectRepository; |
| | |
| | | import com.estate.expert.admin.domain.repository.ScreenAccountMybatisMapper; |
| | | import com.estate.expert.admin.domain.standard.hierachy.HierarchyIds; |
| | | import com.estate.expert.admin.domain.user.User; |
| | | import com.estate.expert.admin.service.DeviceUsageService; |
| | | import com.estate.expert.admin.service.HierarchyService; |
| | | import com.estate.expert.admin.service.ProjectService; |
| | | import com.estate.expert.admin.service.UserFileService; |
| | | import com.estate.expert.admin.service.*; |
| | | import com.estate.expert.admin.service.common.CrudServiceBaseImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Resource |
| | | private ScreenAccountMybatisMapper screenAccountMybatisMapper; |
| | | |
| | | |
| | | @Resource |
| | | private CheckTaskRepository checkTaskRepository; |
| | | |
| | | @Resource |
| | | private PlanService planService; |
| | | |
| | | @Override |
| | | public PageResp<ProjectDto> list(String keyword, |
| | | List<ProjectType> projectTypes, List<Integer> clientIds, PageReq pageReq) { |
| | |
| | | |
| | | @Override |
| | | public List<Project> listByClient(Integer clientId) { |
| | | // clientId为空时查询所有项目 |
| | | if (clientId == null) { |
| | | return projectRepository.findProjects(null, null, null); |
| | | } |
| | | return projectRepository.findAllByClientIdAndDeleted(clientId, false); |
| | | } |
| | | @Override |
| | |
| | | address.setGps(location); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Project> listAvailableByPlan(Integer planId) { |
| | | // 根据planId获取计划,并从计划中获取clientId |
| | | Plan plan = planService.get(planId); |
| | | if (plan == null || plan.getClient() == null) { |
| | | return List.of(); |
| | | } |
| | | Integer clientId = plan.getClient().getId(); |
| | | |
| | | // 根据clientId获取所有未删除的项目 |
| | | List<Project> allProjects = projectRepository.findAllByClientIdAndDeleted(clientId, false); |
| | | |
| | | // 根据planId获取所有未删除的任务,并提取其中的项目ID |
| | | List<CheckTask> tasks = checkTaskRepository.findAllByPlanIdAndDeleted(planId, false); |
| | | List<Integer> usedProjectIds = tasks.stream() |
| | | .map(task -> task.getProject() != null ? task.getProject().getId() : null) |
| | | .filter(id -> id != null) |
| | | .distinct() |
| | | .toList(); |
| | | |
| | | // 过滤掉已经在任务中使用的项目 |
| | | return allProjects.stream() |
| | | .filter(project -> !usedProjectIds.contains(project.getId())) |
| | | .toList(); |
| | | } |
| | | } |
| | | |
| | | |