Compare commits

..

No commits in common. "277485ddda87aa0ff54344ea26afd89cdfadbe3f" and "3f22b0edba6a15159d7cc617247cf9140c093fd0" have entirely different histories.

46 changed files with 847 additions and 1911 deletions

View File

@ -13,4 +13,6 @@ public interface DictConstant {
String NOBLE_GAS_BETAGAMMA = "Noble Gas Beta-Gamma";
String NOBLE_GAS_HPGE = "Noble Gas HPGe";
String ALERT_SYSTEM_CODE = "Alert_System_Code";
}

View File

@ -13,10 +13,16 @@ public interface RedisConstant {
*/
String PREFIX_SILENCE = "SilenceCycle:";
String STREAM_ALARM = "Stream:Alarm";
String STREAM_ANALYSIS = "Stream:Analysis";
String GROUP_ALARM = "Group_Alarm";
String GROUP_ANALYSIS = "Group_Analysis";
String CONSUMER_ALARM = "Consumer_Alarm";
String CONSUMER_ANALYSIS = "Consumer_Analysis";
String NUCLIDE_LINES_LIB = "Nuclide_Lines_Lib:";

View File

@ -1,7 +1,14 @@
package org.jeecg.common.email;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5;
import com.google.common.collect.Lists;
import com.sun.mail.imap.IMAPStore;
import com.sun.mail.smtp.SMTPAddressFailedException;
@ -16,6 +23,7 @@ import org.jeecg.common.exception.DownloadEmailException;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.properties.TaskProperties;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.Md5Util;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.entity.postgre.SysEmail;
import org.jetbrains.annotations.NotNull;
@ -29,10 +37,11 @@ import javax.mail.search.SearchTerm;
import java.io.*;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import java.util.zip.InflaterOutputStream;
/**
* 邮件服务管理器
@ -66,8 +75,6 @@ public class EmailServiceManager {
private Object downloadEmlLocal = new Object();
private final ReentrantLock lock = new ReentrantLock();
@NotNull
public static EmailServiceManager getInstance(){
return new EmailServiceManager();
@ -124,7 +131,7 @@ public class EmailServiceManager {
/**
* 接收邮件
*/
public Message[] receiveMail() throws Exception {
public Message[] receiveMail() {
String status = EmailLogManager.STATUS_SUCCESS;
try{
//配置邮件服务属性
@ -132,15 +139,14 @@ public class EmailServiceManager {
properties.put("mail.store.protocol", "imap");
properties.put("mail.imap.host", email.getEmailServerAddress());
properties.put("mail.imap.port",email.getPort());
properties.put("mail.imap.connectiontimeout", "3000"); // 设置连接超时时间为3秒
properties.put("mail.imap.timeout", "3000"); // 设置读取超时时间为3秒
if (email.getIsQiye() == 1) {
Integer isQiye = email.getIsQiye();
if (ObjectUtil.isNotNull(isQiye) && isQiye == 1) {
properties.put("mail.imap.ssl.enable", "true");
} else {
properties.put("mail.imap.ssl.enable", "false");
}
HashMap IAM = new HashMap();
HashMap<String, String> IAM = new HashMap<>();
//带上IMAP ID信息由key和value组成例如nameversionvendorsupport-email等
IAM.put("name","myname");
IAM.put("version","1.0.0");
@ -176,7 +182,6 @@ public class EmailServiceManager {
return o1.getReceivedDate().compareTo(o2.getReceivedDate());
} catch (MessagingException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
return 0;
});
@ -186,11 +191,12 @@ public class EmailServiceManager {
return Arrays.copyOfRange(messages,0,this.receiveNum-1);
}
}
} catch (Exception e){
}catch (MessagingException e){
status = EmailLogManager.STATUS_ERROR;
log.error("Email connection is abnormal, account is {}, service is {},the reason is {}.",email.getName(),email.getEmailServerAddress(),e.getMessage());
throw e;
} finally {
e.printStackTrace();
return null;
}finally {
EmailLogEvent connectEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,email,status,EmailLogManager.CONNECT);
EmailLogManager.getInstance().setConnectLogEvent(connectEvent);
//GetAllId C++原业务是把远程邮箱邮件同步到C++本次java编写没有这一步所以和Connect绑定若Connect成功则GetAllId成功
@ -529,129 +535,11 @@ public class EmailServiceManager {
* 当计数大于10000后从0开始服务重启后也从0开始
*/
public File downloadEmailToEmlDir(@NotNull Message message,Integer emailCounter,Integer batchesCounter) throws MessagingException {
synchronized (downloadEmlLocal) {
String subject = "";
File emlFile = null;
String status = EmailLogManager.STATUS_SUCCESS;
Date receivedDate = null;
InputStream inputStream = null;
BufferedOutputStream outputStream = null;
try {
//获取发件人
final String address = ((InternetAddress) message.getFrom()[0]).getAddress();
final String from = address.substring(0,address.indexOf(StringConstant.AT));
//获取主题
subject = MimeUtility.decodeText(message.getSubject());
if(subject.indexOf(StringConstant.SLASH) != -1){
subject = StringUtils.replace(subject,StringConstant.SLASH,"");
}
if(subject.indexOf(StringConstant.COLON) != -1){
subject = StringUtils.replace(subject,StringConstant.COLON,"");
}
receivedDate = message.getReceivedDate();
StringBuilder fileName = new StringBuilder();
fileName.append(from);
fileName.append(StringConstant.UNDER_LINE);
fileName.append(subject);
fileName.append(StringConstant.UNDER_LINE);
fileName.append(DateUtils.formatDate(new Date(),"YYMMdd"));
fileName.append(StringConstant.UNDER_LINE);
fileName.append(DateUtils.formatDate(new Date(),"HHmmssSSS"));
fileName.append(StringConstant.UNDER_LINE);
fileName.append("receive");
fileName.append(StringConstant.UNDER_LINE);
fileName.append(DateUtils.formatDate(receivedDate,"YYMMdd"));
fileName.append(StringConstant.UNDER_LINE);
fileName.append(DateUtils.formatDate(receivedDate,"HHmmssSSS"));
fileName.append(StringConstant.UNDER_LINE);
fileName.append(emailCounter);
fileName.append(SAVE_EML_SUFFIX);
final String rootPath = spectrumPathProperties.getRootPath();
final String emlPath = spectrumPathProperties.getEmlPath();
emlFile = new File(rootPath+emlPath+File.separator+fileName);
// outputStream = new FileOutputStream(emlFile);
// message.writeTo(outputStream);
int bufferSize = 1024 * 1024; // 1M
inputStream = message.getInputStream();
outputStream = new BufferedOutputStream(new FileOutputStream(emlFile), bufferSize);
// 从邮件的输入流读取内容并写入到本地文件
byte[] buffer = new byte[bufferSize];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
} catch (MessagingException | IOException e) {
// 下载邮件失败 抛出自定义邮件下载异常
status = EmailLogManager.STATUS_ERROR;
String errorMsg = StrUtil.format("The email download failed, the subject of the email is {}, the reason is {}.", subject, e.getMessage());
log.error(errorMsg);
throw new DownloadEmailException(errorMsg);
}catch (Exception e) {
log.error("",e);
}finally {
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"),
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
try {
if (Objects.nonNull(inputStream)) {
inputStream.close();
}
if (Objects.nonNull(outputStream)) {
outputStream.flush();
outputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return emlFile;
}
}
/*public File downloadEmailToEmlDir(@NotNull Message message, Integer emailCounter, Integer batchesCounter) throws MessagingException, IOException {
AtomicReference<FileOutputStream> outputStream = new AtomicReference<>();
CompletableFuture<File> future = CompletableFuture.supplyAsync(() -> {
try {
lock.lock(); // 获取锁
// 执行需要获取锁才能进行的操作
// return executeWithLock(message, emailCounter, batchesCounter);
File file = executeWithLock(message, emailCounter, batchesCounter);
outputStream.set(new FileOutputStream(file));
a(outputStream,message);
return null;
} catch (MessagingException e) {
throw new RuntimeException(e);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
// 如果成功拿到锁 释放锁
lock.unlock();
}
});
try {
return future.get(5, TimeUnit.SECONDS);
// return future.get(5, TimeUnit.SECONDS);// 等待任务执行超过5秒则抛出TimeoutException
} catch (InterruptedException | ExecutionException | TimeoutException e) {
future.cancel(true); // 取消任务执行
if (ObjectUtil.isNotNull(outputStream) && ObjectUtil.isNotNull(outputStream.get()))
outputStream.get().close();
log.error("下载 eml 执行超时", e);
throw new RuntimeException("下载 eml 执行超时");
}
}*/
public File executeWithLock(Message message,Integer emailCounter,Integer batchesCounter) throws MessagingException {
String subject = "";
File emlFile = null;
String status = EmailLogManager.STATUS_SUCCESS;
Date receivedDate = null;
try {
// 获取锁 设置超时
//获取发件人
final String address = ((InternetAddress) message.getFrom()[0]).getAddress();
final String from = address.substring(0,address.indexOf(StringConstant.AT));
@ -683,22 +571,45 @@ public class EmailServiceManager {
fileName.append(SAVE_EML_SUFFIX);
final String rootPath = spectrumPathProperties.getRootPath();
final String emlPath = spectrumPathProperties.getEmlPath();
emlFile = new File(rootPath+emlPath+File.separator+fileName);
// Thread.sleep(6000l);
// try(FileOutputStream outputStream = new FileOutputStream(emlFile)) {
// message.writeTo(outputStream);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
emlFile = new File(rootPath + emlPath + File.separator + fileName);
/* 如果邮件内容经过Base64编码 需要解码后再生成.eml文件 否则直接生成.eml文件 */
// 先将邮件的内容保存为.eml文件
// message.writeTo(Files.newOutputStream(emlFile.toPath()));
FileUtil.writeFromStream(message.getInputStream(), emlFile);
// 判断是否需要对正文内容进行解码
// String content = (String) message.getContent();
String content = FileUtil.readUtf8String(emlFile);
List<String> contents = ListUtil.toList(StrUtil.split(content, SymbolConstant.VERTICAL));
// 如果邮件正文被|分割为4部分 说明邮件内容经过了编码 尝试进行解码
if (contents.size() == 4){
contents = ListUtil.toList(StrUtil.split(content, SymbolConstant.VERTICAL_CHAR, 2));
String md5 = contents.get(0);
content = contents.get(1);
// 去除可能产生的多余的空格 否则影响MD5的生成结果
content = StrUtil.cleanBlank(content);
String md5Verified = MD5.create().digestHex(content);
// 如果md5验证失败 则不进行解码
if (!StrUtil.equals(md5, md5Verified)) return emlFile;
contents = ListUtil.toList(StrUtil.split(content, SymbolConstant.VERTICAL));
String base64 = contents.get(contents.size() - 1);
// 解码Base64字符串 并用解码后的内容覆盖原始文件内容
byte[] data = Base64.decode(base64);
try (OutputStream out = Files.newOutputStream(emlFile.toPath());
InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(out)) {
inflaterOutputStream.write(data);
} catch (Exception e) {
log.error("Decoded the Base64 eml file[{}] error: {}", emlFile.getAbsolutePath(), e.getMessage());
}
}
} catch (MessagingException | IOException e) {
// 下载邮件失败 抛出自定义邮件下载异常
status = EmailLogManager.STATUS_ERROR;
String errorMsg = StrUtil.format("The email download failed, the subject of the email is {}, the reason is {}.", subject, e.getMessage());
log.error(errorMsg);
throw new DownloadEmailException(errorMsg);
} catch (Exception e) {
log.error("",e);
} finally {
}catch (Exception e) {
log.error("The email download failed: {}", e.getMessage());
}finally {
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"),
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
@ -706,9 +617,6 @@ public class EmailServiceManager {
return emlFile;
}
public void a(AtomicReference<FileOutputStream> outputStream, Message message) throws MessagingException, IOException {
message.writeTo(outputStream.get());
}
/**
* 删除邮件
* @param message
@ -722,12 +630,11 @@ public class EmailServiceManager {
subject = MimeUtility.decodeText(message.getSubject());
receivedDate = message.getReceivedDate();
message.setFlag(Flags.Flag.DELETED,true);
// log.info("EmailServiceManager: Remove Email:{},receiveTime:{}",message.getSubject(), DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss"));
// log.info("EmailServiceManager: Remove Email:{},receiveTime:{}",message.getSubject(), DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss"));
} catch (MessagingException | UnsupportedEncodingException e) {
status = EmailLogManager.STATUS_ERROR;
log.error("Email deletion failed, the subject of the email is :{}, the reason is :{}.",subject,e.getMessage());
e.printStackTrace();
log.error(e.getMessage(), e);
}finally {
EmailLogEvent removeEvent = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.DELETEID,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"));
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),removeEvent);
@ -749,7 +656,6 @@ public class EmailServiceManager {
if(null != store){
store.close();
}
log.info(Thread.currentThread().getName() + ",EmailServiceManage资源关闭完成.");
// for(String messageId : messageIds){
// String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;
// redisUtil.del(key);
@ -757,7 +663,6 @@ public class EmailServiceManager {
} catch (MessagingException e) {
log.error("Email closure failed, email address is: {}, reason is: {}",email.getUsername(),e.getMessage());
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
@ -771,7 +676,7 @@ public class EmailServiceManager {
try {
String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;
int numberKey = redisUtil.get(key) != null? (int) redisUtil.get(key):0;
// exist = redisUtil.hasKey(key);
// exist = redisUtil.hasKey(key);
if(numberKey >= taskProperties.getForceDeletedNumber()){
exist = true;
log.info("Check: Remove Email:{},receiveTime:{}",message.getSubject(), DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss"));

View File

@ -74,27 +74,6 @@ public class FTPUtil {
return this.ftpRootPath;
}
public static void main(String[] args) {
try {
FTPClient ftp = new FTPClient();
//连接
ftp.connect("172.21.170.122", 21);
//登录
ftp.login("rmsops", "cnndc010");
// 切换为本地被动模式可以解决FTP上传后文件为空的问题但需要服务器将FTP服务添加至防火墙白名单
ftp.enterLocalPassiveMode();
//切换工作路径
ftp.changeWorkingDirectory("/SpectrumFile/admin");
//判断是否连接成功
int reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
System.out.printf(reply+"");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* 登录ftp
* @return
@ -110,7 +89,7 @@ public class FTPUtil {
// 切换为本地被动模式可以解决FTP上传后文件为空的问题但需要服务器将FTP服务添加至防火墙白名单
ftp.enterLocalPassiveMode();
//切换工作路径
ftp.changeWorkingDirectory("/");
ftp.changeWorkingDirectory(ftpRootPath);
//判断是否连接成功
int reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
@ -302,74 +281,39 @@ public class FTPUtil {
/**
* 写入文件若文件或文件目录不存在则自行创建
* @param filePath 文件路径
* @param fileName 文件名称
* @param inputStream 文件输入流
* @return 返回值true/false
*/
public synchronized boolean saveFile(String filePath, InputStream inputStream){
//声明目标文件
File targetFile = new File(filePath);
//创建输出流
FileOutputStream outputStream = null;
try {
//获取父级路径
File directory = targetFile.getParentFile();
//判断父级路径是否存在
if (!directory.exists()) {
directory.mkdirs();
public synchronized boolean saveFile(String filePath,String fileName,InputStream inputStream){
final FTPClient ftpClient = this.LoginFTP();
try{
final boolean flag = this.checkDirectory(ftpClient,filePath);
if(flag){
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
String encodedName = new String(fileName.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1);
final boolean result = ftpClient.storeFile(encodedName, inputStream);
return result;
}
// 创建输出流对象并写入数据到文件
outputStream = new FileOutputStream(targetFile);
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
// 关闭输入流和输出流
try {
if (Objects.nonNull(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();
}
if (Objects.nonNull(outputStream)) {
outputStream.close();
}
}
try {
ftpClient.disconnect();
} catch (IOException e) {
throw new RuntimeException(e);
e.printStackTrace();
}
}
return true;
// final FTPClient ftpClient = this.LoginFTP();
// try{
// final boolean flag = this.checkDirectory(ftpClient,filePath);
// if(flag){
// ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
// String encodedName = new String(fileName.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1);
// final boolean result = ftpClient.storeFile(encodedName, inputStream);
// return result;
// }
// }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();
// }
// }
// try {
// ftpClient.disconnect();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return false;
return false;
}
/**
@ -514,85 +458,65 @@ public class FTPUtil {
/*
* 将源FTP路径的文件保存为指定路径的临时文件
* */
public File downloadFile(String fromPath) {
//获取路径下的文件信息
File tempFile = new File(fromPath);
//判断文件是否存在
if (!tempFile.exists()) {
tempFile = null;
public File downloadFile(String fromPath, String toPath) {
FTPClient ftpClient = null;
InputStream inputStream = null;
// 声明一个临时文件
File tempFile = null;
try {
ftpClient = LoginFTP();
// 切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
inputStream = ftpClient.retrieveFileStream(fromPath);
if (Objects.nonNull(inputStream)) {
tempFile = File.createTempFile(toPath, null);
// 将FTP文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, tempFile);
}
return tempFile;
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
try {
if (ObjectUtil.isNotNull(ftpClient))
ftpClient.disconnect();
if (ObjectUtil.isNotNull(inputStream))
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return tempFile;
// FTPClient ftpClient = null;
// InputStream inputStream = null;
// // 声明一个临时文件
// File tempFile = null;
// try {
// //连接ftp
// ftpClient = LoginFTP();
// // 切换被动模式
// ftpClient.enterLocalPassiveMode();
// ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// // 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
// ftpClient.setControlEncoding("UTF-8");
// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
// inputStream = ftpClient.retrieveFileStream(fromPath);
// if (Objects.nonNull(inputStream)) {
// tempFile = File.createTempFile(toPath, null);
// // 将FTP文件的输入流复制给临时文件
// FileUtils.copyInputStreamToFile(inputStream, tempFile);
// }
// return tempFile;
// } catch (IOException e) {
// e.printStackTrace();
// return null;
// } finally {
// try {
// if (ObjectUtil.isNotNull(ftpClient))
// ftpClient.disconnect();
// if (ObjectUtil.isNotNull(inputStream))
// inputStream.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
}
/*
* 将源FTP路径的文件转换为文件流
* */
public InputStream downloadFileStream(String fromPath) {
//获取路径下的文件信息
File tempFile = new File(fromPath);
InputStream inputStream = null;
FTPClient ftpClient = null;
try {
//判断文件是否存在
if (tempFile.exists()) {
inputStream = new FileInputStream(tempFile);
ftpClient = LoginFTP();
// 切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
return ftpClient.retrieveFileStream(fromPath);
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
try {
if (ObjectUtil.isNotNull(ftpClient))
ftpClient.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
return inputStream;
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
// FTPClient ftpClient = null;
// try {
// ftpClient = LoginFTP();
// // 切换被动模式
// ftpClient.enterLocalPassiveMode();
// ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// // 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
// ftpClient.setControlEncoding("UTF-8");
// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
// return ftpClient.retrieveFileStream(fromPath);
// } catch (IOException e) {
// e.printStackTrace();
// return null;
// } finally {
// try {
// if (ObjectUtil.isNotNull(ftpClient))
// ftpClient.disconnect();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
}
}

View File

@ -15,13 +15,9 @@ public enum SystemType {
*/
GAMMA("G"),
/**
* 自建台站 β-γ
* 自建台站
*/
SELFSTATION("C"),
/**
* 海水系统 γ
*/
WATER("W");
SELFSTATION("C");
private String type;

View File

@ -0,0 +1,26 @@
package org.jeecg.modules.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.modules.service.CalculateConcService;
import org.jeecg.modules.service.IAlarmAnalysisNuclideParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(value = "定时计算核素浓度" ,tags="定时计算核素浓度")
@RestController
@RequestMapping("calculateConc")
public class CalculateConcController {
@Autowired
private CalculateConcService calculateConcService;
@GetMapping("caclAndSave")
@ApiOperation(value = "计算并保存核素浓度",notes = "计算并保存核素浓度")
public void caclAndSave(){
calculateConcService.calcAndSave();
}
}

View File

@ -18,8 +18,10 @@ import org.jeecg.common.config.mqtoken.UserTokenContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.constant.enums.SampleType;
import org.jeecg.common.util.*;
import org.jeecg.common.util.dynamic.db.FreemarkerParseFactory;
import org.jeecg.common.util.DataTool;
import org.jeecg.common.util.RedisStreamUtil;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TemplateUtil;
import org.jeecg.modules.base.dto.NuclideInfo;
import org.jeecg.modules.base.dto.Info;
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisLog;
@ -43,7 +45,6 @@ import static org.jeecg.modules.base.enums.Template.ANALYSIS_NUCLIDE;
import static org.jeecg.modules.base.enums.Template.MONITOR_EMAIL;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -79,7 +80,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
try {
String streamKey = message.getStream();
init();
/*
/**
* 新消息在未进行ACK之前,状态也为pending,
* 直接消费所有异常未确认的消息和新消息
*/
@ -94,10 +95,10 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
// 消费完成后,手动确认消费消息[消息消费成功]
// 否则就是消费抛出异常,进入pending_ids[消息消费失败]
redisStreamUtil.ack(streamKey, groupName, recordId.getValue());
// 手动删除已消费消息
redisStreamUtil.del(streamKey, recordId.getValue());
// TODO del 取消手动删除已消费消息
// redisStreamUtil.del(streamKey, recordId.getValue());
}
}catch (Exception e){
}catch (RuntimeException e){
log.error("AnalysisConsumer消费异常: {}", e.getMessage());
}finally {
destroy();
@ -117,8 +118,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
for (AlarmAnalysisRule rule : rules) {
// 当前规则是否有报警条件
String conditionStr = rule.getConditions();
if (StrUtil.isBlank(conditionStr))
continue;
if (StrUtil.isBlank(conditionStr)) continue;
// 是否在当前规则关注的台站列表内
String stations = rule.getStations();
if (!StrUtil.contains(stations, stationId))
@ -146,7 +146,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
info.setRuleId(rule.getId());
info.setGroupId(rule.getContactGroup());
info.setConditions(rule.getConditions());
judge(info, nuclidesCross);
judge(info,nuclidesCross);
}
}
@ -155,31 +155,27 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
String conditionStr = info.getConditions();
String betaOrGamma = info.getBetaOrGamma();
String datasource = info.getDatasource();
String stationId = info.getStationId();
// 获取谱文件采样日期 如果为null 则默认为LocalDate.now()
LocalDate collDate = ObjectUtil.isNull(info.getCollectionDate()) ? LocalDate.now() :
info.getCollectionDate().toLocalDate();
List<String> conditions = ListUtil.toList(conditionStr.split(COMMA));
List<String> firstDetected = new ArrayList<>(); // 首次发现
List<NuclideInfo> moreThanAvg = new ArrayList<>(); // 超浓度均值
List<String> meanwhile = new ArrayList<>(); // 同时出现两种及以上核素
for (String con : conditions) {
Condition condition = Condition.valueOf1(con);
if (ObjectUtil.isNull(condition)) continue;
switch (condition){
case FIRST_FOUND: // 首次发现该元素
firstDetected = firstDetected(betaOrGamma, datasource, nuclideNames);
break;
case ABOVE_AVERAGE: // 元素浓度高于均值
moreThanAvg = moreThanAvg(datasource, stationId, collDate, nuclidesCross);
break;
case MEANWHILE: // 同时出现两种及以上核素
if (CollUtil.isNotEmpty(nuclideNames) && nuclideNames.size() >= 2)
meanwhile.addAll(nuclideNames);
break;
default:
break;
if (ObjectUtil.isNotNull(condition)){
switch (condition){
case FIRST_FOUND: // 首次发现该元素
firstDetected = firstDetected(betaOrGamma, datasource, nuclideNames);
break;
case ABOVE_AVERAGE: // 元素浓度高于均值
moreThanAvg = moreThanAvg(datasource,nuclidesCross);
break;
case MEANWHILE: // 同时出现两种及以上核素
if (CollUtil.isNotEmpty(nuclideNames) && nuclideNames.size() >= 2)
meanwhile.addAll(nuclideNames);
break;
default:
break;
}
}
}
// 构建预警信息
@ -228,12 +224,12 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
/**
* 核素值大于历史浓度均值
*/
private List<NuclideInfo> moreThanAvg(String dataSourceType, String stationId,
LocalDate collDate, Map<String,String> nuclidesCross){
private List<NuclideInfo> moreThanAvg(String dataSourceType,
Map<String,String> nuclidesCross){
List<NuclideInfo> nuclideInfos = new ArrayList<>();
Set<String> nuclideNames = nuclidesCross.keySet();
Map<String, String> nuclideAvgs = nuclideAvgService
.list(nuclideNames, dataSourceType, stationId, collDate).stream()
.list(nuclideNames, dataSourceType).stream()
.collect(Collectors.toMap(AlarmAnalysisNuclideAvg::getNuclide,
AlarmAnalysisNuclideAvg::getVal));
for (Map.Entry<String, String> nuclide : nuclidesCross.entrySet()) {
@ -253,26 +249,25 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
nuclideInfo.setNuclide(nuclideName);
nuclideInfo.setThreshold(avg.toString());
nuclideInfo.setDatasource(DSType.typeOf(dataSourceType));
// 对浓度值保留五位小数
nuclideInfo.setValue(NumUtil.keepStr(concValue, 5));
nuclideInfo.setValue(conc.toString());
nuclideInfos.add(nuclideInfo);
}
return nuclideInfos;
}
private void init() {
// start 生成临时Token到线程中
// start:生成临时Token到线程中
UserTokenContext.setToken(getTempToken());
systemClient = SpringContextUtils.getBean(SystemClient.class);
redisStreamUtil = SpringContextUtils.getBean(RedisStreamUtil.class);
logService = SpringContextUtils.getBean(IAlarmAnalysisLogService.class);
ruleService = SpringContextUtils.getBean(IAlarmAnalysisRuleService.class);
analysisResultService = SpringContextUtils.getBean(AnalysisResultService.class);
ruleService = SpringContextUtils.getBean(IAlarmAnalysisRuleService.class);
nuclideAvgService = SpringContextUtils.getBean(IAlarmAnalysisNuclideAvgService.class);
}
private void destroy(){
// end 删除临时Token
// end:删除临时Token
UserTokenContext.remove();
}
}

View File

@ -34,6 +34,10 @@ public class RedisStreamConfig {
// 每次轮询取几条消息
private final Integer maxMsg = 10;
private final String alarmKey = RedisConstant.STREAM_ALARM;
private final String alarmGroup = RedisConstant.GROUP_ALARM;
private final String alarmConsumer = RedisConstant.CONSUMER_ALARM;
private final String analysisKey = RedisConstant.STREAM_ANALYSIS;
private final String analysisGroup = RedisConstant.GROUP_ANALYSIS;
private final String analysisConsumer = RedisConstant.CONSUMER_ANALYSIS;
@ -99,7 +103,7 @@ public class RedisStreamConfig {
// 独立消费
/*streamMessageListenerContainer.receive(StreamOffset.fromStart(streamKey),
new ConsumeListener("独立消费", null, null));*/
// 非独立消费
/*
register:用于注册一个消息监听器,该监听器将在每次有新的消息到达Redis Stream时被调用
这种方式适用于长期运行的消息消费者它会持续监听Redis Stream并处理新到达的消息
@ -107,28 +111,24 @@ public class RedisStreamConfig {
receive:用于主动从Redis Stream中获取消息并进行处理,你可以指定要获取的消息数量和超时时间
这种方式适用于需要主动控制消息获取的场景,例如批量处理消息或定时任务
**/
/* 1.需要手动确认消费消息 */
// 1.1 使用 register 方式
StreamMessageListenerContainer.ConsumerStreamReadRequest<String> readRequest = StreamMessageListenerContainer
// 注册消费组A中的消费者A1,手动ACK
/*ConsumerStreamReadRequest<String> readA1 = StreamMessageListenerContainer
.StreamReadRequest
.builder(StreamOffset.create(analysisKey, ReadOffset.lastConsumed()))
.consumer(Consumer.from(analysisGroup, analysisConsumer))
// 手动确认消费了消息 默认为自动确认消息
.builder(StreamOffset.create(warnKey, ReadOffset.lastConsumed()))
.consumer(Consumer.from(groupWarnA, consumerWarnA1))
.autoAcknowledge(false)
// 如果消费者发生了异常 不禁止消费者消费 默认为禁止
// 如果消费者发生了异常,是否禁止消费者消费
.cancelOnError(throwable -> false)
.build();
AnalysisConsumer analysis = new AnalysisConsumer(analysisGroup, analysisConsumer);
streamMessageListenerContainer.register(readRequest, analysis);
// 1.2 使用 receive 方式
/*AnalysisConsumer analysis = new AnalysisConsumer(analysisGroup, analysisConsumer);
ConsumeA1 consumeA1 = new ConsumeA1(groupWarnA, consumerWarnA1);
streamMessageListenerContainer.register(readA1, consumeA1);*/
AnalysisConsumer analysis = new AnalysisConsumer(analysisGroup,analysisConsumer);
streamMessageListenerContainer.receive(Consumer.from(analysisGroup, analysisConsumer),
StreamOffset.create(analysisKey, ReadOffset.lastConsumed()), analysis);*/
/* 2.自动确认消费消息 */
// 2.1 使用 receive 方式
/*AnalysisConsumer analysis = new AnalysisConsumer(analysisGroup,analysisConsumer);
streamMessageListenerContainer.receiveAutoAck(Consumer.from(analysisGroup, analysisConsumer),
StreamOffset.create(analysisKey, ReadOffset.lastConsumed()), analysis);*/
StreamOffset.create(analysisKey, ReadOffset.lastConsumed()), analysis);
// 创建消费组A中的消费者A2,自动ACK
/* ConsumeA2 consumeA2 = new ConsumeA2(consumerWarnA2);
streamMessageListenerContainer.receiveAutoAck(Consumer.from(groupWarnA, consumerWarnA2),
StreamOffset.create(warnKey, ReadOffset.lastConsumed()), consumeA2);*/
return streamMessageListenerContainer;
}
}

View File

@ -6,14 +6,12 @@ import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.bizVo.NuclideAvgVo;
import java.time.LocalDate;
import java.util.List;
import java.util.Set;
public interface IAlarmAnalysisNuclideAvgService extends IService<AlarmAnalysisNuclideAvg> {
List<AlarmAnalysisNuclideAvg> list(Set<String> nuclideNames, String dataSourceType,
String stationId, LocalDate collDate);
List<AlarmAnalysisNuclideAvg> list(Set<String> nuclideNames,String dataSourceType);
Page<NuclideAvgDto> findPage(NuclideAvgVo nuclideAvgVo);
}

View File

@ -15,7 +15,6 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -28,15 +27,13 @@ public class AlarmAnalysisNuclideAvgServiceImpl extends ServiceImpl<AlarmAnalysi
private SystemClient systemClient;
@Override
public List<AlarmAnalysisNuclideAvg> list(Set<String> nuclideNames, String dataSourceType,
String stationId, LocalDate collDate) {
LocalDate dayAgo = collDate.minusDays(1);
public List<AlarmAnalysisNuclideAvg> list(Set<String> nuclideNames,String dataSourceType) {
LocalDate dayAgo = LocalDate.now().minusDays(1);
LambdaQueryWrapper<AlarmAnalysisNuclideAvg> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(AlarmAnalysisNuclideAvg::getStationId, stationId);
wrapper.eq(AlarmAnalysisNuclideAvg::getDataSourceType, dataSourceType);
wrapper.eq(AlarmAnalysisNuclideAvg::getCaclDate, dayAgo);
wrapper.eq(AlarmAnalysisNuclideAvg::getDataSourceType,dataSourceType);
wrapper.eq(AlarmAnalysisNuclideAvg::getCaclDate,dayAgo);
wrapper.in(AlarmAnalysisNuclideAvg::getNuclide,nuclideNames);
return this.list(wrapper);
return list(wrapper);
}
@Override

View File

@ -15,6 +15,7 @@ import org.jeecg.modules.spectrum.SpectrumServiceQuotes;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -119,7 +120,6 @@ public class AutoProcessManager{
TimeUnit.MILLISECONDS.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
}
@ -158,7 +158,7 @@ public class AutoProcessManager{
//如果这时邮箱线程里已有执行的线程则设置停止标记
if(emailExecThreadMap.containsKey(email.getId())){
EmailParsingActuator actuator = emailExecThreadMap.get(email.getId());
actuator.setThreadSleep(true);
actuator.setStop(true);
actuator.setStopTime(new Date());
}
log.info("{}邮箱测试连接失败emailMap删除此邮箱数据emailExecThreadMap设置线程停止标记",email.getUsername());
@ -169,7 +169,6 @@ public class AutoProcessManager{
//捕获异常不处理保障线程异常不退出
}catch (Exception e){
e.printStackTrace();
log.error(e.getMessage(), e);
}
long end = System.currentTimeMillis();
long sleepTime = taskProperties.getMonitoringMailCommStatusCycle() - (end-start);
@ -179,7 +178,6 @@ public class AutoProcessManager{
TimeUnit.MILLISECONDS.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
}
@ -237,7 +235,7 @@ public class AutoProcessManager{
if(testFlag){
if (emailExecThreadMap.containsKey(databaseEmail.getId())) {
EmailParsingActuator actuator = emailExecThreadMap.get(databaseEmail.getId());
actuator.setThreadSleep(false);
actuator.setStop(false);
log.info("{}邮箱重新加入监测队列",databaseEmail.getUsername());
} else {
databaseEmail.setNewEmailFlag(true);
@ -253,7 +251,6 @@ public class AutoProcessManager{
//捕获异常不处理保障线程异常不退出
}catch (Exception e){
e.printStackTrace();
log.error(e.getMessage(), e);
}
long end = System.currentTimeMillis();
long sleepTime = taskProperties.getMonitoringMailDataCycle() - (end-start);
@ -263,7 +260,6 @@ public class AutoProcessManager{
TimeUnit.MILLISECONDS.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
}
@ -308,7 +304,6 @@ public class AutoProcessManager{
}
}catch (Exception e){
e.printStackTrace();
log.error(e.getMessage(), e);
}finally {
if(emailExecThread.getState() != State.TERMINATED && emailExecThread.isStop()){
final long nowTime = System.currentTimeMillis();
@ -330,7 +325,6 @@ public class AutoProcessManager{
TimeUnit.MILLISECONDS.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
}

View File

@ -17,7 +17,10 @@ import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.*;
/**
@ -36,8 +39,6 @@ public class EmailParsingActuator extends Thread{
@Setter @Getter
private boolean isStop;
@Setter @Getter
private boolean threadSleep;
@Setter @Getter
private Date stopTime;
public void init(EmailProperties emailProperties,SpectrumServiceQuotes spectrumServiceQuotes,
@ -64,17 +65,8 @@ public class EmailParsingActuator extends Thread{
@Override
public void run() {
for(;;){
String nowDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
if (threadSleep) {
log.info(nowDate + " " +this.emailProperties.getName()+" EmailParsingActuator is sleep!");
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
log.error("Thread sleep error");
}
continue;
}
if (isStop) {
String nowDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
log.info(nowDate + " " +this.emailProperties.getName()+" EmailParsingActuator is Stop!");
closeResource();
return;
@ -86,14 +78,10 @@ public class EmailParsingActuator extends Thread{
List<String> messageIds = new ArrayList<>();
try {
Message[] messages = emailServiceManager.receiveMail();
log.info("EmailParsingActuator本次{}获取邮件数量为:{}", Thread.currentThread().getName(), ArrayUtils.isEmpty(messages) ? 0 : messages.length);
if(ArrayUtils.isNotEmpty(messages)){
log.info("EmailParsingActuator本次{}获取邮件数量为:{}", Thread.currentThread().getName(), messages.length);
//检验获取的邮件是否在之前删除失败列表中若在直接调用邮件API删除并且此次数组里元素也删除
for(int i=messages.length-1;i>=0;i--){
if (null == messages[i].getHeader("Message-ID")) {
messages = ArrayUtils.remove(messages, i);
continue;
}
if (!messages[i].isExpunged()){
String messageId = ((MimeMessage) messages[i]).getMessageID();
final boolean exist = emailServiceManager.check(messages[i],messageId);
@ -115,14 +103,11 @@ public class EmailParsingActuator extends Thread{
poolExecutor.execute(spectrumParsingActuator);
}
taskLatch.await();
log.info("EmailParsingActuator本次{}封邮件处理完成", messages.length);
}
}
} catch (Exception e) {
log.error("EmailParsingActuator has exception: {}", e.getMessage());
log.info("Mail-Parsing线程池资源关闭...");
closeResource();
log.error(e.getMessage(), e);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (MessagingException e) {
throw new RuntimeException(e);
} finally {
//清除本批次邮件日志缓存
@ -143,8 +128,6 @@ public class EmailParsingActuator extends Thread{
TimeUnit.MILLISECONDS.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
throw new RuntimeException();
}
}
}

View File

@ -84,8 +84,7 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
LambdaQueryWrapper<GardsSampleData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSampleData::getInputFileName,inputFileName);
final GardsSampleData sampleData = this.getOne(queryWrapper);
if(Objects.nonNull(sampleData) && !SampleStatus.COMPLETE.getValue().equals(sampleData.getStatus())
&& !SampleStatus.INTERACTIVE.getValue().equals(sampleData.getStatus())){
if(Objects.nonNull(sampleData) && !SampleStatus.COMPLETE.getValue().equals(sampleData.getStatus())){
this.baseMapper.updateStatus(status,inputFileName);
}
}

View File

@ -17,10 +17,7 @@ import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
import org.jeecg.modules.eneity.event.SpectrumLog;
import org.jeecg.modules.enums.ErrorType;
import org.jeecg.modules.enums.SpectrumSource;
import org.jeecg.modules.exception.AnalySpectrumException;
import org.jeecg.modules.exception.AnalyseException;
import org.jeecg.modules.exception.FileRepeatException;
import org.jeecg.modules.exception.HeaderBlockException;
import org.jeecg.modules.exception.*;
import org.jeecg.modules.file.FileOperation;
import java.io.File;
import java.io.FileNotFoundException;
@ -316,7 +313,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
ex.printStackTrace();
}
} else if(SpectrumSource.FROM_FILE_SOURCE.getSourceType().equals(spectrumSource) && (e instanceof FileRepeatException)){
//this.spectrumFile.delete(); // TODO 删除原始谱文件
this.spectrumFile.delete();
} else if (SpectrumSource.FORM_FILE_UNDEL.getSourceType().equals(spectrumSource) && !(e instanceof FileRepeatException)) {
try {
if (isDateFormatErr) {

View File

@ -97,6 +97,9 @@ public class SpectrumParsingActuator implements Runnable{
String emlName = subject+ StringConstant.UNDER_LINE+ receiveDate;
String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;
// spectrumServiceQuotes.getRedisUtil().set(key,emlName,expiryTime);
//判断当前key的下载次数是否超过限制次数
spectrumServiceQuotes.getRedisUtil().incr(key, 1L);
spectrumServiceQuotes.getRedisUtil().expire(key, expiryTime);
//线程开始初始化时初始本线程负责的能谱日志事件
SpectrumLogManager.mailSpectrumLogManager.offer(Thread.currentThread().getId(),null);
@ -141,10 +144,7 @@ public class SpectrumParsingActuator implements Runnable{
log.warn("This email {} parsing failed and is not listed in the Met, Alert, SOH, Sample, Detbkphd, QC, Gasbkphd spectra.",subject);
}
emailServiceManager.removeMail(message,batchesCounter);
} else {
//判断当前key的下载次数是否超过限制次数
spectrumServiceQuotes.getRedisUtil().incr(key, 1L);
spectrumServiceQuotes.getRedisUtil().expire(key, expiryTime);
}else {
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
if (Objects.nonNull(emlFile) && emlFile.exists()){
moveEmail(emlFile, key);

View File

@ -70,9 +70,9 @@ public class GammaFileUtil extends AbstractLogOrReport {
//如果功能是人工交互模块则从ftp获取文件内容
File file = null;
if (sysSource.equals("BetaGamma")) {
file = ftpUtil.downloadFile(fromPath);
file = ftpUtil.downloadFile(fromPath, "betaGamma");
if (Objects.isNull(file)) {
result.error500("file can't find");
result.error500("ftp file can't find");
return false;
}
} else if (sysSource.equals("AUTO")) {//如果是自动处理则从本地文件中获取文件内容
@ -265,7 +265,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
try {
String lcFileName = prefixName+"_"+subFileName + ".lc";
String fromPathLc = pathName + StringPool.SLASH + lcFileName;
lcFile = ftpUtil.downloadFile(fromPathLc);
lcFile = ftpUtil.downloadFile(fromPathLc, "betaGamma");
if (Objects.nonNull(lcFile)) {
List<String> readLinesLc = FileUtils.readLines(lcFile, "UTF-8");
//得到行数据处理后的数据结果
@ -275,7 +275,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
}
String scacFileName = prefixName+"_"+subFileName + ".scac";
String fromPathScac = pathName + StringPool.SLASH + scacFileName;
scacFile = ftpUtil.downloadFile(fromPathScac);
scacFile = ftpUtil.downloadFile(fromPathScac, "betaGamma");
if (Objects.nonNull(scacFile)) {
List<String> readLinesScac = FileUtils.readLines(scacFile, "UTF-8");
//得到行数据处理后的数据结果
@ -298,6 +298,10 @@ public class GammaFileUtil extends AbstractLogOrReport {
try {
if (ObjectUtil.isNotNull(inputStreamBase))
inputStreamBase.close();
if (ObjectUtil.isNotNull(lcFile))
lcFile.delete();
if (ObjectUtil.isNotNull(scacFile))
scacFile.delete();
} catch (IOException e) {
e.printStackTrace();
}
@ -3230,10 +3234,8 @@ public class GammaFileUtil extends AbstractLogOrReport {
File sampleTmp = null;
try {
sampleTmp = new File(fileAnlyse.getTmpFilePath());
//sample文件的存储路径
String saveSamplePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + middleData.analyses_save_filePath;
if (Objects.nonNull(sampleTmp) && !saveSamplePath.equals(fileAnlyse.getTmpFilePath().replace(StringPool.BACK_SLASH, StringPool.SLASH))) {
bRet = ftpUtil.saveFile(saveSamplePath, new FileInputStream(sampleTmp));
if (Objects.nonNull(sampleTmp)) {
bRet = ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + middleData.analyses_save_filePath.substring(0, middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)), middleData.analyses_save_filePath.substring(middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)+1), new FileInputStream(sampleTmp));
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
@ -4367,7 +4369,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
public File analyzeFile(String path, String fileName) {
path = path.replace("\\", "/");
String fromPath = path + StringPool.SLASH + fileName;
return ftpUtil.downloadFile(fromPath);
return ftpUtil.downloadFile(fromPath, "betaGamma");
}
public List<String> readLine(String filePath) {

View File

@ -2,9 +2,7 @@ package org.jeecg.modules.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.modules.base.bizVo.FileVo;
import org.jeecg.modules.entity.FileInfo;
import org.jeecg.modules.entity.LogManage;
import org.jeecg.modules.service.ILogManageService;
@ -22,24 +20,31 @@ import java.util.List;
@Api(value = "日志管理", tags = "日志管理")
public class LogManageController {
@Autowired
private FTPUtil ftpUtil;
@Autowired
private ILogManageService logManageService;
@GetMapping("findFtpFolders")
@ApiOperation(value = "查询日志文件夹树形结构", notes = "查询日志文件夹树形结构")
public List<LogManage> findFtpFolders(String workPath) {
return logManageService.fileTree(workPath);
return logManageService.findFtpFolders(workPath);
}
/**
* 查询目录下文件内容
* @param path
* @return
*/
@GetMapping("findFiles")
@ApiOperation(value = "查询目录下文件内容", notes = "查询目录下文件内容")
public Result<?> findFiles(String path, FileVo fileVo) {
return logManageService.findFiles(path, fileVo);
public List<FileInfo> findFiles(String path) {
return logManageService.findFiles(path);
}
@PostMapping("downloadFile")
@ApiOperation(value = "ftp文件下载", notes = "ftp文件下载")
public void downloadFile(String localPath, HttpServletResponse response) {
logManageService.downloadFile(localPath, response);
public void downloadFile(String localPath, String fileName, HttpServletResponse response) {
ftpUtil.downloadFTPFile(localPath, response);
}
}

View File

@ -1,24 +1,24 @@
package org.jeecg.modules.service;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.base.bizVo.FileVo;
import org.jeecg.modules.entity.FileInfo;
import org.jeecg.modules.entity.LogManage;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
public interface ILogManageService {
/**
* 查询日志文件夹树形结构
* @param workPath
* @return
*/
List<LogManage> fileTree(String workPath);
List<LogManage> findFtpFolders(String workPath);
/**
* 查询目录下文件内容
* @param path
* @return
*/
Result<?> findFiles(String path, FileVo fileVo);
List<FileInfo> findFiles(String path);
void downloadFile(String localPath, HttpServletResponse response);
}

View File

@ -1,159 +1,192 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.Prompt;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.ExportUtil;
import org.jeecg.common.util.PageUtil;
import org.jeecg.modules.base.bizVo.FileVo;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.modules.entity.FileInfo;
import org.jeecg.modules.entity.LogManage;
import org.jeecg.modules.service.ILogManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@Service("logManageService")
public class LogManageServiceImpl implements ILogManageService {
@Autowired
private SpectrumPathProperties spectrumPath;
private FTPUtil ftpUtil;
@Override
public List<LogManage> fileTree(String workPath) {
public List<LogManage> findFtpFolders(String workPath) {
List<LogManage> result = new ArrayList<>();
workPath = spectrumPath.getRootPath() + StringPool.SLASH + workPath;
List<File> files = ListUtil.toList(FileUtil.ls(workPath));
if (CollUtil.isEmpty(files)) return result;
int num = 1;
for (File file : files) {
LogManage logManage = new LogManage();
logManage.setName(file.getName());
logManage.setOrderNum(num++);
logManage.setPath(workPath + StringPool.SLASH + file.getName());
List<LogManage> children = this.getChildren(logManage);
logManage.setHashChild(CollUtil.isNotEmpty(children));
logManage.setChildren(children);
result.add(logManage);
FTPClient ftpClient = ftpUtil.LoginFTP();
if(Objects.isNull(ftpClient)){
throw new RuntimeException("ftp connection failed!");
}
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
//切换工作文件路径
workPath = ftpUtil.getFtpRootPath()+StringPool.SLASH+workPath;
ftpClient.changeWorkingDirectory(workPath);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listDirectories());
if (CollectionUtils.isNotEmpty(ftpFiles)){
int num =1;
for (FTPFile ftpFile:ftpFiles) {
LogManage logManage = new LogManage();
logManage.setName(ftpFile.getName());
logManage.setOrderNum(num);
logManage.setParentNum(0);
logManage.setPath(workPath + StringPool.SLASH + ftpFile.getName());
result.add(logManage);
num++;
}
}
if (CollectionUtils.isNotEmpty(result)){
List<LogManage> list = new LinkedList<>();
for (LogManage logManage:result) {
list = this.findDirectory(ftpClient, list, logManage.getOrderNum(), workPath + StringPool.SLASH + logManage.getName() , logManage.getName());
ftpClient.changeToParentDirectory();
}
result.addAll(list);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (ftpClient != null){
ftpClient.disconnect();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
result = this.LogManageTree(result);
return result;
}
@Override
public Result<?> findFiles(String path, FileVo fileVo) {
String name = fileVo.getName();
Integer pageNo = fileVo.getPageNo();
Integer pageSize = fileVo.getPageSize();
Page<FileInfo> page = new Page<>(pageNo, pageSize);
List<File> files = CollUtil.toList(FileUtil.ls(path));
// 文件名过滤
if (StrUtil.isNotBlank(name))
files = files.stream().filter(file -> StrUtil.containsIgnoreCase(file.getName(), name))
.collect(Collectors.toList());
page.setTotal(files.size());
// 分页
files = PageUtil.page(pageNo, pageSize, files);
List<FileInfo> records = new ArrayList<>();
for (File file : files) {
if (FileUtil.isDirectory(file)) continue;
FileInfo fileInfo = new FileInfo();
fileInfo.setFileName(file.getName());
fileInfo.setFilePath(path + StringPool.SLASH + file.getName());
fileInfo.setFileSize(FileUtil.readableFileSize(file));
fileInfo.setFileDate(DateUtil.formatDateTime(FileUtil.lastModifiedTime(file)));
records.add(fileInfo);
public List<FileInfo> findFiles(String path) {
List<FileInfo> result = new ArrayList<>();
FTPClient ftpClient = ftpUtil.LoginFTP();
if (Objects.isNull(ftpClient)){
throw new RuntimeException("ftp connection failed!");
}
page.setRecords(records);
return Result.OK(page);
}
@Override
public void downloadFile(String localPath, HttpServletResponse response) {
OutputStream outputStream = null;
InputStream inputStream = null;
try {
// 如果是目录 则直接退出方法
if (FileUtil.isDirectory(localPath)) return;
// 判断是否存在此文件
if (!FileUtil.exist(localPath)) return;
// 获取文件名
String fileName = FileUtil.getName(localPath);
inputStream = FileUtil.getInputStream(localPath);
outputStream = ExportUtil.stream(response, fileName);
// 缓冲区大小
byte[] buffer = new byte[4096];
int bytesRead;
// 将文件输出流写入到输出流中
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
//切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
//切换工作文件路径
ftpClient.changeWorkingDirectory(path);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
if (CollectionUtils.isNotEmpty(ftpFiles)){
for (FTPFile ftpFile:ftpFiles) {
if (ftpFile.isFile()){
FileInfo fileInfo = new FileInfo();
fileInfo.setFileName(ftpFile.getName());
fileInfo.setFilePath(path + StringPool.SLASH + ftpFile.getName());
fileInfo.setFileSize(String.format("%.2f", Double.valueOf(Double.valueOf(ftpFile.getSize())/1024)) + "KB");
fileInfo.setFileDate(DateUtils.formatDate(ftpFile.getTimestamp(),"yyyy-MM-dd"));
result.add(fileInfo);
}
}
}
} catch (IOException e) {
log.error("文件{}下载失败 :{}", localPath, e.getMessage());
throw new RuntimeException(e);
} finally {
try {
if (ObjectUtil.isNotNull(inputStream))inputStream.close();
if (ObjectUtil.isNotNull(outputStream))outputStream.close();
if (ftpClient != null){
ftpClient.disconnect();
}
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
return result;
}
/**
* 获取当前目录节点所有子孙节点Tree
* 遍历查询当前路径下的文件夹信息
* @param ftpClient
* @param list
* @param filePath "/"开始和结束
* @return
*/
private List<LogManage> getChildren(LogManage parent){
List<LogManage> result = new LinkedList<>();
String parentPath = parent.getPath();
// 如果是文件 则直接返回空集合
if (FileUtil.isFile(parentPath)) return result;
List<File> files = ListUtil.toList(FileUtil.ls(parentPath));
// 如果当前目录不存在子文件 则返回空集合
if (CollUtil.isEmpty(files)) return result;
int parentOrderNum = parent.getOrderNum();
int num = parentOrderNum * 10 + 1;
for (File file : files) {
// 过滤掉文件 只收集目录
if (FileUtil.isFile(file)) continue;
LogManage logManage = new LogManage();
logManage.setName(file.getName());
logManage.setOrderNum(num++);
logManage.setHashParent(true);
logManage.setParentNum(parentOrderNum);
logManage.setPath(parentPath + StringPool.SLASH + file.getName());
List<LogManage> children = getChildren(logManage);
logManage.setHashChild(CollUtil.isNotEmpty(children));
logManage.setChildren(children);
result.add(logManage);
public List<LogManage> findDirectory(FTPClient ftpClient, List<LogManage> list, Integer parentNum, String filePath, String fileName){
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.changeWorkingDirectory(fileName);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listDirectories());
if (CollectionUtils.isNotEmpty(ftpFiles)){
int num = 1;
for (FTPFile file : ftpFiles) {
if (file.isDirectory()) {
LogManage logManage = new LogManage();
logManage.setName(file.getName());
logManage.setOrderNum(parentNum*10+num);
logManage.setParentNum(parentNum);
logManage.setPath(filePath + StringPool.SLASH + file.getName());
list.add(logManage);
// 需要加此判断否则ftp默认将项目文件所在目录之下的目录./项目文件所在目录向上一级目录下的目录../都纳入递归这样下去就陷入一个死循环了需将其过滤掉
if (!".".equals(file.getName()) && !"..".equals(file.getName())) {
findDirectory(ftpClient, list, parentNum*10+num, filePath + StringPool.SLASH + file.getName(), file.getName());
ftpClient.changeToParentDirectory();
}
num++;
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return list;
}
/**
* 将当前的文件夹转换成树形结构
* @param logManages
* @return
*/
public List<LogManage> LogManageTree(List<LogManage> logManages){
if (logManages == null) {
return null;
}
List<LogManage> result = new LinkedList<>();
Integer TOP_NODE_ID = 0;
logManages.forEach(logManage -> {
Integer pid = logManage.getParentNum();
if (pid == null || TOP_NODE_ID.equals(pid)) {
result.add(logManage);
return;
}
for (LogManage manage : logManages) {
Integer id = manage.getOrderNum();
if (id != null && id.equals(pid)) {
if (manage.getChildren() == null) {
manage.initChildren();
}
logManage.setHashParent(true);
manage.getChildren().add(logManage);
manage.setHashChild(true);
return;
}
}
});
return result;
}
}

View File

@ -817,7 +817,7 @@ public class PHDFileUtil extends AbstractLogOrReport {
File file = null;
try {
String fromPath = filePath + StringPool.SLASH + sampleFileName;
file = ftpUtil.downloadFile(fromPath);
file = ftpUtil.downloadFile(fromPath, "betaGamma");
//加载sampleFile内容
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
//获取所需要的数据
@ -841,6 +841,9 @@ public class PHDFileUtil extends AbstractLogOrReport {
}catch (Exception e){
e.printStackTrace();
return map;
}finally {
if (ObjectUtil.isNotNull(file))
file.delete();
}
}
@ -849,7 +852,7 @@ public class PHDFileUtil extends AbstractLogOrReport {
File file = null;
try {
String fromPath = filePath + StringPool.SLASH + fileName;
file = ftpUtil.downloadFile(fromPath);
file = ftpUtil.downloadFile(fromPath, "betaGamma");
EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
String systemType = sourceData.system_type;
String dataType = sourceData.data_type;
@ -883,6 +886,9 @@ public class PHDFileUtil extends AbstractLogOrReport {
}catch (Exception e){
e.printStackTrace();
return path.toString();
}finally {
if (ObjectUtil.isNotNull(file))
file.delete();
}
}
@ -1114,6 +1120,9 @@ public class PHDFileUtil extends AbstractLogOrReport {
if (Objects.nonNull(inputStream)){
inputStream.close();
}
if (Objects.nonNull(file)) {
file.delete();
}
} catch (IOException e) {
throw new RuntimeException(e);
}

View File

@ -1,7 +1,5 @@
package org.jeecg.common.util;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@ -11,17 +9,11 @@ import org.jeecg.modules.base.enums.CalName;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.BgBoundary;
import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.*;
@ -105,31 +97,8 @@ public class SelfStationUtil extends AbstractLogOrReport {
spectrumData.setDetectorBkMeasurementId(detectorBkMeasurementId);
spectrumData.setMeasurementId(measurementId);
map.put("spectrumData", spectrumData);
//计算边界值
List<Double> gEnergy = struct.g_energy;
List<Double> gCentroidChannel = struct.g_centroid_channel;
List<Double> bElectronEnergy = struct.b_electron_energy;
List<Double> bChannel = struct.b_channel;
CalcBgBoundaryParam calcBgBoundaryParam = new CalcBgBoundaryParam();
calcBgBoundaryParam.g_e_cal = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel);
calcBgBoundaryParam.b_e_cal = EnergySpectrumHandler.GetFileFittingPara(bElectronEnergy, bChannel);
calcBgBoundaryParam.b_energy = struct.b_electron_energy;
calcBgBoundaryParam.b_channel = struct.b_channel;
calcBgBoundaryParam.g_channel = struct.g_centroid_channel;
calcBgBoundaryParam.g_energy = struct.g_energy;
calcBgBoundaryParam.ROI_B_start_x1 = struct.POI_B_x1;
calcBgBoundaryParam.ROI_B_stop_x2 = struct.POI_B_x2;
calcBgBoundaryParam.ROI_G_start_y1 = struct.POI_G_y1;
calcBgBoundaryParam.ROI_G_stop_y2 = struct.POI_G_y2;
BgBoundary bgBoundary = EnergySpectrumHandler.CalcBgBoundary(calcBgBoundaryParam);
// 新beta谱只取X轴数据从Y轴0的位置开始连成一条线一直到顶画出矩形框 这个矩形框内的数据就是Gamma谱数据
List<Integer> roiBBoundaryStart = bgBoundary.ROI_B_Boundary_start;
List<Integer> roiBBoundaryStop = bgBoundary.ROI_B_Boundary_stop;
//根据范围1划分 范围1对应的折线图
Map<String, Object> oneMap = statisticsROIList(roiBBoundaryStart.get(0), roiBBoundaryStop.get(0), struct.b_channels, struct.g_channels, struct.h_counts);
Map<String, Object> oneMap = statisticsROIList(struct.POI_B_x1.get(0).intValue(), struct.POI_B_x2.get(0).intValue(), struct.b_channels, struct.g_channels, struct.h_counts);
if (CollectionUtils.isNotEmpty(oneMap) ) {
Integer startChannel = (Integer) oneMap.get("startChannel");
Integer endChannel = (Integer) oneMap.get("endChannel");
@ -138,18 +107,17 @@ public class SelfStationUtil extends AbstractLogOrReport {
selfStationData.getSampleVueData().setROIOneBetaStart(startChannel);
selfStationData.getSampleVueData().setROIOneBetaStop(endChannel);
selfStationData.getSampleVueData().setROIOneList(seriseDataList);
selfStationData.getSampleVueData().setROIOneCounts((List<Long>)oneMap.get("counts"));
} else if (systemType.equals("det")) {
selfStationData.getDetVueData().setROIOneBetaStart(startChannel);
selfStationData.getDetVueData().setROIOneBetaStop(endChannel);
selfStationData.getDetVueData().setROIOneList(seriseDataList);
}
map.put("ROIOneStart", roiBBoundaryStart.get(0));
map.put("ROIOneStop", roiBBoundaryStop.get(0));
map.put("ROIOneStart", startChannel);
map.put("ROIOneStop", endChannel);
map.put("ROIOneList", seriseDataList);
}
//根据范围2划分 范围2对应的折线图
Map<String, Object> twoMap = statisticsROIList(roiBBoundaryStart.get(1), roiBBoundaryStop.get(1), struct.b_channels, struct.g_channels, struct.h_counts);
Map<String, Object> twoMap = statisticsROIList(struct.POI_B_x1.get(1).intValue(), struct.POI_B_x2.get(1).intValue(), struct.b_channels, struct.g_channels, struct.h_counts);
if ( CollectionUtils.isNotEmpty(twoMap) ) {
Integer startChannel = (Integer) twoMap.get("startChannel");
Integer endChannel = (Integer) twoMap.get("endChannel");
@ -163,12 +131,12 @@ public class SelfStationUtil extends AbstractLogOrReport {
selfStationData.getDetVueData().setROITwoBetaStop(endChannel);
selfStationData.getDetVueData().setROITwoList(seriseDataList);
}
map.put("ROITwoStart", roiBBoundaryStart.get(1));
map.put("ROITwoStop", roiBBoundaryStop.get(1));
map.put("ROITwoStart", startChannel);
map.put("ROITwoStop", endChannel);
map.put("ROITwoList", seriseDataList);
}
//根据范围3划分 范围3对应的折线图
Map<String, Object> threeMap = statisticsROIList(roiBBoundaryStart.get(2), roiBBoundaryStop.get(2), struct.b_channels, struct.g_channels, struct.h_counts);
Map<String, Object> threeMap = statisticsROIList(struct.POI_B_x1.get(2).intValue(), struct.POI_B_x2.get(2).intValue(), struct.b_channels, struct.g_channels, struct.h_counts);
if ( CollectionUtils.isNotEmpty(threeMap) ) {
Integer startChannel = (Integer) threeMap.get("startChannel");
Integer endChannel = (Integer) threeMap.get("endChannel");
@ -181,14 +149,13 @@ public class SelfStationUtil extends AbstractLogOrReport {
selfStationData.getDetVueData().setROIThreeBetaStart(startChannel);
selfStationData.getDetVueData().setROIThreeBetaStop(endChannel);
selfStationData.getDetVueData().setROIThreeList(seriseDataList);
selfStationData.getSampleVueData().setROIOneCounts((List<Long>)threeMap.get("counts"));
}
map.put("ROIThreeStart", roiBBoundaryStart.get(2));
map.put("ROIThreeStop", roiBBoundaryStop.get(2));
map.put("ROIThreeStart", startChannel);
map.put("ROIThreeStop", endChannel);
map.put("ROIThreeList", seriseDataList);
}
//根据范围4划分 范围4对应的折线图
Map<String, Object> fourMap = statisticsROIList(roiBBoundaryStart.get(3), roiBBoundaryStop.get(3), struct.b_channels, struct.g_channels, struct.h_counts);
Map<String, Object> fourMap = statisticsROIList(struct.POI_B_x1.get(3).intValue(), struct.POI_B_x2.get(3).intValue(), struct.b_channels, struct.g_channels, struct.h_counts);
if ( CollectionUtils.isNotEmpty(fourMap) ) {
Integer startChannel = (Integer) fourMap.get("startChannel");
Integer endChannel = (Integer) fourMap.get("endChannel");
@ -202,8 +169,8 @@ public class SelfStationUtil extends AbstractLogOrReport {
selfStationData.getDetVueData().setROIFourBetaStop(endChannel);
selfStationData.getDetVueData().setROIFourList(seriseDataList);
}
map.put("ROIFourStart", roiBBoundaryStart.get(3));
map.put("ROIFourStop", roiBBoundaryStop.get(3));
map.put("ROIFourStart", startChannel);
map.put("ROIFourStop", endChannel);
map.put("ROIFourList", seriseDataList);
}
//散点图
@ -239,9 +206,9 @@ public class SelfStationUtil extends AbstractLogOrReport {
map.put("histogramDataList", histogramDataList);
// map.put("histogramDataDList", histogramDataDList);
//gamma能量部分的计算参数 道值
// List<Double> gCentroidChannel = struct.g_centroid_channel;
List<Double> gCentroidChannel = struct.g_centroid_channel;
//gamma能量部分的计算参数 道值对应能量
// List<Double> gEnergy = struct.g_energy;
List<Double> gEnergy = struct.g_energy;
//调用算法 传入道值和道值对应的能量 得到计算gamma能量公式的参数
List<Double> gammaParam = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
//存储需要计算gamma能量的道值
@ -254,9 +221,9 @@ public class SelfStationUtil extends AbstractLogOrReport {
//将gamma能量折线图进行赋值返回
map.put("gammaEnergyData", gammaEnergyList);
//beta能量部分的计算参数 道值
// List<Double> bChannel = struct.b_channel;
List<Double> bChannel = struct.b_channel;
//beta能量部分的计算参数 道值对应的能量
// List<Double> bElectronEnergy = struct.b_electron_energy;
List<Double> bElectronEnergy = struct.b_electron_energy;
//调用算法 传入道值和道值对应的能量 得到计算beta能量公式的参数
List<Double> betaParam = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
List<Double> bchannels = new ArrayList<>();
@ -333,7 +300,7 @@ public class SelfStationUtil extends AbstractLogOrReport {
File file = null;
try {
//根据完整的文件路径 获取临时文件
file = ftpUtil.downloadFile(filePathName);
file = ftpUtil.downloadFile(filePathName, "betaGamma");
if (Objects.nonNull(file)) {
if (type.equalsIgnoreCase("sample")) {
selfStationData.setSampleTmpPath(file.getAbsolutePath());
@ -359,8 +326,6 @@ public class SelfStationUtil extends AbstractLogOrReport {
*/
public Map<String, Object> statisticsROIList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, List<Long> h_counts) {
Map<String, Object> map = new HashMap<>();
// g_counts
List<Long> counts = new LinkedList<>();
//存储同一列不同行加和后的数量
List<Integer> sumList = new LinkedList<>();
List<SeriseData> seriseDataList = new LinkedList<>();
@ -375,21 +340,18 @@ public class SelfStationUtil extends AbstractLogOrReport {
int index = (int) (i * betaChannels + j);
long count = 0;
//判断下标是否在h_counts范围内
if (index > 0 && index < h_counts.size()) {
if (index < h_counts.size()) {
count = h_counts.get(index);
}
sum+=count;
}
seriseData.setY(sum);
sumList.add(sum);
counts.add((long) sum);
seriseDataList.add(seriseData);
}
map.put("startChannel", startChannel);
map.put("endChannel", endChannel);
map.put("dataList", seriseDataList);
map.put("counts", counts);
Console.log(counts.toString());
return map;
}
@ -660,303 +622,5 @@ public class SelfStationUtil extends AbstractLogOrReport {
map.put("AllData", datalist);
}
/**
* 根据DLL解析GammaPHD内容 得到PHDFile实体
* @param fileName
* @param pathName
* @return
*/
public PHDFile getGammaPHD(String fileName, String pathName) {
PHDFile phd = new PHDFile();
phd.setFilepath(pathName);
phd.setFilename(fileName);
File file = new File(pathName + StringPool.SLASH + fileName);
phd.setTmpFilePath(file.getAbsolutePath());
try {
//读取文件信息
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
//MsgInfo
phd.getMsgInfo().setMsg_id(struct.msg_id);
phd.getMsgInfo().setMsg_type(struct.msg_type);
phd.getMsgInfo().setData_type(struct.data_type);
//Header
phd.getHeader().setDesignator(struct.designator);
phd.getHeader().setSite_code(struct.site_code);
phd.getHeader().setDetector_code(struct.detector_code);
phd.getHeader().setSystem_type(struct.system_type);
phd.getHeader().setSample_geometry(struct.sample_geometry);
phd.getHeader().setSpectrum_quantity(struct.spectrum_quantity);
phd.getHeader().setSample_ref_id(struct.sample_ref_id);
phd.getHeader().setMeasurement_id(struct.measurement_id);
phd.getHeader().setDetector_bk_measurement_id(struct.detector_bk_measurement_id);
phd.getHeader().setGas_bk_measurement_id(struct.gas_bk_measurement_id);
phd.getHeader().setTransmit_date(struct.transmit_date);
phd.getHeader().setTransmit_time(struct.transmit_time);
//Comment
phd.setOriTotalCmt(struct.comment);
//Collection
if (StrUtil.isNotBlank(struct.collection_start_date) && StrUtil.isNotBlank(struct.collection_start_time)
&& StrUtil.isNotBlank(struct.collection_stop_date) && StrUtil.isNotBlank(struct.collection_stop_time)
&& Objects.nonNull(struct.air_volume)) {
phd.getCollect().setCollection_start_date(struct.collection_start_date);
phd.getCollect().setCollection_start_time(struct.collection_start_time);
phd.getCollect().setCollection_stop_date(struct.collection_stop_date);
phd.getCollect().setCollection_stop_time(struct.collection_stop_time);
phd.getCollect().setAir_volume(struct.air_volume);
if (phd.getCollect().getCollection_start_time().indexOf('.') < 0) {
phd.getCollect().setCollection_start_time(phd.getCollect().getCollection_start_time() + ".0");
}
if (phd.getCollect().getCollection_stop_time().indexOf('.') < 0) {
phd.getCollect().setCollection_stop_time(phd.getCollect().getCollection_stop_time() + ".0");
}
} else {
phd.getCollect().setAir_volume(0.0);
}
//Acquisition
if (StrUtil.isNotBlank(struct.acquisition_start_date) && StrUtil.isNotBlank(struct.acquisition_start_time)
&& Objects.nonNull(struct.acquisition_real_time) && Objects.nonNull(struct.acquisition_live_time)) {
phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date);
phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time);
phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time);
phd.getAcq().setAcquisition_live_time(struct.acquisition_live_time);
if (phd.getAcq().getAcquisition_start_time().indexOf('.') < 0) {
phd.getAcq().setAcquisition_start_time(phd.getAcq().getAcquisition_start_time() + ".0");
}
} else {
phd.getAcq().setAcquisition_live_time(0.0);
phd.getAcq().setAcquisition_real_time(0.0);
}
//Processing
if (Objects.nonNull(struct.sample_volume_of_Xe) && Objects.nonNull(struct.uncertainty_1)
&& Objects.nonNull(struct.Xe_collection_yield) && Objects.nonNull(struct.uncertainty_2)
&& StrUtil.isNotBlank(struct.archive_bottle_id)) {
phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe);
phd.getProcess().setUncertainty_1(struct.uncertainty_1);
phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield);
phd.getProcess().setUncertainty_2(struct.uncertainty_2);
phd.getProcess().setArchive_bottle_id(struct.archive_bottle_id);
} else {
phd.getProcess().setSample_volume_of_Xe(0.0);
phd.getProcess().setXe_collection_yield(0.0);
phd.getProcess().setUncertainty_1(0.0);
phd.getProcess().setUncertainty_2(0.0);
}
//Sample
if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) {
phd.getSampleBlock().setDimension_1(struct.dimension_1);
phd.getSampleBlock().setDimension_2(struct.dimension_2);
} else {
phd.getSampleBlock().setDimension_1(0.0);
phd.getSampleBlock().setDimension_2(0.0);
}
//Calibration
if (StrUtil.isNotBlank(struct.date_calibration) && StrUtil.isNotBlank(struct.time_calibration)) {
phd.getCalibration().setDate_calibration(struct.date_calibration);
phd.getCalibration().setTime_calibration(struct.time_calibration);
}
//Certificate
if (Objects.nonNull(struct.total_source_activity) && StrUtil.isNotBlank(struct.assay_date)
&& StrUtil.isNotBlank(struct.assay_time) && StrUtil.isNotBlank(struct.units_activity)
&& CollectionUtils.isNotEmpty(struct.nuclide_name)
&& CollectionUtils.isNotEmpty(struct.half_life_time) && CollectionUtils.isNotEmpty(struct.time_unit)
&& CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) && CollectionUtils.isNotEmpty(struct.uncertainty)
&& CollectionUtils.isNotEmpty(struct.cer_g_energy) && CollectionUtils.isNotEmpty(struct.g_intensity)
&& CollectionUtils.isNotEmpty(struct.electron_decay_mode) && CollectionUtils.isNotEmpty(struct.maximum_energy)
&& CollectionUtils.isNotEmpty(struct.intensity_b_particle) && Objects.nonNull(struct.record_count)) {
phd.getCertificate().setTotal_source_activity(struct.total_source_activity);
phd.getCertificate().setAssay_date(struct.assay_date);
phd.getCertificate().setAssay_time(struct.assay_time);
phd.getCertificate().setUnits_activity(struct.units_activity);
phd.getCertificate().setNuclide_name(struct.nuclide_name);
phd.getCertificate().setHalf_life_time(struct.half_life_time);
phd.getCertificate().setTime_unit(struct.time_unit);
phd.getCertificate().setActivity_nuclide_time_assay(struct.activity_nuclide_time_assay);
phd.getCertificate().setUncertainty(struct.uncertainty);
phd.getCertificate().setG_energy(struct.cer_g_energy);
phd.getCertificate().setG_intensity(struct.g_intensity);
phd.getCertificate().setElectron_decay_mode(struct.electron_decay_mode);
phd.getCertificate().setMaximum_energy(struct.maximum_energy);
phd.getCertificate().setIntensity_b_particle(struct.intensity_b_particle);
phd.getCertificate().setRecord_count(struct.record_count);
}
//g_Spectrum
if (Objects.nonNull(struct.num_g_channel) && Objects.nonNull(struct.g_energy_span)
&& Objects.nonNull(struct.g_begin_channel) && CollectionUtils.isNotEmpty(struct.g_counts)) {
phd.getSpec().setNum_g_channel(struct.g_counts.size()); // todo 原Num_g_channel有误
phd.getSpec().setG_energy_span(struct.g_energy_span);
phd.getSpec().setBegin_channel(struct.g_begin_channel);
phd.getSpec().setCounts(struct.g_counts);
int i = 0;
for (; i < phd.getSpec().getNum_g_channel(); i++) {
if (phd.getSpec().getCounts().get(i) > 0) {
break;
}
}
if (i == phd.getSpec().getNum_g_channel()) {
phd.setValid(false);
}
}
//g_Energy
if (CollectionUtils.isNotEmpty(struct.g_energy) && CollectionUtils.isNotEmpty(struct.g_centroid_channel) &&
CollectionUtils.isNotEmpty(struct.g_uncertainty) && Objects.nonNull(struct.g_record_count)) {
GEnergyBlock gEnergyBlock = new GEnergyBlock();
gEnergyBlock.setG_energy(struct.g_energy);
gEnergyBlock.setCentroid_channel(struct.g_centroid_channel);
gEnergyBlock.setUncertainty(struct.g_uncertainty);
gEnergyBlock.setRecord_count(struct.g_record_count);
phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock);
}
//g_Resolution
if (CollectionUtils.isNotEmpty(struct.g_r_energy) && CollectionUtils.isNotEmpty(struct.g_r_FWHM) &&
CollectionUtils.isNotEmpty(struct.g_r_uncertainty) && Objects.nonNull(struct.g_r_record_count)) {
GResolutionBlock gResolutionBlock = new GResolutionBlock();
gResolutionBlock.setG_energy(struct.g_r_energy);
gResolutionBlock.setFWHM(struct.g_r_FWHM);
gResolutionBlock.setUncertainty(struct.g_r_uncertainty);
gResolutionBlock.setRecord_count(struct.g_r_record_count);
phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock);
}
//g_Efficiency
if (CollectionUtils.isNotEmpty(struct.g_e_energy) && CollectionUtils.isNotEmpty(struct.g_e_efficiency) &&
CollectionUtils.isNotEmpty(struct.g_e_uncertainty) && Objects.nonNull(struct.g_e_record_count)) {
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
gEfficiencyBlock.setG_energy(struct.g_e_energy);
gEfficiencyBlock.setEfficiency(struct.g_e_efficiency);
gEfficiencyBlock.setUncertainty(struct.g_e_uncertainty);
gEfficiencyBlock.setRecord_count(struct.g_e_record_count);
phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock);
}
//TotalEff
if (CollectionUtils.isNotEmpty(struct.t_g_energy) && CollectionUtils.isNotEmpty(struct.total_efficiency) &&
CollectionUtils.isNotEmpty(struct.t_uncertainty) && Objects.nonNull(struct.t_record_count)) {
TotaleffBlock totaleffBlock = new TotaleffBlock();
totaleffBlock.setG_energy(struct.t_g_energy);
totaleffBlock.setTotal_efficiency(struct.total_efficiency);
totaleffBlock.setUncertainty(struct.t_uncertainty);
totaleffBlock.setRecord_count(struct.t_record_count);
phd.getMapTotEKD().put(CalName.CalPHD.getType(), totaleffBlock);
}
// 初始化默认分析设置
if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) {
phd.getSetting().setECutAnalysis_Low(35.0);
phd.getSetting().setBUpdateCal(true);
}
if (StrUtil.isNotBlank(phd.getCollect().getCollection_start_date())
&& StrUtil.isNotBlank(phd.getCollect().getCollection_start_time())) {
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date()
+ StringPool.SPACE + phd.getCollect().getCollection_start_time()));
}
if (StrUtil.isNotBlank(phd.getAcq().getAcquisition_start_date()) && StrUtil.isNotBlank(phd.getAcq().getAcquisition_start_time())) {
phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date()
+ StringPool.SPACE + phd.getAcq().getAcquisition_start_time()));
}
SpecSetup usedSetting = new SpecSetup();
BeanUtils.copyProperties(phd.getSetting(), usedSetting);
phd.setUsedSetting(usedSetting);
phd.setBAnalyed(false);
phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"));
} catch (Exception e) {
throw new RuntimeException(e);
}
return phd;
}
/**
* 根据ROI卡出来的Gamma数据生成新的GammaPHD文件
* @param pathName 文件存储路径
* @param fileName GammaPHD名称
* @param struct BetaPHD内容
* @param g_counts ROI卡出来的Gamma数据
*/
public void createGammaFile(String pathName,String fileName, EnergySpectrumStruct struct, List<Long> g_counts) {
File file = new File(pathName + "\\" + fileName);
// 创建PrintWriter对象
PrintWriter out = null;
DecimalFormat decimalFormat = new DecimalFormat("0.000000");
try {
out = new PrintWriter(file);
out.println("BEGIN IMS2.0");
out.println("MSG_TYPE DATA");
// todo msg_type用的不对dll没解析出这个字段
out.println("MSG_ID " + struct.msg_id + " " + struct.msg_type + "\n" + "DATA_TYPE " + struct.data_type);
out.println("#Header 3");
// 解析出的Gamma谱 系统类型暂时使用G
out.println(struct.site_code + " " + struct.detector_code + " G " +
struct.sample_geometry + " " + struct.spectrum_quantity);
out.println(struct.sample_ref_id);
out.println(struct.measurement_id + " " + struct.detector_bk_measurement_id + " 0");
out.println(struct.transmit_date + " " + struct.transmit_time);
out.println("#Collection");
out.println(struct.collection_start_date + " " + struct.collection_start_time + " " +
struct.collection_stop_date + " " + struct.collection_stop_time + " "
+ decimalFormat.format(struct.air_volume));
out.println("#Acquisition");
out.println(struct.acquisition_start_date + " " + struct.acquisition_start_time + " " +
decimalFormat.format(struct.acquisition_real_time) + " " +
decimalFormat.format(struct.acquisition_live_time));
out.println("#g_Energy");
format(struct.g_energy, struct.g_centroid_channel, struct.g_uncertainty, out);
out.println("#g_Resolution");
format(struct.g_r_energy, struct.g_r_FWHM, struct.g_r_uncertainty, out);
out.println("#g_Efficiency");
format(struct.g_e_energy, struct.g_e_efficiency, struct.g_e_uncertainty, out);
out.println("#g_Spectrum");
// num_g_channel 根据g_counts数量得来和PHD写的数字没有关系g_energy_span是PHD写的值
out.println(struct.num_g_channel + " " + struct.g_energy_span);
// 存储前一个数字
String beforeStr = "";
for (int i = 0; i < g_counts.size(); i++) {
String str = g_counts.get(i).toString();
if(i % 5 == 0) {
if (i == 0) {
out.printf(i+"");
} else {
out.printf("\n" + i );
}
beforeStr = i+"";
}
if(StrUtil.isEmpty(beforeStr)){
beforeStr = str;
}
// 根据前一个字符长度计算需要的空格
out.printf("%" + (str.length() + (6 - beforeStr.length()))+ "s" , g_counts.get(i));
if(i == g_counts.size() - 1) {
out.println();
}
beforeStr = str;
}
out.print("STOP");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
if (null != out) {
out.close();
}
}
}
/**
* 数据格式化
* @param aList 第一列数据
* @param bList 第二列数据
* @param cList 第三列数据
* @param out
*/
private static void format(List<Double> aList, List<Double> bList,List<Double> cList,PrintWriter out) {
for (int i = 0; i < aList.size(); i++) {
DecimalFormat decimalFormat = new DecimalFormat("0.000000");
String a = decimalFormat.format(aList.get(i));
String b = decimalFormat.format(bList.get(i));
String c = decimalFormat.format(cList.get(i));
out.print(a);
out.printf("%" + ( b.length() + (17 - a.length())) + "s", b);
out.printf("%" + ( c.length() + (17 - b.length())) + "s", c+"\n");
}
}
}

View File

@ -157,22 +157,5 @@ public class SelfStationController {
return selfStationService.setCurrentEfficiency(fileName, currentName, request);
}
@GetMapping("viewGammaDetectorCalibration")
@ApiOperation(value = "查询GammaDetectorCalibration数据", notes = "查询GammaDetectorCalibration数据")
public Result viewGammaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request) {
return selfStationService.viewGammaDetectorCalibration(sampleId, sampleFileName, qcFileName, fittingBtn, request);
}
@GetMapping("viewBetaDetectorCalibration")
@ApiOperation(value = "查询BetaDetectorCalibration数据", notes = "查询BetaDetectorCalibration数据")
public Result viewBetaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request) {
return selfStationService.viewBetaDetectorCalibration(sampleId, sampleFileName, qcFileName, fittingBtn, request);
}
@PostMapping("Reprocessing")
@ApiOperation(value = "analyze菜单下Reprocessing页面数据", notes = "analyze菜单下Reprocessing页面数据")
public Result Reprocessing(String fileName, String processKey, HttpServletRequest request) {
return selfStationService.Reprocessing(fileName, processKey, request);
}
}

View File

@ -41,8 +41,6 @@ public class BetaDataFile implements Serializable {
private String stationId;
private String detectorId;
private boolean bProcessed;
private boolean saveAnalysisResult;

View File

@ -31,11 +31,6 @@ public class SelfStationData implements Serializable {
*/
private EnergySpectrumStruct detStruct;
/**
* qc文件分析内容
*/
private EnergySpectrumStruct qcStruct;
/**
* sample对应的操作数据
*/
@ -46,69 +41,6 @@ public class SelfStationData implements Serializable {
*/
private SelfStationVueData detVueData;
private List<List<Double>> gammaNewEnergyListNow;
private List<List<Double>> betaNewEnergyListNow;
//分析用到的信息
private BgCalibratePara bgPara;
private List<SeriseData> betaList;
private List<String> betaFittingPara;
private List<String> betaFittingParaToUi;
private List<SeriseData> gammaList;
private List<String> gammaFittingPara;
private List<String> gammaFittingParaToUi;
private List<SeriseData> betaListNow;
private List<String> betaFittingParaNow;
private List<String> betaFittingParaToUiNow;
private List<SeriseData> gammaListNow;
private List<String> gammaFittingParaNow;
private List<String> gammaFittingParaToUiNow;
/**
* 是否点击过Energy Calibration页面下Gamma Detector Calibration的fitting按钮
*/
private boolean bGammaEnergyValidSample;
/**
* 是否点击过Energy Calibration页面下Beta Detector Calibration的fitting按钮
*/
private boolean bBetaEnergyValidSample;
/**
* 是否点击过Energy Calibration页面下Gamma Detector Calibration的fitting按钮
*/
private boolean bGammaEnergyValidGas;
/**
* 是否点击过Energy Calibration页面下Beta Detector Calibration的fitting按钮
*/
private boolean bBetaEnergyValidGas;
/**
* 是否点击过Energy Calibration页面下Gamma Detector Calibration的fitting按钮
*/
private boolean bGammaEnergyValidDet;
/**
* 是否点击过Energy Calibration页面下Beta Detector Calibration的fitting按钮
*/
private boolean bBetaEnergyValidDet;
public SelfStationData() {
sampleVueData = new SelfStationVueData();
detVueData = new SelfStationVueData();

View File

@ -15,7 +15,6 @@ public class SelfStationVueData implements Serializable {
*/
//折线图横纵坐标数组
private List<SeriseData> ROIOneList;
private List<Long> ROIOneCounts;
//ROI-1范围矩形框起始道值
private Integer ROIOneBetaStart;
//ROI-1范围矩形框终止道值
@ -26,7 +25,6 @@ public class SelfStationVueData implements Serializable {
*/
//折线图横纵坐标数组
private List<SeriseData> ROITwoList;
private List<Long> ROITwoCounts;
//ROI-2范围矩形框起始道值
private Integer ROITwoBetaStart;
//ROI-2范围矩形框终止道值
@ -37,7 +35,6 @@ public class SelfStationVueData implements Serializable {
*/
//折线图横纵坐标数组
private List<SeriseData> ROIThreeList;
private List<Long> ROIThreeCounts;
//ROI-3范围矩形框起始道值
private Integer ROIThreeBetaStart;
//ROI-3范围矩形框终止道值
@ -48,7 +45,6 @@ public class SelfStationVueData implements Serializable {
*/
//折线图横纵坐标数组
private List<SeriseData> ROIFourList;
private List<Long> ROIFourCounts;
//ROI-4范围矩形框起始道值
private Integer ROIFourBetaStart;
//ROI-4范围矩形框终止道值

View File

@ -56,9 +56,4 @@ public interface ISelfStationService {
Result setCurrentEfficiency(String fileName, String currentName, HttpServletRequest request);
Result viewGammaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request);
Result viewBetaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request);
Result Reprocessing(String fileName, String processKey, HttpServletRequest request);
}

View File

@ -180,7 +180,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
return result;
}
// 切割数据库存储的文件路径获取路径信息
String pathName = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
// 切割数据库存储的文件路径获取文件名称
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH) + 1);
// 声明phd实体类
@ -194,10 +194,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (!flag) {
return result;
}
if (Objects.nonNull(phd) && !phd.isValid()) {
result.error500("This Spectrum is invalid! it's counts are all zero");
return result;
}
// 加载phd数据所需的lcscacbaseline数据
if (dbName.equals("auto")) {
gammaFileUtil.SetBaseInfo(phd, "RNAUTO");
@ -602,7 +598,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
Map<String, Object> map = new HashMap<>();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
// 上传文件路径
String path = spectrumPathProperties.getRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String path = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
// 获取当前角色的颜色配置
Map<String, String> colorMap = sysUserColorService.initColor(userName);
PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName);
@ -613,10 +609,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (!bRet) {
return result;
}
if (Objects.nonNull(phd) && !phd.isValid()) {
result.error500("This Spectrum is invalid! it's counts are all zero");
return result;
}
if (!redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()) || !redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list")) {
//读取缓存的全部核素信息
Map<String, NuclideLines> allNuclideMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
@ -679,6 +671,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
String key = fileName + StrUtil.DASHED + username;
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phdFile = phdCache.getIfPresent(key);
if (StringUtils.isNotBlank(phdFile.getTmpFilePath())) {
File file = new File(phdFile.getTmpFilePath());
if (Objects.nonNull(file)) {
file.delete();
}
}
// 删除指定key的Cache
localCache.deletePHDCache(key);
}
@ -745,8 +743,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.error500("The comparison file path does not exist");
return result;
}
compareFilePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + compareFilePath;
File compareFile = ftpUtil.downloadFile(compareFilePath);
compareFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + compareFilePath;
File compareFile = ftpUtil.downloadFile(compareFilePath, "betaGamma");
if (Objects.isNull(compareFile)) {
result.error500("The comparison file path does not exist");
return result;
@ -758,6 +756,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.setSuccess(true);
result.setResult(chartDataList);
}
compareFile.delete();
return result;
}
@ -777,9 +776,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
long m_nCount = phd.getSpec().getNum_g_channel();
List<Double> vEnergy = phd.getVEnergy();
//加载compare文件
String compareFilePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String compareFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String fromPath = compareFilePath + StringPool.SLASH + compareFileName;
File compareFile = ftpUtil.downloadFile(fromPath);
File compareFile = ftpUtil.downloadFile(fromPath, "betaGamma");
if (Objects.nonNull(compareFile)) {
// 获取Compare数据
List<Long> m_vecCompare = gammaFileUtil.loadCompareData(compareFile, userName, m_nCount, result);
@ -788,6 +787,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.setSuccess(true);
result.setResult(chartDataList);
}
compareFile.delete();
}
return result;
}
@ -827,8 +827,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.error500("The comparison file path does not exist");
return result;
}
stripFilePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + stripFilePath;
File stripFile = ftpUtil.downloadFile(stripFilePath);
stripFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + stripFilePath;
File stripFile = ftpUtil.downloadFile(stripFilePath, "betaGamma");
if (Objects.isNull(stripFile)) {
result.error500("The comparison file path does not exist");
return result;
@ -843,6 +843,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.setSuccess(true);
result.setResult(stripMap);
}
stripFile.delete();
return result;
}
@ -876,9 +877,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
m_vCount.add(0L);
}
//加载strip文件
String stripFilePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String stripFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String fromPath = stripFilePath + StringPool.SLASH + stripFileName;
File stripFile = ftpUtil.downloadFile(fromPath);
File stripFile = ftpUtil.downloadFile(fromPath, "betaGamma");
if (Objects.nonNull(stripFile)) {
// 获取Compare数据
List<Long> m_vecCompare = gammaFileUtil.loadCompareData(stripFile, userName, m_nCount, result);
@ -890,6 +891,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.setSuccess(true);
result.setResult(stripMap);
}
stripFile.delete();
}
return result;
}
@ -1310,7 +1312,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
HashMap<String, Object> map = new HashMap<>();
// 根据boolean 决定是否保留本次数据 如果保留则不需要操作vPeak 并重新拟合线
if (accept) {
Map<String, NuclideLines> nuclideLinesMap = phd.getPhdNuclideMap();//(Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
if (flag.equalsIgnoreCase("insert")) {// 如果传递的flag标识 Insert则进行峰值的插入
//重新赋值index
for (int k=0; k<newPeak.size(); k++) {
@ -1693,10 +1695,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
// 用户当前的核素信息新增核素名称
list_identify.add(nuclideName);
// 根据要进行修改的列的数据下标 操作Vpeak数据
List<String> peakNuclides = phd.getVPeak().get(curRow).nuclides;
if (peakNuclides.indexOf(nuclideName) < 0 ) {
peakNuclides.add(nuclideName);
}
phd.getVPeak().get(curRow).nuclides.add(nuclideName);
// 查询当前用户所关心的核素名称
Map<String, NuclideLines> mapNucLines = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
//用户当前缓存的核素信息
@ -1715,10 +1714,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
}
t_idx++;
}
//重新计算核素的MDA值
gammaFileUtil.CalcNuclideMDA(phd, it_line, nuclideName, vPeakIdx);
map.put("identify", list_identify);
//格式化核素表单内容
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
map.put("table", vPeak);
//如果当前缓存的谱核素信息不包含当前核素
@ -3024,6 +3021,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (Objects.nonNull(inputStream)) {
inputStream.close();
}
if (Objects.nonNull(tmpFile)) {
tmpFile.delete();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -3295,6 +3295,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (Objects.nonNull(inputStream)) {
inputStream.close();
}
if (Objects.nonNull(tmpFile)) {
tmpFile.delete();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -3588,6 +3591,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (Objects.nonNull(inputStream)) {
inputStream.close();
}
if (Objects.nonNull(tmpFile)) {
tmpFile.delete();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -3950,7 +3956,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (StringUtils.isBlank(reportPath)) {
throw new RuntimeException("The automatic handler generated report does not exist");
}
String pathFileName = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt";
String pathFileName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt";
InputStream inputStream = null;
ServletOutputStream outputStream = null;
try {
@ -3984,7 +3990,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
public void exportARR(Integer sampleId, HttpServletResponse response) {
// 获取自动处理生成的报告地址
String reportPath = spectrumAnalysisMapper.viewARR(sampleId);
String pathFileName = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt";
String pathFileName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt";
InputStream inputStream = null;
ServletOutputStream outputStream = null;
try {
@ -4584,7 +4590,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (StringUtils.isBlank(logPath)) {
throw new RuntimeException("The log generated by the automatic processor does not exist");
}
String pathFileName = spectrumPathProperties.getRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath;
String pathFileName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath;
InputStream inputStream = null;
ServletOutputStream outputStream = null;
try {
@ -4799,40 +4805,47 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
phd.setStatus("R");
//分析成功后存储日志文件和报告文件
String rootPath = spectrumPathProperties.getRootPath();
// {
// File baselineFile = new File(rootPath+middleData.analyses_baseline_absolute_filePath);
// try {
// FileInputStream in = new FileInputStream(baselineFile);
// ftpUtil.saveFile(spectrumPathProperties.getRootPath()+middleData.analyses_baseline_absolute_filePath, in);
// } catch (FileNotFoundException e) {
// throw new RuntimeException(e);
// }
// }
// {
// File lcFile = new File(rootPath+middleData.analyses_lc_absolute_filePath);
// try {
// FileInputStream in = new FileInputStream(lcFile);
// ftpUtil.saveFile(spectrumPathProperties.getRootPath()+middleData.analyses_lc_absolute_filePath, in);
// } catch (FileNotFoundException e) {
// throw new RuntimeException(e);
// }
// }
// {
// File scacFile = new File(rootPath+middleData.analyses_scac_absolute_filePath);
// try {
// FileInputStream in = new FileInputStream(scacFile);
// ftpUtil.saveFile(spectrumPathProperties.getRootPath()+middleData.analyses_scac_absolute_filePath, in);
// } catch (FileNotFoundException e) {
// throw new RuntimeException(e);
// }
// }
{
String baselinePathName = ftpUtil.getFtpRootPath()+middleData.analyses_baseline_absolute_filePath.substring(0, middleData.analyses_baseline_absolute_filePath.lastIndexOf(StringPool.SLASH));
String baselineFileName = middleData.analyses_baseline_absolute_filePath.substring(middleData.analyses_baseline_absolute_filePath.lastIndexOf(StringPool.SLASH) + 1);
File baselineFile = new File(rootPath+middleData.analyses_baseline_absolute_filePath);
try {
FileInputStream in = new FileInputStream(baselineFile);
ftpUtil.saveFile(baselinePathName, baselineFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
{
String lcPathName = ftpUtil.getFtpRootPath()+middleData.analyses_lc_absolute_filePath.substring(0, middleData.analyses_lc_absolute_filePath.lastIndexOf(StringPool.SLASH));
String lcFileName = middleData.analyses_lc_absolute_filePath.substring(middleData.analyses_lc_absolute_filePath.lastIndexOf(StringPool.SLASH) + 1);
File lcFile = new File(rootPath+middleData.analyses_lc_absolute_filePath);
try {
FileInputStream in = new FileInputStream(lcFile);
ftpUtil.saveFile(lcPathName, lcFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
{
String scacPathName = ftpUtil.getFtpRootPath()+middleData.analyses_scac_absolute_filePath.substring(0, middleData.analyses_scac_absolute_filePath.lastIndexOf(StringPool.SLASH));
String scacFileName = middleData.analyses_scac_absolute_filePath.substring(middleData.analyses_scac_absolute_filePath.lastIndexOf(StringPool.SLASH) + 1);
File scacFile = new File(rootPath+middleData.analyses_scac_absolute_filePath);
try {
FileInputStream in = new FileInputStream(scacFile);
ftpUtil.saveFile(scacPathName, scacFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
{
String logPathName = middleData.analyses_absolute_LogPath.substring(0, middleData.analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH));
String logFileName = middleData.analyses_absolute_LogPath.substring(middleData.analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH)+1);
File logFile = new File(logFileName);
try {
FileUtil.writeString(gammaFileUtil.GetLogContent(middleData), logFile, "UTF-8");
FileInputStream in = new FileInputStream(logFile);
ftpUtil.saveFile(spectrumPathProperties.getRootPath()+middleData.analyses_absolute_LogPath, in);
ftpUtil.saveFile(logPathName, logFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
@ -4840,12 +4853,13 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
}
}
{
String rptPathName = middleData.analyses_absolute_ReportPath.substring(0, middleData.analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH));
String rptFileName = middleData.analyses_absolute_ReportPath.substring(middleData.analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH)+1)+".txt";
File rptFile = new File(rptFileName);
try {
FileUtil.writeString(gammaFileUtil.GetReportContent(middleData), rptFile, "UTF-8");
FileInputStream in = new FileInputStream(rptFile);
ftpUtil.saveFile(spectrumPathProperties.getRootPath()+middleData.analyses_absolute_ReportPath+".txt", in);
ftpUtil.saveFile(rptPathName, rptFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {

View File

@ -7,12 +7,12 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.google.common.cache.Cache;
import org.apache.commons.io.FileUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.LocalCache;
import org.jeecg.common.cache.SelfCache;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.*;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.common.util.PHDFileUtil;
import org.jeecg.common.util.SelfStationUtil;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
@ -20,7 +20,6 @@ import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISelfStationService;
import org.jeecg.modules.service.ISysUserColorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@ -35,17 +34,9 @@ import java.util.stream.Collectors;
@Service
public class SelfStationServiceImpl implements ISelfStationService {
@Autowired
private GammaFileUtil gammaFileUtil;
@Autowired
private ParameterProperties parameterProperties;
@Autowired
private FTPUtil ftpUtil;
@Autowired
private RedisUtil redisUtil;
@Autowired
private ISysUserColorService sysUserColorService;
@Autowired
private SpectrumPathProperties spectrumPathProperties;
@Autowired
private SelfStationUtil selfStationUtil;
@ -242,13 +233,13 @@ public class SelfStationServiceImpl implements ISelfStationService {
if (StringUtils.isNotBlank(selfStationData.getSampleTmpPath())) {
File file = new File(selfStationData.getSampleTmpPath());
if (Objects.nonNull(file)) {
// file.delete();
file.delete();
}
}
if (StringUtils.isNotBlank(selfStationData.getDetTmpPath())) {
File file = new File(selfStationData.getDetTmpPath());
if (Objects.nonNull(file)) {
// file.delete();
file.delete();
}
}
// 删除指定key的Cache
@ -1169,551 +1160,4 @@ public class SelfStationServiceImpl implements ISelfStationService {
return result;
}
@Override
public Result viewGammaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request) {
Result result = new Result();
//接收返回结果内容
Map<String, Object> map = new HashMap<>();
//根据请求头获取用户名称
String userName = JwtUtil.getUserNameByToken(request);
//获取beta的缓存数据
Cache<String, SelfStationData> cache = selfStationCache.getSelfCache();
SelfStationData betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
if (Objects.isNull(betaDataFile)) {
result.error500("Load basic file information first!");
return result;
}
//如果gamma的计算标识是false 则将gamma当前缓存数据进行重置
if (!fittingBtn) {
betaDataFile.setGammaListNow(Collections.EMPTY_LIST);
betaDataFile.setGammaFittingParaNow(Collections.EMPTY_LIST);
betaDataFile.setGammaFittingParaToUiNow(Collections.EMPTY_LIST);
betaDataFile.setGammaNewEnergyListNow(Collections.EMPTY_LIST);
}
//获取qc的分析结果数据
EnergySpectrumStruct struct = betaDataFile.getQcStruct();
//判断qc文件的解析结果是否为空
if (Objects.nonNull(struct)){
//读取Gamma Detector Calibration所需要的参数
long numGChannel = struct.num_g_channel;
List<Double> gCentroidChannel = struct.g_centroid_channel;
List<Double> gEnergy = struct.g_energy;
int gRecordCount = struct.g_record_count;
List<Long> gCounts = struct.g_counts;
List<Double> gammaParam = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
//根据道值和能量的对应关系 存储表单数据
List<SeriseData> oldScatterSeries = new LinkedList<>();
for (int i=0; i<gRecordCount; i++) {
SeriseData temp = new SeriseData();
double p1 = gCentroidChannel.get(i);
double p2 = gEnergy.get(i);
temp.setX(p1);
temp.setY(p2);
oldScatterSeries.add(temp);
}
map.put("oldScatterSeries", oldScatterSeries);
//计算C to E公式参数
List<Double> fittingPara = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
List<String> fittingParaStr = new LinkedList<>();
for (Double para:fittingPara) {
fittingParaStr.add(String.valueOf(para));
}
map.put("CToE", fittingParaStr);
List<Double> channel = new LinkedList<>();
for (int i=0; i<255; ++i) {
channel.add(Double.valueOf(i));
}
//计算出新的道值对应能量值
List<Double> energy = EnergySpectrumHandler.GetFileFittingData(channel, fittingPara);
//根据道值和能量对应关系 封装折线图数据
List<SeriseData> oldLineSeries = new LinkedList<>();
for (int i=0; i<channel.size(); i++) {
SeriseData tmp = new SeriseData();
tmp.setX(channel.get(i));
tmp.setY(energy.get(i));
oldLineSeries.add(tmp);
}
map.put("oldLineSeries", oldLineSeries);
//计算E to C公式参数
List<Double> fittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel);
List<String> fittingParaToUiStr = new LinkedList<>();
for (Double para:fittingParaToUi) {
fittingParaToUiStr.add(String.valueOf(para));
}
map.put("EToC", fittingParaToUiStr);
//计算道值对应能量值参数
List<Double> gchannels = new ArrayList<>();
List<List<Double>> gammaEnergyList = new LinkedList<>();
for (int i=0; i<numGChannel; i++){
gchannels.clear();
gchannels.add(Double.valueOf(i));
List<Double> gammaEnergy = EnergySpectrumHandler.GetFileFittingData(gchannels, gammaParam);
gammaEnergyList.add(gammaEnergy);
}
map.put("gammaEnergy", gammaEnergyList);
//Gamma Spectrum: QC
List<SeriseData> seriseDataList = new LinkedList<>();
long min =0;
double max =0;
for ( int i=1; i<numGChannel; i++ ) {
long count = gCounts.get(i);
SeriseData temp = new SeriseData();
temp.setX(i);
temp.setY(count);
seriseDataList.add(temp);
if (count<min){
min = count;
}
if (count>max){
max = count;
}
}
if (max<10) {
max += max*0.5;
} else if (max<50) {
max += max*0.2;
} else if (max<100) {
max += max*0.1;
} else {
max += max*0.05;
}
map.put("min", min);
map.put("max", max);
map.put("gammaSpectrum", seriseDataList);
//判断人工交互的道值与能量对应参数数组是否为空
if (Objects.nonNull(betaDataFile.getBgPara()) && CollectionUtils.isNotEmpty(betaDataFile.getGammaList())) {
//存储计算参数道值
List<Double> xs = new LinkedList();
//存储计算参数能量值
List<Double> ys = new LinkedList<>();
//存储所有道值
List<Double> channels = new LinkedList<>();
//存储所有的能量值
List<List<Double>> energyList = new LinkedList<>();
//存储新的线点能量值
List<SeriseData> newLineSeries = new LinkedList<>();
//存储新的表单能量值
List<TableWidget> tableWidgets = new LinkedList();
//存储新的公式参数C TO E
List<String> newFittingParaStr = new LinkedList<>();
//存储新的公式参数E TO C
List<String> newFittingParaToUiStr = new LinkedList<>();
//记录点值数组
List<SeriseData> newSeriseDataList = new LinkedList<>();
//遍历临时点数组 将点位的横坐标以及纵坐标封装到对应的数组
for (int i=0; i<betaDataFile.getGammaList().size(); i++){
xs.add(betaDataFile.getGammaList().get(i).getX());
ys.add(betaDataFile.getGammaList().get(i).getY());
}
//计算C to E公式参数
List<Double> newFittingPara = EnergySpectrumHandler.GetFileFittingPara(xs, ys);
for (Double para:newFittingPara) {
newFittingParaStr.add(String.valueOf(para));
}
map.put("newCToE", newFittingParaStr);
//填充道值数组的数据
for (int i=0; i<255; i++) {
channels.add(Double.valueOf(i));
}
//计算道值的能量
List<Double> energys = EnergySpectrumHandler.GetFileFittingData(channels,newFittingPara);
//根据临时点的道值修改对应能量值
//遍历所有道值
for (int i=0; i< channels.size(); i++) {
//获取道值
double newChannel = channels.get(i).doubleValue();
//遍历临时点数据
for (int j=0; j<betaDataFile.getGammaList().size(); j++) {
SeriseData seriseData = betaDataFile.getGammaList().get(j);
double tempChannel = seriseData.getX();
//如果道值等于临时点的道值
if (newChannel == tempChannel) {
energys.set(i, seriseData.getY());
}
}
}
//将新计算的能量封装到数组
for (Double calEnergy:energys) {
List<Double> newEnergy = new LinkedList<>();
newEnergy.add(calEnergy);
energyList.add(newEnergy);
}
//遍历道值添加各道值对应点数据到数组
for (int i=0; i<channels.size(); ++i) {
SeriseData seriseData = new SeriseData();
seriseData.setX(channels.get(i));
seriseData.setY(energys.get(i));
newLineSeries.add(seriseData);
}
map.put("newLineSeries", newLineSeries);
//遍历点 缓存到表单数组以及折线图点位数组
for (int i=0; i<betaDataFile.getGammaList().size(); i++) {
//表单数据信息
TableWidget tableWidget = new TableWidget();
tableWidget.setRowCount(i+1);
tableWidget.setChannel(betaDataFile.getGammaList().get(i).getX());
tableWidget.setEnergy(betaDataFile.getGammaList().get(i).getY());
tableWidgets.add(tableWidget);
//折线图位置信息
SeriseData seriseData = new SeriseData();
seriseData.setX(betaDataFile.getGammaList().get(i).getX());
seriseData.setY(betaDataFile.getGammaList().get(i).getY());
newSeriseDataList.add(seriseData);
}
map.put("tableWidgets", tableWidgets);
map.put("newScatterSeriesData", newSeriseDataList);
//计算E to C公式参数
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(ys, xs);
for (Double para:newFittingParaToUi) {
newFittingParaToUiStr.add(String.valueOf(para));
}
map.put("newEToC", newFittingParaToUiStr);
}
//计算得到的
if (betaDataFile.getGammaList().size() <= 0 ) {
betaDataFile.setGammaList(oldScatterSeries);
}
if (betaDataFile.getGammaFittingPara().size() <= 0 ) {
betaDataFile.setGammaFittingPara(fittingParaStr);
}
if (betaDataFile.getGammaFittingParaToUi().size() <= 0 ) {
betaDataFile.setGammaFittingParaToUi(fittingParaToUiStr);
}
}
result.setSuccess(true);
result.setResult(map);
return result;
}
@Override
public Result viewBetaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request) {
Result result = new Result();
//返回结果内容
Map<String, Object> map = new HashMap<>();
//获取用户名
String userName = JwtUtil.getUserNameByToken(request);
//获取本地缓存
Cache<String, SelfStationData> cache = selfStationCache.getSelfCache();
SelfStationData betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
if (Objects.isNull(betaDataFile)) {
result.error500("Load basic file information first!");
return result;
}
//判断是否进行过计算标识为false时 清空当前beta对应的缓存数据
if (!fittingBtn) {
betaDataFile.setBetaListNow(Collections.EMPTY_LIST);
betaDataFile.setBetaFittingParaNow(Collections.EMPTY_LIST);
betaDataFile.setBetaFittingParaToUiNow(Collections.EMPTY_LIST);
betaDataFile.setBetaNewEnergyListNow(Collections.EMPTY_LIST);
}
//判断qc的分析结果是否为空
EnergySpectrumStruct struct = betaDataFile.getQcStruct();
if (Objects.nonNull(struct)){
//Figure of Beta Detector Calibration
long numBChannel = struct.num_b_channel;
List<Double> bChannel = struct.b_channel;
List<Double> bElectronEnergy = struct.b_electron_energy;
long numGChannel = struct.num_g_channel;
List<Double> gCentroidChannel = struct.g_centroid_channel;
List<Double> gEnergy = struct.g_energy;
long bChannels = struct.b_channels;
long gChannels = struct.g_channels;
List<Long> hCounts = struct.h_counts;
int bRecordCount = struct.b_record_count;
//散点图坐标点关联beta部分相关数据
List<List<Double>> betaEnergyList = new LinkedList<>();
List<Double> betaParam = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
List<Double> bchannels = new ArrayList<>();
for (int i=0; i<numBChannel; i++){
bchannels.clear();
bchannels.add(Double.valueOf(i));
List<Double> betaEnergy = EnergySpectrumHandler.GetFileFittingData(bchannels, betaParam);
betaEnergyList.add(betaEnergy);
}
map.put("betaEnergy", betaEnergyList);
//gamma Energy 散点图坐标点关联gamma部分相关数据
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyListNow())) {
map.put("gammaEnergy", betaDataFile.getGammaNewEnergyListNow());
} else {
List<Double> gammaParam = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
List<Double> gchannels = new ArrayList<>();
List<List<Double>> gammaEnergyList = new LinkedList<>();
for (int i=0; i<numGChannel; i++){
gchannels.clear();
gchannels.add(Double.valueOf(i));
List<Double> gammaEnergy = EnergySpectrumHandler.GetFileFittingData(gchannels, gammaParam);
gammaEnergyList.add(gammaEnergy);
}
map.put("gammaEnergy", gammaEnergyList);
}
//Beta-Gamma Spectrum: QC 散点图相关数据
List<HistogramData> histogramDataList = new LinkedList<>();
for (int column=0; column<bChannels; column++) {
for (int row=0; row<gChannels; row++) {
Long index = column * gChannels + row;
long count = hCounts.get(index.intValue());
if (count>0) {
HistogramData histogramData = new HistogramData();
histogramData.setB(row);
histogramData.setG(column);
histogramDataList.add(histogramData);
}
}
}
map.put("histogramData", histogramDataList);
//计算Calibration Parameter Of Gamma Detector 拟合线图数据
List<SeriseData> oldScatterSeries = new LinkedList<>();
for (int i=0; i<bRecordCount; i++) {
SeriseData temp = new SeriseData();
double p1 = bChannel.get(i);
double p2 = bElectronEnergy.get(i);
temp.setX(p1);
temp.setY(p2);
oldScatterSeries.add(temp);
}
map.put("oldScatterSeries", oldScatterSeries);
//计算得到C to E公式数据
List<Double> fittingPara = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
List<String> fittingParaStr = new LinkedList<>();
for (Double para:fittingPara) {
fittingParaStr.add(String.valueOf(para));
}
map.put("CToE", fittingParaStr);
List<Double> channel = new LinkedList<>();
for (int i=0; i<255; ++i) {
channel.add(Double.valueOf(i));
}
List<Double> energy = EnergySpectrumHandler.GetFileFittingData(channel, fittingPara);
List<SeriseData> oldLineSeries = new LinkedList<>();
for (int i=0; i<channel.size(); i++) {
SeriseData tmp = new SeriseData();
tmp.setX(channel.get(i));
tmp.setY(energy.get(i));
oldLineSeries.add(tmp);
}
map.put("oldLineSeries", oldLineSeries);
//E to C
List<Double> fittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(energy, channel);
List<String> fittingParaToUiStr = new LinkedList<>();
for (Double para:fittingParaToUi) {
fittingParaToUiStr.add(String.valueOf(para));
}
map.put("EToC", fittingParaToUiStr);
//判断人工交互的道值与能量对应参数数组是否为空
if (Objects.nonNull(betaDataFile.getBgPara()) && CollectionUtils.isNotEmpty(betaDataFile.getBetaList())) {
//存储计算参数道值
List<Double> xs = new LinkedList();
//存储计算参数能量值
List<Double> ys = new LinkedList<>();
//存储所有道值
List<Double> channels = new LinkedList<>();
//存储所有的能量值
List<List<Double>> energyList = new LinkedList<>();
//存储新的线点能量值
List<SeriseData> newLineSeries = new LinkedList<>();
//存储新的表单能量值
List<TableWidget> tableWidgets = new LinkedList();
//存储新的公式参数C TO E
List<String> newFittingParaStr = new LinkedList<>();
//存储新的公式参数E TO C
List<String> newFittingParaToUiStr = new LinkedList<>();
//记录点值数组
List<SeriseData> newSeriseDataList = new LinkedList<>();
//遍历临时点数组 将点位的横坐标以及纵坐标封装到对应的数组
for (int i=0; i<betaDataFile.getBetaList().size(); i++){
xs.add(betaDataFile.getBetaList().get(i).getX());
ys.add(betaDataFile.getBetaList().get(i).getY());
}
//计算C to E公式参数
List<Double> newFittingPara = EnergySpectrumHandler.GetFileFittingPara(xs, ys);
for (Double para:newFittingPara) {
newFittingParaStr.add(String.valueOf(para));
}
map.put("newCToE", newFittingParaStr);
//填充道值数组的数据
for (int i=0; i<255; i++) {
channels.add(Double.valueOf(i));
}
//计算道值的能量
List<Double> energys = EnergySpectrumHandler.GetFileFittingData(channels,newFittingPara);
//根据临时点的道值修改对应能量值
//遍历所有道值
for (int i=0; i< channels.size(); i++) {
//获取道值
double newChannel = channels.get(i).doubleValue();
//遍历临时点数据
for (int j=0; j<betaDataFile.getGammaList().size(); j++) {
SeriseData seriseData = betaDataFile.getGammaList().get(j);
double tempChannel = seriseData.getX();
//如果道值等于临时点的道值
if (newChannel == tempChannel) {
energys.set(i, seriseData.getY());
}
}
}
//将新计算的能量封装到数组
for (Double calEnergy:energys) {
List<Double> newEnergy = new LinkedList<>();
newEnergy.add(calEnergy);
energyList.add(newEnergy);
}
//遍历道值添加各道值对应点数据到数组
for (int i=0; i<channels.size(); ++i) {
SeriseData seriseData = new SeriseData();
seriseData.setX(channels.get(i));
seriseData.setY(energys.get(i));
newLineSeries.add(seriseData);
}
map.put("newLineSeries", newLineSeries);
//遍历点 缓存到表单数组以及折线图点位数组
for (int i=0; i<betaDataFile.getGammaList().size(); i++) {
//表单数据信息
TableWidget tableWidget = new TableWidget();
tableWidget.setRowCount(i+1);
tableWidget.setChannel(betaDataFile.getGammaList().get(i).getX());
tableWidget.setEnergy(betaDataFile.getGammaList().get(i).getY());
tableWidgets.add(tableWidget);
//折线图位置信息
SeriseData seriseData = new SeriseData();
seriseData.setX(betaDataFile.getGammaList().get(i).getX());
seriseData.setY(betaDataFile.getGammaList().get(i).getY());
newSeriseDataList.add(seriseData);
}
map.put("tableWidgets", tableWidgets);
map.put("newScatterSeriesData", newSeriseDataList);
//计算E to C公式参数
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(ys, xs);
for (Double para:newFittingParaToUi) {
newFittingParaToUiStr.add(String.valueOf(para));
}
map.put("newEToC", newFittingParaToUiStr);
}
if (betaDataFile.getBetaList().size()<=0) {
betaDataFile.setBetaList(oldScatterSeries);
}
if (betaDataFile.getBetaFittingPara().size()<=0) {
betaDataFile.setBetaFittingPara(fittingParaStr);
}
if (betaDataFile.getBetaFittingParaToUi().size()<=0) {
betaDataFile.setBetaFittingParaToUi(fittingParaToUiStr);
}
}
result.setSuccess(true);
result.setResult(map);
return result;
}
@Override
public Result Reprocessing(String fileName, String processKey, HttpServletRequest request) {
Result result = new Result();
String userName = JwtUtil.getUserNameByToken(request);
//获取自建台站缓存信息
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName);
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
// 根据ROI生成四个Gamma谱文件
// 文件命名为Beta名称后面_ROI_x.PHD
// 生成Gamma文件名
String gammaOneName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_1.PHD";
// 创建Gamma文件
selfStationUtil.createGammaFile(pathName, gammaOneName, selfStationData.getSampleStruct(),
selfStationData.getSampleVueData().getROIOneCounts());
String gammaTwoName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_2.PHD";
selfStationUtil.createGammaFile(pathName, gammaTwoName, selfStationData.getSampleStruct(),
selfStationData.getSampleVueData().getROITwoCounts());
String gammaThreeName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_3.PHD";
selfStationUtil.createGammaFile(pathName, gammaThreeName, selfStationData.getSampleStruct(),
selfStationData.getSampleVueData().getROIThreeCounts());
String gammaFourName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_4.PHD";
selfStationUtil.createGammaFile(pathName, gammaFourName, selfStationData.getSampleStruct(),
selfStationData.getSampleVueData().getROIFourCounts());
// Gamma文件内容转换为PHD实体
PHDFile phd = selfStationUtil.getGammaPHD(gammaTwoName, pathName);
// Cache<String, PHDFile> phdCache = localCache.getPHDCache();
// PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName);
if (Objects.isNull(phd)) {
result.error500("Please select the parse file first");
return result;
}
phd.setUserId(processKey);
// 赋值xml文件存放路径
phd.setXmlFilePath(parameterProperties.getFilePath());
// 获取当前角色的颜色配置
Map<String, String> colorMap = sysUserColorService.initColor(userName);
// 分析文件数据
int flag = gammaFileUtil.AnalyseData(phd);
if (flag == 0) {
String warning = "The spectrum needn't Analyed. Maybe:\n" +
"1. It has already Analyed.\n" +
"2. You didn't change any setting or calibration.";
result.error500(warning);
} else if (flag == -1) {
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
//分析时将phd的核素map重置
phd.setPhdNuclideMap(nuclideLinesMap);
//重新计算核素的活度浓度
gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
// todo 不要qcflags
// gammaFileUtil.RunQC(phd);
phd.setEfficiencyParam(phd.getUsedEffiPara().getP());
phd.setEfficiencyEnergy(phd.getUsedEffiKD().getG_energy());
phd.setEfficiencyCurRow(0);
// 重新计算峰值
Map<String, NuclideLines> nuclideLinesMDCMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
gammaFileUtil.getNuclideMDCValue(phd, phd.getMdcInfoMap(), nuclideLinesMDCMap);
String warning = "Finish three tasks:\n" +
"\t1.Update efficiencies of all peaks;\n" +
"\t2.Identify nuclides again;\n" +
"\t3.Test QC again.";
result.error500(warning);
} else {
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
//分析时将phd的核素map重置
phd.setPhdNuclideMap(nuclideLinesMap);
//调用分析算法
boolean analyseSpectrum = gammaFileUtil.AnalyseSpectrum(phd, nuclideLinesMap);
if (analyseSpectrum) {
// 重新分析各峰值对应的核素信息
// gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
phd.setEfficiencyParam(phd.getUsedEffiPara().getP());
phd.setEfficiencyEnergy(phd.getUsedEffiKD().getG_energy());
phd.setEfficiencyCurRow(0);
// 重新计算峰值
Map<String, NuclideLines> nuclideLinesMDCMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
gammaFileUtil.getNuclideMDCValue(phd, phd.getMdcInfoMap(), nuclideLinesMDCMap);
Map<String, Object> map = new HashMap<>();
gammaFileUtil.UpdateChart(phd, map, colorMap);
// 更新 QC Flags 状态
phd.getQcItems().clear();
// List<String> qcstate = gammaFileUtil.Qcstate(phd);
// todo 不要qcflags
// map.put("QCFlag", qcstate);
map.put("bAnalyed", phd.isBAnalyed());
map.put("peak", phd.getVPeak());
map.put("BaseCtrls", phd.getBaseCtrls());
// Bar Chart 柱状图
List<SeriseData> differance = gammaFileUtil.Differance(phd, phd.getVPeak());
map.put("barChart", differance);
result.setSuccess(true);
result.setResult(map);
} else {
result.error500("There is a problem with the current phd file, Analysis failure!");
}
}
return result;
}
}

View File

@ -14,7 +14,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.cache.Cache;
import com.google.common.collect.Maps;
import io.swagger.models.auth.In;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.shiro.SecurityUtils;
@ -44,7 +43,6 @@ import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.TemplateEngine;
@ -301,7 +299,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
Result result = new Result();
List<Map<String, Object>> resultList = new LinkedList<>();
String userName = JwtUtil.getUserNameByToken(request);
String filePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName;
String filePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName;
String sampleRx = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.PHD";
Pattern regexPattern = Pattern.compile(sampleRx);
String sampleRx1 = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.\\d+\\.PHD";
@ -499,9 +497,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
betaDataFile.setSampleId(String.valueOf(sampleId));
//判断sample信息是否存在
if (Objects.nonNull(sample)) {
betaDataFile.setSampleFilePathName(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath());
betaDataFile.setSampleFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath());
betaDataFile.setSampleFileName(sampleFileName);
sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName());
sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma");
if (Objects.nonNull(sampleTmp)) {
//sample临时文件路径存储
betaDataFile.setSampleTmpPath(sampleTmp.getAbsolutePath());
@ -536,9 +534,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
//判断gas信息是否存在
if (Objects.nonNull(gasBg)) {
betaDataFile.setGasFilePathName(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath());
betaDataFile.setGasFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath());
betaDataFile.setGasFileName(gasFileName);
gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName());
gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma");
if (Objects.nonNull(gasTmp)) {
//存储gas临时文件路径
betaDataFile.setGasTmpPath(gasTmp.getAbsolutePath());
@ -573,9 +571,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
//判断det信息是否存在
if (Objects.nonNull(detBg)) {
betaDataFile.setDetFilePathName(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getDetBgFilePath());
betaDataFile.setDetFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getDetBgFilePath());
betaDataFile.setDetFileName(detFileName);
detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName());
detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma");
if (Objects.nonNull(detTmp)) {
//存储det临时文件路径
betaDataFile.setDetTmpPath(detTmp.getAbsolutePath());
@ -610,9 +608,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
//判断qc信息是否存在
if (Objects.nonNull(qc)) {
betaDataFile.setQcFilePathName(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbQcFilePath);
betaDataFile.setQcFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbQcFilePath);
betaDataFile.setQcFileName(qcFileName);
qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName());
qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName(), "betaGamma");
if (Objects.nonNull(qcTmp)) {
betaDataFile.setQcTmpPath(qcTmp.getAbsolutePath());
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(qcTmp.getAbsolutePath());
@ -624,13 +622,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
//更新缓存数据对应的缓存数据
phdFileUtil.createBgCalPara(betaDataFile, gammaCalibrationSpectrumList, betaCalibrationSpectrumList, gammaCalibrationPairsList, betaCalibrationPairsList);
//第一次加载时初始化数据库数据
betaDataFile.setGammaCalibrationSpectrumEList(gammaCalibrationSpectrumList);
betaDataFile.setBetaCalibrationSpectrumEList(betaCalibrationSpectrumList);
betaDataFile.setRoiChannelsSpectrumList(roiChannelsSpectrumList);
betaDataFile.setRoiResultsSpectrumList(roiResultsSpectrumList);
betaDataFile.setGammaCalibrationPairsList(gammaCalibrationPairsList);
betaDataFile.setBetaCalibrationPairsList(betaCalibrationPairsList);
} else {
xeResultsSpectrumList = betaDataFile.getXeResultsSpectrumList();
sampleMap = loadData("sample", betaDataFile);
@ -665,6 +656,12 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
xeData.setConcErr(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConcErr()))));
}
}
betaDataFile.setGammaCalibrationSpectrumEList(gammaCalibrationSpectrumList);
betaDataFile.setBetaCalibrationSpectrumEList(betaCalibrationSpectrumList);
betaDataFile.setRoiChannelsSpectrumList(roiChannelsSpectrumList);
betaDataFile.setRoiResultsSpectrumList(roiResultsSpectrumList);
betaDataFile.setGammaCalibrationPairsList(gammaCalibrationPairsList);
betaDataFile.setBetaCalibrationPairsList(betaCalibrationPairsList);
betaDataFile.setXeResultsSpectrumList(xeResultsSpectrumList);
betaDataFile.setSaveAnalysisResult(true);
resultMap.put("XeData", phdFileUtil.viewXeData(xeResultsSpectrumList));
@ -690,7 +687,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
//获取用户名
String userName = JwtUtil.getUserNameByToken(request);
//上传文件路径
String path = spectrumPathProperties.getRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String path = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
Map<String, Object> resultMap = new HashMap<>();
Map<String, Object> sampleMap = new HashMap<>();
Map<String, Object> gasBgMap = new HashMap<>();
@ -802,7 +799,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
File file = null;
try {
//根据完整的文件路径 获取临时文件
file = ftpUtil.downloadFile(filePathName);
file = ftpUtil.downloadFile(filePathName, "betaGamma");
if (Objects.nonNull(file)) {
if (type.equalsIgnoreCase("sample")) {
betaDataFile.setSampleTmpPath(file.getAbsolutePath());
@ -899,6 +896,26 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
String betaKey = sampleFileName + "-" + userName;
Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
BetaDataFile betaDataFile = cache.getIfPresent(betaKey);
String sampleTmpPath = betaDataFile.getSampleTmpPath();
if (StringUtils.isNotBlank(sampleTmpPath)) {
File file = new File(sampleTmpPath);
file.delete();
}
String gasTmpPath = betaDataFile.getGasTmpPath();
if (StringUtils.isNotBlank(gasTmpPath)) {
File file = new File(gasTmpPath);
file.delete();
}
String detTmpPath = betaDataFile.getDetTmpPath();
if (StringUtils.isNotBlank(detTmpPath)) {
File file = new File(detTmpPath);
file.delete();
}
String qcTmpPath = betaDataFile.getQcTmpPath();
if (StringUtils.isNotBlank(qcTmpPath)) {
File file = new File(qcTmpPath);
file.delete();
}
betaCache.deleteBetaCache(betaKey);
}
@ -947,7 +964,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
InputStream inputStream = null;
ServletOutputStream outputStream = null;
try {
inputStream = ftpUtil.downloadFileStream(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt");
inputStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt");
if (Objects.nonNull(inputStream)){
outputStream = response.getOutputStream();
byte[] buffer = new byte[1024];
@ -3497,7 +3514,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
betaDataFile.setBProcessed(false);
betaDataFile.setSaveAnalysisResult(false);
betaDataFile.setXeResultsSpectrumList(Collections.EMPTY_LIST);
xeMap.put("XeData", Collections.EMPTY_LIST);
xeMap.put("bProcessed", false);
xeMap.put("savedAnalysisResult", false);
@ -3523,12 +3539,10 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
List<SeriseData> betaList = new LinkedList<>();
List<String> betaFittingPara = new LinkedList<>();
List<String> betaFittingParaToUi = new LinkedList<>();
List<List<Double>> betaNewEnergyListNow = new LinkedList<>();
List<SeriseData> gammaList = new LinkedList<>();
List<String> gammaFittingPara = new LinkedList<>();
List<String> gammaFittingParaToUi = new LinkedList<>();
List<List<Double>> gammaNewEnergyListNow = new LinkedList<>();
//根据sample文件名称获取当前文件的缓存信息
//根据sample文件名称获取当前文件的缓存信息
BetaDataFile sampleBetaData = cache.getIfPresent(sampleFileName + "-" + userName);
//存储重新分析字段的实体类
SpectrumGroup spectrum_group = new SpectrumGroup();
@ -3543,16 +3557,15 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
betaDataFile.setBetaFittingPara(betaDataFile.getBetaFittingParaNow());
betaDataFile.setBetaFittingParaToUi(betaDataFile.getBetaFittingParaToUiNow());
betaDataFile.setBetaNewEnergyList(betaDataFile.getBetaNewEnergyListNow());
//将新的数组封装到各自的数组中
betaList = betaDataFile.getBetaList();
betaFittingPara = betaDataFile.getBetaFittingPara();
betaFittingParaToUi = betaDataFile.getBetaFittingParaToUi();
betaNewEnergyListNow = betaDataFile.getBetaNewEnergyListNow();
//将当前文件用到的计算数据同步到需要计算的文件缓存
sampleBetaData.setBetaList(betaList);
sampleBetaData.setBetaFittingPara(betaFittingPara);
sampleBetaData.setBetaFittingParaToUi(betaFittingParaToUi);
sampleBetaData.setBetaNewEnergyList(betaNewEnergyListNow);
sampleBetaData.setBetaNewEnergyList(betaDataFile.getBetaNewEnergyListNow());
//将新的数组封装到各自的数组中
betaList = betaDataFile.getBetaList();
betaFittingPara = betaDataFile.getBetaFittingPara();
betaFittingParaToUi = betaDataFile.getBetaFittingParaToUi();
}
List<Double> beCal = new LinkedList<>();
beCal.add(Double.valueOf(betaFittingParaToUi.get(0)));
@ -3601,16 +3614,15 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
betaDataFile.setGammaFittingPara(betaDataFile.getGammaFittingParaNow());
betaDataFile.setGammaFittingParaToUi(betaDataFile.getGammaFittingParaToUiNow());
betaDataFile.setGammaNewEnergyList(betaDataFile.getGammaNewEnergyListNow());
//将新的数组封装到各自的数组中
gammaList = betaDataFile.getGammaList();
gammaFittingPara = betaDataFile.getGammaFittingPara();
gammaFittingParaToUi = betaDataFile.getGammaFittingParaToUi();
gammaNewEnergyListNow = betaDataFile.getGammaNewEnergyListNow();
//将当前文件用到的计算数据同步到需要计算的文件缓存
sampleBetaData.setGammaList(gammaList);
sampleBetaData.setGammaFittingPara(gammaFittingPara);
sampleBetaData.setGammaFittingParaToUi(gammaFittingParaToUi);
sampleBetaData.setGammaNewEnergyList(gammaNewEnergyListNow);
sampleBetaData.setGammaNewEnergyList(betaDataFile.getGammaNewEnergyListNow());
//将新的数组封装到各自的数组中
gammaList = betaDataFile.getGammaList();
gammaFittingPara = betaDataFile.getGammaFittingPara();
gammaFittingParaToUi = betaDataFile.getGammaFittingParaToUi();
}
List<Double> geCal = new LinkedList<>();
geCal.add(Double.valueOf(gammaFittingParaToUi.get(0)));
@ -3740,7 +3752,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
sampleBetaData.setBProcessed(false);
sampleBetaData.setSaveAnalysisResult(false);
sampleBetaData.setXeResultsSpectrumList(Collections.EMPTY_LIST);
xeMap.put("XeData", Collections.EMPTY_LIST);
xeMap.put("bProcessed", false);
xeMap.put("savedAnalysisResult", false);
@ -3871,7 +3882,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
map.put("XeData", Collections.EMPTY_LIST);
betaDataFile.setBProcessed(false);
betaDataFile.setSaveAnalysisResult(false);
betaDataFile.setXeResultsSpectrumList(Collections.EMPTY_LIST);
map.put("bProcessed", false);
map.put("savedAnalysisResult", false);
}
@ -3997,7 +4007,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
map.put("XeData", Collections.EMPTY_LIST);
betaDataFile.setBProcessed(false);
betaDataFile.setSaveAnalysisResult(false);
betaDataFile.setXeResultsSpectrumList(Collections.EMPTY_LIST);
map.put("bProcessed", false);
map.put("savedAnalysisResult", false);
mapList.put(sampleFileName, map);
@ -4009,7 +4018,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
e.printStackTrace();
}
result.setSuccess(true);
result.setResult(mapList);
result.setResult(mapList.get(currentFileName));
return result;
}
@ -4022,7 +4031,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
InputStream inputStream = null;
ServletOutputStream outputStream = null;
try {
inputStream = ftpUtil.downloadFileStream(spectrumPathProperties.getRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath);
inputStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath);
if (Objects.nonNull(inputStream)){
outputStream = response.getOutputStream();
byte[] buffer = new byte[1024];
@ -4301,68 +4310,55 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
//上传本次文件到ftp人工交互存储路径下
try {
if (StringUtils.isNotBlank(sampleFilePathName)) {
//sample文件的saveFile存储路径
String saveSamplePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName;
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath()) && !saveSamplePath.equals(betaDataFile.getSampleTmpPath().replace(StringPool.BACK_SLASH, StringPool.SLASH))) {
File sampleTmp = new File(betaDataFile.getSampleTmpPath());
ftpUtil.saveFile(saveSamplePath, new FileInputStream(sampleTmp));
}
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
File sampleTmp = new File(betaDataFile.getSampleTmpPath());
ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp));
}
if (StringUtils.isNotBlank(gasFilePathName)) {
//gas文件的saveFile存储路径
String saveGasPath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName;
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath()) && !saveGasPath.equals(betaDataFile.getGasTmpPath().replace(StringPool.BACK_SLASH, StringPool.SLASH))) {
File gasTmp = new File(betaDataFile.getGasTmpPath());
ftpUtil.saveFile(saveGasPath, new FileInputStream(gasTmp));
}
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
File gasTmp = new File(betaDataFile.getGasTmpPath());
ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp));
}
if (StringUtils.isNotBlank(detFilePathName)) {
//det文件的saveFile存储路径
String saveDetPath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName;
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath()) && !saveDetPath.equals(betaDataFile.getDetTmpPath().replace(StringPool.BACK_SLASH, StringPool.SLASH))) {
File detTmp = new File(betaDataFile.getDetTmpPath());
ftpUtil.saveFile(saveDetPath, new FileInputStream(detTmp));
}
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
File detTmp = new File(betaDataFile.getDetTmpPath());
ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp));
}
if (StringUtils.isNotBlank(qcFilePathName)) {
//qc文件的saveFile存储路径
String saveQcPath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName;
if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath()) && !saveQcPath.equals(betaDataFile.getQcTmpPath().replace(StringPool.BACK_SLASH, StringPool.SLASH))) {
File qcTmp = new File(betaDataFile.getQcTmpPath());
ftpUtil.saveFile(saveQcPath, new FileInputStream(qcTmp));
}
if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath())) {
File qcTmp = new File(betaDataFile.getQcTmpPath());
ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp));
}
//分析成功后存储日志文件和报告文件
{
String logFileName = betaDataFile.getSampleFileName().replace("PHD", "log");
String logPathName = analyses_absolute_LogPath.substring(0, analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH));
String logFileName = analyses_absolute_LogPath.substring(analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH)+1);
//获取日志的文件存放路径
String logFilePath = parameterProperties.getLogFilePath() + File.separator + DateUtils.formatDate(new Date(), "yyyy-MM-dd");
String localLogName = betaDataFile.getSampleFileName().replace("PHD", "log");
//判断文件路径是否存在
File logPath = new File(logFilePath);
if (!logPath.exists()) {
logPath.mkdirs();
}
File logFile = new File(logFilePath + File.separator +logFileName);
File logFile = new File(logFilePath + File.separator +localLogName);
try {
//判断日志文件是否存在 如果不存在创建一个空的文件 上传到ftp
if (!logFile.exists()) {
FileUtil.writeString("", logFile, "UTF-8");
}
FileInputStream in = new FileInputStream(logFile);
ftpUtil.saveFile(spectrumPathProperties.getRootPath()+analyses_absolute_LogPath, in);
ftpUtil.saveFile(logPathName, logFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
{
String rptContent = phdFileUtil.OutPutRnRpt(betaDataFile);
String rptPathName = analyses_absolute_ReportPath.substring(0, analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH));
String rptFileName = analyses_absolute_ReportPath.substring(analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH)+1)+".txt";
File rptFile = new File(rptFileName);
try {
FileUtil.writeString(rptContent, rptFile, "UTF-8");
FileInputStream in = new FileInputStream(rptFile);
ftpUtil.saveFile(spectrumPathProperties.getRootPath()+analyses_absolute_ReportPath+".txt", in);
ftpUtil.saveFile(rptPathName, rptFileName, in);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
@ -4437,7 +4433,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
String error = "get station_id or detect_id error";
return false;
}
betaDataFile.setDetectorId(detectorId.toString());
//新增Gards_Sample_Data表数据
sampleDataSpectrumService.saveSampleData(sourceData, stationId, detectorId, filePathName, readLines);
//获取sampleId
@ -5810,13 +5805,13 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
xeDataList = getXeDataList(xeResultsSpectrumList);
}
for (GardsXeResults xeData :xeDataList) {
if (xeData.getNuclideName().equals(XeNuclideName.XE_131m.getType())) {
if (xeData.getNuclideName().equals(XeNuclideName.XE_131m)) {
xeData.setNidFlag(anlyseResultIn.getXe131mFlag());
} else if (xeData.getNuclideName().equals(XeNuclideName.XE_133.getType())) {
} else if (xeData.getNuclideName().equals(XeNuclideName.XE_133)) {
xeData.setNidFlag(anlyseResultIn.getXe133Flag());
} else if (xeData.getNuclideName().equals(XeNuclideName.XE_133m.getType())) {
} else if (xeData.getNuclideName().equals(XeNuclideName.XE_133m)) {
xeData.setNidFlag(anlyseResultIn.getXe133mFlag());
} else if (xeData.getNuclideName().equals(XeNuclideName.XE_135.getType())) {
} else if (xeData.getNuclideName().equals(XeNuclideName.XE_135)) {
xeData.setNidFlag(anlyseResultIn.getXe135Flag());
}
}
@ -5848,12 +5843,10 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
public List<GardsXeResults> getXeDataList(List<GardsXeResultsSpectrum> xeResultsSpectrumList) {
List<GardsXeResults> xeDataList = new LinkedList<>();
if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)) {
for (GardsXeResultsSpectrum xeResultsSpectrum:xeResultsSpectrumList) {
GardsXeResults xeResults = new GardsXeResults();
BeanUtil.copyProperties(xeResultsSpectrum, xeResults);
xeDataList.add(xeResults);
}
for (GardsXeResultsSpectrum xeResultsSpectrum:xeResultsSpectrumList) {
GardsXeResults xeResults = new GardsXeResults();
BeanUtil.copyProperties(xeResultsSpectrum, xeResults);
xeDataList.add(xeResults);
}
return xeDataList;
}

View File

@ -53,49 +53,31 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
@Override
public Result<?> upload(MultipartFile file) {
//压缩包文件名称
String filename = file.getOriginalFilename();
//判断是否是压缩包文件
boolean isZip = filename.endsWith(FileTypeEnum.zip.getType());
//如果不是压缩包文件 返回错误提示信息
if (!isZip) {
return Result.error(Prompt.FILE_TYPE_ERR);
}
//获取登陆用户名
if (!isZip) return Result.error(Prompt.FILE_TYPE_ERR);
LoginUser user = (LoginUser)SecurityUtils.getSubject().getPrincipal();
String username = user.getUsername();
// FTPClient ftpClient = null;
//获取文件输出流
FTPClient ftpClient = null;
FileOutputStream fos = null;
//获取压缩包文件输入流
ZipInputStream zipInputStream = null;
String slash = SymbolConstant.SINGLE_SLASH;
//上传文件夹路径
String filePath = spectrumPathProperties.getRootPath() + slash + spectrumPathProperties.getUploadPath() + slash + username;
String filePath = spectrumPathProperties.getUploadPath() + slash + username;
//本地临时文件夹路径
String tempFilePath = System.getProperty("java.io.tmpdir") + username + slash;
//文件名称集合
List<String> fileNames = new ArrayList<>();
//文件集合
List<File> fileList = new ArrayList<>();
//正则表达式
String sampleRx = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_(S|G|D|Q)_(FULL_|PREL_)\\d+\\.PHD";
Pattern regexPattern = Pattern.compile(sampleRx);
String sampleRx1 = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_(S|G|D|Q)_(FULL_|PREL_)\\d+\\.\\d+\\.PHD";
Pattern regexPattern1 = Pattern.compile(sampleRx1);
try{
//创建本地临时文件夹
File tempDir = new File(tempFilePath);
//判断本地临时文件夹是否存在
if (!tempDir.exists()) {
tempDir.mkdir();
}
//创建输入流
if (!tempDir.exists()) tempDir.mkdir();
zipInputStream = new ZipInputStream(file.getInputStream());
ZipEntry entry;
//遍历获取压缩包内文件
while (ObjectUtil.isNotNull(entry = zipInputStream.getNextEntry())) {
//文件名称
String fileName = entry.getName();
fileNames.add(fileName);
File oneFile = new File(tempFilePath + fileName);
@ -107,61 +89,46 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
}
fileList.add(oneFile);
}
//判断文件集合是否为空
if (CollUtil.isEmpty(fileList)) {
if (CollUtil.isEmpty(fileList))
return Result.error(Prompt.FILE_IS_EMPTY);
}
// //登陆ftp
// ftpClient = ftpUtil.LoginFTP();
// if (ObjectUtil.isNull(ftpClient)) {
// return Result.error(Prompt.FTP_ERR);
// }
// // 如果指定目录不存在,逐级创建目录
// boolean created = FTPUtil.createDirs(ftpClient, filePath);
// if (!created) {
// return Result.error(Prompt.DIR_CREATE_FAIL + filePath);
// }
ftpClient = ftpUtil.LoginFTP();
if (ObjectUtil.isNull(ftpClient))
return Result.error(Prompt.FTP_ERR);
// 如果指定目录不存在,逐级创建目录
boolean created = FTPUtil.createDirs(ftpClient, filePath);
if (!created) return Result.error(Prompt.DIR_CREATE_FAIL + filePath);
// 上传所有文件
List<String> failList = new ArrayList<>();
for (File oneFile : fileList) {
String fileName = oneFile.getName();
// 判断能谱文件名称是否符合规则不符合则进行重命名
if (!regexPattern.matcher(fileName).find() && !regexPattern1.matcher(fileName).find()) {
//分析文件
EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(oneFile);
//获取文件后缀
String suffix = nameStandUtil.GetSuffix(struct.data_type, struct.spectrum_quantity, String.valueOf(struct.acquisition_live_time));
//获取文件名称
fileName = nameStandUtil.GetFileNameFromDateTime(struct.measurement_id, suffix);
}
String fullFilePath = filePath + slash + fileName;
FileInputStream local = new FileInputStream(oneFile);
boolean success = ftpUtil.saveFile(fullFilePath, local);
if (!success) {
failList.add(fullFilePath);
}
boolean success = ftpClient.storeFile(fileName, local);
if (!success) failList.add(fullFilePath);
}
if (CollUtil.isNotEmpty(failList)) {
if (CollUtil.isNotEmpty(failList))
return Result.error(Prompt.UPLOAD_ERR, failList);
}
return Result.OK(Prompt.UPLOAD_SUCC);
} catch (IOException e) {
e.printStackTrace();
return Result.error(Prompt.UPLOAD_ERR);
}finally {
try {
if (ObjectUtil.isNotNull(zipInputStream)) {
if (ObjectUtil.isNotNull(zipInputStream))
zipInputStream.close();
}
if (ObjectUtil.isNotNull(fos)) {
if (ObjectUtil.isNotNull(fos))
fos.close();
}
// if (ObjectUtil.isNotNull(ftpClient)) {
// if (ftpClient.isConnected()){
// ftpClient.logout();
// ftpClient.disconnect();
// }
// }
if (ObjectUtil.isNotNull(ftpClient))
if (ftpClient.isConnected()){
ftpClient.logout();
ftpClient.disconnect();
}
} catch (IOException e) {
e.printStackTrace();
}
@ -176,18 +143,17 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
String username = user.getUsername();
String slash = SymbolConstant.SINGLE_SLASH;
String comma = SymbolConstant.COMMA;
String filePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getUploadPath() + slash + username;
String filePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + slash + username;
FTPClient ftpClient = null;
List<FileDto> fileDtos = new ArrayList<>();
Page<FileDto> page = new Page<>(pageNo, pageSize);
try {
File folder = new File(filePath);
// ftpClient = ftpUtil.LoginFTP();
// if (ObjectUtil.isNull(ftpClient))
// return Result.error(Prompt.FTP_ERR);
// boolean exist = ftpClient.changeWorkingDirectory(filePath);
// if (!exist) return Result.OK(page);
List<File> ftpFiles = ListUtil.toList(folder.listFiles());
ftpClient = ftpUtil.LoginFTP();
if (ObjectUtil.isNull(ftpClient))
return Result.error(Prompt.FTP_ERR);
boolean exist = ftpClient.changeWorkingDirectory(filePath);
if (!exist) return Result.OK(page);
List<FTPFile> ftpFiles = ListUtil.toList(ftpClient.listFiles());
// 根据文件名进行过滤
String name = fileVo.getName();
if (StrUtil.isNotBlank(name)){
@ -196,10 +162,11 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
.filter(file -> containsAllIgnoreCase(file.getName(),names))
.collect(Collectors.toList());
}
for (File ftpFile : ftpFiles) {
for (FTPFile ftpFile : ftpFiles) {
String fileName = ftpFile.getName();
Date updateDate = new Date(ftpFile.lastModified());
long size = ftpFile.length();
Calendar calendar = ftpFile.getTimestamp();
Date updateDate = calendar.getTime();
long size = ftpFile.getSize();
FileDto fileDto = new FileDto();
fileDto.setName(fileName);
fileDto.setUpdateDate(updateDate);
@ -212,7 +179,7 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
List<FileDto> records = PageUtil.page(pageNo, pageSize, fileDtos);
page.setRecords(records).setTotal(fileDtos.size());
return Result.OK(page);
} catch (Exception e) {
} catch (IOException e) {
e.printStackTrace();
return Result.error(e.getMessage());
}finally {

View File

@ -30,6 +30,14 @@ public interface AbnormalAlarmClient {
@PostMapping("/alarmLog/create")
Result<?> create(@RequestBody AlarmLog alarmLog);
/* CalculateConcController下相关接口 */
@GetMapping("/calculateConc/caclAndSave")
boolean calculateConc();
/* AlarmAnalysisNuclideParamController下相关接口 */
@GetMapping("/nuclideParam/refresh")
boolean refreshParam();
/* SysDatabaseController下相关接口 */
@GetMapping("/sysDatabase/getNameById")
String getDatabaseName(@RequestParam String id);

View File

@ -0,0 +1,70 @@
package org.jeecg.modules.quartz.controller;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.Prompt;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.ImportExcelUtil;
import org.jeecg.common.util.RedisStreamUtil;
import org.jeecg.modules.base.dto.Info;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("sys/testana")
@Slf4j
@Api(tags = "定时任务接口")
public class TestController {
@Autowired
private RedisStreamUtil redisStreamUtil;
@GetMapping("test")
public void test(){
Info info = new Info();
info.setStationId("205");
info.setSampleId("425496");
info.setBetaOrGamma("Gamma");
info.setFullOrPrel("FULL");
info.setDatasource("1");
info.setSampleName("CAX05_001-20230624_0220_Q_FULL_299.3.PHD");
info.setCollectionDate(LocalDateTime.now());
Map<String, String> nuclides = MapUtil.newHashMap();
nuclides.put("Be7","1000000");
nuclides.put("sss","1000000");
nuclides.put("Tl208","10");
info.setNuclides(nuclides);
redisStreamUtil.pushAnalysis(info);
}
}

View File

@ -0,0 +1,36 @@
package org.jeecg.modules.quartz.job;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.config.mqtoken.UserTokenContext;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
import org.quartz.*;
/**
* 此处的同步是指:当定时任务的执行时间大于任务的时间
* 间隔时会等待第一个任务执行完成才会走第二个任务
*/
/**
* 定时更新核素浓度计算参数
*/
@Slf4j
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class NuclideParamJob implements Job {
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
try {
UserTokenContext.setToken(TokenUtils.getTempToken());
AbnormalAlarmClient alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
alarmClient.refreshParam();
}catch (Exception e){
log.error("定时任务[NuclideParamJob]执行异常: {}", e.getMessage());
}finally {
UserTokenContext.remove();
}
}
}

View File

@ -0,0 +1,48 @@
package org.jeecg.modules.quartz.job;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.config.mqtoken.UserTokenContext;
import org.jeecg.common.constant.DateConstant;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
import org.quartz.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* 此处的同步是指:当定时任务的执行时间大于任务的时间
* 间隔时会等待第一个任务执行完成才会走第二个任务
*/
/**
* 定时计算核素浓度均值
*/
@Slf4j
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class NucliedAvgJob implements Job {
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
try {
UserTokenContext.setToken(TokenUtils.getTempToken());
AbnormalAlarmClient alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
alarmClient.calculateConc();
log.info(log());
}catch (Exception e){
log.error("定时任务[NucliedAvgJob]执行异常: {}", e.getMessage());
}finally {
UserTokenContext.remove();
}
}
private String log(){
String now = LocalDateTime.now()
.format(DateTimeFormatter.ofPattern(DateConstant.DATE_TIME));
return "计算核素浓度均值的定时任务成功执行, " +
"任务执行类: org.jeecg.modules.quartz.job.NucliedAvgJob, " +
"任务执行时间: " + now;
}
}

View File

@ -246,7 +246,7 @@ public class LoginController {
return Result.error("Token无效!");
}
}
/**
* 获取访问量
* @return

View File

@ -1,10 +1,8 @@
package org.jeecg.modules.system.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
@ -15,7 +13,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import com.google.common.io.Files;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
@ -50,6 +47,9 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
@Autowired
private RedisUtil redisUtil;
@Autowired
private FTPUtil ftpUtil;
@Autowired
private SpectrumPathProperties pathProperties;
@ -110,9 +110,9 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
TransactionDefinition txDef = new DefaultTransactionDefinition();
final TransactionStatus txStatus = transactionManager.getTransaction(txDef);
try {
String rootPath = pathProperties.getRootPath();
String savePath = rootPath + pathProperties.getSaveFilePath() + StrUtil.SLASH;
String logPath = rootPath + pathProperties.getLogPath() + StrUtil.SLASH;
String ftpRootPath = ftpUtil.getFtpRootPath();
String savePath = ftpRootPath + pathProperties.getSaveFilePath() + StrUtil.SLASH;
String logPath = ftpRootPath + pathProperties.getLogPath() + StrUtil.SLASH;
/* 删除数据库数据 */
// 过滤掉多余的表
String ORIGINAL = "ORIGINAL";String RNAUTO = "RNAUTO";String RNMAN = "RNMAN";
@ -170,14 +170,16 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
needDel = needDel.stream().filter(StrUtil::isNotBlank).collect(Collectors.toList());
if (CollUtil.isEmpty(needDel))
return Result.OK("Data cleaning is complete. No files need to be cleaned!");
// 删除本地文件
List<String> fails = new ArrayList<>();
for (String path : needDel) {
boolean success = FileUtil.del(path);
if (!success) fails.add(path);
// 删除FTP文件
List<String> failList = new ArrayList<>();
for (String path:needDel) {
boolean success = ftpUtil.removeFiles(path);
if (!success) {
failList.add(path);
}
}
if (CollUtil.isNotEmpty(fails))
return Result.error("Data clearing is complete, but file clearing fails!", fails);
if (CollUtil.isNotEmpty(failList))
return Result.error("Data clearing is complete, but file clearing fails!", failList);
return Result.OK("Data and file cleanup complete!");
}catch (Exception e){
transactionManager.rollback(txStatus);
@ -213,25 +215,27 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
Integer sampleId, String owner){
List<String> fileList = new ArrayList<>();
List<AnalysesDto> AnalysesDtoList = baseMapper.getAnalysis(owner, sampleId);
for (AnalysesDto AnalysesDto:AnalysesDtoList) {
String baselinePath = AnalysesDto.getBaselinePath();
if (StrUtil.isNotBlank(baselinePath)) {
fileList.add(savePath + baselinePath);
}
String lcPath = AnalysesDto.getLcPath();
if (StrUtil.isNotBlank(lcPath)) {
fileList.add(savePath + lcPath);
}
String scacPath = AnalysesDto.getScacPath();
if (StrUtil.isNotBlank(scacPath)) {
fileList.add(savePath + scacPath);
}
if (StrUtil.isNotBlank(AnalysesDto.getLogPath())) {
fileList.add(logPath + AnalysesDto.getLogPath());
}
String reportPath = AnalysesDto.getReportPath();
if (StrUtil.isNotBlank(reportPath)) {
fileList.add(savePath + reportPath + FileTypeEnum.txt.getType());
if (CollectionUtils.isNotEmpty(AnalysesDtoList)) {
for (AnalysesDto AnalysesDto:AnalysesDtoList) {
String baselinePath = AnalysesDto.getBaselinePath();
if (StrUtil.isNotBlank(baselinePath)) {
fileList.add(savePath + baselinePath);
}
String lcPath = AnalysesDto.getLcPath();
if (StrUtil.isNotBlank(lcPath)) {
fileList.add(savePath + lcPath);
}
String scacPath = AnalysesDto.getScacPath();
if (StrUtil.isNotBlank(scacPath)) {
fileList.add(savePath + scacPath);
}
if (StrUtil.isNotBlank(AnalysesDto.getLogPath())) {
fileList.add(logPath + AnalysesDto.getLogPath());
}
String reportPath = AnalysesDto.getReportPath();
if (StrUtil.isNotBlank(reportPath)) {
fileList.add(savePath + reportPath + FileTypeEnum.txt.getType());
}
}
}
return fileList;

View File

@ -34,7 +34,7 @@ public class ReadLineUtil {
File file = null;
try {
filePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath;
file = ftpUtil.downloadFile(filePath);
file = ftpUtil.downloadFile(filePath, "betaGamma");
//判断文件路径是否为空
if (Objects.nonNull(file)){
List<String> allLines = FileUtils.readLines(file, encoding);
@ -52,6 +52,10 @@ public class ReadLineUtil {
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (Objects.nonNull(file)) {
file.delete();
}
}
return Collections.emptyMap();
}

View File

@ -133,7 +133,7 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
GardsSampleDataWeb sampleData = getOneSample(sampleId);
String filePath = sampleData.getInputFileName();
if (StringUtils.isNotBlank(filePath)) {
file = ftpUtil.downloadFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath);
file = ftpUtil.downloadFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath, "betaGamma");
if (Objects.nonNull(file)) {
EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
//查询info

View File

@ -31,19 +31,7 @@ public class JeecgAbnormalAlarmApplication extends SpringBootServletInitializer
}
public static void main(String[] args) throws UnknownHostException {
int exitCode = 1;
ConfigurableApplicationContext application = null;
try {
application = SpringApplication.run(JeecgAbnormalAlarmApplication.class, args);
} catch (Exception e) {
if (null != application) {
application.close();
exitCode = SpringApplication.exit(application, () -> 0);
}
System.exit(exitCode);
}
// ConfigurableApplicationContext application = SpringApplication.run(JeecgAbnormalAlarmApplication.class, args);
ConfigurableApplicationContext application = SpringApplication.run(JeecgAbnormalAlarmApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");

View File

@ -53,19 +53,7 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
}
public static void main(String[] args) throws UnknownHostException {
int exitCode = 1;
ConfigurableApplicationContext application = null;
try {
application = SpringApplication.run(JeecgAutoProcessApplication.class, args);
} catch (Exception e) {
if (null != application) {
application.close();
exitCode = SpringApplication.exit(application, () -> 0);
}
System.exit(exitCode);
}
// ConfigurableApplicationContext application = SpringApplication.run(JeecgAutoProcessApplication.class, args);
ConfigurableApplicationContext application = SpringApplication.run(JeecgAutoProcessApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");

View File

@ -27,19 +27,7 @@ public class JeecgLogManageApplication extends SpringBootServletInitializer impl
}
public static void main(String[] args) throws UnknownHostException {
int exitCode = 1;
ConfigurableApplicationContext application = null;
try {
application = SpringApplication.run(JeecgLogManageApplication.class, args);
} catch (Exception e) {
if (null != application) {
application.close();
exitCode = SpringApplication.exit(application, () -> 0);
}
System.exit(exitCode);
}
// ConfigurableApplicationContext application = SpringApplication.run(JeecgLogManageApplication.class, args);
ConfigurableApplicationContext application = SpringApplication.run(JeecgLogManageApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");

View File

@ -15,5 +15,4 @@ spring:
config:
import:
- optional:nacos:armd.yaml
- optional:nacos:armd-@profile.name@.yaml
- optional:nacos:armd-analysis-@profile.name@.yaml
- optional:nacos:armd-@profile.name@.yaml

View File

@ -1,6 +1,5 @@
package org.jeecg;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.cache.BetaCache;
import org.jeecg.common.cache.LocalCache;
@ -11,7 +10,6 @@ import org.jeecg.modules.service.IDataService;
import org.jeecg.modules.service.IGammaService;
import org.jeecg.modules.service.IGardsNuclCoincidenceSumSpectrumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -45,9 +43,6 @@ public class JeecgSpectrumAnalysisApplication extends SpringBootServletInitializ
@Autowired
private IDataService dataService;
@Value("${isOpen}")
private Boolean isOpen;
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
@ -55,19 +50,7 @@ public class JeecgSpectrumAnalysisApplication extends SpringBootServletInitializ
}
public static void main(String[] args) throws UnknownHostException {
int exitCode = 1;
ConfigurableApplicationContext application = null;
try {
application = SpringApplication.run(JeecgSpectrumAnalysisApplication.class, args);
} catch (Exception e) {
if (null != application) {
application.close();
exitCode = SpringApplication.exit(application, () -> 0);
}
System.exit(exitCode);
}
// ConfigurableApplicationContext application = SpringApplication.run(JeecgSpectrumAnalysisApplication.class, args);
ConfigurableApplicationContext application = SpringApplication.run(JeecgSpectrumAnalysisApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
@ -99,7 +82,6 @@ public class JeecgSpectrumAnalysisApplication extends SpringBootServletInitializ
gammaService.readMDCParameter();
nuclLibService.getNuclideMap();
nuclCoincidenceSumSpectrumService.getNuclCoincidenceMap();
if (ObjectUtil.isNotNull(isOpen) && isOpen)
dataService.viewStations();
dataService.viewStations();
}
}

View File

@ -5,7 +5,6 @@ import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.service.ISysUserFocusStationService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@ -36,19 +35,7 @@ public class JeecgStationOperationApplication extends SpringBootServletInitializ
}
public static void main(String[] args) throws UnknownHostException {
int exitCode = 1;
ConfigurableApplicationContext application = null;
try {
application = SpringApplication.run(JeecgStationOperationApplication.class, args);
} catch (Exception e) {
if (null != application) {
application.close();
exitCode = SpringApplication.exit(application, () -> 0);
}
System.exit(exitCode);
}
//ConfigurableApplicationContext application = SpringApplication.run(JeecgStationOperationApplication.class, args);
ConfigurableApplicationContext application = SpringApplication.run(JeecgStationOperationApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");

View File

@ -52,18 +52,7 @@ public class JeecgSystemCloudApplication extends SpringBootServletInitializer im
}
public static void main(String[] args) throws UnknownHostException {
int exitCode = 1;
ConfigurableApplicationContext application = null;
try {
application = SpringApplication.run(JeecgSystemCloudApplication.class, args);
} catch (Exception e) {
if (null != application) {
application.close();
exitCode = SpringApplication.exit(application, () -> 0);
}
System.exit(exitCode);
}
// ConfigurableApplicationContext application = SpringApplication.run(JeecgSystemCloudApplication.class, args);
ConfigurableApplicationContext application = SpringApplication.run(JeecgSystemCloudApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");

View File

@ -26,19 +26,7 @@ public class JeecgWebStatisticsApplication extends SpringBootServletInitializer
}
public static void main(String[] args) throws UnknownHostException {
int exitCode = 1;
ConfigurableApplicationContext application = null;
try {
application = SpringApplication.run(JeecgWebStatisticsApplication.class, args);
} catch (Exception e) {
if (null != application) {
application.close();
exitCode = SpringApplication.exit(application, () -> 0);
}
System.exit(exitCode);
}
// ConfigurableApplicationContext application = SpringApplication.run(JeecgWebStatisticsApplication.class, args);
ConfigurableApplicationContext application = SpringApplication.run(JeecgWebStatisticsApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");