From a1ac20d9cbe90b566bffe3ed39a6e07700c3248f Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期一, 19 六月 2023 10:30:06 +0800
Subject: [PATCH] Merge branch 'wjc'

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java |  340 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 340 insertions(+), 0 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
new file mode 100644
index 0000000..0a4314e
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -0,0 +1,340 @@
+package com.hdl.photovoltaic.other;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.hdl.photovoltaic.bean.HttpResponsePack;
+import com.hdl.photovoltaic.config.UserConfigManage;
+import com.hdl.photovoltaic.internet.HttpClient;
+import com.hdl.photovoltaic.internet.api.HttpApi;
+import com.hdl.photovoltaic.listener.BaseSuccessFailureCallBeak;
+import com.hdl.photovoltaic.listener.CloudCallBeak;
+import com.hdl.photovoltaic.ui.bean.HouseInfoBean;
+import com.hdl.photovoltaic.ui.bean.HouseListBean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 浣忓畢閫昏緫鐣岄潰
+ */
+public class HdlResidenceLogic {
+
+    private static volatile HdlResidenceLogic sHdlResidenceLogic;
+
+    /**
+     * 鑾峰彇褰撳墠瀵硅薄
+     *
+     * @return HdlResidenceLogic
+     */
+    public static synchronized HdlResidenceLogic getInstance() {
+        if (sHdlResidenceLogic == null) {
+            synchronized (HdlResidenceLogic.class) {
+                if (sHdlResidenceLogic == null) {
+                    sHdlResidenceLogic = new HdlResidenceLogic();
+                }
+            }
+
+        }
+        return sHdlResidenceLogic;
+    }
+
+    public List<HouseInfoBean> getHouseInfoList() {
+        return houseInfoList;
+    }
+
+    public void setHouseInfoList(List<HouseInfoBean> houseInfoList) {
+        this.houseInfoList = houseInfoList;
+    }
+
+    public List<HouseListBean> getHouseInfoBeanList() {
+        return houseList;
+    }
+
+    public void setHouseInfoBeanList(List<HouseListBean> houseListBeanList) {
+        this.houseList = houseListBeanList;
+    }
+
+    //浣忓畢鍒楄〃
+    private List<HouseListBean> houseList = new ArrayList<>();
+    //浣忓畢璇︽儏鍒楄〃
+    private List<HouseInfoBean> houseInfoList = new ArrayList<>();
+
+    public HouseListBean getHouseByHouseId(String homeId) {
+        return new HouseListBean();
+    }
+
+
+    /**
+     * 鑾峰彇浣忓畢(鐢电珯)鍒楄〃
+     *
+     * @param pageNo   褰撳墠椤垫暟
+     * @param pageSize 涓�椤靛ぇ灏�
+     */
+    public void getResidenceList(int pageNo, int pageSize, CloudCallBeak<Boolean> cloudCallBeak) {
+        if (pageNo == 1) {
+            //绗竴娆¤繘鏉ユ竻绌哄垪琛�
+            houseList.clear();
+        }
+        String requestUrl = HttpApi.POST_PowerStation_List;
+        JsonObject json = new JsonObject();
+//        json.addProperty("powerSort", "descending");//鍙戠數鍔熺巼鎺掑簭(descending:闄嶅簭ascending:鍗囧簭)
+//        json.addProperty("todayElectricitySort", "descending");//浠婃棩鍙戠數閲忔帓搴�
+//        json.addProperty("createTimeSort", "descending");//鍒涘缓鏃堕棿鎺掑簭
+//        json.addProperty("zoneType", "password");//鍖哄煙
+        json.addProperty("pageNo", pageNo);//椤电爜
+        json.addProperty("pageSize", pageSize);//椤垫暟
+
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+            @Override
+            public void onSuccess(HttpResponsePack httpResponsePack) {
+                if (httpResponsePack != null && httpResponsePack.getData() != null) {
+                    Gson gson = new Gson();
+                    String jsonStr = gson.toJson(httpResponsePack.getData().toString());
+                    HouseInfoBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseInfoBeanClass.class);
+                    houseList.addAll(houseInfoBeanClass.getList());
+                    //鎬诲叡鏈夊灏戦〉
+                    long totalPage = houseInfoBeanClass.totalPage;
+                    if (totalPage == houseInfoBeanClass.getPageNo()) {
+                        if (cloudCallBeak != null) {
+                            cloudCallBeak.onSuccess(true);
+                        }
+                        return;
+                    }
+                    getResidenceList(pageNo + 1, 100, cloudCallBeak);
+
+                }
+            }
+
+
+            @Override
+            public void onFailure(Exception exception) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(exception);
+                }
+            }
+        });
+    }
+
+
+    /**
+     * 鑾峰彇浣忓畢(鐢电珯)璇︽儏
+     *
+     * @param homeId        浣忓畢id
+     * @param cloudCallBeak 鍥炶皟
+     */
+    public void getResidenceInfo(String homeId, CloudCallBeak<HouseInfoBean> cloudCallBeak) {
+        String requestUrl = HttpApi.POST_PowerStation_Info;
+        JsonObject json = new JsonObject();
+        json.addProperty("homeId", homeId);//鐢电珯id
+        //json.addProperty("zoneType", "password");//鍖哄煙
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+            @Override
+            public void onSuccess(HttpResponsePack httpResponsePack) {
+                if (httpResponsePack != null && httpResponsePack.getData() != null) {
+                    Gson gson = new Gson();
+                    String jsonStr = gson.toJson(httpResponsePack.getData().toString());
+                    HouseInfoBean houseInfoBean = gson.fromJson(jsonStr, HouseInfoBean.class);
+                    if (cloudCallBeak != null) {
+                        cloudCallBeak.onSuccess(houseInfoBean);
+                    }
+                }
+            }
+
+            @Override
+            public void onFailure(Exception exception) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(exception);
+                }
+            }
+        });
+
+
+    }
+
+
+    /**
+     * 缂栬緫浣忓畢(鐢电珯)
+     *
+     * @param houseInfoBean -
+     * @param cloudCallBeak -
+     */
+    public void editResidence(HouseInfoBean houseInfoBean, CloudCallBeak<Boolean> cloudCallBeak) {
+        String requestUrl = HttpApi.POST_PowerStation_Edit;
+        JsonObject json = new JsonObject();
+        JsonObject location = new JsonObject();
+        json.addProperty("homeId", houseInfoBean.getHomeId());
+        location.addProperty("nationCode", houseInfoBean.getLocation().getNationCode());
+        location.addProperty("nationName", houseInfoBean.getLocation().getNationName());
+        location.addProperty("provinceCode", houseInfoBean.getLocation().getProvinceCode());
+        location.addProperty("provinceName", houseInfoBean.getLocation().getProvinceName());
+        location.addProperty("cityCode", houseInfoBean.getLocation().getCityCode());
+        location.addProperty("cityName", houseInfoBean.getLocation().getCityName());
+        json.add("location", location);
+        json.addProperty("address", houseInfoBean.getAddress());
+        json.addProperty("latitude", houseInfoBean.getLatitude());
+        json.addProperty("longitude", houseInfoBean.getLongitude());
+        json.addProperty("homeName", houseInfoBean.getHomeName());
+        json.addProperty("timezone", houseInfoBean.getTimezone());
+        json.addProperty("powerStationType", houseInfoBean.getPowerStationType());
+        json.addProperty("workMode", houseInfoBean.getWorkMode());
+        json.addProperty("installedCapacity", houseInfoBean.getInstalledCapacity());
+        json.addProperty("productionTime", houseInfoBean.getProductionTime());
+        json.addProperty("monetaryUnit", houseInfoBean.getMonetaryUnit());
+        json.addProperty("electrovalence", houseInfoBean.getElectrovalence());
+        json.addProperty("totalCost", houseInfoBean.getTotalCost());
+        json.addProperty("zoneType", houseInfoBean.getZoneType());
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+            @Override
+            public void onSuccess(HttpResponsePack httpResponsePack) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onSuccess(true);
+                }
+
+            }
+
+            @Override
+            public void onFailure(Exception exception) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(exception);
+                }
+            }
+        });
+    }
+
+    /**
+     * 鍒犻櫎浣忓畢(鐢电珯)
+     *
+     * @param homeId        -
+     * @param cloudCallBeak -
+     */
+    public void delResidence(String homeId, CloudCallBeak<Boolean> cloudCallBeak) {
+        String requestUrl = HttpApi.POST_PowerStation_Remove;
+        JsonObject json = new JsonObject();
+        json.addProperty("homeId", homeId);//鐢电珯id
+        //json.addProperty("zoneType", "password");//鍖哄煙
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+            @Override
+            public void onSuccess(HttpResponsePack httpResponsePack) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onSuccess(true);
+                }
+
+            }
+
+            @Override
+            public void onFailure(Exception exception) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(exception);
+                }
+            }
+        });
+
+    }
+
+    /**
+     * 娣诲姞浣忓畢(鐢电珯)
+     *
+     * @param houseInfoBean -
+     * @param cloudCallBeak -
+     */
+    public void addResidence(HouseInfoBean houseInfoBean, CloudCallBeak<Boolean> cloudCallBeak) {
+        String requestUrl = HttpApi.POST_PowerStation_Create;
+        JsonObject json = new JsonObject();
+        JsonObject location = new JsonObject();
+        json.addProperty("powerStationImage", "");
+        location.addProperty("nationCode", houseInfoBean.getLocation().getNationCode());
+        location.addProperty("nationName", houseInfoBean.getLocation().getNationName());
+        location.addProperty("provinceCode", houseInfoBean.getLocation().getProvinceCode());
+        location.addProperty("provinceName", houseInfoBean.getLocation().getProvinceName());
+        location.addProperty("cityCode", houseInfoBean.getLocation().getCityCode());
+        location.addProperty("cityName", houseInfoBean.getLocation().getCityName());
+        json.add("location", location);
+        json.addProperty("address", houseInfoBean.getAddress());
+        json.addProperty("latitude", houseInfoBean.getLatitude());
+        json.addProperty("longitude", houseInfoBean.getLongitude());
+        json.addProperty("homeName", houseInfoBean.getHomeName());
+        json.addProperty("timezone", houseInfoBean.getTimezone());
+        json.addProperty("powerStationType", houseInfoBean.getPowerStationType());
+        json.addProperty("workMode", houseInfoBean.getWorkMode());
+        json.addProperty("installedCapacity", houseInfoBean.getInstalledCapacity());
+        json.addProperty("productionTime", houseInfoBean.getProductionTime());
+        json.addProperty("monetaryUnit", houseInfoBean.getMonetaryUnit());
+        json.addProperty("electrovalence", houseInfoBean.getElectrovalence());
+        json.addProperty("totalCost", houseInfoBean.getTotalCost());
+        json.addProperty("zoneType", houseInfoBean.getZoneType());
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
+            @Override
+            public void onSuccess(HttpResponsePack httpResponsePack) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onSuccess(true);
+                }
+
+            }
+
+            @Override
+            public void onFailure(Exception exception) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(exception);
+                }
+            }
+        });
+
+
+    }
+
+
+    static class HouseInfoBeanClass {
+
+        //鎬绘潯鏁�
+        private long totalCount;
+        //鎬婚〉鏁�
+        private long totalPage;
+        //褰撳墠椤�
+        private long pageNo;
+        //椤垫暟
+        private long pageSize;
+        //鐢电珯鍒楄〃
+        private List<HouseListBean> list;
+
+        public long getTotalCount() {
+            return totalCount;
+        }
+
+        public void setTotalCount(long totalCount) {
+            this.totalCount = totalCount;
+        }
+
+        public long getTotalPage() {
+            return totalPage;
+        }
+
+        public void setTotalPage(long totalPage) {
+            this.totalPage = totalPage;
+        }
+
+        public long getPageNo() {
+            return pageNo;
+        }
+
+        public void setPageNo(long pageNo) {
+            this.pageNo = pageNo;
+        }
+
+        public long getPageSize() {
+            return pageSize;
+        }
+
+        public void setPageSize(long pageSize) {
+            this.pageSize = pageSize;
+        }
+
+        public List<HouseListBean> getList() {
+            return list == null ? new ArrayList<>() : list;
+        }
+
+        public void setList(List<HouseListBean> list) {
+            this.list = list;
+        }
+    }
+
+}

--
Gitblit v1.8.0