Merge branch 'main_ZZ'
commit
068aa00a07
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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,249 @@
|
||||||
|
package cn.cecep.talroad.data.analyse.task.execute.report.specifications.audit;
|
||||||
|
|
||||||
|
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;
|
||||||
|
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.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.*;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BStatTableZxbgPflAirMapper bStatTableZxbgPflAirMapper;
|
||||||
|
|
||||||
|
|
||||||
|
public void execute(List<String> reportIds) {
|
||||||
|
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())
|
||||||
|
.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));
|
||||||
|
|
||||||
|
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 + ",不满足年度监测频次。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue