Compare commits

..

84 Commits

Author SHA1 Message Date
duwenyuan
81cb808246 修改登录邮箱配置信息 2025-07-04 15:07:34 +08:00
duwenyuan
5e5d2e7988 添加台站类型枚举 2025-07-02 11:59:17 +08:00
duwenyuan
d15e9a5c7b 删除createBatch 2025-06-30 10:54:39 +08:00
duwenyuan
743da3b207 修改createBatch使用自带函数saveBatch保存信息 2025-06-30 10:52:49 +08:00
duwenyuan
a25e7e91ac 修改解析邮件时获取邮件接收日期或者是发件日期 2025-06-30 10:51:11 +08:00
duwenyuan
0c5127a3ab 修改创建邮箱日志时获取邮件接收日期或者是发件日期 2025-06-30 10:49:29 +08:00
duwenyuan
4de9186c64 添加STATISTICS界面显示mdc信息 2025-06-30 10:45:27 +08:00
duwenyuan
c02fddaf6f 修改数据库关键字function字段为"\"FUNCTION\"" 2025-06-30 10:33:06 +08:00
duwenyuan
f892d450f3 添加g_e_nuclide_name字段 2025-06-30 10:30:56 +08:00
duwenyuan
25bf3542b5 修改获取邮件Message-ID的方式,获取不到Message-ID时换成主题+接收时间或者时发送时间 2025-06-30 10:28:54 +08:00
duwenyuan
9546f610b9 修改findPhdfProvisionEfficiencyParticulate函数参数值 2025-06-30 10:26:28 +08:00
duwenyuan
8010b316b8 添加QC-Flag、sauna、sauna2的显示规则计算参数。
添加规则实体类,修改Sections类获取规则方式
2025-06-30 10:24:35 +08:00
duwenyuan
be5ef47c10 修改findPhdProvisionEfficiencySauna SQl查询条件MDC小于指定值,修改findPhdfProvisionEfficiencyParticulate查询有效率低的问题,添加DATATYPE=Q计数 2025-06-30 10:07:42 +08:00
duwenyuan
1c739466e2 添加PostgreSQL查询台站数据提供率及有效率 2025-06-03 14:21:53 +08:00
duwenyuan
b451236b2a 添加查询台站数据有效率findStationProvisionEfficiency接口 2025-05-29 16:44:25 +08:00
panbaolin
31d9585c0d 1.修改添加刻度数据sql兼容pg问题 2025-05-28 17:26:06 +08:00
panbaolin
9567ab3f60 1.修改实体类主键,适配postgresql
2.修改自动处理工程,添加C++动态库少的字段
2025-05-27 15:57:53 +08:00
duwenyuan
56bd405d8d 邮箱监控界面,添加和修改功能添加邮箱服务器类型,增加emailServerType字段 2025-05-15 10:55:13 +08:00
duwenyuan
9e65ca7493 MET、SOH普文件去重 2025-05-15 10:55:12 +08:00
duwenyuan
2d96fbe7d0 添加邮箱服务器类型标记 2025-04-30 17:40:03 +08:00
duwenyuan
1c4b4af39c 修改台站计算有效率,parameter.xml新加SAUNA2、SPALAX-PLC节点 2025-04-30 17:38:57 +08:00
panbaolin
995c67b603 1.修改启动类注释
2.自动处理工程添加处理老旧邮箱协议jar包
2025-04-27 14:02:23 +08:00
duwenyuan
6a9c3c1e16 Beta Detector Calibration界面 返回结果添加acqStartTime数据 2025-04-16 17:24:36 +08:00
duwenyuan
5a605e432e 修改LoadFromDatabase列表按照活时间排序 2025-04-16 09:06:37 +08:00
xiaoguangbin
17b58e10c2 fix: 删除Analysis_Nuclide_Name 2025-04-07 10:16:17 +08:00
xiaoguangbin
41763af080 fix: 修改发送邮件标题和内容格式 2025-04-02 13:55:29 +08:00
xiaoguangbin
ed9b999a3e fix: 核素分析规则 平均值保留5位小数 2025-01-13 16:23:35 +08:00
xiaoguangbin
14c1ee3468 fix: 核素分析规则 解决识别多个核素报错问题 2025-01-13 16:04:26 +08:00
xiaoguangbin
3761c0deba fix: 核素分析规则 增加核素识别报警,求平均值的周期和系数都整合到规则中 2025-01-13 10:23:11 +08:00
xiaoguangbin
635545cb86 fix: 核素分析规则 增加核素识别报警,求平均值的周期和系数都整合到规则中 2025-01-09 14:17:19 +08:00
xiaoguangbin
8768a2b566 fix: 核素分析规则 增加核素识别报警,求平均值的周期和系数都整合到规则中 2025-01-08 17:15:57 +08:00
xiaoguangbin
139bf46ba0 fix: 核素分析规则 增加核素识别报警,求平均值的周期和系数都整合到规则中 2025-01-08 17:15:45 +08:00
xiaoguangbin
6d0531894d fix: 核素分析规则 增加核素识别报警,求平均值的周期和系数都整合到规则中 2025-01-08 16:35:18 +08:00
xiaoguangbin
accc1d798e fix: 核素分析规则 增加核素识别报警,求平均值的周期和系数都整合到规则中 2025-01-08 16:34:33 +08:00
xiaoguangbin
5317fe2b56 fix: 核素分析规则 解决null值无法入库的问题 2025-01-02 16:25:19 +08:00
xiaoguangbin
decc80fadf fix: 核素分析规则增加QC 条件筛选 2025-01-02 15:21:56 +08:00
xiaoguangbin
26647c137f fix: 核素分析规则增加QC 条件筛选 2025-01-02 15:12:46 +08:00
xiaoguangbin
91bcec7aea fix: 核素分析规则增加QC 条件筛选 2025-01-02 14:57:08 +08:00
xiaoguangbin
befb0de7f1 fix: 核素分析规则增加QC 条件筛选 2025-01-02 14:52:13 +08:00
xiaoguangbin
3aefd94bde fix: 增加mybatis类型转换 解决修改菜单因为Boolean转int sql执行失败问题 2024-12-09 16:10:44 +08:00
xiaoguangbin
db9d27d30d fix: 加载F状态的能谱增加能谱文件找不到提示 2024-12-05 16:24:58 +08:00
xiaoguangbin
10e07c5969 fix: 修改删除能谱功能 增加日志输入和文件夹判断 2024-12-05 16:24:17 +08:00
xiaoguangbin
926aa9fe10 fix:gamma交互工具解决删除核素时重新识别核素会把之前删除的核素识别出来的问题 2024-12-03 11:46:18 +08:00
xiaoguangbin
f97e68c00e fix:setup目录文件 2024-11-28 17:11:43 +08:00
xiaoguangbin
7a6ad817b3 fix:修改配置文件 2024-11-28 17:06:31 +08:00
xiaoguangbin
92f471955d fix:旧beta增加能量刻度自动校正数据;旧beta 自动处理分析失败的能谱也能查询加载 2024-11-28 16:54:47 +08:00
xiaoguangbin
c9b406633d fix:旧beta增加能量刻度自动校正数据 2024-11-25 16:26:24 +08:00
xiaoguangbin
a762d4abab fix:解决自动处理网络不好下载会中断问题 2024-11-25 11:18:45 +08:00
xiaoguangbin
e5bcf3bae0 fix:解决gamma交互工具添加核素之后mdc没有核素的问题 2024-11-18 14:03:59 +08:00
xiaoguangbin
4a0bb05232 fix:解决gamma报告不能生成的问题;解决gamma交互工具添加核素之后mdc没有核素的问题 2024-11-15 10:01:46 +08:00
xiaoguangbin
d71544534c fix:自动处理增加日志写入 2024-11-13 15:56:38 +08:00
xiaoguangbin
8a6e79aef9 fix:排版任务增加日期选择 2024-11-13 09:14:51 +08:00
xiaoguangbin
555a6dd856 fix:修改gamma报告 #MINIMUM 部分,mdc标题增加单位,mda没数据则不显示 2024-10-29 16:08:52 +08:00
xiaoguangbin
7227b70fa8 Revert "fix:修改gamma报告 #MINIMUM 部分,mdc标题增加单位,mda没数据则不显示"
This reverts commit cca97c9ca8.
2024-10-29 16:08:35 +08:00
xiaoguangbin
cca97c9ca8 fix:修改gamma报告 #MINIMUM 部分,mdc标题增加单位,mda没数据则不显示 2024-10-29 16:07:40 +08:00
xiaoguangbin
a5eb7a4ea7 fix:解决异常报警 取核素平均值报错问题 2024-10-22 09:29:45 +08:00
nieziyan
c2c0566dae fix:#MINIMUM数据块 2024-10-08 21:43:34 +08:00
nieziyan
d940f1d6e4 Merge branch 'sleepDownload' into mdc
# Conflicts:
#	jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java
#	jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TemplateUtil.java
#	jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/redisStream/AnalysisConsumer.java
#	jeecg-module-auto-process/src/main/java/org/jeecg/modules/AutoProcessManager.java
#	jeecg-module-auto-process/src/main/java/org/jeecg/modules/EmailParsingActuator.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/DatabaseJob.java
#	jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/ServerJob.java
2024-06-06 15:53:54 +08:00
nieziyan
ff2f73eb41 fix:优化 2024-05-15 09:13:54 +08:00
nieziyan
4bb2518d36 feat:获取探测器Id 2024-05-13 16:25:44 +08:00
qiaoqinzheng
c5ffa77954 自动处理模块模块同步代码 2024-05-13 14:15:05 +08:00
qiaoqinzheng
7b5e167eb2 自动处理模块下载邮件代码修改 2024-05-13 14:10:59 +08:00
nieziyan
cbe8ef9bb0 fix:SQL逻辑判断符 2024-05-13 09:27:23 +08:00
nieziyan
f309792c0d fix:纠正库名 2024-05-11 16:02:33 +08:00
nieziyan
09a23b371b feat:修改分析结果报警[核素首次发现|出现两种及以上] 2024-05-11 15:39:05 +08:00
nieziyan
95a150122c feat:修改分析结果报警条件逻辑 2024-05-08 15:37:52 +08:00
nieziyan
035e842240 feat:自动处理邮箱邮件监控报警逻辑 2024-05-06 18:11:29 +08:00
nieziyan
ebf8958f60 feat:自动处理邮箱邮件监控时间单位 2024-05-06 09:50:46 +08:00
nieziyan
fc978d459e feat:增加自动处理邮箱邮件监控 2024-04-29 17:12:07 +08:00
qiaoqinzheng
99f74539d2 下载邮件增加锁避免异步线程导致邮件内容下载串文件
关闭文件输出流
2024-04-19 16:36:46 +08:00
qiaoqinzheng
a8c32e43bd 同步代码 2024-04-17 09:12:32 +08:00
nieziyan
22b31b5daf fix:消息队列消费模式修改 2024-04-15 18:37:10 +08:00
qiaoqinzheng
d5f40c9023 自动处理模块新增加逻辑,邮箱邮件处理前调用检查方法如果邮件失败处理多次则将邮件从邮箱中移除不影响后续邮件操作 2024-04-01 10:02:38 +08:00
qiaoqinzheng
aa4c2b93d8 人工交互分析beta部分初始化数据时数据库查询的属于因为缓存已经存在的情况导致数据被重置,存储数据库时下标越界问题修改 2024-03-22 09:23:48 +08:00
qiaoqinzheng
2effe67e54 人工交互分析模块Beta保存代码输出语句移除 2024-03-19 17:13:43 +08:00
qiaoqinzheng
2eb2e52e51 人工交互分析模块Beta保存数据代码优化,存储前的分析操作移除,根据分析结果数据存储数据 2024-03-19 16:55:15 +08:00
xiaoguangbin
ae61227d1a fix: 人工交互模块Beta存储日志文件查找本地文件名称错误问题修改 2024-03-15 17:38:10 +08:00
xiaoguangbin
74bc9be6f1 fix: 人工交互模块Beta分析失败的情况下存储数据库接口判断校验字段是否可以存储 2024-03-15 16:00:17 +08:00
xiaoguangbin
9e115f1469 fix: 人工交互模块Beta分析失败的情况下存储数据库接口判断校验字段是否可以存储 2024-03-15 15:57:43 +08:00
xiaoguangbin
797552ea9c fix: 人工交互模块Beta分析失败的情况下返回内容修改
人工交互模块Gamma部分无效的接口删除
2024-03-15 11:57:33 +08:00
qiaoqinzheng
ba7bd409f3 人工交互模块Beta分析算法返回内容增加message字段提示信息 2024-03-15 10:55:00 +08:00
nieziyan
4601af9974 fix:使用枚举方法 2024-03-15 10:17:56 +08:00
nieziyan
73f1dea4e0 feat:Analysis Warn模板 2024-03-14 16:29:27 +08:00
nieziyan
71a4860c63 fix:Eamil Send 2024-03-14 09:14:46 +08:00
252 changed files with 24111 additions and 3719 deletions

View File

@ -124,13 +124,6 @@
<version>${mysql-connector-java.version}</version>
<scope>runtime</scope>
</dependency>
<!-- sqlserver-->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>${sqljdbc4.version}</version>
<scope>runtime</scope>
</dependency>
<!-- oracle驱动 -->
<dependency>
<groupId>com.oracle</groupId>

View File

@ -126,4 +126,8 @@ public class SymbolConstant {
public static final String LINE = "\n";
public static final String AT = "@";
public static final String VERTICAL = "|";
public static final char VERTICAL_CHAR = '|';
}

View File

@ -1,11 +1,17 @@
package org.jeecg.common.email;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.sun.mail.imap.IMAPStore;
import com.sun.mail.pop3.POP3Folder;
import com.sun.mail.smtp.SMTPAddressFailedException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.constant.RedisConstant;
@ -19,6 +25,7 @@ import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.entity.postgre.SysEmail;
import org.jetbrains.annotations.NotNull;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
@ -29,7 +36,9 @@ import javax.mail.search.SearchTerm;
import java.io.*;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.file.Files;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
@ -53,15 +62,25 @@ public class EmailServiceManager {
* 系统启动时间
*/
private Date systemStartupTime;
/** 邮件接收数量 */
/**
* 邮件接收数量
*/
private Integer receiveNum;
/** smtp协议的存储对象 */
private IMAPStore store = null;
/** 邮件附件临时存储路径 */
/**
* smtp协议的存储对象
*/
//private IMAPStore store = null;
private Store store = null;
/**
* 邮件附件临时存储路径
*/
private String temporaryStoragePath;
/** 收件箱 */
/**
* 收件箱
*/
private Folder folder = null;
// 判断协议类型
private String protocol;
private RedisUtil redisUtil;
private Object downloadEmlLocal = new Object();
@ -69,25 +88,27 @@ public class EmailServiceManager {
private final ReentrantLock lock = new ReentrantLock();
@NotNull
public static EmailServiceManager getInstance(){
public static EmailServiceManager getInstance() {
return new EmailServiceManager();
}
/**
* 初始化邮件服务管理器
*
* @param email 邮件属性
*/
public void init(SysEmail email){
public void init(SysEmail email) {
this.email = email;
}
/**
* 初始化邮件服务管理器
*
* @param email 邮件属性
*/
public void init(SysEmail email, Integer receiveNum, String temporaryStoragePath,
Date systemStartupTime, SpectrumPathProperties pathProperties,TaskProperties taskProperties,
RedisUtil redisUtil){
Date systemStartupTime, SpectrumPathProperties pathProperties, TaskProperties taskProperties,
RedisUtil redisUtil) {
this.email = email;
this.receiveNum = receiveNum;
this.temporaryStoragePath = temporaryStoragePath;
@ -100,18 +121,18 @@ public class EmailServiceManager {
/**
* 测试邮件服务连通性
*/
public boolean testConnectEmailServer(){
public boolean testConnectEmailServer() {
Socket socket = new Socket();
boolean flag = false;
try {
socket.connect(new InetSocketAddress(email.getEmailServerAddress(),email.getPort()),3000);
log.info("{}邮件服务连接测试成功",email.getName());
socket.connect(new InetSocketAddress(email.getEmailServerAddress(), email.getPort()), 3000);
log.info("{}邮件服务连接测试成功", email.getName());
flag = true;
} catch (IOException e) {
log.error("{}邮件服务连接测试失败,请检查邮件服务属性配置是否正确或邮件服务未开启,原因{}",email.getName(),e.getMessage());
}finally {
log.error("{}邮件服务连接测试失败,请检查邮件服务属性配置是否正确或邮件服务未开启,原因: ", email.getName(), e);
} finally {
try {
if(null != socket){
if (null != socket) {
socket.close();
}
} catch (IOException e) {
@ -124,16 +145,16 @@ public class EmailServiceManager {
/**
* 接收邮件
*/
public Message[] receiveMail() throws Exception {
public Message[] receiveMail1() throws Exception {
String status = EmailLogManager.STATUS_SUCCESS;
try{
try {
//配置邮件服务属性
Properties properties = new Properties();
properties.put("mail.store.protocol", "imap");
properties.put("mail.imap.host", email.getEmailServerAddress());
properties.put("mail.imap.port",email.getPort());
properties.put("mail.imap.connectiontimeout", "3000"); // 设置连接超时时间为3秒
properties.put("mail.imap.timeout", "3000"); // 设置读取超时时间为3秒
properties.put("mail.imap.port", email.getPort());
properties.put("mail.imap.connectiontimeout", "3000");
properties.put("mail.imap.timeout", "3000");
if (email.getIsQiye() == 1) {
properties.put("mail.imap.ssl.enable", "true");
} else {
@ -142,10 +163,10 @@ public class EmailServiceManager {
HashMap IAM = new HashMap();
//带上IMAP ID信息由key和value组成例如nameversionvendorsupport-email等
IAM.put("name","myname");
IAM.put("version","1.0.0");
IAM.put("vendor","myclient");
IAM.put("support-email","testmail@test.com");
IAM.put("name", "myname");
IAM.put("version", "1.0.0");
IAM.put("vendor", "myclient");
IAM.put("support-email", "testmail@test.com");
//获取邮件回话
final Session session = Session.getDefaultInstance(properties);
@ -154,22 +175,26 @@ public class EmailServiceManager {
//获取smtp协议的存储对象
store = (IMAPStore) session.getStore();
//连接
store.connect(email.getUsername(),email.getPassword());
// 解决163普通邮箱无法建立连接问题
store.id(IAM);
store.connect(email.getUsername(), email.getPassword());
if (email.getEmailServerType() == 1) {
// 解决163普通邮箱无法建立连接问题
((IMAPStore) store).id(IAM);
}
//获取收件箱
folder = store.getFolder("INBOX");//INBOX
folder.open(Folder.READ_WRITE);
//如果邮箱邮件数量 > 0
final int messageCount = folder.getMessageCount();
if(messageCount > 0){
if (messageCount > 0) {
Message[] messages = null;
if(Objects.isNull(this.systemStartupTime)){
int finalNum = messageCount > this.receiveNum?this.receiveNum:messageCount;
if (Objects.isNull(this.systemStartupTime)) {
int finalNum = messageCount > this.receiveNum ? this.receiveNum : messageCount;
//邮箱邮件下标是从1开始的
return folder.getMessages(1,finalNum);
return folder.getMessages(1, finalNum);
}
SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GE,this.systemStartupTime);
SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GE, this.systemStartupTime);
messages = folder.search(searchTerm);
Arrays.sort(messages, (o1, o2) -> {
try {
@ -180,39 +205,164 @@ public class EmailServiceManager {
}
return 0;
});
if(this.receiveNum >= messages.length){
if (this.receiveNum >= messages.length) {
return messages;
}else{
return Arrays.copyOfRange(messages,0,this.receiveNum-1);
} else {
return Arrays.copyOfRange(messages, 0, this.receiveNum - 1);
}
}
} catch (Exception e){
} catch (Exception e) {
status = EmailLogManager.STATUS_ERROR;
log.error("Email connection is abnormal, account is {}, service is {},the reason is {}.",email.getName(),email.getEmailServerAddress(),e.getMessage());
log.error("Email connection is abnormal, account is {}, service is {},the reason is {}.", email.getName(), email.getEmailServerAddress(), e.getMessage());
throw e;
} finally {
EmailLogEvent connectEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,email,status,EmailLogManager.CONNECT);
EmailLogEvent connectEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET, email, status, EmailLogManager.CONNECT);
EmailLogManager.getInstance().setConnectLogEvent(connectEvent);
//GetAllId C++原业务是把远程邮箱邮件同步到C++本次java编写没有这一步所以和Connect绑定若Connect成功则GetAllId成功
EmailLogEvent getAllEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETALLID);
EmailLogEvent getAllEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET, status, EmailLogManager.GETALLID);
EmailLogManager.getInstance().setGetAllIdLogEvent(getAllEvent);
}
return null;
}
public Message[] receiveMail() throws Exception {
String status = EmailLogManager.STATUS_SUCCESS;
try {
store = setStoreProperties();
//获取收件箱
folder = store.getFolder("INBOX");//INBOX
folder.open(Folder.READ_WRITE);
//如果邮箱邮件数量 > 0
final int messageCount = folder.getMessageCount();
if (messageCount > 0) {
Message[] messages = null;
if (Objects.isNull(this.systemStartupTime)) {
int finalNum = messageCount > this.receiveNum ? this.receiveNum : messageCount;
//邮箱邮件下标是从1开始的
return folder.getMessages(1, finalNum);
}
SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GE, this.systemStartupTime);
messages = folder.search(searchTerm);
Arrays.sort(messages, (o1, o2) -> {
try {
if (o1.getReceivedDate() == null && o2.getReceivedDate() == null) {
return o1.getSentDate().compareTo(o2.getSentDate());
} else {
return o1.getReceivedDate().compareTo(o2.getReceivedDate());
}
} catch (MessagingException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
return 0;
});
if (this.receiveNum >= messages.length) {
return messages;
} else {
return Arrays.copyOfRange(messages, 0, this.receiveNum - 1);
}
}
} catch (Exception e) {
status = EmailLogManager.STATUS_ERROR;
log.error("Email connection is abnormal, account is {}, service is {},the reason is {}.", email.getName(), email.getEmailServerAddress(), e.getMessage());
throw e;
} finally {
EmailLogEvent connectEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET, email, status, EmailLogManager.CONNECT);
EmailLogManager.getInstance().setConnectLogEvent(connectEvent);
//GetAllId C++原业务是把远程邮箱邮件同步到C++本次java编写没有这一步所以和Connect绑定若Connect成功则GetAllId成功
EmailLogEvent getAllEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET, status, EmailLogManager.GETALLID);
EmailLogManager.getInstance().setGetAllIdLogEvent(getAllEvent);
}
return null;
}
private Store setStoreProperties() throws MessagingException {
HashMap IAM = new HashMap();
//带上IMAP ID信息由key和value组成例如nameversionvendorsupport-email等
IAM.put("name", "myname");
IAM.put("version", "1.0.0");
IAM.put("vendor", "myclient");
IAM.put("support-email", "testmail@test.com");
Properties properties = getProperties();
//获取邮件回话
Session session = Session.getInstance(properties);
//获取smtp协议的存储对象
Store store = session.getStore();
log.info("连接 {}:{}:{}", email.getUsername(), email.getPassword(), email.getPort());
//连接
store.connect(email.getUsername(), email.getPassword());
if (email.getEmailServerType() == 1) {
// 解决163普通邮箱无法建立连接问题
((IMAPStore) store).id(IAM);
}
protocol = store.getURLName().getProtocol();
return store;
}
@NotNull
private Properties getProperties() {
Properties properties = new Properties();
switch (email.getPort()) {
case 110:
properties.put("mail.store.protocol", "pop3");
properties.put("mail.pop3.host", email.getEmailServerAddress());
properties.put("mail.pop3.port", email.getPort());
properties.put("mail.pop3.starttls.enable", "true");
// 超时设置(毫秒)
properties.put("mail.pop3.connectiontimeout", "10000");
properties.put("mail.pop3.timeout", "15000");
break;
case 995:
properties.put("mail.store.protocol", "pop3");
properties.put("mail.pop3.host", email.getEmailServerAddress());
properties.put("mail.pop3.port", email.getPort());
properties.put("mail.pop3.starttls.enable", "true");
properties.put("mail.pop3.connectiontimeout", "10000");
properties.put("mail.pop3.timeout", "15000");
properties.put("mail.pop3.auth", "true");
break;
case 143:
properties.put("mail.store.protocol", "imap");
properties.put("mail.imap.host", email.getEmailServerAddress());
properties.put("mail.imap.port", email.getPort());
properties.put("mail.imap.ssl.enable", "false");
properties.put("mail.imap.starttls.enable", "true");
properties.put("mail.imap.auth", "true");
// 超时设置(毫秒)
properties.put("mail.imap.connectiontimeout", "10000");
properties.put("mail.imap.timeout", "30000");
break;
case 993:
default:
properties.put("mail.store.protocol", "imap");
properties.put("mail.imap.host", email.getEmailServerAddress());
properties.put("mail.imap.port", email.getPort());
properties.put("mail.imap.connectiontimeout", "3000");
properties.put("mail.imap.timeout", "3000");
if (email.getIsQiye() == 1) {
properties.put("mail.imap.ssl.enable", "true");
} else {
properties.put("mail.imap.ssl.enable", "false");
}
break;
}
return properties;
}
/*
* 测试收件邮箱账号是否可以正常使用
* */
public boolean canReceive(){
public boolean canReceive() {
Integer port = email.getPort();
String username = email.getUsername();
String password = email.getPassword();
String host = email.getEmailServerAddress();
Properties props = new Properties();
props.put("mail.store.protocol","imap");
props.put("mail.imap.host", host);
props.put("mail.imap.port", port);
Properties props = getProperties();
Session session = Session.getInstance(props, new Authenticator() {
@Override
@ -221,26 +371,26 @@ public class EmailServiceManager {
}
});
try(Store store = session.getStore()) {
try (Store store = session.getStore()) {
store.connect(host, username, password);
return store.isConnected();
} catch (Exception e) {
log.error("收件邮箱服务[Host: {}, Port: {}, Username: {}]连接异常: {}",host, port, username, e.getMessage());
log.error("收件邮箱服务[Host: {}, Port: {}, Username: {}]连接异常: {}", host, port, username, e.getMessage());
return false;
}
}
/*
* 测试收件邮箱账号是否可以正常使用(开启了SSL安全验证的邮箱)
* */
public boolean canReceiveSSL(){
* 测试收件邮箱账号是否可以正常使用(开启了SSL安全验证的邮箱)
* */
public boolean canReceiveSSL() {
Integer port = email.getPort();
String username = email.getUsername();
String password = email.getPassword();
String host = email.getEmailServerAddress();
Properties props = new Properties();
props.put("mail.store.protocol","imap");
props.put("mail.store.protocol", "imap");
props.put("mail.imap.host", host);
props.put("mail.imap.port", port);
props.put("mail.imap.auth", "true");
@ -254,19 +404,19 @@ public class EmailServiceManager {
}
});
try(Store store = session.getStore()) {
try (Store store = session.getStore()) {
store.connect(host, username, password);
return store.isConnected();
} catch (Exception e) {
log.error("收件邮箱服务SSL[Host: {}, Port: {}, Username: {}]连接异常: {}",host, port, username, e.getMessage());
log.error("收件邮箱服务SSL[Host: {}, Port: {}, Username: {}]连接异常: {}", host, port, username, e.getMessage());
return false;
}
}
/*
* 测试发件邮箱账号是否可以正常使用
* */
public boolean canSend(){
* 测试发件邮箱账号是否可以正常使用
* */
public boolean canSend() {
Integer port = email.getPort();
String username = email.getUsername();
String password = email.getPassword();
@ -285,19 +435,19 @@ public class EmailServiceManager {
}
});
try (Transport transport = session.getTransport()){
try (Transport transport = session.getTransport()) {
transport.connect(host, username, password);
return true;
} catch (Exception e) {
log.error("发件邮箱服务[Host: {}, Port: {}, Username: {}]连接异常: {}",host, port, username, e.getMessage());
log.error("发件邮箱服务[Host: {}, Port: {}, Username: {}]连接异常: {}", host, port, username, e.getMessage());
return false;
}
}
/*
* 测试发件邮箱账号是否可以正常使用(开启了SSL安全验证的邮箱)
* */
public boolean canSendSSL(){
* 测试发件邮箱账号是否可以正常使用(开启了SSL安全验证的邮箱)
* */
public boolean canSendSSL() {
Integer port = email.getPort();
String username = email.getUsername();
String password = email.getPassword();
@ -318,11 +468,11 @@ public class EmailServiceManager {
}
});
try (Transport transport = session.getTransport()){
try (Transport transport = session.getTransport()) {
transport.connect(host, username, password);
return true;
} catch (Exception e) {
log.error("发件邮箱服务SSL[Host: {}, Port: {}, Username: {}]连接异常: {}",host, port, username, e.getMessage());
log.error("发件邮箱服务SSL[Host: {}, Port: {}, Username: {}]连接异常: {}", host, port, username, e.getMessage());
return false;
}
}
@ -358,7 +508,7 @@ public class EmailServiceManager {
// 发送邮件
Transport transport = session.getTransport();
transport.connect(email.getUsername(),email.getPassword());
transport.connect(email.getUsername(), email.getPassword());
transport.sendMessage(message, message.getAllRecipients());
// 关闭资源
@ -368,7 +518,7 @@ public class EmailServiceManager {
/**
* 发送邮件 群发
*/
public void sendMail(MessageDTO messageDTO){
public void sendMail(MessageDTO messageDTO) {
// 邮箱连接属性
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
@ -393,24 +543,24 @@ public class EmailServiceManager {
InternetAddress.parse(messageDTO.getToUser()));
// 发送邮件
transport = session.getTransport();
transport.connect(email.getUsername(),email.getPassword());
transport.sendMessage(message,message.getAllRecipients());
transport.connect(email.getUsername(), email.getPassword());
transport.sendMessage(message, message.getAllRecipients());
} catch (MessagingException e) {
// 无效的电子邮箱导致群发失败,剔除无效邮箱然后重新发送
Address[] invalid;
if (e instanceof SMTPAddressFailedException) {
invalid = ((SMTPAddressFailedException) e).getInvalidAddresses();
reSendMail(invalid,messageDTO);
reSendMail(invalid, messageDTO);
} else if (e instanceof SendFailedException) {
invalid = ((SendFailedException) e).getInvalidAddresses();
reSendMail(invalid,messageDTO);
reSendMail(invalid, messageDTO);
}
}finally {
if (transport != null){
} finally {
if (transport != null) {
try {
transport.close();
} catch (MessagingException e) {
log.error("Transport关闭失败,{}",e);
log.error("Transport关闭失败,{}", e);
}
}
}
@ -422,20 +572,20 @@ public class EmailServiceManager {
* @param invalid 无效电子邮箱列表
* @param messageDTO 消息dto
*/
private void reSendMail(Address[] invalid,MessageDTO messageDTO){
private void reSendMail(Address[] invalid, MessageDTO messageDTO) {
List<String> invalidEmails = Arrays.stream(invalid)
.map(address -> address.toString())
.collect(Collectors.toList());
log.warn("部分或者全部邮件发送失败,无效的电子邮箱:{}",invalidEmails);
log.warn("部分或者全部邮件发送失败,无效的电子邮箱:{}", invalidEmails);
String[] allEmails = messageDTO.getToUser().split(SymbolConstant.COMMA);
String[] emails = new String[]{};
for (String address : invalidEmails) {
emails = ArrayUtil.removeEle(allEmails,address);
emails = ArrayUtil.removeEle(allEmails, address);
}
// 如果移除无效电子邮箱后,待发送邮箱不为空
String toUser = Arrays.stream(emails)
.collect(Collectors.joining(SymbolConstant.COMMA));
if (StrUtil.isNotBlank(toUser)){
if (StrUtil.isNotBlank(toUser)) {
messageDTO.setToUser(toUser);
sendMail(messageDTO);
}
@ -443,10 +593,11 @@ public class EmailServiceManager {
/**
* 获取邮件主题
*
* @param message
* @return
*/
public String getMailSubject(@NotNull Message message,Integer batchesCounter) throws MessagingException {
public String getMailSubject(@NotNull Message message, Integer batchesCounter) throws MessagingException {
String subject = "";
String status = EmailLogManager.STATUS_SUCCESS;
try {
@ -456,34 +607,61 @@ public class EmailServiceManager {
} catch (MessagingException e) {
status = EmailLogManager.STATUS_ERROR;
throw e;
}finally {
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDHEADER);
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
} finally {
EmailLogEvent event = new EmailLogEvent(batchesCounter, Thread.currentThread().getId(), EmailLogManager.GS_TYPE_GET, status, EmailLogManager.GETIDHEADER);
EmailLogManager.getInstance().offer(Thread.currentThread().getId(), event);
}
return subject;
}
public String getMessagesID(Message message, Integer batchesCounter) throws MessagingException {
String messageId = null;
String status = EmailLogManager.STATUS_SUCCESS;
try {
if (null == message.getHeader("Message-ID")) {
String subject = message.getSubject().replace(" ", StringConstant.UNDER_LINE);
Date date = message.getReceivedDate() == null ? message.getSentDate() : message.getReceivedDate();
String receivedStr = DateUtil.format(date, DatePattern.NORM_DATETIME_MINUTE_PATTERN);
messageId = subject + StringConstant.UNDER_LINE + receivedStr;
} else {
messageId = ((MimeMessage) message).getMessageID();
}
} catch (MessagingException e) {
status = EmailLogManager.STATUS_ERROR;
log.error(e.getMessage());
throw e;
}finally {
EmailLogEvent event = new EmailLogEvent(batchesCounter, Thread.currentThread().getId(), EmailLogManager.GS_TYPE_GET, status, EmailLogManager.GETIDHEADER);
EmailLogManager.getInstance().offer(Thread.currentThread().getId(), event);
}
return messageId;
}
/**
* 获取邮件内容
*
* @param part
* @return
* @throws MessagingException
* @throws IOException
*/
public void getMailContent(@NotNull Part part, StringBuilder content) throws MessagingException, IOException {
if(part.isMimeType(MailContentType.PLAIN.getContentType())){
if (part.isMimeType(MailContentType.PLAIN.getContentType())) {
content.append(part.getContent());
}else if(part.isMimeType("multipart/*")){
} else if (part.isMimeType("multipart/*")) {
Multipart multipart = (Multipart) part.getContent();
for(int i=0;i<multipart.getCount();i++) {
for (int i = 0; i < multipart.getCount(); i++) {
final Part bodyPart = multipart.getBodyPart(i);
getMailContent(bodyPart,content);
getMailContent(bodyPart, content);
}
}
}
/**
* 保存邮件附件
*
* @param part
* @throws MessagingException
* @throws IOException
@ -491,27 +669,27 @@ public class EmailServiceManager {
public List<String> saveAttachment(@NotNull Part part) throws MessagingException, IOException {
List<String> filePathList = Lists.newArrayList();
Multipart multipart = (Multipart) part.getContent();
for(int i=0;i<multipart.getCount();i++){
for (int i = 0; i < multipart.getCount(); i++) {
final BodyPart bodyPart = multipart.getBodyPart(i);
if(Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition())){
if (Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition())) {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try{
try {
final String fileName = MimeUtility.decodeText(bodyPart.getFileName());
bis = new BufferedInputStream(bodyPart.getInputStream());
File file = new File(this.temporaryStoragePath+File.separator+fileName);
File file = new File(this.temporaryStoragePath + File.separator + fileName);
bos = new BufferedOutputStream(new FileOutputStream(file));
byte[] buf = new byte[4096];
int len;
while(-1 != (len = bis.read(buf,0,buf.length))){
bos.write(buf,0,buf.length);
while (-1 != (len = bis.read(buf, 0, buf.length))) {
bos.write(buf, 0, buf.length);
}
filePathList.add(file.getAbsolutePath());
}finally {
if(null != bis){
} finally {
if (null != bis) {
bis.close();
}
if(null != bos){
if (null != bos) {
bos.flush();
bos.close();
}
@ -528,83 +706,75 @@ public class EmailServiceManager {
* 新格式为发件人_主题_年月日_时分秒毫秒_receive_年月日_时分秒毫秒_计数0-10000
* 当计数大于10000后从0开始服务重启后也从0开始
*/
public File downloadEmailToEmlDir(@NotNull Message message,Integer emailCounter,Integer batchesCounter) throws MessagingException {
public File downloadEmailToEmlDir(@NotNull Message message, Integer emailCounter, Integer batchesCounter) throws MessagingException {
synchronized (downloadEmlLocal) {
String subject = "";
File emlFile = null;
String status = EmailLogManager.STATUS_SUCCESS;
Date receivedDate = null;
InputStream inputStream = null;
BufferedOutputStream outputStream = null;
//InputStream inputStream = null;
//BufferedOutputStream outputStream = null;
try {
//获取发件人
final String address = ((InternetAddress) message.getFrom()[0]).getAddress();
final String from = address.substring(0,address.indexOf(StringConstant.AT));
final String from = address.substring(0, address.indexOf(StringConstant.AT));
//获取主题
subject = MimeUtility.decodeText(message.getSubject());
if(subject.indexOf(StringConstant.SLASH) != -1){
subject = StringUtils.replace(subject,StringConstant.SLASH,"");
if (subject.indexOf(StringConstant.SLASH) != -1) {
subject = StringUtils.replace(subject, StringConstant.SLASH, "");
}
if(subject.indexOf(StringConstant.COLON) != -1){
subject = StringUtils.replace(subject,StringConstant.COLON,"");
if (subject.indexOf(StringConstant.COLON) != -1) {
subject = StringUtils.replace(subject, StringConstant.COLON, "");
}
receivedDate = message.getReceivedDate();
receivedDate = message.getReceivedDate() == null ? message.getSentDate() : message.getReceivedDate();
StringBuilder fileName = new StringBuilder();
fileName.append(from);
fileName.append(StringConstant.UNDER_LINE);
fileName.append(subject);
fileName.append(StringConstant.UNDER_LINE);
fileName.append(DateUtils.formatDate(new Date(),"YYMMdd"));
fileName.append(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(DateUtils.formatDate(receivedDate, "YYMMdd"));
fileName.append(StringConstant.UNDER_LINE);
fileName.append(DateUtils.formatDate(receivedDate,"HHmmssSSS"));
fileName.append(DateUtils.formatDate(receivedDate, "HHmmssSSS"));
fileName.append(StringConstant.UNDER_LINE);
fileName.append(emailCounter);
fileName.append(SAVE_EML_SUFFIX);
final String rootPath = spectrumPathProperties.getRootPath();
final String emlPath = spectrumPathProperties.getEmlPath();
emlFile = new File(rootPath+emlPath+File.separator+fileName);
// outputStream = new FileOutputStream(emlFile);
// message.writeTo(outputStream);
emlFile = new File(rootPath + emlPath + File.separator + fileName);
int bufferSize = 1024 * 1024; // 1M
inputStream = message.getInputStream();
outputStream = new BufferedOutputStream(new FileOutputStream(emlFile), bufferSize);
// 从邮件的输入流读取内容并写入到本地文件
byte[] buffer = new byte[bufferSize];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
try (InputStream inputStream = message.getInputStream();
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(emlFile),bufferSize)) {
byte[] buffer = new byte[1024*1024];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.flush(); // 显式刷新
} catch (IOException e) {
FileUtils.copyInputStreamToFile(message.getInputStream(), emlFile);
}
if (emlFile.length() <= 0) {
FileUtils.copyInputStreamToFile(message.getInputStream(), emlFile);
}
} catch (MessagingException | IOException e) {
// 下载邮件失败 抛出自定义邮件下载异常
status = EmailLogManager.STATUS_ERROR;
String errorMsg = StrUtil.format("The email download failed, the subject of the email is {}, the reason is {}.", subject, e.getMessage());
log.error(errorMsg);
throw new DownloadEmailException(errorMsg);
}catch (Exception e) {
log.error("",e);
}finally {
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"),
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
try {
if (Objects.nonNull(inputStream)) {
inputStream.close();
}
if (Objects.nonNull(outputStream)) {
outputStream.flush();
outputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
} catch (Exception e) {
log.error("", e);
throw new RuntimeException(e);
} finally {
EmailLogEvent event = new EmailLogEvent(batchesCounter, Thread.currentThread().getId(), EmailLogManager.GS_TYPE_GET, status, EmailLogManager.GETIDEML, subject, DateUtils.formatDate(receivedDate, "yyyy-MM-dd HH:mm:ss:SSS"),
(Objects.isNull(emlFile) ? " " : emlFile.getAbsolutePath()));
EmailLogManager.getInstance().offer(Thread.currentThread().getId(), event);
}
return emlFile;
}
@ -644,7 +814,7 @@ public class EmailServiceManager {
throw new RuntimeException("下载 eml 执行超时");
}
}*/
public File executeWithLock(Message message,Integer emailCounter,Integer batchesCounter) throws MessagingException {
public File executeWithLock(Message message, Integer emailCounter, Integer batchesCounter) throws MessagingException {
String subject = "";
File emlFile = null;
@ -654,36 +824,36 @@ public class EmailServiceManager {
// 获取锁 设置超时
//获取发件人
final String address = ((InternetAddress) message.getFrom()[0]).getAddress();
final String from = address.substring(0,address.indexOf(StringConstant.AT));
final String from = address.substring(0, address.indexOf(StringConstant.AT));
//获取主题
subject = MimeUtility.decodeText(message.getSubject());
if(subject.contains(StringConstant.SLASH)){
subject = StringUtils.replace(subject,StringConstant.SLASH,"");
if (subject.contains(StringConstant.SLASH)) {
subject = StringUtils.replace(subject, StringConstant.SLASH, "");
}
if(subject.contains(StringConstant.COLON)){
subject = StringUtils.replace(subject,StringConstant.COLON,"");
if (subject.contains(StringConstant.COLON)) {
subject = StringUtils.replace(subject, StringConstant.COLON, "");
}
receivedDate = message.getReceivedDate();
receivedDate = message.getReceivedDate() == null ? message.getSentDate() : message.getReceivedDate();
StringBuilder fileName = new StringBuilder();
fileName.append(from);
fileName.append(StringConstant.UNDER_LINE);
fileName.append(subject);
fileName.append(StringConstant.UNDER_LINE);
fileName.append(DateUtils.formatDate(new Date(),"YYMMdd"));
fileName.append(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(DateUtils.formatDate(receivedDate, "YYMMdd"));
fileName.append(StringConstant.UNDER_LINE);
fileName.append(DateUtils.formatDate(receivedDate,"HHmmssSSS"));
fileName.append(DateUtils.formatDate(receivedDate, "HHmmssSSS"));
fileName.append(StringConstant.UNDER_LINE);
fileName.append(emailCounter);
fileName.append(SAVE_EML_SUFFIX);
final String rootPath = spectrumPathProperties.getRootPath();
final String emlPath = spectrumPathProperties.getEmlPath();
emlFile = new File(rootPath+emlPath+File.separator+fileName);
emlFile = new File(rootPath + emlPath + File.separator + fileName);
// Thread.sleep(6000l);
// try(FileOutputStream outputStream = new FileOutputStream(emlFile)) {
// message.writeTo(outputStream);
@ -696,12 +866,12 @@ public class EmailServiceManager {
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);
} catch (Exception e) {
log.error("", e);
} finally {
EmailLogEvent event = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"),
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
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;
}
@ -709,73 +879,79 @@ public class EmailServiceManager {
public void a(AtomicReference<FileOutputStream> outputStream, Message message) throws MessagingException, IOException {
message.writeTo(outputStream.get());
}
/**
* 删除邮件
*
* @param message
* @throws MessagingException
*/
public void removeMail(@NotNull Message message,Integer batchesCounter){
public void removeMail(@NotNull Message message, Integer batchesCounter) {
String status = EmailLogManager.STATUS_SUCCESS;
String subject = "";
Date receivedDate = null;
try {
subject = MimeUtility.decodeText(message.getSubject());
receivedDate = message.getReceivedDate();
message.setFlag(Flags.Flag.DELETED,true);
receivedDate = message.getReceivedDate() == null ? message.getSentDate() : 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());
log.error("Email deletion failed, the subject of the email is :{}, the reason is :", subject, e);
e.printStackTrace();
} catch (Exception e) {
log.error(e.getMessage(), e);
}finally {
EmailLogEvent removeEvent = new EmailLogEvent(batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,status,EmailLogManager.DELETEID,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"));
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),removeEvent);
} finally {
EmailLogEvent removeEvent = new EmailLogEvent(batchesCounter, Thread.currentThread().getId(), EmailLogManager.GS_TYPE_GET, status, EmailLogManager.DELETEID, subject, DateUtils.formatDate(receivedDate, "yyyy-MM-dd HH:mm:ss:SSS"));
EmailLogManager.getInstance().offer(Thread.currentThread().getId(), removeEvent);
//这里删除和彻底删除一起写入日志java和C++处理有差异java是在连接关闭时彻底删除的
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);
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);
}
}
/**
* 关闭邮件服务连接资源
*/
public void close(List<String> messageIds){
public void close(List<String> messageIds) {
try {
if(null != folder){
folder.expunge();
if (null != folder) {
if ("imap".equalsIgnoreCase(protocol)) {
folder.expunge();
}
folder.close();
}
if(null != store){
if (null != store) {
store.close();
}
log.info(Thread.currentThread().getName() + ",EmailServiceManage资源关闭完成.");
// for(String messageId : messageIds){
// String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;
// redisUtil.del(key);
// }
log.info("{}: EmailServiceManage资源关闭完成.", Thread.currentThread().getName());
for (String messageId : messageIds) {
String key = RedisConstant.EMAIL_MSG_ID + StringConstant.COLON + messageId;
redisUtil.del(key);
}
} catch (MessagingException e) {
log.error("Email closure failed, email address is: {}, reason is: {}",email.getUsername(),e.getMessage());
log.error("Email closure failed, email address is: {}, reason is: {}", email.getUsername(), e);
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
/**
* 校验邮件
* 若此次获取的邮件是上次删除失败的邮件直接删除
*
* @param message
*/
public boolean check(Message message,String messageId){
public boolean check(Message message, String messageId) {
boolean exist = false;
try {
String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;
int numberKey = redisUtil.get(key) != null? (int) redisUtil.get(key):0;
String key = RedisConstant.EMAIL_MSG_ID + StringConstant.COLON + messageId;
int numberKey = redisUtil.get(key) != null ? (int) redisUtil.get(key) : 0;
// exist = redisUtil.hasKey(key);
if(numberKey >= taskProperties.getForceDeletedNumber()){
if (numberKey >= taskProperties.getForceDeletedNumber()) {
exist = true;
log.info("Check: Remove Email:{},receiveTime:{}",message.getSubject(), DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss"));
message.setFlag(Flags.Flag.DELETED,true);
Date dateUtils = message.getReceivedDate() == null ? message.getSentDate() : message.getReceivedDate();
log.info("Check: Remove Email:{},receiveTime:{}", message.getSubject(), DateUtils.formatDate(dateUtils, "yyyy-MM-dd HH:mm:ss"));
message.setFlag(Flags.Flag.DELETED, true);
redisUtil.del(key);
}
return exist;

View File

@ -0,0 +1,48 @@
package org.jeecg.common.handler;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class MybatisTypeHandler extends BaseTypeHandler<Boolean> {
/**
* 功能描述: <br>
* <>
* @param: [ps, i, parameter, jdbcType]
* i:Jdbc预编译时设置参数的索引值
* parameter:要插入的参数值 true 或者false
* jdbcType:要插入JDBC的类型
* 里面的业务逻辑要根据实际开发场景来写 我这里就写的简单一点比较好理解一下
* @return:
* @author: wlt
* @date: 2022/3/22 21:25
**/
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Boolean parameter, JdbcType jdbcType) throws SQLException {
if (parameter){
ps.setInt(i,1);
}else ps.setInt(i,0);
}
@Override
public Boolean getNullableResult(ResultSet rs, String columnName) throws SQLException {
int man = rs.getInt(columnName);
return man == 1 ? true : false;
}
@Override
public Boolean getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
int man = rs.getInt(columnIndex);
return man == 1 ? true : false;
}
@Override
public Boolean getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
int man = cs.getInt(columnIndex);
return man == 1 ? true : false;
}
}

View File

@ -1,13 +1,14 @@
package org.jeecg.common.util;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class DataTool {
private int counter = 1;
private final Map<String, Object> data = new HashMap<>();
private final Map<String, Object> data = new LinkedHashMap<>();
public DataTool put(Object value) {
data.put(String.format("p%d", counter), value);

View File

@ -206,6 +206,29 @@ public class DateUtils extends PropertyEditorSupport {
return sformat.format(nowDate);
}
/**
* 时间字符串格式转换
* @param date 时间字符串
* @param sourceFormat 字符串原有格式
* @param targetFormat 需要转换成的格式
* @return 字符串
*/
public static String dateformat(String date,String sourceFormat,String targetFormat)
{
SimpleDateFormat sformat = new SimpleDateFormat(sourceFormat);
Date nowDate = null;
try {
nowDate = sformat.parse(date);
sformat=new SimpleDateFormat(targetFormat);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return sformat.format(nowDate);
}
/**
* 日期转换为字符串
*

View File

@ -55,6 +55,15 @@ public class NumUtil {
return result;
}
public static String keep6ScienceStr(Double value){
if (ObjectUtil.isNull(value))
return null;
String result = NumberUtil.decimalFormat("0.######E00", value);
if (!StrUtil.contains(result, "E-"))
return StrUtil.replace(result, "E", "E+");
return result;
}
public static Double keep(Double value, int scale){
if (ObjectUtil.isNull(value))
return null;

View File

@ -61,13 +61,42 @@ public class TemplateUtil {
for (String key : keys) {
contents.add(ReUtil.getGroup1(StrUtil.format(pattern, key), templateContent));
}
templateContent = CollUtil.join(contents, "#");
String join = StrUtil.SPACE+ "#"+StrUtil.SPACE;
templateContent = CollUtil.join(contents, join);
String content = FreemarkerParseFactory
.parseTemplateContent(templateContent, data, true);
messageDTO.setContent(content);
String title = FreemarkerParseFactory.parseTemplateContent(templateName,data);
messageDTO.setTitle(title);
return messageDTO;
}
public static MessageDTO parse1(String code, Map<String, Object> data,Map<String,Object> stationData){
MessageDTO messageDTO = new MessageDTO();
SysMessageTemplate template = templateService.getOne(code);
// 如果没有消息模板
if(ObjectUtil.isNull(template))
return messageDTO;
String templateName = template.getTemplateName();
String templateContent = template.getTemplateContent();
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));
}
String replaceStr=System.lineSeparator();
String join = replaceStr+ "#";
templateContent = CollUtil.join(contents, join);
String content = FreemarkerParseFactory
.parseTemplateContent(templateContent, data, true);
messageDTO.setContent(content.replace(":",":"+replaceStr+StrUtil.SPACE));
String title = FreemarkerParseFactory.parseTemplateContent(templateName,stationData);
messageDTO.setTitle(title);
return messageDTO;
}
public static MessageDTO parse(String title, String code, Map<String, Object> data) {
MessageDTO messageDTO = new MessageDTO();
SysMessageTemplate template = templateService.getOne(code);
@ -102,7 +131,8 @@ public class TemplateUtil {
for (String key : keys) {
contents.add(ReUtil.getGroup1(StrUtil.format(pattern, key), templateContent));
}
templateContent = CollUtil.join(contents, "#");
String join = StrUtil.SPACE + "#" + StrUtil.SPACE;
templateContent = CollUtil.join(contents, join);
String content = FreemarkerParseFactory
.parseTemplateContent(templateContent, data, true);
messageDTO.setContent(content);

View File

@ -164,8 +164,8 @@ public class TokenUtils {
String secret = CommonConstant.TEMP_TOKEN_SECRET;
// 模拟登录生成Token
String token = JwtUtil.sign(username, secret);
// 设置Token缓存有效时间为 3 分钟
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token, 3 * 60);
// 设置Token缓存有效时间为 60
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token, 60);
return token;
}
}

View File

@ -27,4 +27,42 @@ public class AlarmAnalysisRuleInfo implements Serializable {
private String contactGroup;
private String remark;
private String sample;
private String sampleType;
private Integer coefficient;
private List<String> colTime;
private List<String> acqTime;
private Double airFlow;
private Double decayTime;
private Double sampVol;
private Double ba140MDC;
private Double be7FWHM;
private List<String> xe133MDC;
private Double xeVol;
private Integer xe131mFlag;
private Integer xe133mFlag;
private Integer xe133Flag;
private Integer xe135Flag;
private Integer days;
private String identifyNuclides;
private List<String> identifyNuclidesChecked;
}

View File

@ -36,4 +36,6 @@ public class EmailDto implements Serializable {
private String username; // 邮箱用户名
private Integer isQiye; // 是否企业邮箱
private Integer emailServerType;
}

View File

@ -9,6 +9,7 @@ import org.jeecg.modules.base.enums.SourceType;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Set;
@Data
@AllArgsConstructor
@ -48,4 +49,6 @@ public class Info implements Serializable{
private String groupId;
private String conditions;
private Set<String> identifyNuclideSet;
}

View File

@ -0,0 +1,11 @@
package org.jeecg.modules.base.dto;
import lombok.Data;
@Data
public class SampNucl {
private String sampleId;
private String nuclideName;
}

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.base.entity.configuration;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +23,7 @@ public class GardsDetectors implements Serializable {
/**
* 探测器id
*/
@TableId(value = "DETECTOR_ID")
@TableId(type = IdType.INPUT)
private Integer detectorId;
/**

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.base.entity.configuration;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -19,57 +20,57 @@ import java.util.Date;
public class GardsStations implements Serializable {
/**
* 台站id
* 台站id
*/
@TableId("STATION_ID")
@TableId(type = IdType.INPUT)
@NotNull(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private Integer stationId;
/**
* 台站编码
* 台站编码
*/
@TableField(value = "STATION_CODE")
@NotBlank(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private String stationCode;
/**
* 城市编码
* 城市编码
*/
@TableField(value = "COUNTRY_CODE")
private String countryCode;
/**
* 台站类型
* 台站类型
*/
@TableField(value = "TYPE")
private String type;
/**
* 经度
* 经度
*/
@TableField(value = "LON")
private Double lon;
/**
* 纬度
* 纬度
*/
@TableField(value = "LAT")
private Double lat;
/**
* 海拔
* 海拔
*/
@TableField(value = "ELEVATION")
private Double elevation;
/**
* 描述
* 描述
*/
@TableField(value = "DESCRIPTION")
private String description;
/**
* 开始运行日期
* 开始运行日期
*/
@TableField(value = "DATE_BEGIN")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ -85,13 +86,13 @@ public class GardsStations implements Serializable {
private Date dateEnd;
/**
* 运行状态
* 运行状态
*/
@TableField(value = "STATUS")
private String status;
/**
* 操作时间
* 操作时间
*/
@TableField(value = "MODDATE")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ -100,5 +101,9 @@ public class GardsStations implements Serializable {
@TableField(value = "CATEGORY")
private Integer category;
/**
* 有效率计算类型
*/
@TableField(value = "EFFIC_CALCUL_TYPE")
private String efficCalculType;
}

View File

@ -22,7 +22,7 @@ public class GardsAlertData implements Serializable {
@TableField(value = "STATION_CODE")
private String stationCode;
@TableId(value = "ALERT_ID",type = IdType.AUTO)
@TableId(type = IdType.AUTO)
private Integer alertId;
@TableField(value = "TIME")

View File

@ -1,6 +1,8 @@
package org.jeecg.modules.base.entity.original;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
@ -19,7 +21,7 @@ public class GardsGPSData implements Serializable {
@TableField(value = "STATION_CODE")
private String stationCode;
@TableField(value = "GPS_ID")
@TableId(type = IdType.AUTO)
private Integer gpsId;
@TableField(value = "LON")

View File

@ -31,7 +31,7 @@ public class GardsMetData implements Serializable {
/**
* 气象数据id
*/
@TableId(value = "MET_ID",type = IdType.AUTO)
@TableId(type = IdType.AUTO)
private Integer metId;
/**

View File

@ -27,7 +27,7 @@ public class GardsSampleData implements Serializable {
* 样品id
*/
@TableId(value = "SAMPLE_ID",type = IdType.AUTO)
@TableId(type = IdType.AUTO)
private Integer sampleId;
/**

View File

@ -31,7 +31,7 @@ public class GardsSohData implements Serializable {
/**
* 报警ID号
*/
@TableId(value = "SOH_ID",type = IdType.AUTO)
@TableId(type = IdType.AUTO)
@Excel(name = "SID",orderNum = "5")
private Integer sohId;

View File

@ -1,21 +1,12 @@
package org.jeecg.modules.base.entity.postgre;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.scheduling.annotation.Scheduled;
import java.math.BigDecimal;
@Data
@TableName("alarm_analysis_rule")
@ -23,6 +14,9 @@ import org.springframework.scheduling.annotation.Scheduled;
@Accessors(chain = true)
public class AlarmAnalysisRule extends JeecgEntity {
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
/** 规则名称 */
private String name;
@ -47,6 +41,55 @@ public class AlarmAnalysisRule extends JeecgEntity {
/** 联系人组id */
private String contactGroup;
private String sample;
private String sampleType;
private BigDecimal coefficient;
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String colTime;
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String acqTime;
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Double airFlow;
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Double decayTime;
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Double sampVol;
@TableField(value = "ba140_mdc", updateStrategy = FieldStrategy.IGNORED)
private Double ba140MDC;
@TableField(value = "be7_fwhm", updateStrategy = FieldStrategy.IGNORED)
private Double be7FWHM;
@TableField(value = "xe133_mdc", updateStrategy = FieldStrategy.IGNORED)
private String xe133MDC;
@TableField(value = "xe_vol", updateStrategy = FieldStrategy.IGNORED)
private Double xeVol;
@TableField(value = "xe131m_flag", updateStrategy = FieldStrategy.IGNORED)
private Integer xe131mFlag;
@TableField(value = "xe133m_flag", updateStrategy = FieldStrategy.IGNORED)
private Integer xe133mFlag;
@TableField(value = "xe133_flag", updateStrategy = FieldStrategy.IGNORED)
private Integer xe133Flag;
@TableField(value = "xe135_flag", updateStrategy = FieldStrategy.IGNORED)
private Integer xe135Flag;
private Integer days;
@TableField(value = "identify_nuclides", updateStrategy = FieldStrategy.IGNORED)
private String identifyNuclides;
/** 备注 */
private String remark;
}

View File

@ -94,4 +94,6 @@ public class SysEmail implements Serializable {
*/
@TableField(value = "update_by")
private String updateBy;
@TableField(value = "email_server_type")
private Integer emailServerType;
}

View File

@ -21,7 +21,7 @@ public class GardsAnalyses implements Serializable {
/**
* 分析ID号
*/
@TableId(value = "IDANALYSIS",type = IdType.AUTO)
@TableId(value = "idanalysis",type = IdType.AUTO)
private Integer idAnalysis;
/**
* 样品id

View File

@ -41,7 +41,7 @@ public class GardsCalibration implements Serializable {
/**
* 拟合方程ID号统一定义
*/
@TableField(value = "FUNCTION")
@TableField(value = "\"FUNCTION\"")
private Integer function;
/**
* 拟合方程描述

View File

@ -1,6 +1,8 @@
package org.jeecg.modules.base.entity.rnman;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
@ -20,7 +22,7 @@ public class GardsAnalyses implements Serializable {
/**
* 分析ID号
*/
@TableField(value = "IDANALYSIS")
@TableId(value = "idanalysis",type = IdType.AUTO)
private Integer idAnalysis;
/**
* 样品id

View File

@ -7,7 +7,22 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum Condition {
FIRST_FOUND("1"), ABOVE_AVERAGE("2"), MEANWHILE("3");
/**
* 首次发现核素
*/
FIRST_FOUND("1"),
/**
* 核素conc超过平均值
*/
ABOVE_AVERAGE("2"),
/**
* 同时识别到多个核素
*/
MEANWHILE("3"),
/**
* 识别到某个核素
*/
IDENTIFY_NUCLIDES("4");
private final String value;

View File

@ -7,12 +7,13 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum Item {
EMAIL_CONN("1", "Connection Status"),
TABLESPACE_USAGE("2", "TableSpace Usage");
EMAIL_CONN("1", "Email Connection Status"),
TABLESPACE_USAGE("2", "TableSpace Usage"),
EMAIL_UNPROCESSED("3", "Email Unprocessed");
private String value;
private final String value;
private String name;
private final String name;
public static Item of(String value){
for (Item item : Item.values()) {

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.base.enums;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
/**
* 资源类型
@ -9,22 +10,19 @@ import cn.hutool.core.util.StrUtil;
* @author nieziyan
* @date 2023-06-30
*/
@Getter
public enum SourceType {
EMAIL("Email"),
DATABASE("Database"),
SERVER("Server");
private String type;
private final String type;
SourceType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public static SourceType typeOf(String type){
for (SourceType sourceType : SourceType.values()) {
if (StrUtil.equals(sourceType.getType(),type))

View File

@ -0,0 +1,13 @@
package org.jeecg.modules.base.enums;
public enum StationDetailType {
SAUNA,
SAUNA2,
SPALAX,
SPALAX_PLC,
Car,
LAB,
CINDER,
RASA,
ARIX_2
}

View File

@ -1,8 +1,12 @@
package org.jeecg.modules.entity.vo;
import cn.hutool.core.util.ObjectUtil;
import lombok.Data;
import org.jeecg.common.util.NumUtil;
import java.io.Serializable;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.List;
@Data
@ -48,4 +52,39 @@ public class CalMDCInfo implements Serializable {
*/
private Double yield;
private Double mda;
private String halfLifeStr = "";
private String mdcStr = "";
private String mdaStr = "";
public void format(){
if (ObjectUtil.isNotNull(halflife))
halfLifeStr = halfLifeStr(halflife);
if (ObjectUtil.isNotNull(mdc))
mdcStr = NumUtil.keep6ScienceStr(mdc);
if (ObjectUtil.isNotNull(mda))
mdaStr = NumUtil.keep6ScienceStr(mda);
}
private String halfLifeStr(Double halflife){
String units = "D";
if (halflife >= 1000) {
halflife = halflife / 365.25;
units = "A";
} else if (halflife < 0.1 && halflife >= 1.0 / 1440.0) {
halflife = halflife * 1440.0;
units = "M";
} else if (halflife <= 1.0 / 1440.0 && halflife > 0.0) {
halflife = halflife * 86400.0;
units = "S";
}
if (halflife < 1000)
return String.format("%.3f", halflife) + units;
NumberFormat numberFormat = new DecimalFormat("0.###E0");
return numberFormat.format(halflife) + units;
}
}

View File

@ -3,10 +3,7 @@ package org.jeecg.modules.entity.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;
@Data
public class GStoreMiddleProcessData implements Serializable {
@ -231,6 +228,8 @@ public class GStoreMiddleProcessData implements Serializable {
//SpecSetup
public SpecSetup setting_specSetup;
public List<CalMDCInfo> mdcInfos;
public GStoreMiddleProcessData(){
dbWriteFlag = false;
dbWriteStatusFlag = "";
@ -419,6 +418,7 @@ public class GStoreMiddleProcessData implements Serializable {
Collection_Station_Comments = "";
NDC_Analysis_General_Comments = "";
setting_specSetup = new SpecSetup();
mdcInfos = new ArrayList<>();
}
}

View File

@ -2,8 +2,10 @@ package org.jeecg.modules.entity.vo;
import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class PeakInfo implements Serializable {
@ -61,11 +63,17 @@ public class PeakInfo implements Serializable {
public List<String> nuclides;
/**
* 记录peak中被删除的核素interactiveTool
*/
public Map<Double, List<String>> deletedNuclideMap;
public PeakInfo(){
nuclides = new LinkedList<>();
comments = "";
recoilBetaChan = "nan";
recoilDeltaChan = "nan";
deletedNuclideMap = new HashMap<>();
}
}

View File

@ -0,0 +1,23 @@
package org.jeecg.modules.entity.vo.QCFlagParmData;
import lombok.Data;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public class ParamConfig {
@XmlElement(name = "collectionTime")
private RuleGroup collectionTime;
@XmlElement(name = "acquisitionTime")
private RuleGroup acquisitionTime;
@XmlElement(name = "xeVolume")
private RuleGroup xeVolume;
@XmlElement(name = "airVolume")
private RuleGroup airVolume;
}

View File

@ -0,0 +1,16 @@
package org.jeecg.modules.entity.vo.QCFlagParmData;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "config")
@XmlAccessorType(XmlAccessType.FIELD)
public class QCFlagParam {
@XmlElement(name = "sauna")
public ParamConfig sauna;
@XmlElement(name = "sauna2")
public ParamConfig sauna2;
}

View File

@ -0,0 +1,20 @@
package org.jeecg.modules.entity.vo.QCFlagParmData;
import lombok.Data;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public class Rule {
@XmlAttribute(name = "min")
private double min;
@XmlAttribute(name = "max")
private Double max; // 使用Double以便可以为null表示没有上限
@XmlAttribute(name = "color")
private String color;
}

View File

@ -0,0 +1,15 @@
package org.jeecg.modules.entity.vo.QCFlagParmData;
import lombok.Data;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import java.util.List;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public class RuleGroup {
@XmlElement(name = "Rule")
List<Rule> rules;
}

View File

@ -1,11 +1,22 @@
package org.jeecg.modules.entity.vo;
import lombok.Data;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.modules.base.enums.StationDetailType;
import org.jeecg.modules.entity.vo.QCFlagParmData.QCFlagParam;
import org.jeecg.modules.entity.vo.QCFlagParmData.Rule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import static org.jeecg.modules.base.enums.StationDetailType.*;
@Data
public class Sections implements Serializable {
@ -17,7 +28,17 @@ public class Sections implements Serializable {
private List<Double> airVolumeSections;
public Sections(){
//region QC-Flag参数
private List<Rule> collectionTimeRules;
private List<Rule> acquisitionTimeRules;
private List<Rule> xeVolumeRules;
private List<Rule> airVolumeRules;
//endregion
public Sections() {
collectionTimeSections = new LinkedList<>();
collectionTimeSections.add(0.0);
collectionTimeSections.add(6.0);
@ -43,4 +64,34 @@ public class Sections implements Serializable {
airVolumeSections.add(10.0);
}
public Sections(StationDetailType sectionsType,String pathname) {
try {
// 创建JAXB上下文
JAXBContext context = JAXBContext.newInstance(QCFlagParam.class);
// 创建Unmarshaller
Unmarshaller unmarshaller = context.createUnmarshaller();
File file = new File(pathname);
QCFlagParam config = (QCFlagParam) unmarshaller.unmarshal(file);
switch (sectionsType) {
case SAUNA:
collectionTimeRules = config.sauna.getCollectionTime().getRules();
acquisitionTimeRules = config.sauna.getAcquisitionTime().getRules();
xeVolumeRules = config.sauna.getXeVolume().getRules();
airVolumeRules = config.sauna.getAirVolume().getRules();
break;
case SAUNA2:
collectionTimeRules = config.sauna2.getCollectionTime().getRules();
acquisitionTimeRules = config.sauna2.getAcquisitionTime().getRules();
xeVolumeRules = config.sauna2.getXeVolume().getRules();
airVolumeRules = config.sauna2.getAirVolume().getRules();
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.entity.vo;
import lombok.Data;
import org.jeecg.common.util.NumUtil;
import java.io.Serializable;
@ -17,4 +18,7 @@ public class TableWidget implements Serializable {
private String fwhmKeV;
public void setChannel(Double channel) {
this.channel = NumUtil.fixedMax(6, channel);
}
}

View File

@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@ -63,8 +64,13 @@ public class SysEmailLogController {
@GetMapping("analysis")
@ApiOperation("根据日期统计-折线图")
public Result<?> analysis(@RequestParam("emailId") String emailId,
@RequestParam("startDate") String startDate,
@RequestParam("endDate") String endDate){
@RequestParam("startDate") String startDate,
@RequestParam("endDate") String endDate){
return sysEmailLogService.analysis(emailId, startDate, endDate);
}
@GetMapping("getMinus")
public Integer getMinus(@RequestParam("emailId") String emailId){
return sysEmailLogService.getMinus(emailId);
}
}

View File

@ -43,5 +43,7 @@ public interface SystemClient {
@PostMapping("/sys/appMessage/pushMessageToSingle")
void pushMessageToSingle(@RequestBody MessageDTO messageDTO, @RequestParam String groupId);
/* GardsSampleDataController下相关接口 */
@GetMapping("/gardsSampleData/getDetectorId")
String getDetectorId(@RequestParam String sampleId);
}

View File

@ -15,6 +15,7 @@ public class NucliedAvgJob implements Job{
@Override
@Scheduled(cron = "${task.period-avg:0 2 0 * * ?}")
// @Scheduled(cron = "${task.period-avg:0/59 0/1 * * * ? }")
public void execute() {
calculateConcService.calcAndSave();
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.dto.SampNucl;
import org.jeecg.modules.base.entity.rnauto.GardsNuclIded;
import java.util.List;
@ -15,5 +16,5 @@ public interface GardsNuclIdedAutoMapper extends BaseMapper<GardsNuclIded> {
List<ConcDto> getConc(Map<String,Object> param);
List<String> nuclideNames(Set<String> nuclideNames);
List<SampNucl> sampNucl(String stationId, String detectorId, Set<String> nuclideNames);
}

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.SampNucl;
import org.jeecg.modules.base.entity.rnman.GardsNuclIded;
import java.util.List;
@ -12,7 +13,7 @@ import java.util.Set;
@Mapper
public interface GardsNuclIdedManMapper extends BaseMapper<GardsNuclIded> {
List<ConcDto> getConc(Map<String,Object> param);
List<ConcDto> getConc(Map<String, Object> param);
List<String> nuclideNames(Set<String> nuclideNames);
List<SampNucl> sampNucl(String stationId, String detectorId, Set<String> nuclideNames);
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.dto.SampNucl;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import java.util.List;
@ -15,5 +16,5 @@ public interface GardsXeResultsAutoMapper extends BaseMapper<GardsXeResults> {
List<ConcDtoXe> getConc(Map<String,Object> params);
List<String> nuclideNames(Set<String> nuclideNames);
List<SampNucl> sampNucl(String stationId, String detectorId, Set<String> nuclideNames);
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.dto.SampNucl;
import org.jeecg.modules.base.entity.rnman.GardsXeResults;
import java.util.List;
@ -15,5 +16,5 @@ public interface GardsXeResultsManMapper extends BaseMapper<GardsXeResults> {
List<ConcDtoXe> getConc(Map<String,Object> params);
List<String> nuclideNames(Set<String> nuclideNames);
List<SampNucl> sampNucl(String stationId, String detectorId, Set<String> nuclideNames);
}

View File

@ -3,6 +3,7 @@
<mapper namespace="org.jeecg.modules.mapper.GardsNuclIdedAutoMapper">
<select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDto">
SELECT
DISTINCT samp.SAMPLE_ID,
nucl.NUCLIDENAME,
nucl.CONCENTRATION AS CONC,
ana.ANALYSISBEGIN
@ -10,31 +11,65 @@
RNAUTO.GARDS_NUCL_IDED nucl
INNER JOIN RNAUTO.GARDS_ANALYSES ana ON ana.IDANALYSIS = nucl.IDANALYSIS
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = nucl.SAMPLE_ID
<where>
INNER JOIN RNAUTO.GARDS_QC_CHECK qc ON samp.SAMPLE_ID = qc.SAMPLE_ID
<trim prefix="where" suffixOverrides="or">
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}
AND samp.SPECTRAL_QUALIFIE = 'FULL'
<if test="nuclideName != null and nuclideName.size() > 0">
AND nucl.NUCLIDENAME IN
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<if test="(colTime != null and colTime.size() > 0) || (acqTime != null and acqTime.size() > 0) ||
airFlow != null || decayTime != null || sampVol != null || be7FWHM != null || ba140MDC != null || xe133MDC != null">
<trim prefix="and(" suffixOverrides="or" suffix=")">
<if test="colTime != null and colTime.size() > 0">
(qc.qc_name = 'col_time' and qc.qc_value between #{colTime[0]} and #{colTime[1]} ) or
</if>
<if test="acqTime != null and acqTime.size() > 0">
(qc.qc_name = 'acq_time' and qc.qc_value = #{acqTime[0]}) or
</if>
<if test="airFlow != null">
(qc.qc_name = 'airFlow' and qc.qc_value &lt; #{airFlow} ) or
</if>
<if test="decayTime != null">
(qc.qc_name = 'decay_time' and qc.qc_value &lt; #{decayTime} ) or
</if>
<if test="sampVol != null">
(qc.qc_name = 'samp_vol' and qc.qc_value &lt; #{sampVol} ) or
</if>
<if test="be7FWHM != null">
(qc.qc_name = 'Be7-FWHM' and qc.qc_value &lt; #{be7FWHM} ) or
</if>
<if test="ba140MDC != null">
(qc.qc_name = 'Ba140-MDC' and qc.qc_value &lt; #{ba140MDC} ) or
</if>
<if test="xe133MDC != null">
(qc.qc_name = 'Xe133-MDC' and qc.qc_value &lt; #{xe133MDC} ) or
</if>
</trim>
</if>
<select id="nuclideNames" resultType="java.lang.String">
</trim>
</select>
<select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl">
SELECT
NUCLIDENAME
n.SAMPLE_ID,
n.NUCLIDENAME AS nuclideName
FROM
RNAUTO.GARDS_NUCL_IDED
WHERE
NUCLIDENAME IN
<foreach collection="nuclideNames" separator="," item="nuclideName" index="index" open="(" close=")">
#{nuclideName}
ORIGINAL.GARDS_SAMPLE_DATA s
INNER JOIN RNAUTO.GARDS_NUCL_IDED n ON s.SAMPLE_ID = n.SAMPLE_ID
WHERE s.STATION_ID = #{stationId} AND s.DETECTOR_ID = #{detectorId}
<if test="nuclideNames != null and nuclideNames.size() > 0">
AND n.NUCLIDENAME IN
<foreach collection="nuclideNames" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
GROUP BY
NUCLIDENAME
</if>
AND n.CONCENTRATION &gt; n.MDC
</select>
</mapper>

View File

@ -3,38 +3,72 @@
<mapper namespace="org.jeecg.modules.mapper.GardsNuclIdedManMapper">
<select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDto">
SELECT
DISTINCT samp.SAMPLE_ID,
nucl.NUCLIDENAME,
nucl.CONCENTRATION AS CONC,
ana.ANALYSISBEGIN
FROM
RNMAN.GARDS_NUCL_IDED nucl
RNMAN.GARDS_NUCL_IDED nucl
INNER JOIN RNMAN.GARDS_ANALYSES ana ON ana.IDANALYSIS = nucl.IDANALYSIS
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = nucl.SAMPLE_ID
INNER JOIN RNMAN.GARDS_QC_CHECK qc ON samp.SAMPLE_ID = qc.SAMPLE_ID
<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}
AND samp.SPECTRAL_QUALIFIE = 'FULL'
<if test="nuclideName != null and nuclideName.size() > 0">
AND nucl.NUCLIDENAME IN
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="(colTime != null and colTime.size() > 0) || (acqTime != null and acqTime.size() > 0) ||
airFlow != null || decayTime != null || sampVol != null || be7FWHM != null || ba140MDC != null || xe133MDC != null">
<trim prefix="and(" suffixOverrides="or" suffix=")">
<if test="colTime != null and colTime.size() > 0">
(qc.qc_name = 'col_time' and qc.qc_value between #{colTime[0]} and #{colTime[1]} ) or
</if>
<if test="acqTime != null and acqTime.size() > 0">
(qc.qc_name = 'acq_time' and qc.qc_value = #{acqTime[0]}) or
</if>
<if test="airFlow != null">
(qc.qc_name = 'airFlow' and qc.qc_value &lt; #{airFlow} ) or
</if>
<if test="decayTime != null">
(qc.qc_name = 'decay_time' and qc.qc_value &lt; #{decayTime} ) or
</if>
<if test="sampVol != null">
(qc.qc_name = 'samp_vol' and qc.qc_value &lt; #{sampVol} ) or
</if>
<if test="be7FWHM != null">
(qc.qc_name = 'Be7-FWHM' and qc.qc_value &lt; #{be7FWHM} ) or
</if>
<if test="ba140MDC != null">
(qc.qc_name = 'Ba140-MDC' and qc.qc_value &lt; #{ba140MDC} ) or
</if>
<if test="xe133MDC != null">
(qc.qc_name = 'Xe133-MDC' and qc.qc_value &lt; #{xe133MDC} ) or
</if>
</trim>
</if>
</where>
</select>
<select id="nuclideNames" resultType="java.lang.String">
<select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl">
SELECT
NUCLIDENAME
n.SAMPLE_ID,
n.NUCLIDENAME AS nuclideName
FROM
RNMAN.GARDS_NUCL_IDED
WHERE
NUCLIDENAME IN
<foreach collection="nuclideNames" separator="," item="nuclideName" index="index" open="(" close=")">
#{nuclideName}
ORIGINAL.GARDS_SAMPLE_DATA s
INNER JOIN RNMAN.GARDS_NUCL_IDED n ON s.SAMPLE_ID = n.SAMPLE_ID
WHERE s.STATION_ID = #{stationId} AND s.DETECTOR_ID = #{detectorId}
<if test="nuclideNames != null and nuclideNames.size() > 0">
AND n.NUCLIDENAME IN
<foreach collection="nuclideNames" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
GROUP BY
NUCLIDENAME
</if>
AND n.CONCENTRATION &gt; n.MDC
</select>
</mapper>

View File

@ -2,39 +2,93 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.mapper.GardsXeResultsAutoMapper">
<select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDtoXe">
SELECT
SELECT * FROM (
SELECT
samp.SAMPLE_ID,
xe.NUCLIDE_NAME,
xe.CONC,
ana.ANALYSISBEGIN
FROM
ana.ANALYSISBEGIN,
xe.NID_FLAG
FROM
RNAUTO.GARDS_XE_RESULTS xe
INNER JOIN RNAUTO.GARDS_ANALYSES ana ON ana.IDANALYSIS = xe.IDANALYSIS
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = xe.SAMPLE_ID
<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=",">
#{item}
</foreach>
</if>
</where>
INNER JOIN RNAUTO.GARDS_ANALYSES ana ON ana.IDANALYSIS = xe.IDANALYSIS
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = xe.SAMPLE_ID
INNER JOIN ORIGINAL.GARDS_SAMPLE_AUX aux ON samp.SAMPLE_ID = aux.SAMPLE_ID
<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}
AND samp.SPECTRAL_QUALIFIE = 'FULL'
<if test="nuclideName != null and nuclideName.size() > 0">
AND xe.NUCLIDE_NAME IN
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="colTime != null and colTime.size() > 0">
and ((TO_NUMBER(samp.COLLECT_STOP - samp.COLLECT_START) * 24) between #{colTime[0]} and #{colTime[1]} )
</if>
<if test="acqTime != null and acqTime.size() > 0">
and (samp.ACQUISITION_LIVE_SEC / 3600 between #{colTime[0]} and #{colTime[1]} )
</if>
<if test="XeVol != null">
AND (aux.XE_VOLUME &gt; #{XeVol} )
</if>
<if test="Xe133MDC != null and Xe133MDC.size() > 0">
AND (xe.NUCLIDE_NAME = 'Xe133m' AND MDC between #{Xe133MDC[0]} AND #{Xe133MDC[1]} )
</if>
</where>
) a
<trim prefix="where" suffixOverrides="or">
<choose>
<when test="Xe133mFlag != null">
(a.NUCLIDE_NAME = 'Xe133m' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe133m' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe133Flag != null">
(a.NUCLIDE_NAME = 'Xe133' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe133' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe131mFlag != null">
(a.NUCLIDE_NAME = 'Xe131m' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe131m' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe135Flag != null">
(a.NUCLIDE_NAME = 'Xe135' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe135' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
</trim>
</select>
<select id="nuclideNames" resultType="java.lang.String">
<select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl">
SELECT
NUCLIDE_NAME
n.SAMPLE_ID,
n.NUCLIDE_NAME
FROM
RNAUTO.GARDS_XE_RESULTS
WHERE
NUCLIDE_NAME IN
<foreach collection="nuclideNames" separator="," item="nuclideName" index="index" open="(" close=")">
#{nuclideName}
</foreach>
GROUP BY
NUCLIDE_NAME
ORIGINAL.GARDS_SAMPLE_DATA s
INNER JOIN RNAUTO.GARDS_XE_RESULTS n ON s.SAMPLE_ID = n.SAMPLE_ID
WHERE s.STATION_ID = #{stationId} AND s.DETECTOR_ID = #{detectorId}
<if test="nuclideNames != null and nuclideNames.size() > 0">
AND n.NUCLIDE_NAME IN
<foreach collection="nuclideNames" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
AND n.NID_FLAG = 1
</select>
</mapper>

View File

@ -2,39 +2,81 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.mapper.GardsXeResultsManMapper">
<select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDtoXe">
SELECT
SELECT * FROM (
SELECT
samp.SAMPLE_ID,
xe.NUCLIDE_NAME,
xe.CONC,
ana.ANALYSISBEGIN
FROM
ana.ANALYSISBEGIN,
xe.NID_FLAG
FROM
RNMAN.GARDS_XE_RESULTS xe
INNER JOIN RNMAN.GARDS_ANALYSES ana ON ana.IDANALYSIS = xe.IDANALYSIS
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = xe.SAMPLE_ID
<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=",">
#{item}
</foreach>
</if>
</where>
INNER JOIN RNMAN.GARDS_ANALYSES ana ON ana.IDANALYSIS = xe.IDANALYSIS
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = xe.SAMPLE_ID
INNER JOIN ORIGINAL.GARDS_SAMPLE_AUX aux ON samp.SAMPLE_ID = aux.SAMPLE_ID
<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}
AND samp.SPECTRAL_QUALIFIE = 'FULL'
<if test="nuclideName != null and nuclideName.size() > 0">
AND xe.NUCLIDE_NAME IN
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
</where>
)a
<trim prefix="where" suffixOverrides="or">
<choose>
<when test="Xe133mFlag != null">
(a.NUCLIDE_NAME = 'Xe133m' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe133m' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe133Flag != null">
(a.NUCLIDE_NAME = 'Xe133' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe133' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe131mFlag != null">
(a.NUCLIDE_NAME = 'Xe131m' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe131m' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe135Flag != null">
(a.NUCLIDE_NAME = 'Xe135' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe135' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
</trim>
</select>
<select id="nuclideNames" resultType="java.lang.String">
<select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl">
SELECT
NUCLIDE_NAME
n.SAMPLE_ID,
n.NUCLIDE_NAME
FROM
RNMAN.GARDS_XE_RESULTS
WHERE
NUCLIDE_NAME IN
<foreach collection="nuclideNames" separator="," item="nuclideName" index="index" open="(" close=")">
#{nuclideName}
ORIGINAL.GARDS_SAMPLE_DATA s
INNER JOIN RNMAN.GARDS_XE_RESULTS n ON s.SAMPLE_ID = n.SAMPLE_ID
WHERE s.STATION_ID = #{stationId} AND s.DETECTOR_ID = #{detectorId}
<if test="nuclideNames != null and nuclideNames.size() > 0">
AND n.NUCLIDE_NAME IN
<foreach collection="nuclideNames" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
GROUP BY
NUCLIDE_NAME
</if>
AND n.NID_FLAG = 1
</select>
</mapper>

View File

@ -36,6 +36,7 @@
e.is_qiye,
e.enabled,
e.email_server_address,
e.email_server_type,
COUNT (l.id) AS alarms
FROM
sys_email e

View File

@ -5,21 +5,20 @@ 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 com.google.common.collect.Maps;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.config.mqtoken.UserTokenContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.RedisConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.constant.enums.SampleType;
import org.jeecg.common.util.*;
import org.jeecg.common.util.dynamic.db.FreemarkerParseFactory;
import org.jeecg.modules.base.dto.NuclideInfo;
import org.jeecg.modules.base.dto.Info;
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisLog;
@ -39,14 +38,11 @@ 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 static org.jeecg.modules.base.enums.Template.ANALYSIS_NUCLIDE;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Data
@ -65,6 +61,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
private IAlarmAnalysisRuleService ruleService;
private AnalysisResultService analysisResultService;
private IAlarmAnalysisNuclideAvgService nuclideAvgService;
private RedisUtil redisUtil;
private final String COMMA = SymbolConstant.COMMA;
@ -98,7 +95,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
redisStreamUtil.del(streamKey, recordId.getValue());
}
}catch (Exception e){
log.error("AnalysisConsumer消费异常: {}", e.getMessage());
log.error("AnalysisConsumer消费异常: ", e);
}finally {
destroy();
}
@ -109,10 +106,11 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
String sampleId = info.getSampleId();
String fullOrPrel = info.getFullOrPrel();
String datasource = info.getDatasource();
Map<String, String> nuclides = info.getNuclides();
Map<String, String> infoNuclideMap = info.getNuclides();
if (StrUtil.isBlank(stationId)) return;
if (StrUtil.isBlank(sampleId)) return;
if (MapUtil.isEmpty(nuclides)) return;
if (MapUtil.isEmpty(infoNuclideMap)) return;
List<AlarmAnalysisRule> rules = ruleService.allAnalysisRule();
for (AlarmAnalysisRule rule : rules) {
// 当前规则是否有报警条件
@ -134,18 +132,36 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
// 是否有当前规则关注的核素
String nuclidesStr = rule.getNuclides();
if (StrUtil.isBlank(nuclidesStr)) continue;
Set<String> names = nuclides.keySet();
Set<String> names = infoNuclideMap.keySet();
List<String> follow = ListUtil.toList(nuclidesStr.split(COMMA));
// 因数据库 Xe核素名称 M大小写不统一先统一大小写再进行比较
Collection<String> follows = follow.stream().map(f -> {
if(f.toLowerCase().contains("xe")){
return f.replace("M", "m");
}
return f;
}).collect(Collectors.toList());
// 推送过来的核素集合与所关注核素集合取交集
Collection<String> cross = CollectionUtil.intersection(names, follow);
Collection<String> cross = CollectionUtil.intersection(names, follows);
if (CollUtil.isEmpty(cross)) continue;
Map<String, String> nuclidesCross = nuclides.entrySet().stream()
Map<String, String> nuclidesCross = infoNuclideMap.entrySet().stream()
.filter(entry -> cross.contains(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
// 开始对交集中的核素进行条件判断
info.setRuleId(rule.getId());
info.setGroupId(rule.getContactGroup());
info.setConditions(rule.getConditions());
if (null != rule.getIdentifyNuclides()) {
String[] inSplit = rule.getIdentifyNuclides().split(",");
if (inSplit.length >= 1) {
info.setIdentifyNuclideSet(Arrays.stream(inSplit).map(f -> {
if(f.toLowerCase().contains("xe")){
return f.replace("M", "m");
}
return f;
}).collect(Collectors.toSet()));
}
}
judge(info, nuclidesCross);
}
}
@ -156,27 +172,37 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
String betaOrGamma = info.getBetaOrGamma();
String datasource = info.getDatasource();
String stationId = info.getStationId();
String stationCode="";
HashMap<String, Object> stationMap = (HashMap<String, Object>)redisUtil.get(RedisConstant.STATION_CODE_MAP);
String sampleId = info.getSampleId();
String sampleName = info.getSampleName();
Set<String> identifyNuclideSet = info.getIdentifyNuclideSet();
// 获取谱文件采样日期 如果为null 则默认为LocalDate.now()
LocalDate collDate = ObjectUtil.isNull(info.getCollectionDate()) ? LocalDate.now() :
info.getCollectionDate().toLocalDate();
List<String> conditions = ListUtil.toList(conditionStr.split(COMMA));
List<String> firstDetected = new ArrayList<>(); // 首次发现
List<NuclideInfo> firstDetected = new ArrayList<>(); // 首次发现
List<NuclideInfo> moreThanAvg = new ArrayList<>(); // 超浓度均值
List<String> meanwhile = new ArrayList<>(); // 同时出现两种及以上核素
List<NuclideInfo> meanWhile = new ArrayList<>(); // 同时出现两种及以上核素
Map<String, NuclideInfo> nuclideInfoMap = Maps.newHashMap();
List<NuclideInfo> identifyNuclideResult = new ArrayList<>();
for (String con : conditions) {
Condition condition = Condition.valueOf1(con);
if (ObjectUtil.isNull(condition)) continue;
switch (condition){
case FIRST_FOUND: // 首次发现该元素
firstDetected = firstDetected(betaOrGamma, datasource, nuclideNames);
firstDetected = this.firstDetected(betaOrGamma, datasource, stationId, sampleId, nuclidesCross);
break;
case ABOVE_AVERAGE: // 元素浓度高于均值
moreThanAvg = moreThanAvg(datasource, stationId, collDate, nuclidesCross);
moreThanAvg = this.moreThanAvg(datasource, stationId, collDate, nuclidesCross);
break;
case MEANWHILE: // 同时出现两种及以上核素
if (CollUtil.isNotEmpty(nuclideNames) && nuclideNames.size() >= 2)
meanwhile.addAll(nuclideNames);
meanWhile = this.meanWhile(betaOrGamma, datasource, sampleId, nuclidesCross);
if (meanWhile.size() < 2) meanWhile = ListUtil.empty();
break;
case IDENTIFY_NUCLIDES: // 识别到某个核素
identifyNuclideResult = this.meanWhile(info.getNuclides(), datasource, identifyNuclideSet);
break;
default:
break;
@ -184,19 +210,54 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
}
// 构建预警信息
DataTool dataTool = DataTool.getInstance();
if (CollUtil.isNotEmpty(firstDetected))
dataTool.put("firstDetected", CollUtil.join(firstDetected, StrUtil.COMMA + StrUtil.SPACE));
if (CollUtil.isNotEmpty(firstDetected)) {
String above = firstDetected.stream()
.map(NuclideInfo::getNuclide)
.collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE));
dataTool.put("firstDetected", above);
for (NuclideInfo nuclideInfo : firstDetected) {
nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo);
}
}
if (CollUtil.isNotEmpty(meanWhile)){
String above = meanWhile.stream()
.map(NuclideInfo::getNuclide)
.collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE));
dataTool.put("meanwhile", above);
for (NuclideInfo nuclideInfo : meanWhile) {
nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo);
}
}
if (CollUtil.isNotEmpty(identifyNuclideResult)){
String above = identifyNuclideResult.stream()
.map(NuclideInfo::getNuclide)
.collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE));
dataTool.put("identifyNuclide", above);
for (NuclideInfo nuclideInfo : identifyNuclideResult) {
nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo);
}
}
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);
for (NuclideInfo nuclideInfo : moreThanAvg) {
nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo);
}
}
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());
// 产生报警信息的Sample信息
if (CollUtil.isNotEmpty(stationMap))
{
stationCode=stationMap.get(stationId).toString();
}
dataTool.put("sampleId", sampleId).put("sampleName", sampleName);
DataTool titleData = DataTool.getInstance();
titleData.put("stationCode",stationCode);
// 构建预警信息实例 准备发送预警信息,20250327--修改模版
MessageDTO messageDTO = TemplateUtil.parse1(ANALYSIS_NUCLIDE.getCode(), dataTool.get(),titleData.get());
// 保存报警日志
AlarmAnalysisLog logInfo = new AlarmAnalysisLog();
BeanUtil.copyProperties(info, logInfo);
@ -204,8 +265,13 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
if (ObjectUtil.isNotNull(sampleType))
logInfo.setSampleType(sampleType.getValue());
logInfo.setAlarmInfo(messageDTO.getContent());
if (CollUtil.isNotEmpty(moreThanAvg))
logInfo.setNuclideInfoList(moreThanAvg);
// 报警信息中核素列表
if (MapUtil.isNotEmpty(nuclideInfoMap)) {
List<NuclideInfo> nuclideInfoList = Lists.newArrayList();
nuclideInfoMap.forEach((key, value) -> nuclideInfoList.add(nuclideInfoMap.get(key)));
logInfo.setNuclideInfoList(nuclideInfoList);
}
logService.saveLog(logInfo);
// 发送报警信息
String groupId = info.getGroupId();
@ -216,13 +282,32 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
/**
* 首次发现该核素
*/
private List<String> firstDetected(String betaOrGamma,
String dataSourceType,
Set<String> nuclideNames){
List<String> existNames = analysisResultService
.nuclideNames(betaOrGamma, dataSourceType, nuclideNames);
// 两个集合元素相减
return CollUtil.subtractToList(nuclideNames, existNames);
private List<NuclideInfo> firstDetected(String betaOrGamma, String dataSourceType,
String stationId, String sampleId, Map<String,String> nuclidesCross){
List<NuclideInfo> result = Lists.newArrayList();
/* 查询用户关注的核素是否存在 如果不存在则为首次发现该核素
判断核素是否存在的条件: 该核素的Conc值是否大于MDC值
*/
String detectorId = systemClient.getDetectorId(sampleId);
if (StrUtil.isBlank(detectorId)) {
throw new RuntimeException("detectorId is null or empty");
}
Set<String> nuclideNames = nuclidesCross.keySet();
List<String> list = analysisResultService.nuclideFirst(betaOrGamma, dataSourceType, stationId,
detectorId, sampleId, nuclideNames);
if(CollUtil.isNotEmpty(list)){
for (Map.Entry<String, String> f : nuclidesCross.entrySet()) {
if(list.contains(f.getKey())){
NuclideInfo nuclideInfo = new NuclideInfo();
nuclideInfo.setNuclide(f.getKey());
nuclideInfo.setDatasource(DSType.typeOf(dataSourceType));
// 对浓度值保留五位小数
nuclideInfo.setValue(NumUtil.keepStr(f.getValue(), 5));
result.add(nuclideInfo);
}
}
}
return result;
}
/**
@ -240,8 +325,6 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
String nuclideName = nuclide.getKey();
String concValue = nuclide.getValue();// 浓度值
String avgValue = nuclideAvgs.get(nuclideName);// 浓度均值
if (StrUtil.isBlank(concValue) || StrUtil.isBlank(avgValue))
continue;
if (!NumberUtil.isNumber(concValue) || !NumberUtil.isNumber(avgValue))
continue;
BigDecimal conc = new BigDecimal(concValue);
@ -260,6 +343,52 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
return nuclideInfos;
}
/*
* 是否同时存在两种及以上核素
* */
private List<NuclideInfo> meanWhile(String betaOrGamma, String dataSourceType,
String sampleId, Map<String,String> nuclidesCross){
List<NuclideInfo> result = Lists.newArrayList();
/* 查询用户关注的核素中 该谱中是否存在两种及以上核素
判断核素是否存在的条件: 该核素的Conc值是否大于MDC值
*/
Set<String> nuclideNames = nuclidesCross.keySet();
List<String> list = analysisResultService.nuclideExist(betaOrGamma, dataSourceType, sampleId, nuclideNames);
if(CollUtil.isNotEmpty(list)){
for (Map.Entry<String, String> f : nuclidesCross.entrySet()) {
if(list.contains(f.getKey())){
NuclideInfo nuclideInfo = new NuclideInfo();
nuclideInfo.setNuclide(f.getKey());
nuclideInfo.setDatasource(DSType.typeOf(dataSourceType));
// 对浓度值保留五位小数
nuclideInfo.setValue(NumUtil.keepStr(f.getValue(), 5));
result.add(nuclideInfo);
}
}
}
return result;
}
/*
* 是否同时存在两种及以上核素
* */
private List<NuclideInfo> meanWhile(Map<String,String> nuclideMap, String dataSourceType, Set<String> nuclideNames){
List<NuclideInfo> result = Lists.newArrayList();
/* 查询用户关注的核素中 该谱中是否存在两种及以上核素
判断核素是否存在的条件: 该核素的Conc值是否大于MDC值
*/
for (String name : nuclideNames) {
if(nuclideMap.containsKey(name)){
NuclideInfo nuclideInfo = new NuclideInfo();
nuclideInfo.setNuclide(name);
nuclideInfo.setDatasource(DSType.typeOf(dataSourceType));
// 对浓度值保留五位小数
nuclideInfo.setValue(NumUtil.keepStr(nuclideMap.get(name), 5));
result.add(nuclideInfo);
}
}
return result;
}
private void init() {
// start 生成临时Token到线程中
UserTokenContext.setToken(getTempToken());
@ -269,6 +398,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
ruleService = SpringContextUtils.getBean(IAlarmAnalysisRuleService.class);
analysisResultService = SpringContextUtils.getBean(AnalysisResultService.class);
nuclideAvgService = SpringContextUtils.getBean(IAlarmAnalysisNuclideAvgService.class);
redisUtil = SpringContextUtils.getBean(RedisUtil.class);
}
private void destroy(){

View File

@ -5,7 +5,10 @@ import java.util.Set;
public interface AnalysisResultService {
List<String> nuclideNames(String betaOrGamma,
String dataSourceType,
Set<String> nuclideNames);
List<String> nuclideExist(String betaOrGamma, String dataSourceType,
String sampleId, Set<String> nuclideNames);
List<String> nuclideFirst(String betaOrGamma, String dataSourceType,
String stationId, String detectorId,
String sampleId, Set<String> nuclideNames);
}

View File

@ -2,7 +2,6 @@ package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnauto.GardsNuclIded;
import java.util.List;
@ -13,5 +12,8 @@ public interface IGardsNuclIdedAutoService extends IService<GardsNuclIded> {
List<ConcDto> getConc(Map<String,Object> params);
List<String> nuclideNames(Set<String> nuclideNames);
List<String> nuclideExist(String sampleId, Set<String> nuclideNames);
List<String> nuclideFirst(String stationId, String detectorId,
String sampleId, Set<String> nuclideNames);
}

View File

@ -10,7 +10,10 @@ import java.util.Set;
public interface IGardsNuclIdedManService extends IService<GardsNuclIded> {
List<ConcDto> getConc(Map<String,Object> params);
List<ConcDto> getConc(Map<String, Object> params);
List<String> nuclideNames(Set<String> nuclideNames);
List<String> nuclideExist(String sampleId, Set<String> nuclideNames);
List<String> nuclideFirst(String stationId, String detectorId,
String sampleId, Set<String> nuclideNames);
}

View File

@ -1,7 +1,6 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
@ -13,5 +12,8 @@ public interface IGardsXeResultsAutoService extends IService<GardsXeResults> {
List<ConcDtoXe> getConc(Map<String,Object> params, Set<String> nuclides);
List<String> nuclideNames(Set<String> nuclideNames);
List<String> nuclideExist(String sampleId, Set<String> nuclideNames);
List<String> nuclideFirst(String stationId, String detectorId,
String sampleId, Set<String> nuclideNames);
}

View File

@ -1,7 +1,6 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.entity.rnman.GardsXeResults;
@ -13,5 +12,8 @@ public interface IGardsXeResultsManService extends IService<GardsXeResults> {
List<ConcDtoXe> getConc(Map<String,Object> params, Set<String> nuclides);
List<String> nuclideNames(Set<String> nuclideNames);
List<String> nuclideExist(String sampleId, Set<String> nuclideNames);
List<String> nuclideFirst(String stationId, String detectorId,
String sampleId, Set<String> nuclideNames);
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
import java.util.List;
import java.util.Map;
public interface ISysEmailLogService extends IService<SysEmailLog> {
@ -16,4 +17,6 @@ public interface ISysEmailLogService extends IService<SysEmailLog> {
Result<?> todayMin(String emailId);
Result<?> analysis(String emailId, String startDate, String endDate);
Integer getMinus(String emailId);
}

View File

@ -135,6 +135,9 @@ public class AlarmAnalysisRuleServiceImpl extends ServiceImpl<AlarmAnalysisRuleM
@Override
public Result add(AlarmAnalysisRule alarmAnalysisRule) {
String name = alarmAnalysisRule.getName();
if (null != alarmAnalysisRule.getIdentifyNuclides()) {
alarmAnalysisRule.setConditions(alarmAnalysisRule.getConditions() + ",4");
}
if (ObjectUtil.isNotNull(getByName(name)))
return Result.error("Rule Name" + Prompt.NOT_REPEAT);
boolean success = save(alarmAnalysisRule);
@ -150,6 +153,11 @@ public class AlarmAnalysisRuleServiceImpl extends ServiceImpl<AlarmAnalysisRuleM
String id = alarmAnalysisRule.getId();
String name = alarmAnalysisRule.getName();
String original = getById(id).getName();
if (null != alarmAnalysisRule.getIdentifyNuclides() && !alarmAnalysisRule.getConditions().contains("4")) {
alarmAnalysisRule.setConditions(alarmAnalysisRule.getConditions() + ",4");
} else if(null == alarmAnalysisRule.getIdentifyNuclides() && alarmAnalysisRule.getConditions().contains("4")) {
alarmAnalysisRule.setConditions(alarmAnalysisRule.getConditions().replace("4", ""));
}
if (!StrUtil.equalsIgnoreCase(name,original)){
if (ObjectUtil.isNotNull(getByName(name)))
return Result.error("Rule Name" + Prompt.NOT_REPEAT);
@ -183,6 +191,30 @@ public class AlarmAnalysisRuleServiceImpl extends ServiceImpl<AlarmAnalysisRuleM
List<String> conditionChecked = ListUtil
.toList(analysisRule.getConditions().split(comma));
analysisRuleInfo.setConditionChecked(conditionChecked);
if (null != analysisRule.getColTime()) {
List<String> colTimes = ListUtil
.toList(analysisRule.getColTime().split(comma));
analysisRuleInfo.setColTime(colTimes);
}
if (null != analysisRule.getAcqTime()) {
List<String> acqTimes = ListUtil
.toList(analysisRule.getAcqTime().split(comma));
analysisRuleInfo.setAcqTime(acqTimes);
}
if (null != analysisRule.getXe133MDC()) {
List<String> xe133MDC = ListUtil
.toList(analysisRule.getXe133MDC().split(comma));
analysisRuleInfo.setXe133MDC(xe133MDC);
}
if (null != analysisRule.getIdentifyNuclides()) {
List<String> inList = ListUtil
.toList(analysisRule.getIdentifyNuclides().split(comma));
analysisRuleInfo.setIdentifyNuclidesChecked(inList);
}
return Result.OK(analysisRuleInfo);
}

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.ListUtil;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.feignclient.SystemClient;
import org.jeecg.modules.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -26,25 +27,51 @@ public class AnalysisResultServiceImpl implements AnalysisResultService {
@Override
public List<String> nuclideNames(String betaOrGamma, String dataSourceType, Set<String> nuclideNames) {
public List<String> nuclideExist(String betaOrGamma, String dataSourceType,
String sampleId, Set<String> nuclideNames) {
if (CommonConstant.ARMDARR.equals(dataSourceType)){
if (CommonConstant.BETA.equals(betaOrGamma)){
return xeResultsAutoService.nuclideNames(nuclideNames);
return xeResultsAutoService.nuclideExist(sampleId, nuclideNames);
}else if (CommonConstant.GAMMA.equals(betaOrGamma)){
return nuclIdedAutoService.nuclideNames(nuclideNames);
return nuclIdedAutoService.nuclideExist(sampleId, nuclideNames);
}else {
return ListUtil.toList(nuclideNames);
return ListUtil.empty();
}
} else if (CommonConstant.ARMDRRR.equals(dataSourceType)) {
if (CommonConstant.BETA.equals(betaOrGamma)){
return xeResultsManService.nuclideNames(nuclideNames);
return xeResultsManService.nuclideExist(sampleId, nuclideNames);
}else if (CommonConstant.GAMMA.equals(betaOrGamma)){
return nuclIdedManService.nuclideNames(nuclideNames);
return nuclIdedManService.nuclideExist(sampleId, nuclideNames);
}else {
return ListUtil.toList(nuclideNames);
return ListUtil.empty();
}
}else {
return ListUtil.toList(nuclideNames);
return ListUtil.empty();
}
}
@Override
public List<String> nuclideFirst(String betaOrGamma, String dataSourceType,
String stationId, String detectorId,
String sampleId, Set<String> nuclideNames) {
if (CommonConstant.ARMDARR.equals(dataSourceType)){
if (CommonConstant.BETA.equals(betaOrGamma)){
return xeResultsAutoService.nuclideFirst(stationId, detectorId, sampleId, nuclideNames);
}else if (CommonConstant.GAMMA.equals(betaOrGamma)){
return nuclIdedAutoService.nuclideFirst(stationId, detectorId, sampleId, nuclideNames);
}else {
return ListUtil.empty();
}
} else if (CommonConstant.ARMDRRR.equals(dataSourceType)) {
if (CommonConstant.BETA.equals(betaOrGamma)){
return xeResultsManService.nuclideFirst(stationId, detectorId, sampleId, nuclideNames);
}else if (CommonConstant.GAMMA.equals(betaOrGamma)){
return nuclIdedManService.nuclideFirst(stationId, detectorId, sampleId, nuclideNames);
}else {
return ListUtil.empty();
}
}else {
return ListUtil.empty();
}
}
}

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@ -28,7 +29,6 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -76,11 +76,33 @@ public class CalculateConcServiceImpl implements CalculateConcService {
String comma = SymbolConstant.COMMA;
// 获取所有生效的报警规则
List<AlarmAnalysisRule> analysisRules = analysisRuleService.allAnalysisRule();
List<AlarmAnalysisNuclideAvg> autoAvgs = new ArrayList<>(); // Auto
List<AlarmAnalysisNuclideAvg> manAvgs = new ArrayList<>(); // Man
// 初始化台站类型
init();
// 对所有报警规则的关注台站和关注核素进行统计
Map<String, Set<String>> nuclideMap = new HashMap<>(); // key:台站code value:核素列表
for (AlarmAnalysisRule analysisRule : analysisRules) {
Map<String,Object> params = new HashMap<>();
BigDecimal coefficient = analysisRule.getCoefficient();
// 获取平均值计算的日期区间系数
Integer days = analysisRule.getDays();
LocalDate dayAgo = LocalDate.now().minusDays(1);
LocalDate daysAgo = dayAgo.minusDays(days);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE);
String startDate = daysAgo.format(formatter);
String endDate = dayAgo.format(formatter);
params.put("startDate",startDate + DateConstant.TIME_START);
params.put("endDate",endDate + DateConstant.TIME_END);
String stationStr = analysisRule.getStations();
String nuclideStr = analysisRule.getNuclides();
// QC Flags
params.putAll(this.getRuleQcFlagParams(analysisRule));
// 获取关注台站
List<String> stations = ListUtil.toList(StrUtil.split(stationStr, comma));
// 获取关注核素
@ -93,89 +115,75 @@ public class CalculateConcServiceImpl implements CalculateConcService {
}else {
nuclideMap.put(station, nuclides);
}
}
}
// 核素浓度值查询参数准备
Map<String,Object> params = new HashMap<>();
AlarmAnalysisNuclideParam paramLatest = nuclideParamService.getLatest();
BigDecimal index = paramLatest.getIndex();
Integer days = paramLatest.getDays();
LocalDate dayAgo = LocalDate.now().minusDays(1);
LocalDate daysAgo = dayAgo.minusDays(days);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE);
String startDate = daysAgo.format(formatter);
String endDate = dayAgo.format(formatter);
params.put("startDate",startDate + DateConstant.TIME_START);
params.put("endDate",endDate + DateConstant.TIME_END);
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));
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));
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);
// 查询指定台站的所有的核素浓度 并计算核素浓度均值
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:
if (analysisRule.getSource().contains("1")) {
xeConcAuto = xeResultsAutoService.getConc(params, nuclides); // beta-gamma Auto
}
if(analysisRule.getSource().contains("2")){
xeConcMan = xeResultsManService.getConc(params, nuclides); // beta-gamma Man
}
break;
case GAMMA:
params.put("nuclideName", nuclides);
if (analysisRule.getSource().contains("1")) {
nuclConcAuto = nuclIdedAutoService.getConc(params); // gamma Auto
}
if(analysisRule.getSource().contains("2")){
nuclConcMan = nuclIdedManService.getConc(params); // gamma Man
}
break;
default:
break;
}
// Auto
Map<String, String> autoResult = new HashMap<>();
autoResult.putAll(calculate(concDto(xeConcAuto), coefficient));
autoResult.putAll(calculate(nuclConcAuto, coefficient));
for (String nuclide : nuclides) {
String val = autoResult.get(nuclide);
if(StrUtil.isBlank(val)) continue;
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), coefficient));
manResult.putAll(calculate(nuclConcMan, coefficient));
for (String nuclide : nuclides) {
String val = manResult.get(nuclide);
if(StrUtil.isBlank(val)) continue;
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(allAvgs));
}
// 计算周期和计算日期
String cycle = startDate + SymbolConstant.WELL_NUMBER + endDate;
allAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo));
nuclideAvgService.saveBatch(allAvgs);
// 记录日志
log.info(log(allAvgs));
}catch (Exception e){
log.error("NucliedAvgJob执行异常: {}", e.getMessage());
log.error("NucliedAvgJob执行异常: ", e);
}
}
@ -194,15 +202,24 @@ public class CalculateConcServiceImpl implements CalculateConcService {
.sorted(Comparator.comparing(ConcDto::getAnalysisBegin))
.collect(Collectors.toList());
if (CollUtil.isEmpty(values)) continue;
int baseLine = values.size();
/**int baseLine = values.size();
BigDecimal line = new BigDecimal(baseLine);
int i = line.multiply(index).setScale(0, RoundingMode.HALF_UP).intValue();
int j = Math.max(i - 1, 0);
result.put(nuclide, values.get(j).getConc());
result.put(nuclide, values.get(j).getConc());**/
// 改为求conc平均值 fix: 20250102 xiao
double sum = 0;
for (ConcDto dto : values) {
sum += Double.valueOf(dto.getConc());
}
BigDecimal avg = index.multiply(new BigDecimal(sum / values.size()));
result.put(nuclide, String.valueOf(avg.setScale(5, RoundingMode.HALF_UP).doubleValue()));
}
return result;
}
private List<ConcDto> concDto(List<ConcDtoXe> concDtoXes){
List<ConcDto> concDtos = new ArrayList<>();
if (CollUtil.isEmpty(concDtoXes)) return concDtos;
@ -248,4 +265,44 @@ public class CalculateConcServiceImpl implements CalculateConcService {
return StationType.BETA;
return StationType.GAMMA;
}
/**
* 获取报警规则中QC质量筛选参数
* @param analysisRule
* @return
*/
private Map<String, Object> getRuleQcFlagParams(AlarmAnalysisRule analysisRule){
Map<String,Object> params = new HashMap<>();
List<String> colTime = StrUtil.isNotBlank(analysisRule.getColTime())
? ListUtil.toList(StrUtil.split(analysisRule.getColTime(), SymbolConstant.COMMA)) : null;
if(null != colTime) {
params.put("colTime", colTime);
}
List<String> acqTime = StrUtil.isNotBlank(analysisRule.getAcqTime())
? ListUtil.toList(StrUtil.split(analysisRule.getAcqTime(), SymbolConstant.COMMA)) : null;
if(null != acqTime) {
params.put("acqTime", acqTime);
}
List<String> xe133MDC = StrUtil.isNotBlank(analysisRule.getXe133MDC())
? ListUtil.toList(StrUtil.split(analysisRule.getXe133MDC(), SymbolConstant.COMMA)) : null;
if(null != xe133MDC) {
params.put("Xe133MDC", xe133MDC);
}
if(null != analysisRule.getAirFlow()) params.put("airFlow", analysisRule.getAirFlow());
if(null != analysisRule.getDecayTime()) params.put("decayTime", analysisRule.getDecayTime());
if(null != analysisRule.getSampVol()) params.put("sampVol", analysisRule.getSampVol());
if(null != analysisRule.getBa140MDC()) params.put("Ba140MDC", analysisRule.getBa140MDC());
if(null != analysisRule.getBe7FWHM()) params.put("Be7FWHM", analysisRule.getBe7FWHM());
if(null != analysisRule.getXeVol()) params.put("XeVol", analysisRule.getXeVol());
if(null != analysisRule.getXe131mFlag()) params.put("Xe131mFlag", analysisRule.getXe131mFlag());
if(null != analysisRule.getXe133mFlag()) params.put("Xe133mFlag", analysisRule.getXe133mFlag());
if(null != analysisRule.getXe133Flag()) params.put("Xe133Flag", analysisRule.getXe133Flag());
if(null != analysisRule.getXe135Flag()) params.put("Xe135Flag", analysisRule.getXe135Flag());
return params;
}
}

View File

@ -1,10 +1,15 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.NumberUtil;
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;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.dto.SampNucl;
import org.jeecg.modules.base.entity.rnauto.GardsNuclIded;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import org.jeecg.modules.mapper.GardsNuclIdedAutoMapper;
@ -13,6 +18,7 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
@ -30,7 +36,34 @@ public class GardsNuclIdedAutoServiceImpl extends ServiceImpl<GardsNuclIdedAutoM
}
@Override
public List<String> nuclideNames(Set<String> nuclideNames) {
return baseMapper.nuclideNames(nuclideNames);
public List<String> nuclideExist(String sampleId, Set<String> nuclideNames) {
LambdaQueryWrapper<GardsNuclIded> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsNuclIded::getSampleId, sampleId);
wrapper.in(GardsNuclIded::getNuclideName, nuclideNames);
List<GardsNuclIded> nuclIdeds = this.list(wrapper);
// 判断核素是否存在的条件: 该核素Conc值是否大于MDC值
Set<String> existNuclides = nuclIdeds.stream()
.filter(item -> NumberUtil.isNumber(item.getConcentration()))
.filter(item -> NumberUtil.isNumber(item.getMdc()))
.filter(item -> NumberUtil.isGreater(new BigDecimal(item.getConcentration()), new BigDecimal(item.getMdc())))
.map(GardsNuclIded::getNuclideName)
.collect(Collectors.toSet());
return ListUtil.toList(existNuclides);
}
@Override
public List<String> nuclideFirst(String stationId, String detectorId,
String sampleId, Set<String> nuclideNames) {
List<SampNucl> sampNucls = this.baseMapper.sampNucl(stationId, detectorId, nuclideNames);
// 获取除了当前谱的所有存在的核素
Set<String> notCurrent = sampNucls.stream()
.filter(item -> !StrUtil.equals(item.getSampleId(), sampleId))
.map(SampNucl::getNuclideName).collect(Collectors.toSet());
// 获取当前谱的所有存在的核素
Set<String> current = sampNucls.stream()
.filter(item -> StrUtil.equals(item.getSampleId(), sampleId))
.map(SampNucl::getNuclideName).collect(Collectors.toSet());
// 两集合相减即为当前谱中的首次在当前台站当前探测器中出现的核素
return CollUtil.subtractToList(current, notCurrent);
}
}

View File

@ -1,16 +1,21 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.NumberUtil;
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;
import org.jeecg.common.constant.DateConstant;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import org.jeecg.modules.base.dto.SampNucl;
import org.jeecg.modules.base.entity.rnman.GardsNuclIded;
import org.jeecg.modules.mapper.GardsNuclIdedManMapper;
import org.jeecg.modules.service.IGardsNuclIdedManService;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
@ -28,7 +33,34 @@ public class GardsNuclIdedManServiceImpl extends ServiceImpl<GardsNuclIdedManMap
}
@Override
public List<String> nuclideNames(Set<String> nuclideNames) {
return baseMapper.nuclideNames(nuclideNames);
public List<String> nuclideExist(String sampleId, Set<String> nuclideNames) {
LambdaQueryWrapper<GardsNuclIded> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsNuclIded::getSampleId, sampleId);
wrapper.in(GardsNuclIded::getNuclideName, nuclideNames);
List<GardsNuclIded> nuclIdeds = this.list(wrapper);
// 判断核素是否存在的条件: 该核素Conc值是否大于MDC值
Set<String> existNuclides = nuclIdeds.stream()
.filter(item -> NumberUtil.isNumber(item.getConcentration()))
.filter(item -> NumberUtil.isNumber(item.getMdc()))
.filter(item -> NumberUtil.isGreater(new BigDecimal(item.getConcentration()), new BigDecimal(item.getMdc())))
.map(GardsNuclIded::getNuclideName)
.collect(Collectors.toSet());
return ListUtil.toList(existNuclides);
}
@Override
public List<String> nuclideFirst(String stationId, String detectorId,
String sampleId, Set<String> nuclideNames) {
List<SampNucl> sampNucls = this.baseMapper.sampNucl(stationId, detectorId, nuclideNames);
// 获取除了当前谱的所有存在的核素
Set<String> notCurrent = sampNucls.stream()
.filter(item -> !StrUtil.equals(item.getSampleId(), sampleId))
.map(SampNucl::getNuclideName).collect(Collectors.toSet());
// 获取当前谱的所有存在的核素
Set<String> current = sampNucls.stream()
.filter(item -> StrUtil.equals(item.getSampleId(), sampleId))
.map(SampNucl::getNuclideName).collect(Collectors.toSet());
// 两集合相减即为当前谱中的首次在当前台站当前探测器中出现的核素
return CollUtil.subtractToList(current, notCurrent);
}
}

View File

@ -2,12 +2,14 @@ package org.jeecg.modules.service.impl;
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.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.constant.DateConstant;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.dto.SampNucl;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import org.jeecg.modules.mapper.GardsXeResultsAutoMapper;
import org.jeecg.modules.service.IGardsXeResultsAutoService;
@ -51,7 +53,33 @@ public class GardsXeResultsAutoServiceImpl extends ServiceImpl<GardsXeResultsAut
}
@Override
public List<String> nuclideNames(Set<String> nuclideNames) {
return baseMapper.nuclideNames(nuclideNames);
public List<String> nuclideExist(String sampleId, Set<String> nuclideNames) {
LambdaQueryWrapper<GardsXeResults> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsXeResults::getSampleId, sampleId);
wrapper.in(GardsXeResults::getNuclideName, nuclideNames);
List<GardsXeResults> xeResults = this.list(wrapper);
// 判断核素是否存在的条件: 该核素NidFlag值是否为1
Set<String> existNuclides = xeResults.stream()
.filter(item -> ObjectUtil.isNotNull(item.getNidFlag()))
.filter(item -> item.getNidFlag() == 1)
.map(GardsXeResults::getNuclideName)
.collect(Collectors.toSet());
return ListUtil.toList(existNuclides);
}
@Override
public List<String> nuclideFirst(String stationId, String detectorId,
String sampleId, Set<String> nuclideNames) {
List<SampNucl> sampNucls = this.baseMapper.sampNucl(stationId, detectorId, nuclideNames);
// 获取除了当前谱的所有存在的核素
Set<String> notCurrent = sampNucls.stream()
.filter(item -> !StrUtil.equals(item.getSampleId(), sampleId))
.map(SampNucl::getNuclideName).collect(Collectors.toSet());
// 获取当前谱的所有存在的核素
Set<String> current = sampNucls.stream()
.filter(item -> StrUtil.equals(item.getSampleId(), sampleId))
.map(SampNucl::getNuclideName).collect(Collectors.toSet());
// 两集合相减即为当前谱中的首次在当前台站当前探测器中出现的核素
return CollUtil.subtractToList(current, notCurrent);
}
}

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
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.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -9,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.constant.DateConstant;
import org.jeecg.modules.base.dto.ConcDto;
import org.jeecg.modules.base.dto.ConcDtoXe;
import org.jeecg.modules.base.dto.SampNucl;
import org.jeecg.modules.base.entity.rnman.GardsXeResults;
import org.jeecg.modules.mapper.GardsXeResultsManMapper;
import org.jeecg.modules.service.IGardsXeResultsManService;
@ -51,7 +53,33 @@ public class GardsXeResultsManServiceImpl extends ServiceImpl<GardsXeResultsManM
}
@Override
public List<String> nuclideNames(Set<String> nuclideNames) {
return baseMapper.nuclideNames(nuclideNames);
public List<String> nuclideExist(String sampleId, Set<String> nuclideNames) {
LambdaQueryWrapper<GardsXeResults> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsXeResults::getSampleId, sampleId);
wrapper.in(GardsXeResults::getNuclideName, nuclideNames);
List<GardsXeResults> xeResults = this.list(wrapper);
// 判断核素是否存在的条件: 该核素NidFlag值是否为1
Set<String> existNuclides = xeResults.stream()
.filter(item -> ObjectUtil.isNotNull(item.getNidFlag()))
.filter(item -> item.getNidFlag() == 1)
.map(GardsXeResults::getNuclideName)
.collect(Collectors.toSet());
return ListUtil.toList(existNuclides);
}
@Override
public List<String> nuclideFirst(String stationId, String detectorId,
String sampleId, Set<String> nuclideNames) {
List<SampNucl> sampNucls = this.baseMapper.sampNucl(stationId, detectorId, nuclideNames);
// 获取除了当前谱的所有存在的核素
Set<String> notCurrent = sampNucls.stream()
.filter(item -> !StrUtil.equals(item.getSampleId(), sampleId))
.map(SampNucl::getNuclideName).collect(Collectors.toSet());
// 获取当前谱的所有存在的核素
Set<String> current = sampNucls.stream()
.filter(item -> StrUtil.equals(item.getSampleId(), sampleId))
.map(SampNucl::getNuclideName).collect(Collectors.toSet());
// 两集合相减即为当前谱中的首次在当前台站当前探测器中出现的核素
return CollUtil.subtractToList(current, notCurrent);
}
}

View File

@ -1,6 +1,9 @@
package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
@ -227,4 +230,20 @@ public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEm
result.put("yData",yData);
return Result.OK(result);
}
@Override
public Integer getMinus(String emailId) {
LambdaQueryWrapper<SysEmailLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysEmailLog::getEmailId, emailId);
wrapper.orderByDesc(SysEmailLog::getCreateTime);
wrapper.last("limit 1");
SysEmailLog emailLog = getOne(wrapper, false);
if (ObjectUtil.isNull(emailLog))
return -1;
Date createTime = emailLog.getCreateTime();
if (ObjectUtil.isNull(createTime))
return -1;
// 获取最新一条数据和当前时间所间隔的分钟数
return Math.toIntExact(DateUtil.between(createTime, new Date(), DateUnit.MINUTE));
}
}

View File

@ -30,5 +30,20 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j-core</artifactId>
<version>0.8.10</version>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j-dom</artifactId>
<version>0.8.10</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version> <!-- 使用最新稳定版 -->
</dependency>
</dependencies>
</project>

View File

@ -1,5 +1,6 @@
package org.jeecg.modules;
import cn.hutool.core.util.RandomUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.constant.RedisConstant;
@ -88,7 +89,6 @@ public class AutoProcessManager{
Iterator<EmailProperties> iterator = emailMap.values().iterator();
while(iterator.hasNext()){
EmailProperties next = iterator.next();
// ConcurrentModificationException
if (next.isResetFlag()) {
EmailParsingActuator actuator = emailExecThreadMap.get(next.getId());
actuator.updateEmail(next);
@ -184,7 +184,6 @@ public class AutoProcessManager{
if(sleepTime > 0){
try {
TimeUnit.MILLISECONDS.sleep(sleepTime);
// throw new RuntimeException("运行时异常");
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
@ -306,6 +305,7 @@ public class AutoProcessManager{
final Iterator<Map.Entry<String, EmailParsingActuator>> iterator = emailExecThreadMap.entrySet().iterator();
emailExecThreadMap.forEach((emailId,emailExecThread)->{
try{
log.info("当前线程状态:{}", emailExecThread.getState());
if(emailExecThread.getState() != State.TERMINATED && emailExecThread.isStop()){
final long nowTime = System.currentTimeMillis();
final long setStoptime = emailExecThread.getStopTime().getTime();

View File

@ -1,9 +1,12 @@
package org.jeecg.modules;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.jeecg.common.constant.StringConstant;
import org.jeecg.common.email.EmailLogManager;
import org.jeecg.common.email.EmailServiceManager;
import org.jeecg.common.properties.TaskProperties;
@ -14,6 +17,7 @@ import org.jeecg.modules.spectrum.SpectrumLogManager;
import org.jeecg.modules.spectrum.SpectrumParsingActuator;
import org.jeecg.modules.spectrum.SpectrumServiceQuotes;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
@ -24,7 +28,7 @@ import java.util.concurrent.*;
* 邮件解析执行器
*/
@Slf4j
public class EmailParsingActuator extends Thread{
public class EmailParsingActuator extends Thread {
private TaskProperties taskProperties;
@Getter
@ -33,15 +37,18 @@ public class EmailParsingActuator extends Thread{
private SpectrumServiceQuotes spectrumServiceQuotes;
private EmailCounter emailCounter;
private Date systemStartupTime;
@Setter @Getter
@Setter
@Getter
private boolean isStop;
@Setter @Getter
@Setter
@Getter
private boolean threadSleep;
@Setter @Getter
@Setter
@Getter
private Date stopTime;
public void init(EmailProperties emailProperties,SpectrumServiceQuotes spectrumServiceQuotes,
EmailCounter emailCounter,Date systemStartupTime){
public void init(EmailProperties emailProperties, SpectrumServiceQuotes spectrumServiceQuotes,
EmailCounter emailCounter, Date systemStartupTime) {
this.emailProperties = emailProperties;
this.spectrumServiceQuotes = spectrumServiceQuotes;
this.taskProperties = spectrumServiceQuotes.getTaskProperties();
@ -50,11 +57,11 @@ public class EmailParsingActuator extends Thread{
//获取机器可用核心数
int systemCores = spectrumServiceQuotes.getMaximumPoolSizeProperties().getAuto();
int maximumPoolSize = taskProperties.getReceiveNum() > systemCores?taskProperties.getReceiveNum():systemCores;
int maximumPoolSize = taskProperties.getReceiveNum() > systemCores ? taskProperties.getReceiveNum() : systemCores;
//初始化线程池
ThreadFactory threadFactory = new CustomizableThreadFactory("mail-parsing-");
poolExecutor = new ThreadPoolExecutor(taskProperties.getReceiveNum(),maximumPoolSize,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory);
poolExecutor = new ThreadPoolExecutor(taskProperties.getReceiveNum(), maximumPoolSize, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), threadFactory);
}
public void updateEmail(EmailProperties emailProperties) {
@ -63,10 +70,10 @@ public class EmailParsingActuator extends Thread{
@Override
public void run() {
for(;;){
for (; ; ) {
String nowDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
if (threadSleep) {
log.info(nowDate + " " +this.emailProperties.getName()+" EmailParsingActuator is sleep!");
log.info(nowDate + " " + this.emailProperties.getName() + " EmailParsingActuator is sleep!");
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
@ -75,43 +82,50 @@ public class EmailParsingActuator extends Thread{
continue;
}
if (isStop) {
log.info(nowDate + " " +this.emailProperties.getName()+" EmailParsingActuator is Stop!");
log.info(nowDate + " " + this.emailProperties.getName() + " EmailParsingActuator is Stop!");
closeResource();
return;
}
long start = System.currentTimeMillis();
final EmailServiceManager emailServiceManager = EmailServiceManager.getInstance();
emailServiceManager.init(this.emailProperties,this.taskProperties.getReceiveNum(),this.taskProperties.getTemporaryStoragePath(),
emailServiceManager.init(this.emailProperties, this.taskProperties.getReceiveNum(), this.taskProperties.getTemporaryStoragePath(),
this.systemStartupTime, spectrumServiceQuotes.getSpectrumPathProperties(), spectrumServiceQuotes.getTaskProperties(), spectrumServiceQuotes.getRedisUtil());
List<String> messageIds = new ArrayList<>();
try {
Message[] messages = emailServiceManager.receiveMail();
log.info("EmailParsingActuator本次{}获取邮件数量为:{}", Thread.currentThread().getName(), ArrayUtils.isEmpty(messages) ? 0 : messages.length);
if(ArrayUtils.isNotEmpty(messages)){
if (ArrayUtils.isNotEmpty(messages)) {
//检验获取的邮件是否在之前删除失败列表中若在直接调用邮件API删除并且此次数组里元素也删除
for(int i=messages.length-1;i>=0;i--){
String messageId = null;
if (null == messages[i].getHeader("Message-ID")) {
messages = ArrayUtils.remove(messages, i);
continue;
// 有些邮箱拿不到 message-ID换成主题+接收时间
String subject = messages[i].getSubject().replace(" ", StringConstant.UNDER_LINE);
Date date = messages[i].getReceivedDate() == null ? messages[i].getSentDate() : messages[i].getReceivedDate();
String receivedStr = DateUtil.format(date, DatePattern.NORM_DATETIME_MINUTE_PATTERN);
messageId = subject + StringConstant.UNDER_LINE + receivedStr;
// messages = ArrayUtils.remove(messages, i);
// continue;
}else {
messageId = ((MimeMessage) messages[i]).getMessageID();
}
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);
if (exist) {
messages = ArrayUtils.remove(messages, i);
}
}
}
log.info("EmailParsingActuator本次真实执行邮件数量为{}",messages.length);
if(messages.length > 0){
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){
for (Message message : messages) {
SpectrumParsingActuator spectrumParsingActuator = new SpectrumParsingActuator();
spectrumParsingActuator.init(message,emailProperties,emailServiceManager,
taskLatch,spectrumServiceQuotes,emailCounter,batchesCounter);
spectrumParsingActuator.init(message, emailProperties, emailServiceManager,
taskLatch, spectrumServiceQuotes, emailCounter, batchesCounter);
poolExecutor.execute(spectrumParsingActuator);
}
taskLatch.await();
@ -119,10 +133,9 @@ public class EmailParsingActuator extends Thread{
}
}
} catch (Exception e) {
log.error("EmailParsingActuator has exception: {}", e.getMessage());
log.error("EmailParsingActuator has exception: ", e);
log.info("Mail-Parsing线程池资源关闭...");
closeResource();
log.error(e.getMessage(), e);
throw new RuntimeException(e);
} finally {
//清除本批次邮件日志缓存
@ -135,16 +148,16 @@ public class EmailParsingActuator extends Thread{
emailServiceManager.close(messageIds);
}
long end = System.currentTimeMillis();
long sleepTime = taskProperties.getMailThreadExecCycle() - (end-start);
long sleepTime = taskProperties.getMailThreadExecCycle() - (end - start);
//如果sleepTime > 0 需要睡眠到指定时间否则继续下次获取邮件
if(sleepTime > 0){
if (sleepTime > 0) {
try {
//如果本次
TimeUnit.MILLISECONDS.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
throw new RuntimeException();
throw new RuntimeException(e);
}
}
}
@ -153,8 +166,8 @@ public class EmailParsingActuator extends Thread{
/**
* 立即关闭线程池
*/
protected void closeResource(){
if(Objects.nonNull(poolExecutor)) {
protected void closeResource() {
if (Objects.nonNull(poolExecutor)) {
poolExecutor.shutdownNow();
}
}

View File

@ -0,0 +1,9 @@
package org.jeecg.modules.exception;
public class CheckMailContentException extends RuntimeException {
public CheckMailContentException() {super();}
public CheckMailContentException(String message) {
super(message);
}
}

View File

@ -11,6 +11,4 @@ public interface GardsCalibrationMapper extends BaseMapper<GardsCalibration> {
@InterceptorIgnore(tenantLine = "true")
public int create(@Param("calibration") GardsCalibration calibration);
@InterceptorIgnore(tenantLine = "true")
public int createBatch(@Param("calibrations") List<GardsCalibration> calibration);
}

View File

@ -31,34 +31,6 @@
#{calibration.moddate})
</insert>
<insert id="createBatch" parameterType="org.jeecg.modules.base.entity.rnauto.GardsCalibration">
begin
<foreach collection="calibrations" separator=";" close=";" item="calibration">
insert into RNAUTO.GARDS_CALIBRATION(
SAMPLE_ID,
IDANALYSIS,
SAMPLE_TYPE,
CALTYPE,
FUNCTION,
FUNCTIONDEF,
STARTOFRANGE,
ENDOFRANGE,
COEFF_STRING,
moddate)
values
(#{calibration.sampleId},
#{calibration.idAnalysis},
#{calibration.sampleType},
#{calibration.calType},
#{calibration.function},
#{calibration.functionDef},
#{calibration.startOfRange},
#{calibration.endOfRange},
#{calibration.coeffString},
#{calibration.moddate})
</foreach>
end;
</insert>
</mapper>

View File

@ -40,7 +40,7 @@ public class GardsCalibrationServiceImpl extends ServiceImpl<GardsCalibrationMap
@Override
public void createBatch(List<GardsCalibration> calibrations) {
this.baseMapper.createBatch(calibrations);
this.saveBatch(calibrations);
}
/**

View File

@ -9,6 +9,7 @@ import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.NumberFormatUtil;
import org.jeecg.modules.base.entity.configuration.GardsStations;
import org.jeecg.modules.base.entity.original.GardsMetData;
import org.jeecg.modules.base.entity.original.GardsSohData;
import org.jeecg.modules.file.FileOperation;
import org.jeecg.modules.mapper.GardsMetDataMapper;
import org.jeecg.modules.mapper.GardsStationsMapper;
@ -22,6 +23,7 @@ import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 处理气象谱
@ -36,6 +38,7 @@ public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, Gard
/**
* 保存气象谱数据
*
* @param struct
* @param fileName
* @return
@ -43,33 +46,42 @@ public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, Gard
*/
@Transactional(rollbackFor = Exception.class)
@Override
public List<GardsMetData> create(MetSpectrumStruct struct,String fileName) throws Exception{
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
public List<GardsMetData> create(MetSpectrumStruct struct, String fileName) throws Exception {
Assert.notNull(struct.station_code, "此次解析结构体中的台站“台站代码”为空");
//校验台站是否存在不存在则报异常
final GardsStations station = stationsService.check(struct.station_code,fileName);
final GardsStations station = stationsService.check(struct.station_code, fileName);
List<GardsMetData> list = Lists.newArrayList();
if(struct.record_count > 0){
for(int i=0;i<struct.record_count;i++){
GardsMetData metData = new GardsMetData();
metData.setStationId(station.getStationId());
metData.setStationCode(struct.station_code);
metData.setStartTime(DateUtils.parseDate(struct.met_start_date.get(i)+" "+struct.met_start_time.get(i)));
metData.setEndTime(DateUtils.parseDate(struct.met_end_date.get(i)+" "+struct.met_end_time.get(i)));
metData.setAveHumidity(numberFormatUtil.DoubleLimit(struct.humidity.get(i)));
metData.setAvgtemperature(numberFormatUtil.DoubleLimit(struct.average_outside_temperature.get(i)));
metData.setAvePressure(numberFormatUtil.DoubleLimit(struct.average_barometric_reading.get(i)));
metData.setAveWindDir(numberFormatUtil.DoubleLimit(struct.average_wind_direction.get(i)));
metData.setAveWindSpeed(numberFormatUtil.DoubleLimit(struct.average_wind_speed.get(i)));
metData.setRainfall(numberFormatUtil.DoubleLimit(struct.rainfall.get(i)));
metData.setInputFileName(FileOperation.separatorConvert(fileName));
metData.setModdate(new Date());
list.add(metData);
}
if(!CollectionUtils.isEmpty(list)){
list.forEach(metData->{
this.save(metData);
});
if (struct.record_count > 0) {
String finalFileName = FileOperation.separatorConvert(fileName);
LambdaQueryWrapper<GardsMetData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(GardsMetData::getMetId);
queryWrapper.eq(GardsMetData::getInputFileName, finalFileName);
GardsMetData metDataOne= this.getOne(queryWrapper,false);
if (Objects.isNull(metDataOne)) {
for (int i = 0; i < struct.record_count; i++) {
GardsMetData metData = new GardsMetData();
metData.setStationId(station.getStationId());
metData.setStationCode(struct.station_code);
metData.setStartTime(DateUtils.parseDate(struct.met_start_date.get(i) + " " + struct.met_start_time.get(i)));
metData.setEndTime(DateUtils.parseDate(struct.met_end_date.get(i) + " " + struct.met_end_time.get(i)));
metData.setAveHumidity(numberFormatUtil.DoubleLimit(struct.humidity.get(i)));
metData.setAvgtemperature(numberFormatUtil.DoubleLimit(struct.average_outside_temperature.get(i)));
metData.setAvePressure(numberFormatUtil.DoubleLimit(struct.average_barometric_reading.get(i)));
metData.setAveWindDir(numberFormatUtil.DoubleLimit(struct.average_wind_direction.get(i)));
metData.setAveWindSpeed(numberFormatUtil.DoubleLimit(struct.average_wind_speed.get(i)));
metData.setRainfall(numberFormatUtil.DoubleLimit(struct.rainfall.get(i)));
metData.setInputFileName(FileOperation.separatorConvert(fileName));
metData.setModdate(new Date());
list.add(metData);
}
if (!CollectionUtils.isEmpty(list)) {
list.forEach(metData -> {
this.save(metData);
});
}
}
}
return list;

View File

@ -4,6 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.NumberFormatUtil;
@ -22,6 +23,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 健康谱数据处理
@ -55,23 +57,29 @@ public class SOHSpectrumServiceImpl extends ServiceImpl<GardsSohDataMapper, Gard
List<GardsSohData> list = Lists.newArrayList();
if(struct.af_record_count > 0){
for(int i=0;i<struct.af_record_count;i++){
GardsSohData sohData = new GardsSohData();
sohData.setStationId(station.getStationId());
sohData.setStationCode(struct.station_code);
sohData.setStartTime(DateUtils.parseDate(struct.af_start_date.get(i)+" "+struct.af_start_time.get(i)));
sohData.setTime(numberFormatUtil.DoubleLimit(struct.af_interval_duration.get(i).doubleValue()));
sohData.setAvgflowrate(numberFormatUtil.DoubleLimit(struct.average_flow_rate.get(i)));
sohData.setFlowratedev(numberFormatUtil.DoubleLimit(struct.flow_rate_standard_deviation.get(i)));
sohData.setInputFileName(FileOperation.separatorConvert(fileName));
sohData.setDetectorId(detector.getDetectorId());
sohData.setModdate(new Date());
list.add(sohData);
}
if(!CollectionUtils.isEmpty(list)){
list.forEach(sohData->{
this.save(sohData);
});
String finalFileName = FileOperation.separatorConvert(fileName);
LambdaQueryWrapper<GardsSohData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSohData::getInputFileName,finalFileName);
GardsSohData sohDataOne= this.getOne(queryWrapper,false);
if(Objects.isNull(sohDataOne)){
for(int i=0;i<struct.af_record_count;i++){
GardsSohData sohData = new GardsSohData();
sohData.setStationId(station.getStationId());
sohData.setStationCode(struct.station_code);
sohData.setStartTime(DateUtils.parseDate(struct.af_start_date.get(i)+" "+struct.af_start_time.get(i)));
sohData.setTime(numberFormatUtil.DoubleLimit(struct.af_interval_duration.get(i).doubleValue()));
sohData.setAvgflowrate(numberFormatUtil.DoubleLimit(struct.average_flow_rate.get(i)));
sohData.setFlowratedev(numberFormatUtil.DoubleLimit(struct.flow_rate_standard_deviation.get(i)));
sohData.setInputFileName(FileOperation.separatorConvert(fileName));
sohData.setDetectorId(detector.getDetectorId());
sohData.setModdate(new Date());
list.add(sohData);
}
if(!CollectionUtils.isEmpty(list)){
list.forEach(sohData->{
this.save(sohData);
});
}
}
}
return list;

View File

@ -29,7 +29,7 @@ public class SysMailLogServiceImpl extends ServiceImpl<SysMailLogMapper, SysEmai
SysEmailLog mailLog = new SysEmailLog();
mailLog.setEmailId(email.getId());
mailLog.setSubject(MimeUtility.decodeText(message.getSubject()));
mailLog.setReceiveTime(message.getReceivedDate());
mailLog.setReceiveTime(message.getReceivedDate()==null?message.getSentDate():message.getReceivedDate());
this.save(mailLog);
}

View File

@ -316,7 +316,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
ex.printStackTrace();
}
} else if(SpectrumSource.FROM_FILE_SOURCE.getSourceType().equals(spectrumSource) && (e instanceof FileRepeatException)){
//this.spectrumFile.delete(); // TODO 删除原始谱文件
this.spectrumFile.delete(); // TODO 删除原始谱文件
} else if (SpectrumSource.FORM_FILE_UNDEL.getSourceType().equals(spectrumSource) && !(e instanceof FileRepeatException)) {
try {
if (isDateFormatErr) {

View File

@ -16,6 +16,7 @@ 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.exception.CheckMailContentException;
import org.jeecg.modules.file.FileOperation;
import javax.mail.Message;
@ -24,6 +25,7 @@ import javax.mail.internet.MimeMessage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Date;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
@ -31,7 +33,7 @@ import java.util.concurrent.CountDownLatch;
* 能谱解析
*/
@Slf4j
public class SpectrumParsingActuator implements Runnable{
public class SpectrumParsingActuator implements Runnable {
/**
* IMS2.0格式邮件判断条件
*/
@ -70,9 +72,9 @@ public class SpectrumParsingActuator implements Runnable{
*/
private final int expiryTime = 86400;
public void init(Message message, EmailProperties emailProperties,EmailServiceManager emailServiceManager,
public void init(Message message, EmailProperties emailProperties, EmailServiceManager emailServiceManager,
CountDownLatch taskLatch, SpectrumServiceQuotes spectrumServiceQuotes,
EmailCounter emailCounter,Integer batchesCounter){
EmailCounter emailCounter, Integer batchesCounter) {
this.message = message;
this.emailProperties = emailProperties;
this.emailServiceManager = emailServiceManager;
@ -89,37 +91,39 @@ public class SpectrumParsingActuator implements Runnable{
String receiveDate = null;
try {
//获取邮件主题
subject = emailServiceManager.getMailSubject(message,this.batchesCounter);
subject = emailServiceManager.getMailSubject(message, this.batchesCounter);
//解析之前先把邮件唯一信息存储到redis
String messageId = ((MimeMessage) message).getMessageID();
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;
String msgID = ((MimeMessage) message).getMessageID();
String messageId = msgID == null ? emailServiceManager.getMessagesID(message,this.batchesCounter) : msgID;
Date dateUtils = message.getReceivedDate() == null ? message.getSentDate() : message.getReceivedDate();
receiveDate = DateUtils.formatDate(dateUtils, "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);
SpectrumLogManager.mailSpectrumLogManager.offer(Thread.currentThread().getId(), null);
//所有邮件都需以.eml格式存储到eml文件夹中
final File emlFile = emailServiceManager.downloadEmailToEmlDir(message, emailCounter.getCurrValue(),this.batchesCounter);
final File emlFile = emailServiceManager.downloadEmailToEmlDir(message, emailCounter.getCurrValue(), this.batchesCounter);
downloadFlag = true;
//保存邮件日志到PG数据库
this.spectrumServiceQuotes.getMailLogService().create(message,emailProperties);
this.spectrumServiceQuotes.getMailLogService().create(message, emailProperties);
//获取邮件内容
StringBuilder mailContent = new StringBuilder();
if(Objects.nonNull(emlFile) && emlFile.length() > 0){
if (Objects.nonNull(emlFile) && emlFile.length() > 0) {
mailContent.append(FileUtil.readUtf8String(emlFile));
}
//判断是否是IMS2.0协议文件
// 如果邮件内容校验成功 将文件保存到eml目录 并删除邮件对象
if(checkMailContent(mailContent,subject)){
if (checkMailContent(mailContent, subject)) {
AbstractSpectrumHandler spectrumHandler = new SamplephdSpectrum();
spectrumHandler.init(mailContent.toString(),emlFile.getName(),spectrumServiceQuotes,new StringBuilder(),SpectrumSource.FORM_EMAIL_SERVICE.getSourceType(),batchesCounter);
spectrumHandler.init(mailContent.toString(), emlFile.getName(), spectrumServiceQuotes, new StringBuilder(), SpectrumSource.FORM_EMAIL_SERVICE.getSourceType(), batchesCounter);
final boolean matchResult = spectrumHandler.saveEmailToLocal();
if(matchResult){
if (matchResult) {
try {
//开始解析
spectrumHandler.handler();
@ -128,44 +132,46 @@ public class SpectrumParsingActuator implements Runnable{
//如果是gamma谱的分析异常
if (e instanceof AnalySpectrumException) {
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
if (Objects.nonNull(emlFile) && emlFile.exists()){
if (Objects.nonNull(emlFile) && emlFile.exists()) {
moveEmail(emlFile, key);
}
//删除邮件
emailServiceManager.removeMail(message,batchesCounter);
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);
} 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);
emailServiceManager.removeMail(message, batchesCounter);
} else {
//判断当前key的下载次数是否超过限制次数
spectrumServiceQuotes.getRedisUtil().incr(key, 1L);
spectrumServiceQuotes.getRedisUtil().expire(key, expiryTime);
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
if (Objects.nonNull(emlFile) && emlFile.exists()){
if (Objects.nonNull(emlFile) && emlFile.exists()) {
moveEmail(emlFile, key);
throw new DownloadEmailException("邮件移走后手动抛出DownloadEmailException");
throw new CheckMailContentException("邮件内容校验失败,邮件移走后手动抛出CheckMailContentException");
}
}
} catch (Exception e) {
// 如果不是下载导致的失败 并且 下载成功则删除下载的邮件对象
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 {
// todo 需要解决其他异常会进入if 删除邮件
// 如果不是下载导致的失败 并且 下载成功则删除下载的邮件对象
if (!(e instanceof DownloadEmailException) && downloadFlag) {
log.error("Catch Remove Email" + subject + StringPool.UNDERSCORE + receiveDate + StringPool.UNDERSCORE);
emailServiceManager.removeMail(message, batchesCounter);
}
} finally {
try {
EmailLogEvent expungeEvent = new EmailLogEvent(this.batchesCounter,Thread.currentThread().getId(),EmailLogManager.GS_TYPE_GET,EmailLogManager.DONE);
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),expungeEvent);
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());
}finally {
} finally {
this.taskLatch.countDown();
}
}
@ -182,30 +188,31 @@ public class SpectrumParsingActuator implements Runnable{
* 这些类型的邮件在头部中会指定相应的内容类型和协议信息
* 3.简单纯文本邮件另一方面简单的纯文本邮件没有特殊的附件或内容类型要求因此可能不需要使用 MIME 格式
* 这种情况下邮件文本中可能不包含 Mime-Version: 1.0 Content-Type: multipart/signed;
*
* @param mailContent
* @return
*/
private boolean checkMailContent(StringBuilder mailContent,String subject){
if(StringUtils.isNotBlank(mailContent) && mailContent.indexOf(EMAIL_BEGIN) != -1 &&
mailContent.indexOf(MSG_TYPE) != -1 && mailContent.indexOf(EMAIL_STOP) != -1){
if(!StringUtils.startsWith(mailContent,EMAIL_BEGIN)){
mailContent.delete(0,mailContent.indexOf(EMAIL_BEGIN));
private boolean checkMailContent(StringBuilder mailContent, String subject) {
if (StringUtils.isNotBlank(mailContent) && mailContent.indexOf(EMAIL_BEGIN) != -1 &&
mailContent.indexOf(MSG_TYPE) != -1 && mailContent.indexOf(EMAIL_STOP) != -1) {
if (!StringUtils.startsWith(mailContent, EMAIL_BEGIN)) {
mailContent.delete(0, mailContent.indexOf(EMAIL_BEGIN));
}
if(!StringUtils.endsWith(mailContent,EMAIL_STOP)){
mailContent.delete(mailContent.indexOf(EMAIL_STOP)+EMAIL_STOP.length(),mailContent.length());
if (!StringUtils.endsWith(mailContent, EMAIL_STOP)) {
mailContent.delete(mailContent.indexOf(EMAIL_STOP) + EMAIL_STOP.length(), mailContent.length());
}
log.info("{}邮件校验成功符合IMS2.0格式",subject);
log.info("{}邮件校验成功符合IMS2.0格式", subject);
return true;
}
log.warn("{}邮件校验成功此邮件不符合IMS2.0格式",subject);
log.warn("{}邮件校验成功此邮件不符合IMS2.0格式", subject);
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);
final String finalPath = rootPath + emlErrorPath;
FileOperation.moveFile(emlFile, finalPath, true);
// 删除 key防止下次线程执行删除邮件
// spectrumServiceQuotes.getRedisUtil().del(key);
}

View File

@ -222,6 +222,12 @@ public class EnergySpectrumStruct {
public int b_r_record_count;
/************************* g_Efficiency Block ******************/
/**
* γ -nuclide
*/
public List<String> g_e_nuclide_name;
/**
* γ -energy (keV)
*/

View File

@ -160,7 +160,8 @@ public class GammaController {
@PostMapping("addNuclide")
@ApiOperation(value = "InteractiveTool页面增加核素信息接口", notes = "InteractiveTool页面增加核素信息接口")
public Result addNuclide(@RequestBody NuclideInfo nuclideInfo, HttpServletRequest request) {
return gammaService.addNuclide(nuclideInfo.getCurRow(), nuclideInfo.getNuclideName(), nuclideInfo.getFileName(), nuclideInfo.getList_identify(), request);
return gammaService.addNuclide(nuclideInfo.getCurRow(), nuclideInfo.getNuclideName(), nuclideInfo.getFileName(),
nuclideInfo.getList_identify(), nuclideInfo.getEnergyTolerance(), request);
}
@PostMapping("deleteNuclide")

View File

@ -16,4 +16,6 @@ public class NuclideInfo implements Serializable {
private List<String> list_identify;
private Double energyTolerance;
}

View File

@ -1,7 +1,19 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import java.util.List;
public interface GardsSampleDataSpectrumMapper extends BaseMapper<GardsSampleData> {
@Select(value = "select " +
"gsd.SAMPLE_ID as sampleId,gsd.input_file_name as inputFileName " +
"from ORIGINAL.GARDS_SAMPLE_AUX gsa inner join ORIGINAL.GARDS_SAMPLE_DATA gsd on gsa.sample_id = gsd.sample_id " +
"where gsa.measurement_id = #{measurementId} and gsd.SAMPLE_TYPE = #{systemType} and gsd.data_type=#{dataType} " +
"AND SPECTRAL_QUALIFIE='FULL' and TRIM(gsd.SITE_DET_CODE) = #{detectorId}")
public List<GardsSampleData> getSampleIdAndInputFileName(@Param("measurementId") String measurementId,
@Param("dataType") String dataType, @Param("systemType") String systemType, String detectorId);
}

View File

@ -22,6 +22,13 @@ public interface SpectrumAnalysisMapper {
Page<GardsSampleDataSpectrum> getDBSpectrumList(IPage<GardsSampleDataSpectrum> page, GardsSampleDataSpectrum gardsSampleData, String dbName, List<String> stationTypes, boolean CollectStopB, boolean AcqStartB, String startTime, String endTime, List<String> userStations, boolean AllUsers, String orderField, String orderType);
Page<GardsSampleDataSpectrum> getDBSpectrumListByLeftJoin(IPage<GardsSampleDataSpectrum> page,
GardsSampleDataSpectrum gardsSampleData, String dbName,
List<String> stationTypes, boolean CollectStopB,
boolean AcqStartB, String startTime, String endTime,
List<String> userStations, boolean AllUsers,
String orderField, String orderType);
Page<GardsSampleDataSpectrum> loadSampleData(IPage<GardsSampleDataSpectrum> page, GardsSampleDataSpectrum gardsSampleData, List<String> stationTypes, boolean CollectStopB, boolean AcqStartB, String startTime, String endTime, List<String> userStations, boolean AllUsers, String orderField, String orderType);
SpectrumFileRecord getDBSpectrumFilePath(String dbName, Integer sampleId, Integer analysisID);

View File

@ -106,6 +106,75 @@
</if>
</select>
<select id="getDBSpectrumListByLeftJoin" resultType="org.jeecg.modules.entity.GardsSampleDataSpectrum">
select c.sample_id sampleId,
b.station_code stationName,
a.detector_code detectorsName,
c.sample_type sampleType,
c.data_type dataType,
c.spectral_qualifie spectralQualifie,
c.collect_stop collectStop,
c.acquisition_start acquisitionStart,
c.acquisition_real_sec acquisitionRealSec,
c.acquisition_live_sec acquisitionLiveSec,
d.IDANALYSIS analysitId,
d.analyst analyst,
c.status status,
c.input_file_name inputFileName
from
ORIGINAL.GARDS_SAMPLE_DATA c
left JOIN ${dbName} d on c.sample_id = d.sample_id
left JOIN CONFIGURATION.GARDS_DETECTORS a on c.detector_id = a.detector_id
left JOIN CONFIGURATION.GARDS_STATIONS b on c.station_id = b.station_id
<where>
c.data_type = 'S'
<if test=" gardsSampleData.sampleId != null ">
and c.sample_id = #{gardsSampleData.sampleId}
</if>
<if test=" gardsSampleData.stationName != null and gardsSampleData.stationName != '' ">
and b.station_code = #{gardsSampleData.stationName}
</if>
<if test=" gardsSampleData.detectorsName != null and gardsSampleData.detectorsName != '' ">
and a.detector_code = #{gardsSampleData.detectorsName}
</if>
<if test=" gardsSampleData.sampleType != null and gardsSampleData.sampleType != '' ">
and c.sample_type = #{gardsSampleData.sampleType}
</if>
<if test=" gardsSampleData.dataType != null and gardsSampleData.dataType != '' ">
and c.data_type = #{gardsSampleData.dataType}
</if>
<if test=" gardsSampleData.spectralQualifie != null and gardsSampleData.spectralQualifie != '' ">
and c.spectral_qualifie = #{gardsSampleData.spectralQualifie}
</if>
<if test=" gardsSampleData.status != null and gardsSampleData.status != '' ">
and c.status = #{gardsSampleData.status}
</if>
<if test=" CollectStopB == true ">
and c.collect_stop between TO_DATE(#{startTime}, 'yyyy-mm-dd hh24:mi:ss') and TO_DATE(#{endTime}, 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test=" AcqStartB == true ">
and c.acquisition_start between TO_DATE(#{startTime}, 'yyyy-mm-dd hh24:mi:ss') and TO_DATE(#{endTime}, 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="AllUsers == false">
<if test=" userStations.size == 0 and userStations != null ">
and c.station_id in ('')
</if>
<if test=" userStations.size > 0 and userStations != null ">
and c.station_id in
<foreach collection="userStations" item="userStation" open="(" close=")" separator=",">
#{userStation}
</foreach>
</if>
</if>
</where>
<if test=" orderField != 'createTime' and orderField != '' and orderField != null and orderType != '' and orderType != null ">
ORDER BY ${orderField} ${orderType},acquisitionRealSec DESC
</if>
<if test=" orderField == 'createTime' or orderField == '' or orderField == null or orderType == '' or orderType == null ">
ORDER BY collectStop DESC,acquisitionRealSec DESC
</if>
</select>
<select id="loadSampleData" resultType="org.jeecg.modules.entity.GardsSampleDataSpectrum">
select
c.sample_id sampleId,

View File

@ -53,7 +53,8 @@ public interface IGammaService{
Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request);
Result addNuclide(Integer curRow, String nuclideName, String fileName, List<String> list_identify, HttpServletRequest request);
Result addNuclide(Integer curRow, String nuclideName, String fileName, List<String> list_identify, Double energyTolerance,
HttpServletRequest request);
Result deleteNuclide(Integer curRow, String nuclideName, String fileName, List<String> list_identify, HttpServletRequest request);

View File

@ -13,4 +13,6 @@ public interface IGardsSampleAuxSpectrumService extends IService<GardsSampleAux>
Integer saveSampleAuxGamma(PHDFile phd, Integer sampleId);
GardsSampleAux getSampleAuxBySampleId(Integer sampleId);
}

View File

@ -13,4 +13,5 @@ public interface IGardsSampleDataSpectrumService extends IService<GardsSampleDat
Integer saveSampleDataGamma(PHDFile phd, String input_file_name, Integer station_id, Integer detect_id);
GardsSampleData getSampleByMId(String measurementId, String dataType, String systemType);
}

View File

@ -25,10 +25,8 @@ import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.LocalCache;
import org.jeecg.common.constant.DateConstant;
import org.jeecg.common.constant.RedisConstant;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.properties.TaskProperties;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*;
@ -44,7 +42,6 @@ import org.jeecg.modules.base.enums.*;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.entity.*;
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
import org.jeecg.modules.native_jni.AnalysisProcess;
import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.native_jni.struct.CalValuesOut;
import org.jeecg.modules.service.*;
@ -1663,7 +1660,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
}
@Override
public Result addNuclide(Integer curRow, String nuclideName, String fileName, List<String> list_identify, HttpServletRequest request) {
public Result addNuclide(Integer curRow, String nuclideName, String fileName, List<String> list_identify,
Double energyTolerance, HttpServletRequest request) {
Result result = new Result();
Map<String, Object> map = new HashMap<>();
String userName = JwtUtil.getUserNameByToken(request);
@ -1685,10 +1683,16 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
// 用户当前的核素信息新增核素名称
list_identify.add(nuclideName);
// 根据要进行修改的列的数据下标 操作Vpeak数据
List<String> peakNuclides = phd.getVPeak().get(curRow).nuclides;
PeakInfo peakInfo = phd.getVPeak().get(curRow);
List<String> peakNuclides = peakInfo.nuclides;
if (peakNuclides.indexOf(nuclideName) < 0 ) {
peakNuclides.add(nuclideName);
}
// todo 添加核素需要把deletedNuclideMap中对应的核素删除
List<String> deletedNuclide = peakInfo.deletedNuclideMap.get(peakInfo.energy);
if (null != deletedNuclide) {
deletedNuclide.remove(nuclideName);
}
// 查询当前用户所关心的核素名称
Map<String, NuclideLines> mapNucLines = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
//用户当前缓存的核素信息
@ -1708,7 +1712,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
t_idx++;
}
//重新计算核素的MDA值
gammaFileUtil.CalcNuclideMDA(phd, it_line, nuclideName, vPeakIdx);
gammaFileUtil.CalcNuclideMDA(phd, it_line, nuclideName, vPeakIdx, energyTolerance);
map.put("identify", list_identify);
//格式化核素表单内容
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
@ -1760,6 +1764,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
//如果峰的核素名称中包含当前删除的核素
if (peakInfo.nuclides.contains(nuclideName)) {
peakInfo.nuclides.remove(nuclideName);
List<String> deletedNuclide = peakInfo.deletedNuclideMap.get(energy);
if (null == deletedNuclide) {
deletedNuclide = new ArrayList<>();
}
deletedNuclide.add(nuclideName);
peakInfo.deletedNuclideMap.put(peakInfo.energy, deletedNuclide);
}
}
//从核素相关map中移除核素信息
@ -1778,8 +1788,15 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
// 更新峰信息列表和表格
// 根据核素名称获取对应的下标并从list_identifyphd.getVPeak()移除
list_identify.remove(index);
PeakInfo peakInfo = phd.getVPeak().get(curRow);
int peakNuclIndex = phd.getVPeak().get(curRow).nuclides.indexOf(nuclideName);
phd.getVPeak().get(curRow).nuclides.remove(peakNuclIndex);
List<String> deletedNuclide = peakInfo.deletedNuclideMap.get(energy);
if (null == deletedNuclide) {
deletedNuclide = new ArrayList<>();
}
deletedNuclide.add(nuclideName);
peakInfo.deletedNuclideMap.put(peakInfo.energy, deletedNuclide);
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
// 处理核素MDAMDC
gammaFileUtil.ReCalcMdaMdc(phd, nuclideName, curRow + 1);

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.DateUtils;
@ -115,4 +116,11 @@ public class GardsSampleAuxSpectrumServiceImpl extends ServiceImpl<GardsSampleAu
int insert = this.baseMapper.insert(sampleAux);
return insert;
}
@Override
public GardsSampleAux getSampleAuxBySampleId(Integer sampleId) {
LambdaQueryWrapper<GardsSampleAux> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsSampleAux::getSampleId, sampleId);
return this.baseMapper.selectOne(queryWrapper);
}
}

View File

@ -13,10 +13,13 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.IGardsSampleDataSpectrumService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.text.ParseException;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service("gardsSampleDataSpectrumService")
@DS("ora")
@ -139,4 +142,16 @@ public class GardsSampleDataSpectrumServiceImpl extends ServiceImpl<GardsSampleD
return insert;
}
@Override
public GardsSampleData getSampleByMId(String measurementId, String dataType, String systemType) {
String detectorId = measurementId.substring(0, 9);
final List<GardsSampleData> sampleDatas = this.baseMapper.getSampleIdAndInputFileName(measurementId, dataType, systemType, detectorId);
if(!CollectionUtils.isEmpty(sampleDatas)){
//如果查询出多条则需要根据inputFileName字段降序排序后返回第一个
final List<GardsSampleData> sortResult = sampleDatas.stream().sorted(Comparator.comparing(GardsSampleData::getInputFileName).reversed()).collect(Collectors.toList());
return sortResult.get(0);
}
return null;
}
}

View File

@ -74,6 +74,7 @@ public class DataProvisionEfficiencyManager {
stationInfo.setType(gardsStations.getType());
stationInfo.setDescription(gardsStations.getDescription());
stationInfo.setStatus(gardsStations.getStatus());
stationInfo.setEfficCalculType(gardsStations.getEfficCalculType());
boolean contains = detectorsUsedList.contains(gardsStations.getStationId());
if (contains) {
stationInfo.setUsed("YES");

View File

@ -16,7 +16,7 @@ import java.util.Objects;
import java.util.concurrent.CountDownLatch;
@Slf4j
public class CalculateDataRateThread implements Runnable{
public class CalculateDataRateThread implements Runnable {
private ICalCulStationDataService calCulStationDataService = ApplicationContextUtil.getContext().getBean(ICalCulStationDataService.class);
@ -36,7 +36,7 @@ public class CalculateDataRateThread implements Runnable{
public void run() {
try {
this.calCulStationInfo();
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
} finally {
// CountDownLatch 计数器减 1
@ -45,11 +45,11 @@ public class CalculateDataRateThread implements Runnable{
}
/**
* 计算台站信息
* 计算台站信息
*/
public void calCulStationInfo(){
public void calCulStationInfo() {
//判断当前台站及数据相关信息是否为空
if(Objects.isNull(stationinfoAndDataRate)) {
if (Objects.isNull(stationinfoAndDataRate)) {
return;
}
//获取台站信息
@ -68,16 +68,17 @@ public class CalculateDataRateThread implements Runnable{
calculateDataRate.setMStationId(stationInfo.getId());
calculateDataRate.setMStationCode(stationInfo.getStationCode());
calculateDataRate.setMStationType(stationInfo.getType());
calculateDataRate.setMEfficCalculType(stationInfo.getEfficCalculType());
//计算台站数据
Rate calculate = this.calculate(calculateDataRate);
stationInfo.setPhdf(calculate.getPhdfOffered()+"/"+calculate.getPhdfEfficient());
stationInfo.setPhd(calculate.getPhdOffered()+"/"+calculate.getPhdEfficient());
stationInfo.setPhdf(calculate.getPhdfOffered() + "/" + calculate.getPhdfEfficient());
stationInfo.setPhd(calculate.getPhdOffered() + "/" + calculate.getPhdEfficient());
stationInfo.setMet(String.valueOf(calculate.getMet()));
stationInfo.setSoh(String.valueOf(calculate.getSoh()));
stationInfo.setPhdMetSoh(String.valueOf(calculate.getPhdMetSoh()));
if(calculate.getPhdfEfficient() >= mRateparam.getParameter().getExcellent()) {
if (calculate.getPhdfEfficient() >= mRateparam.getParameter().getExcellent()) {
stationInfo.setQuality("excellent");
} else if(calculate.getPhdfEfficient() >= mRateparam.getParameter().getGood()) {
} else if (calculate.getPhdfEfficient() >= mRateparam.getParameter().getGood()) {
stationInfo.setQuality("good");
} else {
stationInfo.setQuality("bad");
@ -92,7 +93,7 @@ public class CalculateDataRateThread implements Runnable{
* 根据台站编码及台站类型选择不同的方法
* @param calculateDataRate
*/
public Rate calculate(CalculateDataRate calculateDataRate){
public Rate calculate(CalculateDataRate calculateDataRate) {
Rate mRate = new Rate();
if (StringUtils.isBlank(calculateDataRate.getMStationId())) {
log.error("台站id不能为空");
@ -101,21 +102,30 @@ public class CalculateDataRateThread implements Runnable{
String stationCode = calculateDataRate.getMStationCode();
//获取台站类型
String stationType = calculateDataRate.getMStationType();
//修改使用efficCalculType判断台站类型
String efficCalculType = calculateDataRate.getMEfficCalculType();
//判断台站编码及台站类型
if((StringUtils.isNotBlank(stationCode) && stationCode.substring(2,3).equals("X")) && (StringUtils.isNotBlank(stationType) && stationType.equals("SAUNA")) ) {
//切割台站编码 如果 第三个字符是 X 并且 台站类型是 SAUNA
if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SAUNA"))) {
//切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SAUNA
mRate = saunacalc(calculateDataRate);
} else if((StringUtils.isNotBlank(stationCode) && stationCode.substring(2,3).equals("X")) && (StringUtils.isNotBlank(stationType) && stationType.equals("SPALAX")) ) {
//切割台站编码 如果 第三个字符是 X 并且 台站类型是 SPALAX
} else if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SAUNA2"))) {
//切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SAUNA2
mRate = saunacalc2(calculateDataRate);
} else if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SPALAX"))) {
//切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SPALAX
mRate = spalaxcalc(calculateDataRate);
} else if(StringUtils.isNotBlank(stationCode) && stationCode.substring(2,3).equals("P")) {
} else if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SPALAX_PLC"))) {
//切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SPALAX-PLC
mRate = spalaxcalcPLC(calculateDataRate);
} else if (StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'P') {
//切割台站编码 如果 第三个字符是 P
mRate = particulatecalc(calculateDataRate);
}
return mRate;
}
public Rate saunacalc(CalculateDataRate calculateDataRate){
public Rate saunacalc(CalculateDataRate calculateDataRate) {
Rate mRate = new Rate();
//获取特殊台站相关集合
Map<String, Specialpara> mSpecialparam = calculateDataRate.getMSpecialparam();
@ -136,11 +146,11 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String number = param.getPhdf().getNumber();
phdfProvisionRate = calCulStationDataService.findPhdfProvisionRateSauna(curDateTime, pretime, number, stationId);
}else {
} else {
String number = calculateDataRate.getMParameter().getPhdfSauna().getNumber();
phdfProvisionRate = calCulStationDataService.findPhdfProvisionRateSauna(curDateTime, pretime, number, stationId);
}
if (Objects.nonNull(phdfProvisionRate)){
if (Objects.nonNull(phdfProvisionRate)) {
Double phdf_offered = phdfProvisionRate.getDataRate();
mRate.setPhdfOffered(phdf_offered);
}
@ -159,7 +169,7 @@ public class CalculateDataRateThread implements Runnable{
String liveQc = param.getPhdf().getLiveQc();
String number = param.getPhdf().getNumber();
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencySauna(liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, curDateTime, pretime, number, stationId);
}else {
} else {
String liveLow = calculateDataRate.getMParameter().getPhdfSauna().getLiveLow();
String liveHigh = calculateDataRate.getMParameter().getPhdfSauna().getLiveHigh();
String quantity = calculateDataRate.getMParameter().getPhdfSauna().getQuantity();
@ -170,9 +180,9 @@ public class CalculateDataRateThread implements Runnable{
String nuclideName = calculateDataRate.getMParameter().getPhdfSauna().getNuclideName();
String liveQc = calculateDataRate.getMParameter().getPhdfSauna().getLiveQc();
String number = calculateDataRate.getMParameter().getPhdfSauna().getNumber();
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencySauna(liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, curDateTime,pretime, number,stationId);
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencySauna(liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, curDateTime, pretime, number, stationId);
}
if (Objects.nonNull(phdfProvisionEfficiency)){
if (Objects.nonNull(phdfProvisionEfficiency)) {
Double phdf_efficient = phdfProvisionEfficiency.getDataEfficiency();
mRate.setPhdfEfficient(phdf_efficient);
}
@ -182,11 +192,11 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String number = param.getPhd().getNumber();
phdProvisionRate = calCulStationDataService.findPhdProvisionRateSauna(curDateTime, pretime, number, stationId);
}else {
} else {
String number = calculateDataRate.getMParameter().getPhdSauna().getNumber();
phdProvisionRate = calCulStationDataService.findPhdProvisionRateSauna(curDateTime, pretime, number, stationId);
}
if (Objects.nonNull(phdProvisionRate)){
if (Objects.nonNull(phdProvisionRate)) {
Double phd_offered = phdProvisionRate.getDataRate();
mRate.setPhdOffered(phd_offered);
}
@ -205,7 +215,7 @@ public class CalculateDataRateThread implements Runnable{
String liveQc = param.getPhd().getLiveQc();
String number = param.getPhd().getNumber();
phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencySauna(liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, curDateTime, pretime, number, stationId);
}else {
} else {
String liveLow = calculateDataRate.getMParameter().getPhdSauna().getLiveLow();
String liveHigh = calculateDataRate.getMParameter().getPhdSauna().getLiveHigh();
String quantity = calculateDataRate.getMParameter().getPhdSauna().getQuantity();
@ -216,9 +226,9 @@ public class CalculateDataRateThread implements Runnable{
String nuclideName = calculateDataRate.getMParameter().getPhdSauna().getNuclideName();
String liveQc = calculateDataRate.getMParameter().getPhdSauna().getLiveQc();
String number = calculateDataRate.getMParameter().getPhdSauna().getNumber();
phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencySauna(liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, curDateTime,pretime, number,stationId);
phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencySauna(liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, curDateTime, pretime, number, stationId);
}
if (Objects.nonNull(phdProvisionEfficiency)){
if (Objects.nonNull(phdProvisionEfficiency)) {
Double phd_efficient = phdProvisionEfficiency.getDataEfficiency();
mRate.setPhdEfficient(phd_efficient);
}
@ -228,11 +238,11 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String met = param.getMet();
metProvision = calCulStationDataService.findMetProvisionSauna(curDateTime, pretime, met, stationId);
}else {
} else {
String met = calculateDataRate.getMParameter().getMet();
metProvision = calCulStationDataService.findMetProvisionSauna(curDateTime, pretime, met, stationId);
}
if (Objects.nonNull(metProvision)){
if (Objects.nonNull(metProvision)) {
Double met = metProvision.getDataRate();
mRate.setMet(met);
}
@ -242,11 +252,11 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String soh = param.getSoh();
sohProvision = calCulStationDataService.findSohProvisionSauna(curDateTime, pretime, soh, stationId);
}else {
} else {
String soh = calculateDataRate.getMParameter().getSoh();
sohProvision = calCulStationDataService.findSohProvisionSauna(curDateTime, pretime, soh, stationId);
}
if (Objects.nonNull(sohProvision)){
if (Objects.nonNull(sohProvision)) {
Double soh = sohProvision.getDataRate();
mRate.setSoh(soh);
}
@ -255,7 +265,7 @@ public class CalculateDataRateThread implements Runnable{
ProvisionData sphdProvision = calCulStationDataService.findSphdProvisionSauna(curDateTime, pretime, stationId);
String SPHD_NUM = "0";
if (Objects.nonNull(sphdProvision)) {
SPHD_NUM = sphdProvision.getDataNumber().toString();
SPHD_NUM = sphdProvision.getDataNumber().toString();
}
//获取SPHD+MET+SOH数据提供率 MET部分
ProvisionData sphdMetProvision = calCulStationDataService.findSphdMetProvisionSauna(curDateTime, pretime, stationId);
@ -268,18 +278,173 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String sphdMetSoh = param.getSphdMetSoh();
sphdMetSohProvision = calCulStationDataService.findSphdMetSohProvisionSauna(SPHD_NUM, MET_NUM, curDateTime, pretime, sphdMetSoh, stationId);
}else {
} else {
String sphdMetSoh = calculateDataRate.getMParameter().getSphdMetSoh().getSaunaEverydaynums();
sphdMetSohProvision = calCulStationDataService.findSphdMetSohProvisionSauna(SPHD_NUM, MET_NUM, curDateTime, pretime, sphdMetSoh, stationId);
}
if (Objects.nonNull(sphdMetSohProvision)){
if (Objects.nonNull(sphdMetSohProvision)) {
Double phd_met_soh = sphdMetSohProvision.getDataRate();
mRate.setPhdMetSoh(phd_met_soh);
}
return mRate;
}
public Rate spalaxcalc(CalculateDataRate calculateDataRate){
private Rate saunacalc2(CalculateDataRate calculateDataRate) {
Rate mRate = new Rate();
//region 局部变量
//获取特殊台站相关集合
Map<String, Specialpara> mSpecialparam = calculateDataRate.getMSpecialparam();
//根据台站名称获取对应的 参数信息
Specialpara param = mSpecialparam.get(calculateDataRate.getMStationCode());
//获取日期间隔
double dayspan = calculateDataRate.getMParameter().getDayspan();
//获取当前日期
LocalDateTime currentTime = LocalDateTime.now();
//当前日期转换成字符串格式
String curDateTime = currentTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
//当前日期减去对应的时间间隔 获取开始时间 并转换成字符串格式
String pretime = currentTime.minusDays((long) dayspan).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
//获取台站id
String stationId = calculateDataRate.getMStationId();
String liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, number;
//endregion
//判断当前台站编码是否属于特殊计算的台站 计算PHDF的数据提供率
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
number = param.getPhdf().getNumber();
} else {
number = calculateDataRate.getMParameter().getPhdfSauna2().getNumber();
}
ProvisionData phdfProvisionRate = calCulStationDataService.findPhdfProvisionRateSauna2(curDateTime, pretime, number, stationId);
if (Objects.nonNull(phdfProvisionRate)) {
double phdf_offered = phdfProvisionRate.getDataRate();
mRate.setPhdfOffered(phdf_offered);
}
//判断当前台站编码是否属于特殊计算的台站 计算PHDF的数据提供率
ProvisionData phdfProvisionEfficiency;
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
liveLow = param.getPhdf().getLiveLow();
liveHigh = param.getPhdf().getLiveHigh();
quantity = param.getPhdf().getQuantity();
mdc = param.getPhdf().getMdc();
collectLow = param.getPhdf().getCollectLow();
collectHigh = param.getPhdf().getCollectHigh();
xeVolume = param.getPhdf().getXeVolume();
nuclideName = param.getPhdf().getNuclideName();
liveQc = param.getPhdf().getLiveQc();
number = param.getPhdf().getNumber();
}
else {
liveLow = calculateDataRate.getMParameter().getPhdfSauna2().getLiveLow();
liveHigh = calculateDataRate.getMParameter().getPhdfSauna2().getLiveHigh();
quantity = calculateDataRate.getMParameter().getPhdfSauna2().getQuantity();
mdc = calculateDataRate.getMParameter().getPhdfSauna2().getMdc();
collectLow = calculateDataRate.getMParameter().getPhdfSauna2().getCollectLow();
collectHigh = calculateDataRate.getMParameter().getPhdfSauna2().getCollectHigh();
xeVolume = calculateDataRate.getMParameter().getPhdfSauna2().getXeVolume();
nuclideName = calculateDataRate.getMParameter().getPhdfSauna2().getNuclideName();
liveQc = calculateDataRate.getMParameter().getPhdfSauna2().getLiveQc();
number = calculateDataRate.getMParameter().getPhdfSauna2().getNumber();
}
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencySauna(liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, curDateTime, pretime, number, stationId);
if (Objects.nonNull(phdfProvisionEfficiency)) {
double phdf_efficient = phdfProvisionEfficiency.getDataEfficiency();
mRate.setPhdfEfficient(phdf_efficient);
}
//判断当前台站编码是否属于特殊计算的台站 计算PHD的数据提供率
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
number = param.getPhd().getNumber();
} else {
number = calculateDataRate.getMParameter().getPhdSauna2().getNumber();
}
ProvisionData phdProvisionRate = calCulStationDataService.findPhdProvisionRateSauna2(curDateTime, pretime, number, stationId);
if (Objects.nonNull(phdProvisionRate)) {
double phd_offered = phdProvisionRate.getDataRate();
mRate.setPhdOffered(phd_offered);
}
//判断当前台站编码是否属于特殊计算的台站 计算PHD的数据提供率
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
liveLow = param.getPhd().getLiveLow();
liveHigh = param.getPhd().getLiveHigh();
quantity = param.getPhd().getQuantity();
mdc = param.getPhd().getMdc();
collectLow = param.getPhd().getCollectLow();
collectHigh = param.getPhd().getCollectHigh();
xeVolume = param.getPhd().getXeVolume();
nuclideName = param.getPhd().getNuclideName();
liveQc = param.getPhd().getLiveQc();
number = param.getPhd().getNumber();
} else {
liveLow = calculateDataRate.getMParameter().getPhdSauna2().getLiveLow();
liveHigh = calculateDataRate.getMParameter().getPhdSauna2().getLiveHigh();
quantity = calculateDataRate.getMParameter().getPhdSauna2().getQuantity();
mdc = calculateDataRate.getMParameter().getPhdSauna2().getMdc();
collectLow = calculateDataRate.getMParameter().getPhdSauna2().getCollectLow();
collectHigh = calculateDataRate.getMParameter().getPhdSauna2().getCollectHigh();
xeVolume = calculateDataRate.getMParameter().getPhdSauna2().getXeVolume();
nuclideName = calculateDataRate.getMParameter().getPhdSauna2().getNuclideName();
liveQc = calculateDataRate.getMParameter().getPhdSauna2().getLiveQc();
number = calculateDataRate.getMParameter().getPhdSauna2().getNumber();
}
ProvisionData phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencySauna2(liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, curDateTime, pretime, number, stationId);
if (Objects.nonNull(phdProvisionEfficiency)) {
double phd_efficient = phdProvisionEfficiency.getDataEfficiency();
mRate.setPhdEfficient(phd_efficient);
}
//判断当前台站编码是否属于特殊计算的台站 计算MET的数据提供率
String met;
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
met = param.getMet();
} else {
met = calculateDataRate.getMParameter().getMet();
}
ProvisionData metProvision = calCulStationDataService.findMetProvisionSauna(curDateTime, pretime, met, stationId);
if (Objects.nonNull(metProvision)) {
double metNum = metProvision.getDataRate();
mRate.setMet(metNum);
}
//判断当前台站编码是否属于特殊计算的台站 计算SOH的数据提供率
String soh;
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
soh = param.getSoh();
} else {
soh = calculateDataRate.getMParameter().getSoh();
}
ProvisionData sohProvision = calCulStationDataService.findSohProvisionSauna(curDateTime, pretime, soh, stationId);
if (Objects.nonNull(sohProvision)) {
double sohNum = sohProvision.getDataRate();
mRate.setSoh(sohNum);
}
//计算SPHD+MET+SOH数据提供率 SPHD部分
ProvisionData sphdProvision = calCulStationDataService.findSphdProvisionSauna2(curDateTime, pretime, stationId);
String SPHD_NUM = "0";
if (Objects.nonNull(sphdProvision)) {
SPHD_NUM = sphdProvision.getDataNumber().toString();
}
//获取SPHD+MET+SOH数据提供率 MET部分
ProvisionData sphdMetProvision = calCulStationDataService.findSphdMetProvisionSauna(curDateTime, pretime, stationId);
String MET_NUM = "0";
if (Objects.nonNull(sphdMetProvision)) {
MET_NUM = sphdMetProvision.getDataNumber().toString();
}
//判断当前台站编码是否属于特殊计算的台站 计算SOH的数据提供率
String sphdMetSoh;
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
sphdMetSoh = param.getSphdMetSoh();
} else {
sphdMetSoh = calculateDataRate.getMParameter().getSphdMetSoh().getSaunaEverydaynums();
}
ProvisionData sphdMetSohProvision = calCulStationDataService.findSphdMetSohProvisionSauna(SPHD_NUM, MET_NUM, curDateTime, pretime, sphdMetSoh, stationId);
if (Objects.nonNull(sphdMetSohProvision)) {
double phd_met_soh = sphdMetSohProvision.getDataRate();
mRate.setPhdMetSoh(phd_met_soh);
}
return mRate;
}
public Rate spalaxcalc(CalculateDataRate calculateDataRate) {
Rate mRate = new Rate();
//获取特殊台站相关集合
Map<String, Specialpara> mSpecialparam = calculateDataRate.getMSpecialparam();
@ -300,7 +465,7 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String number = param.getPhdf().getNumber();
phdfProvisionRate = calCulStationDataService.findPhdfProvisionRateSpalax(curDateTime, pretime, number, stationId);
}else {
} else {
String number = calculateDataRate.getMParameter().getPhdfSpalax().getNumber();
phdfProvisionRate = calCulStationDataService.findPhdfProvisionRateSpalax(curDateTime, pretime, number, stationId);
}
@ -320,7 +485,7 @@ public class CalculateDataRateThread implements Runnable{
String liveQc = param.getPhdf().getLiveQc();
String number = param.getPhdf().getNumber();
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencySpalax(liveLow, liveHigh, quantity, collectLow, collectHigh, liveQc, curDateTime, pretime, number, stationId);
}else {
} else {
String liveLow = calculateDataRate.getMParameter().getPhdfSpalax().getLiveLow();
String liveHigh = calculateDataRate.getMParameter().getPhdfSpalax().getLiveHigh();
String quantity = calculateDataRate.getMParameter().getPhdfSpalax().getQuantity();
@ -328,7 +493,7 @@ public class CalculateDataRateThread implements Runnable{
String collectHigh = calculateDataRate.getMParameter().getPhdfSpalax().getCollectHigh();
String liveQc = calculateDataRate.getMParameter().getPhdfSpalax().getLiveQc();
String number = calculateDataRate.getMParameter().getPhdfSpalax().getNumber();
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencySpalax(liveLow, liveHigh, quantity, collectLow, collectHigh, liveQc, curDateTime,pretime, number,stationId);
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencySpalax(liveLow, liveHigh, quantity, collectLow, collectHigh, liveQc, curDateTime, pretime, number, stationId);
}
if (Objects.nonNull(phdfProvisionEfficiency)) {
Double phdf_efficient = phdfProvisionEfficiency.getDataEfficiency();
@ -340,7 +505,7 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String number = param.getPhd().getNumber();
phdProvisionRate = calCulStationDataService.findPhdProvisionRateSpalax(curDateTime, pretime, number, stationId);
}else {
} else {
String number = calculateDataRate.getMParameter().getPhdSpalax().getNumber();
phdProvisionRate = calCulStationDataService.findPhdProvisionRateSpalax(curDateTime, pretime, number, stationId);
}
@ -360,7 +525,7 @@ public class CalculateDataRateThread implements Runnable{
String liveQc = param.getPhd().getLiveQc();
String number = param.getPhd().getNumber();
phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencySpalax(liveLow, liveHigh, quantity, collectLow, collectHigh, liveQc, curDateTime, pretime, number, stationId);
}else {
} else {
String liveLow = calculateDataRate.getMParameter().getPhdSpalax().getLiveLow();
String liveHigh = calculateDataRate.getMParameter().getPhdSpalax().getLiveHigh();
String quantity = calculateDataRate.getMParameter().getPhdSpalax().getQuantity();
@ -368,7 +533,7 @@ public class CalculateDataRateThread implements Runnable{
String collectHigh = calculateDataRate.getMParameter().getPhdSpalax().getCollectHigh();
String liveQc = calculateDataRate.getMParameter().getPhdSpalax().getLiveQc();
String number = calculateDataRate.getMParameter().getPhdSpalax().getNumber();
phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencySpalax(liveLow, liveHigh, quantity, collectLow, collectHigh, liveQc, curDateTime,pretime, number,stationId);
phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencySpalax(liveLow, liveHigh, quantity, collectLow, collectHigh, liveQc, curDateTime, pretime, number, stationId);
}
if (Objects.nonNull(phdProvisionEfficiency)) {
Double phd_efficient = phdProvisionEfficiency.getDataEfficiency();
@ -380,7 +545,7 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String met = param.getMet();
metProvision = calCulStationDataService.findMetProvisionSpalax(curDateTime, pretime, met, stationId);
}else {
} else {
String met = calculateDataRate.getMParameter().getMet();
metProvision = calCulStationDataService.findMetProvisionSpalax(curDateTime, pretime, met, stationId);
}
@ -394,7 +559,7 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String soh = param.getSoh();
sohProvision = calCulStationDataService.findSohProvisionSpalax(curDateTime, pretime, soh, stationId);
}else {
} else {
String soh = calculateDataRate.getMParameter().getSoh();
sohProvision = calCulStationDataService.findSohProvisionSpalax(curDateTime, pretime, soh, stationId);
}
@ -413,7 +578,7 @@ public class CalculateDataRateThread implements Runnable{
//获取SPHD+MET+SOH数据提供率 MET部分
ProvisionData sphdMetProvision = calCulStationDataService.findSphdMetProvisionSpalax(curDateTime, pretime, stationId);
String MET_NUM = "0";
if (Objects.nonNull(sphdMetProvision)){
if (Objects.nonNull(sphdMetProvision)) {
MET_NUM = sphdMetProvision.getDataNumber().toString();
}
@ -422,18 +587,166 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String sphdMetSoh = param.getSphdMetSoh();
sphdMetSohProvision = calCulStationDataService.findSphdMetSohProvisionSpalax(SPHD_NUM, MET_NUM, curDateTime, pretime, sphdMetSoh, stationId);
}else {
} else {
String sphdMetSoh = calculateDataRate.getMParameter().getSphdMetSoh().getSpalaxEverydaynums();
sphdMetSohProvision = calCulStationDataService.findSphdMetSohProvisionSpalax(SPHD_NUM, MET_NUM, curDateTime, pretime, sphdMetSoh, stationId);
}
if (Objects.nonNull(sphdMetSohProvision)){
if (Objects.nonNull(sphdMetSohProvision)) {
Double phd_met_soh = sphdMetSohProvision.getDataRate();
mRate.setPhdMetSoh(phd_met_soh);
}
return mRate;
}
public Rate particulatecalc(CalculateDataRate calculateDataRate){
public Rate spalaxcalcPLC(CalculateDataRate calculateDataRate) {
Rate mRate = new Rate();
//region 局部变量
//获取特殊台站相关集合
Map<String, Specialpara> mSpecialparam = calculateDataRate.getMSpecialparam();
//根据台站名称获取对应的 参数信息
Specialpara param = mSpecialparam.get(calculateDataRate.getMStationCode());
//获取日期间隔
double dayspan = calculateDataRate.getMParameter().getDayspan();
//获取当前日期
LocalDateTime currentTime = LocalDateTime.now();
//当前日期转换成字符串格式
String curDateTime = currentTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
//当前日期减去对应的时间间隔 获取开始时间 并转换成字符串格式
String pretime = currentTime.minusDays((long) dayspan).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
//获取台站id
String stationId = calculateDataRate.getMStationId();
String liveLow, liveHigh, quantity, mdc, collectLow, collectHigh, xeVolume, nuclideName, liveQc, number;
//endregion
//判断当前台站编码是否属于特殊计算的台站 计算PHDF的数据提供率
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
number = param.getPhdf().getNumber();
} else {
number = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getNumber();
}
ProvisionData phdfProvisionRate = calCulStationDataService.findPhdfProvisionRateSpalax(curDateTime, pretime, number, stationId);
if (Objects.nonNull(phdfProvisionRate)) {
double phdf_offered = phdfProvisionRate.getDataRate();
mRate.setPhdfOffered(phdf_offered);
}
//判断当前台站编码是否属于特殊计算的台站 计算PHDF的数据提供率
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
liveLow = param.getPhdf().getLiveLow();
liveHigh = param.getPhdf().getLiveHigh();
quantity = param.getPhdf().getQuantity();
collectLow = param.getPhdf().getCollectLow();
collectHigh = param.getPhdf().getCollectHigh();
liveQc = param.getPhdf().getLiveQc();
number = param.getPhdf().getNumber();
}
else {
liveLow = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getLiveLow();
liveHigh = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getLiveHigh();
quantity = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getQuantity();
collectLow = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getCollectLow();
collectHigh = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getCollectHigh();
liveQc = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getLiveQc();
number = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getNumber();
}
ProvisionData phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencySpalaxPLC(liveLow, liveHigh, quantity, collectLow, collectHigh, liveQc, curDateTime, pretime, number, stationId);
if (Objects.nonNull(phdfProvisionEfficiency)) {
double phdf_efficient = phdfProvisionEfficiency.getDataEfficiency();
mRate.setPhdfEfficient(phdf_efficient);
}
//判断当前台站编码是否属于特殊计算的台站 计算PHD的数据提供率
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
number = param.getPhd().getNumber();
} else {
number = calculateDataRate.getMParameter().getPhdSpalaxPLC().getNumber();
}
ProvisionData phdProvisionRate = calCulStationDataService.findPhdProvisionRateSpalaxPLC(curDateTime, pretime, number, stationId);
if (Objects.nonNull(phdProvisionRate)) {
double phd_offered = phdProvisionRate.getDataRate();
mRate.setPhdOffered(phd_offered);
}
//判断当前台站编码是否属于特殊计算的台站 计算PHD的数据提供率
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
liveLow = param.getPhd().getLiveLow();
liveHigh = param.getPhd().getLiveHigh();
quantity = param.getPhd().getQuantity();
collectLow = param.getPhd().getCollectLow();
collectHigh = param.getPhd().getCollectHigh();
liveQc = param.getPhd().getLiveQc();
number = param.getPhd().getNumber();
}
else {
liveLow = calculateDataRate.getMParameter().getPhdSpalaxPLC().getLiveLow();
liveHigh = calculateDataRate.getMParameter().getPhdSpalaxPLC().getLiveHigh();
quantity = calculateDataRate.getMParameter().getPhdSpalaxPLC().getQuantity();
collectLow = calculateDataRate.getMParameter().getPhdSpalaxPLC().getCollectLow();
collectHigh = calculateDataRate.getMParameter().getPhdSpalaxPLC().getCollectHigh();
liveQc = calculateDataRate.getMParameter().getPhdSpalaxPLC().getLiveQc();
number = calculateDataRate.getMParameter().getPhdSpalaxPLC().getNumber();
}
ProvisionData phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencySpalaxPLC(liveLow, liveHigh, quantity, collectLow, collectHigh, liveQc, curDateTime, pretime, number, stationId);
if (Objects.nonNull(phdProvisionEfficiency)) {
double phd_efficient = phdProvisionEfficiency.getDataEfficiency();
mRate.setPhdEfficient(phd_efficient);
}
//判断当前台站编码是否属于特殊计算的台站 计算MET的数据提供率
String met;
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
met = param.getMet();
} else {
met = calculateDataRate.getMParameter().getMet();
}
ProvisionData metProvision = calCulStationDataService.findMetProvisionSpalax(curDateTime, pretime, met, stationId);
if (Objects.nonNull(metProvision)) {
double metNum = metProvision.getDataRate();
mRate.setMet(metNum);
}
//判断当前台站编码是否属于特殊计算的台站 计算SOH的数据提供率
String soh;
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
soh = param.getSoh();
} else {
soh = calculateDataRate.getMParameter().getSoh();
}
ProvisionData sohProvision = calCulStationDataService.findSohProvisionSpalax(curDateTime, pretime, soh, stationId);
if (Objects.nonNull(sohProvision)) {
double sohNum = sohProvision.getDataRate();
mRate.setSoh(sohNum);
}
//计算SPHD+MET+SOH数据提供率 SPHD部分
ProvisionData sphdProvision = calCulStationDataService.findSphdProvisionSpalax(curDateTime, pretime, stationId);
String SPHD_NUM = "0";
if (Objects.nonNull(sphdProvision)) {
SPHD_NUM = sphdProvision.getDataNumber().toString();
}
//获取SPHD+MET+SOH数据提供率 MET部分
ProvisionData sphdMetProvision = calCulStationDataService.findSphdMetProvisionSpalax(curDateTime, pretime, stationId);
String MET_NUM = "0";
if (Objects.nonNull(sphdMetProvision)) {
MET_NUM = sphdMetProvision.getDataNumber().toString();
}
//判断当前台站编码是否属于特殊计算的台站 计算SOH的数据提供率
String sphdMetSoh;
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
sphdMetSoh = param.getSphdMetSoh();
} else {
sphdMetSoh = calculateDataRate.getMParameter().getSphdMetSoh().getSpalaxEverydaynums();
}
ProvisionData sphdMetSohProvision = calCulStationDataService.findSphdMetSohProvisionSpalax(SPHD_NUM, MET_NUM, curDateTime, pretime, sphdMetSoh, stationId);
if (Objects.nonNull(sphdMetSohProvision)) {
double phd_met_soh = sphdMetSohProvision.getDataRate();
mRate.setPhdMetSoh(phd_met_soh);
}
return mRate;
}
public Rate particulatecalc(CalculateDataRate calculateDataRate) {
Rate mRate = new Rate();
//获取特殊台站相关集合
Map<String, Specialpara> mSpecialparam = calculateDataRate.getMSpecialparam();
@ -454,7 +767,7 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String number = param.getPhdf().getNumber();
phdfProvisionRate = calCulStationDataService.findPhdfProvisionRateParticulate(curDateTime, pretime, number, stationId);
}else {
} else {
String number = calculateDataRate.getMParameter().getPhdfParticulate().getNumber();
phdfProvisionRate = calCulStationDataService.findPhdfProvisionRateParticulate(curDateTime, pretime, number, stationId);
}
@ -473,14 +786,14 @@ public class CalculateDataRateThread implements Runnable{
String collectHigh = param.getPhdf().getCollectHigh();
String number = param.getPhdf().getNumber();
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencyParticulate(liveLow, liveHigh, quantity, collectLow, collectHigh, curDateTime, pretime, number, stationId);
}else {
} else {
String liveLow = calculateDataRate.getMParameter().getPhdfParticulate().getLiveLow();
String liveHigh = calculateDataRate.getMParameter().getPhdfParticulate().getLiveHigh();
String quantity = calculateDataRate.getMParameter().getPhdfParticulate().getQuantity();
String collectLow = calculateDataRate.getMParameter().getPhdfParticulate().getCollectLow();
String collectHigh = calculateDataRate.getMParameter().getPhdfParticulate().getCollectHigh();
String number = calculateDataRate.getMParameter().getPhdfParticulate().getNumber();
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencyParticulate(liveLow, liveHigh, quantity, collectLow, collectHigh, curDateTime,pretime, number,stationId);
phdfProvisionEfficiency = calCulStationDataService.findPhdfProvisionEfficiencyParticulate(liveLow, liveHigh, quantity, collectLow, collectHigh, curDateTime, pretime, number, stationId);
}
if (Objects.nonNull(phdfProvisionEfficiency)) {
Double phdf_efficient = phdfProvisionEfficiency.getDataEfficiency();
@ -492,11 +805,11 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String number = param.getPhd().getNumber();
phdProvisionRate = calCulStationDataService.findPhdProvisionRateParticulate(curDateTime, pretime, number, stationId);
}else {
} else {
String number = calculateDataRate.getMParameter().getPhdParticulate().getNumber();
phdProvisionRate = calCulStationDataService.findPhdProvisionRateParticulate(curDateTime, pretime, number, stationId);
}
if (Objects.nonNull(phdProvisionRate)){
if (Objects.nonNull(phdProvisionRate)) {
Double phd_offered = phdProvisionRate.getDataRate();
mRate.setPhdOffered(phd_offered);
}
@ -511,14 +824,14 @@ public class CalculateDataRateThread implements Runnable{
String collectHigh = param.getPhd().getCollectHigh();
String number = param.getPhd().getNumber();
phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencyParticulate(liveLow, liveHigh, quantity, collectLow, collectHigh, curDateTime, pretime, number, stationId);
}else {
} else {
String liveLow = calculateDataRate.getMParameter().getPhdParticulate().getLiveLow();
String liveHigh = calculateDataRate.getMParameter().getPhdParticulate().getLiveHigh();
String quantity = calculateDataRate.getMParameter().getPhdParticulate().getQuantity();
String collectLow = calculateDataRate.getMParameter().getPhdParticulate().getCollectLow();
String collectHigh = calculateDataRate.getMParameter().getPhdParticulate().getCollectHigh();
String number = calculateDataRate.getMParameter().getPhdParticulate().getNumber();
phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencyParticulate(liveLow, liveHigh, quantity, collectLow, collectHigh, curDateTime, pretime, number,stationId);
phdProvisionEfficiency = calCulStationDataService.findPhdProvisionEfficiencyParticulate(liveLow, liveHigh, quantity, collectLow, collectHigh, curDateTime, pretime, number, stationId);
}
if (Objects.nonNull(phdProvisionEfficiency)) {
Double phd_efficient = phdProvisionEfficiency.getDataEfficiency();
@ -530,7 +843,7 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String met = param.getMet();
metProvision = calCulStationDataService.findMetProvisionParticulate(curDateTime, pretime, met, stationId);
}else {
} else {
String met = calculateDataRate.getMParameter().getMet();
metProvision = calCulStationDataService.findMetProvisionParticulate(curDateTime, pretime, met, stationId);
}
@ -544,7 +857,7 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String soh = param.getSoh();
sohProvision = calCulStationDataService.findSohProvisionParticulate(curDateTime, pretime, soh, stationId);
}else {
} else {
String soh = calculateDataRate.getMParameter().getSoh();
sohProvision = calCulStationDataService.findSohProvisionParticulate(curDateTime, pretime, soh, stationId);
}
@ -571,7 +884,7 @@ public class CalculateDataRateThread implements Runnable{
if (mSpecialparam.containsKey(calculateDataRate.getMStationCode())) {
String sphdMetSoh = param.getSphdMetSoh();
sphdMetSohProvision = calCulStationDataService.findSphdMetSohProvisionParticulate(SPHD_NUM, MET_NUM, curDateTime, pretime, sphdMetSoh, stationId);
}else {
} else {
String sphdMetSoh = calculateDataRate.getMParameter().getSphdMetSoh().getParticulateEverydaynums();
sphdMetSohProvision = calCulStationDataService.findSphdMetSohProvisionParticulate(SPHD_NUM, MET_NUM, curDateTime, pretime, sphdMetSoh, stationId);
}

View File

@ -6,6 +6,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.data.PointVo;
import org.jeecg.modules.entity.data.StationOperation;
import org.jeecg.modules.service.IStationOperationService;
import org.jeecg.modules.service.IStationProvisionEffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;
@ -24,77 +25,79 @@ public class StationOperationController {
@Autowired
private IStationOperationService stationOperationService;
@Autowired
private IStationProvisionEffService stationProvisionEffService;
@GetMapping("findStationType")
@ApiOperation(value = "查询台站/核设施类型", notes = "查询台站/核设施类型")
public List<String> findStationType(){
public List<String> findStationType() {
List<String> result = stationOperationService.findStationType();
return result;
}
@GetMapping("findList")
@ApiOperation(value = "查询台站/核设施信息", notes = "查询台站/核设施信息")
public List<StationOperation> findList(String status, String stationType){
public List<StationOperation> findList(String status, String stationType) {
List<StationOperation> result = stationOperationService.findList(status, stationType);
return result;
}
@GetMapping("findListApp")
@ApiOperation(value = "查询台站/核设施信息", notes = "查询台站/核设施信息")
public List<StationOperation> findListApp(@RequestParam String status,@RequestParam String stationType){
public List<StationOperation> findListApp(@RequestParam String status, @RequestParam String stationType) {
List<StationOperation> result = stationOperationService.findList(status, stationType);
return result;
}
@GetMapping("findInfo")
@ApiOperation(value = "查询台站/核设施详情信息", notes = "查询台站/核设施详情信息")
public Result findInfo(String stationId, String type){
public Result findInfo(String stationId, String type) {
Result result = stationOperationService.findInfo(stationId, type);
return result;
}
@GetMapping("findInfoApp")
@ApiOperation(value = "查询台站/核设施详情信息", notes = "查询台站/核设施详情信息")
public Result findInfoApp(@RequestParam String stationId,@RequestParam String type){
public Result findInfoApp(@RequestParam String stationId, @RequestParam String type) {
Result result = stationOperationService.findInfo(stationId, type);
return result;
}
@GetMapping("findTree")
@ApiOperation(value = "查询台站树形结构", notes = "查询台站树形结构")
public Result findTree(){
public Result findTree() {
Result result = stationOperationService.findTree();
return result;
}
@PostMapping("getHitEquList")
@ApiOperation(value = "查询半径内核设施信息", notes = "查询半径内核设施信息")
public Result getHitEquList(@RequestBody PointVo pointVo){
public Result getHitEquList(@RequestBody PointVo pointVo) {
Result result = stationOperationService.getHitEquList(pointVo);
return result;
}
@GetMapping("getDataReceivingStatus")
@ApiOperation(value = "查询台站监测数据信息", notes = "查询台站监测数据信息")
public Result getDataReceivingStatus(String userId, Double cacheTime, String oneStationId){
public Result getDataReceivingStatus(String userId, Double cacheTime, String oneStationId) {
return stationOperationService.getDataReceivingStatus(userId, cacheTime, oneStationId);
}
@GetMapping("getDataReceivingStatusApp")
@ApiOperation(value = "查询台站监测数据信息", notes = "查询台站监测数据信息")
public Result getDataReceivingStatusApp(@RequestParam String userId,@RequestParam Double cacheTime,@RequestParam String oneStationId){
public Result getDataReceivingStatusApp(@RequestParam String userId, @RequestParam Double cacheTime, @RequestParam String oneStationId) {
return stationOperationService.getDataReceivingStatus(userId, cacheTime, oneStationId);
}
@GetMapping("getDataProvisionEfficiency")
@ApiOperation(value = "查询台站数据提供率及有效率", notes = "查询台站数据提供率及有效率")
public Result getDataProvisionEfficiency(){
public Result getDataProvisionEfficiency() {
return stationOperationService.getDataProvisionEfficiency();
}
@GetMapping("getMapUrl")
@ApiOperation(value = "获取地图地址", notes = "获取地图地址")
public Result<?> getMapUrl(){
public Result<?> getMapUrl() {
Result<String> result = Result.OK();
result.setResult(mapUrl);
return result;
@ -108,4 +111,12 @@ public class StationOperationController {
return stationOperationService.getSelfStationGPS(stationCode, startDate, endDate);
}
@GetMapping("getStationProvisionEff")
@ApiOperation(value = "查询台站提供数据信息", notes = "查询台站提供数据信息")
public Result getStationProvisionEff(Integer[] stationIds, @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
return stationProvisionEffService.getStationProvisionEff(stationIds, startTime, endTime);
}
}

View File

@ -25,6 +25,7 @@ public class CalculateDataRate implements Serializable {
private String mStationCode;
private String mStationType;
private String mEfficCalculType;
double mDayspan; // 天数用来统计数据接受率和有效率

View File

@ -14,14 +14,17 @@ public class Parameter implements Serializable {
private double good;
private StationTypeData phdfSauna;
private StationTypeData phdfSauna2;
private StationTypeData phdfSpalax;
private StationTypeData phdfSpalaxPLC;
private StationTypeData phdfParticulate;
private StationTypeData phdSauna;
private StationTypeData phdSauna2;
private StationTypeData phdSpalax;
private StationTypeData phdSpalaxPLC;
private StationTypeData phdParticulate;

View File

@ -7,29 +7,63 @@ import java.io.Serializable;
@Data
public class Rate implements Serializable {
//数据提供数量
private double phdfOfferedNumber;
//数据有效数量
private double phdfDataNumber;
//数据提供率
private double phdfOffered;
//数据有效率
private double phdfEfficient;
private double phdOfferedNumber;
private double phdDataNumber;
private double phdOffered;
private double phdEfficient;
private double metOfferedNumber;
private double metDataNumber;
private double met;
private double metEfficient;
private double sohOfferedNumber;
private double sohDataNumber;
private double soh;
private double sohEfficient;
private double pmtOfferedNumber;
private double pmtDataNumber;
private double phdMetSoh;
private double pmtEfficient;
public Rate() {
phdfOfferedNumber=0;
phdfDataNumber=0;
phdfOffered = 0;
phdfEfficient = 0;
phdOfferedNumber=0;
phdDataNumber=0;
phdOffered = 0;
phdEfficient = 0;
metOfferedNumber=0;
metDataNumber=0;
met = 0;
metEfficient=0;
sohOfferedNumber=0;
sohDataNumber=0;
soh = 0;
sohEfficient=0;
pmtOfferedNumber=0;
pmtDataNumber=0;
phdMetSoh = 0;
sohEfficient=0;
}
}

View File

@ -37,4 +37,6 @@ public class StationInfo implements Serializable {
private String quality;
private String efficCalculType;
}

Some files were not shown because too many files have changed in this diff Show More