|
@@ -2,18 +2,24 @@ package cn.cslg.pas.service.business;
|
|
|
|
|
|
import cn.cslg.pas.common.dto.business.ReferencesDTO;
|
|
|
import cn.cslg.pas.common.dto.business.ReferencesUpdateDTO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
|
import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.cronModel.SystemFile;
|
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
import cn.cslg.pas.common.vo.business.ReferencesVO;
|
|
|
+import cn.cslg.pas.domain.business.Project;
|
|
|
import cn.cslg.pas.domain.business.References;
|
|
|
+import cn.cslg.pas.domain.business.ReportProject;
|
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.mapper.ReferencesMapper;
|
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
|
+import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -22,7 +28,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Author xiexiang
|
|
@@ -40,6 +45,12 @@ public class ReferencesService extends ServiceImpl<ReferencesMapper, References>
|
|
|
@Autowired
|
|
|
private FileManagerService fileManagerService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PermissionService permissionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProjectService projectService;
|
|
|
+
|
|
|
/**
|
|
|
* 上传报告文档
|
|
|
* @param referencesDTO
|
|
@@ -47,8 +58,6 @@ public class ReferencesService extends ServiceImpl<ReferencesMapper, References>
|
|
|
*/
|
|
|
public Integer add(ReferencesDTO referencesDTO){
|
|
|
if (referencesDTO != null) {
|
|
|
- References references = new References();
|
|
|
- BeanUtils.copyProperties(referencesDTO, references);
|
|
|
//获取登录人信息
|
|
|
PersonnelVO personnelVO = new PersonnelVO();
|
|
|
try {
|
|
@@ -56,6 +65,8 @@ public class ReferencesService extends ServiceImpl<ReferencesMapper, References>
|
|
|
} catch (Exception e) {
|
|
|
throw new UnLoginException("未登录");
|
|
|
}
|
|
|
+ References references = new References();
|
|
|
+ BeanUtils.copyProperties(referencesDTO, references);
|
|
|
references.setCreateId(personnelVO.getId());
|
|
|
references.insert();
|
|
|
return references.getId();
|
|
@@ -64,6 +75,11 @@ public class ReferencesService extends ServiceImpl<ReferencesMapper, References>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新
|
|
|
+ * @param referencesUpdateDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public Integer update(ReferencesUpdateDTO referencesUpdateDTO){
|
|
|
if (referencesUpdateDTO != null) {
|
|
|
Integer id = referencesUpdateDTO.getId();
|
|
@@ -76,37 +92,111 @@ public class ReferencesService extends ServiceImpl<ReferencesMapper, References>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ * @param ids
|
|
|
+ */
|
|
|
public void delete(List<Integer> ids){
|
|
|
if (!ids.isEmpty()) {
|
|
|
this.removeBatchByIds(ids);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public List<ReferencesVO> query(Integer projectId){
|
|
|
- List<ReferencesVO> referencesVOS = new ArrayList<>();
|
|
|
+ /**
|
|
|
+ * 查询
|
|
|
+ * @param projectId
|
|
|
+ * @param pageNum
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ReferencesVO> query(Integer projectId, int pageNum, int pageSize) {
|
|
|
+ Page<References> page = new Page<>(pageNum, pageSize);
|
|
|
LambdaQueryWrapper<References> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(References::getProjectId, projectId);
|
|
|
- List<References> references = this.list(queryWrapper);
|
|
|
+ IPage<References> referencesPage = this.page(page, queryWrapper);
|
|
|
+ List<References> references = referencesPage.getRecords();
|
|
|
+ List<ReferencesVO> referencesVOS = this.loadReferencesVO(references);
|
|
|
+ return referencesVOS;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ReferencesVO> loadReferencesVO(List<References> references){
|
|
|
+ List<ReferencesVO> referencesVOS = new ArrayList<>();
|
|
|
if (!references.isEmpty()) {
|
|
|
- List<String> fileGuids = references.stream().map(References::getFileGuid).collect(Collectors.toList());
|
|
|
- if (fileGuids.size() != 0) {
|
|
|
+ List<String> fileGuids = new ArrayList<>();
|
|
|
+ List<String> createIds = new ArrayList<>();
|
|
|
+ List<Integer> projectIds = new ArrayList<>();
|
|
|
+ references.forEach(item -> {
|
|
|
+ if (item.getProjectId() != null) {
|
|
|
+ projectIds.add(item.getProjectId());
|
|
|
+ }
|
|
|
+ if (item.getFileGuid() != null) {
|
|
|
+ fileGuids.add(item.getFileGuid());
|
|
|
+ }
|
|
|
+ if (item.getCreateId() != null) {
|
|
|
+ createIds.add(item.getCreateId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!fileGuids.isEmpty()) {
|
|
|
+ List<Personnel> personnels = new ArrayList<>();
|
|
|
+ List<SystemFile> systemFiles = new ArrayList<>();
|
|
|
+ List<Project> projects = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ //查询创建人名称
|
|
|
+ if (createIds.size() != 0) {
|
|
|
+ String res = permissionService.getPersonnelByIdsFromPCS(createIds);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException("查询创建人信息错误");
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
String res = fileManagerService.getSystemFileFromFMS(fileGuids);
|
|
|
- List<SystemFile> systemFiles = JSONObject.parseArray(res, SystemFile.class);
|
|
|
- references.forEach(item -> {
|
|
|
- ReferencesVO referencesVO = new ReferencesVO();
|
|
|
- BeanUtils.copyProperties(item, referencesVO);
|
|
|
- SystemFile systemFile = systemFiles.stream().filter(file -> file.getGuid() != null && file.getGuid().equals(item.getFileGuid())).findFirst().orElse(null);
|
|
|
- if (systemFile != null) {
|
|
|
- referencesVO.setType(systemFile.getType());
|
|
|
- }
|
|
|
- referencesVOS.add(referencesVO);
|
|
|
- });
|
|
|
+ systemFiles = JSONObject.parseArray(res, SystemFile.class);
|
|
|
} catch (Exception e) {
|
|
|
throw new XiaoShiException("查询文件信息错误");
|
|
|
}
|
|
|
+
|
|
|
+ LambdaQueryWrapper<Project> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.in(Project::getId, projectIds);
|
|
|
+ projects = projectService.list(queryWrapper1);
|
|
|
+
|
|
|
+ for (References item : references) {
|
|
|
+ ReferencesVO referencesVO = new ReferencesVO();
|
|
|
+ BeanUtils.copyProperties(item, referencesVO);
|
|
|
+ Project project = projects
|
|
|
+ .stream()
|
|
|
+ .filter(p -> p.getId() != null && p.getId().equals(item.getProjectId()))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (project !=null) {
|
|
|
+ referencesVO.setProjectName(project.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ SystemFile systemFile = systemFiles
|
|
|
+ .stream()
|
|
|
+ .filter(file -> file.getGuid() != null && file.getGuid().equals(item.getFileGuid()))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (systemFile != null) {
|
|
|
+ referencesVO.setType(systemFile.getType());
|
|
|
+ }
|
|
|
+
|
|
|
+ Personnel personnel = personnels
|
|
|
+ .stream()
|
|
|
+ .filter(person -> person.getId() != null && person.getId().equals(item.getCreateId()))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (personnel != null) {
|
|
|
+ referencesVO.setCreateName(personnel.getPersonnelName());
|
|
|
+ }
|
|
|
+ referencesVOS.add(referencesVO);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
return referencesVOS;
|
|
|
}
|
|
|
+
|
|
|
}
|