Эх сурвалжийг харах

1.计算化验室的总合格率逻辑调整 2.获取设备接口支持类型查询

王苗苗 5 сар өмнө
parent
commit
47a68254e2

+ 2 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/business/BusinessController.java

@@ -537,10 +537,10 @@ public class BusinessController extends BaseController {
      * 接口10:获取设备列表信息
      */
     @GetMapping("/deviceList")
-    public R<List<BizDevice>> deviceList(){
+    public R<List<BizDevice>> deviceList(@RequestParam(value = "type" ,required = false) String type){
         log.info("进入了 获取设备列表信息 接口");
         DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
-        List<BizDevice> bizWaterWorks = this.bizDeviceMapper.selectBizDeviceList(BizDevice.builder().deviceStatus("0").build());//只获取关联设备的水厂。
+        List<BizDevice> bizWaterWorks = this.bizDeviceMapper.selectBizDeviceList(BizDevice.builder().deviceStatus("0").type(type).build());//只获取关联设备的水厂。
         DynamicDataSourceContextHolder.clearDataSourceType();
         return R.ok(bizWaterWorks);
     }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/business/res/AssayQualityDetailRes.java

@@ -66,7 +66,7 @@ public class AssayQualityDetailRes {
 
     private String zlsyDeviationRate;//正磷酸质控合格率
 
-    private String totalDeviationRate;//总质控合格率(8项的平均值)
+    private String totalDeviationRate;//总质控合格率(8项的平均值)  2024年10月15日13:38:10 逻辑调整:总质控合格率是所有合格数量➗所有的检测数量; 而不是各个指标合格率的平均值
 
 
 

+ 20 - 36
ruoyi-system/src/main/java/com/ruoyi/business/service/impl/BusinessServiceImpl.java

@@ -205,6 +205,9 @@ public class BusinessServiceImpl implements IBusinessService {
                     }
                 }
                 //处理统计信息
+                //处理总的合格率
+                int totalDeviationRateCounts = 0;
+                int totalpassedDeviationRateCounts = 0;
                 //高COD
                 List<ZAssayResult> highCodList = value.stream().filter(zAssayResult -> "1".equals(zAssayResult.getAssayItem())).collect(Collectors.toList());
                 Double highCodDeviationRate = null;//后续有个总的合格率,这里用null默认,后面计算分别做判断
@@ -214,6 +217,8 @@ public class BusinessServiceImpl implements IBusinessService {
                     int highCodPassedCounts = this.getPassedCounts(highCodList);
                     assayQualityDetailRes.setHighCodPassedCounts(highCodPassedCounts);
                     highCodDeviationRate = (double) highCodPassedCounts / (double) highCodArrayCounts;
+                    totalDeviationRateCounts += highCodArrayCounts;
+                    totalpassedDeviationRateCounts += highCodPassedCounts;
                     assayQualityDetailRes.setHighCodDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, highCodDeviationRate, INT_2));
                 }
                 //低COD
@@ -225,6 +230,8 @@ public class BusinessServiceImpl implements IBusinessService {
                     int lowCodPassedCounts = this.getPassedCounts(lowCodList);
                     assayQualityDetailRes.setLowCodPassedCounts(lowCodPassedCounts);
                     lowCodDeviationRate = (double) lowCodPassedCounts / (double) lowCodArrayCounts;
+                    totalDeviationRateCounts += lowCodArrayCounts;
+                    totalpassedDeviationRateCounts += lowCodPassedCounts;
                     assayQualityDetailRes.setLowCodDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, lowCodDeviationRate, INT_2));
                 }
                 //氨氮
@@ -236,6 +243,8 @@ public class BusinessServiceImpl implements IBusinessService {
                     int anDanPassedCounts = this.getPassedCounts(anDanList);
                     assayQualityDetailRes.setAnDanPassedCounts(anDanPassedCounts);
                     anDanDeviationRate = (double) anDanPassedCounts / (double) anDanArrayCounts;
+                    totalDeviationRateCounts += anDanArrayCounts;
+                    totalpassedDeviationRateCounts += anDanPassedCounts;
                     assayQualityDetailRes.setAnDanDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, anDanDeviationRate, INT_2));
                 }
                 //总氮
