|
|
@ -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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|