| app/src/main/java/com/hdl/photovoltaic/config/UserConfigManage.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| app/src/main/res/drawable-xhdpi/bms.png | 补丁 | 查看 | 原始文档 | blame | 历史 | |
| app/src/main/res/layout/item_plant_bms_details.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
app/src/main/java/com/hdl/photovoltaic/config/UserConfigManage.java
@@ -6,6 +6,7 @@ import com.google.gson.Gson; import com.hdl.photovoltaic.HDLApp; import com.hdl.photovoltaic.enums.Languages; import com.hdl.photovoltaic.enums.PowerStationType; import com.hdl.photovoltaic.other.HdlFileLogic; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlResidenceLogic; @@ -72,7 +73,7 @@ //当前会话ID private String conversationId; //电站类型(INV = 逆变器电站;BMS = BMS电站) private String powerStationType = "INV "; private String powerStationType = PowerStationType.INV; public String getAgentUrl() { return agentUrl == null ? "" : agentUrl; app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java
@@ -20,6 +20,7 @@ import com.hdl.photovoltaic.enums.DebugStatus; import com.hdl.photovoltaic.enums.DeliverStatus; import com.hdl.photovoltaic.enums.PowerStationStatus; import com.hdl.photovoltaic.enums.PowerStationType; import com.hdl.photovoltaic.enums.UnitType; import com.hdl.photovoltaic.other.HdlCommonLogic; import com.hdl.photovoltaic.ui.bean.HouseIdBean; @@ -31,7 +32,9 @@ public class HouseInfoAdapter extends RecyclerView.Adapter<HouseInfoAdapter.MyViewHolder> { // 定义不同的 viewType 常量 public static final int VIEW_TYPE_NORMAL = 1; // 普通电站详情 public static final int VIEW_TYPE_BMS = 2; // BMS数据卡片 private List<HouseIdBean> mList; private final Context mContext; private OnclickListener noOnclickListener;//点击了的监听器 @@ -48,18 +51,97 @@ this.mContext = context; } @Override public int getItemViewType(int position) { HouseIdBean item = this.mList.get(position); if (item.getPowerStationType().equals(PowerStationType.BMS)) { return VIEW_TYPE_BMS; } else { return VIEW_TYPE_NORMAL; } } @NonNull @Override public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View contentItem = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_plant_details, parent, false); View contentItem; // 根据 viewType 加载不同的布局文件 if (viewType == VIEW_TYPE_BMS) { contentItem = LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_plant_bms_details, parent, false); } else { contentItem = LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_plant_details, parent, false); } return new MyViewHolder(contentItem); } @Override public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { HouseIdBean houseIdBean = this.mList.get(position); int viewType = getItemViewType(position); if (viewType == VIEW_TYPE_BMS) { holder.setText(R.id.bms_home_name_tv, houseIdBean.getHomeName().trim()); //电池能量(容量*电池数量) holder.setText(R.id.bms_battery_storage_value_tv, HdlCommonLogic.convertDoubleValue(houseIdBean.getBatteryCapacity(), UnitType.kWh)); holder.setText(R.id.bms_battery_storage_kw_unit, HdlCommonLogic.convertKWHUnit(houseIdBean.getBatteryCapacity())); holder.setText(R.id.bms_home_location_tv, houseIdBean.getHomeAddress()); holder.getView(R.id.bms_item_parent_rl).setTag(position); setHomeStateTextViewStyle(holder.getView(R.id.bms_home_state_tv), houseIdBean.getPowerStationStatus()); setHomeDebugStateTextViewStyle(holder.getView(R.id.bms_home_debug_state_tv), holder.getView(R.id.bms_home_debug_state_iv), houseIdBean.getDebugStatus()); GlideUtils.getRoundedCornersImage(mContext, houseIdBean.getPowerStationImage(), holder.getView(R.id.bms_home_image_iv), 6); holder.getView(R.id.bms_item_parent_rl).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { if (noOnclickListener != null) { noOnclickListener.onClick((int) holder.getView(R.id.bms_item_parent_rl).getTag(), houseIdBean); } } catch (Exception ignored) { } } }); //移动电站位置 holder.getView(R.id.bms_move_ll).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { if (noOnclickListener != null) { noOnclickListener.onMoveClick((int) holder.getView(R.id.bms_item_parent_rl).getTag(), houseIdBean); } } catch (Exception ignored) { } } }); holder.getView(R.id.bms_del_ll).setVisibility(View.GONE); if (houseIdBean.getDebugStatus().equals(DebugStatus.Debugging)) { //未交付完要显示删除按钮 holder.getView(R.id.bms_del_ll).setVisibility(View.VISIBLE); holder.setImageResource(R.id.bms_del_home_iv, R.drawable.del_home); } if (houseIdBean.getDebugStatus().equals(DebugStatus.WAIT_DELIVERED)) { //更改成回滚图标 holder.getView(R.id.bms_del_ll).setVisibility(View.VISIBLE); holder.setImageResource(R.id.bms_del_home_iv, R.drawable.roll_back); } //删除电站 holder.getView(R.id.bms_del_ll).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { if (noOnclickListener != null) { noOnclickListener.onDelClick((int) holder.item_parent_rl.getTag(), houseIdBean); } } catch (Exception ignored) { } } }); if (UserConfigManage.getInstance().isTourist_mode()) { holder.getView(R.id.bms_del_ll).setVisibility(View.GONE); } } else { holder.homeNameTv.setText(houseIdBean.getHomeName().trim()); //组串容量(创建电站时输入的组串容量) holder.pv_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getInstalledCapacity(), UnitType.kWp)); @@ -132,7 +214,7 @@ if (UserConfigManage.getInstance().isTourist_mode()) { holder.home_del_ll.setVisibility(View.GONE); } } } @@ -316,6 +398,54 @@ home_location_tv = itemView.findViewById(R.id.home_location_tv); item_parent_swipeLayout = itemView.findViewById(R.id.item_parent_swipeLayout); } /** * 设置文本 */ public void setText(int viewId, String text) { TextView textView = getView(viewId); if (textView != null) { textView.setText(text); } } /** * 设置图片资源 */ public void setImageResource(int viewId, int resId) { ImageView imageView = getView(viewId); if (imageView != null) { imageView.setImageResource(resId); } } /** * 设置文本颜色 */ public void setTextColor(int viewId, int color) { TextView textView = getView(viewId); if (textView != null) { textView.setTextColor(color); } } /** * 设置点击事件 */ public void setOnClickListener(int viewId, View.OnClickListener listener) { View view = getView(viewId); if (view != null) { view.setOnClickListener(listener); } } /** * 获取 View */ @SuppressWarnings("unchecked") public <T extends View> T getView(int viewId) { return (T) itemView.findViewById(viewId); } } public interface OnclickListener { app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -391,7 +391,7 @@ // if (houseIdBean.getDebugType().equals(DebugType.NORMAL)) { //【常规方式】发起删除电站指令(搜索网关是考到网关没有连接到云端,使用本地发送初始化指令) // 硬件那边叫新固件也发初始化 2025年10月14日10:55:18 HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(houseIdBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() { HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(houseIdBean.getHomeId(), houseIdBean.getPowerStationType(), new CloudCallBeak<List<GatewayBean>>() { @Override public void onSuccess(List<GatewayBean> list) { //发起删除电站指令 @@ -503,7 +503,7 @@ List<CloudInverterDeviceBean> newList = new ArrayList<>(); newList.add(deviceBean); //目的是为了获取拿到网关ID,mqtt通讯秘钥等信息,拿到后缓存到本地逆变器列表里面,发送数据数据时自动去缓存列表里面去查找; HdlDeviceLogic.getInstance().setDeviceRemoteInfo(newList, deviceBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() { HdlDeviceLogic.getInstance().setDeviceRemoteInfo(newList, deviceBean.getHomeId(), PowerStationType.All, new CloudCallBeak<List<GatewayBean>>() { @Override public void onSuccess(List<GatewayBean> obj) { @@ -738,8 +738,8 @@ } String homeId = eventBus.getData().toString(); //进去住宅详情uni读取逆变器列表成功后通知 for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).size(); i++) { String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).get(i).getGatewayId(); for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId,PowerStationType.All).size(); i++) { String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId,PowerStationType.All).get(i).getGatewayId(); //字符串是自己按规则拼接的,里面注册主题时会解析字符串,只拿getGatewayId()值; String topic = "/user/" + gatewayId + "/#"; //进去住宅详情开始订阅主题 app/src/main/res/drawable-xhdpi/bms.png
app/src/main/res/layout/item_plant_bms_details.xml
New file @@ -0,0 +1,267 @@ <?xml version="1.0" encoding="utf-8"?> <com.hdl.photovoltaic.widget.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/bms_item_parent_swipeLayout" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/bms_swipe_layout_il" android:layout_width="66dp" android:layout_height="124.5dp" android:layout_marginTop="@dimen/dp_0" android:orientation="vertical"> <View android:layout_width="match_parent" android:layout_height="@dimen/dp_10" /> <LinearLayout android:id="@+id/bms_move_ll" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:orientation="vertical"> <ImageView android:id="@+id/bms_move_home_iv" android:layout_width="@dimen/dp_36" android:layout_height="@dimen/dp_36" android:src="@drawable/move_house" /> </LinearLayout> <LinearLayout android:id="@+id/bms_del_ll" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:orientation="vertical"> <ImageView android:id="@+id/bms_del_home_iv" android:layout_width="@dimen/dp_36" android:layout_height="@dimen/dp_36" android:src="@drawable/del_home" /> </LinearLayout> </LinearLayout> <RelativeLayout android:id="@+id/bms_item_parent_rl" android:layout_width="match_parent" android:layout_height="134.5dp"> <RelativeLayout android:id="@+id/bms_device_details_info_rl" android:layout_width="match_parent" android:layout_height="124.5dp" android:layout_marginStart="@dimen/dp_16" android:layout_marginTop="@dimen/dp_10" android:layout_marginEnd="@dimen/dp_16" android:background="@drawable/bj_ff1c1c1e"> <!--电站图片--> <ImageView android:id="@+id/bms_home_image_iv" android:layout_width="44dp" android:layout_height="42dp" android:layout_marginStart="@dimen/dp_16" android:layout_marginTop="@dimen/dp_13" android:scaleType="centerCrop" /> <!--电站名称以及地址--> <LinearLayout android:id="@+id/bms_home_name_ll" android:layout_width="match_parent" android:layout_height="@dimen/dp_20" android:layout_marginStart="@dimen/dp_5" android:layout_marginTop="13.5dp" android:layout_toStartOf="@+id/bms_home_debug_state_ll" android:layout_toEndOf="@+id/bms_home_image_iv" android:gravity="center_vertical" android:orientation="horizontal"> <LinearLayout android:layout_width="@dimen/dp_19" android:layout_height="@dimen/dp_19" android:gravity="center"> <TextView android:id="@+id/bms_home_state_tv" android:layout_width="7dp" android:layout_height="7dp" android:background="@drawable/device_state_ff38c494" /> </LinearLayout> <TextView android:id="@+id/bms_home_name_tv" android:layout_width="match_parent" android:layout_height="match_parent" android:ellipsize="end" android:gravity="center_vertical|start" android:paddingStart="0dp" android:paddingEnd="@dimen/dp_5" android:singleLine="true" android:text="@string/power_station" android:textColor="@color/text_FFACACAC" android:textSize="@dimen/text_14" /> </LinearLayout> <!--电站状态--> <LinearLayout android:id="@+id/bms_home_debug_state_ll" android:layout_width="wrap_content" android:layout_height="@dimen/dp_18" android:layout_alignParentTop="true" android:layout_alignParentEnd="true" android:layout_marginTop="@dimen/dp_15" android:orientation="horizontal"> <ImageView android:id="@+id/bms_home_debug_state_iv" android:layout_width="@dimen/dp_18" android:layout_height="@dimen/dp_18" /> <TextView android:id="@+id/bms_home_debug_state_tv" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingStart="0dp" android:paddingEnd="@dimen/dp_16" android:textColor="@color/text_FFACACAC" android:textSize="@dimen/text_12" /> </LinearLayout> <!--电站地址--> <LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/dp_19" android:layout_below="@+id/bms_home_name_ll" android:layout_alignStart="@+id/bms_home_name_ll"> <ImageView android:layout_width="@dimen/dp_19" android:layout_height="@dimen/dp_19" android:src="@drawable/location" /> <TextView android:id="@+id/bms_home_location_tv" android:layout_width="match_parent" android:layout_height="match_parent" android:ellipsize="end" android:gravity="center_vertical|start" android:paddingStart="0dp" android:paddingEnd="@dimen/dp_5" android:singleLine="true" android:text="@string/power_station" android:textColor="@color/text_FF5B5B5B" android:textSize="@dimen/text_12" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/bms_home_image_iv" android:layout_alignStart="@+id/bms_home_image_iv" android:layout_marginTop="@dimen/dp_16" android:layout_marginEnd="@dimen/dp_16" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="39dp" android:orientation="horizontal"> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:layout_width="37.5dp" android:layout_height="37.5dp" android:layout_marginEnd="@dimen/dp_12" android:src="@drawable/battery_storage" /> <LinearLayout android:id="@+id/battery_storage_ll" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/dp_20"> <TextView android:id="@+id/bms_battery_storage_value_tv" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical|start" android:text="0" android:textColor="@color/text_FFACACAC" android:textSize="@dimen/text_14" /> <TextView android:id="@+id/bms_battery_storage_kw_unit" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginStart="3dp" android:gravity="bottom" android:text="kWh" android:textColor="@color/text_FF5B5B5B" android:textSize="@dimen/text_10" /> </LinearLayout> <TextView android:id="@+id/bms_attery_storage_type_tv" android:layout_width="match_parent" android:layout_height="@dimen/dp_17" android:layout_marginTop="3dp" android:gravity="center_vertical|start" android:text="@string/battery_capacity_indicator" android:textColor="@color/text_FF5B5B5B" android:textSize="@dimen/text_12" /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:layout_width="37.5dp" android:layout_height="37.5dp" android:layout_marginEnd="@dimen/dp_12" android:src="@drawable/bms" /> <TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical|start" android:text="BMS" android:textColor="@color/text_FFACACAC" android:textSize="@dimen/text_14" /> </LinearLayout> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="@dimen/dp_16" /> </LinearLayout> </RelativeLayout> </RelativeLayout> </com.hdl.photovoltaic.widget.SwipeLayout>