package com.gkhy.labRiskManage.application.riskReport.service.impl;
|
|
import com.gkhy.labRiskManage.api.controller.riskReport.dto.repDto.ReportInfoUpdateReqBO;
|
import com.gkhy.labRiskManage.api.controller.riskReport.dto.repDto.ReportQueryReqBO;
|
import com.gkhy.labRiskManage.api.controller.riskReport.dto.repDto.ReportReqBO;
|
import com.gkhy.labRiskManage.api.controller.riskReport.dto.repDto.ReportUpdateReqBO;
|
import com.gkhy.labRiskManage.api.controller.riskReport.dto.respDto.ReportQueryRespDTO;
|
import com.gkhy.labRiskManage.application.riskReport.dto.bo.*;
|
import com.gkhy.labRiskManage.application.riskReport.dto.dto.ReportAppQueryDTO;
|
import com.gkhy.labRiskManage.application.riskReport.dto.dto.RiskAssessPlanAppQueryDTO;
|
import com.gkhy.labRiskManage.application.riskReport.service.ReportAppService;
|
import com.gkhy.labRiskManage.commons.domain.SearchResult;
|
import com.gkhy.labRiskManage.commons.enums.ResultCode;
|
import com.gkhy.labRiskManage.commons.enums.StatusEnum;
|
import com.gkhy.labRiskManage.commons.exception.BusinessException;
|
import com.gkhy.labRiskManage.commons.utils.BeanCopyUtils;
|
import com.gkhy.labRiskManage.config.annotation.RepeatSubmit;
|
import com.gkhy.labRiskManage.domain.account.service.UserDomainService;
|
import com.gkhy.labRiskManage.domain.experiment.service.ExperimentInfoService;
|
import com.gkhy.labRiskManage.domain.riskReport.model.dto.*;
|
import com.gkhy.labRiskManage.domain.riskReport.service.ReportExperimentRiskSourceService;
|
import com.gkhy.labRiskManage.domain.riskReport.service.ReportExperimentRiskSourceTypeService;
|
import com.gkhy.labRiskManage.domain.riskReport.service.ReportRiskAssessInfoService;
|
import com.gkhy.labRiskManage.domain.riskReport.service.ReportRiskAssessPersonService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.util.ObjectUtils;
|
|
import java.util.List;
|
|
@Service
|
public class ReportAppServiceImpl implements ReportAppService {
|
|
@Autowired
|
private ReportRiskAssessInfoService reportInfoService;
|
@Autowired
|
private ReportRiskAssessPersonService reportPersonService;
|
@Autowired
|
private ReportExperimentRiskSourceTypeService reportSourceTypeService;
|
@Autowired
|
private ReportExperimentRiskSourceService reportSourceService;
|
@Autowired
|
private UserDomainService userDomainService;
|
@Autowired
|
private ExperimentInfoService experimentInfoService;
|
|
|
/**
|
* 风险评估报告 - 查询
|
*/
|
@Override
|
public SearchResult<ReportQueryRespDTO> selectRiskReportPage(Long currentUserId, ReportQueryReqBO queryReqBO) {
|
|
SearchResult searchResult = new SearchResult<>();
|
|
ReportAppQueryBO queryParam = BeanCopyUtils.copyBean(queryReqBO, ReportAppQueryBO.class);
|
|
SearchResult<ReportAppQueryDTO> queryResult = reportInfoService.selectRiskReportPage(currentUserId, queryParam);
|
|
searchResult.setPageIndex(queryResult.getPageIndex());
|
searchResult.setPageSize(queryResult.getPageSize());
|
searchResult.setTotal(queryResult.getTotal());
|
searchResult.setData(BeanCopyUtils.copyRiskAssessPlanAppQueryList(queryResult.getData(), RiskAssessPlanAppQueryDTO.class));
|
|
return searchResult;
|
}
|
|
/**
|
* 风险评估报告 - 生成报告信息
|
*/
|
@Override
|
public int insertRiskReport(Long currentUserId, Long id) {
|
|
ReportInsertDTO insertResult = reportInfoService.insertRiskReport(currentUserId, id);
|
|
if (ObjectUtils.isEmpty(insertResult)){
|
return StatusEnum.FAIL.getCode();
|
}
|
return StatusEnum.SUCCESS.getCode();
|
}
|
|
/**
|
* 风险评估报告 - 填写信息
|
*/
|
@Transactional
|
@Override
|
public int updateRiskReport(Long currentUserId, ReportUpdateReqBO updateReqBO) {
|
|
int i = 0;
|
//报告信息
|
ReportAppUpdateBO reportUpdateBO = BeanCopyUtils.copyBean(updateReqBO, ReportAppUpdateBO.class);
|
ReportUpdateDTO reportUpdateDTO = reportInfoService.updateReportInfoById(currentUserId,reportUpdateBO);
|
if (ObjectUtils.isEmpty(reportUpdateDTO)){
|
i = 1;
|
}
|
//
|
// //审核人信息
|
// if (!ObjectUtils.isEmpty(updateReqBO.getPerson())){
|
// List<ReportPersonAppInsertBO> personInsertBO = BeanCopyUtils.copyBeanList(updateReqBO.getPerson(), ReportPersonAppInsertBO.class);
|
// List<ReportPersonInsertDTO> reportPersonInsertDTOS = reportPersonService.insertReportPerson(currentUserId,personInsertBO);
|
// if (reportPersonInsertDTOS.size() != personInsertBO.size()){
|
// i = 1;
|
// }
|
// }
|
//
|
// //危险源类型信息
|
// if (!ObjectUtils.isEmpty(updateReqBO.getRiskSourceType())){
|
// List<ReportSourceTypeAppInsertBO> reportSourceTypeInsertBO = BeanCopyUtils.copyBeanList(updateReqBO.getRiskSourceType(), ReportSourceTypeAppInsertBO.class);
|
// List<ReportSourceTypeInsertDTO> reportSourceTypeInsertDTOS = reportSourceTypeService.insertReportSourceType(currentUserId,reportSourceTypeInsertBO);
|
// if (reportSourceTypeInsertDTOS.size() != reportSourceTypeInsertBO.size()){
|
// i = 1;
|
// }
|
// }
|
//
|
//危险源信
|
if (!ObjectUtils.isEmpty(updateReqBO.getRiskSource())){
|
List<ReportSourceAppInsertBO> riskSourceInsertBO = BeanCopyUtils.copyBeanList(updateReqBO.getRiskSource(), ReportSourceAppInsertBO.class);
|
List<ReportRiskSourceDTO> reportRiskSourceDTOS = reportSourceService.insertReportSource(currentUserId,riskSourceInsertBO);
|
if (reportRiskSourceDTOS.size() != riskSourceInsertBO.size()){
|
i = 1;
|
}
|
}
|
|
if (ObjectUtils.isEmpty(reportUpdateDTO)){
|
throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "风险评估报告写入失败");
|
}
|
return StatusEnum.SUCCESS.getCode();
|
}
|
|
/**
|
* 风险评估报告 - 修改报告信息
|
*/
|
@Transactional
|
@Override
|
public int updateReportInfo(Long currentUserId, ReportInfoUpdateReqBO updateReqBO) {
|
|
int i = 0;
|
//报告信息
|
ReportAppUpdateBO reportUpdateBO = BeanCopyUtils.copyBean(updateReqBO, ReportAppUpdateBO.class);
|
ReportUpdateDTO reportUpdateDTO = reportInfoService.updateReportInfoById(currentUserId,reportUpdateBO);
|
if (ObjectUtils.isEmpty(reportUpdateDTO)){
|
i = 1;
|
}
|
|
//审核人信息
|
// if (!ObjectUtils.isEmpty(updateReqBO.getPerson())){
|
// List<ReportPersonAppUpdateBO> personUpdateBO = BeanCopyUtils.copyBeanList(updateReqBO.getPerson(), ReportPersonAppUpdateBO.class);
|
// List<ReportPersonInsertDTO> reportPersonUpdateDTOS = reportPersonService.updateReportPerson(currentUserId, personUpdateBO);
|
// if (reportPersonUpdateDTOS.size() != personUpdateBO.size()){
|
// i = 1;
|
// }
|
// }
|
|
//危险源类型信息
|
// if (!ObjectUtils.isEmpty(updateReqBO.getRiskSourceType())){
|
// List<ReportSourceTypeAppUpdateBO> reportSourceTypeUpdateBO = BeanCopyUtils.copyBeanList(updateReqBO.getRiskSourceType(), ReportSourceTypeAppUpdateBO.class);
|
// List<ReportSourceTypeInsertDTO> reportSourceTypeUpdateDTOS = reportSourceTypeService.updateReportSourceType(currentUserId, reportSourceTypeUpdateBO);
|
// if (reportSourceTypeUpdateDTOS.size() != reportSourceTypeUpdateBO.size()){
|
// i = 1;
|
// }
|
// }
|
|
// if (!ObjectUtils.isEmpty(updateReqBO.getRiskSource())){
|
// //危险源信息
|
// List<ReportSourceAppUpdateBO> riskSourceUpdateBO = BeanCopyUtils.copyBeanList(updateReqBO.getRiskSource(), ReportSourceAppUpdateBO.class);
|
// List<ReportRiskSourceDTO> reportRiskSourceUpdateDTOS = reportSourceService.updateReportSource(currentUserId, riskSourceUpdateBO);
|
// if (reportRiskSourceUpdateDTOS.size() != riskSourceUpdateBO.size()){
|
// i = 1;
|
// }
|
// }
|
|
if (i == 1){
|
throw new BusinessException(this.getClass(), ResultCode.BUSINESS_ERROR.getCode(), "风险评估报告修改失败");
|
}
|
return StatusEnum.SUCCESS.getCode();
|
}
|
|
/**
|
* 风险评估报告 - 报告审核 - 旧 - 两层审核
|
*/
|
@Override
|
public int report(Long currentUserId, ReportReqBO reportReqBO) {
|
|
int report = reportInfoService.report(currentUserId, reportReqBO);
|
|
if (report == 0){
|
return StatusEnum.FAIL.getCode();
|
}
|
return StatusEnum.SUCCESS.getCode();
|
}
|
|
/**
|
* 风险评估报告 - 报告审核 - 新 - 单次审核
|
*/
|
@Override
|
public int reportNew(Long currentUserId, ReportReqBO reportReqBO) {
|
|
int report = reportInfoService.reportNew(currentUserId, reportReqBO);
|
|
if (report == 0){
|
return StatusEnum.FAIL.getCode();
|
}
|
return StatusEnum.SUCCESS.getCode();
|
}
|
}
|