|
@@ -10,14 +10,11 @@ import cn.cslg.report.entity.*;
|
|
|
|
|
|
import cn.cslg.report.entity.asso.AssoReportFile;
|
|
|
import cn.cslg.report.entity.asso.AssoReportPerson;
|
|
|
-import cn.cslg.report.entity.invalidReReport.InvalidReReport;
|
|
|
-import cn.cslg.report.entity.invalidReReport.InvalidReason;
|
|
|
+import cn.cslg.report.entity.invalidReReport.*;
|
|
|
import cn.cslg.report.exception.XiaoShiException;
|
|
|
import cn.cslg.report.mapper.ReportMapper;
|
|
|
import cn.cslg.report.service.*;
|
|
|
-import cn.cslg.report.service.business.InvalidReReport.InvalidReReportService;
|
|
|
-import cn.cslg.report.service.business.InvalidReReport.InvalidReasonFieldService;
|
|
|
-import cn.cslg.report.service.business.InvalidReReport.InvalidReasonService;
|
|
|
+import cn.cslg.report.service.business.InvalidReReport.*;
|
|
|
import cn.cslg.report.service.business.asso.AssoReportPersonService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -25,9 +22,15 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import okhttp3.MediaType;
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
+import okhttp3.Request;
|
|
|
+import okhttp3.RequestBody;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -35,7 +38,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.lang.reflect.Type;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -71,6 +76,14 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
private final InvalidReReportService invalidReReportService;
|
|
|
private final InvalidReasonFieldService invalidReasonFieldService;
|
|
|
private final InvalidReasonService invalidReasonService;
|
|
|
+ private final ArgumentsService argumentsService;
|
|
|
+ private final AssoPositionFeaturesService assoPositionFeaturesService;
|
|
|
+ private final ProofGroupService proofGroupService;
|
|
|
+ private final AssoProofGroupStrService assoProofGroupStrService;
|
|
|
+ private final InvalidProcessService invalidProcessService;
|
|
|
+ private final ProofStrService proofStrService;
|
|
|
+ private final ArgumentsScenarioService argumentsScenarioService;
|
|
|
+ private final ScratchService scratchService;
|
|
|
|
|
|
private Report loadReport(ReportDTO reportDto) {
|
|
|
Report report = new Report();
|
|
@@ -140,12 +153,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
}
|
|
|
//新增报告
|
|
|
Report report = this.loadReport(reportDto);
|
|
|
- if (reportDto.getTrack() != null && reportDto.getTrack()) {
|
|
|
- report.setCronConclusion(null);
|
|
|
- report.setConclusionId(null);
|
|
|
- }
|
|
|
report.insert();
|
|
|
- //TODO 当是无效应对报告时,在无效应对报告里插入信息
|
|
|
if (files != null && files.size() != 0) {
|
|
|
//当
|
|
|
if (report.getStatus() != 3) {
|
|
@@ -185,12 +193,38 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
copyService.CopyPatentLabels(oldFields, fields);
|
|
|
}
|
|
|
}
|
|
|
+ if (report.getType() == 7) {
|
|
|
+ invalidReasonFieldService.addDefault(report.getId());
|
|
|
+ // 当是无效应对报告时,在无效应对报告里插入信息
|
|
|
+ InvalidReReport invalidReReport = new InvalidReReport();
|
|
|
+ invalidReReport.setReportId(report.getId());
|
|
|
+ invalidReReport.setCreateId(loginUtils.getId());
|
|
|
+ invalidReReport.setInvalidApplication(reportDto.getInvalidApplication());
|
|
|
+ invalidReReport.setCaseNumber(reportDto.getCaseNumber());
|
|
|
+ invalidReReport.setIssueNumber(reportDto.getIssueNumber());
|
|
|
+ invalidReReport.setInventionName(reportDto.getInventionName());
|
|
|
+ invalidReReport.setCurrentApplication(reportDto.getCurrentApplication());
|
|
|
+ invalidReReport.setInvalidApplication(reportDto.getInvalidApplication());
|
|
|
+ invalidReReport.setSuggestion(reportDto.getSuggestion());
|
|
|
+ invalidReReport.insert();
|
|
|
+ }
|
|
|
} else {
|
|
|
if (report.getType() != 7) {
|
|
|
reportFieldService.addDefaultField(report.getId(), report.getType());
|
|
|
} else {
|
|
|
invalidReasonFieldService.addDefault(report.getId());
|
|
|
-
|
|
|
+ // 当是无效应对报告时,在无效应对报告里插入信息
|
|
|
+ InvalidReReport invalidReReport = new InvalidReReport();
|
|
|
+ invalidReReport.setReportId(report.getId());
|
|
|
+ invalidReReport.setCreateId(loginUtils.getId());
|
|
|
+ invalidReReport.setInvalidApplication(reportDto.getInvalidApplication());
|
|
|
+ invalidReReport.setCaseNumber(reportDto.getCaseNumber());
|
|
|
+ invalidReReport.setIssueNumber(reportDto.getIssueNumber());
|
|
|
+ invalidReReport.setInventionName(reportDto.getInventionName());
|
|
|
+ invalidReReport.setCurrentApplication(reportDto.getCurrentApplication());
|
|
|
+ invalidReReport.setInvalidApplication(reportDto.getInvalidApplication());
|
|
|
+ invalidReReport.setSuggestion(reportDto.getSuggestion());
|
|
|
+ invalidReReport.insert();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -283,6 +317,18 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //查询报告,由分析系统调用使用
|
|
|
+ public String queryReportByPAS() {
|
|
|
+ LambdaQueryWrapper<Report> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.ne(Report::getId, 0);
|
|
|
+ queryWrapper.orderByDesc(Report::getCreateTime);
|
|
|
+ SecurityUtils.startDataScope("/pcs/report/query");
|
|
|
+ List<Report> reports = this.list(queryWrapper);
|
|
|
+ List<Integer> reportIds = reports.stream().map(Report::getId).collect(Collectors.toList());
|
|
|
+ long count = this.count(queryWrapper);
|
|
|
+ return Response.success(reportIds, DataUtils.setPageColumn(0, 0, Math.toIntExact(count)));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param reports
|
|
|
* @return
|
|
@@ -444,6 +490,23 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
List<Integer> fileIdList = reportFileService.uploadFiles(files);
|
|
|
assoReportFileService.addAsso(reportDto.getId(), fileIdList);
|
|
|
}
|
|
|
+ if (report.getType() == 7) {
|
|
|
+ LambdaQueryWrapper<InvalidReReport> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ wrapper1.eq(InvalidReReport::getReportId, report.getId());
|
|
|
+ List<InvalidReReport> invalidReReports = invalidReReportService.list(wrapper1);
|
|
|
+ if (invalidReReports.size() > 0) {
|
|
|
+ InvalidReReport invalidReReport = invalidReReports.get(0);
|
|
|
+ invalidReReport.setInvalidApplication(reportDto.getInvalidApplication());
|
|
|
+ invalidReReport.setCaseNumber(reportDto.getCaseNumber());
|
|
|
+ invalidReReport.setIssueNumber(reportDto.getIssueNumber());
|
|
|
+ invalidReReport.setInventionName(reportDto.getInventionName());
|
|
|
+ invalidReReport.setCurrentApplication(reportDto.getCurrentApplication());
|
|
|
+ invalidReReport.setInvalidApplication(reportDto.getInvalidApplication());
|
|
|
+ invalidReReport.setSuggestion(reportDto.getSuggestion());
|
|
|
+ invalidReReport.updateById();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
return report.updateById();
|
|
|
|
|
|
}
|
|
@@ -458,8 +521,16 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
public String reportDele(int id) throws IOException {
|
|
|
//删除所有和报告有关的任务
|
|
|
taskService.deleteTaskByreportId(id);
|
|
|
+ //删除陈述意见表数据
|
|
|
+ argumentsService.remove(new LambdaQueryWrapper<Arguments>().eq(Arguments::getReportId, id));
|
|
|
//删除所有和报告有关的特征
|
|
|
- featureService.delByReportId(id);
|
|
|
+ List<Features> features = featureService.list(new LambdaQueryWrapper<Features>().eq(Features::getReportId, id));
|
|
|
+ //删除特征位置关联表数据
|
|
|
+ if (features != null && features.size() > 0) {
|
|
|
+ List<Integer> featureIds = features.stream().map(Features::getId).collect(Collectors.toList());
|
|
|
+ assoPositionFeaturesService.remove(new LambdaQueryWrapper<AssoPositionFeatures>().in(AssoPositionFeatures::getFeaturesID, featureIds));
|
|
|
+ featureService.delByReportId(id);
|
|
|
+ }
|
|
|
//删除所有和报告有关的自定义字段
|
|
|
reportFieldService.deleteByReportId(id);
|
|
|
//删除所有和报告有关的对比方案
|
|
@@ -474,6 +545,8 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
compareFilesService.delete(id);
|
|
|
//导入删除导入任务
|
|
|
importTaskService.deleteByRortID(id);
|
|
|
+ //删除分析系统该报告的所有导入导出任务
|
|
|
+ outInterfaceService.deleteReportTasks(id);
|
|
|
|
|
|
//删除报告文件导出
|
|
|
reportDocumentService.deleteByReportId(id);
|
|
@@ -481,12 +554,31 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
reportReferencesService.deleteByReportId(id);
|
|
|
//删除对比信息
|
|
|
compareMessageService.deleteByreportID(id);
|
|
|
- //TODO 当时无效应对报告时
|
|
|
-
|
|
|
//删除与报告关联的表数据
|
|
|
invalidReReportService.remove(new LambdaQueryWrapper<InvalidReReport>().eq(InvalidReReport::getReportId, id));
|
|
|
//删除无效理由表数据
|
|
|
- invalidReasonService.remove(new LambdaQueryWrapper<InvalidReason>().eq(InvalidReason::getReportId, id));
|
|
|
+ List<InvalidReason> invalidReasons = invalidReasonService.list(new LambdaQueryWrapper<InvalidReason>().eq(InvalidReason::getReportId, id));
|
|
|
+ if (invalidReasons != null && invalidReasons.size() > 0) {
|
|
|
+ List<Integer> invalidReasonIds = invalidReasons.stream().map(InvalidReason::getId).collect(Collectors.toList());
|
|
|
+ //删除证据组合表数据
|
|
|
+ List<ProofGroup> proofGroups = proofGroupService.list(new LambdaQueryWrapper<ProofGroup>().in(ProofGroup::getInvalidReasonId, invalidReasonIds));
|
|
|
+ if (proofGroups != null && proofGroups.size() > 0) {
|
|
|
+ List<Integer> proofGroupIds = proofGroups.stream().map(ProofGroup::getId).collect(Collectors.toList());
|
|
|
+ //删除证据组合无效证据关联表数据
|
|
|
+ assoProofGroupStrService.remove(new LambdaQueryWrapper<AssoProofGroupStr>().in(AssoProofGroupStr::getProofGroupId, proofGroupIds));
|
|
|
+ proofGroupService.removeByIds(proofGroupIds);
|
|
|
+ }
|
|
|
+ //删除无效理由表数据
|
|
|
+ invalidReasonService.removeByIds(invalidReasons);
|
|
|
+ }
|
|
|
+ //删除无效事务表数据
|
|
|
+ invalidProcessService.remove(new LambdaQueryWrapper<InvalidProcess>().eq(InvalidProcess::getReportId, id));
|
|
|
+ //删除无效理由证据表数据
|
|
|
+ proofStrService.remove(new LambdaQueryWrapper<ProofStr>().eq(ProofStr::getReportId, id));
|
|
|
+ //删除陈述意见方案表数据
|
|
|
+ argumentsScenarioService.remove(new LambdaQueryWrapper<ArgumentsScenarios>().eq(ArgumentsScenarios::getReportId, id));
|
|
|
+ //删除"SCRATCH"表数据
|
|
|
+ scratchService.remove(new LambdaQueryWrapper<Scratch>().eq(Scratch::getReportId, id));
|
|
|
|
|
|
Boolean dele = this.removeById(id);
|
|
|
if (dele == true) {
|
|
@@ -741,8 +833,8 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
reports.add(report);
|
|
|
try {
|
|
|
//调用this.reportData装载报告
|
|
|
- List<Report> reports1 = this.reportData(reports);
|
|
|
- Report report1 = reports1.get(0);
|
|
|
+// List<Report> reports1 = this.reportData(reports);
|
|
|
+ Report report1 = reports.get(0);
|
|
|
//若报告为无效应对报告则从无效应对报告表中获得无效对应报告拓展信息
|
|
|
if (report1.getType().equals(7)) {
|
|
|
LambdaQueryWrapper<InvalidReReport> queryWrapper = new LambdaQueryWrapper<>();
|
|
@@ -757,12 +849,119 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
} else {
|
|
|
BeanUtils.copyProperties(report1, reportDeVO);
|
|
|
}
|
|
|
- } catch (IOException e) {
|
|
|
+ reportDeVO.setId(report.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return reportDeVO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询租户报告使用报表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public List<ReportUsedByTenantVO> getReportUsedByTenant(List<Integer> tenantIds) throws IOException {
|
|
|
+ List<ReportUsedByTenantVO> reportUsedByTenantVOS = new ArrayList<>();
|
|
|
+ //调用权限系统接口获取租户下人员ids
|
|
|
+ String reData = this.getReportTenantVOFromPCS(tenantIds);
|
|
|
+ //字符串转对象集合
|
|
|
+ Gson gson = new Gson();
|
|
|
+ Type listType = new TypeToken<List<ReportTenantVO>>() {
|
|
|
+ }.getType();
|
|
|
+ List<ReportTenantVO> reportTenantVOS = gson.fromJson(reData, listType);
|
|
|
+ //遍历
|
|
|
+ for (ReportTenantVO rT : reportTenantVOS) {
|
|
|
+ //人员ids
|
|
|
+ List<Integer> personnelIds = rT.getPersonnelIds();
|
|
|
+ if (personnelIds.size() > 0) {
|
|
|
+ //查出所有人员ids名下的报告以及数量
|
|
|
+ LambdaQueryWrapper<Report> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(Report::getCreatePersonId, personnelIds);
|
|
|
+ //所有人员ids名下报告的数量
|
|
|
+ Long count = this.count(queryWrapper);
|
|
|
+ //查询出所有人员ids名下的报告集合
|
|
|
+ List<Report> reports = this.list(queryWrapper);
|
|
|
+ if (reports.size() > 0) {
|
|
|
+ for (Report report : reports) {
|
|
|
+ ReportUsedByTenantVO reportUsedByTenantVO = new ReportUsedByTenantVO();
|
|
|
+ //租户名
|
|
|
+ reportUsedByTenantVO.setTenantName(rT.getTenantName());
|
|
|
+ //报告名
|
|
|
+ reportUsedByTenantVO.setReportName(report.getName());
|
|
|
+ Integer reportNum = Long.valueOf(count).intValue();
|
|
|
+ //报告数量
|
|
|
+ reportUsedByTenantVO.setReportNum(reportNum);
|
|
|
+ reportUsedByTenantVOS.add(reportUsedByTenantVO);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ReportUsedByTenantVO reportUsedByTenantVO = new ReportUsedByTenantVO();
|
|
|
+ //租户名
|
|
|
+ reportUsedByTenantVO.setTenantName(rT.getTenantName());
|
|
|
+ //报告数量
|
|
|
+ reportUsedByTenantVO.setReportNum(0);
|
|
|
+ reportUsedByTenantVOS.add(reportUsedByTenantVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return reportUsedByTenantVOS;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 调用权限系统查询租户人员ids接口
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public String getReportTenantVOFromPCS(List<Integer> tenantIds) throws IOException {
|
|
|
+ String param = new Gson().toJson(tenantIds);
|
|
|
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
+ .connectTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .writeTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .build();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url("http://localhost:8871" + "/permission/api/exportExcel/getTenantPerson")
|
|
|
+ .post(requestBody)
|
|
|
+ .build();
|
|
|
+ return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 传入租户id,返回报告数量
|
|
|
+ *
|
|
|
+ * @param tenantId
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public Integer getReportNumOfTotal(Integer tenantId) throws IOException {
|
|
|
+ //字符串转对象!
|
|
|
+ List<Integer> tenantIds = new ArrayList<>();
|
|
|
+ tenantIds.add(tenantId);
|
|
|
+ String reData = this.getReportTenantVOFromPCS(tenantIds);
|
|
|
+ //字符串转对象集合
|
|
|
+ Gson gson = new Gson();
|
|
|
+ Type listType = new TypeToken<List<ReportTenantVO>>() {
|
|
|
+ }.getType();
|
|
|
+ List<ReportTenantVO> reportTenantVOS = gson.fromJson(reData, listType);
|
|
|
+ ReportTenantVO reportTenantVO = reportTenantVOS.get(0);
|
|
|
+ //人员ids
|
|
|
+ List<Integer> personnelIds = reportTenantVO.getPersonnelIds();
|
|
|
+ if (personnelIds.size() > 0) {
|
|
|
+ //查出所有人员ids名下的报告以及数量
|
|
|
+ LambdaQueryWrapper<Report> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(Report::getCreatePersonId, personnelIds);
|
|
|
+ //所有人员ids名下报告的数量
|
|
|
+ Long count = this.count(queryWrapper);
|
|
|
+ Integer reportNum = Long.valueOf(count).intValue();
|
|
|
+ return reportNum;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public List<Report> getReportsByReportIds(List<Integer> reportIds) {
|
|
|
List<Report> reports = this.list(new LambdaQueryWrapper<Report>().in(Report::getId, reportIds));
|
|
|
return reports;
|