123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- package cn.cslg.pas.service.business;
- import cn.cslg.pas.common.dto.business.AvoidDesignWholeDTO;
- import cn.cslg.pas.common.dto.business.GetFeatureSplitDTO;
- import cn.cslg.pas.common.model.cronModel.PersonnelVO;
- import cn.cslg.pas.common.utils.CacheUtils;
- import cn.cslg.pas.common.utils.LoginUtils;
- 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.common.vo.business.SplitVO;
- import cn.cslg.pas.domain.business.*;
- import cn.cslg.pas.exception.UnLoginException;
- import cn.cslg.pas.exception.XiaoShiException;
- import cn.cslg.pas.mapper.AvoidDesignWholeMapper;
- import cn.cslg.pas.service.permissions.PermissionService;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.stereotype.Service;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * 回避设计方案总体方向Service
- * @Author xiexiang
- * @Date 2023/12/5
- */
- @Service
- public class AvoidDesignWholeService extends ServiceImpl<AvoidDesignWholeMapper, AvoidDesignWhole> {
- @Autowired
- @Lazy
- private AvoidDesignService avoidDesignService;
- @Autowired
- private PermissionService permissionService;
- @Autowired
- private ProjectTaskService projectTaskService;
- @Autowired
- private FeatureService featureService;
- @Autowired
- private ReportProjectService reportProjectService;
- @Autowired
- private CacheUtils cacheUtils;
- @Autowired
- private LoginUtils loginUtils;
- /**
- * 新增回避设计方案总体方向
- * @param avoidDesignWholeDTO
- * @return
- */
- public Integer addAvoidDesignWhole(AvoidDesignWholeDTO avoidDesignWholeDTO){
- AvoidDesignWhole avoidDesignWhole = new AvoidDesignWhole();
- BeanUtils.copyProperties(avoidDesignWholeDTO, avoidDesignWhole);
- //获取登录人信息
- PersonnelVO personnelVO = new PersonnelVO();
- personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
- avoidDesignWhole.setCreateId(personnelVO.getId());
- avoidDesignWhole.insert();
- return avoidDesignWhole.getId();
- }
- /**
- * 查询回避设计方案
- * @param getFeatureSplitDTO
- * @return
- */
- public AvoidDesignWholeVO getAvoidDesignWhole(GetFeatureSplitDTO getFeatureSplitDTO) throws IOException {
- //判断参数不能为空
- Integer projectId = getFeatureSplitDTO.getProjectId();
- if (projectId == null) {
- throw new XiaoShiException("projectId为空");
- }
- if (getFeatureSplitDTO.getIfReSplit() == null) {
- throw new XiaoShiException("ifReSplit不能为空");
- }
- if (getFeatureSplitDTO.getSplitBy() == null) {
- throw new XiaoShiException("splitBy不能为空");
- }
- if (getFeatureSplitDTO.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(getFeatureSplitDTO, splitVO);
- splitVO.setPatentNo(patentNo);
- List<PatentRightVo> patentRightVos = new ArrayList<>();
- //判断是否重拆
- if (getFeatureSplitDTO.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 {
- //不重拆
- patentRightVos = featureService.splitPatentFeature(splitVO);
- }
- 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 {
- 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("特征查询错误");
- }
- // //装载名称等信息
- // 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);
- if (!features.isEmpty()) {
- 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());
- }
- }
- 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());
- // }
- // }
- }
|