|
@@ -1,16 +1,25 @@
|
|
package cn.cslg.pas.service.business;
|
|
package cn.cslg.pas.service.business;
|
|
|
|
|
|
|
|
+import cn.cslg.pas.common.dto.QueryScratchWordsDTO;
|
|
import cn.cslg.pas.common.dto.SwQueryDTO;
|
|
import cn.cslg.pas.common.dto.SwQueryDTO;
|
|
import cn.cslg.pas.common.dto.business.UpdateScratchWordsDTO;
|
|
import cn.cslg.pas.common.dto.business.UpdateScratchWordsDTO;
|
|
|
|
+import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
|
+import cn.cslg.pas.common.model.cronModel.Records;
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
import cn.cslg.pas.common.utils.LoginUtils;
|
|
import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
|
+import cn.cslg.pas.common.vo.ScratchWordsVO;
|
|
import cn.cslg.pas.domain.business.ScratchWords;
|
|
import cn.cslg.pas.domain.business.ScratchWords;
|
|
import cn.cslg.pas.domain.es.Marking;
|
|
import cn.cslg.pas.domain.es.Marking;
|
|
|
|
+import cn.cslg.pas.domain.es.Patent;
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
import cn.cslg.pas.mapper.ScratchWordsMapper;
|
|
import cn.cslg.pas.mapper.ScratchWordsMapper;
|
|
|
|
+import cn.cslg.pas.service.business.es.EsPatentService;
|
|
import cn.cslg.pas.service.business.es.EsScratchWordsService;
|
|
import cn.cslg.pas.service.business.es.EsScratchWordsService;
|
|
import cn.cslg.pas.service.business.es.EsService;
|
|
import cn.cslg.pas.service.business.es.EsService;
|
|
|
|
+import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
|
+import co.elastic.clients.elasticsearch.core.search.Hit;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -18,7 +27,9 @@ import org.springframework.beans.BeanUtils;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -32,7 +43,8 @@ public class ScratchWordsService extends ServiceImpl<ScratchWordsMapper, Scratch
|
|
private final CacheUtils cacheUtils;
|
|
private final CacheUtils cacheUtils;
|
|
private final LoginUtils loginUtils;
|
|
private final LoginUtils loginUtils;
|
|
private final EsScratchWordsService esScratchWordsService;
|
|
private final EsScratchWordsService esScratchWordsService;
|
|
- private final EsService esService;
|
|
|
|
|
|
+ private final EsPatentService esPatentService;
|
|
|
|
+ private final PermissionService permissionService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增划词高亮
|
|
* 新增划词高亮
|
|
@@ -74,20 +86,19 @@ public class ScratchWordsService extends ServiceImpl<ScratchWordsMapper, Scratch
|
|
/**
|
|
/**
|
|
* 查询划词高亮
|
|
* 查询划词高亮
|
|
*
|
|
*
|
|
- * @param swQueryDTO
|
|
|
|
|
|
+ * @param queryScratchWordsDTO
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public List<String> queryAll(SwQueryDTO swQueryDTO) {
|
|
|
|
- if (swQueryDTO.getPatentNo() != null) {
|
|
|
|
- //获取当前登陆人信息
|
|
|
|
- PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
|
- Integer tenantId = personnelVO.getTenantId();
|
|
|
|
- String createId = personnelVO.getId();
|
|
|
|
|
|
+ public Records query(QueryScratchWordsDTO queryScratchWordsDTO) {
|
|
|
|
+
|
|
|
|
+ Records records = esScratchWordsService.queryScratchWord(queryScratchWordsDTO);
|
|
|
|
+ List<ScratchWordsVO> scratchWordsVOS = (List<ScratchWordsVO>) records.getData();
|
|
|
|
+ this.loadData(scratchWordsVOS);
|
|
|
|
+ records.setData(scratchWordsVOS);
|
|
|
|
+ records.setSize(queryScratchWordsDTO.getSize());
|
|
|
|
+ records.setCurrent(queryScratchWordsDTO.getCurrent());
|
|
|
|
+ return records;
|
|
|
|
|
|
- } else {
|
|
|
|
- throw new XiaoShiException("传入参数不可为空");
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -100,11 +111,54 @@ public class ScratchWordsService extends ServiceImpl<ScratchWordsMapper, Scratch
|
|
ids.forEach(item -> {
|
|
ids.forEach(item -> {
|
|
try {
|
|
try {
|
|
esScratchWordsService.removeById(item);
|
|
esScratchWordsService.removeById(item);
|
|
- }catch (Exception e){
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
throw new XiaoShiException("删除错误");
|
|
throw new XiaoShiException("删除错误");
|
|
}
|
|
}
|
|
|
|
|
|
});
|
|
});
|
|
return ids;
|
|
return ids;
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
+ private void loadData(List<ScratchWordsVO> scratchWordsVOS) {
|
|
|
|
+ List<String> ids = scratchWordsVOS.stream().map(ScratchWordsVO::getMarkUserId).collect(Collectors.toList());
|
|
|
|
+ List<String> patentIds = scratchWordsVOS.stream().map(ScratchWordsVO::getPatentId).collect(Collectors.toList());
|
|
|
|
+ //查询创建人名称
|
|
|
|
+ List<Personnel> personnels = new ArrayList<>();
|
|
|
|
+ List<Hit<Patent>> patents = new ArrayList<>();
|
|
|
|
+ if (ids.size() != 0) {
|
|
|
|
+ try {
|
|
|
|
+ String res = permissionService.getPersonnelByIdsFromPCS(ids);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
|
+ personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (patentIds.size() != 0) {
|
|
|
|
+ try {
|
|
|
|
+ patents = esPatentService.getById(patentIds);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (ScratchWordsVO scratchWordsVO : scratchWordsVOS) {
|
|
|
|
+ Personnel personnel = personnels.stream().filter(item -> item.getId().equals(scratchWordsVO.getMarkUserId())).findFirst().orElse(null);
|
|
|
|
+ if (personnel != null) {
|
|
|
|
+ scratchWordsVO.setCreateName(personnel.getPersonnelName());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Hit<Patent> patentHit = patents.stream().filter(item -> item.id().equals(scratchWordsVO.getPatentId())).findFirst().orElse(null);
|
|
|
|
+ if (patentHit != null) {
|
|
|
|
+ Patent patent = patentHit.source();
|
|
|
|
+ scratchWordsVO.setPatentNo(patent.getPatentNo());
|
|
|
|
+ if (patent.getTitle() != null && patent.getTitle().size() > 0) {
|
|
|
|
+ scratchWordsVO.setTitle(patentHit.source().getTitle().get(0).getTextContent());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|