Browse Source

# 巡检对象设备树-机构层级接口

zhongwei
haungxing 1 year ago
parent
commit
eae7059715
  1. 18
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java

18
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<List<ProjectVO>> getProjectAndContentByEmCodes(@RequestParam String emCodes) {
return R.data(projectService.getProjectAndContentByEmCodes(emCodes));
}
@GetMapping("/getProjectDept")
@ApiOperation(value = "获取巡检项目下的机构")
@ApiOperationSupport(order = 9)
public R<List> getProjectDept() {
QueryWrapper<ProjectEntity> queryWrapper = Wrappers.<ProjectEntity>query().select("distinct create_dept deptId");
List<Long> deptIdList = projectService.listObjs(queryWrapper, Func::toLong);
List<HashMap> 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);
}
}

Loading…
Cancel
Save