init
parent
10e6a9cd1b
commit
5c04a2595c
|
|
@ -7,6 +7,7 @@ import org.qinan.safetyeval.client.api.institution.EvalInternalReviewApi;
|
|||
import org.qinan.safetyeval.client.co.institution.EvalInternalReviewCO;
|
||||
import org.qinan.safetyeval.client.co.institution.EvalInternalReviewDetailCO;
|
||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||
import org.qinan.safetyeval.client.dto.institution.EvalInternalReviewConfirmCmd;
|
||||
import org.qinan.safetyeval.client.dto.institution.EvalInternalReviewSaveCmd;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -21,17 +22,23 @@ public class EvalInternalReviewController {
|
|||
@Resource
|
||||
private EvalInternalReviewApi evalInternalReviewApi;
|
||||
|
||||
@ApiOperation("按项目获取或保存")
|
||||
/* @ApiOperation("按项目获取或保存")
|
||||
@PostMapping("/get-or-save")
|
||||
public SingleResponse<EvalInternalReviewCO> getOrSave(@Validated @RequestBody EvalInternalReviewSaveCmd cmd) {
|
||||
return evalInternalReviewApi.getOrSave(cmd);
|
||||
}*/
|
||||
|
||||
@ApiOperation("内审确认")
|
||||
@PostMapping("/confirm")
|
||||
public SingleResponse<Void> confirm(@Validated @RequestBody EvalInternalReviewConfirmCmd cmd) {
|
||||
return evalInternalReviewApi.confirm(cmd);
|
||||
}
|
||||
|
||||
@ApiOperation("按项目查询")
|
||||
/*@ApiOperation("按项目查询")
|
||||
@GetMapping("/get")
|
||||
public SingleResponse<EvalInternalReviewCO> get(@ApiParam("项目ID") @RequestParam Long projectId) {
|
||||
return evalInternalReviewApi.getByProject(projectId);
|
||||
}
|
||||
}*/
|
||||
|
||||
@ApiOperation("按项目查询详情(内审人成员+审核项)")
|
||||
@GetMapping("/detail")
|
||||
|
|
|
|||
|
|
@ -3,11 +3,14 @@ package org.qinan.safetyeval.app.executor.institution;
|
|||
import org.qinan.safetyeval.app.executor.institution.support.EvalCmdCopy;
|
||||
import org.qinan.safetyeval.app.executor.institution.support.EvalNodeCoConverter;
|
||||
import org.qinan.safetyeval.app.executor.institution.support.EvalProjectNodeSupport;
|
||||
import org.qinan.safetyeval.app.item.convertor.EvalReviewItemCmdConvertor;
|
||||
import org.qinan.safetyeval.client.api.institution.EvalInternalReviewApi;
|
||||
import org.qinan.safetyeval.client.co.institution.EvalInternalReviewCO;
|
||||
import org.qinan.safetyeval.client.co.institution.EvalInternalReviewDetailCO;
|
||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||
import org.qinan.safetyeval.client.dto.institution.EvalInternalReviewConfirmCmd;
|
||||
import org.qinan.safetyeval.client.dto.institution.EvalInternalReviewSaveCmd;
|
||||
import org.qinan.safetyeval.client.item.request.EvalReviewItemAddCmd;
|
||||
import org.qinan.safetyeval.client.item.response.EvalReviewItemCo;
|
||||
import org.qinan.safetyeval.domain.constant.ReviewDimensionEnum;
|
||||
import org.qinan.safetyeval.domain.entity.EvalInternalReviewEntity;
|
||||
|
|
@ -17,11 +20,14 @@ import org.qinan.safetyeval.domain.exception.BizException;
|
|||
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||
import org.qinan.safetyeval.domain.gateway.EvalInternalReviewGateway;
|
||||
import org.qinan.safetyeval.domain.gateway.EvalProjectMemberGateway;
|
||||
import org.qinan.safetyeval.domain.item.gateway.EvalReviewItemGateway;
|
||||
import org.qinan.safetyeval.domain.item.model.EvalReviewItemE;
|
||||
import org.qinan.safetyeval.domain.support.EvalNodeCodes;
|
||||
import org.qinan.safetyeval.infrastructure.convertor.EvalInternalReviewConvertor;
|
||||
import org.qinan.safetyeval.infrastructure.persistence.queryservice.EvalReviewItemQueryService;
|
||||
import org.qinan.safetyeval.infrastructure.support.NodeWriteAuthority;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
|
@ -40,6 +46,10 @@ public class EvalInternalReviewExecutor implements EvalInternalReviewApi {
|
|||
private EvalReviewItemQueryService evalReviewItemQueryService;
|
||||
@Resource
|
||||
private EvalInternalReviewConvertor evalInternalReviewConvertor;
|
||||
@Resource
|
||||
private EvalReviewItemGateway evalReviewItemGateway;
|
||||
@Resource
|
||||
private EvalReviewItemCmdConvertor evalReviewItemCmdConvertor;
|
||||
|
||||
@Override
|
||||
public SingleResponse<EvalInternalReviewCO> getOrSave(EvalInternalReviewSaveCmd cmd) {
|
||||
|
|
@ -62,6 +72,46 @@ public class EvalInternalReviewExecutor implements EvalInternalReviewApi {
|
|||
return SingleResponse.success(EvalNodeCoConverter.toInternalCO(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SingleResponse<Void> confirm(EvalInternalReviewConfirmCmd cmd) {
|
||||
Long projectId = Long.parseLong(cmd.getProjectId());
|
||||
EvalProjectEntity project = evalProjectNodeSupport.requireProject(projectId);
|
||||
|
||||
// 判断项目是否归档
|
||||
if (project.getArchiveFlag() != null && project.getArchiveFlag() == 1) {
|
||||
throw new BizException(ErrorCode.EVAL_PROJECT_ARCHIVED);
|
||||
}
|
||||
|
||||
EvalInternalReviewEntity entity = evalInternalReviewConvertor.applyConfirmCmd(cmd);
|
||||
if (cmd.getId() != null) {
|
||||
// id不为空,查询数据,查不到则抛异常
|
||||
entity = evalInternalReviewGateway.get(cmd.getId());
|
||||
if (entity == null) {
|
||||
throw new BizException(ErrorCode.EVAL_INTERNAL_REVIEW_NOT_FOUND);
|
||||
}
|
||||
evalProjectNodeSupport.fillNodeStatus(entity.getStatusCode(), entity);
|
||||
entity = evalInternalReviewGateway.modify(entity);
|
||||
} else {
|
||||
// id为空,新增数据
|
||||
entity.setOrgId(project.getOrgId());
|
||||
entity.setStatusCode(1);
|
||||
evalProjectNodeSupport.fillNodeStatus(entity.getStatusCode(), entity);
|
||||
entity = evalInternalReviewGateway.save(entity);
|
||||
}
|
||||
|
||||
// 审核项:根据bizId和bizType先删后增
|
||||
String bizType = ReviewDimensionEnum.TypeEnum.EVAL_INTERNAL_REVIEW.getCode();
|
||||
evalReviewItemGateway.deletedEvalReviewItemByBizIdAndBizType(entity.getId(), bizType);
|
||||
for (EvalReviewItemAddCmd itemCmd : cmd.getReviewItems()) {
|
||||
EvalReviewItemE itemE = evalReviewItemCmdConvertor.convertCmdToE(itemCmd);
|
||||
itemE.setBizId(entity.getId());
|
||||
itemE.setBizType(bizType);
|
||||
evalReviewItemGateway.add(itemE);
|
||||
}
|
||||
return SingleResponse.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<EvalInternalReviewCO> getByProject(Long projectId) {
|
||||
evalProjectNodeSupport.assertRead(projectId);
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ package org.qinan.safetyeval.client.api.institution;
|
|||
import org.qinan.safetyeval.client.co.institution.EvalInternalReviewCO;
|
||||
import org.qinan.safetyeval.client.co.institution.EvalInternalReviewDetailCO;
|
||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||
import org.qinan.safetyeval.client.dto.institution.EvalInternalReviewConfirmCmd;
|
||||
import org.qinan.safetyeval.client.dto.institution.EvalInternalReviewSaveCmd;
|
||||
|
||||
public interface EvalInternalReviewApi {
|
||||
SingleResponse<EvalInternalReviewCO> getOrSave(EvalInternalReviewSaveCmd cmd);
|
||||
SingleResponse<Void> confirm(EvalInternalReviewConfirmCmd cmd);
|
||||
SingleResponse<EvalInternalReviewCO> getByProject(Long projectId);
|
||||
SingleResponse<EvalInternalReviewDetailCO> getDetailByProject(Long projectId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import java.time.LocalDateTime;
|
|||
|
||||
@Data
|
||||
public class EvalInternalReviewCO {
|
||||
private String id;
|
||||
private Long id;
|
||||
private String orgId;
|
||||
private String projectId;
|
||||
@ApiModelProperty(value = "节点状态编码:1未开始 2进行中 3已完成 4退回", example = "2")
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
public class EvalInternalReviewConfirmCmd {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("项目id")
|
||||
private String projectId;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import java.time.LocalDateTime;
|
|||
|
||||
@Data
|
||||
public class EvalInternalReviewSaveCmd {
|
||||
private String id;
|
||||
private Long id;
|
||||
private String projectId;
|
||||
@ApiModelProperty(value = "节点状态编码:1未开始 2进行中 3已完成 4退回", example = "2")
|
||||
private Integer statusCode;
|
||||
|
|
|
|||
|
|
@ -41,4 +41,13 @@ public interface EvalReviewItemGateway {
|
|||
* @return 结果
|
||||
*/
|
||||
Boolean deletedEvalReviewItemByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据业务id与业务类型删除审核项信息
|
||||
*
|
||||
* @param bizId 业务id
|
||||
* @param bizType 业务类型
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean deletedEvalReviewItemByBizIdAndBizType(Long bizId, String bizType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package org.qinan.safetyeval.infrastructure.convertor;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.qinan.safetyeval.client.co.institution.EvalInternalReviewCO;
|
||||
import org.qinan.safetyeval.client.co.institution.EvalProjectMemberCO;
|
||||
import org.qinan.safetyeval.client.dto.institution.EvalInternalReviewConfirmCmd;
|
||||
import org.qinan.safetyeval.domain.entity.EvalInternalReviewEntity;
|
||||
import org.qinan.safetyeval.domain.entity.EvalProjectMemberEntity;
|
||||
|
||||
|
|
@ -19,4 +22,18 @@ public interface EvalInternalReviewConvertor {
|
|||
EvalProjectMemberCO toMemberCO(EvalProjectMemberEntity entity);
|
||||
|
||||
List<EvalProjectMemberCO> toMemberCOs(List<EvalProjectMemberEntity> entities);
|
||||
|
||||
/**
|
||||
* 将 ConfirmCmd 转换为新的 entity(projectId、reviewerPersonnelId 由 String 转 Long)。
|
||||
*/
|
||||
@Mapping(target = "projectId", expression = "java(cmd.getProjectId() == null ? null : Long.parseLong(cmd.getProjectId()))")
|
||||
@Mapping(target = "reviewerPersonnelId", expression = "java(cmd.getReviewerPersonnelId() == null ? null : Long.parseLong(cmd.getReviewerPersonnelId()))")
|
||||
EvalInternalReviewEntity applyConfirmCmd(EvalInternalReviewConfirmCmd cmd);
|
||||
|
||||
/**
|
||||
* 将 ConfirmCmd 中的字段拷贝到 entity(projectId、reviewerPersonnelId 由 String 转 Long)。
|
||||
*/
|
||||
@Mapping(target = "projectId", expression = "java(cmd.getProjectId() == null ? null : Long.parseLong(cmd.getProjectId()))")
|
||||
@Mapping(target = "reviewerPersonnelId", expression = "java(cmd.getReviewerPersonnelId() == null ? null : Long.parseLong(cmd.getReviewerPersonnelId()))")
|
||||
void applyConfirmCmd(EvalInternalReviewConfirmCmd cmd, @MappingTarget EvalInternalReviewEntity entity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,9 @@ public class EvalReviewItemGatewayImpl implements EvalReviewItemGateway {
|
|||
public Boolean deletedEvalReviewItemByIds(Long[] ids) {
|
||||
return evalReviewItemRepository.deletedEvalReviewItemByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deletedEvalReviewItemByBizIdAndBizType(Long bizId, String bizType) {
|
||||
return evalReviewItemRepository.deletedEvalReviewItemByBizIdAndBizType(bizId, bizType);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.qinan.safetyeval.infrastructure.gatewayimpl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.qinan.safetyeval.domain.constant.BooleanQAEnum;
|
||||
import org.qinan.safetyeval.domain.entity.EvalInternalReviewEntity;
|
||||
import org.qinan.safetyeval.domain.gateway.EvalInternalReviewGateway;
|
||||
import org.qinan.safetyeval.domain.query.EvalInternalReviewQuery;
|
||||
|
|
@ -39,7 +40,7 @@ public class EvalInternalReviewGatewayImpl implements EvalInternalReviewGateway
|
|||
@Override
|
||||
public EvalInternalReviewEntity get(Long id) {
|
||||
EvalInternalReviewDO dataObject = evalInternalReviewMapper.selectById(id);
|
||||
if (dataObject == null || !"false".equals(dataObject.getDeleteEnum())) {
|
||||
if (dataObject == null || !BooleanQAEnum.FALSE.getValue().equals(dataObject.getDeleteEnum())) {
|
||||
return null;
|
||||
}
|
||||
return toEntity(dataObject);
|
||||
|
|
|
|||
|
|
@ -73,4 +73,13 @@ public interface EvalReviewItemRepository extends BaseRepository<EvalReviewItemD
|
|||
*/
|
||||
Boolean deletedEvalReviewItemByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据业务id与业务类型删除审核项信息
|
||||
*
|
||||
* @param bizId 业务id
|
||||
* @param bizType 业务类型
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean deletedEvalReviewItemByBizIdAndBizType(Long bizId, String bizType);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,4 +91,14 @@ public class EvalReviewItemRepositoryImpl extends BaseRepositoryImpl<EvalReviewI
|
|||
public Boolean deletedEvalReviewItemByIds(Long[] ids) {
|
||||
return super.removeBatchEnByIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deletedEvalReviewItemByBizIdAndBizType(Long bizId, String bizType) {
|
||||
return super.lambdaUpdate()
|
||||
.eq(EvalReviewItemDO::getBizId, bizId)
|
||||
.eq(EvalReviewItemDO::getBizType, bizType)
|
||||
.eq(EvalReviewItemDO::getDeleteEnum, BooleanEnum.FALSE.getValue())
|
||||
.set(EvalReviewItemDO::getDeleteEnum, BooleanEnum.TRUE.getValue())
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue