From 6f50adc782d11a238746bedf0d33ff987f5d00e5 Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Fri, 17 Mar 2023 13:50:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=A8=A1=E7=BB=84=E6=A1=A3?= =?UTF-8?q?=E4=BD=8D=E7=BB=9F=E8=AE=A1=E5=88=86=E5=B8=83=E5=9B=BE=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WoPackagingBoxSubstrateController.java | 12 ++++++++---- .../java/com/cnbm/packing/dto/PowerReportDTO.java | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ym-packing/src/main/java/com/cnbm/packing/controller/WoPackagingBoxSubstrateController.java b/ym-packing/src/main/java/com/cnbm/packing/controller/WoPackagingBoxSubstrateController.java index 6cbe471..e49214f 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/controller/WoPackagingBoxSubstrateController.java +++ b/ym-packing/src/main/java/com/cnbm/packing/controller/WoPackagingBoxSubstrateController.java @@ -184,10 +184,14 @@ public class WoPackagingBoxSubstrateController { totalSubNum+= subNum; } for(PowerReportDTO power : powerReportList){ - Float prop = (Float.valueOf(power.getSubNum())/Float.valueOf(totalSubNum))*100; - DecimalFormat df = new DecimalFormat("0.00"); - String propS = df.format(prop)+"%"; - power.setProportion(propS); + if(power.getSubNum()==0 ||totalSubNum ==0 ){ + power.setProportion("0%"); + }else { + Float prop = (Float.valueOf(power.getSubNum())/Float.valueOf(totalSubNum))*100; + DecimalFormat df = new DecimalFormat("0.00"); + String propS = df.format(prop)+"%"; + power.setProportion(propS); + } } diff --git a/ym-packing/src/main/java/com/cnbm/packing/dto/PowerReportDTO.java b/ym-packing/src/main/java/com/cnbm/packing/dto/PowerReportDTO.java index f87a080..1420a47 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/dto/PowerReportDTO.java +++ b/ym-packing/src/main/java/com/cnbm/packing/dto/PowerReportDTO.java @@ -40,4 +40,9 @@ public class PowerReportDTO implements Serializable { this.sumPMPP = sumPMPP; this.proportion = proportion; } + public PowerReportDTO(Integer subNum, String subLevel, Float sumPMPP) { + this.subNum = subNum; + this.subLevel = subLevel; + this.sumPMPP = sumPMPP; + } } \ No newline at end of file