|
|
@@ -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())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |