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

This commit is contained in:
nieziyan 2023-08-18 17:10:54 +08:00
commit 72a8d901ea
79 changed files with 2656 additions and 431 deletions

View File

@ -210,12 +210,14 @@ public class EmailServiceManager {
* @throws IOException
*/
public void getMailContent(@NotNull Part part, StringBuilder content) throws MessagingException, IOException {
Multipart multipart = (Multipart) part.getContent();
for(int i=0;i<multipart.getCount();i++) {
final Part bodyPart = multipart.getBodyPart(i);
if(bodyPart.isMimeType(MailContentType.PLAIN.getContentType())){
content.append(bodyPart.getContent().toString());
}else if(bodyPart.isMimeType(MailContentType.RELATED.getContentType()) || bodyPart.isMimeType(MailContentType.ALTERNATIVE.getContentType())){
if(part.isMimeType(MailContentType.PLAIN.getContentType())){
content.append(part.getContent());
}else if(part.isMimeType(MailContentType.HTML.getContentType())){
content.append(part.getContent());
}else if(part.isMimeType("multipart/*")){
Multipart multipart = (Multipart) part.getContent();
for(int i=0;i<multipart.getCount();i++) {
final Part bodyPart = multipart.getBodyPart(i);
getMailContent(bodyPart,content);
}
}

View File

@ -16,6 +16,11 @@ import java.util.Map;
@ConfigurationProperties(prefix = "filesystem")
public class SpectrumPathProperties implements Serializable {
/**
* eml格式邮件存储路径
*/
private String emlPath;
/**
* 能谱文件存储根路径
*/

View File

@ -551,6 +551,22 @@ public class DateUtils extends PropertyEditorSupport {
}
/**
* 把日期字符串转换为时间
* 如果日期字符串包含毫秒则以yyyy/MM/dd HH:mm:ss.S格式进行转换
* 如果日期字符串不包含毫秒则以yyyy/MM/dd HH:mm:ss格式进行转换
* @param src 将要转换的原始字符窜
* @return 如果转换成功则返回转换后的日期
* @throws ParseException
*/
public static Date parseDate(String src) throws ParseException {
if(src.indexOf(".") != -1){
return getSdFormat("yyyy/MM/dd HH:mm:ss.S").parse(src);
}else{
return getSdFormat("yyyy/MM/dd HH:mm:ss").parse(src);
}
}
/**
* 根据指定的格式将字符串转换成Date 如输入2003-11-19 11:20:20将按照这个转成时间
*

View File

@ -205,7 +205,7 @@ public class FTPUtil {
* @param inputStream 文件输入流
* @return 返回值true/false
*/
public boolean saveFile(String filePath,String fileName,InputStream inputStream){
public synchronized boolean saveFile(String filePath,String fileName,InputStream inputStream){
final FTPClient ftpClient = this.LoginFTP();
try{
final boolean flag = this.checkDirectory(ftpClient,filePath);
@ -220,6 +220,13 @@ public class FTPUtil {
e.printStackTrace();
return false;
}finally {
if(null != inputStream){
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
ftpClient.disconnect();
} catch (IOException e) {

View File

@ -39,7 +39,7 @@ public class GardsCalibrationPairsOrig implements Serializable {
* 刻度点ID号
*/
@TableField(value = "IDCALPOINT")
private Double idCalPoint;
private Integer idCalPoint;
@TableField(value = "XVALUE")
private Double xValue;

View File

@ -55,41 +55,41 @@ public class GardsMetData implements Serializable {
*/
@TableField(value = "AVE_HUMIDITY")
@Excel(name = "AVG.REL.HUMIDITY",orderNum = "5",width = 30)
private Integer aveHumidity;
private Double aveHumidity;
/**
* 平均温度
*/
@TableField(value = "AVGTEMPERATURE")
@Excel(name = "AVG.TEMP",orderNum = "7",width = 30)
private Integer avgtemperature;
private Double avgtemperature;
/**
* 平均压力hPa
*/
@TableField(value = "AVE_PRESSURE")
private Integer avePressure;
private Double avePressure;
/**
* 平均风向偏离正北的度数
*/
@TableField(value = "AVE_WIND_DIR")
@Excel(name = "AVG.WIND.DIRECTION",orderNum = "8",width = 30)
private Integer aveWindDir;
private Double aveWindDir;
/**
* 平均风速m/s
*/
@TableField(value = "AVE_WIND_SPEED")
@Excel(name = "AVG.WIND.SPEED",orderNum = "9",width = 30)
private Integer aveWindSpeed;
private Double aveWindSpeed;
/**
* 降雨量mm
*/
@TableField(value = "RAINFALL")
@Excel(name = "RAINFALL", orderNum = "4",width = 20)
private Integer rainfall;
private Double rainfall;
/**
* 文件路径

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;
@ -24,8 +26,8 @@ public class GardsSampleData implements Serializable {
/**
* 样品id
*/
@TableField(value = "SAMPLE_ID")
@TableId(value = "SAMPLE_ID",type = IdType.AUTO)
private Integer sampleId;
/**

View File

@ -47,19 +47,19 @@ public class GardsSohData implements Serializable {
* 时间间隔长度
*/
@TableField(value = "TIME")
private Integer time;
private Double time;
/**
* 采样流速均值scm/h
*/
@TableField(value = "AVGFLOWRATE")
private Integer avgflowrate;
private Double avgflowrate;
/**
* 采样流速偏差scm/h
*/
@TableField(value = "FLOWRATEDEV")
private Integer flowratedev;
private Double flowratedev;
/**
* 文件路径

View File

@ -33,12 +33,6 @@ public class SysEmailLog implements Serializable {
@TableField(value = "subject")
private String subject;
/**
* 邮件内容
*/
@TableField(value = "context")
private String context;
/**
* 接收时间
*/

View File

@ -4,14 +4,14 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.constant.EmailConstant;
import org.jeecg.common.email.EmailServiceManager;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.email.EmailParsingActuator;
import org.jeecg.modules.emuns.SysMailEnableType;
import org.jeecg.modules.email.EmailProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.properties.TaskProperties;
import org.jeecg.modules.service.ISysMailService;
import org.jeecg.modules.spectrum.EmailCounter;
import org.jeecg.modules.spectrum.SpectrumServiceQuotes;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
@ -28,12 +28,12 @@ import java.util.concurrent.TimeUnit;
@RequiredArgsConstructor
public class AutoProcessManager{
private final FTPUtil ftpUtil;
private final ISysMailService mailService;
private final TaskProperties taskProperties;
private final RedisUtil redisUtil;
private final SpectrumPathProperties spectrumPathProperties;
private final SpectrumServiceQuotes spectrumServiceQuotes;
private final EmailCounter emailCounter;
/**
* 邮件Map数据锁
*/
@ -93,7 +93,7 @@ public class AutoProcessManager{
}
if(next.isNewEmailFlag()){
EmailParsingActuator emailParsingActuator = new EmailParsingActuator();
emailParsingActuator.init(taskProperties,next,ftpUtil);
emailParsingActuator.init(next,spectrumServiceQuotes,emailCounter);
emailParsingActuator.setName(next.getUsername()+"-email-monitor");
emailParsingActuator.start();
//把邮件监测执行线程加入管理队列

View File

@ -1,10 +1,14 @@
package org.jeecg.modules.email;
package org.jeecg.modules;
import org.apache.commons.lang3.ArrayUtils;
import org.jeecg.common.email.EmailServiceManager;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.common.properties.TaskProperties;
import org.jeecg.modules.email.EmailProperties;
import org.jeecg.modules.spectrum.EmailCounter;
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;
@ -15,18 +19,24 @@ import java.util.concurrent.*;
*/
public class EmailParsingActuator extends Thread{
private FTPUtil ftpUtil;
private TaskProperties taskProperties;
private EmailProperties emailProperties;
private ThreadPoolExecutor poolExecutor;
private SpectrumServiceQuotes spectrumServiceQuotes;
private EmailCounter emailCounter;
public void init(TaskProperties taskProperties,EmailProperties emailProperties,FTPUtil ftpUtil){
this.taskProperties = taskProperties;
public void init(EmailProperties emailProperties,SpectrumServiceQuotes spectrumServiceQuotes,EmailCounter emailCounter){
this.emailProperties = emailProperties;
this.ftpUtil = ftpUtil;
this.spectrumServiceQuotes = spectrumServiceQuotes;
this.taskProperties = spectrumServiceQuotes.getTaskProperties();
this.emailCounter = emailCounter;
//获取机器可用核心数
int systemCores = Runtime.getRuntime().availableProcessors();
int maximumPoolSize = taskProperties.getReceiveNum() > systemCores?taskProperties.getReceiveNum():systemCores;
//初始化线程池
ThreadFactory threadFactory = new CustomizableThreadFactory("mail-parsing-");
poolExecutor = new ThreadPoolExecutor(taskProperties.getReceiveNum(),taskProperties.getReceiveNum()*2,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory);
poolExecutor = new ThreadPoolExecutor(taskProperties.getReceiveNum(),maximumPoolSize,5, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),threadFactory);
}
@Override
@ -38,17 +48,20 @@ public class EmailParsingActuator extends Thread{
try {
final Message[] messages = emailServiceManager.receiveMail();
if(ArrayUtils.isNotEmpty(messages)){
System.out.println(messages.length);
CountDownLatch taskLatch = new CountDownLatch(messages.length);
for(Message message : messages){
SpectrumParsingActuator spectrumParsingActuator = new SpectrumParsingActuator();
spectrumParsingActuator.init(message,emailProperties,emailServiceManager,ftpUtil,taskLatch);
spectrumParsingActuator.init(message,emailProperties,emailServiceManager,
taskLatch,spectrumServiceQuotes,emailCounter);
poolExecutor.execute(spectrumParsingActuator);
}
taskLatch.await();
}
}catch (MessagingException | InterruptedException e) {
e.printStackTrace();
}finally {
//关闭资源
emailServiceManager.close();
}
long end = System.currentTimeMillis();
long sleepTime = taskProperties.getMailThreadExecCycle() - (end-start);

View File

@ -0,0 +1,25 @@
package org.jeecg.modules.config.datasource;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
/**
* 数据源切换器
*/
public class DataSourceSwitcher {
private final static String ORACLE = "ora";
private final static String PGSQL = "master";
public static void switchToOracle(){
DynamicDataSourceContextHolder.push(ORACLE);
}
public static void switchToPGSql(){
DynamicDataSourceContextHolder.push(PGSQL);
}
public static void clearDataSource(){
DynamicDataSourceContextHolder.clear();
}
}

View File

@ -0,0 +1,65 @@
package org.jeecg.modules.emuns;
/**
* 邮件类型
*/
public enum DataType {
/**
* 气象谱
*/
MET("MET",".met"),
/**
* 警告谱
*/
ALERT_UPS("ALERT_UPS",".alt"),
/**
* 警告谱
*/
ALERT_SYSTEM("ALERT_SYSTEM",".alt"),
/**
* 警告谱
*/
ALERT_TEMP("ALERT_TEMP",".alt"),
/**
* 警告谱
*/
ALERT_FLOW("ALERT_FLOW",".alt"),
/**
* 健康状态谱
*/
SOH("RMSSOH",".soh"),
/**
* 样品谱
*/
SAMPLEPHD("SAMPLEPHD",".PHD"),
/**
* 探测器本地谱
*/
DETBKPHD("DETBKPHD",".PHD"),
/**
* QC谱
*/
QCPHD("QCPHD",".PHD"),
/**
* 气体谱
*/
GASBKPHD("GASBKPHD",".PHD");
private String type;
private String suffix;
DataType(String type, String suffix) {
this.type = type;
this.suffix = suffix;
}
public String getType(){
return this.type;
}
public String getSuffix(){
return this.suffix;
}
}

View File

@ -1,46 +0,0 @@
package org.jeecg.modules.emuns;
/**
* 邮件类型
*/
public enum SpectrumType {
/**
* 气象谱
*/
MET("MET"),
/**
* 警告谱
*/
ALERT("ALERT_UPS"),
/**
* 健康状态谱
*/
SOH("RMSSOH"),
/**
* 样品谱
*/
SAMPLEPHD("SAMPLEPHD"),
/**
* 探测器本地谱
*/
DETBKPHD("DETBKPHD"),
/**
* QC谱
*/
QCPHD("QCPHD"),
/**
* 气体谱
*/
GASBKPHD("GASBKPHD");
private String type;
SpectrumType(String type) {
this.type = type;
}
public String getType(){
return this.type;
}
}

View File

@ -0,0 +1,28 @@
package org.jeecg.modules.emuns;
public enum SystemType {
/**
* 颗粒物
*/
PARTICULATE("P"),
/**
* β-γ
*/
BETA("B"),
/**
* γ
*/
GAMMA("G");
private String type;
SystemType(String type) {
this.type = type;
}
public String getType(){
return this.type;
}
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsAlertData;
public interface GardsAlertDataMapper extends BaseMapper<GardsAlertData> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsBgEfficiencyPairs;
public interface GardsBgEfficiencyPairsMapper extends BaseMapper<GardsBgEfficiencyPairs> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsCalibrationPairsOrig;
public interface GardsCalibrationPairsOrigMapper extends BaseMapper<GardsCalibrationPairsOrig> {
}

View File

@ -0,0 +1,10 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.configuration.GardsDetectors;
/**
* 台站的探测器信息数据表Mapper
*/
public interface GardsDetectorsMapper extends BaseMapper<GardsDetectors> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsHistogram;
public interface GardsHistogramMapper extends BaseMapper<GardsHistogram> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsMetData;
public interface GardsMetDataMapper extends BaseMapper<GardsMetData> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsRoiLimits;
public interface GardsRoiLimitsMapper extends BaseMapper<GardsRoiLimits> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSampleAux;
public interface GardsSampleAuxMapper extends BaseMapper<GardsSampleAux> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSampleCertLine;
public interface GardsSampleCertLineMapper extends BaseMapper<GardsSampleCertLine> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSampleCert;
public interface GardsSampleCertMapper extends BaseMapper<GardsSampleCert> {
}

View File

@ -0,0 +1,8 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSampleData;
public interface GardsSampleDataMapper extends BaseMapper<GardsSampleData> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSampleDescription;
public interface GardsSampleDescriptionMapper extends BaseMapper<GardsSampleDescription> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSampleRatios;
public interface GardsSampleRatiosMapper extends BaseMapper<GardsSampleRatios> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSohData;
public interface GardsSohDataMapper extends BaseMapper<GardsSohData> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSpectrum;
public interface GardsSpectrumMapper extends BaseMapper<GardsSpectrum> {
}

View File

@ -0,0 +1,10 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.configuration.GardsStations;
/**
* 台站数据表Mapper
*/
public interface GardsStationsMapper extends BaseMapper<GardsStations> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsTotalEfficiencyPairs;
public interface GardsTotalEfficiencyPairsMapper extends BaseMapper<GardsTotalEfficiencyPairs> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
public interface SysMailLogMapper extends BaseMapper<SysEmailLog> {
}

View File

@ -1,6 +1,11 @@
package org.jeecg.modules.native_jni;
import org.jeecg.modules.native_jni.struct.AlertSpectrumStruct;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.native_jni.struct.MetSpectrumStruct;
import org.jeecg.modules.native_jni.struct.SOHSpectrumStruct;
import java.util.List;
/**
* 能谱处理本地类
@ -13,4 +18,25 @@ public class EnergySpectrumHandler {
* @return 能谱原始数据
*/
public static native EnergySpectrumStruct getSourceData(String path);
/**
* 获取健康状态谱原始数据
* @param path 能谱文件路径
* @return 能谱原始数据
*/
public static native SOHSpectrumStruct getSOHSourceData(String path);
/**
* 获取警告谱原始数据
* @param path 能谱文件路径
* @return 能谱原始数据
*/
public static native AlertSpectrumStruct getAlertSourceData(String path);
/**
* 获取气象谱原始数据
* @param path 能谱文件路径
* @return 能谱原始数据
*/
public static native MetSpectrumStruct getMetSourceData(String path);
}

View File

@ -0,0 +1,31 @@
package org.jeecg.modules.native_jni.struct;
/**
* 警告谱结构体
*/
public class AlertSpectrumStruct {
public String station_code;
public String alert_type;
public String date;
public String time;
public String desc;
public AlertSpectrumStruct() {
}
@Override
public String toString() {
return "AlertSpectrumStruct{" +
"station_code='" + station_code + '\'' +
", alert_type='" + alert_type + '\'' +
", date='" + date + '\'' +
", time='" + time + '\'' +
", desc='" + desc + '\'' +
'}';
}
}

View File

@ -71,6 +71,10 @@ public class EnergySpectrumStruct {
*/
public String transmit_time;
/************************* Sample ******************/
public double dimension_1;
public double dimension_2;
/************************* Comment ******************/
public String comment;
@ -263,7 +267,7 @@ public class EnergySpectrumStruct {
/**
* ROI number
*/
public List<String> bg_ROI_number;
public List<Double> bg_ROI_number;
/**
* β-γ coincidence efficiency (counts in ROI/β-γ pair emitted)
*/
@ -357,46 +361,199 @@ public class EnergySpectrumStruct {
*/
public List<Long> h_counts;
/************************* Certificate_Block ******************/
/**
* total source activity (Bq)
*/
public double total_source_activity;
/**
* assay date (yyyy / mm / dd)
*/
public String assay_date;
/**
* assay time (hh : mm : ss)
*/
public String assay_time;
/**
* units of activity: B, b for Bq or [blank]; if nothing, then B is assigned
*/
public String units_activity;
/**
* nuclide name
*/
public List<String> nuclide_name;
/**
* half-life in seconds, hours, days, or years
*/
public List<String> half_life_time;
/**
* time unit(Y, D, H, S)
*/
public List<String> time_unit;
/**
* activity of nuclide at time of assay
*/
public List<Double> activity_nuclide_time_assay;
/**
* uncertainty (%)
*/
public List<Double> uncertainty;
/**
* γ-energy (keV)
*/
public List<Double> cer_g_energy;
/**
* γ-intensity (percent)
*/
public List<Double> g_intensity;
/**
* electron decay mode descriptor: B for β particle or C for conversion electron (CE), 0 for none (that is, γ-only source)
*/
public List<String> electron_decay_mode;
/**
* maximum β-particle energy or CE energy (keV)
*/
public List<Double> maximum_energy;
/**
* intensity of β-particle (percent)
*/
public List<Double> intensity_b_particle;
public int record_count;
/************************* Totaleff Block ******************/
/**
* γ-energy (keV)
*/
public List<String> t_g_energy;
/**
* total efficiency (counts/photon emitted)
*/
public List<Double> total_efficiency;
/**
* uncertainty (counts/photon emitted)
*/
public List<Double> t_uncertainty;
public int t_record_count;
public EnergySpectrumStruct() {
super();
}
@Override
public String toString() {
return "EnergySpectrumStruct [msg_type=" + msg_type + ", msg_id=" + msg_id + ", data_type=" + data_type
+ ", designator=" + designator + ", site_code=" + site_code + ", detector_code=" + detector_code
+ ", system_type=" + system_type + ", sample_geometry=" + sample_geometry + ", spectrum_quantity="
+ spectrum_quantity + ", sample_ref_id=" + sample_ref_id + ", measurement_id=" + measurement_id
+ ", detector_bk_measurement_id=" + detector_bk_measurement_id + ", gas_bk_measurement_id="
+ gas_bk_measurement_id + ", transmit_date=" + transmit_date + ", transmit_time=" + transmit_time
+ ", comment=" + comment + ", acquisition_start_date=" + acquisition_start_date
+ ", acquisition_start_time=" + acquisition_start_time + ", acquisition_real_time="
+ acquisition_real_time + ", acquisition_live_time=" + acquisition_live_time
+ ", collection_start_date=" + collection_start_date + ", collection_start_time="
+ collection_start_time + ", collection_stop_date=" + collection_stop_date + ", collection_stop_time="
+ collection_stop_time + ", air_volume=" + air_volume + ", sample_volume_of_Xe=" + sample_volume_of_Xe
+ ", uncertainty_1=" + uncertainty_1 + ", Xe_collection_yield=" + Xe_collection_yield
+ ", uncertainty_2=" + uncertainty_2 + ", archive_bottle_id=" + archive_bottle_id
+ ", date_calibration=" + date_calibration + ", time_calibration=" + time_calibration + ", g_energy="
+ g_energy + ", g_centroid_channel=" + g_centroid_channel + ", g_uncertainty=" + g_uncertainty
+ ", g_record_count=" + g_record_count + ", b_electron_energy=" + b_electron_energy + ", b_decay_mode="
+ b_decay_mode + ", b_channel=" + b_channel + ", b_uncertainty=" + b_uncertainty + ", b_record_count="
+ b_record_count + ", g_r_energy=" + g_r_energy + ", g_r_FWHM=" + g_r_FWHM + ", g_r_uncertainty="
+ g_r_uncertainty + ", g_r_record_count=" + g_r_record_count + ", b_r_electron_energy="
+ b_r_electron_energy + ", b_r_FWHM=" + b_r_FWHM + ", b_r_uncertainty=" + b_r_uncertainty
+ ", b_r_record_count=" + b_r_record_count + ", g_e_energy=" + g_e_energy + ", g_e_efficiency="
+ g_e_efficiency + ", g_e_uncertainty=" + g_e_uncertainty + ", g_e_record_count=" + g_e_record_count
+ ", ROI_number=" + ROI_number + ", POI_B_x1=" + POI_B_x1 + ", POI_B_x2=" + POI_B_x2 + ", POI_G_y1="
+ POI_G_y1 + ", POI_G_y2=" + POI_G_y2 + ", roi_record_count=" + roi_record_count + ", bg_nuclide_name="
+ bg_nuclide_name + ", bg_ROI_number=" + bg_ROI_number + ", bg_efficiency=" + bg_efficiency
+ ", bg_uncertainty=" + bg_uncertainty + ", bg_record_count=" + bg_record_count + ", ratio_id="
+ ratio_id + ", ROI_num_highter_G_energy_ROI=" + ROI_num_highter_G_energy_ROI
+ ", ROI_num_lower_G_energy_ROI=" + ROI_num_lower_G_energy_ROI + ", count_ratio=" + count_ratio
+ ", count_ratio_uncertainty=" + count_ratio_uncertainty + ", ratio_record_count=" + ratio_record_count
+ ", num_g_channel=" + num_g_channel + ", g_energy_span=" + g_energy_span + ", g_begin_channel="
+ g_begin_channel + ", g_counts=" + g_counts + ", num_b_channel=" + num_b_channel + ", b_energy_span="
+ b_energy_span + ", b_begin_channel=" + b_begin_channel + ", b_counts=" + b_counts + ", b_channels="
+ b_channels + ", g_channels=" + g_channels + ", b_h_energy_span=" + b_h_energy_span
+ ", g_h_energy_span=" + g_h_energy_span + ", h_counts=1]";
return "EnergySpectrumStruct{" +
"msg_type='" + msg_type + '\'' +
", msg_id='" + msg_id + '\'' +
", data_type='" + data_type + '\'' +
", designator='" + designator + '\'' +
", site_code='" + site_code + '\'' +
", detector_code='" + detector_code + '\'' +
", system_type='" + system_type + '\'' +
", sample_geometry='" + sample_geometry + '\'' +
", spectrum_quantity='" + spectrum_quantity + '\'' +
", sample_ref_id='" + sample_ref_id + '\'' +
", measurement_id='" + measurement_id + '\'' +
", detector_bk_measurement_id='" + detector_bk_measurement_id + '\'' +
", gas_bk_measurement_id='" + gas_bk_measurement_id + '\'' +
", transmit_date='" + transmit_date + '\'' +
", transmit_time='" + transmit_time + '\'' +
", dimension_1=" + dimension_1 +
", dimension_2=" + dimension_2 +
", comment='" + comment + '\'' +
", acquisition_start_date='" + acquisition_start_date + '\'' +
", acquisition_start_time='" + acquisition_start_time + '\'' +
", acquisition_real_time=" + acquisition_real_time +
", acquisition_live_time=" + acquisition_live_time +
", collection_start_date='" + collection_start_date + '\'' +
", collection_start_time='" + collection_start_time + '\'' +
", collection_stop_date='" + collection_stop_date + '\'' +
", collection_stop_time='" + collection_stop_time + '\'' +
", air_volume=" + air_volume +
", sample_volume_of_Xe=" + sample_volume_of_Xe +
", uncertainty_1=" + uncertainty_1 +
", Xe_collection_yield=" + Xe_collection_yield +
", uncertainty_2=" + uncertainty_2 +
", archive_bottle_id='" + archive_bottle_id + '\'' +
", date_calibration='" + date_calibration + '\'' +
", time_calibration='" + time_calibration + '\'' +
", g_energy=" + g_energy +
", g_centroid_channel=" + g_centroid_channel +
", g_uncertainty=" + g_uncertainty +
", g_record_count=" + g_record_count +
", b_electron_energy=" + b_electron_energy +
", b_decay_mode=" + b_decay_mode +
", b_channel=" + b_channel +
", b_uncertainty=" + b_uncertainty +
", b_record_count=" + b_record_count +
", g_r_energy=" + g_r_energy +
", g_r_FWHM=" + g_r_FWHM +
", g_r_uncertainty=" + g_r_uncertainty +
", g_r_record_count=" + g_r_record_count +
", b_r_electron_energy=" + b_r_electron_energy +
", b_r_FWHM=" + b_r_FWHM +
", b_r_uncertainty=" + b_r_uncertainty +
", b_r_record_count=" + b_r_record_count +
", g_e_energy=" + g_e_energy +
", g_e_efficiency=" + g_e_efficiency +
", g_e_uncertainty=" + g_e_uncertainty +
", g_e_record_count=" + g_e_record_count +
", ROI_number=" + ROI_number +
", POI_B_x1=" + POI_B_x1 +
", POI_B_x2=" + POI_B_x2 +
", POI_G_y1=" + POI_G_y1 +
", POI_G_y2=" + POI_G_y2 +
", roi_record_count=" + roi_record_count +
", bg_nuclide_name=" + bg_nuclide_name +
", bg_ROI_number=" + bg_ROI_number +
", bg_efficiency=" + bg_efficiency +
", bg_uncertainty=" + bg_uncertainty +
", bg_record_count=" + bg_record_count +
", ratio_id=" + ratio_id +
", ROI_num_highter_G_energy_ROI=" + ROI_num_highter_G_energy_ROI +
", ROI_num_lower_G_energy_ROI=" + ROI_num_lower_G_energy_ROI +
", count_ratio=" + count_ratio +
", count_ratio_uncertainty=" + count_ratio_uncertainty +
", ratio_record_count=" + ratio_record_count +
", num_g_channel=" + num_g_channel +
", g_energy_span=" + g_energy_span +
", g_begin_channel=" + g_begin_channel +
", g_counts=" + g_counts +
", num_b_channel=" + num_b_channel +
", b_energy_span=" + b_energy_span +
", b_begin_channel=" + b_begin_channel +
", b_counts=" + b_counts +
", b_channels=" + b_channels +
", g_channels=" + g_channels +
", b_h_energy_span=" + b_h_energy_span +
", g_h_energy_span=" + g_h_energy_span +
", h_counts=" + h_counts +
", total_source_activity=" + total_source_activity +
", assay_date='" + assay_date + '\'' +
", assay_time='" + assay_time + '\'' +
", units_activity='" + units_activity + '\'' +
", nuclide_name=" + nuclide_name +
", half_life_time=" + half_life_time +
", time_unit=" + time_unit +
", activity_nuclide_time_assay=" + activity_nuclide_time_assay +
", uncertainty=" + uncertainty +
", cer_g_energy=" + cer_g_energy +
", g_intensity=" + g_intensity +
", electron_decay_mode=" + electron_decay_mode +
", maximum_energy=" + maximum_energy +
", intensity_b_particle=" + intensity_b_particle +
", record_count=" + record_count +
", t_g_energy=" + t_g_energy +
", total_efficiency=" + total_efficiency +
", t_uncertainty=" + t_uncertainty +
", t_record_count=" + t_record_count +
'}';
}
public static void main(String[] args) {
EnergySpectrumStruct s = new EnergySpectrumStruct();
System.out.println(s);
System.out.println(s.gas_bk_measurement_id);
}
}

View File

@ -0,0 +1,71 @@
package org.jeecg.modules.native_jni.struct;
import java.util.List;
/**
* 气象谱结构体
*/
public class MetSpectrumStruct {
public String station_code;
/**
* met start date (yyyy/mm/dd)
*/
public List<String> met_start_date;
/**
* met start time (hh:mm:ss)
*/
public List<String> met_start_time;
/**
* met end date (yyyy/mm/dd)=
*/
public List<String> met_end_date;
/**
* met end time (hh:mm:ss)
*/
public List<String> met_end_time;
/**
* average outside temperature (°C)
*/
public List<Double> average_outside_temperature;
/**
* average wind-direction (degrees from north)
*/
public List<Double> average_wind_direction;
/**
* average wind-speed (m/s)
*/
public List<Double> average_wind_speed;
/**
* average barometric reading (hPa)
*/
public List<Double> average_barometric_reading;
/**
* average relative humidity (percent relative humidity)
*/
public List<Double> humidity;
/**
* rainfall (mm)
*/
public List<Double> rainfall;
public int record_count;
@Override
public String toString() {
return "MetSpectrumStruct{" +
"station_code='" + station_code + '\'' +
", met_start_date=" + met_start_date +
", met_start_time=" + met_start_time +
", met_end_date=" + met_end_date +
", met_end_time=" + met_end_time +
", average_outside_temperature=" + average_outside_temperature +
", average_wind_direction=" + average_wind_direction +
", average_wind_speed=" + average_wind_speed +
", average_barometric_reading=" + average_barometric_reading +
", humidity=" + humidity +
", rainfall=" + rainfall +
", record_count=" + record_count +
'}';
}
}

View File

@ -0,0 +1,67 @@
package org.jeecg.modules.native_jni.struct;
import java.util.List;
/**
* 健康状态谱结构体
*/
public class SOHSpectrumStruct {
/**
* station code
*/
public String station_code;
/**
* detector code or NA if 1) there is more than one detector or 2) data are from the sam-pling site of a split station
*/
public String detector_code;
/**
* SOH data sampling period start date (yyyy/mm/dd)
*/
public String start_date;
/**
* SOH data sampling period start time (hh:mm:ss)
*/
public String start_time;
/* Air Sampler Flow block */
/**
* average flow rate (standard cubic metersper hour (scm/h))
*/
public List<Double> average_flow_rate;
/**
* flow rate standard deviation (scm/h)
*/
public List<Double> flow_rate_standard_deviation;
/**
* SOH data sampling interval start date (yyyy/mm/dd)
*/
public List<String> af_start_date;
/**
* SOH data sampling interval start time (hh:mm:ss)
*/
public List<String> af_start_time;
/**
* SOH data sampling interval duration (s)
*/
public List<Long> af_interval_duration;
public int af_record_count;
public SOHSpectrumStruct() {
super();
}
@Override
public String toString() {
return "SOHSpectrumStruct{" +
"station_code='" + station_code + '\'' +
", detector_code='" + detector_code + '\'' +
", average_flow_rate=" + average_flow_rate +
", flow_rate_standard_deviation=" + flow_rate_standard_deviation +
", af_start_date=" + af_start_date +
", af_start_time=" + af_start_time +
", af_interval_duration=" + af_interval_duration +
", af_record_count=" + af_record_count +
'}';
}
}

View File

@ -0,0 +1,18 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.original.GardsAlertData;
import org.jeecg.modules.native_jni.struct.AlertSpectrumStruct;
/**
* 报警谱处理
*/
public interface IAlertSpectrumService extends IService<GardsAlertData> {
/**
* 保存报警谱信息
* @param struct
* @param fileName
*/
public void create(AlertSpectrumStruct struct,String fileName) throws Exception;
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.original.GardsMetData;
import org.jeecg.modules.native_jni.struct.MetSpectrumStruct;
/**
* 处理气象谱
*/
public interface IMetSpectrumService extends IService<GardsMetData> {
/**
* 保存气象谱数据
* @param struct
* @param fileName
* @throws Exception
*/
public void create(MetSpectrumStruct struct,String fileName) throws Exception;
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.original.GardsSohData;
import org.jeecg.modules.native_jni.struct.SOHSpectrumStruct;
/**
* 健康谱数据处理
*/
public interface ISOHSpectrumService extends IService<GardsSohData> {
/**
* 保存健康谱数据
* @param struct
* @param fileName
* @throws Exception
*/
public void create(SOHSpectrumStruct struct,String fileName) throws Exception;
}

View File

@ -0,0 +1,20 @@
package org.jeecg.modules.service;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
/**
* 处理能谱文件块数据GardsSampleDataGardsSampleAux
*/
public interface ISpectrumBaseBlockService {
/**
* 保存块数据
* 不添加事务注解由调用方手动事务提交
* @param struct
* @param fileName
* @return
* @throws Exception
*/
public GardsSampleData create(EnergySpectrumStruct struct,String fileName) throws Exception;
}

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.service;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
/**
* 处理能谱文件块数据除GardsSampleDataGardsSampleAux
*/
public interface ISpectrumBlockService {
/**
* 保存块数据
* 不添加事务注解由调用方手动事务提交
* @param struct
* @param sampleData
*/
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData) throws Exception;
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
import org.jeecg.modules.email.EmailProperties;
import javax.mail.Message;
/**
* 邮件处理日志
*/
public interface ISysMailLogService extends IService<SysEmailLog> {
/**
* 创建邮箱日志
* @param message
* @param email
*/
public void create(Message message,EmailProperties email) throws Exception;
}

View File

@ -14,5 +14,6 @@ public interface ISysMailService extends IService<SysEmail> {
* 查询接收邮箱数据
* @return
*/
List<EmailProperties> findReceiveMails();
public List<EmailProperties> findReceiveMails();
}

View File

@ -0,0 +1,54 @@
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.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.base.entity.configuration.GardsStations;
import org.jeecg.modules.base.entity.original.GardsAlertData;
import org.jeecg.modules.mapper.GardsAlertDataMapper;
import org.jeecg.modules.mapper.GardsStationsMapper;
import org.jeecg.modules.native_jni.struct.AlertSpectrumStruct;
import org.jeecg.modules.service.IAlertSpectrumService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
* 报警谱处理
*/
@Service
@DS("ora")
@RequiredArgsConstructor
public class AlertSpectrumServiceImpl extends ServiceImpl<GardsAlertDataMapper, GardsAlertData> implements IAlertSpectrumService {
private final GardsStationsMapper gardsStationsMapper;
/**
* 保存报警谱信息
*
* @param struct
* @param fileName
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void create(AlertSpectrumStruct struct, String fileName) throws Exception{
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
LambdaQueryWrapper<GardsStations> gardsStationsQuery = new LambdaQueryWrapper<>();
gardsStationsQuery.select(GardsStations::getStationId);
gardsStationsQuery.eq(GardsStations::getStationCode,struct.station_code);
final GardsStations stations = gardsStationsMapper.selectOne(gardsStationsQuery);
Assert.notNull(stations,"此台站代码:"+struct.station_code+"所属台站不存在");
GardsAlertData alertData = new GardsAlertData();
alertData.setStationId(stations.getStationId());
alertData.setStationCode(struct.station_code);
alertData.setTime(DateUtils.parseDate(struct.date+" "+struct.time));
alertData.setAlertType(struct.alert_type);
alertData.setAlertText(struct.desc);
alertData.setInputFileName(fileName);
this.save(alertData);
}
}

View File

@ -0,0 +1,52 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.modules.base.entity.original.GardsCalibrationPairsOrig;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsCalibrationPairsOrigMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* #b_Energy块
*/
@Service("#b_Energy")
public class B_EnergyBlockServiceImpl extends ServiceImpl<GardsCalibrationPairsOrigMapper, GardsCalibrationPairsOrig> implements ISpectrumBlockService {
private final static String PHD = "PHD";
private final static String SYSTEMTYPE_B = "B";
private final static String ENERGY_CAL = "ENERGY_CAL";
/**
* #b_Energy数据块中的刻度点
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData){
if(struct.b_record_count > 0){
List<GardsCalibrationPairsOrig> list = Lists.newArrayList();
for (int i=0;i<struct.b_record_count;i++){
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleData.getSampleId());
calibrationPairsOrig.setSampleType(SYSTEMTYPE_B);
calibrationPairsOrig.setCaltype(ENERGY_CAL);
calibrationPairsOrig.setInput(PHD);
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(struct.b_channel.get(i));
calibrationPairsOrig.setYValue(struct.b_electron_energy.get(i));
calibrationPairsOrig.setUncYValue(struct.b_uncertainty.get(i));
calibrationPairsOrig.setDecayMode(struct.b_decay_mode.get(i));
list.add(calibrationPairsOrig);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,46 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.modules.base.entity.original.GardsBgEfficiencyPairs;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsBgEfficiencyPairsMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* #b-gEfficiency块
*/
@Service("#b-gEfficiency")
public class B_G_EfficiencyBlockServiceImpl extends ServiceImpl<GardsBgEfficiencyPairsMapper,GardsBgEfficiencyPairs> implements ISpectrumBlockService {
/**
* 保存β-γ符合谱中#b-gEfficiency数据块中的探测器符合效率刻度点
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData) {
List<GardsBgEfficiencyPairs> list = Lists.newArrayList();
if(struct.bg_record_count > 0){
for(int i=0;i<struct.bg_record_count;i++){
GardsBgEfficiencyPairs efficiencyPairs = new GardsBgEfficiencyPairs();
efficiencyPairs.setSampleId(sampleData.getSampleId());
efficiencyPairs.setRoi(struct.bg_ROI_number.get(i).intValue());
efficiencyPairs.setNuclideName(struct.bg_nuclide_name.get(i));
efficiencyPairs.setBgEfficiency(struct.bg_efficiency.get(i));
efficiencyPairs.setBgEfficError(struct.bg_uncertainty.get(i));
efficiencyPairs.setModdate(new Date());
list.add(efficiencyPairs);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,51 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.modules.base.entity.original.GardsCalibrationPairsOrig;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsCalibrationPairsOrigMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* #b_Resolution块
*/
@Service("#b_Resolution")
public class B_ResolutionBlockServiceImpl extends ServiceImpl<GardsCalibrationPairsOrigMapper, GardsCalibrationPairsOrig> implements ISpectrumBlockService {
private final static String PHD = "PHD";
private final static String SYSTEMTYPE_B = "B";
private final static String RESOLUTION_CAL = "Resolution";
/**
* #b_Resolution数据块中的刻度点
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData){
if(struct.b_r_record_count > 0){
List<GardsCalibrationPairsOrig> list = Lists.newArrayList();
for (int i=0;i<struct.b_r_record_count;i++){
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleData.getSampleId());
calibrationPairsOrig.setSampleType(SYSTEMTYPE_B);
calibrationPairsOrig.setCaltype(RESOLUTION_CAL);
calibrationPairsOrig.setInput(PHD);
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(struct.b_r_electron_energy.get(i));
calibrationPairsOrig.setYValue(struct.b_r_FWHM.get(i));
calibrationPairsOrig.setUncYValue(struct.b_r_uncertainty.get(i));
list.add(calibrationPairsOrig);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,37 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.original.GardsSpectrum;
import org.jeecg.modules.mapper.GardsSpectrumMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* #b_Spectrum块
*/
@Service("#b_Spectrum")
public class B_SpectrumBlockServiceImpl extends ServiceImpl<GardsSpectrumMapper, GardsSpectrum> implements ISpectrumBlockService {
private final static String SYSTEMTYPE_B = "B";
/**
* #b_Spectrum数据块中的数据
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData) {
GardsSpectrum spectrum = new GardsSpectrum();
spectrum.setSampleId(sampleData.getSampleId());
spectrum.setSampleType(SYSTEMTYPE_B);
spectrum.setFilename(sampleData.getInputFileName());
spectrum.setChannels((int)struct.num_b_channel);
spectrum.setEnergySpan((int)struct.b_energy_span);
spectrum.setStartChannel((int)struct.b_begin_channel);
spectrum.setModdate(new Date());
this.save(spectrum);
}
}

View File

@ -0,0 +1,74 @@
package org.jeecg.modules.service.impl;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.base.entity.original.GardsSampleCert;
import org.jeecg.modules.base.entity.original.GardsSampleCertLine;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsSampleCertLineMapper;
import org.jeecg.modules.mapper.GardsSampleCertMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
/**
* #Certificate块
*/
@Service("#Certificate")
@RequiredArgsConstructor
public class CertificateBlockServiceImpl implements ISpectrumBlockService {
private final GardsSampleCertMapper sampleCertMapper;
private final GardsSampleCertLineMapper sampleCertLine;
/**
* QCPHD CALIBPHD谱中#CERTIFICATE数据块中的内容
* @param struct
* @param sampleData
* @throws Exception
*/
@Override
public void create(EnergySpectrumStruct struct, GardsSampleData sampleData) throws Exception {
this.saveSampleCert(struct,sampleData);
this.saveSampleCertLine(struct,sampleData);
}
/**
* 保存GardsSampleCert数据表数据
* @param struct
* @param sampleData
*/
private void saveSampleCert(EnergySpectrumStruct struct, GardsSampleData sampleData)throws Exception{
GardsSampleCert sampleCert = new GardsSampleCert();
sampleCert.setSampleId(sampleData.getSampleId());
sampleCert.setQuantity(struct.total_source_activity);
if(StringUtils.isNotBlank(struct.assay_date) && StringUtils.isNotBlank(struct.assay_time)){
sampleCert.setAssayDate(DateUtils.parseDate(struct.assay_date+" "+struct.assay_time));
}
sampleCert.setUnit(struct.units_activity);
this.sampleCertMapper.insert(sampleCert);
}
private void saveSampleCertLine(EnergySpectrumStruct struct,GardsSampleData sampleData) {
if(struct.record_count > 0){
for(int i=0;i<struct.record_count;i++){
GardsSampleCertLine sampleCertLine = new GardsSampleCertLine();
sampleCertLine.setSampleId(sampleData.getSampleId());
sampleCertLine.setNuclName(struct.nuclide_name.get(i));
sampleCertLine.setHalflife(struct.half_life_time.get(i));
sampleCertLine.setEnergy(struct.cer_g_energy.get(i));
sampleCertLine.setActivity(struct.activity_nuclide_time_assay.get(i));
sampleCertLine.setError(struct.uncertainty.get(i));
sampleCertLine.setAbundance(struct.g_intensity.get(i));
sampleCertLine.setBAbundance(struct.intensity_b_particle.get(i));
sampleCertLine.setBEnergy(struct.maximum_energy.get(i));
sampleCertLine.setDecayMode(struct.electron_decay_mode.get(i));
sampleCertLine.setHalfliftUnit(struct.time_unit.get(i));
this.sampleCertLine.insert(sampleCertLine);
}
}
}
}

View File

@ -0,0 +1,30 @@
package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.original.GardsSampleDescription;
import org.jeecg.modules.mapper.GardsSampleDescriptionMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
/**
* #Comment块
*/
@Service("#Comment")
public class CommentBlockServiceImpl extends ServiceImpl<GardsSampleDescriptionMapper, GardsSampleDescription> implements ISpectrumBlockService {
/**
* 保存#Comment块台站注释
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData){
GardsSampleDescription description = new GardsSampleDescription();
description.setSampleId(sampleData.getSampleId());
description.setDescription(struct.comment);
this.save(description);
}
}

View File

@ -0,0 +1,51 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.modules.base.entity.original.GardsCalibrationPairsOrig;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsCalibrationPairsOrigMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* #g_Efficiency块
*/
@Service("#g_Efficiency")
public class G_EfficiencyBlockServiceImpl extends ServiceImpl<GardsCalibrationPairsOrigMapper, GardsCalibrationPairsOrig> implements ISpectrumBlockService {
private final static String PHD = "PHD";
private final static String SYSTEMTYPE_G = "G";
private final static String EFFICIENCY_CAL ="efficiency";
/**
* #g_efficiency数据块中的刻度点
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData){
if(struct.g_e_record_count > 0){
List<GardsCalibrationPairsOrig> list = Lists.newArrayList();
for (int i=0;i<struct.g_e_record_count;i++){
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleData.getSampleId());
calibrationPairsOrig.setSampleType(SYSTEMTYPE_G);
calibrationPairsOrig.setCaltype(EFFICIENCY_CAL);
calibrationPairsOrig.setInput(PHD);
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(struct.g_e_energy.get(i));
calibrationPairsOrig.setYValue(struct.g_e_efficiency.get(i));
calibrationPairsOrig.setUncYValue(struct.g_e_uncertainty.get(i));
list.add(calibrationPairsOrig);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,51 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.modules.base.entity.original.GardsCalibrationPairsOrig;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsCalibrationPairsOrigMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* #g_energy块
*/
@Service("#g_Energy")
public class G_EnergyBlockServiceImpl extends ServiceImpl<GardsCalibrationPairsOrigMapper, GardsCalibrationPairsOrig> implements ISpectrumBlockService {
private final static String PHD = "PHD";
private final static String SYSTEMTYPE_G = "G";
private final static String ENERGY_CAL = "ENERGY_CAL";
/**
* #g_energy数据块中的刻度点
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData){
if(struct.g_record_count > 0){
List<GardsCalibrationPairsOrig> list = Lists.newArrayList();
for (int i=0;i<struct.g_record_count;i++){
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleData.getSampleId());
calibrationPairsOrig.setSampleType(SYSTEMTYPE_G);
calibrationPairsOrig.setCaltype(ENERGY_CAL);
calibrationPairsOrig.setInput(PHD);
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(struct.g_centroid_channel.get(i));
calibrationPairsOrig.setYValue(struct.g_energy.get(i));
calibrationPairsOrig.setUncYValue(struct.g_uncertainty.get(i));
list.add(calibrationPairsOrig);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,51 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.modules.base.entity.original.GardsCalibrationPairsOrig;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsCalibrationPairsOrigMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* #g_Resolution块
*/
@Service("#g_Resolution")
public class G_ResolutionBlockServiceImpl extends ServiceImpl<GardsCalibrationPairsOrigMapper, GardsCalibrationPairsOrig> implements ISpectrumBlockService {
private final static String PHD = "PHD";
private final static String SYSTEMTYPE_G = "G";
private final static String RESOLUTION_CAL = "Resolution";
/**
* #g_Resolution数据块中的刻度点
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData){
if(struct.g_r_record_count > 0){
List<GardsCalibrationPairsOrig> list = Lists.newArrayList();
for (int i=0;i<struct.g_r_record_count;i++){
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleData.getSampleId());
calibrationPairsOrig.setSampleType(SYSTEMTYPE_G);
calibrationPairsOrig.setCaltype(RESOLUTION_CAL);
calibrationPairsOrig.setInput(PHD);
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(struct.g_r_energy.get(i));
calibrationPairsOrig.setYValue(struct.g_r_FWHM.get(i));
calibrationPairsOrig.setUncYValue(struct.g_r_uncertainty.get(i));
list.add(calibrationPairsOrig);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,37 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.original.GardsSpectrum;
import org.jeecg.modules.mapper.GardsSpectrumMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* #g_Spectrum块
*/
@Service("#g_Spectrum")
public class G_SpectrumBlockServiceImpl extends ServiceImpl<GardsSpectrumMapper, GardsSpectrum> implements ISpectrumBlockService {
private final static String SYSTEMTYPE_G = "G";
/**
* #G_Spectrum数据块中的数据
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData) {
GardsSpectrum spectrum = new GardsSpectrum();
spectrum.setSampleId(sampleData.getSampleId());
spectrum.setSampleType(SYSTEMTYPE_G);
spectrum.setFilename(sampleData.getInputFileName());
spectrum.setChannels((int)struct.num_g_channel);
spectrum.setEnergySpan((int)struct.g_energy_span);
spectrum.setStartChannel((int)struct.g_begin_channel);
spectrum.setModdate(new Date());
this.save(spectrum);
}
}

View File

@ -0,0 +1,35 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.original.GardsHistogram;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsHistogramMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
*#Histogram块
*/
@Service("#Histogram")
public class HistogramBlockServiceImpl extends ServiceImpl<GardsHistogramMapper, GardsHistogram> implements ISpectrumBlockService {
/**
* β-γ符合谱中#histogram数据块中的数据
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct, GardsSampleData sampleData) {
GardsHistogram histogram = new GardsHistogram();
histogram.setSampleId(sampleData.getSampleId());
histogram.setFilename(sampleData.getInputFileName());
histogram.setGChannels((int)struct.g_channels);
histogram.setBChannels((int)struct.b_channels);
histogram.setGEnergySpan((int)struct.g_energy_span);
histogram.setBEnergySpan((int)struct.b_energy_span);
histogram.setModdate(new Date());
this.save(histogram);
}
}

View File

@ -0,0 +1,73 @@
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.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.base.entity.configuration.GardsStations;
import org.jeecg.modules.base.entity.original.GardsMetData;
import org.jeecg.modules.mapper.GardsMetDataMapper;
import org.jeecg.modules.mapper.GardsStationsMapper;
import org.jeecg.modules.native_jni.struct.MetSpectrumStruct;
import org.jeecg.modules.service.IMetSpectrumService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
/**
* 处理气象谱
*/
@Service
@DS("ora")
@RequiredArgsConstructor
public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, GardsMetData> implements IMetSpectrumService {
private final GardsStationsMapper gardsStationsMapper;
/**
* 保存气象谱数据
* @param struct
* @param fileName
* @throws Exception
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void create(MetSpectrumStruct struct,String fileName) throws Exception{
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
LambdaQueryWrapper<GardsStations> gardsStationsQuery = new LambdaQueryWrapper<>();
gardsStationsQuery.select(GardsStations::getStationId);
gardsStationsQuery.eq(GardsStations::getStationCode,struct.station_code);
final GardsStations stations = gardsStationsMapper.selectOne(gardsStationsQuery);
Assert.notNull(stations,"此台站代码:"+struct.station_code+"所属台站不存在");
if(struct.record_count > 0){
List<GardsMetData> list = Lists.newArrayList();
for(int i=0;i<struct.record_count;i++){
GardsMetData metData = new GardsMetData();
metData.setStationId(stations.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(struct.humidity.get(i));
metData.setAvgtemperature(struct.average_outside_temperature.get(i));
metData.setAvePressure(struct.average_barometric_reading.get(i));
metData.setAveWindDir(struct.average_wind_direction.get(i));
metData.setAveWindSpeed(struct.average_wind_speed.get(i));
metData.setRainfall(struct.rainfall.get(i));
metData.setInputFileName(fileName);
metData.setModdate(new Date());
list.add(metData);
}
if(!CollectionUtils.isEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,47 @@
package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.modules.base.entity.original.GardsRoiLimits;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsRoiLimitsMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* #ROI_Limits块
*/
@Service("#ROI_Limits")
public class ROI_LimitsBlockServiceImpl extends ServiceImpl<GardsRoiLimitsMapper, GardsRoiLimits> implements ISpectrumBlockService {
/**
* 保存β-γ符合谱中#ROI_LMITS 数据块中的感兴趣区能量边界数据
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct, GardsSampleData sampleData) {
if(struct.roi_record_count > 0) {
List<GardsRoiLimits> list = Lists.newArrayList();
for (int i = 0; i < struct.roi_record_count; i++) {
GardsRoiLimits roiLimits = new GardsRoiLimits();
roiLimits.setSampleId(sampleData.getSampleId());
roiLimits.setRoi(Integer.valueOf(struct.ROI_number.get(i)));
roiLimits.setBEnergyStart(struct.POI_B_x1.get(i));
roiLimits.setBEnergyStop(struct.POI_B_x2.get(i));
roiLimits.setGEnergyStart(struct.POI_G_y1.get(i));
roiLimits.setGEnergyStop(struct.POI_G_y2.get(i));
roiLimits.setModdate(new Date());
list.add(roiLimits);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,47 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.original.GardsSampleRatios;
import org.jeecg.modules.mapper.GardsSampleRatiosMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* #Ratios块
*/
@Service("#Ratios")
public class RatiosBlockServiceImpl extends ServiceImpl<GardsSampleRatiosMapper,GardsSampleRatios> implements ISpectrumBlockService {
/**
* β-γ符合谱中# Ratios 数据块中的感兴趣区相应核素的计数比率
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct, GardsSampleData sampleData) {
if(struct.ratio_record_count > 0) {
List<GardsSampleRatios> list = Lists.newArrayList();
for (int i = 0; i < struct.ratio_record_count; i++) {
GardsSampleRatios sampleRatios = new GardsSampleRatios();
sampleRatios.setSampleId(sampleData.getSampleId());
sampleRatios.setRatioId(struct.ratio_id.get(i));
sampleRatios.setUpperRoiNumber(Integer.valueOf(struct.ROI_num_highter_G_energy_ROI.get(i)));
sampleRatios.setLowerRoiNumber(Integer.valueOf(struct.ROI_num_lower_G_energy_ROI.get(i)));
sampleRatios.setCountRatio(struct.count_ratio.get(i));
sampleRatios.setCountRatioErr(struct.count_ratio_uncertainty.get(i));
sampleRatios.setModdate(new Date());
list.add(sampleRatios);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,79 @@
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.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.base.entity.configuration.GardsDetectors;
import org.jeecg.modules.base.entity.configuration.GardsStations;
import org.jeecg.modules.base.entity.original.GardsSohData;
import org.jeecg.modules.mapper.GardsDetectorsMapper;
import org.jeecg.modules.mapper.GardsSohDataMapper;
import org.jeecg.modules.mapper.GardsStationsMapper;
import org.jeecg.modules.native_jni.struct.SOHSpectrumStruct;
import org.jeecg.modules.service.ISOHSpectrumService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
/**
* 健康谱数据处理
*/
@DS("ora")
@Service
@RequiredArgsConstructor
public class SOHSpectrumServiceImpl extends ServiceImpl<GardsSohDataMapper, GardsSohData> implements ISOHSpectrumService {
private final GardsStationsMapper gardsStationsMapper;
private final GardsDetectorsMapper gardsDetectorsMapper;
/**
* 保存健康谱数据
* @param struct
* @param fileName
* @throws Exception
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void create(SOHSpectrumStruct struct,String fileName) throws Exception{
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
Assert.notNull(struct.detector_code,"此次解析结构体中的台站“探测器代码”为空");
LambdaQueryWrapper<GardsStations> gardsStationsQuery = new LambdaQueryWrapper<>();
gardsStationsQuery.select(GardsStations::getStationId);
gardsStationsQuery.eq(GardsStations::getStationCode,struct.station_code);
final GardsStations stations = gardsStationsMapper.selectOne(gardsStationsQuery);
Assert.notNull(stations,"此台站代码:"+struct.station_code+"所属台站不存在");
LambdaQueryWrapper<GardsDetectors> gardsGardsDetectorsQuery = new LambdaQueryWrapper<>();
gardsGardsDetectorsQuery.select(GardsDetectors::getDetectorId);
gardsGardsDetectorsQuery.eq(GardsDetectors::getDetectorCode,struct.detector_code);
final GardsDetectors gardsDetectors = gardsDetectorsMapper.selectOne(gardsGardsDetectorsQuery);
Assert.notNull(gardsDetectors,"此探测器代码:"+struct.detector_code+"所属探测器不存在");
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(stations.getStationId());
sohData.setStationCode(struct.station_code);
sohData.setStartTime(DateUtils.parseDate(struct.af_start_date.get(i)+" "+struct.af_start_time.get(i)));
sohData.setTime(struct.af_interval_duration.get(i).doubleValue());
sohData.setAvgflowrate(struct.average_flow_rate.get(i));
sohData.setFlowratedev(struct.flow_rate_standard_deviation.get(i));
sohData.setInputFileName(fileName);
sohData.setDetectorId(gardsDetectors.getDetectorId());
sohData.setModdate(new Date());
list.add(sohData);
}
if(!CollectionUtils.isEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -0,0 +1,136 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.base.entity.configuration.GardsDetectors;
import org.jeecg.modules.base.entity.configuration.GardsStations;
import org.jeecg.modules.base.entity.original.GardsSampleAux;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.enums.SampleStatus;
import org.jeecg.modules.mapper.GardsDetectorsMapper;
import org.jeecg.modules.mapper.GardsSampleAuxMapper;
import org.jeecg.modules.mapper.GardsSampleDataMapper;
import org.jeecg.modules.mapper.GardsStationsMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBaseBlockService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.text.ParseException;
import java.util.Date;
import java.util.Objects;
/**
* 原始库基本数据
*/
@Service
@RequiredArgsConstructor
public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
private final GardsStationsMapper gardsStationsMapper;
private final GardsDetectorsMapper gardsDetectorsMapper;
private final GardsSampleDataMapper sampleDataMapper;
private final GardsSampleAuxMapper sampleAuxMapper;
/**
* 保存块数据
* 不添加事务注解由调用方手动事务提交
* @param struct
* @param fileName
* @return
* @throws Exception
*/
@Override
public GardsSampleData create(EnergySpectrumStruct struct,String fileName) throws Exception {
final GardsSampleData sampleData = this.saveSampleData(struct,fileName);
this.saveSampleAux(struct,sampleData);
return sampleData;
}
/**
* 保存GardsSampleData基础数据
* @param struct
* @return
* @throws Exception
*/
private GardsSampleData saveSampleData(EnergySpectrumStruct struct,String fileName) throws Exception{
Assert.notNull(struct.site_code,"此次解析结构体中的台站“台站代码”为空");
Assert.notNull(struct.detector_code,"此次解析结构体中的台站“探测器代码”为空");
LambdaQueryWrapper<GardsStations> gardsStationsQuery = new LambdaQueryWrapper<>();
gardsStationsQuery.select(GardsStations::getStationId);
gardsStationsQuery.eq(GardsStations::getStationCode,struct.site_code);
final GardsStations stations = gardsStationsMapper.selectOne(gardsStationsQuery);
Assert.notNull(stations,"此台站代码:"+struct.site_code+"所属台站不存在");
LambdaQueryWrapper<GardsDetectors> gardsGardsDetectorsQuery = new LambdaQueryWrapper<>();
gardsGardsDetectorsQuery.select(GardsDetectors::getDetectorId);
gardsGardsDetectorsQuery.eq(GardsDetectors::getDetectorCode,struct.detector_code);
final GardsDetectors gardsDetectors = gardsDetectorsMapper.selectOne(gardsGardsDetectorsQuery);
Assert.notNull(gardsDetectors,"此探测器代码:"+struct.detector_code+"所属探测器不存在");
GardsSampleData gardsSampleData = new GardsSampleData();
gardsSampleData.setSiteDetCode(struct.detector_code);
// gardsSampleData.setSampleId();//数据库自增
gardsSampleData.setStationId(stations.getStationId());
gardsSampleData.setDetectorId(gardsDetectors.getDetectorId());
gardsSampleData.setInputFileName(fileName);
gardsSampleData.setSampleType(struct.system_type);
gardsSampleData.setDataType(String.valueOf(struct.data_type.charAt(0)));
gardsSampleData.setGeometry(struct.sample_geometry);
gardsSampleData.setSpectralQualifie(struct.spectrum_quantity);
if(StringUtils.isNotBlank(struct.transmit_date) && StringUtils.isNotBlank(struct.transmit_time)){
gardsSampleData.setTransmitDtg(DateUtils.parseDate(struct.transmit_date+" "+struct.transmit_time));
}
if(StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time)){
gardsSampleData.setCollectStart(DateUtils.parseDate(struct.collection_start_date+" "+struct.collection_start_time));
}
if(StringUtils.isNotBlank(struct.collection_stop_date) && StringUtils.isNotBlank(struct.collection_stop_time)){
gardsSampleData.setCollectStart(DateUtils.parseDate(struct.collection_stop_date+" "+struct.collection_stop_time));
}
if(StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time)){
gardsSampleData.setAcquisitionStart(DateUtils.parseDate(struct.acquisition_start_date+" "+struct.acquisition_start_time));
}
if(Objects.nonNull(gardsSampleData.getAcquisitionStart()) && struct.acquisition_real_time > 0){
Date acquisitionStop = new Date((long) (gardsSampleData.getAcquisitionStart().getTime()+struct.acquisition_real_time));
gardsSampleData.setAcquisitionStop(acquisitionStop);
}
gardsSampleData.setAcquisitionRealSec(struct.acquisition_real_time);
gardsSampleData.setAcquisitionLiveSec(struct.acquisition_live_time);
gardsSampleData.setQuantity(struct.air_volume);
gardsSampleData.setStatus(SampleStatus.UNTREATED.getValue());
gardsSampleData.setModdate(new Date());
this.sampleDataMapper.insert(gardsSampleData);
return gardsSampleData;
}
/**
* 保存GardsSampleAux基础数据
* @param sampleData
*/
private void saveSampleAux(EnergySpectrumStruct struct,GardsSampleData sampleData) throws Exception{
GardsSampleAux gardsSampleAux = new GardsSampleAux();
gardsSampleAux.setSampleId(sampleData.getSampleId());
gardsSampleAux.setSampleRefId(struct.sample_ref_id);
gardsSampleAux.setMeasurementId(struct.measurement_id);
gardsSampleAux.setBkgdMeasurementId(struct.detector_bk_measurement_id);
gardsSampleAux.setGasBkgdMeasurementId(struct.gas_bk_measurement_id);
gardsSampleAux.setSampleHeight(struct.dimension_2);
gardsSampleAux.setSampleDiameter(struct.dimension_1);
if(StringUtils.isNotBlank(struct.date_calibration) && StringUtils.isNotBlank(struct.time_calibration)){
gardsSampleAux.setCalibrationDtg(DateUtils.parseDate(struct.date_calibration+" "+struct.time_calibration));
}
gardsSampleAux.setMsgId(struct.msg_id);
gardsSampleAux.setArchiveBottleId(struct.archive_bottle_id);
gardsSampleAux.setXeVolume(struct.sample_volume_of_Xe);
gardsSampleAux.setXeVolumeUncer(struct.uncertainty_1);
gardsSampleAux.setXeCollectionYied(struct.Xe_collection_yield);
gardsSampleAux.setXeCollectionYiedUncer(struct.uncertainty_2);
this.sampleAuxMapper.insert(gardsSampleAux);
}
}

View File

@ -0,0 +1,32 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
import org.jeecg.modules.email.EmailProperties;
import org.jeecg.modules.mapper.SysMailLogMapper;
import org.jeecg.modules.service.ISysMailLogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.mail.Message;
import javax.mail.internet.MimeUtility;
/**
* 邮件处理日志
*/
@Service
public class SysMailLogServiceImpl extends ServiceImpl<SysMailLogMapper, SysEmailLog> implements ISysMailLogService {
/**
* 创建邮箱日志
* @param message
* @param email
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void create(Message message,EmailProperties email) throws Exception {
SysEmailLog mailLog = new SysEmailLog();
mailLog.setEmailId(email.getId());
mailLog.setSubject(MimeUtility.decodeText(message.getSubject()));
mailLog.setReceiveTime(message.getReceivedDate());
this.save(mailLog);
}
}

View File

@ -0,0 +1,45 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.original.GardsTotalEfficiencyPairs;
import org.jeecg.modules.mapper.GardsTotalEfficiencyPairsMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* #TotalEff块
*/
@Service("#TotalEff")
public class TotalEffBlockServiceImpl extends ServiceImpl<GardsTotalEfficiencyPairsMapper,GardsTotalEfficiencyPairs> implements ISpectrumBlockService {
/**
* 所有谱中#TotalEff 数据块中的探测器总效率刻度点此数据块是可选项 IDC没有
* @param struct
* @param sampleData
*/
@Override
public void create(EnergySpectrumStruct struct,GardsSampleData sampleData) {
if(struct.t_record_count > 0){
List<GardsTotalEfficiencyPairs> list = Lists.newArrayList();
for(int i=0;i<struct.t_record_count;i++){
GardsTotalEfficiencyPairs totalEfficiencyPairs = new GardsTotalEfficiencyPairs();
totalEfficiencyPairs.setSampleId(sampleData.getSampleId());
totalEfficiencyPairs.setEfficEnergy(struct.t_g_energy.get(i));
totalEfficiencyPairs.setTotalEfficiency(struct.total_efficiency.get(i));
totalEfficiencyPairs.setTotalEfficError(struct.t_uncertainty.get(i));
totalEfficiencyPairs.setModdate(new Date());
list.add(totalEfficiencyPairs);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -1,23 +1,34 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.emuns.SpectrumType;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.util.Objects;
import cn.hutool.core.io.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.modules.emuns.DataType;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.AlertSpectrumStruct;
import java.io.FileInputStream;
import java.time.LocalDate;
/**
* 警告谱处理
*/
@Slf4j
public class AlertSpectrum extends SpectrumHandler{
/**
* 解析后的数据
*/
private AlertSpectrumStruct sourceData = null;
/**
* 设置过滤链路
*/
@Override
protected void setChina() {
SpectrumHandler spectrumHandler = new HealthStatusSpectrum();
spectrumHandler.init(super.filePath,super.ftpUtil,super.sourceData);
spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile,
super.currDataType,super.message,super.emailProperties);
spectrumHandler.setPrevious(this);
super.setNext(spectrumHandler);
}
@ -26,11 +37,24 @@ public class AlertSpectrum extends SpectrumHandler{
* 检查规则并处理数据
*/
@Override
protected void handler() {
if(Objects.nonNull(super.sourceData) && SpectrumType.ALERT.getType().equals(super.sourceData.data_type)){
System.out.println("----------------------------------");
System.out.println(SpectrumType.ALERT.getType());
System.out.println("----------------------------------");
protected void handler() throws Exception {
if(DataType.ALERT_FLOW.getType().equals(super.currDataType.getType()) ||
DataType.ALERT_TEMP.getType().equals(super.currDataType.getType()) ||
DataType.ALERT_SYSTEM.getType().equals(super.currDataType.getType()) ||
DataType.ALERT_UPS.getType().equals(super.currDataType.getType())){
log.info("----------------------------------");
log.info(super.currDataType.getType());
log.info("----------------------------------");
//解析邮件内容
this.parseingEmail();
//保存PHD文件到ftp
this.saveFileToFtp();
//结构体数据入库
this.handlerOriginalData();
//保存email日志
super.saveEmailLog();
//删除本地临时文件
super.deleteLocalTemporaryFile();
}else{
super.next.handler();
}
@ -38,31 +62,65 @@ public class AlertSpectrum extends SpectrumHandler{
/**
* 处理原始数据
*
* @param struct
*/
@Override
protected void handlerOriginalData(EnergySpectrumStruct struct) {
protected void handlerAnalysisResult() {
}
/**
* 调用dll解析邮件
*/
@Override
protected void parseingEmail() {
final AlertSpectrumStruct sourceData = EnergySpectrumHandler.getAlertSourceData(mailFile.getAbsolutePath());
this.sourceData = sourceData;
}
/**
* 保存能谱文件到ftp
*/
@Override
protected void saveFileToFtp() throws Exception {
this.updateSpectrumFileName();
//处理此文件需要保存到ftp服务的路径
final int year = LocalDate.now().getYear();
final int month = LocalDate.now().getMonth().getValue();
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
StringBuilder ftpPath = new StringBuilder();
ftpPath.append(properties.getFilePathMap().get(super.currDataType.getType()));
ftpPath.append("/");
ftpPath.append(year);
ftpPath.append("/");
ftpPath.append(month>=10?month:"0"+month);
super.spectrumServiceQuotes.getFtpUtil().saveFile(properties.getRootPath()+"/"+ftpPath.toString(),this.mailFile.getName(),new FileInputStream(this.mailFile));
//设置FTP文件保存路径
super.ftpSavePath = ftpPath+"/"+this.mailFile.getName();
// FileUtil.appendString(super.ftpSavePath+System.lineSeparator(),"C:\\Users\\86187\\Desktop\\engine\\sampleId.txt", "UTF-8");
}
/**
* 对本地能谱临时文件进行改名
*/
@Override
protected void updateSpectrumFileName() {
StringBuilder newFileName = new StringBuilder();
newFileName.append(this.sourceData.station_code);
newFileName.append("_");
newFileName.append(super.currDataType.getType());
newFileName.append("-");
newFileName.append(StringUtils.replace(this.sourceData.date,"/",""));
newFileName.append("_");
newFileName.append(StringUtils.replace(this.sourceData.time,":",""));
newFileName.append(super.currDataType.getSuffix());
mailFile = FileUtil.rename(mailFile,newFileName.toString(),true);
}
/**
* 处理原始数据
*
* @param struct
*/
@Override
protected void handlerAnalysisResult(EnergySpectrumStruct struct) {
}
/**
* 转存本地邮件到FTP服务
*
* @return
*/
@Override
protected void transferToFTP() {
protected void handlerOriginalData() throws Exception {
spectrumServiceQuotes.getAlertSpectrumService().create(this.sourceData,super.ftpSavePath);
}
}

View File

@ -1,15 +1,13 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.emuns.SpectrumType;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.emuns.DataType;
/**
* 探测器本地谱处理
*/
public class DetbkphdSpectrum extends SpectrumHandler{
@Slf4j
public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
/**
* 设置过滤链路
@ -17,7 +15,8 @@ public class DetbkphdSpectrum extends SpectrumHandler{
@Override
protected void setChina() {
SpectrumHandler spectrumHandler = new QcphdSpectrum();
spectrumHandler.init(super.filePath,super.ftpUtil,super.sourceData);
spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile,
super.currDataType,super.message,super.emailProperties);
spectrumHandler.setPrevious(this);
super.setNext(spectrumHandler);
}
@ -26,43 +25,35 @@ public class DetbkphdSpectrum extends SpectrumHandler{
* 检查规则并处理数据
*/
@Override
protected void handler() {
if(Objects.nonNull(super.sourceData) && SpectrumType.DETBKPHD.getType().equals(super.sourceData.data_type)){
System.out.println("----------------------------------");
System.out.println(SpectrumType.DETBKPHD.getType());
System.out.println("----------------------------------");
protected void handler() throws Exception {
if(DataType.DETBKPHD.getType().equals(super.currDataType.getType())){
log.info("----------------------------------");
log.info(super.currDataType.getType());
log.info("----------------------------------");
//解析邮件内容
super.parseingEmail();
//读取邮件内容标签
super.readFileLabel();
//保存PHD文件到ftp
super.saveFileToFtp();
//结构体数据入库
super.handlerOriginalData();
//保存email日志
super.saveEmailLog();
//删除本地临时文件
super.deleteLocalTemporaryFile();
}else{
super.next.handler();
}
}
/**
* 处理原始数据
*
* @param struct
*/
@Override
protected void handlerOriginalData(EnergySpectrumStruct struct) {
}
/**
* 处理分析结果
*
* @param struct
*/
@Override
protected void handlerAnalysisResult(EnergySpectrumStruct struct) {
}
/**
* 转存本地邮件到FTP服务
*
* @return
*/
@Override
protected void transferToFTP() {
protected void handlerAnalysisResult() {
}
}

View File

@ -0,0 +1,26 @@
package org.jeecg.modules.spectrum;
import org.springframework.stereotype.Component;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 邮件计数器
*/
@Component
public class EmailCounter {
private Object lock = new Object();
private AtomicInteger emlCounter = new AtomicInteger();
public int getCurrValue(){
synchronized (lock){
final int currValue = emlCounter.getAndIncrement();
if(currValue >= 10){
emlCounter.set(0);
}
return currValue;
}
}
}

View File

@ -1,42 +1,47 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.emuns.SpectrumType;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.emuns.DataType;
/**
* 气体谱处理
*/
public class GasbkphdSpectrum extends SpectrumHandler{
@Slf4j
public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
/**
* 设置过滤链路
*/
@Override
protected void setChina() {
SpectrumHandler spectrumHandler = new MetSpectrum();
spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile,
super.currDataType,super.message,super.emailProperties);
spectrumHandler.setPrevious(this);
super.setNext(spectrumHandler);
}
/**
* 检查规则并处理数据
*/
@Override
protected void handler() {
}
/**
* 处理原始数据
*
* @param struct
*/
@Override
protected void handlerOriginalData(EnergySpectrumStruct struct) {
if(Objects.nonNull(super.sourceData) && SpectrumType.GASBKPHD.getType().equals(super.sourceData.data_type)){
System.out.println("----------------------------------");
System.out.println(SpectrumType.GASBKPHD.getType());
System.out.println("----------------------------------");
protected void handler() throws Exception {
if(DataType.GASBKPHD.getType().equals(super.currDataType.getType())){
log.info("----------------------------------");
log.info(super.currDataType.getType());
log.info("----------------------------------");
//解析邮件内容
super.parseingEmail();
//读取邮件内容标签
super.readFileLabel();
//保存PHD文件到ftp
super.saveFileToFtp();
//结构体数据入库
super.handlerOriginalData();
//保存email日志
super.saveEmailLog();
//删除本地临时文件
super.deleteLocalTemporaryFile();
}else{
super.next.handler();
}
@ -44,21 +49,9 @@ public class GasbkphdSpectrum extends SpectrumHandler{
/**
* 处理分析结果
*
* @param struct
*/
@Override
protected void handlerAnalysisResult(EnergySpectrumStruct struct) {
}
/**
* 转存本地邮件到FTP服务
*
* @return
*/
@Override
protected void transferToFTP() {
protected void handlerAnalysisResult() {
}
}

View File

@ -1,67 +1,117 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.emuns.SpectrumType;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.util.Objects;
import cn.hutool.core.io.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.modules.emuns.DataType;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.SOHSpectrumStruct;
import java.io.FileInputStream;
import java.time.LocalDate;
/**
* 健康状态谱处理
*/
@Slf4j
public class HealthStatusSpectrum extends SpectrumHandler{
/**
* 解析后的数据
*/
private SOHSpectrumStruct sourceData = null;
/**
* 设置过滤链路
*/
@Override
protected void setChina() {
SpectrumHandler spectrumHandler = new SamplephdSpectrum();
spectrumHandler.init(super.filePath,super.ftpUtil,super.sourceData);
spectrumHandler.setPrevious(this);
super.setNext(spectrumHandler);
}
/**
* 检查规则并处理数据
*/
@Override
protected void handler() {
if(Objects.nonNull(super.sourceData) && SpectrumType.SOH.getType().equals(super.sourceData.data_type)){
System.out.println("----------------------------------");
System.out.println(SpectrumType.SOH.getType());
System.out.println("----------------------------------");
}else{
super.next.handler();
protected void handler() throws Exception {
if(DataType.SOH.getType().equals(super.currDataType.getType())){
log.info("----------------------------------");
log.info(super.currDataType.getType());
log.info("----------------------------------");
//解析邮件内容
this.parseingEmail();
//保存PHD文件到ftp
this.saveFileToFtp();
//结构体数据入库
this.handlerOriginalData();
//保存email日志
super.saveEmailLog();
//删除本地临时文件
super.deleteLocalTemporaryFile();
}
}
/**
* 处理原始数据
*
* @param struct
*/
@Override
protected void handlerOriginalData(EnergySpectrumStruct struct) {
}
/**
* 处理分析结果
*
* @param struct
*/
@Override
protected void handlerAnalysisResult(EnergySpectrumStruct struct) {
protected void handlerAnalysisResult() {
}
/**
* 转存本地邮件到FTP服务
*
* @return
* 调用dll解析邮件
*/
@Override
protected void transferToFTP() {
protected void parseingEmail() {
final SOHSpectrumStruct sourceData = EnergySpectrumHandler.getSOHSourceData(mailFile.getAbsolutePath());
this.sourceData = sourceData;
}
/**
* 保存能谱文件到ftp
*/
@Override
protected void saveFileToFtp() throws Exception {
this.updateSpectrumFileName();
//处理此文件需要保存到ftp服务的路径
final int year = LocalDate.now().getYear();
final int month = LocalDate.now().getMonth().getValue();
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
StringBuilder ftpPath = new StringBuilder();
ftpPath.append(properties.getFilePathMap().get(super.currDataType.getType()));
ftpPath.append("/");
ftpPath.append(year);
ftpPath.append("/");
ftpPath.append(month>=10?month:"0"+month);
super.spectrumServiceQuotes.getFtpUtil().saveFile(properties.getRootPath()+"/"+ftpPath.toString(),this.mailFile.getName(),new FileInputStream(this.mailFile));
//设置FTP文件保存路径
super.ftpSavePath = ftpPath+"/"+this.mailFile.getName();
// FileUtil.appendString(super.ftpSavePath+System.lineSeparator(),"C:\\Users\\86187\\Desktop\\engine\\sampleId.txt", "UTF-8");
}
/**
* 对本地能谱临时文件进行改名
*/
@Override
protected void updateSpectrumFileName() {
StringBuilder newFileName = new StringBuilder();
newFileName.append(this.sourceData.station_code);
newFileName.append("_");
newFileName.append(super.currDataType.getType());
newFileName.append("-");
newFileName.append(StringUtils.replace(this.sourceData.start_date,"/",""));
newFileName.append("_");
newFileName.append(StringUtils.replace(this.sourceData.start_time,":",""));
newFileName.append(super.currDataType.getSuffix());
mailFile = FileUtil.rename(mailFile,newFileName.toString(),true);
}
/**
* 处理原始数据
*/
@Override
protected void handlerOriginalData() throws Exception {
spectrumServiceQuotes.getSohSpectrumService().create(this.sourceData,super.ftpSavePath);
}
}

View File

@ -1,22 +1,34 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.emuns.SpectrumType;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.util.Objects;
import cn.hutool.core.io.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.modules.emuns.DataType;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.MetSpectrumStruct;
import java.io.FileInputStream;
import java.time.LocalDate;
/**
* 气象谱处理
*/
@Slf4j
public class MetSpectrum extends SpectrumHandler{
/**
* 解析后的数据
*/
private MetSpectrumStruct sourceData = null;
/**
* 设置过滤链路
*/
@Override
protected void setChina() {
SpectrumHandler spectrumHandler = new AlertSpectrum();
spectrumHandler.init(super.filePath,super.ftpUtil,super.sourceData);
spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile,
super.currDataType,super.message,super.emailProperties);
spectrumHandler.setPrevious(this);
super.setNext(spectrumHandler);
}
@ -25,43 +37,87 @@ public class MetSpectrum extends SpectrumHandler{
* 检查规则并处理数据
*/
@Override
protected void handler() {
if(Objects.nonNull(super.sourceData) && SpectrumType.MET.getType().equals(super.sourceData.data_type)){
System.out.println("----------------------------------");
System.out.println(SpectrumType.MET.getType());
System.out.println("----------------------------------");
protected void handler() throws Exception {
if(DataType.MET.getType().equals(super.currDataType.getType())){
log.info("----------------------------------");
log.info(super.currDataType.getType());
log.info("----------------------------------");
//解析邮件内容
this.parseingEmail();
//保存PHD文件到ftp
this.saveFileToFtp();
//结构体数据入库
this.handlerOriginalData();
//保存email日志
super.saveEmailLog();
//删除本地临时文件
super.deleteLocalTemporaryFile();
}else{
super.next.handler();
}
}
/**
* 处理原始数据
*
* @param struct
*/
@Override
protected void handlerOriginalData(EnergySpectrumStruct struct) {
}
/**
* 处理分析结果
*
* @param struct
*/
@Override
protected void handlerAnalysisResult(EnergySpectrumStruct struct) {
protected void handlerAnalysisResult() {
}
/**
* 转存本地邮件到FTP服务
*
* @return
* 调用dll解析邮件
*/
@Override
protected void transferToFTP() {
protected void parseingEmail() {
final MetSpectrumStruct sourceData = EnergySpectrumHandler.getMetSourceData(mailFile.getAbsolutePath());
this.sourceData = sourceData;
}
/**
* 保存能谱文件到ftp
*/
@Override
protected void saveFileToFtp() throws Exception {
this.updateSpectrumFileName();
//处理此文件需要保存到ftp服务的路径
final int year = LocalDate.now().getYear();
final int month = LocalDate.now().getMonth().getValue();
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
StringBuilder ftpPath = new StringBuilder();
ftpPath.append(properties.getFilePathMap().get(super.currDataType.getType()));
ftpPath.append("/");
ftpPath.append(year);
ftpPath.append("/");
ftpPath.append(month>=10?month:"0"+month);
super.spectrumServiceQuotes.getFtpUtil().saveFile(properties.getRootPath()+"/"+ftpPath.toString(),this.mailFile.getName(),new FileInputStream(this.mailFile));
//设置FTP文件保存路径
super.ftpSavePath = ftpPath+"/"+this.mailFile.getName();
FileUtil.appendString(super.ftpSavePath+System.lineSeparator(),"C:\\Users\\86187\\Desktop\\engine\\sampleId.txt", "UTF-8");
}
/**
* 对本地能谱临时文件进行改名
*/
@Override
protected void updateSpectrumFileName() {
StringBuilder newFileName = new StringBuilder();
newFileName.append(this.sourceData.station_code);
newFileName.append("_");
newFileName.append(super.currDataType.getType());
newFileName.append("-");
newFileName.append(StringUtils.replace(this.sourceData.met_start_date.get(0),"/",""));
newFileName.append("_");
newFileName.append(StringUtils.replace(this.sourceData.met_start_time.get(0),":",""));
newFileName.append(super.currDataType.getSuffix());
mailFile = FileUtil.rename(mailFile,newFileName.toString(),true);
}
/**
* 处理原始数据
*/
@Override
protected void handlerOriginalData() throws Exception {
spectrumServiceQuotes.getMetSpectrumService().create(this.sourceData,super.ftpSavePath);
}
}

View File

@ -1,14 +1,13 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.emuns.SpectrumType;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.emuns.DataType;
/**
* QC谱处理
*/
public class QcphdSpectrum extends SpectrumHandler{
@Slf4j
public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{
/**
* 设置过滤链路
@ -16,7 +15,8 @@ public class QcphdSpectrum extends SpectrumHandler{
@Override
protected void setChina() {
SpectrumHandler spectrumHandler = new GasbkphdSpectrum();
spectrumHandler.init(super.filePath,super.ftpUtil,super.sourceData);
spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile,
super.currDataType,super.message,super.emailProperties);
spectrumHandler.setPrevious(this);
super.setNext(spectrumHandler);
}
@ -25,43 +25,34 @@ public class QcphdSpectrum extends SpectrumHandler{
* 检查规则并处理数据
*/
@Override
protected void handler() {
if(Objects.nonNull(super.sourceData) && SpectrumType.QCPHD.getType().equals(super.sourceData.data_type)){
System.out.println("----------------------------------");
System.out.println(SpectrumType.QCPHD.getType());
System.out.println("----------------------------------");
protected void handler() throws Exception {
//判断当前邮件内容是否是QC谱
if(DataType.QCPHD.getType().equals(super.currDataType.getType())){
log.info("----------------------------------");
log.info(super.currDataType.getType());
log.info("----------------------------------");
//解析邮件内容
super.parseingEmail();
//读取邮件内容标签
super.readFileLabel();
//保存PHD文件到ftp
super.saveFileToFtp();
//结构体数据入库
super.handlerOriginalData();
//保存email日志
super.saveEmailLog();
//删除本地临时文件
super.deleteLocalTemporaryFile();
}else{
super.next.handler();
}
}
/**
* 处理原始数据
*
* @param struct
*/
@Override
protected void handlerOriginalData(EnergySpectrumStruct struct) {
}
/**
* 处理分析结果
*
* @param struct
*/
@Override
protected void handlerAnalysisResult(EnergySpectrumStruct struct) {
}
/**
* 转存本地邮件到FTP服务
*
* @return
*/
@Override
protected void transferToFTP() {
protected void handlerAnalysisResult() {
}
}

View File

@ -0,0 +1,127 @@
package org.jeecg.modules.spectrum;
import cn.hutool.core.io.FileUtil;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.transaction.TransactionStatus;
import java.io.FileInputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
/**
* 样品谱(Samplephd)探测器本地谱DetbkphdQC谱Qcphd气体谱Gasbkphd
*/
public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
/**
* 解析后的数据
*/
protected EnergySpectrumStruct sourceData = null;
/**
* 调用dll解析邮件
*/
@Override
protected void parseingEmail() {
final EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(mailFile.getAbsolutePath());
this.sourceData = sourceData;
}
/**
* 保存能谱文件到ftp
*/
@Override
protected void saveFileToFtp() throws Exception {
//修改能谱文件名称
this.updateSpectrumFileName();
//处理此文件需要保存到ftp服务的路径
final int year = LocalDate.now().getYear();
final int month = LocalDate.now().getMonth().getValue();
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
StringBuilder ftpPath = new StringBuilder();
ftpPath.append(properties.getFilePathMap().get(this.sourceData.system_type));
ftpPath.append("/");
ftpPath.append(properties.getFilePathMap().get(this.sourceData.data_type));
ftpPath.append("/");
ftpPath.append(year);
ftpPath.append("/");
ftpPath.append(month>=10?month:"0"+month);
this.spectrumServiceQuotes.getFtpUtil().saveFile(properties.getRootPath()+"/"+ftpPath.toString(),this.mailFile.getName(),new FileInputStream(this.mailFile));
//设置FTP文件保存路径
super.ftpSavePath = ftpPath+"/"+this.mailFile.getName();
// FileUtil.appendString(super.ftpSavePath+System.lineSeparator(),"C:\\Users\\86187\\Desktop\\engine\\sampleId.txt", "UTF-8");
}
/**
* 对本地能谱临时文件进行改名
*/
@Override
protected void updateSpectrumFileName() {
StringBuilder newFileName = new StringBuilder();
newFileName.append(this.sourceData.detector_code);
newFileName.append("-");
newFileName.append(StringUtils.replace(this.sourceData.acquisition_start_date,"/",""));
newFileName.append("_");
newFileName.append(StringUtils.replace(this.sourceData.acquisition_start_time.substring(0,this.sourceData.acquisition_start_time.lastIndexOf(":")),":",""));
newFileName.append("_");
newFileName.append(this.sourceData.data_type.charAt(0));
newFileName.append("_");
newFileName.append(this.sourceData.spectrum_quantity);
newFileName.append("_");
newFileName.append(this.sourceData.acquisition_live_time);
newFileName.append(super.currDataType.getSuffix());
mailFile = FileUtil.rename(mailFile,newFileName.toString(),true);
}
/**
* 读取邮件内容#开头的标签
* @throws Exception
*/
protected void readFileLabel() throws Exception{
Path path = Paths.get(mailFile.getAbsolutePath());
final List<String> lines = Files.readAllLines(path);
for(String line : lines){
if(line.indexOf("#") != -1){
spectrumFileLabels.add(line);
}
}
}
/**
* 处理原始数据
*/
@Override
protected void handlerOriginalData() throws Exception {
DataSourceSwitcher.switchToOracle();
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
try{
//存储基础数据
final GardsSampleData sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.ftpSavePath);
//存储其他块数据
for(String labels : spectrumFileLabels){
final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels);
if(Objects.nonNull(spectrumBlockService)){
spectrumBlockService.create(sourceData,sampleData);
}
}
//提交事务
spectrumServiceQuotes.getTransactionManager().commit(transactionStatus);
}catch (Exception e){
//回滚事务
spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus);
throw e;
}finally {
DataSourceSwitcher.clearDataSource();
}
}
}

View File

@ -1,15 +1,13 @@
package org.jeecg.modules.spectrum;
import org.bouncycastle.tsp.TSPUtil;
import org.jeecg.modules.emuns.SpectrumType;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.emuns.DataType;
/**
* 样品谱处理
*/
public class SamplephdSpectrum extends SpectrumHandler{
@Slf4j
public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
/**
* 设置过滤链路
@ -17,7 +15,8 @@ public class SamplephdSpectrum extends SpectrumHandler{
@Override
protected void setChina() {
SpectrumHandler spectrumHandler = new DetbkphdSpectrum();
spectrumHandler.init(super.filePath,super.ftpUtil,super.sourceData);
spectrumHandler.initNext(super.spectrumServiceQuotes,super.mailFile,
super.currDataType,super.message,super.emailProperties);
spectrumHandler.setPrevious(this);
super.setNext(spectrumHandler);
}
@ -26,42 +25,35 @@ public class SamplephdSpectrum extends SpectrumHandler{
* 检查规则并处理数据
*/
@Override
protected void handler() {
if(Objects.nonNull(super.sourceData) && SpectrumType.SAMPLEPHD.getType().equals(super.sourceData.data_type)){
System.out.println("1111111111111111111111111111111111111111111111111");
System.out.println(super.sourceData);
protected void handler() throws Exception {
if(DataType.SAMPLEPHD.getType().equals(super.currDataType.getType())){
log.info("----------------------------------");
log.info(super.currDataType.getType());
log.info("----------------------------------");
//解析邮件内容
super.parseingEmail();
//读取邮件内容标签
super.readFileLabel();
//保存PHD文件到ftp
super.saveFileToFtp();
//结构体数据入库
super.handlerOriginalData();
//保存email日志
super.saveEmailLog();
//删除本地临时文件
super.deleteLocalTemporaryFile();
}else{
super.next.handler();
}
}
/**
* 处理原始数据
*
* @param struct
*/
@Override
protected void handlerOriginalData(EnergySpectrumStruct struct) {
}
/**
* 处理分析结果
*
* @param struct
*/
@Override
protected void handlerAnalysisResult(EnergySpectrumStruct struct) {
}
/**
* 转存本地邮件到FTP服务
*
* @return
*/
@Override
protected void transferToFTP() {
protected void handlerAnalysisResult() {
}
}

View File

@ -1,66 +1,146 @@
package org.jeecg.modules.spectrum;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import cn.hutool.core.io.FileUtil;
import com.google.common.collect.Lists;
import org.jeecg.modules.email.EmailProperties;
import org.jeecg.modules.emuns.DataType;
import javax.mail.Message;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.Objects;
/**
* 能谱处理模版
*/
public abstract class SpectrumHandler extends Chain{
protected FTPUtil ftpUtil;
private final static String DATA_TYPE_PREFIX = "DATA_TYPE ";
/**
* 当前邮件信息
*/
protected Message message;
/**
* 邮件属性
*/
protected EmailProperties emailProperties;
/**
* 处理能谱数据相关Service引用
*/
protected SpectrumServiceQuotes spectrumServiceQuotes;
/**
* 当前解析的邮件内容文本
*/
protected String mailContent;
/**
* 能谱类型
*/
protected DataType currDataType;
/**
* 当前解析的能谱文件路径
*/
protected String filePath;
protected File mailFile = null;
/**
* 能谱文件FTP保存路径
*/
protected String ftpSavePath;
protected EnergySpectrumStruct sourceData =null;
/**
* 保存当前能谱文件有哪些#开头的标签
*/
protected List<String> spectrumFileLabels = Lists.newArrayList();
/**
* 初始化参数
*/
protected void init(String filePath,FTPUtil ftpUtil,EnergySpectrumStruct sourceData){
this.filePath = filePath;
this.ftpUtil = ftpUtil;
this.sourceData = sourceData;
protected void init(String mailContent,SpectrumServiceQuotes spectrumServiceQuotes,Message message,EmailProperties emailProperties) throws Exception{
this.mailContent = mailContent;
this.spectrumServiceQuotes = spectrumServiceQuotes;
this.message = message;
this.emailProperties = emailProperties;
}
/**
* 初始化参数
*/
protected void initNext(SpectrumServiceQuotes spectrumServiceQuotes,File mailFile,DataType currDataType,Message message,EmailProperties emailProperties){
this.spectrumServiceQuotes = spectrumServiceQuotes;
this.mailFile = mailFile;
this.currDataType = currDataType;
this.message = message;
this.emailProperties = emailProperties;
this.setChina();
}
/**
* 检查规则并处理数据
*/
protected abstract void handler();
/**
* 处理原始数据
* @param struct
*/
protected abstract void handlerOriginalData(EnergySpectrumStruct struct);
protected abstract void handler() throws Exception;
/**
* 处理分析结果
* @param struct
*/
protected abstract void handlerAnalysisResult(EnergySpectrumStruct struct);
protected abstract void handlerAnalysisResult();
/**
* 转存本地邮件到FTP服务
* @return
* 调用dll解析邮件
*/
protected abstract void transferToFTP();
protected abstract void parseingEmail();
/**
* 删除本地邮件
* 保存能谱文件到ftp
*/
protected void removeLocalFile(){
File file = new File(this.filePath);
if(file.exists() && file.isFile()){
file.delete();
protected abstract void saveFileToFtp() throws Exception;
/**
* 对本地能谱临时文件进行改名
*/
protected abstract void updateSpectrumFileName();
/**
* 处理原始数据
*/
protected abstract void handlerOriginalData() throws Exception;
/**
* 把邮件内容存储到本地
*/
protected boolean saveEmailToLocal(){
boolean flag = false;
final DataType[] values = DataType.values();
for(DataType value : values){
if(this.mailContent.indexOf(DATA_TYPE_PREFIX+value.getType()) != -1){
StringBuilder localPath = new StringBuilder();
localPath.append(this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
localPath.append(File.separator);
localPath.append(System.currentTimeMillis());
localPath.append(value.getSuffix());
this.mailFile = FileUtil.writeString(this.mailContent, localPath.toString(), "UTF-8");
this.currDataType = value;
flag = true;
break;
}
}
//如果匹配成功则设置过滤链路
if(flag){
this.setChina();
}
return flag;
}
/**
* 保存邮件日志到PG数据库
* @throws Exception
*/
protected void saveEmailLog() throws Exception {
this.spectrumServiceQuotes.getMailLogService().create(this.message,this.emailProperties);
}
/**
* 删除本地临时文件
*/
protected void deleteLocalTemporaryFile(){
if(Objects.nonNull(mailFile) && mailFile.isFile()){
mailFile.delete();
}
}
}

View File

@ -1,25 +1,40 @@
package org.jeecg.modules.spectrum;
import cn.hutool.core.io.FileUtil;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.email.EmailServiceManager;
import org.jeecg.common.email.emuns.MailContentType;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.properties.TaskProperties;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.modules.email.EmailLogProperties;
import org.jeecg.modules.email.EmailProperties;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeUtility;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.io.File;
import java.util.Date;
import java.util.concurrent.CountDownLatch;
/**
* 能谱解析
*/
@Slf4j
public class SpectrumParsingActuator implements Runnable{
/**
* IMS2.0格式邮件判断条件
*/
private final static String EMAIL_BEGIN = "BEGIN IMS2.0";
private final static String MSG_TYPE = "MSG_TYPE DATA";
private final static String EMAIL_STOP = "STOP";
/**
* 存储到ftp的Email文件后缀
*/
private final static String SAVE_EML_SUFFIX = ".eml";
/**
* 邮件对象
@ -34,58 +49,135 @@ public class SpectrumParsingActuator implements Runnable{
*/
private EmailServiceManager emailServiceManager;
/**
* FTP工具
* 线程池任务计数器
*/
private CountDownLatch taskLatch;
/**
* 相关Spring组件引用
*/
private SpectrumServiceQuotes spectrumServiceQuotes;
/**
* 邮件保存路径相关属性
*/
private SpectrumPathProperties spectrumPathProperties;
/**
* 邮件计数器
*/
private EmailCounter emailCounter;
/**
* ftp工具
*/
private FTPUtil ftpUtil;
CountDownLatch taskLatch;
public void init(Message message,EmailProperties emailProperties,
EmailServiceManager emailServiceManager,FTPUtil ftpUtil,
CountDownLatch taskLatch){
public void init(Message message, EmailProperties emailProperties,
EmailServiceManager emailServiceManager,
CountDownLatch taskLatch,SpectrumServiceQuotes spectrumServiceQuotes,
EmailCounter emailCounter){
this.message = message;
this.emailProperties = emailProperties;
this.emailServiceManager = emailServiceManager;
this.ftpUtil = ftpUtil;
this.taskLatch = taskLatch;
this.spectrumServiceQuotes = spectrumServiceQuotes;
this.spectrumPathProperties = spectrumServiceQuotes.getSpectrumPathProperties();
this.emailCounter = emailCounter;
this.ftpUtil = spectrumServiceQuotes.getFtpUtil();
}
@Override
public void run() {
//如果是带有附件的邮件
String subject = null;
StringBuilder mailContent = null;
try {
if(message.getContentType().startsWith(MailContentType.MIXED.getContentType())){
//封装邮件日志信息
EmailLogProperties mailLog = new EmailLogProperties();
mailLog.setEmailId(emailProperties.getId());
mailLog.setSubject(MimeUtility.decodeText(message.getSubject()));
final StringBuilder content = new StringBuilder();
emailServiceManager.getMailContent(message,content);
mailLog.setContext(content.toString());
mailLog.setReceiveTime(message.getSentDate());
final List<String> filePathList = emailServiceManager.saveAttachment(message);
//通过策略模式根据条件适配那个谱所属类执行处理原始信息和分析结果
for (String filePath : filePathList){
final EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(filePath);
//如果返回的结构体数据是错误的说明文件不是正常能谱文件则跳出
if(false){
}else{
SpectrumHandler spectrumHandler = new MetSpectrum();
spectrumHandler.init(filePath,ftpUtil,sourceData);
spectrumHandler.handler();
}
subject = MimeUtility.decodeText(message.getSubject());
System.out.println(subject);
mailContent = new StringBuilder();
emailServiceManager.getMailContent(message,mailContent);
// mailContent = new StringBuilder(FileUtil.readUtf8String("E:\\file\\AUX04_RMSSOH-20230601_021743.soh"));
//所有邮件都需以.eml格式存储到ftp eml文件夹中
downloadEmailToFtp();
//判断是否是IMS2.0协议文件
if(checkMailContent(mailContent,subject)){
SpectrumHandler spectrumHandler = new SamplephdSpectrum();
spectrumHandler.init(mailContent.toString(),spectrumServiceQuotes,message,emailProperties);
final boolean matchResult = spectrumHandler.saveEmailToLocal();
if(matchResult){
spectrumHandler.handler();
}else{
log.warn("此邮件{}匹配失败不在气象谱、警告谱、健康状态谱、样品谱、探测器本地谱、QC谱、气体谱之列",subject);
}
}else{
//如果此邮件不带有附件则删除
emailServiceManager.removeMail(message);
}
} catch (MessagingException | IOException e) {
//删除邮箱中已处理过的邮件
emailServiceManager.removeMail(message);
} catch (Exception e) {
System.out.println(mailContent.toString());
log.error("邮件解析失败,邮件主题为:{},失败原因为:{}",subject,e.getMessage());
e.printStackTrace();
}finally {
this.taskLatch.countDown();
//关闭资源
emailServiceManager.close();
}
}
/**
* 校验邮件内容完整性
* 1.虽然包含BEGIN IMS2.0但是有些邮件的第一行不是BEGIN IMS2.0而是Mime-Version: 1.0 Content-Type: multipart/signed;等信息
* 2.所以若是IMS2.0协议邮件但是头部包含Mime-Version等信息了要删除
* 具体解释如下
* 1.邮件包含附件或特殊内容类型当邮件包含附件HTML 内容图像或其他非纯文本内容时通常会采用 MIME 格式来处理和传输这些内容
* 因此这样的邮件可能会在头部中指定 Mime-Version 和适当的 Content-Type
* 2.邮件需要进行签名或加密如果邮件需要进行数字签名加密或其他安全操作通常会使用 multipart/signed 或其他相关的 Content-Type
* 这些类型的邮件在头部中会指定相应的内容类型和协议信息
* 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));
}
if(!StringUtils.endsWith(mailContent,EMAIL_STOP)){
mailContent.delete(mailContent.indexOf(EMAIL_STOP)+EMAIL_STOP.length(),mailContent.length());
}
log.info("{}邮件校验成功符合IMS2.0格式",subject);
return true;
}
log.warn("{}邮件校验成功此邮件不符合IMS2.0格式",subject);
return false;
}
/**
* 把邮件下载到ftp指定文件夹eml
* 格式为发件人_主题_年月日_时分秒毫秒_计数0-10000
* 当计数大于10000后从0开始服务重启后也从0开始
*/
private void downloadEmailToFtp() throws Exception{
//获取发件人
final String address = ((InternetAddress) message.getFrom()[0]).getAddress();
final String from = address.substring(0,address.indexOf("@"));
//获取主题
String subject = MimeUtility.decodeText(message.getSubject());
if(subject.indexOf("/") != -1){
subject = StringUtils.replace(subject,"/","");
}
if(subject.indexOf(":") != -1){
subject = StringUtils.replace(subject,":","");
}
StringBuilder fileName = new StringBuilder();
fileName.append(from);
fileName.append("_");
fileName.append(subject);
fileName.append("_");
fileName.append(DateUtils.formatDate(new Date(),"YYMMdd"));
fileName.append("_");
fileName.append(DateUtils.formatDate(new Date(),"HHMMSSSSS"));
fileName.append("_");
fileName.append(emailCounter.getCurrValue());
fileName.append(SAVE_EML_SUFFIX);
// final File file = new File("E:\\file\\" + fileName.toString());
// FileUtil.writeFromStream(message.getInputStream(),file);
ftpUtil.saveFile(spectrumPathProperties.getEmlPath(),fileName.toString(),message.getInputStream());
}
}

View File

@ -0,0 +1,44 @@
package org.jeecg.modules.spectrum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.properties.TaskProperties;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.modules.service.*;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Component;
import org.springframework.transaction.TransactionDefinition;
import java.util.Map;
/**
* 各能谱Service引用封装
*/
@Getter
@Component
@RequiredArgsConstructor
public class SpectrumServiceQuotes {
private final DataSourceTransactionManager transactionManager;
private final TransactionDefinition transactionDefinition;
private final ISpectrumBaseBlockService spectrumBaseBlockService;
private final Map<String,ISpectrumBlockService> spectrumBlockService;
private final TaskProperties taskProperties;
private final FTPUtil ftpUtil;
private final SpectrumPathProperties spectrumPathProperties;
private final ISOHSpectrumService sohSpectrumService;
private final IAlertSpectrumService alertSpectrumService;
private final IMetSpectrumService metSpectrumService;
private final ISysMailLogService mailLogService;
}

View File

@ -1,14 +0,0 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
public class SpecturmDataStorage {
/**
* 保存 GARDS_SAMPLE_DATA
*/
public static void saveSampleData(EnergySpectrumStruct struct){
GardsSampleData gardsSampleData = new GardsSampleData();
}
}

View File

@ -66,7 +66,9 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
@Override
@Transactional(rollbackFor = JeecgBootException.class)
public boolean resumeJob(QuartzJob quartzJob) {
schedulerDelete(quartzJob.getId());
if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
schedulerDelete(quartzJob.getId());
}
schedulerAdd(quartzJob.getId(), quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
quartzJob.setStatus(CommonConstant.STATUS_NORMAL);
return this.updateById(quartzJob);
@ -74,7 +76,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
/**
* 编辑&启停定时任务
* @throws SchedulerException
* @throws SchedulerException
*/
@Override
@Transactional(rollbackFor = JeecgBootException.class)
@ -163,7 +165,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
/**
* 删除定时任务
*
*
* @param id
*/
private void schedulerDelete(String id) {

View File

@ -15,5 +15,5 @@ spring:
config:
import:
- optional:nacos:jeecg.yaml
- optional:nacos:jeecg-@profile.name@.yaml
- optional:nacos:jeecg-@profile.name@-pbl.yaml