|
|
@@ -1,9 +1,11 @@ |
|
|
|
package com.ningdatech.pmapi.projectlib.manage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.dto.ProjectRenewalFundDeclarationDTO; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectRenewalFundDeclaration; |
|
|
@@ -90,14 +92,26 @@ public class ProjectRenewalFundManage { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Long declared(ProjectRenewalFundDeclarationDTO dto) { |
|
|
|
//要判断 项目id 是否 以及状态是 已验收 |
|
|
|
Long projectId = dto.getProjectId(); |
|
|
|
Project project = projectService.getById(projectId); |
|
|
|
VUtils.isTrue(Objects.isNull(project)).throwMessage(String.format("关联的项目【%s】不存在 提交失败!",projectId)); |
|
|
|
VUtils.isTrue(!ProjectStatusEnum.ACCEPTED.getCode().equals(project.getStatus()) || |
|
|
|
!ProjectStatusEnum.ARCHIVED.getCode().equals(project.getStage())) |
|
|
|
.throwMessage("提交失败 该项目不是 已验收状态或者已归档阶段"); |
|
|
|
ProjectRenewalFundDeclaration declaration = new ProjectRenewalFundDeclaration(); |
|
|
|
//如果是重新申报 |
|
|
|
if(Objects.nonNull(dto.getId())){ |
|
|
|
ProjectRenewalFundDeclaration oldDeclaration = projectRenewalFundDeclarationService.getById(dto.getId()); |
|
|
|
VUtils.isTrue(Objects.isNull(oldDeclaration)).throwMessage(String.format("重新申报失败 【%s】 该申报不存在!",dto.getId())); |
|
|
|
BeanUtils.copyProperties(oldDeclaration,declaration); |
|
|
|
} |
|
|
|
BeanUtils.copyProperties(dto,declaration); |
|
|
|
declaration.setId(null); |
|
|
|
declaration.setCreateOn(LocalDateTime.now()); |
|
|
|
declaration.setUpdateOn(LocalDateTime.now()); |
|
|
|
declaration.setApprovalStatus(ProjectRenewalApprovalStatusEnum.PENDING.name()); |
|
|
|
if(!projectRenewalFundDeclarationService.save(declaration)){ |
|
|
|
throw new BusinessException("申报失败"); |
|
|
|
if(!projectRenewalFundDeclarationService.saveOrUpdate(declaration)){ |
|
|
|
throw new BusinessException(String.format("申报失败 【%s】",dto.getId())); |
|
|
|
} |
|
|
|
return declaration.getId(); |
|
|
|
} |
|
|
|