|
@@ -2,11 +2,13 @@ package cn.cslg.report.service.business;
|
|
|
|
|
|
import cn.cslg.report.common.model.vo.CompareRecordsVO;
|
|
|
import cn.cslg.report.common.utils.Response;
|
|
|
+import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
|
import cn.cslg.report.common.utils.StringUtils;
|
|
|
import cn.cslg.report.entity.CompareFiles;
|
|
|
import cn.cslg.report.entity.CompareRecords;
|
|
|
import cn.cslg.report.entity.Features;
|
|
|
import cn.cslg.report.entity.Report;
|
|
|
+import cn.cslg.report.entity.asso.AssoRecordsFeature;
|
|
|
import cn.cslg.report.mapper.CompareFilesMapper;
|
|
|
import cn.cslg.report.mapper.CompareRecordsMapper;
|
|
|
import cn.cslg.report.mapper.FeatureMapper;
|
|
@@ -25,101 +27,77 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
public class CompareRecordsService extends ServiceImpl<CompareRecordsMapper, CompareRecords> {
|
|
|
- public final CompareRecordsMapper compareRecordsMapper;
|
|
|
- public final FeatureMapper featureMapper;
|
|
|
- public String addCompareRecord(CompareRecords compareRecord) throws IOException{
|
|
|
- compareRecord.setFeaturesId(StringUtils.join(compareRecord.getFeaturesIdList(),","));
|
|
|
+ public final CompareRecordsMapper compareRecordsMapper;
|
|
|
+ public final FeatureMapper featureMapper;
|
|
|
+ public final LoginUtils loginUtils;
|
|
|
+ public final FeatureService featureService;
|
|
|
+ public final AssoRecordsFeatureService assoRecordsFeatureService;
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String addCompareRecord(CompareRecords compareRecord) throws IOException {
|
|
|
compareRecord.insert();
|
|
|
+ List<AssoRecordsFeature> assoRecordsFeatures = compareRecord.getAssoRecordsFeatures();
|
|
|
+ assoRecordsFeatures.forEach(item -> item.setRecordsId(compareRecord.getId()));
|
|
|
+ assoRecordsFeatureService.saveBatch(assoRecordsFeatures);
|
|
|
return Response.success();
|
|
|
|
|
|
}
|
|
|
- public String deleCompareRecords(int id)throws IOException{
|
|
|
- this.removeById(id);
|
|
|
- return Response.success();
|
|
|
+
|
|
|
+ public String deleCompareRecords(int id) throws IOException {
|
|
|
+ this.removeById(id);
|
|
|
+ return Response.success();
|
|
|
}
|
|
|
+
|
|
|
@Transactional
|
|
|
- public String updateCompareRecords(CompareRecords compareRecord)throws IOException{
|
|
|
+ public String updateCompareRecords(CompareRecords compareRecord) throws IOException {
|
|
|
String str = StringUtils.join(compareRecord.getFeaturesIdList(), ",");
|
|
|
Integer id = compareRecord.getId();
|
|
|
- compareRecordsMapper.updateCompareRecords(str,id);
|
|
|
+ compareRecordsMapper.updateCompareRecords(str, id);
|
|
|
return Response.success();
|
|
|
}
|
|
|
- public String getCompareRecords(int reportId,String patentNo,int personId)throws IOException{
|
|
|
- List<CompareRecords> compareRecords = compareRecordsMapper.find(reportId, patentNo, personId);
|
|
|
- List<CompareRecords> list=new ArrayList<>();
|
|
|
- for(CompareRecords c:compareRecords){
|
|
|
- String featuresId = c.getFeaturesId();
|
|
|
- if(featuresId==null){
|
|
|
- return Response.success(compareRecords);
|
|
|
- }
|
|
|
- List<CompareRecords.CY> list1=new ArrayList<>();
|
|
|
- String[] split = featuresId.split(",");
|
|
|
- for(String str :split){
|
|
|
- int id=Integer.parseInt(str);
|
|
|
- Features features = featureMapper.find(id);
|
|
|
- CompareRecords.CY cy=new CompareRecords.CY();
|
|
|
- cy.setId(id);
|
|
|
- cy.setContent(features.getContent());
|
|
|
- cy.setRightName(features.getRightName());
|
|
|
- list1.add(cy);
|
|
|
- }
|
|
|
- c.setCY(list1);
|
|
|
- list.add(c);
|
|
|
- }
|
|
|
|
|
|
- return Response.success(list);
|
|
|
- }
|
|
|
- public String getCompareRecords(int reportId,int id)throws IOException{
|
|
|
- CompareRecords compareRecords = compareRecordsMapper.getCompareRecords(reportId);
|
|
|
- int personId = compareRecords.getPersonId();
|
|
|
- String str1=String.valueOf(personId);
|
|
|
- String str2=String.valueOf(id);
|
|
|
- if(str1.equals(str2)){
|
|
|
- List<CompareRecords> compareRecords1 = compareRecordsMapper.findCompareRecords(id);
|
|
|
- List<CompareRecords> list2=new ArrayList<>();
|
|
|
- for(CompareRecords a:compareRecords1){
|
|
|
- CompareRecords compareRecords2=new CompareRecords();
|
|
|
- String featuresId = a.getFeaturesId();
|
|
|
- if(featuresId==null){
|
|
|
- return Response.success(compareRecords);
|
|
|
- }
|
|
|
- String[] split = featuresId.split(",");
|
|
|
- List<CompareRecords.CY> list=new ArrayList<>();
|
|
|
- for(String str :split){
|
|
|
- int i=Integer.parseInt(str);
|
|
|
- Features features = featureMapper.find(i);
|
|
|
- CompareRecords.CY cy=new CompareRecords.CY();
|
|
|
- cy.setId(i);
|
|
|
- cy.setContent(features.getContent());
|
|
|
- cy.setRightName(features.getRightName());
|
|
|
- list.add(cy);
|
|
|
- }
|
|
|
- a.setCY(list);
|
|
|
- list2.add(a);
|
|
|
- }
|
|
|
- return Response.success(list2);
|
|
|
+ public String getCompareRecords(int reportId, String patentNo) throws IOException {
|
|
|
+ Integer personId = loginUtils.getId();
|
|
|
+ LambdaQueryWrapper<CompareRecords> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(CompareRecords::getReportId, reportId)
|
|
|
+ .eq(CompareRecords::getPersonId, personId);
|
|
|
+ if (patentNo != null) {
|
|
|
+ wrapper.eq(CompareRecords::getPatentNo, patentNo);
|
|
|
+ }
|
|
|
+ List<CompareRecords> list = new ArrayList<>();
|
|
|
+ List<CompareRecords> compareRecords = this.list(wrapper);
|
|
|
+ if (compareRecords.size() == 0 || compareRecords == null) {
|
|
|
+ return Response.success(list);
|
|
|
}
|
|
|
- List<CompareRecords.CY> list=new ArrayList<>();
|
|
|
- String str3=compareRecords.getFeaturesId();
|
|
|
- if(str3==null){
|
|
|
+ List<Integer> ids = compareRecords.stream().map(CompareRecords::getId).collect(Collectors.toList());
|
|
|
+ if (ids.size() == 0) {
|
|
|
return Response.success(compareRecords);
|
|
|
}
|
|
|
- String[] split = str3.split(",");
|
|
|
- for(String str :split){
|
|
|
- int i=Integer.parseInt(str);
|
|
|
- Features features = featureMapper.find(i);
|
|
|
- CompareRecords.CY cy=new CompareRecords.CY();
|
|
|
- cy.setId(i);
|
|
|
- cy.setContent(features.getContent());
|
|
|
- cy.setRightName(features.getRightName());
|
|
|
- list.add(cy);
|
|
|
+ LambdaQueryWrapper<AssoRecordsFeature> assoWrapper = new LambdaQueryWrapper<>();
|
|
|
+ assoWrapper.in(AssoRecordsFeature::getRecordsId, ids);
|
|
|
+ List<AssoRecordsFeature> assoRecordsFeatures = assoRecordsFeatureService.list(assoWrapper);
|
|
|
+ List<Integer> featureIds = assoRecordsFeatures.stream().map(AssoRecordsFeature::getFeatureId).collect(Collectors.toList());
|
|
|
+ List<Features> features = new ArrayList<>();
|
|
|
+ if (featureIds.size() != 0 && featureIds != null) {
|
|
|
+ LambdaQueryWrapper<Features> featuresLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ featuresLambdaQueryWrapper.in(Features::getId, featureIds);
|
|
|
+ features = featureService.list(featuresLambdaQueryWrapper);
|
|
|
+
|
|
|
+ }
|
|
|
+ for (CompareRecords records : compareRecords) {
|
|
|
+ List<AssoRecordsFeature> assoRecordsFeatures1 = assoRecordsFeatures.stream().filter(item -> item.getRecordsId().equals(records.getId())).collect(Collectors.toList());
|
|
|
+ List<Integer> featureId = assoRecordsFeatures1.stream().map(AssoRecordsFeature::getFeatureId).collect(Collectors.toList());
|
|
|
+ records.setAssoRecordsFeatures(assoRecordsFeatures1);
|
|
|
+ List<Features> featuresList = features.stream().filter(item -> featureId.contains(item.getId())).collect(Collectors.toList());
|
|
|
+ records.setFeatures(featuresList);
|
|
|
}
|
|
|
- compareRecords.setCY(list);
|
|
|
return Response.success(compareRecords);
|
|
|
}
|
|
|
+
|
|
|
}
|