liujie
2026-04-13 eff3c1988ffa0537419d6646688f4119cebe138a
update
5个文件已修改
68 ■■■■■ 已修改文件
admin-server/src/main/java/com/estate/expert/admin/controller/admin/option/OptionEntityController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin-server/src/main/java/com/estate/expert/admin/service/ProjectService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin-server/src/main/java/com/estate/expert/admin/service/impl/ProjectServiceImpl.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin-server/src/main/resources/mapper/CheckMapper.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin-server/src/main/resources/mapper/OnDutyMapper.xml 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin-server/src/main/java/com/estate/expert/admin/controller/admin/option/OptionEntityController.java
@@ -92,6 +92,13 @@
        return Result.success( projectService.listByTitle(name));
    }
    @ApiOperation(value = "计划可用项目下拉框")
    @RequestMapping("/availableProjects")
    public Result availableProjects(@RequestParam(value = "title", required = false) String title,
                                    @RequestParam("planId") Integer planId) {
        return Result.success(SelectOptionVo.buildOptions(title, projectService.listAvailableByPlan(planId)));
    }
    //////////  综合体系  //////////
    @ApiOperation(value = "综合模型")
admin-server/src/main/java/com/estate/expert/admin/service/ProjectService.java
@@ -41,4 +41,12 @@
    List<Project> listByClient(Integer clientId);
    List<Project> listByTitle(String name);
    /**
     * 获取计划可用的项目列表
     * 根据plan中的clientId获取相应的project,同时过滤掉plan对应的没有删除的task中已经包含的project
     * @param planId 计划ID
     * @return 可用的项目列表
     */
    List<Project> listAvailableByPlan(Integer planId);
}
admin-server/src/main/java/com/estate/expert/admin/service/impl/ProjectServiceImpl.java
@@ -4,6 +4,9 @@
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;
@@ -11,10 +14,7 @@
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;
@@ -44,6 +44,13 @@
    @Resource
    private ScreenAccountMybatisMapper screenAccountMybatisMapper;
    @Resource
    private CheckTaskRepository checkTaskRepository;
    @Resource
    private PlanService planService;
    @Override
    public PageResp<ProjectDto> list(String keyword,
@@ -119,6 +126,32 @@
            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();
    }
}
admin-server/src/main/resources/mapper/CheckMapper.xml
@@ -16,8 +16,8 @@
        <if test="request.planId != null">
            and t1.plan_id = #{request.planId}
        </if>
        <if test="request.projectId != null">
            and t1.project_id = #{request.projectId}
        <if test="request.taskId != null">
            and t1.check_task_id = #{request.taskId}
        </if>
        <if test="request.clientId != null">
            and t1.client_id = #{request.clientId}
@@ -51,8 +51,8 @@
        <if test="request.planId != null">
            and t1.plan_id = #{request.planId}
        </if>
        <if test="request.projectId != null">
            and t1.project_id = #{request.projectId}
        <if test="request.taskId != null">
            and t1.check_task_id = #{request.taskId}
        </if>
        <if test="request.clientId != null">
            and t1.client_id = #{request.clientId}
admin-server/src/main/resources/mapper/OnDutyMapper.xml
@@ -51,8 +51,8 @@
        <if test="request.planId != null">
            and t1.plan_id = #{request.planId}
        </if>
        <if test="request.projectId != null">
            and t1.project_id = #{request.projectId}
        <if test="request.taskId != null">
            and t1.check_task_id = #{request.taskId}
        </if>
        <if test="request.clientId != null">
            and t1.client_id = #{request.clientId}