|
|
@@ -0,0 +1,79 @@ |
|
|
|
package com.ningdatech.pmapi.projectdeclared.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.dto.OperationDTO; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.entity.Operation; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.vo.OperationVO; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.service.IOperationService; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
|
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; |
|
|
|
import com.ningdatech.pmapi.user.util.LoginUserUtil; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Classname OperationManage |
|
|
|
* @Description |
|
|
|
* @Date 2023/7/31 14:48 |
|
|
|
* @Author PoffyZhang |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@Slf4j |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class OperationManage { |
|
|
|
|
|
|
|
private final IOperationService operationService; |
|
|
|
|
|
|
|
private final IProjectService projectService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取实施详情 |
|
|
|
* @param projectId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public OperationVO detail(Long projectId) { |
|
|
|
Project project = projectService.getNewProject(projectId); |
|
|
|
VUtils.isTrue(Objects.isNull(project)) |
|
|
|
.throwMessage("项目不存在!"); |
|
|
|
|
|
|
|
Operation operation = operationService.getOne(Wrappers.lambdaQuery(Operation.class) |
|
|
|
.eq(Operation::getProjectId, project.getProjectCode()) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
|
|
|
|
return BeanUtil.copyProperties(operation,OperationVO.class); |
|
|
|
} |
|
|
|
|
|
|
|
public String pushOperation(OperationDTO operation) { |
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
|
|
|
|
Project project = projectService.getNewProject(operation.getProjectId()); |
|
|
|
VUtils.isTrue(Objects.isNull(project)) |
|
|
|
.throwMessage("项目不存在!"); |
|
|
|
|
|
|
|
Operation old = operationService.getOne(Wrappers.lambdaQuery(Operation.class) |
|
|
|
.eq(Operation::getProjectId, project.getProjectCode()) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
|
|
|
|
Operation entity = BeanUtil.copyProperties(operation, Operation.class); |
|
|
|
if(Objects.nonNull(old)){ |
|
|
|
entity.setId(old.getId()); |
|
|
|
}else{ |
|
|
|
entity.setCreateOn(LocalDateTime.now()); |
|
|
|
entity.setCreateBy(user.getUsername()); |
|
|
|
} |
|
|
|
entity.setProjectCode(project.getProjectCode()); |
|
|
|
entity.setUpdateOn(LocalDateTime.now()); |
|
|
|
entity.setUpdateBy(user.getUsername()); |
|
|
|
operationService.saveOrUpdate(entity); |
|
|
|
|
|
|
|
return entity.getProjectCode(); |
|
|
|
} |
|
|
|
} |