|
@@ -105,20 +105,97 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
}
|
|
|
|
|
|
private void addAssayExtra(String assayNo, AssayDetailRes assayDetailRes) {
|
|
|
- //分别处理化验设备的名称、水厂的名字字段
|
|
|
+ //分别处理化验设备的名称、水厂的名字字段(没有通过SQL关联查询,数据量大会很慢。。。)
|
|
|
+ //化验室
|
|
|
List<BizDevice> bizDevices = this.bizDeviceMapper.selectBizDeviceList(BizDevice.builder().deviceNo(assayDetailRes.getDeviceNo()).build());
|
|
|
if(!CollectionUtils.isEmpty(bizDevices)){
|
|
|
assayDetailRes.setDeviceName(bizDevices.get(0).getDeviceName());
|
|
|
assayDetailRes.setDeviceWorks(bizDevices.get(0).getDeviceWorks());
|
|
|
}
|
|
|
+ //水厂
|
|
|
List<BizWaterWork> bizWaterWorks = this.bizWaterWorkMapper.selectBizWaterWorkList(BizWaterWork.builder().worksId(assayDetailRes.getDeviceWorks()).build());
|
|
|
if(!CollectionUtils.isEmpty(bizWaterWorks)){
|
|
|
assayDetailRes.setWorksName(bizWaterWorks.get(0).getWorksName());
|
|
|
}
|
|
|
//通过化验编号查询所有的化验明细,然后根据类型计算对应的
|
|
|
List<ZAssayResult> zAssayResults = this.zAssayResultMapper.selectZAssayResultList(ZAssayResult.builder().assayNo(assayNo).assayType("3").build());
|
|
|
+ calculateRate(assayDetailRes, zAssayResults);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void calculateRate(AssayDetailRes assayDetailRes, List<ZAssayResult> zAssayResults) {
|
|
|
if(!CollectionUtils.isEmpty(zAssayResults)){
|
|
|
- //todo 处理八种类型化验的计算
|
|
|
+ //高COD
|
|
|
+ Optional<ZAssayResult> highCodOptional = zAssayResults.stream().filter(zAssayResult -> "1".equals(zAssayResult.getAssayItem())).findFirst();
|
|
|
+ if(highCodOptional.isPresent()){
|
|
|
+ ZAssayResult zAssayResult = highCodOptional.get();
|
|
|
+ Double resultConcentration = zAssayResult.getResultConcentration();
|
|
|
+ assayDetailRes.setHighCodResultConcentration(resultConcentration);
|
|
|
+ Double highCodStandardVal = assayDetailRes.getHighCodStandardVal();
|
|
|
+ assayDetailRes.setHighCodDeviationRate((resultConcentration - highCodStandardVal) / highCodStandardVal);
|
|
|
+ }
|
|
|
+ //低COD
|
|
|
+ Optional<ZAssayResult> lowCodOptional = zAssayResults.stream().filter(zAssayResult -> "2".equals(zAssayResult.getAssayItem())).findFirst();
|
|
|
+ if(lowCodOptional.isPresent()){
|
|
|
+ ZAssayResult zAssayResult = lowCodOptional.get();
|
|
|
+ Double resultConcentration = zAssayResult.getResultConcentration();
|
|
|
+ assayDetailRes.setLowCodResultConcentration(resultConcentration);
|
|
|
+ Double lowCodStandardVal = assayDetailRes.getLowCodStandardVal();
|
|
|
+ assayDetailRes.setHighCodDeviationRate((resultConcentration - lowCodStandardVal) / lowCodStandardVal);
|
|
|
+ }
|
|
|
+ //氨氮
|
|
|
+ Optional<ZAssayResult> andanOptional = zAssayResults.stream().filter(zAssayResult -> "3".equals(zAssayResult.getAssayItem())).findFirst();
|
|
|
+ if(andanOptional.isPresent()){
|
|
|
+ ZAssayResult zAssayResult = andanOptional.get();
|
|
|
+ Double resultConcentration = zAssayResult.getResultConcentration();
|
|
|
+ assayDetailRes.setAnDanResultConcentration(resultConcentration);
|
|
|
+ Double anDanStandardVal = assayDetailRes.getAnDanStandardVal();
|
|
|
+ assayDetailRes.setHighCodDeviationRate((resultConcentration - anDanStandardVal) / anDanStandardVal);
|
|
|
+ }
|
|
|
+ //总氮
|
|
|
+ Optional<ZAssayResult> tnOptional = zAssayResults.stream().filter(zAssayResult -> "4".equals(zAssayResult.getAssayItem())).findFirst();
|
|
|
+ if(tnOptional.isPresent()){
|
|
|
+ ZAssayResult zAssayResult = tnOptional.get();
|
|
|
+ Double resultConcentration = zAssayResult.getResultConcentration();
|
|
|
+ assayDetailRes.setTnResultConcentration(resultConcentration);
|
|
|
+ Double tnStandardVal = assayDetailRes.getTnStandardVal();
|
|
|
+ assayDetailRes.setHighCodDeviationRate((resultConcentration - tnStandardVal) / tnStandardVal);
|
|
|
+ }
|
|
|
+ //总磷
|
|
|
+ Optional<ZAssayResult> tpOptional = zAssayResults.stream().filter(zAssayResult -> "5".equals(zAssayResult.getAssayItem())).findFirst();
|
|
|
+ if(tpOptional.isPresent()){
|
|
|
+ ZAssayResult zAssayResult = tpOptional.get();
|
|
|
+ Double resultConcentration = zAssayResult.getResultConcentration();
|
|
|
+ assayDetailRes.setTpResultConcentration(resultConcentration);
|
|
|
+ Double tpStandardVal = assayDetailRes.getTpStandardVal();
|
|
|
+ assayDetailRes.setHighCodDeviationRate((resultConcentration - tpStandardVal) / tpStandardVal);
|
|
|
+ }
|
|
|
+ //正磷酸盐
|
|
|
+ Optional<ZAssayResult> zlsyOptional = zAssayResults.stream().filter(zAssayResult -> "6".equals(zAssayResult.getAssayItem())).findFirst();
|
|
|
+ if(zlsyOptional.isPresent()){
|
|
|
+ ZAssayResult zAssayResult = zlsyOptional.get();
|
|
|
+ Double resultConcentration = zAssayResult.getResultConcentration();
|
|
|
+ assayDetailRes.setZlsyResultConcentration(resultConcentration);
|
|
|
+ Double zlsyStandardVal = assayDetailRes.getZlsyStandardVal();
|
|
|
+ assayDetailRes.setHighCodDeviationRate((resultConcentration - zlsyStandardVal) / zlsyStandardVal);
|
|
|
+ }
|
|
|
+ //亚硝酸盐氮
|
|
|
+ Optional<ZAssayResult> yxsydOptional = zAssayResults.stream().filter(zAssayResult -> "7".equals(zAssayResult.getAssayItem())).findFirst();
|
|
|
+ if(yxsydOptional.isPresent()){
|
|
|
+ ZAssayResult zAssayResult = yxsydOptional.get();
|
|
|
+ Double resultConcentration = zAssayResult.getResultConcentration();
|
|
|
+ assayDetailRes.setYxsyResultConcentration(resultConcentration);
|
|
|
+ Double yxsyStandardVal = assayDetailRes.getYxsyStandardVal();
|
|
|
+ assayDetailRes.setHighCodDeviationRate((resultConcentration - yxsyStandardVal) / yxsyStandardVal);
|
|
|
+ }
|
|
|
+ //硝酸盐氮
|
|
|
+ Optional<ZAssayResult> xsydOptional = zAssayResults.stream().filter(zAssayResult -> "8".equals(zAssayResult.getAssayItem())).findFirst();
|
|
|
+ if(xsydOptional.isPresent()){
|
|
|
+ ZAssayResult zAssayResult = xsydOptional.get();
|
|
|
+ Double resultConcentration = zAssayResult.getResultConcentration();
|
|
|
+ assayDetailRes.setXsydResultConcentration(resultConcentration);
|
|
|
+ Double xsydStandardVal = assayDetailRes.getXsydStandardVal();
|
|
|
+ assayDetailRes.setHighCodDeviationRate((resultConcentration - xsydStandardVal) / xsydStandardVal);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|