diff --git a/ruoyi-admin/src/main/resources/mapper/algorithm/WmsAlgorithmMapper.xml b/ruoyi-admin/src/main/resources/mapper/algorithm/WmsAlgorithmMapper.xml index 8dacfa8..cf9a878 100644 --- a/ruoyi-admin/src/main/resources/mapper/algorithm/WmsAlgorithmMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/algorithm/WmsAlgorithmMapper.xml @@ -134,6 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update alg.tidy_workflow set status = 'COMPLETED', completed_at = SYSUTCDATETIME(), updated_at = SYSUTCDATETIME() where workflow_id = #{workflowId} + and status not in ('COMPLETED', 'CANCELLED_RECONCILED') and not exists (select 1 from alg.tidy_step where workflow_id = #{workflowId} and status <> 'COMPLETED') @@ -146,7 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update alg.tidy_workflow set status = 'PAUSED_RECOVERY', status_reason = #{statusReason}, updated_at = SYSUTCDATETIME() - where workflow_id = #{workflowId} and status not in ('COMPLETED', 'CANCELLED_RECONCILED') + where workflow_id = #{workflowId} + and status not in ('PAUSED_RECOVERY', 'COMPLETED', 'CANCELLED_RECONCILED') diff --git a/ruoyi-admin/src/test/java/com/ruoyi/algorithm/wms/WmsAlgorithmMapperWorkflowSqlTest.java b/ruoyi-admin/src/test/java/com/ruoyi/algorithm/wms/WmsAlgorithmMapperWorkflowSqlTest.java index f390cb9..5bb4d07 100644 --- a/ruoyi-admin/src/test/java/com/ruoyi/algorithm/wms/WmsAlgorithmMapperWorkflowSqlTest.java +++ b/ruoyi-admin/src/test/java/com/ruoyi/algorithm/wms/WmsAlgorithmMapperWorkflowSqlTest.java @@ -172,6 +172,18 @@ class WmsAlgorithmMapperWorkflowSqlTest { .contains("resultmap=\"tidyworkflowstatemap\""); } + @Test + void tidyWorkflowCompletionDoesNotRewriteTerminalRows() throws IOException { + assertThat(statement("update", "completeTidyWorkflow")) + .contains("status not in ('completed', 'cancelled_reconciled')"); + } + + @Test + void tidyWorkflowPauseDoesNotRewriteAlreadyPausedOrTerminalRows() throws IOException { + assertThat(statement("update", "pauseTidyWorkflow")) + .contains("status not in ('paused_recovery', 'completed', 'cancelled_reconciled')"); + } + @Test void tidyRecoveryProjectionMapsWorkflowJobInventoryAndLockEvidence() throws IOException { String mapping = statement("resultmap", "tidyRecoveryEvidenceMap");