From 840dbd97d5a5497b034bbfdd7a6d64baa313ecb7 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 29 Aug 2024 16:21:44 +0800 Subject: [PATCH 01/11] =?UTF-8?q?modify:=201.=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8B=9B=E6=A0=87=E9=87=87=E8=B4=AD=E9=A1=B9=E7=9B=AEID?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=9F=A5=E8=AF=A2=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java index dab0f74..08380a1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java @@ -422,7 +422,7 @@ public class WorkbenchManage { currStat.setTargetCount(systemReplaceCount.getValue()); List projectCodes = CollUtils.convert(projectIds, ProjectIdCodeCacheUtil::get); currStat.setStoppedCount(stoppedProjectCount(projectStatusChangeMap, projectCodes)); - if (!purchases.isEmpty()) { + if (!projectIds.isEmpty()) { Wrapper pQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) .select(PurchaseStatusChange::getEvent, PurchaseStatusChange::getProjectId) .in(PurchaseStatusChange::getProjectId, projectIds) From 3a3327bed7088a778f44600f1238981980e3a96e Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 29 Aug 2024 16:39:58 +0800 Subject: [PATCH 02/11] =?UTF-8?q?modify:=201.=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8B=9B=E6=A0=87=E9=87=87=E8=B4=AD=E7=BB=9F=E8=AE=A1=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index 6c88642..ad19c77 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -152,7 +152,7 @@ public class PurchaseManage { w -> CollUtil.anyMatch(w, x -> TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(x.getStatus())))); stat.setToBePurchaseCount(CollUtil.count(projectPurchaseMap.values(), Collection::isEmpty)); stat.setPurchaseFinishedCount(CollUtil.count(projectPurchaseMap.values(), - w -> CollUtil.anyMatch(w, x -> !TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(x.getStatus())))); + w -> CollUtil.allMatch(w, x -> !TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(x.getStatus())))); stat.setTotalCount(projects.size()); return stat; } From ed74515ac125dc3511848f7dc3c589675c220f13 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 29 Aug 2024 16:50:48 +0800 Subject: [PATCH 03/11] =?UTF-8?q?modify:=201.=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8B=9B=E6=A0=87=E9=87=87=E8=B4=ADtab=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index ad19c77..8837bb6 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -152,7 +152,7 @@ public class PurchaseManage { w -> CollUtil.anyMatch(w, x -> TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(x.getStatus())))); stat.setToBePurchaseCount(CollUtil.count(projectPurchaseMap.values(), Collection::isEmpty)); stat.setPurchaseFinishedCount(CollUtil.count(projectPurchaseMap.values(), - w -> CollUtil.allMatch(w, x -> !TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(x.getStatus())))); + w -> !w.isEmpty() && CollUtil.allMatch(w, x -> !TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(x.getStatus())))); stat.setTotalCount(projects.size()); return stat; } From ce3172882f056557ef86c01c73b095f4dd7b3ba7 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 29 Aug 2024 18:56:11 +0800 Subject: [PATCH 04/11] =?UTF-8?q?modify:=201.=20=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E5=A4=B1=E8=B4=A5=E6=8A=A5=E9=94=99=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hz/pm/api/common/config/BeanConfig.java | 4 +--- .../com/hz/pm/api/common/handler/CpuLoadTask.java | 24 ++++++++++------------ .../statemachine/util/TenderStateMachineUtil.java | 6 ++++++ .../api/projectdeclared/manage/PurchaseManage.java | 4 ++-- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/config/BeanConfig.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/config/BeanConfig.java index 4945c38..65bd1dc 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/config/BeanConfig.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/config/BeanConfig.java @@ -17,14 +17,12 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.web.client.RestTemplate; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** @@ -55,7 +53,7 @@ public class BeanConfig { converterList.remove(converterTarget); } HttpMessageConverter converter = new StringHttpMessageConverter(StandardCharsets.UTF_8); - converterList.add(1,converter); + converterList.add(1, converter); MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); mappingJackson2HttpMessageConverter.setSupportedMediaTypes(Arrays.asList( diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/handler/CpuLoadTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/handler/CpuLoadTask.java index 9dc1bc9..ee69397 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/handler/CpuLoadTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/handler/CpuLoadTask.java @@ -4,8 +4,8 @@ import cn.hutool.core.date.StopWatch; import cn.hutool.core.util.RandomUtil; import cn.hutool.system.oshi.OshiUtil; import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; import org.springframework.lang.NonNull; import org.springframework.scheduling.annotation.Scheduled; @@ -25,16 +25,21 @@ import java.util.stream.Stream; * @since 20:30 2024/3/5 */ @Slf4j -@Profile("prod") @Configuration +@ConditionalOnExpression("${cpu-load-task.open:false}") public class CpuLoadTask { - private static final int LIMIT_COUNT = 2000000000; - private final AtomicInteger taskNo = new AtomicInteger(0); + public CpuLoadTask() { + CpuLoadThreadFactory threadFactory = new CpuLoadThreadFactory(Thread.MIN_PRIORITY); + fixedThreadPool = Executors.newFixedThreadPool(1, threadFactory); + } + + private final ExecutorService fixedThreadPool; private static final Integer CPU_LIMIT = 20; + private static final int LIMIT_COUNT = 1000000000; + private final AtomicInteger taskNo = new AtomicInteger(0); - private static final ExecutorService FIXED_THREAD_POOL; private static class CpuLoadThreadFactory implements ThreadFactory { @@ -53,13 +58,6 @@ public class CpuLoadTask { } - static { - int logicalProcessorCount = OshiUtil.getProcessor().getLogicalProcessorCount(); - int max = Math.max(logicalProcessorCount * CPU_LIMIT / 100, 1); - CpuLoadThreadFactory threadFactory = new CpuLoadThreadFactory(Thread.MIN_PRIORITY); - FIXED_THREAD_POOL = Executors.newFixedThreadPool(max, threadFactory); - } - @Scheduled(fixedRate = 1, timeUnit = TimeUnit.MINUTES) public void run() { @@ -67,7 +65,7 @@ public class CpuLoadTask { log.info("当前CPU使用率:{}", cpuUsage); if (cpuUsage < CPU_LIMIT) { log.info("提交计算任务:{}", taskNo.incrementAndGet()); - FIXED_THREAD_POOL.execute(() -> { + fixedThreadPool.execute(() -> { StopWatch watch = new StopWatch(); watch.start(); long sum = Stream.generate(() -> RandomUtil.randomLong(1, LIMIT_COUNT)) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java index b429652..c792a0e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java @@ -1,5 +1,6 @@ package com.hz.pm.api.common.statemachine.util; +import cn.hutool.core.util.ObjUtil; import com.hz.pm.api.common.statemachine.builder.impl.TenderStateMachineBuilderImpl; import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; @@ -7,6 +8,7 @@ import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; import com.hz.pm.api.projectlib.model.enumeration.status.ITenderStatus; import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; +import com.ningdatech.basic.exception.BizException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; @@ -64,6 +66,10 @@ public class TenderStateMachineUtil implements AbstractStateMachineUtil Date: Fri, 30 Aug 2024 11:34:16 +0800 Subject: [PATCH 05/11] =?UTF-8?q?modify:=201.=20=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=9C=BA=E7=8A=B6=E6=80=81=E5=8F=98=E6=9B=B4=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hz-pm-api/pom.xml | 12 +++++ .../impl/ProjectStateMachineBuilderImpl.java | 12 +++-- .../impl/TenderStateMachineBuilderImpl.java | 12 +++-- .../builder/impl/XcfhxStateMachineBuilderImpl.java | 1 - .../statemachine/factory/ProjectGuardFactory.java | 59 +++++++++++++++----- .../statemachine/factory/TenderGuardFactory.java | 22 +++++++- .../util/AbstractStateMachineUtil.java | 28 +++++++--- .../statemachine/util/AdaptStateMachineUtil.java | 19 +++---- .../statemachine/util/ProjectStateMachineUtil.java | 39 +++++++------- .../util/SelfTestStateMachineUtil.java | 15 +++--- .../statemachine/util/TenderStateMachineUtil.java | 20 ++++--- .../util/TestValidStateMachineUtil.java | 4 +- .../statemachine/util/XcfhxStateMachineUtil.java | 17 +++--- .../com/hz/pm/api/common/util/ThreadPoolUtil.java | 1 - .../meeting/task/ExpertInviteExecutorConfig.java | 15 +++--- .../api/meeting/task/MsgCallReplyRewriteTask.java | 4 +- .../api/meeting/task/RandomInviteProperties.java | 6 +++ hz-pm-api/src/main/resources/application-dev.yml | 6 ++- hz-pm-api/src/main/resources/application-prod.yml | 4 ++ .../com/hz/pm/api/common/StateMachineTest.java | 46 ++++++++++++++++ hz-pm-api/src/test/resources/application-dev.yml | 62 +++++++++++++++------- pom.xml | 2 +- 22 files changed, 294 insertions(+), 112 deletions(-) create mode 100644 hz-pm-api/src/test/java/com/hz/pm/api/common/StateMachineTest.java diff --git a/hz-pm-api/pom.xml b/hz-pm-api/pom.xml index ee0c566..6825829 100644 --- a/hz-pm-api/pom.xml +++ b/hz-pm-api/pom.xml @@ -12,6 +12,18 @@ + org.openjdk.jmh + jmh-core + 1.37 + test + + + org.openjdk.jmh + jmh-generator-annprocess + 1.37 + test + + com.google.guava guava 33.0.0-jre diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java index 9b002ab..72386fe 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/ProjectStateMachineBuilderImpl.java @@ -3,7 +3,7 @@ package com.hz.pm.api.common.statemachine.builder.impl; import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder; import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.common.statemachine.factory.ProjectGuardFactory; -import com.hz.pm.api.common.statemachine.factory.ProjectGuardFactory.ProjectPurchaseToFirstAcceptGuard; +import com.hz.pm.api.common.statemachine.factory.ProjectGuardFactory.ProjectPurchaseToAcceptGuard; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; import lombok.RequiredArgsConstructor; @@ -32,13 +32,15 @@ import java.util.EnumSet; */ @Slf4j @Component -@EnableStateMachine(name = ProjectStateMachineBuilderImpl.MACHINE_ID) @RequiredArgsConstructor +@EnableStateMachine(name = ProjectStateMachineBuilderImpl.MACHINE_ID) public class ProjectStateMachineBuilderImpl implements BaseStateMachineBuilder { public static final String MACHINE_ID = "projectDeclareStateMachine"; private final BeanFactory beanFactory; + private final ProjectPurchaseToAcceptGuard projectPurchaseToAcceptGuard; + private final ProjectGuardFactory.ProjectPurchaseToAdaptGuard projectPurchaseToAdaptGuard; @Override public StateMachine build() throws StateMachineException { @@ -149,13 +151,15 @@ public class ProjectStateMachineBuilderImpl implements BaseStateMachineBuilder

待初验 .withExternal() .source(ProjectStatus.ON_PURCHASING) .target(ProjectStatus.TO_BE_FIRST_INSPECTED) .event(ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD) - .guard(new ProjectPurchaseToFirstAcceptGuard()) + .guard(projectPurchaseToAcceptGuard) .and() // 填写试试计划 -> 待初验 .withExternal() diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java index e16659a..c1593a1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java @@ -3,7 +3,7 @@ package com.hz.pm.api.common.statemachine.builder.impl; import cn.hutool.core.collection.ListUtil; import com.hz.pm.api.common.statemachine.builder.BaseStateMachineBuilder; import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent; -import com.hz.pm.api.common.statemachine.factory.TenderGuardFactory; +import com.hz.pm.api.common.statemachine.factory.TenderGuardFactory.PurchaseContractRecordToAcceptGuard; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectlib.model.enumeration.status.ITenderStatus; import com.hz.pm.api.projectlib.model.enumeration.status.TenderAdaptStatus; @@ -26,6 +26,8 @@ import org.springframework.stereotype.Component; import java.util.HashSet; import java.util.List; +import static com.hz.pm.api.common.statemachine.factory.TenderGuardFactory.PurchaseContractRecordToOperationGuard; + /** *

* 标段状态机 @@ -36,13 +38,16 @@ import java.util.List; */ @Slf4j @Component -@EnableStateMachine(name = TenderStateMachineBuilderImpl.MACHINE_ID) @RequiredArgsConstructor +@EnableStateMachine(name = TenderStateMachineBuilderImpl.MACHINE_ID) public class TenderStateMachineBuilderImpl implements BaseStateMachineBuilder { public static final String MACHINE_ID = "tenderStateMachine"; private final BeanFactory beanFactory; + private final PurchaseContractRecordToAcceptGuard purchaseContractRecordToAcceptGuard; + private final PurchaseContractRecordToOperationGuard purchaseContractRecordToOperationGuard; + @Override public StateMachine build() throws StateMachineException { @@ -81,12 +86,13 @@ public class TenderStateMachineBuilderImpl implements BaseStateMachineBuilder { + + private IPurchaseService purchaseService; + + @Override + public boolean evaluate(StateContext ctx) { + return !canTurnToAdapt(ctx, purchaseService); + } + } - public static class ProjectPurchaseToFirstAcceptGuard implements Guard { + @AllArgsConstructor + public static class ProjectPurchaseToAdaptGuard implements Guard { - private final IPurchaseService purchaseService = SpringUtils.getBean(IPurchaseService.class); + private IPurchaseService purchaseService; @Override - public boolean evaluate(StateContext stateContext) { - Project project = ProjectStateChangeAction.getProject(stateContext.getMessage()); - Wrapper query = Wrappers.lambdaQuery(Purchase.class) - .select(Purchase::getId, Purchase::getBidType) - .eq(Purchase::getProjectId, project.getId()); - List purchases = purchaseService.list(query); - return CollUtil.allMatch(purchases, w -> !BidTypeEnum.BUILD_APP.eq(w.getBidType())); + public boolean evaluate(StateContext ctx) { + return canTurnToAdapt(ctx, purchaseService); } } + private static boolean canTurnToAdapt(StateContext ctx, + IPurchaseService purchaseService) { + Project project = ProjectStateChangeAction.getProject(ctx.getMessage()); + Wrapper query = Wrappers.lambdaQuery(Purchase.class) + .select(Purchase::getId, Purchase::getBidType) + .eq(Purchase::getProjectId, project.getId()); + List purchases = purchaseService.list(query); + return CollUtil.anyMatch(purchases, w -> BidTypeEnum.BUILD_APP.eq(w.getBidType())); + } + + + @Bean + public ProjectPurchaseToAcceptGuard projectPurchaseToAcceptGuard() { + return new ProjectPurchaseToAcceptGuard(purchaseService); + } + + @Bean + public ProjectPurchaseToAdaptGuard projectPurchaseToAdaptGuard() { + return new ProjectPurchaseToAdaptGuard(purchaseService); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/TenderGuardFactory.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/TenderGuardFactory.java index 95e7a7c..83297d3 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/TenderGuardFactory.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/factory/TenderGuardFactory.java @@ -5,6 +5,8 @@ import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectdeclared.model.enumerization.BidTypeEnum; import com.hz.pm.api.projectlib.model.enumeration.status.ITenderStatus; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.statemachine.StateContext; import org.springframework.statemachine.guard.Guard; @@ -16,12 +18,28 @@ import org.springframework.statemachine.guard.Guard; * @author WendyYang * @since 17:51 2024/8/20 */ +@Configuration public class TenderGuardFactory { - private TenderGuardFactory() { + @Bean + public PurchaseContractRecordToOperationGuard purchaseContractRecordToOperationGuard() { + return new PurchaseContractRecordToOperationGuard(); } - public static class PurchaseContractRecordGuard implements Guard { + @Bean + public PurchaseContractRecordToAcceptGuard purchaseContractRecordToAcceptGuard() { + return new PurchaseContractRecordToAcceptGuard(); + } + + public static class PurchaseContractRecordToOperationGuard implements Guard { + @Override + public boolean evaluate(StateContext context) { + Purchase purchase = TenderStateChangeActionUtil.getPurchaseInfo(context.getMessage()); + return BidTypeEnum.BUILD_APP.eq(purchase.getBidType()); + } + } + + public static class PurchaseContractRecordToAcceptGuard implements Guard { @Override public boolean evaluate(StateContext context) { Purchase purchase = TenderStateChangeActionUtil.getPurchaseInfo(context.getMessage()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AbstractStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AbstractStateMachineUtil.java index f64afc1..1a8ddad 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AbstractStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AbstractStateMachineUtil.java @@ -1,9 +1,10 @@ package com.hz.pm.api.common.statemachine.util; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; import com.hz.pm.api.common.statemachine.event.AbstractStateChangeEvent; import com.ningdatech.basic.exception.BizException; import com.wflow.exception.BusinessException; -import org.slf4j.LoggerFactory; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; @@ -19,6 +20,8 @@ import java.util.function.Function; */ public interface AbstractStateMachineUtil & AbstractStateChangeEvent> { + Log LOG = LogFactory.get(AbstractStateMachineUtil.class); + /** * 获取状态变更事件类型 * @@ -29,12 +32,19 @@ public interface AbstractStateMachineUtil & AbstractStateCh return (Class) ((ParameterizedType) type).getActualTypeArguments()[1]; } + default AbstractStateMachineUtil getLockClass() { + LOG.info("acquire state machine lock:{}", this.getClass().getSimpleName()); + return this; + } + //通过审核 default void pass(O obj) { try { - execute(obj, AbstractStateChangeEvent.getPassEvent(eventClass(), statusFunction().apply(obj))); + synchronized (getLockClass()) { + execute(obj, AbstractStateChangeEvent.getPassEvent(eventClass(), statusFunction().apply(obj))); + } } catch (Exception e) { - LoggerFactory.getLogger(this.getClass()).info("状态机 通过失败", e); + LOG.error("状态机通过失败", e); throw BizException.wrap("状态机通过失败"); } } @@ -43,9 +53,11 @@ public interface AbstractStateMachineUtil & AbstractStateCh //拒绝 default void reject(O obj) { try { - execute(obj, AbstractStateChangeEvent.getRejectEvent(eventClass(), statusFunction().apply(obj))); + synchronized (getLockClass()) { + execute(obj, AbstractStateChangeEvent.getRejectEvent(eventClass(), statusFunction().apply(obj))); + } } catch (Exception e) { - LoggerFactory.getLogger(this.getClass()).info("状态机 拒绝失败 :{}", e.getMessage()); + LOG.error("状态机拒绝失败", e); throw new BusinessException("状态机拒绝失败"); } } @@ -53,9 +65,11 @@ public interface AbstractStateMachineUtil & AbstractStateCh //撤回 default void withDraw(O obj) { try { - execute(obj, AbstractStateChangeEvent.getWithdrawEvent(eventClass(), statusFunction().apply(obj))); + synchronized (getLockClass()) { + execute(obj, AbstractStateChangeEvent.getWithdrawEvent(eventClass(), statusFunction().apply(obj))); + } } catch (Exception e) { - LoggerFactory.getLogger(this.getClass()).info("状态机 撤回失败 :{}", e.getMessage()); + LOG.error("状态机撤回失败", e); throw new BusinessException("状态机撤回失败"); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java index a74f381..83c881c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java @@ -5,10 +5,8 @@ import com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; -import com.hz.pm.api.projectlib.model.enumeration.status.ITenderStatus; import com.hz.pm.api.projectlib.model.enumeration.status.TenderAdaptStatus; import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; -import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; import org.springframework.messaging.support.MessageBuilder; @@ -29,16 +27,23 @@ import java.util.function.Function; */ @Slf4j @Component -@RequiredArgsConstructor public class AdaptStateMachineUtil implements AbstractStateMachineUtil { public static final String PURCHASE = "purchaseInfo"; //================================================================================================================== - private final AdaptStateMachineBuilderImpl adaptStateMachineBuilder; + private final StateMachinePersister stateMachinePersister; + private final StateMachine stateMachine; private final IPurchaseStatusChangeService purchaseStatusChangeService; + public AdaptStateMachineUtil(AdaptStateMachineBuilderImpl adaptStateMachineBuilder, + IPurchaseStatusChangeService purchaseStatusChangeService) { + this.purchaseStatusChangeService = purchaseStatusChangeService; + this.stateMachine = adaptStateMachineBuilder.build(); + this.stateMachinePersister = adaptStateMachineBuilder.stateMachinePersister(); + } + @Override public Function statusFunction() { return Purchase::getAdaptStatus; @@ -46,8 +51,6 @@ public class AdaptStateMachineUtil implements AbstractStateMachineUtil stateMachine = adaptStateMachineBuilder.build(); Message message = MessageBuilder.withPayload(event) .setHeader(PURCHASE, purchase) .build(); //初始化状态机 - StateMachinePersister stateMachinePersister = adaptStateMachineBuilder.stateMachinePersister(); stateMachinePersister.restore(stateMachine, purchase); stateMachine.sendEvent(message); change.setAfterStatus(purchase.getAdaptStatus()); purchaseStatusChangeService.save(change); - log.info("调用状态机后的标段状态为:{}", purchase.getAdaptStatus()); + log.info("调用状态机后的标段状态为:{} ==> {}", change.getBeforeStatus(), change.getAfterStatus()); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/ProjectStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/ProjectStateMachineUtil.java index b7050d4..1f0d44b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/ProjectStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/ProjectStateMachineUtil.java @@ -27,7 +27,6 @@ import java.util.function.Function; */ @Slf4j @Component -@RequiredArgsConstructor public class ProjectStateMachineUtil implements AbstractStateMachineUtil { private static final String PROJECT_DECLARE = StateMachineConst.PROJECT_DECLARE; @@ -36,12 +35,20 @@ public class ProjectStateMachineUtil implements AbstractStateMachineUtil stateMachinePersister; + private final StateMachine stateMachine; private final IProjectStatusChangeService projectStatusChangeService; - private final IProjectApplicationService projectApplicationService; + public ProjectStateMachineUtil(ProjectStateMachineBuilderImpl projectStateMachineBuilder, + IProjectStatusChangeService projectStatusChangeService, + IProjectApplicationService projectApplicationService) { + this.projectStatusChangeService = projectStatusChangeService; + this.projectApplicationService = projectApplicationService; + this.stateMachinePersister = projectStateMachineBuilder.stateMachinePersister(); + this.stateMachine = projectStateMachineBuilder.build(); + } + @Override public Function statusFunction() { return Project::getStatus; @@ -49,29 +56,25 @@ public class ProjectStateMachineUtil implements AbstractStateMachineUtil stateMachine = projectStateMachineBuilder.build(); Message message = MessageBuilder.withPayload(event) .setHeader(PROJECT_DECLARE, project) .setHeader(APPLICATION_DECLARE, projectApplicationService.getApplicationsByProject(project)) .build(); //初始化状态机 - StateMachinePersister projectDeclareStateMachinePersister = projectStateMachineBuilder.stateMachinePersister(); - projectDeclareStateMachinePersister.restore(stateMachine, project); + stateMachinePersister.restore(stateMachine, project); stateMachine.sendEvent(message); - projectStatusChange.setProjectId(project.getId()); - projectStatusChange.setAfterStatus(project.getStatus()); - projectStatusChange.setEvent(event.name()); - projectStatusChange.setCreateOn(LocalDateTime.now()); - projectStatusChange.setProjectCode(project.getProjectCode()); + change.setProjectId(project.getId()); + change.setAfterStatus(project.getStatus()); + change.setEvent(event.name()); + change.setCreateOn(LocalDateTime.now()); + change.setProjectCode(project.getProjectCode()); // 插入项目状态变更表中 - projectStatusChangeService.save(projectStatusChange); - log.info("调用状态机后的项目状态为:{}", project.getStatus()); + projectStatusChangeService.save(change); + log.info("调用状态机后的标段状态为:{} ==> {}", change.getBeforeStatus(), change.getAfterStatus()); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java index 25f096d..513a8ba 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java @@ -28,15 +28,21 @@ import java.util.function.Function; */ @Slf4j @Component -@RequiredArgsConstructor public class SelfTestStateMachineUtil implements AbstractStateMachineUtil { public static final String PURCHASE = "purchaseInfo"; //================================================================================================================== - private final SelfTestStateMachineBuilderImpl selfTestStateMachineBuilder; private final IPurchaseStatusChangeService purchaseStatusChangeService; + private final StateMachinePersister stateMachinePersister; + private final StateMachine stateMachine; + + public SelfTestStateMachineUtil(SelfTestStateMachineBuilderImpl selfTestStateMachineBuilder, IPurchaseStatusChangeService purchaseStatusChangeService) { + this.purchaseStatusChangeService = purchaseStatusChangeService; + this.stateMachinePersister = selfTestStateMachineBuilder.stateMachinePersister(); + this.stateMachine = selfTestStateMachineBuilder.build(); + } @Override public Function statusFunction() { @@ -45,7 +51,6 @@ public class SelfTestStateMachineUtil implements AbstractStateMachineUtil stateMachine = selfTestStateMachineBuilder.build(); Message message = MessageBuilder.withPayload(event) .setHeader(PURCHASE, purchase) .build(); //初始化状态机 - StateMachinePersister stateMachinePersister = selfTestStateMachineBuilder.stateMachinePersister(); stateMachinePersister.restore(stateMachine, purchase); stateMachine.sendEvent(message); change.setAfterStatus(purchase.getSelfTestStatus()); purchaseStatusChangeService.save(change); - log.info("调用状态机后的标段状态为:{}", purchase.getSelfTestStatus()); + log.info("调用状态机后的标段状态为:{} ==> {}", change.getBeforeStatus(), change.getAfterStatus()); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java index c792a0e..983e34d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TenderStateMachineUtil.java @@ -1,6 +1,5 @@ package com.hz.pm.api.common.statemachine.util; -import cn.hutool.core.util.ObjUtil; import com.hz.pm.api.common.statemachine.builder.impl.TenderStateMachineBuilderImpl; import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent; import com.hz.pm.api.projectdeclared.model.entity.Purchase; @@ -30,15 +29,21 @@ import java.util.function.Function; */ @Slf4j @Component -@RequiredArgsConstructor public class TenderStateMachineUtil implements AbstractStateMachineUtil { public static final String PURCHASE = "purchaseInfo"; //================================================================================================================== - private final TenderStateMachineBuilderImpl tenderStateMachineBuilder; private final IPurchaseStatusChangeService purchaseStatusChangeService; + private final StateMachinePersister stateMachinePersister; + private final StateMachine stateMachine; + + public TenderStateMachineUtil(IPurchaseStatusChangeService purchaseStatusChangeService, TenderStateMachineBuilderImpl tenderStateMachineBuilder) { + this.purchaseStatusChangeService = purchaseStatusChangeService; + this.stateMachinePersister = tenderStateMachineBuilder.stateMachinePersister(); + this.stateMachine = tenderStateMachineBuilder.build(); + } @Override public Function statusFunction() { @@ -47,7 +52,6 @@ public class TenderStateMachineUtil implements AbstractStateMachineUtil stateMachine = tenderStateMachineBuilder.build(); Message message = MessageBuilder.withPayload(event) .setHeader(PURCHASE, purchase) .build(); //初始化状态机 - StateMachinePersister stateMachinePersister = tenderStateMachineBuilder.stateMachinePersister(); stateMachinePersister.restore(stateMachine, purchase); stateMachine.sendEvent(message); change.setAfterStatus(purchase.getStatus()); purchaseStatusChangeService.save(change); - if (ObjUtil.equal(change.getBeforeStatus(), change.getBeforeStatus())) { - log.error("状态变更失败:{} {}", purchase, event); - throw BizException.wrap("状态变更失败"); - } - log.info("调用状态机后的标段状态为:{}", purchase.getStatus()); + log.info("调用状态机后的标段状态为:{} ==> {}", change.getBeforeStatus(), change.getAfterStatus()); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java index 58ff54c..5e069d8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java @@ -45,8 +45,6 @@ public class TestValidStateMachineUtil implements AbstractStateMachineUtil {}", change.getBeforeStatus(), change.getAfterStatus()); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/XcfhxStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/XcfhxStateMachineUtil.java index f41cf4b..f4f1127 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/XcfhxStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/XcfhxStateMachineUtil.java @@ -28,15 +28,22 @@ import java.util.function.Function; */ @Slf4j @Component -@RequiredArgsConstructor public class XcfhxStateMachineUtil implements AbstractStateMachineUtil { public static final String PURCHASE = "purchaseInfo"; //================================================================================================================== - private final XcfhxStateMachineBuilderImpl xcfhxStateMachineBuilder; private final IPurchaseStatusChangeService purchaseStatusChangeService; + private final StateMachinePersister stateMachinePersister; + private final StateMachine stateMachine; + + public XcfhxStateMachineUtil(XcfhxStateMachineBuilderImpl xcfhxStateMachineBuilder, + IPurchaseStatusChangeService purchaseStatusChangeService) { + this.purchaseStatusChangeService = purchaseStatusChangeService; + this.stateMachine = xcfhxStateMachineBuilder.build(); + this.stateMachinePersister = xcfhxStateMachineBuilder.stateMachinePersister(); + } @Override public Function statusFunction() { @@ -45,8 +52,6 @@ public class XcfhxStateMachineUtil implements AbstractStateMachineUtil stateMachine = xcfhxStateMachineBuilder.build(); Message message = MessageBuilder.withPayload(event) .setHeader(PURCHASE, purchase) .build(); //初始化状态机 - StateMachinePersister stateMachinePersister = xcfhxStateMachineBuilder.stateMachinePersister(); stateMachinePersister.restore(stateMachine, purchase); stateMachine.sendEvent(message); change.setAfterStatus(purchase.getXcfhxApplyStatus()); purchaseStatusChangeService.save(change); - log.info("调用状态机后的标段状态为:{}", purchase.getXcfhxApplyStatus()); + log.info("调用状态机后的标段状态为:{} ==> {}", change.getBeforeStatus(), change.getAfterStatus()); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ThreadPoolUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ThreadPoolUtil.java index cd8584a..a09fb84 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ThreadPoolUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ThreadPoolUtil.java @@ -28,7 +28,6 @@ public class ThreadPoolUtil { static { ThreadPoolUtilProperties properties = SpringUtil.getBean(ThreadPoolUtilProperties.class); - log.info("ThreadPoolUtilProperties:{}", properties); ThreadPoolProperties requestProps = properties.getRequest(); REQUEST = new MDCThreadPoolTaskExecutor(); REQUEST.setCorePoolSize(requestProps.getCorePoolSize()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/ExpertInviteExecutorConfig.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/ExpertInviteExecutorConfig.java index f73bf5d..898f866 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/ExpertInviteExecutorConfig.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/ExpertInviteExecutorConfig.java @@ -1,5 +1,7 @@ package com.hz.pm.api.meeting.task; +import com.hz.pm.api.common.config.ThreadPoolUtilProperties.ThreadPoolProperties; +import com.hz.pm.api.common.util.MDCThreadPoolTaskScheduler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; @@ -16,13 +18,14 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; public class ExpertInviteExecutorConfig { @Bean(name = "expertInviteScheduler") - public ThreadPoolTaskScheduler threadPoolTaskScheduler() { - ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); - scheduler.setPoolSize(3); + public ThreadPoolTaskScheduler threadPoolTaskScheduler(RandomInviteProperties properties) { + ThreadPoolProperties threadPoolProperties = properties.getThreadPoolProperties(); + MDCThreadPoolTaskScheduler scheduler = new MDCThreadPoolTaskScheduler(); + scheduler.setPoolSize(threadPoolProperties.getCorePoolSize()); scheduler.setThreadGroupName("expert-invite"); - scheduler.setThreadNamePrefix("invite-executor-"); - scheduler.setAwaitTerminationSeconds(60); - scheduler.setWaitForTasksToCompleteOnShutdown(true); + scheduler.setThreadNamePrefix(threadPoolProperties.getThreadNamePrefix()); + scheduler.setAwaitTerminationSeconds(120); + scheduler.setWaitForTasksToCompleteOnShutdown(threadPoolProperties.getWaitForTasksToCompleteOnShutdown()); return scheduler; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java index b0b6970..0e82572 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java @@ -48,13 +48,15 @@ public class MsgCallReplyRewriteTask { static { // 初始化线程池 EXECUTOR = new MDCThreadPoolTaskExecutor(); + EXECUTOR.setBeanName("msgCallReplyRewriteExecutor"); EXECUTOR.setCorePoolSize(2); EXECUTOR.setMaxPoolSize(4); EXECUTOR.setQueueCapacity(100); EXECUTOR.setKeepAliveSeconds(120); - EXECUTOR.setThreadPriority(Thread.NORM_PRIORITY); + EXECUTOR.setThreadPriority(Thread.NORM_PRIORITY - 1); EXECUTOR.setWaitForTasksToCompleteOnShutdown(true); EXECUTOR.setThreadNamePrefix("callRewriteExecutor-"); + EXECUTOR.setAllowCoreThreadTimeOut(true); EXECUTOR.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/RandomInviteProperties.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/RandomInviteProperties.java index 2b674b3..7f4a3f3 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/RandomInviteProperties.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/RandomInviteProperties.java @@ -1,7 +1,10 @@ package com.hz.pm.api.meeting.task; +import com.hz.pm.api.common.config.ThreadPoolUtilProperties; +import com.hz.pm.api.common.config.ThreadPoolUtilProperties.ThreadPoolProperties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.stereotype.Component; /** @@ -56,4 +59,7 @@ public class RandomInviteProperties { private Integer inviteEndHour = 20; + @NestedConfigurationProperty + private ThreadPoolProperties threadPoolProperties; + } diff --git a/hz-pm-api/src/main/resources/application-dev.yml b/hz-pm-api/src/main/resources/application-dev.yml index c2ea566..8b16536 100644 --- a/hz-pm-api/src/main/resources/application-dev.yml +++ b/hz-pm-api/src/main/resources/application-dev.yml @@ -224,4 +224,8 @@ thread-pool-util: thread-name-prefix: request-executor- scheduler: core-pool-size: 2 - thread-name-prefix: scheduler-executor- \ No newline at end of file + thread-name-prefix: scheduler-executor- +random-invite: + thread-pool-properties: + core-pool-size: 2 + thread-name-prefix: expert-invite-executor- \ No newline at end of file diff --git a/hz-pm-api/src/main/resources/application-prod.yml b/hz-pm-api/src/main/resources/application-prod.yml index 8d92e3d..9efb5b9 100644 --- a/hz-pm-api/src/main/resources/application-prod.yml +++ b/hz-pm-api/src/main/resources/application-prod.yml @@ -248,3 +248,7 @@ wflow-thread-pool-util: queue-capacity: 300 keep-alive-seconds: 120 max-pool-size: 8 +random-invite: + thread-pool-properties: + core-pool-size: 3 + thread-name-prefix: expert-invite-executor- \ No newline at end of file diff --git a/hz-pm-api/src/test/java/com/hz/pm/api/common/StateMachineTest.java b/hz-pm-api/src/test/java/com/hz/pm/api/common/StateMachineTest.java new file mode 100644 index 0000000..8e32776 --- /dev/null +++ b/hz-pm-api/src/test/java/com/hz/pm/api/common/StateMachineTest.java @@ -0,0 +1,46 @@ +package com.hz.pm.api.common; + +import com.hz.pm.api.AppTests; +import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; +import com.hz.pm.api.common.statemachine.util.XcfhxStateMachineUtil; +import com.hz.pm.api.common.util.ThreadPoolUtil; +import com.hz.pm.api.projectdeclared.model.entity.Purchase; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.concurrent.CountDownLatch; + +/** + *

+ * StateMachineTest + *

+ * + * @author WendyYang + * @since 19:43 2024/8/29 + */ +public class StateMachineTest extends AppTests { + + @Autowired + private TenderStateMachineUtil tenderStateMachineUtil; + @Autowired + private XcfhxStateMachineUtil xcfhxStateMachineUtil; + + @Test + public void test() { + CountDownLatch count = new CountDownLatch(1000); + for (int j = 0; j < 100; j++) { + ThreadPoolUtil.REQUEST.execute(() -> { + Purchase purchase = new Purchase(); + purchase.setProjectId(3496L); + for (int i = 0; i < 5; i++) { + purchase.setBidType(i % 2 == 0 ? 2 : 1); + purchase.setStatus(101); + purchase.setXcfhxApplyStatus(301); + xcfhxStateMachineUtil.pass(purchase); + } + count.countDown(); + }); + } + } + +} diff --git a/hz-pm-api/src/test/resources/application-dev.yml b/hz-pm-api/src/test/resources/application-dev.yml index ff43fda..b9d5c9e 100644 --- a/hz-pm-api/src/test/resources/application-dev.yml +++ b/hz-pm-api/src/test/resources/application-dev.yml @@ -16,7 +16,7 @@ spring: timeout: 5000 host: 47.98.125.47 port: 26379 - database: 5 + database: 7 password: Ndkj1234 jedis: pool: @@ -153,17 +153,6 @@ sa-token: # 是否输出操作日志 is-log: false -yxt: - # wsdl-url: http://115.239.137.23:9501/ws/v1?wsdl - wsdl-url: classpath:/wsdl.xml - #账号 - user-code: hzndkj - #密码 - password: hzndkj@2021 - #音信通开关 - sms-enable: true - tel-enable: true - login: phone-verify-code: skip: true @@ -176,26 +165,63 @@ sync-mh-user: sync-mh-company: open: false mh: - zwdd-work-notice: + sso: client-id: ningda-74a5e5da-3bc3-414a-b9e6-004b7d87e310 client-secret: ningda-df746ce4-0c79-4242-b3c7-90ff8630c9742c6727cd-3ae7-48ae-87ad-2b39188ebabd - sso: + zwdd-work-notice: client-id: ningda-74a5e5da-3bc3-414a-b9e6-004b7d87e310 client-secret: ningda-df746ce4-0c79-4242-b3c7-90ff8630c9742c6727cd-3ae7-48ae-87ad-2b39188ebabd - api-host: https://hzszxc.hzswb.cn:8443/mh-gateway/auth-single + api-host: https://hzszxc.hzswb.cn:8443/test/mh-gateway/auth-single expert-qr-code-url: https://jiema.wwei.cn/uploads/2023/12/28/658d7a3f15f06.jpg file: down-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/previewFileLogin detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList upload-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/uploadFileSkipLogin + file-preview: + public-host: http://ztzz2.hzswb.cn/yl + auth-code: secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 agent-login: proxy: secret-key: nqkwiqojg7g4eiypr3rb8s7nb4noa8b2 -# 短信服务地址 sms-send: host: http://10.54.38.13:8081/mh-gateway/auth-single -# 电话服务地址 +sms-client: + host: http://10.54.38.13:8081/mh-gateway/auth-single + open: false + mobile-call: - host: http://183.158.240.86:18181/blue_esl_api \ No newline at end of file + host: http://183.158.240.86:18181/blue_esl_api + +# 提醒任务 +reminder-task: + declared-record: + open: false + cron: 0 30 8 * * ? +hz-pm: + interfaceKey: hz_meeting_expert_info + +web: + login: + url: http://hzpm.ningdatech.com + api: + url: http://hzpm.ningdatech.com/hzpm + +expert-invite: + skip-send-call: true + skip-send-sms: true + +mh-system-replace-sync: + open: false + +thread-pool-util: + request: + core-pool-size: 5 + max-pool-size: 10 + queue-capacity: 100 + keep-alive-seconds: 120 + thread-name-prefix: request-executor- + scheduler: + core-pool-size: 2 + thread-name-prefix: scheduler-executor- \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2d0c6b0..2545291 100644 --- a/pom.xml +++ b/pom.xml @@ -103,7 +103,7 @@ org.springframework.statemachine spring-statemachine-core - 2.0.1.RELEASE + 2.2.0.RELEASE com.github.oshi From b8207853d58b3d2c38518289b70a47c68c037773 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 29 Aug 2024 11:39:36 +0800 Subject: [PATCH 06/11] =?UTF-8?q?modify:=201.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=98=AF=E5=8C=BA=E5=8E=BF=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hz/pm/api/common/model/constant/MhUnitConst.java | 2 ++ .../src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java | 8 +++++--- .../main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java | 3 +++ .../java/com/hz/pm/api/user/security/model/UserInfoDetails.java | 5 +++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java index c6ff5c6..7222c3b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java @@ -16,6 +16,8 @@ public class MhUnitConst { private MhUnitConst() { } + public static final long COUNTY_PARENT_UNIT_ID = 1084; + public static final long ROOT_UNIT_ID = 1; public static final String UNIT_XCB = "信创办"; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java index ade128d..fea19e2 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java @@ -26,6 +26,7 @@ import com.hz.pm.api.user.model.vo.ResUserDetailVO; import com.hz.pm.api.user.model.vo.UserInfoListVO; import com.hz.pm.api.user.model.vo.UserRoleVO; import com.hz.pm.api.user.security.model.UserFullInfoDTO; +import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.service.IUserInfoService; import com.hz.pm.api.user.util.LoginUserUtil; import com.ningdatech.basic.exception.BizException; @@ -267,8 +268,8 @@ public class UserInfoManage { public ResUserDetailVO currentUserInfo() { - Long userId = LoginUserUtil.getUserId(); - UserInfo userInfo = userInfoService.getById(userId); + UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); + UserInfo userInfo = userInfoService.getById(userDetail.getUserId()); if (Objects.isNull(userInfo)) { return null; } @@ -286,7 +287,7 @@ public class UserInfoManage { resUserDetail.setMhUnitName(userInfo.getMhUnitName()); // 装配用户角色信息列表 - List userRoleList = userRoleService.listByUserId(userId); + List userRoleList = userRoleService.listByUserId(userDetail.getUserId()); if (CollUtil.isNotEmpty(userRoleList)) { List roleIdList = CollUtils.fieldList(userRoleList, UserRole::getRoleId); List roleList = roleService.listByIds(roleIdList); @@ -299,6 +300,7 @@ public class UserInfoManage { }).collect(Collectors.toList()); resUserDetail.setUserRoleInfoList(userRoles); } + resUserDetail.setIsCountyUser(userDetail.isCountyUser()); return resUserDetail; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java index 0b72723..4f80066 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java @@ -51,4 +51,7 @@ public class ResUserDetailVO { @ApiModelProperty("头像") private String avatar; + @ApiModelProperty("是否是区县用户") + private Boolean isCountyUser; + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java index 1e5f722..49bbf6e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java @@ -2,6 +2,7 @@ package com.hz.pm.api.user.security.model; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import com.hz.pm.api.common.model.constant.MhUnitConst; import com.hz.pm.api.sys.model.entity.Role; import com.hz.pm.api.user.model.enumeration.RoleEnum; import com.ningdatech.basic.auth.AbstractLoginUser; @@ -162,4 +163,8 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { return Collections.emptyList(); } + public boolean isCountyUser() { + return getMhUnitId().equals(MhUnitConst.COUNTY_PARENT_UNIT_ID); + } + } From 3fc4e643ae86f3b6ddc28963107f060abc84edb5 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 30 Aug 2024 13:24:10 +0800 Subject: [PATCH 07/11] =?UTF-8?q?modify:=201.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8C=BA=E5=8E=BF=E7=94=A8=E6=88=B7=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java | 6 +++++- .../api/projectdeclared/model/req/SubmitPurchaseNoticeReq.java | 2 +- .../main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java | 1 + .../src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java | 2 +- .../java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java | 4 ++++ .../java/com/hz/pm/api/user/security/model/UserInfoDetails.java | 9 +++++---- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java index db66c56..26eb4a7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java @@ -6,11 +6,13 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; 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.MhUnitConst; 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.helper.MhUnitCache; 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; @@ -38,6 +40,7 @@ public class UserInfoHelperImpl implements UserInfoHelper { private final IUserInfoService userInfoService; private final IUserRoleService iUserRoleService; private final RoleMapper roleMapper; + private final MhUnitCache mhUnitCache; @Override public UserFullInfoDTO getUserFullInfoByMhUserIdOrOpenId(String mhUserId) { @@ -73,7 +76,8 @@ public class UserInfoHelperImpl implements UserInfoHelper { .collect(Collectors.toList()); userFullInfo.setUserRoleList(roleMapper.selectBatchIds(roleIdList)); } - + List viewUnitIds = mhUnitCache.getViewChildIdsRecursion(MhUnitConst.COUNTY_PARENT_UNIT_ID); + userFullInfo.setIsCountyUser(viewUnitIds.contains(userInfo.getMhUnitId())); // 装配返回 userFullInfo.setUserId(userInfo.getId()); userFullInfo.setMhUserId(userInfo.getMhUserId()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/SubmitPurchaseNoticeReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/SubmitPurchaseNoticeReq.java index 9f8af6a..f24dabb 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/SubmitPurchaseNoticeReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/SubmitPurchaseNoticeReq.java @@ -69,7 +69,7 @@ public class SubmitPurchaseNoticeReq { private String purchaseMethod; @ApiModelProperty("是否发布信创云图") - public Boolean publishMhNotice; + private Boolean publishMhNotice; @ApiModelProperty("采购范围:1 公开采购、2 非公开采购") private Integer purchaseScope; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java index c0b27bf..fb0b7fa 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java @@ -29,6 +29,7 @@ public class UserInfoConvertor { userInfoDetails.setMhUnitName(userFullInfo.getMhUnitName()); userInfoDetails.setMobile(userFullInfo.getMobile()); userInfoDetails.setMhUserId(userFullInfo.getMhUserId()); + userInfoDetails.setIsCountyUser(userFullInfo.getIsCountyUser()); return userInfoDetails; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java index fea19e2..a747909 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java @@ -300,7 +300,7 @@ public class UserInfoManage { }).collect(Collectors.toList()); resUserDetail.setUserRoleInfoList(userRoles); } - resUserDetail.setIsCountyUser(userDetail.isCountyUser()); + resUserDetail.setIsCountyUser(userDetail.getIsCountyUser()); return resUserDetail; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java index 80e70ad..d76d3f7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java @@ -51,6 +51,10 @@ public class UserFullInfoDTO { */ private UserAvailableEnum available; + /** + * 是否是区县用户 + */ + private Boolean isCountyUser; /** * 取最高的权限 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java index 49bbf6e..ed9b669 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java @@ -57,6 +57,11 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { private String mobile; + /** + * 是否是区县用户 + */ + private Boolean isCountyUser; + public String getUserIdStr() { return String.valueOf(getUserId()); } @@ -163,8 +168,4 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { return Collections.emptyList(); } - public boolean isCountyUser() { - return getMhUnitId().equals(MhUnitConst.COUNTY_PARENT_UNIT_ID); - } - } From 3c4abdc34adc17300e8877030397f16bca3b8d05 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 30 Aug 2024 15:10:56 +0800 Subject: [PATCH 08/11] =?UTF-8?q?modify:=201.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8C=BA=E5=8E=BF=E7=94=A8=E6=88=B7=E3=80=81?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=9B=BD=E6=9C=89=E4=BC=81=E4=B8=9A=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E3=80=81=E6=98=AF=E5=90=A6=E9=87=8D=E7=82=B9=E8=A1=8C?= =?UTF-8?q?=E4=B8=9A=E7=94=A8=E6=88=B7=E3=80=81=E6=98=AF=E5=90=A6=E5=B8=82?= =?UTF-8?q?=E6=9C=AC=E7=BA=A7=E7=94=A8=E6=88=B7=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/common/helper/impl/UserInfoHelperImpl.java | 30 +++++++++++++++++++--- .../pm/api/common/model/constant/MhUnitConst.java | 16 ++++++++++++ .../com/hz/pm/api/common/util/ThreadPoolUtil.java | 1 - .../com/hz/pm/api/user/manage/UserInfoManage.java | 8 +++--- .../hz/pm/api/user/model/vo/ResUserDetailVO.java | 15 +++++++++++ .../api/user/security/model/UserFullInfoDTO.java | 17 ++++++++++++ .../api/user/security/model/UserInfoDetails.java | 17 ++++++++++++ 7 files changed, 95 insertions(+), 9 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java index 26eb4a7..38a3716 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java @@ -13,6 +13,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.IUserRoleService; import com.hz.pm.api.user.helper.MhUnitCache; +import com.hz.pm.api.user.model.dto.UnitDTO; 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; @@ -76,8 +77,29 @@ public class UserInfoHelperImpl implements UserInfoHelper { .collect(Collectors.toList()); userFullInfo.setUserRoleList(roleMapper.selectBatchIds(roleIdList)); } - List viewUnitIds = mhUnitCache.getViewChildIdsRecursion(MhUnitConst.COUNTY_PARENT_UNIT_ID); - userFullInfo.setIsCountyUser(viewUnitIds.contains(userInfo.getMhUnitId())); + UnitDTO unit = mhUnitCache.getById(userInfo.getMhUnitId()); + if (unit != null && unit.getType() != null) { + userFullInfo.setUnitStrip(unit.getType().getStrip().getCode()); + // 是否市属国有企业下用户 + List citySoeUnitIds = mhUnitCache.getViewChildIdsRecursion(MhUnitConst.CITY_SOE_UNIT_ID); + userFullInfo.setIsCitySoeUser(citySoeUnitIds.contains(userInfo.getMhUnitId())); + if (!userFullInfo.getIsCitySoeUser()) { + // 是否关键行业部门下用户 + List keyIndustryUnitIds = mhUnitCache.getViewChildIdsRecursion(MhUnitConst.KEY_INDUSTRY_UNIT_ID); + userFullInfo.setIsKeyIndustryUser(keyIndustryUnitIds.contains(userInfo.getMhUnitId())); + if (!userFullInfo.getIsKeyIndustryUser()) { + // 是否区县部门下用户 + List countyUnitIds = mhUnitCache.getViewChildIdsRecursion(MhUnitConst.COUNTY_PARENT_UNIT_ID); + userFullInfo.setIsCountyUser(countyUnitIds.contains(userInfo.getMhUnitId())); + if (!userFullInfo.getIsCountyUser()) { + // 是否市本级用户 + List cityDistrictUnitIds = mhUnitCache.getViewChildIdsRecursion(MhUnitConst.CITY_DISTRICT_UNIT_ID); + userFullInfo.setIsCityDistrictUser(cityDistrictUnitIds.contains(userInfo.getMhUnitId())); + } + } + } + } + // 装配返回 userFullInfo.setUserId(userInfo.getId()); userFullInfo.setMhUserId(userInfo.getMhUserId()); @@ -109,7 +131,7 @@ public class UserInfoHelperImpl implements UserInfoHelper { return userInfos.stream().map(this::convert).collect(Collectors.toList()); } - private UserFullInfoDTO convert(UserInfo userInfo){ + private UserFullInfoDTO convert(UserInfo userInfo) { UserFullInfoDTO userFullInfo = new UserFullInfoDTO(); // 装配返回 userFullInfo.setMhUnitName(userInfo.getMhUnitName()); @@ -168,7 +190,7 @@ public class UserInfoHelperImpl implements UserInfoHelper { .exists("select 1 from nd_user_role nur where nur.user_id = nd_user_info.id" + " and nur.role_id = {0}", role.getId()); List userInfos = userInfoService.list(query); - return CollUtils.convert(userInfos,this::convert); + return CollUtils.convert(userInfos, this::convert); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java index 7222c3b..006b741 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java @@ -16,6 +16,22 @@ public class MhUnitConst { private MhUnitConst() { } + /** + * 重点行业 + */ + public static final long KEY_INDUSTRY_UNIT_ID = 6788; + + /** + * 市级部门 + */ + public static final long CITY_DISTRICT_UNIT_ID = 970; + /** + * 市属国有企业 + */ + public static final long CITY_SOE_UNIT_ID = 3269; + /** + * 区县部门 + */ public static final long COUNTY_PARENT_UNIT_ID = 1084; public static final long ROOT_UNIT_ID = 1; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ThreadPoolUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ThreadPoolUtil.java index a09fb84..a883990 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ThreadPoolUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ThreadPoolUtil.java @@ -46,7 +46,6 @@ public class ThreadPoolUtil { SCHEDULER.setPoolSize(schedulerProps.getCorePoolSize()); SCHEDULER.setThreadPriority(Thread.NORM_PRIORITY - 1); SCHEDULER.setWaitForTasksToCompleteOnShutdown(schedulerProps.getWaitForTasksToCompleteOnShutdown()); - SCHEDULER.setThreadNamePrefix("scheduler-"); SCHEDULER.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); SCHEDULER.initialize(); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java index a747909..979d7d7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java @@ -280,10 +280,7 @@ public class UserInfoManage { resUserDetail.setStatus(userInfo.getAvailable()); resUserDetail.setEmployeeCode(userInfo.getEmployeeCode()); resUserDetail.setMhUnitId(userInfo.getMhUnitId()); - UnitDTO unit = mhUnitCache.getById(userInfo.getMhUnitId()); - if (unit != null && unit.getType() != null) { - resUserDetail.setUnitStrip(unit.getType().getStrip().getCode()); - } + resUserDetail.setUnitStrip(userDetail.getUnitStrip()); resUserDetail.setMhUnitName(userInfo.getMhUnitName()); // 装配用户角色信息列表 @@ -301,6 +298,9 @@ public class UserInfoManage { resUserDetail.setUserRoleInfoList(userRoles); } resUserDetail.setIsCountyUser(userDetail.getIsCountyUser()); + resUserDetail.setIsCityDistrictUser(userDetail.getIsCityDistrictUser()); + resUserDetail.setIsCityDistrictUser(userDetail.getIsCitySoeUser()); + resUserDetail.setIsKeyIndustryUser(userDetail.getIsKeyIndustryUser()); return resUserDetail; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java index 4f80066..f95c6fe 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java @@ -54,4 +54,19 @@ public class ResUserDetailVO { @ApiModelProperty("是否是区县用户") private Boolean isCountyUser; + /** + * 是否是市属国有企业用户 + */ + private Boolean isCitySoeUser; + + /** + * 是否是市级单位用户 + */ + private Boolean isCityDistrictUser; + + /** + * 是否是重点行业用户 + */ + private Boolean isKeyIndustryUser; + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java index d76d3f7..0d617b7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java @@ -57,6 +57,23 @@ public class UserFullInfoDTO { private Boolean isCountyUser; /** + * 是否是市属国有企业 + */ + private Boolean isCitySoeUser; + + /** + * 是否是市级单位 + */ + private Boolean isCityDistrictUser; + + /** + * 是否是重点行业 + */ + private Boolean isKeyIndustryUser; + + private Integer unitStrip; + + /** * 取最高的权限 * * @return \ diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java index ed9b669..ad4e611 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java @@ -62,6 +62,23 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { */ private Boolean isCountyUser; + /** + * 是否是市属国有企业 + */ + private Boolean isCitySoeUser; + + /** + * 是否是市级单位 + */ + private Boolean isCityDistrictUser; + + /** + * 是否是重点行业 + */ + private Boolean isKeyIndustryUser; + + private Integer unitStrip; + public String getUserIdStr() { return String.valueOf(getUserId()); } From 32d1b8ccf59902e6b8185395819c1d921a1183da Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 30 Aug 2024 15:19:36 +0800 Subject: [PATCH 09/11] =?UTF-8?q?modify:=201.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8C=BA=E5=8E=BF=E7=94=A8=E6=88=B7=E3=80=81?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=9B=BD=E6=9C=89=E4=BC=81=E4=B8=9A=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E3=80=81=E6=98=AF=E5=90=A6=E9=87=8D=E7=82=B9=E8=A1=8C?= =?UTF-8?q?=E4=B8=9A=E7=94=A8=E6=88=B7=E3=80=81=E6=98=AF=E5=90=A6=E5=B8=82?= =?UTF-8?q?=E6=9C=AC=E7=BA=A7=E7=94=A8=E6=88=B7=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java index fb0b7fa..b88f79c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java @@ -30,6 +30,9 @@ public class UserInfoConvertor { userInfoDetails.setMobile(userFullInfo.getMobile()); userInfoDetails.setMhUserId(userFullInfo.getMhUserId()); userInfoDetails.setIsCountyUser(userFullInfo.getIsCountyUser()); + userInfoDetails.setIsCitySoeUser(userFullInfo.getIsCitySoeUser()); + userInfoDetails.setIsCityDistrictUser(userFullInfo.getIsCityDistrictUser()); + userInfoDetails.setIsKeyIndustryUser(userFullInfo.getIsKeyIndustryUser()); return userInfoDetails; } From dadab3a4dbca27294ec8f1aeb3f988fb0e63201c Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 30 Aug 2024 16:03:59 +0800 Subject: [PATCH 10/11] =?UTF-8?q?modify:=201.=20=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E9=98=B6=E6=AE=B5=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml index 9547743..52e7ac5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml @@ -359,6 +359,9 @@ and p.status = #{req.status} + + and p.stage = #{req.stage} + and p.project_year = #{req.projectYear} From 0cb5d03a6188515f1c3c596409958f9c24605b58 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 30 Aug 2024 17:05:23 +0800 Subject: [PATCH 11/11] =?UTF-8?q?modify:=201.=20=E6=8B=9B=E6=A0=87?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E3=80=81=E9=A1=B9=E7=9B=AE=E7=AB=8B=E9=A1=B9?= =?UTF-8?q?=E3=80=81=E9=80=82=E9=85=8D=E6=94=B9=E9=80=A0=E3=80=81=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=BA=93=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/projectdeclared/controller/PurchaseController.java | 4 ++-- .../com/hz/pm/api/projectdeclared/manage/PurchaseManage.java | 12 +++++++++++- .../java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml | 12 ++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java index 0b736ab..0c369d0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/PurchaseController.java @@ -88,8 +88,8 @@ public class PurchaseController { @GetMapping("/adaptionProgressStatistics") @ApiOperation("获取采购进度统计") - public AdaptionProgressStatVO adaptionProgressStatistics() { - return purchaseManage.adaptionProgressStatistics(); + public AdaptionProgressStatVO adaptionProgressStatistics(PurchaseAdaptionListReq req) { + return purchaseManage.adaptionProgressStatistics(req); } @GetMapping("/pageAdaption") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index 2b19e00..16d7471 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -540,7 +540,7 @@ public class PurchaseManage { projectService.updateById(project); } - public AdaptionProgressStatVO adaptionProgressStatistics() { + public AdaptionProgressStatVO adaptionProgressStatistics(PurchaseAdaptionListReq req) { LambdaQueryWrapper query = Wrappers.lambdaQuery(Purchase.class) .select(Purchase::getStatus, Purchase::getId) .eq(Purchase::getBidType, BidTypeEnum.BUILD_APP.getCode()) @@ -554,6 +554,16 @@ public class PurchaseManage { if (!purchaseService.buildPurchaseQueryPermission(query, user)) { return null; } + if (req.hasProjectQuery()) { + List projectIds = filterProjectIdsForPurchase(req); + if (projectIds.isEmpty()) { + return null; + } + query.in(Purchase::getProjectId, projectIds); + } + query.like(StrUtil.isNotBlank(req.getBidName()), Purchase::getBidName, req.getBidName()) + .le(req.getCreateOnMax() != null, Purchase::getCreateOn, req.getCreateOnMax()) + .ge(req.getCreateOnMin() != null, Purchase::getCreateOn, req.getCreateOnMin()); List purchases = purchaseService.list(query); return adaptionProgressStatistics(purchases); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml index 52e7ac5..49644e5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/ProjectMapper.xml @@ -362,6 +362,18 @@ and p.stage = #{req.stage} + + and p.status in + + #{statusItem} + + + + and p.stage in + + #{stageItem} + + and p.project_year = #{req.projectYear}