|
@@ -3,17 +3,19 @@ package cn.cslg.pas.service.business;
|
|
|
import cn.cslg.pas.common.dto.AddNoveltyProjectDTO;
|
|
|
import cn.cslg.pas.common.dto.NoveltyProjectIdDTO;
|
|
|
import cn.cslg.pas.common.dto.QueryNoveltyProjectDTO;
|
|
|
-import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
-import cn.cslg.pas.common.model.cronModel.Records;
|
|
|
-import cn.cslg.pas.common.model.cronModel.SystemFile;
|
|
|
+import cn.cslg.pas.common.model.cronModel.*;
|
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
+import cn.cslg.pas.common.vo.DepartmentVO;
|
|
|
import cn.cslg.pas.common.vo.QueryNoveltyProjectVO;
|
|
|
+import cn.cslg.pas.domain.business.AssoProjectFile;
|
|
|
import cn.cslg.pas.domain.business.NoveltyProject;
|
|
|
import cn.cslg.pas.domain.business.Project;
|
|
|
import cn.cslg.pas.mapper.NoveltyProjectMapper;
|
|
|
import cn.cslg.pas.mapper.ProjectMapper;
|
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
|
+import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -32,6 +34,7 @@ import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -44,34 +47,20 @@ public class NoveltyProjectService extends ServiceImpl<NoveltyProjectMapper, Nov
|
|
|
private FileManagerService fileManagerService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private PermissionService permissionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private ProjectMapper projectMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private NoveltyProjectMapper noveltyProjectMapper;
|
|
|
|
|
|
|
|
|
- public Records queryNoveltyProject(QueryNoveltyProjectDTO vo) {
|
|
|
+ public Records queryNoveltyProject(QueryNoveltyProjectDTO vo) throws IOException {
|
|
|
vo.setCurrent(vo.getCurrent() - 1);
|
|
|
//查询数据库
|
|
|
List<QueryNoveltyProjectVO> noveltyProjectVOS = noveltyProjectMapper.queryNoveltyProject(vo);
|
|
|
- if (!CollectionUtils.isEmpty(noveltyProjectVOS)) {
|
|
|
- noveltyProjectVOS.forEach(i -> {
|
|
|
- if (StringUtils.isNotEmpty(i.getPicture())) {
|
|
|
- List<String> guids = new ArrayList<>();
|
|
|
- guids.add(i.getPicture());
|
|
|
- String res = null;
|
|
|
- try {
|
|
|
- res = fileManagerService.getSystemFileFromFMS(guids);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(res)) {
|
|
|
- final List<SystemFile> systemFiles = JSONObject.parseArray(res, SystemFile.class);
|
|
|
- i.setSystemFileList(systemFiles);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ this.loadNoveltyProjectVOS(noveltyProjectVOS);
|
|
|
//查询总数
|
|
|
final Long total = noveltyProjectMapper.queryNoveltyProjectCount(vo);
|
|
|
Records records = new Records();
|
|
@@ -82,6 +71,109 @@ public class NoveltyProjectService extends ServiceImpl<NoveltyProjectMapper, Nov
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
+ public void loadNoveltyProjectVOS(List<QueryNoveltyProjectVO> noveltyProjectVOS) throws IOException {
|
|
|
+ if (!CollectionUtils.isEmpty(noveltyProjectVOS)) {
|
|
|
+ List<String> createIds = new ArrayList<>();
|
|
|
+ List<String> departmentIds = new ArrayList<>();
|
|
|
+ List<Integer> clientIds = new ArrayList<>();
|
|
|
+ List<DepartmentVO> departmentVOS = new ArrayList<>();
|
|
|
+ List<Personnel> personnels = new ArrayList<>();
|
|
|
+ List<Client> clients = new ArrayList<>();
|
|
|
+ noveltyProjectVOS.forEach(item -> {
|
|
|
+ if (item.getCreateId() != null) {
|
|
|
+ createIds.add(item.getCreateId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.getHeadId() != null) {
|
|
|
+ createIds.add(item.getHeadId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.getDepartmentId() != null) {
|
|
|
+ departmentIds.add(item.getDepartmentId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.getEntrustType() != null && item.getEntrustType().equals(2)) {
|
|
|
+ departmentIds.add(item.getEntrustId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.getEntrustType() != null && item.getEntrustType().equals(1)) {
|
|
|
+ clientIds.add(Integer.parseInt(item.getEntrustId()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //查询创建人名称
|
|
|
+ if (!CollectionUtils.isEmpty(createIds)) {
|
|
|
+ String res = permissionService.getPersonnelByIdsFromPCS(createIds);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(res);
|
|
|
+ personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询部门名称
|
|
|
+ if (!CollectionUtils.isEmpty(departmentIds)) {
|
|
|
+ String json = permissionService.getDepartmentByIdsFromPCS(departmentIds);
|
|
|
+ departmentVOS = JSON.parseArray(json, DepartmentVO.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询客户名称
|
|
|
+ if (!CollectionUtils.isEmpty(clientIds)) {
|
|
|
+ String res = permissionService.getClientByIdsFromPCS(clientIds);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(res);
|
|
|
+ clients = JSONObject.parseArray(jsonObject.getString("data"), Client.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SystemFile> systemFiles = new ArrayList<>();
|
|
|
+ List<String> guids = noveltyProjectVOS.stream().map(QueryNoveltyProjectVO::getPicture).collect(Collectors.toList());
|
|
|
+ //查询文件
|
|
|
+ if (!CollectionUtils.isEmpty(guids)) {
|
|
|
+ String res = fileManagerService.getSystemFileFromFMS(guids);
|
|
|
+ systemFiles = JSON.parseArray(res, SystemFile.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (QueryNoveltyProjectVO noveltyProjectVO : noveltyProjectVOS) {
|
|
|
+ //装载人员信息
|
|
|
+ Personnel personnel = personnels.stream().filter(item -> item.getId().equals(noveltyProjectVO.getCreateId())).findFirst().orElse(null);
|
|
|
+ if (personnel != null) {
|
|
|
+ noveltyProjectVO.setCreateName(personnel.getPersonnelName());
|
|
|
+ }
|
|
|
+ //装载负责人
|
|
|
+ if (noveltyProjectVO.getHeadId() != null) {
|
|
|
+ Personnel headPersonnel = personnels.stream().filter(item -> item.getId().equals(noveltyProjectVO.getHeadId())).findFirst().orElse(null);
|
|
|
+ if (headPersonnel != null) {
|
|
|
+ noveltyProjectVO.setHeadName(headPersonnel.getPersonnelName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //装载部门
|
|
|
+ if (noveltyProjectVO.getDepartmentId() != null) {
|
|
|
+ DepartmentVO departmentVO = departmentVOS.stream().filter(item -> item.getDepartId().equals(noveltyProjectVO.getDepartmentId())).findFirst().orElse(null);
|
|
|
+ if (departmentVO != null) {
|
|
|
+ noveltyProjectVO.setDepartmentName(departmentVO.getDepartName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //裝载委托方
|
|
|
+ if (noveltyProjectVO.getEntrustType() != null) {
|
|
|
+ //当委托方为客户时
|
|
|
+ if (noveltyProjectVO.getEntrustType().equals(1)) {
|
|
|
+ Client client = clients.stream().filter(item -> item.getId().equals(Integer.parseInt(noveltyProjectVO.getEntrustId()))).findFirst().orElse(null);
|
|
|
+ if (client != null) {
|
|
|
+ noveltyProjectVO.setEntrustName(client.getName());
|
|
|
+ }
|
|
|
+ } else if (noveltyProjectVO.getEntrustType().equals(2)) {
|
|
|
+ DepartmentVO departmentVO = departmentVOS.stream().filter(item -> item.getDepartId().equals(noveltyProjectVO.getEntrustId())).findFirst().orElse(null);
|
|
|
+ if (departmentVO != null) {
|
|
|
+ noveltyProjectVO.setEntrustName(departmentVO.getDepartName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //装载文件信息
|
|
|
+ if (StringUtils.isNotEmpty(noveltyProjectVO.getPicture())) {
|
|
|
+ SystemFile systemFile = systemFiles.stream().filter(i -> i.getGuid().equals(noveltyProjectVO.getPicture())).findFirst().orElse(null);
|
|
|
+ List<SystemFile> systemFileList = new ArrayList<>();
|
|
|
+ systemFileList.add(systemFile);
|
|
|
+ noveltyProjectVO.setSystemFileList(systemFileList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
|
public Integer addNoveltyProject(AddNoveltyProjectDTO vo) {
|