文件查看
This commit is contained in:
parent
0b286a9af2
commit
cc8830a749
|
@ -0,0 +1,15 @@
|
||||||
|
package org.jeecg.modules.base.enums;
|
||||||
|
|
||||||
|
public enum PageType {
|
||||||
|
ARR("arr"), RRR("rrr");
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
PageType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,9 +6,11 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||||
public class TestDll {
|
public class TestDll {
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
|
String dllPath = "D:\\Work\\核素\\C++\\c++lib\\ReadPHDFile.dll";
|
||||||
|
String sourcePath = "D:\\Work\\核素\\C++\\谱文件样例\\Gamma\\CNP21_001-20170116_0245_S.PHD";
|
||||||
while (true){
|
while (true){
|
||||||
System.loadLibrary("ReadPHDFile");
|
System.load(dllPath);
|
||||||
final EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData("E:\\工作\\五木\\核素监测数据自动处理与交互分析系统\\rndata\\savefile\\Spectrum\\Xenon\\Sauna\\Samplephd\\2011\\06\\CNX22_001-20110601_2306_S_FULL_40146.PHD");
|
final EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sourcePath);
|
||||||
System.out.println(sourceData);
|
System.out.println(sourceData);
|
||||||
Thread.sleep(10000L);
|
Thread.sleep(10000L);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,9 @@ public class PHDFileUtil {
|
||||||
|
|
||||||
public static Map<String, Object> getSourceData(String filePath){
|
public static Map<String, Object> getSourceData(String filePath){
|
||||||
//加载dll工具库
|
//加载dll工具库
|
||||||
System.loadLibrary("ReadPHDFile");
|
/* System.loadLibrary("ReadPHDFile");*/
|
||||||
|
String dllPath = "D:\\Work\\C++\\c++lib\\ReadPHDFile.dll";
|
||||||
|
System.load(dllPath);
|
||||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(filePath);
|
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(filePath);
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
|
@ -114,8 +116,8 @@ public class PHDFileUtil {
|
||||||
//Gamma Spectrum Projected
|
//Gamma Spectrum Projected
|
||||||
List<Double> gCentroidChannel = struct.g_centroid_channel;
|
List<Double> gCentroidChannel = struct.g_centroid_channel;
|
||||||
List<Double> gEnergy = struct.g_energy;
|
List<Double> gEnergy = struct.g_energy;
|
||||||
List<Double> gammaProjectedData = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
|
/*List<Double> gammaProjectedData = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);*/
|
||||||
map.put("gammaProjectedData", gammaProjectedData);
|
map.put("gammaProjectedData", null);
|
||||||
|
|
||||||
//Beta Spectrum Original
|
//Beta Spectrum Original
|
||||||
List<Long> betaOriginalData = new LinkedList<>();
|
List<Long> betaOriginalData = new LinkedList<>();
|
||||||
|
@ -139,8 +141,8 @@ public class PHDFileUtil {
|
||||||
//Beta Spectrum Projected
|
//Beta Spectrum Projected
|
||||||
List<Double> bChannel = struct.b_channel;
|
List<Double> bChannel = struct.b_channel;
|
||||||
List<Double> bElectronEnergy = struct.b_electron_energy;
|
List<Double> bElectronEnergy = struct.b_electron_energy;
|
||||||
List<Double> betaProjectedData = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
|
/*List<Double> betaProjectedData = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);*/
|
||||||
map.put("betaProjectedData", betaProjectedData);
|
map.put("betaProjectedData", null);
|
||||||
|
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.jeecg.modules.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import com.google.common.io.Files;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.jeecg.common.api.QueryRequest;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.base.entity.GardsSampleData;
|
||||||
|
import org.jeecg.modules.service.IGammaService;
|
||||||
|
import org.jeecg.modules.service.ISpectrumAnalysisService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("gamma")
|
||||||
|
public class GammaController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IGammaService gammaService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISpectrumAnalysisService spectrumAnalysisService;
|
||||||
|
|
||||||
|
@GetMapping("gammaByFile")
|
||||||
|
public Result gammaByFile(@RequestParam Integer[] sampleId,
|
||||||
|
@RequestParam String dbName){
|
||||||
|
return spectrumAnalysisService.getDBSpectrumPie(dbName, sampleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String filePath = "C:\\Users/qiaoqinzheng/Desktop/核素/AUX09_003-20151224_1855_S_FULL_40184.5.PHD";
|
||||||
|
File file = new File(filePath);
|
||||||
|
System.out.println(file.getParent());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.jeecg.modules.service;
|
||||||
|
|
||||||
|
public interface IGammaService{
|
||||||
|
void gammaByFile(String path,String fileName);
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
|
import org.jeecg.modules.service.IGammaService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GammaServiceImpl implements IGammaService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gammaByFile(String path,String fileName) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,7 +33,6 @@ public class SysInfoJob implements Job {
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
RedisStreamUtil redisStreamUtil = SpringContextUtils.getBean(RedisStreamUtil.class);
|
RedisStreamUtil redisStreamUtil = SpringContextUtils.getBean(RedisStreamUtil.class);
|
||||||
|
|
||||||
/* 获取服务器信息并推送 */
|
/* 获取服务器信息并推送 */
|
||||||
log.info("监控的主机地址:{}",parameter);
|
log.info("监控的主机地址:{}",parameter);
|
||||||
WarnDto warnDto = new WarnDto();
|
WarnDto warnDto = new WarnDto();
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package org.jeecg.common.util;
|
package org.jeecg.common.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.net.ftp.FTP;
|
||||||
import org.apache.commons.net.ftp.FTPClient;
|
import org.apache.commons.net.ftp.FTPClient;
|
||||||
import org.apache.commons.net.ftp.FTPFile;
|
import org.apache.commons.net.ftp.FTPFile;
|
||||||
import org.jeecg.common.enums.SampleFileHeader;
|
import org.jeecg.common.enums.SampleFileHeader;
|
||||||
|
@ -12,9 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.File;
|
import javax.servlet.ServletOutputStream;
|
||||||
import java.io.IOException;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.InputStream;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -132,5 +135,99 @@ public class ReadLineUtil {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void readFile(String filePath, HttpServletResponse response){
|
||||||
|
InputStream inputStream = null;
|
||||||
|
OutputStream outputStream = null;
|
||||||
|
try {
|
||||||
|
String fileName = FileUtil.getName(filePath);
|
||||||
|
// 设置响应头
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||||
|
// 获取文件输入流
|
||||||
|
inputStream = new FileInputStream(filePath);
|
||||||
|
|
||||||
|
// 获取输出流
|
||||||
|
outputStream = response.getOutputStream();
|
||||||
|
|
||||||
|
// 缓冲区大小
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
|
||||||
|
// 将文件输出流写入到输出流中
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e){
|
||||||
|
log.error("Report文件["+filePath+"]不存在!");
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally {
|
||||||
|
// 关闭文件输入流和输出流
|
||||||
|
try {
|
||||||
|
if (ObjectUtil.isNotNull(inputStream))inputStream.close();
|
||||||
|
if (ObjectUtil.isNotNull(outputStream))outputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFtpFile(String filePath, HttpServletResponse response){
|
||||||
|
// 连接FTP
|
||||||
|
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||||
|
// 判断FTP是否连接成功
|
||||||
|
if (Objects.isNull(ftpClient)){
|
||||||
|
throw new RuntimeException("ftp连接失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1);
|
||||||
|
String parameterFilePath = filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH));
|
||||||
|
// 根据字符切割文件路径
|
||||||
|
List<String> paths = Arrays.asList(parameterFilePath.split(StringPool.SLASH));
|
||||||
|
OutputStream outputStream = null;
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
for (String path : paths) {
|
||||||
|
ftpClient.changeWorkingDirectory(path);
|
||||||
|
}
|
||||||
|
// 在当前工作路径下读取文件
|
||||||
|
ftpClient.enterLocalPassiveMode();
|
||||||
|
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
||||||
|
// 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项
|
||||||
|
ftpClient.setControlEncoding(encoding);
|
||||||
|
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||||
|
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
|
||||||
|
for (FTPFile ftpFile : ftpFiles) {
|
||||||
|
if (ftpFile.getName().equals(fileName)){
|
||||||
|
inputStream = ftpClient.retrieveFileStream(fileName);
|
||||||
|
outputStream = response.getOutputStream();
|
||||||
|
// 设置响应头
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||||
|
// 缓冲区大小
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
|
||||||
|
// 将文件输出流写入到输出流中
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if (ObjectUtil.isNotNull(inputStream))inputStream.close();
|
||||||
|
if (ObjectUtil.isNotNull(outputStream))outputStream.close();
|
||||||
|
ftpClient.disconnect();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,41 @@
|
||||||
package org.jeecg.modules.controller;
|
package org.jeecg.modules.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.jeecg.common.api.QueryRequest;
|
import org.jeecg.common.api.QueryRequest;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.util.ReadLineUtil;
|
||||||
|
import org.jeecg.modules.base.enums.PageType;
|
||||||
|
import org.jeecg.modules.entity.GardsAnalysesAuto;
|
||||||
|
import org.jeecg.modules.entity.GardsAnalysesMan;
|
||||||
import org.jeecg.modules.service.IAutoService;
|
import org.jeecg.modules.service.IAutoService;
|
||||||
|
import org.jeecg.modules.service.IManService;
|
||||||
import org.jeecg.modules.service.IReviewedService;
|
import org.jeecg.modules.service.IReviewedService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("radionuclide")
|
@RequestMapping("radionuclide")
|
||||||
public class RadionuclideController {
|
public class RadionuclideController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ReadLineUtil readLineUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IManService manService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAutoService autoService;
|
private IAutoService autoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IReviewedService reviewedService;
|
private IReviewedService reviewedService;
|
||||||
|
|
||||||
|
@ -36,5 +53,28 @@ public class RadionuclideController {
|
||||||
return reviewedService.findReviewedPage(queryRequest, stationIds, startTime, endTime);
|
return reviewedService.findReviewedPage(queryRequest, stationIds, startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("reportContent")
|
||||||
|
public void reportContent(@RequestParam String type,
|
||||||
|
@RequestParam Integer sampleId,
|
||||||
|
HttpServletResponse response){
|
||||||
|
String reportPath = "";
|
||||||
|
if (PageType.ARR.getType().equals(type)){ // 自动处理
|
||||||
|
LambdaQueryWrapper<GardsAnalysesAuto> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(GardsAnalysesAuto::getSampleId,sampleId);
|
||||||
|
GardsAnalysesAuto gardsAnalyses = autoService.getOne(wrapper);
|
||||||
|
reportPath = Optional.ofNullable(gardsAnalyses)
|
||||||
|
.orElse(new GardsAnalysesAuto())
|
||||||
|
.getReportPath();
|
||||||
|
}else if (PageType.RRR.getType().equals(type)){ // 人工交互
|
||||||
|
LambdaQueryWrapper<GardsAnalysesMan> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(GardsAnalysesMan::getSampleId,sampleId);
|
||||||
|
GardsAnalysesMan gardsAnalyses = manService.getOne(wrapper);
|
||||||
|
reportPath = Optional.ofNullable(gardsAnalyses)
|
||||||
|
.orElse(new GardsAnalysesMan())
|
||||||
|
.getReportPath();
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(reportPath))return;
|
||||||
|
// 将FTP上的文件转为文件流返回到前端
|
||||||
|
readLineUtil.readFtpFile(reportPath,response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.jeecg.modules.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.common.api.QueryRequest;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.entity.GardsAnalysesAuto;
|
||||||
|
import org.jeecg.modules.entity.GardsAnalysesMan;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public interface IManService extends IService<GardsAnalysesMan> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.jeecg.common.api.QueryRequest;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.entity.GardsAnalysesAuto;
|
||||||
|
import org.jeecg.modules.entity.GardsAnalysesMan;
|
||||||
|
import org.jeecg.modules.mapper.GardsAnalysesAutoMapper;
|
||||||
|
import org.jeecg.modules.mapper.GardsAnalysesManMapper;
|
||||||
|
import org.jeecg.modules.service.IAutoService;
|
||||||
|
import org.jeecg.modules.service.IGardsSampleDataWebService;
|
||||||
|
import org.jeecg.modules.service.IManService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service("manService")
|
||||||
|
@DS("ora")
|
||||||
|
public class ManServiceImpl extends ServiceImpl<GardsAnalysesManMapper, GardsAnalysesMan> implements IManService {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user