监测频次合规
parent
9d3c2b4c62
commit
b873ef231f
|
@ -0,0 +1,16 @@
|
|||
package cn.cecep.talroad.data.analyse.task.enums;
|
||||
|
||||
public enum monitoringFacilitiesEnum {
|
||||
HANDIWORK("手工"),
|
||||
AUTOMATIC("自动"),
|
||||
;
|
||||
private final String name;
|
||||
|
||||
monitoringFacilitiesEnum(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package cn.cecep.talroad.data.analyse.task.execute.report.specifications.audit;
|
||||
|
||||
import cn.cecep.talroad.domain.BMainActionReports;
|
||||
import cn.cecep.talroad.domain.BMainPollDisSelfMon;
|
||||
import cn.cecep.talroad.domain.BStatTableZxbgGasEmission;
|
||||
import cn.cecep.talroad.data.analyse.task.enums.monitoringFacilitiesEnum;
|
||||
import cn.cecep.talroad.domain.*;
|
||||
import cn.cecep.talroad.domain.analysis.SRaActionReportsAuditRecord;
|
||||
import cn.cecep.talroad.domain.analysis.SRaActionReportsAuditResult;
|
||||
import cn.cecep.talroad.enums.EmlTypeEnums;
|
||||
|
@ -10,8 +9,8 @@ import cn.cecep.talroad.mapper.*;
|
|||
import cn.cecep.talroad.mapper.analysis.SRaActionReportsAuditRecordMapper;
|
||||
import cn.cecep.talroad.mapper.analysis.SRaActionReportsAuditResultMapper;
|
||||
import cn.cecep.talroad.service.ISEnvWaterMonDayService;
|
||||
import cn.cecep.talroad.util.DateUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
|
@ -19,9 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -53,16 +50,39 @@ public class MonitorFrequencyomplianceService {
|
|||
@Autowired
|
||||
private BMainPollDisSelfMonMapper pollDisSelfMonMapper;
|
||||
|
||||
@Autowired
|
||||
private BStatTableZxbgPflAirMapper bStatTableZxbgPflAirMapper;
|
||||
|
||||
|
||||
public void execute(List<String> reportIds) {
|
||||
LambdaQueryWrapper<BMainActionReports> reportQueryWrapper = new QueryWrapper<BMainActionReports>().lambda()
|
||||
.in(BMainActionReports::getId, reportIds);
|
||||
List<BMainActionReports> bMainActionReports = actionReportsMapper.selectList(reportQueryWrapper);
|
||||
List<BMainActionReports> bMainActionReports = actionReportsMapper.selectList(new QueryWrapper<BMainActionReports>().lambda().in(BMainActionReports::getId, reportIds));
|
||||
List<SRaActionReportsAuditResult> updateList = new ArrayList<>();
|
||||
Map<String, SRaActionReportsAuditResult> reportRecordMap = getReportRecordMap(reportIds);
|
||||
//执行报告循环
|
||||
for (BMainActionReports bMainActionReport : bMainActionReports) {
|
||||
|
||||
String reportsType = bMainActionReport.getReportsType();
|
||||
String factoryId = bMainActionReport.getFactoryId();
|
||||
Calendar startCalendar = Calendar.getInstance();
|
||||
Calendar endCalendar = Calendar.getInstance();
|
||||
if (EmlTypeEnums.YEAR.getCode().equals(reportsType)) {
|
||||
//去年 开始的数据 到今年的数据
|
||||
startCalendar.setTime(DateUtil.parseTime(startCalendar.get(Calendar.YEAR) - 1 + "-01-01 00:00:00"));
|
||||
endCalendar.setTime(DateUtil.parseTime(endCalendar.get(Calendar.YEAR) + "-01-01 00:00:00"));
|
||||
} else if (EmlTypeEnums.QUARTER.getCode().equals(reportsType)) {
|
||||
//获取上季度的数据 此处获取到当前季度开始的日期 手动去-3月 上季度结束日期 就是本季度开始
|
||||
startCalendar.setTime(DateUtil.getQuarterStart(new Date()));
|
||||
startCalendar.set(Calendar.MONTH, startCalendar.get(Calendar.MONTH) - 3);
|
||||
endCalendar.setTime(DateUtil.getQuarterStart(new Date()));
|
||||
} else if (EmlTypeEnums.MONTH.getCode().equals(reportsType)) {
|
||||
//上月开始 到 这月结束的数据
|
||||
startCalendar.set(Calendar.DAY_OF_MONTH, 0);
|
||||
DateUtil.setTimeZero(startCalendar);
|
||||
endCalendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
DateUtil.setTimeZero(endCalendar);
|
||||
startCalendar.set(Calendar.MONTH, startCalendar.get(Calendar.MONTH) - 1);
|
||||
}
|
||||
Date endTime = endCalendar.getTime();
|
||||
Date startTime = startCalendar.getTime();
|
||||
StringBuilder message = new StringBuilder();
|
||||
//获取执行报告对应的有组织废气污染物排放浓度监测数据统计表的数据
|
||||
LambdaQueryWrapper<BStatTableZxbgGasEmission> bStatTableZxbgGasEmissionLambdaQueryWrapper = new QueryWrapper<BStatTableZxbgGasEmission>().lambda()
|
||||
.eq(BStatTableZxbgGasEmission::getFactoryId, bMainActionReport.getFactoryId())
|
||||
|
@ -71,46 +91,90 @@ public class MonitorFrequencyomplianceService {
|
|||
.notLike(BStatTableZxbgGasEmission::getRemark, "停产");
|
||||
List<BStatTableZxbgGasEmission> bStatTableZxbgGasEmissions = bStatTableZxbgGasEmissionMapper.selectList(bStatTableZxbgGasEmissionLambdaQueryWrapper);
|
||||
//分为 手工和自动 bStatTableZxbgGasEmissions 获取 monitoringFacilities
|
||||
|
||||
if (CollectionUtil.isNotEmpty(bStatTableZxbgGasEmissions)) {
|
||||
Map<String, List<BStatTableZxbgGasEmission>> emissionMap = bStatTableZxbgGasEmissions.stream().collect(Collectors.groupingBy(BStatTableZxbgGasEmission::getMonitoringFacilities));
|
||||
//effectivelyHour 监测数量小时值
|
||||
List<BStatTableZxbgGasEmission> statTableZxbgGasEmissions = emissionMap.get("手工");
|
||||
if (CollectionUtil.isNotEmpty(statTableZxbgGasEmissions)){
|
||||
List<String> outletCode = statTableZxbgGasEmissions.stream().map(BStatTableZxbgGasEmission::getOutletCode).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<BMainPollDisSelfMon> pollQueryWrapper = new QueryWrapper<BMainPollDisSelfMon>().lambda()
|
||||
.eq(BMainPollDisSelfMon::getFactoryId, bMainActionReport.getFactoryId())
|
||||
.in(BMainPollDisSelfMon::getOutletCode, outletCode);
|
||||
List<BMainPollDisSelfMon> bMainPollDisSelfMons = pollDisSelfMonMapper.selectList(pollQueryWrapper);
|
||||
}
|
||||
emissionMap.forEach((k, v) -> {
|
||||
if (k.equals("手工")) {
|
||||
Map<String, List<BStatTableZxbgGasEmission>> emissionMap = bStatTableZxbgGasEmissions.stream()
|
||||
.collect(Collectors.groupingBy(BStatTableZxbgGasEmission::getMonitoringFacilities));
|
||||
|
||||
} else {
|
||||
emissionMap.forEach((monitoringFacilities, statTableZxbgGasEmissions) -> {
|
||||
if (CollectionUtil.isNotEmpty(statTableZxbgGasEmissions)) {
|
||||
List<String> outletCode = statTableZxbgGasEmissions.stream()
|
||||
.map(BStatTableZxbgGasEmission::getOutletCode)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (monitoringFacilitiesEnum.HANDIWORK.getName().equals(monitoringFacilities)) {
|
||||
LambdaQueryWrapper<BMainPollDisSelfMon> pollQueryWrapper = new QueryWrapper<BMainPollDisSelfMon>().lambda()
|
||||
.eq(BMainPollDisSelfMon::getFactoryId, bMainActionReport.getFactoryId())
|
||||
.in(BMainPollDisSelfMon::getOutletCode, outletCode);
|
||||
List<BMainPollDisSelfMon> bMainPollDisSelfMons = pollDisSelfMonMapper.selectList(pollQueryWrapper);
|
||||
Map<String, BMainPollDisSelfMon> bMainPollDisSelfMonMap = bMainPollDisSelfMons.stream().collect(Collectors.toMap(BMainPollDisSelfMon::getOutletCode, Function.identity()));
|
||||
for (BStatTableZxbgGasEmission statTableZxbgGasEmission : statTableZxbgGasEmissions) {
|
||||
BMainPollDisSelfMon bMainPollDisSelfMon = bMainPollDisSelfMonMap.get(statTableZxbgGasEmission.getOutletCode());
|
||||
String effectivelyHour = statTableZxbgGasEmission.getEffectivelyHour();
|
||||
int count = getCount(bMainPollDisSelfMon.getMonitoringManualFrequency(), reportsType);
|
||||
int parseInt = 0;
|
||||
try {
|
||||
parseInt = Integer.parseInt(effectivelyHour);
|
||||
} catch (Exception e) {
|
||||
message.append("排口编号" + outletCode + "污染物种类" + statTableZxbgGasEmission.getPollutantName() + "有效监测数据数量应为整数,企业填报数量为" + effectivelyHour + ",不符合规范要求。");
|
||||
}
|
||||
if (parseInt < count) {
|
||||
message.append("排口编号" + outletCode + "污染物种类" + statTableZxbgGasEmission.getPollutantName() + "为手工监测,监测频次为:" +
|
||||
bMainPollDisSelfMon.getMonitoringManualFrequency() + ",有效监测数据数量应不低于" + count + "企业填报数量为" + parseInt + ",不满足年度监测频次。");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LambdaQueryWrapper<PcOutlet> outletLambdaQueryWrapper = new QueryWrapper<PcOutlet>().lambda().in(PcOutlet::getOutletCode, outletCode);
|
||||
List<PcOutlet> pcOutlets = pcOutletMapper.selectList(outletLambdaQueryWrapper);
|
||||
List<String> pcOutletIds = pcOutlets.stream().map(PcOutlet::getId).collect(Collectors.toList());
|
||||
|
||||
LambdaQueryWrapper<SEnvGasMonHour> sEnvWaterMonDayLambdaQueryWrapper = new QueryWrapper<SEnvGasMonHour>().lambda()
|
||||
.eq(SEnvGasMonHour::getFactoryId, factoryId)
|
||||
.in(SEnvGasMonHour::getOutletId, pcOutletIds)
|
||||
.ge(SEnvGasMonHour::getCreateTime, startTime)
|
||||
.le(SEnvGasMonHour::getCreateTime, endTime);
|
||||
|
||||
List<SEnvGasMonHour> sEnvGasMonHours = sEnvGasMonHourMapper.selectList(sEnvWaterMonDayLambdaQueryWrapper);
|
||||
Map<String, List<SEnvGasMonHour>> hourMap = sEnvGasMonHours.stream()
|
||||
.collect(Collectors.groupingBy(SEnvGasMonHour::getOutletId));
|
||||
|
||||
for (BStatTableZxbgGasEmission statTableZxbgGasEmission : statTableZxbgGasEmissions) {
|
||||
PcOutlet desiredOutlet = pcOutlets.stream()
|
||||
.filter(outlet -> outlet.getOutletCode().equals(statTableZxbgGasEmission.getOutletCode()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
int size = hourMap.getOrDefault(desiredOutlet.getId(), Collections.emptyList()).size();
|
||||
String effectivelyHour = statTableZxbgGasEmission.getEffectivelyHour();
|
||||
int parseInt = 0;
|
||||
|
||||
try {
|
||||
parseInt = Integer.parseInt(effectivelyHour);
|
||||
} catch (Exception e) {
|
||||
message.append("排口编号" + outletCode + "污染物种类" + statTableZxbgGasEmission.getPollutantName() + "有效监测数据数量应为整数,企业填报数量为" + effectivelyHour + ",不符合规范要求。");
|
||||
}
|
||||
|
||||
if (parseInt < size) {
|
||||
message.append("排口编号" + outletCode + "污染物种类" + statTableZxbgGasEmission.getPollutantName() + "为自动监测,系统根据在线监测系统核算有效监测数据数量为:" +
|
||||
size + "企业填报数量为" + parseInt + ",不满足年度监测频次。");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// //根据企业查询到所有频次 然后根据 报告类型判断 生产设施/无组织排放编号要用许可系统的无组织编号全部查一下 以排污许可自行监测为主表进行判断
|
||||
// LambdaQueryWrapper<BMainPollDisSelfMon> pollQueryWrapper = new QueryWrapper<BMainPollDisSelfMon>().lambda()
|
||||
// .select(BMainPollDisSelfMon::getFactoryId, BMainPollDisSelfMon::getOutletCode, BMainPollDisSelfMon::getPollutantType)
|
||||
// .eq(BMainPollDisSelfMon::getFactoryId, factoryId);
|
||||
// List<BMainPollDisSelfMon> bMainPollDisSelfMons = pollDisSelfMonMapper.selectList(pollQueryWrapper);
|
||||
// if (CollectionUtil.isEmpty(bMainPollDisSelfMons)){
|
||||
// log.warn("bMainActionReport:{} 无自行监测频率数据!", JSON.toJSONString(bMainActionReport));
|
||||
// continue;
|
||||
// }
|
||||
// Map<String, Integer> shouldDatCountMap = new HashMap<>();
|
||||
// //需要建立一个 排放口编号-污染物种类:检测频率 的映射
|
||||
// for (BMainPollDisSelfMon bMainPollDisSelfMon : bMainPollDisSelfMons) {
|
||||
// String monitoringManualFrequency = bMainPollDisSelfMon.getMonitoringManualFrequency();
|
||||
// //如果是年报则判断 手工检测频次1年1次 或者1季度1次*4 或者1月一次*12 就是 需要填报数据的总次数
|
||||
// int count = getCount(monitoringManualFrequency, reportsType);
|
||||
// //此处能获取到排口-污染物:报表对应需要检测的次数
|
||||
// shouldDatCountMap.put(buildKey(bMainPollDisSelfMon.getOutletCode(),bMainPollDisSelfMon.getPollutantType()),count);
|
||||
// }
|
||||
if (StringUtils.isNotBlank(message)) {
|
||||
SRaActionReportsAuditResult sRaActionReportsAuditResult = reportRecordMap.get(bMainActionReport.getId());
|
||||
if (sRaActionReportsAuditResult != null) {
|
||||
sRaActionReportsAuditResult.setMonitoringFrequency(message.toString());
|
||||
updateList.add(sRaActionReportsAuditResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(updateList)) {
|
||||
auditResultMapper.batchUpdate(updateList);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, SRaActionReportsAuditResult> getReportRecordMap(List<String> reportIds) {
|
||||
|
@ -182,21 +246,4 @@ public class MonitorFrequencyomplianceService {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public String buildKey(String outletCode, String pollutantType) {
|
||||
return outletCode + "-" + pollutantType;
|
||||
}
|
||||
|
||||
public String getOutletCodeByKey(String key) {
|
||||
if (StringUtils.isBlank(key)) {
|
||||
return null;
|
||||
}
|
||||
return key.split("-")[0];
|
||||
}
|
||||
|
||||
public String getPollutantTypeByKey(String key) {
|
||||
if (StringUtils.isBlank(key)) {
|
||||
return null;
|
||||
}
|
||||
return key.split("-")[1];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue