|
@@ -215,12 +215,29 @@ public class ControlUtil {
|
|
|
JSONObject postJSON = new JSONObject();
|
|
|
postJSON.put("building", RepositoryContainer.RepositoryProject.projectId.substring(2));
|
|
|
postJSON.put("points", points);
|
|
|
- String post_url = Constant.iot_project_url + "/sync_pointsetbatch_post";
|
|
|
- log.debug(postJSON.toJSONString());
|
|
|
- String post_result = HttpClientUtil.instance("iot_project").post(post_url, postJSON.toJSONString());
|
|
|
- JSONObject result = JSON.parseObject(post_result);
|
|
|
- JSONArray result_points = (JSONArray) result.get("points");
|
|
|
- log.debug(post_result);
|
|
|
- return result_points;
|
|
|
+ if (Constant.control_mode.equals("sync")) {
|
|
|
+ String post_url = Constant.iot_project_url + "/sync_pointsetbatch_post";
|
|
|
+ log.debug(postJSON.toJSONString());
|
|
|
+ String post_result = HttpClientUtil.instance("iot_project").post(post_url, postJSON.toJSONString());
|
|
|
+ JSONObject result = JSON.parseObject(post_result);
|
|
|
+ JSONArray result_points = (JSONArray) result.get("points");
|
|
|
+ log.debug(post_result);
|
|
|
+ return result_points;
|
|
|
+ } else {
|
|
|
+ String post_url = Constant.iot_project_url + "/pointsetbatch_post";
|
|
|
+ log.debug(postJSON.toJSONString());
|
|
|
+ String post_result = HttpClientUtil.instance("iot_project").post(post_url, postJSON.toJSONString());
|
|
|
+ JSONObject result = JSON.parseObject(post_result);
|
|
|
+ JSONArray result_points = (JSONArray) result.get("points");
|
|
|
+ for (int i = 0; i < result_points.size(); i++) {
|
|
|
+ JSONObject item = result_points.getJSONObject(i);
|
|
|
+ String status = item.getString("status");
|
|
|
+ if (status.equals("start:sent")) {
|
|
|
+ item.put("status", "finish:success");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.debug(post_result);
|
|
|
+ return result_points;
|
|
|
+ }
|
|
|
}
|
|
|
}
|