@@ -24,7 +24,7 @@ public class ProjectStateChangeAction { | |||||
private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE; | private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE; | ||||
private Project getProject(Message<ProjectStateChangeEvent> message) { | |||||
public static Project getProject(Message<ProjectStateChangeEvent> message) { | |||||
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE); | Project project = (Project) message.getHeaders().get(PROJECT_DECLARE); | ||||
Assert.notNull(project, "未获取到需要状态变更的项目信息"); | Assert.notNull(project, "未获取到需要状态变更的项目信息"); | ||||
return project; | return project; | ||||
@@ -137,6 +137,12 @@ public class ProjectStateChangeAction { | |||||
project.setStatus(ProjectStatus.ON_ADAPTING.getCode()); | project.setStatus(ProjectStatus.ON_ADAPTING.getCode()); | ||||
} | } | ||||
@OnTransition(source = "ON_PURCHASING", target = "TO_BE_FIRST_INSPECTED") | |||||
public void SUBMIT_PURCHASE_CONTRACT_RECORD_TO_FIRST_ACCEPT(Message<ProjectStateChangeEvent> message) { | |||||
Project project = getProject(message); | |||||
project.setStatus(ProjectStatus.TO_BE_FIRST_INSPECTED.getCode()); | |||||
} | |||||
@OnTransition(source = "ON_ADAPTING", target = "TO_BE_FIRST_INSPECTED") | @OnTransition(source = "ON_ADAPTING", target = "TO_BE_FIRST_INSPECTED") | ||||
public void SUBMIT_PURCHASE_ORG_CONFIRM(Message<ProjectStateChangeEvent> message) { | public void SUBMIT_PURCHASE_ORG_CONFIRM(Message<ProjectStateChangeEvent> message) { | ||||
Project project = getProject(message); | Project project = getProject(message); | ||||
@@ -2,6 +2,7 @@ package com.hz.pm.api.common.statemachine.builder.impl; | |||||
import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder; | import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder; | ||||
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; | import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; | ||||
import com.hz.pm.api.common.statemachine.factory.ProjectGuardFactory; | |||||
import com.hz.pm.api.projectlib.model.entity.Project; | import com.hz.pm.api.projectlib.model.entity.Project; | ||||
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; | import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
@@ -150,6 +151,13 @@ public class ProjectStateMachineBuilderImpl implements BaseStateMachineBuilder<P | |||||
.event(ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD).and() | .event(ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD).and() | ||||
// 填写试试计划 -> 待初验 | // 填写试试计划 -> 待初验 | ||||
.withExternal() | .withExternal() | ||||
.source(ProjectStatus.ON_PURCHASING) | |||||
.target(ProjectStatus.TO_BE_FIRST_INSPECTED) | |||||
.event(ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD) | |||||
.guard(new ProjectGuardFactory.ProjectPurchaseToFirstAcceptGuard()) | |||||
.and() | |||||
// 填写试试计划 -> 待初验 | |||||
.withExternal() | |||||
.source(ProjectStatus.ON_ADAPTING) | .source(ProjectStatus.ON_ADAPTING) | ||||
.target(ProjectStatus.TO_BE_FIRST_INSPECTED) | .target(ProjectStatus.TO_BE_FIRST_INSPECTED) | ||||
.event(ProjectStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM).and() | .event(ProjectStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM).and() | ||||
@@ -0,0 +1,50 @@ | |||||
package com.hz.pm.api.common.statemachine.factory; | |||||
import cn.hutool.core.collection.CollUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.hz.pm.api.common.statemachine.action.ProjectStateChangeAction; | |||||
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; | |||||
import com.hz.pm.api.projectdeclared.model.entity.Purchase; | |||||
import com.hz.pm.api.projectdeclared.model.enumerization.BidTypeEnum; | |||||
import com.hz.pm.api.projectdeclared.service.IPurchaseService; | |||||
import com.hz.pm.api.projectlib.model.entity.Project; | |||||
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; | |||||
import com.hz.pm.api.projectlib.model.enumeration.status.TenderMainStatus; | |||||
import com.ningdatech.basic.util.SpringUtils; | |||||
import org.springframework.statemachine.StateContext; | |||||
import org.springframework.statemachine.guard.Guard; | |||||
import java.util.List; | |||||
/** | |||||
* <p> | |||||
* ProjectGuardFactory | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 11:28 2024/8/22 | |||||
*/ | |||||
public class ProjectGuardFactory { | |||||
private ProjectGuardFactory() { | |||||
} | |||||
public static class ProjectPurchaseToFirstAcceptGuard implements Guard<ProjectStatus, ProjectStateChangeEvent> { | |||||
private final IPurchaseService purchaseService = SpringUtils.getBean(IPurchaseService.class); | |||||
@Override | |||||
public boolean evaluate(StateContext<ProjectStatus, ProjectStateChangeEvent> stateContext) { | |||||
Project project = ProjectStateChangeAction.getProject(stateContext.getMessage()); | |||||
Wrapper<Purchase> query = Wrappers.lambdaQuery(Purchase.class) | |||||
.select(Purchase::getId, Purchase::getBidType) | |||||
.eq(Purchase::getProjectId, project.getId()); | |||||
List<Purchase> purchases = purchaseService.list(query); | |||||
return CollUtil.allMatch(purchases, w -> !BidTypeEnum.BUILD_APP.eq(w.getBidType())); | |||||
} | |||||
} | |||||
} |
@@ -450,6 +450,14 @@ public class PurchaseManage { | |||||
contract.setSupplierContact(req.getSupplierContact()); | contract.setSupplierContact(req.getSupplierContact()); | ||||
contract.setSupplierContactInfo(req.getSupplierContactInfo()); | contract.setSupplierContactInfo(req.getSupplierContactInfo()); | ||||
contractService.saveOrUpdate(contract); | contractService.saveOrUpdate(contract); | ||||
// 判断是否所有标项都完成了采购合同备案 | |||||
Wrapper<Purchase> select = Wrappers.lambdaQuery(Purchase.class) | |||||
.select(Purchase::getId, Purchase::getAgency) | |||||
.eq(Purchase::getProjectId, projectId); | |||||
List<Purchase> purchases = purchaseService.list(select); | |||||
if (CollUtil.allMatch(purchases, w -> StrUtil.isNotBlank(w.getAgency()))) { | |||||
projectStateMachineUtil.pass(project); | |||||
} | |||||
// 修改项目合同金额 | // 修改项目合同金额 | ||||
Wrapper<Contract> query = Wrappers.lambdaQuery(Contract.class) | Wrapper<Contract> query = Wrappers.lambdaQuery(Contract.class) | ||||
.eq(Contract::getProjectId, projectId); | .eq(Contract::getProjectId, projectId); | ||||
@@ -186,7 +186,7 @@ public class WorkbenchManage { | |||||
initWorkbenchDefaultParam(req); | initWorkbenchDefaultParam(req); | ||||
LambdaQueryWrapper<Project> projectQuery = Wrappers.lambdaQuery(Project.class) | LambdaQueryWrapper<Project> projectQuery = Wrappers.lambdaQuery(Project.class) | ||||
.ne(Project::getStatus, ProjectStatus.STOPPED_PASSED.getCode()) | .ne(Project::getStatus, ProjectStatus.STOPPED_PASSED.getCode()) | ||||
.select(Project::getReviewAmount, Project::getApprovalGovOwnFinanceAmount, Project::getId) | |||||
.select(Project::getReviewAmount, Project::getApprovalAmount, Project::getId) | |||||
.eq(Project::getProjectYear, req.getProjectYear()) | .eq(Project::getProjectYear, req.getProjectYear()) | ||||
.eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) | .eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) | ||||
.eq(Project::getNewest, Boolean.TRUE); | .eq(Project::getNewest, Boolean.TRUE); | ||||
@@ -13,7 +13,7 @@ | |||||
<properties> | <properties> | ||||
<skipTests>true</skipTests> | <skipTests>true</skipTests> | ||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||||
<spring-boot.version>2.6.11</spring-boot.version> | |||||
<spring-boot.version>2.6.15</spring-boot.version> | |||||
<maven.compiler.source>1.8</maven.compiler.source> | <maven.compiler.source>1.8</maven.compiler.source> | ||||
<maven.compiler.target>1.8</maven.compiler.target> | <maven.compiler.target>1.8</maven.compiler.target> | ||||
<mybatis.plus.version>3.5.1</mybatis.plus.version> | <mybatis.plus.version>3.5.1</mybatis.plus.version> | ||||