mac
2024-06-18 73919e36e6c84a665a2c4352fa3b22d1b2e9e6bb
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -33,7 +33,9 @@
import com.hdl.photovoltaic.bean.ModBusBean;
import com.hdl.photovoltaic.bean.PageNumberObject;
import com.hdl.photovoltaic.config.AppConfigManage;
import com.hdl.photovoltaic.config.ConstantManage;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.enums.LowerTagType;
import com.hdl.photovoltaic.internet.HttpServer.MyNanoHttpServer;
import com.hdl.photovoltaic.internet.TcpClient;
import com.hdl.photovoltaic.internet.api.HttpApi;
@@ -168,11 +170,10 @@
                    //创建电站
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: {
                        //EventBus事件分发
                        BaseEventBus baseEventBus = new BaseEventBus();
                        baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL);
                        baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION);
                        baseEventBus.setData(getKeyValue("data", data));
                        EventBus.getDefault().post(baseEventBus);
                        HdlCommonLogic.getInstance().postEventBus(
                                HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL,
                                HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION,
                                getKeyValue("data", data));
                    }
                    break;
                    //读取详情
@@ -180,23 +181,28 @@
                    }
                    break;
                    //电站删除
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_DEl: {
                        this.uniGetDelResidence(mode_type, data, callback);
                    }
                    break;
                    //关闭详情页
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE: {
                        //EventBus事件分发
                        BaseEventBus baseEventBus = new BaseEventBus();
                        baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE);
                        baseEventBus.setData(getKeyValue("data", data));
                        EventBus.getDefault().post(baseEventBus);
                        // todo 在HDLUniMPSDKManager类里面有方法()监听到小程序关闭,然后发布调用EventBus发布出去;
//                        HdlCommonLogic.getInstance().postEventBus(
//                                HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE,
//                                LowerTagType.power_station.toString(),
//                                getKeyValue("data", data));
                    }
                    break;
                    //住宅【电站】编辑
                    case HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT: {
                        //EventBus事件分发
                        BaseEventBus baseEventBus = new BaseEventBus();
                        baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL);
                        baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT);
                        baseEventBus.setData(getKeyValue("data", data));
                        EventBus.getDefault().post(baseEventBus);
                        HdlCommonLogic.getInstance().postEventBus(
                                HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL,
                                HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT,
                                getKeyValue("data", data));
                    }
                    break;
                    //电站的交付二维码(安装商)
@@ -643,6 +649,34 @@
    //endregion
    //region ******uni接口方法******
    /**
     * 电站删除
     */
    private void uniGetDelResidence(String type, Object data, DCUniMPJSCallback callback) {
        String homeId = getKeyValue("homeId", getKeyValue("data", data));
        HdlResidenceLogic.getInstance().delResidence(homeId, new CloudCallBeak<Boolean>() {
            @Override
            public void onSuccess(Boolean obj) {
                List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId);
                for (int i = 0; i < list.size(); i++) {
                    GatewayBean gatewayBean = list.get(i);
                    HdlDeviceLogic.getInstance().initializeInverter(gatewayBean.getDevice_mac(), null);
                }
                list.clear();//清空缓存;
//              HDLLinkLocalGateway.getInstance().getGatewayList().clear();
                HdlResidenceLogic.getInstance().delHouseId(homeId);//删除电站缓存
                //uni收到成功结果响应后,会自动关闭小程序,在HDLUniMPSDKManager类里面有方法()监听到小程序关闭,监听到小程序关闭事件后,会重新获取电站列表进行刷界面;
                uniSuccessCallback(type, obj, callback);
            }
            @Override
            public void onFailure(HDLException e) {
                uniExceptionCallback(type, e, callback);
            }
        });
    }
    /**
     * 电站授权安装商(C端)
@@ -1915,12 +1949,11 @@
    private void uniDelInverterDevice(String type, Object data, DCUniMPJSCallback callback) {
        String deviceId = getKeyValue("deviceId", getKeyValue("data", data));
        String homeId = getKeyValue("homeId", getKeyValue("data", data));
        if (TextUtils.isEmpty(homeId)) {
            homeId = UserConfigManage.getInstance().getHomeId();
        }
        HdlDeviceLogic.getInstance().delInverterDevice(homeId, deviceId, new CloudCallBeak<Boolean>() {
            @Override
            public void onSuccess(Boolean obj) {
                //移除本地缓存
                HdlDeviceLogic.getInstance().removeLocalCacheMemoryGatewayToDeviceId(homeId, deviceId);
                uniSuccessCallback(type, null, callback);
            }