|
@@ -1,12 +1,10 @@
|
|
|
package cn.cslg.report.service.business;
|
|
|
|
|
|
import cn.cslg.report.common.core.base.Constants;
|
|
|
+import cn.cslg.report.common.model.dto.ConclusionDTO;
|
|
|
import cn.cslg.report.common.model.dto.EventAddNewDTO;
|
|
|
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.SecurityUtils.LoginUtils;
|
|
|
import cn.cslg.report.common.utils.SecurityUtils.SecurityUtils;
|
|
@@ -488,5 +486,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();
|
|
|
+
|
|
|
+ }
|
|
|
}
|