app/src/main/java/com/hdl/photovoltaic/enums/DeliverStatus.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsListEdit.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/layout/item_plant_details.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
app/src/main/java/com/hdl/photovoltaic/enums/DeliverStatus.java
New file @@ -0,0 +1,15 @@ package com.hdl.photovoltaic.enums; /** * 电站的调试状态 */ public @interface DeliverStatus { /** * 已交付 */ String PAID = "PAID"; /** * 未交付 */ String UNDELIVERED = "UNDELIVERED";//未交付 } app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -86,6 +86,33 @@ return mHouseIdList; } /** * 设置列表数据 * * @param list 新列表 * @param isClear 是否清除旧数据,true表示清除,否则不清除; */ public void setHouseIdList(List<HouseIdBean> list, boolean isClear) { if (list == null || list.size() == 0) { return; } if (isClear) { this.clearHouseList(); } if (this.mHouseIdList.size() == 0) { this.mHouseIdList.addAll(list); return; } for (int i = 0; i < list.size(); i++) { this.setSingleHouseId(list.get(i)); } } /** * 设置列表数据 * * @param list 新列表数据 */ public void setHouseIdList(List<HouseIdBean> list) { if (list == null || list.size() == 0) { return; @@ -348,14 +375,7 @@ * @param pageNo 页码 * @param pageSize 页数(一页多少数据) */ public void getResidenceIdList( String key, String keyValue, String installedCapacityMin, String installedCapacityMax, String debugStatus, String powerStationStatus, long pageNo, long pageSize, CloudCallBeak<HouseBeanClass> cloudCallBeak) { public void getResidenceIdList(String key, String keyValue, String installedCapacityMin, String installedCapacityMax, String debugStatus, String powerStationStatus, long pageNo, long pageSize, CloudCallBeak<HouseBeanClass> cloudCallBeak) { String requestUrl = HttpApi.POST_PowerStation_List; JsonObject json = new JsonObject(); @@ -914,8 +934,7 @@ * * @param homeId 住宅id */ public void getResidenceInverterAllInfo(String homeId, CloudCallBeak<Bitmap> cloudCallBeak) { public void getResidenceInverterAllInfo(String homeId, CloudCallBeak<Bitmap> cloudCallBeak) { String requestUrl = HttpApi.POST_inverter_allInfo; JsonObject json = new JsonObject(); json.addProperty("homeId", homeId); @@ -945,8 +964,7 @@ * @param debugPerm 授权状态(true可以继续调试) * @param cloudCallBeak - */ public void homeUpdateDebugPerm(String homeId, boolean debugPerm, CloudCallBeak< Boolean> cloudCallBeak) { public void homeUpdateDebugPerm(String homeId, boolean debugPerm, CloudCallBeak<Boolean> cloudCallBeak) { String requestUrl = HttpApi.C_POST_HOME_UPDATEDEBUGPERM; JsonObject json = new JsonObject(); json.addProperty("homeId", homeId); @@ -1043,8 +1061,7 @@ * @param account C端账号 * @param cloudCallBeak - */ public void getDeliverToAccount(String homeId, String account, CloudCallBeak<Boolean> cloudCallBeak) { public void getDeliverToAccount(String homeId, String account, CloudCallBeak<Boolean> cloudCallBeak) { String requestUrl = HttpApi.POST_deliverToAccount; JsonObject json = new JsonObject(); json.addProperty("homeId", homeId); app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
@@ -236,7 +236,7 @@ } UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(0); List<HouseIdBean> HouseIdList = HdlResidenceLogic.getInstance().getHouseIdList(); if (HouseIdList.size() == 0) { if (HouseIdList.isEmpty()) { if (TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) { String path = HDLUniMP.UNI_EVENT_OPEN_HOME_Null_C; HdlUniLogic.getInstance().openUniMP(path, null); app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java
@@ -15,6 +15,8 @@ import androidx.recyclerview.widget.RecyclerView; import com.hdl.photovoltaic.R; import com.hdl.photovoltaic.enums.DebugStatus; import com.hdl.photovoltaic.enums.DeliverStatus; import com.hdl.photovoltaic.enums.PowerStationStatus; import com.hdl.photovoltaic.enums.UnitType; import com.hdl.photovoltaic.other.HdlCommonLogic; @@ -73,7 +75,7 @@ holder.home_location_tv.setText(houseIdBean.getHomeAddress()); holder.item_parent_rl.setTag(position); setTextViewStyle(holder.stateTv, houseIdBean.getPowerStationStatus()); setHomeStateTextViewStyle(holder.home_state_tv, houseIdBean.getPowerStationStatus()); GlideUtils.getRoundedCornersImage(mContext, houseIdBean.getPowerStationImage(), holder.homeIconIv, 6); // HdlLogLogic.print("---电站名称:" + houseIdBean.getHomeName() + "---图片url:" + houseIdBean.getPowerStationImage(), false); holder.item_parent_rl.setOnClickListener(new View.OnClickListener() { @@ -88,7 +90,7 @@ } }); //移动电站位置 holder.move_home_ll.setOnClickListener(new View.OnClickListener() { holder.home_move_ll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { @@ -99,13 +101,13 @@ } } }); holder.del_home_ll.setVisibility(View.GONE); if (houseIdBean.getDeliverStatus().equals("UNDELIVERED")) { holder.home_del_ll.setVisibility(View.GONE); if (houseIdBean.getDeliverStatus().equals(DeliverStatus.UNDELIVERED)) { //未交付完要显示删除按钮 holder.del_home_ll.setVisibility(View.VISIBLE); holder.home_del_ll.setVisibility(View.VISIBLE); } //删除电站 holder.del_home_ll.setOnClickListener(new View.OnClickListener() { holder.home_del_ll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { @@ -150,7 +152,7 @@ } /** * 改变组件样式 * 设置【电站调试状态】组件样式 * * @param textView 显示组件 * 如果设备从来没上报过数据数据 状态:连接中 @@ -159,7 +161,67 @@ * 设备离线 状态:离线 * @param state_value 电站状态(1:正常(运行),2:离线,3:连接中,4:故障,5:离线有故障) */ private void setTextViewStyle(TextView textView, int state_value) { private void setHomeDebugStateTextViewStyle(TextView textView, int state_value) { String text = mContext.getString(R.string.my_power_station_operation); Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ff38c494); if (mPowerStationStatus.equals(DebugStatus.All)) { switch (state_value) { case 1: { text = mContext.getString(R.string.my_power_station_operation); } break; case 2: { text = mContext.getString(R.string.my_power_station_off_line); drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ffb9b9b9); } break; case 3: { text = mContext.getString(R.string.my_power_station_connecting); drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_satte_ffb300); } break; case 4: case 5: { text = mContext.getString(R.string.my_power_station_malfunction); drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_fff55252); } //5:离线有故障Offline_fault break; // case 5: { // text = mContext.getString(R.string.Offline_fault); // drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343); // } // break; } } else if (mPowerStationStatus.equals(PowerStationStatus.malfunction)) { text = mContext.getString(R.string.my_power_station_malfunction); drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_fff55252); } else if (mPowerStationStatus.equals(PowerStationStatus.off)) { text = mContext.getString(R.string.my_power_station_off_line); drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ffb9b9b9); } else if (mPowerStationStatus.equals(PowerStationStatus.connecting)) { text = mContext.getString(R.string.my_power_station_connecting); drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_satte_ffb300); } // textView.setText(text); textView.setBackground(drawable); } /** * 设置【电站状态】组件样式 * * @param textView 显示组件 * 如果设备从来没上报过数据数据 状态:连接中 * 设备在线 但是当前处于故障 状态:故障 * 设备在线(有上报过数据,没有故障) 状态:在线 * 设备离线 状态:离线 * @param state_value 电站状态(1:正常(运行),2:离线,3:连接中,4:故障,5:离线有故障) */ private void setHomeStateTextViewStyle(TextView textView, int state_value) { String text = mContext.getString(R.string.my_power_station_operation); Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ff38c494); @@ -225,10 +287,10 @@ public TextView output_kw_unit;//额定功率单位 public TextView battery_storage_value_tv;//电池能量 public TextView battery_storage_kw_unit;//电池能量单位 public TextView stateTv;//电站状态(连接中,运行,离线,故障); public TextView home_state_tv;//电站状态(连接中,运行,离线,故障); public RelativeLayout item_parent_rl;//条目父容器 public LinearLayout move_home_ll;//移动电站位置 public LinearLayout del_home_ll;//删除电站 public LinearLayout home_move_ll;//移动电站位置 public LinearLayout home_del_ll;//删除电站 public TextView home_location_tv;//电站地址 public SwipeLayout item_parent_swipeLayout;//父容器 @@ -244,10 +306,10 @@ output_kw_unit = itemView.findViewById(R.id.output_kw_unit); battery_storage_value_tv = itemView.findViewById(R.id.battery_storage_value_tv); battery_storage_kw_unit = itemView.findViewById(R.id.battery_storage_kw_unit); stateTv = itemView.findViewById(R.id.device_state_tv); home_state_tv = itemView.findViewById(R.id.home_state_tv); item_parent_rl = itemView.findViewById(R.id.item_parent_rl); move_home_ll = itemView.findViewById(R.id.move_ll); del_home_ll = itemView.findViewById(R.id.del_ll); home_move_ll = itemView.findViewById(R.id.move_ll); home_del_ll = itemView.findViewById(R.id.del_ll); home_location_tv = itemView.findViewById(R.id.home_location_tv); item_parent_swipeLayout = itemView.findViewById(R.id.item_parent_swipeLayout); } app/src/main/java/com/hdl/photovoltaic/ui/newC/PowerStationsListEdit.java
@@ -5,6 +5,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import androidx.recyclerview.widget.LinearLayoutManager; @@ -12,6 +13,7 @@ import com.google.gson.JsonObject; import com.hdl.linkpm.sdk.core.exception.HDLException; import com.hdl.linkpm.sdk.user.HDLLinkPMUser; import com.hdl.photovoltaic.R; import com.hdl.photovoltaic.base.CustomBaseActivity; import com.hdl.photovoltaic.config.ConstantManage; @@ -21,6 +23,7 @@ import com.hdl.photovoltaic.internet.HttpClient; import com.hdl.photovoltaic.listener.CloudCallBeak; import com.hdl.photovoltaic.other.HdlCommonLogic; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlResidenceLogic; import com.hdl.photovoltaic.other.HdlThreadLogic; import com.hdl.photovoltaic.other.HdlUniLogic; @@ -38,6 +41,7 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** @@ -67,6 +71,8 @@ initView(); //初始化界面监听器 initEvent(); //后台读取住宅列表 downReadData(false); } private void initData() { @@ -99,7 +105,6 @@ viewBinding.fragmentHouseSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { HdlResidenceLogic.getInstance().clearHouseList(); downReadData(true); } }); @@ -177,14 +182,20 @@ //关闭下拉刷新的圈圈 viewBinding.fragmentHouseSrl.setRefreshing(false); } if (list != null && list.size() > 0) { //更新缓存 HdlResidenceLogic.getInstance().setHouseIdList(list); if (houseListAdapter != null) { initData(); setSelectState(); //更新UI houseListAdapter.setList(houseListBeanIDList); if (list != null && !list.isEmpty()) { if (!comparableList(houseListBeanIDList, list)) { //更新缓存 HdlResidenceLogic.getInstance().setHouseIdList(list, true); if (houseListAdapter != null) { //重新获取列表数据 initData(); refreshDetails(); //更新电站选中状态 setSelectState(); //更新列表数据 houseListAdapter.setList(houseListBeanIDList); } } } @@ -333,4 +344,68 @@ } } /** * 比较住宅列表数据是否都一样 * * @param oldList 旧列表 * @param newList 新列表 * @return 相同返回true,否则返回false */ boolean comparableList(List<HouseIdBean> oldList, List<HouseIdBean> newList) { if (oldList == null || newList == null) return false; if (oldList.size() != newList.size()) return false; List<String> oidStrList = new ArrayList<>(); for (int i = 0; i < oldList.size(); i++) { oidStrList.add(oldList.get(i).getHomeId()); } List<String> newStrList = new ArrayList<>(); for (int i = 0; i < newList.size(); i++) { newStrList.add(newList.get(i).getHomeId()); } Collections.sort(oidStrList); Collections.sort(newStrList); return oidStrList.equals(newStrList); } /** * 通知uni更新数据 * (在平台上删除C端当前住宅后,获取列表实收要通知uni那边更新界面卡片) */ private void refreshDetails() { try { List<HouseIdBean> localHouseIdList = HdlResidenceLogic.getInstance().getHouseIdList(); if (localHouseIdList.isEmpty()) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("homeId", ""); HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_DETAILS); uniCallBackBaseBean.setData(jsonObject); HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); } else { int select_home = -1; for (int i = 0; i < localHouseIdList.size(); i++) { if (localHouseIdList.get(i).getHomeId().equals(UserConfigManage.getInstance().getHomeId())) { select_home = i; break; } } if (select_home == -1) { //找不到默认第一个 HouseIdBean houseIdBean = localHouseIdList.get(0); HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true); JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("homeId", houseIdBean.getHomeId()); jsonObject.addProperty("homeName", houseIdBean.getHomeName()); jsonObject.addProperty("powerStationStatus", houseIdBean.getPowerStationStatus() + ""); HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_DETAILS); uniCallBackBaseBean.setData(jsonObject); HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); } } } catch (Exception e) { } } } app/src/main/res/layout/item_plant_details.xml
@@ -21,7 +21,7 @@ android:layout_marginStart="@dimen/dp_16" android:layout_marginEnd="@dimen/dp_16" android:background="@drawable/bj_ff1c1c1e"> <!--电站图片--> <ImageView android:id="@+id/home_image_iv" android:layout_width="44dp" @@ -29,14 +29,14 @@ android:layout_marginStart="@dimen/dp_16" android:layout_marginTop="@dimen/dp_13" android:scaleType="centerCrop" /> <!--电站名称以及地址--> <LinearLayout android:id="@+id/home_name_ll" android:layout_width="match_parent" android:layout_height="@dimen/dp_20" android:layout_marginStart="@dimen/dp_5" android:layout_marginTop="14.5dp" android:layout_toStartOf="@+id/home_debug_state_ll" android:layout_toEndOf="@+id/home_image_iv" android:gravity="center_vertical" android:orientation="horizontal"> @@ -47,7 +47,7 @@ android:gravity="center"> <TextView android:id="@+id/device_state_tv" android:id="@+id/home_state_tv" android:layout_width="7dp" android:layout_height="7dp" android:background="@drawable/device_state_ff38c494" /> @@ -59,13 +59,39 @@ android:layout_height="match_parent" android:ellipsize="end" android:gravity="center_vertical|start" android:paddingEnd="@dimen/dp_20" 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/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_14" android:orientation="horizontal"> <ImageView android:id="@+id/home_debug_state_iv" android:layout_width="@dimen/dp_18" android:layout_height="@dimen/dp_18" android:src="@drawable/initiai" /> <TextView android:id="@+id/home_debug_state_tv" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingStart="0dp" android:paddingEnd="@dimen/dp_16" android:text="Initial" android:textColor="@color/text_FFACACAC" android:textSize="@dimen/text_12" /> </LinearLayout> <!--电站地址--> <LinearLayout android:layout_width="match_parent" @@ -80,10 +106,12 @@ <TextView android:id="@+id/home_location_tv" android:layout_width="280dp" 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"