@@ -247,6 +256,8 @@ public class BusinessServiceImpl implements IBusinessService {
                     int tnPassedCounts = this.getPassedCounts(tnList);
                     assayQualityDetailRes.setTnPassedCounts(tnPassedCounts);
                     tnDeviationRate = (double) tnPassedCounts / (double) tnArrayCounts;
+                    totalDeviationRateCounts += tnArrayCounts;
+                    totalpassedDeviationRateCounts += tnPassedCounts;
                     assayQualityDetailRes.setTnDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, tnDeviationRate, INT_2));
                 }
                 //总磷
@@ -258,6 +269,8 @@ public class BusinessServiceImpl implements IBusinessService {
                     int tpPassedCounts = this.getPassedCounts(tpList);
                     assayQualityDetailRes.setTpPassedCounts(tpPassedCounts);
                     tpDeviationRate = (double) tpPassedCounts / (double) tpArrayCounts;
+                    totalDeviationRateCounts += tpArrayCounts;
+                    totalpassedDeviationRateCounts += tpPassedCounts;
                     assayQualityDetailRes.setTpDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, tpDeviationRate, INT_2));
                 }
                 //正磷酸盐
@@ -269,6 +282,8 @@ public class BusinessServiceImpl implements IBusinessService {
                     int zlsyPassedCounts = this.getPassedCounts(zlsyList);
                     assayQualityDetailRes.setZlsyPassedCounts(zlsyPassedCounts);
                     zlsyDeviationRate = (double) zlsyPassedCounts / (double) zlsyArrayCounts;
+                    totalDeviationRateCounts += zlsyArrayCounts;
+                    totalpassedDeviationRateCounts += zlsyPassedCounts;
                     assayQualityDetailRes.setZlsyDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, zlsyDeviationRate, INT_2));
                 }
                 //亚硝酸盐氮
@@ -280,6 +295,8 @@ public class BusinessServiceImpl implements IBusinessService {
                     int ysxydPassedCounts = this.getPassedCounts(yxsydList);
                     assayQualityDetailRes.setYxsyPassedCounts(ysxydPassedCounts);
                     yxsydDeviationRate = (double) ysxydPassedCounts / (double) yxsydArrayCounts;
+                    totalDeviationRateCounts += yxsydArrayCounts;
+                    totalpassedDeviationRateCounts += ysxydPassedCounts;
                     assayQualityDetailRes.setYxsyDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, yxsydDeviationRate, INT_2));
                 }
                 //硝酸盐氮
@@ -291,44 +308,11 @@ public class BusinessServiceImpl implements IBusinessService {
                     int xsydPassedCounts = this.getPassedCounts(xsydList);
                     assayQualityDetailRes.setXsydPassedCounts(xsydPassedCounts);
                     xsydDeviationRate = (double) xsydPassedCounts / (double) xsydArrayCounts;
+                    totalDeviationRateCounts += xsydArrayCounts;
+                    totalpassedDeviationRateCounts += xsydPassedCounts;
                     assayQualityDetailRes.setXsydDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, xsydDeviationRate, INT_2));
                 }
-                //处理总的合格率
-                Double totalDeviationRate = 0D;
-                int index = 0;
-                if(!Objects.isNull(highCodDeviationRate)){
-                    totalDeviationRate += highCodDeviationRate;
-                    index++;
-                }
-                if(!Objects.isNull(lowCodDeviationRate)){
-                    totalDeviationRate += lowCodDeviationRate;
-                    index++;
-                }
-                if(!Objects.isNull(anDanDeviationRate)){
-                    totalDeviationRate += anDanDeviationRate;
-                    index++;
-                }
-                if(!Objects.isNull(tnDeviationRate)){
-                    totalDeviationRate += tnDeviationRate;
-                    index++;
-                }
-                if(!Objects.isNull(tpDeviationRate)){
-                    totalDeviationRate += tpDeviationRate;
-                    index++;
-                }
-                if(!Objects.isNull(zlsyDeviationRate)){
-                    totalDeviationRate += zlsyDeviationRate;
-                    index++;
-                }
-                if(!Objects.isNull(yxsydDeviationRate)){
-                    totalDeviationRate += yxsydDeviationRate;
-                    index++;
-                }
-                if(!Objects.isNull(xsydDeviationRate)){
-                    totalDeviationRate += xsydDeviationRate;
-                    index++;
-                }
-                assayQualityDetailRes.setTotalDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, totalDeviationRate / index, INT_2));
+                assayQualityDetailRes.setTotalDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, (double)totalpassedDeviationRateCounts / (double)totalDeviationRateCounts, INT_2));
                 result.add(assayQualityDetailRes);
             });
         }