Bläddra i källkod

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	hz-pm-api/src/main/resources/application-dev.yml
tags/24080901
wangrenkang 10 månader sedan
förälder
incheckning
845cb3b020
100 ändrade filer med 1020 tillägg och 7428 borttagningar
  1. +7
    -15
      hz-pm-api/pom.xml
  2. +35
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/config/AuthCodeProps.java
  3. +0
    -10
      hz-pm-api/src/main/java/com/hz/pm/api/common/helper/RegionLimitHelper.java
  4. +15
    -19
      hz-pm-api/src/main/java/com/hz/pm/api/common/helper/UserInfoHelper.java
  5. +0
    -32
      hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/RegionLimitHelperImpl.java
  6. +29
    -142
      hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java
  7. +1
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/BizConst.java
  8. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/RegionConst.java
  9. +3
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/StateMachineConst.java
  10. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/common/model/entity/MenuTreeEntity.java
  11. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/HzProjectDeclareAction.java
  12. +0
    -273
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareAction.java
  13. +30
    -26
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareChoiceAction.java
  14. +0
    -279
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareJNAction.java
  15. +0
    -279
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareJYAction.java
  16. +0
    -279
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareKFBAction.java
  17. +0
    -279
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareLDAction.java
  18. +0
    -279
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareLQAction.java
  19. +0
    -279
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareQTAction.java
  20. +0
    -279
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareQYAction.java
  21. +0
    -287
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareSCAction.java
  22. +0
    -279
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareSYAction.java
  23. +0
    -280
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareYHAction.java
  24. +3
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineBuilder.java
  25. +27
    -34
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineBuilderImpl.java
  26. +0
    -284
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineJNBuilder.java
  27. +0
    -285
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineJYBuilder.java
  28. +0
    -285
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineKFQBuilder.java
  29. +0
    -285
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineLDBuilder.java
  30. +0
    -286
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineLQBuilder.java
  31. +0
    -285
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineQTBuilder.java
  32. +0
    -285
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineQYBuilder.java
  33. +0
    -295
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineSCBuilder.java
  34. +0
    -285
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineSYBuilder.java
  35. +0
    -285
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineYHBuilder.java
  36. +0
    -34
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/contant/RegionContant.java
  37. +2
    -37
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/ProjectDeclareGuardFactory.java
  38. +0
    -73
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/MachineBuilderFounder.java
  39. +30
    -50
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/StateMachineUtil.java
  40. +0
    -13
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java
  41. +2
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/FreemarkerWordUtil.java
  42. +2
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/HmacAuthUtil.java
  43. +0
    -91
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/JwtTokenUtil.java
  44. +3
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/MDCUtil.java
  45. +30
    -23
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/SendWorkNoticeUtil.java
  46. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/TreeUtil.java
  47. +2
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/constant/AnalysisBasicConstant.java
  48. +70
    -74
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/handle/CockpitStatsHandler.java
  49. +8
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/handle/ProjectStatusHandler.java
  50. +5
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/helper/DashboardChartAssembler.java
  51. +1
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/helper/DashboardHelper.java
  52. +85
    -97
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/DashboardProjectManage.java
  53. +63
    -64
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/EarlyWarningStatisticsManage.java
  54. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/ExpertStatisticsManage.java
  55. +18
    -24
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/MeetingStatisticsManage.java
  56. +38
    -33
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/ProjectCostStatisticsManage.java
  57. +1
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/model/vo/PerformanceStatisticsVO.java
  58. +1
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/dashboard/model/vo/ProjectStatisticsVO.java
  59. +1
    -7
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/model/DataScopeDTO.java
  60. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/DataScopeContext.java
  61. +6
    -11
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java
  62. +2
    -27
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertAdminDataScopeProviderImpl.java
  63. +2
    -17
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertDataScopeProviderImpl.java
  64. +0
    -27
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/HigherUserDataScopeProviderImpl.java
  65. +4
    -7
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java
  66. +3
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java
  67. +0
    -27
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java
  68. +0
    -14
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java
  69. +4
    -11
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/VisitorDataScopeProviderImpl.java
  70. +4
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/datascope/utils/DataScopeUtil.java
  71. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/ding/controller/DingInfoPullController.java
  72. +42
    -89
      hz-pm-api/src/main/java/com/hz/pm/api/ding/task/EmployeeBatchGetTask.java
  73. +3
    -5
      hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertAdminExpertManageAssembler.java
  74. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertInfoCmdAssembler.java
  75. +0
    -29
      hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/TagAssembler.java
  76. +0
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/expert/controller/ExpertController.java
  77. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/expert/helper/ExpertInfoSensitiveFieldModifyCheckHelper.java
  78. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertAdminManage.java
  79. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertManage.java
  80. +0
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertMetaApplyManage.java
  81. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/expert/model/SensitiveModifySegment.java
  82. +0
    -37
      hz-pm-api/src/main/java/com/hz/pm/api/expert/model/cmd/AdminModifyExpertInfoCmd.java
  83. +0
    -60
      hz-pm-api/src/main/java/com/hz/pm/api/expert/model/cmd/SaveExpertAdminCmd.java
  84. +0
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/expert/model/vo/MetaApplyResultVo.java
  85. +2
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertAdminManageServiceImpl.java
  86. +35
    -41
      hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertInfoServiceImpl.java
  87. +8
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java
  88. +0
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java
  89. +46
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhProjectDTO.java
  90. +91
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhProjectSchemeTargetDTO.java
  91. +0
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhTechExpertDTO.java
  92. +21
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhUnitDTO.java
  93. +26
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/model/enumeration/MhUnitStripEnum.java
  94. +100
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/model/enumeration/MhUnitTypeEnum.java
  95. +1
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/external/sms/SmsServiceClient.java
  96. +2
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java
  97. +1
    -5
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java
  98. +6
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/filemanage/manage/DocumentationManage.java
  99. +72
    -89
      hz-pm-api/src/main/java/com/hz/pm/api/filemanage/manage/ProjectFileManage.java
  100. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/entity/ProjectApplyBorrow.java

+ 7
- 15
hz-pm-api/pom.xml Visa fil

@@ -9,9 +9,6 @@
</parent>
<artifactId>hz-pm-api</artifactId>
<version>1.0.0</version>
<properties>
<jjwt.version>0.11.5</jjwt.version>
</properties>

<dependencies>
<dependency>
@@ -108,12 +105,6 @@
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<!-- 阿里云oss -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.15.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -128,12 +119,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!--引入jwt-->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.10.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
@@ -274,6 +259,13 @@
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<!--使用${environment}获取值-->
<environment>test</environment>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<environment>prod</environment>


+ 35
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/config/AuthCodeProps.java Visa fil

@@ -0,0 +1,35 @@
package com.hz.pm.api.common.config;

import cn.hutool.core.util.RandomUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
* <p>
* AuthCodeProps
* </p>
*
* @author WendyYang
* @since 00:15 2023/12/21
*/
@Data
@ConfigurationProperties(prefix = "auth-code")
public class AuthCodeProps {

private String secretKey;

/**
* authCode失效时间(单位:秒)
*/
private Integer expireTime = 10;

/**
* authCode长度(最大:24~32)
*/
private Integer length = 24;

public static void main(String[] args) {
System.out.println("secretKey:" + RandomUtil.randomString(24));
}

}

+ 0
- 10
hz-pm-api/src/main/java/com/hz/pm/api/common/helper/RegionLimitHelper.java Visa fil

@@ -39,14 +39,4 @@ public interface RegionLimitHelper {
*/
RegionContainsBO getContainsRegionBo(Integer regionLevel, String regionCode);



/**
* 根据专家管理员用户id 获取专家管理员管辖区域列表
*
* @param expertAdminUserId 专家管理员用户id
* @return
*/
List<RegionContainsBO> getExpertAdminContainsRegion(Long expertAdminUserId);

}

+ 15
- 19
hz-pm-api/src/main/java/com/hz/pm/api/common/helper/UserInfoHelper.java Visa fil

@@ -1,7 +1,9 @@
package com.hz.pm.api.common.helper;

import com.hz.pm.api.user.entity.UserInfo;
import cn.hutool.core.util.NumberUtil;
import com.hz.pm.api.user.model.entity.UserInfo;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
import com.ningdatech.basic.util.CollUtils;

import java.util.Collection;
import java.util.List;
@@ -14,18 +16,17 @@ import java.util.List;

public interface UserInfoHelper {

/**
* 根据用户id 获取 用户所属组织code organizationCode
*
* @param userId \
* @return \
*/
String getOrganizationCode(Long userId);

UserFullInfoDTO getUserFullInfoByMhUserIdOrOpenId(String mhUserId);

UserFullInfoDTO getUserFullInfo(Long userId);

default UserFullInfoDTO getUserFullInfo(String userId) {
if (NumberUtil.isLong(userId)) {
return getUserFullInfo(Long.parseLong(userId));
}
return null;
}

UserFullInfoDTO getUserFullInfo(UserInfo userInfo);

List<UserFullInfoDTO> getUserFullInfos(List<UserInfo> userInfos);
@@ -39,16 +40,11 @@ public interface UserInfoHelper {
*/
boolean isSuperOrRegionAdmin(Long userId);

UserFullInfoDTO getUserFullInfoByEmployeeCode(String employeeCode);
List<UserFullInfoDTO> listUserFullInfoByUserIds(Collection<Long> userIds);

List<UserFullInfoDTO> getUserFullInfoByEmployeeCodes(Collection<String> employeeCodes);

/**
* 获取用户任职所在单位code \
*
* @return \
*/
String getUserEmpPosUnitCode(Long userId);
default List<UserFullInfoDTO> listUserFullInfoByUserIds(List<String> userIds){
List<Long> userIdsLong = CollUtils.convert(userIds, Long::parseLong);
return listUserFullInfoByUserIds(userIdsLong);
}

String getMainOrgCode(String empPosUnitCode);
}

+ 0
- 32
hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/RegionLimitHelperImpl.java Visa fil

@@ -1,15 +1,10 @@
package com.hz.pm.api.common.helper.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.common.helper.basic.AbstractRegionLimitHelper;
import com.hz.pm.api.expert.service.IExpertUserFullInfoService;
import com.hz.pm.api.meta.model.bo.RegionContainsBO;
import com.hz.pm.api.sys.model.entity.Region;
import com.hz.pm.api.sys.service.IRegionService;
import com.hz.pm.api.user.entity.UserInfo;
import com.hz.pm.api.user.service.IUserInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
@@ -28,8 +23,6 @@ import java.util.Objects;
@Component
public class RegionLimitHelperImpl extends AbstractRegionLimitHelper {

private static final Logger logger = LoggerFactory.getLogger(RegionLimitHelperImpl.class);

public RegionLimitHelperImpl(RegionCacheHelper regionCache, IExpertUserFullInfoService expertUserFullInfoService
, IUserInfoService iUserInfoService, IRegionService regionService) {
super(regionCache, expertUserFullInfoService, iUserInfoService, regionService);
@@ -91,29 +84,4 @@ public class RegionLimitHelperImpl extends AbstractRegionLimitHelper {
return regionContains;
}


@Override
public List<RegionContainsBO> getExpertAdminContainsRegion(Long expertAdminUserId) {
if (Objects.isNull(expertAdminUserId)) {
logger.error("getExpertAdminContainsRegion expertAdminUserId is null");
return new ArrayList<>();
}
UserInfo userInfo = iUserInfoService.getById(expertAdminUserId);
if (Objects.isNull(userInfo) || StringUtils.isBlank(userInfo.getRegionCode())) {
logger.error("getExpertAdminContainsRegion userInfo is null Or regionCode is null");
return new ArrayList<>();
}
String regionCode = userInfo.getRegionCode();
List<Region> regionList = regionService.list(Wrappers.lambdaQuery(Region.class)
.eq(Region::getRegionCode, regionCode)
.orderByDesc(Region::getRegionLevel));
Region region = regionList.get(0);
Collection<String> regionCodes = regionCache
.listChildRegionCodeList(region.getRegionCode(), region.getRegionLevel());
RegionContainsBO regionContainsBO = new RegionContainsBO();
regionContainsBO.setContainsRegionCodeList(new ArrayList<>(regionCodes));
regionContainsBO.setParentRegionTreeLevel(region.getRegionLevel());
return CollectionUtil.toList(regionContainsBO);
}

}

+ 29
- 142
hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java Visa fil

@@ -1,31 +1,28 @@
package com.hz.pm.api.common.helper.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.organization.model.entity.DingEmployeeInfo;
import com.hz.pm.api.organization.model.entity.DingOrganization;
import com.hz.pm.api.organization.service.IDingEmployeeInfoService;
import com.hz.pm.api.organization.service.IDingOrganizationService;
import com.hz.pm.api.common.util.StrUtils;
import com.hz.pm.api.sys.mapper.RoleMapper;
import com.hz.pm.api.sys.model.entity.Role;
import com.hz.pm.api.sys.model.entity.UserRole;
import com.hz.pm.api.sys.service.IUserRoleService;
import com.hz.pm.api.user.model.enumeration.UserAvailableEnum;
import com.hz.pm.api.user.entity.UserInfo;
import com.hz.pm.api.user.model.entity.UserInfo;
import com.hz.pm.api.user.model.enumeration.RoleEnum;
import com.hz.pm.api.user.model.enumeration.UserAvailableEnum;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
import com.hz.pm.api.user.service.IUserInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* @author liuxinxin
@@ -37,22 +34,14 @@ public class UserInfoHelperImpl implements UserInfoHelper {


private final IUserInfoService userInfoService;
private final IDingEmployeeInfoService iDingEmployeeInfoService;
private final IDingOrganizationService iDingOrganizationService;
private final IUserRoleService iUserRoleService;
private final RoleMapper roleMapper;

@Override
public String getOrganizationCode(Long userId) {
UserFullInfoDTO userFullInfo = getUserFullInfo(userId);
return userFullInfo.getOrganizationCode();
}

@Override
public UserFullInfoDTO getUserFullInfoByMhUserIdOrOpenId(String mhUserId) {
LambdaQueryWrapper<UserInfo> query = Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getMhUserId, mhUserId)
.or(q1 -> q1.eq(UserInfo::getWechatOpenId,mhUserId));
.or(q1 -> q1.eq(UserInfo::getWechatOpenId, mhUserId));
UserInfo userInfo = userInfoService.getOne(query);
if (Objects.isNull(userInfo)) {
return null;
@@ -74,65 +63,25 @@ public class UserInfoHelperImpl implements UserInfoHelper {
@Override
public UserFullInfoDTO getUserFullInfo(UserInfo userInfo) {
UserFullInfoDTO userFullInfo = new UserFullInfoDTO();
// 获取浙政钉雇员信息 组织信息
String employeeCode = userInfo.getEmployeeCode();
if (StringUtils.isNotBlank(employeeCode)) {
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService
.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode)
.eq(DingEmployeeInfo::getMainJob, "true"));
DingEmployeeInfo dingEmployeeInfo = dingEmployeeInfoList.get(0);


// 装配用户任职所在单位
String empPosUnitCode = dingEmployeeInfo.getEmpPosUnitCode();
if (StringUtils.isNotBlank(empPosUnitCode)) {
DingOrganization dingOrganization = iDingOrganizationService.getByOrgCode(empPosUnitCode);
if (Objects.nonNull(dingOrganization)) {
userFullInfo.setEmpPosUnitCode(empPosUnitCode);
userFullInfo.setEmpPosUnitName(dingOrganization.getOrganizationName());
userFullInfo.setRegionCode(dingOrganization.getDivisionCode());
}
}

// 装配用户所在orgCode
String organizationCode = dingEmployeeInfo.getOrganizationCode();
List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(Wrappers
.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getOrganizationCode, organizationCode));
if (CollectionUtil.isNotEmpty(dingOrganizationList)) {
DingOrganization dingOrganization = dingOrganizationList.get(0);
userFullInfo.setOrganizationCode(dingOrganization.getOrganizationCode());
userFullInfo.setOrganizationName(dingOrganization.getOrganizationName());
// 测试使用
userFullInfo.setRegionLevel(3);
}
}

List<Role> roleList = new ArrayList<>();
// 获取用户角色列表信息
List<UserRole> userRoleList = iUserRoleService
.list(Wrappers.lambdaQuery(UserRole.class)
.eq(UserRole::getUserId, userInfo.getId()));
if (CollectionUtil.isNotEmpty(userRoleList)) {
List<UserRole> userRoleList = iUserRoleService.listByUserId(userInfo.getId());
if (CollUtil.isNotEmpty(userRoleList)) {
List<Long> roleIdList = userRoleList.stream()
.map(UserRole::getRoleId).distinct()
.collect(Collectors.toList());
roleList = roleMapper.selectBatchIds(roleIdList);
userFullInfo.setUserRoleList(roleMapper.selectBatchIds(roleIdList));
}
userFullInfo.setUserRoleList(roleList);

// 装配用户任职所在单位

// 装配返回
userFullInfo.setUserId(userInfo.getId());
userFullInfo.setMhUserId(userInfo.getMhUserId());
userFullInfo.setIdentifier(userInfo.getRealName());
userFullInfo.setRealName(userInfo.getRealName());
userFullInfo.setEmployeeCode(employeeCode);
userFullInfo.setMhUnitId(userInfo.getMhUnitId());
userFullInfo.setMhUnitName(userInfo.getMhUnitName());
userFullInfo.setUsername(userInfo.getRealName());
userFullInfo.setMobile(userInfo.getMobile());
userFullInfo.setAccountId(userInfo.getAccountId());

String available = userInfo.getAvailable();
if (StringUtils.isNotBlank(available)) {
userFullInfo.setAvailable(UserAvailableEnum.valueOf(available));
@@ -151,60 +100,20 @@ public class UserInfoHelperImpl implements UserInfoHelper {
if (CollUtil.isEmpty(userInfos)) {
return Collections.emptyList();
}
Map<String, UserInfo> userMap = userInfos.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode, e -> e));
// 获取浙政钉雇员信息 组织信息
List<String> employeeCodes = userInfos.stream().map(UserInfo::getEmployeeCode).collect(Collectors.toList());
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService
.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.in(DingEmployeeInfo::getEmployeeCode, employeeCodes)
.eq(DingEmployeeInfo::getMainJob, "true"));

if (CollUtil.isEmpty(dingEmployeeInfoList)) {
return Collections.emptyList();
}

// 装配用户任职所在单位
List<String> empPosUnitCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getEmpPosUnitCode).collect(Collectors.toList());
List<String> orgCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getOrganizationCode).collect(Collectors.toList());
List<String> allOrgCodes = Stream.concat(empPosUnitCodes.stream(), orgCodes.stream()).collect(Collectors.toList());
if (CollUtil.isEmpty(allOrgCodes)) {
return Collections.emptyList();
}
List<DingOrganization> dingOrganizations = iDingOrganizationService.listByCodes(allOrgCodes);
if (CollUtil.isEmpty(dingOrganizations)) {
return Collections.emptyList();
}
Map<String, DingOrganization> orgMap = dingOrganizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode, d -> d));

return dingEmployeeInfoList.stream().map(e -> {
return userInfos.stream().map(userInfo -> {
UserFullInfoDTO userFullInfo = new UserFullInfoDTO();
if (orgMap.containsKey(e.getEmpPosUnitCode())) {
DingOrganization organization = orgMap.get(e.getEmpPosUnitCode());
userFullInfo.setEmpPosUnitCode(e.getEmpPosUnitCode());
userFullInfo.setEmpPosUnitName(organization.getOrganizationName());
userFullInfo.setRegionCode(organization.getDivisionCode());
}
if (orgMap.containsKey(e.getOrganizationCode())) {
DingOrganization organization = orgMap.get(e.getOrganizationCode());
userFullInfo.setOrganizationCode(organization.getOrganizationCode());
userFullInfo.setOrganizationName(organization.getOrganizationName());
// 测试使用
userFullInfo.setRegionLevel(3);
}
if (userMap.containsKey(e.getEmployeeCode())) {
UserInfo userInfo = userMap.get(e.getEmployeeCode());
// 装配返回
userFullInfo.setUserId(userInfo.getId());
userFullInfo.setIdentifier(userInfo.getRealName());
userFullInfo.setRealName(userInfo.getRealName());
userFullInfo.setEmployeeCode(e.getEmployeeCode());
userFullInfo.setUsername(userInfo.getRealName());
userFullInfo.setMobile(userInfo.getMobile());
userFullInfo.setAccountId(userInfo.getAccountId());
String available = userInfo.getAvailable();
if (StringUtils.isNotBlank(available)) {
userFullInfo.setAvailable(UserAvailableEnum.valueOf(available));
}
// 装配返回
userFullInfo.setMhUnitName(userInfo.getMhUnitName());
userFullInfo.setMhUnitId(userInfo.getMhUnitId());
userFullInfo.setUserId(userInfo.getId());
userFullInfo.setIdentifier(userInfo.getRealName());
userFullInfo.setRealName(userInfo.getRealName());
userFullInfo.setUsername(userInfo.getRealName());
userFullInfo.setMobile(userInfo.getMobile());
userFullInfo.setAccountId(userInfo.getAccountId());
String available = userInfo.getAvailable();
if (StrUtils.isNotBlank(available)) {
userFullInfo.setAvailable(UserAvailableEnum.valueOf(available));
}
return userFullInfo;
}).collect(Collectors.toList());
@@ -231,31 +140,9 @@ public class UserInfoHelperImpl implements UserInfoHelper {
}

@Override
public UserFullInfoDTO getUserFullInfoByEmployeeCode(String employeeCode) {
UserInfo userInfo = userInfoService.getUserInfoByEmployeeCode(employeeCode);
return getUserFullInfo(userInfo);
}

@Override
public List<UserFullInfoDTO> getUserFullInfoByEmployeeCodes(Collection<String> employeeCodes) {
List<UserInfo> userInfos = userInfoService.getUserInfoByEmployeeCodes(employeeCodes);
public List<UserFullInfoDTO> listUserFullInfoByUserIds(Collection<Long> userIds) {
List<UserInfo> userInfos = userInfoService.listByIds(userIds);
return getUserFullInfos(userInfos);
}

@Override
public String getUserEmpPosUnitCode(Long userId) {
UserFullInfoDTO userFullInfo = getUserFullInfo(userId);
return userFullInfo.getEmpPosUnitCode();
}

@Override
public String getMainOrgCode(String empPosUnitCode) {
DingOrganization org = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getOrganizationCode, empPosUnitCode)
.last(BizConst.LIMIT_1));
if(Objects.isNull(org)){
return null;
}
return org.getParentCode();
}
}

+ 1
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/BizConst.java Visa fil

@@ -65,6 +65,7 @@ public class BizConst {
* 浙江省的region_id
*/
public static final long ZJ_REGION_CODE = 330000L;

public static final String NINE_AREA_CODE_LAST = "000";

/**


+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/RegionConst.java Visa fil

@@ -25,9 +25,9 @@ public interface RegionConst {
//---------------------------------------地区编码(缩写RC)-------------------------------------------------------------

/**
* 丽水行政区划编码
* 杭州市行政区划编码
*/
String RC_LS = "331100";
String RC_HZ = "330100";
//丽水开发区
String LS_KF = "331118";
String LS_KF_IRS = "331151";
@@ -65,7 +65,7 @@ public interface RegionConst {
String QN = "331127";
String LQ = "331181";

List<String> LS_ARR = Lists.newArrayList(RC_LS, LS_KF, LD, QT, JY, SC, SY, YH, QY, QN, LQ);
List<String> LS_ARR = Lists.newArrayList(RC_HZ, LS_KF, LD, QT, JY, SC, SY, YH, QY, QN, LQ);

//----------------------------------------地区父级ID(缩写PID)---------------------------------------------------------



+ 3
- 1
hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/StateMachineConst.java Visa fil

@@ -7,8 +7,10 @@ package com.hz.pm.api.common.model.constant;

public class StateMachineConst {

private StateMachineConst() {
}

public static final String PROJECT_DECLARE = "projectDeclare";
public static final String APPLICATION_DECLARE = "applicationDeclare";
public static final String LI_SHUI_CITY_AREA_CODE = "331100";

}

+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/common/model/entity/MenuTreeEntity.java Visa fil

@@ -29,7 +29,7 @@ import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
@Setter
@Accessors(chain = true)
@ToString(callSuper = true)
public class MenuTreeEntity<E, T extends Serializable> {
public class MenuTreeEntity<E> {

@TableId(value = "id", type = IdType.AUTO)
protected Long id;


hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareSBJAction.java → hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/HzProjectDeclareAction.java Visa fil

@@ -1,7 +1,7 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.builder.ProjectDeclareStateMachineBuilderImpl;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
@@ -17,8 +17,8 @@ import org.springframework.statemachine.annotation.WithStateMachine;
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_SBJ_CODE)
public class ProjectDeclareSBJAction {
@WithStateMachine(id = ProjectDeclareStateMachineBuilderImpl.MACHINE_ID)
public class HzProjectDeclareAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;


+ 0
- 273
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareAction.java Visa fil

@@ -1,273 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
*
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_SBJ_CODE)
public class ProjectDeclareAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}


@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}
@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 30
- 26
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareChoiceAction.java Visa fil

@@ -1,10 +1,12 @@
package com.hz.pm.api.common.statemachine.action;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.hz.pm.api.common.model.constant.ProjectDeclareConst;
import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.enumeration.CommonEnum;
import com.hz.pm.api.common.statemachine.util.StateMachineUtils;
import com.hz.pm.api.common.statemachine.util.StateMachineUtil;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
@@ -32,7 +34,7 @@ public class ProjectDeclareChoiceAction implements Action<ProjectStatusEnum, Pro
public void execute(StateContext<ProjectStatusEnum, ProjectStatusChangeEvent> stateContext) {
log.info(String.valueOf(stateContext.getTarget().getId()));
ProjectStatusEnum projectStatusEnum = stateContext.getTarget().getId();
switch (projectStatusEnum){
switch (projectStatusEnum) {
case PENDING_PREQUALIFICATION_CHOICE:
preDeclareChoice(stateContext);
break;
@@ -48,49 +50,51 @@ public class ProjectDeclareChoiceAction implements Action<ProjectStatusEnum, Pro
}

private void approvedAfterChoice(StateContext<ProjectStatusEnum, ProjectStatusChangeEvent> stateContext) {
List<ProjectApplication> projectApplications = stateContext.getMessage().getHeaders().get(APPLICATION_DECLARE, List.class);
Project project = stateContext.getMessage().getHeaders().get(PROJECT_DECLARE, Project.class);
log.info("立项批复之后,项目的状态为:{}" + project.getStatus());
Project project = getProject(stateContext);
List<ProjectApplication> projectApplications = getProjectApplication(stateContext);
log.info("立项批复之后,项目的状态为:{}", project.getStatus());
// 判断 是否有初次创建的应用
if (CollUtil.isEmpty(projectApplications)){
if (CollUtil.isEmpty(projectApplications)) {
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}
final Boolean[] isFirstApp = {Boolean.FALSE};
projectApplications.stream().forEach(app -> {
final boolean[] isFirstApp = {Boolean.FALSE};
projectApplications.forEach(app -> {
Integer isFirst = app.getIsFirst();
if(isFirst.equals(CommonEnum.YES.getCode())){
if (isFirst.equals(CommonEnum.YES.getCode())) {
isFirstApp[0] = Boolean.TRUE;
}
});
if(isFirstApp[0]){
if (isFirstApp[0]) {
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APP_REGISTER.getCode());
}else{
} else {
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}
}

private void preDeclareChoice(StateContext<ProjectStatusEnum, ProjectStatusChangeEvent> stateContext) {
Project project = stateContext.getMessage().getHeaders().get(PROJECT_DECLARE, Project.class);
log.info("预审申报事件之前,项目的状态为:{}"+project.getStatus());
if (StateMachineUtils.isCityProject(project) && StateMachineUtils.judgeDeclareAmount(project,
ProjectDeclareConst.Number.DECLARE_AMOUNT_JUDGEMENT)){
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode());
}else {
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}
Project project = getProject(stateContext);
log.info("预审申报事件之前,项目的状态为:{}", project.getStatus());
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

private void preWithDrawChoice(StateContext<ProjectStatusEnum, ProjectStatusChangeEvent> stateContext) {
Project project = getProject(stateContext);
log.info("预审中撤回事件之前,项目的状态为:{}", project.getStatus());
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

private Project getProject(StateContext<ProjectStatusEnum, ProjectStatusChangeEvent> stateContext) {
Project project = stateContext.getMessage().getHeaders().get(PROJECT_DECLARE, Project.class);
log.info("预审中撤回事件之前,项目的状态为:{}"+project.getStatus());
if (StateMachineUtils.isCityProject(project) && StateMachineUtils.judgeDeclareAmount(project,
ProjectDeclareConst.Number.DECLARE_AMOUNT_JUDGEMENT)){
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}else {
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}
Assert.notNull(project, "项目信息获取失败%s", JSONUtil.toJsonStr(stateContext.getMessage()));
return project;
}
@SuppressWarnings("unchecked")
private List<ProjectApplication> getProjectApplication(StateContext<ProjectStatusEnum, ProjectStatusChangeEvent> stateContext) {
return stateContext.getMessage().getHeaders().get(APPLICATION_DECLARE, List.class);
}

}

+ 0
- 279
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareJNAction.java Visa fil

@@ -1,279 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* 景宁畲族自治县
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_JN_CODE)
public class ProjectDeclareJNAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}


@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}
@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 0
- 279
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareJYAction.java Visa fil

@@ -1,279 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* 缙云县
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_JY_CODE)
public class ProjectDeclareJYAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}

@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 0
- 279
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareKFBAction.java Visa fil

@@ -1,279 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* 开发区
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_KFQ_CODE)
public class ProjectDeclareKFBAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}

@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 0
- 279
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareLDAction.java Visa fil

@@ -1,279 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* 莲都区
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_LD_CODE)
public class ProjectDeclareLDAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}

@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 0
- 279
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareLQAction.java Visa fil

@@ -1,279 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* ;龙泉市
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_LQ_CODE)
public class ProjectDeclareLQAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "TO_BE_APPROVED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}

@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 0
- 279
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareQTAction.java Visa fil

@@ -1,279 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* 青田县
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_QT_CODE)
public class ProjectDeclareQTAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}

@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 0
- 279
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareQYAction.java Visa fil

@@ -1,279 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* 庆元县
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_QY_CODE)
public class ProjectDeclareQYAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}

@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 0
- 287
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareSCAction.java Visa fil

@@ -1,287 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* 遂昌县
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_SC_CODE)
public class ProjectDeclareSCAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "APPROVED_AFTER_CHOICE")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.APPROVED_AFTER_CHOICE.getCode());
}

@OnTransition(source = "TO_BE_APP_REGISTER", target = "TO_BE_PURCHASED")
public void REGISTER_APP(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}

@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 0
- 279
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareSYAction.java Visa fil

@@ -1,279 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* 松阳县
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_SY_CODE)
public class ProjectDeclareSYAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}

@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 0
- 280
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/ProjectDeclareYHAction.java Visa fil

@@ -1,280 +0,0 @@
package com.hz.pm.api.common.statemachine.action;

import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* 项目申报状态机action集合类
* 云和县
* @author CMM
* @since 2023/02/08 13:48
*/
@Slf4j
@WithStateMachine(id = RegionContant.LS_YH_CODE)
public class ProjectDeclareYHAction {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "PENDING_PREQUALIFICATION")
public void UNDER_INTERNAL_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "UNDER_INTERNAL_AUDIT_NOT_PASS")
public void UNDER_INTERNAL_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT", target = "TO_BE_DECLARED")
public void UNDER_INTERNAL_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_DECLARED.getCode());
}

@OnTransition(source = "UNDER_INTERNAL_AUDIT_NOT_PASS", target = "UNDER_INTERNAL_AUDIT")
public void UNDER_INTERNAL_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "PENDING_PREQUALIFICATION", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PENDING_PREQUALIFICATION", target = "UNDER_INTERNAL_AUDIT")
public void PENDING_PREQUALIFICATION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode());
}


@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS")
public void PROVINCIAL_DEPARTMENT_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS", target = "PRE_APPLYING")
public void PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED")
public void PROVINCIAL_DEPARTMENT_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode());
}

@OnTransition(source = "JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS", target = "PENDING_PREQUALIFICATION")
public void JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "DEPARTMENT_JOINT_REVIEW")
public void PRELIMINARY_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_FAILED")
public void PRELIMINARY_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode());
}

@OnTransition(source = "PREQUALIFICATION_FAILED", target = "PENDING_PREQUALIFICATION_CHOICE")
public void PRELIMINARY_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE.getCode());
}

@OnTransition(source = "PRE_APPLYING", target = "PREQUALIFICATION_WITHDRAW_CHOICE")
public void PRE_APPLYING_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE.getCode());
}


@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "IN_THE_ANNUAL_PLAN")
public void DEPARTMENT_UNITED_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "DEPARTMENT_JOINT_REVIEW_FAILED")
public void DEPARTMENT_UNITED_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED.getCode());
}

@OnTransition(source = "DEPARTMENT_JOINT_REVIEW", target = "PRE_APPLYING")
public void DEPARTMENT_JOINT_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PRE_APPLYING.getCode());
}


@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "PLAN_TO_BE_DECLARED")
public void ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "BE_SUSPENDED")
public void ANNUAL_PLAN_SUSPEND(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.BE_SUSPENDED.getCode());
}

@OnTransition(source = "IN_THE_ANNUAL_PLAN", target = "DEPARTMENT_JOINT_REVIEW")
public void IN_THE_ANNUAL_PLAN_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode());
}


@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "PLAN_TO_BE_DECLARED", target = "IN_THE_ANNUAL_PLAN")
public void PLAN_TO_DECLARE_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void DECLARE_PLAN_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "TO_BE_APPROVED")
public void PLAN_REVIEW_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "SCHEME_REVIEW_FAILED")
public void PLAN_REVIEW_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode());
}

@OnTransition(source = "SCHEME_REVIEW_FAILED", target = "SCHEME_UNDER_REVIEW")
public void PLAN_REVIEW_REJECT_RESUBMIT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}

@OnTransition(source = "SCHEME_UNDER_REVIEW", target = "PLAN_TO_BE_DECLARED")
public void SCHEME_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode());
}


@OnTransition(source = "TO_BE_APPROVED", target = "TO_BE_PURCHASED")
public void PROJECT_APPROVAL(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待立项批复批复后,项目一级状态变更为已立项
project.setStage(ProjectStatusEnum.PROJECT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}

@OnTransition(source = "TO_BE_APPROVED", target = "SCHEME_UNDER_REVIEW")
public void TO_BE_APPROVED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode());
}


@OnTransition(source = "TO_BE_PURCHASED", target = "OPERATION")
public void PURCHASE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.OPERATION.getCode());
}

@OnTransition(source = "OPERATION", target = "UNDER_CONSTRUCTION")
public void START_TO_WORK(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}

@OnTransition(source = "TO_BE_PURCHASED", target = "TO_BE_APPROVED")
public void TO_BE_PURCHASED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 待采购状态撤回后,项目一级状态回退到未立项
project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode());
project.setStatus(ProjectStatusEnum.TO_BE_APPROVED.getCode());
}


@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_FINALLY_INSPECTED")
public void PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());
}

@OnTransition(source = "UNDER_CONSTRUCTION", target = "TO_BE_PURCHASED")
public void UNDER_CONSTRUCTION_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.TO_BE_PURCHASED.getCode());
}


@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "TO_BE_FINALLY_INSPECTED", target = "UNDER_CONSTRUCTION")
public void TO_BE_FINALLY_INSPECTED_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode());
}


@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "ARCHIVED")
public void FINAL_ACCEPTANCE_PASS(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
// 终验审核通过后,项目一级状态变更为已归档
project.setStage(ProjectStatusEnum.ARCHIVED.getCode());
project.setStatus(ProjectStatusEnum.ACCEPTED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_REVIEW_FAILED")
public void FINAL_ACCEPTANCE_REJECT(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}

@OnTransition(source = "FINAL_ACCEPTANCE_REVIEW_FAILED", target = "FINAL_ACCEPTANCE_IS_UNDER_REVIEW")
public void FINAL_RE_ACCEPTANCE_APPLICATION(Message<ProjectStatusChangeEvent> message) {
Project project = (Project) message.getHeaders().get(PROJECT_DECLARE);
project.setStatus(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW.getCode());
}
}

+ 3
- 1
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineBuilder.java Visa fil

@@ -14,10 +14,11 @@ import org.springframework.statemachine.persist.StateMachinePersister;
* @since 2023/02/07 15:56
*/
public interface ProjectDeclareStateMachineBuilder {

StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception;
/**
* 构建状态机
* @param beanFactory
* @param beanFactory \
* @author CMM
* @since 2023/02/07 16:15
*/
@@ -29,4 +30,5 @@ public interface ProjectDeclareStateMachineBuilder {
* @since 2023/02/07 16:22
*/
StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister();

}

hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineSBJBuilder.java → hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineBuilderImpl.java Visa fil

@@ -1,14 +1,12 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory.PendingPreQualificationChoiceGuard;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
@@ -26,32 +24,31 @@ import java.util.EnumSet;
/**
* 项目申报状态机
* 市本级
*
* @author CMM
* @since 2023/02/07 15:56
*/
@Slf4j
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineSBJBuilder.MACHINEID_TO)
@EnableStateMachine(name = ProjectDeclareStateMachineBuilderImpl.MACHINE_ID)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineSBJBuilder implements ProjectDeclareStateMachineBuilder {
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;
public class ProjectDeclareStateMachineBuilderImpl implements ProjectDeclareStateMachineBuilder {

private StateMachinePersister stateMachinePersister;
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_SBJ_CODE;
public static final String MACHINE_ID = "projectDeclareStateMachine";

private final BeanFactory beanFactory;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
log.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}

/**
* 构建状态机
*
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
@@ -61,7 +58,7 @@ public class ProjectDeclareStateMachineSBJBuilder implements ProjectDeclareState
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.machineId(MACHINE_ID)
.beanFactory(beanFactory);

builder.configureStates()
@@ -101,8 +98,8 @@ public class ProjectDeclareStateMachineSBJBuilder implements ProjectDeclareState
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS, new PendingPreQualificationChoiceGuard(), new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING, new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
@@ -143,9 +140,9 @@ public class ProjectDeclareStateMachineSBJBuilder implements ProjectDeclareState
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS, new PendingPreQualificationChoiceGuard()
, new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION, new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
@@ -154,8 +151,8 @@ public class ProjectDeclareStateMachineSBJBuilder implements ProjectDeclareState
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS, new PendingPreQualificationChoiceGuard(), new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING, new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
@@ -257,29 +254,25 @@ public class ProjectDeclareStateMachineSBJBuilder implements ProjectDeclareState

/**
* 持久化配置
*
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineSBJPersister")
@Bean(name = "projectDeclareStatePersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
return new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
log.info("当前项目为:{}", contextObj);
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_SBJ_CODE);
return result;
return new DefaultStateMachineContext<>(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, MACHINE_ID);
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 284
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineJNBuilder.java Visa fil

@@ -1,284 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 景宁畲族自治县
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineJNBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineJNBuilder implements ProjectDeclareStateMachineBuilder{
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;
private Logger logger = LoggerFactory.getLogger(getClass());

private StateMachinePersister stateMachinePersister;
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_JN_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()
// 年度计划中开启方案申报,从年度计划中到方案待申报
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()
// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineJNPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_JN_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 285
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineJYBuilder.java Visa fil

@@ -1,285 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 缙云县
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineJYBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineJYBuilder implements ProjectDeclareStateMachineBuilder {
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;
private Logger logger = LoggerFactory.getLogger(getClass());

private StateMachinePersister stateMachinePersister;
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_JY_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()
// 年度计划中开启方案申报,从年度计划中到方案待申报
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()

// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineJYPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_JY_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 285
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineKFQBuilder.java Visa fil

@@ -1,285 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 开发区
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineKFQBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineKFQBuilder implements ProjectDeclareStateMachineBuilder {
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;
private Logger logger = LoggerFactory.getLogger(getClass());

private StateMachinePersister stateMachinePersister;
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_KFQ_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()
// 年度计划中开启方案申报,从年度计划中到方案待申报
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()

// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineKFQPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_KFQ_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 285
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineLDBuilder.java Visa fil

@@ -1,285 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 莲都区
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineLDBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineLDBuilder implements ProjectDeclareStateMachineBuilder {
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;

private StateMachinePersister stateMachinePersister;
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_LD_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()
// 年度计划中开启方案申报,从年度计划中到方案待申报
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()

// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineLDPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_LD_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 286
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineLQBuilder.java Visa fil

@@ -1,286 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 龙泉市
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineLQBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineLQBuilder implements ProjectDeclareStateMachineBuilder {
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;

private StateMachinePersister stateMachinePersister;
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_LQ_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()

// 年度计划中开启方案申报,从年度计划中到立项批复
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()

// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineLQPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_LQ_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 285
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineQTBuilder.java Visa fil

@@ -1,285 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 青田县
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineQTBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineQTBuilder implements ProjectDeclareStateMachineBuilder {
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;

private StateMachinePersister stateMachinePersister;
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_QT_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()
// 年度计划中开启方案申报,从年度计划中到方案待申报
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()

// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineQTPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_QT_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 285
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineQYBuilder.java Visa fil

@@ -1,285 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 庆元县
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineQYBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineQYBuilder implements ProjectDeclareStateMachineBuilder {
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;

private StateMachinePersister stateMachinePersister;
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_QY_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()
// 年度计划中开启方案申报,从年度计划中到方案待申报
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()

// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineQYPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_QY_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 295
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineSCBuilder.java Visa fil

@@ -1,295 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 遂昌县
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineSCBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineSCBuilder implements ProjectDeclareStateMachineBuilder{
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;

private StateMachinePersister stateMachinePersister;
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_SC_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.choice(ProjectStatusEnum.APPROVED_AFTER_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()
// 年度计划中开启方案申报,从年度计划中到方案待申报
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.APPROVED_AFTER_CHOICE)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
.withChoice()
.source(ProjectStatusEnum.APPROVED_AFTER_CHOICE)
.first(ProjectStatusEnum.TO_BE_APP_REGISTER,projectDeclareGuardFactory.new ApprovedAfterChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.TO_BE_PURCHASED,new ProjectDeclareChoiceAction()).and()
//待所有应用都注册 并且 绑定了关系后 再进入下一状态 待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APP_REGISTER)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.REGISTER_APP).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()

// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineSCPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_SC_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 285
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineSYBuilder.java Visa fil

@@ -1,285 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 松阳县
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineSYBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineSYBuilder implements ProjectDeclareStateMachineBuilder {
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;

private StateMachinePersister stateMachinePersister;
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_SY_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()
// 年度计划中开启方案申报,从年度计划中到方案待申报
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()

// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineSYPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_SY_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 285
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineYHBuilder.java Visa fil

@@ -1,285 +0,0 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.action.ProjectDeclareChoiceAction;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.common.statemachine.factory.ProjectDeclareGuardFactory;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* 项目申报状态机
* 云和县
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@EnableStateMachine(name= ProjectDeclareStateMachineYHBuilder.MACHINEID_TO)
@RequiredArgsConstructor
public class ProjectDeclareStateMachineYHBuilder implements ProjectDeclareStateMachineBuilder {
private static final ProjectDeclareGuardFactory projectDeclareGuardFactory = new ProjectDeclareGuardFactory();
private final BeanFactory beanFactory;

private StateMachinePersister stateMachinePersister;
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* TO状态机
*/
public final static String MACHINEID_TO = RegionContant.LS_YH_CODE;

@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build() throws Exception {
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = build(beanFactory);
logger.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}
/**
* 构建状态机
* @param beanFactory
* @author CMM
* @since 2023/02/07 16:15
*/
@Override
public StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> build(BeanFactory beanFactory) throws Exception {
StateMachineBuilder.Builder<ProjectStatusEnum, ProjectStatusChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINEID_TO)
.beanFactory(beanFactory);

builder.configureStates()
.withStates()
.initial(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.choice(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.choice(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.states(EnumSet.allOf(ProjectStatusEnum.class));

builder.configureTransitions()
// 单位内部审核通过,从单位内部审核中到待预审
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_PASS).and()
// 单位内部审核驳回,从单位内部审核中到单位内部审核不通过
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT).and()
// 单位内部审核中撤回,从单位内部审核中到待申报
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.target(ProjectStatusEnum.TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_WITHDRAW).and()
// 单位内部审核不通过重新提交,从单位内部审核不通过到单位内部审核中
.withExternal()
.source(ProjectStatusEnum.UNDER_INTERNAL_AUDIT_NOT_PASS)
.target(ProjectStatusEnum.UNDER_INTERNAL_AUDIT)
.event(ProjectStatusChangeEvent.UNDER_INTERNAL_REJECT_RESUBMIT).and()

// 待预审预审申报,从待预审到待预审选择
.withExternal()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_DECLARE).and()
// 待预审申报,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()

// 省级部门联审通过,从省级部门联审中到省级部门联审成功
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_PASS).and()
// 省级部门联审通过,从省级部门联审成功到预审中
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.PROVINCIAL_PASS_TO_PRELIMINARY_REVIEW).and()
// 省级部门联审不通过,从省级部门联审中到省级部门联审不通过
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED)
.event(ProjectStatusChangeEvent.PROVINCIAL_DEPARTMENT_REVIEW_REJECT).and()
// 省级部门联审中撤回,从省级部门联审中到待预审
.withExternal()
.source(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION)
.event(ProjectStatusChangeEvent.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_WITHDRAW).and()

// 预审通过,从预审中到部门联审中
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_PASS).and()
// 预审驳回,从预审中到预审不通过
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT).and()
// 预审中撤回,从预审中到预审中撤回选择态
.withExternal()
.source(ProjectStatusEnum.PRE_APPLYING)
.target(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.event(ProjectStatusChangeEvent.PRE_APPLYING_WITHDRAW).and()
// 预审中撤回,从预审中撤回选择态->省级部门联审成功,待预审,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PREQUALIFICATION_WITHDRAW_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard()
,new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PENDING_PREQUALIFICATION,new ProjectDeclareChoiceAction()).and()
// 预审不通过重新提交,从预审不通过到待预审选择
.withExternal()
.source(ProjectStatusEnum.PREQUALIFICATION_FAILED)
.target(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.event(ProjectStatusChangeEvent.PRELIMINARY_REVIEW_REJECT_RESUBMIT).and()
// 预审不通过重新提交,从待预审选择->省级部门联审中,预审中,完成其中一种状态
.withChoice()
.source(ProjectStatusEnum.PENDING_PREQUALIFICATION_CHOICE)
.first(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,projectDeclareGuardFactory.new PendingPreQualificationChoiceGuard(),new ProjectDeclareChoiceAction())
.last(ProjectStatusEnum.PRE_APPLYING,new ProjectDeclareChoiceAction()).and()
// 部门联审通过,从部门联审中到年度计划中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS).and()
// 部门联审驳回,从部门联审中到部门联审不通过
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_REJECT).and()
// 部门联审中撤回,从部门联审中到预审中
.withExternal()
.source(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW)
.target(ProjectStatusEnum.PRE_APPLYING)
.event(ProjectStatusChangeEvent.DEPARTMENT_JOINT_REVIEW_WITHDRAW).and()
// 年度计划中开启方案申报,从年度计划中到方案待申报
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE).and()
// 年度计划中暂缓,从年度计划中到被暂缓
.withExternal()
.source(ProjectStatusEnum.IN_THE_ANNUAL_PLAN)
.target(ProjectStatusEnum.BE_SUSPENDED)
.event(ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND).and()
// 方案待申报申报方案,从方案待申报到方案评审中
.withExternal()
.source(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.DECLARE_PLAN).and()
// 方案评审通过,从方案评审中到待立项批复
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.TO_BE_APPROVED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_PASS).and()
// 方案评审驳回,从方案评审中到方案评审不通过
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT).and()
// 方案评审中撤回,从方案评审中到方案待申报
.withExternal()
.source(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.target(ProjectStatusEnum.PLAN_TO_BE_DECLARED)
.event(ProjectStatusChangeEvent.SCHEME_UNDER_REVIEW_WITHDRAW).and()
// 方案评审不通过重新提交,从方案评审不通过到方案评审中
.withExternal()
.source(ProjectStatusEnum.SCHEME_REVIEW_FAILED)
.target(ProjectStatusEnum.SCHEME_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.PLAN_REVIEW_REJECT_RESUBMIT).and()
// 待立项批复批复,从待立项批复到待采购
.withExternal()
.source(ProjectStatusEnum.TO_BE_APPROVED)
.target(ProjectStatusEnum.TO_BE_PURCHASED)
.event(ProjectStatusChangeEvent.PROJECT_APPROVAL).and()
// 待采购采购备案,从待采购到实施中
.withExternal()
.source(ProjectStatusEnum.TO_BE_PURCHASED)
.target(ProjectStatusEnum.OPERATION)
.event(ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD).and()

// 待开工 实施,从实施到建设中
.withExternal()
.source(ProjectStatusEnum.OPERATION)
.target(ProjectStatusEnum.UNDER_CONSTRUCTION)
.event(ProjectStatusChangeEvent.START_TO_WORK).and()
// 建设中初验备案,从建设中到待终验
.withExternal()
.source(ProjectStatusEnum.UNDER_CONSTRUCTION)
.target(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.event(ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD).and()
// 待终验终验申请,从待终验到终验审核中
.withExternal()
.source(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_APPLICATION).and()
// 终审审核通过,从终审审核中到已归档
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.ARCHIVED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS).and()
// 终审审核不通过,从终审审核中到终审审核不通过
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_REJECT).and()
// 终审审核中撤回,从终审审核中到待终验
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_ACCEPTANCE_IS_UNDER_REVIEW_WITHDRAW).and()
// 终验中 重新提交
.withExternal()
.source(ProjectStatusEnum.FINAL_ACCEPTANCE_REVIEW_FAILED)
.target(ProjectStatusEnum.FINAL_ACCEPTANCE_IS_UNDER_REVIEW)
.event(ProjectStatusChangeEvent.FINAL_RE_ACCEPTANCE_APPLICATION).and();
return builder.build();
}

/**
* 持久化配置
* @author CMM
* @since 2023/02/07 16:22
*/
@Bean(name = "projectDeclareStateMachineYHPersister")
@Override
public StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> getProjectPersister() {
StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist<ProjectStatusEnum, ProjectStatusChangeEvent, Project>() {
@Override
public void write(StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> context, Project contextObj) {
}

@Override
public StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> read(Project contextObj) {
StateMachineContext<ProjectStatusEnum, ProjectStatusChangeEvent> result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()),
null, null, null, null, RegionContant.LS_YH_CODE);
return result;
}
});
stateMachinePersister = sp;
return sp;
}

public StateMachinePersister getStateMachinePersister(){
return stateMachinePersister;
}
}

+ 0
- 34
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/contant/RegionContant.java Visa fil

@@ -1,34 +0,0 @@
package com.hz.pm.api.common.statemachine.contant;

/**
* @Classname RegionContant
* @Description
* @Date 2023/6/13 13:57
* @Author PoffyZhang
*/
public class RegionContant {
//市本级
public static final String LS_SBJ_CODE = "331100";
//莲都区
public static final String LS_LD_CODE = "331102";
//青田县
public static final String LS_QT_CODE = "331121";
//缙云县
public static final String LS_JY_CODE = "331122";
//遂昌县
public static final String LS_SC_CODE = "331123";
//松阳县
public static final String LS_SY_CODE = "331124";
//云和县
public static final String LS_YH_CODE = "331125";
//庆元县
public static final String LS_QY_CODE = "331126";
//景宁畲族自治县
public static final String LS_JN_CODE = "331127";
//龙泉市
public static final String LS_LQ_CODE = "331181";
//开发区
public static final String LS_KFQ_CODE = "331199";

public static final String MORE_CODE = "000";
}

+ 2
- 37
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/ProjectDeclareGuardFactory.java Visa fil

@@ -1,21 +1,10 @@
package com.hz.pm.api.common.statemachine.factory;

import cn.hutool.core.collection.CollUtil;
import com.hz.pm.api.common.model.constant.ProjectDeclareConst;
import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.enumeration.CommonEnum;
import com.hz.pm.api.common.statemachine.util.StateMachineUtils;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectApplication;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.guard.Guard;

import java.util.List;

import static com.hz.pm.api.common.model.constant.StateMachineConst.APPLICATION_DECLARE;

/**
* 项目申报状态机guard集合类
*
@@ -24,37 +13,13 @@ import static com.hz.pm.api.common.model.constant.StateMachineConst.APPLICATION_
*/

public class ProjectDeclareGuardFactory {
private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

public class PendingPreQualificationChoiceGuard implements Guard<ProjectStatusEnum, ProjectStatusChangeEvent> {
public static class PendingPreQualificationChoiceGuard implements Guard<ProjectStatusEnum, ProjectStatusChangeEvent> {
@Override
public boolean evaluate(StateContext<ProjectStatusEnum, ProjectStatusChangeEvent> context) {
Project project = context.getMessage().getHeaders().get(PROJECT_DECLARE, Project.class);
// 判断申报项目是否是市级项目,且申报金额是否大于等于1000万元
if (StateMachineUtils.isCityProject(project) && StateMachineUtils.judgeDeclareAmount(project,
ProjectDeclareConst.Number.DECLARE_AMOUNT_JUDGEMENT)){
return true;
}
return false;
return true;
}
}

public class ApprovedAfterChoiceGuard implements Guard<ProjectStatusEnum, ProjectStatusChangeEvent> {
@Override
public boolean evaluate(StateContext<ProjectStatusEnum, ProjectStatusChangeEvent> context) {
List<ProjectApplication> projectApplications = context.getMessage().getHeaders().get(APPLICATION_DECLARE, List.class);
final Boolean[] res = {Boolean.FALSE};
// 判断 是否有初次创建的应用
if (CollUtil.isEmpty(projectApplications)){
return res[0];
}
projectApplications.stream().forEach(app -> {
Integer isFirst = app.getIsFirst();
if(isFirst.equals(CommonEnum.YES.getCode())){
res[0] = Boolean.TRUE;
}
});
return res[0];
}
}
}

+ 0
- 73
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/MachineBuilderFounder.java Visa fil

@@ -1,73 +0,0 @@
package com.hz.pm.api.common.statemachine.util;

import com.google.common.collect.Maps;
import com.hz.pm.api.common.statemachine.builder.*;
import com.hz.pm.api.common.statemachine.contant.RegionContant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Map;

/**
* 项目申报状态机
*
* @author CMM
* @since 2023/02/07 15:56
*/
@Component
@Slf4j
public class MachineBuilderFounder {

public final static Map<String,ProjectDeclareStateMachineBuilder> machineBuilderMap =
Maps.newConcurrentMap();

@Autowired
private ProjectDeclareStateMachineSBJBuilder projectDeclareStateMachineSBJBuilder;

@Autowired
private ProjectDeclareStateMachineLDBuilder projectDeclareStateMachineLDBuilder;

@Autowired
private ProjectDeclareStateMachineQTBuilder projectDeclareStateMachineQTBuilder;

@Autowired
private ProjectDeclareStateMachineJYBuilder projectDeclareStateMachineJYBuilder;

@Autowired
private ProjectDeclareStateMachineSCBuilder projectDeclareStateMachineSCBuilder;

@Autowired
private ProjectDeclareStateMachineSYBuilder projectDeclareStateMachineSYBuilder;

@Autowired
private ProjectDeclareStateMachineYHBuilder projectDeclareStateMachineYHBuilder;

@Autowired
private ProjectDeclareStateMachineQYBuilder projectDeclareStateMachineQYBuilder;

@Autowired
private ProjectDeclareStateMachineJNBuilder projectDeclareStateMachineJNBuilder;

@Autowired
private ProjectDeclareStateMachineLQBuilder projectDeclareStateMachineLQBuilder;

@Autowired
private ProjectDeclareStateMachineKFQBuilder projectDeclareStateMachineKFQBuilder;

@PostConstruct
public void MachineBuilderFounder(){
machineBuilderMap.put(RegionContant.LS_SBJ_CODE, projectDeclareStateMachineSBJBuilder);
machineBuilderMap.put(RegionContant.LS_LD_CODE, projectDeclareStateMachineLDBuilder);
machineBuilderMap.put(RegionContant.LS_QT_CODE, projectDeclareStateMachineQTBuilder);
machineBuilderMap.put(RegionContant.LS_JY_CODE, projectDeclareStateMachineJYBuilder);
machineBuilderMap.put(RegionContant.LS_SC_CODE, projectDeclareStateMachineSCBuilder);
machineBuilderMap.put(RegionContant.LS_SY_CODE, projectDeclareStateMachineSYBuilder);
machineBuilderMap.put(RegionContant.LS_YH_CODE, projectDeclareStateMachineYHBuilder);
machineBuilderMap.put(RegionContant.LS_QY_CODE, projectDeclareStateMachineQYBuilder);
machineBuilderMap.put(RegionContant.LS_JN_CODE, projectDeclareStateMachineJNBuilder);
machineBuilderMap.put(RegionContant.LS_LQ_CODE, projectDeclareStateMachineLQBuilder);
machineBuilderMap.put(RegionContant.LS_KFQ_CODE, projectDeclareStateMachineKFQBuilder);
}
}

hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/StateMachineUtils.java → hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/StateMachineUtil.java Visa fil

@@ -1,16 +1,14 @@
package com.hz.pm.api.common.statemachine.util;

import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.function.VUtils;
import com.hz.pm.api.common.model.constant.RegionConst;
import com.hz.pm.api.common.model.constant.StateMachineConst;
import com.hz.pm.api.common.statemachine.builder.ProjectDeclareStateMachineBuilder;
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.service.INdProjectStatusChangeService;
import com.hz.pm.api.projectlib.service.IProjectApplicationService;
import com.ningdatech.basic.exception.BizException;
import com.wflow.exception.BusinessException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -33,63 +31,64 @@ import java.util.Objects;
@Slf4j
@Component
@RequiredArgsConstructor
public class StateMachineUtils {
public class StateMachineUtil {

private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE;

private static final String APPLICATION_DECLARE = StateMachineConst.APPLICATION_DECLARE;

//==================================================================================================================

private final ProjectDeclareStateMachineBuilder projectDeclareStateMachineBuilder;

private final INdProjectStatusChangeService projectStatusChangeService;

private final IProjectApplicationService projectApplicationService;

//通过审核
public void pass(Project project) {
try{
execute(project,getProjectStatusPassEvent(project.getStatus()));
}catch (Exception e){
log.info("状态机 通过失败 :{}",e.getMessage());
try {
execute(project, getProjectStatusPassEvent(project.getStatus()));
} catch (Exception e) {
log.info("状态机 通过失败 :{}", e.getMessage());
throw new BusinessException("状态机 通过失败: " + e);
}
}

//拒绝
public void reject(Project project) {
try{
execute(project,getProjectStatusRejectEvent(project.getStatus()));
}catch (Exception e){
log.info("状态机 拒绝失败 :{}",e.getMessage());
try {
execute(project, getProjectStatusRejectEvent(project.getStatus()));
} catch (Exception e) {
log.info("状态机 拒绝失败 :{}", e.getMessage());
throw new BusinessException("状态机 拒绝失败: " + e);
}
}

//撤回
public void withDraw(Project project) {
try{
execute(project,getProjectStatusWithdrawEvent(project.getStatus()));
}catch (Exception e){
log.info("状态机 撤回失败 :{}",e.getMessage());
try {
execute(project, getProjectStatusWithdrawEvent(project.getStatus()));
} catch (Exception e) {
log.info("状态机 撤回失败 :{}", e.getMessage());
throw new BusinessException("状态机 撤回失败: " + e);
}
}

public void execute(Project project, ProjectStatusChangeEvent event) throws Exception {
log.info("调用状态机前的项目状态为>>>>>>>>>>{}" + project.getStatus());
log.info("调用状态机前的项目状态为:{}", project.getStatus());
// 将状态变更记录保存到项目状态变更表中
ProjectStatusChange projectStatusChange = new ProjectStatusChange();
projectStatusChange.setBeforeStatus(project.getStatus());

ProjectDeclareStateMachineBuilder builder = MachineBuilderFounder.machineBuilderMap.get(project.getAreaCode());

VUtils.isTrue(Objects.isNull(builder)).throwMessage("状态机初始化失败!");
//获取TO状态机
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = builder.build();
Message message = MessageBuilder.withPayload(event)
// 获取TO状态机
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = projectDeclareStateMachineBuilder.build();
Message<ProjectStatusChangeEvent> message = MessageBuilder.withPayload(event)
.setHeader(PROJECT_DECLARE, project)
.setHeader(APPLICATION_DECLARE,projectApplicationService.getApplicationsByProject(project))
.setHeader(APPLICATION_DECLARE, projectApplicationService.getApplicationsByProject(project))
.build();
//初始化状态机
StateMachinePersister projectDeclareStateMachinePersister = builder.getProjectPersister();
StateMachinePersister<ProjectStatusEnum, ProjectStatusChangeEvent, Project> projectDeclareStateMachinePersister = projectDeclareStateMachineBuilder.getProjectPersister();
projectDeclareStateMachinePersister.restore(stateMachine, project);
stateMachine.sendEvent(message);
projectStatusChange.setProjectId(project.getId());
@@ -99,39 +98,19 @@ public class StateMachineUtils {
projectStatusChange.setProjectCode(project.getProjectCode());
// 插入项目状态变更表中
projectStatusChangeService.save(projectStatusChange);
log.info("调用状态机后的项目状态为>>>>>>>>>>{}" + project.getStatus());
log.info("调用状态机后的项目状态为:{}", project.getStatus());
}

/**
* 判断项目申报金额是否大于1000万元
*
* @param project
* @param project \
* @return boolean
* @author CMM
* @since 2023/02/07 17:13
*/
public static boolean judgeDeclareAmount(Project project, BigDecimal targetAmount) {
int flag = project.getDeclareAmount().compareTo(targetAmount);
if (flag > 0 || flag == 0) {
return true;
}
return false;
}

/**
* 判断申报项目是否为市级项目
*
* @param project
* @return boolean
* @author CMM
* @since 2023/02/07 17:05
*/
public static boolean isCityProject(Project project) {
String areaCode = project.getAreaCode();
if (areaCode.equals(RegionConst.RC_LS)) {
return true;
}
return false;
return flag > 0 || flag == 0;
}

public ProjectStatusChangeEvent getProjectStatusPassEvent(Integer status) {
@@ -157,4 +136,5 @@ public class StateMachineUtils {
}
return event;
}

}

+ 0
- 13
hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java Visa fil

@@ -66,19 +66,6 @@ public class BizUtils {
}
}

public static boolean getJSONType(String str) {
boolean result = false;
if (StringUtils.isNotBlank(str)) {
str = str.trim();
if (str.startsWith("{") && str.endsWith("}")) {
result = true;
} else if (str.startsWith("[") && str.endsWith("]")) {
result = true;
}
}
return result;
}

public static String uuid32() {
return UUID.randomUUID().toString().replace("-", "");
}


+ 2
- 4
hz-pm-api/src/main/java/com/hz/pm/api/common/util/FreemarkerWordUtil.java Visa fil

@@ -66,10 +66,8 @@ public class FreemarkerWordUtil {
//输出文件
File outFile = new File(filePath + File.separator + fileName);
//如果输出目标文件夹不存在,则创建
if (!outFile.getParentFile().exists()) {
if (outFile.getParentFile().mkdirs()) {
log.info("创建文件目录:{}", outFile.getParentFile().getAbsolutePath());
}
if (!outFile.getParentFile().exists() && (outFile.getParentFile().mkdirs())) {
log.info("创建文件目录:{}", outFile.getParentFile().getAbsolutePath());
}
//将模板和数据模型合并生成文件
Writer out = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(outFile.toPath()), StandardCharsets.UTF_8));


+ 2
- 2
hz-pm-api/src/main/java/com/hz/pm/api/common/util/HmacAuthUtil.java Visa fil

@@ -58,12 +58,12 @@ public class HmacAuthUtil {
String[] params = query.split("&");
for (String param : params) {
String[] keyValue = param.split("=");
Pair<String, String> pair = new Pair<String, String>(keyValue[0], keyValue.length > 1 ? keyValue[1] : "");
Pair<String, String> pair = new Pair<>(keyValue[0], keyValue.length > 1 ? keyValue[1] : "");
queryParamList.add(pair);
}
List<Pair<String, String>> sortedParamList = queryParamList.stream().sorted(Comparator.comparing(param -> param.getKey() + "=" + Optional.ofNullable(param.getValue()).orElse(""))).collect(Collectors.toList());
List<Pair<String, String>> encodeParamList = new ArrayList<>();
sortedParamList.stream().forEach(param -> {
sortedParamList.forEach(param -> {
try {
String key = URLEncoder.encode(param.getKey(), "utf-8");
String value = URLEncoder.encode(Optional.ofNullable(param.getValue()).orElse(""), "utf-8");


+ 0
- 91
hz-pm-api/src/main/java/com/hz/pm/api/common/util/JwtTokenUtil.java Visa fil

@@ -1,91 +0,0 @@
package com.hz.pm.api.common.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.hz.pm.api.common.model.ZwddTokenUser;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
* @author liuxinxin
* @date 2023/5/4 下午2:34
*/

public class JwtTokenUtil {

private static final String SECRET_KEY = "dbe1cc89019c4c7abd5085bf47a25fb0";

private static final String CLAIM_KEY = "content";

private static final Integer DEFAULT_EXPIRE_TIME = Integer.valueOf(86400);

public static String createToken(ZwddTokenUser dingTokenUser) {
return createToken(dingTokenUser, DEFAULT_EXPIRE_TIME);
}

public static String createToken(ZwddTokenUser dingTokenUser, Integer expireTime) {
if (dingTokenUser == null) {
throw new IllegalArgumentException("");
}
if (dingTokenUser.getTenantId() == null) {
throw new IllegalArgumentException("");
}
if (StringUtils.isEmpty(dingTokenUser.getEmployeeCode())) {
throw new IllegalArgumentException("");
}
if (dingTokenUser.getTenantId() == null) {
throw new IllegalArgumentException("");
}
return createToken(JSON.toJSONString(dingTokenUser), expireTime);
}

private static String createToken(String content, Integer expireTime) {
if (StringUtils.isEmpty(content)) {
throw new IllegalArgumentException("");
}
Map<String, Object> header = new HashMap<>(4);
header.put("alg", "HS256");
header.put("typ", "JWT");
Algorithm algorithm = Algorithm.HMAC256(SECRET_KEY);
return JWT.create()
.withHeader(header)
.withClaim("content", content)
.withIssuedAt(new Date())
.withExpiresAt(new Date(System.currentTimeMillis() + (expireTime.intValue() * 1000)))
.sign(algorithm);
}

public static boolean verifyToken(String token) {
if (StringUtils.isEmpty(token)) {
throw new IllegalArgumentException("token");
}
Algorithm algorithm = Algorithm.HMAC256(SECRET_KEY);
JWTVerifier verifier = JWT.require(algorithm).build();
verifier.verify(token);
return true;
}

private static String parseJwtString(String token) {
if (StringUtils.isEmpty(token)) {
throw new IllegalArgumentException("token");
}
Algorithm algorithm = Algorithm.HMAC256(SECRET_KEY);
JWTVerifier verifier = JWT.require(algorithm).build();
return verifier.verify(token).getClaim("content").asString();
}

public static ZwddTokenUser parseJwt(String token) {
String dingUserJson = parseJwtString(token);
if (StringUtils.isEmpty(dingUserJson)) {
return null;
}
ZwddTokenUser dingTokenUser = (ZwddTokenUser) JSONObject.parseObject(dingUserJson, ZwddTokenUser.class);
return dingTokenUser;
}
}

+ 3
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/util/MDCUtil.java Visa fil

@@ -12,6 +12,9 @@ import org.slf4j.MDC;
**/
public class MDCUtil {

private MDCUtil() {
}

public static final String TRACE_ID = "traceId";
public static final String TRACE_ID_HEADER = "Trace-Id";



+ 30
- 23
hz-pm-api/src/main/java/com/hz/pm/api/common/util/SendWorkNoticeUtil.java Visa fil

@@ -1,15 +1,16 @@
package com.hz.pm.api.common.util;

import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.GenericResult;
import com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo;
import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.zwdd.client.ZwddClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadPoolExecutor;

/**
* 异步发送工作通知工具类
@@ -18,8 +19,8 @@ import java.util.concurrent.*;
* @since 2023/02/23 13:50
*/
@Slf4j
@RequiredArgsConstructor
@Component
@RequiredArgsConstructor
public class SendWorkNoticeUtil {

private final ZwddClient zwddClient;
@@ -27,10 +28,21 @@ public class SendWorkNoticeUtil {
/**
* 初始化线程池
*/
public static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(2, 10,
60, TimeUnit.SECONDS, new ArrayBlockingQueue(10), new ThreadPoolExecutor.AbortPolicy());
public static final ThreadPoolTaskExecutor EXECUTOR;

public Boolean sendWorkNotice(WorkNoticeInfo workNoticeInfo){
static {
EXECUTOR = new ThreadPoolTaskExecutor();
EXECUTOR.setCorePoolSize(2);
EXECUTOR.setMaxPoolSize(4);
EXECUTOR.setQueueCapacity(200);
EXECUTOR.setKeepAliveSeconds(120);
EXECUTOR.setThreadNamePrefix("sendWorkNotice-");
EXECUTOR.setWaitForTasksToCompleteOnShutdown(true);
EXECUTOR.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
EXECUTOR.initialize();
}

public Boolean sendWorkNotice(WorkNoticeInfo workNoticeInfo) {

// 将发送工作通知交给异步任务Future
String msg = workNoticeInfo.getMsg();
@@ -44,23 +56,18 @@ public class SendWorkNoticeUtil {
log.info("异步任务执行完成, " + workNoticeInfo.getBizMsgId() + " 当前线程:" + Thread.currentThread().getName());
long endTime = System.currentTimeMillis();
log.info("方法执行完成返回,耗时:" + (endTime - startTime));
}else {
} else {
return "发送工作通知失败!";
}
return "发送工作通知成功!";
}, threadPool);
String s;
try {
s = future.get();
} catch (Exception e) {
throw new BizException("获取异步线程处理结果失败!");
}
threadPool.shutdown();
while (!threadPool.isTerminated()) {
log.info(s);
return Boolean.FALSE;
}
log.info(s);
return Boolean.TRUE;
}, EXECUTOR);
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
log.error("获取异步线程处理结果失败!", e);
Thread.currentThread().interrupt();
}
return Boolean.TRUE;
}

}

+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/common/util/TreeUtil.java Visa fil

@@ -46,7 +46,7 @@ public final class TreeUtil {
* @param treeList 待转换的集合
* @return 树结构
*/
public static <E extends MenuTreeEntity<E, ? extends Serializable>> List<E> buildTree(List<E> treeList) {
public static <E extends MenuTreeEntity<E>> List<E> buildTree(List<E> treeList) {
if (CollUtil.isEmpty(treeList)) {
return treeList;
}
@@ -71,7 +71,7 @@ public final class TreeUtil {
return trees;
}

private static <E extends MenuTreeEntity<E, ? extends Serializable>>
private static <E extends MenuTreeEntity<E>>
void foreachNodes(List<E> treeList, List<Serializable> selfIdEqSelfParent) {
nodeMap = Maps.newConcurrentMap();
for (E parent : treeList) {
@@ -98,7 +98,7 @@ public final class TreeUtil {
}
}

private static <E extends MenuTreeEntity<E, ? extends Serializable>> void foreachNodesWithTopMenu(List<E> treeList) {
private static <E extends MenuTreeEntity<E>> void foreachNodesWithTopMenu(List<E> treeList) {
for (E parent : treeList) {
Serializable id = parent.getId();
for (E children : treeList) {


+ 2
- 0
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/constant/AnalysisBasicConstant.java Visa fil

@@ -7,6 +7,8 @@ package com.hz.pm.api.dashboard.constant;

public class AnalysisBasicConstant {

private AnalysisBasicConstant() {
}

/**
* 丽水市区域编码


+ 70
- 74
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/handle/CockpitStatsHandler.java Visa fil

@@ -5,13 +5,13 @@ import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.hz.pm.api.common.model.constant.RegionConst;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.dashboard.constant.DashboardConstant;
import com.hz.pm.api.common.model.constant.RegionConst;
import com.hz.pm.api.dashboard.enums.CockpitAppcationTypeEnum;
import com.hz.pm.api.dashboard.model.entity.CockpitApplication;
import com.hz.pm.api.dashboard.model.entity.CockpitStats;
import com.hz.pm.api.dashboard.model.vo.CockpitStatsVO;
import com.hz.pm.api.dashboard.model.vo.CockpitStatsVO.*;
import com.hz.pm.api.dashboard.service.ICockpitStatsService;
import com.hz.pm.api.sys.model.dto.RegionDTO;
import lombok.RequiredArgsConstructor;
@@ -24,6 +24,8 @@ import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;

import static com.hz.pm.api.dashboard.constant.DashboardConstant.CockpitStats.*;

/**
* @Classname CockpitStatsHandler
* @Description
@@ -39,23 +41,23 @@ public class CockpitStatsHandler {

private final ICockpitStatsService cockpitStatsService;

private static final List<Integer> years = Lists.newArrayList(2021,2022,2023,2024,2025);
private static final List<Integer> years = Lists.newArrayList(2021, 2022, 2023, 2024, 2025);

public CockpitStatsVO convertCockpitStats(CockpitStats cockpitStats, String regionCode, Integer year
, List<CockpitApplication> appDatas) {
CockpitStatsVO res = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.class);
CockpitStatsVO res = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.class);

if(Objects.isNull(cockpitStats)){
if (Objects.isNull(cockpitStats)) {
return res;
}
//监测数据
res.setMonitorData(convertMonitor(cockpitStats,regionCode));
res.setMonitorData(convertMonitor(cockpitStats, regionCode));
//专家数据
res.setExpertData(convertExpertData(cockpitStats));
//顶部数据
res.setTopData(convertTopData(cockpitStats));
//地图数据
res.setMapProjectData(convertMapProjectsData(cockpitStats,year));
res.setMapProjectData(convertMapProjectsData(cockpitStats, year));
//项目项目数据
res.setStatusProjectsData(convertStatusProjectsData(cockpitStats));
//项目效益 优秀项目
@@ -69,23 +71,23 @@ public class CockpitStatsHandler {
//最佳/重大应用
res.setAppDatas(convertCockpitApps(appDatas));
//数据质量分数
res.setQualityDatas(convertQualityDatas(year));
res.setQualityDatas(convertQualityData(year));
return res;
}

private List<CockpitStatsVO.QualityData> convertQualityDatas(Integer year) {
List<CockpitStats> datas = cockpitStatsService.list(Wrappers.lambdaQuery(CockpitStats.class)
private List<QualityData> convertQualityData(Integer year) {
List<CockpitStats> dataList = cockpitStatsService.list(Wrappers.lambdaQuery(CockpitStats.class)
.eq(Objects.nonNull(year), CockpitStats::getYear, year)
.eq(Objects.isNull(year), CockpitStats::getYear, DashboardConstant.CockpitStats.NONE_YEAR)
.ne(CockpitStats::getRegionCode,DashboardConstant.CockpitStats.TOTAL)
.eq(Objects.isNull(year), CockpitStats::getYear, NONE_YEAR)
.ne(CockpitStats::getRegionCode, TOTAL)
.orderByAsc(CockpitStats::getRegionCode));

if(CollUtil.isEmpty(datas)){
if (CollUtil.isEmpty(dataList)) {
return Collections.emptyList();
}

return datas.stream().map(d -> {
CockpitStatsVO.QualityData data = new CockpitStatsVO.QualityData();
return dataList.stream().map(d -> {
QualityData data = new QualityData();
data.setRegionCode(d.getRegionCode());
data.setRegionName(d.getRegionName());
data.setQuality(d.getDataQuality());
@@ -105,150 +107,144 @@ public class CockpitStatsHandler {
}

private CockpitStatsVO.PerformanceData convertPerformanceData(CockpitStats cockpitStats) {
CockpitStatsVO.PerformanceData data = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.PerformanceData.class);
CockpitStatsVO.PerformanceData data = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.PerformanceData.class);
data.setPerformanceTops(convertTops(cockpitStats));
return data;
}

private List<CockpitStatsVO.PerformanceTop> convertTops(CockpitStats cockpitStats) {
List<CockpitStatsVO.PerformanceTop> tops = Lists.newArrayList();
tops.add(new CockpitStatsVO.PerformanceTop("一星",cockpitStats.getPerformanceTop1Score(),cockpitStats.getPerformanceTop1Name()));
tops.add(new CockpitStatsVO.PerformanceTop("二星",cockpitStats.getPerformanceTop2Score(),cockpitStats.getPerformanceTop2Name()));
tops.add(new CockpitStatsVO.PerformanceTop("三星",cockpitStats.getPerformanceTop3Score(),cockpitStats.getPerformanceTop3Name()));
tops.add(new CockpitStatsVO.PerformanceTop("四星",cockpitStats.getPerformanceTop4Score(),cockpitStats.getPerformanceTop4Name()));
tops.add(new CockpitStatsVO.PerformanceTop("五星",cockpitStats.getPerformanceTop5Score(),cockpitStats.getPerformanceTop5Name()));
private List<PerformanceTop> convertTops(CockpitStats cockpitStats) {
List<PerformanceTop> tops = Lists.newArrayList();
tops.add(new PerformanceTop("一星", cockpitStats.getPerformanceTop1Score(), cockpitStats.getPerformanceTop1Name()));
tops.add(new PerformanceTop("二星", cockpitStats.getPerformanceTop2Score(), cockpitStats.getPerformanceTop2Name()));
tops.add(new PerformanceTop("三星", cockpitStats.getPerformanceTop3Score(), cockpitStats.getPerformanceTop3Name()));
tops.add(new PerformanceTop("四星", cockpitStats.getPerformanceTop4Score(), cockpitStats.getPerformanceTop4Name()));
tops.add(new PerformanceTop("五星", cockpitStats.getPerformanceTop5Score(), cockpitStats.getPerformanceTop5Name()));
return tops;
}

private CockpitStatsVO.ProduceData convertProduceData(CockpitStats cockpitStats) {
return BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.ProduceData.class);
return BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.ProduceData.class);
}

private CockpitStatsVO.ReduceData convertReduceData(CockpitStats cockpitStats) {
CockpitStatsVO.ReduceData data = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.ReduceData.class);
CockpitStatsVO.ReduceData data = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.ReduceData.class);
data.setAmountComparisonCharts(convertAmountComparisonChart(cockpitStats));
return data;
}

private List<CockpitStatsVO.AmountComparisonChart> convertAmountComparisonChart(CockpitStats cockpitStats) {
List<CockpitStatsVO.AmountComparisonChart> res = Lists.newArrayList();
res.add(new CockpitStatsVO.AmountComparisonChart("申报", cockpitStats.getDeclaredAmountApprove(),cockpitStats.getApprovalAmountApprove(),cockpitStats.getDifferenceApprove()));
res.add(new CockpitStatsVO.AmountComparisonChart("批复", cockpitStats.getDeclaredAmountApproval(),cockpitStats.getApprovalAmountApproval(),cockpitStats.getDifferenceApproval()));
res.add(new CockpitStatsVO.AmountComparisonChart("合同", cockpitStats.getDeclaredAmountContract(),cockpitStats.getApprovalAmountContract(),cockpitStats.getDifferenceContract()));
private List<AmountComparisonChart> convertAmountComparisonChart(CockpitStats cockpitStats) {
List<AmountComparisonChart> res = Lists.newArrayList();
res.add(new AmountComparisonChart("申报", cockpitStats.getDeclaredAmountApprove(), cockpitStats.getApprovalAmountApprove(), cockpitStats.getDifferenceApprove()));
res.add(new AmountComparisonChart("批复", cockpitStats.getDeclaredAmountApproval(), cockpitStats.getApprovalAmountApproval(), cockpitStats.getDifferenceApproval()));
res.add(new AmountComparisonChart("合同", cockpitStats.getDeclaredAmountContract(), cockpitStats.getApprovalAmountContract(), cockpitStats.getDifferenceContract()));
return res;
}

private CockpitStatsVO.ExcellentData convertExcellentData(CockpitStats cockpitStats) {
CockpitStatsVO.ExcellentData data = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.ExcellentData.class);
CockpitStatsVO.ExcellentData data = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.ExcellentData.class);
data.setExcellentProjects(Lists.newArrayList());
return data;
}

private CockpitStatsVO.StatusProjectsData convertStatusProjectsData(CockpitStats cockpitStats) {
return BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.StatusProjectsData.class);
return BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.StatusProjectsData.class);
}

private List<CockpitStatsVO.MapProjectsData> convertMapProjectsData(CockpitStats cockpitStats,Integer year) {
private List<CockpitStatsVO.MapProjectsData> convertMapProjectsData(CockpitStats cockpitStats, Integer year) {
List<CockpitStatsVO.MapProjectsData> mapProjectsDatas = Lists.newArrayList();
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_LS, RegionConst.RL_CITY);
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_HZ, RegionConst.RL_CITY);
regions = regions.stream().filter(r -> r.getRegionLevel() != 2).sorted(Comparator.comparing(RegionDTO::getRegionCode)).collect(Collectors.toList());

List<CockpitStats> cockpitStatsAll = cockpitStatsService.list(Wrappers.lambdaQuery(CockpitStats.class)
.eq(Objects.nonNull(year), CockpitStats::getYear, year)
.eq(Objects.isNull(year), CockpitStats::getYear, DashboardConstant.CockpitStats.NONE_YEAR));
Map<String, Integer> totalMap = cockpitStatsAll.stream().filter(c -> Objects.nonNull(c.getRegionCode()) && Objects.nonNull(c.getProjectsTotal()))
.collect(Collectors.toMap(c -> c.getRegionCode(), c -> c.getProjectsTotal()));
.eq(Objects.isNull(year), CockpitStats::getYear, NONE_YEAR));
Map<String, Integer> totalMap = cockpitStatsAll.stream()
.filter(c -> Objects.nonNull(c.getRegionCode()) && Objects.nonNull(c.getProjectsTotal()))
.collect(Collectors.toMap(CockpitStats::getRegionCode, CockpitStats::getProjectsTotal));

for(RegionDTO region : regions){
for (RegionDTO region : regions) {
CockpitStatsVO.MapProjectsData mapProjectsData = new CockpitStatsVO.MapProjectsData();
mapProjectsData.setRegionCode(region.getRegionCode());
mapProjectsData.setRegionName(region.getRegionName());
if(totalMap.containsKey(mapProjectsData.getRegionCode())){
mapProjectsData.setProjectsNum(totalMap.get(mapProjectsData.getRegionCode()));
}else{
mapProjectsData.setProjectsNum(0);
}
mapProjectsData.setProjectsNum(totalMap.getOrDefault(mapProjectsData.getRegionCode(), 0));
mapProjectsDatas.add(mapProjectsData);
}
return mapProjectsDatas;
}

private CockpitStatsVO.TopData convertTopData(CockpitStats cockpitStats) {
return BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.TopData.class);
return BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.TopData.class);
}

private CockpitStatsVO.Expert convertExpertData(CockpitStats cockpitStats) {
CockpitStatsVO.Expert expert = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.Expert.class);
expert.setExpertRegionData(buidExpertRegionData(cockpitStats));
CockpitStatsVO.Expert expert = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.Expert.class);
expert.setExpertRegionData(buildExpertRegionData(cockpitStats));
return expert;
}

private List<CockpitStatsVO.ExpertRegion> buidExpertRegionData(CockpitStats cockpitStats) {
private List<CockpitStatsVO.ExpertRegion> buildExpertRegionData(CockpitStats cockpitStats) {
List<CockpitStatsVO.ExpertRegion> regionData = Lists.newArrayList();
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_LS, RegionConst.RL_CITY);
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_HZ, RegionConst.RL_CITY);
regions = regions.stream().filter(r -> r.getRegionLevel() != 2).sorted(Comparator.comparing(RegionDTO::getRegionCode)).collect(Collectors.toList());

List<CockpitStats> cs = cockpitStatsService.list();
Map<String, Integer> csMap = cs.stream().collect(Collectors.toMap(c -> c.getRegionCode() + c.getYear(), CockpitStats::getExpertTotalNum));
for(RegionDTO region : regions){
for (RegionDTO region : regions) {
CockpitStatsVO.ExpertRegion expertRegion = new CockpitStatsVO.ExpertRegion();
expertRegion.setRegionCode(region.getRegionCode());
expertRegion.setRegionName(region.getRegionName());
if(csMap.containsKey(region.getRegionCode() + 0)){
expertRegion.setExpertNum(csMap.get(region.getRegionCode() + 0));
}else{
expertRegion.setExpertNum(0);
}
expertRegion.setExpertNum(csMap.getOrDefault(region.getRegionCode() + 0, 0));
regionData.add(expertRegion);
}
return regionData;
}

private CockpitStatsVO.Monitor convertMonitor(CockpitStats cockpitStats,String regionCode) {
CockpitStatsVO.Monitor monitor = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.Monitor.class);
monitor.setPasswordGradeCharts(buidPasswordGradeCharts(cockpitStats));
monitor.setSecrecyGradeCharts(buidSecrecyGradeCharts(cockpitStats));
private CockpitStatsVO.Monitor convertMonitor(CockpitStats cockpitStats, String regionCode) {
CockpitStatsVO.Monitor monitor = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.Monitor.class);
monitor.setPasswordGradeCharts(buildPasswordGradeCharts(cockpitStats));
monitor.setSecrecyGradeCharts(buildSecrecyGradeCharts(cockpitStats));
monitor.setMonitorSafetyInputRate(computeSafetyRate(regionCode));
return monitor;
}

/**
* 安全投入 比 图
*
* @param regionCode
* @return
*/
private List<CockpitStatsVO.SafetyInput> computeSafetyRate(String regionCode) {
List<CockpitStats> cocks = cockpitStatsService.list(Wrappers.lambdaQuery(CockpitStats.class)
.eq(StringUtils.isNotBlank(regionCode), CockpitStats::getRegionCode, regionCode)
.eq(StringUtils.isBlank(regionCode), CockpitStats::getRegionCode, DashboardConstant.CockpitStats.TOTAL)
.eq(StringUtils.isBlank(regionCode), CockpitStats::getRegionCode, TOTAL)
.in(CockpitStats::getYear, years)
.orderByAsc(CockpitStats::getYear));
return cocks.stream().map(c -> {
CockpitStatsVO.SafetyInput safetyInput = new CockpitStatsVO.SafetyInput();
safetyInput.setYear(c.getYear());
safetyInput.setRate(Objects.nonNull(c.getMonitorDeclaredAmount()) && c.getMonitorDeclaredAmount().compareTo(BigDecimal.ZERO) > 0 ?
c.getMonitorSafetyInputAmount().multiply(BigDecimal.valueOf(100)).divide(c.getMonitorDeclaredAmount(),2, RoundingMode.CEILING): BigDecimal.ZERO);
c.getMonitorSafetyInputAmount().multiply(BigDecimal.valueOf(100)).divide(c.getMonitorDeclaredAmount(), 2, RoundingMode.CEILING) : BigDecimal.ZERO);
return safetyInput;
}).collect(Collectors.toList());
}

private List<CockpitStatsVO.SecrecyGradeChart> buidSecrecyGradeCharts(CockpitStats cockpitStats) {
List<CockpitStatsVO.SecrecyGradeChart> chars = Lists.newArrayList();
chars.add(new CockpitStatsVO.SecrecyGradeChart(1,cockpitStats.getMonitorSecrecyGrade1Num()));
chars.add(new CockpitStatsVO.SecrecyGradeChart(2,cockpitStats.getMonitorSecrecyGrade2Num()));
chars.add(new CockpitStatsVO.SecrecyGradeChart(3,cockpitStats.getMonitorSecrecyGrade3Num()));
chars.add(new CockpitStatsVO.SecrecyGradeChart(4,cockpitStats.getMonitorSecrecyGrade4Num()));
chars.add(new CockpitStatsVO.SecrecyGradeChart(5,cockpitStats.getMonitorSecrecyGrade5Num()));
private List<SecrecyGradeChart> buildSecrecyGradeCharts(CockpitStats cockpitStats) {
List<SecrecyGradeChart> chars = Lists.newArrayList();
chars.add(new SecrecyGradeChart(1, cockpitStats.getMonitorSecrecyGrade1Num()));
chars.add(new SecrecyGradeChart(2, cockpitStats.getMonitorSecrecyGrade2Num()));
chars.add(new SecrecyGradeChart(3, cockpitStats.getMonitorSecrecyGrade3Num()));
chars.add(new SecrecyGradeChart(4, cockpitStats.getMonitorSecrecyGrade4Num()));
chars.add(new SecrecyGradeChart(5, cockpitStats.getMonitorSecrecyGrade5Num()));
return chars;
}

private List<CockpitStatsVO.PasswordGradeChart> buidPasswordGradeCharts(CockpitStats cockpitStats) {
List<CockpitStatsVO.PasswordGradeChart> chars = Lists.newArrayList();
chars.add(new CockpitStatsVO.PasswordGradeChart(1,cockpitStats.getMonitorPasswordGrade1Num()));
chars.add(new CockpitStatsVO.PasswordGradeChart(2,cockpitStats.getMonitorPasswordGrade2Num()));
chars.add(new CockpitStatsVO.PasswordGradeChart(3,cockpitStats.getMonitorPasswordGrade3Num()));
chars.add(new CockpitStatsVO.PasswordGradeChart(4,cockpitStats.getMonitorPasswordGrade4Num()));
chars.add(new CockpitStatsVO.PasswordGradeChart(5,cockpitStats.getMonitorPasswordGrade5Num()));
private List<PasswordGradeChart> buildPasswordGradeCharts(CockpitStats cockpitStats) {
List<PasswordGradeChart> chars = Lists.newArrayList();
chars.add(new PasswordGradeChart(1, cockpitStats.getMonitorPasswordGrade1Num()));
chars.add(new PasswordGradeChart(2, cockpitStats.getMonitorPasswordGrade2Num()));
chars.add(new PasswordGradeChart(3, cockpitStats.getMonitorPasswordGrade3Num()));
chars.add(new PasswordGradeChart(4, cockpitStats.getMonitorPasswordGrade4Num()));
chars.add(new PasswordGradeChart(5, cockpitStats.getMonitorPasswordGrade5Num()));
return chars;
}
}

+ 8
- 6
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/handle/ProjectStatusHandler.java Visa fil

@@ -11,6 +11,8 @@ import com.hz.pm.api.performance.service.IPerformanceAppraisalProjectService;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectInst;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.service.INdProjectStatusChangeService;
import com.hz.pm.api.projectlib.service.IProjectInstService;
import com.hz.pm.api.projectlib.service.IProjectService;
@@ -51,7 +53,7 @@ public class ProjectStatusHandler {
* @param project \
* @return \
*/
public ProtraitProjectStatusSituationVO generateApproveStatus(Project project, String statusName, Integer instType) {
public ProtraitProjectStatusSituationVO genApproveStatus(Project project, String statusName, InstTypeEnum instType) {
ProtraitProjectStatusSituationVO vo = new ProtraitProjectStatusSituationVO();
if (Objects.isNull(project)) {
return vo;
@@ -65,7 +67,7 @@ public class ProjectStatusHandler {
//查询 项目与实例关联表
ProjectInst unitInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, ids)
.eq(ProjectInst::getInstType, instType)
.eq(ProjectInst::getInstType, instType.getCode())
.last(BizConst.LIMIT_1));
if (Objects.isNull(unitInst)) {
return vo;
@@ -89,8 +91,8 @@ public class ProjectStatusHandler {
* @param project \
* @return \
*/
public ProtraitProjectStatusSituationVO generateStatus(Project project, String statusName,
Integer currStatus, Integer nextStatus) {
public ProtraitProjectStatusSituationVO genStatus(Project project, String statusName,
ProjectStatusEnum currStatus, ProjectStatusEnum nextStatus) {
ProtraitProjectStatusSituationVO vo = new ProtraitProjectStatusSituationVO();
if (Objects.isNull(project)) {
return vo;
@@ -101,9 +103,9 @@ public class ProjectStatusHandler {
//查询 状态机流转的时间点
LambdaQueryWrapper<ProjectStatusChange> pscQuery = Wrappers
.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getBeforeStatus, currStatus)
.eq(ProjectStatusChange::getBeforeStatus, currStatus.getCode())
.eq(ProjectStatusChange::getProjectCode, projectCode)
.eq(ProjectStatusChange::getAfterStatus, nextStatus)
.eq(ProjectStatusChange::getAfterStatus, nextStatus.getCode())
.last(BizConst.LIMIT_1);
ProjectStatusChange statusChange = statusChangeService.getOne(pscQuery);
if (Objects.isNull(statusChange)) {


+ 5
- 6
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/helper/DashboardChartAssembler.java Visa fil

@@ -5,8 +5,8 @@ import com.hz.pm.api.dashboard.constant.ChartTypeEnum;
import com.hz.pm.api.dashboard.model.basic.AnalysisChart;
import com.hz.pm.api.dashboard.model.basic.AnalysisData;
import com.hz.pm.api.meta.helper.DictionaryCache;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@@ -33,12 +33,11 @@ public class DashboardChartAssembler {
List<AnalysisData> dataList = new ArrayList<>();
analysisChart.setChartType(chartTypeEnum);
analysisChart.setDataList(dataList);
for (Integer key : projectGroupMap.keySet()) {
for (Map.Entry<Integer, List<Project>> entry : projectGroupMap.entrySet()) {
AnalysisData analysisData = new AnalysisData();
String chartKey = ProjectStatusEnum.getDesc(key);
List<Project> projectList = projectGroupMap.get(key);
String chartKey = ProjectStatusEnum.getDesc(entry.getKey());
analysisData.setKey(chartKey);
analysisData.setValue(CollUtil.isEmpty(projectList) ? 0 : projectList.size());
analysisData.setValue(CollUtil.size(entry.getValue()));
dataList.add(analysisData);
}
return analysisChart;
@@ -105,7 +104,7 @@ public class DashboardChartAssembler {
return analysisChart;
}

public <T> AnalysisChart assemblerAnalysisChart(Map<String, List<T>> dictionaryCodeIdMap
public <T> AnalysisChart assemblerAnalysisChart(Map<String, List<T>> dictionaryCodeIdMap
, ChartTypeEnum chartTypeEnum) {
AnalysisChart analysisChart = new AnalysisChart();
List<AnalysisData> dataList = new ArrayList<>();


+ 1
- 6
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/helper/DashboardHelper.java Visa fil

@@ -1,10 +1,7 @@
package com.hz.pm.api.dashboard.helper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.dashboard.constant.AnalysisBasicConstant;
import com.hz.pm.api.dashboard.model.entity.CockpitStats;
import com.hz.pm.api.dashboard.model.vo.CockpitStatsVO;
import com.hz.pm.api.sys.model.entity.Region;
import com.hz.pm.api.sys.service.IRegionService;
import lombok.RequiredArgsConstructor;
@@ -13,7 +10,6 @@ import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

/**
@@ -33,8 +29,7 @@ public class DashboardHelper {
public Map<String, String> getLiShuiRegionCodeNameMap() {
List<Region> regionList = iRegionService.list(Wrappers.lambdaQuery(Region.class)
.eq(Region::getParentCode, AnalysisBasicConstant.LS_REGION_CODE));
Map<String, String> regionCodeNameMap = regionList.stream().collect(Collectors.toMap(Region::getRegionCode, Region::getRegionName));
return regionCodeNameMap;
return regionList.stream().collect(Collectors.toMap(Region::getRegionCode, Region::getRegionName));
}

/**


+ 85
- 97
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/DashboardProjectManage.java Visa fil

@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.dashboard.constant.ChartTypeEnum;
import com.hz.pm.api.dashboard.constant.DashboardConstant;
import com.hz.pm.api.dashboard.constant.DashboardConstant.Protrait;
import com.hz.pm.api.dashboard.handle.ApplicationHandler;
import com.hz.pm.api.dashboard.handle.ProjectStatusHandler;
import com.hz.pm.api.dashboard.helper.DashboardChartAssembler;
@@ -28,10 +28,10 @@ import com.hz.pm.api.gov.service.IGovOperationProjectBaseinfoService;
import com.hz.pm.api.portrait.service.IProjectTagService;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectDelayApply;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.service.INdProjectDelayApplyService;
import com.hz.pm.api.projectlib.service.IProjectService;
import lombok.RequiredArgsConstructor;
@@ -97,20 +97,20 @@ public class DashboardProjectManage {
Integer approvedProjectCnt = projectCnt - toBeApprovedProjectCnt;

// 项目立项率
Double projectApprovalRate = new BigDecimal((float) approvedProjectCnt / projectCnt).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
Double projectApprovalRate = BigDecimal.valueOf((float) approvedProjectCnt / projectCnt).setScale(2, RoundingMode.HALF_UP).doubleValue();

// 项目申报总金额
List<BigDecimal> declareAmountList = allProjectList.stream().filter(r -> Objects.nonNull(r.getDeclareAmount()))
.map(Project::getDeclareAmount).
collect(Collectors.toList());
List<BigDecimal> declareAmountList = allProjectList.stream().map(Project::getDeclareAmount)
.filter(Objects::nonNull).
collect(Collectors.toList());
BigDecimal declareAmountSum = new BigDecimal("0");
for (BigDecimal declareAmount : declareAmountList) {
declareAmountSum.add(declareAmount);
}

// 项目批复总金额
List<BigDecimal> approvedTotalInvestmentIncreaseList = allProjectList.stream().filter(r -> Objects.nonNull(r.getApprovedTotalInvestmentIncrease()))
.map(Project::getApprovedTotalInvestmentIncrease)
List<BigDecimal> approvedTotalInvestmentIncreaseList = allProjectList.stream().map(Project::getApprovedTotalInvestmentIncrease)
.filter(Objects::nonNull)
.collect(Collectors.toList());
BigDecimal approvedTotalInvestmentIncreaseSum = new BigDecimal("0");
for (BigDecimal approvedTotalInvestmentIncrease : approvedTotalInvestmentIncreaseList) {
@@ -120,7 +120,7 @@ public class DashboardProjectManage {
// 资金核定率
BigDecimal fundApprovalRate = new BigDecimal("0");
if (new BigDecimal("0").compareTo(approvedTotalInvestmentIncreaseSum) != 0) {
fundApprovalRate = declareAmountSum.divide(approvedTotalInvestmentIncreaseSum, 2, BigDecimal.ROUND_HALF_UP);
fundApprovalRate = declareAmountSum.divide(approvedTotalInvestmentIncreaseSum, 2, RoundingMode.HALF_UP);
}


@@ -143,7 +143,7 @@ public class DashboardProjectManage {
.in(ProjectDelayApply::getProjectId, allProjectIdWithRepeatList));
Map<Long, List<ProjectDelayApply>> projectDelayApplyListMap = projectDelayApplyList.stream().collect(Collectors.groupingBy(ProjectDelayApply::getProjectId));
Integer delayProjectCnt = projectDelayApplyListMap.keySet().size();
Double delayProportion = new BigDecimal((float) delayProjectCnt / projectCnt).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
Double delayProportion = BigDecimal.valueOf((float) delayProjectCnt / projectCnt).setScale(2, RoundingMode.HALF_UP).doubleValue();

// 项目变更数量 项目变更金额
List<Project> changedProjectList = new ArrayList<>();
@@ -151,12 +151,12 @@ public class DashboardProjectManage {
for (String projectCode : allProjectMap.keySet()) {
List<Project> projectList = allProjectMap.get(projectCode);
Project newestProject = projectList.stream()
.filter(r -> r.getNewest())
.filter(Project::getNewest)
.collect(Collectors.toList()).get(0);
Boolean isChanged = false;
boolean isChanged = false;
for (Project project : projectList) {
Boolean newest = project.getNewest();
Boolean isBackReject = project.getIsBackReject();
boolean isBackReject = project.getIsBackReject();
if (!newest && isBackReject) {
isChanged = true;
break;
@@ -194,15 +194,12 @@ public class DashboardProjectManage {
return dashboardProjectSummaryVO;
}

public DashboardProjectCntSummaryVO getProjectCntSummary(QueryYearPO queryYearPO) {
public DashboardProjectCntSummaryVO getProjectCntSummary(QueryYearPO req) {
// 预算年度
Integer year = queryYearPO.getYear();
String regionCode = queryYearPO.getRegionCode();
Integer year = req.getYear();
List<Project> allProjectList = iProjectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getNewest, true)
.eq(Objects.nonNull(year), Project::getProjectYear, year)
.eq(StringUtils.isNotBlank(regionCode), Project::getAreaCode, regionCode)
);
.eq(Objects.nonNull(year), Project::getProjectYear, year));

// 单位项目数量TOP5
List<CompanyProjectCntBO> companyProjectCntTop5List = new ArrayList<>();
@@ -215,9 +212,7 @@ public class DashboardProjectManage {
companyProjectCntBO.setProjectCnt(projectList.size());
companyProjectCntTop5List.add(companyProjectCntBO);
}
companyProjectCntTop5List = companyProjectCntTop5List.stream()
.sorted(Comparator.comparing(CompanyProjectCntBO::getProjectCnt).reversed())
.collect(Collectors.toList());
companyProjectCntTop5List.sort(Comparator.comparing(CompanyProjectCntBO::getProjectCnt).reversed());
if (companyProjectCntTop5List.size() > 5) {
companyProjectCntTop5List = companyProjectCntTop5List.subList(0, 5);
}
@@ -269,10 +264,10 @@ public class DashboardProjectManage {
}


public DashboardInvestmentSummaryVO getInvestmentSummary(QueryYearPO queryYearPO) {
public DashboardInvestmentSummaryVO getInvestmentSummary(QueryYearPO req) {
// 预算年度
Integer year = queryYearPO.getYear();
String regionCode = queryYearPO.getRegionCode();
Integer year = req.getYear();
String regionCode = req.getRegionCode();
List<Project> allProjectList = iProjectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getNewest, true)
.eq(Objects.nonNull(year), Project::getProjectYear, year)
@@ -289,9 +284,7 @@ public class DashboardProjectManage {
projectATIISBO.setApprovedTotalInvestmentIncrease(r.getApprovedTotalInvestmentIncrease());
return projectATIISBO;
}).collect(Collectors.toList());
projectATIISTop5List = projectATIISTop5List.stream()
.sorted(Comparator.comparing(ProjectATIISBO::getApprovedTotalInvestmentIncrease)
.reversed()).collect(Collectors.toList());
projectATIISTop5List.sort(Comparator.comparing(ProjectATIISBO::getApprovedTotalInvestmentIncrease));
if (projectATIISTop5List.size() > 5) {
projectATIISTop5List = projectATIISTop5List.subList(0, 5);
}
@@ -314,9 +307,7 @@ public class DashboardProjectManage {
companyProjectCntBO.setApprovedTotalInvestmentIncreaseSum(approvedTotalInvestmentIncreaseSum);
companyProjectATIISTop5List.add(companyProjectCntBO);
}
companyProjectATIISTop5List = companyProjectATIISTop5List.stream()
.sorted(Comparator.comparing(CompanyProjectCntBO::getApprovedTotalInvestmentIncreaseSum).reversed())
.collect(Collectors.toList());
companyProjectATIISTop5List.sort(Comparator.comparing(CompanyProjectCntBO::getApprovedTotalInvestmentIncreaseSum).reversed());
if (companyProjectATIISTop5List.size() > 5) {
companyProjectATIISTop5List = companyProjectATIISTop5List.subList(0, 5);
}
@@ -347,6 +338,7 @@ public class DashboardProjectManage {

/**
* 驾驶舱-项目画像
*
* @param projectCode
* @return
*/
@@ -367,27 +359,27 @@ public class DashboardProjectManage {
.eq(GovBizProjectApply::getBaseProjId, projectCode)
.last(BizConst.LIMIT_1));

if(Objects.isNull(project) && Objects.isNull(baseInfo) && Objects.isNull(operationBase)){
if (Objects.isNull(project) && Objects.isNull(baseInfo) && Objects.isNull(operationBase)) {
return res;
}

//2.转换项目信息
if(Objects.nonNull(project)){
ProtraitProjectInfoVO projectInfo = BeanUtil.copyProperties(project,ProtraitProjectInfoVO.class);
if (Objects.nonNull(project)) {
ProtraitProjectInfoVO projectInfo = BeanUtil.copyProperties(project, ProtraitProjectInfoVO.class);
projectInfo.setOverdueSituation("即将超期");
projectInfo.setSafetyInputRate(convertSafetyInputRate(project));
projectInfo.setStatus(Objects.nonNull(project.getStatus()) ? project.getStatus().toString() : null);
//3.项目状态情况
projectInfo.setStatusSituation(generateProjectStatus(project));
projectInfo.setStatusSituation(genProjectStatus(project));
res.setProjectInfo(projectInfo);
}else if(Objects.nonNull(baseInfo)){
ProtraitProjectInfoVO projectInfo = BeanUtil.copyProperties(baseInfo,ProtraitProjectInfoVO.class);
} else if (Objects.nonNull(baseInfo)) {
ProtraitProjectInfoVO projectInfo = BeanUtil.copyProperties(baseInfo, ProtraitProjectInfoVO.class);
projectInfo.setOverdueSituation("即将超期");
projectInfo.setSafetyInputRate("0");
if(Objects.nonNull(apply)){
try{
if (Objects.nonNull(apply)) {
try {
projectInfo.setProjectYear(Integer.valueOf(apply.getBaseProjSetYear()));
}catch (Exception e){
} catch (Exception ignored) {
}
projectInfo.setProjectIntroduction(apply.getBaseProjIntro());
projectInfo.setBuildCycle(apply.getBaseProjDuration());
@@ -398,17 +390,17 @@ public class DashboardProjectManage {
projectInfo.setBuildOrgName(baseInfo.getBaseBuildDeprt());
projectInfo.setBuildOrgCode(baseInfo.getBaseBuildDeprtDing());
//3.项目状态情况
projectInfo.setStatusSituation(generateProjectStatus(baseInfo));
projectInfo.setStatusSituation(genProjectStatus(baseInfo));
projectInfo.setStatus(baseInfo.getBaseProjSetProg());
res.setProjectInfo(projectInfo);
}else if(Objects.nonNull(operationBase)){
ProtraitProjectInfoVO projectInfo = BeanUtil.copyProperties(operationBase,ProtraitProjectInfoVO.class);
} else if (Objects.nonNull(operationBase)) {
ProtraitProjectInfoVO projectInfo = BeanUtil.copyProperties(operationBase, ProtraitProjectInfoVO.class);
projectInfo.setOverdueSituation("即将超期");
projectInfo.setSafetyInputRate("0");
if(Objects.nonNull(apply)){
try{
if (Objects.nonNull(apply)) {
try {
projectInfo.setProjectYear(Integer.valueOf(apply.getBaseProjSetYear()));
}catch (Exception e){
} catch (Exception ignored) {
}
projectInfo.setProjectIntroduction(apply.getBaseProjIntro());
projectInfo.setBuildCycle(apply.getBaseProjDuration());
@@ -419,7 +411,7 @@ public class DashboardProjectManage {
projectInfo.setBuildOrgName(operationBase.getBaseBuildDeprt());
projectInfo.setBuildOrgCode(operationBase.getBaseBuildDeprtDing());
//3.项目状态情况
projectInfo.setStatusSituation(generateProjectStatus(operationBase));
projectInfo.setStatusSituation(genProjectStatus(operationBase));
projectInfo.setStatus(operationBase.getBaseProjSetProg());
res.setProjectInfo(projectInfo);
}
@@ -436,43 +428,46 @@ public class DashboardProjectManage {

/**
* 计算安全投入
*
* @param project
* @return
*/
public static String convertSafetyInputRate(Project project) {
String safetyInputDescribe = project.getSafetyInputDescribe();
if(org.apache.commons.lang3.StringUtils.isNotBlank(safetyInputDescribe)){
try{
if (org.apache.commons.lang3.StringUtils.isNotBlank(safetyInputDescribe)) {
try {
JSONArray array = JSON.parseArray(safetyInputDescribe);
final Double[] total = {0.0};
array.forEach(j -> {
JSONObject json = JSON.parseObject(JSON.toJSONString(j));
Double safetyInputAmount = json.getDouble(DashboardConstant.Protrait.FEILD_SAFETYMONEY);
if(Objects.nonNull(safetyInputAmount)){
Double safetyInputAmount = json.getDouble(Protrait.FEILD_SAFETYMONEY);
if (Objects.nonNull(safetyInputAmount)) {
total[0] += safetyInputAmount;
}
});
Double totalAmount = total[0];
//申报金额
BigDecimal declareAmount = project.getDeclareAmount();
if(Objects.isNull(declareAmount) || declareAmount.compareTo(BigDecimal.ZERO) == 0){
return DashboardConstant.Protrait.ZREO_PERCEN;
if (Objects.isNull(declareAmount) || declareAmount.compareTo(BigDecimal.ZERO) == 0) {
return Protrait.ZREO_PERCEN;
}
BigDecimal rate = BigDecimal.valueOf(totalAmount).multiply(BigDecimal.valueOf(100))
.divide(declareAmount,BigDecimal.ROUND_CEILING, RoundingMode.HALF_UP)
.divide(declareAmount, BigDecimal.ROUND_CEILING, RoundingMode.HALF_UP)
.stripTrailingZeros();
return rate.toPlainString();
}catch (Exception e){}
} catch (Exception ignored) {
}
}
return DashboardConstant.Protrait.ZREO_PERCEN;
return Protrait.ZREO_PERCEN;
}

/**
* 生成项目 状态流转信息
*
* @param project
* @return
*/
private List<ProtraitProjectStatusSituationVO> generateProjectStatus(Project project) {
private List<ProtraitProjectStatusSituationVO> genProjectStatus(Project project) {
final List<ProtraitProjectStatusSituationVO> res = Lists.newArrayList();
//1.计划(单位内部审核)
res.add(new ProtraitProjectStatusSituationVO());
@@ -485,77 +480,70 @@ public class DashboardProjectManage {
//5.验收(终验)
res.add(new ProtraitProjectStatusSituationVO());
//6.运维(todo: 运维时间还没有)
res.add(ProtraitProjectStatusSituationVO.builder().statusName(DashboardConstant.Protrait.OPERATION).build());
res.add(ProtraitProjectStatusSituationVO.builder().statusName(Protrait.OPERATION).build());
//7.绩效
res.add(new ProtraitProjectStatusSituationVO());
//8.注销(todo: 还没有注销功能)
res.add(ProtraitProjectStatusSituationVO.builder().statusName(DashboardConstant.Protrait.LOG_OFF).build());
res.add(ProtraitProjectStatusSituationVO.builder().statusName(Protrait.LOG_OFF).build());

CompletableFuture.allOf(
CompletableFuture.runAsync(() -> {
res.set(0,statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.PLAN,InstTypeEnum.UNIT_INNER_AUDIT.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(1,statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.DECLARED,InstTypeEnum.PRELIMINARY_PREVIEW.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(2,statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.APPROVE,InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(3,statusHandler.generateStatus(project,DashboardConstant.Protrait.CONSTRUCTION,
ProjectStatusEnum.UNDER_CONSTRUCTION.getCode(),ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(4,statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.ACCEPT,InstTypeEnum.PROJECT_FINAL_INSPECTION.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(6, statusHandler.generatePerformanceStatus(project));
}, ForkJoinPool.commonPool())
CompletableFuture.runAsync(() -> res.set(0, statusHandler.genApproveStatus(project, Protrait.PLAN,
InstTypeEnum.UNIT_INNER_AUDIT)), ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> res.set(1, statusHandler.genApproveStatus(project, Protrait.DECLARED,
InstTypeEnum.PRELIMINARY_PREVIEW)), ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> res.set(2, statusHandler.genApproveStatus(project, Protrait.APPROVE,
InstTypeEnum.CONSTRUCTION_PLAN_REVIEW)), ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> res.set(3, statusHandler.genStatus(project, Protrait.CONSTRUCTION,
ProjectStatusEnum.UNDER_CONSTRUCTION, ProjectStatusEnum.TO_BE_FINALLY_INSPECTED)), ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> res.set(4, statusHandler.genApproveStatus(project, Protrait.ACCEPT,
InstTypeEnum.PROJECT_FINAL_INSPECTION)), ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> res.set(6, statusHandler.generatePerformanceStatus(project)),
ForkJoinPool.commonPool())
).join();
return res;
}

private List<ProtraitProjectStatusSituationVO> generateProjectStatus(GovBizProjectBaseinfo baseinfo) {
private List<ProtraitProjectStatusSituationVO> genProjectStatus(GovBizProjectBaseinfo baseinfo) {
final List<ProtraitProjectStatusSituationVO> res = Lists.newArrayList();
//1.计划(单位内部审核)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.PLAN,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.PLAN, null));
//2.申报(项目预审)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.DECLARED,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.DECLARED, null));
//3.审批(建设方案审批)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.APPROVE,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.APPROVE, null));
//4.建设(立项后的建设中)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.CONSTRUCTION,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.CONSTRUCTION, null));
//5.验收(终验)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.ACCEPT,
res.add(new ProtraitProjectStatusSituationVO(Protrait.ACCEPT,
Objects.nonNull(baseinfo.getBaseProjSetProg()) && "07".equals(baseinfo.getBaseProjSetProg()) ? baseinfo.getTongTime() : null));
//6.运维(todo: 运维时间还没有)
res.add(ProtraitProjectStatusSituationVO.builder().statusName(DashboardConstant.Protrait.OPERATION).build());
res.add(ProtraitProjectStatusSituationVO.builder().statusName(Protrait.OPERATION).build());
//7.绩效
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.ACCEPT,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.ACCEPT, null));
//8.注销(todo: 还没有注销功能)
res.add(ProtraitProjectStatusSituationVO.builder().statusName(DashboardConstant.Protrait.LOG_OFF).build());
res.add(ProtraitProjectStatusSituationVO.builder().statusName(Protrait.LOG_OFF).build());
return res;
}

private List<ProtraitProjectStatusSituationVO> generateProjectStatus(GovOperationProjectBaseinfo baseinfo) {
private List<ProtraitProjectStatusSituationVO> genProjectStatus(GovOperationProjectBaseinfo baseinfo) {
final List<ProtraitProjectStatusSituationVO> res = Lists.newArrayList();
//1.计划(单位内部审核)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.PLAN,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.PLAN, null));
//2.申报(项目预审)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.DECLARED,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.DECLARED, null));
//3.审批(建设方案审批)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.APPROVE,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.APPROVE, null));
//4.建设(立项后的建设中)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.CONSTRUCTION,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.CONSTRUCTION, null));
//5.验收(终验)
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.ACCEPT,
res.add(new ProtraitProjectStatusSituationVO(Protrait.ACCEPT,
Objects.nonNull(baseinfo.getBaseProjSetProg()) && "07".equals(baseinfo.getBaseProjSetProg()) ? baseinfo.getTongTime() : null));
//6.运维(todo: 运维时间还没有)
res.add(ProtraitProjectStatusSituationVO.builder().statusName(DashboardConstant.Protrait.OPERATION).build());
res.add(ProtraitProjectStatusSituationVO.builder().statusName(Protrait.OPERATION).build());
//7.绩效
res.add(new ProtraitProjectStatusSituationVO(DashboardConstant.Protrait.ACCEPT,null));
res.add(new ProtraitProjectStatusSituationVO(Protrait.ACCEPT, null));
//8.注销(todo: 还没有注销功能)
res.add(ProtraitProjectStatusSituationVO.builder().statusName(DashboardConstant.Protrait.LOG_OFF).build());
res.add(ProtraitProjectStatusSituationVO.builder().statusName(Protrait.LOG_OFF).build());
return res;
}
}

+ 63
- 64
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/EarlyWarningStatisticsManage.java Visa fil

@@ -60,127 +60,126 @@ public class EarlyWarningStatisticsManage {
private final TaskService taskService;

private static final List<Integer> threeYears = Lists.newArrayList(LocalDateTime.now().getYear() - 2,
LocalDateTime.now().getYear() - 1,LocalDateTime.now().getYear());
LocalDateTime.now().getYear() - 1, LocalDateTime.now().getYear());

public EarlyWarningStatisticsVO statistics(Integer year) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();

//项目
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getNewest, Boolean.TRUE));
.eq(Project::getNewest, Boolean.TRUE));

EarlyWarningStatisticsVO res = new EarlyWarningStatisticsVO();
LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class);
EarlyWarningUtil.buildPermissonWrapper(wrapper,user);
EarlyWarningUtil.buildPermissionWrapper(wrapper, user);
List<WflowEarlyWarningRecords> records = earlyWarningRecordsService.list(wrapper);
//累积总告警数
res.setAccumulatedAlarmsTotal(records.size());
res.setAccumulatedAlarmsFlow(records.stream().filter(a -> {
res.setAccumulatedAlarmsFlow((int) records.stream().filter(a -> {
if (Objects.nonNull(a.getRuleType()) &&
a.getRuleType().equals(WarningRuleTypeEnum.PROCESS_WARNING.getCode())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size());
res.setAccumulatedAlarmsFilling(records.stream().filter(a -> {
}).count());
res.setAccumulatedAlarmsFilling((int) records.stream().filter(a -> {
if (Objects.nonNull(a.getRuleType()) &&
a.getRuleType().equals(WarningRuleTypeEnum.DECLARED_WARNING.getCode())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size());
}).count());

//近三年
List<DataDTO> threeYearsAlarms = Lists.newArrayList();
for(Integer thisYear : threeYears){
for (Integer thisYear : threeYears) {
DataDTO yearData = new DataDTO();
yearData.setName(thisYear.toString());
yearData.setNum(records.stream().filter(r -> {
if(Objects.nonNull(r.getWarningTime()) &&
thisYear.equals(r.getWarningTime().getYear())){
yearData.setNum((int) records.stream().filter(r -> {
if (Objects.nonNull(r.getWarningTime()) &&
thisYear.equals(r.getWarningTime().getYear())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size());
}).count());
threeYearsAlarms.add(yearData);
}
res.setThreeYearsAlarms(threeYearsAlarms);

//当前各流程报警数
List<DataDTO> alarmsFlowsNow = Lists.newArrayList();
for(ProjectProcessStageEnum stageEnum : ProjectProcessStageEnum.values()){
for (ProjectProcessStageEnum stageEnum : ProjectProcessStageEnum.values()) {
String processName = stageEnum.getDesc();
Integer processType = stageEnum.getCode();
alarmsFlowsNow.add(DataDTO.of(processName,computeFlowWarningNow(processType,records)));
alarmsFlowsNow.add(DataDTO.of(processName, computeFlowWarningNow(processType, records)));
}
res.setAlarmsFlowsNow(alarmsFlowsNow);

//当前各填报报警数
List<DataDTO> alarmsFillingNow = Lists.newArrayList();
for(WarningFlowTypeEnum fillingEnum : WarningFlowTypeEnum.values()){
for (WarningFlowTypeEnum fillingEnum : WarningFlowTypeEnum.values()) {
String processName = fillingEnum.getDesc();
Integer projectStutas = fillingEnum.getProjectStutas();
alarmsFillingNow.add(DataDTO.of(processName,computeFillingNow(projectStutas,records,projects)));
Integer projectStatus = fillingEnum.getProjectStutas();
alarmsFillingNow.add(DataDTO.of(processName, computeFillingNow(projectStatus, records, projects)));
}
res.setAlarmsFillingNow(alarmsFillingNow);

//实施预警
List<DataDTO> alarmsConstruction = Lists.newArrayList();
for(WarningNoticeTypeEnum noticeTypeEnum : WarningNoticeTypeEnum.values()){
for (WarningNoticeTypeEnum noticeTypeEnum : WarningNoticeTypeEnum.values()) {
String name = noticeTypeEnum.getDesc();
Integer noticeType = noticeTypeEnum.getCode();
alarmsConstruction.add(DataDTO.of(name,computeConstruction(noticeType,records,projects)));
alarmsConstruction.add(DataDTO.of(name, computeConstruction(noticeType, records, projects)));
}
res.setConstructionAlarms(alarmsConstruction);

//安全监测
List<DataDTO> safetyMonitoring = Lists.newArrayList();
//--1 安全设计
safetyMonitoring.add(DataDTO.of("安全设计",0));
safetyMonitoring.add(DataDTO.of("安全设计", 0));
//--2 安全投入低于5%
safetyMonitoring.add(DataDTO.of("安全投入低于5%",computeSafeLessFive(projects)));
safetyMonitoring.add(DataDTO.of("安全投入低于5%", computeSafeLessFive(projects)));
//--3 非信创
safetyMonitoring.add(DataDTO.of("非信创",computeNotXinChuang(projects)));
safetyMonitoring.add(DataDTO.of("非信创", computeNotXinChuang(projects)));
//--4 等保未做
safetyMonitoring.add(DataDTO.of("等保未做",0));
safetyMonitoring.add(DataDTO.of("等保未做", 0));
//--5 密评未做
safetyMonitoring.add(DataDTO.of("密评未做",0));
safetyMonitoring.add(DataDTO.of("密评未做", 0));
res.setSafetyMonitoring(safetyMonitoring);
return res;
}

//计算非信创
private Integer computeNotXinChuang(List<Project> projects) {
return projects.stream().filter(p -> StringUtils.isNotBlank(p.getCloudType()) &&
!p.getCloudType().contains("2"))
.collect(Collectors.toList()).size();
return (int) projects.stream().filter(p -> StringUtils.isNotBlank(p.getCloudType()) &&
!p.getCloudType().contains("2")).count();
}

//计算安全投入低于5%
private Integer computeSafeLessFive(List<Project> projects) {
return projects.stream().filter(p -> {
return (int) projects.stream().filter(p -> {
//计算出 安全投入
BigDecimal rate = new BigDecimal(DashboardProjectManage.convertSafetyInputRate(p));
if (rate.compareTo(new BigDecimal(5)) < 0) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size();
}).count();
}

private Integer computeConstruction(Integer noticeType, List<WflowEarlyWarningRecords> records,
List<Project> projects) {
//终验告警
List<WflowEarlyWarningRecords> constructionRecords = records.stream().filter(r -> {
if (Objects.nonNull(r.getRuleType()) &&
WarningRuleTypeEnum.OPERATION_WARNING.getCode().equals(r.getRuleType())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).filter(r -> Objects.nonNull(r.getNoticeType()) && r.getNoticeType().equals(noticeType) &&
if (Objects.nonNull(r.getRuleType()) &&
WarningRuleTypeEnum.OPERATION_WARNING.getCode().equals(r.getRuleType())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).filter(r -> Objects.nonNull(r.getNoticeType()) && r.getNoticeType().equals(noticeType) &&
WarningOperationTypeEnum.ZHONGYAN.getCode().equals(r.getBiz()))
.collect(Collectors.toList());
if(CollUtil.isEmpty(constructionRecords)){
if (CollUtil.isEmpty(constructionRecords)) {
return 0;
}
Map<String, List<WflowEarlyWarningRecords>> recordsMap = constructionRecords.stream().collect(Collectors.groupingBy(
@@ -188,21 +187,21 @@ public class EarlyWarningStatisticsManage {

//待终验的项目
List<Project> tobeFinalProjects = projects.stream().filter(p -> {
if(Objects.nonNull(p.getStatus()) &&
p.getStatus().equals(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode())){
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList());
if (Objects.nonNull(p.getStatus()) &&
p.getStatus().equals(ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList());

return tobeFinalProjects.stream().filter(p -> {
if(recordsMap.containsKey(p.getProjectCode())){
return (int) tobeFinalProjects.stream().filter(p -> {
if (recordsMap.containsKey(p.getProjectCode())) {
List<WflowEarlyWarningRecords> warningRecords = recordsMap.get(p.getProjectCode());
//如果是临期的 不能包含有超期的
if(noticeType.equals(WarningNoticeTypeEnum.ADVENT.getCode())){
for(WflowEarlyWarningRecords warningRecord : warningRecords){
if(Objects.isNull(warningRecord.getNoticeType()) || warningRecord.getNoticeType()
.equals(WarningNoticeTypeEnum.OVER.getCode())){
if (noticeType.equals(WarningNoticeTypeEnum.ADVENT.getCode())) {
for (WflowEarlyWarningRecords warningRecord : warningRecords) {
if (Objects.isNull(warningRecord.getNoticeType()) || warningRecord.getNoticeType()
.equals(WarningNoticeTypeEnum.OVER.getCode())) {
return Boolean.FALSE;
}
}
@@ -211,7 +210,7 @@ public class EarlyWarningStatisticsManage {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size();
}).count();
}

private Integer computeFillingNow(Integer projectStutas, List<WflowEarlyWarningRecords> records,
@@ -223,30 +222,30 @@ public class EarlyWarningStatisticsManage {
}
return Boolean.FALSE;
}).filter(r -> Objects.nonNull(r.getNodeId())).collect(Collectors.toList());
if(CollUtil.isEmpty(fillingRecords)){
if (CollUtil.isEmpty(fillingRecords)) {
return 0;
}
Map<String, List<WflowEarlyWarningRecords>> warningMap = fillingRecords.stream()
.collect(Collectors.groupingBy(WflowEarlyWarningRecords::getProjectCode));

List<Project> thisStatusProjects = projects.stream().filter(p -> {
if(Objects.nonNull(p.getStatus()) && p.getStatus().equals(projectStutas)){
if (Objects.nonNull(p.getStatus()) && p.getStatus().equals(projectStutas)) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList());

return thisStatusProjects.stream().filter(p -> {
if(warningMap.containsKey(p.getProjectCode())){
return (int) thisStatusProjects.stream().filter(p -> {
if (warningMap.containsKey(p.getProjectCode())) {
//这个状态有告警 并且 这个项目也是这个类型
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size();
}).count();
}

//计算某个流程当前正在告警的数量
private Integer computeFlowWarningNow(Integer processType,List<WflowEarlyWarningRecords> records) {
private Integer computeFlowWarningNow(Integer processType, List<WflowEarlyWarningRecords> records) {
List<WflowEarlyWarningRecords> processRecords = records.stream().filter(r -> {
if (Objects.nonNull(r.getRuleType()) &&
WarningRuleTypeEnum.PROCESS_WARNING.getCode().equals(r.getRuleType())) {
@@ -254,7 +253,7 @@ public class EarlyWarningStatisticsManage {
}
return Boolean.FALSE;
}).filter(r -> Objects.nonNull(r.getNodeId())).collect(Collectors.toList());
if(CollUtil.isEmpty(processRecords)){
if (CollUtil.isEmpty(processRecords)) {
return 0;
}
Map<String, List<WflowEarlyWarningRecords>> warningMap = processRecords.stream()
@@ -263,7 +262,7 @@ public class EarlyWarningStatisticsManage {
//1.先查出 所育 这个类型的 流程
List<ProjectInst> proInsts = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class)
.eq(ProjectInst::getInstType, processType));
if(CollUtil.isEmpty(proInsts)){
if (CollUtil.isEmpty(proInsts)) {
return 0;
}
//2.再筛选一下 选出 正在审核 未完成的
@@ -275,28 +274,28 @@ public class EarlyWarningStatisticsManage {
.orderByProcessInstanceStartTime()
.asc()
.list();
if(CollUtil.isEmpty(processes)){
if (CollUtil.isEmpty(processes)) {
return 0;
}
//查出所有正在执行的工作流任务
List<Task> tasks = taskService.createTaskQuery()
.list();
if(CollUtil.isEmpty(tasks)){
if (CollUtil.isEmpty(tasks)) {
return 0;
}
Map<String, List<Task>> taskMap = tasks.stream()
.collect(Collectors.groupingBy(Task::getProcessInstanceId));
return processes.stream().filter(p -> {
if(taskMap.containsKey(p.getId())){
return (int) processes.stream().filter(p -> {
if (taskMap.containsKey(p.getId())) {
List<Task> tasksThis = taskMap.get(p.getId());
for(Task taskThis : tasksThis){
for (Task taskThis : tasksThis) {
//说明 当前有告警
if(warningMap.containsKey(taskThis.getTaskDefinitionKey())){
if (warningMap.containsKey(taskThis.getTaskDefinitionKey())) {
return Boolean.TRUE;
}
}
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size();
}).count();
}
}

+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/ExpertStatisticsManage.java Visa fil

@@ -172,7 +172,7 @@ public class ExpertStatisticsManage {
Map<Long, ExpertUserFullInfo> expertMap = experts.stream().filter(e -> userSet.add(e.getUserId()))
.collect(Collectors.toMap(ExpertUserFullInfo::getUserId, e -> e));

List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_LS, RegionConst.RL_CITY)
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_HZ, RegionConst.RL_CITY)
.stream().filter(r -> r.getRegionLevel().equals(RegionConst.RL_COUNTY))
.sorted(Comparator.comparing(RegionDTO::getRegionCode)).collect(Collectors.toList());



+ 18
- 24
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/MeetingStatisticsManage.java Visa fil

@@ -57,8 +57,8 @@ public class MeetingStatisticsManage {
List<Meeting> meetings = meetingService.list(Wrappers.lambdaQuery(Meeting.class));
//查出 年份的 会议数据
meetings = meetings.stream().filter(m -> {
if(Objects.nonNull(m.getStartTime()) &&
(Objects.isNull(year) || year.equals(m.getStartTime().getYear()))){
if (Objects.nonNull(m.getStartTime()) &&
(Objects.isNull(year) || year.equals(m.getStartTime().getYear()))) {
return Boolean.TRUE;
}
return Boolean.FALSE;
@@ -72,10 +72,10 @@ public class MeetingStatisticsManage {
//评审数
List<ExpertReview> expertReviews = Lists.newArrayList();
Integer reviewsTotal = 0;
if(CollUtil.isNotEmpty(meetingIds)){
if (CollUtil.isNotEmpty(meetingIds)) {
expertReviews = expertReviewService.list(Wrappers.lambdaQuery(ExpertReview.class)
.eq(ExpertReview::getIsFinal, Boolean.TRUE)
.in(ExpertReview::getMeetingId,meetingIds));
.in(ExpertReview::getMeetingId, meetingIds));
reviewsTotal = expertReviews.size();
}
//通过的评审
@@ -91,18 +91,15 @@ public class MeetingStatisticsManage {
res.setPassReview(passExpertReviews.size());
res.setNotPassRate(reviewsTotal.compareTo(0) == 0 ? BigDecimal.ZERO :
BigDecimal.valueOf(notpassExpertReviews.size()).multiply(BigDecimal.valueOf(100)
.divide(BigDecimal.valueOf(reviewsTotal), RoundingMode.HALF_UP)));
.divide(BigDecimal.valueOf(reviewsTotal), RoundingMode.HALF_UP)));

//各区域
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_LS, RegionConst.RL_CITY)
List<RegionDTO> regions = regionCacheHelper.listChildren(RegionConst.RC_HZ, RegionConst.RL_CITY)
.stream().filter(r -> r.getRegionLevel().equals(RegionConst.RL_COUNTY))
.sorted(Comparator.comparing(RegionDTO::getRegionCode)).collect(Collectors.toList());
List<DataDTO> regionMeetngs = Lists.newArrayList();
for(RegionDTO region : regions){
regionMeetngs.add(DataDTO.of(region.getRegionName(),region.getRegionCode(),meetings.stream().filter(m -> {

return Boolean.FALSE;
}).collect(Collectors.toList()).size()));
for (RegionDTO region : regions) {
regionMeetngs.add(DataDTO.of(region.getRegionName(), region.getRegionCode(), meetings.size()));
}
res.setRegionMeetings(regionMeetngs);

@@ -110,14 +107,14 @@ public class MeetingStatisticsManage {
List<DataDTO> meetingTypes = Lists.newArrayList();
meetingTypes.add(DataDTO.of("预审会议", ReviewTemplateTypeEnum.PRELIMINARY_SCHEME_REVIEW.getCode().toString(),
meetings.stream().filter(m -> {
if(StringUtils.isNotBlank(m.getType()) &&
if (StringUtils.isNotBlank(m.getType()) &&
m.getType().equals(ReviewTemplateTypeEnum.PRELIMINARY_SCHEME_REVIEW.getCode()
.toString())){
.toString())) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList()).size()));
Long yanshouCount = meetings.stream().filter(m -> {
long yanshouCount = meetings.stream().filter(m -> {
if (StringUtils.isNotBlank(m.getType()) &&
m.getType().equals(ReviewTemplateTypeEnum.ACCEPTANCE_SCHEME_REVIEW.getCode()
.toString())) {
@@ -125,21 +122,18 @@ public class MeetingStatisticsManage {
}
return Boolean.FALSE;
}).count();
meetingTypes.add(DataDTO.of("验收会议",ReviewTemplateTypeEnum.ACCEPTANCE_SCHEME_REVIEW.getCode().toString(),
yanshouCount.intValue()));
meetingTypes.add(DataDTO.of("验收会议", ReviewTemplateTypeEnum.ACCEPTANCE_SCHEME_REVIEW.getCode().toString(),
(int) yanshouCount));
res.setMeetingTypes(meetingTypes);

//各区县评审 不通过率
List<DataDTO> regionNotpassReview = Lists.newArrayList();
for(RegionDTO region : regions){
for (RegionDTO region : regions) {
DataDTO data = new DataDTO();
data.setCode(region.getRegionCode());
data.setName(region.getRegionName());
//先求出 此区域会议
List<Long> regionMeetingIds = meetings.stream().filter(m -> {

return Boolean.FALSE;
}).map(Meeting::getId).collect(Collectors.toList());
List<Long> regionMeetingIds = meetings.stream().filter(m -> Boolean.FALSE).map(Meeting::getId).collect(Collectors.toList());

List<ExpertReview> regionReviews = expertReviews.stream().filter(r -> {
if (Objects.nonNull(r.getMeetingId()) &&
@@ -154,7 +148,7 @@ public class MeetingStatisticsManage {

data.setRate(CollUtil.isEmpty(regionReviews) ? BigDecimal.ZERO :
BigDecimal.valueOf(regionNotpass).multiply(BigDecimal.valueOf(100))
.divide(BigDecimal.valueOf(regionReviews.size()),BigDecimal.ROUND_CEILING,RoundingMode.HALF_UP));
.divide(BigDecimal.valueOf(regionReviews.size()), BigDecimal.ROUND_CEILING, RoundingMode.HALF_UP));

regionNotpassReview.add(data);
}
@@ -179,7 +173,7 @@ public class MeetingStatisticsManage {
.collect(Collectors.toList());
List<String> projectCodes = orgProjects.stream().map(Project::getProjectCode)
.collect(Collectors.toList());
if(CollUtil.isEmpty(projectCodes)){
if (CollUtil.isEmpty(projectCodes)) {
return data;
}
List<ExpertReview> reviews = finalExpertReviews.stream().filter(r -> Objects.nonNull(r.getProjectCode()) &&
@@ -189,7 +183,7 @@ public class MeetingStatisticsManage {
.count();
data.setRate(CollUtil.isEmpty(reviews) ? BigDecimal.ZERO :
BigDecimal.valueOf(orgNotpass).multiply(BigDecimal.valueOf(100))
.divide(BigDecimal.valueOf(reviews.size()),BigDecimal.ROUND_CEILING,RoundingMode.HALF_UP));
.divide(BigDecimal.valueOf(reviews.size()), BigDecimal.ROUND_CEILING, RoundingMode.HALF_UP));
return data;
})
.filter(d -> Objects.nonNull(d.getRate()))


+ 38
- 33
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/ProjectCostStatisticsManage.java Visa fil

@@ -1,6 +1,5 @@
package com.hz.pm.api.dashboard.manage;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hz.pm.api.common.model.entity.DataDTO;
@@ -10,15 +9,15 @@ import com.hz.pm.api.meeting.entity.domain.Meeting;
import com.hz.pm.api.meeting.entity.domain.MeetingExpert;
import com.hz.pm.api.meeting.service.IMeetingExpertService;
import com.hz.pm.api.meeting.service.IMeetingService;
import com.ningdatech.basic.util.CollUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;

/**
@@ -36,22 +35,31 @@ public class ProjectCostStatisticsManage {

private final IMeetingService meetingService;

List<Integer> thisTwoYears = Lists.newArrayList(LocalDateTime.now().getYear() - 1
,LocalDateTime.now().getYear());
//评审费 每人500 (0.05万)
private static final BigDecimal REVIEW_AMOUNT_EXPERT = DashboardConstant.Expert.REVIEW_AOUMT_EXPERT;

private List<Integer> getRecentTwoYears() {
int currYear = LocalDate.now().getYear();
return Arrays.asList(currYear - 1, currYear);
}

public CostStatisticsVO statistics() {
CostStatisticsVO res = new CostStatisticsVO();
List<Meeting> meetings = meetingService.list(Wrappers.lambdaQuery(Meeting.class));
List<Long> meetingIds = meetings.stream().map(Meeting::getId)
.collect(Collectors.toList());
List<Meeting> meetings = meetingService.list(Wrappers.lambdaQuery(Meeting.class)
.select(Meeting::getStartTime, Meeting::getId));
//算出所有的 同意的专家
List<MeetingExpert> meetingExperts = meetingExpertService.listAgreedExperts(meetingIds);
List<MeetingExpert> meetingExperts;

//评审费 每人500 (0.05万)
BigDecimal reviewAoumtExpert = DashboardConstant.Expert.REVIEW_AOUMT_EXPERT;
if (meetings.isEmpty()) {
meetingExperts = Collections.emptyList();
} else {
List<Long> meetingIds = CollUtils.fieldList(meetings, Meeting::getId);
meetingExperts = meetingExpertService.listAgreedExperts(meetingIds);
}

//计算累积
res.setReviewAmount(reviewAoumtExpert.multiply(BigDecimal.valueOf(meetingExperts.size())));
res.setReviewAmount(REVIEW_AMOUNT_EXPERT.multiply(BigDecimal.valueOf(meetingExperts.size())));
res.setPricingAmount(BigDecimal.ZERO);

//近两年
@@ -64,30 +72,27 @@ public class ProjectCostStatisticsManage {
DataDTO pricingAvg = new DataDTO();
pricingAvg.setName("核价费");
BigDecimal reviewTwoYearTotal = BigDecimal.ZERO;
for(Integer thisYear : thisTwoYears){

Map<Integer, List<Meeting>> meetingMapYear = CollUtils.group(meetings, w -> w.getStartTime().getYear());
Map<Long, List<MeetingExpert>> expertMapMeetingId = CollUtils.group(meetingExperts, MeetingExpert::getMeetingId);

for (Integer thisYear : getRecentTwoYears()) {
//查出 年份的 会议数据
List<Meeting> yearMeetings = meetings.stream().filter(m -> {
if(Objects.nonNull(m.getStartTime()) &&
( thisYear.equals(m.getStartTime().getYear()))){
return Boolean.TRUE;
}
return Boolean.FALSE;
}).collect(Collectors.toList());
List<Long> yearMeetingIds = yearMeetings.stream().map(Meeting::getId)
List<Meeting> yearMeetings = meetingMapYear.getOrDefault(thisYear, Collections.emptyList());
List<MeetingExpert> yearMeetingExperts = yearMeetings.stream()
.map(w -> expertMapMeetingId.get(w.getId()))
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.collect(Collectors.toList());
//算出所有的 同意的专家
List<MeetingExpert> yearMeetingExperts = Lists.newArrayList();
if(CollUtil.isNotEmpty(yearMeetingIds)){
yearMeetingExperts = meetingExpertService.listAgreedExperts(yearMeetingIds);
}
twoYearsReviews.add(DataDTO.of(thisYear.toString(),reviewAoumtExpert.multiply(BigDecimal
.valueOf(yearMeetingExperts.size()))));
twoYearsPricing.add(DataDTO.of(thisYear.toString(),BigDecimal.ZERO));

reviewTwoYearTotal = reviewTwoYearTotal.add(reviewAoumtExpert.multiply(BigDecimal
.valueOf(yearMeetingExperts.size())));
BigDecimal yearExpertCnt = BigDecimal.valueOf(yearMeetingExperts.size());
BigDecimal yearExpertAmount = REVIEW_AMOUNT_EXPERT.multiply(yearExpertCnt);
twoYearsReviews.add(DataDTO.of(thisYear.toString(), yearExpertAmount));
twoYearsPricing.add(DataDTO.of(thisYear.toString(), BigDecimal.ZERO));

reviewTwoYearTotal = reviewTwoYearTotal.add(yearExpertAmount);
}
reviewAvg.setAmount(reviewTwoYearTotal.divide(BigDecimal.valueOf(2),BigDecimal.ROUND_CEILING,
reviewAvg.setAmount(reviewTwoYearTotal.divide(BigDecimal.valueOf(2), BigDecimal.ROUND_CEILING,
RoundingMode.HALF_UP));
twoYearsAvg.add(reviewAvg);
twoYearsAvg.add(pricingAvg);


+ 1
- 2
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/model/vo/PerformanceStatisticsVO.java Visa fil

@@ -6,11 +6,10 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@Data
@ApiModel(value = "绩效统计", description = "")
@ApiModel(value = "绩效统计")
public class PerformanceStatisticsVO implements Serializable {
private static final long serialVersionUID = 1L;



+ 1
- 3
hz-pm-api/src/main/java/com/hz/pm/api/dashboard/model/vo/ProjectStatisticsVO.java Visa fil

@@ -5,13 +5,11 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
@ApiModel(value = "项目统计")
public class ProjectStatisticsVO implements Serializable {
private static final long serialVersionUID = 1L;
public class ProjectStatisticsVO {

@ApiModelProperty("项目计划数")
private Integer planTotal = 0;


+ 1
- 7
hz-pm-api/src/main/java/com/hz/pm/api/datascope/model/DataScopeDTO.java Visa fil

@@ -7,7 +7,7 @@ import java.util.List;

/**
* <p>
* DataScopeDto
* DataScopeDTO
* </p>
*
* @author WendyYang
@@ -18,14 +18,8 @@ public class DataScopeDTO {

private RoleEnum role;

private List<Long> regionIds;

private List<String> regionCodes;

private String orgCode;

private String employeeCode;

private Long userId;

}

+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/DataScopeContext.java Visa fil

@@ -1,7 +1,7 @@
package com.hz.pm.api.datascope.provider;

import com.ningdatech.basic.util.SpringUtils;
import com.hz.pm.api.datascope.model.DataScopeDTO;
import com.ningdatech.basic.util.SpringUtils;
import lombok.RequiredArgsConstructor;

import java.io.Serializable;
@@ -19,7 +19,7 @@ import java.util.Optional;
@RequiredArgsConstructor
public class DataScopeContext implements Serializable {

private static final String WARN_MSG = "请先创建数据权限[%s]的实现类,使其实现 DataScopeProvider";
private static final String WARN_MSG = "请先创建数据权限[%s]的实现类";

private static final Map<String, DataScopeProvider> DSP_MAP;

@@ -35,7 +35,7 @@ public class DataScopeContext implements Serializable {
return dataScopeProvider.findDataFieldProperty();
}

public static Optional<DataScopeDTO> getDataScopeHasUserId(String roleCode,Long userId) {
public static Optional<DataScopeDTO> getDataScopeHasUserId(String roleCode, Long userId) {
DataScopeProvider dataScopeProvider = DSP_MAP.get(roleCode);
if (dataScopeProvider == null) {
throw new IllegalArgumentException(String.format(WARN_MSG, roleCode));


+ 6
- 11
hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java Visa fil

@@ -1,6 +1,5 @@
package com.hz.pm.api.datascope.provider.impl;

import com.google.common.collect.Lists;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.datascope.model.DataScopeDTO;
import com.hz.pm.api.datascope.provider.DataScopeProvider;
@@ -30,23 +29,19 @@ public class DashboardUserDataScopeProviderImpl implements DataScopeProvider {

@Override
public Optional<DataScopeDTO> findDataFieldProperty() {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
DataScopeDTO ds = new DataScopeDTO();
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode()));
ds.setUserId(userFullInfo.getUserId());
ds.setUserId(user.getUserId());
ds.setRole(RoleEnum.DASHBOARD);
return Optional.ofNullable(ds);
return Optional.of(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId);
DataScopeDTO ds = new DataScopeDTO();
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode()));
ds.setUserId(userFullInfo.getUserId());
ds.setUserId(user.getUserId());
ds.setRole(RoleEnum.DASHBOARD);
return Optional.ofNullable(ds);
return Optional.of(ds);
}
}

+ 2
- 27
hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertAdminDataScopeProviderImpl.java Visa fil

@@ -1,11 +1,8 @@
package com.hz.pm.api.datascope.provider.impl;

import com.ningdatech.basic.util.CollUtils;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.datascope.model.DataScopeDTO;
import com.hz.pm.api.datascope.provider.DataScopeProvider;
import com.hz.pm.api.sys.model.dto.RegionDTO;
import com.hz.pm.api.user.model.enumeration.RoleEnum;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
import com.hz.pm.api.user.security.model.UserInfoDetails;
@@ -13,9 +10,6 @@ import com.hz.pm.api.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
@@ -30,25 +24,15 @@ import java.util.Optional;
@RequiredArgsConstructor
public class ExpertAdminDataScopeProviderImpl implements DataScopeProvider {

private final RegionCacheHelper regionCacheHelper;
private final UserInfoHelper userInfoHelper;

@Override
public Optional<DataScopeDTO> findDataFieldProperty() {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
DataScopeDTO ds = new DataScopeDTO();
if (Objects.isNull(user.getRegionLevel())) {
ds.setRegionIds(Collections.emptyList());
ds.setRegionCodes(Collections.emptyList());
} else {
List<RegionDTO> regions = regionCacheHelper.listChildren(user.getRegionCode(), user.getRegionLevel());
ds.setRegionCodes(CollUtils.fieldList(regions, RegionDTO::getRegionCode));
ds.setRegionIds(CollUtils.fieldList(regions, RegionDTO::getId));
}
ds.setRole(RoleEnum.EXPERT_ADMIN);
ds.setUserId(user.getUserId());
ds.setEmployeeCode(user.getEmployeeCode());
ds.setOrgCode(user.getOrganizationCode());
ds.setOrgCode(user.getMhUnitIdStr());
return Optional.of(ds);
}

@@ -56,18 +40,9 @@ public class ExpertAdminDataScopeProviderImpl implements DataScopeProvider {
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId);
DataScopeDTO ds = new DataScopeDTO();
if (Objects.isNull(user.getRegionLevel())) {
ds.setRegionIds(Collections.emptyList());
ds.setRegionCodes(Collections.emptyList());
} else {
List<RegionDTO> regions = regionCacheHelper.listChildren(user.getRegionCode(), user.getRegionLevel());
ds.setRegionCodes(CollUtils.fieldList(regions, RegionDTO::getRegionCode));
ds.setRegionIds(CollUtils.fieldList(regions, RegionDTO::getId));
}
ds.setRole(RoleEnum.EXPERT_ADMIN);
ds.setUserId(user.getUserId());
ds.setEmployeeCode(user.getEmployeeCode());
ds.setOrgCode(user.getOrganizationCode());
ds.setOrgCode(user.getMhUnitIdStr());
return Optional.of(ds);
}



+ 2
- 17
hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertDataScopeProviderImpl.java Visa fil

@@ -1,6 +1,5 @@
package com.hz.pm.api.datascope.provider.impl;

import com.hz.pm.api.common.model.constant.RegionConst;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.datascope.model.DataScopeDTO;
@@ -12,9 +11,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;

/**
* <p>
@@ -36,30 +33,18 @@ public class ExpertDataScopeProviderImpl implements DataScopeProvider {
@Override
public Optional<DataScopeDTO> findDataFieldProperty() {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
//所有 丽水市的code
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_LS,
RegionConst.RL_CITY);

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(regionCodes.stream().collect(Collectors.toList()));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.EXPERT);
return Optional.ofNullable(ds);
return Optional.of(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
//所有 丽水市的code
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_LS,
RegionConst.RL_CITY);

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(regionCodes.stream().collect(Collectors.toList()));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.EXPERT);
return Optional.ofNullable(ds);
return Optional.of(ds);
}
}

+ 0
- 27
hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/HigherUserDataScopeProviderImpl.java Visa fil

@@ -1,9 +1,5 @@
package com.hz.pm.api.datascope.provider.impl;

import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Lists;
import com.hz.pm.api.common.model.constant.RegionConst;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.datascope.model.DataScopeDTO;
import com.hz.pm.api.datascope.provider.DataScopeProvider;
@@ -14,8 +10,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;

/**
@@ -31,26 +25,14 @@ import java.util.Optional;
@Component("HIGH_MEMBER")
public class HigherUserDataScopeProviderImpl implements DataScopeProvider {

private final RegionCacheHelper regionCacheHelper;
private final UserInfoHelper userInfoHelper;

//和区域管理员一样
@Override
public Optional<DataScopeDTO> findDataFieldProperty() {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
//借由 丽水市的code 来映射市本级的regionCode
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(userFullInfo.getRegionCode(),
RegionConst.RL_CITY);
//如果不是市本级的话 就直接放入本区域的县就好了
if(CollUtil.isEmpty(regionCodes)){
regionCodes = Lists.newArrayList();
regionCodes.add(userFullInfo.getRegionCode());
}

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.REGION_MANAGER);
return Optional.of(ds);
}
@@ -59,18 +41,9 @@ public class HigherUserDataScopeProviderImpl implements DataScopeProvider {
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
//借由 丽水市的code 来映射市本级的regionCode
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(userFullInfo.getRegionCode(),
RegionConst.RL_CITY);
//如果不是市本级的话 就直接放入本区域的县就好了
if(CollUtil.isEmpty(regionCodes)){
regionCodes = Lists.newArrayList();
regionCodes.add(userFullInfo.getRegionCode());
}

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.REGION_MANAGER);
return Optional.of(ds);
}


+ 4
- 7
hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java Visa fil

@@ -1,6 +1,5 @@
package com.hz.pm.api.datascope.provider.impl;

import com.google.common.collect.Lists;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.datascope.model.DataScopeDTO;
import com.hz.pm.api.datascope.provider.DataScopeProvider;
@@ -10,6 +9,7 @@ import com.hz.pm.api.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
@@ -31,21 +31,18 @@ public class OrdinaryUserDataScopeProviderImpl implements DataScopeProvider {
public Optional<DataScopeDTO> findDataFieldProperty() {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
DataScopeDTO ds = new DataScopeDTO();
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode()));
ds.setUserId(userFullInfo.getUserId());
ds.setRole(RoleEnum.NORMAL_MEMBER);
return Optional.ofNullable(ds);
return Optional.of(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
DataScopeDTO ds = new DataScopeDTO();
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode()));
ds.setUserId(userFullInfo.getUserId());
ds.setRole(RoleEnum.NORMAL_MEMBER);
return Optional.ofNullable(ds);
return Optional.of(ds);
}

}

+ 3
- 4
hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java Visa fil

@@ -9,6 +9,7 @@ import com.hz.pm.api.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
@@ -30,9 +31,8 @@ public class OrgAdminDataScopeProviderImpl implements DataScopeProvider {
public Optional<DataScopeDTO> findDataFieldProperty() {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
DataScopeDTO ds = new DataScopeDTO();
ds.setOrgCode(userFullInfo.getEmpPosUnitCode());
ds.setOrgCode(String.valueOf(userFullInfo.getMhUnitId()));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.COMPANY_MANAGER);
return Optional.of(ds);
}
@@ -41,9 +41,8 @@ public class OrgAdminDataScopeProviderImpl implements DataScopeProvider {
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
DataScopeDTO ds = new DataScopeDTO();
ds.setOrgCode(userFullInfo.getEmpPosUnitCode());
ds.setOrgCode(String.valueOf(userFullInfo.getMhUnitId()));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.COMPANY_MANAGER);
return Optional.of(ds);
}


+ 0
- 27
hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java Visa fil

@@ -1,8 +1,5 @@
package com.hz.pm.api.datascope.provider.impl;

import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Lists;
import com.hz.pm.api.common.model.constant.RegionConst;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.datascope.model.DataScopeDTO;
@@ -14,8 +11,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;

/**
@@ -37,19 +32,8 @@ public class RegionAdminDataScopeProviderImpl implements DataScopeProvider {
@Override
public Optional<DataScopeDTO> findDataFieldProperty() {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
//借由 丽水市的code 来映射市本级的regionCode
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(userFullInfo.getRegionCode(),
RegionConst.RL_CITY);
//如果不是市本级的话 就直接放入本区域的县就好了
if(CollUtil.isEmpty(regionCodes)){
regionCodes = Lists.newArrayList();
regionCodes.add(userFullInfo.getRegionCode());
}

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.REGION_MANAGER);
return Optional.of(ds);
}
@@ -57,19 +41,8 @@ public class RegionAdminDataScopeProviderImpl implements DataScopeProvider {
@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
//借由 丽水市的code 来映射市本级的regionCode
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(userFullInfo.getRegionCode(),
RegionConst.RL_CITY);
//如果不是市本级的话 就直接放入本区域的县就好了
if(CollUtil.isEmpty(regionCodes)){
regionCodes = Lists.newArrayList();
regionCodes.add(userFullInfo.getRegionCode());
}

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.REGION_MANAGER);
return Optional.of(ds);
}


+ 0
- 14
hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java Visa fil

@@ -1,6 +1,5 @@
package com.hz.pm.api.datascope.provider.impl;

import com.hz.pm.api.common.model.constant.RegionConst;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.datascope.model.DataScopeDTO;
@@ -12,8 +11,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;

/**
@@ -37,13 +34,8 @@ public class SuperAdminDataScopeProviderImpl implements DataScopeProvider {
public Optional<DataScopeDTO> findDataFieldProperty() {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
//所有 丽水市的code
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_LS,
RegionConst.RL_CITY);

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.SUPER_ADMIN);
return Optional.of(ds);
}
@@ -51,14 +43,8 @@ public class SuperAdminDataScopeProviderImpl implements DataScopeProvider {
@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
//所有 丽水市的code
Collection<String> regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_LS,
RegionConst.RL_CITY);

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.SUPER_ADMIN);
return Optional.of(ds);
}


hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/VisitoyDataScopeProviderImpl.java → hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/VisitorDataScopeProviderImpl.java Visa fil

@@ -1,14 +1,12 @@
package com.hz.pm.api.datascope.provider.impl;

import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.datascope.model.DataScopeDTO;
import com.hz.pm.api.datascope.provider.DataScopeProvider;
import com.hz.pm.api.user.model.enumeration.RoleEnum;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
import com.hz.pm.api.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
@@ -22,24 +20,19 @@ import java.util.Optional;
@Slf4j
@RequiredArgsConstructor
@Component("VISITOR")
public class VisitoyDataScopeProviderImpl implements DataScopeProvider {
private final UserInfoHelper userInfoHelper;
public class VisitorDataScopeProviderImpl implements DataScopeProvider {

@Override
public Optional<DataScopeDTO> findDataFieldProperty() {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
DataScopeDTO ds = new DataScopeDTO();
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.SUPER_ADMIN);
return Optional.ofNullable(ds);
return Optional.of(ds);
}

@Override
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
DataScopeDTO ds = new DataScopeDTO();
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.SUPER_ADMIN);
return Optional.ofNullable(ds);
return Optional.of(ds);
}
}

+ 4
- 1
hz-pm-api/src/main/java/com/hz/pm/api/datascope/utils/DataScopeUtil.java Visa fil

@@ -17,6 +17,9 @@ import java.util.Optional;
*/
public class DataScopeUtil {

private DataScopeUtil() {
}

public static Optional<DataScopeDTO> getCurrentUserDataScope(UserFullInfoDTO user) {
if (Objects.isNull(user) || Objects.isNull(user.getRoleCode())) {
return Optional.empty();
@@ -28,7 +31,7 @@ public class DataScopeUtil {
if (Objects.isNull(user) || Objects.isNull(user.getRoleCode())) {
return Optional.empty();
}
return DataScopeContext.getDataScopeHasUserId(user.getRoleCode().name(),user.getUserId());
return DataScopeContext.getDataScopeHasUserId(user.getRoleCode().name(), user.getUserId());
}

public static Optional<DataScopeDTO> getCurrentUserDataScope() {


+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/ding/controller/DingInfoPullController.java Visa fil

@@ -292,11 +292,11 @@ public class DingInfoPullController {
extString = extString.substring(extString.lastIndexOf("."));
try {
if (".xls".equals(extString)) {
return wb = new HSSFWorkbook(is);
return new HSSFWorkbook(is);
} else if (".xlsx".equals(extString)) {
return wb = new XSSFWorkbook(is);
return new XSSFWorkbook(is);
} else {
return wb = null;
return null;
}
} catch (IOException e) {
e.printStackTrace();


+ 42
- 89
hz-pm-api/src/main/java/com/hz/pm/api/ding/task/EmployeeBatchGetTask.java Visa fil

@@ -5,17 +5,16 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.GenericResult;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.ding.constants.DingOrganizationContant;
import com.hz.pm.api.organization.model.entity.DingEmployeeInfo;
import com.hz.pm.api.organization.model.entity.DingOrganization;
import com.hz.pm.api.organization.service.IDingEmployeeInfoService;
import com.hz.pm.api.organization.service.IDingOrganizationService;
import com.hz.pm.api.user.model.enumeration.UserAvailableEnum;
import com.hz.pm.api.user.entity.UserInfo;
import com.hz.pm.api.user.model.entity.UserInfo;
import com.hz.pm.api.user.service.IUserInfoService;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.zwdd.ZwddIntegrationProperties;
import com.ningdatech.zwdd.client.ZwddAuthClient;
import com.ningdatech.zwdd.client.ZwddClient;
@@ -25,9 +24,9 @@ import com.ningdatech.zwdd.model.dto.EmployeeInfoDTO;
import com.ningdatech.zwdd.model.query.PageOrganizationEmployeePositionsQuery;
import com.ningdatech.zwdd.model.response.OrganizationEmployeePosition;
import com.ningdatech.zwdd.model.response.OrganizationEmployeePosition.GovEmployeePosition;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@@ -40,49 +39,42 @@ import java.util.stream.Collectors;
* @date 2023/2/10 上午9:52
*/

@Component
@Slf4j
@Component
@RequiredArgsConstructor
public class EmployeeBatchGetTask {

private final static Integer PAGE_SIZE = 20;
private static final int PAGE_SIZE = 20;
private static final int GROUP_SIZE = 100;
private static final long MAX_SIZE = 10000;

private final static Integer GROUP_SIZE = 100;
//==================================================================================================================

private final static Integer MAX_SIZE = 10000;
private final ZwddClient zwddClient;
private final ZwddAuthClient zwddAuthClient;
private final IDingOrganizationService dingOrganizationService;
private final IDingEmployeeInfoService dingEmployeeInfoService;
private final ZwddIntegrationProperties zwddIntegrationProperties;
private final IUserInfoService userInfoService;

@Autowired
private ZwddClient zwddClient;

@Autowired
private ZwddAuthClient zwddAuthClient;

@Autowired
private IDingOrganizationService iDingOrganizationService;

@Autowired
private IDingEmployeeInfoService iDingEmployeeInfoService;

@Autowired
private ZwddIntegrationProperties zwddIntegrationProperties;

@Autowired
private IUserInfoService iUserInfoService;
//==================================================================================================================

@Transactional(rollbackFor = Exception.class)
// @Scheduled(cron = "0 0 1 * * ?")
public void batchGetEmployeeTask() {
// 获取所有的组织列表用户获取组织下的 用户信息(暂时 只查 单位的类型)
List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getTypeCode, DingOrganizationContant.UNIT_TYPE));
// 获取所有的组织列表用户获取组织下的 用户信息(暂时只查单位的类型)
List<DingOrganization> dingOrganizationList = dingOrganizationService.list(
Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getTypeCode, DingOrganizationContant.UNIT_TYPE));
log.info("所有待更新员工的单位数:{}", dingOrganizationList.size());
if (CollUtil.isNotEmpty(dingOrganizationList)) {
//记录任务 单位数
Integer index = 0;
for (DingOrganization dingOrganization : dingOrganizationList) {
log.info("当前单位:{},下标数,{}", dingOrganization.getOrganizationName(), index);
for (DingOrganization dingOrg : dingOrganizationList) {
log.info("当前单位:{},下标数,{}", dingOrg.getOrganizationName(), index);
index++;
List<OrganizationEmployeePosition> allOrganizationEmployeePositionList = new ArrayList<>();
String organizationCode = dingOrganization.getOrganizationCode();
String organizationCode = dingOrg.getOrganizationCode();
PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery();
query.setEmployeeStatus("A");
query.setOrganizationCode(organizationCode);
@@ -104,13 +96,13 @@ public class EmployeeBatchGetTask {
}
Long totalSize = data.getTotalSize();

log.info("dingOrganization :{}", JSON.toJSONString(dingOrganization));
log.info("dingOrg :{}", JSON.toJSONString(dingOrg));

log.info("totalSize :{},{}", totalSize, dingOrganization.getOrganizationName());
log.info("totalSize :{},{}", totalSize, dingOrg.getOrganizationName());
if (totalSize > PAGE_SIZE) {
if (totalSize > MAX_SIZE) {
//超过1万 按1万的处理
totalSize = MAX_SIZE.longValue();
totalSize = MAX_SIZE;
}

int restPageNo = totalSize % PAGE_SIZE > 0 ? 1 : 0;
@@ -118,7 +110,6 @@ public class EmployeeBatchGetTask {
for (pageNo = 2; pageNo <= maxPageNo; pageNo++) {
query.setPageNo(pageNo);
GenericResult<Page<OrganizationEmployeePosition>> pageGenericResult = zwddClient.pageOrganizationEmployeePositions(query);
// log.info("pageGenericResult :{}", JSON.toJSONString(pageGenericResult));
if (pageGenericResult.isSuccess()) {
allOrganizationEmployeePositionList.addAll(pageGenericResult.getData().getData());
} else {
@@ -216,57 +207,21 @@ public class EmployeeBatchGetTask {
}
}

List<DingOrganization> organizations = iDingOrganizationService.list();
List<DingOrganization> organizations = dingOrganizationService.list();
Map<String, DingOrganization> organizationMap = organizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode, o -> o));

for (DingEmployeeInfo dingEmployeeInfo : saveList) {
String employeeCode = dingEmployeeInfo.getEmployeeCode();

DingEmployeeInfo employeeInfo = iDingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class)
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode)
.last(BizConst.LIMIT_1));
if (Objects.isNull(employeeInfo)) {
iDingEmployeeInfoService.save(dingEmployeeInfo);
dingEmployeeInfoService.save(dingEmployeeInfo);
} else {
dingEmployeeInfo.setId(employeeInfo.getId());
iDingEmployeeInfoService.saveOrUpdate(dingEmployeeInfo);
dingEmployeeInfoService.saveOrUpdate(dingEmployeeInfo);
}
generateOrUpdateUserInfo(dingEmployeeInfo, organizationMap);
}
}

public void generateOrUpdateUserInfo(DingEmployeeInfo dingEmployeeInfo, Map<String, DingOrganization> organizationMap) {
String employeeCode = dingEmployeeInfo.getEmployeeCode();
UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getEmployeeCode, employeeCode));
if (Objects.isNull(userInfo)) {
userInfo = new UserInfo();
userInfo.setAccountId(dingEmployeeInfo.getAccountId());
userInfo.setUsername(dingEmployeeInfo.getEmployeeName());
userInfo.setRealName(dingEmployeeInfo.getEmployeeName());
userInfo.setEmployeeCode(dingEmployeeInfo.getEmployeeCode());
userInfo.setAvailable(UserAvailableEnum.DISABLE.name());
userInfo.setCreateBy(-1L);
userInfo.setUpdateBy(-1L);
userInfo.setCreateOn(LocalDateTime.now());
userInfo.setUpdateOn(LocalDateTime.now());
userInfo.setEmpPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode());
userInfo.setAvatar(dingEmployeeInfo.getAvatar());
if (StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())) {
DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode());
userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName());
userInfo.setRegionCode(dingOrganization.getDivisionCode());
}
iUserInfoService.save(userInfo);
} else {
userInfo.setAvatar(dingEmployeeInfo.getAvatar());
userInfo.setEmpPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode());
if (StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())) {
DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode());
userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName());
userInfo.setRegionCode(dingOrganization.getDivisionCode());
}
iUserInfoService.updateById(userInfo);
}
}

@@ -276,7 +231,7 @@ public class EmployeeBatchGetTask {
* @param regionCode
*/
public void batchGetEmployeeTaskByRegionCode(String regionCode) {
List<DingOrganization> units = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class)
List<DingOrganization> units = dingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getTypeCode, DingOrganizationContant.UNIT_TYPE)
.eq(DingOrganization::getDivisionCode, regionCode));

@@ -317,7 +272,7 @@ public class EmployeeBatchGetTask {
if (totalSize > PAGE_SIZE) {
if (totalSize > MAX_SIZE) {
//超过1万 按1万的处理
totalSize = MAX_SIZE.longValue();
totalSize = MAX_SIZE;
}

int restPageNo = totalSize % PAGE_SIZE > 0 ? 1 : 0;
@@ -325,7 +280,6 @@ public class EmployeeBatchGetTask {
for (pageNo = 2; pageNo <= maxPageNo; pageNo++) {
query.setPageNo(pageNo);
GenericResult<Page<OrganizationEmployeePosition>> pageGenericResult = zwddClient.pageOrganizationEmployeePositions(query);
// log.info("pageGenericResult :{}", JSON.toJSONString(pageGenericResult));
if (pageGenericResult.isSuccess()) {
allOrganizationEmployeePositionList.addAll(pageGenericResult.getData().getData());
} else {
@@ -354,17 +308,16 @@ public class EmployeeBatchGetTask {
}

public void batchGetEmployeeTaskByOrdCode(String orgCode) {
DingOrganization org = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class)
DingOrganization org = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getOrganizationCode, orgCode)
.last(BizConst.LIMIT_1));
VUtils.isTrue(Objects.isNull(org)).throwMessage("单位不存在");
log.info("所属单位 {} 要更新员工信息了", org.getOrganizationName());

List<OrganizationEmployeePosition> allOrganizationEmployeePositionList = new ArrayList<>();
String organizationCode = orgCode;
PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery();
query.setEmployeeStatus("A");
query.setOrganizationCode(organizationCode);
query.setOrganizationCode(orgCode);
query.setReturnTotalSize(true);
query.setTenantId(zwddIntegrationProperties.getTenantId());
int pageNo = 1;
@@ -375,7 +328,7 @@ public class EmployeeBatchGetTask {
GenericResult<Page<OrganizationEmployeePosition>> firstPageGenericResult = zwddClient.pageOrganizationEmployeePositions(query);
Page<OrganizationEmployeePosition> data = firstPageGenericResult.getData();
if (Objects.isNull(data)) {
log.info("响应为空:{}", organizationCode);
log.info("响应为空:{}", orgCode);
return;
}
if (CollUtil.isNotEmpty(data.getData())) {
@@ -389,7 +342,7 @@ public class EmployeeBatchGetTask {
if (totalSize > PAGE_SIZE) {
if (totalSize > MAX_SIZE) {
//超过1万 按1万的处理
totalSize = MAX_SIZE.longValue();
totalSize = MAX_SIZE;
}

int restPageNo = totalSize % PAGE_SIZE > 0 ? 1 : 0;
@@ -444,22 +397,22 @@ public class EmployeeBatchGetTask {
return;
}

DingEmployeeInfo emp = iDingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class)
DingEmployeeInfo emp = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getEmployeeCode, empCode)
.last(BizConst.LIMIT_1));

if (Objects.nonNull(emp)) {
emp.setAvatar(data.getGovEmpAvatar());
iDingEmployeeInfoService.updateById(emp);
dingEmployeeInfoService.updateById(emp);
}

UserInfo user = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
UserInfo user = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getEmployeeCode, empCode)
.last(BizConst.LIMIT_1));

if (Objects.nonNull(user)) {
user.setAvatar(data.getGovEmpAvatar());
iUserInfoService.updateById(user);
userInfoService.updateById(user);
}
}

@@ -470,7 +423,7 @@ public class EmployeeBatchGetTask {
*/
public void getBatchEmployeeByCode(String orgCode) {

List<DingEmployeeInfo> employees = iDingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
List<DingEmployeeInfo> employees = dingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getEmpPosUnitCode, orgCode));

for (DingEmployeeInfo employee : employees) {


+ 3
- 5
hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertAdminExpertManageAssembler.java Visa fil

@@ -2,19 +2,17 @@ package com.hz.pm.api.expert.assembler;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.expert.model.DictFieldInfoDTO;
import com.hz.pm.api.expert.model.TagFieldInfo;
import com.hz.pm.api.expert.model.dto.ExpertAdminExpertListDTO;
import com.hz.pm.api.expert.model.vo.ExpertLibraryListItemVO;
import com.hz.pm.api.meta.helper.DictionaryCache;
import com.hz.pm.api.meta.helper.impl.TagsCacheImpl;
import com.hz.pm.api.meta.model.dto.DictionaryDTO;
import com.hz.pm.api.meta.model.dto.TagDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**


+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertInfoCmdAssembler.java Visa fil

@@ -33,7 +33,7 @@ public class ExpertInfoCmdAssembler {

ExpertFullInfoSaveCmd expertFullInfoSaveCmd = new ExpertFullInfoSaveCmd();
ExpertUserFullInfoDTO expertUserInfoDTO = buildExpertUserFullInfoDTO(
expertBasicInfo, expertEduInfo, expertJobInfo, expertProfessionalInfo, null, null);
expertBasicInfo, expertEduInfo, expertJobInfo, expertProfessionalInfo, null);
List<ExpertDictionaryDTO> expertDictionaryList =
buildExpertDictionaryList(expertBasicInfo, expertEduInfo, expertJobInfo, expertProfessionalInfo, null);
List<ExpertTagDTO> expertTagList = buildExpertTagList(expertProfessionalInfo, expertBasicInfo, null);
@@ -164,7 +164,7 @@ public class ExpertInfoCmdAssembler {
}

private static ExpertUserFullInfoDTO buildExpertUserFullInfoDTO(ExpertBasicInfo basicInfo, ExpertEduInfo eduInfo
, ExpertJobInfo jobInfo, ExpertProfessionalInfo professionalInfo, ExpertRecommendInfo recommendInfo, ExpertOtherInfo otherInfo) {
, ExpertJobInfo jobInfo, ExpertProfessionalInfo professionalInfo, ExpertOtherInfo otherInfo) {
ExpertUserFullInfoDTO expertFullInfo = new ExpertUserFullInfoDTO();

expertFullInfo.setIsDingUser(basicInfo.getIsDingUser());
@@ -214,7 +214,7 @@ public class ExpertInfoCmdAssembler {
, ExpertInfoSensitiveFieldCheckBO expertInfoSensitiveFieldCheckBO
, ModifyApplyExtraInfo modifyApplyExtraInfo) {
ExpertInfoModifyCmd expertInfoModifyCmd = new ExpertInfoModifyCmd();
ExpertUserFullInfoDTO expertUserInfoDTO = buildExpertUserFullInfoDTO(expertBasicInfo, expertEduInfo, expertJobInfo, expertProfessionalInfo, recommendInfo, otherInfo);
ExpertUserFullInfoDTO expertUserInfoDTO = buildExpertUserFullInfoDTO(expertBasicInfo, expertEduInfo, expertJobInfo, expertProfessionalInfo, otherInfo);

List<ExpertDictionaryDTO> expertDictionaryList = buildExpertDictionaryList(expertBasicInfo, expertEduInfo, expertJobInfo, expertProfessionalInfo, recommendInfo);
List<ExpertTagDTO> expertTagList = buildExpertTagList(expertProfessionalInfo, expertBasicInfo, otherInfo);


+ 0
- 29
hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/TagAssembler.java Visa fil

@@ -1,29 +0,0 @@
package com.hz.pm.api.expert.assembler;

import cn.hutool.core.collection.CollectionUtil;
import com.hz.pm.api.expert.model.TagFieldInfo;
import com.hz.pm.api.meta.model.entity.ExpertTag;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author liuxinxin
* @date 2022/7/25 下午4:30
*/

public class TagAssembler {

public static List<TagFieldInfo> toTagFieldInfoList(List<ExpertTag> expertTagList) {
if (CollectionUtil.isEmpty(expertTagList)) {
return new ArrayList<>();
}
return expertTagList.stream().map(r -> {
TagFieldInfo dictionaryFieldInfo = new TagFieldInfo();
dictionaryFieldInfo.setTagFieldName(r.getExpertInfoField());
dictionaryFieldInfo.setTagCode(r.getTagCode());
return dictionaryFieldInfo;
}).collect(Collectors.toList());
}
}

+ 0
- 3
hz-pm-api/src/main/java/com/hz/pm/api/expert/controller/ExpertController.java Visa fil

@@ -16,12 +16,9 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.IOException;

/**
* <p>


+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/expert/helper/ExpertInfoSensitiveFieldModifyCheckHelper.java Visa fil

@@ -42,7 +42,7 @@ public class ExpertInfoSensitiveFieldModifyCheckHelper {


public ExpertInfoSensitiveFieldCheckBO expertInfoSensitiveFieldModifyCheck(ExpertBasicInfo applyBasicInfo
, ExpertEduInfo applyEduInfo, ExpertJobInfo applyJobInfo, ExpertProfessionalInfo applyProfessionalInfo, Long expertUserId) {
, ExpertJobInfo applyJobInfo, ExpertProfessionalInfo applyProfessionalInfo, Long expertUserId) {

ExpertFullInfoAllDTO expertUserFullInfoAll = expertInfoService.getExpertUserFullInfoAll(expertUserId);
if (Objects.isNull(expertUserFullInfoAll)) {


+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertAdminManage.java Visa fil

@@ -181,7 +181,7 @@ public class ExpertAdminManage {
ExpertOtherInfo otherInfo = request.getExpertOtherInfo();

ExpertInfoSensitiveFieldCheckBO expertInfoSensitiveFieldCheckBO =
expertInfoSensitiveFieldModifyCheckHelper.expertInfoSensitiveFieldModifyCheck(basicInfo, eduInfo, jobInfo, professionalInfo, expertUserId);
expertInfoSensitiveFieldModifyCheckHelper.expertInfoSensitiveFieldModifyCheck(basicInfo, jobInfo, professionalInfo, expertUserId);
ExpertInfoModifyCmd expertInfoModifyCmd = ExpertInfoCmdAssembler
.buildExpertInfoModifyCmd(expertUserId, basicInfo, eduInfo, jobInfo, professionalInfo, recommendInfo, otherInfo, expertInfoSensitiveFieldCheckBO, null);
List<Long> applyIdList = expertInfoService.adminModifyExpertInfo(expertInfoModifyCmd, adminUserId);


+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertManage.java Visa fil

@@ -44,7 +44,7 @@ import com.hz.pm.api.sys.model.entity.Role;
import com.hz.pm.api.sys.model.entity.UserRole;
import com.hz.pm.api.sys.service.IRoleService;
import com.hz.pm.api.sys.service.IUserRoleService;
import com.hz.pm.api.user.entity.UserInfo;
import com.hz.pm.api.user.model.entity.UserInfo;
import com.hz.pm.api.user.model.enumeration.RoleEnum;
import com.hz.pm.api.user.model.enumeration.UserAvailableEnum;
import com.hz.pm.api.user.service.IUserInfoService;


+ 0
- 1
hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertMetaApplyManage.java Visa fil

@@ -37,7 +37,6 @@ import com.hz.pm.api.meta.model.bo.RegionContainsBO;
import com.hz.pm.api.meta.model.dto.DictionaryDTO;
import com.hz.pm.api.meta.model.entity.ExpertDictionary;
import com.hz.pm.api.meta.service.IExpertDictionaryService;
import com.hz.pm.api.sys.model.dto.RegionDTO;
import com.hz.pm.api.user.util.LoginUserUtil;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.PageVo;


+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/expert/model/SensitiveModifySegment.java Visa fil

@@ -78,7 +78,7 @@ public class SensitiveModifySegment {
return false;
}
for (SensitiveModifySegment segment : segmentList) {
if (!segment.isValueEquals()) {
if (Boolean.FALSE.equals(segment.isValueEquals())) {
return true;
}
}


+ 0
- 37
hz-pm-api/src/main/java/com/hz/pm/api/expert/model/cmd/AdminModifyExpertInfoCmd.java Visa fil

@@ -1,37 +0,0 @@
//package com.hz.pm.api.expert.model.cmd;
//
//import com.ningdatech.emapi.expert.entity.bo.ExpertInfoSensitiveFieldCheckBO;
//import com.ningdatech.emapi.expert.entity.dto.*;
//import lombok.Data;
//
//import java.util.List;
//
///**
// * @author liuxinxin
// * @date 2022/7/28 下午2:43
// */
//@Data
//public class AdminModifyExpertInfoCmd {
//
// private Long userId;
//
// private ExpertUserFullInfoDTO expertUserInfoDTO;
//
// private List<ExpertDictionaryDTO> expertDictionaryList;
//
// private List<ExpertTagDTO> expertTagList;
//
// /**
// * 专家履职意向(区域编码)
// */
// private List<ExpertRegionDTO> expertIntentionWorkRegionInfo;
//
// /**
// * 回避单位列表
// */
// private List<ExpertAvoidCompanyDTO> expertAvoidCompanyList;
//
// private ExpertInfoSensitiveFieldCheckBO expertInfoSensitiveFieldCheckBO;
//
// private ModifyApplyExtraInfoDTO modifyApplyExtraInfo;
//}

+ 0
- 60
hz-pm-api/src/main/java/com/hz/pm/api/expert/model/cmd/SaveExpertAdminCmd.java Visa fil

@@ -1,60 +0,0 @@
//package com.hz.pm.api.expert.model.cmd;
//
//import com.ningdatech.emapi.expert.entity.dto.ExpertAdminRegionDTO;
//import lombok.Data;
//
//import java.util.List;
//
///**
// * @author liuxinxin
// * @date 2022/8/1 上午10:54
// */
//@Data
//public class SaveExpertAdminCmd {
//
// /**
// * 用户id
// */
// private Long userId;
//
// /**
// * 是否浙政钉用户Y/N
// */
// private Boolean isDingUser;
//
// /**
// * 手机号
// */
// private String phoneNo;
//
// /**
// * 用户名称
// */
// private String name;
//
// /**
// * 工作单位
// */
// private String company;
//
// /**
// * 公司唯一标识
// */
// private String companyUniqCode;
//
// /**
// * 层级
// */
// private List<ExpertAdminRegionDTO> regionInfoList;
//
// /**
// * 用户状态(启用/关闭)
// */
// private Boolean isEnable;
//
// /**
// * 操作者id
// */
// private Long operatorId;
//
//}

+ 0
- 6
hz-pm-api/src/main/java/com/hz/pm/api/expert/model/vo/MetaApplyResultVo.java Visa fil

@@ -42,12 +42,6 @@ public class MetaApplyResultVo {
@ApiModelProperty("专家用户userId")
private Long expertUserId;

// @ApiModelProperty("额外的材料")
// private ModifyApplyExtraInfo modifyApplyExtraInfo;
//
// @ApiModelProperty("信息修改申请展示列表-只有审核类型为信息变更审核时才有值")
// private InfoModifyApplyDisplayVO infoModifyApplyDisplayVo;

@ApiModelProperty("履职意向修改申请展示列表-只有审核类型为履职意向变更时才会有值")
private IntentionApplyDisplayVO intentionApplyDisplayVo;



+ 2
- 6
hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertAdminManageServiceImpl.java Visa fil

@@ -1,14 +1,11 @@
package com.hz.pm.api.expert.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.expert.entity.ExpertUserFullInfo;
import com.ningdatech.basic.util.CollUtils;
import com.hz.pm.api.common.model.CommonPage;
import com.hz.pm.api.expert.assembler.ExpertUserInfoAssembler;
import com.hz.pm.api.expert.constant.ExpertAccountStatusEnum;
import com.hz.pm.api.expert.entity.ExpertUserFullInfo;
import com.hz.pm.api.expert.mapper.ExpertAdminManageMapper;
import com.hz.pm.api.expert.model.cmd.ExpertAdminExpertManageQueryCmd;
import com.hz.pm.api.expert.model.dto.ExpertAdminExpertListDTO;
@@ -18,16 +15,15 @@ import com.hz.pm.api.expert.model.query.ListExpertQuery;
import com.hz.pm.api.expert.service.ExpertAdminManageService;
import com.hz.pm.api.expert.service.IExpertUserFullInfoService;
import com.hz.pm.api.meta.model.entity.ExpertDictionary;
import com.hz.pm.api.meta.model.entity.ExpertTag;
import com.hz.pm.api.meta.service.IExpertDictionaryService;
import com.hz.pm.api.meta.service.IExpertTagService;
import com.ningdatech.basic.util.CollUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @author liuxinxin


+ 35
- 41
hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertInfoServiceImpl.java Visa fil

@@ -24,7 +24,7 @@ import com.hz.pm.api.expert.model.cmd.*;
import com.hz.pm.api.expert.model.dto.*;
import com.hz.pm.api.expert.service.*;
import com.hz.pm.api.expert.utils.SensitiveModifySegmentUtils;
import com.hz.pm.api.meeting.helper.YxtCallOrSmsHelper;
import com.hz.pm.api.meeting.helper.YxtClientHelper;
import com.hz.pm.api.meta.constant.ExpertDictTypeEnum;
import com.hz.pm.api.meta.model.ExpertRegionInfo;
import com.hz.pm.api.meta.model.entity.ExpertDictionary;
@@ -36,7 +36,7 @@ import com.hz.pm.api.sys.model.entity.UserRole;
import com.hz.pm.api.sys.service.IRoleService;
import com.hz.pm.api.sys.service.IUserRoleService;
import com.hz.pm.api.user.model.enumeration.UserAvailableEnum;
import com.hz.pm.api.user.entity.UserInfo;
import com.hz.pm.api.user.model.entity.UserInfo;
import com.hz.pm.api.user.model.enumeration.RoleEnum;
import com.hz.pm.api.user.security.model.UserInfoDetails;
import com.hz.pm.api.user.service.IUserInfoService;
@@ -78,7 +78,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
private final IUserRoleService userRoleService;
private final IExpertSensitiveInfoModifyDetailRecordService iExpertSensitiveInfoModifyDetailRecordService;
private final IUserInfoService userInfoService;
private final YxtCallOrSmsHelper yxtCallOrSmsHelper;
private final YxtClientHelper yxtClientHelper;
private final IExpertGovBusinessStripService expertGovBusinessStripService;

@Value("${login.url:}")
@@ -101,7 +101,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {

ExpertUserFullInfo expertUserFullInfo = iExpertUserFullInfoService.getByUserId(userId);

ExpertUserFullInfo saveExpertUserFullInfo = buildSaveExpertUserFullInfo(expertUserInfoDTO);
ExpertUserFullInfo saveExpertUserFullInfo = buildExpertUserFullInfo(expertUserInfoDTO);
if (Objects.nonNull(expertUserFullInfo)) {
// 专家信息审核通过之前,所有信息无需备份
iExpertUserFullInfoService.removeById(expertUserFullInfo.getId());
@@ -129,7 +129,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
iExpertTagService.saveBatch(saveExpertTagList);
}
// 保存所有专家字典字段
List<ExpertDictionary> saveExpertDictionaryList = buildSaveExpertDictionaryList(userId, expertDictionaryList);
List<ExpertDictionary> saveExpertDictionaryList = buildExpertDicts(userId, expertDictionaryList);
if (CollectionUtils.isNotEmpty(saveExpertDictionaryList)) {
iExpertDictionaryService.saveBatch(saveExpertDictionaryList);
}
@@ -141,14 +141,14 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
iExpertMetaApplyService.saveBatch(saveExpertIntentionWorkRegionApplyList);
}
// 保存所有专家回避单位
List<ExpertAvoidCompany> saveExpertAvoidCompanyList = buildSaveExpertAvoidCompanyList(userId, expertAvoidCompanyList);
List<ExpertAvoidCompany> saveExpertAvoidCompanyList = buildExpertAvoidCompany(userId, expertAvoidCompanyList);
if (CollectionUtils.isNotEmpty(saveExpertAvoidCompanyList)) {
iExpertAvoidCompanyService.saveBatch(saveExpertAvoidCompanyList);
}
}


private ExpertUserFullInfo buildSaveExpertUserFullInfo(ExpertUserFullInfoDTO expertUserInfoDTO) {
private ExpertUserFullInfo buildExpertUserFullInfo(ExpertUserFullInfoDTO expertUserInfoDTO) {
ExpertUserFullInfo expertUserFullInfo = new ExpertUserFullInfo();
if (Objects.nonNull(expertUserInfoDTO.getIsDingUser())) {
expertUserFullInfo.setIsDingUser(expertUserInfoDTO.getIsDingUser());
@@ -197,33 +197,35 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
}).collect(Collectors.toList());
}

private List<ExpertDictionary> buildSaveExpertDictionaryList(Long userId, List<ExpertDictionaryDTO> expertDictionaryList) {
if (CollectionUtils.isEmpty(expertDictionaryList)) {
return new ArrayList<>();
}
return expertDictionaryList.stream().map(r -> {
ExpertDictionary expertDictionary = new ExpertDictionary();
expertDictionary.setUserId(userId);
expertDictionary.setExpertInfoField(r.getExpertInfoField());
expertDictionary.setDictionaryCode(r.getDictionaryCode());
expertDictionary.setUpdateOn(LocalDateTime.now());
expertDictionary.setCreateOn(LocalDateTime.now());
return expertDictionary;
private List<ExpertDictionary> buildExpertDicts(Long userId, List<ExpertDictionaryDTO> exertDicts) {
if (CollectionUtils.isEmpty(exertDicts)) {
return Collections.emptyList();
}
LocalDateTime now = LocalDateTime.now();
return exertDicts.stream().map(r -> {
ExpertDictionary expertDict = new ExpertDictionary();
expertDict.setUserId(userId);
expertDict.setExpertInfoField(r.getExpertInfoField());
expertDict.setDictionaryCode(r.getDictionaryCode());
expertDict.setUpdateOn(now);
expertDict.setCreateOn(now);
return expertDict;
}).collect(Collectors.toList());
}


private List<ExpertAvoidCompany> buildSaveExpertAvoidCompanyList(Long userId, List<ExpertAvoidCompanyDTO> expertAvoidCompanyList) {
if (CollectionUtils.isEmpty(expertAvoidCompanyList)) {
return new ArrayList<>();
private List<ExpertAvoidCompany> buildExpertAvoidCompany(Long userId, List<ExpertAvoidCompanyDTO> avoidCompanies) {
if (CollectionUtils.isEmpty(avoidCompanies)) {
return Collections.emptyList();
}
return expertAvoidCompanyList.stream().map(r -> {
LocalDateTime now = LocalDateTime.now();
return avoidCompanies.stream().map(r -> {
ExpertAvoidCompany expertAvoidCompany = new ExpertAvoidCompany();
expertAvoidCompany.setCompanyName(r.getCompanyName());
expertAvoidCompany.setUserId(userId);
expertAvoidCompany.setCompanyUniqCode(r.getCompanyUniqCode());
expertAvoidCompany.setCreateOn(LocalDateTime.now());
expertAvoidCompany.setUpdateOn(LocalDateTime.now());
expertAvoidCompany.setCreateOn(now);
expertAvoidCompany.setUpdateOn(now);
return expertAvoidCompany;
}).collect(Collectors.toList());
}
@@ -239,15 +241,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {

List<ExpertDictionaryDTO> recommendedWayList = cmd.getRecommendedWay();
if (CollectionUtils.isNotEmpty(recommendedWayList)) {
List<ExpertDictionary> saveExpertDictionaryList = recommendedWayList.stream().map(r -> {
ExpertDictionary expertDictionary = new ExpertDictionary();
expertDictionary.setUserId(userId);
expertDictionary.setExpertInfoField(r.getExpertInfoField());
expertDictionary.setDictionaryCode(r.getDictionaryCode());
expertDictionary.setUpdateOn(LocalDateTime.now());
expertDictionary.setCreateOn(LocalDateTime.now());
return expertDictionary;
}).collect(Collectors.toList());
List<ExpertDictionary> saveExpertDictionaryList = buildExpertDicts(userId, recommendedWayList);
iExpertDictionaryService.saveBatch(saveExpertDictionaryList);
}

@@ -325,7 +319,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
Integer expertRegionLevel = cmd.getExpertRegionLevel();
Long expertUserId = cmd.getExpertUserId();

if (applyResult) {
if (Boolean.TRUE.equals(applyResult)) {
switch (applyTypeEnum) {
case EXPERT_INTENTION_JOIN: {
// 新增履职意向地
@@ -372,7 +366,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
ExpertUserFullInfo expertInfo = iExpertUserFullInfoService.getByUserId(expertUserId);
UserInfoDetails userDetail = LoginUserUtil.loginUserDetail();
String content;
if (cmd.getApplyResult()) {
if (Boolean.TRUE.equals(cmd.getApplyResult())) {
// 修改专家状态为可用
// 账号启用
LambdaUpdateWrapper<UserInfo> userInfoUpdate = Wrappers.lambdaUpdate(UserInfo.class)
@@ -387,7 +381,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
List<ExpertDictionaryDTO> expertType = cmd.getExpertType();
if (CollUtil.isNotEmpty(expertType)) {
expertType.forEach(r -> r.setExpertInfoField(ExpertDictTypeEnum.EXPERT_TYPE.getKey()));
List<ExpertDictionary> saveExpertDictList = buildSaveExpertDictionaryList(expertUserId, expertType);
List<ExpertDictionary> saveExpertDictList = buildExpertDicts(expertUserId, expertType);
iExpertDictionaryService.saveBatch(saveExpertDictList);
}
// 补充专家 专家角色
@@ -410,7 +404,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
SendSmsContext smsCtx = new SendSmsContext();
smsCtx.setContent(content);
smsCtx.setReceiveNumber(expertInfo.getPhoneNo());
yxtCallOrSmsHelper.sendSms(smsCtx);
yxtClientHelper.sendSms(smsCtx);
}
}

@@ -464,7 +458,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
List<Long> applyIdList = new ArrayList<>();

ExpertUserFullInfo originalExpertUserFullInfo = iExpertUserFullInfoService.getByUserId(userId);
ExpertUserFullInfo saveExpertUserFullInfo = buildSaveExpertUserFullInfo(expertUserInfoDTO);
ExpertUserFullInfo saveExpertUserFullInfo = buildExpertUserFullInfo(expertUserInfoDTO);
if (Objects.nonNull(originalExpertUserFullInfo)) {
saveExpertUserFullInfo.setId(originalExpertUserFullInfo.getId());
// 删除所有专家字典字段(需审核敏感字段不删除)
@@ -497,7 +491,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
iExpertUserFullInfoService.saveOrUpdate(saveExpertUserFullInfo);

// 保存所有专家字典字段
List<ExpertDictionary> saveExpertDictionaryList = buildSaveExpertDictionaryList(userId, expertDictionaryList);
List<ExpertDictionary> saveExpertDictionaryList = buildExpertDicts(userId, expertDictionaryList);
saveExpertDictionaryList = saveExpertDictionaryList
.stream().filter(r -> !ExpertUserInfoSensitiveFieldEnum.getSensitiveDictionaryList().contains(r.getExpertInfoField()))
.collect(Collectors.toList());
@@ -506,7 +500,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
}

// 保存所有专家回避单位
List<ExpertAvoidCompany> saveExpertAvoidCompanyList = buildSaveExpertAvoidCompanyList(userId, expertAvoidCompanyList);
List<ExpertAvoidCompany> saveExpertAvoidCompanyList = buildExpertAvoidCompany(userId, expertAvoidCompanyList);
if (CollectionUtils.isNotEmpty(saveExpertAvoidCompanyList)) {
// 删除回避单位
LambdaQueryWrapper<ExpertAvoidCompany> expertAvoidCompanyRemove = Wrappers.lambdaQuery(ExpertAvoidCompany.class)


+ 8
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java Visa fil

@@ -31,6 +31,7 @@ public class MhApiClient {
private static final String USER_URL = "/sync/user";
private static final String EXPERT_URL = "/sync/expert";
private static final String COMPANY_URL = "/sync/company";
private static final String PROJECT_URL = "/project_info/getProjectInfoList";


public MhRetDTO<List<MhUnitDTO>> queryUnits() {
@@ -69,4 +70,11 @@ public class MhApiClient {
}, false);
}

public MhRetDTO<List<MhProjectDTO>> listProjects() {
String requestUrl = mhApiHost + PROJECT_URL;
String retBody = HttpUtil.get(requestUrl);
return JSONUtil.toBean(retBody, new TypeReference<MhRetDTO<List<MhProjectDTO>>>() {
}, false);
}

}

+ 0
- 1
hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java Visa fil

@@ -1,6 +1,5 @@
package com.hz.pm.api.external.controller;

import com.hz.pm.api.external.MhApiClient;
import com.hz.pm.api.user.manage.SyncMhUserOrgManage;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;


+ 46
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhProjectDTO.java Visa fil

@@ -0,0 +1,46 @@
package com.hz.pm.api.external.model.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

/**
* <p>
* ResponseData
* </p>
*
* @author WendyYang
* @since 14:24 2024/1/23
*/
@Data
public class MhProjectDTO {

@ApiModelProperty("项目合规性检查附件")
private String fileId;

@ApiModelProperty("项目复核附件")
private String fileIdThree;

@ApiModelProperty("项目评审附件")
private String fileIdTwo;

@ApiModelProperty("项目评审预算金额")
private BigDecimal money;

@ApiModelProperty("项目名称")
private String projectName;

@ApiModelProperty("关键指标对象")
private MhProjectSchemeTargetDTO schemeTargetData;

@ApiModelProperty("项目总金额")
private BigDecimal totalMoney;

@ApiModelProperty("单位ID")
private Long unitId;

@ApiModelProperty("单位名称")
private String unitName;

}

+ 91
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhProjectSchemeTargetDTO.java Visa fil

@@ -0,0 +1,91 @@
package com.hz.pm.api.external.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
* <p>
* MhProjectSchemeTargetDTO
* </p>
*
* @author WendyYang
* @since 14:26 2024/1/23
*/
@Data
@ApiModel("关键指标对象")
public class MhProjectSchemeTargetDTO {

@ApiModelProperty(value = "迁移上云信息系统数量")
private int cloudSystemNum;

@ApiModelProperty(value = "创建时间")
private Date createTime;

@ApiModelProperty(value = "创建单位")
private Long createUnit;

@ApiModelProperty(value = "创建人")
private String createUser;

@ApiModelProperty(value = "附件")
private String fileId;

@ApiModelProperty(value = "本地部署非涉密信息系统数量")
private Integer fsmLocalSystemNum;

@ApiModelProperty(value = "更新购置非涉密服务器数量")
private Integer fsmServerNum;

@ApiModelProperty(value = "更新购置非涉密数据库数量")
private Integer fsmUpdateDbNum;

@ApiModelProperty(value = "更新购置非涉密中间件数量")
private Integer fsmUpdateMiddleNum;

@ApiModelProperty(value = "vCPU(核数)")
private Integer hostCpuNum;

@ApiModelProperty(value = "内存(GB)")
private Integer hostMemoryNum;

@ApiModelProperty(value = "信创云虚拟主机数量")
private Integer hostNum;

@ApiModelProperty(value = "存储(GB)")
private Integer hostStoreNum;

@ApiModelProperty(value = "ID")
private String id;

@ApiModelProperty(value = "总投资预算金额(万元)")
private BigDecimal money;

@ApiModelProperty(value = "本地部署涉密信息系统数量")
private Integer smLocalSystemNum;

@ApiModelProperty(value = "更新购置涉密服务器数量")
private Integer smServerNum;

@ApiModelProperty(value = "更新购置涉密数据库数量")
private Integer smUpdateDbNum;

@ApiModelProperty(value = "更新购置涉密中间件数量")
private Integer smUpdateMiddleNum;

@ApiModelProperty(value = "更新时间")
private Date updateTime;

@ApiModelProperty(value = "更新人")
private String updateUser;

@ApiModelProperty(value = "信创云数据库数量")
private Integer xcDbNum;

@ApiModelProperty(value = "信创云中间件数量")
private Integer xcMiddleNum;

}

+ 0
- 4
hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhTechExpertDTO.java Visa fil

@@ -1,12 +1,8 @@
package com.hz.pm.api.external.model.dto;

import cn.hutool.core.collection.CollUtil;
import lombok.Data;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
* <p>


+ 21
- 4
hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhUnitDTO.java Visa fil

@@ -4,7 +4,7 @@ import lombok.Data;

/**
* <p>
* OrgDTO-信创组织同步实体
* 信产组织同步实体
* </p>
*
* @author WendyYang
@@ -13,12 +13,29 @@ import lombok.Data;
@Data
public class MhUnitDTO {

/**
* 单位排序号
*/
private String sortNum;

/**
* 单位ID
*/
private Long unitId;

/**
* 单位名称
*/
private String unitName;

/**
* 父级单位ID
*/
private Long unitPid;
/**
* 单位类型
*/
private String type;
/**
* 统一社会信用代码
*/
private String unifiedSocialCreditCode;

}

+ 26
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/model/enumeration/MhUnitStripEnum.java Visa fil

@@ -0,0 +1,26 @@
package com.hz.pm.api.external.model.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* <p>
* MhUnitStripEnum
* </p>
*
* @author WendyYang
* @since 10:26 2024/1/25
*/
@Getter
@AllArgsConstructor
public enum MhUnitStripEnum {

GOV_COMPANY("国企"),

PARTY_GOV("党政"),

INDUSTRY("行业");

private final String name;

}

+ 100
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/model/enumeration/MhUnitTypeEnum.java Visa fil

@@ -0,0 +1,100 @@
package com.hz.pm.api.external.model.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
* <p>
* MhUnitTypeEnum
* </p>
*
* @author WendyYang
* @since 09:11 2024/1/25
*/
@Getter
@AllArgsConstructor
public enum MhUnitTypeEnum {

REGION("A", "区域"),
NODE("N", "节点"),
UNIT("U", "单位"),
PFPI("Y", "公益一类事业单位"),
PSPI("S", "公益二类事业单位"),
DEPT("D", "部门"),
OFFICE("O", "科室"),
SASAC("G", "国资委"),
TWO_GOV_COMPANY("C", "一级国企"),
ONE_GOV_COMPANY("E", "二级国企"),
KEY_INDUSTRY("K", "重点行业"),
INDUSTRY_MANAGE_DEPT("Z", "行业主管部门"),
INDUSTRY_COMPANY_UNIT("Q", "行业企事业单位");

private final String code;
private final String val;

//==================================================================================================================

public static Optional<MhUnitTypeEnum> getByCode(String code) {
return Arrays.stream(values()).filter(w -> w.getCode().equals(code)).findFirst();
}

private static final List<MhUnitTypeEnum> INDUSTRIES;
private static final List<MhUnitTypeEnum> GOV_COMPANIES;

static {
// 行业
INDUSTRIES = new ArrayList<>();
INDUSTRIES.add(KEY_INDUSTRY);
INDUSTRIES.add(INDUSTRY_MANAGE_DEPT);
INDUSTRIES.add(INDUSTRY_COMPANY_UNIT);

// 国资委
GOV_COMPANIES = new ArrayList<>();
GOV_COMPANIES.add(SASAC);
GOV_COMPANIES.add(ONE_GOV_COMPANY);
GOV_COMPANIES.add(TWO_GOV_COMPANY);
}

/**
* 是否是国企
*
* @return \
*/
public boolean isGovCompany() {
return GOV_COMPANIES.contains(this);
}

/**
* 是否是行业
*
* @return \
*/
public boolean isIndustry() {
return INDUSTRIES.contains(this);
}

/**
* 是否是党政
*
* @return \
*/
public boolean isPartyOrGov() {
return !isGovCompany() && !isIndustry();
}

public MhUnitStripEnum getStrip() {
if (isIndustry()) {
return MhUnitStripEnum.INDUSTRY;
} else if (isGovCompany()) {
return MhUnitStripEnum.GOV_COMPANY;
} else {
return MhUnitStripEnum.PARTY_GOV;
}
}

}

+ 1
- 2
hz-pm-api/src/main/java/com/hz/pm/api/external/sms/SmsServiceClient.java Visa fil

@@ -56,7 +56,7 @@ public class SmsServiceClient {
* @return
*/
public SmsDto<SmsSendResponse> smsSend(String content, List<String> phones) {
String phonesSplit = String.join(",", phones);;
String phonesSplit = String.join(",", phones);
String refreshUrl = smsUrl + SMS_SEND;
Map<String,Object> map = new HashMap<>();
map.put("content",content);
@@ -72,7 +72,6 @@ public class SmsServiceClient {
* @return
*/
public SmsReceipt smsReceipt(String result) {
SmsReceipt smsReceipt = null;
String refreshUrl = smsUrl + SMS_RECEIPT;
HashMap<String,Object> map = new HashMap<>();
map.put("result",result);


+ 2
- 6
hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java Visa fil

@@ -54,11 +54,8 @@ public class TodoServiceClient {
map.put("wkType",addSingleWkHandleDTO.getWkType());
map.put("wkUser",addSingleWkHandleDTO.getWkUser());
String responseResult = HttpUtil.post(url, JSON.toJSONString(map));
TodoDto todoDto = JSON.parseObject(responseResult, new TypeReference<TodoDto>() {
return JSON.parseObject(responseResult, new TypeReference<TodoDto>() {
});
// return JSON.parseObject(responseResult, new TypeReference<HashMap<String, String>>() {
// }).get("data");
return todoDto;
}

/**
@@ -74,9 +71,8 @@ public class TodoServiceClient {
.form("wkhandleId",wkhandleId);
HttpResponse response = request.execute();
String responseBody = response.body();
TodoDto todoDto = JSON.parseObject(responseBody, new TypeReference<TodoDto>() {
return JSON.parseObject(responseBody, new TypeReference<TodoDto>() {
});
return todoDto;
}



+ 1
- 5
hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java Visa fil

@@ -4,8 +4,6 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* @author 王仁康
* @date 2024-01-02 16:55:51
@@ -13,9 +11,7 @@ import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AddSingleWkHandleDTO implements Serializable {

private static final long serialVersionUID = -2067546352159912820L;
public class AddSingleWkHandleDTO {

// 待办参数,ObjectJson字符串
private Object params;


+ 6
- 6
hz-pm-api/src/main/java/com/hz/pm/api/filemanage/manage/DocumentationManage.java Visa fil

@@ -2,6 +2,7 @@ package com.hz.pm.api.filemanage.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hz.pm.api.filemanage.model.dto.DocumentationGroupSaveDTO;
@@ -106,7 +107,7 @@ public class DocumentationManage {
* @param id
* @return
*/
@Transactional
@Transactional(rollbackFor = Exception.class)
public String deleteGroup(Long id) {
DocumentationGroup group = documentationGroupService.getById(id);
VUtils.isTrue(Objects.isNull(group)).throwMessage("该分组不存在!");
@@ -125,22 +126,21 @@ public class DocumentationManage {
* @param dto
* @return
*/
@Transactional(rollbackFor = Exception.class)
public String addDoc(DocumentationSaveDTO dto) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();

Long fileId = dto.getFileId();
File file = fileService.getById(fileId);

VUtils.isTrue(Objects.isNull(file)).throwMessage("该文件不存在!");
Assert.notNull(file, "该文件不存在!");

DocumentationGroup group = documentationGroupService.getById(dto.getGroupId());

VUtils.isTrue(Objects.isNull(group)).throwMessage("分组不存在!");
Assert.notNull(group, "分组不存在!");

Documentation documentation = new Documentation();
documentation.setCreateBy(user.getRealName());
documentation.setCreateOn(LocalDateTime.now());
documentation.setSize(Objects.nonNull(file.getSize()) ? file.getSize() / 1000L : 0L);
documentation.setSize(file.getSize() / 1000L);
documentation.setFileId(fileId);
documentation.setGroupId(dto.getGroupId());
documentation.setFileName(file.getOriginalFileName());


+ 72
- 89
hz-pm-api/src/main/java/com/hz/pm/api/filemanage/manage/ProjectFileManage.java Visa fil

@@ -2,24 +2,21 @@ package com.hz.pm.api.filemanage.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.file.entity.File;
import com.ningdatech.file.service.FileService;
import com.ningdatech.file.utils.StrPool;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.common.util.ExcelDownUtil;
import com.hz.pm.api.common.util.StrUtils;
import com.hz.pm.api.expert.manage.ExpertReviewManage;
import com.hz.pm.api.expert.model.vo.ExpertReviewDetailVO;
import com.hz.pm.api.expert.model.vo.ProjectReviewDetailVO;
@@ -29,8 +26,6 @@ import com.hz.pm.api.filemanage.model.vo.ProjectApplyBorrowVO;
import com.hz.pm.api.filemanage.model.vo.ProjectFileListVO;
import com.hz.pm.api.filemanage.model.vo.ProjectFileVO;
import com.hz.pm.api.filemanage.service.INdProjectApplyBorrowService;
import com.hz.pm.api.organization.model.entity.DingOrganization;
import com.hz.pm.api.organization.service.IDingOrganizationService;
import com.hz.pm.api.projectdeclared.manage.ConstructionManage;
import com.hz.pm.api.projectdeclared.manage.DefaultDeclaredProjectManage;
import com.hz.pm.api.projectdeclared.manage.FinalAcceptanceManage;
@@ -43,12 +38,12 @@ import com.hz.pm.api.projectdeclared.model.vo.PreInsVO;
import com.hz.pm.api.projectdeclared.model.vo.PurchaseVO;
import com.hz.pm.api.projectdeclared.service.IContractService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.manage.ProjectLibManage;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectApplication;
import com.hz.pm.api.projectlib.model.entity.ProjectInst;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.vo.ProjectDetailVO;
import com.hz.pm.api.projectlib.service.IProjectApplicationService;
import com.hz.pm.api.projectlib.service.IProjectInstService;
@@ -56,8 +51,18 @@ import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.staging.enums.MsgTypeEnum;
import com.hz.pm.api.sys.manage.NoticeManage;
import com.hz.pm.api.todocenter.constant.WorkNoticeConstant;
import com.hz.pm.api.user.helper.MhUnitCache;
import com.hz.pm.api.user.model.dto.UnitDTO;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
import com.hz.pm.api.user.security.model.UserInfoDetails;
import com.hz.pm.api.user.util.LoginUserUtil;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.file.entity.File;
import com.ningdatech.file.service.FileService;
import com.ningdatech.file.utils.StrPool;
import com.wflow.bean.entity.WflowModels;
import com.wflow.contants.HisProInsEndActId;
import com.wflow.exception.BusinessException;
@@ -106,7 +111,6 @@ public class ProjectFileManage {
private final IProjectInstService projectInstService;
private final HistoryService historyService;
private final INdProjectApplyBorrowService projectApplyBorrowService;
private final IDingOrganizationService dingOrganizationService;
private final IProjectApplicationService projectApplicationService;
private final TaskService taskService;
private final IPurchaseService purchaseService;
@@ -116,69 +120,70 @@ public class ProjectFileManage {
private final PurchaseManage purchaseManage;
private final ConstructionManage constructionManage;
private final FinalAcceptanceManage finalAcceptanceManage;
private final MhUnitCache mhUnitCache;

public PageVo<ProjectFileListVO> list(ProjectFileListParam param) {

UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
String employeeCode = userFullInfo.getEmployeeCode();
String empPosUnitCode = userFullInfo.getEmpPosUnitCode();

Page<Project> page = param.page();
projectService.page(page, Wrappers.lambdaQuery(Project.class)
.like(StringUtils.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName())
.like(StringUtils.isNotBlank(param.getBuildOrgName()), Project::getBuildOrgName, param.getBuildOrgName())
public PageVo<ProjectFileListVO> list(ProjectFileListParam req) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
LambdaQueryWrapper<Project> query = Wrappers.lambdaQuery(Project.class)
.like(StrUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName())
.like(StrUtils.isNotBlank(req.getBuildOrgName()), Project::getBuildOrgName, req.getBuildOrgName())
.eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode())
.orderByDesc(Project::getUpdateOn));
.orderByDesc(Project::getUpdateOn);
Page<Project> page = projectService.page(req.page(), query);
if (CollUtil.isEmpty(page.getRecords())) {
return PageVo.empty();
}

// 获取本单位及下属单位的单位code
Set<String> subOrgSet = getSubOrgList(empPosUnitCode);
List<Long> subOrgSet = getSubOrgList(user.getMhUnitId());

List<ProjectFileListVO> vos = page.getRecords().stream().map(p -> {
ProjectFileListVO vo = new ProjectFileListVO();
vo.setId(p.getId());
// 用户只可查阅自己及下属单位的项目档案和已经申请借阅通过的项目档案
if (subOrgSet.contains(p.getBuildOrgCode()) || checkCanRead(subOrgSet, p)) {
if (!NumberUtil.isNumber(p.getBuildOrgCode())
|| subOrgSet.contains(Long.parseLong(p.getBuildOrgCode()))
|| checkCanRead(subOrgSet, p)) {
vo.setCanRead(Boolean.TRUE);
}
vo.setBuildOrgName(p.getBuildOrgName());
vo.setPojectCode(p.getProjectCode());
vo.setProjectName(p.getProjectName());
// 判断当前项目,当前登录用户是否已经开启了申请借阅并且没有审批完成
ProjectApplyBorrow projectApplyBorrow = projectApplyBorrowService.getOne(Wrappers.lambdaQuery(ProjectApplyBorrow.class)
.eq(ProjectApplyBorrow::getApplyBorrowEmployeeCode, employeeCode)
Wrapper<ProjectApplyBorrow> pabQuery = Wrappers.lambdaQuery(ProjectApplyBorrow.class)
.select(ProjectApplyBorrow::getInstanceId)
.eq(ProjectApplyBorrow::getApplyBorrowUserId, user.getUserIdStr())
.eq(ProjectApplyBorrow::getProjectId, p.getId())
.orderByDesc(ProjectApplyBorrow::getCreateOn)
.last("limit 1"));
.last(BizConst.LIMIT_1);
ProjectApplyBorrow projectApplyBorrow = projectApplyBorrowService.getOne(pabQuery);
if (Objects.nonNull(projectApplyBorrow)) {
String instCode = projectApplyBorrow.getInstanceId();
// 获取流程实例
HistoricProcessInstance newInstance =
historyService.createHistoricProcessInstanceQuery().processInstanceId(instCode).singleResult();
HistoricProcessInstance newInstance = historyService.createHistoricProcessInstanceQuery()
.processInstanceId(instCode)
.singleResult();
if (newInstance == null) {
vo.setCanApplyBorrow(Boolean.FALSE);
return vo;
}
ProjectInst projectInst = projectInstService
.getOne(Wrappers.lambdaQuery(ProjectInst.class).eq(ProjectInst::getInstCode, instCode));
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.eq(ProjectInst::getInstCode, instCode));
// 推送省局联审的项目流程实例为EMPTY
if (Objects.nonNull(projectInst)) {
Integer instType = projectInst.getInstType();
// 从申请借阅信息表中查询当前项目是否有当前登录用户发起的申请借阅审批流程
ProjectApplyBorrow applyBorrow = projectApplyBorrowService.getOne(Wrappers
.lambdaQuery(ProjectApplyBorrow.class).eq(ProjectApplyBorrow::getApplyBorrowEmployeeCode, employeeCode)
.eq(ProjectApplyBorrow::getProjectId, p.getId()).eq(ProjectApplyBorrow::getInstanceId, instCode));
.lambdaQuery(ProjectApplyBorrow.class)
.eq(ProjectApplyBorrow::getApplyBorrowUserId, user.getUserIdStr())
.eq(ProjectApplyBorrow::getProjectId, p.getId())
.eq(ProjectApplyBorrow::getInstanceId, instCode));
// 延期申请流程还未审核结束
if (Objects.nonNull(applyBorrow) && InstTypeEnum.APPLY_BORROW.getCode().equals(instType)
if (Objects.nonNull(applyBorrow) && InstTypeEnum.APPLY_BORROW.eq(instType)
&& Objects.isNull(newInstance.getEndActivityId())) {
vo.setCanApplyBorrow(Boolean.FALSE);
}
// 如果是延期申请审核被驳回,设置项目可以申请延期申报
else if (InstTypeEnum.APPLY_BORROW.getCode().equals(instType) &&
} else if (InstTypeEnum.APPLY_BORROW.eq(instType) &&
HisProInsEndActId.REJECT.equals(newInstance.getEndActivityId())) {
// 如果是延期申请审核被驳回,设置项目可以申请延期申报
vo.setCanApplyBorrow(Boolean.TRUE);
}
}
@@ -189,39 +194,32 @@ public class ProjectFileManage {
return PageVo.of(vos, page.getTotal());
}

private boolean checkCanRead(Set<String> subOrgSet, Project project) {
private boolean checkCanRead(List<Long> subOrgSet, Project project) {
// 从申请借阅信息表中查出本单位及下属单位审批通过的项目
List<String> subOrgSetStr = CollUtils.convert(subOrgSet, String::valueOf);
HashSet<Long> borrowProjectIdSet = new HashSet<>();
List<Long> applyBorrowProjectIdList = projectApplyBorrowService
.list(Wrappers.lambdaQuery(ProjectApplyBorrow.class)
.in(ProjectApplyBorrow::getApplyBorrowEmpPosUnitCode, subOrgSet)
.select(ProjectApplyBorrow::getProjectId)
.in(ProjectApplyBorrow::getApplyBorrowOrgCode, subOrgSetStr)
.eq(ProjectApplyBorrow::getIsSuccess, Boolean.TRUE))
.stream().map(ProjectApplyBorrow::getProjectId).filter(borrowProjectIdSet::add).collect(Collectors.toList());
.stream().map(ProjectApplyBorrow::getProjectId)
.filter(borrowProjectIdSet::add)
.collect(Collectors.toList());
return applyBorrowProjectIdList.contains(project.getId());
}

private Set<String> getSubOrgList(String empPosUnitCode) {
HashSet<String> orgSet = new HashSet<>();
// 先将自己加入子集
orgSet.add(empPosUnitCode);
Set<String> subOrgList = dingOrganizationService
.list(Wrappers.lambdaQuery(DingOrganization.class).eq(DingOrganization::getParentCode, empPosUnitCode))
.stream().map(DingOrganization::getOrganizationCode).collect(Collectors.toSet());
// 遍历子集
for (String orgCode : subOrgList) {
orgSet.addAll(getSubOrgList(orgCode));
}
return orgSet;
private List<Long> getSubOrgList(Long mhUnitId) {
List<Long> childIds = mhUnitCache.getChildrenIdsRecursion(mhUnitId);
childIds.add(mhUnitId);
return childIds;
}

public ProjectFileVO file(Long projectId) {

UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
String empPosUnitCode = userFullInfo.getEmpPosUnitCode();

UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
// 判断该项目是否为本单位或下属单位的项目或者已经申请借阅成功的项目
Project project = projectService.getById(projectId);
Set<String> subOrgList = getSubOrgList(empPosUnitCode);
List<Long> subOrgList = getSubOrgList(user.getMhUnitId());

if (!checkCanRead(subOrgList, project)) {
throw new BizException("您没有权限查看此项目档案!");
@@ -247,34 +245,24 @@ public class ProjectFileManage {
return projectFileVo;
}

public String wantRead(Long projectId) {
return "申请成功";
}

public String startApplyBorrowProcess(Long projectId) {
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
String employeeCode = user.getEmployeeCode();
VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!");

Project project = projectService.getNewProject(projectId);
VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!");

// 首先要判断 项目当前状态 是不是 已归档
VUtils.isTrue(!ProjectStatusEnum.ACCEPTED.getCode().equals(project.getStatus())).throwMessage("提交失败 该项目不是 已归档");

String regionCode = user.getRegionCode();

WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class)
.eq(WflowModels::getRegionCode, regionCode)
.eq(WflowModels::getProcessType, ProjectProcessStageEnum.APPLY_BORROW.getCode()).last(BizConst.LIMIT_1));
.eq(WflowModels::getProcessType, ProjectProcessStageEnum.APPLY_BORROW.getCode())
.last(BizConst.LIMIT_1));

if (Objects.isNull(model)) {
log.error("此 【{}】区域找不到申请借阅流程配置", regionCode);
throw new BusinessException(String.format("此 【%s】区域找不到申请借阅流程配置", regionCode));
throw new BusinessException("找不到申请借阅流程配置");
}

ProcessStartParamsVo params = new ProcessStartParamsVo();
params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode));
params.setUser(defaultDeclaredProjectManage.buildUser(user.getUserId()));
params.setProcessUsers(Collections.emptyMap());
// 放入条件判断的项目字段
// 把条件值给放入工作流
@@ -289,7 +277,7 @@ public class ProjectFileManage {
projectLibManage.saveProjectByApplyBorrow(project, user, instanceId);

// 发送给第一个审批人消息
noticeManage.sendFirtUser(project, model.getFormName(), instanceId, WorkNoticeConstant.PASS_MSG_TEMPLATE,
noticeManage.sendFirstUser(project, model.getFormName(), instanceId, WorkNoticeConstant.PASS_MSG_TEMPLATE,
MsgTypeEnum.PROJECT_REVIEW);

return instanceId;
@@ -525,8 +513,7 @@ public class ProjectFileManage {

private List<Long> getFileIdList(String buildBasis) {
List<JSONObject> prePlanFileArray = JSON.parseArray(buildBasis, JSONObject.class);
List<Long> prePlanFileIdList = CollUtils.fieldList(prePlanFileArray, w -> w.getLong(CommonConst.ID_STR));
return prePlanFileIdList;
return CollUtils.fieldList(prePlanFileArray, w -> w.getLong(CommonConst.ID_STR));
}

/**
@@ -545,19 +532,15 @@ public class ProjectFileManage {
}

ProjectApplyBorrowVO vo = BeanUtil.copyProperties(apply, ProjectApplyBorrowVO.class);
if (StringUtils.isNotBlank(vo.getApplyBorrowEmployeeCode())) {
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(vo.getApplyBorrowEmployeeCode());
if (StrUtils.isNotBlank(vo.getApplyBorrowUserId())) {
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(Long.valueOf(vo.getApplyBorrowUserId()));
if (Objects.nonNull(user)) {
vo.setApplyBorrowEmployeeName(user.getUsername());
vo.setApplyBorrowUserName(user.getUsername());
}
}
if (StringUtils.isNotBlank(vo.getApplyBorrowEmpPosUnitCode())) {
DingOrganization organization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getOrganizationCode, vo.getApplyBorrowEmpPosUnitCode())
.last(BizConst.LIMIT_1));
if (Objects.nonNull(organization)) {
vo.setApplyBorrowEmpPosUnitName(organization.getOrganizationName());
}
if (StrUtils.isNotBlank(vo.getApplyBorrowOrgCode())) {
UnitDTO mhUnit = mhUnitCache.getById(Long.parseLong(vo.getApplyBorrowOrgCode()));
vo.setApplyBorrowOrgName(mhUnit.getName());
}
if (Objects.nonNull(vo.getProjectId())) {
Project project = projectService.getById(vo.getProjectId());


+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/entity/ProjectApplyBorrow.java Visa fil

@@ -19,7 +19,7 @@ import lombok.Data;
*/
@Data
@TableName("nd_project_apply_borrow")
@ApiModel(value = "NdProjectApplyBorrow对象", description = "")
@ApiModel(value = "NdProjectApplyBorrow对象")
public class ProjectApplyBorrow implements Serializable {

private static final long serialVersionUID = 1L;
@@ -32,10 +32,10 @@ public class ProjectApplyBorrow implements Serializable {
private Long projectId;

@ApiModelProperty("申请借阅员工code")
private String applyBorrowEmployeeCode;
private String applyBorrowUserId;

@ApiModelProperty("申请借阅用户任职单位code")
private String applyBorrowEmpPosUnitCode;
private String applyBorrowOrgCode;

@ApiModelProperty("申请借阅审批流程ID")
private String instanceId;


Vissa filer visades inte eftersom för många filer har ändrats

Laddar…
Avbryt
Spara