| | |
| | | // CrashReport.initCrashReport(this, Constant.BUGLY_APP_ID, true); |
| | | //6.初始化DCUniMPSDK |
| | | initDCUniMPSDK(); |
| | | // this.initUniMqtt();//如果是部署到/手机上正式使用,注释掉这行代码就可 |
| | | this.initUniMqtt();//如果是部署到/手机上正式使用,注释掉这行代码就可 |
| | | // //7.初始化自定义IconToast |
| | | // ToastUtils.getInstance().initIconToast(this); |
| | | // //8.对fastjson进行设置,解决fastjosn转换成字符串时首字母大小写问题 |
| | |
| | | */ |
| | | private void initUniMqtt() { |
| | | try { |
| | | String ip = NetworkUtils.getIPAddress(this); |
| | | String ip = "10.10.35.79";//NetworkUtils.getIPAddress(this); |
| | | if (TextUtils.isEmpty(ip)) { |
| | | return; |
| | | } |
| | |
| | | private static final String APP_KEY_ONLINE = "CSZEMDJL"; |
| | | private static final String APP_SECRET_ONLINE = "CSZEMDKBCSZEMDKR"; |
| | | private static final String APP_REGIONURL_ONLINE = "https://nearest.hdlcontrol.com"; |
| | | |
| | | /*********测试环境*********/ |
| | | private static final String APP_KEY_TEST = "CTBGMNUV"; |
| | | private static final String APP_SECRET_TEST = "CTBGMNVLCTBGMNWB"; |
| | | private static final String APP_REGIONURL_TEST = "https://test-gz.hdlcontrol.com"; |
| | | |
| | | |
| | | /*********获取当前是否使用正式服务器环境*********/ |
| | | public static boolean isIsOnlineServer() { |
| | | return isOnlineServer; |
| | |
| | | |
| | | private static volatile HttpClient sHttpClient; |
| | | |
| | | private static final boolean isAddToMemory=false; |
| | | private static final boolean isAddToMemory = false; |
| | | |
| | | public static synchronized HttpClient getInstance() { |
| | | if (sHttpClient == null) { |
| | |
| | | private Disposable requestPost(String api, String body, CloudCallBeak<String> callBack) { |
| | | String requestUrl = HDLCloudUserApi.getRequestUrl(api); |
| | | HdlLogLogic.print("http->发送->" + requestUrl + "\r\n" + body, isAddToMemory); |
| | | return HxHttp.builder().url(requestUrl).raw(body).build().post().subscribeWith(new HDLResponse<String>() { |
| | | return HxHttp.builder().headers("x-lbs-version", "hdl-yt").url(requestUrl).raw(body).build().post().subscribeWith(new HDLResponse<String>() { |
| | | @Override |
| | | public void onResponse(String str) { |
| | | if (callBack != null) { |
| | |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.home.type.GatewayType; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.internet.HttpClient; |
| | |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import io.dcloud.common.adapter.util.DeviceInfo; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | oidList.addAll(oidBeanList); |
| | | if (atomicInteger.get() == oidList.size()) { |
| | | //全部获取后再上传 |
| | | fullUpdateOid(homeId, oidList, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | |
| | | /** |
| | | * 添加多个逆变器到云端上 |
| | | * |
| | | * @param mac - |
| | | * @param list 逆变器列表 |
| | | * @param cloudCallBeak - |
| | | */ |
| | | public void addAllInverterDeviceToCloud(String homeId, String mac, List<GatewayBean> list, CloudCallBeak<Boolean> cloudCallBeak) { |
| | | public void addAllInverterDeviceToCloud(String homeId, List<GatewayBean> list, CloudCallBeak<Boolean> cloudCallBeak) { |
| | | |
| | | String requestUrl = HttpApi.POST_Device_Add_All; |
| | | JsonObject json = new JsonObject(); |
| | |
| | | * @param isOpened true=点击通知栏回调,false=收到推送通知回调; |
| | | */ |
| | | public void JpushPushCommonData(Context context, JPushMessageInfoBean jPushMessageInfoBean, boolean isOpened) { |
| | | //添加推送数据到缓存列表中; |
| | | this.addPushDataToMemoryList(jPushMessageInfoBean); |
| | | if (isOpened) { |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //添加推送数据到缓存列表中; |
| | | this.addPushDataToMemoryList(jPushMessageInfoBean); |
| | | if (isOpened) { |
| | | //安装商跳转界面 |
| | | Intent intent = new Intent(context, MyPowerStationActivity.class); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| | | intent.putExtra("skip", "skip");//里面判断有这个标识就跳转到消息中心界面 |
| | | context.startActivity(intent); |
| | | |
| | | } else { |
| | | BaseEventBus bus = new BaseEventBus(); |
| | | bus.setTopic(ConstantManage.message_function_push_post); |
| | | bus.setType(MessageStateType.untreated); |
| | | EventBus.getDefault().post(bus); |
| | | } |
| | | } else { |
| | | BaseEventBus bus = new BaseEventBus(); |
| | | bus.setTopic(ConstantManage.message_function_push_post); |
| | | bus.setType(MessageStateType.untreated); |
| | | EventBus.getDefault().post(bus); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.hdl.photovoltaic.other; |
| | | |
| | | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.utils.TimeUtils; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public class HdlLogLogic { |
| | | |
| | | //是否需要打印到Logcat上(true不需要打印) |
| | | public static boolean isPrintLogcat = false; |
| | | //是否需要打印到Logcat上(false不需要打印) |
| | | public static boolean isPrintLogcat = true; |
| | | //默认打印标题 |
| | | private static final String title = "自定义输出打印信息:"; |
| | | |
| | | private static String logTitle = "自定义输出打印信息"+ (UserConfigManage.getInstance().isBAccount() ? "(B):" : "(C):"); |
| | | |
| | | /** |
| | | * java打印 |
| | |
| | | * @param isAddToMemory 是否加入内存(本地日志用到) |
| | | */ |
| | | private static void printBase(String msg, String code, boolean isAddToMemory) { |
| | | if (isPrintLogcat) { |
| | | return; |
| | | } |
| | | CustomLogObject customLogObject = new CustomLogObject(); |
| | | customLogObject.msgOrData = msg; |
| | | customLogObject.code = code; |
| | | String json = title; |
| | | String json =logTitle; |
| | | json += customLogObject.getJointMessage(); |
| | | System.out.println(json); |
| | | if (isPrintLogcat) { |
| | | System.out.println(json); |
| | | } |
| | | if (isAddToMemory) { |
| | | writeLog(customLogObject.getJointMessage()); |
| | | } |
| | |
| | | return sortList(newList); |
| | | } |
| | | |
| | | /** |
| | | * 消息全部已读(本地缓存) |
| | | * |
| | | * @param isRead 是否读取(true已读取) |
| | | */ |
| | | public void setAllRead(boolean isRead) { |
| | | for (int i = 0; i < mListMessage.size(); i++) { |
| | | MessageBean messageBean = mListMessage.get(i); |
| | | if (messageBean == null) { |
| | | continue; |
| | | } |
| | | messageBean.setRead(isRead); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取恢复中缓存列表 |
| | |
| | | /** |
| | | * 获取指定页的获取消息列表(用于C端) |
| | | * |
| | | * @param homeId 电站id |
| | | * @param pageNo 页码 |
| | | * @param messageStateType all:全部,UNTREATED:未处理,PROCESSED:已处理; |
| | | * @param filter_key 类型(设备,等级,时间) |
| | |
| | | * timeType(TODAY :今天;LAST_3_DAYS: 近3天;LAST_7_DAYS :近7天;LAST_30_DAYS :近30天); |
| | | * @param cloudCallBeak - |
| | | */ |
| | | public void getPageNoMessageList_C(int pageNo, String messageStateType, String filter_key, String filter_value, CloudCallBeak<MessageListClass> cloudCallBeak) { |
| | | public void getPageNoMessageList_C(String homeId, int pageNo, String messageStateType, String filter_key, String filter_value, CloudCallBeak<MessageListClass> cloudCallBeak) { |
| | | String requestUrl = HttpApi.POST_Message_List; |
| | | JsonObject json = new JsonObject(); |
| | | |
| | | if (!TextUtils.isEmpty(homeId)) { |
| | | json.addProperty("homeId", homeId); |
| | | } |
| | | if (!MessageStateType.all.equals(messageStateType)) { |
| | | json.addProperty("status", messageStateType); |
| | | } |
| | |
| | | */ |
| | | public class HdlResidenceLogic { |
| | | |
| | | public static final int pageSize = 500; |
| | | public static final int pageSize = 50; |
| | | |
| | | private static volatile HdlResidenceLogic sHdlResidenceLogic; |
| | | |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | HdlAccountLogic.getInstance().regionByAccount(account, new CloudCallBeak<HDLUserRegionBean>() { |
| | | @Override |
| | | public void onSuccess(HDLUserRegionBean obj) { |
| | | String APP_REGIONURL_TEST = "http://47.114.131.143:27199"; |
| | | //初始化服务域名 |
| | | AppConfigManage.setUserRegionUrl(obj.getRegionUrl()); |
| | | // AppConfigManage.setUserRegionUrl(obj.getRegionUrl()); |
| | | AppConfigManage.setUserRegionUrl(APP_REGIONURL_TEST); |
| | | HDLLinkPMUser.getInstance().setUserRegionUrl(AppConfigManage.getUserRegionUrl()); |
| | | HdlAccountLogic.getInstance().loginByPassword(account, password, new ILoginCallBack() { |
| | | @Override |
| | |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | hideLoading(); |
| | | loadNextPageMessageList(1, true, mFilterKye, mFilterValue); |
| | | HdlMessageLogic.getInstance().setAllRead(true); |
| | | updateListData(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } else { |
| | | messageStateType = MessageStateType.processed; |
| | | } |
| | | HdlMessageLogic.getInstance().getPageNoMessageList_C(pageNo, messageStateType, filter_key, filter_value, new CloudCallBeak<HdlMessageLogic.MessageListClass>() { |
| | | HdlMessageLogic.getInstance().getPageNoMessageList_C(UserConfigManage.getInstance().getHomeId(), pageNo, messageStateType, filter_key, filter_value, new CloudCallBeak<HdlMessageLogic.MessageListClass>() { |
| | | @Override |
| | | public void onSuccess(HdlMessageLogic.MessageListClass messageListClass) { |
| | | if (messageListClass != null) { |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) |
| | |
| | | //移动电站位置 |
| | | HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId()); |
| | | initData();//初始化缓存数据 |
| | | setAllItemEdit(is_edit); |
| | | houseListAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | } |
| | |
| | | /** |
| | | * 监听相关回调 |
| | | */ |
| | | private void registerCallBack() {DCUniMPSDK.getInstance(); |
| | | private void registerCallBack() { |
| | | DCUniMPSDK.getInstance(); |
| | | //1.设置小程序被关闭事件监听 |
| | | DCUniMPSDK.getInstance().setUniMPOnCloseCallBack(new IUniMPOnCloseCallBack() { |
| | | @Override |
| | |
| | | HdlLogLogic.print("收到小程序通知 event=" + event); |
| | | //暂时通过这个处理小程序同时多条相同的请求 |
| | | if (data == null) { |
| | | HdlLogLogic.print("收到小程序通知,data数据为null。", true); |
| | | |
| | | return; |
| | | } |
| | | // String key= MD5Utils.getMd5(event+data.toString()); |
| | |
| | | //除了统一处理,剩余其它特定场景的事件通知 |
| | | if (onOtherUniMPEventCallBack != null) { |
| | | onOtherUniMPEventCallBack.onOtherUniMPEventReceive(appid, event, data, callback); |
| | | } else { |
| | | HdlLogLogic.print("收到小程序通知,回调事件为null,无法回调事件并执行业务逻辑 event=" + event + "\r\n" + "data=" + data, true); |
| | | } |
| | | } |
| | | } |