|
@@ -2,26 +2,38 @@ package cn.cslg.pas.service;
|
|
|
|
|
|
|
|
|
import cn.cslg.pas.common.model.PersonnelVO;
|
|
|
-import cn.cslg.pas.common.model.dto.SWQueryDTO;
|
|
|
-import cn.cslg.pas.common.model.dto.ScratchWordsDTO;
|
|
|
-import cn.cslg.pas.common.model.dto.ScratchWordsUpdateDTO;
|
|
|
+import cn.cslg.pas.common.model.dto.*;
|
|
|
+import cn.cslg.pas.common.model.vo.PageVO;
|
|
|
+import cn.cslg.pas.common.model.vo.ProjectVO;
|
|
|
+import cn.cslg.pas.common.model.vo.ScratchWordVO;
|
|
|
import cn.cslg.pas.common.model.vo.ScratchWordsVO;
|
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
|
|
|
-import cn.cslg.pas.domain.ScratchWords;
|
|
|
+import cn.cslg.pas.domain.*;
|
|
|
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
+import cn.cslg.pas.mapper.ProjectMapper;
|
|
|
import cn.cslg.pas.mapper.ScratchWordsMapper;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.IPage;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -32,21 +44,27 @@ import java.util.List;
|
|
|
* @author 李仁杰
|
|
|
* @since 2023-06-13
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
public class ScratchWordsService extends ServiceImpl<ScratchWordsMapper, ScratchWords> {
|
|
|
private final ScratchWordsMapper scratchWordsMapper;
|
|
|
private final CacheUtils cacheUtils;
|
|
|
private final LoginUtils loginUtils;
|
|
|
+ private final ProjectService projectService;
|
|
|
+ private final ProjectMapper projectMapper;
|
|
|
+ private final OutInterfaceService outInterfaceService;
|
|
|
+ private final PatentService patentService;
|
|
|
|
|
|
/**
|
|
|
* 新增划词高亮
|
|
|
+ *
|
|
|
* @param scratchWordsDTO
|
|
|
*/
|
|
|
- public void add(ScratchWordsDTO scratchWordsDTO){
|
|
|
+ public void add(ScratchWordsDTO scratchWordsDTO) {
|
|
|
//判断传入列表不为空
|
|
|
- if(scratchWordsDTO != null){
|
|
|
- if(scratchWordsDTO.getCreateFrom() == null){
|
|
|
+ if (scratchWordsDTO != null) {
|
|
|
+ if (scratchWordsDTO.getCreateFrom() == null) {
|
|
|
scratchWordsDTO.setCreateFrom(0);
|
|
|
}
|
|
|
ScratchWords scratchWords = new ScratchWords();
|
|
@@ -66,11 +84,12 @@ public class ScratchWordsService extends ServiceImpl<ScratchWordsMapper, Scratch
|
|
|
|
|
|
/**
|
|
|
* 更新划词高亮
|
|
|
+ *
|
|
|
* @param scratchWordsUpdateDTO
|
|
|
*/
|
|
|
- public void update(ScratchWordsUpdateDTO scratchWordsUpdateDTO){
|
|
|
+ public void update(ScratchWordsUpdateDTO scratchWordsUpdateDTO) {
|
|
|
//判断传入列表不为空
|
|
|
- if(scratchWordsUpdateDTO != null){
|
|
|
+ if (scratchWordsUpdateDTO != null) {
|
|
|
ScratchWords scratchWords = this.getById(scratchWordsUpdateDTO.getId());
|
|
|
BeanUtils.copyProperties(scratchWordsUpdateDTO, scratchWords);
|
|
|
scratchWords.updateById();
|
|
@@ -81,36 +100,37 @@ public class ScratchWordsService extends ServiceImpl<ScratchWordsMapper, Scratch
|
|
|
|
|
|
/**
|
|
|
* 查询划词高亮
|
|
|
+ *
|
|
|
* @param swQueryDTO
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<ScratchWordsVO> queryAll(SWQueryDTO swQueryDTO){
|
|
|
- if(swQueryDTO.getPatentNo() != null) {
|
|
|
+ public List<ScratchWordsVO> queryAll(SWQueryDTO swQueryDTO) {
|
|
|
+ if (swQueryDTO.getPatentNo() != null) {
|
|
|
//获取当前登陆人信息
|
|
|
PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
Integer tenantId = personnelVO.getTenantId();
|
|
|
Integer createId = personnelVO.getId();
|
|
|
//创建来源(默认0/专题库1/报告2)
|
|
|
- if(swQueryDTO.getCreateFrom().equals(1)){
|
|
|
+ if (swQueryDTO.getCreateFrom().equals(1)) {
|
|
|
Integer projectId = swQueryDTO.getId();
|
|
|
Integer reportId = -1;
|
|
|
List<ScratchWordsVO> scratchWords = scratchWordsMapper.querySW(swQueryDTO.getPatentNo(), tenantId, createId, projectId, reportId);
|
|
|
return scratchWords;
|
|
|
}
|
|
|
//创建来源(默认0/专题库1/报告2)
|
|
|
- else if(swQueryDTO.getCreateFrom().equals(2)){
|
|
|
+ else if (swQueryDTO.getCreateFrom().equals(2)) {
|
|
|
Integer reportId = swQueryDTO.getId();
|
|
|
Integer projectId = -1;
|
|
|
List<ScratchWordsVO> scratchWords = scratchWordsMapper.querySW(swQueryDTO.getPatentNo(), tenantId, createId, projectId, reportId);
|
|
|
return scratchWords;
|
|
|
}
|
|
|
//创建来源(默认0/专题库1/报告2)
|
|
|
- else if(swQueryDTO.getCreateFrom().equals(0)){
|
|
|
+ else if (swQueryDTO.getCreateFrom().equals(0)) {
|
|
|
Integer reportId = -1;
|
|
|
Integer projectId = -1;
|
|
|
List<ScratchWordsVO> scratchWords = scratchWordsMapper.querySW(swQueryDTO.getPatentNo(), tenantId, createId, projectId, reportId);
|
|
|
return scratchWords;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new XiaoShiException("暂无该情况");
|
|
|
}
|
|
|
} else {
|
|
@@ -118,12 +138,183 @@ public class ScratchWordsService extends ServiceImpl<ScratchWordsMapper, Scratch
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public PageVO queryScratchs(QueryScratchsDTO queryScratchsDTO) throws IOException {
|
|
|
+ log.info("开始处理【查询标注清单】的业务,参数为:{}", queryScratchsDTO);
|
|
|
+
|
|
|
+ PageVO pageVO = new PageVO()
|
|
|
+ .setCurrent(queryScratchsDTO.getCurrent())
|
|
|
+ .setSize(queryScratchsDTO.getSize());
|
|
|
+
|
|
|
+ //若根据创建人名称模糊查询,调用权限系统根据人员名称获得人员ids并装载到参数中
|
|
|
+ if (queryScratchsDTO.getName() != null && !queryScratchsDTO.getName().equals("")) {
|
|
|
+ String res = outInterfaceService.getPersonIdByNamePCS(queryScratchsDTO.getName());
|
|
|
+ List<Integer> personIds = JSON.parseArray(res, Integer.class);
|
|
|
+ if (personIds.size() == 0) {
|
|
|
+ personIds.add(-1);
|
|
|
+ }
|
|
|
+ queryScratchsDTO.setPersonIds(personIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取登陆人id、所属租户id、token
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ Integer personId = personnelVO.getId();
|
|
|
+ Integer tenantId = personnelVO.getTenantId();
|
|
|
+ String token = "token=" + personnelVO.getToken();
|
|
|
+
|
|
|
+ //获取当前登陆人有权查看的专题库projectIds
|
|
|
+ ProjectVO params = new ProjectVO();
|
|
|
+ if (personnelVO.getRoleType() == null || personnelVO.getRoleType() != 1) { //代码控制不同类型的角色查询权限
|
|
|
+ params.setPersonnelId(personId);
|
|
|
+ if (personnelVO.getRoleType() != null && personnelVO.getRoleType() == 2) {
|
|
|
+ params.setTenantId(personnelVO.getTenantId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Project> projects = projectMapper.getProjects(params);
|
|
|
+ List<Integer> projectIds = new ArrayList<>();
|
|
|
+ if (projects == null || projects.size() == 0) {
|
|
|
+ projectIds.add(-1);
|
|
|
+ } else {
|
|
|
+ projectIds = projects.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取当前登陆人有权查看的报告reportIds
|
|
|
+ String res = outInterfaceService.getReportsFromRMS(token);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<Integer> reportIds = JSON.parseArray(jsonObject.get("data").toString(), Integer.class);
|
|
|
+
|
|
|
+
|
|
|
+ //开始分页(分组)查询标注表标注清单
|
|
|
+ if (queryScratchsDTO.getCurrent() != null && queryScratchsDTO.getSize() != null) {
|
|
|
+ PageHelper.startPage(queryScratchsDTO.getCurrent(), queryScratchsDTO.getSize());
|
|
|
+ }
|
|
|
+// if (queryScratchsDTO.getGrouping() == null || queryScratchsDTO.getGrouping().equals("")) { //不分组
|
|
|
+ List<ScratchWordVO> scratchWords = scratchWordsMapper.queryScratchWords(queryScratchsDTO, tenantId, personId, projectIds, reportIds);
|
|
|
+ PageInfo<ScratchWordVO> pageInfo = new PageInfo<>(scratchWords);
|
|
|
+ if (scratchWords.size() > 0) {
|
|
|
+ //装载创建人名称
|
|
|
+ List<Integer> createPersonIds = scratchWords.stream().map(ScratchWordVO::getCreateId).collect(Collectors.toList());
|
|
|
+ res = outInterfaceService.getPersonnelByIdsFromPCS(createPersonIds);
|
|
|
+ jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<Personnel> personnels = JSON.parseArray(jsonObject.get("data").toString(), Personnel.class);
|
|
|
+ scratchWords.forEach(scratchWord -> {
|
|
|
+ personnels.forEach(personnel -> {
|
|
|
+ if (personnel.getId().equals(scratchWord.getCreateId())) {
|
|
|
+ scratchWord.setName(personnel.getPersonnelName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ //装载专利id和专利标题
|
|
|
+ List<String> patentNos = scratchWords.stream().map(ScratchWordVO::getPatentNo).collect(Collectors.toList());
|
|
|
+ List<Patent> patents = patentService.list(new LambdaQueryWrapper<Patent>().in(Patent::getPatentNo, patentNos).or().in(Patent::getPublicNo, patentNos));
|
|
|
+ scratchWords.forEach(scratchWord -> {
|
|
|
+ patents.forEach(patent -> {
|
|
|
+ if (patent.getPatentNo().equals(scratchWord.getPatentNo()) || patent.getPublicNo().equals(scratchWord.getPatentNo())) {
|
|
|
+ scratchWord.setPatentId(patent.getId());
|
|
|
+ scratchWord.setPatentTitle(patent.getName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ pageVO.setRecords(scratchWords)
|
|
|
+ .setTotal((int) pageInfo.getTotal());
|
|
|
+// } else { //分组
|
|
|
+// List<GroupName> groupNames = scratchWordsMapper.queryGroupScratchs(queryScratchsDTO, tenantId, personId, projectIds, reportIds);
|
|
|
+// PageInfo<GroupName> pageInfo = new PageInfo<>(groupNames);
|
|
|
+// if (groupNames.size() > 0) {
|
|
|
+// //装载创建人名称
|
|
|
+// List<Integer> createPersonIds = groupNames.stream().map(GroupName::getCreateId).collect(Collectors.toList());
|
|
|
+// res = outInterfaceService.getPersonnelByIdsFromPCS(createPersonIds);
|
|
|
+// jsonObject = JSONObject.parseObject(res);
|
|
|
+// List<Personnel> personnels = JSON.parseArray(jsonObject.get("data").toString(), Personnel.class);
|
|
|
+// groupNames.forEach(groupName -> {
|
|
|
+// personnels.forEach(personnel -> {
|
|
|
+// if (personnel.getId().equals(groupName.getCreateId())) {
|
|
|
+// groupName.setName(personnel.getPersonnelName());
|
|
|
+// }
|
|
|
+// });
|
|
|
+// });
|
|
|
+// }
|
|
|
+// pageVO.setRecords(groupNames)
|
|
|
+// .setTotal((int) pageInfo.getTotal());
|
|
|
+// }
|
|
|
+
|
|
|
+ return pageVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ public PageVO queryGroupScratchs(QueryGroupScratchsDTO queryGroupScratchsDTO) throws IOException {
|
|
|
+ log.info("开始处理【分页分组查询标注清单】的业务,参数为:{}", queryGroupScratchsDTO);
|
|
|
+
|
|
|
+ //调用权限系统根据人员名称获得人员ids
|
|
|
+ if (queryGroupScratchsDTO.getName() != null && !queryGroupScratchsDTO.getName().equals("")) {
|
|
|
+ String res = outInterfaceService.getPersonIdByNamePCS(queryGroupScratchsDTO.getName());
|
|
|
+ //JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<Integer> personIds = JSON.parseArray(res, Integer.class);
|
|
|
+ if (personIds.size() == 0) {
|
|
|
+ personIds.add(-1);
|
|
|
+ }
|
|
|
+ queryGroupScratchsDTO.setPersonIds(personIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取登陆人id和所属租户id
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ Integer personId = personnelVO.getId();
|
|
|
+ Integer tenantId = personnelVO.getTenantId();
|
|
|
+ String token = "token=" + personnelVO.getToken();
|
|
|
+
|
|
|
+ //查询本系统的专题库表"os_thematic",获取当前登陆人有权查看的专题库projectIds
|
|
|
+ ProjectVO params = new ProjectVO();
|
|
|
+ //代码控制不同类型的角色查询权限
|
|
|
+ if (personnelVO.getRoleType() == null || personnelVO.getRoleType() != 1) {
|
|
|
+ params.setPersonnelId(personId);
|
|
|
+ if (personnelVO.getRoleType() != null && personnelVO.getRoleType() == 2) {
|
|
|
+ params.setTenantId(personnelVO.getTenantId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Project> projects = projectMapper.getProjects(params);
|
|
|
+ List<Integer> projectIds = projects.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
+ //查询报告系统,获取当前登陆人有权查看的报告reportIds
|
|
|
+ String res = outInterfaceService.getReportsFromRMS(token);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<Integer> reportIds = JSON.parseArray(jsonObject.get("data").toString(), Integer.class);
|
|
|
+
|
|
|
+ //开始查询标注表标注清单
|
|
|
+ if (queryGroupScratchsDTO.getCurrent() != null) {
|
|
|
+ PageHelper.startPage(queryGroupScratchsDTO.getCurrent(), queryGroupScratchsDTO.getSize());
|
|
|
+ }
|
|
|
+ List<GroupName> groupNames = scratchWordsMapper.queryGroupScratchs(queryGroupScratchsDTO, tenantId, personId, projectIds, reportIds);
|
|
|
+ PageInfo<GroupName> pageInfo = new PageInfo<>(groupNames);
|
|
|
+
|
|
|
+ if (groupNames.size() > 0) {
|
|
|
+ //装载创建人名称
|
|
|
+ List<Integer> createPersonIds = groupNames.stream().map(GroupName::getCreateId).collect(Collectors.toList());
|
|
|
+ res = outInterfaceService.getPersonnelByIdsFromPCS(createPersonIds);
|
|
|
+ jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<Personnel> personnels = JSON.parseArray(jsonObject.get("data").toString(), Personnel.class);
|
|
|
+ groupNames.forEach(groupName -> {
|
|
|
+ personnels.forEach(personnel -> {
|
|
|
+ if (personnel.getId().equals(groupName.getCreateId())) {
|
|
|
+ groupName.setName(personnel.getPersonnelName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ PageVO pageVO = new PageVO()
|
|
|
+ .setRecords(groupNames)
|
|
|
+ .setCurrent(queryGroupScratchsDTO.getCurrent())
|
|
|
+ .setSize(queryGroupScratchsDTO.getSize())
|
|
|
+ .setTotal((int) pageInfo.getTotal());
|
|
|
+ return pageVO;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 删除划词高亮
|
|
|
+ *
|
|
|
* @param ids
|
|
|
*/
|
|
|
- public void delete(List<Integer> ids){
|
|
|
- for(int i = 0; i < ids.size(); i++){
|
|
|
+ public void delete(List<Integer> ids) {
|
|
|
+ for (int i = 0; i < ids.size(); i++) {
|
|
|
LambdaQueryWrapper<ScratchWords> LW = new LambdaQueryWrapper<>();
|
|
|
LW.eq(ScratchWords::getId, ids.get(i));
|
|
|
ScratchWords scratchWords = this.getOne(LW);
|