| | |
| | | package com.zy.core.utils; |
| | | |
| | | import com.zy.asrs.entity.BasStationOpt; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.BasStationOptService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.service.WrkAnalysisService; |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.test.util.ReflectionTestUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | } |
| | | |
| | | @Test |
| | | void idleRecover_skipsWhenStationCommandLogShowsRecentIssuedMove() { |
| | | StationOperateProcessUtils utils = new StationOperateProcessUtils(); |
| | | StationMoveCoordinator coordinator = mock(StationMoveCoordinator.class); |
| | | BasStationOptService basStationOptService = mock(BasStationOptService.class); |
| | | RedisUtil redisUtil = mock(RedisUtil.class); |
| | | ReflectionTestUtils.setField(utils, "stationMoveCoordinator", coordinator); |
| | | ReflectionTestUtils.setField(utils, "basStationOptService", basStationOptService); |
| | | ReflectionTestUtils.setField(utils, "redisUtil", redisUtil); |
| | | |
| | | StationMoveSession session = new StationMoveSession(); |
| | | session.setStatus(StationMoveSession.STATUS_RUNNING); |
| | | session.setDispatchStationId(136); |
| | | session.setCurrentStationId(145); |
| | | session.setFullPathStationIds(List.of(136, 137, 139, 142, 143, 145, 148, 149, 151)); |
| | | session.setLastIssuedAt(System.currentTimeMillis() - 20_000L); |
| | | when(coordinator.loadSession(10493)).thenReturn(session); |
| | | |
| | | BasStationOpt recentOpt = new BasStationOpt(); |
| | | recentOpt.setTaskNo(10493); |
| | | recentOpt.setStationId(148); |
| | | recentOpt.setSend(1); |
| | | recentOpt.setMode(String.valueOf(com.zy.core.enums.StationCommandType.MOVE)); |
| | | recentOpt.setSendTime(new Date()); |
| | | when(basStationOptService.list(any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))) |
| | | .thenReturn(Collections.singletonList(recentOpt)); |
| | | |
| | | Boolean skipped = ReflectionTestUtils.invokeMethod(utils, |
| | | "shouldSkipIdleRecoverForRecentDispatch", |
| | | 10493, |
| | | 148); |
| | | |
| | | assertTrue(Boolean.TRUE.equals(skipped)); |
| | | } |
| | | |
| | | @Test |
| | | void checkStationOutOrder_skipsWhenActiveSessionAlreadyOwnsCurrentStation() { |
| | | StationOperateProcessUtils utils = new StationOperateProcessUtils(); |
| | | BasDevpService basDevpService = mock(BasDevpService.class); |