Browse Source

# 巡检项目选择树接口修改

zhongwei
haungxing 1 year ago
parent
commit
03eee141b9
  1. 7
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/ProjectService.java
  2. 43
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ProjectServiceImpl.java
  3. 8
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java

7
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/ProjectService.java

@ -49,4 +49,11 @@ public interface ProjectService extends BaseService<ProjectEntity>{
* @return Map key-emCode value-projectVO * @return Map key-emCode value-projectVO
*/ */
List<ProjectVO> getProjectAndContentByEmCodes(String emCodes); List<ProjectVO> getProjectAndContentByEmCodes(String emCodes);
/**
* 获取项目树 - 一级机构 二级项目设备
* @param project - isNewModel 是否只查询emCode不为空情况下的项目树
* @return 机构-项目树
*/
List<Map<String,Object>> deptProjectTree(ProjectDTO project);
} }

43
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ProjectServiceImpl.java

@ -3,8 +3,10 @@ package com.hnac.hzinfo.inspect.obj.services.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzinfo.inspect.Constants; import com.hnac.hzinfo.inspect.Constants;
import com.hnac.hzinfo.inspect.obj.ObjectConstants; import com.hnac.hzinfo.inspect.obj.ObjectConstants;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
@ -27,14 +29,13 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
import org.springblade.system.feign.ISysClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.Collection; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -47,6 +48,7 @@ import java.util.stream.Stream;
public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, ProjectEntity> implements ProjectService { public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, ProjectEntity> implements ProjectService {
private final ContentService contentService; private final ContentService contentService;
private final ISysClient sysClient;
//private final ProjectContentService projectContentService; //private final ProjectContentService projectContentService;
@Override @Override
@ -139,4 +141,37 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, ProjectEn
query.setSize(-1); query.setSize(-1);
return Stream.of(emCodes.split(",")).map(emCode -> this.getProjectAndContentByEmCode(emCode, new ContentDTO(), query)).collect(Collectors.toList()); return Stream.of(emCodes.split(",")).map(emCode -> this.getProjectAndContentByEmCode(emCode, new ContentDTO(), query)).collect(Collectors.toList());
} }
@Override
public List<Map<String, Object>> deptProjectTree(ProjectDTO project) {
// 获取第一层机构
QueryWrapper<ProjectEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.copy(project, ProjectEntity.class));
queryWrapper.select("create_dept deptId")
.isNotNull(project.getIsNewModel(), "em_code")
.ne(project.getIsNewModel(), "em_code", "")
.groupBy("create_dept");
List<Map<String,Object>> list = this.getBaseMapper().selectMaps(queryWrapper);
return list.stream().filter(Func::isNotEmpty).peek(deptMap -> {
Long deptId = (Long) deptMap.get("deptId");
// 获取机构名称
deptMap.put("deptName",Optional.ofNullable(sysClient.getDeptName(deptId).getData()).orElse(String.valueOf(deptId)));
// 获取机构下的项目
deptMap.put("children",this.getProjectTreeChildren(project,deptId));
}).collect(Collectors.toList());
}
/**
* 获取项目树中 机构下巡检项目的子集
* @param project 筛选条件
* @param deptId 机构ID
* @return 巡检项目子集
*/
private List<Map<String,Object>> getProjectTreeChildren(ProjectDTO project,Long deptId) {
QueryWrapper<ProjectEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.copy(project, ProjectEntity.class));
queryWrapper.eq(Func.isNotEmpty(deptId),"create_dept",deptId);
queryWrapper.isNotNull(project.getIsNewModel(), "em_code");
queryWrapper.ne(project.getIsNewModel(), "em_code", "");
queryWrapper.select("em_code","name");
return this.listMaps(queryWrapper);
}
} }

8
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java

@ -84,12 +84,8 @@ public class ProjectController {
@GetMapping("/selectProject") @GetMapping("/selectProject")
@ApiOperation(value = "巡检项目列表-下拉框", notes = "巡检项目列表-下拉框") @ApiOperation(value = "巡检项目列表-下拉框", notes = "巡检项目列表-下拉框")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public R<List<ProjectVO>> selectProject(ProjectDTO project) { public R<List<Map<String,Object>>> selectProject(ProjectDTO project) {
LambdaQueryWrapper<ProjectEntity> queryWrapper = Condition.getQueryWrapper(new ProjectEntity(),project); return R.data(projectService.deptProjectTree(project));
queryWrapper.isNotNull(project.getIsNewModel(),ProjectEntity::getEmCode);
queryWrapper.ne(project.getIsNewModel(),ProjectEntity::getEmCode,"");
List<ProjectEntity> projectList = projectService.list(queryWrapper);
return R.data(ProjectWrapper.build().listVO(projectList));
} }
/** /**

Loading…
Cancel
Save