|
@@ -1,25 +1,31 @@
|
|
|
package cn.cslg.pas.service.business;
|
|
|
|
|
|
-import cn.cslg.pas.common.dto.business.PatentDigProjectDTO;
|
|
|
-import cn.cslg.pas.common.dto.business.ReportProjectDTO;
|
|
|
+import cn.cslg.pas.common.dto.business.PatentDigProjectFilesDTO;
|
|
|
+import cn.cslg.pas.common.dto.business.UpdatePatentDigProjectFilesDTO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
|
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.Records;
|
|
|
import cn.cslg.pas.common.model.request.GroupRequest;
|
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
|
-import cn.cslg.pas.domain.business.PatentDigProject;
|
|
|
+import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
+import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
+import cn.cslg.pas.common.vo.business.PatentDigProjectFilesVO;
|
|
|
import cn.cslg.pas.domain.business.PatentDigProjectFiles;
|
|
|
-import cn.cslg.pas.domain.business.Project;
|
|
|
-import cn.cslg.pas.domain.business.RdProject;
|
|
|
+import cn.cslg.pas.exception.UnLoginException;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.factorys.businessFactory.Business;
|
|
|
import cn.cslg.pas.mapper.PatentDigProjectFilesMapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
+import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import lombok.experimental.Accessors;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -30,12 +36,38 @@ import java.util.List;
|
|
|
public class PatentDigProjectFilesService extends ServiceImpl<PatentDigProjectFilesMapper, PatentDigProjectFiles> implements Business {
|
|
|
|
|
|
@Autowired
|
|
|
- private RdProjectService rdProjectService;
|
|
|
+ private CacheUtils cacheUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LoginUtils loginUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FormatQueryService formatQueryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PatentDigProjectFilesMapper patentDigProjectFilesMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PermissionService permissionService;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public Object queryMessage(QueryRequest queryRequest) throws Exception {
|
|
|
- return null;
|
|
|
+ //根据专题库/报告id查询自定义栏位
|
|
|
+ List<String> sqls = formatQueryService.reSqls(queryRequest,"patentDigProjectFiles");
|
|
|
+ //根据sql查询自定义栏位信息
|
|
|
+ List<PatentDigProjectFilesVO> patentDigProjectFilesVOS = patentDigProjectFilesMapper.getPatentDigProjectFiles(sqls.get(0), sqls.get(1), sqls.get(2));
|
|
|
+ //查询总数
|
|
|
+ Long total = patentDigProjectFilesMapper.getPatentDigProjectFilesCount(sqls.get(0));
|
|
|
+ //装载自定义栏位信息
|
|
|
+ this.loadPatentDigProjectFiles(patentDigProjectFilesVOS);
|
|
|
+ //装载返回信息
|
|
|
+ Records records = new Records();
|
|
|
+ records.setCurrent(queryRequest.getCurrent());
|
|
|
+ records.setSize(queryRequest.getSize());
|
|
|
+ records.setData(patentDigProjectFilesVOS);
|
|
|
+ records.setTotal(total);
|
|
|
+ return records;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -60,44 +92,76 @@ public class PatentDigProjectFilesService extends ServiceImpl<PatentDigProjectFi
|
|
|
|
|
|
@Override
|
|
|
public Object addMessage(Object object) {
|
|
|
- PatentDigProjectDTO patentDigProjectDTO = (PatentDigProjectDTO) object;
|
|
|
-
|
|
|
- PatentDigProject patentDigProject = new PatentDigProject();
|
|
|
- BeanUtils.copyProperties(patentDigProjectDTO, patentDigProject);
|
|
|
- Project project =new Project();
|
|
|
- project.setTenantId(1);
|
|
|
- project.setType(3);
|
|
|
- project.setCreateId("328");
|
|
|
- project.insert();
|
|
|
- patentDigProject.setProjectId(project.getId());
|
|
|
-
|
|
|
- //判断rdProjectId是否为空
|
|
|
- if (patentDigProjectDTO.getRdProjectId() == null) {
|
|
|
- //根据编号查询研发项目
|
|
|
- if (patentDigProjectDTO.getRdnumber() != null) {
|
|
|
- //根据研发项目编号查询研发项目
|
|
|
- LambdaQueryWrapper<RdProject> queryWrapper =new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(RdProject::getNumber,patentDigProjectDTO.getRdnumber());
|
|
|
- List<RdProject> rdProjects = rdProjectService.list(queryWrapper);
|
|
|
- if(rdProjects.size()!=0){
|
|
|
- patentDigProject.setRdProjectId(rdProjects.get(0).getId());
|
|
|
- }
|
|
|
-else{
|
|
|
- RdProject rdProject =new RdProject();
|
|
|
- rdProject.setCreateId("328");
|
|
|
- rdProject.setTenantId(1);
|
|
|
- rdProject.setNumber(patentDigProjectDTO.getRdnumber());
|
|
|
- rdProject.setProductPhase(patentDigProjectDTO.getProductPhase());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ if (object.equals(null)) {
|
|
|
+ throw new XiaoShiException("传入参数不能为空");
|
|
|
}
|
|
|
-
|
|
|
- return null;
|
|
|
+ PatentDigProjectFilesDTO patentDigProjectFilesDTO = (PatentDigProjectFilesDTO) object;
|
|
|
+ if (patentDigProjectFilesDTO.getProjectId().equals(null)) {
|
|
|
+ throw new XiaoShiException("projectId不能为空");
|
|
|
+ }
|
|
|
+ if (patentDigProjectFilesDTO.getType().equals(null)) {
|
|
|
+ throw new XiaoShiException("文件类型不能为空");
|
|
|
+ }
|
|
|
+ PatentDigProjectFiles patentDigProjectFiles = new PatentDigProjectFiles();
|
|
|
+ BeanUtils.copyProperties(patentDigProjectFilesDTO, patentDigProjectFiles);
|
|
|
+ //获取登陆人信息 用于设置创建人
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new UnLoginException("未登录");
|
|
|
+ }
|
|
|
+ patentDigProjectFiles.setCreateId(personnelVO.getId());
|
|
|
+ patentDigProjectFiles.insert();
|
|
|
+ return patentDigProjectFiles.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object updateMessage(Object object) {
|
|
|
- return null;
|
|
|
+ if (object.equals(null)) {
|
|
|
+ throw new XiaoShiException("传入参数不能为空");
|
|
|
+ }
|
|
|
+ UpdatePatentDigProjectFilesDTO updatePatentDigProjectFilesDTO = (UpdatePatentDigProjectFilesDTO) object;
|
|
|
+ if (updatePatentDigProjectFilesDTO.getProjectId().equals(null)) {
|
|
|
+ throw new XiaoShiException("projectId不能为空");
|
|
|
+ }
|
|
|
+ if (updatePatentDigProjectFilesDTO.getType().equals(null)) {
|
|
|
+ throw new XiaoShiException("文件类型不能为空");
|
|
|
+ }
|
|
|
+ PatentDigProjectFiles patentDigProjectFiles = this.getById(updatePatentDigProjectFilesDTO.getId());
|
|
|
+ BeanUtils.copyProperties(updatePatentDigProjectFilesDTO, patentDigProjectFiles);
|
|
|
+ patentDigProjectFiles.updateById();
|
|
|
+ return patentDigProjectFiles.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 装载
|
|
|
+ * @param patentDigProjectFilesVOS
|
|
|
+ */
|
|
|
+ private void loadPatentDigProjectFiles(List<PatentDigProjectFilesVO> patentDigProjectFilesVOS) throws IOException {
|
|
|
+ List<String> createIds = new ArrayList<>();
|
|
|
+ patentDigProjectFilesVOS.forEach(
|
|
|
+ item -> {
|
|
|
+ if (item.getCreateId() != null) {
|
|
|
+ createIds.add(item.getCreateId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ List<Personnel> personnels = new ArrayList<>();
|
|
|
+ //查询创建人名称
|
|
|
+ if (createIds.size() != 0) {
|
|
|
+ String res = permissionService.getPersonnelByIdsFromPCS(createIds);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
+ }
|
|
|
+ for (PatentDigProjectFilesVO patentDigProjectFilesVO : patentDigProjectFilesVOS) {
|
|
|
+ //装载人员信息
|
|
|
+ Personnel personnel = personnels.stream().filter(item -> item.getId().equals(patentDigProjectFilesVO.getCreateId())).findFirst().orElse(null);
|
|
|
+ if (personnel != null) {
|
|
|
+ patentDigProjectFilesVO.setCreateName(personnel.getPersonnelName());
|
|
|
+ } else {
|
|
|
+ throw new XiaoShiException("未获取到当前登陆人信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|