邮件统计
This commit is contained in:
parent
eb99b95bd7
commit
9913770471
|
@ -0,0 +1,71 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.jeecg.modules.entity.data.OriginalDataNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface StatReportMapper {
|
||||
|
||||
List<OriginalDataNumber> queryOriginalDataNumberFromGardsSampleData(String startTime, String endTime);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_SAMPLE_DESCRIPTION where sample_id = #{sampleId}")
|
||||
Integer countGardsSampleDescriptionBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_SAMPLE_RATIOS where sample_id = #{sampleId}")
|
||||
Integer countGardsSampleRatiosBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_SPECTRUM where sample_id = #{sampleId}")
|
||||
Integer countGardsSpectrumBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_TOTAL_EFFICIENCY_PAIRS where sample_id = #{sampleId}")
|
||||
Integer countGardsTotalEfficiencyPairsBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_HISTOGRAM where sample_id = #{sampleId}")
|
||||
Integer countGardsHistogramBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_CALIBRATION_PAIRS_ORIG where sample_id = #{sampleId}")
|
||||
Integer countGardsCalibrationPairsOrig(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_BG_EFFICIENCY_PAIRS where sample_id = #{sampleId}")
|
||||
Integer countGardsBGEfficinecyPairsBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_ROI_LIMITS where sample_id = #{sampleId}")
|
||||
Integer countGardsROILimitsBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_SAMPLE_AUX where sample_id = #{sampleId}")
|
||||
Integer countGardsSampleAUXBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_SAMPLE_CERT where sample_id = #{sampleId}")
|
||||
Integer countGardsSampleCertBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from original.GARDS_SAMPLE_CERT_LINE where sample_id = #{sampleId}")
|
||||
Integer countGardsSampleCertLineBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from rnauto.GARDS_ANALYSES where sample_id = #{sampleId}")
|
||||
Integer countGardsAnalysesBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from rnauto.GARDS_CALIBRATION where sample_id = #{sampleId}")
|
||||
Integer countGardsCalibrationBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from rnauto.GARDS_CALIBRATION_PAIRS where sample_id = #{sampleId}")
|
||||
Integer countGardsCalibrationPairsBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from rnauto.GARDS_NUCL_LINES_IDED where sample_id = #{sampleId}")
|
||||
Integer countGardsNuclLinesIdedBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from rnauto.GARDS_ROI_CHANNELS where sample_id = #{sampleId}")
|
||||
Integer countGardsRoiChannelsBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from rnauto.GARDS_ROI_RESULTS where sample_id = #{sampleId}")
|
||||
Integer countGardsRoiResultsBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from rnauto.GARDS_XE_RESULTS where sample_id = #{sampleId}")
|
||||
Integer countGardsXeResultsBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from rnauto.GARDS_PEAKS where sample_id = #{sampleId}")
|
||||
Integer countGardsPeaksBySampleId(Integer sampleId);
|
||||
|
||||
@Select("select count(sample_id) from rnauto.GARDS_QC_CHECK where sample_id = #{sampleId}")
|
||||
Integer countGardsQcCheckBySampleId(Integer sampleId);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
|
||||
import org.jeecg.modules.entity.GardsAlertDataWeb;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface SysEmailLogStatMapper extends BaseMapper<SysEmailLog> {
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.mapper.GardsSampleDataWebMapper">
|
||||
|
||||
<select id="queryOriginalDataNumber" resultType="org.jeecg.modules.entity.data.OriginalDataNumber">
|
||||
select SUBSTR(SITE_DET_CODE, 1, 5) as siteCode, data_Type as dataType, COUNT(DATA_TYPE) as count
|
||||
from original.GARDS_SAMPLE_DATA t
|
||||
where moddate BETWEEN TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
|
||||
GROUP BY SUBSTR(SITE_DET_CODE, 1, 5), DATA_TYPE
|
||||
order by SUBSTR(SITE_DET_CODE, 1, 5)
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,19 @@
|
|||
package org.jeecg.modules.service;
|
||||
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import org.jeecg.modules.entity.bo.StatDataNumber;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface IStatReportService {
|
||||
|
||||
/**
|
||||
* 统计LoadIntoDB
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
*/
|
||||
HashBasedTable<String, String, StatDataNumber> statLoadIntoDB(Date startTime, Date endTime);
|
||||
|
||||
void doStat(Date startTime, Date endTime);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package org.jeecg.modules.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
|
||||
import java.util.Date;
|
||||
|
||||
public interface ISysEmailLogStatService extends IService<SysEmailLog> {
|
||||
|
||||
long queryEmailCount(Date startTime, Date endTime);
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import org.jeecg.modules.entity.GardsAlertDataWeb;
|
||||
import org.jeecg.modules.entity.GardsMetDataWeb;
|
||||
import org.jeecg.modules.entity.GardsSampleDataWeb;
|
||||
import org.jeecg.modules.entity.GardsSohDataWeb;
|
||||
import org.jeecg.modules.entity.bo.StatDataNumber;
|
||||
import org.jeecg.modules.mapper.StatReportMapper;
|
||||
import org.jeecg.modules.service.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@DS("ora")
|
||||
public class StatReportServiceImpl implements IStatReportService {
|
||||
@Resource
|
||||
private IGardsSampleDataWebService gardsSampleDataWebService;
|
||||
@Resource
|
||||
private StatReportMapper statReportMapper;
|
||||
@Resource
|
||||
private IGardsMetDataService gardsMetDataService;
|
||||
@Resource
|
||||
private IGardsSohDataService gardsSohDataService;
|
||||
@Resource
|
||||
private IGardsAlertDataService gardsAlertDataService;
|
||||
@Resource
|
||||
private ISysEmailLogStatService sysEmailLogStatService;
|
||||
|
||||
@Override
|
||||
public HashBasedTable<String, String, StatDataNumber> statLoadIntoDB(Date startTime, Date endTime) {
|
||||
HashBasedTable<String, String, StatDataNumber> statTable = HashBasedTable.create();
|
||||
|
||||
List<GardsSampleDataWeb> gardsSampleDataWebs = gardsSampleDataWebService.queryByModDate(startTime, endTime);
|
||||
for (GardsSampleDataWeb gardsSampleDataWeb : gardsSampleDataWebs) {
|
||||
Integer sampleId = gardsSampleDataWeb.getSampleId();
|
||||
String site = gardsSampleDataWeb.getSiteDetCode().split("_")[0];
|
||||
String dataType = gardsSampleDataWeb.getDataType();
|
||||
increase(statTable, site, dataType, 1, 0);
|
||||
|
||||
Integer sampleDescription = statReportMapper.countGardsSampleDescriptionBySampleId(sampleId);
|
||||
Integer sampleCertLine = statReportMapper.countGardsSampleCertLineBySampleId(sampleId);
|
||||
Integer bgEfficinecyPairs = statReportMapper.countGardsBGEfficinecyPairsBySampleId(sampleId);
|
||||
Integer calibrationPairsOrig = statReportMapper.countGardsCalibrationPairsOrig(sampleId);
|
||||
Integer gardsHistogram = statReportMapper.countGardsHistogramBySampleId(sampleId);
|
||||
Integer roiLimits = statReportMapper.countGardsROILimitsBySampleId(sampleId);
|
||||
Integer sampleAUX = statReportMapper.countGardsSampleAUXBySampleId(sampleId);
|
||||
Integer totalEfficiencyPairs = statReportMapper.countGardsTotalEfficiencyPairsBySampleId(sampleId);
|
||||
Integer spectrum = statReportMapper.countGardsSpectrumBySampleId(sampleId);
|
||||
Integer sampleCert = statReportMapper.countGardsSampleCertBySampleId(sampleId);
|
||||
Integer sampleRatios = statReportMapper.countGardsSampleRatiosBySampleId(sampleId);
|
||||
int originalNumberTotal = sampleDescription + sampleCertLine + bgEfficinecyPairs + calibrationPairsOrig
|
||||
+ gardsHistogram + roiLimits + sampleAUX + totalEfficiencyPairs + spectrum + sampleCert + sampleRatios;
|
||||
increase(statTable, site, dataType, originalNumberTotal, 0);
|
||||
|
||||
if (gardsSampleDataWeb.getDataType().equals("S")) { // 只有SAMPLEPHD才有分析数据
|
||||
Integer i = statReportMapper.countGardsCalibrationPairsBySampleId(sampleId);
|
||||
Integer i1 = statReportMapper.countGardsNuclLinesIdedBySampleId(sampleId);
|
||||
Integer i2 = statReportMapper.countGardsRoiChannelsBySampleId(sampleId);
|
||||
Integer i3 = statReportMapper.countGardsRoiResultsBySampleId(sampleId);
|
||||
Integer i4 = statReportMapper.countGardsXeResultsBySampleId(sampleId);
|
||||
Integer i5 = statReportMapper.countGardsPeaksBySampleId(sampleId);
|
||||
Integer i6 = statReportMapper.countGardsQcCheckBySampleId(sampleId);
|
||||
Integer i7 = statReportMapper.countGardsAnalysesBySampleId(sampleId);
|
||||
Integer i8 = statReportMapper.countGardsCalibrationBySampleId(sampleId);
|
||||
int total = i + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8;
|
||||
increase(statTable, site, dataType, 0, total);
|
||||
}
|
||||
}
|
||||
|
||||
List<GardsMetDataWeb> metDataList = gardsMetDataService.queryByModDate(startTime, endTime);
|
||||
for (GardsMetDataWeb gardsMetDataWeb : metDataList) {
|
||||
increase(statTable, gardsMetDataWeb.getStationCode(), "MET", 1, 0);
|
||||
}
|
||||
List<GardsSohDataWeb> sohDataList = gardsSohDataService.queryByModDate(startTime, endTime);
|
||||
for (GardsSohDataWeb gardsSohDataWeb : sohDataList) {
|
||||
increase(statTable, gardsSohDataWeb.getStationCode(), "SOH", 1, 0);
|
||||
}
|
||||
List<GardsAlertDataWeb> alertDataList = gardsAlertDataService.queryByTime(startTime, endTime);
|
||||
for (GardsAlertDataWeb gardsAlertDataWeb : alertDataList) {
|
||||
increase(statTable, gardsAlertDataWeb.getStationCode(), "ALERT", 1, 0);
|
||||
}
|
||||
return statTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doStat(Date startTime, Date endTime) {
|
||||
long emailCount = sysEmailLogStatService.queryEmailCount(startTime, endTime);
|
||||
HashBasedTable<String, String, StatDataNumber> loadToDBTable = statLoadIntoDB(startTime, endTime);
|
||||
Collection<StatDataNumber> values = loadToDBTable.values();
|
||||
Optional<Integer> originalDataLoadTotal = values.stream().map(StatDataNumber::getOriginalDataNumber).reduce(Integer::sum);
|
||||
}
|
||||
|
||||
|
||||
private String genReport(Date startTime, Date endTime, long emailNumber, int originalDataLoadToDB, int fileFormatErr, int fileRepeatErr, HashBasedTable<String, String, StatDataNumber> statTable) {
|
||||
String content =
|
||||
" GENERATED STATISTICS REPORT \n" +
|
||||
" Creation Date %s \n" +
|
||||
"\n" +
|
||||
"#STATISTICS INFO \n" +
|
||||
" Statistics BeginTime: %s \n" +
|
||||
" Statistics EndTime: %s \n" +
|
||||
" Email Number: %d \n" +
|
||||
" Original Data Load to DB Number: %d \n" +
|
||||
"\n" +
|
||||
"#STATISTICS ERROR FILE \n" +
|
||||
" File Format Error: %d \n" +
|
||||
" File Repeat Error: %d \n" +
|
||||
"\n" +
|
||||
"#LOAD INTO DB INFO \n" +
|
||||
" Station Name DataType Original Data Number Anlyse Data Number ";
|
||||
String dateFormat = "yyyy/MM/dd-HH:mm:ss";
|
||||
String nowDateStr = DateUtil.format(new Date(), dateFormat);
|
||||
String startTimeStr = DateUtil.format(startTime, dateFormat);
|
||||
String endTimeStr = DateUtil.format(endTime, dateFormat);
|
||||
String format = String.format(content, nowDateStr, startTimeStr, endTimeStr, emailNumber, originalDataLoadToDB, fileFormatErr, fileRepeatErr);
|
||||
// ARP01 SAMPLEPHD 19 19
|
||||
return format;
|
||||
}
|
||||
|
||||
private void increase(HashBasedTable<String, String, StatDataNumber> statTable, String key1, String key2, int originalDataNumberIncr, int anlyseDataNumberIncr) {
|
||||
StatDataNumber statDataNumber;
|
||||
if (!statTable.contains(key1, key2)) {
|
||||
statDataNumber = new StatDataNumber();
|
||||
} else {
|
||||
statDataNumber = statTable.get(key1, key2);
|
||||
}
|
||||
statDataNumber.addOriginalDataNumber(originalDataNumberIncr);
|
||||
statDataNumber.addAnlyseDataNumber(anlyseDataNumberIncr);
|
||||
statTable.put(key1, key2, statDataNumber);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
|
||||
import org.jeecg.modules.mapper.SysEmailLogStatMapper;
|
||||
import org.jeecg.modules.service.ISysEmailLogStatService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class SysEmailLogStatServiceImpl extends ServiceImpl<SysEmailLogStatMapper, SysEmailLog> implements ISysEmailLogStatService {
|
||||
|
||||
@Override
|
||||
public long queryEmailCount(Date startTime, Date endTime) {
|
||||
LambdaQueryWrapper<SysEmailLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(SysEmailLog::getCreateTime, startTime, endTime);
|
||||
return count(queryWrapper);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user