|
@@ -5,6 +5,7 @@ import com.ruoyi.business.mapper.*;
|
|
|
import com.ruoyi.business.req.AssayReq;
|
|
|
import com.ruoyi.business.req.DeviceReq;
|
|
|
import com.ruoyi.business.res.AssayDetailRes;
|
|
|
+import com.ruoyi.business.res.AssayQualityDetailRes;
|
|
|
import com.ruoyi.business.res.DeviceRes;
|
|
|
import com.ruoyi.business.res.HomeCountsRes;
|
|
|
import com.ruoyi.business.service.IBusinessService;
|
|
@@ -108,6 +109,155 @@ public class BusinessServiceImpl implements IBusinessService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<AssayQualityDetailRes> assayCountListByDates(AssayReq assayReq) {
|
|
|
+ List<ZAssayResult> zAssayResults = this.zAssayResultMapper.selectZAssayResultList(ZAssayResult.builder().timeBegin(assayReq.getTimeBegin()).timeEnd(assayReq.getTimeEnd()).assayType("3").build());
|
|
|
+ if(CollectionUtils.isEmpty(zAssayResults)){
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ //有数据 处理统计信息
|
|
|
+ return this.getCountInfoByAssayResults(zAssayResults);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<AssayQualityDetailRes> getCountInfoByAssayResults(List<ZAssayResult> zAssayResults) {
|
|
|
+ List<AssayQualityDetailRes> result = new ArrayList<>();
|
|
|
+ if(!CollectionUtils.isEmpty(zAssayResults)){
|
|
|
+ //先按照水厂进行分组
|
|
|
+ Map<String, List<ZAssayResult>> map = zAssayResults.stream().collect(Collectors.groupingBy(ZAssayResult::getDeviceNo));
|
|
|
+ map.forEach((deviceNo, value) -> {
|
|
|
+ AssayQualityDetailRes assayQualityDetailRes = new AssayQualityDetailRes();
|
|
|
+ //获取水厂的名称
|
|
|
+ //先查询化验室,再获取水厂信息
|
|
|
+ List<BizDevice> bizDevices = this.bizDeviceMapper.selectBizDeviceList(BizDevice.builder().deviceNo(deviceNo).build());
|
|
|
+ if(!CollectionUtils.isEmpty(bizDevices)){
|
|
|
+ //水厂
|
|
|
+ List<BizWaterWork> bizWaterWorks = this.bizWaterWorkMapper.selectBizWaterWorkList(BizWaterWork.builder().worksId(bizDevices.get(0).getDeviceWorks()).build());
|
|
|
+ if(!CollectionUtils.isEmpty(bizWaterWorks)){
|
|
|
+ assayQualityDetailRes.setWorksName(bizWaterWorks.get(0).getWorksName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理统计信息
|
|
|
+ //高COD
|
|
|
+ List<ZAssayResult> highCodList = value.stream().filter(zAssayResult -> "1".equals(zAssayResult.getAssayItem())).collect(Collectors.toList());
|
|
|
+ Double highCodDeviationRate = null;//后续有个总的合格率,这里用null默认,后面计算分别做判断
|
|
|
+ if(!CollectionUtils.isEmpty(highCodList)){
|
|
|
+ int highCodArrayCounts = highCodList.size();
|
|
|
+ assayQualityDetailRes.setHighCodArrayCounts(highCodArrayCounts);
|
|
|
+ int highCodPassedCounts = this.getPassedCounts(highCodList);
|
|
|
+ assayQualityDetailRes.setHighCodPassedCounts(highCodPassedCounts);
|
|
|
+ highCodDeviationRate = (double) highCodPassedCounts / (double) highCodArrayCounts;
|
|
|
+ assayQualityDetailRes.setHighCodDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, highCodDeviationRate, INT_2));
|
|
|
+ }
|
|
|
+ //低COD
|
|
|
+ List<ZAssayResult> lowCodList = value.stream().filter(zAssayResult -> "2".equals(zAssayResult.getAssayItem())).collect(Collectors.toList());
|
|
|
+ Double lowCodDeviationRate = null;//后续有个总的合格率,这里用null默认,后面计算分别做判断
|
|
|
+ if(!CollectionUtils.isEmpty(lowCodList)){
|
|
|
+ int lowCodArrayCounts = lowCodList.size();
|
|
|
+ assayQualityDetailRes.setLowCodArrayCounts(lowCodArrayCounts);
|
|
|
+ int lowCodPassedCounts = this.getPassedCounts(lowCodList);
|
|
|
+ assayQualityDetailRes.setLowCodPassedCounts(lowCodPassedCounts);
|
|
|
+ lowCodDeviationRate = (double) lowCodPassedCounts / (double) lowCodArrayCounts;
|
|
|
+ assayQualityDetailRes.setLowCodDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, lowCodDeviationRate, INT_2));
|
|
|
+ }
|
|
|
+ //氨氮
|
|
|
+ List<ZAssayResult> anDanList = value.stream().filter(zAssayResult -> "3".equals(zAssayResult.getAssayItem())).collect(Collectors.toList());
|
|
|
+ Double anDanDeviationRate = null;//后续有个总的合格率,这里用null默认,后面计算分别做判断
|
|
|
+ if(!CollectionUtils.isEmpty(anDanList)){
|
|
|
+ int anDanArrayCounts = anDanList.size();
|
|
|
+ assayQualityDetailRes.setAnDanArrayCounts(anDanArrayCounts);
|
|
|
+ int anDanPassedCounts = this.getPassedCounts(anDanList);
|
|
|
+ assayQualityDetailRes.setAnDanPassedCounts(anDanPassedCounts);
|
|
|
+ anDanDeviationRate = (double) anDanPassedCounts / (double) anDanArrayCounts;
|
|
|
+ assayQualityDetailRes.setAnDanDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, anDanDeviationRate, INT_2));
|
|
|
+ }
|
|
|
+ //总氮
|
|
|
+ List<ZAssayResult> tnList = value.stream().filter(zAssayResult -> "4".equals(zAssayResult.getAssayItem())).collect(Collectors.toList());
|
|
|
+ Double tnDeviationRate = null;//后续有个总的合格率,这里用null默认,后面计算分别做判断
|
|
|
+ if(!CollectionUtils.isEmpty(tnList)){
|
|
|
+ int tnArrayCounts = tnList.size();
|
|
|
+ assayQualityDetailRes.setTnArrayCounts(tnArrayCounts);
|
|
|
+ int tnPassedCounts = this.getPassedCounts(tnList);
|
|
|
+ assayQualityDetailRes.setTnPassedCounts(tnPassedCounts);
|
|
|
+ tnDeviationRate = (double) tnPassedCounts / (double) tnArrayCounts;
|
|
|
+ assayQualityDetailRes.setTnDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, tnDeviationRate, INT_2));
|
|
|
+ }
|
|
|
+ //总磷
|
|
|
+ List<ZAssayResult> tpList = value.stream().filter(zAssayResult -> "5".equals(zAssayResult.getAssayItem())).collect(Collectors.toList());
|
|
|
+ Double tpDeviationRate = null;//后续有个总的合格率,这里用null默认,后面计算分别做判断
|
|
|
+ if(!CollectionUtils.isEmpty(tpList)){
|
|
|
+ int tpArrayCounts = tpList.size();
|
|
|
+ assayQualityDetailRes.setTpArrayCounts(tpArrayCounts);
|
|
|
+ int tpPassedCounts = this.getPassedCounts(tpList);
|
|
|
+ assayQualityDetailRes.setTpPassedCounts(tpPassedCounts);
|
|
|
+ tpDeviationRate = (double) tpPassedCounts / (double) tpArrayCounts;
|
|
|
+ assayQualityDetailRes.setTpDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, tpDeviationRate, INT_2));
|
|
|
+ }
|
|
|
+ //正磷酸盐
|
|
|
+ List<ZAssayResult> zlsyList = value.stream().filter(zAssayResult -> "6".equals(zAssayResult.getAssayItem())).collect(Collectors.toList());
|
|
|
+ Double zlsyDeviationRate = null;//后续有个总的合格率,这里用null默认,后面计算分别做判断
|
|
|
+ if(!CollectionUtils.isEmpty(zlsyList)){
|
|
|
+ int zlsyArrayCounts = zlsyList.size();
|
|
|
+ assayQualityDetailRes.setZlsyArrayCounts(zlsyArrayCounts);
|
|
|
+ int zlsyPassedCounts = this.getPassedCounts(zlsyList);
|
|
|
+ assayQualityDetailRes.setZlsyPassedCounts(zlsyPassedCounts);
|
|
|
+ zlsyDeviationRate = (double) zlsyPassedCounts / (double) zlsyArrayCounts;
|
|
|
+ assayQualityDetailRes.setZlsyDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, zlsyDeviationRate, INT_2));
|
|
|
+ }
|
|
|
+ //亚硝酸盐氮
|
|
|
+ List<ZAssayResult> yxsydList = value.stream().filter(zAssayResult -> "7".equals(zAssayResult.getAssayItem())).collect(Collectors.toList());
|
|
|
+ Double yxsydDeviationRate = null;//后续有个总的合格率,这里用null默认,后面计算分别做判断
|
|
|
+ if(!CollectionUtils.isEmpty(yxsydList)){
|
|
|
+ int yxsydArrayCounts = yxsydList.size();
|
|
|
+ assayQualityDetailRes.setYxsyArrayCounts(yxsydArrayCounts);
|
|
|
+ int ysxydPassedCounts = this.getPassedCounts(yxsydList);
|
|
|
+ assayQualityDetailRes.setYxsyPassedCounts(ysxydPassedCounts);
|
|
|
+ yxsydDeviationRate = (double) ysxydPassedCounts / (double) yxsydArrayCounts;
|
|
|
+ assayQualityDetailRes.setYxsyDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, yxsydDeviationRate, INT_2));
|
|
|
+ }
|
|
|
+ //硝酸盐氮
|
|
|
+ List<ZAssayResult> xsydList = value.stream().filter(zAssayResult -> "8".equals(zAssayResult.getAssayItem())).collect(Collectors.toList());
|
|
|
+ Double xsydDeviationRate = null;//后续有个总的合格率,这里用null默认,后面计算分别做判断
|
|
|
+ if(!CollectionUtils.isEmpty(xsydList)){
|
|
|
+ int xsydArrayCounts = xsydList.size();
|
|
|
+ assayQualityDetailRes.setXsydArrayCounts(xsydArrayCounts);
|
|
|
+ int xsydPassedCounts = this.getPassedCounts(xsydList);
|
|
|
+ assayQualityDetailRes.setXsydPassedCounts(xsydPassedCounts);
|
|
|
+ xsydDeviationRate = (double) xsydPassedCounts / (double) xsydArrayCounts;
|
|
|
+ assayQualityDetailRes.setXsydDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, xsydDeviationRate, INT_2));
|
|
|
+ }
|
|
|
+ //处理总的合格率
|
|
|
+ Double totalDeviationRate = 0D;
|
|
|
+ if(!Objects.isNull(highCodDeviationRate)){
|
|
|
+ totalDeviationRate += highCodDeviationRate;
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(lowCodDeviationRate)){
|
|
|
+ totalDeviationRate += lowCodDeviationRate;
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(anDanDeviationRate)){
|
|
|
+ totalDeviationRate += anDanDeviationRate;
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(tnDeviationRate)){
|
|
|
+ totalDeviationRate += tnDeviationRate;
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(tpDeviationRate)){
|
|
|
+ totalDeviationRate += tpDeviationRate;
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(zlsyDeviationRate)){
|
|
|
+ totalDeviationRate += zlsyDeviationRate;
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(yxsydDeviationRate)){
|
|
|
+ totalDeviationRate += yxsydDeviationRate;
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(xsydDeviationRate)){
|
|
|
+ totalDeviationRate += xsydDeviationRate;
|
|
|
+ }
|
|
|
+ assayQualityDetailRes.setTotalDeviationRate(NumberUtils.getDoublePercentAndNLength(INT_4, totalDeviationRate / 8, INT_2));
|
|
|
+ result.add(assayQualityDetailRes);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private void addAssayExtra(String assayNo, AssayDetailRes assayDetailRes) {
|
|
|
//分别处理化验设备的名称、水厂的名字字段(没有通过SQL关联查询,数据量大会很慢。。。)
|
|
|
//化验室
|