监测频次合规
parent
b353b22f6f
commit
6be37ac12d
|
@ -20,6 +20,8 @@ public class ExecuteReportAuditService {
|
||||||
final FugitiveExhaustPollutantsService fugitiveExhaustPollutantsService;
|
final FugitiveExhaustPollutantsService fugitiveExhaustPollutantsService;
|
||||||
//序号 64 非正常工况/特殊时段有组织废气污染物监测数据统计表
|
//序号 64 非正常工况/特殊时段有组织废气污染物监测数据统计表
|
||||||
final NotNormalOrgGasPollutantsService notNormalOrgGasPollutantsService;
|
final NotNormalOrgGasPollutantsService notNormalOrgGasPollutantsService;
|
||||||
|
//序号 65 监测频次合规
|
||||||
|
final MonitorFrequencyomplianceService monitorFrequencyomplianceService;
|
||||||
//序号 67 超标排放信息
|
//序号 67 超标排放信息
|
||||||
final ExcessiveEmissionsService excessiveEmissionsService;
|
final ExcessiveEmissionsService excessiveEmissionsService;
|
||||||
//序号 68 附图附件-自行监测布点图
|
//序号 68 附图附件-自行监测布点图
|
||||||
|
@ -54,6 +56,8 @@ public class ExecuteReportAuditService {
|
||||||
fugitiveExhaustPollutantsService.execute(reportIds); //比较耗时
|
fugitiveExhaustPollutantsService.execute(reportIds); //比较耗时
|
||||||
//序号 64 非正常工况/特殊时段有组织废气污染物监测数据统计表
|
//序号 64 非正常工况/特殊时段有组织废气污染物监测数据统计表
|
||||||
notNormalOrgGasPollutantsService.execute(reportIds); //比较耗时;
|
notNormalOrgGasPollutantsService.execute(reportIds); //比较耗时;
|
||||||
|
//监测频次合规
|
||||||
|
monitorFrequencyomplianceService.execute(reportIds);
|
||||||
//序号 67 超标排放信息
|
//序号 67 超标排放信息
|
||||||
excessiveEmissionsService.execute(reportIds); //比较耗时
|
excessiveEmissionsService.execute(reportIds); //比较耗时
|
||||||
//序号 66 差异占比
|
//序号 66 差异占比
|
||||||
|
|
|
@ -0,0 +1,202 @@
|
||||||
|
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.domain.analysis.SRaActionReportsAuditRecord;
|
||||||
|
import cn.cecep.talroad.domain.analysis.SRaActionReportsAuditResult;
|
||||||
|
import cn.cecep.talroad.enums.EmlTypeEnums;
|
||||||
|
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.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;
|
||||||
|
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.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class MonitorFrequencyomplianceService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PcOutletMapper pcOutletMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SEnvGasMonHourMapper sEnvGasMonHourMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISEnvWaterMonDayService isEnvWaterMonDayService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BStatTableZxbgGasEmissionMapper bStatTableZxbgGasEmissionMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BMainActionReportsMapper actionReportsMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SRaActionReportsAuditRecordMapper recordMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SRaActionReportsAuditResultMapper auditResultMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BMainPollDisSelfMonMapper pollDisSelfMonMapper;
|
||||||
|
|
||||||
|
|
||||||
|
public void execute(List<String> reportIds) {
|
||||||
|
LambdaQueryWrapper<BMainActionReports> reportQueryWrapper = new QueryWrapper<BMainActionReports>().lambda()
|
||||||
|
.in(BMainActionReports::getId, reportIds);
|
||||||
|
List<BMainActionReports> bMainActionReports = actionReportsMapper.selectList(reportQueryWrapper);
|
||||||
|
List<SRaActionReportsAuditResult> updateList = new ArrayList<>();
|
||||||
|
Map<String, SRaActionReportsAuditResult> reportRecordMap = getReportRecordMap(reportIds);
|
||||||
|
//执行报告循环
|
||||||
|
for (BMainActionReports bMainActionReport : bMainActionReports) {
|
||||||
|
|
||||||
|
//获取执行报告对应的有组织废气污染物排放浓度监测数据统计表的数据
|
||||||
|
LambdaQueryWrapper<BStatTableZxbgGasEmission> bStatTableZxbgGasEmissionLambdaQueryWrapper = new QueryWrapper<BStatTableZxbgGasEmission>().lambda()
|
||||||
|
.eq(BStatTableZxbgGasEmission::getFactoryId, bMainActionReport.getFactoryId())
|
||||||
|
.eq(BStatTableZxbgGasEmission::getZxbgPeriod, bMainActionReport.getReportsTime())
|
||||||
|
.eq(BStatTableZxbgGasEmission::getZxbgType, bMainActionReport.getReportsType())
|
||||||
|
.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("手工")) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// //根据企业查询到所有频次 然后根据 报告类型判断 生产设施/无组织排放编号要用许可系统的无组织编号全部查一下 以排污许可自行监测为主表进行判断
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, SRaActionReportsAuditResult> getReportRecordMap(List<String> reportIds) {
|
||||||
|
LambdaQueryWrapper<SRaActionReportsAuditRecord> recordQueryWrapper = new QueryWrapper<SRaActionReportsAuditRecord>()
|
||||||
|
.lambda()
|
||||||
|
.select(SRaActionReportsAuditRecord::getId, SRaActionReportsAuditRecord::getReportId)
|
||||||
|
.in(SRaActionReportsAuditRecord::getReportId, reportIds);
|
||||||
|
List<SRaActionReportsAuditRecord> sRaActionReportsAuditRecords = recordMapper.selectList(recordQueryWrapper);
|
||||||
|
if (CollectionUtil.isEmpty(sRaActionReportsAuditRecords)) {
|
||||||
|
log.warn("执行报告审核记录不存在!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<String> recordIds = sRaActionReportsAuditRecords.stream().map(SRaActionReportsAuditRecord::getId).collect(Collectors.toList());
|
||||||
|
Map<String, String> recordReportIdMap = sRaActionReportsAuditRecords.stream().collect(Collectors.toMap(SRaActionReportsAuditRecord::getId, SRaActionReportsAuditRecord::getReportId));
|
||||||
|
LambdaQueryWrapper<SRaActionReportsAuditResult> queryWrapper = new QueryWrapper<SRaActionReportsAuditResult>().lambda().in(SRaActionReportsAuditResult::getRecordId, recordIds);
|
||||||
|
List<SRaActionReportsAuditResult> sRaActionReportsAuditResults = auditResultMapper.selectList(queryWrapper);
|
||||||
|
if (CollectionUtil.isEmpty(sRaActionReportsAuditResults)) {
|
||||||
|
log.warn("执行报告规范性审核结果记录不存在!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return sRaActionReportsAuditResults.stream().collect(Collectors.toMap(data -> recordReportIdMap.get(data.getRecordId()), Function.identity()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount(String monitoringManualFrequency, String reportsType) {
|
||||||
|
if (EmlTypeEnums.YEAR.getCode().equals(reportsType)) {
|
||||||
|
return getYearCount(monitoringManualFrequency);
|
||||||
|
} else if (EmlTypeEnums.QUARTER.getCode().equals(reportsType)) {
|
||||||
|
//直接拿年的所有频次去除季度
|
||||||
|
int yearCount = getYearCount(monitoringManualFrequency);
|
||||||
|
//小于12 代表 获取到的是 季度以上的单位
|
||||||
|
if (yearCount < 4) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return yearCount / 4;
|
||||||
|
} else if (EmlTypeEnums.MONTH.getCode().equals(reportsType)) {
|
||||||
|
//直接拿年的所有频次去除月
|
||||||
|
int yearCount = getYearCount(monitoringManualFrequency);
|
||||||
|
//小于12 代表 获取到的是月度以上的单位
|
||||||
|
if (yearCount < 12) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return yearCount / 12;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getYearCount(String monitoringManualFrequency) {
|
||||||
|
//返回各种频次对应的 一整年需要多少次 此处周按照一年52周 每月5个星期算
|
||||||
|
if (monitoringManualFrequency.contains("周")) {
|
||||||
|
//直接返回52周
|
||||||
|
return 52;
|
||||||
|
}
|
||||||
|
if (monitoringManualFrequency.contains("月")) {
|
||||||
|
//每年有12个月
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
if (monitoringManualFrequency.contains("季")) {
|
||||||
|
//每年有4个季度
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
if (monitoringManualFrequency.contains("半年")) {
|
||||||
|
//每年有两个半年
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (monitoringManualFrequency.contains("年")) {
|
||||||
|
//每年一次
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
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