app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/ui/adapter/DeviceInfoAdapter.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/layout/item_plant_details.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java
@@ -62,14 +62,15 @@ /** * @param value 值 * @param value 值 * @param unitType 需要转的单位(kW,kWh) * @return 字符串值返回 */ public static String convertDoubleValue(String value) { public static String convertDoubleValue(String value, String unitType) { if (TextUtils.isEmpty(value)) { return UnitType.noValue; } return divideByOneThousandAndFormat(value).toString(); return divideByOneThousandAndFormat(value,unitType).toString(); } /** @@ -122,10 +123,10 @@ * @param value 值 * @return BigDecimal */ public static BigDecimal divideByOneThousandAndFormat(String value) { public static BigDecimal divideByOneThousandAndFormat(String value, String unitType) { try { double doubleValue = Double.parseDouble(value); int mDoubleValue = doubleValue(value); long mDoubleValue = doubleValue(value,unitType); if (mDoubleValue == 0) { return getBigDecimal(value); } else { @@ -143,17 +144,29 @@ * * @param value 值 */ public static int doubleValue(String value) { public static long doubleValue(String value, String unitType) { try { double doubleValue = Double.parseDouble(value); if (doubleValue > 1000 && doubleValue < 1000 * 1000) { return 1000; } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { return 1000 * 1000; } else if (doubleValue > 1000 * 1000 * 1000) { return 1000 * 1000 * 1000; if (unitType.equals(UnitType.kW)) { if (doubleValue > 1000 && doubleValue < 1000 * 1000) { return 1000 ; } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { return 1000 * 1000 ; } else if (doubleValue >= 1000 * 1000 * 1000) { return 1000L * 1000 * 1000 ; } else { return 1000; } } else { return 0; if (doubleValue >= 1000 && doubleValue < 1000 * 1000) { return 1000; } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { return 1000 * 1000; } else if (doubleValue >= 1000 * 1000 * 1000) { return 1000 * 1000 * 1000; } else { return 0; } } } catch (Exception e) { return 0; @@ -161,29 +174,7 @@ } /** * 转换单位 * * @param value 值 * @param unitType 表示是单位(功率,电量) */ public static String convertUnit(String value, String unitType) { try { double doubleValue = Double.parseDouble(value); if (doubleValue > 1000 && doubleValue < 1000 * 1000) { return unitType.equals(UnitType.kW) ? UnitType.mW : UnitType.mWh; } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { return unitType.equals(UnitType.kW) ? UnitType.gW : UnitType.gWh; } else if (doubleValue > 1000 * 1000 * 1000) { return unitType.equals(UnitType.kW) ? UnitType.tW : UnitType.tWh; } else { return unitType.equals(UnitType.kW) ? UnitType.kW : UnitType.kWh; } } catch (Exception e) { return unitType.equals(UnitType.kW) ? UnitType.kW : UnitType.kWh; } } /** * 转换电量(kWh)单位 @@ -193,11 +184,11 @@ public static String convertKWHUnit(String value) { try { double doubleValue = Double.parseDouble(value); if (doubleValue > 1000 && doubleValue < 1000 * 1000) { if (doubleValue >= 1000 && doubleValue < 1000 * 1000) { return UnitType.mWh; } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { return UnitType.gWh; } else if (doubleValue > 1000 * 1000 * 1000) { } else if (doubleValue >= 1000 * 1000 * 1000) { return UnitType.tWh; } else { return UnitType.kWh; @@ -217,10 +208,12 @@ try { double doubleValue = Double.parseDouble(value); if (doubleValue > 1000 && doubleValue < 1000 * 1000) { return UnitType.kW; } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { return UnitType.mW; } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { } else if (doubleValue >= 1000 * 1000 * 1000&&doubleValue < 1000 * 1000 * 1000*1000L) { return UnitType.gW; } else if (doubleValue > 1000 * 1000 * 1000) { } else if (doubleValue >= 1000 * 1000 * 1000*1000L) { return UnitType.tW; } else { return UnitType.kW; @@ -239,11 +232,11 @@ public static String convertKWPUnit(String value) { try { double doubleValue = Double.parseDouble(value); if (doubleValue > 1000 && doubleValue < 1000 * 1000) { if (doubleValue >= 1000 && doubleValue < 1000 * 1000) { return UnitType.MWp; } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { return UnitType.GWp; } else if (doubleValue > 1000 * 1000 * 1000) { } else if (doubleValue >= 1000 * 1000 * 1000) { return UnitType.TWp; } else { return UnitType.kWp; app/src/main/java/com/hdl/photovoltaic/ui/adapter/DeviceInfoAdapter.java
@@ -44,13 +44,14 @@ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { CloudInverterDeviceBean deviceBean = this.mList.get(position); holder.homeNameTv.setText(deviceBean.getHomeNameAndDeviceName()); holder.device_details_sn_tv.setText(deviceBean.getOsn()); holder.device_label_run_state_value_tv.setText(deviceBean.getSystemStatusDesc()); holder.device_label_power_value_tv.setText(HdlCommonLogic.convertDoubleValue(deviceBean.getOutputActivePower(), 1000)); holder.device_label_power_unit.setText(HdlCommonLogic.convertUnit(deviceBean.getOutputActivePower(), UnitType.kW)); holder.device_label_day_value_tv.setText(HdlCommonLogic.convertDoubleValue(deviceBean.getTotalElectricityPvToday())); holder.device_label_day_unit.setText(HdlCommonLogic.convertUnit(deviceBean.getOutputActivePower(), UnitType.kWh)); holder.device_label_power_value_tv.setText(HdlCommonLogic.convertDoubleValue(deviceBean.getOutputActivePower(), UnitType.kW)); holder.device_label_power_unit.setText(HdlCommonLogic.convertKWUnit(deviceBean.getOutputActivePower())); holder.device_label_day_value_tv.setText(HdlCommonLogic.convertDoubleValue(deviceBean.getTotalElectricityPvToday(), UnitType.kWh)); holder.device_label_day_unit.setText(HdlCommonLogic.convertKWHUnit(deviceBean.getTotalElectricityPvToday())); holder.device_label_location_tv.setText(deviceBean.getHomeAddress()); setTextViewStyle(holder.device_label_state_tv, deviceBean.getDeviceStatus()); holder.itemView.setTag(position); app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java
@@ -61,17 +61,18 @@ HouseIdBean houseIdBean = this.mList.get(position); holder.homeNameTv.setText(houseIdBean.getHomeName().trim()); //装机容量 String capacity = HdlCommonLogic.getBigDecimal(houseIdBean.getInstalledCapacity()).toString(); holder.capacityTv.setText(capacity); holder.capacityTv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getInstalledCapacity(), UnitType.kWp)); holder.capacity_kwp_unit.setText(HdlCommonLogic.convertKWPUnit(houseIdBean.getInstalledCapacity())); //发电功率 holder.power_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getPower())); holder.power_kw_unit.setText(HdlCommonLogic.convertUnit(houseIdBean.getPower(), UnitType.kW)); holder.power_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getPower(), UnitType.kW)); holder.power_kw_unit.setText(HdlCommonLogic.convertKWUnit(houseIdBean.getPower())); //当日发电量 holder.day_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getTodayElectricity())); holder.day_kwh_unit.setText(HdlCommonLogic.convertUnit(houseIdBean.getTodayElectricity(), UnitType.kWh)); holder.day_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getTodayElectricity(), UnitType.kWh)); holder.day_kwh_unit.setText(HdlCommonLogic.convertKWHUnit(houseIdBean.getTodayElectricity())); //电池容量 holder.month_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getBatteryCapacity())); holder.month_kwh_unit.setText(HdlCommonLogic.convertUnit(houseIdBean.getBatteryCapacity(), UnitType.kWh)); holder.month_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getBatteryCapacity(), UnitType.kWh)); holder.month_kwh_unit.setText(HdlCommonLogic.convertKWHUnit(houseIdBean.getBatteryCapacity())); holder.plant_details_location_tv.setText(houseIdBean.getHomeAddress()); holder.item_parent_rl.setTag(position); @@ -219,6 +220,7 @@ public ImageView homeIconIv;//住宅图片 public TextView homeNameTv;//住宅名称 public TextView capacityTv;//装机容量 public TextView capacity_kwp_unit;//装机容量单位 public TextView power_value_tv;//发电功率 public TextView power_kw_unit;//发电功率单位 public TextView day_value_tv;//当日发电量 @@ -237,6 +239,7 @@ homeIconIv = itemView.findViewById(R.id.device_details_image_iv); homeNameTv = itemView.findViewById(R.id.device_details_name_tv); capacityTv = itemView.findViewById(R.id.device_details_value_tv); capacity_kwp_unit = itemView.findViewById(R.id.capacity_kwp_unit); power_value_tv = itemView.findViewById(R.id.power_value_tv); power_kw_unit = itemView.findViewById(R.id.power_kw_unit); day_value_tv = itemView.findViewById(R.id.day_value_tv); app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java
@@ -535,11 +535,13 @@ if (dataOverBean == null) { return; } String capacityValue = HdlCommonLogic.divideByOneThousandAndFormat(dataOverBean.getInstalledCapacity()).toString(); String capacityValue = HdlCommonLogic.convertDoubleValue(dataOverBean.getInstalledCapacity(), UnitType.kWp); viewBinding.infoRl1Text1Tv.setText(capacityValue); viewBinding.kwpUnit.setText(HdlCommonLogic.convertKWPUnit(dataOverBean.getInstalledCapacity())); viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getPower())); viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getPower(), UnitType.kW)); viewBinding.kwUnit.setText(HdlCommonLogic.convertKWUnit(dataOverBean.getPower())); // String str = dataOverBean.getPowerRatio() + "%"; // int startIndex = str.lastIndexOf("%"); // int endIndex = str.lastIndexOf("%") + 1; @@ -567,14 +569,14 @@ } catch (Exception ignored) { } viewBinding.day.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getTodayElectricity())); viewBinding.dayUnit.setText(HdlCommonLogic.convertUnit(dataOverBean.getTodayElectricity(), UnitType.kWh)); viewBinding.month.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getMonthElectricity())); viewBinding.monthUnit.setText(HdlCommonLogic.convertUnit(dataOverBean.getMonthElectricity(), UnitType.kWh)); viewBinding.year.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getYearElectricity())); viewBinding.yearUnit.setText(HdlCommonLogic.convertUnit(dataOverBean.getYearElectricity(), UnitType.kWh)); viewBinding.Total.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getTotalElectricity())); viewBinding.TotalUnit.setText(HdlCommonLogic.convertUnit(dataOverBean.getTotalElectricity(), UnitType.kWh)); viewBinding.day.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getTodayElectricity(), UnitType.kWh)); viewBinding.dayUnit.setText(HdlCommonLogic.convertKWHUnit(dataOverBean.getTodayElectricity())); viewBinding.month.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getMonthElectricity(), UnitType.kWh)); viewBinding.monthUnit.setText(HdlCommonLogic.convertKWHUnit(dataOverBean.getMonthElectricity())); viewBinding.year.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getYearElectricity(), UnitType.kWh)); viewBinding.yearUnit.setText(HdlCommonLogic.convertKWHUnit(dataOverBean.getYearElectricity())); viewBinding.Total.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getTotalElectricity(), UnitType.kWh)); viewBinding.TotalUnit.setText(HdlCommonLogic.convertKWHUnit(dataOverBean.getTotalElectricity())); } }); app/src/main/res/layout/item_plant_details.xml
@@ -86,7 +86,7 @@ android:textSize="@dimen/text_14" /> <TextView android:id="@+id/kwp_unit" android:id="@+id/capacity_kwp_unit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/device_details_value_tv"