From 0201c32312f6478b2bde706607c8c6338e9e1d06 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期三, 27 五月 2026 17:05:29 +0800
Subject: [PATCH] 新增智能电表、空调管理

---
 server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/ConditionerUtil.java |   80 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/ConditionerUtil.java b/server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/ConditionerUtil.java
index 95dd398..0872b5e 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/ConditionerUtil.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/ConditionerUtil.java
@@ -283,11 +283,51 @@
     }
 
     public static ConditionerBaseResponse<Object> addGs(CompanyGsManageRequest req) {
-        return postJson("/addGs", req, Object.class);
+        if (req == null) {
+            return null;
+        }
+        req.fillSessionDefaults();
+        JSONObject body = new JSONObject(true);
+        putSessionFields(body, req);
+        body.put("is_pwr", req.getIs_pwr() != null ? req.getIs_pwr() : 1);
+        if (req.getLi_dev() != null && !req.getLi_dev().isEmpty()) {
+            body.put("li_dev", req.getLi_dev());
+        }
+        if (req.getD_dev() != null && !req.getD_dev().isEmpty()) {
+            body.put("d_dev", req.getD_dev());
+        }
+        body.put("gs_name", req.getGs_name());
+        body.put("is_rest_stop", req.getIs_rest_stop() != null ? req.getIs_rest_stop() : 0);
+        body.put("gs_bz", StringUtils.defaultString(req.getGs_bz()));
+        putStopMoney(body, req.getStop_money());
+        return postJsonBody("/addGs", body, Object.class);
     }
 
     public static ConditionerBaseResponse<Object> changeGs(CompanyGsManageRequest req) {
-        return postJson("/changeGs", req, Object.class);
+        if (req == null || req.getId() == null) {
+            return null;
+        }
+        req.fillSessionDefaults();
+        JSONObject body = new JSONObject(true);
+        body.put("id", req.getId());
+        body.put("is_pwr", req.getIs_pwr() != null ? req.getIs_pwr() : 1);
+        body.put("is_rest_stop", req.getIs_rest_stop() != null ? req.getIs_rest_stop() : 0);
+        body.put("gs_name", req.getGs_name());
+        if (req.getLeft_money() != null) {
+            body.put("left_money", req.getLeft_money());
+        }
+        body.put("is_stop", req.getIs_stop() != null ? req.getIs_stop() : 0);
+        body.put("li_dev", req.getLi_dev());
+        body.put("d_dev", req.getD_dev());
+        body.put("gs_bz", StringUtils.defaultString(req.getGs_bz()));
+        putStopMoney(body, req.getStop_money());
+        return postJsonBody("/changeGs", body, Object.class);
+    }
+
+    private static void putStopMoney(JSONObject body, Object stopMoney) {
+        if (stopMoney != null) {
+            body.put("stop_money", stopMoney);
+        }
     }
 
     public static ConditionerBaseResponse<Object> delGs(CompanyGsManageRequest req) {
@@ -299,11 +339,26 @@
     }
 
     public static ConditionerBaseResponse<Object> addMoney(AddMoneyRequest req) {
-        return postJson("/addMoney", req, Object.class);
+        if (req == null) {
+            return null;
+        }
+        req.fillSessionDefaults();
+        JSONObject body = new JSONObject(true);
+        putSessionFields(body, req);
+        body.put("id", req.getId());
+        body.put("cz_money", req.getCz_money());
+        return postJsonBody("/addMoney", body, Object.class);
     }
 
     public static ConditionerBaseResponse<Object> cleanMoney(CompanyGsManageRequest req) {
-        return postJson("/cleanMoney", req, Object.class);
+        if (req == null || req.getId() == null) {
+            return null;
+        }
+        req.fillSessionDefaults();
+        JSONObject body = new JSONObject(true);
+        putSessionFields(body, req);
+        body.put("id", req.getId());
+        return postJsonBody("/cleanMoney", body, Object.class);
     }
 
     public static ConditionerBaseResponse<List<Object>> getCzLog(LogQueryRequest req) {
@@ -381,6 +436,23 @@
         }
     }
 
+    private static <T> ConditionerBaseResponse<T> postJsonBody(String path, JSONObject body, Class<T> dataClass) {
+        try {
+            String raw = doPostRaw(path, body.toJSONString());
+            return parseObjectResponse(raw, dataClass);
+        } catch (Exception e) {
+            log.error("conditioner POST {} failed", path, e);
+            return null;
+        }
+    }
+
+    private static void putSessionFields(JSONObject body, ConditionerSessionRequest req) {
+        body.put("kt_token", req.getKt_token());
+        body.put("kt_dwid", req.getKt_dwid());
+        body.put("kt_unit", StringUtils.defaultIfBlank(req.getKt_unit(), ConditionerConstant.DEFAULT_KT_UNIT));
+        body.put("kt_sonid", req.getKt_sonid());
+    }
+
     private static String resolveUrl(String path) {
         String base = StringUtils.defaultIfBlank(ConditionerConstant.base_url, ConditionerConstant.DEFAULT_BASE_URL);
         if (base.endsWith("/")) {

--
Gitblit v1.9.3