Merge remote-tracking branch 'origin/station' into station

This commit is contained in:
qiaoqinzheng 2023-07-13 10:06:02 +08:00
commit 2c7a47f4bb
10 changed files with 271 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -6,9 +6,11 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
public class TestDll {
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){
System.loadLibrary("ReadPHDFile");
final EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData("E:\\工作\\五木\\核素监测数据自动处理与交互分析系统\\rndata\\savefile\\Spectrum\\Xenon\\Sauna\\Samplephd\\2011\\06\\CNX22_001-20110601_2306_S_FULL_40146.PHD");
System.load(dllPath);
final EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sourcePath);
System.out.println(sourceData);
Thread.sleep(10000L);
}

View File

@ -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());
}
}

View File

@ -0,0 +1,5 @@
package org.jeecg.modules.service;
public interface IGammaService{
void gammaByFile(String path,String fileName);
}

View File

@ -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) {
}
}

View File

@ -33,7 +33,6 @@ public class SysInfoJob implements Job {
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
RedisStreamUtil redisStreamUtil = SpringContextUtils.getBean(RedisStreamUtil.class);
/* 获取服务器信息并推送 */
log.info("监控的主机地址:{}",parameter);
WarnDto warnDto = new WarnDto();

View File

@ -1,20 +1,25 @@
package org.jeecg.common.util;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import lombok.extern.slf4j.Slf4j;
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.FTPFile;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.enums.SampleFileHeader;
import org.jeecg.modules.entity.data.HistogramData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
@Component
@ -132,5 +137,105 @@ public class ReadLineUtil {
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("文件["+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连接失败!");
}
OutputStream outputStream = null;
InputStream inputStream = null;
try {
// 切换工作目录为 /
ftpClient.changeWorkingDirectory(SymbolConstant.SINGLE_SLASH);
// 判断FTP服务器上是否存在此文件
String[] files = ftpClient.listNames(filePath);
if (ArrayUtil.isEmpty(files)){
log.error("文件["+filePath+"]不存在!");
return;
}
// 存在多个文件名表示此路径为目录而非文件
if (ArrayUtil.length(files) > 1){
log.error("路径["+filePath+"]存在多个文件名,可能是一个目录!");
return;
}
// 获取文件名
String fileName = FileUtil.getName(filePath);
// 在当前工作路径下读取文件
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding(encoding);
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
inputStream = ftpClient.retrieveFileStream(filePath);
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();
}
}
}
}

View File

@ -1,24 +1,41 @@
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 org.jeecg.common.api.QueryRequest;
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.IManService;
import org.jeecg.modules.service.IReviewedService;
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 javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.Optional;
@RestController
@RequestMapping("radionuclide")
public class RadionuclideController {
@Autowired
private ReadLineUtil readLineUtil;
@Autowired
private IManService manService;
@Autowired
private IAutoService autoService;
@Autowired
private IReviewedService reviewedService;
@ -36,5 +53,28 @@ public class RadionuclideController {
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);
}
}

View File

@ -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> {
}

View File

@ -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 {
}