| | |
| | | |
| | | String requestUrl = HDLCloudUserApi.getRequestUrl(api); |
| | | Gson gson = new Gson(); |
| | | System.out.println("发送->" + requestUrl + "\r\n" + body); |
| | | System.out.println("http->发送->" + requestUrl + "\r\n" + body); |
| | | return HxHttp.builder() |
| | | .url(requestUrl) |
| | | .raw(body) |
| | |
| | | public void onResponse(String str) { |
| | | if (callBack != null) { |
| | | callBack.onSuccess(str); |
| | | // System.out.println("回复->" + requestUrl + "\r\n" + gson.fromJson(str, JsonObject.class).toString()); |
| | | System.out.println("回复->" + requestUrl + "\r\n" + str); |
| | | // System.out.println("http->回复->" + requestUrl + "\r\n" + gson.fromJson(str, JsonObject.class).toString()); |
| | | System.out.println("http->回复->" + requestUrl + "\r\n" + str); |
| | | } |
| | | } |
| | | |
| | |
| | | HDLExceptionSubmitUtils.submit(requestUrl, body, e); |
| | | if (callBack != null) { |
| | | callBack.onFailure(e); |
| | | System.out.println("回复->" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}"); |
| | | System.out.println("http->回复->" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}"); |
| | | } |
| | | } |
| | | }); |
| | |
| | | import com.hdl.photovoltaic.ui.bean.CloudInverterChildDeviceBean; |
| | | import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceTimeBean; |
| | | import com.hdl.photovoltaic.ui.bean.OidBean; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkException; |
| | | import com.hdl.sdk.link.core.bean.gateway.GatewayBean; |
| | |
| | | if (TextUtils.isEmpty(gatewayBean.getDevice_mac())) { |
| | | continue; |
| | | } |
| | | if (gatewayBean.getMaster().equals(GatewayMasterType.MasterTrue) |
| | | && gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) { |
| | | if (gatewayBean.getMaster().equals(GatewayMasterType.MasterTrue) && gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) { |
| | | newList.add(gatewayBean); |
| | | } |
| | | } |
| | |
| | | * @param mac 设备mac |
| | | * @param linkCallBack 回调update |
| | | */ |
| | | public void getGatewayTime(String mac, LinkCallBack<Boolean> linkCallBack) { |
| | | public void getGatewayTime(String mac, LinkCallBack<DeviceTimeBean> linkCallBack) { |
| | | String requestUrl = TopicApi.GET_GATEWAY_TIME; |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, null, "", new HDLLinkCallBack() { |
| | | @Override |
| | | public void onSuccess(String msg) { |
| | | public void onSuccess(String json) { |
| | | |
| | | if (TextUtils.isEmpty(json)) { |
| | | if (linkCallBack != null) { |
| | | linkCallBack.onSuccess(true); |
| | | linkCallBack.onSuccess(new DeviceTimeBean()); |
| | | } |
| | | return; |
| | | } |
| | | Gson gson = new Gson(); |
| | | DeviceTimeBean deviceTimeBean = gson.fromJson(json, DeviceTimeBean.class); |
| | | if (linkCallBack != null) { |
| | | linkCallBack.onSuccess(deviceTimeBean); |
| | | } |
| | | } |
| | | |
| | |
| | | * 网关时间修改 |
| | | * |
| | | * @param mac 设备mac |
| | | * @param date 日期 |
| | | * @param time 时间 |
| | | * @param linkCallBack 回调update |
| | | */ |
| | | public void editGatewayTime(String mac, JsonObject jsonObject, LinkCallBack<Boolean> linkCallBack) { |
| | | public void editGatewayTime(String mac, String date, String time, LinkCallBack<Boolean> linkCallBack) { |
| | | String requestUrl = TopicApi.SET_GATEWAY_TIME_EDIT; |
| | | // JsonObject json = new JsonObject(); |
| | | // json.addProperty("master", "true"); |
| | | // "objects": { |
| | | // "date": "2020-08-15", |
| | | // "time": "17:25:20" |
| | | // } |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, jsonObject, "", new HDLLinkCallBack() { |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("date", date);// "2020-08-15" |
| | | json.addProperty("time", time);//"17:25:20" |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, json, "", new HDLLinkCallBack() { |
| | | @Override |
| | | public void onSuccess(String msg) { |
| | | if (linkCallBack != null) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除本地逆变器 |
| | | * 删除本地缓存逆变器 |
| | | * |
| | | * @param sid 设备sid |
| | | */ |
| | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.listener.LinkCallBack; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceTimeBean; |
| | | import com.hdl.photovoltaic.ui.bean.OidBean; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | uniCallbackData(null, -100, e.getMessage(), callback); |
| | | uniCallbackData(null, e.getCode(), e.getMessage(), callback); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 逆变器上传数据到云端 |
| | | * 逆变器【上传数据】到云端 |
| | | * |
| | | * @param data uni数据 |
| | | * @param callback uni回调 |
| | |
| | | */ |
| | | private void uniEditInverterTime(Object data, DCUniMPJSCallback callback) { |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | HdlDeviceLogic.getInstance().editGatewayTime(mac, new JsonObject(), null); |
| | | String date = getKeyValue("date", getKeyValue("data", data)); |
| | | String time = getKeyValue("time", getKeyValue("data", data)); |
| | | HdlDeviceLogic.getInstance().editGatewayTime(mac, date, time, new LinkCallBack<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | uniCallbackData(true, callback); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | uniCallbackData(null, e.getCode(), e.getMsg(), callback); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private void uniGetInverterTime(Object data, DCUniMPJSCallback callback) { |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | HdlDeviceLogic.getInstance().getGatewayTime(mac, new LinkCallBack<Boolean>() { |
| | | HdlDeviceLogic.getInstance().getGatewayTime(mac, new LinkCallBack<DeviceTimeBean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | |
| | | public void onSuccess(DeviceTimeBean deviceTimeBean) { |
| | | if (callback != null) { |
| | | uniCallbackData(deviceTimeBean, callback); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | |
| | | uniCallbackData(null, e.getCode(), e.getMsg(), callback); |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | uniCallbackData(null, -2, e.getMsg(), callback); |
| | | uniCallbackData(null, e.getCode(), e.getMsg(), callback); |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | uniCallbackData(null, -100, e.getMessage(), callback); |
| | | uniCallbackData(null, e.getCode(), e.getMessage(), callback); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | uniCallbackData(null, -100, e.getMessage(), callback); |
| | | uniCallbackData(null, e.getCode(), e.getMessage(), callback); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | uniCallbackData(null, -100, e.getMessage(), callback); |
| | | uniCallbackData(null, e.getCode(), e.getMessage(), callback); |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | uniCallbackData(null, -100, e.getMessage(), callback); |
| | | uniCallbackData(null, e.getCode(), e.getMessage(), callback); |
| | | } |
| | | }); |
| | | } |
| | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | //发送失败 |
| | | uniCallbackData(null, e.getCode(), "", callback); |
| | | uniCallbackData(null, e.getCode(), e.getMessage(), callback); |
| | | } |
| | | }); |
| | | |
| | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | if (callback != null) { |
| | | uniCallbackData(null, -2, e.getMessage(), callback); |
| | | uniCallbackData(null, e.getCode(), e.getMessage(), callback); |
| | | } |
| | | } |
| | | }); |
New file |
| | |
| | | package com.hdl.photovoltaic.ui.bean; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class DeviceTimeBean implements Serializable { |
| | | |
| | | private String date; |
| | | private String lunar; |
| | | private String time; |
| | | private String week; |
| | | private String sunrise;//日出时间 |
| | | private String sunset;//日落时间 |
| | | private String noon;//正午时间 |
| | | private String broadcast_time;//广播时间间隔 |
| | | private String localtimestamp;//本地时间时间戳 |
| | | private String zone;//时区 |
| | | private DstBean dst; |
| | | |
| | | public String getDate() { |
| | | return date; |
| | | } |
| | | |
| | | public void setDate(String date) { |
| | | this.date = date; |
| | | } |
| | | |
| | | public String getLunar() { |
| | | return lunar == null ? "" : lunar; |
| | | } |
| | | |
| | | public void setLunar(String lunar) { |
| | | this.lunar = lunar; |
| | | } |
| | | |
| | | public String getTime() { |
| | | return time == null ? "" : time; |
| | | } |
| | | |
| | | public void setTime(String time) { |
| | | this.time = time; |
| | | } |
| | | |
| | | public String getWeek() { |
| | | return week == null ? "" : week; |
| | | } |
| | | |
| | | public void setWeek(String week) { |
| | | this.week = week; |
| | | } |
| | | |
| | | public String getSunrise() { |
| | | return sunrise == null ? "" : sunrise; |
| | | } |
| | | |
| | | public void setSunrise(String sunrise) { |
| | | this.sunrise = sunrise; |
| | | } |
| | | |
| | | public String getSunset() { |
| | | return sunset == null ? "" : sunset; |
| | | } |
| | | |
| | | public void setSunset(String sunset) { |
| | | this.sunset = sunset; |
| | | } |
| | | |
| | | public String getNoon() { |
| | | return noon == null ? "" : noon; |
| | | } |
| | | |
| | | public void setNoon(String noon) { |
| | | this.noon = noon; |
| | | } |
| | | |
| | | public String getBroadcast_time() { |
| | | return broadcast_time == null ? "" : broadcast_time; |
| | | } |
| | | |
| | | public void setBroadcast_time(String broadcast_time) { |
| | | this.broadcast_time = broadcast_time; |
| | | } |
| | | |
| | | public String getLocaltimestamp() { |
| | | return localtimestamp == null ? "" : localtimestamp; |
| | | } |
| | | |
| | | public void setLocaltimestamp(String localtimestamp) { |
| | | this.localtimestamp = localtimestamp; |
| | | } |
| | | |
| | | public String getZone() { |
| | | return zone == null ? "" : zone; |
| | | } |
| | | |
| | | public void setZone(String zone) { |
| | | this.zone = zone; |
| | | } |
| | | |
| | | public DstBean getDst() { |
| | | return dst; |
| | | } |
| | | |
| | | public void setDst(DstBean dst) { |
| | | this.dst = dst; |
| | | } |
| | | |
| | | public static class DstBean { |
| | | /** |
| | | * enable : false |
| | | * status : false |
| | | * start : 0,0,0,0 |
| | | * stop : 0,0,0,0 |
| | | */ |
| | | |
| | | private String enable; |
| | | private String status; |
| | | private String start;//五月,第三周,周日,两点 |
| | | private String stop;//十月,第四周,周日,两点 |
| | | |
| | | public String getEnable() { |
| | | return enable == null ? "" : enable; |
| | | } |
| | | |
| | | public void setEnable(String enable) { |
| | | this.enable = enable; |
| | | } |
| | | |
| | | public String getStatus() { |
| | | return status == null ? "" : status; |
| | | } |
| | | |
| | | public void setStatus(String status) { |
| | | this.status = status; |
| | | } |
| | | |
| | | public String getStart() { |
| | | return start == null ? "" : start; |
| | | } |
| | | |
| | | public void setStart(String start) { |
| | | this.start = start; |
| | | } |
| | | |
| | | public String getStop() { |
| | | return stop == null ? "" : stop; |
| | | } |
| | | |
| | | public void setStop(String stop) { |
| | | this.stop = stop; |
| | | } |
| | | } |
| | | } |