|
@@ -1,6 +1,7 @@
|
|
|
package cn.cslg.report.service.business;
|
|
|
|
|
|
import cn.cslg.report.common.core.base.Constants;
|
|
|
+import cn.cslg.report.common.model.dto.ReportDTO;
|
|
|
import cn.cslg.report.common.model.vo.ClientVO;
|
|
|
import cn.cslg.report.common.model.vo.PersonnelVO;
|
|
|
import cn.cslg.report.common.model.vo.ReportVO;
|
|
@@ -9,10 +10,8 @@ import cn.cslg.report.common.utils.*;
|
|
|
import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
|
import cn.cslg.report.common.utils.SecurityUtils.SecurityUtils;
|
|
|
import cn.cslg.report.common.utils.auth.checkAuth;
|
|
|
-import cn.cslg.report.entity.Personnel;
|
|
|
-import cn.cslg.report.entity.Report;
|
|
|
+import cn.cslg.report.entity.*;
|
|
|
|
|
|
-import cn.cslg.report.entity.ReportFiles;
|
|
|
import cn.cslg.report.entity.asso.AssoReportFile;
|
|
|
import cn.cslg.report.mapper.ReportMapper;
|
|
|
import cn.cslg.report.service.IAvoidDesignDirectionService;
|
|
@@ -38,10 +37,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -68,51 +64,106 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
private final InvalidRecordService invalidRecordService;
|
|
|
private final ReportDocumentService reportDocumentService;
|
|
|
private final ReportReferencesService reportReferencesService;
|
|
|
+ private final CopyService copyService;
|
|
|
+
|
|
|
+ private Report loadReport(ReportDTO reportDto) {
|
|
|
+ Report report = new Report();
|
|
|
+ //装载基本信息
|
|
|
+ //标的专利号
|
|
|
+ report.setSignPatentNo(reportDto.getSignPatentNo());
|
|
|
+ //名称
|
|
|
+ report.setName(reportDto.getName());
|
|
|
+ //产品/技术
|
|
|
+ report.setProTec(reportDto.getProTec());
|
|
|
+ if (reportDto.getCreatePersonId() == null) {
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ //创建人
|
|
|
+ report.setCreatePersonId(personnelVO.getId());
|
|
|
+ } else {
|
|
|
+ report.setCreatePersonId(reportDto.getCreatePersonId());
|
|
|
+ }
|
|
|
+ //类型
|
|
|
+ report.setType(reportDto.getType());
|
|
|
+ //装载状态
|
|
|
+ if (reportDto.getType().equals(4) || reportDto.getType().equals(5)) {
|
|
|
+ report.setStatus(2);
|
|
|
+ } else {
|
|
|
+ report.setStatus(reportDto.getStatus());
|
|
|
+ }
|
|
|
+ // 装载客户
|
|
|
+ report.setClientId(reportDto.getClientId());
|
|
|
+ //装载应用场景
|
|
|
+ if (reportDto.getScenarioList() != null) {
|
|
|
+ report.setScenarioId(StringUtils.join(report.getScenarioList(), ","));
|
|
|
+ }
|
|
|
+ //装载核心论述
|
|
|
+ report.setCronConclusion(reportDto.getCronConclusion());
|
|
|
+ //装载核心结论
|
|
|
+ if (reportDto.getConclusionIds() != null) {
|
|
|
+ report.setScenarioId(StringUtils.join(reportDto.getConclusionIds(), ","));
|
|
|
+ }
|
|
|
+ //装载承担部门
|
|
|
+ report.setDepartmentId(reportDto.getDepartmentId());
|
|
|
+ //装载专题库
|
|
|
+ report.setProjectId(reportDto.getProjectId());
|
|
|
+ //调查类型
|
|
|
+ report.setItFlag(reportDto.getItFlag());
|
|
|
+ //卷号
|
|
|
+ report.setVolumeNumber(reportDto.getVolumeNumber());
|
|
|
+ //备注
|
|
|
+ report.setRemark(reportDto.getRemark());
|
|
|
+ return report;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @param report 报告类
|
|
|
* @author 沈永艺
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Integer addReport(Report report, List<MultipartFile> files) {
|
|
|
- report.getScenarioList();
|
|
|
- report.setScenarioId(StringUtils.join(report.getScenarioList(), ","));
|
|
|
- if (report.getAssociateReportId() != null) {
|
|
|
- LambdaQueryWrapper<Report> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(Report::getId, report.getAssociateReportId());
|
|
|
- Report assioReport = this.list(wrapper).get(0);
|
|
|
- report.setAssociateReportName(assioReport.getName());
|
|
|
- }
|
|
|
- PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
- report.setCreatePersonId(personnelVO.getId());
|
|
|
- //如果报告类型是4(侵权分析报告)或 5(规避设计报告)则将状态设为2(处理中)
|
|
|
- if (!report.getStatus().equals(0) &&!report.getStatus().equals(2)&& (report.getType().equals(4) || report.getType().equals(5))) {
|
|
|
- report.setStatus(2);
|
|
|
- }
|
|
|
- else if(report.getStatus().equals(1))
|
|
|
- { report.getConclusionIds();
|
|
|
- report.setConclusionId(StringUtils.join(report.getConclusionIds(), ","));
|
|
|
- report.setStatus(1);
|
|
|
- }
|
|
|
-
|
|
|
- boolean addFlag = this.save(report);
|
|
|
-
|
|
|
- if (files != null && files.size() != 0) {
|
|
|
- //将文档上传并返回文件入库的Id
|
|
|
- List<Integer> fileIds = reportFileService.uploadFiles(files);
|
|
|
- assoReportFileService.addAsso(report.getId(), fileIds);
|
|
|
+ public Integer addReport(ReportDTO reportDto, List<MultipartFile> files) {
|
|
|
+ //新增报告
|
|
|
+ Report report = this.loadReport(reportDto);
|
|
|
+ report.insert();
|
|
|
+ //添加事件
|
|
|
+ // 添加后续事项
|
|
|
+ if (files != null && files.size() != 0) {
|
|
|
+ //将文档上传并返回文件入库的Id
|
|
|
+ List<Integer> fileIds = reportFileService.uploadFiles(files);
|
|
|
+ assoReportFileService.addAsso(report.getId(), fileIds);
|
|
|
+ }
|
|
|
+ //当报告是已完成时
|
|
|
+ if (report.getStatus() != null && report.getStatus().equals(3)) {
|
|
|
+ //复制父报告自定义栏位
|
|
|
+ LambdaQueryWrapper<ReportField> fieldWrapper = new LambdaQueryWrapper<>();
|
|
|
+ fieldWrapper.eq(ReportField::getReportId, reportDto.getAssociateReportId());
|
|
|
+ List<ReportField> fields = reportFieldService.list(fieldWrapper);
|
|
|
+ List<ReportField> oldFields =new ArrayList<>(fields);
|
|
|
+ if (fields.size() != 0) {
|
|
|
+ for (ReportField reportField : fields) {
|
|
|
+ reportField.setId(null);
|
|
|
+ reportField.setReportId(report.getId());
|
|
|
+ }
|
|
|
+ reportFieldService.saveBatch(fields);
|
|
|
}
|
|
|
- //如果报告生成成功,给报告添加默认自定义字段
|
|
|
- if (addFlag) {
|
|
|
- reportFieldService.addDefaultField(report.getId(), report.getType());
|
|
|
- return report.getId();
|
|
|
- } else {
|
|
|
- return 0;
|
|
|
+ //复制
|
|
|
+ if (reportDto.getCopyIds() != null) {
|
|
|
+ //复制对比文件
|
|
|
+ if (reportDto.getCopyIds().contains(Arrays.asList())) {
|
|
|
+ copyService.CopyComparePatents(reportDto.getAssociateReportId(), report.getId());
|
|
|
+ }
|
|
|
+ //复制标引信息
|
|
|
+ if (reportDto.getCopyIds().contains(Arrays.asList())) {
|
|
|
+ copyService.CopyPatentLabels(oldFields,fields);
|
|
|
+ }
|
|
|
}
|
|
|
+ } else {
|
|
|
+ reportFieldService.addDefaultField(report.getId(), report.getType());
|
|
|
+ }
|
|
|
+ return report.getId();
|
|
|
|
|
|
}
|
|
|
|
|
|
- // @Transactional(rollbackFor = Exception.class)
|
|
|
//查询报告
|
|
|
public String queryReport(ReportVO reportVO) throws IOException {
|
|
|
Integer id = loginUtils.getId();
|
|
@@ -128,6 +179,24 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
if (reportVO.getSignPatentNo() != null && reportVO.getSignPatentNo() != "") {
|
|
|
queryWrapper.like(Report::getSignPatentNo, reportVO.getSignPatentNo());
|
|
|
}
|
|
|
+ if (reportVO.getType() != null && reportVO.getType() != "") {
|
|
|
+ queryWrapper.eq(Report::getType, reportVO.getType());
|
|
|
+ }
|
|
|
+ if(reportVO.getCronIds()!=null&&reportVO.getCronIds().size()>0){
|
|
|
+ StringBuilder strs =new StringBuilder();
|
|
|
+ for (int i=0;i<reportVO.getCronIds().size();i++){
|
|
|
+ Integer item =reportVO.getCronIds().get(i);
|
|
|
+ if(i==0){
|
|
|
+ strs.append("(FIND_IN_SET("+item+",REPLACE(CONCLUSION_ID, '/', ','))");}
|
|
|
+ else {
|
|
|
+ strs.append("or FIND_IN_SET("+item+",REPLACE(CONCLUSION_ID, '/', ','))");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ strs.append(")");
|
|
|
+ queryWrapper.apply(strs.toString());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
queryWrapper.orderByDesc(Report::getCreateTime);
|
|
|
//分页
|
|
|
if (reportVO.getSize() != null && reportVO.getCurrent() != null) {
|
|
@@ -203,10 +272,12 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
if (mapCre.size() != 0)
|
|
|
item.setCreatePersonName(mapCre.get(0).getPersonnelName());
|
|
|
//装载部门名
|
|
|
- List<Map<String, Object>> mapDeaprt = mapDeparts.stream().filter(tem -> tem.get("departId").toString().equals(item.getDepartmentId().toString())).collect(Collectors.toList());
|
|
|
- if (mapDeaprt.size() != 0) {
|
|
|
- item.setDepartmentName(mapDeaprt.get(0).get("departName").toString());
|
|
|
- }
|
|
|
+ if(item.getDepartmentId()!=null) {
|
|
|
+ List<Map<String, Object>> mapDeaprt = mapDeparts.stream().filter(tem -> tem.get("departId").toString().equals(item.getDepartmentId().toString())).collect(Collectors.toList());
|
|
|
+ if (mapDeaprt.size() != 0) {
|
|
|
+ item.setDepartmentName(mapDeaprt.get(0).get("departName").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
if (item.getClientId() == null) {
|
|
|
item.setClientId(0);
|
|
|
}
|
|
@@ -242,16 +313,17 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
* @function 修改报告
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean updateReport(Report report, List<MultipartFile> files) throws IOException {
|
|
|
+ public Boolean updateReport(ReportDTO reportDto, List<MultipartFile> files) throws IOException {
|
|
|
+ Report report = this.loadReport(reportDto);
|
|
|
// 根据报告Id查询对应的附件Id
|
|
|
LambdaQueryWrapper<AssoReportFile> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(AssoReportFile::getReportId, report.getId());
|
|
|
+ wrapper.eq(AssoReportFile::getReportId, reportDto.getId());
|
|
|
List<AssoReportFile> assoReportFiles = assoReportFileService.list(wrapper);
|
|
|
List<Integer> fileIds = assoReportFiles.stream().map(AssoReportFile::getFileId).collect(Collectors.toList());
|
|
|
// 获得报告更新后的附件Id
|
|
|
List<Integer> updateFileId = new ArrayList<>();
|
|
|
- if (report.getReportFiles() != null) {
|
|
|
- updateFileId = report.getReportFiles().stream().map(ReportFiles::getId).collect(Collectors.toList());
|
|
|
+ if (reportDto.getReportFiles() != null) {
|
|
|
+ updateFileId = reportDto.getReportFiles().stream().map(ReportFiles::getId).collect(Collectors.toList());
|
|
|
fileIds.removeAll(updateFileId);
|
|
|
}
|
|
|
//做差获得被删除的文件Id
|
|
@@ -267,7 +339,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
if (files != null && files.size() != 0) {
|
|
|
//将文档上传并返回文件入库的Id
|
|
|
List<Integer> fileIdList = reportFileService.uploadFiles(files);
|
|
|
- assoReportFileService.addAsso(report.getId(), fileIdList);
|
|
|
+ assoReportFileService.addAsso(reportDto.getId(), fileIdList);
|
|
|
}
|
|
|
return report.updateById();
|
|
|
|