package com.gkhy.labRiskManage.domain.riskReport.service.impl;
|
|
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.domain.account.service.UserDomainService;
|
import com.gkhy.labRiskManage.domain.riskReport.entity.RiskAssessPlanIdentificationJha;
|
import com.gkhy.labRiskManage.domain.riskReport.entity.RiskAssessPlanIdentificationScl;
|
import com.gkhy.labRiskManage.domain.riskReport.model.dto.IdentificationMethodDeleteDTO;
|
import com.gkhy.labRiskManage.domain.riskReport.model.dto.SclInsertDTO;
|
import com.gkhy.labRiskManage.domain.riskReport.model.dto.SclQueryDTO;
|
import com.gkhy.labRiskManage.domain.riskReport.repository.jpa.RiskAssessPlanIdentificationSclRepository;
|
import com.gkhy.labRiskManage.domain.riskReport.service.RiskAssessPlanIdentificationSclService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.jdbc.datasource.lookup.BeanFactoryDataSourceLookup;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.ObjectUtils;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
/**
|
* 辨识方法-Scl
|
*/
|
@Service
|
public class RiskAssessPlanIdentificationSclServiceImpl implements RiskAssessPlanIdentificationSclService {
|
|
@Autowired
|
private RiskAssessPlanIdentificationSclRepository sclRepository;
|
@Autowired
|
private UserDomainService userDomainService;
|
|
/**
|
* 辨识方法-Scl - 插入
|
*/
|
@Override
|
public SclInsertDTO insertScl(Long currentUserId, RiskAssessPlanIdentificationScl scl) {
|
|
if (ObjectUtils.isEmpty(scl.getAssessPlanId())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识的计划不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getSclCheckItem())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "SCL_检查项目不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getSclCheckStandard())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "SCL_检查标准不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getSclCheckUnstandard())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "SCL_不符合标准情况不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getSclCheckResult())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "SCL_主要后果不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getResult())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识结果不能为空");
|
}
|
if (scl.getResult() == 1){
|
if (ObjectUtils.isEmpty(scl.getIdentificationDesc())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识专家意见不能为空");
|
}
|
}
|
scl.setDeleteStatus(StatusEnum.DELETE_NOT.getCode().byteValue());
|
LocalDateTime data = LocalDateTime.now();
|
scl.setCreateTime(data);
|
scl.setUpdateTime(data);
|
scl.setId(null); //参数拷贝多了,重设id为空
|
|
RiskAssessPlanIdentificationScl insertResult = sclRepository.save(scl);
|
return BeanCopyUtils.copyBean(insertResult, SclInsertDTO.class);
|
|
}
|
|
/**
|
* 辨识方法-Scl - 修改
|
*/
|
@Override
|
public SclInsertDTO updateScl(Long currentUserId, RiskAssessPlanIdentificationScl scl) {
|
|
if (ObjectUtils.isEmpty(scl.getId())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识的计划不能为空");
|
}
|
RiskAssessPlanIdentificationScl sclById = sclRepository.getSclById(scl.getId());
|
if (ObjectUtils.isEmpty(sclById)){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "要修改的辨识项不存在");
|
}
|
if (ObjectUtils.isEmpty(scl.getAssessPlanId())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识的计划不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getSclCheckItem())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "SCL_检查项目不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getSclCheckStandard())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "SCL_检查标准不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getSclCheckUnstandard())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "SCL_不符合标准情况不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getSclCheckResult())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "SCL_主要后果不能为空");
|
}
|
if (ObjectUtils.isEmpty(scl.getResult())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识结果不能为空");
|
}
|
if (scl.getResult() == 1){
|
if (ObjectUtils.isEmpty(scl.getIdentificationDesc())){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "辨识专家意见不能为空");
|
}
|
}
|
LocalDateTime data = LocalDateTime.now();
|
|
sclById.setUpdateTime(data);
|
sclById.setSclCheckItem(scl.getSclCheckItem());
|
sclById.setSclCheckResult(scl.getSclCheckResult());
|
sclById.setSclCheckStandard(scl.getSclCheckStandard());
|
sclById.setSclCheckUnstandard(scl.getSclCheckUnstandard());
|
sclById.setFileData(scl.getFileData());
|
// sclById.setEducationMeasure(scl.getEducationMeasure());
|
// sclById.setManageMeasure(scl.getManageMeasure());
|
// sclById.setEmergencyMeasure(scl.getEmergencyMeasure());
|
// sclById.setTechnologyMeasure(scl.getTechnologyMeasure());
|
// sclById.setPersonalProtectionMeasure(scl.getPersonalProtectionMeasure());
|
sclById.setResult(scl.getResult());
|
sclById.setIdentificationDesc(scl.getIdentificationDesc());
|
|
RiskAssessPlanIdentificationScl updateResult = sclRepository.save(sclById);
|
|
return BeanCopyUtils.copyBean(updateResult, SclInsertDTO.class);
|
}
|
|
/**
|
* 辨识方法-Scl - 查询
|
*/
|
@Override
|
public SclQueryDTO getSclByPlanId(Long id) {
|
|
RiskAssessPlanIdentificationScl sclById = sclRepository.getSclById(id);
|
if (ObjectUtils.isEmpty(sclById)){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "scl辨识方法不存在或已被删除");
|
}
|
return BeanCopyUtils.copyBean(sclById, SclQueryDTO.class);
|
}
|
|
/**
|
* 辨识方法-Scl - 删除
|
*/
|
@Override
|
public IdentificationMethodDeleteDTO deleteSclByPlanId(Long currentUserId, Long id) {
|
|
RiskAssessPlanIdentificationScl sclById = sclRepository.getSclById(id);
|
if (ObjectUtils.isEmpty(sclById)){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "Scl辨识方法不存在或已被删除");
|
}
|
IdentificationMethodDeleteDTO deleteDTO = new IdentificationMethodDeleteDTO();
|
|
LocalDateTime data = LocalDateTime.now();
|
sclById.setDeleteStatus(StatusEnum.DELETED.getCode().byteValue());
|
sclById.setUpdateTime(data);
|
|
RiskAssessPlanIdentificationScl deleteResult = sclRepository.save(sclById);
|
|
if (ObjectUtils.isEmpty(deleteResult)){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "Scl辨识方法不存在或已被删除");
|
}
|
deleteDTO.setResult(StatusEnum.DELETED.getCode().byteValue());
|
|
return deleteDTO;
|
}
|
|
/**
|
* 辨识方法-Scl - 查询 -- 不校验结果
|
*/
|
@Override
|
public RiskAssessPlanIdentificationScl checkSclByPlanId(Long identificationId) {
|
return sclRepository.getSclById(identificationId);
|
}
|
|
/**
|
* 辨识方法-Scl - list
|
*/
|
@Override
|
public List<SclQueryDTO> listSclByPlanId(Long id) {
|
List<RiskAssessPlanIdentificationScl> sclList = sclRepository.listSclByPlanId(id);
|
return BeanCopyUtils.copyBeanList(sclList, SclQueryDTO.class);
|
}
|
}
|