|
|
|
@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.entity.ProjectContentEntity; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.request.ProjectContentRequest; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.services.ProjectContentService; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.services.ProjectService; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
@ -16,11 +18,14 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
|
import javax.validation.constraints.NotNull; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @ClassName ProjectClient |
|
|
|
@ -35,6 +40,7 @@ import java.util.List;
|
|
|
|
|
public class ProjectClient extends BladeController implements IProjectClient { |
|
|
|
|
|
|
|
|
|
private final ProjectService projectService; |
|
|
|
|
private final ProjectContentService projectContentService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@PostMapping(ADD_PROJECT_AND_CONTENT) |
|
|
|
@ -55,8 +61,13 @@ public class ProjectClient extends BladeController implements IProjectClient {
|
|
|
|
|
@GetMapping(GET_EM_CODES_BY_DEPT_ID) |
|
|
|
|
public R<List<String>> getEmCodesByDeptId(@RequestParam Long deptId) { |
|
|
|
|
QueryWrapper<ProjectEntity> queryWrapper = Wrappers.<ProjectEntity>query().eq("create_dept", deptId); |
|
|
|
|
queryWrapper.select("distinct em_code emCode"); |
|
|
|
|
queryWrapper.ne("em_code","").isNotNull("em_code"); |
|
|
|
|
return R.data(projectService.listObjs(queryWrapper, String::valueOf)); |
|
|
|
|
List<ProjectEntity> projects = projectService.list(queryWrapper); |
|
|
|
|
if(CollectionUtil.isNotEmpty(projects)) { |
|
|
|
|
QueryWrapper<ProjectContentEntity> in = Wrappers.<ProjectContentEntity>query().select("distinct project_id").in("project_id", projects.stream().map(ProjectEntity::getId).collect(Collectors.toList())); |
|
|
|
|
List<Long> projectIds = projectContentService.listObjs(in, Func::toLong); |
|
|
|
|
return R.data(projects.stream().filter(project -> projectIds.contains(project.getId())).map(ProjectEntity::getEmCode).collect(Collectors.toList())); |
|
|
|
|
} |
|
|
|
|
return R.data(projects.stream().map(ProjectEntity::getEmCode).collect(Collectors.toList())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|