mac
2024-03-22 e9e9ea0e5bf22953d5c0816d0a052bdd3acf92fc
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -18,6 +18,7 @@
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.linkpm.sdk.device.bean.DeviceOidInfoBean;
@@ -67,6 +68,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
@@ -115,8 +117,9 @@
                return;
            }
            String type = getKeyValue("type", data);//小类
            String logTag = getKeyValue("logTag", data);//标记uni指令
            String mode_type = "大类->" + topic + "--->" + "小类->" + type;//用来打印的
            HdlLogLogic.print("uni--->发送--->" + mode_type + "\r\n" + data, true);
            HdlLogLogic.print(logTag + ":" + "uni--->发送--->" + mode_type + "\r\n" + data, true);
            if (HDLUniMP.UNI_EVENT_REPLY_USER_MODEL.equals(topic)) {
                //用户模块
                switch (type) {
@@ -124,9 +127,18 @@
                    case HDLUniMP.UNI_EVENT_REPLY_USER_INFO: {
                        this.uniGetUserInfo(mode_type, data, callback);
                    }
                    break;
                    //用户头像(旧平台逻辑是头像单独获取下载地址)
                    case HDLUniMP.UNI_EVENT_REPLY_USER_IMAGE: {
                        uniGetImageKey(mode_type, data, callback);
                    }
                    break;
                    //用户本地缓存信息
                    case HDLUniMP.UNI_EVENT_REPLY_USER_LOCAL_INFO: {
                        JsonObject jsonObject = new JsonObject();
                        jsonObject.addProperty("user_name", UserConfigManage.getInstance().getUserName());
                        jsonObject.addProperty("user_image_url", UserConfigManage.getInstance().getUserImageUrl());
                        uniCallbackData(mode_type, jsonObject, callback);
                    }
                    break;
                }
@@ -1121,6 +1133,7 @@
                UserConfigManage.getInstance().Save();
                //获取用户头像路径
                if (cUserInfo.getMemberHeadIcon().contains("http")) {
                    UserConfigManage.getInstance().setUserImageUrl(cUserInfo.getMemberHeadIcon());
                    //更新用户头像
                    uniCallbackData(type, cUserInfo, callback);
                } else {
@@ -1128,12 +1141,13 @@
                        @Override
                        public void onSuccess(String url) {
                            cUserInfo.setMemberHeadIcon(url);
                            UserConfigManage.getInstance().setUserImageUrl(cUserInfo.getMemberHeadIcon());
                            uniCallbackData(type, cUserInfo, callback);
                        }
                        @Override
                        public void onFailure(HDLException e) {
                            uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
                            uniCallbackData(type, cUserInfo, callback);
                        }
                    });
                }
@@ -1356,6 +1370,7 @@
//        com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray(data);
        try {
            String devices = getKeyValue("devices", getKeyValue("data", data));
            String homeId = UserConfigManage.getInstance().getHomeId(); //getKeyValue("homeId", getKeyValue("data", data));
            Gson gson = new Gson();
            Type typeOfT = new TypeToken<List<GatewayBean>>() {
            }.getType();
@@ -1364,7 +1379,6 @@
                uniCallbackData(type, null, -100, HDLApp.getInstance().getString(R.string.The_gateway_cannot_be_found_locally), callback);
                return;
            }
            String homeId = UserConfigManage.getInstance().getHomeId();
            //记录条数
            AtomicInteger atomicInteger = new AtomicInteger(0);
            final boolean[] is_boolean = {false};
@@ -1379,7 +1393,7 @@
                                atomicInteger.set(atomicInteger.get() + 1);
                                //最后一条才做添加逆变器逻辑处理
                                if (atomicInteger.get() == list.size()) {
                                    HdlDeviceLogic.getInstance().addAllInverterDeviceToCloud(homeId, gatewayBean.getDevice_mac(), list, new CloudCallBeak<Boolean>() {
                                    HdlDeviceLogic.getInstance().addAllInverterDeviceToCloud(homeId, list, new CloudCallBeak<Boolean>() {
                                        @Override
                                        public void onSuccess(Boolean obj) {
                                            uniCallbackData(type, null, callback);
@@ -1448,7 +1462,7 @@
    private void uniSearchGateway(String type, DCUniMPJSCallback callback) {
        HdlDeviceLogic.getInstance().searchCurrentHomeGateway(new GatewayCallBack() {
        HdlDeviceLogic.getInstance().searchAllNetworkGateway(new GatewayCallBack() {
            @Override
            public void onSuccess(List<GatewayBean> gatewayBeanList) {
                uniCallbackData(type, gatewayBeanList, callback);
@@ -1480,16 +1494,16 @@
                    }
                    return;
                }
                //进来住宅详情都要上传一次oid列表到云端;
                HdlDeviceLogic.getInstance().uploadDataToCloud(homeId, list, null);
                if (callback != null) {
                    uniCallbackData(type, list, callback);
                }
                //EventBus事件分发,进入住宅开始订阅主题
                BaseEventBus baseEventBus = new BaseEventBus();
                baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST);
                baseEventBus.setData(list);
                EventBus.getDefault().post(baseEventBus);
                if (callback != null) {
                    uniCallbackData(type, list, callback);
                }
                //进来住宅详情都要上传一次oid列表到云端;
                HdlDeviceLogic.getInstance().uploadDataToCloud(homeId, list, null);
            }
            @Override
@@ -1550,7 +1564,7 @@
            @Override
            public void onError(HDLLinkException e) {
                uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
                //HdlLogLogic.print("uni--->接收--->ModBus--->" + e.getMsg() + "(" + e.getCode() + ")", true);
//                HdlLogLogic.print("uni--->接收--->ModBus--->" + e.getMsg() + "(" + e.getCode() + ")", true);
            }
        });
    }