|
@@ -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.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;
|
|
@@ -15,6 +16,7 @@ import cn.cslg.report.entity.*;
|
|
|
import cn.cslg.report.entity.asso.AssoReportFile;
|
|
|
import cn.cslg.report.entity.asso.AssoReportPerson;
|
|
|
import cn.cslg.report.mapper.ReportMapper;
|
|
|
+import cn.cslg.report.service.IAssoEventReportService;
|
|
|
import cn.cslg.report.service.IAvoidDesignDirectionService;
|
|
|
import cn.cslg.report.service.IProductService;
|
|
|
import cn.cslg.report.service.OutInterfaceService;
|
|
@@ -70,6 +72,8 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
private final CopyService copyService;
|
|
|
private final SystemDictItemService systemDictItemService;
|
|
|
private final AssoReportPersonService assoReportPersonService;
|
|
|
+ private final IAssoEventReportService assoEventReportService;
|
|
|
+
|
|
|
private Report loadReport(ReportDTO reportDto) {
|
|
|
Report report = new Report();
|
|
|
//装载基本信息
|
|
@@ -104,7 +108,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
report.setCronConclusion(reportDto.getCronConclusion());
|
|
|
//装载核心结论
|
|
|
if (reportDto.getConclusionIds() != null) {
|
|
|
- report.setConclusionId(StringUtils.join(reportDto.getConclusionIds(), "/"));
|
|
|
+ report.setScenarioId(StringUtils.join(reportDto.getConclusionIds(), ","));
|
|
|
}
|
|
|
//装载承担部门
|
|
|
report.setDepartmentId(reportDto.getDepartmentId());
|
|
@@ -125,7 +129,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
* @author 沈永艺
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Integer addReport(ReportDTO reportDto, List<MultipartFile> files) {
|
|
|
+ public Integer addReport(ReportDTO reportDto, List<MultipartFile> files) throws IOException {
|
|
|
//新增报告
|
|
|
Report report = this.loadReport(reportDto);
|
|
|
report.insert();
|
|
@@ -164,6 +168,30 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
} else {
|
|
|
reportFieldService.addDefaultField(report.getId(), report.getType());
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //新增事件(若有事件)
|
|
|
+ List<EventAddNewDTO> eventAddNewDTOs = reportDto.getEventAddNewDTOs();
|
|
|
+ if (eventAddNewDTOs != null && eventAddNewDTOs.size() > 0) {
|
|
|
+ List<Integer> eventIds = new ArrayList<>();
|
|
|
+ //过滤去除已有事件(已有事件无需新增,只做关联)
|
|
|
+ List<EventAddNewDTO> oldEventAddNewDTOs = eventAddNewDTOs.stream().filter(item -> item.getId() != null).collect(Collectors.toList());
|
|
|
+ eventAddNewDTOs.removeAll(oldEventAddNewDTOs);
|
|
|
+ if (eventAddNewDTOs.size() > 0) {
|
|
|
+ //调用分析系统新增事件接口
|
|
|
+ String res = outInterfaceService.getEventIdsFromPAS(eventAddNewDTOs);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<Integer> newEventIds = JSONObject.parseObject(jsonObject.get("data").toString(), ArrayList.class);
|
|
|
+ eventIds.addAll(newEventIds);
|
|
|
+ }
|
|
|
+ for (EventAddNewDTO oldEventAddNewDTO : oldEventAddNewDTOs) {
|
|
|
+ eventIds.add(oldEventAddNewDTO.getId());
|
|
|
+ }
|
|
|
+ //新增事件和报告关联
|
|
|
+ assoEventReportService.addNew(eventIds, report.getId());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return report.getId();
|
|
|
|
|
|
}
|
|
@@ -354,7 +382,6 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateReport(ReportDTO reportDto, List<MultipartFile> files) throws IOException {
|
|
|
Report report = this.loadReport(reportDto);
|
|
|
- report.setId(reportDto.getId());
|
|
|
// 根据报告Id查询对应的附件Id
|
|
|
LambdaQueryWrapper<AssoReportFile> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(AssoReportFile::getReportId, reportDto.getId());
|
|
@@ -461,181 +488,5 @@ 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();
|
|
|
-
|
|
|
- }
|
|
|
}
|