Browse Source

连续检测周报接口 新增判断分母(除数)为0的情况

王苗苗 3 days ago
parent
commit
066d2406a4

+ 9 - 6
ruoyi-system/src/main/java/com/ruoyi/business/service/impl/BusinessServiceImpl.java

@@ -226,17 +226,20 @@ public class BusinessServiceImpl implements IBusinessService {
             List<ZAssayResult> zAssayResults = this.zAssayResultMapper.selectZAssayResultList(ZAssayResult.builder().assayType("3").assayItem(value.get(0).getAssayItem()).deviceNo(assayReq.getDeviceNo()).timeBegin(assayReq.getTimeBegin()).timeEnd(assayReq.getTimeEnd()).build());
             int zkCounts = zAssayResults.size();
             int passedCounts = this.getPassedCounts(zAssayResults);
-            double val = (double) passedCounts / zkCounts;//质控样合格率
             //组装对应的数据
             ContinuousAssayResultResNew continuousAssayResultResNew = new ContinuousAssayResultResNew();
             continuousAssayResultResNew.setAssayName(key);
             continuousAssayResultResNew.setAssayCounts(value.size());
             continuousAssayResultResNew.setZkCounts(zkCounts);
-            continuousAssayResultResNew.setPassedRates(NumberUtils.getDoublePercentAndNLength(INT_4, val, INT_2));
-            double ratesDeviation = val - continuousAssayResultResNew.getBxDouble();
-            double ratesDeviationNumber = ratesDeviation > 0 ? 0D : Math.abs(ratesDeviation);
-            continuousAssayResultResNew.setRatesDeviation(NumberUtils.getDoublePercentAndNLength(INT_4, ratesDeviationNumber, INT_2));
-            continuousAssayResultResNew.setRatesDeviationNumber(ratesDeviationNumber);
+            //2025年04月01日11:11:51 需要考虑分母(除数)为0的情况
+            if(zkCounts > 0){
+                double val = (double) passedCounts / zkCounts;//质控样合格率
+                continuousAssayResultResNew.setPassedRates(NumberUtils.getDoublePercentAndNLength(INT_4, val, INT_2));
+                double ratesDeviation = val - continuousAssayResultResNew.getBxDouble();
+                double ratesDeviationNumber = ratesDeviation > 0 ? 0D : Math.abs(ratesDeviation);
+                continuousAssayResultResNew.setRatesDeviation(NumberUtils.getDoublePercentAndNLength(INT_4, ratesDeviationNumber, INT_2));
+                continuousAssayResultResNew.setRatesDeviationNumber(ratesDeviationNumber);
+            }
             resultMap.put(key, continuousAssayResultResNew);
         });