diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/component/BoardLayoutResultSummary.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/component/BoardLayoutResultSummary.java index 682b5a5e3..4fbf8a887 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/component/BoardLayoutResultSummary.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/component/BoardLayoutResultSummary.java @@ -100,12 +100,22 @@ public class BoardLayoutResultSummary { private List customBlockNos; /** - * 开始开料板ID列表 + * 开始开料的组件内部板件 ID 列表。 */ private List startCutBlockIds; /** - * 结束开料板ID列表 + * 开始开料的自定义板件编号列表,对应 MES 的板件短号。 + */ + private List customStartCutBlockNos; + + /** + * 结束开料的组件内部板件 ID 列表。 */ private List endCutBlockIds; + + /** + * 结束开料的自定义板件编号列表,对应 MES 的板件短号。 + */ + private List customEndCutBlockNos; } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java index 6bf6bacfe..915bd3cfe 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java @@ -1611,7 +1611,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { if (planDO.getStatus().equals(PlanStatusEnum.OPENING.getStatus()) || planDO.getStatus().equals(PlanStatusEnum.OPENED.getStatus())) { throw new ServiceException(PLAN_PLATE_IS_CUT); } - List optimizatePlateNoList = layoutResultSummary.stream().flatMap(summary -> summary.getStartCutBlockIds().stream()).toList(); + List optimizatePlateNoList = layoutResultSummary.stream() + .flatMap(summary -> summary.getCustomStartCutBlockNos().stream()) + .toList(); // 更新开料中状态 plateMapper.updatePlanPlateCuttingStatus(planId, orderIds, optimizatePlateNoList); @@ -1638,7 +1640,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { if (planDO.getStatus().equals(PlanStatusEnum.OPENED.getStatus())) { throw new ServiceException(PLAN_OPTIMIZE_DATA_ALL_OPENED); } - List optimizatePlateNoList = layoutResultSummary.stream().flatMap(summary -> summary.getEndCutBlockIds().stream()).toList(); + List optimizatePlateNoList = layoutResultSummary.stream() + .flatMap(summary -> summary.getCustomEndCutBlockNos().stream()) + .toList(); // 累计开料大板数量 int endCutBoardCount = layoutResultSummary.stream().mapToInt(BoardLayoutResultSummary::getEndCutBoardCount).sum(); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/test/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImplComponentResultTest.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/test/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImplComponentResultTest.java index b224afbda..55606bfad 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/test/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImplComponentResultTest.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/test/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImplComponentResultTest.java @@ -8,6 +8,8 @@ import com.cf.imes.module.executor.controller.admin.plan.component.BoardLayoutRe import com.cf.imes.module.executor.controller.admin.plan.component.FlowSessionSavedContent; import com.cf.imes.module.executor.controller.admin.plan.component.OptimizationResultsReqVO; import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO; +import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; +import com.cf.imes.module.executor.dal.mysql.order.OrderMapper; import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper; import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper; import com.cf.imes.module.executor.enums.plan.FlowProcessStatus; @@ -23,7 +25,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -41,6 +42,8 @@ class OptimizePlanServiceImplComponentResultTest { private PlanMapper planMapper; @Mock private PlateMapper plateMapper; + @Mock + private OrderMapper orderMapper; @InjectMocks private OptimizePlanServiceImpl optimizePlanService; @@ -68,16 +71,55 @@ class OptimizePlanServiceImplComponentResultTest { .doesNotContainValue("component-material-id"); } + @Test + void shouldUseCustomStartCutBlockNosWhenStartingCut() { + Long planId = 1002L; + when(planMapper.selectById(planId)).thenReturn(plan(planId)); + when(orderMapper.selectByIds(List.of(2001L))).thenReturn(List.of(new OrderDO())); + + optimizePlanService.saveComponentOptimizationResults( + request(planId, FlowProcessStatus.IN_PROGRESS.getStatus())); + + verify(plateMapper).updatePlanPlateCuttingStatus( + planId, List.of(2001L), List.of("custom-start-cut-block-1")); + } + + @Test + void shouldUseCustomEndCutBlockNosWhenCompletingCut() { + Long planId = 1003L; + when(planMapper.selectById(planId)).thenReturn(plan(planId)); + when(plateMapper.updatePlanPlateCutStatus( + eq(planId), eq(List.of(2001L)), eq(List.of("custom-end-cut-block-1")))) + .thenReturn(1); + when(plateMapper.selectPlanAllCuttedOrderIdList(planId, List.of(2001L))) + .thenReturn(List.of()); + + optimizePlanService.saveComponentOptimizationResults( + request(planId, FlowProcessStatus.COMPLETED.getStatus())); + + verify(plateMapper).updatePlanPlateCutStatus( + planId, List.of(2001L), List.of("custom-end-cut-block-1")); + } + private OptimizationResultsReqVO request(Long planId) { + return request(planId, FlowProcessStatus.NOT_STARTED.getStatus()); + } + + private OptimizationResultsReqVO request(Long planId, Integer processStatus) { BoardLayoutResultSummary summary = new BoardLayoutResultSummary(); summary.setBoardCount(1); + summary.setEndCutBoardCount(1); summary.setMaterialIds(List.of("component-material-id")); summary.setCustomMaterialNos(List.of("custom-material-1")); summary.setPlacedBlockIds(List.of("component-block-id")); summary.setCustomBlockNos(List.of("custom-block-1")); + summary.setStartCutBlockIds(List.of("component-start-cut-block-id")); + summary.setCustomStartCutBlockNos(List.of("custom-start-cut-block-1")); + summary.setEndCutBlockIds(List.of("component-end-cut-block-id")); + summary.setCustomEndCutBlockNos(List.of("custom-end-cut-block-1")); FlowSessionSavedContent content = new FlowSessionSavedContent(); - content.setProcessStatus(FlowProcessStatus.NOT_STARTED.getStatus()); + content.setProcessStatus(processStatus); content.setLayoutResultSummary(List.of(summary)); OptimizationResultsReqVO request = new OptimizationResultsReqVO(); @@ -85,4 +127,12 @@ class OptimizePlanServiceImplComponentResultTest { request.setFlowSessionSavedContent(content); return request; } + + private PlanDO plan(Long planId) { + PlanDO plan = new PlanDO(); + plan.setId(planId); + plan.setOrderNos("[2001]"); + plan.setStatus(PlanStatusEnum.NOCUTTING.getStatus()); + return plan; + } }