fix:1.错误eml情况处理2.核素浓度均值列表页增加过滤条件
This commit is contained in:
parent
fe755c83ee
commit
09b2eb9739
|
@ -1,6 +1,8 @@
|
|||
package org.jeecg.common.email;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sun.mail.imap.IMAPStore;
|
||||
|
@ -12,6 +14,7 @@ import org.jeecg.common.constant.RedisConstant;
|
|||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.email.emuns.MailContentType;
|
||||
import org.jeecg.common.exception.DownloadEmailException;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.Md5Util;
|
||||
|
@ -512,9 +515,10 @@ public class EmailServiceManager {
|
|||
/**
|
||||
* 把邮件下载到eml目录
|
||||
* 格式为:发件人_主题_年月日_时分秒毫秒_计数(0-10000)
|
||||
* 新格式为:发件人_主题_年月日_时分秒毫秒_receive_年月日_时分秒毫秒_计数(0-10000)
|
||||
* 当计数大于10000后从0开始,服务重启后也从0开始
|
||||
*/
|
||||
public File downloadEmailToEmlDir(@NotNull Message message,Integer emailCounter) throws MessagingException, IOException {
|
||||
public File downloadEmailToEmlDir(@NotNull Message message,Integer emailCounter) throws MessagingException {
|
||||
String subject = "";
|
||||
File emlFile = null;
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
|
@ -540,6 +544,12 @@ public class EmailServiceManager {
|
|||
fileName.append(StringConstant.UNDER_LINE);
|
||||
fileName.append(DateUtils.formatDate(new Date(),"HHMMSSSSS"));
|
||||
fileName.append(StringConstant.UNDER_LINE);
|
||||
fileName.append("receive");
|
||||
fileName.append(StringConstant.UNDER_LINE);
|
||||
fileName.append(DateUtils.formatDate(message.getReceivedDate(),"YYMMdd"));
|
||||
fileName.append(StringConstant.UNDER_LINE);
|
||||
fileName.append(DateUtils.formatDate(message.getReceivedDate(),"HHMMSSSSS"));
|
||||
fileName.append(StringConstant.UNDER_LINE);
|
||||
fileName.append(emailCounter);
|
||||
fileName.append(SAVE_EML_SUFFIX);
|
||||
final String rootPath = spectrumPathProperties.getRootPath();
|
||||
|
@ -547,10 +557,11 @@ public class EmailServiceManager {
|
|||
emlFile = new File(rootPath+emlPath+File.separator+fileName);
|
||||
message.writeTo(new FileOutputStream(emlFile));
|
||||
} catch (MessagingException | IOException e) {
|
||||
//下载邮件失败
|
||||
// 下载邮件失败 抛出自定义邮件下载异常
|
||||
status = EmailLogManager.STATUS_ERROR;
|
||||
log.error("The email download failed, the subject of the email is {}, the reason is {}.",subject,e.getMessage());
|
||||
throw e;
|
||||
String errorMsg = StrUtil.format("The email download failed, the subject of the email is {}, the reason is {}.", subject, e.getMessage());
|
||||
log.error(errorMsg);
|
||||
throw new DownloadEmailException(errorMsg);
|
||||
}finally {
|
||||
EmailLogEvent event = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,message.getReceivedDate(),
|
||||
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
|
||||
|
@ -560,6 +571,24 @@ public class EmailServiceManager {
|
|||
return emlFile;
|
||||
}
|
||||
|
||||
/*
|
||||
* 将eml中下载的未通过内容校验的邮件 移动到emlError目录
|
||||
* */
|
||||
public void emlToEmlError(File emlFile){
|
||||
if (ObjectUtil.isNull(emlFile)) return;
|
||||
final String filename = emlFile.getName();
|
||||
try {
|
||||
final String rootPath = spectrumPathProperties.getRootPath();
|
||||
final String emlErrorPath = spectrumPathProperties.getEmlErrorPath();
|
||||
File destDir = new File(rootPath + emlErrorPath);
|
||||
// 如果目标目录不存在 则先创建
|
||||
if (!destDir.exists()) destDir.mkdir();
|
||||
FileUtil.move(emlFile, destDir, true);
|
||||
}catch (Exception e){
|
||||
log.error("The error email {} move from eml to emlError failed: {}", filename, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除邮件
|
||||
* @param message
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package org.jeecg.common.exception;
|
||||
|
||||
/*
|
||||
* 自定义 邮件下载异常
|
||||
* */
|
||||
public class DownloadEmailException extends RuntimeException{
|
||||
|
||||
public DownloadEmailException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DownloadEmailException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -39,6 +39,11 @@ public class SpectrumPathProperties implements Serializable {
|
|||
*/
|
||||
private String emlPath;
|
||||
|
||||
/**
|
||||
* eml格式错误邮件存储路径
|
||||
*/
|
||||
private String emlErrorPath;
|
||||
|
||||
/**
|
||||
* 日志文件存储路径
|
||||
*/
|
||||
|
|
|
@ -9,4 +9,8 @@ public class NuclideAvgVo extends QueryRequest {
|
|||
private String startDate;
|
||||
|
||||
private String endDate;
|
||||
|
||||
private String stationId;
|
||||
|
||||
private String sourceType;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ import java.time.LocalDate;
|
|||
@Data
|
||||
public class NuclideAvgDto implements Serializable {
|
||||
|
||||
private String stationId;
|
||||
|
||||
private String stationCode;
|
||||
|
||||
/** 核素名称 */
|
||||
private String nuclide;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class AlarmAnalysisNuclideAvgController extends JeecgController<AlarmAnal
|
|||
|
||||
@GetMapping("findPage")
|
||||
@ApiOperation(value = "核素浓度均值列表信息",notes = "核素浓度均值列表信息")
|
||||
public Result findPage(NuclideAvgVo nuclideAvgVo){
|
||||
public Result<?> findPage(NuclideAvgVo nuclideAvgVo){
|
||||
Page<NuclideAvgDto> result = service.findPage(nuclideAvgVo);
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
<select id="findPage" resultType="org.jeecg.modules.base.dto.NuclideAvgDto">
|
||||
SELECT
|
||||
station_id,
|
||||
nuclide,
|
||||
val,
|
||||
cycle,
|
||||
|
@ -23,7 +24,13 @@
|
|||
<if test="params.endDate != null and params.endDate != ''">
|
||||
AND cacl_date <= #{params.endDate}
|
||||
</if>
|
||||
<if test="params.stationId != null and params.stationId != ''">
|
||||
AND station_id = #{params.stationId}
|
||||
</if>
|
||||
<if test="params.sourceType != null and params.sourceType != ''">
|
||||
AND data_source_type = #{params.sourceType}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY cacl_date DESC
|
||||
ORDER BY cacl_date DESC, station_id, data_source_type, nuclide
|
||||
</select>
|
||||
</mapper>
|
|
@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import org.jeecg.modules.base.dto.NuclideAvgDto;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
||||
import org.jeecg.modules.base.bizVo.NuclideAvgVo;
|
||||
import org.jeecg.modules.feignclient.SystemClient;
|
||||
import org.jeecg.modules.mapper.AlarmAnalysisNuclideAvgMapper;
|
||||
import org.jeecg.modules.service.IAlarmAnalysisNuclideAvgService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -16,10 +18,14 @@ import java.time.LocalDate;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class AlarmAnalysisNuclideAvgServiceImpl extends ServiceImpl<AlarmAnalysisNuclideAvgMapper, AlarmAnalysisNuclideAvg> implements IAlarmAnalysisNuclideAvgService {
|
||||
|
||||
@Autowired
|
||||
private SystemClient systemClient;
|
||||
|
||||
@Override
|
||||
public List<AlarmAnalysisNuclideAvg> list(Set<String> nuclideNames,String dataSourceType) {
|
||||
LocalDate dayAgo = LocalDate.now().minusDays(1);
|
||||
|
@ -37,6 +43,10 @@ public class AlarmAnalysisNuclideAvgServiceImpl extends ServiceImpl<AlarmAnalysi
|
|||
Map<String, Object> params = BeanUtil.beanToMap(nuclideAvgVo);
|
||||
Page<NuclideAvgDto> page = new Page<>(pageNo, pageSize);
|
||||
page = baseMapper.findPage(page, params);
|
||||
return page;
|
||||
List<NuclideAvgDto> nuclideAvgs = page.getRecords();
|
||||
List<String> stationIds = nuclideAvgs.stream().map(NuclideAvgDto::getStationId).collect(Collectors.toList());
|
||||
Map<String, String> codeMap = systemClient.stationCodesMap(stationIds);
|
||||
nuclideAvgs.forEach(item -> item.setStationCode(codeMap.get(item.getStationId())));
|
||||
return page.setRecords(nuclideAvgs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,14 @@ import org.jeecg.common.constant.StringConstant;
|
|||
import org.jeecg.common.email.EmailLogEvent;
|
||||
import org.jeecg.common.email.EmailLogManager;
|
||||
import org.jeecg.common.email.EmailServiceManager;
|
||||
import org.jeecg.common.exception.DownloadEmailException;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.email.EmailProperties;
|
||||
import org.jeecg.modules.enums.SpectrumSource;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
|
@ -96,6 +98,7 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
}
|
||||
|
||||
//判断是否是IMS2.0协议文件
|
||||
// 如果邮件内容校验成功 将文件保存到eml目录 并删除邮件对象
|
||||
if(checkMailContent(mailContent,subject)){
|
||||
AbstractSpectrumHandler spectrumHandler = new SamplephdSpectrum();
|
||||
spectrumHandler.init(mailContent.toString(),emlFile.getName(),spectrumServiceQuotes,new StringBuilder(),SpectrumSource.FORM_EMAIL_SERVICE.getSourceType());
|
||||
|
@ -106,9 +109,15 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
}else{
|
||||
log.warn("This email {} parsing failed and is not listed in the Met, Alert, SOH, Sample, Detbkphd, QC, Gasbkphd spectra.",subject);
|
||||
}
|
||||
}
|
||||
emailServiceManager.removeMail(message);
|
||||
}
|
||||
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
|
||||
else {
|
||||
emailServiceManager.emlToEmlError(emlFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果邮件正常下载 则删除下载的邮件对象
|
||||
if (!(e instanceof DownloadEmailException))
|
||||
emailServiceManager.removeMail(message);
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
|
|
|
@ -120,6 +120,7 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getUndealPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getFilesourcePath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getEmlPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getEmlErrorPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getErrorFilePath());
|
||||
}
|
||||
}
|
|
@ -63,11 +63,11 @@ public class JeecgSpectrumAnalysisApplication extends SpringBootServletInitializ
|
|||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
//Windows加载dll工具库
|
||||
/*System.loadLibrary("ReadPHDFile");
|
||||
System.loadLibrary("GammaAnaly");*/
|
||||
System.loadLibrary("ReadPHDFile");
|
||||
System.loadLibrary("GammaAnaly");
|
||||
//Linux版本加载dll工具库
|
||||
System.load("/usr/local/jdk/lib/libReadPHDFile.so");
|
||||
System.load("/usr/local/jdk/lib/libGammaAnalyALG.so");
|
||||
/*System.load("/usr/local/jdk/lib/libReadPHDFile.so");
|
||||
System.load("/usr/local/jdk/lib/libGammaAnalyALG.so");*/
|
||||
//创建缓存
|
||||
betaCache.initCache();
|
||||
localCache.initCache();
|
||||
|
|
Loading…
Reference in New Issue
Block a user