package com.gkhy.assess.system.service.impl;
|
|
import com.gkhy.assess.common.enums.RequestSourceEnum;
|
import com.gkhy.assess.common.exception.ApiException;
|
import com.gkhy.assess.system.domain.AssInvestigation;
|
import com.gkhy.assess.system.enums.AccessoryFileTypeEnum;
|
import com.gkhy.assess.system.enums.ReportProgressEnum;
|
import com.gkhy.assess.system.mapper.AssInvestigationMapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gkhy.assess.system.service.AssAccessoryFileService;
|
import com.gkhy.assess.system.service.AssInvestigationService;
|
import com.gkhy.assess.system.service.AssProjectService;
|
import com.gkhy.assess.system.utils.ShiroUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
/**
|
* <p>
|
* 现场勘验记录表 服务实现类
|
* </p>
|
*
|
* @author kzy
|
* @since 2023-12-12 10:46:54
|
*/
|
@Service
|
public class AssInvestigationServiceImpl extends ServiceImpl<AssInvestigationMapper, AssInvestigation> implements AssInvestigationService {
|
|
@Autowired
|
private AssProjectService projectService;
|
|
@Autowired
|
private AssAccessoryFileService accessoryFileService;
|
|
@Override
|
@Transactional(rollbackFor = RuntimeException.class)
|
public int addInvestigation(AssInvestigation investigation,String requestSourceType) {
|
Long projectId=investigation.getProjectId();
|
projectService.checkUserAllowed(projectId);
|
checkInvestigationCount(projectId);
|
investigation.setCreateBy(ShiroUtils.getSysUser().getUsername());
|
if(investigation.getIsSafetyCheck()!=null&&investigation.getIsSafetyCheck()==1){
|
Integer fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_ATTACHMENT.getCode());
|
if(fileCount==0){
|
throw new ApiException("未上传现场安全检查表");
|
}
|
}
|
//校验图片数量
|
Integer fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.DEVICE_IMAGE.getCode());
|
if(fileCount==0){
|
throw new ApiException("主要装置前的合影照片不能为空");
|
}
|
fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_IMAGE.getCode());
|
if(fileCount==0){
|
throw new ApiException("现场勘验照片照片不能为空");
|
}
|
fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.COMPANY_IMAGE.getCode());
|
if(fileCount==0){
|
throw new ApiException("现场勘验人员与企业陪同人员图片不能为空");
|
}
|
// fileCount=accessoryFileService.getAccessoryFileCountByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_VIDEO.getCode());
|
// if(fileCount==0){
|
// throw new ApiException("现场勘验视频不能为空");
|
// }
|
int row=baseMapper.insert(investigation);
|
if(requestSourceType== RequestSourceEnum.WEB.getCode()){
|
//校验项目状态
|
projectService.checkReportProgress(projectId, ReportProgressEnum.WORK_NOTIFICATION);
|
//更新项目状态
|
projectService.changeReportProgress(projectId,ReportProgressEnum.INVESTINGATION);
|
}
|
//校验项目状态
|
// projectService.checkReportProgress(projectId, ReportProgressEnum.WORK_NOTIFICATION);
|
// int row=baseMapper.insert(investigation);
|
// if(row>0 && (investigation.getState()==null||!investigation.getState().equals(ApproveStatusEnum.TEMPORARY.getCode()))) {
|
// //更新项目状态
|
// projectService.changeReportProgress(projectId,ReportProgressEnum.INVESTINGATION);
|
// }
|
return row;
|
}
|
|
public void checkInvestigationCount(Long projectId){
|
//校验项目下勘验记录数量
|
int count= baseMapper.getCountByProjectId(projectId);
|
if(count>0){
|
throw new ApiException("项目下已存在现场勘验记录");
|
}
|
}
|
|
@Override
|
public int editInvestigation(AssInvestigation investigation) {
|
projectService.checkUserAllowed(investigation.getProjectId());
|
investigation.setUpdateBy(ShiroUtils.getSysUser().getUsername());
|
int row=baseMapper.updateById(investigation);
|
return row;
|
}
|
|
@Override
|
public AssInvestigation getInvestigationByProjectId(Long projectId) {
|
projectService.checkUserAllowed(projectId);
|
AssInvestigation investigation= baseMapper.getInvestigationByProjectId(projectId);
|
if(investigation!=null) {
|
investigation.setAssAccessoryFiles(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_ATTACHMENT.getCode()));
|
investigation.setCcompanyImages(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.COMPANY_IMAGE.getCode()));
|
investigation.setDeviceImages(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.DEVICE_IMAGE.getCode()));
|
investigation.setInvestingationImages(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_IMAGE.getCode()));
|
investigation.setInvestingationVideos(accessoryFileService.getAccessoryFileByProjectId(projectId, AccessoryFileTypeEnum.INVESTINGATION_VIDEO.getCode()));
|
}
|
return investigation;
|
}
|
|
|
@Override
|
public AssInvestigation getInvestigationById(Long investigationId) {
|
return baseMapper.getInvestigationById(investigationId);
|
}
|
|
@Override
|
public void doInvestigationProcess(Long projectId) {
|
projectService.checkUserAllowed(projectId);
|
//校验项目状态
|
projectService.checkReportProgress(projectId, ReportProgressEnum.WORK_NOTIFICATION);
|
//更新项目状态
|
projectService.changeReportProgress(projectId,ReportProgressEnum.INVESTINGATION);
|
}
|
}
|