|
@@ -9,16 +9,12 @@ import cn.cslg.report.common.model.vo.*;
|
|
|
import cn.cslg.report.common.utils.DataUtils;
|
|
|
import cn.cslg.report.common.utils.DateUtils;
|
|
|
import cn.cslg.report.common.utils.Response;
|
|
|
-import cn.cslg.report.entity.CompareRecords;
|
|
|
-import cn.cslg.report.entity.CompareScenarios;
|
|
|
-import cn.cslg.report.entity.CompareScenariosAndRecords;
|
|
|
-import cn.cslg.report.entity.Task;
|
|
|
+import cn.cslg.report.common.utils.StringUtils;
|
|
|
+import cn.cslg.report.entity.*;
|
|
|
+import cn.cslg.report.entity.asso.AssoRecordsFeature;
|
|
|
import cn.cslg.report.service.BaseService;
|
|
|
import cn.cslg.report.service.OutInterfaceService;
|
|
|
-import cn.cslg.report.service.business.CompareRecordsService;
|
|
|
-import cn.cslg.report.service.business.CompareScenariosAndRecordsService;
|
|
|
-import cn.cslg.report.service.business.CompareScenariosService;
|
|
|
-import cn.cslg.report.service.business.TaskService;
|
|
|
+import cn.cslg.report.service.business.*;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -54,10 +50,14 @@ public class TaskController {
|
|
|
|
|
|
private final TaskService taskService;
|
|
|
private final BaseService baseService;
|
|
|
+
|
|
|
private final OutInterfaceService outInterfaceService;
|
|
|
private final CompareScenariosService compareScenariosService;
|
|
|
private final CompareScenariosAndRecordsService scenariosRecordsService;
|
|
|
private final CompareRecordsService compareRecordsService;
|
|
|
+ private final AssoRecordsFeatureService assoRecordsFeatureService;
|
|
|
+ private final FeatureService featureService;
|
|
|
+ private final ReportService reportService;
|
|
|
|
|
|
@RequestMapping(value = "/deleteTask", method = RequestMethod.POST)
|
|
|
@Operation(summary = "删除任务")
|
|
@@ -97,9 +97,9 @@ public class TaskController {
|
|
|
|
|
|
@RequestMapping(value = "/test", method = RequestMethod.GET)
|
|
|
@Operation(summary = "测试")
|
|
|
- public String test(String text1,String text2) throws ParseException, IOException {
|
|
|
- float a= DataUtils.getSimilarityRatio(text1,text2);
|
|
|
- return Response.success("相似度"+a);
|
|
|
+ public String test(String text1, String text2) throws ParseException, IOException {
|
|
|
+ float a = DataUtils.getSimilarityRatio(text1, text2);
|
|
|
+ return Response.success("相似度" + a);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/addAssTask", method = RequestMethod.POST)
|
|
@@ -107,6 +107,7 @@ public class TaskController {
|
|
|
public String addAssTask(@RequestBody AssignTaskVO assignTaskVO) throws ParseException, IOException {
|
|
|
return taskService.addAssTask(assignTaskVO);
|
|
|
}
|
|
|
+
|
|
|
@RequestMapping(value = "/reTaskPatents", method = RequestMethod.POST)
|
|
|
@Operation(summary = "返回任务专利清单")
|
|
|
public String reTaskPatents(@RequestBody TaskVO taskVO) throws ParseException, IOException {
|
|
@@ -115,82 +116,190 @@ public class TaskController {
|
|
|
|
|
|
@RequestMapping(value = "/import", method = RequestMethod.GET)
|
|
|
@Operation(summary = "导入")
|
|
|
- public String importPatent(MultipartFile file,Integer reportId) throws ParseException, IOException {
|
|
|
+ public String importPatent(MultipartFile file, Integer reportId) throws ParseException, IOException {
|
|
|
//解析file装载数据
|
|
|
- TaskParams taskParams = baseService.getImportPatentTaskParamsBro(file, reportId);
|
|
|
+ TaskParams taskParams = baseService.getImportPatentTaskParamsBro(file, reportId);
|
|
|
return Response.success();
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/temple", method = RequestMethod.GET)
|
|
|
@Operation(summary = "测试")
|
|
|
public String temple(Integer reportId) throws ParseException, IOException {
|
|
|
- String filePath= "C:\\Users\\admin\\Desktop\\1.docx";
|
|
|
+ String filePath = "C:\\Users\\admin\\Desktop\\3.docx";
|
|
|
// 读取模板后保存生成word的地址
|
|
|
- String outPath = "C:\\Users\\admin\\Desktop\\2.docx";
|
|
|
+ String outPath = "C:\\Users\\admin\\Desktop\\4.docx";
|
|
|
+ //根据报告Id获得报告信息
|
|
|
+ Report report = reportService.getById(reportId);
|
|
|
+ // 根据拆分人(报告的创建人)Id和报告ID获得所有特征
|
|
|
+ LambdaQueryWrapper<Features> allFeaturesWrapper = new LambdaQueryWrapper<>();
|
|
|
+ allFeaturesWrapper.eq(Features::getPartnerId, report.getPersonId())
|
|
|
+ .eq(Features::getReportId, report.getId());
|
|
|
+ List<Features> allFeatures = featureService.list(allFeaturesWrapper);
|
|
|
//查询所有的对比方案并获得Id
|
|
|
- LambdaQueryWrapper<CompareScenarios> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(CompareScenarios::getReportId,reportId);
|
|
|
- List<CompareScenarios> compareScenarios =compareScenariosService.list(queryWrapper);
|
|
|
- List<Integer> scenarioIds= compareScenarios.stream().map(CompareScenarios::getId).collect(Collectors.toList());
|
|
|
+ LambdaQueryWrapper<CompareScenarios> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(CompareScenarios::getReportId, reportId);
|
|
|
+ List<CompareScenarios> compareScenarios = compareScenariosService.list(queryWrapper);
|
|
|
+ List<Integer> scenarioIds = compareScenarios.stream().map(CompareScenarios::getId).collect(Collectors.toList());
|
|
|
//根据对比方案Id 从关联表里获得对比记录ID
|
|
|
- LambdaQueryWrapper<CompareScenariosAndRecords> queryRecordsByIDs=new LambdaQueryWrapper<>();
|
|
|
- queryRecordsByIDs.in(CompareScenariosAndRecords::getScenariosID,scenarioIds);
|
|
|
- List<CompareScenariosAndRecords> scenariosRecords= scenariosRecordsService.list(queryRecordsByIDs);
|
|
|
+ LambdaQueryWrapper<CompareScenariosAndRecords> queryRecordsByIDs = new LambdaQueryWrapper<>();
|
|
|
+ queryRecordsByIDs.in(CompareScenariosAndRecords::getScenariosID, scenarioIds);
|
|
|
+ List<CompareScenariosAndRecords> scenariosRecords = scenariosRecordsService.list(queryRecordsByIDs);
|
|
|
List<Integer> recordIds = scenariosRecords.stream().map(CompareScenariosAndRecords::getRecordID).collect(Collectors.toList());
|
|
|
+ //根据对比记录ID查询对比记录
|
|
|
+ LambdaQueryWrapper<CompareRecords> queryPatentByIDs = new LambdaQueryWrapper<>();
|
|
|
+ queryPatentByIDs.in(CompareRecords::getId, recordIds);
|
|
|
+ List<CompareRecords> compareRecords = compareRecordsService.list(queryPatentByIDs);
|
|
|
//根据对比记录ID获得专利号
|
|
|
- LambdaQueryWrapper<CompareRecords> queryPatentByIDs=new LambdaQueryWrapper<>();
|
|
|
- queryPatentByIDs.in(CompareRecords::getId,recordIds);
|
|
|
- List<CompareRecords> compareRecords =compareRecordsService.list(queryPatentByIDs);
|
|
|
- List<String> PatentNos =compareRecords.stream().map(CompareRecords::getPatentNo).collect(Collectors.toList());
|
|
|
- PatentVO patentVO =new PatentVO();
|
|
|
+ List<String> PatentNos = compareRecords.stream().map(CompareRecords::getPatentNo).collect(Collectors.toList());
|
|
|
+ //根据对比记录ID从对比记录特征关联表里获得关联数据
|
|
|
+ LambdaQueryWrapper<AssoRecordsFeature> queryAssoByRecordId = new LambdaQueryWrapper<>();
|
|
|
+ queryAssoByRecordId.in(AssoRecordsFeature::getRecordsId, recordIds);
|
|
|
+ List<AssoRecordsFeature> assoRecordsFeatures = assoRecordsFeatureService.list(queryAssoByRecordId);
|
|
|
+ // 从关联数据里获得特征id
|
|
|
+ List<Integer> featureIds = assoRecordsFeatures.stream().map(AssoRecordsFeature::getFeatureId).collect(Collectors.toList());
|
|
|
+ // 根据特征ID查询特征
|
|
|
+ LambdaQueryWrapper<Features> featuresWrapper = new LambdaQueryWrapper<>();
|
|
|
+ featuresWrapper.in(Features::getId, featureIds);
|
|
|
+ List<Features> features = featureService.list(featuresWrapper);
|
|
|
+
|
|
|
+ PatentVO patentVO = new PatentVO();
|
|
|
patentVO.setPatentNos(PatentNos);
|
|
|
//根据专利号查询专利详细信息
|
|
|
- String resBody= outInterfaceService. getPatentDTOListForRMS(patentVO);
|
|
|
- JSONObject jsonObject =JSONObject.parseObject(resBody);
|
|
|
- List<JSONObject> patentDTOS =JSON.parseArray(jsonObject.get("data").toString(),JSONObject.class);
|
|
|
+ String resBody = outInterfaceService.getPatentDTOListForRMS(patentVO);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
+ List<JSONObject> patentDTOS = JSON.parseArray(jsonObject.get("data").toString(), JSONObject.class);
|
|
|
+ //存放专利信息的map集合
|
|
|
+ List<Map<String, Object>> patentListMaps = new ArrayList<>();
|
|
|
+ //专利号别名的map
|
|
|
+ Map<String,Object> OtherName =new HashMap<>();
|
|
|
+ //填充专利数据到patentListMap
|
|
|
+ for (int i = 0; i < patentDTOS.size(); i++) {
|
|
|
+ JSONObject item = patentDTOS.get(i);
|
|
|
+ Map<String, Object> patentListMap = new HashMap<>();
|
|
|
+ List<JSONObject> applicantJSONs = JSON.parseArray(item.get("applicant").toString(), JSONObject.class);
|
|
|
+ ;
|
|
|
+ StringBuilder applicants = new StringBuilder();
|
|
|
+ applicantJSONs.forEach(tem -> {
|
|
|
+ applicants.append(tem.get("name") + "\r");
|
|
|
+ });
|
|
|
+ patentListMap.put("name", item.get("name"));
|
|
|
+ patentListMap.put("fileName", "D" + (i + 1));
|
|
|
+ patentListMap.put("publicDate", item.get("publicDate"));
|
|
|
+ patentListMap.put("publicNo", item.get("publicNo"));
|
|
|
+ patentListMap.put("SSIM", "");
|
|
|
+ patentListMap.put("applicant", applicants);
|
|
|
+ patentListMap.put("patentNo", item.get("publicNo"));
|
|
|
+ patentListMap.put("abstractStr", item.get("abstractStr"));
|
|
|
+ patentListMap.put("compareFileName", "对比文件" + (i + 1));
|
|
|
+ patentListMap.put("applicationDate", item.get("applicationDate"));
|
|
|
+ patentListMap.put("abstractPath", item.get("abstractPath"));
|
|
|
+ patentListMaps.add(patentListMap);
|
|
|
+ OtherName.put(item.get("publicNo").toString(),("D" + (i + 1)));
|
|
|
+ }
|
|
|
+
|
|
|
+ //存放对比方案信息的map集合
|
|
|
+ List<Map<String, Object>> scenariosMaps = new ArrayList<>();
|
|
|
+ for (int i = 0; i < compareScenarios.size(); i++) {
|
|
|
+ CompareScenarios item1 = compareScenarios.get(i);
|
|
|
+ //获得单个对比方案的权要的所有特征
|
|
|
+ List<Features> partFeatures = allFeatures.stream().filter(item -> item.getRightId().equals(item1.getRightId())).collect(Collectors.toList());
|
|
|
+ List<Integer> partFeatureIds =partFeatures.stream().map(Features::getId).collect(Collectors.toList());
|
|
|
+ //获得单个对比方案的
|
|
|
+ List<CompareScenariosAndRecords> partScenariosRecords = scenariosRecords.stream().filter(item -> item.getScenariosID().equals(item1.getId())).collect(Collectors.toList());
|
|
|
+ List<Integer> recordsIds = partScenariosRecords.stream().map(CompareScenariosAndRecords::getRecordID).collect(Collectors.toList());
|
|
|
+ List<CompareRecords> records = compareRecords.stream().filter(item -> recordsIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
+ //存放单条对比结果的map
|
|
|
+ Map<String, Object> temMap = new HashMap<>();
|
|
|
+ if (partFeatures.get(0).getRightType().equals(1)) {
|
|
|
+ temMap.put("rightName", "独立" + partFeatures.get(0).getRightName());
|
|
|
+ } else {
|
|
|
+ temMap.put("rightName", "附属" + partFeatures.get(0).getRightName());
|
|
|
+ }
|
|
|
|
|
|
- //获得详情转换为List
|
|
|
+ //新颖性模块
|
|
|
+ //获得本方案所有的专利号
|
|
|
+ List<String> patentNOs = new ArrayList<>();
|
|
|
+ records.forEach(item -> {
|
|
|
+ if (!patentNOs.contains(item.getPatentNo())) {
|
|
|
+ patentNOs.add(item.getPatentNo());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //比较所有专利号和权要所有权要的大小,如果相等则将该专利加入到新颖性列表中
|
|
|
+ List<String> noveltyFiles = new ArrayList<>();
|
|
|
+ patentNOs.forEach(
|
|
|
+ item -> {
|
|
|
+ List<Integer> temRecordIds = records.stream().filter(tm -> tm.getPatentNo().equals(item)).map(CompareRecords::getId).collect(Collectors.toList());
|
|
|
+ List<Integer> temFIds = assoRecordsFeatures.stream().filter(tm -> temRecordIds.contains(tm.getRecordsId())).map(AssoRecordsFeature::getFeatureId).collect(Collectors.toList());
|
|
|
+ if (temFIds.size() == partFeatures.size()) {
|
|
|
+ String tmName = item;
|
|
|
+ if(OtherName.containsKey(item))
|
|
|
+ {
|
|
|
+ tmName=OtherName.get(item).toString();
|
|
|
+ }
|
|
|
+ noveltyFiles.add(tmName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ //创造性模块
|
|
|
+ List<String> creativeFiles = new ArrayList<>();
|
|
|
+ partFeatureIds.forEach(
|
|
|
+ item->{
|
|
|
+ List<Integer> temRecordIDs = assoRecordsFeatures.stream().filter(tm->tm.getFeatureId().equals(item)).map(AssoRecordsFeature::getRecordsId).collect(Collectors.toList());
|
|
|
+ List<CompareRecords> temRecords =records.stream().filter(tm->temRecordIDs.contains(tm.getId())).collect(Collectors.toList());
|
|
|
+ List<String> temStrs =new ArrayList<>();
|
|
|
+ temRecords.forEach(
|
|
|
+ tm->{String name =tm.getPatentNo();
|
|
|
+ if(OtherName.containsKey(tm.getPatentNo())){
|
|
|
+ name= OtherName.get(tm.getPatentNo()).toString();
|
|
|
+ }
|
|
|
|
|
|
- //填充到map
|
|
|
+ if(!temStrs.contains(name)){
|
|
|
+ temStrs.add(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ List<CompareScenariosAndRecords> andRecords = partScenariosRecords.stream().filter(tm->tm.getFeaturesID().equals(item)).collect(Collectors.toList());
|
|
|
+ if(andRecords.size()!=0){
|
|
|
+ temStrs.add("C");
|
|
|
+ }
|
|
|
+ String join = StringUtils.join(temStrs, "+");
|
|
|
+ creativeFiles.add(join);
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ String creative = StringUtils.join(creativeFiles, ",");
|
|
|
+ String novelty = StringUtils.join(noveltyFiles, "-");
|
|
|
+ temMap.put("novelty", novelty);
|
|
|
+ temMap.put("creative", creative);
|
|
|
+ scenariosMaps.add(temMap);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// 为表格的显示绑定行循环
|
|
|
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
|
|
// 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
|
|
|
- Configure configure = Configure.builder().bind("pss", policy).build();
|
|
|
- List<Patents> aa =new ArrayList<>();
|
|
|
- for(int i=0;i<5;i++) {
|
|
|
- Patents patents = new Patents();
|
|
|
- patents.setPatentNo("专利号"+i);
|
|
|
- patents.setPerson("专利人"+i);
|
|
|
- patents.setName("发明"+i);
|
|
|
- patents.setId(i);
|
|
|
- patents.setExplain("https://tse4-mm.cn.bing.net/th/id/OIP-C.QFdwl07_aviM1ch2KpyyFgHaEo?pid=ImgDet&rs=1");
|
|
|
- patents.setTime("202"+i+"/11/11 11:11:11");
|
|
|
- aa.add(patents);
|
|
|
- }
|
|
|
- Map<String,Object> map= new HashMap<>();
|
|
|
- PatentList patentList =new PatentList();
|
|
|
- patentList.setPatentsList(aa);
|
|
|
- patentList.setName("列表");
|
|
|
+ Configure configure = Configure.builder().bind("patentList", policy).bind("compareResult",policy).build();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
//1.系统数据
|
|
|
String date = DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD);
|
|
|
String[] ds = date.split("-");
|
|
|
- map.put("sys", new SystemMO(ds[0], ds[1], ds[2], "","reportName"));
|
|
|
- map.put("pss",aa);
|
|
|
- map.put("sss","saeqeq");
|
|
|
- map.put("tm",patentList);
|
|
|
+ map.put("sys", new SystemMO(ds[0], ds[1], ds[2], "", "reportName"));
|
|
|
+ map.put("sss", "saeqeq");
|
|
|
+ map.put("patentList", patentListMaps);
|
|
|
+ map.put("compareResult",scenariosMaps);
|
|
|
// 读取模板、数据并渲染
|
|
|
XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
|
|
|
|
|
|
-// 文件是否已存在,则删除map = {TaskController$1@15526} size = 7
|
|
|
+// 文件是否已存在,则删除
|
|
|
File file = new File(outPath);
|
|
|
- if (file.exists()){
|
|
|
+ if (file.exists()) {
|
|
|
file.delete();
|
|
|
}
|
|
|
// 生成word保存在指定目录
|
|
|
template.writeToFile(outPath);
|
|
|
template.close();
|
|
|
|
|
|
-return Response.success();
|
|
|
+ return Response.success();
|
|
|
}
|
|
|
}
|