diff --git a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/mobile/MobHelpProcessor.java b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/mobile/MobHelpProcessor.java index 034928ca..8dbee73a 100644 --- a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/mobile/MobHelpProcessor.java +++ b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/mobile/MobHelpProcessor.java @@ -41,7 +41,7 @@ public void handle(ProcessContext context) { // list telecom nb-iot devices sb.append(ColorUtils.cyanAnnotation("list: " + bundle.getString("nb.operation.list.desc"))) .append(StringUtils.lineSeparator()); - sb.append(" usage: list pageNo searchValue").append(StringUtils.lineSeparator()); + sb.append(" usage: list searchValue pageNo").append(StringUtils.lineSeparator()); sb.append(StringUtils.lineSeparator()); // get telecom nb-iot device detail info diff --git a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/mobile/MobListDeviceProcessor.java b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/mobile/MobListDeviceProcessor.java index 8fb0a73d..99681fa8 100644 --- a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/mobile/MobListDeviceProcessor.java +++ b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/mobile/MobListDeviceProcessor.java @@ -20,6 +20,7 @@ import com.github.freva.asciitable.HorizontalAlign; import com.github.freva.asciitable.OverflowBehaviour; import iot.technology.client.toolkit.common.rule.ProcessContext; +import iot.technology.client.toolkit.common.rule.TkAbstractProcessor; import iot.technology.client.toolkit.common.rule.TkProcessor; import iot.technology.client.toolkit.common.utils.ColorUtils; import iot.technology.client.toolkit.nb.service.mobile.MobileDeviceService; @@ -33,9 +34,18 @@ import java.util.List; /** + * usage: + *

+ * 1、list: print first page device list + *

+ * 2、list pageNo: print pageNo device list + *

+ * 3、list searchValue pageNo: print searchValue pageNo device list + *

+ * * @author mushuwei */ -public class MobListDeviceProcessor implements TkProcessor { +public class MobListDeviceProcessor extends TkAbstractProcessor implements TkProcessor { private final MobileDeviceService mobileDeviceService = new MobileDeviceService(); @@ -47,15 +57,29 @@ public boolean supports(ProcessContext context) { @Override public void handle(ProcessContext context) { List arguArgs = List.of(context.getData().split(" ")); - if (arguArgs.size() > 3 || arguArgs.size() < 2) { + if (arguArgs.size() > 3) { System.out.format(ColorUtils.blackBold("argument:%s is illegal"), context.getData()); System.out.format(" " + "%n"); return; } + Integer pageNo = 1; String searchValue = null; - Integer pageNo = Integer.valueOf(arguArgs.get(1)); - if (arguArgs.size() > 2) { - searchValue = arguArgs.get(2); + if (arguArgs.size() == 1) { + } + if (arguArgs.size() == 2) { + String pageNoStr = arguArgs.get(1); + if (!validateLimit(pageNoStr)) { + return; + } + pageNo = Integer.parseInt(pageNoStr); + } + if (arguArgs.size() == 3) { + searchValue = arguArgs.get(1); + String pageNoStr = arguArgs.get(2); + if (!validateLimit(pageNoStr)) { + return; + } + pageNo = Integer.parseInt(pageNoStr); } MobProcessContext mobProcessContext = (MobProcessContext) context; MobileConfigDomain mobileConfigDomain = mobProcessContext.getMobileConfigDomain(); diff --git a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/telecom/TelHelpProcessor.java b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/telecom/TelHelpProcessor.java index 1e0cab0d..c705ed17 100644 --- a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/telecom/TelHelpProcessor.java +++ b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/telecom/TelHelpProcessor.java @@ -41,7 +41,7 @@ public void handle(ProcessContext context) { // list telecom nb-iot devices sb.append(ColorUtils.cyanAnnotation("list: " + bundle.getString("nb.operation.list.desc"))) .append(StringUtils.lineSeparator()); - sb.append(" usage: list pageNo searchValue").append(StringUtils.lineSeparator()); + sb.append(" usage: list searchValue pageNo").append(StringUtils.lineSeparator()); sb.append(StringUtils.lineSeparator()); // get telecom nb-iot device detail info diff --git a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/telecom/TelListDeviceProcessor.java b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/telecom/TelListDeviceProcessor.java index 6d065e34..40c7c726 100644 --- a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/telecom/TelListDeviceProcessor.java +++ b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/telecom/TelListDeviceProcessor.java @@ -36,11 +36,14 @@ import java.util.List; /** - * 1、list + * usage: *

- * 2、list 1 + * 1、list: print first page device list + *

+ * 2、list pageNo: print pageNo device list + *

+ * 3、list searchValue pageNo: print searchValue pageNo device list *

- * 3、list searchValue 1 * * @author mushuwei */ diff --git a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/telecom/domain/action/device/TelQueryDeviceByImeiResponse.java b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/telecom/domain/action/device/TelQueryDeviceByImeiResponse.java index 46a7b950..de828e4d 100644 --- a/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/telecom/domain/action/device/TelQueryDeviceByImeiResponse.java +++ b/toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/telecom/domain/action/device/TelQueryDeviceByImeiResponse.java @@ -33,23 +33,29 @@ public class TelQueryDeviceByImeiResponse extends BaseTelResponse { private TelQueryDeviceByImeiBody result; public void printToConsole() { - System.out.format("deviceId: " + ColorUtils.blackBold(result.getDeviceId()) + "%n"); - System.out.format("deviceName: " + ColorUtils.blackBold(result.getDeviceName()) + "%n"); - System.out.format("productId: " + ColorUtils.blackBold(String.valueOf(result.getProductId())) + "%n"); - System.out.format("imei: " + ColorUtils.blackBold(result.getImei()) + "%n"); - System.out.format("deviceStatus: " + ColorUtils.blackBold(TelDeviceStatusEnum.type(result.getDeviceStatus())) + "%n"); - System.out.format( - "imsi: " + (Objects.nonNull(result.getImsi()) ? ColorUtils.blackBold(String.valueOf(result.getImsi())) : "") + "%n"); - System.out.format("firmwareVersion: " + - (Objects.nonNull(result.getFirmwareVersion()) ? ColorUtils.blackBold(result.getFirmwareVersion()) : "") + "%n"); - System.out.format("autoObserver: " + ColorUtils.blackBold(TelAutoObserverEnum.type(result.getAutoObserver())) + "%n"); - System.out.format("netStatus: " + ColorUtils.blackBold(TelNetStatusEnum.type(result.getNetStatus())) + "%n"); - System.out.format("onlineAt: " + - (Objects.nonNull(result.getOnlineAt()) ? ColorUtils.blackBold(DateUtils.timestampToFormatterTime(result.getOnlineAt())) : - "") + "%n"); - System.out.format("offlineAt: " + - (Objects.nonNull(result.getOfflineAt()) ? ColorUtils.blackBold(DateUtils.timestampToFormatterTime(result.getOfflineAt())) : - "") + "%n"); + if (Objects.nonNull(result)) { + System.out.format("deviceId: " + ColorUtils.blackBold(result.getDeviceId()) + "%n"); + System.out.format("deviceName: " + ColorUtils.blackBold(result.getDeviceName()) + "%n"); + System.out.format("productId: " + ColorUtils.blackBold(String.valueOf(result.getProductId())) + "%n"); + System.out.format("imei: " + ColorUtils.blackBold(result.getImei()) + "%n"); + System.out.format("deviceStatus: " + ColorUtils.blackBold(TelDeviceStatusEnum.type(result.getDeviceStatus())) + "%n"); + System.out.format( + "imsi: " + (Objects.nonNull(result.getImsi()) ? ColorUtils.blackBold(String.valueOf(result.getImsi())) : "") + "%n"); + System.out.format("firmwareVersion: " + + (Objects.nonNull(result.getFirmwareVersion()) ? ColorUtils.blackBold(result.getFirmwareVersion()) : "") + "%n"); + System.out.format("autoObserver: " + ColorUtils.blackBold(TelAutoObserverEnum.type(result.getAutoObserver())) + "%n"); + System.out.format("netStatus: " + ColorUtils.blackBold(TelNetStatusEnum.type(result.getNetStatus())) + "%n"); + System.out.format("onlineAt: " + + (Objects.nonNull(result.getOnlineAt()) ? ColorUtils.blackBold(DateUtils.timestampToFormatterTime(result.getOnlineAt())) : + "") + "%n"); + System.out.format("offlineAt: " + + (Objects.nonNull(result.getOfflineAt()) ? ColorUtils.blackBold(DateUtils.timestampToFormatterTime(result.getOfflineAt())) : + "") + "%n"); + } else { + System.out.println("this product does not have this imei!"); + } + + } public TelQueryDeviceByImeiBody getResult() {