Browse Source

modify:

1. 项目状态变更;
tags/24082201
WendyYang 2 months ago
parent
commit
780dd5939d
7 changed files with 75 additions and 3 deletions
  1. +7
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectStateChangeAction.java
  2. +8
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java
  3. +50
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/ProjectGuardFactory.java
  4. +8
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java
  5. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java
  6. BIN
      hz-pm-api/src/main/resources/response/mh-system-replace.xlsx
  7. +1
    -1
      pom.xml

+ 7
- 1
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectStateChangeAction.java View File

@@ -24,7 +24,7 @@ public class ProjectStateChangeAction {

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);
Assert.notNull(project, "未获取到需要状态变更的项目信息");
return project;
@@ -137,6 +137,12 @@ public class ProjectStateChangeAction {
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")
public void SUBMIT_PURCHASE_ORG_CONFIRM(Message<ProjectStateChangeEvent> message) {
Project project = getProject(message);


+ 8
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java View File

@@ -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.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.enumeration.status.ProjectStatus;
import lombok.RequiredArgsConstructor;
@@ -150,6 +151,13 @@ public class ProjectStateMachineBuilderImpl implements BaseStateMachineBuilder<P
.event(ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD).and()
// 填写试试计划 -> 待初验
.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)
.target(ProjectStatus.TO_BE_FIRST_INSPECTED)
.event(ProjectStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM).and()


+ 50
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/ProjectGuardFactory.java View File

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


}

+ 8
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java View File

@@ -450,6 +450,14 @@ public class PurchaseManage {
contract.setSupplierContact(req.getSupplierContact());
contract.setSupplierContactInfo(req.getSupplierContactInfo());
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)
.eq(Contract::getProjectId, projectId);


+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java View File

@@ -186,7 +186,7 @@ public class WorkbenchManage {
initWorkbenchDefaultParam(req);
LambdaQueryWrapper<Project> projectQuery = Wrappers.lambdaQuery(Project.class)
.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(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip())
.eq(Project::getNewest, Boolean.TRUE);


BIN
hz-pm-api/src/main/resources/response/mh-system-replace.xlsx View File


+ 1
- 1
pom.xml View File

@@ -13,7 +13,7 @@
<properties>
<skipTests>true</skipTests>
<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.target>1.8</maven.compiler.target>
<mybatis.plus.version>3.5.1</mybatis.plus.version>


Loading…
Cancel
Save