wjc
1 天以前 770c89ab981b7659faabf8a812a25d99a11bdebf
app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
@@ -29,6 +29,7 @@
import com.hdl.photovoltaic.databinding.ActivityCpowerStationBinding;
import com.hdl.photovoltaic.enums.NetworkType;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.other.HdlAiLogic;
import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.other.HdlDeviceLogic;
import com.hdl.photovoltaic.other.HdlESLocalJsonLogic;
@@ -41,6 +42,9 @@
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.push.PushMessageInfoBean;
import com.hdl.photovoltaic.services.ForeService;
import com.hdl.photovoltaic.ui.bean.ChatInfoBean;
import com.hdl.photovoltaic.ui.bean.ChatMessageListBean;
import com.hdl.photovoltaic.ui.bean.ChatMessagePageBean;
import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.bean.MessageBean;
@@ -91,6 +95,10 @@
    @Override
    public void onBindView(Bundle savedInstanceState) {
//        //通知栏点击进来,防止应用在后台时被重复启动,阿里云推动通知指定打开某个Activity,没有设置Flags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);默认启动新实例,导致多个实例
//        if (!isTaskRoot()) {
//            finish();
//        }
        setStatusBarTranslucent();
        getWindow().setNavigationBarColor(getColor(R.color.text_FF000000));
        //C端启动App自动打开小程序电站详情界面
@@ -101,6 +109,7 @@
        this.initMqttClient();
//        //上传极光注册ID到云端
//        this.pushTokens();
        this.getChatInfo();
        //上传推动令牌到云端(谷歌FCM推送)
        this.sendPushTokenToServer(UserConfigManage.getInstance().getPushToken());
        //点击通知栏消息进来
@@ -109,6 +118,45 @@
        HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson();
//        mForegroundService= new Intent(this, ForeService.class);
//        startService();
    }
    /**
     * 查看智能体详情
     *
     */
    private void getChatInfo() {
        HdlAiLogic.getInstance().getChatInfo(new CloudCallBeak<ChatInfoBean>() {
            @Override
            public void onSuccess(ChatInfoBean chatInfoBean) {
                UserConfigManage.getInstance().setAgentSecret(chatInfoBean.getAgentSecret());
                UserConfigManage.getInstance().setAgentUrl(chatInfoBean.getAgentUrl());
                UserConfigManage.getInstance().Save();
                HdlAiLogic.getInstance().chatMessagesList(new CloudCallBeak<ChatMessagePageBean>() {
                    @Override
                    public void onSuccess(ChatMessagePageBean obj) {
                        if (obj != null && !obj.getData().isEmpty()) {
                            UserConfigManage.getInstance().setConversationId(obj.getData().get(0).getId());
                            UserConfigManage.getInstance().Save();
                        } else {
                            //没有拿到对话列表,把旧的当前会话ID清空
                            UserConfigManage.getInstance().setConversationId("");
                            HdlLogLogic.print("没有拿到对话列表,把旧的当前会话ID清空 ", true);
                        }
                    }
                    @Override
                    public void onFailure(HDLException e) {
                    }
                });
            }
            @Override
            public void onFailure(HDLException e) {
                HdlLogLogic.print("获取智能体详情失败:" + e.getMessage(), true);
            }
        });
    }
    Intent mForegroundService;
@@ -148,9 +196,10 @@
                return;
            }
            PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data);
            if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) {
            if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId()) && !pushMessageInfoBean.isAiPrompt()) {
                return;
            }
            Log.d("==========111111", tag);
            HDLUniMPSDKManager.uinEnabled = false;
            if (tag.equals("onNewIntent")) {
                HDLUniMPSDKManager.uinEnabled = false;
@@ -204,7 +253,10 @@
                            @Override
                            public void run() {
                                if (pushMessageInfoBean.isAiPrompt()) {
                                    HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_open_ai_push_message, new HDLUniMP.UniCallBackBaseBean());
                                    HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
                                    uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_open_ai_push_message);
                                    HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
                                    HdlLogLogic.print("uni---原生主动向小程序发送通知AI事件---", false);
                                } else {
                                    MessageBean messageBean = new MessageBean();
                                    messageBean.setMsgId(Long.valueOf(pushMessageInfoBean.getMsgId()));
@@ -212,6 +264,7 @@
                                    intentMessageInfoActivity.setClass(_mActivity, MessageInfoActivity.class);
                                    intentMessageInfoActivity.putExtra("messageBean", JSONObject.toJSONString(messageBean));
                                    startActivity(intentMessageInfoActivity);
                                    HdlLogLogic.print("uni---原生主动向小程序发送通知AI事件---11111", false);
                                }
                            }
@@ -293,7 +346,7 @@
                        //防止app启动的时候没有网络(app也登录不了),导致获取不了mqtt远程连接信息;
                        initMqttClient();
                        HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<GatewayBean>>() {
                        HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(UserConfigManage.getInstance().getHomeId(), UserConfigManage.getInstance().getPowerStationType(), new CloudCallBeak<List<GatewayBean>>() {
                            @Override
                            public void onSuccess(List<GatewayBean> obj) {
//                                AppManagerUtils.getAppManager().hideLoading();
@@ -374,8 +427,7 @@
            }
            HouseIdBean houseIdBean = HouseIdList.get(select_home);
            HdlResidenceLogic.getInstance().switchHouse(houseIdBean, false);
            String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus();
            HdlUniLogic.getInstance().openUniMP(path, null);
            HdlResidenceLogic.getInstance().openPowerStationDetails(houseIdBean);
        }
    }
@@ -461,7 +513,7 @@
//                    UserConfigManage.getInstance().setRegistrationID(registrationID);
//                    UserConfigManage.getInstance().Save();
                    String finalRegistrationID = registrationID;
                    HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
                    HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
                        @Override
                        public void onSuccess(String pushId) {
@@ -498,7 +550,7 @@
        if (TextUtils.isEmpty(token)) {
            return;
        }
        HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
        HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
            @Override
            public void onSuccess(String pushId) {
@@ -651,6 +703,7 @@
                                    jsonObject.addProperty("homeId", houseIdBean.getHomeId());
                                    jsonObject.addProperty("homeName", houseIdBean.getHomeName());
                                    jsonObject.addProperty("powerStationStatus", houseIdBean.getPowerStationStatus() + "");
                                    jsonObject.addProperty("powerStationType", houseIdBean.getPowerStationType());
                                    HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
                                    uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_DETAILS);
                                    uniCallBackBaseBean.setData(jsonObject);