|
@@ -0,0 +1,309 @@
|
|
|
|
+package cn.cslg.pas.service.business;
|
|
|
|
+
|
|
|
|
+import cn.cslg.pas.common.dto.business.ScratchWordsDTO;
|
|
|
|
+import cn.cslg.pas.common.dto.business.UpdateScratchWordsDTO;
|
|
|
|
+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.domain.business.ScratchWords;
|
|
|
|
+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.service.impl.ServiceImpl;
|
|
|
|
+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.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Author xiexiang
|
|
|
|
+ * @Date 2024/1/10
|
|
|
|
+ */
|
|
|
|
+@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 PatentService patentService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增划词高亮
|
|
|
|
+ *
|
|
|
|
+ * @param scratchWordsDTO
|
|
|
|
+ */
|
|
|
|
+ public Integer add(ScratchWordsDTO scratchWordsDTO) {
|
|
|
|
+ if (scratchWordsDTO.getCreateFrom() == null) {
|
|
|
|
+ scratchWordsDTO.setCreateFrom(0);
|
|
|
|
+ }
|
|
|
|
+ ScratchWords scratchWords = new ScratchWords();
|
|
|
|
+ BeanUtils.copyProperties(scratchWordsDTO, scratchWords);
|
|
|
|
+ //获取当前登陆人信息
|
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
|
+ if (personnelVO != null) {
|
|
|
|
+ //设置创建人id
|
|
|
|
+ scratchWords.setCreateId(personnelVO.getId());
|
|
|
|
+ //设置租户id
|
|
|
|
+ scratchWords.setTenantId(personnelVO.getTenantId());
|
|
|
|
+ } else {
|
|
|
|
+ throw new XiaoShiException("未查询到创建人信息");
|
|
|
|
+ }
|
|
|
|
+ //数据入表
|
|
|
|
+ scratchWords.insert();
|
|
|
|
+ return scratchWords.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更新划词高亮
|
|
|
|
+ *
|
|
|
|
+ * @param updateScratchWordsDTO
|
|
|
|
+ */
|
|
|
|
+ public Integer update(UpdateScratchWordsDTO updateScratchWordsDTO) {
|
|
|
|
+ //判断传入列表不为空
|
|
|
|
+ if (updateScratchWordsDTO.getId() != null) {
|
|
|
|
+ ScratchWords scratchWords = this.getById(updateScratchWordsDTO.getId());
|
|
|
|
+ BeanUtils.copyProperties(updateScratchWordsDTO, scratchWords);
|
|
|
|
+ scratchWords.updateById();
|
|
|
|
+ return scratchWords.getId();
|
|
|
|
+ } else {
|
|
|
|
+ throw new XiaoShiException("传入对象的id不能为空");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// /**
|
|
|
|
+// * 查询划词高亮
|
|
|
|
+// *
|
|
|
|
+// * @param swQueryDTO
|
|
|
|
+// * @return
|
|
|
|
+// */
|
|
|
|
+// 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)) {
|
|
|
|
+// 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)) {
|
|
|
|
+// 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)) {
|
|
|
|
+// Integer reportId = -1;
|
|
|
|
+// Integer projectId = -1;
|
|
|
|
+// List<ScratchWordsVO> scratchWords = scratchWordsMapper.querySW(swQueryDTO.getPatentNo(), tenantId, createId, projectId, reportId);
|
|
|
|
+// return scratchWords;
|
|
|
|
+// } else {
|
|
|
|
+// throw new XiaoShiException("暂无该情况");
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// throw new XiaoShiException("传入参数不可为空");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// public PageVO queryScratchs(QueryScratchsDTO queryScratchsDTO) throws IOException {
|
|
|
|
+// log.info("开始处理【查询标注清单】的业务,参数为:{}", queryScratchsDTO);
|
|
|
|
+//
|
|
|
|
+// List<SearchItem> search = queryScratchsDTO.getSearch();
|
|
|
|
+// List<String> names = search.stream().filter(searchItem -> searchItem.getValue().equals("name")).map(SearchItem::getContent).collect(Collectors.toList());
|
|
|
|
+// List<Integer> personIds = new ArrayList<>();
|
|
|
|
+// if (names.size() > 0) {
|
|
|
|
+// //若根据创建人名称模糊查询,调用权限系统根据人员名称获得人员ids并装载到参数中
|
|
|
|
+// String res = outInterfaceService.getPersonIdByNamesPCS(names);
|
|
|
|
+// personIds = JSON.parseArray(res, Integer.class);
|
|
|
|
+// if (personIds.size() == 0) {
|
|
|
|
+// personIds.add(-1);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// PageVO pageVO = new PageVO()
|
|
|
|
+// .setCurrent(queryScratchsDTO.getCurrent())
|
|
|
|
+// .setSize(queryScratchsDTO.getSize());
|
|
|
|
+//
|
|
|
|
+// //获取登陆人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(personIds, search, 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 (scratchWord.getPatentNo().equals(patent.getPatentNo()) || scratchWord.getPatentNo().equals(patent.getPublicNo())) {
|
|
|
|
+// 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);
|
|
|
|
+//
|
|
|
|
+// List<SearchItem> search = queryGroupScratchsDTO.getSearch();
|
|
|
|
+// List<String> names = search.stream().filter(searchItem -> searchItem.getValue().equals("name")).map(SearchItem::getContent).collect(Collectors.toList());
|
|
|
|
+// List<Integer> personIds = new ArrayList<>();
|
|
|
|
+// if (names.size() > 0) {
|
|
|
|
+// //若根据创建人名称模糊查询,调用权限系统根据人员名称获得人员ids并装载到参数中
|
|
|
|
+// String res = outInterfaceService.getPersonIdByNamesPCS(names);
|
|
|
|
+// personIds = JSON.parseArray(res, Integer.class);
|
|
|
|
+// if (personIds.size() == 0) {
|
|
|
|
+// personIds.add(-1);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //获取登陆人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 && queryGroupScratchsDTO.getSize() != null) {
|
|
|
|
+// PageHelper.startPage(queryGroupScratchsDTO.getCurrent(), queryGroupScratchsDTO.getSize());
|
|
|
|
+// }
|
|
|
|
+// List<GroupName> groupNames = scratchWordsMapper.queryGroupScratchs(personIds, search, queryGroupScratchsDTO.getGrouping(), tenantId, personId, projectIds, reportIds);
|
|
|
|
+// PageInfo<GroupName> pageInfo = new PageInfo<>(groupNames);
|
|
|
|
+//
|
|
|
|
+// //若本次请求是根据创建人分组查询,则装载创建人名称
|
|
|
|
+// if (groupNames.size() > 0 && queryGroupScratchsDTO.getGrouping().equals("name")) {
|
|
|
|
+// 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 List<Integer> delete(List<Integer> ids) {
|
|
|
|
+ this.removeBatchByIds(ids);
|
|
|
|
+ return ids;
|
|
|
|
+ }
|
|
|
|
+}
|