|
|
@@ -2,16 +2,21 @@ package com.ningdatech.pmapi.projectlib.manage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent; |
|
|
|
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.req.StartProjectDeclareReq; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.vo.AnnualPlanListItemVO; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
@@ -32,6 +37,7 @@ import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*; |
|
|
|
public class AnnualPlanLibManage { |
|
|
|
|
|
|
|
private final IProjectService projectService; |
|
|
|
private final StateMachineUtils stateMachine; |
|
|
|
|
|
|
|
/** |
|
|
|
* 年度计划查询状态 |
|
|
@@ -57,6 +63,7 @@ public class AnnualPlanLibManage { |
|
|
|
|
|
|
|
public PageVo<AnnualPlanListItemVO> annulPlanLibList(ProjectListReq req) { |
|
|
|
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); |
|
|
|
query.eq(Project::getIsTemporaryAugment, 0); |
|
|
|
query.orderByDesc(Project::getAnnualPlanAddTime); |
|
|
|
query.in(Project::getStatus, CollUtils.fieldList(ANNUAL_PLAN_LIST_STATUS, ProjectStatusEnum::getCode)); |
|
|
|
Page<Project> page = projectService.page(req.page(), query); |
|
|
@@ -82,4 +89,21 @@ public class AnnualPlanLibManage { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void startProjectDeclared(StartProjectDeclareReq req) { |
|
|
|
List<Project> projects = projectService.listByIds(req.getProjectIds()); |
|
|
|
projects.forEach(w -> { |
|
|
|
if (!IN_THE_ANNUAL_PLAN.eq(w.getStatus())) { |
|
|
|
throw BizException.wrap("开启方案申报失败"); |
|
|
|
} |
|
|
|
}); |
|
|
|
projects.forEach(project -> { |
|
|
|
try { |
|
|
|
stateMachine.execute(project, ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new BizException("开启方案申报失败"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |