Browse Source

优化设备功能调用返回内容逻辑

develop
zhaoxianglong 9 months ago
parent
commit
8abda21eb4
  1. 34
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

34
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -537,7 +537,41 @@ public class DcDeviceController extends BaseController {
String deviceType = device.getString("deviceType");
boolean continueToExecute = true;
if (Objects.equals(deviceType, UniversalEnum.TEN.getValue())) {
if (iotDeviceId == null) {
for (Object function : functions) {
JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function);
//JSONObject functionJSONObject = (JSONObject) JSON.toJSON(function.toString()) ;
String functionId = functionJSONObject.getString("functionId");
List<Object> collect = resultArray.stream().filter(item -> Objects.equals(((JSONObject) JSON.toJSON(item)).getString("device"), device.getString("id"))).collect(Collectors.toList());
if (collect.size() == UniversalEnum.ZERO.getNumber()) {
JSONObject result = new JSONObject();
result.put("device", device.getString("id"));
result.put("deviceType", device.getInteger("deviceType"));
result.put("functionId", functionId);
result.put("result", AjaxResult.error());
resultArray.add(result);
} else {
for (int i = UniversalEnum.ZERO.getNumber(); i < resultArray.size(); i++) {
JSONObject jsonObject = (JSONObject) JSON.toJSON(resultArray.get(i));
if (!Objects.equals(jsonObject.getString("device"), device.getString("id"))) {
JSONObject result = jsonObject.getJSONObject("result");
if (!Objects.equals(result.getString("code"), UniversalEnum.TWO_HUNDRED.getValue())) {
break;
} else {
result.put("code", UniversalEnum.FIVE_HUNDRED.getValue());
jsonObject.put("result", result);
resultArray.add(i, jsonObject);
}
} else {
break;
}
}
}
}
break;
}
JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.MD.getValue()).get("data"));
String mdValue = mdJSONObject.getString("value");

Loading…
Cancel
Save