From 66c4c910dcfe5d955103376c4c4afc685557dc55 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期四, 23 十一月 2023 18:13:02 +0800 Subject: [PATCH] 2023年11月23日18:11:10 --- app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 43 ++++++++++++++++++++----------------------- 1 files changed, 20 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java index a5be3d4..8136a4a 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java @@ -53,6 +53,7 @@ import java.util.Objects; import io.dcloud.feature.unimp.DCUniMPJSCallback; +import okhttp3.ResponseBody; /** * uni灏忕▼搴忕殑閫昏緫 @@ -530,12 +531,15 @@ File file = new File(driverFileList); if (file.list() != null) { for (int i = 0; i < Objects.requireNonNull(file.list()).length; i++) { - String path = Objects.requireNonNull(file.list())[i]; - String[] ary = path.split("/"); - String[] driverInfoAry = ary[ary.length - 1].split("_"); + String fileName = Objects.requireNonNull(file.list())[i]; + if (!fileName.contains(driveCode)) { + continue; + } + String[] driverInfoAry = fileName.split("_"); GatewayDriverBean gatewayDriverBean = new GatewayDriverBean(); gatewayDriverBean.setDriverCode(driverInfoAry[0]); gatewayDriverBean.setVersion(driverInfoAry[1].replace(".zip", "")); + gatewayDriverBean.setLocalUrl(HdlFileLogic.getInstance().getDrivePathFileName(gatewayDriverBean.getDriverCode(), gatewayDriverBean.getVersion())); list.add(gatewayDriverBean); } } @@ -557,32 +561,25 @@ String imageId = getKeyValue("imageId", getKeyValue("data", data));//椹卞姩闀滃儚id String version = getKeyValue("version", getKeyValue("data", data));//椹卞姩鐗堟湰 String driverVersionId = getKeyValue("driverVersionId", getKeyValue("data", data));//椹卞姩鐗堟湰id - HdlOtaLogic.getInstance().getDeviceDriverDownloadUrl(driverVersionId, new CloudCallBeak<DownloadUrlBean>() { + String localUrl = getKeyValue("localUrl", getKeyValue("data", data));//鍌ㄥ瓨鍦ㄦ湰鍦伴┍鍔ㄦ枃浠惰矾寰� + String url = getKeyValue("url", getKeyValue("data", data));//浜戠涓婃枃浠跺湴鍧� + String md5 = getKeyValue("md5", getKeyValue("data", data));//浜戠涓婃枃浠禡D5 + HdlOtaLogic.getInstance().getDeviceDriverDownloadFile(url, new CloudCallBeak<ResponseBody>() { @Override - public void onSuccess(DownloadUrlBean downloadUrlBean) { - if (downloadUrlBean == null) { - uniCallbackData(null, -2, "涓嬭浇閾炬帴鎵句笉鍒�", callback); - return; + public void onSuccess(ResponseBody responseBody) { + String drivePathFileName = HdlFileLogic.getInstance().getDrivePathFileName(driverCode, version); + boolean isBoolean = HdlOtaLogic.getInstance().disposeDownLoadFile(drivePathFileName, responseBody, md5, HdlOtaLogic.driver_type); + if (isBoolean) { + HdlFileLogic.getInstance().deleteFile(localUrl);//涓嬭浇鎴愬姛,鍒犻櫎鏃ф枃浠�; + } else { + HdlFileLogic.getInstance().deleteFile(drivePathFileName);//涓嬭浇澶辫触鍒犻櫎涓嶅畬鎴愭暟鎹�; } - HdlOtaLogic.getInstance().getDeviceDriverDownloadFile(downloadUrlBean.getDownloadUrl(), new CloudCallBeak<DownloadUrlBean>() { - @Override - public void onSuccess(DownloadUrlBean obj) { - Gson gson = new Gson(); - String json = gson.toJson(obj); - String drivePathFileName = HdlFileLogic.getInstance().getDrivePathFileName(driverCode, version); - HdlFileLogic.getInstance().writeFile(drivePathFileName, json); - - } - - @Override - public void onFailure(HDLException e) { - - } - }); + HdlLogLogic.print("鍐欏叆鏂伴┍鍔ㄦ枃浠跺埌鍐呭瓨鎴愬姛.", false); } @Override public void onFailure(HDLException e) { + HdlLogLogic.print("涓嬭浇椹卞姩鏂囦欢鍒板唴瀛樺け璐�.", false); uniCallbackData(null, e.getCode(), e.getMsg(), callback); } }); -- Gitblit v1.8.0