Merge remote-tracking branch 'origin/station' into station
This commit is contained in:
commit
3156a8e608
|
@ -4,6 +4,7 @@ import lombok.Data;
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
@ -64,4 +65,5 @@ public class TaskProperties implements Serializable {
|
|||
* 邮件附件临时存储路径
|
||||
*/
|
||||
private String temporaryStoragePath;
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,10 @@ public class AutoProcessManager{
|
|||
private final SpectrumServiceQuotes spectrumServiceQuotes;
|
||||
private final EmailCounter emailCounter;
|
||||
private Date systemStartupTime;
|
||||
|
||||
/**
|
||||
* FTP目录操作锁
|
||||
*/
|
||||
private Object ftpOpierationLock;
|
||||
/**
|
||||
* 邮件Map数据锁
|
||||
*/
|
||||
|
@ -50,8 +53,9 @@ public class AutoProcessManager{
|
|||
/**
|
||||
* 启动自动处理
|
||||
*/
|
||||
public void start(Date systemStartupTime) {
|
||||
public void start(Date systemStartupTime,Object ftpOpierationLock) {
|
||||
this.systemStartupTime = systemStartupTime;
|
||||
this.ftpOpierationLock = ftpOpierationLock;
|
||||
//邮件数据监测线程
|
||||
final MailDataMonitor mailDataMonitor = new MailDataMonitor();
|
||||
mailDataMonitor.setName("mail-data-monitor");
|
||||
|
@ -90,7 +94,7 @@ public class AutoProcessManager{
|
|||
}
|
||||
if(next.isNewEmailFlag()){
|
||||
EmailParsingActuator emailParsingActuator = new EmailParsingActuator();
|
||||
emailParsingActuator.init(next,spectrumServiceQuotes,emailCounter,systemStartupTime);
|
||||
emailParsingActuator.init(next,spectrumServiceQuotes,emailCounter,systemStartupTime,ftpOpierationLock);
|
||||
emailParsingActuator.setName(next.getUsername()+"-email-monitor");
|
||||
emailParsingActuator.start();
|
||||
//把邮件监测执行线程加入管理队列
|
||||
|
|
|
@ -24,13 +24,16 @@ public class EmailParsingActuator extends Thread{
|
|||
private SpectrumServiceQuotes spectrumServiceQuotes;
|
||||
private EmailCounter emailCounter;
|
||||
private Date systemStartupTime;
|
||||
private Object ftpOpierationLock;
|
||||
|
||||
public void init(EmailProperties emailProperties,SpectrumServiceQuotes spectrumServiceQuotes,EmailCounter emailCounter,Date systemStartupTime){
|
||||
public void init(EmailProperties emailProperties,SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
EmailCounter emailCounter,Date systemStartupTime,Object ftpOpierationLock){
|
||||
this.emailProperties = emailProperties;
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.taskProperties = spectrumServiceQuotes.getTaskProperties();
|
||||
this.emailCounter = emailCounter;
|
||||
this.systemStartupTime = systemStartupTime;
|
||||
this.ftpOpierationLock = ftpOpierationLock;
|
||||
|
||||
//获取机器可用核心数
|
||||
int systemCores = Runtime.getRuntime().availableProcessors();
|
||||
|
@ -54,7 +57,7 @@ public class EmailParsingActuator extends Thread{
|
|||
for(Message message : messages){
|
||||
SpectrumParsingActuator spectrumParsingActuator = new SpectrumParsingActuator();
|
||||
spectrumParsingActuator.init(message,emailProperties,emailServiceManager,
|
||||
taskLatch,spectrumServiceQuotes,emailCounter);
|
||||
taskLatch,spectrumServiceQuotes,emailCounter,ftpOpierationLock);
|
||||
poolExecutor.execute(spectrumParsingActuator);
|
||||
}
|
||||
taskLatch.await();
|
||||
|
|
|
@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.modules.ftp.FTPProperties;
|
||||
import org.jeecg.modules.ftp.FTPUtils;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
import org.jeecg.modules.spectrum.SamplephdSpectrum;
|
||||
import org.jeecg.modules.spectrum.SpectrumHandler;
|
||||
import org.jeecg.modules.spectrum.SpectrumServiceQuotes;
|
||||
|
@ -38,11 +39,16 @@ public class FileSourceHandleManager {
|
|||
* 相关Spring组件引用
|
||||
*/
|
||||
private final SpectrumServiceQuotes spectrumServiceQuotes;
|
||||
/**
|
||||
* FTP目录操作锁
|
||||
*/
|
||||
private Object ftpOpierationLock;
|
||||
|
||||
/**
|
||||
* 开始
|
||||
*/
|
||||
public void start(){
|
||||
public void start(Object ftpOpierationLock){
|
||||
this.ftpOpierationLock = ftpOpierationLock;
|
||||
ParseingFileSourceThreadManager fileSourceThreadManager = new ParseingFileSourceThreadManager();
|
||||
fileSourceThreadManager.init();
|
||||
fileSourceThreadManager.start();
|
||||
|
@ -79,13 +85,13 @@ public class FileSourceHandleManager {
|
|||
String filePath = spectrumServiceQuotes.getSpectrumPathProperties().getFilesourcePath();
|
||||
List<String> fileNames = ftpUtil.getFiles(filePath, taskProperties.getFilesourceDirReceiveNum().intValue());
|
||||
ftpUtil.close();
|
||||
//如果获取到的文件数量大于1,则进行排序保障Sample谱最后执行
|
||||
if(fileNames.size() > 1){
|
||||
fileNames = fileNames.stream().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList());
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(fileNames)){
|
||||
CountDownLatch taskLatch = new CountDownLatch(fileNames.size());
|
||||
for(String fileName : fileNames){
|
||||
//如果是Sample谱则延迟500毫秒后执行
|
||||
if(fileName.contains(BlockConstant.sampleFlag)){
|
||||
TimeUnit.MILLISECONDS.sleep(200);
|
||||
}
|
||||
ParseingFileSourceThread parseingFileSourceThread = new ParseingFileSourceThread();
|
||||
parseingFileSourceThread.init(fileName,filePath,taskLatch);
|
||||
poolExecutor.execute(parseingFileSourceThread);
|
||||
|
@ -145,7 +151,7 @@ public class FileSourceHandleManager {
|
|||
//初始化FTP客户端对象
|
||||
final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties();
|
||||
this.ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(),
|
||||
ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath());
|
||||
ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath(),ftpOpierationLock);
|
||||
//获取文件内容
|
||||
fileContent = this.ftpUtil.getFileContent(filePath, fileName);
|
||||
//解析文件
|
||||
|
@ -169,4 +175,25 @@ public class FileSourceHandleManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("AUX09_003-20150524_1855_S_FULL_40184.5.PHD");
|
||||
list.add("CNX22_001-20150126_0707_S_FULL_40204.PHD");
|
||||
list.add("JPX38_001-20150126_1541_S_FULL_40188.8.PHD");
|
||||
list.add("AUX09_003-20150527_0425_D_FULL_259450.PHD");
|
||||
list.add("AUX09_003-20151224_0655_G_FULL_40182.9.PHD");
|
||||
list.add("AUX09_003-20151224_1810_Q_FULL_2393.7.PHD");
|
||||
|
||||
List<String> newList = new ArrayList<>();
|
||||
for(String name : list){
|
||||
if(name.contains("_S_")){
|
||||
newList.add(name);
|
||||
}else {
|
||||
newList.add(0,name);
|
||||
}
|
||||
}
|
||||
list = newList;
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.modules.ftp.FTPProperties;
|
||||
import org.jeecg.modules.ftp.FTPUtils;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
import org.jeecg.modules.spectrum.SamplephdSpectrum;
|
||||
import org.jeecg.modules.spectrum.SpectrumHandler;
|
||||
import org.jeecg.modules.spectrum.SpectrumServiceQuotes;
|
||||
|
@ -12,6 +13,7 @@ import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
@ -23,7 +25,7 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class UndealHandleManager {
|
||||
public class UndealHandleManager{
|
||||
|
||||
/**
|
||||
* 任务属性
|
||||
|
@ -33,11 +35,16 @@ public class UndealHandleManager {
|
|||
* 相关Spring组件引用
|
||||
*/
|
||||
private final SpectrumServiceQuotes spectrumServiceQuotes;
|
||||
/**
|
||||
* FTP目录操作锁
|
||||
*/
|
||||
private Object ftpOpierationLock;
|
||||
|
||||
/**
|
||||
* 开始
|
||||
*/
|
||||
public void start(){
|
||||
public void start(Object ftpOpierationLock){
|
||||
this.ftpOpierationLock = ftpOpierationLock;
|
||||
ParseingFaliFileThreadManager faliFileThreadManager = new ParseingFaliFileThreadManager();
|
||||
faliFileThreadManager.init();
|
||||
faliFileThreadManager.start();
|
||||
|
@ -74,13 +81,13 @@ public class UndealHandleManager {
|
|||
String filePath = spectrumServiceQuotes.getSpectrumPathProperties().getFailPath();
|
||||
List<String> fileNames = ftpUtil.getFiles(filePath, taskProperties.getUndealDirReceiveNum().intValue());
|
||||
ftpUtil.close();
|
||||
//如果获取到的文件数量大于1,则进行排序保障Sample谱最后执行
|
||||
if(fileNames.size() > 1){
|
||||
fileNames = fileNames.stream().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList());
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(fileNames)){
|
||||
CountDownLatch taskLatch = new CountDownLatch(fileNames.size());
|
||||
for(String fileName : fileNames){
|
||||
//如果是Sample谱则延迟500毫秒后执行
|
||||
if(fileName.contains(BlockConstant.sampleFlag)){
|
||||
TimeUnit.MILLISECONDS.sleep(200);
|
||||
}
|
||||
ParseingFaliFileThread faliFileThread = new ParseingFaliFileThread();
|
||||
faliFileThread.init(fileName,filePath,taskLatch);
|
||||
poolExecutor.execute(faliFileThread);
|
||||
|
@ -137,7 +144,7 @@ public class UndealHandleManager {
|
|||
//初始化FTP客户端对象
|
||||
final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties();
|
||||
this.ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(),
|
||||
ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath());
|
||||
ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath(),ftpOpierationLock);
|
||||
//获取文件内容
|
||||
final String fileContent = this.ftpUtil.getFileContent(filePath, fileName);
|
||||
//解析文件
|
||||
|
|
|
@ -6,44 +6,74 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.net.ftp.*;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Slf4j
|
||||
public class FTPUtils {
|
||||
|
||||
private String host;
|
||||
private Integer port;
|
||||
private String userName;
|
||||
private String password;
|
||||
private String encoding;
|
||||
|
||||
private String ftpRootPath;
|
||||
|
||||
private FTPClient client;
|
||||
/**
|
||||
* FTP目录操作锁
|
||||
*/
|
||||
private Object ftpOpierationLock;
|
||||
|
||||
public FTPUtils(String host, Integer port, String userName, String password, String encoding,String ftpRootPath){
|
||||
public FTPUtils(String host, Integer port, String userName, String password,
|
||||
String encoding,String ftpRootPath,Object ftpOpierationLock){
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.userName = userName;
|
||||
this.password = password;
|
||||
this.encoding = encoding;
|
||||
this.ftpRootPath = ftpRootPath;
|
||||
this.ftpOpierationLock = ftpOpierationLock;
|
||||
|
||||
connect();
|
||||
}
|
||||
|
||||
public FTPUtils(String host, Integer port, String userName, String password,
|
||||
String encoding,String ftpRootPath){
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.userName = userName;
|
||||
this.password = password;
|
||||
this.encoding = encoding;
|
||||
this.ftpRootPath = ftpRootPath;
|
||||
this.ftpOpierationLock = new Object();
|
||||
connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接FTP服务
|
||||
*/
|
||||
private void connect(){
|
||||
try{
|
||||
//声明FTP客户端
|
||||
client = new FTPClient();
|
||||
this.client = new FTPClient();
|
||||
//连接
|
||||
client.connect(host, port);
|
||||
this.client.connect(host, port);
|
||||
//登录
|
||||
client.login(userName, password);
|
||||
this.client.login(userName, password);
|
||||
// 切换为本地被动模式,可以解决FTP上传后文件为空的问题,但需要服务器将FTP服务添加至防火墙白名单
|
||||
client.enterLocalPassiveMode();
|
||||
this.client.enterLocalPassiveMode();
|
||||
//设置文件client参数
|
||||
this.client.setFileType(FTPClient.BINARY_FILE_TYPE);
|
||||
this.client.setControlEncoding(this.encoding);
|
||||
this.client.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
// this.client.setDataTimeout(60000);
|
||||
// this.client.setConnectTimeout();
|
||||
//判断是否连接成功
|
||||
int reply = client.getReplyCode();
|
||||
int reply = this.client.getReplyCode();
|
||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||
client.disconnect();
|
||||
this.client.disconnect();
|
||||
}
|
||||
}catch (IOException e){
|
||||
log.error("FTP服务连接失败,原因:{}",e.getMessage());
|
||||
|
@ -59,30 +89,32 @@ public class FTPUtils {
|
|||
* @throws IOException
|
||||
*/
|
||||
public boolean downloadFTPFile(String ftpFilePath,String fileName,String localPath) throws IOException {
|
||||
this.checkDirectory(ftpFilePath);
|
||||
InputStream inputStream = null;
|
||||
try{
|
||||
final String formatFileName = new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
|
||||
final FTPFile[] ftpFiles = this.client.listFiles(formatFileName);
|
||||
if(ArrayUtils.isNotEmpty(ftpFiles)){
|
||||
inputStream = this.client.retrieveFileStream(formatFileName);
|
||||
if(Objects.nonNull(inputStream)){
|
||||
FileUtil.writeFromStream(inputStream,localPath+File.separator+fileName);
|
||||
return true;
|
||||
synchronized (ftpOpierationLock){
|
||||
this.checkDirectory(ftpFilePath);
|
||||
InputStream inputStream = null;
|
||||
try{
|
||||
final String formatFileName = new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
|
||||
final FTPFile[] ftpFiles = this.client.listFiles(formatFileName);
|
||||
if(ArrayUtils.isNotEmpty(ftpFiles)){
|
||||
inputStream = this.client.retrieveFileStream(formatFileName);
|
||||
if(Objects.nonNull(inputStream)){
|
||||
FileUtil.writeFromStream(inputStream,localPath+File.separator+fileName);
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
log.warn("{}不存在",fileName);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}finally {
|
||||
if(Objects.nonNull(inputStream)){
|
||||
inputStream.close();
|
||||
this.client.completePendingCommand();
|
||||
}
|
||||
}else {
|
||||
log.warn("{}不存在",fileName);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}finally {
|
||||
if(Objects.nonNull(inputStream)){
|
||||
inputStream.close();
|
||||
this.client.completePendingCommand();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,7 +124,7 @@ public class FTPUtils {
|
|||
*/
|
||||
private boolean checkDirectory(String path){
|
||||
try{
|
||||
final boolean changeFlag = client.changeWorkingDirectory(ftpRootPath);
|
||||
final boolean changeFlag = this.client.changeWorkingDirectory(ftpRootPath);
|
||||
if(!changeFlag){
|
||||
log.error("{},根目录切换失败",ftpRootPath);
|
||||
return false;
|
||||
|
@ -102,12 +134,12 @@ public class FTPUtils {
|
|||
if(StringUtils.isEmpty(directory)){
|
||||
continue;
|
||||
}
|
||||
if(!client.changeWorkingDirectory(directory)){
|
||||
if(!client.makeDirectory(directory)){
|
||||
if(!this.client.changeWorkingDirectory(directory)){
|
||||
if(!this.client.makeDirectory(directory)){
|
||||
log.error("{},目录创建失败",directory);
|
||||
return false;
|
||||
}
|
||||
if(!client.changeWorkingDirectory(directory)){
|
||||
if(!this.client.changeWorkingDirectory(directory)){
|
||||
log.error("{},目录切换失败",directory);
|
||||
return false;
|
||||
}
|
||||
|
@ -129,28 +161,30 @@ public class FTPUtils {
|
|||
* @return 返回值true/false
|
||||
*/
|
||||
public boolean saveFile(String filePath,String fileName,InputStream inputStream){
|
||||
try{
|
||||
final boolean flag = this.checkDirectory(filePath);
|
||||
if(flag){
|
||||
final FTPFile[] ftpFiles = this.client.listFiles(fileName);
|
||||
if(ArrayUtils.isEmpty(ftpFiles)){
|
||||
return client.storeFile(fileName, inputStream);
|
||||
synchronized (ftpOpierationLock){
|
||||
try{
|
||||
final boolean flag = this.checkDirectory(filePath);
|
||||
if(flag){
|
||||
final FTPFile[] ftpFiles = this.client.listFiles(fileName);
|
||||
if(ArrayUtils.isEmpty(ftpFiles)){
|
||||
return this.client.storeFile(fileName, inputStream);
|
||||
}
|
||||
}
|
||||
}catch (IOException e){
|
||||
log.error("{}文件创建失败,原因为:{}",filePath+"/"+fileName,e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}finally {
|
||||
if(null != inputStream){
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (IOException e){
|
||||
log.error("{}文件创建失败,原因为:{}",filePath+"/"+fileName,e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}finally {
|
||||
if(null != inputStream){
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,50 +195,62 @@ public class FTPUtils {
|
|||
* @return 返回值true/false
|
||||
*/
|
||||
public boolean saveOrAppendFile(String filePath,String fileName,InputStream inputStream){
|
||||
try{
|
||||
final boolean flag = this.checkDirectory(filePath);
|
||||
if(flag){
|
||||
final FTPFile[] ftpFiles = this.client.listFiles(fileName);
|
||||
if(ArrayUtils.isEmpty(ftpFiles)){
|
||||
return client.storeFile(fileName, inputStream);
|
||||
}else{
|
||||
return client.appendFile(fileName,inputStream);
|
||||
synchronized (ftpOpierationLock){
|
||||
try{
|
||||
final boolean flag = this.checkDirectory(filePath);
|
||||
if(flag){
|
||||
final FTPFile[] ftpFiles = this.client.listFiles(fileName);
|
||||
if(ArrayUtils.isEmpty(ftpFiles)){
|
||||
return this.client.storeFile(fileName, inputStream);
|
||||
}else{
|
||||
return this.client.appendFile(fileName,inputStream);
|
||||
}
|
||||
}
|
||||
}catch (IOException e){
|
||||
log.error("{}文件创建失败,原因为:{}",filePath+"/"+fileName,e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}finally {
|
||||
if(null != inputStream){
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (IOException e){
|
||||
log.error("{}文件创建失败,原因为:{}",filePath+"/"+fileName,e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}finally {
|
||||
if(null != inputStream){
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定路径下获取指定数量的文件名称列表
|
||||
* 在指定路径下获取指定数量的文件名称列表,若有Sample谱则排在最后
|
||||
* @param filePath
|
||||
* @param getNum
|
||||
* @return
|
||||
*/
|
||||
public List<String> getFiles(String filePath,int getNum) throws IOException {
|
||||
final boolean flag = this.checkDirectory(filePath);
|
||||
if(flag){
|
||||
final FTPFile[] ftpFiles = this.client.listFiles();
|
||||
if(ArrayUtils.isNotEmpty(ftpFiles)){
|
||||
//最终实际获取数量
|
||||
int num = getNum > ftpFiles.length?ftpFiles.length:getNum;
|
||||
final List<String> fileNames = Arrays.stream(ftpFiles).sorted(Comparator.comparing(FTPFile::getTimestamp)).map(f->f.getName()).limit(num).collect(Collectors.toList());
|
||||
return fileNames;
|
||||
synchronized (ftpOpierationLock){
|
||||
final boolean flag = this.checkDirectory(filePath);
|
||||
if(flag){
|
||||
final FTPFile[] ftpFiles = this.client.listFiles();
|
||||
if(ArrayUtils.isNotEmpty(ftpFiles)){
|
||||
List<String> sortList = new ArrayList<>();
|
||||
for (FTPFile file : ftpFiles){
|
||||
if(file.getName().contains(BlockConstant.sampleFlag)){
|
||||
sortList.add(file.getName());
|
||||
}else {
|
||||
sortList.add(0,file.getName());
|
||||
}
|
||||
}
|
||||
//最终实际获取数量
|
||||
int num = getNum > sortList.size()?sortList.size():getNum;
|
||||
|
||||
return sortList.stream().limit(num).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,37 +261,33 @@ public class FTPUtils {
|
|||
* @throws IOException
|
||||
*/
|
||||
public String getFileContent(String filePath,String fileName) throws IOException {
|
||||
this.checkDirectory(filePath);
|
||||
final FTPFile[] ftpFiles = this.client.listFiles(fileName);
|
||||
if(ArrayUtils.isNotEmpty(ftpFiles)){
|
||||
InputStream inputStream = this.client.retrieveFileStream(fileName);
|
||||
if(Objects.nonNull(inputStream)){
|
||||
try(BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"))){
|
||||
StringBuilder fileContent = new StringBuilder();
|
||||
String lineContent;
|
||||
while ((lineContent = reader.readLine()) != null){
|
||||
fileContent.append(lineContent);
|
||||
fileContent.append(System.lineSeparator());
|
||||
}
|
||||
return fileContent.toString();
|
||||
}finally {
|
||||
if(Objects.nonNull(inputStream)){
|
||||
inputStream.close();
|
||||
// 完成文件传输命令
|
||||
this.client.completePendingCommand();
|
||||
synchronized (ftpOpierationLock){
|
||||
this.checkDirectory(filePath);
|
||||
final FTPFile[] ftpFiles = this.client.listFiles(fileName);
|
||||
if(ArrayUtils.isNotEmpty(ftpFiles)){
|
||||
InputStream inputStream = this.client.retrieveFileStream(fileName);
|
||||
if(Objects.nonNull(inputStream)){
|
||||
try(BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"))){
|
||||
StringBuilder fileContent = new StringBuilder();
|
||||
String lineContent;
|
||||
while ((lineContent = reader.readLine()) != null){
|
||||
fileContent.append(lineContent);
|
||||
fileContent.append(System.lineSeparator());
|
||||
}
|
||||
return fileContent.toString();
|
||||
}finally {
|
||||
if(Objects.nonNull(inputStream)){
|
||||
inputStream.close();
|
||||
// 完成文件传输命令
|
||||
this.client.completePendingCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Strings.EMPTY;
|
||||
}
|
||||
return Strings.EMPTY;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws IOException {
|
||||
// FTPUtils ftp = new FTPUtils("192.168.17.168",21,"ubuntu","123456","utf-8","/home/ubuntu/ftp");
|
||||
// final String fileContent = ftp.getFileContent("/undeal", "CNX22_004-20230731_1436_S_PREL_21593.8.PHD");
|
||||
// System.out.println(fileContent);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param filePath 文件路径
|
||||
|
@ -253,31 +295,33 @@ public class FTPUtils {
|
|||
* @return 返回值true/false
|
||||
*/
|
||||
public boolean removeFile(String filePath,String fileName){
|
||||
try {
|
||||
final boolean changeFlag = client.changeWorkingDirectory(ftpRootPath);
|
||||
if(!changeFlag){
|
||||
log.error("{},根目录切换失败",ftpRootPath);
|
||||
return false;
|
||||
}
|
||||
String[] directories = filePath.split("/");
|
||||
for(String directory : directories){
|
||||
if(StringUtils.isEmpty(directory)){
|
||||
continue;
|
||||
}
|
||||
if(!client.changeWorkingDirectory(directory)){
|
||||
log.error("此文件目录不存在:{}",filePath);
|
||||
synchronized (ftpOpierationLock){
|
||||
try {
|
||||
final boolean changeFlag = this.client.changeWorkingDirectory(ftpRootPath);
|
||||
if(!changeFlag){
|
||||
log.error("{},根目录切换失败",ftpRootPath);
|
||||
return false;
|
||||
}
|
||||
String[] directories = filePath.split("/");
|
||||
for(String directory : directories){
|
||||
if(StringUtils.isEmpty(directory)){
|
||||
continue;
|
||||
}
|
||||
if(!this.client.changeWorkingDirectory(directory)){
|
||||
log.error("此文件目录不存在:{}",filePath);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean result = this.client.deleteFile(new String(fileName.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1));
|
||||
if(!result){
|
||||
log.error("此文件不存在:{}",filePath+"/"+fileName);
|
||||
}
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
log.error("{}文件删除失败,原因为:{}",filePath,e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
boolean result = client.deleteFile(new String(fileName.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1));
|
||||
if(!result){
|
||||
log.error("此文件不存在:{}",filePath+"/"+fileName);
|
||||
}
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
log.error("{}文件删除失败,原因为:{}",filePath,e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +331,7 @@ public class FTPUtils {
|
|||
*/
|
||||
public String getRootPath(){
|
||||
try {
|
||||
final String rootPath = client.printWorkingDirectory();
|
||||
final String rootPath = this.client.printWorkingDirectory();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -300,9 +344,8 @@ public class FTPUtils {
|
|||
*/
|
||||
public void close(){
|
||||
try{
|
||||
if (client != null){
|
||||
// client.logout();
|
||||
client.disconnect();
|
||||
if (this.client != null){
|
||||
this.client.disconnect();
|
||||
}
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -24,5 +24,10 @@ public interface BlockConstant {
|
|||
String unit_kev = " keV";
|
||||
String unit_mbq = " mBq/m3";
|
||||
|
||||
/**
|
||||
* Sample谱文件名称标记
|
||||
*/
|
||||
String sampleFlag = "_S_";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import org.jeecg.modules.base.abstracts.AbstractLogOrReport;
|
||||
import org.jeecg.modules.base.enums.FittingEquation;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractLogOrReport {
|
||||
public abstract class AbstractAutoLogOrReport extends AbstractLogOrReport implements BlockConstant {
|
||||
|
||||
/**
|
||||
* 获取sample、gas、det谱Beta和Gamma的CH(x)、E(x)
|
|
@ -13,6 +13,7 @@ import org.jeecg.modules.native_jni.struct.AlertSpectrumStruct;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
@ -92,7 +93,7 @@ public class AlertSpectrum extends SpectrumHandler{
|
|||
* 保存能谱文件到ftp
|
||||
*/
|
||||
@Override
|
||||
protected void saveFileToFtp() throws Exception {
|
||||
protected void saveFileToFtp() throws FileNotFoundException {
|
||||
this.updateSpectrumFileName();
|
||||
//获取文件保存路径
|
||||
String fileSavePath = this.getFileSavePath();
|
||||
|
|
|
@ -47,6 +47,7 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
//修改状态为解析失败
|
||||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
|
|
@ -48,6 +48,7 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
//修改状态为解析失败
|
||||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.springframework.util.CollectionUtils;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
@ -94,7 +95,7 @@ public class HealthStatusSpectrum extends SpectrumHandler{
|
|||
* 保存能谱文件到ftp
|
||||
*/
|
||||
@Override
|
||||
protected void saveFileToFtp() throws Exception {
|
||||
protected void saveFileToFtp() throws FileNotFoundException {
|
||||
this.updateSpectrumFileName();
|
||||
//获取文件保存路径
|
||||
String fileSavePath = this.getFileSavePath();
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.util.CollectionUtils;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
@ -90,7 +91,7 @@ public class MetSpectrum extends SpectrumHandler{
|
|||
* 保存能谱文件到ftp
|
||||
*/
|
||||
@Override
|
||||
protected void saveFileToFtp() throws Exception {
|
||||
protected void saveFileToFtp() throws FileNotFoundException {
|
||||
this.updateSpectrumFileName();
|
||||
//获取文件保存路径
|
||||
String fileSavePath = this.getFileSavePath();
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* B谱邮件解析流程日志
|
||||
*/
|
||||
public class ParsingProcessLog {
|
||||
public class ParsingProcessLog extends AbstractAutoLogOrReport{
|
||||
|
||||
/**
|
||||
* 存储日志内容
|
||||
|
@ -143,7 +143,7 @@ public class ParsingProcessLog {
|
|||
/**
|
||||
* 分析过程日志
|
||||
*/
|
||||
private class AnalyseProcessLog extends AbstractLogOrReport implements BlockConstant {
|
||||
private class AnalyseProcessLog{
|
||||
|
||||
/**
|
||||
* 开始处理分析过程日志
|
||||
|
@ -475,14 +475,14 @@ public class ParsingProcessLog {
|
|||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Beta:");
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c)));
|
||||
analysisLog.append(rowFormat(ch,calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)));
|
||||
analysisLog.append(rowFormat(ex,calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Gamma:");
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c)));
|
||||
analysisLog.append(rowFormat(ch,calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)));
|
||||
analysisLog.append(rowFormat(ex,calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(endTitle,22,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
@ -530,14 +530,14 @@ public class ParsingProcessLog {
|
|||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Beta:");
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c)));
|
||||
analysisLog.append(rowFormat(ch,calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)));
|
||||
analysisLog.append(rowFormat(ex,calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Gamma:");
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c)));
|
||||
analysisLog.append(rowFormat(ch,calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)));
|
||||
analysisLog.append(rowFormat(ex,calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(endTitle,22,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
@ -585,14 +585,14 @@ public class ParsingProcessLog {
|
|||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Beta:");
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c)));
|
||||
analysisLog.append(rowFormat(ch,calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)));
|
||||
analysisLog.append(rowFormat(ex,calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Gamma:");
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c)));
|
||||
analysisLog.append(rowFormat(ch,calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)));
|
||||
analysisLog.append(rowFormat(ex,calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(endTitle,22,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
@ -634,9 +634,9 @@ public class ParsingProcessLog {
|
|||
final String format = "ROI : %-6s Sample : %-14s GasBkgnd : %-14s DetBkgnd : %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
@ -661,13 +661,13 @@ public class ParsingProcessLog {
|
|||
List<String> roi = analyseResult.ROI.stream().map(String::valueOf).collect(Collectors.toList());
|
||||
//此参数需第一位补0
|
||||
analyseResult.LC_CTS.add(0,0D);
|
||||
List<String> lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> lc = analyseResult.LC_CTS.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
for(int i=0;i<roi.size();i++){
|
||||
String netCountStr = super.formatToStr5(roi_net_count.get(i)) + arithmetic_flag + super.formatToStr5(roi_net_count_err.get(i));
|
||||
String netCountStr = formatToStr5(roi_net_count.get(i)) + arithmetic_flag + formatToStr5(roi_net_count_err.get(i));
|
||||
analysisLog.append(rowFormat(format,roi.get(i),netCountStr,lc.get(i)));
|
||||
if(i<roi.size()-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
@ -683,13 +683,13 @@ public class ParsingProcessLog {
|
|||
final String title = "Concentration and MDC per ROI.....";
|
||||
final String format = "ROI : %-6s Conc : %-31s LC : %-19s MDC : %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
List<String> con = analyseResult.ROI_con_uncer.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> conErr = analyseResult.ROI_con_uncer_err.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> con = analyseResult.ROI_con_uncer.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> conErr = analyseResult.ROI_con_uncer_err.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
analyseResult.LC.add(0,0.0D);
|
||||
analyseResult.MDC.add(0,0.0D);
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> lc = analyseResult.LC.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> mdc = analyseResult.MDC.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
@ -713,14 +713,14 @@ public class ParsingProcessLog {
|
|||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
|
||||
String[] nuclideName = {XE_135,XE_131m,XE_133m,XE_133};
|
||||
String[] conc = {super.formatToStr5(analyseResult.Xe135_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe135_uncer) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.Xe131m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe131m_uncer) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.Xe133m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133m_uncer) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.Xe133_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133_uncer) + unit_mbq};
|
||||
String[] uncertainty = {super.formatToStr5(analyseResult.LC_Xe135) + unit_mbq,super.formatToStr5(analyseResult.LC_Xe131m) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.LC_Xe133m) + unit_mbq,super.formatToStr5(analyseResult.LC_Xe133) + unit_mbq};
|
||||
String[] mdc = {super.formatToStr5(analyseResult.MDC_Xe135) + unit_mbq,super.formatToStr5(analyseResult.MDC_Xe131m) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.MDC_Xe133m) + unit_mbq,super.formatToStr5(analyseResult.MDC_Xe133) + unit_mbq};
|
||||
String[] conc = {formatToStr5(analyseResult.Xe135_con) + arithmetic_flag + formatToStr5(analyseResult.Xe135_uncer) + unit_mbq,
|
||||
formatToStr5(analyseResult.Xe131m_con) + arithmetic_flag + formatToStr5(analyseResult.Xe131m_uncer) + unit_mbq,
|
||||
formatToStr5(analyseResult.Xe133m_con) + arithmetic_flag + formatToStr5(analyseResult.Xe133m_uncer) + unit_mbq,
|
||||
formatToStr5(analyseResult.Xe133_con) + arithmetic_flag + formatToStr5(analyseResult.Xe133_uncer) + unit_mbq};
|
||||
String[] uncertainty = {formatToStr5(analyseResult.LC_Xe135) + unit_mbq,formatToStr5(analyseResult.LC_Xe131m) + unit_mbq,
|
||||
formatToStr5(analyseResult.LC_Xe133m) + unit_mbq,formatToStr5(analyseResult.LC_Xe133) + unit_mbq};
|
||||
String[] mdc = {formatToStr5(analyseResult.MDC_Xe135) + unit_mbq,formatToStr5(analyseResult.MDC_Xe131m) + unit_mbq,
|
||||
formatToStr5(analyseResult.MDC_Xe133m) + unit_mbq,formatToStr5(analyseResult.MDC_Xe133) + unit_mbq};
|
||||
String xe_135_nid_flag = analyseResult.Xe135_con>analyseResult.MDC_Xe135?"1":"0";
|
||||
String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0";
|
||||
String xe_133m_nid_flag = analyseResult.Xe133m_con>analyseResult.MDC_Xe133m?"1":"0";
|
||||
|
@ -786,39 +786,4 @@ public class ParsingProcessLog {
|
|||
|
||||
spectrumHandler.ftpUtil.saveOrAppendFile(logFilePath,logFileName,new ByteArrayInputStream(log.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 行日志格式化
|
||||
* @param source 需要格式化的字符串
|
||||
* @param symbolNum 格式化的符号数量
|
||||
* @param args 格式化替换参数数组
|
||||
* @return
|
||||
*/
|
||||
private String titleFormat(String source, Integer symbolNum, String... args){
|
||||
StringBuilder firstParam = new StringBuilder();
|
||||
for (int i=0;i<symbolNum;i++){
|
||||
firstParam.append(args[0]);
|
||||
}
|
||||
args[0] = firstParam.toString();
|
||||
|
||||
StringBuilder lastParam = new StringBuilder();
|
||||
for (int i=0;i<symbolNum;i++){
|
||||
lastParam.append(args[args.length-1]);
|
||||
}
|
||||
args[args.length-1] = lastParam.toString();
|
||||
|
||||
return String.format(source,args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 行格式化
|
||||
* @param source
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
private String rowFormat(String source, String... args){
|
||||
return String.format(source,args);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
//修改状态为解析失败
|
||||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.spectrum;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
|
@ -103,7 +104,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
* 保存能谱文件到ftp
|
||||
*/
|
||||
@Override
|
||||
protected void saveFileToFtp() throws Exception {
|
||||
protected void saveFileToFtp() throws FileNotFoundException {
|
||||
//修改能谱文件名称
|
||||
this.updateSpectrumFileName();
|
||||
//获取文件保存路径
|
||||
|
@ -140,7 +141,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
* 对本地能谱临时文件进行改名
|
||||
*/
|
||||
@Override
|
||||
protected void updateSpectrumFileName() {
|
||||
protected void updateSpectrumFileName() throws FileNotFoundException {
|
||||
StringBuilder newFileName = new StringBuilder();
|
||||
newFileName.append(this.sourceData.detector_code);
|
||||
newFileName.append(StringConstant.DASH);
|
||||
|
@ -154,7 +155,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
newFileName.append(StringConstant.UNDER_LINE);
|
||||
newFileName.append(handleLiveTime());
|
||||
newFileName.append(super.currDataType.getSuffix());
|
||||
mailFile = FileUtil.rename(mailFile,newFileName.toString(),true);
|
||||
if(!mailFile.exists()){
|
||||
throw new FileNotFoundException(mailFile.getAbsolutePath()+"文件不存在");
|
||||
}
|
||||
mailFile = FileUtil.rename(mailFile, newFileName.toString(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
|
@ -21,10 +18,9 @@ import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
|||
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
|
||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
@ -250,6 +246,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
flag = true;
|
||||
}
|
||||
gasTempFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+File.separator+gasFileName;
|
||||
File gasFile = new File(gasTempFilePath);
|
||||
if(!gasFile.exists()){
|
||||
flag = true;
|
||||
}
|
||||
|
||||
//下载det谱PHD文件到本地临时路径
|
||||
final String detFileName = detSampleData.getInputFileName().substring(detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1);
|
||||
|
@ -259,6 +259,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
flag = true;
|
||||
}
|
||||
detTempFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+ File.separator+detFileName;
|
||||
File detFile = new File(detTempFilePath);
|
||||
if(!detFile.exists()){
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if(flag){
|
||||
parsingProcessLog.setFileNotExist(true);
|
||||
|
@ -368,27 +372,18 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
/**
|
||||
* B谱分析报告
|
||||
*/
|
||||
private class B_AnalysisReport extends AbstractLogOrReport{
|
||||
private class B_AnalysisReport extends AbstractAutoLogOrReport{
|
||||
/**
|
||||
* 模版内容
|
||||
*/
|
||||
private String templateContent;
|
||||
/**
|
||||
* 报告临时文件
|
||||
*/
|
||||
private File reportTmpFile;
|
||||
private StringBuilder reportContent = new StringBuilder();
|
||||
|
||||
/**
|
||||
* 开始处理报告内容
|
||||
*/
|
||||
public void start() throws IOException {
|
||||
//获取报告内容
|
||||
this.getTemplateContent();
|
||||
|
||||
//创建报告临时文件
|
||||
this.createTmpReportFile();
|
||||
//处理报告时间
|
||||
this.handleReportCreateDate();
|
||||
//处理报告头
|
||||
this.handleReportHeader();
|
||||
//处理#FILE INFORMATION 模块
|
||||
this.handleFileInfoMation();
|
||||
//处理#COLLECTION INFORMATION 模块
|
||||
|
@ -397,10 +392,6 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
this.handleAcquistionInfoMation();
|
||||
//处理#SOFTWARE 模块
|
||||
this.handleSoftware();
|
||||
//处理Sample谱、Gas谱、Det谱sampleId
|
||||
this.handleSampleId();
|
||||
//把已经替换好的字符写入文件
|
||||
this.reportTmpFile = FileUtil.writeString(this.templateContent,this.reportTmpFile,"utf-8");
|
||||
//处理#SAMPLE CALIBRATION 模块
|
||||
this.handleSampleCalibration();
|
||||
//处理#SAMPLE LIMITS PER ROI 模块
|
||||
|
@ -426,370 +417,404 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取报告内容
|
||||
* @throws IOException
|
||||
* 处理报告头
|
||||
*/
|
||||
private void getTemplateContent() throws IOException {
|
||||
Resource resource = new ClassPathResource("template/b_report_template.txt");
|
||||
this.templateContent = FileUtil.readUtf8String(resource.getFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建报告临时文件
|
||||
* @throws IOException
|
||||
*/
|
||||
private void createTmpReportFile() throws IOException {
|
||||
String reportTmpFilePath = spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+ File.separator+arrFileName;
|
||||
this.reportTmpFile = new File(reportTmpFilePath);
|
||||
if(!this.reportTmpFile.exists()){
|
||||
this.reportTmpFile.createNewFile();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理报告时间
|
||||
*/
|
||||
private void handleReportCreateDate(){
|
||||
private void handleReportHeader(){
|
||||
String header_1 = "%-64s CNL06 GENERATED REPORT";
|
||||
String header_2 = "%-63s AUTO RADIONUCLIDE REPORT";
|
||||
String header_3 = "%-65s (Noble Gas Version) ";
|
||||
String createDateLine = "%-58s Creation Date %s";
|
||||
final String createDate = DateUtils.formatDate(new Date(), "yyyy/MM/dd-HH:mm:ss");
|
||||
this.templateContent = this.templateContent.replace("${create_date}",createDate);
|
||||
reportContent.append(super.rowFormat(header_1,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(header_2,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(header_3,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(createDateLine,StringConstant.SPACE,createDate));
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#FILE INFORMATION 模块
|
||||
*/
|
||||
private void handleFileInfoMation(){
|
||||
this.templateContent = this.templateContent.replace("${SampleMeasID}",sampleStruct.measurement_id);
|
||||
this.templateContent = this.templateContent.replace("${GASBKMeasID}",sampleStruct.gas_bk_measurement_id);
|
||||
this.templateContent = this.templateContent.replace("${DETBKMeasID}",sampleStruct.detector_bk_measurement_id);
|
||||
this.templateContent = this.templateContent.replace("${SRID}",sampleStruct.sample_ref_id);
|
||||
this.templateContent = this.templateContent.replace("${DetectorType}","3D b-g");
|
||||
String fileBlock = "#FILE INFORMATION";
|
||||
String sampleMeasId = " SampleMeasID:%-36s %s";
|
||||
String gasMeasId = " GASBKMeasID:%-37s %s";
|
||||
String detMeasId = " DETBKMeasID:%-37s %s";
|
||||
String srId = " SRID:%-44s %s";
|
||||
String detectorType = " Detector Type:%-35s %s";
|
||||
reportContent.append(fileBlock);
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(sampleMeasId,StringConstant.SPACE,sampleStruct.measurement_id));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(gasMeasId,StringConstant.SPACE,sampleStruct.gas_bk_measurement_id));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(detMeasId,StringConstant.SPACE,sampleStruct.detector_bk_measurement_id));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(srId,StringConstant.SPACE,sampleStruct.sample_ref_id));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(detectorType,StringConstant.SPACE,"3D b-g"));
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#COLLECTION INFORMATION 模块
|
||||
*/
|
||||
private void handleCollectionInfoMation(){
|
||||
this.templateContent = this.templateContent.replace("${StationID}",sampleStruct.site_code);
|
||||
this.templateContent = this.templateContent.replace("${DetectorID}",sampleStruct.detector_code);
|
||||
this.templateContent = this.templateContent.replace("${CollectionStart}",sampleStruct.collection_start_date+StringConstant.SPACE+sampleStruct.collection_start_time);
|
||||
this.templateContent = this.templateContent.replace("${CollectionStop}",sampleStruct.collection_stop_date+StringConstant.SPACE+sampleStruct.collection_stop_time);
|
||||
this.templateContent = this.templateContent.replace("${CollectionTIME}",String.valueOf((sampleData.getCollectStart().getTime()-sampleData.getCollectStop().getTime())/1000));
|
||||
this.templateContent = this.templateContent.replace("${AirVolume}",String.valueOf(sampleStruct.air_volume));
|
||||
this.templateContent = this.templateContent.replace("${XeVolume}",String.valueOf(sampleStruct.sample_volume_of_Xe));
|
||||
String collectionInfoBlock = "#COLLECTION INFORMATION";
|
||||
String stationId = " Station ID:%-38s %s";
|
||||
String detectorId = " Detector ID:%-37s %s";
|
||||
String sampleId = " Sample ID:%-39s %s";
|
||||
String collectionStart = " Collection Start:%-32s %s";
|
||||
String collectionStop = " Collection Stop:%-33s %s";
|
||||
String collectionTime = " Collection TIME(h):%-30s %s";
|
||||
String airVolume = " Air Volume[cm3]:%-33s %s";
|
||||
String xeVolume = " Xe Volume[cm3]:%-34s %s";
|
||||
reportContent.append(collectionInfoBlock);
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(stationId,StringConstant.SPACE,sampleStruct.site_code));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(detectorId,StringConstant.SPACE,sampleStruct.detector_code));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(sampleId,StringConstant.SPACE,sampleData.getSampleId().toString()));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(collectionStart,StringConstant.SPACE,sampleStruct.collection_start_date+StringConstant.SPACE+sampleStruct.collection_start_time));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(collectionStop,StringConstant.SPACE,sampleStruct.collection_stop_date+StringConstant.SPACE+sampleStruct.collection_stop_time));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(collectionTime,StringConstant.SPACE,String.valueOf((sampleData.getCollectStart().getTime()-sampleData.getCollectStop().getTime())/1000)));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(airVolume,StringConstant.SPACE,String.valueOf(sampleStruct.air_volume)));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(xeVolume,StringConstant.SPACE,String.valueOf(sampleStruct.sample_volume_of_Xe)));
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#ACQUISITION INFORMATION 模块
|
||||
*/
|
||||
private void handleAcquistionInfoMation(){
|
||||
this.templateContent = this.templateContent.replace("${AcquisitionStart}",sampleStruct.acquisition_start_date+StringConstant.SPACE+sampleStruct.acquisition_start_time);
|
||||
this.templateContent = this.templateContent.replace("${AcqRealTime}",String.valueOf(sampleStruct.acquisition_real_time));
|
||||
this.templateContent = this.templateContent.replace("${AcqLiveTime}",String.valueOf(sampleStruct.acquisition_live_time));
|
||||
String acqInfoBlock = "#ACQUISITION INFORMATION";
|
||||
String acquisitionStart = " Acquisition Start:%-31s %s";
|
||||
String acqRealTime = " Acq Real Time(s):%-32s %s";
|
||||
String acqLiveTime = " Acq Live Time(s):%-32s %s";
|
||||
reportContent.append(acqInfoBlock);
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(acquisitionStart,StringConstant.SPACE,sampleStruct.acquisition_start_date+StringConstant.SPACE+sampleStruct.acquisition_start_time));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(acqRealTime,StringConstant.SPACE,String.valueOf(sampleStruct.acquisition_real_time)));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(acqLiveTime,StringConstant.SPACE,String.valueOf(sampleStruct.acquisition_live_time)));
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#SOFTWARE 模块
|
||||
*/
|
||||
private void handleSoftware(){
|
||||
this.templateContent = this.templateContent.replace("${version}",spectrumServiceQuotes.getSoftwareProperties().getSwVersion());
|
||||
String softwareBlock = "#SOFTWARE";
|
||||
String version = " version:%-42s %s";
|
||||
reportContent.append(softwareBlock);
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(version,StringConstant.SPACE,spectrumServiceQuotes.getSoftwareProperties().getSwVersion()));
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理Sample谱、Gas谱、Det谱sampleId
|
||||
*/
|
||||
private void handleSampleId(){
|
||||
this.templateContent = this.templateContent.replace("${SampleID}",sampleData.getSampleId().toString());
|
||||
this.templateContent = this.templateContent.replace("${DET_SampleID}",detSampleData.getSampleId().toString());
|
||||
this.templateContent = this.templateContent.replace("${GAS_SampleID}",gasSampleData.getSampleId().toString());
|
||||
}
|
||||
/**
|
||||
* 处理#SAMPLE CALIBRATION 模块
|
||||
* 还需和周雨涵确认s_b_fitting_c_e、s_g_fitting_c_e
|
||||
*/
|
||||
private void handleSampleCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c),
|
||||
E_Contant+super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)};
|
||||
String sampleCalibrationBlock = "#SAMPLE CALIBRATION (SAMPLEID:%s)";
|
||||
String rowTitle = " Beta %-45s Gamma";
|
||||
String rowValue = " %-50s %s";
|
||||
|
||||
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c),
|
||||
E_Contant+super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)};
|
||||
String beta_ch = CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c);
|
||||
String gamma_ch = CH_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c);
|
||||
String beta_e = E_Contant+super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e);
|
||||
String gamma_e = E_Contant+super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e);
|
||||
|
||||
this.handleTwoParamFormat("#SAMPLE CALIBRATION",betaArr,gammaArr);
|
||||
reportContent.append(super.rowFormat(sampleCalibrationBlock,sampleData.getSampleId().toString()));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,beta_ch,gamma_ch));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,beta_e,gamma_e));
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#SAMPLE LIMITS PER ROI 模块
|
||||
*/
|
||||
private void handleSampleLimits() throws IOException {
|
||||
String sampleLimitsBlock = "#SAMPLE LIMITS PER ROI (SAMPLEID:%s)";
|
||||
String rowTitle = " Roi %-46s Beta %-46s Gamma";
|
||||
String rowValue = " %-50s %-51s %s";
|
||||
List<Integer> roi = analyseResult.S_ROI;
|
||||
List<Integer> b_chan_start = analyseResult.S_ROI_B_Boundary_start;
|
||||
List<Integer> b_chan_stop = analyseResult.S_ROI_B_Boundary_stop;
|
||||
List<Integer> g_chan_start = analyseResult.S_ROI_G_Boundary_start;
|
||||
List<Integer> g_chan_stop = analyseResult.S_ROI_G_Boundary_stop;
|
||||
|
||||
List<String> roi = analyseResult.S_ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> beta = Lists.newArrayList();
|
||||
List<String> gamma = Lists.newArrayList();
|
||||
String flag = " to ";
|
||||
reportContent.append(super.rowFormat(sampleLimitsBlock,sampleData.getSampleId().toString()));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
for(int i=0;i<roi.size();i++){
|
||||
beta.add(b_chan_start.get(i)+flag+b_chan_stop.get(i));
|
||||
gamma.add(g_chan_start.get(i)+flag+g_chan_stop.get(i));
|
||||
String beta = b_chan_start.get(i)+to_flag+b_chan_stop.get(i);
|
||||
String gamma = g_chan_start.get(i)+to_flag+g_chan_stop.get(i);
|
||||
reportContent.append(super.rowFormat(rowValue,String.valueOf(i),beta,gamma));
|
||||
if(i==roi.size()-1){
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}else{
|
||||
reportContent.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
handleThreeParamFormat("#SAMPLE LIMITS PER ROI",roi,beta,gamma);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#DET CALIBRATION 模块
|
||||
*/
|
||||
private void handleDetCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)};
|
||||
String detCalibrationBlock = "#DET CALIBRATION (SAMPLEID:%s)";
|
||||
String rowTitle = " Beta %-45s Gamma";
|
||||
String rowValue = " %-50s %s";
|
||||
|
||||
String[] gammaArr = {CH_Contant+super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)};
|
||||
String beta_ch = CH_Contant+super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c);
|
||||
String gamma_ch = CH_Contant+super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c);
|
||||
String beta_e = E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e);
|
||||
String gamma_e = E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e);
|
||||
|
||||
this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr);
|
||||
reportContent.append(super.rowFormat(detCalibrationBlock,detSampleData.getSampleId().toString()));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,beta_ch,gamma_ch));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,beta_e,gamma_e));
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#DET LIMITS PER ROI 模块
|
||||
*/
|
||||
private void handleDetLimits() throws IOException {
|
||||
String detLimitsBlock = "#DET LIMITS PER ROI (SAMPLEID:%s)";
|
||||
String rowTitle = " Roi %-46s Beta %-46s Gamma";
|
||||
String rowValue = " %-50s %-51s %s";
|
||||
List<Integer> roi = analyseResult.D_ROI;
|
||||
List<Integer> b_chan_start = analyseResult.D_ROI_B_Boundary_start;
|
||||
List<Integer> b_chan_stop = analyseResult.D_ROI_B_Boundary_stop;
|
||||
List<Integer> g_chan_start = analyseResult.D_ROI_G_Boundary_start;
|
||||
List<Integer> g_chan_stop = analyseResult.D_ROI_G_Boundary_stop;
|
||||
|
||||
List<String> roi = analyseResult.D_ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> beta = Lists.newArrayList();
|
||||
List<String> gamma = Lists.newArrayList();
|
||||
String flag = " to ";
|
||||
reportContent.append(super.rowFormat(detLimitsBlock,detSampleData.getSampleId().toString()));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
for(int i=0;i<roi.size();i++){
|
||||
beta.add(b_chan_start.get(i)+flag+b_chan_stop.get(i));
|
||||
gamma.add(g_chan_start.get(i)+flag+g_chan_stop.get(i));
|
||||
String beta = b_chan_start.get(i)+to_flag+b_chan_stop.get(i);
|
||||
String gamma = g_chan_start.get(i)+to_flag+g_chan_stop.get(i);
|
||||
reportContent.append(super.rowFormat(rowValue,String.valueOf(i),beta,gamma));
|
||||
if(i==roi.size()-1){
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}else{
|
||||
reportContent.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
handleThreeParamFormat("#DET LIMITS PER ROI",roi,beta,gamma);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#GAS CALIBRATION 模块
|
||||
*/
|
||||
private void handleGasCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c),
|
||||
E_Contant+super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)};
|
||||
String gasSampleCalibrationBlock = "#GAS CALIBRATION (SAMPLEID:%s)";
|
||||
String rowTitle = " Beta %-45s Gamma";
|
||||
String rowValue = " %-50s %s";
|
||||
|
||||
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c),
|
||||
E_Contant+super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)};
|
||||
String beta_ch = CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c);
|
||||
String gamma_ch = CH_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c);
|
||||
String beta_e = E_Contant+super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e);
|
||||
String gamma_e = E_Contant+super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e);
|
||||
|
||||
this.handleTwoParamFormat("#GAS CALIBRATION",betaArr,gammaArr);
|
||||
reportContent.append(super.rowFormat(gasSampleCalibrationBlock,gasSampleData.getSampleId().toString()));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,beta_ch,gamma_ch));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,beta_e,gamma_e));
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#GAS LIMITS PER ROI 模块
|
||||
*/
|
||||
private void handleGasLimits() throws IOException {
|
||||
String gasLimitsBlock = "#DET LIMITS PER ROI (SAMPLEID:%s)";
|
||||
String rowTitle = " Roi %-46s Beta %-46s Gamma";
|
||||
String rowValue = " %-50s %-51s %s";
|
||||
List<Integer> roi = analyseResult.G_ROI;
|
||||
List<Integer> b_chan_start = analyseResult.G_ROI_B_Boundary_start;
|
||||
List<Integer> b_chan_stop = analyseResult.G_ROI_B_Boundary_stop;
|
||||
List<Integer> g_chan_start = analyseResult.G_ROI_G_Boundary_start;
|
||||
List<Integer> g_chan_stop = analyseResult.G_ROI_G_Boundary_stop;
|
||||
|
||||
List<String> roi = analyseResult.G_ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> beta = Lists.newArrayList();
|
||||
List<String> gamma = Lists.newArrayList();
|
||||
reportContent.append(super.rowFormat(gasLimitsBlock,gasSampleData.getSampleId().toString()));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
for(int i=0;i<roi.size();i++){
|
||||
beta.add(b_chan_start.get(i)+to_flag+b_chan_stop.get(i));
|
||||
gamma.add(g_chan_start.get(i)+to_flag+g_chan_stop.get(i));
|
||||
String beta = b_chan_start.get(i)+to_flag+b_chan_stop.get(i);
|
||||
String gamma = g_chan_start.get(i)+to_flag+g_chan_stop.get(i);
|
||||
reportContent.append(super.rowFormat(rowValue,String.valueOf(i),beta,gamma));
|
||||
if(i==roi.size()-1){
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}else{
|
||||
reportContent.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
handleThreeParamFormat("#GAS LIMITS PER ROI",roi,beta,gamma);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#GROSS COUNTS PER ROI模块
|
||||
*/
|
||||
private void handleGrossCounts() throws IOException {
|
||||
String grossCountsBlock = "#GROSS COUNTS PER ROI";
|
||||
String rowTitle = " Roi %-46s Sample %-44s GasBkgnd %-12s DetBkgnd";
|
||||
String rowValue = " %-50s %-51s %-21s %s";
|
||||
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
this.handleFourParamFormat("#GROSS COUNTS PER ROI",roi,s_roi_cts,g_roi_cts,d_roi_cts);
|
||||
reportContent.append(grossCountsBlock);
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE,StringConstant.SPACE,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
for (int i=0;i<roi.size();i++){
|
||||
reportContent.append(super.rowFormat(rowValue,roi.get(i),s_roi_cts.get(i),g_roi_cts.get(i),d_roi_cts.get(i)));
|
||||
if(i==roi.size()-1){
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}else{
|
||||
reportContent.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#NET COUNTS AND LC PER ROI模块
|
||||
*/
|
||||
private void handleNetCountsAndLC() throws IOException {
|
||||
List<Double> roi_net_count = analyseResult.ROI_net_coutns;
|
||||
List<Double> roi_net_count_err = analyseResult.ROI_net_coutns_err;
|
||||
String netCountsBlock = "#NET COUNTS AND LC PER ROI ";
|
||||
String rowTitle = " Roi %-46s Net count %-41s LC";
|
||||
String rowValue = " %-50s %-51s %s";
|
||||
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
//此参数需第一位补0
|
||||
analyseResult.LC_CTS.add(0,0D);
|
||||
List<String> lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> netCount = Lists.newArrayList();
|
||||
for(int i=0;i<roi.size();i++){
|
||||
netCount.add(super.formatToStr5(roi_net_count.get(i))+arithmetic_flag+super.formatToStr5(roi_net_count_err.get(i)));
|
||||
}
|
||||
this.handleThreeParamFormat("#NET COUNTS AND LC PER ROI",roi,netCount,lc);
|
||||
List<Integer> roi = analyseResult.ROI;
|
||||
List<Double> roi_net_count = analyseResult.ROI_net_coutns;
|
||||
List<Double> roi_net_count_err = analyseResult.ROI_net_coutns_err;
|
||||
//此参数需第一位补0
|
||||
analyseResult.LC_CTS.add(0,0D);
|
||||
List<String> lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
reportContent.append(netCountsBlock);
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
for (int i=0;i<roi.size();i++){
|
||||
String netCount = super.formatToStr5(roi_net_count.get(i))+arithmetic_flag+super.formatToStr5(roi_net_count_err.get(i));
|
||||
reportContent.append(super.rowFormat(rowValue,String.valueOf(roi.get(i)),netCount,lc.get(i)));
|
||||
if(i==roi.size()-1){
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}else{
|
||||
reportContent.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#CONCENTRATION AND LC PER ROI模块
|
||||
*/
|
||||
private void handleConcentrationAndLC() throws IOException {
|
||||
String grossCountsBlock = "#CONCENTRATION AND LC PER ROI";
|
||||
String rowTitle = " Roi %-46s Conc(mBq/m3) %-38s LC(mBq/m3) %-10s MDC(mBq/m3)";
|
||||
String rowValue = " %-50s %-51s %-21s %s";
|
||||
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<Double> con = analyseResult.ROI_con_uncer;
|
||||
List<Double> conErr = analyseResult.ROI_con_uncer_err;
|
||||
analyseResult.LC.add(0,0.0D);
|
||||
analyseResult.MDC.add(0,0.0D);
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> conc = Lists.newArrayList();
|
||||
for(int i=0;i<roi.size();i++){
|
||||
conc.add(super.formatToStr5(con.get(i))+arithmetic_flag+super.formatToStr5(conErr.get(i)));
|
||||
|
||||
reportContent.append(grossCountsBlock);
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE,StringConstant.SPACE,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
for (int i=0;i<roi.size();i++){
|
||||
String conc = super.formatToStr5(con.get(i))+arithmetic_flag+super.formatToStr5(conErr.get(i));
|
||||
reportContent.append(super.rowFormat(rowValue,roi.get(i),conc,lc.get(i),mdc.get(i)));
|
||||
if(i==roi.size()-1){
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}else{
|
||||
reportContent.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
this.handleFourParamFormat("#CONCENTRATION AND LC PER ROI",roi,conc,lc,mdc);
|
||||
}
|
||||
|
||||
/**
|
||||
* #RESULT SUMMARY
|
||||
*/
|
||||
private void handleResultSummary() throws IOException {
|
||||
String resultSummaryBlock = "#RESULT SUMMARY";
|
||||
String rowTitle = " Nuclide Name %-37s Conc(mBq/m3) %-38s Uncertainty(mBq/m3) %s MDC(mBq/m3) %-2s NID Flag";
|
||||
String rowValue = " %-50s %-51s %-21s %-14s %s";
|
||||
|
||||
String[] nuclideName = {XE_135,XE_131m,XE_133m,XE_133};
|
||||
|
||||
String[] conc = {super.formatToStr5(analyseResult.Xe135_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe135_uncer),
|
||||
super.formatToStr5(analyseResult.Xe131m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe131m_uncer),
|
||||
super.formatToStr5(analyseResult.Xe133m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133m_uncer),
|
||||
super.formatToStr5(analyseResult.Xe133_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133_uncer)};
|
||||
String xe_135_conc = super.formatToStr5(analyseResult.Xe135_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe135_uncer);
|
||||
String xe_131m_conc = super.formatToStr5(analyseResult.Xe131m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe131m_uncer);
|
||||
String xe_133m_conc = super.formatToStr5(analyseResult.Xe133m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133m_uncer);
|
||||
String xe_133_conc = super.formatToStr5(analyseResult.Xe133_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133_uncer);
|
||||
|
||||
String[] uncertainty = {super.formatToStr5(analyseResult.LC_Xe135),super.formatToStr5(analyseResult.LC_Xe131m),
|
||||
super.formatToStr5(analyseResult.LC_Xe133m),super.formatToStr5(analyseResult.LC_Xe133)};
|
||||
String xe_135_uncertainty = super.formatToStr5(analyseResult.LC_Xe135);
|
||||
String xe_131m_uncertainty = super.formatToStr5(analyseResult.LC_Xe131m);
|
||||
String xe_133m_uncertainty = super.formatToStr5(analyseResult.LC_Xe133m);
|
||||
String xe_133_uncertainty = super.formatToStr5(analyseResult.LC_Xe133);
|
||||
|
||||
String[] mdc = {super.formatToStr5(analyseResult.MDC_Xe135),super.formatToStr5(analyseResult.MDC_Xe131m),
|
||||
super.formatToStr5(analyseResult.MDC_Xe133m),super.formatToStr5(analyseResult.MDC_Xe133)};
|
||||
String xe_135_mdc = super.formatToStr5(analyseResult.MDC_Xe135);
|
||||
String xe_131m_mdc = super.formatToStr5(analyseResult.MDC_Xe131m);
|
||||
String xe_133m_mdc = super.formatToStr5(analyseResult.MDC_Xe133m);
|
||||
String xe_133_mdc = super.formatToStr5(analyseResult.MDC_Xe133);
|
||||
|
||||
String xe_135_nid_flag = analyseResult.Xe135_con>analyseResult.MDC_Xe135?"1":"0";
|
||||
String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0";
|
||||
String xe_133m_nid_flag = analyseResult.Xe133m_con>analyseResult.MDC_Xe133m?"1":"0";
|
||||
String xe_133_nid_flag = analyseResult.Xe133_con>analyseResult.MDC_Xe133?"1":"0";
|
||||
String[] nid_flag = {xe_135_nid_flag,xe_131m_nid_flag,xe_133m_nid_flag,xe_133_nid_flag};
|
||||
|
||||
this.handleFiveParamFormat("#RESULT SUMMARY",nuclideName,conc,uncertainty,mdc,nid_flag);
|
||||
reportContent.append(resultSummaryBlock);
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE,StringConstant.SPACE,StringConstant.SPACE,StringConstant.SPACE));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,XE_135,xe_135_conc,xe_135_uncertainty,xe_135_mdc,xe_135_nid_flag));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,XE_131m,xe_131m_conc,xe_131m_uncertainty,xe_131m_mdc,xe_131m_nid_flag));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,XE_133m,xe_133m_conc,xe_133m_uncertainty,xe_133m_mdc,xe_133m_nid_flag));
|
||||
reportContent.append(System.lineSeparator());
|
||||
reportContent.append(super.rowFormat(rowValue,XE_133,xe_133_conc,xe_133_uncertainty,xe_133_mdc,xe_133_nid_flag));
|
||||
reportContent.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存报告到ftp
|
||||
*/
|
||||
private void saveReportToFtp() throws FileNotFoundException {
|
||||
ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+StringConstant.SLASH+arrFilePath,arrFileName,new FileInputStream(this.reportTmpFile));
|
||||
this.reportTmpFile.delete();
|
||||
ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+StringConstant.SLASH+arrFilePath,arrFileName,new ByteArrayInputStream(reportContent.toString().getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理两个参数的占位符格式化
|
||||
* 1.#SAMPLE CALIBRATION 模块
|
||||
* 2.#DET CALIBRATION 模块
|
||||
* 3.#GAS CALIBRATION 模块
|
||||
*/
|
||||
private void handleTwoParamFormat(String key,String[] param,String[] param1) throws IOException {
|
||||
final List<String> lines = FileUtils.readLines(this.reportTmpFile, "utf-8");
|
||||
for(int i=0;i<lines.size();i++){
|
||||
if(lines.get(i).startsWith(key)){
|
||||
//i+1行是行头
|
||||
//i+2行是占位符,所以要删除i+2行返回行格式
|
||||
final String format = lines.remove(i+2);
|
||||
for(int j=0;j<param.length;j++){
|
||||
String copyFormat = new String(format);
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(String.format(copyFormat,param[j],param1[j]));
|
||||
//i+2行是占位符,已经删除,此时添加数据应从i+1行开始
|
||||
lines.add((i+1+j+1),line.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理三个参数的占位符格式化
|
||||
* 1.#SAMPLE、DET、GAS LIMITS PER ROI 模块
|
||||
* 2.#NET COUNTS AND LC PER ROI 模块
|
||||
*/
|
||||
private void handleThreeParamFormat(String key,List<String> param,List<String> param1,List<String> param2) throws IOException {
|
||||
final List<String> lines = FileUtils.readLines(this.reportTmpFile, "utf-8");
|
||||
for(int i=0;i<lines.size();i++){
|
||||
if(lines.get(i).startsWith(key)){
|
||||
//i+1行是行头
|
||||
//i+2行是占位符,所以要删除i+2行返回行格式
|
||||
final String format = lines.remove(i+2);
|
||||
for(int j=0;j<param.size();j++){
|
||||
String copyFormat = new String(format);
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(String.format(copyFormat,param.get(j),param1.get(j),param2.get(j)));
|
||||
//i+2行是占位符,已经删除,此时添加数据应从i+1行开始
|
||||
lines.add((i+1+j+1),line.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理四个参数的占位符格式化
|
||||
* 1.#GROSS COUNTS PER ROI 模块
|
||||
* 2.#CONCENTRATION AND LC PER ROI 模块
|
||||
*/
|
||||
private void handleFourParamFormat(String key,List<String> param,List<String> param1,List<String> param2,List<String> param3) throws IOException {
|
||||
final List<String> lines = FileUtils.readLines(this.reportTmpFile, "utf-8");
|
||||
for(int i=0;i<lines.size();i++){
|
||||
if(lines.get(i).startsWith(key)){
|
||||
//i+1行是行头
|
||||
//i+2行是占位符,所以要删除i+2行返回行格式
|
||||
final String format = lines.remove(i+2);
|
||||
for(int j=0;j<param.size();j++){
|
||||
String copyFormat = new String(format);
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(String.format(copyFormat,param.get(j),param1.get(j),param2.get(j),param3.get(j)));
|
||||
//i+2行是占位符,已经删除,此时添加数据应从i+1行开始
|
||||
lines.add((i+1+j+1),line.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理五个参数的占位符格式化
|
||||
* 1.#RESULT SUMMARY 模块
|
||||
* @param key
|
||||
* @param param
|
||||
* @param param1
|
||||
* @param param2
|
||||
* @param param3
|
||||
* @param param4
|
||||
* @throws IOException
|
||||
*/
|
||||
private void handleFiveParamFormat(String key,String[] param,String[] param1,String[] param2,String[] param3,String[] param4) throws IOException {
|
||||
final List<String> lines = FileUtils.readLines(this.reportTmpFile, "utf-8");
|
||||
for(int i=0;i<lines.size();i++){
|
||||
if(lines.get(i).startsWith(key)){
|
||||
//i+1行是行头
|
||||
//i+2行是占位符,所以要删除i+2行返回行格式
|
||||
final String format = lines.remove(i+2);
|
||||
for(int j=0;j<param.length;j++){
|
||||
String copyFormat = new String(format);
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(String.format(copyFormat,param[j],param1[j],param2[j],param3[j],param4[j]));
|
||||
//i+2行是占位符,已经删除,此时添加数据应从i+1行开始
|
||||
lines.add((i+1+j+1),line.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
//修改状态为解析失败
|
||||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
|
|
@ -3,6 +3,8 @@ package org.jeecg.modules.spectrum;
|
|||
import cn.hutool.core.io.FileUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.ftp.FTPUtils;
|
||||
import java.io.File;
|
||||
|
@ -90,7 +92,7 @@ public abstract class SpectrumHandler extends Chain{
|
|||
/**
|
||||
* 对本地能谱临时文件进行改名
|
||||
*/
|
||||
protected abstract void updateSpectrumFileName();
|
||||
protected abstract void updateSpectrumFileName() throws FileNotFoundException;
|
||||
|
||||
/**
|
||||
* 处理原始数据
|
||||
|
@ -100,7 +102,7 @@ public abstract class SpectrumHandler extends Chain{
|
|||
/**
|
||||
* 把流程日志写入ftp日志文件
|
||||
*/
|
||||
protected void saveLogToFtp() throws FileNotFoundException{};
|
||||
protected void saveLogToFtp() {};
|
||||
|
||||
/**
|
||||
* 打印当前能谱类型
|
||||
|
@ -123,7 +125,7 @@ public abstract class SpectrumHandler extends Chain{
|
|||
StringBuilder localPath = new StringBuilder();
|
||||
localPath.append(this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
|
||||
localPath.append(File.separator);
|
||||
localPath.append(System.currentTimeMillis());
|
||||
localPath.append(System.currentTimeMillis()+StringConstant.UNDER_LINE+RandomUtils.nextInt());
|
||||
localPath.append(value.getSuffix());
|
||||
this.mailFile = FileUtil.writeString(this.mailContent, localPath.toString(), "UTF-8");
|
||||
// 能谱数据类型如果是 SPHDP 或者 SPHDF 统一改为 SAMPLEPHD
|
||||
|
|
|
@ -64,9 +64,14 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
* ftp工具
|
||||
*/
|
||||
private FTPUtils ftpUtil;
|
||||
/**
|
||||
* FTP目录操作锁
|
||||
*/
|
||||
private Object ftpOpierationLock;
|
||||
|
||||
public void init(Message message, EmailProperties emailProperties,EmailServiceManager emailServiceManager,
|
||||
CountDownLatch taskLatch, SpectrumServiceQuotes spectrumServiceQuotes,EmailCounter emailCounter){
|
||||
CountDownLatch taskLatch, SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
EmailCounter emailCounter,Object ftpOpierationLock){
|
||||
this.message = message;
|
||||
this.emailProperties = emailProperties;
|
||||
this.emailServiceManager = emailServiceManager;
|
||||
|
@ -74,10 +79,11 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.spectrumPathProperties = spectrumServiceQuotes.getSpectrumPathProperties();
|
||||
this.emailCounter = emailCounter;
|
||||
this.ftpOpierationLock = ftpOpierationLock;
|
||||
//初始化FTP客户端对象
|
||||
final FTPProperties ftpProperties = spectrumServiceQuotes.getFtpProperties();
|
||||
ftpUtil = new FTPUtils(ftpProperties.getHost(),ftpProperties.getPort(),ftpProperties.getUserName(),
|
||||
ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath());
|
||||
ftpProperties.getPassword(),ftpProperties.getEncoding(),ftpProperties.getFtpRootPath(),ftpOpierationLock);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.jeecg.common.util.RedisStreamUtil;
|
|||
import org.jeecg.modules.datasource.OraDataSourceProperties;
|
||||
import org.jeecg.modules.ftp.FTPProperties;
|
||||
import org.jeecg.modules.service.*;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
|
@ -76,4 +77,6 @@ public class SpectrumServiceQuotes {
|
|||
|
||||
private final RedisStreamUtil redisStreamUtil;
|
||||
|
||||
private final ResourceLoader resourceLoader;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
CNL06 GENERATED REPORT
|
||||
AUTO RADIONUCLIDE REPORT
|
||||
(Noble Gas Version)
|
||||
Creation Date ${create_date}
|
||||
|
||||
#FILE INFORMATION
|
||||
SampleMeasID: ${SampleMeasID}
|
||||
GASBKMeasID: ${GASBKMeasID}
|
||||
DETBKMeasID: ${DETBKMeasID}
|
||||
SRID: ${SRID}
|
||||
Detector Type: ${DetectorType}
|
||||
|
||||
#COLLECTION INFORMATION
|
||||
Station ID: ${StationID}
|
||||
Detector ID: ${DetectorID}
|
||||
Sample ID: ${SampleID}
|
||||
Collection Start: ${CollectionStart}
|
||||
Collection Stop: ${CollectionStop}
|
||||
Collection TIME(h): ${CollectionTIME}
|
||||
Air Volume[cm3]: ${AirVolume}
|
||||
Xe Volume[cm3]: ${XeVolume}
|
||||
|
||||
#ACQUISITION INFORMATION
|
||||
Acquisition Start: ${AcquisitionStart}
|
||||
Acq Real Time(s): ${AcqRealTime}
|
||||
Acq Live Time(s): ${AcqLiveTime}
|
||||
|
||||
#SOFTWARE
|
||||
version: ${version}
|
||||
|
||||
#SAMPLE CALIBRATION (SAMPLEID:${SampleID})
|
||||
Beta Gamma
|
||||
%-49s %-49s
|
||||
|
||||
#SAMPLE LIMITS PER ROI (SAMPLEID:${SampleID})
|
||||
Roi Beta Gamma
|
||||
%-2s %-11s %-11s
|
||||
|
||||
#DET CALIBRATION (SAMPLEID:${DET_SampleID})
|
||||
Beta Gamma
|
||||
%-49s %-49s
|
||||
|
||||
#DET LIMITS PER ROI (SAMPLEID:${DET_SampleID})
|
||||
Roi Beta Gamma
|
||||
%-2s %-11s %-11s
|
||||
|
||||
#GAS CALIBRATION (SAMPLEID:${GAS_SampleID})
|
||||
Beta Gamma
|
||||
%-49s %-49s
|
||||
|
||||
#GAS LIMITS PER ROI (SAMPLEID:${GAS_SampleID})
|
||||
Roi Beta Gamma
|
||||
%-2s %-11s %-11s
|
||||
|
||||
#GROSS COUNTS PER ROI
|
||||
Roi Sample GasBkgnd DetBkgnd
|
||||
%-2s %-10s %-10s %-10s
|
||||
|
||||
#NET COUNTS AND LC PER ROI
|
||||
Roi Net count LC
|
||||
%-2s %-22s %-7s
|
||||
|
||||
#CONCENTRATION AND LC PER ROI
|
||||
Roi Conc(mBq/m3) LC(mBq/m3) MDC(mBq/m3):
|
||||
%-2s %-22s %-10s %-10s
|
||||
|
||||
#RESULT SUMMARY
|
||||
Nuclide Name Conc(mBq/m3) Uncertainty(mBq/m3) MDC(mBq/m3) NID Flag
|
||||
%-6s %-20s %-7s %-7s %-1s
|
||||
|
|
@ -2,6 +2,7 @@ package org.jeecg;
|
|||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
|
@ -13,11 +14,15 @@ import org.springframework.boot.CommandLineRunner;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.system.ApplicationHome;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
|
@ -36,6 +41,7 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
private final AutoProcessManager autoProcessManager;
|
||||
private final UndealHandleManager undealHandleManager;
|
||||
private final FileSourceHandleManager fileSourceHandleManager;
|
||||
private final Object ftpOpierationLock = new Object();
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
|
@ -66,8 +72,27 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
if(EmailReceivePolicy.CURR_DATE_ORDER_RECEIVE.getPolicy().equals(taskProperties.getReceivePolicy())){
|
||||
systemStartupTime = new Date();
|
||||
}
|
||||
// autoProcessManager.start(systemStartupTime);
|
||||
// undealHandleManager.start();
|
||||
fileSourceHandleManager.start();
|
||||
//校验临时存储目录是否存在
|
||||
checkTemporaryStorageDirectory();
|
||||
// autoProcessManager.start(systemStartupTime,ftpOpierationLock);
|
||||
// undealHandleManager.start(ftpOpierationLock);
|
||||
fileSourceHandleManager.start(ftpOpierationLock);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验临时存储目录是否存在,不存在则创建
|
||||
*/
|
||||
private void checkTemporaryStorageDirectory() throws IOException {
|
||||
ApplicationHome home = new ApplicationHome(getClass());
|
||||
File tempStorageDirectory = new File(home.getSource().getParentFile().getAbsolutePath()+File.separator+taskProperties.getTemporaryStoragePath());
|
||||
if(!tempStorageDirectory.exists() || !tempStorageDirectory.isDirectory()){
|
||||
tempStorageDirectory.setReadable(true);
|
||||
tempStorageDirectory.setWritable(true);
|
||||
tempStorageDirectory.mkdir();
|
||||
taskProperties.setTemporaryStoragePath(tempStorageDirectory.getAbsolutePath());
|
||||
}else{
|
||||
FileUtils.deleteDirectory(tempStorageDirectory);
|
||||
checkTemporaryStorageDirectory();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user