wjc
2025-05-07 5d3efa4c93dde0cde474951e5310bb72ebbf4184
app/src/main/java/com/hdl/photovoltaic/other/HdlMemberLogic.java
@@ -6,17 +6,29 @@
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.HDLApp;
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.bean.PageNumberObject;
import com.hdl.photovoltaic.internet.HttpClient;
import com.hdl.photovoltaic.internet.api.HttpApi;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
import com.hdl.photovoltaic.ui.bean.MemberBean;
import com.hdl.photovoltaic.ui.bean.StaffBean;
import com.hdl.photovoltaic.ui.bean.UserRightTypeBean;
import com.hdl.photovoltaic.utils.AesUtils;
import com.hdl.photovoltaic.utils.Md5Utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import okhttp3.ResponseBody;
/**
 * 成员逻辑
@@ -120,7 +132,7 @@
     * @param userId        -
     * @param cloudCallBeak -
     */
    public void getStaffInfo(String userId, CloudCallBeak<PageNumberObject<StaffBean>> cloudCallBeak) {
    public void getStaffInfo(String userId, CloudCallBeak<StaffBean> cloudCallBeak) {
        String requestUrl = HttpApi.B_POST_GET_MANAGE_INFO;
        JsonObject json = new JsonObject();
        json.addProperty("userId", userId);
@@ -129,15 +141,14 @@
            public void onSuccess(String jsonStr) {
                if (TextUtils.isEmpty(jsonStr)) {
                    if (cloudCallBeak != null) {
                        cloudCallBeak.onSuccess(new PageNumberObject<>());
                        cloudCallBeak.onSuccess(new StaffBean());
                    }
                }
                Gson gson = new Gson();
                Type type = new TypeToken<PageNumberObject<StaffBean>>() {
                }.getType();
                PageNumberObject<StaffBean> pageNumberObject = gson.fromJson(jsonStr, type);
                StaffBean staffBean = gson.fromJson(jsonStr, StaffBean.class);
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(pageNumberObject);
                    cloudCallBeak.onSuccess(staffBean);
                }
            }
@@ -272,7 +283,6 @@
        String requestUrl = HttpApi.C_POST_MEMBER_LIST;
        JsonObject json = new JsonObject();
        json.addProperty("homeId", memberBean.getHomeId());
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(String jsonStr) {
@@ -298,7 +308,9 @@
            }
        });
    }
    /**
     * 添加成员(C端)
@@ -398,5 +410,72 @@
    }
    /**
     * 下载成员(子账号)头像  已丢弃
     */
    public void getHeadPIortrait(MemberBean memberBean, CloudCallBeak<byte[]> cloudCallBeak) {
        String requestUrl = HttpApi.C_POST_HOME_GETHEADPÏORTRAIT;
        JsonObject json = new JsonObject();
        json.addProperty("homeId", memberBean.getHomeId());
        json.addProperty("childAccountId", memberBean.getChildAccountId());
//        json.addProperty("childId", memberBean.getChildAccountId());//查找子账号接口获取到的数据(主键id==childId)
        HttpClient.getInstance().downLoadFile(requestUrl, new CloudCallBeak<ResponseBody>() {
            @Override
            public void onSuccess(ResponseBody zipData) {
                HdlThreadLogic.runSubThread(new Runnable() {
                    @Override
                    public void run() {
                        byte[] buf = new byte[1204 * 4];
                        int len = 0;
                        try {
                            long total = zipData.contentLength();
                            if (total == 0) {
                                if (cloudCallBeak != null) {
                                    cloudCallBeak.onSuccess(new byte[]{});
                                }
                                return;
                            }
                            List<Byte> byteList = new ArrayList<>();
                            InputStream is = zipData.byteStream();
                            while ((len = is.read(buf)) != -1) {
                                for (int i = 0; i < len; i++) {
                                    byteList.add(buf[i]);
                                }
                            }
                            is.close();
                            if (byteList.size() == 0) {
                                if (cloudCallBeak != null) {
                                    cloudCallBeak.onSuccess(new byte[]{});
                                }
                                return;
                            }
                            byte[] newByte = new byte[byteList.size()];
                            for (int i = 0; i < byteList.size(); i++) {
                                newByte[i] = byteList.get(i);
                            }
                            if (cloudCallBeak != null) {
                                cloudCallBeak.onSuccess(newByte);
                            }
                        } catch (Exception e) {
                            if (cloudCallBeak != null) {
                                cloudCallBeak.onSuccess(new byte[]{});
                            }
                        }
                    }
                });
            }
            @Override
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(new byte[]{});
                }
            }
        });
    }
}