diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java index bf4cfa5..2e2aabd 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java @@ -32,6 +32,8 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; @@ -41,6 +43,7 @@ import javax.validation.constraints.NotNull; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -59,6 +62,8 @@ public class ProjectController { private TemplateProjectService templateProjectService; @Autowired private ProjectContentServiceImpl projectContentService; + @Autowired + private ISysClient sysClient; /** * 巡检项目列表 @@ -178,4 +183,17 @@ public class ProjectController { public R> getProjectAndContentByEmCodes(@RequestParam String emCodes) { return R.data(projectService.getProjectAndContentByEmCodes(emCodes)); } + + @GetMapping("/getProjectDept") + @ApiOperation(value = "获取巡检项目下的机构") + @ApiOperationSupport(order = 9) + public R getProjectDept() { + QueryWrapper queryWrapper = Wrappers.query().select("distinct create_dept deptId"); + List deptIdList = projectService.listObjs(queryWrapper, Func::toLong); + List result = deptIdList.stream().map(deptId -> new HashMap() {{ + put("deptId", deptId); + put("deptName", Optional.ofNullable(sysClient.getDept(deptId).getData()).map(Dept::getDeptName).orElse(deptId.toString())); + }}).collect(Collectors.toList()); + return R.data(result); + } }