|
@@ -2,24 +2,25 @@ package cn.cslg.pas.service.business;
|
|
|
|
|
|
import cn.cslg.pas.common.dto.business.AvoidDesignWholeDTO;
|
|
|
import cn.cslg.pas.common.dto.business.AvoidDesignWholeUpdateDTO;
|
|
|
+import cn.cslg.pas.common.dto.business.GetAvoidDesignDTO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
|
+import cn.cslg.pas.common.vo.PatentRightVo;
|
|
|
+import cn.cslg.pas.common.vo.business.AvoidDesignRightVO;
|
|
|
import cn.cslg.pas.common.vo.business.AvoidDesignVO;
|
|
|
import cn.cslg.pas.common.vo.business.AvoidDesignWholeVO;
|
|
|
-import cn.cslg.pas.domain.business.AvoidDesignWhole;
|
|
|
-import cn.cslg.pas.domain.business.Feature;
|
|
|
-import cn.cslg.pas.domain.business.Project;
|
|
|
-import cn.cslg.pas.domain.business.ProjectTask;
|
|
|
+import cn.cslg.pas.common.vo.business.SplitVO;
|
|
|
+import cn.cslg.pas.domain.business.*;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.mapper.AvoidDesignWholeMapper;
|
|
|
import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import org.apache.xmlbeans.xml.stream.XMLStreamException;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.context.annotation.ApplicationScope;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
@@ -33,6 +34,7 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class AvoidDesignWholeService extends ServiceImpl<AvoidDesignWholeMapper, AvoidDesignWhole> {
|
|
|
@Autowired
|
|
|
+ @Lazy
|
|
|
private AvoidDesignService avoidDesignService;
|
|
|
|
|
|
@Autowired
|
|
@@ -44,6 +46,9 @@ public class AvoidDesignWholeService extends ServiceImpl<AvoidDesignWholeMapper,
|
|
|
@Autowired
|
|
|
private FeatureService featureService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ReportProjectService reportProjectService;
|
|
|
+
|
|
|
/**
|
|
|
* 新增回避设计方案总体方向
|
|
|
* @param avoidDesignWholeDTO
|
|
@@ -66,105 +71,185 @@ public class AvoidDesignWholeService extends ServiceImpl<AvoidDesignWholeMapper,
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 更新回避设计方案总体方向
|
|
|
- * @param avoidDesignWholeUpdateDTO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Integer updateAvoidDesignWhole(AvoidDesignWholeUpdateDTO avoidDesignWholeUpdateDTO){
|
|
|
- if (avoidDesignWholeUpdateDTO.getId() == null) {
|
|
|
- throw new XiaoShiException("id不能为空");
|
|
|
- }
|
|
|
- //根据id查询回避设计总体方向
|
|
|
- AvoidDesignWhole avoidDesignWhole = this.getById(avoidDesignWholeUpdateDTO.getId());
|
|
|
- BeanUtils.copyProperties(avoidDesignWholeUpdateDTO, avoidDesignWhole);
|
|
|
- avoidDesignWhole.updateById();
|
|
|
- return avoidDesignWhole.getId();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 查询回避设计方案
|
|
|
- * @param projectId
|
|
|
+ * @param getAvoidDesignDTO
|
|
|
* @return
|
|
|
*/
|
|
|
- public AvoidDesignWholeVO getAvoidDesignWhole(Integer projectId) throws IOException {
|
|
|
- AvoidDesignWholeVO avoidDesignWholeVO = new AvoidDesignWholeVO();
|
|
|
- //根据projectId查询回避设计方案总体方向
|
|
|
- LambdaQueryWrapper<AvoidDesignWhole> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(AvoidDesignWhole::getProjectId, projectId);
|
|
|
- List<AvoidDesignWhole> avoidDesignWholeList = this.list(queryWrapper);
|
|
|
- if (!avoidDesignWholeList.isEmpty()) {
|
|
|
- AvoidDesignWhole avoidDesignWhole = avoidDesignWholeList.get(0);
|
|
|
- //复制总体方向数据
|
|
|
- BeanUtils.copyProperties(avoidDesignWhole, avoidDesignWholeVO);
|
|
|
- //根据projectId查询回避设计方向数据
|
|
|
- List<AvoidDesignVO> avoidDesignVOS = avoidDesignService.queryAvoidDesign(projectId);
|
|
|
- avoidDesignWholeVO.setAvoidDesignVOS(avoidDesignVOS);
|
|
|
- //装载名称等信息
|
|
|
- this.loadAvoidDesignWhole(avoidDesignWholeVO);
|
|
|
+ public AvoidDesignWholeVO getAvoidDesignWhole(GetAvoidDesignDTO getAvoidDesignDTO) throws IOException {
|
|
|
+ //判断参数不能为空
|
|
|
+ Integer projectId = getAvoidDesignDTO.getProjectId();
|
|
|
+ if (projectId == null) {
|
|
|
+ throw new XiaoShiException("projectId为空");
|
|
|
}
|
|
|
- return avoidDesignWholeVO;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 装载回避设计方案总数据(回避设计方案总体方向and回避设计方向集合)
|
|
|
- * @param avoidDesignWholeVO
|
|
|
- */
|
|
|
- public void loadAvoidDesignWhole(AvoidDesignWholeVO avoidDesignWholeVO) throws IOException {
|
|
|
- //创建需要查询的ids
|
|
|
- List<String> createIds = new ArrayList<>();
|
|
|
- List<Personnel> personnels = new ArrayList<>();
|
|
|
- //将回避设计总体方向的人员id插入其中
|
|
|
- createIds.add(avoidDesignWholeVO.getCreateId());
|
|
|
- List<AvoidDesignVO> avoidDesignVOS = avoidDesignWholeVO.getAvoidDesignVOS();
|
|
|
- //回避设计方向集合不为空,遍历将人员ids插入其中
|
|
|
- if (!avoidDesignVOS.isEmpty()) {
|
|
|
- avoidDesignVOS.forEach(item -> {
|
|
|
- if (item.getCreateId() != null) {
|
|
|
- createIds.add(item.getCreateId());
|
|
|
- }
|
|
|
- });
|
|
|
+ if (getAvoidDesignDTO.getIfReSplit() == null) {
|
|
|
+ throw new XiaoShiException("ifReSplit不能为空");
|
|
|
}
|
|
|
- //查询创建人名称
|
|
|
- if (createIds.size() != 0) {
|
|
|
- String res = permissionService.getPersonnelByIdsFromPCS(createIds);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
- personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
+ if (getAvoidDesignDTO.getSplitBy() == null) {
|
|
|
+ throw new XiaoShiException("splitBy不能为空");
|
|
|
}
|
|
|
- //首先装载回避设计总体方向的人员名称
|
|
|
- Personnel personnelWhole = personnels.stream().filter(item -> item.getId().equals(avoidDesignWholeVO.getCreateId())).findFirst().orElse(null);
|
|
|
- if (personnelWhole != null) {
|
|
|
- avoidDesignWholeVO.setCreateName(personnelWhole.getPersonnelName());
|
|
|
+ if (getAvoidDesignDTO.getSplitType() == null) {
|
|
|
+ throw new XiaoShiException("splitType不能为空");
|
|
|
+ }
|
|
|
+ //返回的VO类
|
|
|
+ AvoidDesignWholeVO avoidDesignWholeVO = new AvoidDesignWholeVO();
|
|
|
+ avoidDesignWholeVO.setProjectId(projectId);
|
|
|
+ //根据projectId查询专利号
|
|
|
+ LambdaQueryWrapper<ReportProject> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(ReportProject::getProjectId, projectId);
|
|
|
+ ReportProject reportProject = reportProjectService.getOne(queryWrapper, false);
|
|
|
+ String patentNo = reportProject.getSignPatentNo();
|
|
|
+ //新建查询拆分特征DTO
|
|
|
+ SplitVO splitVO = new SplitVO();
|
|
|
+ BeanUtils.copyProperties(getAvoidDesignDTO, splitVO);
|
|
|
+ splitVO.setPatentNo(patentNo);
|
|
|
+ List<PatentRightVo> patentRightVos = new ArrayList<>();
|
|
|
+ //判断是否重拆
|
|
|
+ if (getAvoidDesignDTO.getIfReSplit() == true) {//重拆
|
|
|
+ //重拆需要清空原有特征表、回避设计方向表、回避设计总体方向表
|
|
|
+ //清空回避设计方向表
|
|
|
+ LambdaQueryWrapper<AvoidDesign> deleteWrapper = new LambdaQueryWrapper<>();
|
|
|
+ deleteWrapper.eq(AvoidDesign::getProjectId, projectId);
|
|
|
+ avoidDesignService.remove(deleteWrapper);
|
|
|
+ //清空回避设计总体方向表
|
|
|
+ LambdaQueryWrapper<AvoidDesignWhole> deleteWholeWapper = new LambdaQueryWrapper<>();
|
|
|
+ deleteWholeWapper.eq(AvoidDesignWhole::getProjectId, projectId);
|
|
|
+ this.remove(deleteWholeWapper);
|
|
|
+ //清空特征表
|
|
|
+ //根据重拆条件拆分权要保存到特征表
|
|
|
+ patentRightVos = featureService.splitPatentFeature(splitVO);
|
|
|
} else {
|
|
|
- throw new XiaoShiException("未获取到当前登陆人信息");
|
|
|
+ //不重拆
|
|
|
+ patentRightVos = featureService.splitPatentFeature(splitVO);
|
|
|
}
|
|
|
- //新建
|
|
|
- List<Integer> projectIds = new ArrayList<>();
|
|
|
- //将回避设计的projectId插入其中
|
|
|
- projectIds.add(avoidDesignWholeVO.getProjectId());
|
|
|
- List<Project> projects = projectTaskService.getProjectInfo(projectIds);
|
|
|
- if (!projects.isEmpty()) {
|
|
|
- Project project = projects.stream().filter(item -> item.getId().equals(avoidDesignWholeVO.getProjectId())).findFirst().orElse(null);
|
|
|
- if (project != null) {
|
|
|
- avoidDesignWholeVO.setProjectName(project.getName());
|
|
|
- avoidDesignWholeVO.setProjectType(project.getType());
|
|
|
+ if (!patentRightVos.isEmpty()) {
|
|
|
+ //根据projectId查询回避设计方案总体方向
|
|
|
+ LambdaQueryWrapper<AvoidDesignWhole> getWholeWrapper = new LambdaQueryWrapper<>();
|
|
|
+ getWholeWrapper.eq(AvoidDesignWhole::getProjectId, projectId);
|
|
|
+ AvoidDesignWhole avoidDesignWhole = this.getOne(getWholeWrapper, false);
|
|
|
+ //复制总体方向数据
|
|
|
+ if (avoidDesignWhole != null) {
|
|
|
+ BeanUtils.copyProperties(avoidDesignWhole, avoidDesignWholeVO);
|
|
|
+ avoidDesignWholeVO.setWholeContent(avoidDesignWhole.getContent());
|
|
|
} else {
|
|
|
- throw new XiaoShiException("未查询到报告信息");
|
|
|
+ avoidDesignWholeVO.setWholeContent(null);
|
|
|
}
|
|
|
+ //新建权要层信息
|
|
|
+ List<AvoidDesignRightVO> avoidDesignRightVOS = new ArrayList<>();
|
|
|
+ //遍历装载权要层信息
|
|
|
+ patentRightVos.forEach(item -> {
|
|
|
+ AvoidDesignRightVO avoidDesignRightVO = new AvoidDesignRightVO();
|
|
|
+ BeanUtils.copyProperties(item, avoidDesignRightVO);
|
|
|
+ //新建特征与回避设计方向VOS
|
|
|
+ List<AvoidDesignVO> avoidDesignVOS = new ArrayList<>();
|
|
|
+ //特征信息
|
|
|
+ List<Feature> features = item.getFeatures();
|
|
|
+ avoidDesignVOS = this.loadAvoidDesign(projectId, features);
|
|
|
+ avoidDesignRightVO.setAvoidDesignVOS(avoidDesignVOS);
|
|
|
+ avoidDesignRightVOS.add(avoidDesignRightVO);
|
|
|
+ });
|
|
|
+ avoidDesignWholeVO.setAvoidDesignRightVOS(avoidDesignRightVOS);
|
|
|
+ } else {
|
|
|
+ throw new XiaoShiException("特征查询错误");
|
|
|
}
|
|
|
- //遍历装载回避设计方向的人员名称
|
|
|
- for (AvoidDesignVO avoidDesignVO : avoidDesignVOS) {
|
|
|
- //装载人员信息
|
|
|
- Personnel personnel = personnels.stream().filter(item -> item.getId().equals(avoidDesignVO.getCreateId())).findFirst().orElse(null);
|
|
|
- if (personnel != null) {
|
|
|
- avoidDesignVO.setCreateName(personnel.getPersonnelName());
|
|
|
- } else {
|
|
|
- throw new XiaoShiException("未获取到当前登陆人信息");
|
|
|
+// //装载名称等信息
|
|
|
+// this.loadAvoidDesignWhole(avoidDesignWholeVO);
|
|
|
+ return avoidDesignWholeVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<AvoidDesignVO> loadAvoidDesign(Integer projectId, List<Feature> features) {
|
|
|
+ List<AvoidDesignVO> avoidDesignVOS = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<AvoidDesign> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AvoidDesign::getProjectId, projectId);
|
|
|
+ List<AvoidDesign> avoidDesignList = avoidDesignService.list(queryWrapper);
|
|
|
+ for (Feature feature : features) {
|
|
|
+ //新建特征与回避设计方向VO
|
|
|
+ AvoidDesignVO avoidDesignVO = new AvoidDesignVO();
|
|
|
+ //装载特征部分的信息
|
|
|
+ avoidDesignVO.setFeatureId(feature.getId());
|
|
|
+ avoidDesignVO.setContent(feature.getContent());
|
|
|
+ avoidDesignVO.setPatentNo(feature.getPatentNo());
|
|
|
+ avoidDesignVO.setRightSort(feature.getRightSort());
|
|
|
+ avoidDesignVO.setRightType(feature.getRightType());
|
|
|
+ avoidDesignVO.setExplainText(feature.getExplainText());
|
|
|
+ avoidDesignVO.setFormId(feature.getFromId());
|
|
|
+ avoidDesignVO.setSysOrder(feature.getSysOrder());
|
|
|
+ //装载回避设计部分(可能为空)
|
|
|
+ if (!avoidDesignList.isEmpty()) {
|
|
|
+ AvoidDesign avoidDesign = avoidDesignList.stream().filter(item -> item.getFeatureId() != null && item.getFeatureId().equals(feature.getId())).findFirst().orElse(null);
|
|
|
+ if (avoidDesign != null) {
|
|
|
+ avoidDesignVO.setId(avoidDesign.getId());
|
|
|
+ avoidDesignVO.setDirection(avoidDesign.getDirection());
|
|
|
+ avoidDesignVO.setCreateId(avoidDesign.getCreateId());
|
|
|
+ avoidDesignVO.setCreateTime(avoidDesign.getCreateTime());
|
|
|
+ }
|
|
|
}
|
|
|
- //装载特征集合
|
|
|
- Feature feature = featureService.getById(avoidDesignVO.getFeatureId());
|
|
|
- avoidDesignVO.setFeature(feature);
|
|
|
+ avoidDesignVOS.add(avoidDesignVO);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ return avoidDesignVOS;
|
|
|
}
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 装载回避设计方案总数据(回避设计方案总体方向and回避设计方向集合)
|
|
|
+// * @param avoidDesignWholeVO
|
|
|
+// */
|
|
|
+// public void loadAvoidDesignWhole(AvoidDesignWholeVO avoidDesignWholeVO) throws IOException {
|
|
|
+// //创建需要查询的ids
|
|
|
+// List<String> createIds = new ArrayList<>();
|
|
|
+// List<Personnel> personnels = new ArrayList<>();
|
|
|
+// //将回避设计总体方向的人员id插入其中
|
|
|
+// createIds.add(avoidDesignWholeVO.getCreateId());
|
|
|
+// List<AvoidDesignVO> avoidDesignVOS = avoidDesignWholeVO.getAvoidDesignVOS();
|
|
|
+// //回避设计方向集合不为空,遍历将人员ids插入其中
|
|
|
+// if (!avoidDesignVOS.isEmpty()) {
|
|
|
+// avoidDesignVOS.forEach(item -> {
|
|
|
+// if (item.getCreateId() != null) {
|
|
|
+// createIds.add(item.getCreateId());
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// //查询创建人名称
|
|
|
+// if (createIds.size() != 0) {
|
|
|
+// String res = permissionService.getPersonnelByIdsFromPCS(createIds);
|
|
|
+// JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+// personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
+// }
|
|
|
+// //首先装载回避设计总体方向的人员名称
|
|
|
+// Personnel personnelWhole = personnels.stream().filter(item -> item.getId().equals(avoidDesignWholeVO.getCreateId())).findFirst().orElse(null);
|
|
|
+// if (personnelWhole != null) {
|
|
|
+// avoidDesignWholeVO.setCreateName(personnelWhole.getPersonnelName());
|
|
|
+// } else {
|
|
|
+// throw new XiaoShiException("未获取到当前登陆人信息");
|
|
|
+// }
|
|
|
+// //新建
|
|
|
+// List<Integer> projectIds = new ArrayList<>();
|
|
|
+// //将回避设计的projectId插入其中
|
|
|
+// projectIds.add(avoidDesignWholeVO.getProjectId());
|
|
|
+// List<Project> projects = projectTaskService.getProjectInfo(projectIds);
|
|
|
+// if (!projects.isEmpty()) {
|
|
|
+// Project project = projects.stream().filter(item -> item.getId().equals(avoidDesignWholeVO.getProjectId())).findFirst().orElse(null);
|
|
|
+// if (project != null) {
|
|
|
+// avoidDesignWholeVO.setProjectName(project.getName());
|
|
|
+// avoidDesignWholeVO.setProjectType(project.getType());
|
|
|
+// } else {
|
|
|
+// throw new XiaoShiException("未查询到报告信息");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //遍历装载回避设计方向的人员名称
|
|
|
+// for (AvoidDesignVO avoidDesignVO : avoidDesignVOS) {
|
|
|
+// //装载人员信息
|
|
|
+// Personnel personnel = personnels.stream().filter(item -> item.getId().equals(avoidDesignVO.getCreateId())).findFirst().orElse(null);
|
|
|
+// if (personnel != null) {
|
|
|
+// avoidDesignVO.setCreateName(personnel.getPersonnelName());
|
|
|
+// } else {
|
|
|
+// throw new XiaoShiException("未获取到当前登陆人信息");
|
|
|
+// }
|
|
|
+// //装载特征集合
|
|
|
+// Feature feature = featureService.getById(avoidDesignVO.getFeatureId());
|
|
|
+// avoidDesignVO.setContent(feature.getContent());
|
|
|
+// avoidDesignVO.setExplainText(feature.getExplainText());
|
|
|
+// avoidDesignVO.setRightSort(feature.getRightSort());
|
|
|
+// avoidDesignVO.setRightType(feature.getRightType());
|
|
|
+// avoidDesignVO.setPatentNo(feature.getPatentNo());
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|