Merge remote-tracking branch 'origin/station' into station
This commit is contained in:
commit
f3406eaae0
|
@ -1,6 +1,8 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
@ -20,6 +22,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -292,6 +295,34 @@ public class FTPUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 批量删除FTP文件 返回删除失败的文件路径
|
||||
* */
|
||||
public List<String> removeFiles(List<String> paths){
|
||||
List<String> failList = new ArrayList<>();
|
||||
if (CollUtil.isEmpty(paths))
|
||||
return failList;
|
||||
// 连接FTP服务
|
||||
final FTPClient ftpClient = this.LoginFTP();
|
||||
for (String path : paths) {
|
||||
try {
|
||||
if (StrUtil.isBlank(path)) continue;
|
||||
boolean success = ftpClient.deleteFile(path);
|
||||
if (!success) failList.add(path);
|
||||
} catch (IOException e) {
|
||||
failList.add(path);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 关闭FTP连接
|
||||
try {
|
||||
if (ObjectUtil.isNotNull(ftpClient)) ftpClient.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return failList;
|
||||
}
|
||||
|
||||
public static boolean createDirs(FTPClient ftp , String path) throws IOException {
|
||||
/* 该部分为逐级创建 */
|
||||
String[] split = path.split(SymbolConstant.SINGLE_SLASH);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OwnerDto {
|
||||
|
||||
private String owner;
|
||||
|
||||
private String tableName;
|
||||
}
|
|
@ -257,6 +257,11 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
}
|
||||
|
||||
private List<DBInfo> dbInfoMY(String dataBase){
|
||||
return baseMapper.dbInfoMY(dataBase);
|
||||
// 切换数据源
|
||||
|
||||
List<DBInfo> dbInfos = baseMapper.dbInfoMY(dataBase);
|
||||
// 清除数据源
|
||||
|
||||
return dbInfos;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,7 @@ import org.jeecg.common.util.RedisUtil;
|
|||
import org.jeecg.modules.system.entity.GardsSampleDataSystem;
|
||||
import org.jeecg.modules.system.service.IGardsSampleDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -49,8 +46,9 @@ public class GardsSampleDataController {
|
|||
|
||||
@DeleteMapping("deleteById")
|
||||
@ApiOperation(value = "删除DATA_BASE数据", notes = "删除DATA_BASE数据")
|
||||
public Result deleteById(Integer sampleId){
|
||||
return gardsSampleDataService.deleteById(sampleId);
|
||||
public Result<?> deleteById(@RequestParam Integer sampleId, boolean sampleData,
|
||||
boolean rnAuto, boolean rnMan){
|
||||
return gardsSampleDataService.deleteById(sampleId, sampleData, rnAuto, rnMan);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.base.dto.OwnerDto;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
||||
import org.jeecg.modules.system.entity.GardsSampleDataSystem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GardsSampleDataMapper extends BaseMapper<GardsSampleDataSystem> {
|
||||
|
||||
List<OwnerDto> containSampleId(String filed);
|
||||
|
||||
void delTables(@Param("tableNames") List<String> tableNames,
|
||||
@Param("sampleId") Integer sampleId);
|
||||
|
||||
GardsAnalyses getAnalysis(@Param("sampleId") Integer sampleId,
|
||||
@Param("owner") String owner);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?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.system.mapper.GardsSampleDataMapper">
|
||||
<delete id="delTables">
|
||||
<foreach collection = "tableNames" item = "tableName" index = "index">
|
||||
DELETE FROM ${tableName} WHERE SAMPLE_ID = #{sampleId};
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="containSampleId" resultType="org.jeecg.modules.base.dto.OwnerDto">
|
||||
SELECT
|
||||
OWNER,
|
||||
TABLE_NAME AS tableName
|
||||
FROM
|
||||
DBA_TAB_COLUMNS
|
||||
WHERE
|
||||
COLUMN_NAME = #{filed}
|
||||
</select>
|
||||
<select id="getAnalysis" resultType="org.jeecg.modules.base.entity.rnauto.GardsAnalyses">
|
||||
SELECT
|
||||
BASELINE_PATH AS baselinePath,
|
||||
LC_PATH AS lcPath,
|
||||
SCAC_PATH AS scacPath,
|
||||
LOG_PATH AS logPath,
|
||||
REPORT_PAHT AS reportPath
|
||||
FROM
|
||||
${owner}.GARDS_ANALYSES
|
||||
WHERE
|
||||
SAMPLE_ID = #{sampleId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
||||
import org.jeecg.modules.system.entity.GardsSampleDataSystem;
|
||||
|
||||
public interface IGardsSampleDataService extends IService<GardsSampleDataSystem> {
|
||||
|
@ -21,6 +22,7 @@ public interface IGardsSampleDataService extends IService<GardsSampleDataSystem>
|
|||
* @param sampleId
|
||||
* @return
|
||||
*/
|
||||
Result deleteById(Integer sampleId);
|
||||
Result<?> deleteById(Integer sampleId, boolean sampleData, boolean rnAuto, boolean rnMan);
|
||||
|
||||
GardsSampleDataSystem getOne(Integer sampleId);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
@ -9,23 +14,44 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.enums.FileTypeEnum;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.FTPUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.modules.base.dto.OwnerDto;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
||||
import org.jeecg.modules.system.entity.GardsSampleDataSystem;
|
||||
import org.jeecg.modules.system.mapper.GardsSampleDataMapper;
|
||||
import org.jeecg.modules.system.service.IGardsSampleDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("gardsSampleDataService")
|
||||
@DS("ora")
|
||||
public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMapper, GardsSampleDataSystem> implements IGardsSampleDataService {
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private FTPUtil ftpUtil;
|
||||
|
||||
@Autowired
|
||||
private SpectrumPathProperties pathProperties;
|
||||
|
||||
@Autowired
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
@Override
|
||||
public Result<IPage<GardsSampleDataSystem>> findPage(QueryRequest queryRequest, GardsSampleDataSystem gardsSampleData) {
|
||||
//查询全部台站信息
|
||||
|
@ -62,14 +88,115 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result deleteById(Integer sampleId) {
|
||||
Result result = new Result();
|
||||
LambdaQueryWrapper<GardsSampleDataSystem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(GardsSampleDataSystem::getSampleId, sampleId);
|
||||
this.baseMapper.delete(queryWrapper);
|
||||
result.success("Successfully deleted");
|
||||
return result;
|
||||
public Result<?> deleteById(Integer sampleId, boolean sampleData,
|
||||
boolean rnAuto, boolean rnMan) {
|
||||
String ftpRootPath = ftpUtil.getFtpRootPath();
|
||||
String savePath = ftpRootPath + pathProperties.getSaveFilePath() + StrUtil.SLASH;
|
||||
String logPath = ftpRootPath + pathProperties.getLogPath() + StrUtil.SLASH;
|
||||
/* 删除数据库数据 */
|
||||
// 过滤掉多余的表
|
||||
String ORIGINAL = "ORIGINAL";String RNAUTO = "RNAUTO";String RNMAN = "RNMAN";
|
||||
List<String> suitable = ListUtil.toList(ORIGINAL, RNAUTO, RNMAN);
|
||||
List<OwnerDto> ownerDtos = baseMapper.containSampleId("SAMPLE_ID").stream()
|
||||
.filter(owner -> CollUtil.contains(suitable, owner.getOwner()))
|
||||
.collect(Collectors.toList());
|
||||
String DOT = StrUtil.DOT;
|
||||
// 手动控制事务
|
||||
TransactionDefinition txDef = new DefaultTransactionDefinition();
|
||||
TransactionStatus txStatus = transactionManager.getTransaction(txDef);
|
||||
try {
|
||||
List<String> needDel = new ArrayList<>();
|
||||
if (sampleData){
|
||||
// 收集所有表名
|
||||
List<String> allTables = ownerDtos.stream()
|
||||
.map(owner -> owner.getOwner() + DOT + owner.getTableName())
|
||||
.collect(Collectors.toList());
|
||||
// 删除表数据
|
||||
if (CollUtil.isNotEmpty(allTables))
|
||||
baseMapper.delTables(allTables, sampleId);
|
||||
// 收集待删除文件路径
|
||||
needDel.add(samplePath(savePath, sampleId)); // 原始谱文件
|
||||
needDel.addAll(manOrAutoPath(savePath, logPath, sampleId, RNMAN)); // 人工交互文件
|
||||
needDel.addAll(manOrAutoPath(savePath, logPath, sampleId, RNAUTO)); // 自动处理文件
|
||||
}
|
||||
else {
|
||||
if (rnAuto){
|
||||
// 收集自动处理库所有表名
|
||||
List<String> autoTables = ownerDtos.stream()
|
||||
.filter(owner -> StrUtil.equals(owner.getOwner(), RNAUTO))
|
||||
.map(owner -> owner.getOwner() + DOT + owner.getTableName())
|
||||
.collect(Collectors.toList());
|
||||
// 删除表数据
|
||||
if (CollUtil.isNotEmpty(autoTables))
|
||||
baseMapper.delTables(autoTables, sampleId);
|
||||
// 收集待删除文件路径
|
||||
needDel.addAll(manOrAutoPath(savePath, logPath, sampleId, RNAUTO)); // 自动处理文件
|
||||
}
|
||||
if (rnMan){
|
||||
// 收集人工交互库所有表名
|
||||
List<String> manTables = ownerDtos.stream()
|
||||
.filter(owner -> StrUtil.equals(owner.getOwner(), RNMAN))
|
||||
.map(owner -> owner.getOwner() + DOT + owner.getTableName())
|
||||
.collect(Collectors.toList());
|
||||
// 删除表数据
|
||||
if (CollUtil.isNotEmpty(manTables))
|
||||
baseMapper.delTables(manTables, sampleId);
|
||||
// 收集待删除文件路径
|
||||
needDel.addAll(manOrAutoPath(savePath, logPath, sampleId, RNMAN)); // 人工交互文件
|
||||
}
|
||||
}
|
||||
transactionManager.commit(txStatus);
|
||||
needDel = needDel.stream().filter(StrUtil::isNotBlank).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(needDel))
|
||||
return Result.OK("Data cleaning is complete. No files need to be cleaned!");
|
||||
// 删除FTP文件
|
||||
List<String> failList = ftpUtil.removeFiles(needDel);
|
||||
if (CollUtil.isNotEmpty(failList))
|
||||
return Result.error("Data clearing is complete, but file clearing fails!", failList);
|
||||
return Result.OK("Data and file cleanup complete!");
|
||||
}catch (Exception e){
|
||||
transactionManager.rollback(txStatus);
|
||||
e.printStackTrace();
|
||||
return Result.error("Data deletion is abnormal, The file deletion operation has not been performed!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GardsSampleDataSystem getOne(Integer sampleId) {
|
||||
LambdaQueryWrapper<GardsSampleDataSystem> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(GardsSampleDataSystem::getSampleId, sampleId);
|
||||
return Optional.ofNullable(getOne(wrapper))
|
||||
.orElse(new GardsSampleDataSystem());
|
||||
}
|
||||
|
||||
private String samplePath(String savePath, Integer sampleId){
|
||||
GardsSampleDataSystem sampleData = getOne(sampleId);
|
||||
String inputFileName = sampleData.getInputFileName();
|
||||
if (StrUtil.isBlank(inputFileName))
|
||||
return null;
|
||||
return savePath + inputFileName;
|
||||
}
|
||||
|
||||
private List<String> manOrAutoPath(String savePath, String logPath,
|
||||
Integer sampleId, String owner){
|
||||
List<String> fileList = new ArrayList<>();
|
||||
GardsAnalyses analysisMan = baseMapper.getAnalysis(sampleId, owner);
|
||||
if (ObjectUtil.isNull(analysisMan))
|
||||
return fileList;
|
||||
String baselinePath = analysisMan.getBaselinePath();
|
||||
if (StrUtil.isNotBlank(baselinePath))
|
||||
fileList.add(savePath + baselinePath);
|
||||
String lcPath = analysisMan.getLcPath();
|
||||
if (StrUtil.isNotBlank(lcPath))
|
||||
fileList.add(savePath + lcPath);
|
||||
String scacPath = analysisMan.getScacPath();
|
||||
if (StrUtil.isNotBlank(scacPath))
|
||||
fileList.add(savePath + scacPath);
|
||||
if (StrUtil.isNotBlank(analysisMan.getLogPath()))
|
||||
fileList.add(logPath + analysisMan.getLogPath());
|
||||
String reportPath = analysisMan.getReportPath();
|
||||
if (StrUtil.isNotBlank(reportPath))
|
||||
fileList.add(savePath + reportPath + FileTypeEnum.txt.getType());
|
||||
return fileList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,14 @@
|
|||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-starter-cloud</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>32.1.2-jre</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package org.jeecg.modules.entity.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class StatDataNumber implements Serializable {
|
||||
|
||||
private int originalDataNumber = 0;
|
||||
private int anlyseDataNumber = 0;
|
||||
|
||||
public void addOriginalDataNumber(int incr) {
|
||||
originalDataNumber += incr;
|
||||
}
|
||||
|
||||
public void addAnlyseDataNumber(int incr) {
|
||||
anlyseDataNumber += incr;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.jeecg.modules.entity.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class OriginalDataNumber implements Serializable {
|
||||
|
||||
private String siteCode;
|
||||
private String dataType;
|
||||
private Integer count;
|
||||
}
|
|
@ -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>
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import org.jeecg.modules.entity.GardsAlertDataWeb;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface IGardsAlertDataService extends IService<GardsAlertDataWeb> {
|
||||
|
||||
|
@ -11,4 +13,6 @@ public interface IGardsAlertDataService extends IService<GardsAlertDataWeb> {
|
|||
String startTime,
|
||||
String endTime,
|
||||
HttpServletResponse response);
|
||||
|
||||
List<GardsAlertDataWeb> queryByTime(Date startTime, Date endTime);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.jeecg.modules.entity.GardsMetDataWeb;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface IGardsMetDataService extends IService<GardsMetDataWeb> {
|
||||
|
||||
|
@ -24,4 +25,6 @@ public interface IGardsMetDataService extends IService<GardsMetDataWeb> {
|
|||
String startTime,
|
||||
String endTime,
|
||||
HttpServletResponse response);
|
||||
|
||||
List<GardsMetDataWeb> queryByModDate(Date startTime, Date endTime);
|
||||
}
|
||||
|
|
|
@ -48,4 +48,6 @@ public interface IGardsSampleDataWebService extends IService<GardsSampleDataWeb>
|
|||
String startTime,
|
||||
String endTime,
|
||||
List<Integer> sampleIds);
|
||||
|
||||
List<GardsSampleDataWeb> queryByModDate(Date startTime, Date endTime);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.jeecg.modules.entity.GardsSohDataWeb;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface IGardsSohDataService extends IService<GardsSohDataWeb> {
|
||||
|
||||
|
@ -41,4 +42,7 @@ public interface IGardsSohDataService extends IService<GardsSohDataWeb> {
|
|||
String startTime,
|
||||
String endTime,
|
||||
HttpServletResponse response);
|
||||
|
||||
|
||||
List<GardsSohDataWeb> queryByModDate(Date startTime, Date endTime);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -73,4 +73,11 @@ public class GardsAlertDataServiceImpl extends ServiceImpl<GardsAlertDataMapper,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GardsAlertDataWeb> queryByTime(Date startTime, Date endTime) {
|
||||
LambdaQueryWrapper<GardsAlertDataWeb> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(GardsAlertDataWeb::getTime, startTime, endTime);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,4 +112,11 @@ public class GardsMetDataServiceImpl extends ServiceImpl<GardsMetDataMapper, Gar
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GardsMetDataWeb> queryByModDate(Date startTime, Date endTime) {
|
||||
LambdaQueryWrapper<GardsMetDataWeb> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(GardsMetDataWeb::getModdate, startTime ,endTime);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -709,4 +709,12 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
|
|||
}
|
||||
return sampleData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GardsSampleDataWeb> queryByModDate(Date startTime, Date endTime) {
|
||||
LambdaQueryWrapper<GardsSampleDataWeb> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(GardsSampleDataWeb::getModdate, startTime, endTime);
|
||||
queryWrapper.orderByAsc(GardsSampleDataWeb::getSiteDetCode);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.codec.language.bm.Lang;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
@ -192,4 +193,11 @@ public class GardsSohDataServiceImpl extends ServiceImpl<GardsSohDataMapper, Gar
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GardsSohDataWeb> queryByModDate(Date startTime, Date endTime) {
|
||||
LambdaQueryWrapper<GardsSohDataWeb> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(GardsSohDataWeb::getModdate, startTime, endTime);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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