同步mdc分支代码
This commit is contained in:
parent
1c34f3dde1
commit
bde5eed237
|
@ -9,4 +9,8 @@ public interface DictConstant {
|
|||
String ANALYSE_SOURCE = "alarm_analyse_rule_source";
|
||||
|
||||
String DATASOURCE_TYPE = "database_type";
|
||||
|
||||
String NOBLE_GAS_BETAGAMMA = "Noble Gas Beta-Gamma";
|
||||
|
||||
String NOBLE_GAS_HPGE = "Noble Gas HPGe";
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ public interface MonitorConstant {
|
|||
// 监控项名称
|
||||
String ITEM_CPUUSED = "cpuUtilization";
|
||||
String ITEM_SWAPUSED = "swapUtilization";
|
||||
String ITEM_MEMORYFREESIZE = "memoryFreeSize"; // byte
|
||||
String ITEM_MEMORYUSED = "memoryUtilization";
|
||||
String ITEM_RUNTIME = "uptime";
|
||||
String ITEM_RAMSIZE = "totalMemory";
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.jeecg.common.email;
|
|||
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +33,7 @@ public class EmailLogEvent {
|
|||
/**
|
||||
* 接收时间
|
||||
*/
|
||||
private Date recieveTime;
|
||||
private String recieveTime;
|
||||
/**
|
||||
* 能谱文件名称
|
||||
*/
|
||||
|
@ -49,6 +48,10 @@ public class EmailLogEvent {
|
|||
*/
|
||||
private Date logTime;
|
||||
|
||||
private Long threadId;
|
||||
|
||||
private Integer batchesCounter;
|
||||
|
||||
public EmailLogEvent(){
|
||||
|
||||
}
|
||||
|
@ -61,7 +64,9 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String logProcess) {
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String logProcess) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.logProcess = logProcess;
|
||||
this.logTime = new Date();
|
||||
|
@ -74,7 +79,18 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String phdMailLoadPath) {
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String state, String logProcess) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String state, String logProcess,String phdMailLoadPath) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
|
@ -82,7 +98,9 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String subject,Date recieveTime,String emlPath) {
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String state, String logProcess,String subject,String recieveTime,String emlPath) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
|
@ -92,7 +110,9 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String subject,Date recieveTime) {
|
||||
public EmailLogEvent(Integer batchesCounter,Long threadId,String gsType,String state, String logProcess,String subject,String recieveTime) {
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.threadId = threadId;
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
|
|
|
@ -201,6 +201,11 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getIdHeaderLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Get FileNameHeader ");
|
||||
logContent.append(event.getState());
|
||||
|
@ -217,6 +222,11 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getIdBodyLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Get File ");
|
||||
logContent.append(event.getPhdMailLoadPath());
|
||||
|
@ -234,11 +244,16 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getIdEmlLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Get File subject:");
|
||||
logContent.append(event.getSubject());
|
||||
logContent.append(" recieve datetime:");
|
||||
logContent.append(DateUtils.formatDate(event.getRecieveTime(),"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
logContent.append(event.getRecieveTime());
|
||||
logContent.append(event.getState());
|
||||
logContent.append(" EmlFile ");
|
||||
logContent.append(event.getEmlPath());
|
||||
|
@ -255,11 +270,16 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getDeleteLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Delete File subject:");
|
||||
logContent.append(event.getSubject());
|
||||
logContent.append(" recieve datetime:");
|
||||
logContent.append(DateUtils.formatDate(event.getRecieveTime(),"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
logContent.append(event.getRecieveTime());
|
||||
logContent.append(event.getState());
|
||||
logContent.append(LOG_SUFFIX);
|
||||
logContent.append(System.lineSeparator());
|
||||
|
@ -274,11 +294,16 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getExpungeLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Expunge File subject:");
|
||||
logContent.append(event.getSubject());
|
||||
logContent.append(" recieve datetime:");
|
||||
logContent.append(DateUtils.formatDate(event.getRecieveTime(),"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
logContent.append(event.getRecieveTime());
|
||||
logContent.append(event.getState());
|
||||
logContent.append(LOG_SUFFIX);
|
||||
logContent.append(System.lineSeparator());
|
||||
|
@ -293,6 +318,11 @@ public class EmailLogManager {
|
|||
*/
|
||||
private String getDoneLog(EmailLogEvent event){
|
||||
StringBuilder logContent = new StringBuilder();
|
||||
logContent.append("Batches: ");
|
||||
logContent.append(event.getBatchesCounter());
|
||||
logContent.append(" ThreadId: ");
|
||||
logContent.append(event.getThreadId());
|
||||
logContent.append(StringConstant.SPACE);
|
||||
logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
logContent.append(" Done");
|
||||
logContent.append(LOG_SUFFIX);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.jeecg.common.email;
|
||||
|
||||
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.google.common.collect.Lists;
|
||||
import com.sun.mail.imap.IMAPStore;
|
||||
|
@ -12,6 +14,7 @@ import org.jeecg.common.constant.RedisConstant;
|
|||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.email.emuns.MailContentType;
|
||||
import org.jeecg.common.exception.DownloadEmailException;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.Md5Util;
|
||||
|
@ -94,7 +97,7 @@ public class EmailServiceManager {
|
|||
Socket socket = new Socket();
|
||||
boolean flag = false;
|
||||
try {
|
||||
socket.connect(new InetSocketAddress(email.getEmailServerAddress(),email.getPort()),5000);
|
||||
socket.connect(new InetSocketAddress(email.getEmailServerAddress(),email.getPort()),3000);
|
||||
log.info("{}邮件服务连接测试成功",email.getName());
|
||||
flag = true;
|
||||
} catch (IOException e) {
|
||||
|
@ -325,8 +328,9 @@ public class EmailServiceManager {
|
|||
props.put("mail.smtp.host", email.getEmailServerAddress());
|
||||
props.put("mail.smtp.port", email.getPort());
|
||||
props.put("mail.smtp.auth", "true");
|
||||
/*props.put("mail.smtp.socketFactory.port", email.getPort());
|
||||
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");*/
|
||||
props.put("mail.smtp.starttls.enable", "true");
|
||||
props.put("mail.smtp.socketFactory.port", email.getPort());
|
||||
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||
|
||||
Session session = Session.getInstance(props);
|
||||
|
||||
|
@ -433,7 +437,7 @@ public class EmailServiceManager {
|
|||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public String getMailSubject(@NotNull Message message) throws MessagingException {
|
||||
public String getMailSubject(@NotNull Message message,Integer batchesCounter) throws MessagingException {
|
||||
String subject = "";
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
try {
|
||||
|
@ -444,7 +448,7 @@ public class EmailServiceManager {
|
|||
status = EmailLogManager.STATUS_ERROR;
|
||||
throw e;
|
||||
}finally {
|
||||
EmailLogEvent event = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDHEADER);
|
||||
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDHEADER);
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
|
||||
}
|
||||
return subject;
|
||||
|
@ -512,12 +516,14 @@ public class EmailServiceManager {
|
|||
/**
|
||||
* 把邮件下载到eml目录
|
||||
* 格式为:发件人_主题_年月日_时分秒毫秒_计数(0-10000)
|
||||
* 新格式为:发件人_主题_年月日_时分秒毫秒_receive_年月日_时分秒毫秒_计数(0-10000)
|
||||
* 当计数大于10000后从0开始,服务重启后也从0开始
|
||||
*/
|
||||
public File downloadEmailToEmlDir(@NotNull Message message,Integer emailCounter) throws MessagingException, IOException {
|
||||
public File downloadEmailToEmlDir(@NotNull 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();
|
||||
|
@ -530,7 +536,7 @@ public class EmailServiceManager {
|
|||
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);
|
||||
|
@ -538,7 +544,13 @@ public class EmailServiceManager {
|
|||
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(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);
|
||||
|
@ -546,17 +558,36 @@ public class EmailServiceManager {
|
|||
final String emlPath = spectrumPathProperties.getEmlPath();
|
||||
emlFile = new File(rootPath+emlPath+File.separator+fileName);
|
||||
message.writeTo(new FileOutputStream(emlFile));
|
||||
|
||||
// int bufferSize = 1024 * 1024; // 1M
|
||||
// InputStream inputStream = message.getInputStream();
|
||||
// BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, bufferSize);
|
||||
// // 或者使用 BufferedOutputStream
|
||||
// OutputStream outputStream = new FileOutputStream(emlFile);
|
||||
// BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream, bufferSize);
|
||||
// // 从邮件的输入流读取内容,并写入到本地文件
|
||||
// byte[] buffer = new byte[bufferSize];
|
||||
// int bytesRead;
|
||||
// while ((bytesRead = bufferedInputStream.read(buffer)) != -1) {
|
||||
// bufferedOutputStream.write(buffer, 0, bytesRead);
|
||||
// }
|
||||
//
|
||||
// // 关闭流
|
||||
// bufferedInputStream.close();
|
||||
// bufferedOutputStream.close();
|
||||
} catch (MessagingException | IOException e) {
|
||||
//下载邮件失败
|
||||
// 下载邮件失败 抛出自定义邮件下载异常
|
||||
status = EmailLogManager.STATUS_ERROR;
|
||||
log.error("The email download failed, the subject of the email is {}, the reason is {}.",subject,e.getMessage());
|
||||
throw e;
|
||||
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(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,message.getReceivedDate(),
|
||||
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);
|
||||
}
|
||||
|
||||
return emlFile;
|
||||
}
|
||||
|
||||
|
@ -565,7 +596,7 @@ public class EmailServiceManager {
|
|||
* @param message
|
||||
* @throws MessagingException
|
||||
*/
|
||||
public void removeMail(@NotNull Message message){
|
||||
public void removeMail(@NotNull Message message,Integer batchesCounter){
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
String subject = "";
|
||||
Date receivedDate = null;
|
||||
|
@ -573,15 +604,16 @@ 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"));
|
||||
} 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();
|
||||
}finally {
|
||||
EmailLogEvent removeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.DELETEID,subject,receivedDate);
|
||||
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);
|
||||
//这里删除和彻底删除一起写入日志,java和C++处理有差异,java是在连接关闭时彻底删除的
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.EXPUNGE,subject,receivedDate);
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.EXPUNGE,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),expungeEvent);
|
||||
}
|
||||
}
|
||||
|
@ -619,6 +651,7 @@ public class EmailServiceManager {
|
|||
String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;
|
||||
exist = redisUtil.hasKey(key);
|
||||
if(exist){
|
||||
log.info("Check: Remove Email:{},receiveTime:{}",message.getSubject(), DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss"));
|
||||
message.setFlag(Flags.Flag.DELETED,true);
|
||||
}
|
||||
return exist;
|
||||
|
|
|
@ -39,6 +39,11 @@ public class SpectrumPathProperties implements Serializable {
|
|||
*/
|
||||
private String emlPath;
|
||||
|
||||
/**
|
||||
* eml格式错误邮件存储路径
|
||||
*/
|
||||
private String emlErrorPath;
|
||||
|
||||
/**
|
||||
* 日志文件存储路径
|
||||
*/
|
||||
|
|
|
@ -41,6 +41,16 @@ public class TaskProperties implements Serializable {
|
|||
*/
|
||||
private Integer mailThreadExecCycle;
|
||||
|
||||
/**
|
||||
* 监测需删除的邮件线程执行周期(毫秒)
|
||||
*/
|
||||
private Integer deletedMailThreadExecCycle;
|
||||
|
||||
/**
|
||||
* 强制删除邮件线程时间(毫秒)
|
||||
*/
|
||||
private Integer forceDeletedTime;
|
||||
|
||||
/**
|
||||
* undeal目录文件获取周期
|
||||
*/
|
||||
|
|
|
@ -256,6 +256,9 @@ public class FTPUtil {
|
|||
log.error("{},根目录切换失败",rootPath);
|
||||
return false;
|
||||
}
|
||||
if (path.contains(rootPath)) {
|
||||
path = path.substring(path.indexOf(rootPath) + rootPath.length());
|
||||
}
|
||||
String[] directories = path.split("/");
|
||||
for(String directory : directories){
|
||||
if(StringUtils.isEmpty(directory)){
|
||||
|
@ -263,7 +266,7 @@ public class FTPUtil {
|
|||
}
|
||||
if(!ftpClient.changeWorkingDirectory(directory)){
|
||||
if(!ftpClient.makeDirectory(directory)){
|
||||
log.error("{},目录创建失败",directory);
|
||||
log.error("{},目录创建失败",ftpClient.printWorkingDirectory()+StringPool.SLASH+directory);
|
||||
return false;
|
||||
}
|
||||
if(!ftpClient.changeWorkingDirectory(directory)){
|
||||
|
@ -356,6 +359,45 @@ public class FTPUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 批量删除FTP文件 返回删除失败的文件路径
|
||||
* */
|
||||
public boolean removeFiles(String path){
|
||||
boolean success = false;
|
||||
// 连接FTP服务
|
||||
final FTPClient ftpClient = this.LoginFTP();
|
||||
//判断ftp是否连接成功
|
||||
if (ObjectUtil.isNull(ftpClient)){
|
||||
log.error("FTPUtil.removeFiles(): FTPClient is null");
|
||||
}
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = ftpClient.retrieveFileStream(path);
|
||||
//读取文件路径的流 如果文件存在则读取流数据不为空
|
||||
if (Objects.nonNull(inputStream)) {
|
||||
//删除文件
|
||||
success = ftpClient.deleteFile(path);
|
||||
}
|
||||
//日志输出文件删除状态
|
||||
log.info(path + " Delete Status:"+success);
|
||||
} catch (Exception e) {
|
||||
log.error("FTPUtil.removeFiles()删除文件[{}]失败: {}", path, e.getMessage());
|
||||
} finally {
|
||||
// 关闭FTP连接
|
||||
try {
|
||||
if (Objects.nonNull(inputStream)) {
|
||||
inputStream.close();
|
||||
}
|
||||
if (ObjectUtil.isNotNull(ftpClient)) {
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/*
|
||||
* 批量删除FTP文件 返回删除失败的文件路径
|
||||
* */
|
||||
|
@ -369,10 +411,19 @@ public class FTPUtil {
|
|||
return paths;
|
||||
}
|
||||
for (String path : paths) {
|
||||
boolean success = false;
|
||||
try {
|
||||
if (StrUtil.isBlank(path)) continue;
|
||||
boolean success = ftpClient.deleteFile(path);
|
||||
if (!success) failList.add(path);
|
||||
if (StrUtil.isBlank(path)) {
|
||||
continue;
|
||||
}
|
||||
if (Objects.nonNull(ftpClient.retrieveFileStream(path))) {
|
||||
success = ftpClient.deleteFile(path);
|
||||
log.info(path + " Delete Status:"+success);
|
||||
} else {
|
||||
log.info(path + " Delete Status:false");
|
||||
failList.add(path);
|
||||
log.error("FTPUtil.removeFiles()删除文件[{}]失败", path);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failList.add(path);
|
||||
log.error("FTPUtil.removeFiles()删除文件[{}]失败: {}", path, e.getMessage());
|
||||
|
@ -380,8 +431,9 @@ public class FTPUtil {
|
|||
}
|
||||
// 关闭FTP连接
|
||||
try {
|
||||
if (ObjectUtil.isNotNull(ftpClient))
|
||||
if (ObjectUtil.isNotNull(ftpClient)) {
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jeecg.modules.base.enums.Op.*;
|
||||
import static org.jeecg.modules.base.enums.Op.LE;
|
||||
|
@ -125,4 +128,63 @@ public class NumUtil {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Boolean> compare(Map<String, Double> current, Double threshold, String op){
|
||||
boolean cNull = MapUtil.isEmpty(current);
|
||||
boolean tNull = ObjectUtil.isNull(threshold);
|
||||
|
||||
Map<String, Boolean> result = new HashMap<>();
|
||||
if (cNull || tNull) return result;
|
||||
|
||||
double thresholdV = threshold;
|
||||
for (Map.Entry<String, Double> entry : current.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
double currentV = entry.getValue();
|
||||
if (EQ.getOp().equals(op)){
|
||||
result.put(key, currentV == thresholdV);
|
||||
} else if (GT.getOp().equals(op)) {
|
||||
result.put(key, currentV > thresholdV);
|
||||
} else if (GE.getOp().equals(op)) {
|
||||
result.put(key, currentV >= thresholdV);
|
||||
} else if (LT.getOp().equals(op)) {
|
||||
result.put(key, currentV < thresholdV);
|
||||
} else if (LE.getOp().equals(op)) {
|
||||
result.put(key, currentV <= thresholdV);
|
||||
}else {
|
||||
result.put(key, false);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String kb2Gb(String kb, int scale){
|
||||
if (StrUtil.isBlank(kb))
|
||||
return null;
|
||||
BigDecimal decimal = new BigDecimal(kb);
|
||||
double v = decimal.divide(new BigDecimal(1024), scale, RoundingMode.HALF_UP)
|
||||
.divide(new BigDecimal(1024), scale, RoundingMode.HALF_UP)
|
||||
.doubleValue();
|
||||
return String.valueOf(v);
|
||||
}
|
||||
|
||||
public static String byte2Mb(String bytes, int scale){
|
||||
if (StrUtil.isBlank(bytes))
|
||||
return null;
|
||||
BigDecimal decimal = new BigDecimal(bytes);
|
||||
double v = decimal.divide(new BigDecimal(1024), scale, RoundingMode.HALF_UP)
|
||||
.divide(new BigDecimal(1024), scale, RoundingMode.HALF_UP)
|
||||
.doubleValue();
|
||||
return String.valueOf(v);
|
||||
}
|
||||
|
||||
public static String byte2Gb(String bytes, int scale){
|
||||
if (StrUtil.isBlank(bytes))
|
||||
return null;
|
||||
BigDecimal decimal = new BigDecimal(bytes);
|
||||
double v = decimal.divide(new BigDecimal(1024), scale, RoundingMode.HALF_UP)
|
||||
.divide(new BigDecimal(1024), scale, RoundingMode.HALF_UP)
|
||||
.divide(new BigDecimal(1024), scale, RoundingMode.HALF_UP)
|
||||
.doubleValue();
|
||||
return String.valueOf(v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,20 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.util.dynamic.db.FreemarkerParseFactory;
|
||||
import org.jeecg.modules.base.entity.postgre.SysMessageTemplate;
|
||||
import org.jeecg.modules.base.service.ISysMessageTemplateService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* 模板工具类
|
||||
|
@ -37,6 +44,30 @@ public class TemplateUtil {
|
|||
return messageDTO;
|
||||
}
|
||||
|
||||
public static MessageDTO parse1(String code, Map<String, Object> data){
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
SysMessageTemplate template = templateService.getOne(code);
|
||||
// 如果没有消息模板
|
||||
if(ObjectUtil.isNull(template))
|
||||
return messageDTO;
|
||||
String templateName = template.getTemplateName();
|
||||
String templateContent = template.getTemplateContent();
|
||||
messageDTO.setTitle(templateName);
|
||||
if (MapUtil.isEmpty(data))
|
||||
return messageDTO;
|
||||
Set<String> keys = data.keySet();
|
||||
String pattern = "\\<([^<>]*{}[^<>]*)\\>";
|
||||
List<String> contents = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
contents.add(ReUtil.getGroup1(StrUtil.format(pattern, key), templateContent));
|
||||
}
|
||||
templateContent = CollUtil.join(contents, "#");
|
||||
String content = FreemarkerParseFactory
|
||||
.parseTemplateContent(templateContent, data, true);
|
||||
messageDTO.setContent(content);
|
||||
return messageDTO;
|
||||
}
|
||||
|
||||
public static MessageDTO parse(String title, String code, Map<String, Object> data) {
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
SysMessageTemplate template = templateService.getOne(code);
|
||||
|
@ -53,4 +84,28 @@ public class TemplateUtil {
|
|||
messageDTO.setContent(content);
|
||||
return messageDTO;
|
||||
}
|
||||
|
||||
public static MessageDTO parse1(String title, String code, Map<String, Object> data) {
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
SysMessageTemplate template = templateService.getOne(code);
|
||||
// 如果没有消息模板
|
||||
if(ObjectUtil.isNull(template))
|
||||
return messageDTO;
|
||||
String templateName = template.getTemplateName();
|
||||
String templateContent = template.getTemplateContent();
|
||||
messageDTO.setTitle(StrUtil.isBlank(title) ? templateName : title);
|
||||
if (MapUtil.isEmpty(data))
|
||||
return messageDTO;
|
||||
Set<String> keys = data.keySet();
|
||||
String pattern = "\\<([^<>]*{}[^<>]*)\\>";
|
||||
List<String> contents = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
contents.add(ReUtil.getGroup1(StrUtil.format(pattern, key), templateContent));
|
||||
}
|
||||
templateContent = CollUtil.join(contents, "#");
|
||||
String content = FreemarkerParseFactory
|
||||
.parseTemplateContent(templateContent, data, true);
|
||||
messageDTO.setContent(content);
|
||||
return messageDTO;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,4 +9,8 @@ public class NuclideAvgVo extends QueryRequest {
|
|||
private String startDate;
|
||||
|
||||
private String endDate;
|
||||
|
||||
private String stationId;
|
||||
|
||||
private String sourceType;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import lombok.Data;
|
|||
@Data
|
||||
public class AnalysesDto {
|
||||
|
||||
private Integer sampleId;
|
||||
|
||||
private String baselinePath;
|
||||
|
||||
private String lcPath;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
@ -21,21 +22,29 @@ public class DatabaseDto implements Serializable {
|
|||
|
||||
private boolean online;
|
||||
|
||||
private String slowQuery;
|
||||
|
||||
private Integer alarms;
|
||||
|
||||
private boolean alarmRed;
|
||||
|
||||
private String cpuUutilzation;
|
||||
private String dbMemory; // kb
|
||||
|
||||
private boolean cpuRed;
|
||||
private String logRemainingSize; // byte
|
||||
|
||||
private String memoryUsage;
|
||||
private String dbSize; // byte
|
||||
|
||||
private boolean memoryRed;
|
||||
|
||||
private String diskUsage;
|
||||
|
||||
private boolean diskRed;
|
||||
public void setDbMemory(String dbMemory) {
|
||||
if (StrUtil.isNotBlank(dbMemory))
|
||||
this.dbMemory = dbMemory + "GB";
|
||||
}
|
||||
|
||||
public void setLogRemainingSize(String logRemainingSize) {
|
||||
if (StrUtil.isNotBlank(logRemainingSize))
|
||||
this.logRemainingSize = logRemainingSize + "MB";
|
||||
|
||||
}
|
||||
|
||||
public void setDbSize(String dbSize) {
|
||||
if (StrUtil.isNotBlank(dbSize))
|
||||
this.dbSize = dbSize + "GB";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,17 +15,10 @@ public class NameValue implements Serializable {
|
|||
|
||||
private Boolean value;
|
||||
|
||||
private String valueT;
|
||||
|
||||
private Integer usage; // 单位 MB
|
||||
|
||||
public NameValue(String name, Boolean value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public NameValue(String name, String valueT) {
|
||||
this.name = name;
|
||||
this.valueT = valueT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ import java.time.LocalDate;
|
|||
@Data
|
||||
public class NuclideAvgDto implements Serializable {
|
||||
|
||||
private String stationId;
|
||||
|
||||
private String stationCode;
|
||||
|
||||
/** 核素名称 */
|
||||
private String nuclide;
|
||||
|
||||
|
|
|
@ -3,8 +3,12 @@ package org.jeecg.modules.base.dto;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.util.NumUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
|
@ -17,4 +21,8 @@ public class NuclideInfo implements Serializable {
|
|||
private String datasource;
|
||||
|
||||
private String value;
|
||||
|
||||
public void keepSix(){
|
||||
this.value = NumUtil.keepStr(this.value, 6);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ public class ServerDto implements Serializable {
|
|||
|
||||
private boolean memoryRed;
|
||||
|
||||
private String diskUsage;
|
||||
private String memoryFree;
|
||||
|
||||
private boolean diskRed;
|
||||
private boolean memoryFreeRed;
|
||||
|
||||
public ServerDto() {
|
||||
this.cpuUutilzation = "--";
|
||||
this.memoryUsage = "--";
|
||||
this.diskUsage = "--";
|
||||
this.memoryFree = "--";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,4 +98,7 @@ public class GardsStations implements Serializable {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date moddate;
|
||||
|
||||
@TableField(value = "CATEGORY")
|
||||
private Integer category;
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,14 @@ public class AlarmAnalysisNuclideAvg extends JeecgEntity {
|
|||
this.val = val;
|
||||
}
|
||||
|
||||
public AlarmAnalysisNuclideAvg(String stationId ,String nuclide, String val) {
|
||||
this.stationId = stationId;
|
||||
this.nuclide = nuclide;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
private String stationId;
|
||||
|
||||
/** 核素名称 */
|
||||
private String nuclide;
|
||||
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package org.jeecg.modules.base.enums;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author nieziyan
|
||||
* 数据源类型
|
||||
*/
|
||||
@Getter
|
||||
public enum DSType {
|
||||
/* ARMD自动处理库 */
|
||||
ARMDARR("1"),
|
||||
|
@ -15,13 +19,17 @@ public enum DSType {
|
|||
/* IDC人工交互库 */
|
||||
IDCRRR("4");
|
||||
|
||||
DSType(java.lang.String type) {
|
||||
DSType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private String type;
|
||||
private final String type;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
public static String typeOf(String type){
|
||||
for (DSType dsType : DSType.values()) {
|
||||
if (StrUtil.equals(type, dsType.getType()))
|
||||
return dsType.name();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import lombok.Getter;
|
|||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum Item {
|
||||
EMAIL_CONN("1", "邮箱服务连接情况"),
|
||||
DATABASE_CONN("2", "数据源连接情况");
|
||||
EMAIL_CONN("1", "Connection Status"),
|
||||
TABLESPACE_USAGE("2", "TableSpace Usage");
|
||||
|
||||
private String value;
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.jeecg.modules.base.enums;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
public enum StationType {
|
||||
BETA, GAMMA, NULL
|
||||
}
|
|
@ -16,6 +16,10 @@ public class PHDFile implements Serializable {
|
|||
|
||||
private String tmpFilePath;
|
||||
|
||||
private String analyMessage;
|
||||
|
||||
private boolean analyFlag;
|
||||
|
||||
private boolean isValid; // 是否有效谱
|
||||
|
||||
private boolean bAnalyed; // 记录是否被分析
|
||||
|
@ -175,10 +179,14 @@ public class PHDFile implements Serializable {
|
|||
*/
|
||||
private Integer efficiencyCurRow;
|
||||
|
||||
private Map<String, NuclideLines> phdNuclideMap;
|
||||
|
||||
public PHDFile() {
|
||||
userId = "";
|
||||
xmlFilePath = "";
|
||||
tmpFilePath = "";
|
||||
analyMessage = "";
|
||||
analyFlag = true;
|
||||
bAnalyed = false;
|
||||
isValid = true;
|
||||
analy_start_time = "";
|
||||
|
@ -243,6 +251,7 @@ public class PHDFile implements Serializable {
|
|||
efficiencyEnergy = new LinkedList<>();
|
||||
efficiencyParam = new LinkedList<>();
|
||||
efficiencyCurRow = 0;
|
||||
phdNuclideMap = new HashMap<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,15 +41,15 @@
|
|||
<groupId>com.netease.qiye</groupId>
|
||||
<artifactId>open-common</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/open-common-1.0-SNAPSHOT.jar</systemPath>
|
||||
<!--<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/open-common-1.0-SNAPSHOT.jar</systemPath>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netease.qiye</groupId>
|
||||
<artifactId>open-sdk</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/open-sdk-20211201132528.jar</systemPath>
|
||||
<!--<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/open-sdk-20211201132528.jar</systemPath>-->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.aspect;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
@ -91,6 +92,7 @@ public class StatusAspect {
|
|||
|
||||
/*
|
||||
* 新增|修改数据源信息后 异步更新其状态信息
|
||||
* 更新数据源的状态(1:正常 2:离线 3:告警)和它对应的系统监控的HostId
|
||||
* */
|
||||
@Async
|
||||
@AfterReturning("execution(* org.jeecg.modules.service.impl.SysDatabaseServiceImpl.update(..)) || " +
|
||||
|
@ -98,25 +100,52 @@ public class StatusAspect {
|
|||
public void updateDatabaseStatus(JoinPoint point){
|
||||
Object[] args = point.getArgs();
|
||||
if (ArrayUtil.length(args) == 0) return;
|
||||
String key = RedisConstant.DATABASE_STATUS;
|
||||
Boolean online = null;
|
||||
SysDatabase database = (SysDatabase) args[0];
|
||||
try {
|
||||
databaseService.status2Redis(database);
|
||||
String token = ManageUtil.getToken();
|
||||
Page<Host> hostPage = monitorAlarm.dbList(null, 1, 99, token).getResult();
|
||||
if (ObjectUtil.isNull(hostPage) || CollUtil.isEmpty(hostPage.getRecords()))
|
||||
return;
|
||||
List<Host> hosts = hostPage.getRecords();
|
||||
String id = database.getId();
|
||||
String name = database.getName();
|
||||
try {
|
||||
String token = ManageUtil.getToken();
|
||||
Page<Host> hostPage = monitorAlarm.dbList(MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult();
|
||||
if (ObjectUtil.isNull(hostPage) || CollUtil.isEmpty(hostPage.getRecords())) {
|
||||
redisUtil.hset(key, id, new NameValue(name, online));
|
||||
return;
|
||||
}
|
||||
List<Host> hosts = hostPage.getRecords();
|
||||
Host host = null;
|
||||
for (Host oneHost : hosts) {
|
||||
if (StrUtil.equals(name, oneHost.getCode()))
|
||||
host = oneHost;
|
||||
}
|
||||
if (ObjectUtil.isNull(host))
|
||||
if (ObjectUtil.isNull(host)) {
|
||||
redisUtil.hset(key, id, new NameValue(name, online));
|
||||
return;
|
||||
}
|
||||
// 更新该数据源状态信息
|
||||
String status = host.getStatus();
|
||||
online = CollUtil.contains(ListUtil.toList(ServerStatus.ON.getValue(),
|
||||
ServerStatus.WARN.getValue()), status);
|
||||
redisUtil.hset(key, id, new NameValue(name, online));
|
||||
// 更新数据源的HostId
|
||||
database.setHostId(host.getHostId());
|
||||
databaseService.updateById(database);
|
||||
// 同步数据库监控项
|
||||
Map<String, Item> itemMap = host.getItems();
|
||||
if (MapUtil.isEmpty(itemMap) || CollUtil.isEmpty(itemMap.values()))
|
||||
return;
|
||||
Collection<Item> items = itemMap.values();
|
||||
List<AlarmItem> alarmItems = new ArrayList<>();
|
||||
// 只保留六个有效的监控项
|
||||
List<String> itemNames = ListUtil.toList("dbMemory", "logRemainingSize", "latency",
|
||||
"login", "dbSize", "dblSize", "connections");
|
||||
for (Item item : items) {
|
||||
if (!itemNames.contains(item.getName())) continue;
|
||||
AlarmItem alarmItem = BeanUtil.copyProperties(item, AlarmItem.class);
|
||||
alarmItem.setId(item.getItemId());
|
||||
alarmItems.add(alarmItem);
|
||||
}
|
||||
alarmItemService.saveOrUpdateBatch(alarmItems);
|
||||
}catch (FeignException.Unauthorized e){
|
||||
ManageUtil.refreshToken();
|
||||
log.warn("向运管系统查询Hosts信息异常: Token失效,已刷新Token");
|
||||
|
@ -127,7 +156,7 @@ public class StatusAspect {
|
|||
|
||||
/*
|
||||
* 新增|修改服务器信息后 异步更新其状态信息
|
||||
* 更新服务器的状态(-1:未知 1:正常 2:离线 3:告警)和它对应的系统监控的HostId
|
||||
* 更新服务器的状态(1:正常 2:离线 3:告警)和它对应的系统监控的HostId
|
||||
* */
|
||||
@Async
|
||||
@AfterReturning("execution(* org.jeecg.modules.service.impl.SysServerServiceImpl.update(..)) || " +
|
||||
|
@ -136,32 +165,32 @@ public class StatusAspect {
|
|||
Object[] args = point.getArgs();
|
||||
if (ArrayUtil.length(args) == 0) return;
|
||||
String key = RedisConstant.SERVER_STATUS;
|
||||
String status = ServerStatus.OFF.getValue();
|
||||
Boolean online = null;
|
||||
SysServer server = (SysServer) args[0];
|
||||
String id = server.getId();
|
||||
String name = server.getName();
|
||||
String ipAddress = server.getIpAddress();
|
||||
try {
|
||||
String token = ManageUtil.getToken();
|
||||
Page<Host> hostPage = monitorAlarm.listApp(ipAddress, MonitorConstant.SERVER_APP,
|
||||
MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult();
|
||||
Page<Host> hostPage = monitorAlarm.listApp(name, MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult();
|
||||
if (ObjectUtil.isNull(hostPage) || CollUtil.isEmpty(hostPage.getRecords())){
|
||||
redisUtil.hset(key, id, new NameValue(name, status));
|
||||
redisUtil.hset(key, id, new NameValue(name, online));
|
||||
return;
|
||||
}
|
||||
List<Host> hosts = hostPage.getRecords();
|
||||
Host host = null;
|
||||
for (Host oneHost : hosts) {
|
||||
if (StrUtil.equals(ipAddress, oneHost.getCode()))
|
||||
if (StrUtil.equals(name, oneHost.getCode()))
|
||||
host = oneHost;
|
||||
}
|
||||
if (ObjectUtil.isNull(host)){
|
||||
redisUtil.hset(key, id, new NameValue(name, status));
|
||||
redisUtil.hset(key, id, new NameValue(name, online));
|
||||
return;
|
||||
}
|
||||
// 更新该服务器状态信息
|
||||
status = host.getStatus();
|
||||
redisUtil.hset(key, id, new NameValue(name, status));
|
||||
String status = host.getStatus();
|
||||
online = CollUtil.contains(ListUtil.toList(ServerStatus.ON.getValue(),
|
||||
ServerStatus.WARN.getValue()), status);
|
||||
redisUtil.hset(key, id, new NameValue(name, online));
|
||||
// 更新该服务器的HostId
|
||||
server.setHostId(host.getHostId());
|
||||
serverService.updateById(server);
|
||||
|
@ -194,6 +223,7 @@ public class StatusAspect {
|
|||
if (ObjectUtil.isNotNull(result)){
|
||||
String hostId = ((Result<String>) result).getResult();
|
||||
// 删除服务器相关联的监控项
|
||||
if (StrUtil.isNotBlank(hostId))
|
||||
alarmItemService.deleteByHostId(hostId);
|
||||
}
|
||||
// 删除服务器相关联的报警规则
|
||||
|
@ -206,8 +236,14 @@ public class StatusAspect {
|
|||
* 删除Database时 同步删除关联的报警规则
|
||||
* */
|
||||
@Async
|
||||
@AfterReturning("execution(* org.jeecg.modules.service.impl.SysDatabaseServiceImpl.deleteById(..))")
|
||||
public void databaseDelete(JoinPoint point){
|
||||
@AfterReturning(value = "execution(* org.jeecg.modules.service.impl.SysDatabaseServiceImpl.deleteById(..))", returning = "result")
|
||||
public void databaseDelete(JoinPoint point, Object result){
|
||||
if (ObjectUtil.isNotNull(result)){
|
||||
String hostId = ((Result<String>) result).getResult();
|
||||
// 删除服务器相关联的监控项
|
||||
if (StrUtil.isNotBlank(hostId))
|
||||
alarmItemService.deleteByHostId(hostId);
|
||||
}
|
||||
// 删除数据库相关联的报警规则
|
||||
Object[] args = point.getArgs();
|
||||
if (ArrayUtil.length(args) > 0)
|
||||
|
|
|
@ -22,6 +22,12 @@ public class AlarmAnalysisLogController extends JeecgController<AlarmAnalysisLog
|
|||
return service.findPage(analysisLogVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value="报警日志分页查询", notes="报警日志分页查询")
|
||||
@PostMapping(value = "findPageApp")
|
||||
public Result<?> findPageApp(@RequestBody AnalysisLogVo analysisLogVo) {
|
||||
return service.findPage(analysisLogVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value="添加报警日志", notes="添加报警日志")
|
||||
@PostMapping(value = "add")
|
||||
public Result<?> add(@RequestBody AlarmAnalysisLog alarmAnalysisLog) {
|
||||
|
|
|
@ -19,7 +19,7 @@ public class AlarmAnalysisNuclideAvgController extends JeecgController<AlarmAnal
|
|||
|
||||
@GetMapping("findPage")
|
||||
@ApiOperation(value = "核素浓度均值列表信息",notes = "核素浓度均值列表信息")
|
||||
public Result findPage(NuclideAvgVo nuclideAvgVo){
|
||||
public Result<?> findPage(NuclideAvgVo nuclideAvgVo){
|
||||
Page<NuclideAvgDto> result = service.findPage(nuclideAvgVo);
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
|
|
@ -18,12 +18,6 @@ import io.swagger.annotations.Api;
|
|||
@RequestMapping("nuclideParam")
|
||||
public class AlarmAnalysisNuclideParamController extends JeecgController<AlarmAnalysisNuclideParam, IAlarmAnalysisNuclideParamService> {
|
||||
|
||||
@GetMapping("refresh")
|
||||
@ApiOperation(value = "定时刷新核素计算参数信息",notes = "定时刷新核素计算参数信息")
|
||||
public boolean refreshParam(){
|
||||
return service.refresh();
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
@ApiOperation(value = "回显核素计算参数信息",notes = "回显核素计算参数信息")
|
||||
public Result findInfo(){
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.jeecg.common.api.vo.Result;
|
|||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||
import org.jeecg.modules.service.IAlarmItemService;
|
||||
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.RequestParam;
|
||||
|
@ -24,7 +23,7 @@ public class AlarmItemController extends JeecgController<AlarmItem, IAlarmItemSe
|
|||
@GetMapping("alarmItems")
|
||||
@ApiOperation(value = "服务器所有监控项",notes = "服务器所有监控项")
|
||||
public Result<?> alarmItems(@RequestParam String sourceId){
|
||||
List<AlarmItem> alarmItems = service.alarmItems(sourceId);
|
||||
List<AlarmItem> alarmItems = service.alarmItemsServer(sourceId);
|
||||
Map<String, String> itemIds = alarmItems.stream()
|
||||
.collect(Collectors.toMap(AlarmItem::getName, AlarmItem::getId));
|
||||
return Result.OK(itemIds);
|
||||
|
|
|
@ -34,6 +34,13 @@ public class AlarmLogController {
|
|||
public Result findPage(@RequestBody AlarmVo alarmVo){
|
||||
return alarmLogService.findPage(alarmVo);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询报警日志信息")
|
||||
@PostMapping("findPageApp")
|
||||
public Result findPageApp(@RequestBody AlarmVo alarmVo){
|
||||
return alarmLogService.findPage(alarmVo);
|
||||
}
|
||||
|
||||
@ApiOperation("各类型报警量统计-饼图")
|
||||
@PostMapping("typeAlarms")
|
||||
public Result typeAlarms(@RequestBody AlarmVo alarmVo){
|
||||
|
|
|
@ -19,8 +19,8 @@ public class CalculateConcController {
|
|||
|
||||
@GetMapping("caclAndSave")
|
||||
@ApiOperation(value = "计算并保存核素浓度",notes = "计算并保存核素浓度")
|
||||
public boolean caclAndSave(){
|
||||
return calculateConcService.calcAndSave();
|
||||
public void caclAndSave(){
|
||||
calculateConcService.calcAndSave();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,12 @@ public class SysDatabaseController {
|
|||
return sysDatabaseService.findPage(query);
|
||||
}
|
||||
|
||||
@PostMapping("findPageApp")
|
||||
@ApiOperation(value = "分页查询数据库配置信息", notes = "分页查询数据库配置信息")
|
||||
public Result<?> findPageApp(@RequestBody QueryRequest query){
|
||||
return sysDatabaseService.findPage(query);
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
@ApiOperation(value = "查询数据库配置信息详情", notes = "查询数据库配置信息详情")
|
||||
public Result<?> findInfo(String id){
|
||||
|
|
|
@ -27,6 +27,12 @@ public class SysEmailController {
|
|||
return sysEmailService.findPage(query);
|
||||
}
|
||||
|
||||
@PostMapping("findPageApp")
|
||||
@ApiOperation(value = "分页查询邮箱配置信息", notes = "分页查询邮箱配置信息")
|
||||
public Result findPageApp(@RequestBody QueryRequest query){
|
||||
return sysEmailService.findPage(query);
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
@ApiOperation(value = "查询邮箱配置信息详情", notes = "查询邮箱配置信息详情")
|
||||
public Result findInfo(String id){
|
||||
|
|
|
@ -28,6 +28,12 @@ public class SysServerController {
|
|||
return sysServerService.findPage(query);
|
||||
}
|
||||
|
||||
@PostMapping("findPageApp")
|
||||
@ApiOperation(value = "分页查询服务器数据", notes = "分页查询服务器数据")
|
||||
public Result findPageApp(@RequestBody QueryRequest query){
|
||||
return sysServerService.findPage(query);
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
@ApiOperation(value = "服务器数据详情信息", notes = "服务器数据详情信息")
|
||||
public Result findInfo(@RequestParam String id){
|
||||
|
|
|
@ -24,21 +24,12 @@ public interface MonitorAlarm {
|
|||
|
||||
// --------------------后端专用-------------------
|
||||
@GetMapping("/omms/device/monitor/list") // 获取所有 服务器/数据库服务 信息
|
||||
Result<Page<Host>> listApp(@RequestParam("type") String type,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
Result<Page<Host>> listApp(@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestHeader("X-Access-Token") String token);
|
||||
|
||||
@GetMapping("/omms/device/monitor/list") // 获取所有 服务器/数据库服务 信息
|
||||
Result<Page<Host>> listApp(@RequestParam("code") String code,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestHeader("X-Access-Token") String token);
|
||||
|
||||
@GetMapping("/omms/device/monitor/list") // 获取所有在线 服务器/数据库服务 信息
|
||||
Result<Page<Host>> listOnApp(@RequestParam("status") String status,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestHeader("X-Access-Token") String token);
|
||||
|
@ -116,8 +107,7 @@ public interface MonitorAlarm {
|
|||
@RequestHeader("X-Access-Token") String token);
|
||||
|
||||
@GetMapping("/omms/monitor/db/list")
|
||||
Result<Page<Host>> dbList(@RequestParam("code") String code,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
Result<Page<Host>> dbList(@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestHeader("X-Access-Token") String token);
|
||||
}
|
||||
|
|
|
@ -7,5 +7,7 @@ import java.util.List;
|
|||
|
||||
public interface AlarmItemMapper extends BaseMapper<AlarmItem> {
|
||||
|
||||
List<AlarmItem> alarmItems(String sourceId);
|
||||
List<AlarmItem> alarmItemsServer(String sourceId);
|
||||
|
||||
List<AlarmItem> alarmItemsDatabase(String sourceId);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
<select id="findPage" resultType="org.jeecg.modules.base.dto.NuclideAvgDto">
|
||||
SELECT
|
||||
station_id,
|
||||
nuclide,
|
||||
val,
|
||||
cycle,
|
||||
|
@ -23,7 +24,13 @@
|
|||
<if test="params.endDate != null and params.endDate != ''">
|
||||
AND cacl_date <= #{params.endDate}
|
||||
</if>
|
||||
<if test="params.stationId != null and params.stationId != ''">
|
||||
AND station_id = #{params.stationId}
|
||||
</if>
|
||||
<if test="params.sourceType != null and params.sourceType != ''">
|
||||
AND data_source_type = #{params.sourceType}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY cacl_date DESC
|
||||
ORDER BY cacl_date DESC, station_id, data_source_type, nuclide
|
||||
</select>
|
||||
</mapper>
|
|
@ -9,4 +9,13 @@
|
|||
INNER JOIN sys_server s ON i.host_id = s.host_id
|
||||
WHERE s.ID = #{sourceId}
|
||||
</select>
|
||||
|
||||
<select id="alarmItemsDatabase" resultType="org.jeecg.modules.base.entity.postgre.AlarmItem">
|
||||
SELECT
|
||||
i.*
|
||||
FROM
|
||||
alarm_item i
|
||||
INNER JOIN sys_database d ON i.host_id = d.host_id
|
||||
WHERE d.ID = #{sourceId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -13,6 +13,8 @@
|
|||
<where>
|
||||
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND to_date(#{endDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND samp.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
|
||||
AND samp.STATION_ID = #{stationId}
|
||||
<if test="nuclideName != null and nuclideName.size() > 0">
|
||||
AND nucl.NUCLIDENAME IN
|
||||
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
<where>
|
||||
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND to_date(#{endDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND samp.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
|
||||
AND samp.STATION_ID = #{stationId}
|
||||
<if test="nuclideName != null and nuclideName.size() > 0">
|
||||
AND nucl.NUCLIDENAME IN
|
||||
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
<where>
|
||||
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND to_date(#{endDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND samp.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
|
||||
AND samp.STATION_ID = #{stationId}
|
||||
<if test="nuclideName != null and nuclideName.size() > 0">
|
||||
AND xe.NUCLIDE_NAME IN
|
||||
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
<where>
|
||||
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND to_date(#{endDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND samp.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
|
||||
AND samp.STATION_ID = #{stationId}
|
||||
<if test="nuclideName != null and nuclideName.size() > 0">
|
||||
AND xe.NUCLIDE_NAME IN
|
||||
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
|
||||
|
|
|
@ -5,8 +5,10 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.StrBuilder;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -16,14 +18,17 @@ 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.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;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisRule;
|
||||
import org.jeecg.modules.base.enums.Condition;
|
||||
import org.jeecg.modules.base.enums.DSType;
|
||||
import org.jeecg.modules.feignclient.SystemClient;
|
||||
import org.jeecg.modules.service.AnalysisResultService;
|
||||
import org.jeecg.modules.service.IAlarmAnalysisLogService;
|
||||
|
@ -36,9 +41,13 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import static org.jeecg.common.constant.enums.MessageTypeEnum.*;
|
||||
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||
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.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
|
@ -143,69 +152,62 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
|
||||
private void judge(Info info, Map<String,String> nuclidesCross){
|
||||
Set<String> nuclideNames = nuclidesCross.keySet();
|
||||
StringBuilder alarmInfo = new StringBuilder();
|
||||
List<String> firstDetected;
|
||||
List<NuclideInfo> moreThanAvg = new ArrayList<>();
|
||||
String conditionStr = info.getConditions();
|
||||
String betaOrGamma = info.getBetaOrGamma();
|
||||
String datasource = info.getDatasource();
|
||||
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.isNotNull(condition)){
|
||||
switch (condition){
|
||||
case FIRST_FOUND: // 首次发现该元素
|
||||
firstDetected = firstDetected(betaOrGamma, datasource, nuclideNames);
|
||||
if (CollUtil.isNotEmpty(firstDetected)){
|
||||
String message = "First discovery of nuclides: [" + StrUtil.join(COMMA,firstDetected) + "]";
|
||||
alarmInfo.append(message);
|
||||
}
|
||||
break;
|
||||
case ABOVE_AVERAGE: // 元素浓度高于均值
|
||||
moreThanAvg = moreThanAvg(datasource,nuclidesCross);
|
||||
if (CollUtil.isNotEmpty(moreThanAvg)){
|
||||
for (NuclideInfo nuclideInfo : moreThanAvg) {
|
||||
String nuclide = nuclideInfo.getNuclide();
|
||||
String threshold = nuclideInfo.getThreshold();
|
||||
String message = "Nuclide " + nuclide + "is above average: " + threshold;
|
||||
alarmInfo.append(COMMA).append(message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MEANWHILE: // 同时出现两种及以上核素
|
||||
if (nuclideNames.size() >= 2){
|
||||
String message = "Simultaneously detecting nuclides: [" + StrUtil.join(COMMA,nuclideNames) + "]";
|
||||
alarmInfo.append(COMMA).append(message);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(nuclideNames) && nuclideNames.size() >= 2)
|
||||
meanwhile.addAll(nuclideNames);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(alarmInfo.toString())){
|
||||
// 构建预警信息
|
||||
DataTool dataTool = DataTool.getInstance();
|
||||
if (CollUtil.isNotEmpty(firstDetected))
|
||||
dataTool.put("firstDetected", CollUtil.join(firstDetected, StrUtil.COMMA + StrUtil.SPACE));
|
||||
if (CollUtil.isNotEmpty(moreThanAvg)){
|
||||
String above = moreThanAvg.stream()
|
||||
.map(item -> item.getNuclide() + "(" + item.getValue() + ")" + " > " + item.getThreshold())
|
||||
.collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE));
|
||||
dataTool.put("moreThanAvg", above);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(meanwhile))
|
||||
dataTool.put("meanwhile", CollUtil.join(meanwhile, StrUtil.COMMA + StrUtil.SPACE));
|
||||
// 如果报警数据为空 则不需要发送报警信息和生成报警日志
|
||||
if (MapUtil.isEmpty(dataTool.get())) return;
|
||||
MessageDTO messageDTO = TemplateUtil.parse1(ANALYSIS_NUCLIDE.getCode(), dataTool.get());
|
||||
// 保存报警日志
|
||||
AlarmAnalysisLog logInfo = new AlarmAnalysisLog();
|
||||
BeanUtil.copyProperties(info, logInfo);
|
||||
SampleType sampleType = SampleType.typeOf(betaOrGamma);
|
||||
if (ObjectUtil.isNotNull(sampleType))
|
||||
logInfo.setSampleType(sampleType.getValue());
|
||||
if (alarmInfo.toString().startsWith(COMMA))
|
||||
alarmInfo = new StringBuilder(StrUtil.sub(alarmInfo.toString(), 1, alarmInfo.length()));
|
||||
logInfo.setAlarmInfo(alarmInfo.toString());
|
||||
logInfo.setAlarmInfo(messageDTO.getContent());
|
||||
if (CollUtil.isNotEmpty(moreThanAvg))
|
||||
logInfo.setNuclideInfoList(moreThanAvg);
|
||||
logService.saveLog(logInfo);
|
||||
// 发送报警信息
|
||||
String groupId = info.getGroupId();
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
messageDTO.setTitle("Nuclied Warn Info").setContent(alarmInfo.toString());
|
||||
if (StrUtil.isNotBlank(groupId)) {
|
||||
systemClient.sendMessage(messageDTO, groupId, ALL.getValue());
|
||||
systemClient.pushMessageToSingle(messageDTO, groupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首次发现该核素
|
||||
|
@ -246,28 +248,13 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
NuclideInfo nuclideInfo = new NuclideInfo();
|
||||
nuclideInfo.setNuclide(nuclideName);
|
||||
nuclideInfo.setThreshold(avg.toString());
|
||||
nuclideInfo.setDatasource(type(dataSourceType));
|
||||
nuclideInfo.setDatasource(DSType.typeOf(dataSourceType));
|
||||
nuclideInfo.setValue(conc.toString());
|
||||
nuclideInfos.add(nuclideInfo);
|
||||
}
|
||||
return nuclideInfos;
|
||||
}
|
||||
|
||||
private String type(String dataSourceType){
|
||||
switch (dataSourceType){
|
||||
case CommonConstant.ARMDARR:
|
||||
return "ARMDARR";
|
||||
case CommonConstant.ARMDRRR:
|
||||
return "ARMDRRR";
|
||||
case CommonConstant.IDCARR:
|
||||
return "IDCARR";
|
||||
case CommonConstant.IDCRRR:
|
||||
return "IDCRRR";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
// start:生成临时Token到线程中
|
||||
UserTokenContext.setToken(getTempToken());
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Map;
|
|||
|
||||
public interface CalculateConcService {
|
||||
|
||||
boolean calcAndSave();
|
||||
void calcAndSave();
|
||||
|
||||
Map<String, String> calculate(List<ConcDto> concDtos, BigDecimal index);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ public interface IAlarmAnalysisNuclideParamService extends IService<AlarmAnalysi
|
|||
|
||||
AlarmAnalysisNuclideParam getLatest();
|
||||
|
||||
boolean refresh();
|
||||
void refresh();
|
||||
|
||||
boolean update(AlarmAnalysisNuclideParam nuclideParam);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ public interface IAlarmItemService extends IService<AlarmItem> {
|
|||
|
||||
void deleteByHostId(String serverId);
|
||||
|
||||
List<AlarmItem> alarmItems(String sourceId);
|
||||
List<AlarmItem> alarmItemsServer(String sourceId);
|
||||
|
||||
List<ItemDto> alarmItemsDatabase(String sourceType, String sourceId);
|
||||
|
||||
List<ItemDto> allItems(String sourceType, String sourceId);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Set;
|
|||
|
||||
public interface IGardsXeResultsAutoService extends IService<GardsXeResults> {
|
||||
|
||||
List<ConcDtoXe> getConc(Map<String,Object> params);
|
||||
List<ConcDtoXe> getConc(Map<String,Object> params, Set<String> nuclides);
|
||||
|
||||
List<String> nuclideNames(Set<String> nuclideNames);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Set;
|
|||
|
||||
public interface IGardsXeResultsManService extends IService<GardsXeResults> {
|
||||
|
||||
List<ConcDtoXe> getConc(Map<String,Object> params);
|
||||
List<ConcDtoXe> getConc(Map<String,Object> params, Set<String> nuclides);
|
||||
|
||||
List<String> nuclideNames(Set<String> nuclideNames);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,5 @@ public interface ISysDatabaseService extends IService<SysDatabase> {
|
|||
|
||||
void status2Redis();
|
||||
|
||||
void status2Redis(SysDatabase database);
|
||||
|
||||
String getNameById(String id);
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ public class AlarmAnalysisLogServiceImpl extends ServiceImpl<AlarmAnalysisLogMap
|
|||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
List<NuclideInfo> nuclideInfos = mapper.readValue(nuclideInfo, new TypeReference<List<NuclideInfo>>() {});
|
||||
nuclideInfos.forEach(NuclideInfo::keepSix);
|
||||
logDto.setNuclideList(nuclideInfos);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("NuclideInfo解析异常: {}", e.getMessage());
|
||||
|
@ -170,8 +171,8 @@ public class AlarmAnalysisLogServiceImpl extends ServiceImpl<AlarmAnalysisLogMap
|
|||
return result;
|
||||
}
|
||||
Map<String, Long> stationGroup = analysisLogs.stream()
|
||||
.filter(log -> StrUtil.isNotBlank(log.getStationId()))
|
||||
.map(AlarmAnalysisLog::getStationId)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.collect(Collectors.groupingBy(stationId -> stationId, Collectors.counting()));
|
||||
Set<String> stationIds = stationGroup.keySet();
|
||||
Map<String, String> stationCodesMap = systemClient.stationCodesMap(stationIds);
|
||||
|
|
|
@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.jeecg.modules.base.dto.NuclideAvgDto;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
||||
import org.jeecg.modules.base.bizVo.NuclideAvgVo;
|
||||
import org.jeecg.modules.feignclient.SystemClient;
|
||||
import org.jeecg.modules.mapper.AlarmAnalysisNuclideAvgMapper;
|
||||
import org.jeecg.modules.service.IAlarmAnalysisNuclideAvgService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -16,10 +18,14 @@ import java.time.LocalDate;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class AlarmAnalysisNuclideAvgServiceImpl extends ServiceImpl<AlarmAnalysisNuclideAvgMapper, AlarmAnalysisNuclideAvg> implements IAlarmAnalysisNuclideAvgService {
|
||||
|
||||
@Autowired
|
||||
private SystemClient systemClient;
|
||||
|
||||
@Override
|
||||
public List<AlarmAnalysisNuclideAvg> list(Set<String> nuclideNames,String dataSourceType) {
|
||||
LocalDate dayAgo = LocalDate.now().minusDays(1);
|
||||
|
@ -37,6 +43,10 @@ public class AlarmAnalysisNuclideAvgServiceImpl extends ServiceImpl<AlarmAnalysi
|
|||
Map<String, Object> params = BeanUtil.beanToMap(nuclideAvgVo);
|
||||
Page<NuclideAvgDto> page = new Page<>(pageNo, pageSize);
|
||||
page = baseMapper.findPage(page, params);
|
||||
return page;
|
||||
List<NuclideAvgDto> nuclideAvgs = page.getRecords();
|
||||
List<String> stationIds = nuclideAvgs.stream().map(NuclideAvgDto::getStationId).collect(Collectors.toList());
|
||||
Map<String, String> codeMap = systemClient.stationCodesMap(stationIds);
|
||||
nuclideAvgs.forEach(item -> item.setStationCode(codeMap.get(item.getStationId())));
|
||||
return page.setRecords(nuclideAvgs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideParam;
|
||||
import org.jeecg.modules.mapper.AlarmAnalysisNuclideParamMapper;
|
||||
import org.jeecg.modules.service.IAlarmAnalysisNuclideParamService;
|
||||
|
@ -13,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AlarmAnalysisNuclideParamServiceImpl extends ServiceImpl<AlarmAnalysisNuclideParamMapper, AlarmAnalysisNuclideParam> implements IAlarmAnalysisNuclideParamService {
|
||||
|
||||
|
@ -24,7 +26,7 @@ public class AlarmAnalysisNuclideParamServiceImpl extends ServiceImpl<AlarmAnaly
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean refresh() {
|
||||
public void refresh() {
|
||||
try {
|
||||
AlarmAnalysisNuclideParam nuclideParam = new AlarmAnalysisNuclideParam();
|
||||
AlarmAnalysisNuclideParam latest = getLatest();
|
||||
|
@ -32,14 +34,16 @@ public class AlarmAnalysisNuclideParamServiceImpl extends ServiceImpl<AlarmAnaly
|
|||
.atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
LocalDate today = LocalDate.now();
|
||||
boolean isToday = today.equals(localDate);
|
||||
if (isToday) return true;
|
||||
if (isToday) return;
|
||||
CopyOptions options = CopyOptions.create()
|
||||
.setIgnoreProperties("id","createTime");
|
||||
BeanUtil.copyProperties(latest,nuclideParam,options);
|
||||
return save(nuclideParam);
|
||||
}catch (Throwable e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
save(nuclideParam);
|
||||
// log记录
|
||||
log.info("NuclideParamJob执行成功, 当前核素参数: [days: {},index: {}]",
|
||||
nuclideParam.getDays(), nuclideParam.getIndex());
|
||||
}catch (Exception e){
|
||||
log.error("NuclideParamJob执行异常: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,50 +1,35 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import feign.FeignException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.MonitorConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.util.RedisStreamUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.constant.enums.DbType;
|
||||
import org.jeecg.modules.base.dto.ItemDto;
|
||||
import org.jeecg.modules.base.entity.monitor.Host;
|
||||
import org.jeecg.modules.base.entity.monitor.Item;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmItemDe;
|
||||
import org.jeecg.modules.base.entity.postgre.SysServer;
|
||||
import org.jeecg.modules.base.entity.postgre.SysDatabase;
|
||||
import org.jeecg.modules.base.enums.SourceType;
|
||||
import org.jeecg.modules.feignclient.ManageUtil;
|
||||
import org.jeecg.modules.feignclient.MonitorAlarm;
|
||||
import org.jeecg.modules.mapper.AlarmItemMapper;
|
||||
import org.jeecg.modules.service.IAlarmItemDeService;
|
||||
import org.jeecg.modules.service.IAlarmItemService;
|
||||
import org.jeecg.modules.service.ISysDatabaseService;
|
||||
import org.jeecg.modules.service.ISysServerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.jeecg.modules.base.enums.SourceType.DATABASE;
|
||||
import static org.jeecg.modules.base.enums.SourceType.SERVER;
|
||||
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AlarmItemServiceImpl extends ServiceImpl<AlarmItemMapper, AlarmItem> implements IAlarmItemService {
|
||||
|
||||
@Autowired
|
||||
private ISysDatabaseService databaseService;
|
||||
|
||||
@Autowired
|
||||
private IAlarmItemDeService alarmItemDeService;
|
||||
|
||||
|
@ -62,8 +47,21 @@ public class AlarmItemServiceImpl extends ServiceImpl<AlarmItemMapper, AlarmItem
|
|||
* 返回指定服务器的所有监控项
|
||||
*/
|
||||
@Override
|
||||
public List<AlarmItem> alarmItems(String sourceId) {
|
||||
return baseMapper.alarmItems(sourceId);
|
||||
public List<AlarmItem> alarmItemsServer(String sourceId) {
|
||||
return baseMapper.alarmItemsServer(sourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> alarmItemsDatabase(String sourceType, String sourceId) {
|
||||
List<ItemDto> itemDtos = baseMapper.alarmItemsDatabase(sourceId).stream()
|
||||
.map(ItemDto::new).collect(Collectors.toList());
|
||||
SysDatabase database = databaseService.getById(sourceId);
|
||||
String dbType = database.getDbType();
|
||||
// 如果数据库类型是Oracle 则添加额外的监控项:表空间使用率
|
||||
if (StrUtil.equals(dbType, DbType.ORACLE.getType()))
|
||||
itemDtos.addAll(alarmItemDeService.alarmItemDes(sourceType).stream()
|
||||
.map(ItemDto::new).collect(Collectors.toList()));
|
||||
return itemDtos;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -77,10 +75,12 @@ public class AlarmItemServiceImpl extends ServiceImpl<AlarmItemMapper, AlarmItem
|
|||
return itemDtos;
|
||||
switch (type){
|
||||
case SERVER:
|
||||
itemDtos = alarmItems(sourceId).stream()
|
||||
itemDtos = alarmItemsServer(sourceId).stream()
|
||||
.map(ItemDto::new).collect(Collectors.toList());
|
||||
break;
|
||||
case DATABASE:
|
||||
itemDtos = alarmItemsDatabase(sourceType, sourceId);
|
||||
break;
|
||||
case EMAIL:
|
||||
itemDtos = alarmItemDeService.alarmItemDes(sourceType).stream()
|
||||
.map(ItemDto::new).collect(Collectors.toList());
|
||||
|
|
|
@ -94,10 +94,8 @@ public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRule
|
|||
@Override
|
||||
public Result<?> update(AlarmRule alarmRule) {
|
||||
AlarmRule alarmRuleOld = getById(alarmRule.getId());
|
||||
if (ObjectUtil.isNull(alarmRuleOld)){
|
||||
return Result.error(Prompt.DATA_NOT_EXITS);
|
||||
}
|
||||
String ruleId = alarmRuleOld.getId();
|
||||
Integer enabled = alarmRuleOld.getEnabled();
|
||||
// 保存oldRule的sourceType 避免修改了sourceType
|
||||
String sourceTypeOld = alarmRuleOld.getSourceType();
|
||||
Rule rule = alarmRule.getRule();
|
||||
|
@ -105,10 +103,10 @@ public class AlarmRuleServiceImpl extends ServiceImpl<AlarmRuleMapper, AlarmRule
|
|||
String operator = JSON.toJSONString(rule);
|
||||
alarmRule.setOperator(operator);
|
||||
}
|
||||
alarmRule.setEnabled(enabled);
|
||||
boolean success = updateById(alarmRule);
|
||||
if (success){
|
||||
// 如果当前规则是生效状态 则将修改后的规则同步到Redis
|
||||
Integer enabled = alarmRuleOld.getEnabled();
|
||||
if (Enabled.valueOf(enabled) == ENABLED)
|
||||
updateRule(ruleId, sourceTypeOld);
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
|
|
|
@ -2,16 +2,25 @@ package org.jeecg.modules.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.common.constant.DictConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.modules.base.dto.ConcDto;
|
||||
import org.jeecg.modules.base.dto.ConcDtoXe;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideParam;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisRule;
|
||||
import org.jeecg.modules.base.enums.StationType;
|
||||
import org.jeecg.modules.feignclient.SystemClient;
|
||||
import org.jeecg.modules.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -24,8 +33,10 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CalculateConcServiceImpl implements CalculateConcService {
|
||||
|
||||
@Autowired
|
||||
|
@ -49,18 +60,43 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
|||
@Autowired
|
||||
private IAlarmAnalysisNuclideParamService nuclideParamService;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private SystemClient systemClient;
|
||||
|
||||
private List<String> beta;
|
||||
|
||||
private Map<String, GardsStations> stations;
|
||||
|
||||
@Override
|
||||
public boolean calcAndSave() {
|
||||
public void calcAndSave() {
|
||||
try {
|
||||
String comma = SymbolConstant.COMMA;
|
||||
// 获取所有生效的报警规则
|
||||
List<AlarmAnalysisRule> analysisRules = analysisRuleService.allAnalysisRule();
|
||||
Set<String> nuclideNames = analysisRules.stream()
|
||||
.map(AlarmAnalysisRule::getNuclides)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.flatMap(nuclides -> ListUtil.toList(nuclides.split(comma)).stream())
|
||||
.collect(Collectors.toSet());
|
||||
// 对所有报警规则的关注台站和关注核素进行统计
|
||||
Map<String, Set<String>> nuclideMap = new HashMap<>(); // key:台站code value:核素列表
|
||||
for (AlarmAnalysisRule analysisRule : analysisRules) {
|
||||
String stationStr = analysisRule.getStations();
|
||||
String nuclideStr = analysisRule.getNuclides();
|
||||
// 获取关注台站
|
||||
List<String> stations = ListUtil.toList(StrUtil.split(stationStr, comma));
|
||||
// 获取关注核素
|
||||
Set<String> nuclides = new HashSet<>(ListUtil.toList(StrUtil.split(nuclideStr, comma)));
|
||||
for (String station : stations) {
|
||||
if (nuclideMap.containsKey(station)){
|
||||
Set<String> partNuclides = new HashSet<>(nuclideMap.get(station));
|
||||
partNuclides.addAll(nuclides);
|
||||
nuclideMap.put(station, partNuclides);
|
||||
}else {
|
||||
nuclideMap.put(station, nuclides);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 核素浓度值查询参数准备
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("nuclideName",nuclideNames);
|
||||
AlarmAnalysisNuclideParam paramLatest = nuclideParamService.getLatest();
|
||||
BigDecimal index = paramLatest.getIndex();
|
||||
Integer days = paramLatest.getDays();
|
||||
|
@ -71,48 +107,82 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
|||
String endDate = dayAgo.format(formatter);
|
||||
params.put("startDate",startDate + DateConstant.TIME_START);
|
||||
params.put("endDate",endDate + DateConstant.TIME_END);
|
||||
/* Auto自动处理 */
|
||||
// beta-gamma
|
||||
List<ConcDtoXe> xeConcAuto = xeResultsAutoService.getConc(params);
|
||||
// gamma
|
||||
List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params);
|
||||
|
||||
List<AlarmAnalysisNuclideAvg> autoAvgs = new ArrayList<>(); // Auto
|
||||
List<AlarmAnalysisNuclideAvg> manAvgs = new ArrayList<>(); // Man
|
||||
// 遍历所有台站 计算每个台站的所有核素浓度均值
|
||||
init();
|
||||
for (Map.Entry<String, Set<String>> entry : nuclideMap.entrySet()) {
|
||||
String station = entry.getKey();
|
||||
Set<String> nuclides = entry.getValue();
|
||||
// 查询指定台站的所有的核素浓度 并计算核素浓度均值
|
||||
params.put("stationId", station);
|
||||
StationType stationType = stationType(station);
|
||||
List<ConcDtoXe> xeConcAuto = new ArrayList<>();
|
||||
List<ConcDtoXe> xeConcMan = new ArrayList<>();
|
||||
List<ConcDto> nuclConcAuto = new ArrayList<>();
|
||||
List<ConcDto> nuclConcMan = new ArrayList<>();
|
||||
switch (stationType){
|
||||
case BETA:
|
||||
xeConcAuto = xeResultsAutoService.getConc(params, nuclides); // beta-gamma Auto
|
||||
xeConcMan = xeResultsManService.getConc(params, nuclides); // beta-gamma Man
|
||||
break;
|
||||
case GAMMA:
|
||||
params.put("nuclideName", nuclides);
|
||||
nuclConcAuto = nuclIdedAutoService.getConc(params); // gamma Auto
|
||||
nuclConcMan = nuclIdedManService.getConc(params); // gamma Man
|
||||
break;
|
||||
case NULL:
|
||||
xeConcAuto = xeResultsAutoService.getConc(params, nuclides); // beta-gamma Auto
|
||||
xeConcMan = xeResultsManService.getConc(params, nuclides); // beta-gamma Man
|
||||
params.put("nuclideName", nuclides);
|
||||
nuclConcAuto = nuclIdedAutoService.getConc(params); // gamma Auto
|
||||
nuclConcMan = nuclIdedManService.getConc(params); // gamma Man
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Auto
|
||||
Map<String, String> autoResult = new HashMap<>();
|
||||
autoResult.putAll(calculate(concDto(xeConcAuto), index));
|
||||
autoResult.putAll(calculate(nuclConcAuto, index));
|
||||
List<AlarmAnalysisNuclideAvg> autoAvgs = autoResult.entrySet().stream()
|
||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
autoAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDARR));
|
||||
/* Man人工交互 */
|
||||
// beta-gamma
|
||||
List<ConcDtoXe> xeConcMan = xeResultsManService.getConc(params);
|
||||
// gamma
|
||||
List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params);
|
||||
for (String nuclide : nuclides) {
|
||||
String val = autoResult.get(nuclide);
|
||||
AlarmAnalysisNuclideAvg analysisNuclideAvg = new AlarmAnalysisNuclideAvg(station, nuclide, val);
|
||||
analysisNuclideAvg.setDataSourceType(CommonConstant.ARMDARR);
|
||||
autoAvgs.add(analysisNuclideAvg);
|
||||
}
|
||||
// Man
|
||||
Map<String,String> manResult = new HashMap<>();
|
||||
manResult.putAll(calculate(concDto(xeConcMan), index));
|
||||
manResult.putAll(calculate(nuclConcMan, index));
|
||||
List<AlarmAnalysisNuclideAvg> manAvgs = manResult.entrySet().stream()
|
||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
manAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDRRR));
|
||||
manAvgs.addAll(autoAvgs);
|
||||
String cycle = startDate + SymbolConstant.WELL_NUMBER + endDate;
|
||||
manAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo));
|
||||
for (String nuclide : nuclides) {
|
||||
String val = manResult.get(nuclide);
|
||||
AlarmAnalysisNuclideAvg analysisNuclideAvg = new AlarmAnalysisNuclideAvg(station, nuclide, val);
|
||||
analysisNuclideAvg.setDataSourceType(CommonConstant.ARMDRRR);
|
||||
manAvgs.add(analysisNuclideAvg);
|
||||
}
|
||||
}
|
||||
// 自动处理和人工交互库的台站核素浓度均值结果合并
|
||||
List<AlarmAnalysisNuclideAvg> allAvgs = new ArrayList<>();
|
||||
allAvgs.addAll(autoAvgs);
|
||||
allAvgs.addAll(manAvgs);
|
||||
|
||||
// 计算周期和计算日期
|
||||
String cycle = startDate + SymbolConstant.WELL_NUMBER + endDate;
|
||||
allAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo));
|
||||
nuclideAvgService.saveBatch(allAvgs);
|
||||
// 记录日志
|
||||
log.info(log(manAvgs));
|
||||
return nuclideAvgService.saveBatch(manAvgs);
|
||||
}catch (Throwable e){
|
||||
e.printStackTrace();
|
||||
log.error("核素浓度计算过程异常: {}", e.getMessage());
|
||||
return false;
|
||||
log.info(log(allAvgs));
|
||||
}catch (Exception e){
|
||||
log.error("NucliedAvgJob执行异常: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> calculate(List<ConcDto> concDtos, BigDecimal index) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
if (CollUtil.isEmpty(concDtos)) return result;
|
||||
// 按照核素名进行分组
|
||||
Map<String, List<ConcDto>> concDtoMap = concDtos.stream()
|
||||
.collect(Collectors.groupingBy(ConcDto::getNuclideName));
|
||||
|
@ -144,12 +214,38 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
|||
}
|
||||
|
||||
private String log(List<AlarmAnalysisNuclideAvg> nuclideAvgs){
|
||||
List<String> nuclideNames = nuclideAvgs.stream()
|
||||
Set<String> nuclideNames = nuclideAvgs.stream()
|
||||
.map(AlarmAnalysisNuclideAvg::getNuclide)
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toSet());
|
||||
String nuclide = CollUtil.join(nuclideNames, ",");
|
||||
String now = LocalDateTime.now()
|
||||
.format(DateTimeFormatter.ofPattern(DateConstant.DATE_TIME));
|
||||
return "核素 [" + nuclide + "] 进行了浓度均值计算, 计算时间: " + now;
|
||||
return "核素 [" + nuclide + "] 进行了浓度均值计算";
|
||||
}
|
||||
|
||||
private void init(){
|
||||
try {
|
||||
stations = (Map<String, GardsStations>) redisUtil.get("stationInfoMap");
|
||||
UserTokenContext.setToken(getTempToken());
|
||||
// 获取Beta台站类型字典
|
||||
beta = systemClient.getItems(DictConstant.NOBLE_GAS_BETAGAMMA).stream()
|
||||
.map(DictModel::getValue).collect(Collectors.toList());
|
||||
}catch (Exception e){
|
||||
log.error("核素浓度均值计算时, 获取台站类型字典异常: {}", e.getMessage());
|
||||
}finally {
|
||||
UserTokenContext.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private StationType stationType(String stationId){
|
||||
if (MapUtil.isEmpty(stations))
|
||||
return StationType.NULL;
|
||||
GardsStations station = stations.get(stationId);
|
||||
if (ObjectUtil.isNull(station) || StrUtil.isBlank(station.getType()))
|
||||
return StationType.NULL;
|
||||
if (CollUtil.isEmpty(beta))
|
||||
return StationType.NULL;
|
||||
String stationType = station.getType();
|
||||
if (CollUtil.contains(beta, stationType))
|
||||
return StationType.BETA;
|
||||
return StationType.GAMMA;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
|
@ -13,6 +16,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -22,10 +26,28 @@ import java.util.stream.Collectors;
|
|||
@DS("ora")
|
||||
public class GardsXeResultsAutoServiceImpl extends ServiceImpl<GardsXeResultsAutoMapper, GardsXeResults> implements IGardsXeResultsAutoService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<ConcDtoXe> getConc(Map<String, Object> params) {
|
||||
return baseMapper.getConc(params);
|
||||
public List<ConcDtoXe> getConc(Map<String, Object> params, Set<String> nuclideList) {
|
||||
Set<String> nuclides = new HashSet<>();
|
||||
List<String> M = ListUtil.toList("Xe131M", "Xe133M");
|
||||
// XeResults表: 查询条件使用m
|
||||
for (String nuclide : nuclideList) {
|
||||
if (CollUtil.contains(M, nuclide)){
|
||||
nuclides.add(StrUtil.replace(nuclide, "M","m"));
|
||||
continue;
|
||||
}
|
||||
nuclides.add(nuclide);
|
||||
}
|
||||
params.put("nuclideName", nuclides);
|
||||
List<ConcDtoXe> result = baseMapper.getConc(params);
|
||||
// 将查询结果的m转换为M
|
||||
List<String> m = ListUtil.toList("Xe131m", "Xe133m");
|
||||
for (ConcDtoXe concDtoXe : result) {
|
||||
String nuclideName = concDtoXe.getNuclideName();
|
||||
if (CollUtil.contains(m, nuclideName))
|
||||
concDtoXe.setNuclideName(StrUtil.replace(nuclideName, "m","M"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -13,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -22,10 +26,28 @@ import java.util.stream.Collectors;
|
|||
@DS("ora")
|
||||
public class GardsXeResultsManServiceImpl extends ServiceImpl<GardsXeResultsManMapper, GardsXeResults> implements IGardsXeResultsManService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<ConcDtoXe> getConc(Map<String, Object> params) {
|
||||
return baseMapper.getConc(params);
|
||||
public List<ConcDtoXe> getConc(Map<String, Object> params ,Set<String> nuclideList) {
|
||||
Set<String> nuclides = new HashSet<>();
|
||||
List<String> M = ListUtil.toList("Xe131M", "Xe133M");
|
||||
// XeResults表: 查询条件使用m
|
||||
for (String nuclide : nuclideList) {
|
||||
if (CollUtil.contains(M, nuclide)){
|
||||
nuclides.add(StrUtil.replace(nuclide, "M","m"));
|
||||
continue;
|
||||
}
|
||||
nuclides.add(nuclide);
|
||||
}
|
||||
params.put("nuclideName", nuclides);
|
||||
List<ConcDtoXe> result = baseMapper.getConc(params);
|
||||
// 将查询结果的m转换为M
|
||||
List<String> m = ListUtil.toList("Xe131m", "Xe133m");
|
||||
for (ConcDtoXe concDtoXe : result) {
|
||||
String nuclideName = concDtoXe.getNuclideName();
|
||||
if (CollUtil.contains(m, nuclideName))
|
||||
concDtoXe.setNuclideName(StrUtil.replace(nuclideName, "m","M"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,29 +2,39 @@ package org.jeecg.modules.service.impl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import feign.FeignException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.*;
|
||||
import org.jeecg.common.constant.enums.DbType;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.util.JDBCUtil;
|
||||
import org.jeecg.common.util.NumUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.base.dto.*;
|
||||
import org.jeecg.modules.base.entity.monitor.Host;
|
||||
import org.jeecg.modules.base.entity.monitor.Item;
|
||||
import org.jeecg.modules.base.entity.postgre.SysDatabase;
|
||||
import org.jeecg.modules.base.bizVo.SourceVo;
|
||||
import org.jeecg.modules.base.entity.postgre.SysServer;
|
||||
import org.jeecg.modules.base.enums.DbItem;
|
||||
import org.jeecg.modules.base.enums.ServerStatus;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.feignclient.ManageUtil;
|
||||
import org.jeecg.modules.feignclient.MonitorAlarm;
|
||||
import org.jeecg.modules.feignclient.SystemClient;
|
||||
import org.jeecg.modules.mapper.DBRowMapper;
|
||||
import org.jeecg.modules.mapper.SpaceRowMapper;
|
||||
import org.jeecg.modules.mapper.SysDatabaseMapper;
|
||||
import org.jeecg.modules.service.IAlarmRuleService;
|
||||
import org.jeecg.modules.service.ISysDatabaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
@ -40,7 +50,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.jeecg.common.constant.enums.DbType.*;
|
||||
|
||||
@Slf4j
|
||||
@Service("sysDatabaseService")
|
||||
public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDatabase> implements ISysDatabaseService {
|
||||
|
||||
|
@ -50,6 +60,9 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
@Autowired
|
||||
private SystemClient systemClient;
|
||||
|
||||
@Autowired
|
||||
private MonitorAlarm monitorAlarm;
|
||||
|
||||
@Override
|
||||
public Result<?> findPage(QueryRequest query) {
|
||||
Integer pageNo = query.getPageNo();
|
||||
|
@ -72,23 +85,59 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
// 数据库连接状态Map key:id value:状态值(true|false)
|
||||
String statusKey = RedisConstant.DATABASE_STATUS;
|
||||
Map<Object, Object> statusMap = redisUtil.hmget(statusKey);
|
||||
// 向运管系统查询数据库相关指标信息
|
||||
Map<String,Host> dbMap = new HashMap<>();
|
||||
try {
|
||||
String token = ManageUtil.getToken();
|
||||
Page<Host> dbPage = monitorAlarm.dbList( MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult();
|
||||
if (ObjectUtil.isNotNull(dbPage) && CollUtil.isNotEmpty(dbPage.getRecords()))
|
||||
dbMap = dbPage.getRecords().stream().collect(Collectors.toMap(Host::getName, host -> host));
|
||||
}catch (FeignException.Unauthorized e){
|
||||
ManageUtil.refreshToken();
|
||||
log.warn("向运管系统查询DB信息异常: Token失效,已刷新Token");
|
||||
}catch (Exception e){
|
||||
log.error("向运管系统查询DB信息异常: {}", e.getMessage());
|
||||
}
|
||||
for (DatabaseDto databaseDto : databaseDtos) {
|
||||
boolean online = false;
|
||||
String id = databaseDto.getId();
|
||||
String type = databaseDto.getType();
|
||||
String name = databaseDto.getName();
|
||||
Integer alarms = databaseDto.getAlarms();
|
||||
boolean alarmRed = ObjectUtil.isNotNull(alarms) && alarms > 0;
|
||||
NameValue nameValue = (NameValue) statusMap.get(id);
|
||||
if (ObjectUtil.isNotNull(nameValue)){
|
||||
Boolean value = nameValue.getValue();
|
||||
if (ObjectUtil.isNotNull(value))
|
||||
online = value;
|
||||
if (ObjectUtil.isNotNull(value)) online = value;
|
||||
}
|
||||
String dataBaseType = dataSourceMap.get(type);
|
||||
databaseDto.setDataBaseType(dataBaseType)
|
||||
.setOnline(online).setSlowQuery("328/s")
|
||||
.setAlarmRed(alarmRed).setCpuUutilzation("35.8%")
|
||||
.setMemoryUsage("55.8%").setDiskUsage("35.6%");
|
||||
.setAlarmRed(alarmRed).setOnline(online);
|
||||
// 如果数据库不在线 则不需要查询数据库的使用情况
|
||||
if (!online) continue;
|
||||
|
||||
// 获取数据库指标信息
|
||||
Host db = dbMap.get(name);
|
||||
if (ObjectUtil.isNull(db)) continue;
|
||||
Map<String, Item> itemMap = db.getItems();
|
||||
if (MapUtil.isEmpty(itemMap)) continue;
|
||||
// dbMemory kb -> GB
|
||||
Item item = itemMap.get(DbItem.DBMEMORY.getValue());
|
||||
if (ObjectUtil.isNotNull(item))
|
||||
databaseDto.setDbMemory(NumUtil.kb2Gb(item.getLastValue(), 2));
|
||||
// logRemainingSize byte -> MB
|
||||
item = itemMap.get(DbItem.LOGREMAININGSIZE.getValue());
|
||||
if (ObjectUtil.isNotNull(item))
|
||||
databaseDto.setLogRemainingSize(NumUtil.byte2Mb(item.getLastValue(), 2));
|
||||
// dbSize byte -> GB
|
||||
item = itemMap.get(DbItem.DBSIZE.getValue());
|
||||
if (ObjectUtil.isNotNull(item)){
|
||||
databaseDto.setDbSize(NumUtil.byte2Gb(item.getLastValue(), 2));
|
||||
}else {
|
||||
item = itemMap.get(DbItem.DBLSIZE.getValue());
|
||||
if (ObjectUtil.isNotNull(item))
|
||||
databaseDto.setDbSize(NumUtil.byte2Gb(item.getLastValue(), 2));
|
||||
}
|
||||
}
|
||||
page.setRecords(databaseDtos);
|
||||
return Result.OK(page);
|
||||
|
@ -182,10 +231,12 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
@Override
|
||||
@Transactional
|
||||
public Result<?> deleteById(String id) {
|
||||
SysDatabase database = getById(id);
|
||||
boolean success = removeById(id);
|
||||
if(success) {
|
||||
delStatus(id);
|
||||
return Result.OK(Prompt.DELETE_SUCC);
|
||||
String hostId = ObjectUtil.isNotNull(database) ? database.getHostId() : null;
|
||||
return Result.OK(Prompt.DELETE_SUCC, hostId);
|
||||
}
|
||||
return Result.error(Prompt.DELETE_ERR);
|
||||
}
|
||||
|
@ -317,22 +368,37 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
public void status2Redis() {
|
||||
// 获取所有配置的数据源
|
||||
List<SysDatabase> databases = list();
|
||||
String key = RedisConstant.DATABASE_STATUS;
|
||||
Map<String, Object> values = new HashMap<>();
|
||||
try {
|
||||
String token = ManageUtil.getToken();
|
||||
List<Host> hosts = monitorAlarm.dbList(MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult().getRecords();
|
||||
Map<String, Host> hostMap = hosts.stream().collect(Collectors.toMap(Host::getHostId, Host -> Host));
|
||||
for (SysDatabase database : databases) {
|
||||
this.status2Redis(database);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void status2Redis(SysDatabase database) {
|
||||
String statusKey = RedisConstant.DATABASE_STATUS;
|
||||
String id = database.getId();
|
||||
Boolean online = null;
|
||||
String hostId = database.getHostId();
|
||||
String name = database.getName();
|
||||
String dbUrl = database.getDbUrl();
|
||||
String dbDriver = database.getDbDriver();
|
||||
String dbUsername = database.getDbUsername();
|
||||
String dbPassword = database.getDbPassword();
|
||||
boolean isConn = JDBCUtil.isConnection(dbUrl, dbDriver, dbUsername, dbPassword);
|
||||
redisUtil.hset(statusKey, id, new NameValue(name, isConn));
|
||||
String databaseId = database.getId();
|
||||
Host host = hostMap.get(hostId);
|
||||
// 获取该数据源的状态并保存
|
||||
if (ObjectUtil.isNotNull(host)) {
|
||||
String status = host.getStatus();
|
||||
online = CollUtil.contains(ListUtil.toList(ServerStatus.ON.getValue(),
|
||||
ServerStatus.WARN.getValue()), status);
|
||||
values.put(databaseId, new NameValue(name, online));
|
||||
continue;
|
||||
}
|
||||
// 当前数据库不在监控数据库列表
|
||||
values.put(databaseId, new NameValue(name, online));
|
||||
}
|
||||
redisUtil.hmset(key, values);
|
||||
}catch (FeignException.Unauthorized e){
|
||||
ManageUtil.refreshToken();
|
||||
log.warn("向运管系统查询Hosts信息异常: Token失效,已刷新Token");
|
||||
} catch (Exception e){
|
||||
defaultStatus(databases);
|
||||
log.error("向运管系统查询Hosts信息异常: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -410,6 +476,17 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
return dbName;
|
||||
}
|
||||
|
||||
private void defaultStatus(List<SysDatabase> sysDatabases){
|
||||
String key = RedisConstant.DATABASE_STATUS;
|
||||
Map<String, Object> values = new HashMap<>();
|
||||
for (SysDatabase database: sysDatabases) {
|
||||
String id = database.getId();
|
||||
String name = database.getName();
|
||||
values.put(id, new NameValue(name, null));
|
||||
}
|
||||
redisUtil.hmset(key, values);
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除指定id的数据源的状态值
|
||||
* */
|
||||
|
|
|
@ -270,12 +270,16 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
|
|||
wrapper.eq(SysEmail::getEnabled, ENABLED.getValue());
|
||||
List<SysEmail> emails = this.list(wrapper);
|
||||
Optional<SysEmail> first = emails.stream().findFirst();
|
||||
if(!first.isPresent()) return null;
|
||||
if(first.isPresent()) {
|
||||
SysEmail sender = first.get();
|
||||
redisUtil.set(RedisConstant.EMAIL_SENDER, sender);
|
||||
log.info("缓存了可用的发件邮箱到Redis: {}", sender.getUsername());
|
||||
return sender;
|
||||
}
|
||||
// 删除缓存中旧的发件邮箱信息
|
||||
if (redisUtil.hasKey(RedisConstant.EMAIL_SENDER))
|
||||
redisUtil.del(RedisConstant.EMAIL_SENDER);
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除指定id的邮箱服务器的状态值
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
|
@ -80,8 +81,7 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
List<Host> hosts = new ArrayList<>();
|
||||
try {
|
||||
String token = ManageUtil.getToken();
|
||||
hosts = monitorAlarm.listOnApp(ON.getValue(), MonitorConstant.SERVER_APP,
|
||||
MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult().getRecords();
|
||||
hosts = monitorAlarm.listApp(MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult().getRecords();
|
||||
}catch (FeignException.Unauthorized e){
|
||||
ManageUtil.refreshToken();
|
||||
log.warn("向运管系统查询Hosts信息异常: Token失效,已刷新Token");
|
||||
|
@ -100,32 +100,33 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
serverDto.setAlarmRed(alarms > 0);
|
||||
// 设置服务器状态信息
|
||||
NameValue nameValue = (NameValue) statusMap.get(id);
|
||||
String status = OFF.getValue();
|
||||
if (ObjectUtil.isNotNull(nameValue)){
|
||||
String valueT = nameValue.getValueT();
|
||||
if (StrUtil.isNotBlank(valueT))
|
||||
status = valueT;
|
||||
}
|
||||
boolean online = StrUtil.equals(status, ON.getValue());
|
||||
Boolean value = null;
|
||||
if (ObjectUtil.isNotNull(nameValue))
|
||||
value = nameValue.getValue();
|
||||
boolean online = ObjectUtil.isNotNull(value) && value;
|
||||
serverDto.setOnline(online);
|
||||
// 如果机器不在线 则不需要查询机器的硬件使用情况
|
||||
if (!online) continue;
|
||||
|
||||
// 设置服务器的硬件使用情况信息
|
||||
Host host = hostMap.get(hostId);
|
||||
if (ObjectUtil.isNull(host))
|
||||
continue;
|
||||
if (ObjectUtil.isNull(host)) continue;
|
||||
Map<String, Item> items = host.getItems();
|
||||
// CPU利用率
|
||||
Item cpuItem = items.getOrDefault(MonitorConstant.ITEM_CPUUSED, new Item());
|
||||
String cpuValue = cpuItem.getLastValue();
|
||||
String cpu = StrUtil.isBlank(cpuValue) ? "--" :
|
||||
NumUtil.keepStr(cpuValue, 1) + "%";
|
||||
Item item = items.getOrDefault(MonitorConstant.ITEM_CPUUSED, new Item());
|
||||
String cpu = item.getLastValue();
|
||||
if (StrUtil.isNotBlank(cpu))
|
||||
serverDto.setCpuUutilzation(NumUtil.keepStr(cpu, 1) + "%");
|
||||
// 内存使用率
|
||||
Item memoryItem = items.getOrDefault(MonitorConstant.ITEM_MEMORYUSED, new Item());
|
||||
String memoryValue = memoryItem.getLastValue();
|
||||
String memory = StrUtil.isBlank(memoryValue) ? "--" :
|
||||
NumUtil.keepStr(memoryValue, 1) + "%";
|
||||
// 磁盘使用率
|
||||
|
||||
serverDto.setOnline(online).setCpuUutilzation(cpu)
|
||||
.setMemoryUsage(memory).setDiskUsage("--");
|
||||
item = items.getOrDefault(MonitorConstant.ITEM_MEMORYUSED, new Item());
|
||||
String memory = item.getLastValue();
|
||||
if (StrUtil.isNotBlank(memory))
|
||||
serverDto.setMemoryUsage(NumUtil.keepStr(memory, 1) + "%");
|
||||
// 内存可用空间
|
||||
item = items.getOrDefault(MonitorConstant.ITEM_MEMORYFREESIZE, new Item());
|
||||
String memoryFree = item.getLastValue();
|
||||
if (StrUtil.isNotBlank(memoryFree))
|
||||
serverDto.setMemoryFree(NumUtil.byte2Gb(memoryFree, 2) + "GB");
|
||||
}
|
||||
page.setRecords(serverDtos);
|
||||
return Result.OK(page);
|
||||
|
@ -188,12 +189,11 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
@Override
|
||||
@Transactional
|
||||
public Result<?> deleteById(String id) {
|
||||
String hostId = null;
|
||||
SysServer server = getById(id);
|
||||
boolean success = removeById(id);
|
||||
if(success) {
|
||||
delStatus(id);
|
||||
hostId = ObjectUtil.isNotNull(server) ? server.getHostId() : hostId;
|
||||
String hostId = ObjectUtil.isNotNull(server) ? server.getHostId() : null;
|
||||
return Result.OK(Prompt.DELETE_SUCC, hostId);
|
||||
}
|
||||
return Result.error(Prompt.DELETE_ERR);
|
||||
|
@ -368,10 +368,10 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
Map<String, Object> values = new HashMap<>();
|
||||
try {
|
||||
String token = ManageUtil.getToken();
|
||||
List<Host> hosts = monitorAlarm.listApp(MonitorConstant.SERVER_APP,
|
||||
MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult().getRecords();
|
||||
List<Host> hosts = monitorAlarm.listApp(MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult().getRecords();
|
||||
Map<String, Host> hostMap = hosts.stream().collect(Collectors.toMap(Host::getHostId, Host -> Host));
|
||||
for (SysServer server : sysServers) {
|
||||
Boolean online = null;
|
||||
String hostId = server.getHostId();
|
||||
String name = server.getName();
|
||||
String serverId = server.getId();
|
||||
|
@ -379,11 +379,13 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
// 获取该服务器的状态并保存
|
||||
if (ObjectUtil.isNotNull(host)) {
|
||||
String status = host.getStatus();
|
||||
values.put(serverId, new NameValue(name, status));
|
||||
online = CollUtil.contains(ListUtil.toList(ServerStatus.ON.getValue(),
|
||||
ServerStatus.WARN.getValue()), status);
|
||||
values.put(serverId, new NameValue(name, online));
|
||||
continue;
|
||||
}
|
||||
// 当前服务器不在监控服务器列表 将它的状态设置为未知
|
||||
values.put(serverId, new NameValue(name, OFF.getValue()));
|
||||
// 当前服务器不在监控服务器列表
|
||||
values.put(serverId, new NameValue(name, online));
|
||||
}
|
||||
redisUtil.hmset(key, values);
|
||||
}catch (FeignException.Unauthorized e){
|
||||
|
@ -412,7 +414,7 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
for (SysServer sysServer : sysServers) {
|
||||
String id = sysServer.getId();
|
||||
String name = sysServer.getName();
|
||||
values.put(id, new NameValue(name, OFF.getValue()));
|
||||
values.put(id, new NameValue(name, null));
|
||||
}
|
||||
redisUtil.hmset(key, values);
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ import org.jeecg.modules.entity.StationOperation;
|
|||
import org.jeecg.modules.entity.SysUserFocusStationStation;
|
||||
import org.jeecg.modules.feignclient.StationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
@ -84,6 +86,14 @@ public class StationController {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
// /stationOperation/getSelfStationGPS
|
||||
@GetMapping("/stationOperation/getSelfStationGPS")
|
||||
@ApiOperation(value = "查询台站运行轨迹", notes = "查询台站运行轨迹")
|
||||
public Result getSelfStationGPS(String stationCode,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
|
||||
Result result = stationService.getSelfStationGPS(stationCode, startDate, endDate);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,10 +4,12 @@ import org.jeecg.common.api.vo.Result;
|
|||
import org.jeecg.modules.entity.StationOperation;
|
||||
import org.jeecg.modules.entity.SysUserFocusStationStation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
|
@ -35,4 +37,8 @@ public interface StationService {
|
|||
@GetMapping("/sysUserFocusStation/findUserFocusByUserIdApp")
|
||||
Result findUserFocusByUserId(@RequestParam String userId);
|
||||
|
||||
@GetMapping("/stationOperation/getSelfStationGPS")
|
||||
Result getSelfStationGPS(@RequestParam("stationCode") String stationCode,
|
||||
@RequestParam("startDate") @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
|
||||
@RequestParam("endDate") @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -66,6 +67,10 @@ public class AutoProcessManager{
|
|||
final MailExecManager autoProcessThread = new MailExecManager();
|
||||
autoProcessThread.setName("mail-exec-thread-manage");
|
||||
autoProcessThread.start();
|
||||
//删除邮件执行线程管理
|
||||
final DeletedMailMonitor detedMailMonitor = new DeletedMailMonitor();
|
||||
detedMailMonitor.setName("deleted-mail-monitor");
|
||||
detedMailMonitor.start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,23 +83,21 @@ public class AutoProcessManager{
|
|||
for(;;){
|
||||
long start = System.currentTimeMillis();
|
||||
if(!CollectionUtils.isEmpty(emailMap)){
|
||||
synchronized (lock){
|
||||
Iterator<EmailProperties> iterator = emailMap.values().iterator();
|
||||
while(iterator.hasNext()){
|
||||
EmailProperties next = iterator.next();
|
||||
if(next.isDelFlag()){
|
||||
if(emailExecThreadMap.containsKey(next.getId())){
|
||||
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
|
||||
actuator.setStop(true);
|
||||
emailExecThreadMap.remove(next.getId());
|
||||
}
|
||||
iterator.remove();
|
||||
}
|
||||
if (next.isResetFlag()) {
|
||||
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
|
||||
actuator.updateEmail(next);
|
||||
next.setResetFlag(false);
|
||||
}
|
||||
if(next.isNewEmailFlag()){
|
||||
// 网络正常之后才允许创建新的实例
|
||||
final EmailServiceManager emailServiceManager = EmailServiceManager.getInstance();
|
||||
emailServiceManager.init(next);
|
||||
boolean testFlag = emailServiceManager.testConnectEmailServer();
|
||||
if(testFlag){
|
||||
EmailParsingActuator emailParsingActuator = new EmailParsingActuator();
|
||||
emailParsingActuator.init(next,spectrumServiceQuotes,emailCounter,systemStartupTime);
|
||||
emailParsingActuator.setName(next.getUsername()+"-email-monitor");
|
||||
|
@ -106,6 +109,8 @@ public class AutoProcessManager{
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
long sleepTime = taskProperties.getMonitoringMailDataCycle() - (end-start);
|
||||
//如果sleepTime > 0 需要睡眠到指定时间,否则继续下次获取邮件
|
||||
|
@ -133,21 +138,33 @@ public class AutoProcessManager{
|
|||
long start = System.currentTimeMillis();
|
||||
try{
|
||||
if(!CollectionUtils.isEmpty(emailMap)){
|
||||
synchronized (lock){
|
||||
//记录连接测试失败的邮箱
|
||||
List<EmailProperties> emails = new ArrayList<>();
|
||||
emailMap.values().forEach(email->{
|
||||
if(!email.isDelFlag()){
|
||||
final EmailServiceManager emailServiceManager = EmailServiceManager.getInstance();
|
||||
emailServiceManager.init(email);
|
||||
boolean testFlag = emailServiceManager.testConnectEmailServer();
|
||||
// redisUtil.hset(EmailConstant.EMAIL_STATUS_PREFIX,email.getId(),testFlag);
|
||||
if(testFlag && !emailExecThreadMap.containsKey(email.getId())){
|
||||
email.setNewEmailFlag(true);
|
||||
}
|
||||
if(!testFlag){
|
||||
//如果邮件服务通信测试失败则添加删除标记
|
||||
email.setDelFlag(true);
|
||||
emails.add(email);
|
||||
}
|
||||
}
|
||||
});
|
||||
//如果emailIds不为空,说明此次有测试连接失败的邮箱,直接删除
|
||||
if(!CollectionUtils.isEmpty(emails)){
|
||||
emails.forEach(email->{
|
||||
emailMap.remove(email.getId());
|
||||
//如果这时邮箱线程里已有执行的线程则设置停止标记
|
||||
if(emailExecThreadMap.containsKey(email.getId())){
|
||||
EmailParsingActuator actuator = emailExecThreadMap.get(email.getId());
|
||||
actuator.setStop(true);
|
||||
actuator.setStopTime(new Date());
|
||||
}
|
||||
log.info("{}邮箱测试连接失败,emailMap删除此邮箱数据,emailExecThreadMap设置线程停止标记",email.getUsername());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
//捕获异常不处理保障线程异常不退出
|
||||
}catch (Exception e){
|
||||
|
@ -182,41 +199,48 @@ public class AutoProcessManager{
|
|||
try{
|
||||
final List<EmailProperties> receiveMails = mailService.findReceiveMails();
|
||||
if(!CollectionUtils.isEmpty(receiveMails)){
|
||||
//如果库里已有数据原来已开启使用并且监测Map中已存在,现在关闭使用则添加删除标记
|
||||
//如果本次查询数据监测Map中不存在,并且已开启使用的则加入监测Map
|
||||
for(EmailProperties email : receiveMails){
|
||||
//判断map里是否包含邮箱id
|
||||
final boolean flag = emailMap.containsKey(email.getId());
|
||||
//如果包含邮箱id 并且 邮箱处于未启用的状态 将邮箱的删除标识设置为true
|
||||
if(flag && email.getEnabled().equals(SysMailEnableType.NOT_ENABLE.getMailEnableType())){
|
||||
EmailProperties sourceEmail = emailMap.get(email.getId());
|
||||
sourceEmail.setDelFlag(true);
|
||||
final Iterator<EmailProperties> iterator = receiveMails.iterator();
|
||||
synchronized (lock){
|
||||
while(iterator.hasNext()){
|
||||
EmailProperties databaseEmail = iterator.next();
|
||||
//判断map里存储的邮箱数据是否包含当前数据库邮箱记录的id
|
||||
if(emailMap.containsKey(databaseEmail.getId())){
|
||||
final EmailProperties mapEmail = emailMap.get(databaseEmail.getId());
|
||||
//如果数据库里邮箱数据已关闭,则删除
|
||||
if(databaseEmail.getEnabled().equals(SysMailEnableType.NOT_ENABLE.getMailEnableType())){
|
||||
emailMap.remove(mapEmail.getId());
|
||||
//如果这时邮箱线程里已有执行的线程则设置停止标记
|
||||
if(emailExecThreadMap.containsKey(databaseEmail.getId())){
|
||||
EmailParsingActuator actuator = emailExecThreadMap.get(databaseEmail.getId());
|
||||
actuator.setStop(true);
|
||||
actuator.setStopTime(new Date());
|
||||
}
|
||||
//如果包含邮箱id 并且 邮箱处于启用状态 将邮箱数据进行更新
|
||||
if (flag && email.getEnabled().equals(SysMailEnableType.ENABLE.getMailEnableType())) {
|
||||
EmailProperties properties = emailMap.get(email.getId());
|
||||
//判断邮箱的用户名,密码是否与原邮箱用户名,密码一致
|
||||
//如果不一致则进行更新
|
||||
if ( !properties.getUsername().equals(email.getUsername()) || !properties.getPassword().equals(email.getPassword()) ) {
|
||||
email.setResetFlag(true);
|
||||
putSysEmailMap(email);
|
||||
log.info("{}邮箱加入监测队列",email.getEmailServerAddress());
|
||||
log.info("{}邮箱已关闭服务,emailMap删除此邮箱数据,emailExecThreadMap设置线程停止标记",mapEmail.getUsername());
|
||||
}else{
|
||||
//判断邮箱的用户名,密码是否与原邮箱用户名,密码一致,如果不一致则进行更新
|
||||
if (!mapEmail.getUsername().equals(databaseEmail.getUsername()) || !mapEmail.getPassword().equals(databaseEmail.getPassword())
|
||||
|| !mapEmail.getEmailServerAddress().equals(databaseEmail.getEmailServerAddress())) {
|
||||
final boolean testFlag = testConnectEmailServer(databaseEmail);
|
||||
if(testFlag){
|
||||
databaseEmail.setResetFlag(true);
|
||||
emailMap.put(databaseEmail.getId(),databaseEmail);
|
||||
log.info("{}邮箱数据已更新,覆盖原邮箱数据,设置重置标记",mapEmail.getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//如果不包含邮箱id 并且 邮箱处于启用状态 将邮箱对象存入到map中 并将新邮箱标识设置为true
|
||||
if(!flag && email.getEnabled().equals(SysMailEnableType.ENABLE.getMailEnableType())){
|
||||
email.setNewEmailFlag(true);
|
||||
putSysEmailMap(email);
|
||||
log.info("{}邮箱加入监测队列",email.getEmailServerAddress());
|
||||
if(databaseEmail.getEnabled().equals(SysMailEnableType.ENABLE.getMailEnableType())){
|
||||
final boolean testFlag = testConnectEmailServer(databaseEmail);
|
||||
if(testFlag){
|
||||
databaseEmail.setNewEmailFlag(true);
|
||||
emailMap.put(databaseEmail.getId(),databaseEmail);
|
||||
log.info("{}邮箱加入监测队列,设置新增标记",databaseEmail.getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//如果监测Map中存在的邮箱数据,在本次查询数据中不存在说明库里已删除,则添加删除标记
|
||||
emailMap.forEach((emailId,sourceEmail)->{
|
||||
final long result = receiveMails.stream().filter(email -> emailId.equals(email.getId())).count();
|
||||
if (result <= 0){
|
||||
sourceEmail.setDelFlag(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
//捕获异常不处理保障线程异常不退出
|
||||
}catch (Exception e){
|
||||
|
@ -237,38 +261,78 @@ public class AutoProcessManager{
|
|||
}
|
||||
|
||||
/**
|
||||
* 新增邮箱数据
|
||||
* 监测已设置删除标记的邮箱线程
|
||||
* isStop值为true的邮箱线程
|
||||
* 20秒还未停止则进行强制停止
|
||||
*/
|
||||
private class DeletedMailMonitor extends Thread{
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(;;){
|
||||
long start = System.currentTimeMillis();
|
||||
if(!CollectionUtils.isEmpty(emailExecThreadMap)){
|
||||
//遍历邮箱执行线程,如果状态为已停止则删除
|
||||
final Iterator<Map.Entry<String, EmailParsingActuator>> checkStopThreads = emailExecThreadMap.entrySet().iterator();
|
||||
while (checkStopThreads.hasNext()){
|
||||
final Map.Entry<String, EmailParsingActuator> next = checkStopThreads.next();
|
||||
if(next.getValue().getState() == State.TERMINATED){
|
||||
log.info("{}邮箱执行线程已停止,emailExecThreadMap删除此邮箱数据",next.getValue().getEmailProperties().getUsername());
|
||||
checkStopThreads.remove();
|
||||
}
|
||||
}
|
||||
|
||||
//遍历邮箱执行线程,如果邮箱执行线程stop属性已被设置为true则关闭资源停止线程
|
||||
final Iterator<Map.Entry<String, EmailParsingActuator>> iterator = emailExecThreadMap.entrySet().iterator();
|
||||
emailExecThreadMap.forEach((emailId,emailExecThread)->{
|
||||
try{
|
||||
if(emailExecThread.getState() != State.TERMINATED && emailExecThread.isStop()){
|
||||
final long nowTime = System.currentTimeMillis();
|
||||
final long setStoptime = emailExecThread.getStopTime().getTime();
|
||||
final long val = nowTime - setStoptime;
|
||||
if(val >= taskProperties.getForceDeletedTime()){
|
||||
log.info("关闭{}邮箱线程内部线程池资源",emailExecThread.getEmailProperties().getUsername());
|
||||
emailExecThread.closeResource();
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(emailExecThread.getState() != State.TERMINATED && emailExecThread.isStop()){
|
||||
final long nowTime = System.currentTimeMillis();
|
||||
final long setStoptime = emailExecThread.getStopTime().getTime();
|
||||
final long val = nowTime - setStoptime;
|
||||
if(val >= taskProperties.getForceDeletedTime()){
|
||||
log.info("强制停止{}邮箱线程",emailExecThread.getEmailProperties().getUsername());
|
||||
emailExecThread.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
long sleepTime = taskProperties.getDeletedMailThreadExecCycle() - (end-start);
|
||||
//如果sleepTime > 0 需要睡眠到指定时间,否则继续下次监测
|
||||
if(sleepTime > 0){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(sleepTime);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试邮箱连通性
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
private void putSysEmailMap(EmailProperties email){
|
||||
synchronized (this.lock){
|
||||
emailMap.put(email.getId(),email);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除邮箱数据
|
||||
* @param emailId
|
||||
*/
|
||||
private void removeSysEmailMap(String emailId){
|
||||
synchronized (this.lock){
|
||||
if (emailMap.containsKey(emailId)){
|
||||
emailMap.remove(emailId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除邮箱数据
|
||||
* @param sysEmailIds
|
||||
*/
|
||||
private void removeSysEmailMap(List<String> sysEmailIds){
|
||||
synchronized (this.lock){
|
||||
for(String sysEmailId : sysEmailIds){
|
||||
if (emailMap.containsKey(sysEmailId)){
|
||||
emailMap.remove(sysEmailId);
|
||||
}
|
||||
}
|
||||
}
|
||||
private boolean testConnectEmailServer(EmailProperties email){
|
||||
final EmailServiceManager emailServiceManager = EmailServiceManager.getInstance();
|
||||
emailServiceManager.init(email);
|
||||
boolean testFlag = emailServiceManager.testConnectEmailServer();
|
||||
return testFlag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package org.jeecg.modules;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.jeecg.common.email.EmailLogManager;
|
||||
import org.jeecg.common.email.EmailServiceManager;
|
||||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.email.EmailProperties;
|
||||
import org.jeecg.modules.spectrum.EmailCounter;
|
||||
import org.jeecg.modules.spectrum.SpectrumLogManager;
|
||||
|
@ -17,21 +20,26 @@ import javax.mail.internet.MimeMessage;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* 邮件解析执行器
|
||||
*/
|
||||
@Slf4j
|
||||
public class EmailParsingActuator extends Thread{
|
||||
|
||||
private TaskProperties taskProperties;
|
||||
@Getter
|
||||
private EmailProperties emailProperties;
|
||||
private ThreadPoolExecutor poolExecutor;
|
||||
private SpectrumServiceQuotes spectrumServiceQuotes;
|
||||
private EmailCounter emailCounter;
|
||||
private Date systemStartupTime;
|
||||
@Setter
|
||||
@Setter @Getter
|
||||
private boolean isStop;
|
||||
@Setter @Getter
|
||||
private Date stopTime;
|
||||
|
||||
public void init(EmailProperties emailProperties,SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
EmailCounter emailCounter,Date systemStartupTime){
|
||||
|
@ -58,7 +66,9 @@ public class EmailParsingActuator extends Thread{
|
|||
public void run() {
|
||||
for(;;){
|
||||
if (isStop) {
|
||||
System.out.println("EmailParsingActuator is Stop!");
|
||||
String nowDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
log.info(nowDate + " " +this.emailProperties.getName()+" EmailParsingActuator is Stop!");
|
||||
closeResource();
|
||||
return;
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
|
@ -69,27 +79,33 @@ public class EmailParsingActuator extends Thread{
|
|||
try {
|
||||
Message[] messages = emailServiceManager.receiveMail();
|
||||
if(ArrayUtils.isNotEmpty(messages)){
|
||||
log.info("EmailParsingActuator本次获取邮件数量为:{}",messages.length);
|
||||
//检验获取的邮件是否在之前删除失败列表中,若在直接调用邮件API删除,并且此次数组里元素也删除
|
||||
for(int i=messages.length-1;i>=0;i--){
|
||||
if (!messages[i].isExpunged()){
|
||||
String messageId = ((MimeMessage) messages[i]).getMessageID();
|
||||
final boolean exist = emailServiceManager.check(messages[i],messageId);
|
||||
messageIds.add(messageId);
|
||||
if(exist){
|
||||
messages = ArrayUtils.remove(messages,i);
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int i=messages.length-1;i>=0;i--){
|
||||
// if (!messages[i].isExpunged()){
|
||||
// String messageId = ((MimeMessage) messages[i]).getMessageID();
|
||||
// final boolean exist = emailServiceManager.check(messages[i],messageId);
|
||||
// messageIds.add(messageId);
|
||||
// if(exist){
|
||||
// messages = ArrayUtils.remove(messages,i);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
log.info("EmailParsingActuator本次真实执行邮件数量为:{}",messages.length);
|
||||
if(messages.length > 0){
|
||||
//本批次邮件号
|
||||
final Integer batchesCounter = spectrumServiceQuotes.getBatchesCounter().getCurrValue();
|
||||
CountDownLatch taskLatch = new CountDownLatch(messages.length);
|
||||
for(Message message : messages){
|
||||
SpectrumParsingActuator spectrumParsingActuator = new SpectrumParsingActuator();
|
||||
spectrumParsingActuator.init(message,emailProperties,emailServiceManager,
|
||||
taskLatch,spectrumServiceQuotes,emailCounter);
|
||||
taskLatch,spectrumServiceQuotes,emailCounter,batchesCounter);
|
||||
poolExecutor.execute(spectrumParsingActuator);
|
||||
}
|
||||
taskLatch.await();
|
||||
}
|
||||
}catch (InterruptedException | MessagingException e) {
|
||||
}
|
||||
}catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
//清除本批次邮件日志缓存
|
||||
|
@ -114,4 +130,13 @@ public class EmailParsingActuator extends Thread{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 立即关闭线程池
|
||||
*/
|
||||
protected void closeResource(){
|
||||
if(Objects.nonNull(poolExecutor)) {
|
||||
poolExecutor.shutdownNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class UndealHandleManager{
|
|||
//ftp解析失败文件存储路径
|
||||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||
final String filePath = spectrumServiceQuotes.getSpectrumPathProperties().getUndealPath();
|
||||
List<File> spectrumFiles = FileOperation.getFiles(rootPath+ filePath,taskProperties.getUndealDirReceiveNum());
|
||||
List<File> spectrumFiles = FileOperation.getFiles(rootPath+ filePath);
|
||||
if(!CollectionUtils.isEmpty(spectrumFiles)){
|
||||
CountDownLatch taskLatch = new CountDownLatch(spectrumFiles.size());
|
||||
for(File spectrumFile : spectrumFiles){
|
||||
|
@ -128,7 +128,7 @@ public class UndealHandleManager{
|
|||
long currentMillis = System.currentTimeMillis();
|
||||
long createMillis = currentMillis;
|
||||
//判断redis是否包含文件名称 key
|
||||
if (spectrumServiceQuotes.getRedisStreamUtil().hasKey(spectrumFile.getName())) {
|
||||
if (spectrumServiceQuotes.getRedisStreamUtil().hasKey(RedisConstant.UNDEAL_FILE + spectrumFile.getName())) {
|
||||
createMillis = (long) spectrumServiceQuotes.getRedisStreamUtil().get(RedisConstant.UNDEAL_FILE + spectrumFile.getName());
|
||||
} else {
|
||||
spectrumServiceQuotes.getRedisStreamUtil().set(RedisConstant.UNDEAL_FILE + spectrumFile.getName(), currentMillis);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package org.jeecg.modules.exception;
|
||||
|
||||
public class AnalySpectrumException extends AnalyseException {
|
||||
|
||||
public AnalySpectrumException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -69,6 +69,50 @@ public class FileOperation {
|
|||
return sortList.stream().limit(num).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定路径下指定数量的文件
|
||||
* @param path
|
||||
* @return
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public static List<File> getFiles(String path) throws FileNotFoundException {
|
||||
File file = new File(path);
|
||||
if (!file.exists()){
|
||||
throw new FileNotFoundException(path+" directory does not exist");
|
||||
}
|
||||
if (!file.isDirectory()){
|
||||
throw new FileNotFoundException(path+" file is not a directory");
|
||||
}
|
||||
if(FileUtil.isDirEmpty(file)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if(CollectionUtils.isEmpty(dataTypeMap)){
|
||||
final DataType[] dataTypes = DataType.values();
|
||||
for (DataType dataType : dataTypes){
|
||||
dataTypeMap.put(dataType.getSuffix(),"default");
|
||||
}
|
||||
}
|
||||
File[] spectrumFiles = file.listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
final String suffix = file.getName().substring(file.getName().lastIndexOf(StringConstant.DOT));
|
||||
if (dataTypeMap.containsKey(suffix)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
List<File> sortList = new ArrayList<>();
|
||||
for (File spectrumFile : spectrumFiles){
|
||||
if(spectrumFile.getName().contains(BlockConstant.sampleFlag)){
|
||||
sortList.add(spectrumFile);
|
||||
}else {
|
||||
sortList.add(0,spectrumFile);
|
||||
}
|
||||
}
|
||||
return sortList.stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存或追加写入文件
|
||||
* @param filePath
|
||||
|
|
|
@ -85,7 +85,7 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
|
|||
if(StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time)){
|
||||
gardsSampleData.setAcquisitionStart(DateUtils.parseDate(struct.acquisition_start_date+StringConstant.SPACE+struct.acquisition_start_time));
|
||||
}
|
||||
if(Objects.nonNull(gardsSampleData.getAcquisitionStart()) && struct.acquisition_real_time > 0){
|
||||
if(Objects.nonNull(gardsSampleData.getAcquisitionStart()) && struct.acquisition_real_time >= 0){
|
||||
Date acquisitionStop = new Date((long) (gardsSampleData.getAcquisitionStart().getTime()+(struct.acquisition_real_time*1000)));
|
||||
gardsSampleData.setAcquisitionStop(acquisitionStop);
|
||||
}
|
||||
|
|
|
@ -118,6 +118,10 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
|||
} else if (StringUtils.isNotBlank(sourceData.acquisition_start_time) && StringUtils.isNotBlank(sourceData.acquisition_start_date)) {
|
||||
DateUtils.parseDate(sourceData.acquisition_start_date + StringPool.SPACE + sourceData.acquisition_start_time);
|
||||
}
|
||||
|
||||
if (!Double.isFinite(sourceData.acquisition_live_time) || !Double.isFinite(sourceData.acquisition_real_time)) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//将文件移动到错误文件目录
|
||||
super.isDateFormatErr = true;
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.spectrum;
|
|||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
@ -16,6 +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;
|
||||
|
@ -80,15 +82,19 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
*/
|
||||
protected List<String> spectrumFileLabels = Lists.newArrayList();
|
||||
|
||||
protected Integer batchesCounter;
|
||||
|
||||
/**
|
||||
* 初始化参数
|
||||
*/
|
||||
public void init(String mailContent,String emlFileName,SpectrumServiceQuotes spectrumServiceQuotes,StringBuilder returnFileName,Integer spectrumSource) throws Exception{
|
||||
public void init(String mailContent, String emlFileName, SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
StringBuilder returnFileName, Integer spectrumSource, Integer batchesCounter) throws Exception{
|
||||
this.mailContent = mailContent;
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.returnFileName = returnFileName;
|
||||
this.spectrumSource = spectrumSource;
|
||||
this.emlFileName = emlFileName;
|
||||
this.batchesCounter = batchesCounter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +115,9 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
*/
|
||||
protected void initNext(SpectrumServiceQuotes spectrumServiceQuotes,File spectrumFile,
|
||||
String sourceFilePath,DataType currDataType,
|
||||
String mailContent,String emlFileName,Integer spectrumSource,StringBuilder returnFileName){
|
||||
String mailContent,String emlFileName,
|
||||
Integer spectrumSource,StringBuilder returnFileName,
|
||||
Integer batchesCounter){
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.spectrumFile = spectrumFile;
|
||||
this.sourceFilePath = sourceFilePath;
|
||||
|
@ -118,6 +126,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
this.emlFileName = emlFileName;
|
||||
this.spectrumSource = spectrumSource;
|
||||
this.returnFileName = returnFileName;
|
||||
this.batchesCounter = batchesCounter;
|
||||
this.setChina();
|
||||
}
|
||||
|
||||
|
@ -242,7 +251,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
e.printStackTrace();
|
||||
}finally {
|
||||
if(SpectrumSource.FORM_EMAIL_SERVICE.getSourceType().equals(spectrumSource)){
|
||||
EmailLogEvent event = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDBODY,
|
||||
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDBODY,
|
||||
Objects.isNull(this.spectrumFile)?" ":this.spectrumFile.getAbsolutePath());
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
|
||||
}
|
||||
|
@ -260,7 +269,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
protected void handleParseingFailFile(Exception e) throws FileNotFoundException {
|
||||
if(!SpectrumSource.FORM_FILE_UNDEL.getSourceType().equals(spectrumSource) && !(e instanceof FileRepeatException)){
|
||||
try {
|
||||
if (isDateFormatErr) {
|
||||
if (isDateFormatErr || (e instanceof AnalySpectrumException)) {
|
||||
//修改能谱文件名称
|
||||
this.updateErrorSpectrumFileName();
|
||||
//解析失败会把文件移动到errorfile目录
|
||||
|
@ -308,6 +317,20 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
|||
}
|
||||
} else if(SpectrumSource.FROM_FILE_SOURCE.getSourceType().equals(spectrumSource) && (e instanceof FileRepeatException)){
|
||||
this.spectrumFile.delete();
|
||||
} else if (SpectrumSource.FORM_FILE_UNDEL.getSourceType().equals(spectrumSource) && !(e instanceof FileRepeatException)) {
|
||||
try {
|
||||
if (isDateFormatErr) {
|
||||
//修改能谱文件名称
|
||||
this.updateErrorSpectrumFileName();
|
||||
//解析失败会把文件移动到errorfile目录
|
||||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||
final String errorFilePath = spectrumServiceQuotes.getSpectrumPathProperties().getErrorFilePath();
|
||||
final String finalPath = rootPath+errorFilePath;
|
||||
FileOperation.moveFile(spectrumFile,finalPath,true);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
|||
AbstractSpectrumHandler spectrumHandler = new HealthStatusSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class DetbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
AbstractSpectrumHandler spectrumHandler = new QcphdSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
AbstractSpectrumHandler spectrumHandler = new MetSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -48,12 +48,6 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
|||
*/
|
||||
@Override
|
||||
protected void setChina() {
|
||||
AbstractSpectrumHandler spectrumHandler = new GPSSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
|||
AbstractSpectrumHandler spectrumHandler = new AlertSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
AbstractSpectrumHandler spectrumHandler = new GasbkphdSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
|||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.entity.vo.*;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.exception.AnalySpectrumException;
|
||||
import org.jeecg.modules.exception.GAnalyseException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||
|
@ -130,7 +131,7 @@ public class Sample_G_Analysis {
|
|||
sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH))+1);
|
||||
}
|
||||
|
||||
public void analysis() throws GAnalyseException{
|
||||
public void analysis() throws GAnalyseException, AnalySpectrumException{
|
||||
log.info("Gamma自动处理分析--Start");
|
||||
PHDFile phdFile = new PHDFile();
|
||||
try {
|
||||
|
@ -174,8 +175,9 @@ public class Sample_G_Analysis {
|
|||
//读取参数内容
|
||||
readMDCParameter(phdFile);
|
||||
// 执行分析业务代码
|
||||
gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, MiddleDataType.Auto.getType(), "");
|
||||
boolean analyFlag = gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, MiddleDataType.Auto.getType(), "");
|
||||
|
||||
if (analyFlag) {
|
||||
// 数据插入数据库
|
||||
this.storageDataToDatabase(phdFile, middleData, phdFile.getQcItems());
|
||||
|
||||
|
@ -193,11 +195,17 @@ public class Sample_G_Analysis {
|
|||
//发送数据到redis
|
||||
middleData.setSample_id(String.valueOf(sampleId));
|
||||
pushToRedis(middleData);
|
||||
} else {
|
||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), phdFile.getAnalyMessage(), this.sampleFilename));
|
||||
throw new AnalySpectrumException(phdFile.getAnalyMessage());
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("Sample_G_Analysis", e);
|
||||
if (e instanceof DuplicateKeyException) {
|
||||
throw new GAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"), true);
|
||||
} else if (e instanceof AnalySpectrumException) {
|
||||
throw new AnalySpectrumException(e.getMessage());
|
||||
} else {
|
||||
throw new GAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.jeecg.modules.base.enums.SystemType;
|
|||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
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.GAnalyseException;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
|
@ -28,7 +29,7 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
|
|||
AbstractSpectrumHandler spectrumHandler = new DetbkphdSpectrum();
|
||||
spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile,super.sourceFilePath,
|
||||
super.currDataType,super.mailContent,super.emlFileName,
|
||||
super.spectrumSource,super.returnFileName);
|
||||
super.spectrumSource,super.returnFileName,super.batchesCounter);
|
||||
spectrumHandler.setPrevious(this);
|
||||
super.setNext(spectrumHandler);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.RedisConstant;
|
||||
|
@ -8,12 +11,19 @@ import org.jeecg.common.constant.StringConstant;
|
|||
import org.jeecg.common.email.EmailLogEvent;
|
||||
import org.jeecg.common.email.EmailLogManager;
|
||||
import org.jeecg.common.email.EmailServiceManager;
|
||||
import org.jeecg.common.exception.DownloadEmailException;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.email.EmailProperties;
|
||||
import org.jeecg.modules.enums.SpectrumSource;
|
||||
import org.jeecg.modules.exception.AnalySpectrumException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
|
@ -53,6 +63,8 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
* 邮件计数器
|
||||
*/
|
||||
private EmailCounter emailCounter;
|
||||
|
||||
private Integer batchesCounter;
|
||||
/**
|
||||
* 一天秒数
|
||||
*/
|
||||
|
@ -60,32 +72,38 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
|
||||
public void init(Message message, EmailProperties emailProperties,EmailServiceManager emailServiceManager,
|
||||
CountDownLatch taskLatch, SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
EmailCounter emailCounter){
|
||||
EmailCounter emailCounter,Integer batchesCounter){
|
||||
this.message = message;
|
||||
this.emailProperties = emailProperties;
|
||||
this.emailServiceManager = emailServiceManager;
|
||||
this.taskLatch = taskLatch;
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
this.emailCounter = emailCounter;
|
||||
this.batchesCounter = batchesCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String subject = null;
|
||||
boolean downloadFlag = false;
|
||||
String receiveDate = null;
|
||||
try {
|
||||
//获取邮件主题
|
||||
subject = emailServiceManager.getMailSubject(message);
|
||||
subject = emailServiceManager.getMailSubject(message,this.batchesCounter);
|
||||
|
||||
//解析之前先把邮件唯一信息存储到redis
|
||||
String messageId = ((MimeMessage) message).getMessageID();
|
||||
String emlName = subject+ StringConstant.UNDER_LINE+ DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss");
|
||||
receiveDate = DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss");
|
||||
String emlName = subject+ StringConstant.UNDER_LINE+ receiveDate;
|
||||
String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;
|
||||
spectrumServiceQuotes.getRedisUtil().set(key,emlName,expiryTime);
|
||||
//线程开始初始化时,初始本线程负责的能谱日志事件
|
||||
SpectrumLogManager.mailSpectrumLogManager.offer(Thread.currentThread().getId(),null);
|
||||
|
||||
//所有邮件都需以.eml格式存储到eml文件夹中
|
||||
final File emlFile = emailServiceManager.downloadEmailToEmlDir(message, emailCounter.getCurrValue());
|
||||
final File emlFile = emailServiceManager.downloadEmailToEmlDir(message, emailCounter.getCurrValue(),this.batchesCounter);
|
||||
downloadFlag = true;
|
||||
|
||||
//保存邮件日志到PG数据库
|
||||
this.spectrumServiceQuotes.getMailLogService().create(message,emailProperties);
|
||||
|
||||
|
@ -96,24 +114,51 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
}
|
||||
|
||||
//判断是否是IMS2.0协议文件
|
||||
// 如果邮件内容校验成功 将文件保存到eml目录 并删除邮件对象
|
||||
if(checkMailContent(mailContent,subject)){
|
||||
AbstractSpectrumHandler spectrumHandler = new SamplephdSpectrum();
|
||||
spectrumHandler.init(mailContent.toString(),emlFile.getName(),spectrumServiceQuotes,new StringBuilder(),SpectrumSource.FORM_EMAIL_SERVICE.getSourceType());
|
||||
spectrumHandler.init(mailContent.toString(),emlFile.getName(),spectrumServiceQuotes,new StringBuilder(),SpectrumSource.FORM_EMAIL_SERVICE.getSourceType(),batchesCounter);
|
||||
final boolean matchResult = spectrumHandler.saveEmailToLocal();
|
||||
if(matchResult){
|
||||
try {
|
||||
//开始解析
|
||||
spectrumHandler.handler();
|
||||
} catch (Exception e) {
|
||||
//如果是gamma谱的分析异常
|
||||
if (e instanceof AnalySpectrumException) {
|
||||
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
|
||||
if (Objects.nonNull(emlFile) && emlFile.exists()){
|
||||
moveEmail(emlFile, key);
|
||||
}
|
||||
//删除邮件
|
||||
emailServiceManager.removeMail(message,batchesCounter);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
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 {
|
||||
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
|
||||
if (Objects.nonNull(emlFile) && emlFile.exists()){
|
||||
moveEmail(emlFile, key);
|
||||
throw new DownloadEmailException("邮件移走后手动抛出DownloadEmailException");
|
||||
}
|
||||
}
|
||||
emailServiceManager.removeMail(message);
|
||||
} catch (Exception e) {
|
||||
emailServiceManager.removeMail(message);
|
||||
e.printStackTrace();
|
||||
// 如果不是下载导致的失败 并且 下载成功,则删除下载的邮件对象
|
||||
if(!(e instanceof DownloadEmailException) && downloadFlag){
|
||||
log.error("Catch Remove Email:"+ subject + StringPool.UNDERSCORE + receiveDate + StringPool.UNDERSCORE);
|
||||
emailServiceManager.removeMail(message,batchesCounter);
|
||||
}
|
||||
//输出异常信息
|
||||
log.error("邮件处理异常{},邮件主题:{}:", e, subject);
|
||||
}finally {
|
||||
try {
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,EmailLogManager.DONE);
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(this.batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,EmailLogManager.DONE);
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),expungeEvent);
|
||||
|
||||
EmailLogManager.getInstance().writeLog(Thread.currentThread().getId());
|
||||
|
@ -153,4 +198,13 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
return false;
|
||||
}
|
||||
|
||||
private void moveEmail(File emlFile, String key) throws IOException {
|
||||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||
final String emlErrorPath = spectrumServiceQuotes.getSpectrumPathProperties().getEmlErrorPath();
|
||||
final String finalPath = rootPath+emlErrorPath;
|
||||
FileOperation.moveFile(emlFile,finalPath,true);
|
||||
// 删除 key,防止下次线程执行删除邮件
|
||||
spectrumServiceQuotes.getRedisUtil().del(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,11 +85,11 @@ public class SpectrumServiceQuotes {
|
|||
private final RedisUtil redisUtil;
|
||||
|
||||
private final MaximumPoolSizeProperties maximumPoolSizeProperties;
|
||||
|
||||
private final IGardsGPSDataService gardsGPSDataService;
|
||||
/**
|
||||
* 原始库插入数据锁
|
||||
*/
|
||||
private final Object originalLibraryLock = new Object();
|
||||
|
||||
private final BatchesCounter batchesCounter;
|
||||
|
||||
}
|
||||
|
|
|
@ -1335,6 +1335,11 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
}
|
||||
String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, phd.getTmpFilePath(), analysisProcess);
|
||||
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
|
||||
boolean analyFlag = JSON.parseObject(JSON.toJSONString(parseMap.get("analyFlag")), Boolean.class);
|
||||
phd.setAnalyFlag(analyFlag);
|
||||
String analyMessage = JSON.parseObject(JSON.toJSONString(parseMap.get("analyMessage")), String.class);
|
||||
phd.setAnalyMessage(analyMessage);
|
||||
if (analyFlag) {
|
||||
for (Map.Entry<String, Object> entry:parseMap.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase("bAnalyed")) {
|
||||
boolean value = JSON.parseObject(JSON.toJSONString(entry.getValue()), Boolean.class);
|
||||
|
@ -1521,6 +1526,10 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
peak.recoilDeltaChan = "nan";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.error("AnalyseSpectrum(): {}", analyMessage);
|
||||
return false;
|
||||
}
|
||||
} catch (JsonProcessingException e){
|
||||
e.printStackTrace();
|
||||
log.error("AnalyseSpectrum(): {}", e.getMessage());
|
||||
|
@ -3206,6 +3215,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
String anylseEnd;
|
||||
anylseBegin = DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss");
|
||||
bRet = AnalyseSpectrum(fileAnlyse,nucline);
|
||||
if (bRet) {
|
||||
RunQC(fileAnlyse);
|
||||
fileAnlyse.setEfficiencyParam(fileAnlyse.getUsedEffiPara().getP());
|
||||
fileAnlyse.setEfficiencyEnergy(fileAnlyse.getUsedEffiKD().getG_energy());
|
||||
|
@ -3216,6 +3226,9 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
anylseEnd = DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss");
|
||||
middleData.analyses_analysisBegin = anylseBegin;
|
||||
middleData.analyses_analysisEnd = anylseEnd;
|
||||
} else {
|
||||
return bRet;
|
||||
}
|
||||
} else if (type.equals(MiddleDataType.InterAction.getType()) && flag.equalsIgnoreCase("save")){ //如果是人工交互分析 则先上传phd对应文件信息
|
||||
//上传本次文件到ftp人工交互存储路径下
|
||||
File sampleTmp = null;
|
||||
|
@ -4359,6 +4372,17 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
return ftpUtil.downloadFile(fromPath, "betaGamma");
|
||||
}
|
||||
|
||||
public List<String> readLine(String filePath) {
|
||||
List<String> allLines = new ArrayList<>();
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
return FileUtils.readLines(file, "UTF-8");
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
return allLines;
|
||||
}
|
||||
}
|
||||
|
||||
public String makeUpSpectrum(PHDFile phd) {
|
||||
StringBuilder spectrum = new StringBuilder();
|
||||
//PHD文本内容头部部分
|
||||
|
|
|
@ -6,6 +6,7 @@ import cn.hutool.core.map.MapUtil;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -21,6 +22,7 @@ import org.jeecg.modules.service.IGardsNuclLinesLibService;
|
|||
import org.jeecg.modules.service.ISysDefaultNuclideService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
|
@ -58,6 +60,7 @@ public class SysDefaultNuclideServiceImpl extends ServiceImpl<SysDefaultNuclideM
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result<?> add(List<String> nuclideNames, String nuclideType, Integer useType) {
|
||||
if (CollUtil.isEmpty(nuclideNames))
|
||||
return Result.error(Prompt.PARAM_NOT_EMPTY);
|
||||
|
@ -65,6 +68,10 @@ public class SysDefaultNuclideServiceImpl extends ServiceImpl<SysDefaultNuclideM
|
|||
return Result.error("nuclideType" + Prompt.PARAM_REQUIRED);
|
||||
if (ObjectUtil.isNull(useType))
|
||||
return Result.error("useType" + Prompt.PARAM_REQUIRED);
|
||||
LambdaUpdateWrapper<SysDefaultNuclide> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.eq(SysDefaultNuclide::getNuclideType, nuclideType);
|
||||
wrapper.eq(SysDefaultNuclide::getUseType, useType);
|
||||
this.remove(wrapper);
|
||||
List<SysDefaultNuclide> SysDefaultNuclides = new ArrayList<>();
|
||||
for (String nuclideName : nuclideNames) {
|
||||
SysDefaultNuclide sysDefaultNuclide = new SysDefaultNuclide();
|
||||
|
@ -73,7 +80,7 @@ public class SysDefaultNuclideServiceImpl extends ServiceImpl<SysDefaultNuclideM
|
|||
sysDefaultNuclide.setUseType(useType);
|
||||
SysDefaultNuclides.add(sysDefaultNuclide);
|
||||
}
|
||||
boolean success = saveBatch(SysDefaultNuclides);
|
||||
boolean success = this.saveBatch(SysDefaultNuclides);
|
||||
if (success)
|
||||
return Result.OK(Prompt.ADD_SUCC);
|
||||
return Result.error(Prompt.ADD_ERR);
|
||||
|
@ -128,4 +135,19 @@ public class SysDefaultNuclideServiceImpl extends ServiceImpl<SysDefaultNuclideM
|
|||
redisUtil.set(key,mapLines);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> newList = ListUtil.toList("A", "F");
|
||||
List<String> oldList = ListUtil.toList("A", "B", "C");
|
||||
Collection<String> intersection = CollUtil.intersection(newList, oldList);
|
||||
newList = newList.stream()
|
||||
.filter(item -> !CollUtil.contains(intersection, item))
|
||||
.collect(Collectors.toList());
|
||||
System.out.println("add: " + newList);
|
||||
|
||||
oldList = oldList.stream()
|
||||
.filter(item -> !CollUtil.contains(intersection, item))
|
||||
.collect(Collectors.toList());
|
||||
System.out.println("del: " + oldList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONArray;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -15,7 +13,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.net.ftp.FTP;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.aspect.annotation.PermissionData;
|
||||
|
@ -55,13 +52,15 @@ public class JeecgDemoController extends JeecgController<JeecgDemo, IJeecgDemoSe
|
|||
//声明FTP客户端
|
||||
FTPClient ftpClient = new FTPClient();
|
||||
//连接
|
||||
ftpClient.connect("127.0.0.1", 21);
|
||||
ftpClient.connect("172.21.70.87", 21);
|
||||
//登录
|
||||
ftpClient.login("rmsops", "cnndc010");
|
||||
ftpClient.login("rmsops", "cnndc66367220");
|
||||
//判断ftp是否连接成功
|
||||
if (Objects.isNull(ftpClient)){
|
||||
throw new RuntimeException("ftp connection failed!");
|
||||
}
|
||||
InputStream iStream= null;
|
||||
File file = null;
|
||||
try {
|
||||
//被动模式
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
|
@ -70,9 +69,10 @@ public class JeecgDemoController extends JeecgController<JeecgDemo, IJeecgDemoSe
|
|||
//
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
List<String> files = new LinkedList<>();
|
||||
readFiles(ftpClient, ftpClient.printWorkingDirectory()+ StringPool.SLASH + "savefile", files);
|
||||
System.out.println("文件数量:"+files.size());
|
||||
System.out.println(ftpClient.printWorkingDirectory());
|
||||
//读取ftp文件的输入流
|
||||
iStream=ftpClient.retrieveFileStream("/savefile/Spectrum/Xenon/Sauna/Samplephd/2023/10/SEX63_007-20231026_0452_S_FULL_22495.8.PHD");
|
||||
System.out.println(Objects.isNull(iStream));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -80,31 +80,17 @@ public class JeecgDemoController extends JeecgController<JeecgDemo, IJeecgDemoSe
|
|||
if (Objects.nonNull(ftpClient)){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void readFiles(FTPClient ftpClient, String parentFilePath, List<String> files) {
|
||||
String oldPath = parentFilePath;
|
||||
try {
|
||||
ftpClient.changeWorkingDirectory(parentFilePath);
|
||||
FTPFile[] directories = ftpClient.listFiles(parentFilePath);
|
||||
if (Objects.nonNull(directories)) {
|
||||
for (FTPFile ftpFile:directories) {
|
||||
if (ftpFile.isDirectory()) {
|
||||
parentFilePath = oldPath + StringPool.SLASH + ftpFile.getName();
|
||||
readFiles(ftpClient, parentFilePath, files);
|
||||
} else if (ftpFile.isFile()) {
|
||||
files.add(ftpFile.getName());
|
||||
}
|
||||
if (Objects.nonNull(iStream)){
|
||||
iStream.close();
|
||||
}
|
||||
if (Objects.nonNull(file)) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -331,6 +331,338 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
|||
return map;
|
||||
}
|
||||
|
||||
public void updateBoundary(BetaDataFile betaDataFile, String type, List<GardsROIChannelsSpectrum> sampleRoiChannel, Map<String, Object> map) {
|
||||
List<Boundary> boundaryList = new LinkedList<>();
|
||||
for (int i=0; i<sampleRoiChannel.size(); i++){
|
||||
Boundary boundary = new Boundary();
|
||||
GardsROIChannelsSpectrum roiChannelsSpectrum = sampleRoiChannel.get(i);
|
||||
boundary.setMinX(roiChannelsSpectrum.getBChanStart());
|
||||
boundary.setMaxX(roiChannelsSpectrum.getBChanStop());
|
||||
boundary.setMinY(roiChannelsSpectrum.getGChanStart());
|
||||
boundary.setMaxY(roiChannelsSpectrum.getGChanStop());
|
||||
boundaryList.add(boundary);
|
||||
}
|
||||
map.put("Boundary", boundaryList);
|
||||
if (type.equalsIgnoreCase("sample")) {
|
||||
betaDataFile.setSampleBoundary(boundaryList);
|
||||
} else if (type.equalsIgnoreCase("gas")) {
|
||||
betaDataFile.setGasBoundary(boundaryList);
|
||||
} else if (type.equalsIgnoreCase("det")) {
|
||||
betaDataFile.setDetBoundary(boundaryList);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateEnergyData(BetaDataFile betaDataFile, String type, List<GardsCalibrationPairsSpectrum> gammaCalibrationPairs, List<GardsCalibrationPairsSpectrum> betaCalibrationPairs, Map<String, Object> map) {
|
||||
List<Double> channels = new LinkedList<>();
|
||||
List<List<Double>> gammaNewEnergyList = new LinkedList<>();
|
||||
List<List<Double>> betaNewEnergyList = new LinkedList<>();
|
||||
//填充道值数组的数据
|
||||
for (int i=0; i<255; i++) {
|
||||
channels.add(Double.valueOf(i));
|
||||
}
|
||||
//过滤出Gamma对应的表单数据
|
||||
List<Double> gammaChannelList = gammaCalibrationPairs.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList());
|
||||
List<Double> gammaEnergyList = gammaCalibrationPairs.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList());
|
||||
//计算gamma对应的数据
|
||||
List<Double> gammaFittingPara = EnergySpectrumHandler.GetFileFittingPara(gammaChannelList, gammaEnergyList);
|
||||
//计算道值的能量
|
||||
List<Double> gammaEnergys = EnergySpectrumHandler.GetFileFittingData(channels,gammaFittingPara);
|
||||
//将新计算的能量封装到数组
|
||||
for (Double calEnergy:gammaEnergys) {
|
||||
List<Double> newEnergy = new LinkedList<>();
|
||||
newEnergy.add(calEnergy);
|
||||
gammaNewEnergyList.add(newEnergy);
|
||||
}
|
||||
map.put("gammaEnergyData", gammaNewEnergyList);
|
||||
|
||||
//过滤出Beta对应的表单数据
|
||||
List<Double> betaChannelList = betaCalibrationPairs.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList());
|
||||
List<Double> betaEnergyList = betaCalibrationPairs.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList());
|
||||
//计算beta对应的数据
|
||||
List<Double> betaFittingPara = EnergySpectrumHandler.GetFileFittingPara(betaChannelList, betaEnergyList);
|
||||
|
||||
//计算道值的能量
|
||||
List<Double> betaEnergys = EnergySpectrumHandler.GetFileFittingData(channels,betaFittingPara);
|
||||
//将新计算的能量封装到数组
|
||||
for (Double calEnergy:betaEnergys) {
|
||||
List<Double> newEnergy = new LinkedList<>();
|
||||
newEnergy.add(calEnergy);
|
||||
betaNewEnergyList.add(newEnergy);
|
||||
}
|
||||
map.put("betaEnergyData", betaNewEnergyList);
|
||||
if (type.equalsIgnoreCase("sample")) {
|
||||
betaDataFile.setSampleGammaEnergyList(gammaNewEnergyList);
|
||||
betaDataFile.setSampleBetaEnergyList(betaNewEnergyList);
|
||||
} else if (type.equalsIgnoreCase("gas")) {
|
||||
betaDataFile.setGasGammaEnergyList(gammaNewEnergyList);
|
||||
betaDataFile.setGasBetaEnergyList(betaNewEnergyList);
|
||||
} else if (type.equalsIgnoreCase("det")) {
|
||||
betaDataFile.setDetGammaEnergyList(gammaNewEnergyList);
|
||||
betaDataFile.setDetBetaEnergyList(betaNewEnergyList);
|
||||
}
|
||||
}
|
||||
|
||||
public void createBgCalPara(BetaDataFile betaDataFile, List<GardsCalibrationSpectrum> gammaCalibrationSpectrumList,List<GardsCalibrationSpectrum> betaCalibrationSpectrumList,
|
||||
List<GardsCalibrationPairsSpectrum> gammaCalibrationPairsList,List<GardsCalibrationPairsSpectrum> betaCalibrationPairsList) {
|
||||
SpectrumGroup spectrum_group = new SpectrumGroup();
|
||||
//我需要根据 calibration页面对应的数组 及 公式判断是否有勾选sample det gas 这四个文件的操作
|
||||
//gammaCalibrationSpectrumList存储的是gamma对应的公式数据
|
||||
//betaCalibrationSpectrumList存储的是beta对应的公式数据
|
||||
//gammaCalibrationPairsList存储的是gamma对应的表单数据
|
||||
//betaCalibrationPairsList存储的是beta对应的表单数据
|
||||
//根据数据类型过滤出sample对应的参数
|
||||
if (CollectionUtils.isNotEmpty(gammaCalibrationSpectrumList) && CollectionUtils.isNotEmpty(betaCalibrationSpectrumList) && CollectionUtils.isNotEmpty(gammaCalibrationPairsList) && CollectionUtils.isNotEmpty(betaCalibrationPairsList)) {
|
||||
List<GardsCalibrationSpectrum> sampleGammaCalibrationList = gammaCalibrationSpectrumList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList());
|
||||
List<GardsCalibrationSpectrum> sampleBetaCalibrationList = betaCalibrationSpectrumList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList());
|
||||
List<GardsCalibrationPairsSpectrum> sampleGammaCalibrationPairsList = gammaCalibrationPairsList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList());
|
||||
List<GardsCalibrationPairsSpectrum> sampleBetaCalibrationPairsList = betaCalibrationPairsList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList());
|
||||
//过滤出sampleGamma对应的表单数据
|
||||
List<Double> gammaChannelList = sampleGammaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList());
|
||||
List<Double> gammaEnergyList = sampleGammaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList());
|
||||
//过滤出sampleBeta对应的表单数据
|
||||
List<Double> betaChannelList = sampleBetaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList());
|
||||
List<Double> betaEnergyList = sampleBetaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList());
|
||||
//获取文件中的表单数据
|
||||
EnergySpectrumStruct struct = betaDataFile.getSampleStruct();
|
||||
List<Double> gCentroidChannel = struct.g_centroid_channel;
|
||||
List<Double> gEnergy = struct.g_energy;
|
||||
List<Double> bChannel = struct.b_channel;
|
||||
List<Double> bElectronEnergy = struct.b_electron_energy;
|
||||
//比较四组表单数据
|
||||
if ( !gammaChannelList.equals(gCentroidChannel) || !gammaEnergyList.equals(gEnergy) ) {
|
||||
//将公式参数放入到重新计算的参数内
|
||||
List<Double> newFittingPara = EnergySpectrumHandler.GetFileFittingPara(gammaChannelList, gammaEnergyList);
|
||||
//计算E to C公式参数
|
||||
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(gammaEnergyList, gammaChannelList);
|
||||
List<Double> geCal = new LinkedList<>();
|
||||
geCal.add(Double.valueOf(newFittingParaToUi.get(0)));
|
||||
geCal.add(Double.valueOf(newFittingParaToUi.get(1)));
|
||||
geCal.add(Double.valueOf(newFittingParaToUi.get(2)));
|
||||
spectrum_group.BgCalPara.g_e_cal = geCal;
|
||||
//公式C TO E参数
|
||||
List<String> fittingPara = new LinkedList<>();
|
||||
fittingPara.add(String.valueOf(sampleGammaCalibrationList.get(0).getCoeff1()));
|
||||
fittingPara.add(String.valueOf(sampleGammaCalibrationList.get(0).getCoeff2()));
|
||||
fittingPara.add(String.valueOf(sampleGammaCalibrationList.get(0).getCoeff3()));
|
||||
|
||||
List<Double> gc2e = new LinkedList<>();
|
||||
gc2e.add(Double.valueOf(sampleGammaCalibrationList.get(0).getCoeff1()));
|
||||
gc2e.add(Double.valueOf(sampleGammaCalibrationList.get(0).getCoeff2()));
|
||||
gc2e.add(Double.valueOf(sampleGammaCalibrationList.get(0).getCoeff3()));
|
||||
spectrum_group.g_c2e = gc2e;
|
||||
//将新的道值对应能量值参数存储
|
||||
for (int i=0; i<gammaChannelList.size(); i++) {
|
||||
SeriseData seriseData = new SeriseData();
|
||||
seriseData.setX(gammaChannelList.get(i));
|
||||
seriseData.setY(gammaEnergyList.get(i));
|
||||
betaDataFile.getGammaList().add(seriseData);
|
||||
}
|
||||
//将sample的重新计算标识标为true
|
||||
spectrum_group.BgCalPara.bApplyNewCalicSample = true;
|
||||
betaDataFile.setBGammaEnergyValidSample(true);
|
||||
betaDataFile.setGammaFittingPara(fittingPara);
|
||||
}
|
||||
if ( !betaChannelList.equals(bChannel) || !betaEnergyList.equals(bElectronEnergy) ) {
|
||||
//将公式参数放入到重新计算的参数内
|
||||
//计算E to C公式参数
|
||||
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(betaEnergyList, betaChannelList);
|
||||
List<Double> beCal = new LinkedList<>();
|
||||
beCal.add(Double.valueOf(newFittingParaToUi.get(0)));
|
||||
beCal.add(Double.valueOf(newFittingParaToUi.get(1)));
|
||||
beCal.add(Double.valueOf(newFittingParaToUi.get(2)));
|
||||
spectrum_group.BgCalPara.b_e_cal = beCal;
|
||||
//公式C TO E参数
|
||||
List<String> fittingPara = new LinkedList<>();
|
||||
fittingPara.add(String.valueOf(sampleBetaCalibrationList.get(0).getCoeff1()));
|
||||
fittingPara.add(String.valueOf(sampleBetaCalibrationList.get(0).getCoeff2()));
|
||||
fittingPara.add(String.valueOf(sampleBetaCalibrationList.get(0).getCoeff3()));
|
||||
|
||||
List<Double> bc2e = new LinkedList<>();
|
||||
bc2e.add(Double.valueOf(sampleBetaCalibrationList.get(0).getCoeff1()));
|
||||
bc2e.add(Double.valueOf(sampleBetaCalibrationList.get(0).getCoeff2()));
|
||||
bc2e.add(Double.valueOf(sampleBetaCalibrationList.get(0).getCoeff3()));
|
||||
spectrum_group.b_c2e = bc2e;
|
||||
//将新的道值对应能量值参数存储
|
||||
for (int i=0; i<betaChannelList.size(); i++) {
|
||||
SeriseData seriseData = new SeriseData();
|
||||
seriseData.setX(betaChannelList.get(i));
|
||||
seriseData.setY(betaEnergyList.get(i));
|
||||
betaDataFile.getBetaList().add(seriseData);
|
||||
}
|
||||
//将sample的重新计算标识标为true
|
||||
spectrum_group.BgCalPara.bApplyNewCalicSample = true;
|
||||
betaDataFile.setBBetaEnergyValidSample(true);
|
||||
betaDataFile.setBetaFittingPara(fittingPara);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(gammaCalibrationSpectrumList) && CollectionUtils.isNotEmpty(betaCalibrationSpectrumList) && CollectionUtils.isNotEmpty(gammaCalibrationPairsList) && CollectionUtils.isNotEmpty(betaCalibrationPairsList)) {
|
||||
//根据数据类型过滤出gas对应的参数
|
||||
List<GardsCalibrationSpectrum> gasGammaCalibrationList = gammaCalibrationSpectrumList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList());
|
||||
List<GardsCalibrationSpectrum> gasBetaCalibrationList = betaCalibrationSpectrumList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList());
|
||||
List<GardsCalibrationPairsSpectrum> gasGammaCalibrationPairsList = gammaCalibrationPairsList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList());
|
||||
List<GardsCalibrationPairsSpectrum> gasBetaCalibrationPairsList = betaCalibrationPairsList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList());
|
||||
//过滤出gasGamma对应的表单数据
|
||||
List<Double> gammaChannelList = gasGammaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList());
|
||||
List<Double> gammaEnergyList = gasGammaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList());
|
||||
//过滤出gasBeta对应的表单数据
|
||||
List<Double> betaChannelList = gasBetaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList());
|
||||
List<Double> betaEnergyList = gasBetaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList());
|
||||
//获取文件中的表单数据
|
||||
EnergySpectrumStruct struct = betaDataFile.getGasStruct();
|
||||
List<Double> gCentroidChannel = struct.g_centroid_channel;
|
||||
List<Double> gEnergy = struct.g_energy;
|
||||
List<Double> bChannel = struct.b_channel;
|
||||
List<Double> bElectronEnergy = struct.b_electron_energy;
|
||||
//比较gamma部分表单数据
|
||||
if ( !gammaChannelList.equals(gCentroidChannel) || !gammaEnergyList.equals(gEnergy) ) {
|
||||
//将公式参数放入到重新计算的参数内
|
||||
//计算E to C公式参数
|
||||
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(gammaEnergyList, gammaChannelList);
|
||||
List<Double> geCal = new LinkedList<>();
|
||||
geCal.add(Double.valueOf(newFittingParaToUi.get(0)));
|
||||
geCal.add(Double.valueOf(newFittingParaToUi.get(1)));
|
||||
geCal.add(Double.valueOf(newFittingParaToUi.get(2)));
|
||||
spectrum_group.BgCalPara.g_e_cal = geCal;
|
||||
//公式C TO E参数
|
||||
List<String> fittingPara = new LinkedList<>();
|
||||
fittingPara.add(String.valueOf(gasGammaCalibrationList.get(0).getCoeff1()));
|
||||
fittingPara.add(String.valueOf(gasGammaCalibrationList.get(0).getCoeff2()));
|
||||
fittingPara.add(String.valueOf(gasGammaCalibrationList.get(0).getCoeff3()));
|
||||
|
||||
List<Double> gc2e = new LinkedList<>();
|
||||
gc2e.add(Double.valueOf(gasGammaCalibrationList.get(0).getCoeff1()));
|
||||
gc2e.add(Double.valueOf(gasGammaCalibrationList.get(0).getCoeff2()));
|
||||
gc2e.add(Double.valueOf(gasGammaCalibrationList.get(0).getCoeff3()));
|
||||
spectrum_group.g_c2e = gc2e;
|
||||
//将新的道值对应能量值参数存储
|
||||
for (int i=0; i<gammaChannelList.size(); i++) {
|
||||
SeriseData seriseData = new SeriseData();
|
||||
seriseData.setX(gammaChannelList.get(i));
|
||||
seriseData.setY(gammaEnergyList.get(i));
|
||||
betaDataFile.getGammaList().add(seriseData);
|
||||
}
|
||||
spectrum_group.BgCalPara.bApplyNewCalicGasBg = true;
|
||||
betaDataFile.setBGammaEnergyValidGas(true);
|
||||
betaDataFile.setGammaFittingPara(fittingPara);
|
||||
}
|
||||
//比较beta部分表单数据
|
||||
if ( !betaChannelList.equals(bChannel) || !betaEnergyList.equals(bElectronEnergy) ) {
|
||||
//计算E to C公式参数
|
||||
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(betaEnergyList, betaChannelList);
|
||||
List<Double> beCal = new LinkedList<>();
|
||||
beCal.add(Double.valueOf(newFittingParaToUi.get(0)));
|
||||
beCal.add(Double.valueOf(newFittingParaToUi.get(1)));
|
||||
beCal.add(Double.valueOf(newFittingParaToUi.get(2)));
|
||||
spectrum_group.BgCalPara.b_e_cal = beCal;
|
||||
//公式C TO E参数
|
||||
List<String> fittingPara = new LinkedList<>();
|
||||
fittingPara.add(String.valueOf(gasBetaCalibrationList.get(0).getCoeff1()));
|
||||
fittingPara.add(String.valueOf(gasBetaCalibrationList.get(0).getCoeff2()));
|
||||
fittingPara.add(String.valueOf(gasBetaCalibrationList.get(0).getCoeff3()));
|
||||
|
||||
List<Double> bc2e = new LinkedList<>();
|
||||
bc2e.add(Double.valueOf(gasBetaCalibrationList.get(0).getCoeff1()));
|
||||
bc2e.add(Double.valueOf(gasBetaCalibrationList.get(0).getCoeff2()));
|
||||
bc2e.add(Double.valueOf(gasBetaCalibrationList.get(0).getCoeff3()));
|
||||
spectrum_group.b_c2e = bc2e;
|
||||
//将新的道值对应能量值参数存储
|
||||
for (int i=0; i<betaChannelList.size(); i++) {
|
||||
SeriseData seriseData = new SeriseData();
|
||||
seriseData.setX(betaChannelList.get(i));
|
||||
seriseData.setY(betaEnergyList.get(i));
|
||||
betaDataFile.getBetaList().add(seriseData);
|
||||
}
|
||||
spectrum_group.BgCalPara.bApplyNewCalicGasBg = true;
|
||||
betaDataFile.setBBetaEnergyValidGas(true);
|
||||
betaDataFile.setBetaFittingPara(fittingPara);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(gammaCalibrationSpectrumList) && CollectionUtils.isNotEmpty(betaCalibrationSpectrumList) && CollectionUtils.isNotEmpty(gammaCalibrationPairsList) && CollectionUtils.isNotEmpty(betaCalibrationPairsList)) {
|
||||
//根据参数类型过滤出det对应的参数
|
||||
List<GardsCalibrationSpectrum> detGammaCalibrationList = gammaCalibrationSpectrumList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList());
|
||||
List<GardsCalibrationSpectrum> detBetaCalibrationList = betaCalibrationSpectrumList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList());
|
||||
List<GardsCalibrationPairsSpectrum> detGammaCalibrationPairsList = gammaCalibrationPairsList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList());
|
||||
List<GardsCalibrationPairsSpectrum> detBetaCalibrationPairsList = betaCalibrationPairsList.stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList());
|
||||
//过滤出gasGamma对应的表单数据
|
||||
List<Double> gammaChannelList = detGammaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList());
|
||||
List<Double> gammaEnergyList = detGammaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList());
|
||||
//过滤出gasBeta对应的表单数据
|
||||
List<Double> betaChannelList = detBetaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList());
|
||||
List<Double> betaEnergyList = detBetaCalibrationPairsList.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList());
|
||||
//获取文件中的表单数据
|
||||
EnergySpectrumStruct struct = betaDataFile.getDetStruct();
|
||||
List<Double> gCentroidChannel = struct.g_centroid_channel;
|
||||
List<Double> gEnergy = struct.g_energy;
|
||||
List<Double> bChannel = struct.b_channel;
|
||||
List<Double> bElectronEnergy = struct.b_electron_energy;
|
||||
//比较四组表单数据
|
||||
if ( !gammaChannelList.equals(gCentroidChannel) || !gammaEnergyList.equals(gEnergy) ) {
|
||||
//计算E to C公式参数
|
||||
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(gammaEnergyList, gammaChannelList);
|
||||
List<Double> geCal = new LinkedList<>();
|
||||
geCal.add(Double.valueOf(newFittingParaToUi.get(0)));
|
||||
geCal.add(Double.valueOf(newFittingParaToUi.get(1)));
|
||||
geCal.add(Double.valueOf(newFittingParaToUi.get(2)));
|
||||
spectrum_group.BgCalPara.g_e_cal = geCal;
|
||||
//公式C TO E参数
|
||||
List<String> fittingPara = new LinkedList<>();
|
||||
fittingPara.add(String.valueOf(detGammaCalibrationList.get(0).getCoeff1()));
|
||||
fittingPara.add(String.valueOf(detGammaCalibrationList.get(0).getCoeff2()));
|
||||
fittingPara.add(String.valueOf(detGammaCalibrationList.get(0).getCoeff3()));
|
||||
|
||||
List<Double> gc2e = new LinkedList<>();
|
||||
gc2e.add(Double.valueOf(detGammaCalibrationList.get(0).getCoeff1()));
|
||||
gc2e.add(Double.valueOf(detGammaCalibrationList.get(0).getCoeff2()));
|
||||
gc2e.add(Double.valueOf(detGammaCalibrationList.get(0).getCoeff3()));
|
||||
spectrum_group.g_c2e = gc2e;
|
||||
//将新的道值对应能量值参数存储
|
||||
for (int i=0; i<gammaChannelList.size(); i++) {
|
||||
SeriseData seriseData = new SeriseData();
|
||||
seriseData.setX(gammaChannelList.get(i));
|
||||
seriseData.setY(gammaEnergyList.get(i));
|
||||
betaDataFile.getGammaList().add(seriseData);
|
||||
}
|
||||
spectrum_group.BgCalPara.bApplyNewCalicDetBg = true;
|
||||
betaDataFile.setBGammaEnergyValidDet(true);
|
||||
betaDataFile.setGammaFittingPara(fittingPara);
|
||||
}
|
||||
if ( !betaChannelList.equals(bChannel) || !betaEnergyList.equals(bElectronEnergy) ) {
|
||||
//计算E to C公式参数
|
||||
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(betaEnergyList, betaChannelList);
|
||||
//将公式参数放入到重新计算的参数内
|
||||
List<Double> beCal = new LinkedList<>();
|
||||
beCal.add(Double.valueOf(newFittingParaToUi.get(0)));
|
||||
beCal.add(Double.valueOf(newFittingParaToUi.get(1)));
|
||||
beCal.add(Double.valueOf(newFittingParaToUi.get(2)));
|
||||
spectrum_group.BgCalPara.b_e_cal = beCal;
|
||||
//公式C TO E参数
|
||||
List<String> fittingPara = new LinkedList<>();
|
||||
fittingPara.add(String.valueOf(detBetaCalibrationList.get(0).getCoeff1()));
|
||||
fittingPara.add(String.valueOf(detBetaCalibrationList.get(0).getCoeff2()));
|
||||
fittingPara.add(String.valueOf(detBetaCalibrationList.get(0).getCoeff3()));
|
||||
|
||||
List<Double> bc2e = new LinkedList<>();
|
||||
bc2e.add(Double.valueOf(detBetaCalibrationList.get(0).getCoeff1()));
|
||||
bc2e.add(Double.valueOf(detBetaCalibrationList.get(0).getCoeff2()));
|
||||
bc2e.add(Double.valueOf(detBetaCalibrationList.get(0).getCoeff3()));
|
||||
spectrum_group.b_c2e = bc2e;
|
||||
//将新的道值对应能量值参数存储
|
||||
for (int i=0; i<betaChannelList.size(); i++) {
|
||||
SeriseData seriseData = new SeriseData();
|
||||
seriseData.setX(betaChannelList.get(i));
|
||||
seriseData.setY(betaEnergyList.get(i));
|
||||
betaDataFile.getBetaList().add(seriseData);
|
||||
}
|
||||
spectrum_group.BgCalPara.bApplyNewCalicDetBg = true;
|
||||
betaDataFile.setBBetaEnergyValidDet(true);
|
||||
betaDataFile.setBetaFittingPara(fittingPara);
|
||||
}
|
||||
}
|
||||
if (spectrum_group.BgCalPara.bApplyNewCalicSample || spectrum_group.BgCalPara.bApplyNewCalicGasBg || spectrum_group.BgCalPara.bApplyNewCalicDetBg) {
|
||||
betaDataFile.setBgPara(spectrum_group.BgCalPara);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> readLine(String filePath) {
|
||||
List<String> allLines = new ArrayList<>();
|
||||
try {
|
||||
|
@ -676,6 +1008,7 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
|||
}
|
||||
map.put("DetBoundary", boundaryList);
|
||||
}
|
||||
map.put("message", analyseResult.error_log);
|
||||
bRet = false;
|
||||
return bRet;
|
||||
} else {
|
||||
|
@ -762,6 +1095,7 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
|||
}
|
||||
map.put("DetBoundary", boundaryList);
|
||||
}
|
||||
map.put("message", "analyse Success.");
|
||||
return bRet;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,21 +29,23 @@ public class GammaController {
|
|||
|
||||
@GetMapping("initValue")
|
||||
@ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据")
|
||||
public Result initValue(Integer sampleId, String dbName, String analyst, String fileName, HttpServletRequest request) {
|
||||
return gammaService.initValue(sampleId, dbName, analyst, fileName, request);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("testFun")
|
||||
public Result testFun(String fileName,HttpServletRequest request){
|
||||
return gammaService.testFun(fileName, request);
|
||||
public void initValue(Integer sampleId, String dbName, String analyst, String fileName, HttpServletRequest request) {
|
||||
gammaService.initValue(sampleId, dbName, analyst, fileName, request);
|
||||
}
|
||||
|
||||
@GetMapping("gammaByDB")
|
||||
@ApiOperation(value = "gamma页面loadFromDB加载数据", notes = "gamma页面loadFromDB加载数据")
|
||||
public Result gammaByDB(Integer sampleId, String dbName, String analyst, HttpServletRequest request){
|
||||
return gammaService.gammaByDB(dbName, sampleId, analyst, request);
|
||||
}
|
||||
|
||||
@GetMapping("gammaByDBApp")
|
||||
@ApiOperation(value = "gamma页面loadFromDB加载数据", notes = "gamma页面loadFromDB加载数据")
|
||||
public Result gammaByDBApp(@RequestParam("sampleId") Integer sampleId,@RequestParam("dbName") String dbName,
|
||||
@RequestParam("analyst") String analyst, HttpServletRequest request){
|
||||
return gammaService.gammaByDB(dbName, sampleId, analyst, request);
|
||||
}
|
||||
|
||||
@GetMapping("gammaByFile")
|
||||
@ApiOperation(value = "gamma页面loadFromFile加载数据", notes = "gamma页面loadFromFile加载数据")
|
||||
public Result gammaByFile(String fileName, HttpServletRequest request) {
|
||||
|
@ -56,6 +58,12 @@ public class GammaController {
|
|||
gammaService.delPHDCache(fileName);
|
||||
}
|
||||
|
||||
@DeleteMapping("delPHDCacheApp")
|
||||
@ApiOperation(value = "删除PHD文件缓存", notes = "删除PHD文件缓存")
|
||||
public void delPHDCacheApp(@RequestParam String fileName) {
|
||||
gammaService.delPHDCache(fileName);
|
||||
}
|
||||
|
||||
@GetMapping("loadSampleData")
|
||||
public Result loadSampleData(QueryRequest queryRequest, GardsSampleDataSpectrum gardsSampleData, String[] menuTypes, boolean AllUsers, boolean CollectStopB, boolean AcqStartB,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate, HttpServletRequest request) {
|
||||
|
@ -135,6 +143,14 @@ public class GammaController {
|
|||
return gammaService.getGammaSelPosNuclide(sampleId, fileName, channel, energy, request);
|
||||
}
|
||||
|
||||
@GetMapping("getGammaSelPosNuclideApp")
|
||||
@ApiOperation(value = "gamma主页面选择channel加载对应核素信息接口", notes = "gamma主页面选择channel加载对应核素信息接口")
|
||||
public Result getGammaSelPosNuclideApp(@RequestParam("sampleId") Integer sampleId,@RequestParam("fileName") String fileName,
|
||||
@RequestParam("channel") int channel,@RequestParam("energy") double energy,
|
||||
HttpServletRequest request) {
|
||||
return gammaService.getGammaSelPosNuclide(sampleId, fileName, channel, energy, request);
|
||||
}
|
||||
|
||||
@GetMapping("getSelPosNuclide")
|
||||
@ApiOperation(value = "InteractiveTool页面选择channel加载对应核素信息接口", notes = "InteractiveTool页面选择channel加载对应核素信息接口")
|
||||
public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request) {
|
||||
|
@ -401,6 +417,13 @@ public class GammaController {
|
|||
return gammaService.peakInformation(sampleId, fileName, request);
|
||||
}
|
||||
|
||||
@GetMapping("peakInformationApp")
|
||||
@ApiOperation(value = "查看Peak Information页面数据", notes = "查看Peak Information页面数据")
|
||||
public Result<?> peakInformationApp(@RequestParam("sampleId") Integer sampleId,@RequestParam("fileName") String fileName,
|
||||
HttpServletRequest request){
|
||||
return gammaService.peakInformation(sampleId, fileName, request);
|
||||
}
|
||||
|
||||
@GetMapping("exportPeakInformation")
|
||||
public void exportPeakInformation(Integer sampleId, String fileName, HttpServletRequest request, HttpServletResponse response){
|
||||
gammaService.exportPeakInformation(sampleId, fileName, request, response);
|
||||
|
@ -434,6 +457,14 @@ public class GammaController {
|
|||
return gammaService.radionuclideActivity(sampleId, fileName, request);
|
||||
}
|
||||
|
||||
@GetMapping("radionuclideActivityApp")
|
||||
@ApiOperation(value = "查看Radionuclide Activity页面数据", notes = "查看Radionuclide Activity页面数据")
|
||||
public Result radionuclideActivityApp(@RequestParam("sampleId") Integer sampleId,
|
||||
@RequestParam("fileName") String fileName,
|
||||
HttpServletRequest request) {
|
||||
return gammaService.radionuclideActivity(sampleId, fileName, request);
|
||||
}
|
||||
|
||||
@GetMapping("exportRadionuclideActivity")
|
||||
public void exportRadionuclideActivity(Integer sampleId, String fileName,
|
||||
String arTime, String crTime,
|
||||
|
|
|
@ -26,8 +26,8 @@ public class SpectrumAnalysesController {
|
|||
|
||||
@GetMapping("initValue")
|
||||
@ApiOperation(value = "初始化数据", notes = "初始化数据")
|
||||
public Result initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) {
|
||||
return spectrumAnalysisService.initValue(dbName, sampleId, analyst, sampleFileName, gasFileName, detFileName, qcFileName, request);
|
||||
public void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) {
|
||||
spectrumAnalysisService.initValue(dbName, sampleId, analyst, sampleFileName, gasFileName, detFileName, qcFileName, request);
|
||||
}
|
||||
|
||||
@GetMapping("getDBSearchList")
|
||||
|
@ -55,6 +55,13 @@ public class SpectrumAnalysesController {
|
|||
return spectrumAnalysisService.getDBSpectrumChart(dbName, sampleId, analyst, request);
|
||||
}
|
||||
|
||||
@GetMapping("getDBSpectrumChartApp")
|
||||
@ApiOperation(value = "查询折线图相关信息接口", notes = "查询折线图相关信息接口")
|
||||
public Result getDBSpectrumChartApp(@RequestParam("dbName") String dbName,@RequestParam("sampleId") Integer sampleId,
|
||||
@RequestParam("analyst") String analyst, HttpServletRequest request) {
|
||||
return spectrumAnalysisService.getDBSpectrumChart(dbName, sampleId, analyst, request);
|
||||
}
|
||||
|
||||
@GetMapping("getFileSpectrumChart")
|
||||
@ApiOperation(value = "查询文件折线图相关信息接口", notes = "查询文件折线图相关信息接口")
|
||||
public Result getFileSpectrumChart(String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) {
|
||||
|
@ -67,6 +74,12 @@ public class SpectrumAnalysesController {
|
|||
spectrumAnalysisService.deleteSpectrumCacheData(sampleFileName, request);
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteSpectrumCacheDataApp")
|
||||
@ApiOperation(value = "删除缓存数据",notes = "删除缓存数据")
|
||||
public void deleteSpectrumCacheDataApp(@RequestParam("sampleFileName") String sampleFileName, HttpServletRequest request) {
|
||||
spectrumAnalysisService.deleteSpectrumCacheData(sampleFileName, request);
|
||||
}
|
||||
|
||||
@GetMapping("viewComment")
|
||||
@ApiOperation(value = "查看comment数据", notes = "查看comment数据")
|
||||
public Result viewComment(Integer sampleId, String sampleFileName, HttpServletRequest request) {
|
||||
|
|
|
@ -7,6 +7,9 @@ import org.jeecg.modules.base.entity.rnman.GardsCalibration;
|
|||
|
||||
public interface GardsCalibrationSpectrumMapper extends BaseMapper<GardsCalibration> {
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
void insertCalibration(@Param(value = "calibration") GardsCalibration calibration);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
void insertCalibrationGamma(@Param(value = "calibration") GardsCalibration calibration);
|
||||
|
||||
|
|
|
@ -86,11 +86,11 @@ public interface SpectrumAnalysisMapper {
|
|||
|
||||
Integer getAnalysisID(@Param(value = "dbName") String dbName, @Param(value = "sampleId") Integer sampleId, @Param(value = "userName") String userName);
|
||||
|
||||
List<GardsCalibrationPairsSpectrum> ReadGammaFitChannelEnergy(@Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId);
|
||||
List<GardsCalibrationPairsSpectrum> ReadGammaFitChannelEnergy(@Param(value = "idAnalysis") Integer idAnalysis);
|
||||
|
||||
List<GardsCalibrationSpectrum> ReadGammaCalibrationParam(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis);
|
||||
|
||||
List<GardsCalibrationPairsSpectrum> ReadBetaFitChannelEnergy(@Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId);
|
||||
List<GardsCalibrationPairsSpectrum> ReadBetaFitChannelEnergy(@Param(value = "idAnalysis") Integer idAnalysis);
|
||||
|
||||
List<GardsCalibrationSpectrum> ReadBetaCalibrationParam(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis);
|
||||
|
||||
|
|
|
@ -2,6 +2,34 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.mapper.GardsCalibrationSpectrumMapper">
|
||||
|
||||
<insert id="insertCalibration">
|
||||
INSERT INTO
|
||||
RNMAN.GARDS_CALIBRATION(
|
||||
SAMPLE_ID,
|
||||
IDANALYSIS,
|
||||
SAMPLE_TYPE,
|
||||
CALTYPE,
|
||||
FUNCTION,
|
||||
FUNCTIONDEF,
|
||||
STARTOFRANGE,
|
||||
ENDOFRANGE,
|
||||
COEFF1,
|
||||
COEFF2,
|
||||
COEFF3)
|
||||
VALUES(#{calibration.sampleId},
|
||||
#{calibration.idAnalysis},
|
||||
#{calibration.sampleType},
|
||||
#{calibration.calType},
|
||||
#{calibration.function},
|
||||
#{calibration.functionDef},
|
||||
#{calibration.startOfRange},
|
||||
#{calibration.endOfRange},
|
||||
#{calibration.coeff1},
|
||||
#{calibration.coeff2},
|
||||
#{calibration.coeff3})
|
||||
|
||||
</insert>
|
||||
|
||||
<insert id="insertCalibrationGamma">
|
||||
INSERT INTO
|
||||
RNMAN.GARDS_CALIBRATION(
|
||||
|
|
|
@ -619,7 +619,6 @@
|
|||
CALIBRATION_PAIRS.SAMPLE_ID = SMAPLE_DATA.SAMPLE_ID
|
||||
AND CALIBRATION_PAIRS.SAMPLE_TYPE = 'G'
|
||||
AND CALIBRATION_PAIRS.IDANALYSIS = #{idAnalysis}
|
||||
AND CALIBRATION_PAIRS.SAMPLE_ID = #{sampleId}
|
||||
ORDER BY CALIBRATION_PAIRS.IDCALPOINT ASC
|
||||
</select>
|
||||
|
||||
|
@ -651,7 +650,6 @@
|
|||
CALIBRATION_PAIRS.SAMPLE_ID = SMAPLE_DATA.SAMPLE_ID
|
||||
AND CALIBRATION_PAIRS.SAMPLE_TYPE = 'B'
|
||||
AND CALIBRATION_PAIRS.IDANALYSIS = #{idAnalysis}
|
||||
AND CALIBRATION_PAIRS.SAMPLE_ID = #{sampleId}
|
||||
ORDER BY CALIBRATION_PAIRS.IDCALPOINT ASC
|
||||
</select>
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@ import java.util.List;
|
|||
|
||||
public interface IGammaService{
|
||||
|
||||
Result initValue(Integer sampleId, String dbName, String analyst, String fileName, HttpServletRequest request);
|
||||
|
||||
Result testFun(String fileName, HttpServletRequest request);
|
||||
void initValue(Integer sampleId, String dbName, String analyst, String fileName, HttpServletRequest request);
|
||||
|
||||
Result gammaByDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsCalibrationPairs;
|
||||
import org.jeecg.modules.entity.vo.BgDataAnlyseResultIn;
|
||||
import org.jeecg.modules.entity.vo.GStoreMiddleProcessData;
|
||||
import org.jeecg.modules.entity.vo.PHDFile;
|
||||
|
||||
|
@ -9,7 +10,7 @@ import java.util.List;
|
|||
|
||||
public interface IGardsCalibrationPairsSpectrumService extends IService<GardsCalibrationPairs> {
|
||||
|
||||
int saveGardsCalibrationPairs(List<GardsCalibrationPairs> calibrationPairsList);
|
||||
int saveGardsCalibrationPairs(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis);
|
||||
|
||||
int saveGardsCalibrationPairsGamma(GStoreMiddleProcessData middleData, Integer sampleId, String idAnalysis);
|
||||
|
||||
|
|
|
@ -2,13 +2,14 @@ package org.jeecg.modules.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsCalibration;
|
||||
import org.jeecg.modules.entity.vo.BgDataAnlyseResultIn;
|
||||
import org.jeecg.modules.entity.vo.GStoreMiddleProcessData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IGardsCalibrationSpectrumService extends IService<GardsCalibration> {
|
||||
|
||||
int saveGardsCalibration(List<GardsCalibration> calibrationPairsList);
|
||||
int saveGardsCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis);
|
||||
|
||||
int saveCalibrationGamma(GStoreMiddleProcessData middleData, Integer sampleId, String idAnalysis);
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@ package org.jeecg.modules.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsRoiChannels;
|
||||
import org.jeecg.modules.entity.vo.BgDataAnlyseResultIn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IGardsROIChannelsSpectrumService extends IService<GardsRoiChannels> {
|
||||
|
||||
int saveGardsROIChannels(List<GardsRoiChannels> roiChannelsList);
|
||||
int saveGardsROIChannels(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@ package org.jeecg.modules.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsRoiResults;
|
||||
import org.jeecg.modules.entity.vo.BgDataAnlyseResultIn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IGardsROIResultsSpectrumService extends IService<GardsRoiResults> {
|
||||
|
||||
int saveGardsROIResults(List<GardsRoiResults> roiResultsList);
|
||||
int saveGardsROIResults(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer idAnalysis);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@ package org.jeecg.modules.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsXeResults;
|
||||
import org.jeecg.modules.entity.vo.BgDataAnlyseResultIn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IGardsXeResultsSpectrumService extends IService<GardsXeResults> {
|
||||
|
||||
int saveGardsXeResults(List<GardsXeResults> xeResultsList);
|
||||
int saveGardsXeResults(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer idAnalysis);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
|
||||
public interface ISpectrumAnalysisService {
|
||||
|
||||
Result initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request);
|
||||
void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request);
|
||||
|
||||
Result getDBSearchList(HttpServletRequest request, boolean AllUsers, String sampleType);
|
||||
|
||||
|
|
|
@ -156,338 +156,13 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
private IDataService dataService;
|
||||
|
||||
@Override
|
||||
public Result initValue(Integer sampleId, String dbName, String analyst, String samfileName, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
//获取用户名
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
PHDFile phd = new PHDFile();
|
||||
// 读取文件内容
|
||||
String key = "";
|
||||
public void initValue(Integer sampleId, String dbName, String analyst, String samfileName, HttpServletRequest request) {
|
||||
if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) {
|
||||
// 根据sampleId获取sample文件路径
|
||||
String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
|
||||
if (StringUtils.isBlank(sampleFilePath)) {
|
||||
result.error500("Sample file does not exist!");
|
||||
return result;
|
||||
}
|
||||
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,响应结果result
|
||||
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, "BetaGamma", result);
|
||||
// 如果文件加载失败 返回失败原因
|
||||
if (!flag) {
|
||||
return result;
|
||||
}
|
||||
// 加载phd数据所需的lc,scac,baseline数据
|
||||
if (dbName.equals("auto")) {
|
||||
gammaFileUtil.SetBaseInfo(phd, "RNAUTO");
|
||||
} else if (dbName.equals("man")) {
|
||||
gammaFileUtil.SetBaseInfo(phd, analyst);
|
||||
}
|
||||
// 从数据库中读取phd其他相关信息
|
||||
boolean bRet = getResultFromDB(dbName, analyst, sampleId, phd, 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");
|
||||
// 查询当前用户关联的核素信息
|
||||
List<String> userLib = new LinkedList<>();
|
||||
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
|
||||
userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
|
||||
if (CollectionUtils.isEmpty(userLib)) {
|
||||
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
|
||||
}
|
||||
userLib = userLib.stream().sorted().collect(Collectors.toList());
|
||||
Map<String, NuclideLines> nuclideMap = new HashMap<>();
|
||||
for (Map.Entry<String, NuclideLines> entry:allNuclideMap.entrySet()) {
|
||||
if (userLib.contains(entry.getKey())) {
|
||||
nuclideMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
|
||||
}
|
||||
// 判断数据库信息是否读取正常
|
||||
if (!bRet) {
|
||||
return result;
|
||||
}
|
||||
//读取redis缓存的计算mdc信息
|
||||
Map<String, CalMDCInfo> mdcInfoMap = (Map<String, CalMDCInfo>) redisUtil.get("mdcInfoMap-"+phd.getHeader().getSystem_type());
|
||||
//如果是数据库加载 判断如果mdc计算结果是空的 就加入新的 否则使用数据库加载的mdc数据
|
||||
if (CollectionUtils.isEmpty(phd.getMdcInfoMap())) {
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
phd.setMdcInfoMap(mdcInfoMap);
|
||||
}
|
||||
gammaByDB(dbName, sampleId, analyst, request);
|
||||
} else {
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
Map<String, CalMDCInfo> infoMap = phd.getMdcInfoMap();
|
||||
for (Map.Entry<String, CalMDCInfo> entry:infoMap.entrySet()) {
|
||||
String nuclName = entry.getKey();
|
||||
CalMDCInfo info = mdcInfoMap.get(nuclName);
|
||||
if (Objects.nonNull(info)) {
|
||||
CalMDCInfo mdcInfo = entry.getValue();
|
||||
mdcInfo.setHalflife(info.getHalflife());
|
||||
gammaByFile(samfileName, request);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
gammaFileUtil.Qcstate(phd);
|
||||
key = fileName + StringPool.DASH + userName;
|
||||
} else {
|
||||
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||
String fileName = samfileName;
|
||||
// 加载文件内容
|
||||
boolean bRet = gammaFileUtil.loadFile(pathName, fileName, phd, "BetaGamma", result);
|
||||
if (!bRet) {
|
||||
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");
|
||||
// 查询当前用户关联的核素信息
|
||||
List<String> userLib = new LinkedList<>();
|
||||
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
|
||||
userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
|
||||
if (CollectionUtils.isEmpty(userLib)) {
|
||||
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
|
||||
}
|
||||
userLib = userLib.stream().sorted().collect(Collectors.toList());
|
||||
Map<String, NuclideLines> nuclideMap = new HashMap<>();
|
||||
for (Map.Entry<String, NuclideLines> entry:allNuclideMap.entrySet()) {
|
||||
if (userLib.contains(entry.getKey())) {
|
||||
nuclideMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
|
||||
}
|
||||
//读取redis缓存的计算mdc信息
|
||||
Map<String, CalMDCInfo> mdcInfoMap = (Map<String, CalMDCInfo>) redisUtil.get("mdcInfoMap-"+phd.getHeader().getSystem_type());
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
phd.setMdcInfoMap(mdcInfoMap);
|
||||
}
|
||||
key = fileName + StringPool.DASH + userName;
|
||||
}
|
||||
phdCache.put(key, phd);
|
||||
localCache.setPHDCache(phdCache);
|
||||
result.setSuccess(true);
|
||||
result.setResult(phd);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result testFun(String fileName, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName);
|
||||
phd.setUserId("1");
|
||||
phd.setXmlFilePath(parameterProperties.getFilePath());
|
||||
String systemType = fileName.substring(2, 3);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||
// 解析获取临时文件信息
|
||||
File tmpFile = gammaFileUtil.analyzeFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
String phdStr = mapper.writeValueAsString(phd);
|
||||
String mapLines = mapper.writeValueAsString(nuclideLinesMap);
|
||||
String strValue = CalValuesHandler.analyseSpectrum(phdStr, mapLines, tmpFile.getAbsolutePath(), new AnalysisProcess());
|
||||
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
|
||||
for (Map.Entry<String, Object> entry : parseMap.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase("bAnalyed")) {
|
||||
boolean value = JSON.parseObject(JSON.toJSONString(entry.getValue()), Boolean.class);
|
||||
phd.setBAnalyed(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("mapEnerPara")) {
|
||||
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
|
||||
Map<String, ParameterInfo> value = new HashMap<>();
|
||||
for (Map.Entry<String, Object> objectEntry : jsonMap.entrySet()) {
|
||||
String key = objectEntry.getKey();
|
||||
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
|
||||
value.put(key, entryValue);
|
||||
}
|
||||
phd.setMapEnerPara(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("mapResoPara")) {
|
||||
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
|
||||
Map<String, ParameterInfo> value = new HashMap<>();
|
||||
for (Map.Entry<String, Object> objectEntry : jsonMap.entrySet()) {
|
||||
String key = objectEntry.getKey();
|
||||
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
|
||||
value.put(key, entryValue);
|
||||
}
|
||||
phd.setMapResoPara(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("mapEffiPara")) {
|
||||
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
|
||||
Map<String, ParameterInfo> value = new HashMap<>();
|
||||
for (Map.Entry<String, Object> objectEntry : jsonMap.entrySet()) {
|
||||
String key = objectEntry.getKey();
|
||||
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
|
||||
value.put(key, entryValue);
|
||||
}
|
||||
phd.setMapEffiPara(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("mapTotEPara")) {
|
||||
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
|
||||
Map<String, ParameterInfo> value = new HashMap<>();
|
||||
for (Map.Entry<String, Object> objectEntry : jsonMap.entrySet()) {
|
||||
String key = objectEntry.getKey();
|
||||
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
|
||||
value.put(key, entryValue);
|
||||
}
|
||||
phd.setMapTotEPara(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("para_stepRatio")) {
|
||||
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
|
||||
phd.setPara_stepRatio(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("para_tail")) {
|
||||
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
|
||||
phd.setPara_tail(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("para_tailAlpha")) {
|
||||
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
|
||||
phd.setPara_tailAlpha(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("para_tailRight")) {
|
||||
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
|
||||
phd.setPara_tailRight(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("para_tailRightAlpha")) {
|
||||
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
|
||||
phd.setPara_tailRightAlpha(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("newEner")) {
|
||||
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
|
||||
phd.setNewEner(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("newReso")) {
|
||||
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
|
||||
phd.setNewReso(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("mapEnerKD")) {
|
||||
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
|
||||
Map<String, GEnergyBlock> value = new HashMap<>();
|
||||
for (Map.Entry<String, Object> objectEntry : jsonMap.entrySet()) {
|
||||
String key = objectEntry.getKey();
|
||||
GEnergyBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GEnergyBlock.class);
|
||||
value.put(key, entryValue);
|
||||
}
|
||||
phd.setMapEnerKD(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("mapResoKD")) {
|
||||
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
|
||||
Map<String, GResolutionBlock> value = new HashMap<>();
|
||||
for (Map.Entry<String, Object> objectEntry : jsonMap.entrySet()) {
|
||||
String key = objectEntry.getKey();
|
||||
GResolutionBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GResolutionBlock.class);
|
||||
value.put(key, entryValue);
|
||||
}
|
||||
phd.setMapResoKD(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("vEnergy")) {
|
||||
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
|
||||
phd.setVEnergy(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("vBase")) {
|
||||
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
|
||||
phd.setVBase(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("vLc")) {
|
||||
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
|
||||
phd.setVLc(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("vScac")) {
|
||||
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
|
||||
phd.setVScac(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("vPeak")) {
|
||||
List<PeakInfo> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), PeakInfo.class);
|
||||
phd.setVPeak(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("baseCtrls")) {
|
||||
BaseControls value = JSON.parseObject(JSON.toJSONString(entry.getValue()), BaseControls.class);
|
||||
phd.setBaseCtrls(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedEner")) {
|
||||
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
|
||||
phd.setUsedEner(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedEnerKD")) {
|
||||
GEnergyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEnergyBlock.class);
|
||||
phd.setUsedEnerKD(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedEnerPara")) {
|
||||
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
|
||||
phd.setUsedEnerPara(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedReso")) {
|
||||
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
|
||||
phd.setUsedReso(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedResoKD")) {
|
||||
GResolutionBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GResolutionBlock.class);
|
||||
phd.setUsedResoKD(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedResoPara")) {
|
||||
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
|
||||
phd.setUsedResoPara(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedEffi")) {
|
||||
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
|
||||
phd.setUsedEffi(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedEffiKD")) {
|
||||
GEfficiencyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEfficiencyBlock.class);
|
||||
phd.setUsedEffiKD(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedEffiPara")) {
|
||||
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
|
||||
phd.setUsedEffiPara(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedTotE")) {
|
||||
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
|
||||
phd.setUsedTotE(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedTotEKD")) {
|
||||
TotaleffBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), TotaleffBlock.class);
|
||||
phd.setUsedTotEKD(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("usedTotEPara")) {
|
||||
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
|
||||
phd.setUsedTotEPara(value);
|
||||
}
|
||||
}
|
||||
BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting());
|
||||
|
||||
for (PeakInfo info:phd.getVPeak()) {
|
||||
if (Objects.isNull(info.recoilBetaChan)) {
|
||||
info.recoilBetaChan = "nan";
|
||||
}
|
||||
if (Objects.isNull(info.recoilDeltaChan)) {
|
||||
info.recoilDeltaChan = "nan";
|
||||
}
|
||||
}
|
||||
// 重新分析各峰值对应的核素信息
|
||||
gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
|
||||
gammaFileUtil.RunQC(phd);
|
||||
result.setResult(phd);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (Objects.nonNull(tmpFile)) {
|
||||
tmpFile.delete();
|
||||
}
|
||||
}
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result gammaByDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
|
||||
|
@ -547,6 +222,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
|
||||
}
|
||||
//缓存phd谱的核素信息
|
||||
Map<String, NuclideLines> phdNuclideMap = (Map<String, NuclideLines>) redisUtil.get(userName + StringPool.DASH + phd.getHeader().getSystem_type());
|
||||
phd.setPhdNuclideMap(phdNuclideMap);
|
||||
// 判断数据库信息是否读取正常
|
||||
if (!bRet) {
|
||||
return result;
|
||||
|
@ -951,6 +629,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
|
||||
}
|
||||
//缓存phd谱的核素信息
|
||||
Map<String, NuclideLines> phdNuclideMap = (Map<String, NuclideLines>) redisUtil.get(userName + StringPool.DASH + phd.getHeader().getSystem_type());
|
||||
phd.setPhdNuclideMap(phdNuclideMap);
|
||||
//读取redis缓存的计算mdc信息
|
||||
Map<String, CalMDCInfo> mdcInfoMap = (Map<String, CalMDCInfo>) redisUtil.get("mdcInfoMap-"+phd.getHeader().getSystem_type());
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
|
@ -1335,6 +1016,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
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);
|
||||
gammaFileUtil.RunQC(phd);
|
||||
phd.setEfficiencyParam(phd.getUsedEffiPara().getP());
|
||||
|
@ -1350,7 +1034,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
result.error500(warning);
|
||||
} else {
|
||||
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||
gammaFileUtil.AnalyseSpectrum(phd, nuclideLinesMap);
|
||||
//分析时将phd的核素map重置
|
||||
phd.setPhdNuclideMap(nuclideLinesMap);
|
||||
//调用分析算法
|
||||
boolean analyseSpectrum = gammaFileUtil.AnalyseSpectrum(phd, nuclideLinesMap);
|
||||
if (analyseSpectrum) {
|
||||
// 重新分析各峰值对应的核素信息
|
||||
// gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
|
||||
phd.setEfficiencyParam(phd.getUsedEffiPara().getP());
|
||||
|
@ -1373,6 +1061,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
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;
|
||||
}
|
||||
|
@ -1738,7 +1429,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
return result;
|
||||
}
|
||||
//获取缓存的核素信息
|
||||
Map<String, NuclideLines> nuclideMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||
Map<String, NuclideLines> nuclideMap = phd.getPhdNuclideMap();
|
||||
//获取颜色信息
|
||||
Map<String, String> colorMap = sysUserColorService.initColor(userName);
|
||||
//声明一个结果的map
|
||||
|
@ -1785,7 +1476,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
phd.getVPeak().remove(curRow);
|
||||
//重新计算核素活度浓度
|
||||
gammaFileUtil.NuclidesIdent(phd, nuclideMap);
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
|
||||
//重新分析数据
|
||||
gammaFileUtil.PeaksChanged(phd);
|
||||
for (int i = 0; i < phd.getVPeak().size(); i++) {
|
||||
|
@ -2008,6 +1698,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
phd.getVPeak().get(curRow).nuclides.add(nuclideName);
|
||||
// 查询当前用户所关心的核素名称
|
||||
Map<String, NuclideLines> mapNucLines = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||
//用户当前缓存的核素信息
|
||||
Map<String, NuclideLines> phdNuclideMap = phd.getPhdNuclideMap();
|
||||
// 查询出核素信息
|
||||
NuclideLines it_line = mapNucLines.get(nuclideName);
|
||||
// 如果核素信息不存在返回
|
||||
|
@ -2026,6 +1718,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
map.put("identify", list_identify);
|
||||
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
|
||||
map.put("table", vPeak);
|
||||
//如果当前缓存的谱核素信息不包含当前核素
|
||||
if (Objects.isNull(phdNuclideMap.get(nuclideName))) {
|
||||
//将redis缓存的谱核素信息 存入到缓存map中
|
||||
phdNuclideMap.put(nuclideName, it_line);
|
||||
phd.setPhdNuclideMap(phdNuclideMap);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
|
@ -2044,7 +1742,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
return result;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, NuclideLines> nuclideMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||
Map<String, NuclideLines> nuclideMap = phd.getPhdNuclideMap();
|
||||
//判断当前选择的核素名称是否包含在当前Peak的核素列表中
|
||||
int index = list_identify.indexOf(nuclideName);
|
||||
if (index >= 0) {
|
||||
|
@ -2075,7 +1773,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
nuclideMap.remove(nuclideName);
|
||||
//重新计算核素活度浓度
|
||||
gammaFileUtil.NuclidesIdent(phd, nuclideMap);
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
|
||||
//从核素的选中列表中移除对应下标的核素信息
|
||||
list_identify.remove(index);
|
||||
//重新初始化峰列表信息
|
||||
|
@ -2091,6 +1788,13 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
|
||||
// 处理核素MDA、MDC
|
||||
gammaFileUtil.ReCalcMdaMdc(phd, nuclideName, curRow + 1);
|
||||
// 谱的峰信息通过stream流过滤出包含当前核素名称的峰信息
|
||||
List<PeakInfo> peakInfoList = phd.getVPeak().stream().filter(item -> item.nuclides.indexOf(nuclideName) >= 0).collect(Collectors.toList());
|
||||
//过滤结果小于等于0 则说明当前核素在峰值中不存在了 需要从缓存的核素信息map中移除核素
|
||||
if (peakInfoList.size() <= 0) {
|
||||
//移除核素信息
|
||||
nuclideMap.remove(nuclideName);
|
||||
}
|
||||
map.put("identify", list_identify);
|
||||
map.put("table", vPeak);
|
||||
}
|
||||
|
@ -4147,6 +3851,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
}
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
|
||||
phd.setPhdNuclideMap(nuclideMap);
|
||||
} else {
|
||||
result.success("Modification failure!");
|
||||
}
|
||||
|
@ -4411,6 +4116,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
@Override
|
||||
public Result Spectrum(Integer sampleId, String fileName, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName);
|
||||
|
@ -4419,8 +4125,13 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
return result;
|
||||
}
|
||||
String spectrum = gammaFileUtil.makeUpSpectrum(phd);
|
||||
map.put("Spectrum", spectrum);
|
||||
if(StringUtils.isNotBlank(phd.getTmpFilePath())) {
|
||||
List<String> lines = gammaFileUtil.readLine(phd.getTmpFilePath());
|
||||
map.put("phdSpectrum", lines);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(spectrum);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -5001,8 +4712,16 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
//格式化名称
|
||||
Map<String, String> nameMap = nameStandUtil.NameStandard(phd);
|
||||
String mSaveFileName = nameMap.get("saveFile");
|
||||
String dateTimeSubdir = "";
|
||||
int pos = mSaveFileName.indexOf('-');
|
||||
if(-1 == pos) {
|
||||
|
||||
} else if(fileName.length() >= pos+7) {
|
||||
dateTimeSubdir+=StringPool.SLASH+fileName.substring(pos+1,pos+5);
|
||||
dateTimeSubdir+=StringPool.SLASH+fileName.substring(pos+5,pos+7);
|
||||
}
|
||||
//判断当前分析员是否有过历史分析当前文件
|
||||
Integer isExist = spectrumAnalysisMapper.SampleIsExist(sysTemSubdir+ dateTypeSubdir + StringPool.SLASH + mSaveFileName, userName);
|
||||
Integer isExist = spectrumAnalysisMapper.SampleIsExist(sysTemSubdir+ dateTypeSubdir + dateTimeSubdir + StringPool.SLASH + mSaveFileName, userName);
|
||||
// 如果用户没有权限操作 则查看当前用户是否是高级分析员/管理员
|
||||
if (!bAnalysisResultWriteAuthority && Objects.isNull(isExist)) {
|
||||
result.error500("You have no permission to save "+phd.getHeader().getSite_code()+" results to DB!");
|
||||
|
|
|
@ -4,6 +4,10 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
|||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsCalibrationPairs;
|
||||
import org.jeecg.modules.base.enums.CalName;
|
||||
import org.jeecg.modules.base.enums.CalType;
|
||||
import org.jeecg.modules.base.enums.SystemType;
|
||||
import org.jeecg.modules.entity.vo.BgDataAnlyseResultIn;
|
||||
import org.jeecg.modules.entity.vo.GStoreMiddleProcessData;
|
||||
import org.jeecg.modules.entity.vo.PHDFile;
|
||||
import org.jeecg.modules.entity.GardsCalibrationPairsSpectrum;
|
||||
|
@ -22,7 +26,92 @@ public class GardsCalibrationPairsSpectrumServiceImpl extends ServiceImpl<GardsC
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public int saveGardsCalibrationPairs(List<GardsCalibrationPairs> calibrationPairsList) {
|
||||
public int saveGardsCalibrationPairs(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) {
|
||||
List<GardsCalibrationPairs> calibrationPairsList = new LinkedList<>();
|
||||
if (CollectionUtils.isNotEmpty(anlyseResultIn.getB_channel_sample())) {
|
||||
for (int i=0; i< anlyseResultIn.getB_channel_sample().size(); i++){
|
||||
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
|
||||
calibrationPairs.setSampleId(sampleId);
|
||||
calibrationPairs.setIdAnalysis(idAnalysis);
|
||||
calibrationPairs.setSampleType(SystemType.BETA.getType());
|
||||
calibrationPairs.setCaltype(CalType.ENERGY_CAL.getType());
|
||||
calibrationPairs.setInput(CalName.CalPHD.getType());
|
||||
calibrationPairs.setIdCalPoint(i);
|
||||
calibrationPairs.setXValue(anlyseResultIn.getB_channel_sample().get(i));
|
||||
calibrationPairs.setYValue(anlyseResultIn.getB_energy_sample().get(i));
|
||||
calibrationPairsList.add(calibrationPairs);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(anlyseResultIn.getG_channel_sample())) {
|
||||
for (int i=0; i< anlyseResultIn.getG_channel_sample().size(); i++){
|
||||
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
|
||||
calibrationPairs.setSampleId(sampleId);
|
||||
calibrationPairs.setIdAnalysis(idAnalysis);
|
||||
calibrationPairs.setSampleType(SystemType.GAMMA.getType());
|
||||
calibrationPairs.setCaltype(CalType.ENERGY_CAL.getType());
|
||||
calibrationPairs.setInput(CalName.CalPHD.getType());
|
||||
calibrationPairs.setIdCalPoint(i);
|
||||
calibrationPairs.setXValue(anlyseResultIn.getG_channel_sample().get(i));
|
||||
calibrationPairs.setYValue(anlyseResultIn.getG_energy_sample().get(i));
|
||||
calibrationPairsList.add(calibrationPairs);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(anlyseResultIn.getB_channel_gas())) {
|
||||
for (int i=0; i< anlyseResultIn.getB_channel_gas().size(); i++){
|
||||
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
|
||||
calibrationPairs.setSampleId(gasId);
|
||||
calibrationPairs.setIdAnalysis(idAnalysis);
|
||||
calibrationPairs.setSampleType(SystemType.BETA.getType());
|
||||
calibrationPairs.setCaltype(CalType.ENERGY_CAL.getType());
|
||||
calibrationPairs.setInput(CalName.CalPHD.getType());
|
||||
calibrationPairs.setIdCalPoint(i);
|
||||
calibrationPairs.setXValue(anlyseResultIn.getB_channel_gas().get(i));
|
||||
calibrationPairs.setYValue(anlyseResultIn.getB_energy_gas().get(i));
|
||||
calibrationPairsList.add(calibrationPairs);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(anlyseResultIn.getG_channel_gas())) {
|
||||
for (int i=0; i< anlyseResultIn.getG_channel_gas().size(); i++){
|
||||
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
|
||||
calibrationPairs.setSampleId(gasId);
|
||||
calibrationPairs.setIdAnalysis(idAnalysis);
|
||||
calibrationPairs.setSampleType(SystemType.GAMMA.getType());
|
||||
calibrationPairs.setCaltype(CalType.ENERGY_CAL.getType());
|
||||
calibrationPairs.setInput(CalName.CalPHD.getType());
|
||||
calibrationPairs.setIdCalPoint(i);
|
||||
calibrationPairs.setXValue(anlyseResultIn.getG_channel_gas().get(i));
|
||||
calibrationPairs.setYValue(anlyseResultIn.getG_energy_gas().get(i));
|
||||
calibrationPairsList.add(calibrationPairs);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(anlyseResultIn.getB_channel_det())) {
|
||||
for (int i=0; i< anlyseResultIn.getB_channel_det().size(); i++){
|
||||
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
|
||||
calibrationPairs.setSampleId(detId);
|
||||
calibrationPairs.setIdAnalysis(idAnalysis);
|
||||
calibrationPairs.setSampleType(SystemType.BETA.getType());
|
||||
calibrationPairs.setCaltype(CalType.ENERGY_CAL.getType());
|
||||
calibrationPairs.setInput(CalName.CalPHD.getType());
|
||||
calibrationPairs.setIdCalPoint(i);
|
||||
calibrationPairs.setXValue(anlyseResultIn.getB_channel_det().get(i));
|
||||
calibrationPairs.setYValue(anlyseResultIn.getB_energy_det().get(i));
|
||||
calibrationPairsList.add(calibrationPairs);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(anlyseResultIn.getG_channel_det())) {
|
||||
for (int i=0; i< anlyseResultIn.getG_channel_det().size(); i++){
|
||||
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
|
||||
calibrationPairs.setSampleId(detId);
|
||||
calibrationPairs.setIdAnalysis(idAnalysis);
|
||||
calibrationPairs.setSampleType(SystemType.GAMMA.getType());
|
||||
calibrationPairs.setCaltype(CalType.ENERGY_CAL.getType());
|
||||
calibrationPairs.setInput(CalName.CalPHD.getType());
|
||||
calibrationPairs.setIdCalPoint(i);
|
||||
calibrationPairs.setXValue(anlyseResultIn.getG_channel_det().get(i));
|
||||
calibrationPairs.setYValue(anlyseResultIn.getG_energy_det().get(i));
|
||||
calibrationPairsList.add(calibrationPairs);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(calibrationPairsList)) {
|
||||
this.saveBatch(calibrationPairsList);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,12 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
|||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsCalibration;
|
||||
import org.jeecg.modules.base.enums.CalType;
|
||||
import org.jeecg.modules.base.enums.DataTypeAbbr;
|
||||
import org.jeecg.modules.base.enums.FittingType;
|
||||
import org.jeecg.modules.base.enums.SystemType;
|
||||
import org.jeecg.modules.entity.GardsCalibrationSpectrum;
|
||||
import org.jeecg.modules.entity.vo.BgDataAnlyseResultIn;
|
||||
import org.jeecg.modules.entity.vo.GStoreMiddleProcessData;
|
||||
import org.jeecg.modules.mapper.GardsCalibrationSpectrumMapper;
|
||||
import org.jeecg.modules.service.IGardsCalibrationSpectrumService;
|
||||
|
@ -12,6 +18,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("gardsCalibrationSpectrumService")
|
||||
@DS("ora")
|
||||
|
@ -20,11 +28,116 @@ public class GardsCalibrationSpectrumServiceImpl extends ServiceImpl<GardsCalibr
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public int saveGardsCalibration(List<GardsCalibration> calibrationPairsList) {
|
||||
if (CollectionUtils.isNotEmpty(calibrationPairsList)) {
|
||||
this.saveBatch(calibrationPairsList);
|
||||
public int saveGardsCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) {
|
||||
List<GardsCalibration> calibrationSpectrumList = new LinkedList<>();
|
||||
if (Objects.nonNull(sampleId)) {
|
||||
GardsCalibration calibrationB = new GardsCalibration();
|
||||
calibrationB.setSampleId(sampleId);
|
||||
calibrationB.setIdAnalysis(idAnalysis);
|
||||
calibrationB.setSampleType(SystemType.BETA.getType());
|
||||
calibrationB.setCalType(CalType.ENERGY_CAL.getType());
|
||||
calibrationB.setFunction(FittingType.POLY2.getCode());
|
||||
calibrationB.setFunctionDef(FittingType.POLY2.getDescription());
|
||||
calibrationB.setStartOfRange(0);
|
||||
calibrationB.setEndOfRange(1);
|
||||
List<GardsCalibrationSpectrum> betaCollect = anlyseResultIn.getBetaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList());
|
||||
GardsCalibrationSpectrum betaCalibrationSpectrum = betaCollect.get(0);
|
||||
calibrationB.setCoeff1(Double.valueOf(betaCalibrationSpectrum.getCoeff1()));
|
||||
calibrationB.setCoeff2(Double.valueOf(betaCalibrationSpectrum.getCoeff2()));
|
||||
calibrationB.setCoeff3(Double.valueOf(betaCalibrationSpectrum.getCoeff3()));
|
||||
calibrationSpectrumList.add(calibrationB);
|
||||
|
||||
GardsCalibration calibrationG = new GardsCalibration();
|
||||
calibrationG.setSampleId(sampleId);
|
||||
calibrationG.setIdAnalysis(idAnalysis);
|
||||
calibrationG.setSampleType(SystemType.GAMMA.getType());
|
||||
calibrationG.setCalType(CalType.ENERGY_CAL.getType());
|
||||
calibrationG.setFunction(FittingType.POLY2.getCode());
|
||||
calibrationG.setFunctionDef(FittingType.POLY2.getDescription());
|
||||
calibrationG.setStartOfRange(0);
|
||||
calibrationG.setEndOfRange(1);
|
||||
List<GardsCalibrationSpectrum> gammaCollect = anlyseResultIn.getGammaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList());
|
||||
GardsCalibrationSpectrum gammaCalibrationSpectrum = gammaCollect.get(0);
|
||||
calibrationG.setCoeff1(Double.valueOf(gammaCalibrationSpectrum.getCoeff1()));
|
||||
calibrationG.setCoeff2(Double.valueOf(gammaCalibrationSpectrum.getCoeff2()));
|
||||
calibrationG.setCoeff3(Double.valueOf(gammaCalibrationSpectrum.getCoeff3()));
|
||||
calibrationSpectrumList.add(calibrationG);
|
||||
}
|
||||
return calibrationPairsList.size();
|
||||
|
||||
if (Objects.nonNull(gasId)) {
|
||||
//gas文件 Beta部分
|
||||
GardsCalibration calibrationB = new GardsCalibration();
|
||||
calibrationB.setSampleId(gasId);
|
||||
calibrationB.setIdAnalysis(idAnalysis);
|
||||
calibrationB.setSampleType(SystemType.BETA.getType());
|
||||
calibrationB.setCalType(CalType.ENERGY_CAL.getType());
|
||||
calibrationB.setFunction(FittingType.POLY2.getCode());
|
||||
calibrationB.setFunctionDef(FittingType.POLY2.getDescription());
|
||||
calibrationB.setStartOfRange(0);
|
||||
calibrationB.setEndOfRange(1);
|
||||
List<GardsCalibrationSpectrum> betaCollect = anlyseResultIn.getBetaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList());
|
||||
GardsCalibrationSpectrum betaCalibrationSpectrum = betaCollect.get(0);
|
||||
calibrationB.setCoeff1(Double.valueOf(betaCalibrationSpectrum.getCoeff1()));
|
||||
calibrationB.setCoeff2(Double.valueOf(betaCalibrationSpectrum.getCoeff2()));
|
||||
calibrationB.setCoeff3(Double.valueOf(betaCalibrationSpectrum.getCoeff3()));
|
||||
calibrationSpectrumList.add(calibrationB);
|
||||
//gas文件 gamma部分
|
||||
GardsCalibration calibrationG = new GardsCalibration();
|
||||
calibrationG.setSampleId(gasId);
|
||||
calibrationG.setIdAnalysis(idAnalysis);
|
||||
calibrationG.setSampleType(SystemType.GAMMA.getType());
|
||||
calibrationG.setCalType(CalType.ENERGY_CAL.getType());
|
||||
calibrationG.setFunction(FittingType.POLY2.getCode());
|
||||
calibrationG.setFunctionDef(FittingType.POLY2.getDescription());
|
||||
calibrationG.setStartOfRange(0);
|
||||
calibrationG.setEndOfRange(1);
|
||||
List<GardsCalibrationSpectrum> gammaCollect = anlyseResultIn.getGammaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList());
|
||||
GardsCalibrationSpectrum gammaCalibrationSpectrum = gammaCollect.get(0);
|
||||
calibrationG.setCoeff1(Double.valueOf(gammaCalibrationSpectrum.getCoeff1()));
|
||||
calibrationG.setCoeff2(Double.valueOf(gammaCalibrationSpectrum.getCoeff2()));
|
||||
calibrationG.setCoeff3(Double.valueOf(gammaCalibrationSpectrum.getCoeff3()));
|
||||
calibrationSpectrumList.add(calibrationG);
|
||||
}
|
||||
|
||||
if (Objects.nonNull(detId)) {
|
||||
GardsCalibration calibrationB = new GardsCalibration();
|
||||
calibrationB.setSampleId(detId);
|
||||
calibrationB.setIdAnalysis(idAnalysis);
|
||||
calibrationB.setSampleType(SystemType.BETA.getType());
|
||||
calibrationB.setCalType(CalType.ENERGY_CAL.getType());
|
||||
calibrationB.setFunction(FittingType.POLY2.getCode());
|
||||
calibrationB.setFunctionDef(FittingType.POLY2.getDescription());
|
||||
calibrationB.setStartOfRange(0);
|
||||
calibrationB.setEndOfRange(1);
|
||||
List<GardsCalibrationSpectrum> betaCollect = anlyseResultIn.getBetaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList());
|
||||
GardsCalibrationSpectrum betaCalibrationSpectrum = betaCollect.get(0);
|
||||
calibrationB.setCoeff1(Double.valueOf(betaCalibrationSpectrum.getCoeff1()));
|
||||
calibrationB.setCoeff2(Double.valueOf(betaCalibrationSpectrum.getCoeff2()));
|
||||
calibrationB.setCoeff3(Double.valueOf(betaCalibrationSpectrum.getCoeff3()));
|
||||
calibrationSpectrumList.add(calibrationB);
|
||||
GardsCalibration calibrationG = new GardsCalibration();
|
||||
calibrationG.setSampleId(detId);
|
||||
calibrationG.setIdAnalysis(idAnalysis);
|
||||
calibrationG.setSampleType(SystemType.GAMMA.getType());
|
||||
calibrationG.setCalType(CalType.ENERGY_CAL.getType());
|
||||
calibrationG.setFunction(FittingType.POLY2.getCode());
|
||||
calibrationG.setFunctionDef(FittingType.POLY2.getDescription());
|
||||
calibrationG.setStartOfRange(0);
|
||||
calibrationG.setEndOfRange(1);
|
||||
List<GardsCalibrationSpectrum> gammaCollect = anlyseResultIn.getGammaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList());
|
||||
GardsCalibrationSpectrum gammaCalibrationSpectrum = gammaCollect.get(0);
|
||||
calibrationG.setCoeff1(Double.valueOf(gammaCalibrationSpectrum.getCoeff1()));
|
||||
calibrationG.setCoeff2(Double.valueOf(gammaCalibrationSpectrum.getCoeff2()));
|
||||
calibrationG.setCoeff3(Double.valueOf(gammaCalibrationSpectrum.getCoeff3()));
|
||||
calibrationSpectrumList.add(calibrationG);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(calibrationSpectrumList)) {
|
||||
for (GardsCalibration calibration:calibrationSpectrumList) {
|
||||
this.baseMapper.insertCalibration(calibration);
|
||||
}
|
||||
}
|
||||
return calibrationSpectrumList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user