|
@@ -1,6 +1,5 @@
|
|
|
package cn.cslg.pas.service.business;
|
|
|
|
|
|
-import cn.cslg.pas.common.dto.AddNoveltyProjectDTO;
|
|
|
import cn.cslg.pas.common.dto.AddTechnicalCaseDTO;
|
|
|
import cn.cslg.pas.common.dto.TechnicalCaseIdDTO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
@@ -22,16 +21,10 @@ import cn.cslg.pas.mapper.TechnicalCaseMapper;
|
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
|
import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
|
-import co.elastic.clients.elasticsearch._types.SortOptions;
|
|
|
-import co.elastic.clients.elasticsearch._types.SortOrder;
|
|
|
-import co.elastic.clients.elasticsearch._types.query_dsl.IdsQuery;
|
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.Like;
|
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
|
|
|
-import co.elastic.clients.elasticsearch.core.IndexResponse;
|
|
|
-import co.elastic.clients.elasticsearch.core.SearchRequest;
|
|
|
-import co.elastic.clients.elasticsearch.core.SearchResponse;
|
|
|
-import co.elastic.clients.elasticsearch.core.UpdateRequest;
|
|
|
+import co.elastic.clients.elasticsearch.core.*;
|
|
|
import co.elastic.clients.elasticsearch.core.search.Hit;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
@@ -51,7 +44,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -125,7 +117,7 @@ public class TechnicalCaseService extends ServiceImpl<TechnicalCaseMapper, Techn
|
|
|
// casePatent.setProjectId(vo.getProjectId());
|
|
|
casePatent.setInventionPoint(vo.getInventionPoint());
|
|
|
Integer count = this.updateTechnicalCasePatent(casePatent, pointVO.getPatentId());
|
|
|
- if (count > 0) {
|
|
|
+ if (count < 1) {
|
|
|
throw new XiaoShiException("发明点更新Es失败");
|
|
|
}
|
|
|
}
|
|
@@ -179,25 +171,31 @@ public class TechnicalCaseService extends ServiceImpl<TechnicalCaseMapper, Techn
|
|
|
return technicalCaseVO;
|
|
|
}
|
|
|
|
|
|
- public void deleteTechnicalCase(TechnicalCaseIdDTO vo) {
|
|
|
+ public void deleteTechnicalCase(TechnicalCaseIdDTO vo) throws Exception {
|
|
|
LambdaQueryWrapper<AssoTechnicalCaseFile> deleteFileWrapper = new LambdaQueryWrapper<>();
|
|
|
deleteFileWrapper.eq(AssoTechnicalCaseFile::getTechnicalCaseId, vo.getTechnicalCaseId());
|
|
|
assoTechnicalCaseFileService.remove(deleteFileWrapper);
|
|
|
|
|
|
+ TechnicalCase technicalCase = technicalCaseMapper.selectById(vo.getTechnicalCaseId());
|
|
|
+ EditInventionPointVO pointVO = this.selectTechnicalCasePatent(technicalCase.getProjectId());
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ list.add(pointVO.getPatentId());
|
|
|
+ this.delete(list);
|
|
|
+
|
|
|
this.removeById(vo.getTechnicalCaseId());
|
|
|
}
|
|
|
|
|
|
public List<QueryInventionPointVO> querySimilarInventionPoint(String content) throws IOException {
|
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
//设置查询索引
|
|
|
- builder.index("technical_case_patent");
|
|
|
+ builder.index("technicalPatent");
|
|
|
Like likeContent = Like.of(i -> i.text(content));
|
|
|
Query query = QueryBuilders.moreLikeThis(i -> i.fields("invention_point").like(likeContent)
|
|
|
- .minTermFreq(1).maxQueryTerms(12));
|
|
|
+ .minTermFreq(1).maxQueryTerms(12).minDocFreq(1));
|
|
|
builder.query(query);
|
|
|
- builder.from(0).size(5);
|
|
|
+ builder.size(5);
|
|
|
//解除最大条数限制
|
|
|
- builder.trackTotalHits(i -> i.enabled(true));
|
|
|
+// builder.trackTotalHits(i -> i.enabled(true));
|
|
|
SearchResponse<TechnicalCasePatent> response = client.search(builder.build(), TechnicalCasePatent.class);
|
|
|
List<Hit<TechnicalCasePatent>> hits = response.hits().hits();
|
|
|
List<QueryInventionPointVO> inventionPointVOS = new ArrayList<>();
|
|
@@ -240,7 +238,7 @@ public class TechnicalCaseService extends ServiceImpl<TechnicalCaseMapper, Techn
|
|
|
EditInventionPointVO pointVO = new EditInventionPointVO();
|
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
//设置查询索引
|
|
|
- builder.index("technical_case_patent");
|
|
|
+ builder.index("technicalPatent");
|
|
|
Query query = QueryBuilders.term(i -> i.field("project_id").value(projectId));
|
|
|
builder.query(query);
|
|
|
SearchResponse<TechnicalCasePatent> response = client.search(builder.build(), TechnicalCasePatent.class);
|
|
@@ -258,7 +256,7 @@ public class TechnicalCaseService extends ServiceImpl<TechnicalCaseMapper, Techn
|
|
|
//添加TechnicalCasePatent
|
|
|
public String addTechnicalCasePatent(TechnicalCasePatent casePatent) throws Exception {
|
|
|
IndexResponse indexResponse = client.index(i -> i
|
|
|
- .index("technical_case_patent")
|
|
|
+ .index("technicalPatent")
|
|
|
//传入user对象
|
|
|
.document(casePatent)
|
|
|
);
|
|
@@ -269,7 +267,7 @@ public class TechnicalCaseService extends ServiceImpl<TechnicalCaseMapper, Techn
|
|
|
public Integer updateTechnicalCasePatent(TechnicalCasePatent patent, String id) {
|
|
|
UpdateRequest<TechnicalCasePatent, TechnicalCasePatent> req;
|
|
|
req = UpdateRequest.of(
|
|
|
- b -> b.index("technical_case_patent").id(id)
|
|
|
+ b -> b.index("technicalPatent").id(id)
|
|
|
.doc(patent));
|
|
|
try {
|
|
|
client.update(req, TechnicalCasePatent.class);
|
|
@@ -278,4 +276,16 @@ public class TechnicalCaseService extends ServiceImpl<TechnicalCaseMapper, Techn
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //删除TechnicalCasePatent
|
|
|
+ public Integer delete(List<String> ids) {
|
|
|
+ Query query = QueryBuilders.ids(n -> n.values(ids));
|
|
|
+ DeleteByQueryRequest request = DeleteByQueryRequest.of(i -> i.index("technicalPatent").refresh(true).query(query));
|
|
|
+ try {
|
|
|
+ client.deleteByQuery(request);
|
|
|
+ return 1;
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new XiaoShiException("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|