|
|
@@ -144,9 +144,21 @@ public class DeviceQuery {
|
|
|
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
|
|
boolean status = deviceService.isSyncRunning(deviceId);
|
|
|
// 已存在则返回进度
|
|
|
- if (status) {
|
|
|
+ if (deviceService.isSyncRunning(deviceId)) {
|
|
|
SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId);
|
|
|
- return WVPResult.success(channelSyncStatus);
|
|
|
+ WVPResult wvpResult = new WVPResult();
|
|
|
+ if (channelSyncStatus.getErrorMsg() != null) {
|
|
|
+ wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
+ wvpResult.setMsg(channelSyncStatus.getErrorMsg());
|
|
|
+ }else if (channelSyncStatus.getTotal() == null || channelSyncStatus.getTotal() == 0){
|
|
|
+ wvpResult.setCode(ErrorCode.SUCCESS.getCode());
|
|
|
+ wvpResult.setMsg("等待通道信息...");
|
|
|
+ }else {
|
|
|
+ wvpResult.setCode(ErrorCode.SUCCESS.getCode());
|
|
|
+ wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
|
|
|
+ wvpResult.setData(channelSyncStatus);
|
|
|
+ }
|
|
|
+ return wvpResult;
|
|
|
}
|
|
|
deviceService.sync(device);
|
|
|
|
|
|
@@ -413,18 +425,19 @@ public class DeviceQuery {
|
|
|
public WVPResult<SyncStatus> getSyncStatus(@PathVariable String deviceId) {
|
|
|
SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId);
|
|
|
WVPResult<SyncStatus> wvpResult = new WVPResult<>();
|
|
|
- if (channelSyncStatus == null || channelSyncStatus.getTotal() == null) {
|
|
|
- wvpResult.setCode(0);
|
|
|
- wvpResult.setMsg("同步尚未开始");
|
|
|
+ if (channelSyncStatus == null) {
|
|
|
+ wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
+ wvpResult.setMsg("同步不存在");
|
|
|
+ }else if (channelSyncStatus.getErrorMsg() != null) {
|
|
|
+ wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
+ wvpResult.setMsg(channelSyncStatus.getErrorMsg());
|
|
|
+ }else if (channelSyncStatus.getTotal() == null || channelSyncStatus.getTotal() == 0){
|
|
|
+ wvpResult.setCode(ErrorCode.SUCCESS.getCode());
|
|
|
+ wvpResult.setMsg("等待通道信息...");
|
|
|
}else {
|
|
|
- if (channelSyncStatus.getErrorMsg() == null) {
|
|
|
- wvpResult.setCode(ErrorCode.SUCCESS.getCode());
|
|
|
- wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
|
|
|
- wvpResult.setData(channelSyncStatus);
|
|
|
- }else {
|
|
|
- wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
- wvpResult.setMsg(channelSyncStatus.getErrorMsg());
|
|
|
- }
|
|
|
+ wvpResult.setCode(ErrorCode.SUCCESS.getCode());
|
|
|
+ wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
|
|
|
+ wvpResult.setData(channelSyncStatus);
|
|
|
}
|
|
|
return wvpResult;
|
|
|
}
|