fix(ft546): preserve legacy vehicle snapshots
This commit is contained in:
@@ -27,7 +27,6 @@ import com.ruoyi.job.domain.MydoJob;
|
|||||||
import com.ruoyi.job.service.IMydoJobService;
|
import com.ruoyi.job.service.IMydoJobService;
|
||||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||||
import com.ruoyi.project.ft546.wms.Ft546WmsAdapterService;
|
|
||||||
import com.ruoyi.system.domain.AgvContainerTask;
|
import com.ruoyi.system.domain.AgvContainerTask;
|
||||||
import com.ruoyi.system.service.IAgvContainerTaskService;
|
import com.ruoyi.system.service.IAgvContainerTaskService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -61,8 +60,6 @@ public class ApiServiceImpl implements IApiService {
|
|||||||
private IAgvContainerTaskService agvContainerTaskService;
|
private IAgvContainerTaskService agvContainerTaskService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceSrgvMapper deviceSrgvMapper;
|
private DeviceSrgvMapper deviceSrgvMapper;
|
||||||
@Autowired
|
|
||||||
private Ft546WmsAdapterService ft546WmsAdapterService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -523,8 +520,39 @@ public class ApiServiceImpl implements IApiService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult tidyVehicleSnapshot() {
|
public AjaxResult tidyVehicleSnapshot() {
|
||||||
return AjaxResult.success(ft546WmsAdapterService
|
List<DeviceSrgv> vehicles = deviceSrgvMapper
|
||||||
.tidyVehicleSnapshot());
|
.selectDeviceSrgvList(new DeviceSrgv());
|
||||||
|
List<SrgvVehicleSnapshot> snapshots = new ArrayList<>();
|
||||||
|
for (DeviceSrgv vehicle : vehicles) {
|
||||||
|
boolean online = "1".equals(vehicle.getAgvStatus());
|
||||||
|
boolean healthy = online && value(vehicle.getAlarm()) <= 1
|
||||||
|
&& value(vehicle.getErrMsg()) == 0;
|
||||||
|
boolean idle = healthy && value(vehicle.getTaskNo()) == 0
|
||||||
|
&& value(vehicle.getLocked()) == 0
|
||||||
|
&& value(vehicle.getChargeFlag()) == 0;
|
||||||
|
SrgvVehicleSnapshot snapshot = new SrgvVehicleSnapshot();
|
||||||
|
snapshot.setGuid(vehicle.getGuid());
|
||||||
|
snapshot.setDeviceId(vehicle.getDeviceId());
|
||||||
|
snapshot.setDeviceName(vehicle.getDeviceName());
|
||||||
|
snapshot.setAgvStatus(vehicle.getAgvStatus());
|
||||||
|
snapshot.setOnline(online);
|
||||||
|
snapshot.setHealthy(healthy);
|
||||||
|
snapshot.setIdle(idle);
|
||||||
|
snapshot.setTaskNo(vehicle.getTaskNo());
|
||||||
|
snapshot.setAlarm(vehicle.getAlarm());
|
||||||
|
snapshot.setErrMsg(vehicle.getErrMsg());
|
||||||
|
snapshot.setChargeFlag(vehicle.getChargeFlag());
|
||||||
|
snapshot.setLocked(vehicle.getLocked());
|
||||||
|
snapshot.setBattery(vehicle.getBattery());
|
||||||
|
snapshot.setCurrSite(vehicle.getCurrSite());
|
||||||
|
snapshot.setCurrFloor(vehicle.getCurrFloor());
|
||||||
|
snapshots.add(snapshot);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(snapshots);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int value(Integer number) {
|
||||||
|
return number == null ? 0 : number;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,13 @@ import com.ruoyi.api.controller.Wcs2WmsController;
|
|||||||
import com.ruoyi.api.domain.RequestLog;
|
import com.ruoyi.api.domain.RequestLog;
|
||||||
import com.ruoyi.api.domain.wcs2wms.JobParam;
|
import com.ruoyi.api.domain.wcs2wms.JobParam;
|
||||||
import com.ruoyi.api.domain.wcs2wms.ReceiveJob;
|
import com.ruoyi.api.domain.wcs2wms.ReceiveJob;
|
||||||
|
import com.ruoyi.api.domain.wcs2wms.SrgvVehicleSnapshot;
|
||||||
import com.ruoyi.api.service.IApiService;
|
import com.ruoyi.api.service.IApiService;
|
||||||
|
import com.ruoyi.api.service.impl.ApiServiceImpl;
|
||||||
import com.ruoyi.api.service.impl.RequestLogServiceImpl;
|
import com.ruoyi.api.service.impl.RequestLogServiceImpl;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.device.srgv.domain.DeviceSrgv;
|
||||||
|
import com.ruoyi.device.srgv.mapper.DeviceSrgvMapper;
|
||||||
import com.ruoyi.project.ft546.config.Ft546WcsProperties;
|
import com.ruoyi.project.ft546.config.Ft546WcsProperties;
|
||||||
import com.ruoyi.wcs.application.task.CreateTransportOrderCommand;
|
import com.ruoyi.wcs.application.task.CreateTransportOrderCommand;
|
||||||
import com.ruoyi.wcs.application.task.TransportOrderResult;
|
import com.ruoyi.wcs.application.task.TransportOrderResult;
|
||||||
@@ -18,6 +22,7 @@ import com.ruoyi.wcs.port.in.TransportOrderUseCase;
|
|||||||
import com.ruoyi.wcs.port.out.WmsNotification;
|
import com.ruoyi.wcs.port.out.WmsNotification;
|
||||||
import com.ruoyi.wcs.port.out.WmsNotificationReceipt;
|
import com.ruoyi.wcs.port.out.WmsNotificationReceipt;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -141,6 +146,37 @@ class Ft546WmsAdapterServiceTest {
|
|||||||
verify(legacy, never()).tidyVehicleSnapshot();
|
verify(legacy, never()).tidyVehicleSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void legacySnapshotDoesNotDependOnTheStandardWcsAdapter() {
|
||||||
|
DeviceSrgvMapper deviceMapper = mock(DeviceSrgvMapper.class);
|
||||||
|
DeviceSrgv vehicle = new DeviceSrgv();
|
||||||
|
vehicle.setGuid("GUID-1");
|
||||||
|
vehicle.setDeviceId(1);
|
||||||
|
vehicle.setAgvStatus("1");
|
||||||
|
vehicle.setAlarm(0);
|
||||||
|
vehicle.setErrMsg(0);
|
||||||
|
vehicle.setTaskNo(0);
|
||||||
|
vehicle.setLocked(0);
|
||||||
|
vehicle.setChargeFlag(0);
|
||||||
|
vehicle.setCurrSite("070501");
|
||||||
|
when(deviceMapper.selectDeviceSrgvList(any(DeviceSrgv.class)))
|
||||||
|
.thenReturn(Collections.singletonList(vehicle));
|
||||||
|
ApiServiceImpl legacy = new ApiServiceImpl();
|
||||||
|
ReflectionTestUtils.setField(legacy, "deviceSrgvMapper", deviceMapper);
|
||||||
|
|
||||||
|
AjaxResult result = legacy.tidyVehicleSnapshot();
|
||||||
|
|
||||||
|
assertTrue(result.isSuccess());
|
||||||
|
List<?> snapshots = (List<?>) result.get(AjaxResult.DATA_TAG);
|
||||||
|
assertEquals(1, snapshots.size());
|
||||||
|
SrgvVehicleSnapshot snapshot = (SrgvVehicleSnapshot) snapshots.get(0);
|
||||||
|
assertEquals("GUID-1", snapshot.getGuid());
|
||||||
|
assertTrue(snapshot.getOnline());
|
||||||
|
assertTrue(snapshot.getHealthy());
|
||||||
|
assertTrue(snapshot.getIdle());
|
||||||
|
assertEquals("070501", snapshot.getCurrSite());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notificationUsesEventIdAsLegacyCallbackIdempotencyKey() {
|
void notificationUsesEventIdAsLegacyCallbackIdempotencyKey() {
|
||||||
FakeRequestLogService requestLogs = new FakeRequestLogService();
|
FakeRequestLogService requestLogs = new FakeRequestLogService();
|
||||||
|
|||||||
Reference in New Issue
Block a user