|
@@ -1,11 +1,9 @@
|
|
package cn.cslg.report.service.business;
|
|
package cn.cslg.report.service.business;
|
|
|
|
|
|
import cn.cslg.report.common.core.base.Constants;
|
|
import cn.cslg.report.common.core.base.Constants;
|
|
|
|
+import cn.cslg.report.common.model.dto.ConclusionDTO;
|
|
import cn.cslg.report.common.model.dto.ReportDTO;
|
|
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;
|
|
|
|
-import cn.cslg.report.common.model.vo.SystemDictVO;
|
|
|
|
|
|
+import cn.cslg.report.common.model.vo.*;
|
|
import cn.cslg.report.common.utils.*;
|
|
import cn.cslg.report.common.utils.*;
|
|
import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
import cn.cslg.report.common.utils.SecurityUtils.SecurityUtils;
|
|
import cn.cslg.report.common.utils.SecurityUtils.SecurityUtils;
|
|
@@ -24,6 +22,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
@@ -37,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import java.awt.geom.IllegalPathStateException;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -70,6 +70,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
private final CopyService copyService;
|
|
private final CopyService copyService;
|
|
private final SystemDictItemService systemDictItemService;
|
|
private final SystemDictItemService systemDictItemService;
|
|
private final AssoReportPersonService assoReportPersonService;
|
|
private final AssoReportPersonService assoReportPersonService;
|
|
|
|
+
|
|
private Report loadReport(ReportDTO reportDto) {
|
|
private Report loadReport(ReportDTO reportDto) {
|
|
Report report = new Report();
|
|
Report report = new Report();
|
|
//装载基本信息
|
|
//装载基本信息
|
|
@@ -104,7 +105,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
report.setCronConclusion(reportDto.getCronConclusion());
|
|
report.setCronConclusion(reportDto.getCronConclusion());
|
|
//装载核心结论
|
|
//装载核心结论
|
|
if (reportDto.getConclusionIds() != null) {
|
|
if (reportDto.getConclusionIds() != null) {
|
|
- report.setScenarioId(StringUtils.join(reportDto.getConclusionIds(), ","));
|
|
|
|
|
|
+ report.setConclusionId(StringUtils.join(reportDto.getConclusionIds(), "/"));
|
|
}
|
|
}
|
|
//装载承担部门
|
|
//装载承担部门
|
|
report.setDepartmentId(reportDto.getDepartmentId());
|
|
report.setDepartmentId(reportDto.getDepartmentId());
|
|
@@ -205,7 +206,8 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
//分页
|
|
//分页
|
|
if (reportVO.getSize() != null && reportVO.getCurrent() != null) {
|
|
if (reportVO.getSize() != null && reportVO.getCurrent() != null) {
|
|
SecurityUtils.startDataScope("/pcs/report/query");
|
|
SecurityUtils.startDataScope("/pcs/report/query");
|
|
- List<Report> reports = this.page(new Page<>(reportVO.getCurrent(), reportVO.getSize()), queryWrapper).getRecords();
|
|
|
|
|
|
+ IPage<Report> records = this.page(new Page<>(reportVO.getCurrent(), reportVO.getSize()), queryWrapper);
|
|
|
|
+ List<Report> reports = records.getRecords();
|
|
reports = this.reportData(reports);
|
|
reports = this.reportData(reports);
|
|
SecurityUtils.startDataScope("/pcs/report/query");
|
|
SecurityUtils.startDataScope("/pcs/report/query");
|
|
Long count = this.count(queryWrapper);
|
|
Long count = this.count(queryWrapper);
|
|
@@ -228,12 +230,12 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
*/
|
|
*/
|
|
public List<Report> reportData(List<Report> reports) throws IOException {
|
|
public List<Report> reportData(List<Report> reports) throws IOException {
|
|
PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
- //根据登录人id获得登录人被分享的报告id
|
|
|
|
- LambdaQueryWrapper<AssoReportPerson> wrapper =new LambdaQueryWrapper<>();
|
|
|
|
|
|
+ //根据登录人id获得登录人被分享的报告id
|
|
|
|
+ LambdaQueryWrapper<AssoReportPerson> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.select(AssoReportPerson::getReportId);
|
|
wrapper.select(AssoReportPerson::getReportId);
|
|
- wrapper.eq(AssoReportPerson::getPersonId,personnelVO.getId());
|
|
|
|
- Function<Object,Integer> f = (o -> Integer.parseInt(o.toString())) ;
|
|
|
|
- List<Integer> shareIds =assoReportPersonService.listObjs(wrapper,f);
|
|
|
|
|
|
+ wrapper.eq(AssoReportPerson::getPersonId, personnelVO.getId());
|
|
|
|
+ Function<Object, Integer> f = (o -> Integer.parseInt(o.toString()));
|
|
|
|
+ List<Integer> shareIds = assoReportPersonService.listObjs(wrapper, f);
|
|
|
|
|
|
//提出报告Id
|
|
//提出报告Id
|
|
List<Integer> reportIds = reports.stream().map(Report::getId).collect(Collectors.toList());
|
|
List<Integer> reportIds = reports.stream().map(Report::getId).collect(Collectors.toList());
|
|
@@ -279,14 +281,14 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
//过滤报告
|
|
//过滤报告
|
|
for (Report item : reports) {
|
|
for (Report item : reports) {
|
|
//装载登录人在报告中的角色
|
|
//装载登录人在报告中的角色
|
|
- List<Integer> roles =new ArrayList<>();
|
|
|
|
- if(item.getCreatePersonId().equals(personnelVO.getId())){
|
|
|
|
|
|
+ List<Integer> roles = new ArrayList<>();
|
|
|
|
+ if (item.getCreatePersonId().equals(personnelVO.getId())) {
|
|
roles.add(0);
|
|
roles.add(0);
|
|
}
|
|
}
|
|
- if(item.getPersonId()!=null&&item.getPersonId().equals(personnelVO.getId())){
|
|
|
|
|
|
+ if (item.getPersonId() != null && item.getPersonId().equals(personnelVO.getId())) {
|
|
roles.add(1);
|
|
roles.add(1);
|
|
}
|
|
}
|
|
- if(shareIds.contains(item.getId())){
|
|
|
|
|
|
+ if (shareIds.contains(item.getId())) {
|
|
roles.add(2);
|
|
roles.add(2);
|
|
}
|
|
}
|
|
item.setLoginRole(roles);
|
|
item.setLoginRole(roles);
|
|
@@ -354,6 +356,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public Boolean updateReport(ReportDTO reportDto, List<MultipartFile> files) throws IOException {
|
|
public Boolean updateReport(ReportDTO reportDto, List<MultipartFile> files) throws IOException {
|
|
Report report = this.loadReport(reportDto);
|
|
Report report = this.loadReport(reportDto);
|
|
|
|
+ report.setId(reportDto.getId());
|
|
// 根据报告Id查询对应的附件Id
|
|
// 根据报告Id查询对应的附件Id
|
|
LambdaQueryWrapper<AssoReportFile> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<AssoReportFile> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.eq(AssoReportFile::getReportId, reportDto.getId());
|
|
wrapper.eq(AssoReportFile::getReportId, reportDto.getId());
|
|
@@ -460,5 +463,181 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ public List<VisualReportVO> reportVisual(ReportVO reportVO) throws IOException {
|
|
|
|
+ Integer id = loginUtils.getId();
|
|
|
|
+ LambdaQueryWrapper<Report> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.ne(Report::getId, 0);
|
|
|
|
+ if (reportVO.getName() != null) {
|
|
|
|
+ queryWrapper.like(Report::getName, reportVO.getName());
|
|
|
|
+ }
|
|
|
|
+ if (reportVO.getReportId() != null) {
|
|
|
|
+ queryWrapper.eq(Report::getId, reportVO.getReportId());
|
|
|
|
+ }
|
|
|
|
+ if (reportVO.getSignPatentNo() != null && reportVO.getSignPatentNo() != "") {
|
|
|
|
+ queryWrapper.like(Report::getSignPatentNo, reportVO.getSignPatentNo());
|
|
|
|
+ }
|
|
|
|
+ if (reportVO.getTypes() != null && reportVO.getTypes().size() > 0) {
|
|
|
|
+ queryWrapper.in(Report::getType, reportVO.getTypes());
|
|
|
|
+ }
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ SecurityUtils.startDataScope("/pcs/report/query");
|
|
|
|
+ List<Report> reports = this.list(queryWrapper);
|
|
|
|
+ List<Map<String, Object>> map = new ArrayList<>();
|
|
|
|
+ List<VisualReportVO> reportVOS = this.loadVisualReport();
|
|
|
|
+ for (Report report : reports) {
|
|
|
|
+ VisualReportVO reportDTO = reportVOS.stream().filter(item -> item.getTypeValue().equals(report.getType() + "")).findFirst().orElse(null);
|
|
|
|
+ if (reportDTO != null) {
|
|
|
|
+ reportDTO.setReportNum(reportDTO.getReportNum() + 1);
|
|
|
|
+ //获得核心结论值
|
|
|
|
+ if (report.getConclusionId() == null) {
|
|
|
|
+ report.setConclusionId("");
|
|
|
|
+ }
|
|
|
|
+ List<String> ids = StringUtils.changeStringToString(report.getConclusionId(), "/");
|
|
|
|
+ List<VisualReportVO.Conclusions> conclusions = reportDTO.getConclusions().stream().filter(item -> ids.contains(item.getValue())).collect(Collectors.toList());
|
|
|
|
+ conclusions.forEach(item -> {
|
|
|
|
+ item.setNum(item.getNum() + 1);
|
|
|
|
+ });
|
|
|
|
+ //获得未完成的结论
|
|
|
|
+ VisualReportVO.Conclusions noComplate = reportDTO.getConclusions().stream().filter(item -> item.getValue().equals("-1")).findFirst().orElse(null);
|
|
|
|
+ if (noComplate != null) {
|
|
|
|
+ List<Integer> status = new ArrayList<>(Arrays.asList(0, 1, 2));
|
|
|
|
+ if (status.contains(report.getStatus())) {
|
|
|
|
+ noComplate.setNum(noComplate.getNum() + 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return reportVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<VisualReportVO> loadVisualReport() {
|
|
|
|
+ List<VisualReportVO> reportVOS = new ArrayList<>();
|
|
|
|
+ //获得所有报告的分类
|
|
|
|
+ LambdaQueryWrapper<SysDictItem> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(SysDictItem::getDictParentKey, "REPORT_TYPE");
|
|
|
|
+ List<SysDictItem> reportTypes = systemDictItemService.list(wrapper);
|
|
|
|
+ //获得所有报告的核心结论
|
|
|
|
+ List<Integer> ids = reportTypes.stream().map(SysDictItem::getId).collect(Collectors.toList());
|
|
|
|
+ List<SysDictItem> conclusions = new ArrayList<>();
|
|
|
|
+ if (ids.size() != 0) {
|
|
|
|
+ LambdaQueryWrapper<SysDictItem> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper1.in(SysDictItem::getParentId, ids)
|
|
|
|
+ .eq(SysDictItem::getGroupId, 1);
|
|
|
|
+ conclusions = systemDictItemService.list(wrapper1);
|
|
|
|
+ }
|
|
|
|
+ for (SysDictItem item : reportTypes) {
|
|
|
|
+ VisualReportVO reportVO = new VisualReportVO();
|
|
|
|
+ reportVO.setReportType(item.getDictChildLabel());
|
|
|
|
+ reportVO.setTypeValue(item.getDictChildValue());
|
|
|
|
+ reportVO.setReportNum(0);
|
|
|
|
+ //获得不同报告类别的核心结论字典
|
|
|
|
+ List<SysDictItem> sysDictItems = conclusions.stream().filter(tem -> tem.getParentId().equals(item.getId() + "")).collect(Collectors.toList());
|
|
|
|
+ List<VisualReportVO.Conclusions> conclusions1 = new ArrayList<>();
|
|
|
|
+ VisualReportVO.Conclusions noComplate = new VisualReportVO.Conclusions();
|
|
|
|
+ noComplate.setName("未完成");
|
|
|
|
+ noComplate.setValue("-1");
|
|
|
|
+ noComplate.setNum(0);
|
|
|
|
+ conclusions1.add(noComplate);
|
|
|
|
+ sysDictItems.forEach(
|
|
|
|
+ tem -> {
|
|
|
|
+ VisualReportVO.Conclusions conclusion = new VisualReportVO.Conclusions();
|
|
|
|
+ conclusion.setName(tem.getDictChildLabel());
|
|
|
|
+ conclusion.setValue(tem.getDictChildValue());
|
|
|
|
+ conclusion.setNum(0);
|
|
|
|
+ conclusions1.add(conclusion);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ reportVO.setConclusions(conclusions1);
|
|
|
|
+ reportVOS.add(reportVO);
|
|
|
|
+ }
|
|
|
|
+ return reportVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public Map<Integer, List<Integer>> getPermession() {
|
|
|
|
+ Map<Integer, List<Integer>> map = new HashMap<>();
|
|
|
|
+ Integer id = loginUtils.getId();
|
|
|
|
+ //查询登录人创建的报告
|
|
|
|
+ LambdaQueryWrapper<Report> createWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ createWrapper.select(Report::getId);
|
|
|
|
+ createWrapper.eq(Report::getCreatePersonId, id);
|
|
|
|
+ List<Report> creates = this.list(createWrapper);
|
|
|
|
+ creates.forEach(
|
|
|
|
+ item -> {
|
|
|
|
+ if (map.get(item.getId()) == null) {
|
|
|
|
+ List<Integer> roles = new ArrayList<>(0);
|
|
|
|
+ map.put(item.getId(), roles);
|
|
|
|
+ } else {
|
|
|
|
+ List<Integer> roles = map.get(item.getId());
|
|
|
|
+ if (!roles.contains(0)) {
|
|
|
|
+ roles.add(0);
|
|
|
|
+ map.put(item.getId(), roles);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ //查询登录人负责的报告
|
|
|
|
+ LambdaQueryWrapper<Report> dutyWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ dutyWrapper.select(Report::getId);
|
|
|
|
+ dutyWrapper.eq(Report::getPersonId, id);
|
|
|
|
+ List<Report> dutys = this.list(dutyWrapper);
|
|
|
|
+ dutys.forEach(
|
|
|
|
+ item -> {
|
|
|
|
+ if (map.get(item.getId()) == null) {
|
|
|
|
+ List<Integer> roles = new ArrayList<>(1);
|
|
|
|
+ map.put(item.getId(), roles);
|
|
|
|
+ } else {
|
|
|
|
+ List<Integer> roles = map.get(item.getId());
|
|
|
|
+ if (!roles.contains(1)) {
|
|
|
|
+ roles.add(1);
|
|
|
|
+ map.put(item.getId(), roles);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ //查询登录人被分享的报告
|
|
|
|
+ LambdaQueryWrapper<AssoReportPerson> shareWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ shareWrapper.select(AssoReportPerson::getReportId);
|
|
|
|
+ shareWrapper.eq(AssoReportPerson::getPersonId, id);
|
|
|
|
+ List<AssoReportPerson> shares = assoReportPersonService.list(shareWrapper);
|
|
|
|
+ shares.forEach(
|
|
|
|
+ item -> {
|
|
|
|
+ if (map.get(item.getReportId()) == null) {
|
|
|
|
+ List<Integer> roles = new ArrayList<>(2);
|
|
|
|
+ map.put(item.getId(), roles);
|
|
|
|
+ } else {
|
|
|
|
+ List<Integer> roles = map.get(item.getReportId());
|
|
|
|
+ if (!roles.contains(2)) {
|
|
|
|
+ roles.add(2);
|
|
|
|
+ map.put(item.getId(), roles);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Boolean addConclusions(ConclusionDTO conclusionDTO) {
|
|
|
|
+ Report report = this.getById(conclusionDTO.getReportId());
|
|
|
|
+ report.setCronConclusion(conclusionDTO.getCronConclusion());
|
|
|
|
+ if (report.getConclusionIds() != null) {
|
|
|
|
+ report.setConclusionId(StringUtils.join(conclusionDTO.getConclusionIds(), ","));
|
|
|
|
+ }
|
|
|
|
+ return report.updateById();
|
|
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|