|
@@ -1,18 +1,45 @@
|
|
|
package com.fdkankan.contro.util;
|
|
package com.fdkankan.contro.util;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
|
import com.fdkankan.contro.constant.ScenePlugin;
|
|
import com.fdkankan.contro.constant.ScenePlugin;
|
|
|
|
|
|
|
|
public class ScenePluginUtil {
|
|
public class ScenePluginUtil {
|
|
|
|
|
|
|
|
- public static boolean hasOBPlugin(JSONObject dataFdage) {
|
|
|
|
|
- return dataFdage.getJSONArray("plugin")
|
|
|
|
|
- .stream()
|
|
|
|
|
- .map(obj -> ((JSONObject) obj).getString("name"))
|
|
|
|
|
- .anyMatch(name -> name != null && name.startsWith(ScenePlugin.OB.code()))//新的app版本是以数组元素的结构记录插件
|
|
|
|
|
- || dataFdage.getIntValue("zxState") == CommonStatus.YES.code().intValue();//旧版本app以zxState字段标识是否使用了知像光电插件
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断是否包含知象插件
|
|
|
|
|
+ * @param data
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static boolean hasOBPlugin(JSONObject data) {
|
|
|
|
|
+
|
|
|
|
|
+ //先判断旧版本字段
|
|
|
|
|
+ if (CommonStatus.YES.code().intValue() == data.getIntValue("zxState")) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 再判断新版本 plugins 数组
|
|
|
|
|
+ JSONArray plugins = data.getJSONArray("plugins");
|
|
|
|
|
+ if (plugins == null || plugins.isEmpty()) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ final String obPrefix = ScenePlugin.OB.code();
|
|
|
|
|
+
|
|
|
|
|
+ for (Object obj : plugins) {
|
|
|
|
|
+ if (!(obj instanceof JSONObject)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String name = ((JSONObject) obj).getString("name");
|
|
|
|
|
+ if (name != null && name.startsWith(obPrefix)) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|