|
@@ -0,0 +1,52 @@
|
|
|
|
|
+package com.yunfeiyun.agmp.iot.common.util.dev;
|
|
|
|
|
+
|
|
|
|
|
+import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.enums.IotDeviceStatusTypeEnum;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.HashSet;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+
|
|
|
|
|
+public class DevOperateUtil {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 在线检测
|
|
|
|
|
+ * @param iotDevice
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static void sendConfigCmdCheck(IotDevice iotDevice) {
|
|
|
|
|
+ if(iotDevice == null){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"设备不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ String devtypeBid = iotDevice.getDevtypeBid();
|
|
|
|
|
+ Set<String> devtypeBidSet = new HashSet<>();
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_SQZ);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_QXZ);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_CBD);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_SDCBD);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_GKCBD);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_XCT);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_SCD);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_FXSSCD);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_JGFXSSCD);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_BZY);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_L_BZY);
|
|
|
|
|
+ devtypeBidSet.add(IotDeviceDictConst.TYPE_YF_XYCB_III);
|
|
|
|
|
+
|
|
|
|
|
+ if(!devtypeBidSet.contains(devtypeBid)){
|
|
|
|
|
+ throw new IotBizException(IotErrorCode.FAILURE.getCode(), "暂不支持该此操作");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String devStatus = iotDevice.getDevStatus();
|
|
|
|
|
+ IotDeviceStatusTypeEnum iotDeviceStatusTypeEnum = IotDeviceStatusTypeEnum.findEnumByCode(devStatus);
|
|
|
|
|
+ if(iotDeviceStatusTypeEnum == null){
|
|
|
|
|
+ throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备状态异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!Objects.equals(devStatus, IotDeviceStatusTypeEnum.ONLINE.getCode())){
|
|
|
|
|
+ throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备" + iotDeviceStatusTypeEnum.getName() + "无法操作");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|