feat:saveToTxt
This commit is contained in:
parent
f39dc57682
commit
94ec6ec463
|
@ -86,10 +86,25 @@
|
|||
</select>
|
||||
|
||||
<select id="dbInfoPG" resultType="org.jeecg.modules.base.dto.DBInfo">
|
||||
|
||||
SELECT
|
||||
relname AS tableName,
|
||||
ROUND( pg_relation_size ( relid ) / ( 1024 * 1024 ), 2 ) AS dataSize,
|
||||
ROUND( pg_indexes_size ( relid ) / ( 1024 * 1024 ), 2 ) AS indexSize
|
||||
FROM
|
||||
pg_stat_user_tables
|
||||
WHERE
|
||||
schemaname = 'public'
|
||||
</select>
|
||||
<select id="dbRowNumPG" resultType="org.jeecg.modules.base.dto.DBInfo">
|
||||
|
||||
SELECT
|
||||
relname AS tableName,
|
||||
reltuples AS numRow
|
||||
FROM
|
||||
pg_class
|
||||
WHERE
|
||||
relkind = 'r'
|
||||
AND relname NOT LIKE 'pg_%'
|
||||
AND relname NOT LIKE 'sql_%'
|
||||
</select>
|
||||
|
||||
<select id="dbInfoMY" resultType="org.jeecg.modules.base.dto.DBInfo">
|
||||
|
|
|
@ -208,7 +208,7 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
dbInfos = dbInfoOR(dataBase);
|
||||
break;
|
||||
case DataBaseConstant.DB_TYPE_POSTGRESQL:
|
||||
|
||||
dbInfos = dbInfoPG();
|
||||
break;
|
||||
case DataBaseConstant.DB_TYPE_MYSQL:
|
||||
// ...
|
||||
|
@ -247,8 +247,8 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
double min = 40.0;
|
||||
double max = 100.0;
|
||||
double random = min + (max - min) * new Random().nextDouble();
|
||||
|
||||
dbInfo.setUsed(random);
|
||||
|
||||
String tableName = dbInfo.getTableName();
|
||||
dbInfo.setIndexSize(indexSize.get(tableName));
|
||||
}
|
||||
|
@ -256,9 +256,15 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
return dbInfos;
|
||||
}
|
||||
|
||||
private List<DBInfo> dbInfoPG(String dataBase){
|
||||
|
||||
return null;
|
||||
private List<DBInfo> dbInfoPG(){
|
||||
List<DBInfo> dbInfos = baseMapper.dbInfoPG();
|
||||
Map<String, Integer> rowNum = baseMapper.dbRowNumPG().stream()
|
||||
.collect(Collectors.toMap(DBInfo::getTableName, DBInfo::getNumRow));
|
||||
for (DBInfo dbInfo : dbInfos) {
|
||||
String tableName = dbInfo.getTableName();
|
||||
dbInfo.setNumRow(rowNum.get(tableName));
|
||||
}
|
||||
return dbInfos;
|
||||
}
|
||||
|
||||
private List<DBInfo> dbInfoMY(String dataBase){
|
||||
|
|
|
@ -239,8 +239,8 @@ public class SpectrumAnalysesController {
|
|||
|
||||
@PostMapping("saveToTxt")
|
||||
public void saveToTxt(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody BgDataAnlyseResultIn anlyseResultIn){
|
||||
spectrumAnalysisService.saveToTxt(anlyseResultIn, request, response);
|
||||
@RequestBody RRRLogInfo rrrLogInfo){
|
||||
spectrumAnalysisService.saveToTxt(rrrLogInfo, request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,5 +84,5 @@ public interface ISpectrumAnalysisService {
|
|||
|
||||
void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response);
|
||||
void saveToTxt(RRRLogInfo rrrLogInfo, HttpServletRequest request, HttpServletResponse response);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
@ -3731,8 +3732,8 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
ExportUtil.exportXls(response, template, analyze, export);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
public void saveToTxtOld(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response) {
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 解析文件,生成导出数据
|
||||
Map<String, Object> analyze = exportData(anlyseResultIn, userName);
|
||||
|
@ -3820,6 +3821,30 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToTxt(RRRLogInfo rrrLogInfo, HttpServletRequest request, HttpServletResponse response) {
|
||||
String result = (String)viewRRR(rrrLogInfo, request).getResult();
|
||||
if (StrUtil.isBlank(result)) return;
|
||||
List<String> lines = ListUtil.toList(StrUtil.split(result, "\n"));
|
||||
PrintWriter writer = null;
|
||||
try{
|
||||
String export = "SaveToTxt.txt";
|
||||
String sampleFileName = rrrLogInfo.getSampleFileName();
|
||||
if (StrUtil.isNotBlank(sampleFileName)){
|
||||
if (StrUtil.contains(sampleFileName, ".PHD"))
|
||||
export = StrUtil.replace(sampleFileName, ".PHD", ".txt");
|
||||
}
|
||||
writer = ExportUtil.streamWriter(response, export);
|
||||
for (String newLine : lines) {
|
||||
writer.println(newLine);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if (ObjectUtil.isNotNull(writer)) writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> calibrations(GardsCalibrationSpectrum gammaCalibrationCE,GardsCalibrationSpectrum gammaCalibrationEC, GardsCalibrationSpectrum betaCalibrationCE, GardsCalibrationSpectrum betaCalibrationEC) {
|
||||
int min = 79;
|
||||
String space = StrUtil.SPACE;
|
||||
|
|
Loading…
Reference in New Issue
Block a user