From 44ba605a4e850efa757020da5fb4cf02bdf6e3ab Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期一, 08 九月 2025 10:55:18 +0800
Subject: [PATCH] 2025年09月08日10:55:15
---
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java | 184 ++++++++++++++++++++++++++++++++--------------
1 files changed, 128 insertions(+), 56 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
index c3f00bd..8cffbfd 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -29,9 +29,11 @@
import com.hdl.photovoltaic.databinding.FragmentHouseListBinding;
import com.hdl.photovoltaic.base.CustomBaseFragment;
import com.hdl.photovoltaic.enums.DebugStatus;
+import com.hdl.photovoltaic.enums.DebugType;
import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch;
import com.hdl.photovoltaic.enums.LowerTagType;
import com.hdl.photovoltaic.enums.PowerStationStatus;
+import com.hdl.photovoltaic.enums.ProjectOperation;
import com.hdl.photovoltaic.enums.ShowErrorMode;
import com.hdl.photovoltaic.enums.SortType;
import com.hdl.photovoltaic.enums.SortValue;
@@ -54,9 +56,11 @@
import com.hdl.photovoltaic.utils.GPSManagerUtils;
import com.hdl.photovoltaic.utils.PermissionUtils;
import com.hdl.photovoltaic.utils.URLEncodingUtils;
+import com.hdl.photovoltaic.widget.AddPowerStationDialog;
import com.hdl.photovoltaic.widget.ConfirmationCancelDialog;
import com.hdl.photovoltaic.widget.DefaultFilteringDialog;
import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog;
+import com.hdl.photovoltaic.widget.adapter.PowerStationDialogAdapter;
import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout;
import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder;
import com.hdl.sdk.link.common.exception.HDLLinkException;
@@ -219,15 +223,40 @@
viewBinding.addIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+ HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+// AddPowerStationDialog addPowerStationDialog = new AddPowerStationDialog(_mActivity);
+// addPowerStationDialog.show();
+// addPowerStationDialog.setCanceledOnTouchOutside(true);
+// addPowerStationDialog.setItemOnclickListener(new PowerStationDialogAdapter.OnclickListener() {
+// @Override
+// public void onClick(int position, String str) {
+// addPowerStationDialog.dismiss();
+//
+//// UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+//// if (_mActivity.getString(R.string.simple_debugging).equals(str)) {
+//// HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION_SIMPLE, null);
+//// } else {
+//// HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+//// }
+//// requestPermissions(new OnCallBeak() {
+//// @Override
+//// public void onClickCallBeak() {
+////// UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+////// HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+//// }
+//// });
+// }
+// });
- requestPermissions(new OnCallBeak() {
- @Override
- public void onClickCallBeak() {
-// UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
-// HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
- }
- });
-
+ }
+ });
+ viewBinding.addIv.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+ HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION_SIMPLE, null);
+ return true;
}
});
//鐢电珯鎼滅储
@@ -301,49 +330,69 @@
@Override
public void onDelClick(int position, HouseIdBean houseIdBean) {
-
+ final boolean isWaitDelivered = houseIdBean.getDebugStatus().equals(DebugStatus.WAIT_DELIVERED);
DelayedConfirmationCancelDialog delayedConfirmationCancelDialog = new DelayedConfirmationCancelDialog(_mActivity);
delayedConfirmationCancelDialog.show();
delayedConfirmationCancelDialog.isHideTitle(true);
String homeName = "\"" + houseIdBean.getHomeName() + "\"";
- delayedConfirmationCancelDialog.setContent(getString(R.string.delete_power_station).replace("%s", homeName));
-
- delayedConfirmationCancelDialog.startCountdown(4);
+ if (isWaitDelivered) {
+ //"鏄惁灏嗙數绔欑殑璋冭瘯鐘舵�佸洖閫�鍒拌皟璇曚腑"
+ delayedConfirmationCancelDialog.setContent(getString(R.string.debug_status_rollback).replace("%s", homeName));
+ } else {
+ delayedConfirmationCancelDialog.startCountdown(4);
+ delayedConfirmationCancelDialog.setContent(getString(R.string.delete_power_station).replace("%s", homeName));
+ }
delayedConfirmationCancelDialog.setYesOnclickListener(new DelayedConfirmationCancelDialog.onYesOnclickListener() {
@Override
public void Confirm() {
delayedConfirmationCancelDialog.dismiss();
- showLoading(getString(R.string.deleting_please_wait));
- HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(houseIdBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() {
- @Override
- public void onSuccess(List<GatewayBean> list) {
- //鍙戣捣鍒犻櫎鐢电珯鎸囦护
- deleteResidence(houseIdBean.getHomeId(), list);
+ if (isWaitDelivered) {
+ showLoading();
+ String flowRecordContent = UserConfigManage.getInstance().isZh() ? "鏂扮壒閿愯兘app鍙戣捣鐢电珯閲嶆柊璋冭瘯" : "The Xenterra app initiates the re-commissioning of the power station";
+ HdlResidenceLogic.getInstance().setUpdateProjectDebugStatus(houseIdBean.getHomeId(), houseIdBean.getCommunityId(), flowRecordContent, ProjectOperation.DEBUGGING_AGAIN.toString(), new CloudCallBeak<Boolean>() {
+ @Override
+ public void onSuccess(Boolean list) {
+ hideLoading();
+ if (houseInfoAdapter != null) {
+ houseIdBean.setDebugStatus(DebugStatus.Debugging);
+ HdlResidenceLogic.getInstance().updateHouseIdBean(houseIdBean);
+ initData();
+ if (houseInfoAdapter != null) {
+ houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃
+ }
+ //鏇存柊UI
+// houseInfoAdapter.notifyItemChanged(position);
+ }
+ }
+ @Override
+ public void onFailure(HDLException e) {
+ hideLoading();
+ }
+ });
+ } else {
+ showLoading(getString(R.string.deleting_please_wait));
+ if (houseIdBean.getDebugType().equals(DebugType.NORMAL)) {
+ //銆愬父瑙勬柟寮忋�戝彂璧峰垹闄ょ數绔欐寚浠�
+ HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(houseIdBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() {
+ @Override
+ public void onSuccess(List<GatewayBean> list) {
+ //鍙戣捣鍒犻櫎鐢电珯鎸囦护
+ deleteResidence(position, houseIdBean, list);
+
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ //鍙戣捣鍒犻櫎鐢电珯鎸囦护
+ deleteResidence(position, houseIdBean, null);
+ }
+ });
+ } else {
+ //銆愮畝鏄撴柟寮忋�戝彂璧峰垹闄ょ數绔欐寚浠�
+ deleteResidence(position, houseIdBean, null);
}
-
- @Override
- public void onFailure(HDLException e) {
- //鍙戣捣鍒犻櫎鐢电珯鎸囦护
- deleteResidence(houseIdBean.getHomeId(), null);
- }
- });
-
-// //鍒犻櫎浣忓畢
-// HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() {
-// @Override
-// public void onSuccess(Boolean obj) {
-// HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId());
-// initData();//鍒濆鍖栫紦瀛樻暟鎹�
-// houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃
-// nullDataUpdateUi(houseListBeanIDList);//妫�娴嬫暟鎹槸鍚︿负绌�
-// }
-//
-// @Override
-// public void onFailure(HDLException e) {
-// HdlThreadLogic.toast(_mActivity, e);
-// }
-// });
+ }
}
});
delayedConfirmationCancelDialog.setNoOnclickListener(new DelayedConfirmationCancelDialog.onNoOnclickListener() {
@@ -407,6 +456,12 @@
deviceInfoAdapter.setOnclickListener(new DeviceInfoAdapter.OnClickListener() {
@Override
public void onClick(int position, CloudInverterDeviceBean deviceBean) {
+ deviceBean.setActivate(true);//榛樿婵�娲�
+// //鏉ㄦ稕璇磋繖涓垪琛ㄤ笉杩斿洖鏈縺娲荤殑璁惧锛屾墍浠ュ幓鎺夊垽鏂�
+// if (!deviceBean.isActivate()) {
+// HdlThreadLogic.toast(_mActivity, getString(R.string.device_not_activated));
+// return;
+// }
// GatewayBean gatewayBean = new GatewayBean();
// gatewayBean.setCategorySecondName(deviceBean.getCategorySecondName());
// gatewayBean.setDevice_mac(deviceBean.getOsn());
@@ -522,7 +577,6 @@
viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter);
houseInfoAdapter.setList(this.houseListBeanIDList, powerStationStatusValue);
-
//璁惧鏍囩
deviceInfoAdapter = new DeviceInfoAdapter(_mActivity);
viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity));
@@ -839,7 +893,7 @@
if (isRefreshing) {
showLoading(getString(R.string.device_loading));
}
- //鑾峰彇浣忓畢(鐢电珯)ID鍒楄〃
+ //鑾峰彇璁惧鍒楄〃
HdlDeviceLogic.getInstance().getPowerStationDeviceList("", pageNo, pageSize, new CloudCallBeak<PageNumberObject<CloudInverterDeviceBean>>() {
@Override
public void onSuccess(PageNumberObject<CloudInverterDeviceBean> pageNumberObject) {
@@ -959,20 +1013,26 @@
/**
* 鍒犻櫎鐢电珯
*
- * @param homeId 鐢电珯id
- * @param list 閫嗗彉鍣ㄥ垪琛�
+ * @param position 浣嶇疆
+ * @param houseIdBean 鐢电珯id瀵硅薄
+ * @param list 閫嗗彉鍣ㄥ垪琛�
*/
- private void deleteResidence(String homeId, List<GatewayBean> list) {
+ private void deleteResidence(int position, HouseIdBean houseIdBean, List<GatewayBean> list) {
//鍒犻櫎浣忓畢
- HdlResidenceLogic.getInstance().delResidence(homeId, new CloudCallBeak<Boolean>() {
+ HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() {
@Override
public void onSuccess(Boolean obj) {
hideLoading();
- initializeInverter(list); //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;锛堟敞鎰�:鍓嶉潰宸插厛瑙g粦浜戠閫嗗彉鍣紝mqtt閫氶亾宸叉柇寮�锛屽垵濮嬪寲鍙兘鏄湰鍦板彂閫�(鍏堟悳绱㈠眬鍩熺綉閫嗗彉鍣ㄥ垪琛紝寤虹珛鏈湴閫氳閫氶亾)锛�
- HdlResidenceLogic.getInstance().delHouseId(homeId);//鍒犻櫎鐢电珯缂撳瓨
+ if (houseIdBean.getDebugType().equals(DebugType.NORMAL)) {
+ initializeInverter(list); //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;锛堟敞鎰�:鍓嶉潰宸插厛瑙g粦浜戠閫嗗彉鍣紝mqtt閫氶亾宸叉柇寮�锛屽垵濮嬪寲鍙兘鏄湰鍦板彂閫�(鍏堟悳绱㈠眬鍩熺綉閫嗗彉鍣ㄥ垪琛紝寤虹珛鏈湴閫氳閫氶亾)锛�
+ }
+ HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId());//鍒犻櫎鐢电珯缂撳瓨
initData();//鍒濆鍖栫紦瀛樻暟鎹�
- houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃
+ if (houseInfoAdapter != null) {
+ houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃
+// houseInfoAdapter.notifyItemRemoved(position);//鍙埛鏂板綋鍓嶇殑浣嶇疆
+ }
getStatusOverview();//鍒犻櫎鎴愬姛鍚庡埛鏂扮數绔欑姸鎬佹瑙�
nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌�
}
@@ -1019,12 +1079,24 @@
if (ary.length > 0) {
this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
} else {
-
- UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
- HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
- locationUpdates();
-
-
+ AddPowerStationDialog addPowerStationDialog = new AddPowerStationDialog(_mActivity);
+ addPowerStationDialog.show();
+ addPowerStationDialog.setCanceledOnTouchOutside(true);
+ addPowerStationDialog.setItemOnclickListener(new PowerStationDialogAdapter.OnclickListener() {
+ @Override
+ public void onClick(int position, String str) {
+ addPowerStationDialog.dismiss();
+// UserConfigManage.getInstance().setCurrentAppLanguage(itemData.getLanguage());
+// UserConfigManage.getInstance().Save();
+ UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+ if (_mActivity.getString(R.string.simple_debugging).equals(str)) {
+ HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION_SIMPLE, null);
+ } else {
+ HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+ }
+ locationUpdates();
+ }
+ });
}
}
--
Gitblit v1.8.0