Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
939ffb1f6c | ||
|
6b16aa6a40 | ||
|
41245f0546 | ||
|
86968e383b | ||
|
9fffd2436c | ||
|
2407b65a06 | ||
|
6c5a0bf546 | ||
|
caf47a58d5 | ||
|
18b495d1d0 | ||
|
6335a3f588 |
|
@ -9,6 +9,8 @@ import com.sun.mail.imap.IMAPStore;
|
|||
import com.sun.mail.smtp.SMTPAddressFailedException;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.constant.RedisConstant;
|
||||
|
@ -124,7 +126,7 @@ public class EmailServiceManager {
|
|||
/**
|
||||
* 接收邮件
|
||||
*/
|
||||
public Message[] receiveMail() {
|
||||
public Message[] receiveMail() throws MessagingException {
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
try{
|
||||
//配置邮件服务属性
|
||||
|
@ -183,12 +185,11 @@ public class EmailServiceManager {
|
|||
return Arrays.copyOfRange(messages,0,this.receiveNum-1);
|
||||
}
|
||||
}
|
||||
}catch (MessagingException e){
|
||||
} catch (MessagingException e){
|
||||
status = EmailLogManager.STATUS_ERROR;
|
||||
log.error("Email connection is abnormal, account is {}, service is {},the reason is {}.",email.getName(),email.getEmailServerAddress(),e.getMessage());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}finally {
|
||||
throw e;
|
||||
} finally {
|
||||
EmailLogEvent connectEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,email,status,EmailLogManager.CONNECT);
|
||||
EmailLogManager.getInstance().setConnectLogEvent(connectEvent);
|
||||
//GetAllId C++原业务是把远程邮箱邮件同步到C++,本次java编写没有这一步,所以和Connect绑定,若Connect成功则GetAllId成功
|
||||
|
@ -532,7 +533,8 @@ public class EmailServiceManager {
|
|||
File emlFile = null;
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
Date receivedDate = null;
|
||||
FileOutputStream outputStream = null;
|
||||
InputStream inputStream = null;
|
||||
BufferedOutputStream outputStream = null;
|
||||
try {
|
||||
//获取发件人
|
||||
final String address = ((InternetAddress) message.getFrom()[0]).getAddress();
|
||||
|
@ -566,25 +568,19 @@ public class EmailServiceManager {
|
|||
final String rootPath = spectrumPathProperties.getRootPath();
|
||||
final String emlPath = spectrumPathProperties.getEmlPath();
|
||||
emlFile = new File(rootPath+emlPath+File.separator+fileName);
|
||||
outputStream = new FileOutputStream(emlFile);
|
||||
message.writeTo(outputStream);
|
||||
// outputStream = new FileOutputStream(emlFile);
|
||||
// message.writeTo(outputStream);
|
||||
|
||||
int bufferSize = 1024 * 1024; // 1M
|
||||
inputStream = message.getInputStream();
|
||||
outputStream = new BufferedOutputStream(new FileOutputStream(emlFile), bufferSize);
|
||||
// 从邮件的输入流读取内容,并写入到本地文件
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
// int bufferSize = 1024 * 1024; // 1M
|
||||
// InputStream inputStream = message.getInputStream();
|
||||
// BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, bufferSize);
|
||||
// // 或者使用 BufferedOutputStream
|
||||
// OutputStream outputStream = new FileOutputStream(emlFile);
|
||||
// BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream, bufferSize);
|
||||
// // 从邮件的输入流读取内容,并写入到本地文件
|
||||
// byte[] buffer = new byte[bufferSize];
|
||||
// int bytesRead;
|
||||
// while ((bytesRead = bufferedInputStream.read(buffer)) != -1) {
|
||||
// bufferedOutputStream.write(buffer, 0, bytesRead);
|
||||
// }
|
||||
//
|
||||
// // 关闭流
|
||||
// bufferedInputStream.close();
|
||||
// bufferedOutputStream.close();
|
||||
} catch (MessagingException | IOException e) {
|
||||
// 下载邮件失败 抛出自定义邮件下载异常
|
||||
status = EmailLogManager.STATUS_ERROR;
|
||||
|
@ -598,7 +594,11 @@ public class EmailServiceManager {
|
|||
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
|
||||
try {
|
||||
if (Objects.nonNull(inputStream)) {
|
||||
inputStream.close();
|
||||
}
|
||||
if (Objects.nonNull(outputStream)) {
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -233,9 +233,15 @@ public class AutoProcessManager{
|
|||
if(databaseEmail.getEnabled().equals(SysMailEnableType.ENABLE.getMailEnableType())){
|
||||
final boolean testFlag = testConnectEmailServer(databaseEmail);
|
||||
if(testFlag){
|
||||
databaseEmail.setNewEmailFlag(true);
|
||||
if (emailExecThreadMap.containsKey(databaseEmail.getId())) {
|
||||
EmailParsingActuator actuator = emailExecThreadMap.get(databaseEmail.getId());
|
||||
actuator.setStop(false);
|
||||
log.info("{}邮箱重新加入监测队列",databaseEmail.getUsername());
|
||||
} else {
|
||||
databaseEmail.setNewEmailFlag(true);
|
||||
log.info("{}邮箱加入监测队列,设置新增标记",databaseEmail.getUsername());
|
||||
}
|
||||
emailMap.put(databaseEmail.getId(),databaseEmail);
|
||||
log.info("{}邮箱加入监测队列,设置新增标记",databaseEmail.getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -279,6 +285,7 @@ public class AutoProcessManager{
|
|||
if(next.getValue().getState() == State.TERMINATED){
|
||||
log.info("{}邮箱执行线程已停止,emailExecThreadMap删除此邮箱数据",next.getValue().getEmailProperties().getUsername());
|
||||
checkStopThreads.remove();
|
||||
emailMap.remove(next.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,7 @@ import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
|||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
|
@ -79,11 +76,17 @@ public class EmailParsingActuator extends Thread{
|
|||
try {
|
||||
Message[] messages = emailServiceManager.receiveMail();
|
||||
if(ArrayUtils.isNotEmpty(messages)){
|
||||
log.info("EmailParsingActuator本次获取邮件数量为:{}",messages.length);
|
||||
log.info("EmailParsingActuator本次{}获取邮件数量为:{}", Thread.currentThread().getName(), messages.length);
|
||||
//检验获取的邮件是否在之前删除失败列表中,若在直接调用邮件API删除,并且此次数组里元素也删除
|
||||
for(int i=messages.length-1;i>=0;i--){
|
||||
if (null == messages[i].getHeader("Message-ID")) {
|
||||
System.out.println("Message ID是空值信息!!!!!!!");
|
||||
messages = ArrayUtils.remove(messages, i);
|
||||
continue;
|
||||
}
|
||||
if (!messages[i].isExpunged()){
|
||||
String messageId = ((MimeMessage) messages[i]).getMessageID();
|
||||
System.out.println("正常获取到的Message ID是:"+messageId);
|
||||
final boolean exist = emailServiceManager.check(messages[i],messageId);
|
||||
messageIds.add(messageId);
|
||||
if(exist){
|
||||
|
@ -105,10 +108,13 @@ public class EmailParsingActuator extends Thread{
|
|||
taskLatch.await();
|
||||
}
|
||||
}
|
||||
}catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (MessagingException e) {
|
||||
System.out.println("捕获MessagingException!!!!!!!!");
|
||||
closeResource();
|
||||
throw new RuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
closeResource();
|
||||
log.error(""+e);
|
||||
} finally {
|
||||
//清除本批次邮件日志缓存
|
||||
EmailLogManager.getInstance().clear();
|
||||
|
|
|
@ -97,9 +97,6 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
String emlName = subject+ StringConstant.UNDER_LINE+ receiveDate;
|
||||
String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;
|
||||
// spectrumServiceQuotes.getRedisUtil().set(key,emlName,expiryTime);
|
||||
//判断当前key的下载次数是否超过限制次数
|
||||
spectrumServiceQuotes.getRedisUtil().incr(key, 1L);
|
||||
spectrumServiceQuotes.getRedisUtil().expire(key, expiryTime);
|
||||
//线程开始初始化时,初始本线程负责的能谱日志事件
|
||||
SpectrumLogManager.mailSpectrumLogManager.offer(Thread.currentThread().getId(),null);
|
||||
|
||||
|
@ -144,7 +141,10 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
log.warn("This email {} parsing failed and is not listed in the Met, Alert, SOH, Sample, Detbkphd, QC, Gasbkphd spectra.",subject);
|
||||
}
|
||||
emailServiceManager.removeMail(message,batchesCounter);
|
||||
}else {
|
||||
} else {
|
||||
//判断当前key的下载次数是否超过限制次数
|
||||
spectrumServiceQuotes.getRedisUtil().incr(key, 1L);
|
||||
spectrumServiceQuotes.getRedisUtil().expire(key, expiryTime);
|
||||
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
|
||||
if (Objects.nonNull(emlFile) && emlFile.exists()){
|
||||
moveEmail(emlFile, key);
|
||||
|
|
|
@ -29,14 +29,18 @@ public class GammaController {
|
|||
|
||||
@GetMapping("initValue")
|
||||
@ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据")
|
||||
public void initValue(Integer sampleId, String dbName, String analyst, String fileName, HttpServletRequest request) {
|
||||
gammaService.initValue(sampleId, dbName, analyst, fileName, request);
|
||||
public void initValue(Integer sampleId, String dbName,
|
||||
String analyst, String fileName,
|
||||
String status, HttpServletRequest request) {
|
||||
gammaService.initValue(sampleId, dbName, analyst, fileName, status, request);
|
||||
}
|
||||
|
||||
@GetMapping("gammaByDB")
|
||||
@ApiOperation(value = "gamma页面loadFromDB加载数据", notes = "gamma页面loadFromDB加载数据")
|
||||
public Result gammaByDB(Integer sampleId, String dbName, String analyst, HttpServletRequest request){
|
||||
return gammaService.gammaByDB(dbName, sampleId, analyst, request);
|
||||
public Result gammaByDB(Integer sampleId, String dbName,
|
||||
String analyst, String status,
|
||||
HttpServletRequest request){
|
||||
return gammaService.gammaByDB(dbName, sampleId, analyst, status, request);
|
||||
}
|
||||
|
||||
@GetMapping("gammaByDBApp")
|
||||
|
|
|
@ -26,8 +26,12 @@ public class SpectrumAnalysesController {
|
|||
|
||||
@GetMapping("initValue")
|
||||
@ApiOperation(value = "初始化数据", notes = "初始化数据")
|
||||
public void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) {
|
||||
spectrumAnalysisService.initValue(dbName, sampleId, analyst, sampleFileName, gasFileName, detFileName, qcFileName, request);
|
||||
public void initValue(String dbName, Integer sampleId,
|
||||
String analyst, String sampleFileName,
|
||||
String gasFileName, String detFileName,
|
||||
String qcFileName, String status, HttpServletRequest request) {
|
||||
spectrumAnalysisService.initValue(dbName, sampleId, analyst, sampleFileName,
|
||||
gasFileName, detFileName, qcFileName, status, request);
|
||||
}
|
||||
|
||||
@GetMapping("getDBSearchList")
|
||||
|
@ -51,8 +55,9 @@ public class SpectrumAnalysesController {
|
|||
|
||||
@GetMapping("getDBSpectrumChart")
|
||||
@ApiOperation(value = "查询折线图相关信息接口", notes = "查询折线图相关信息接口")
|
||||
public Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
|
||||
return spectrumAnalysisService.getDBSpectrumChart(dbName, sampleId, analyst, request);
|
||||
public Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst,
|
||||
String status, HttpServletRequest request) {
|
||||
return spectrumAnalysisService.getDBSpectrumChart(dbName, sampleId, analyst, status, request);
|
||||
}
|
||||
|
||||
@GetMapping("getDBSpectrumChartApp")
|
||||
|
|
|
@ -41,6 +41,8 @@ public class BetaDataFile implements Serializable {
|
|||
|
||||
private String stationId;
|
||||
|
||||
private String detectorId;
|
||||
|
||||
private boolean bProcessed;
|
||||
|
||||
private boolean saveAnalysisResult;
|
||||
|
|
|
@ -22,6 +22,8 @@ public interface SpectrumAnalysisMapper {
|
|||
|
||||
Page<GardsSampleDataSpectrum> getDBSpectrumList(IPage<GardsSampleDataSpectrum> page, GardsSampleDataSpectrum gardsSampleData, String dbName, List<String> stationTypes, boolean CollectStopB, boolean AcqStartB, String startTime, String endTime, List<String> userStations, boolean AllUsers, String orderField, String orderType);
|
||||
|
||||
Page<GardsSampleDataSpectrum> getDBSpectrumListInner(IPage<GardsSampleDataSpectrum> page, GardsSampleDataSpectrum gardsSampleData, String dbName, List<String> stationTypes, boolean CollectStopB, boolean AcqStartB, String startTime, String endTime, List<String> userStations, boolean AllUsers, String orderField, String orderType);
|
||||
|
||||
Page<GardsSampleDataSpectrum> loadSampleData(IPage<GardsSampleDataSpectrum> page, GardsSampleDataSpectrum gardsSampleData, List<String> stationTypes, boolean CollectStopB, boolean AcqStartB, String startTime, String endTime, List<String> userStations, boolean AllUsers, String orderField, String orderType);
|
||||
|
||||
SpectrumFileRecord getDBSpectrumFilePath(String dbName, Integer sampleId, Integer analysisID);
|
||||
|
@ -30,6 +32,8 @@ public interface SpectrumAnalysisMapper {
|
|||
|
||||
String getQCFilePath(String siteDetCode, String collectStartStr);
|
||||
|
||||
String gasDetFilePath(String measurementId);
|
||||
|
||||
CommentData viewComment(@Param(value = "sampleId") Integer sampleId);
|
||||
|
||||
String getSampleFilePath(@Param(value = "sampleId") Integer sampleId);
|
||||
|
|
|
@ -46,16 +46,85 @@
|
|||
d.analyst analyst,
|
||||
c.status status,
|
||||
c.input_file_name inputFileName
|
||||
from
|
||||
CONFIGURATION.GARDS_DETECTORS a,
|
||||
CONFIGURATION.GARDS_STATIONS b,
|
||||
ORIGINAL.GARDS_SAMPLE_DATA c,
|
||||
${dbName} d
|
||||
FROM
|
||||
ORIGINAL.GARDS_SAMPLE_DATA c
|
||||
LEFT JOIN ${dbName} d ON c.sample_id = d.sample_id
|
||||
INNER JOIN CONFIGURATION.GARDS_DETECTORS a ON c.detector_id = a.detector_id
|
||||
INNER JOIN CONFIGURATION.GARDS_STATIONS b ON c.station_id = b.station_id
|
||||
<where>
|
||||
c.sample_id = d.sample_id
|
||||
and c.detector_id = a.detector_id
|
||||
and c.station_id = b.station_id
|
||||
and b.type in
|
||||
b.type in
|
||||
<foreach collection="stationTypes" item="stationType" open="(" close=")" separator=",">
|
||||
#{stationType}
|
||||
</foreach>
|
||||
<if test=" gardsSampleData.sampleId != null ">
|
||||
and c.sample_id = #{gardsSampleData.sampleId}
|
||||
</if>
|
||||
<if test=" gardsSampleData.stationName != null and gardsSampleData.stationName != '' ">
|
||||
and b.station_code = #{gardsSampleData.stationName}
|
||||
</if>
|
||||
<if test=" gardsSampleData.detectorsName != null and gardsSampleData.detectorsName != '' ">
|
||||
and a.detector_code = #{gardsSampleData.detectorsName}
|
||||
</if>
|
||||
<if test=" gardsSampleData.sampleType != null and gardsSampleData.sampleType != '' ">
|
||||
and c.sample_type = #{gardsSampleData.sampleType}
|
||||
</if>
|
||||
<if test=" gardsSampleData.dataType != null and gardsSampleData.dataType != '' ">
|
||||
and c.data_type = #{gardsSampleData.dataType}
|
||||
</if>
|
||||
<if test=" gardsSampleData.spectralQualifie != null and gardsSampleData.spectralQualifie != '' ">
|
||||
and c.spectral_qualifie = #{gardsSampleData.spectralQualifie}
|
||||
</if>
|
||||
<if test=" gardsSampleData.status != null and gardsSampleData.status != '' ">
|
||||
and c.status = #{gardsSampleData.status}
|
||||
</if>
|
||||
<if test=" CollectStopB == true ">
|
||||
and c.collect_stop between TO_DATE(#{startTime}, 'yyyy-mm-dd hh24:mi:ss') and TO_DATE(#{endTime}, 'yyyy-mm-dd hh24:mi:ss')
|
||||
</if>
|
||||
<if test=" AcqStartB == true ">
|
||||
and c.acquisition_start between TO_DATE(#{startTime}, 'yyyy-mm-dd hh24:mi:ss') and TO_DATE(#{endTime}, 'yyyy-mm-dd hh24:mi:ss')
|
||||
</if>
|
||||
<if test="AllUsers == false">
|
||||
<if test=" userStations.size == 0 and userStations != null ">
|
||||
and c.station_id in ('')
|
||||
</if>
|
||||
<if test=" userStations.size > 0 and userStations != null ">
|
||||
and c.station_id in
|
||||
<foreach collection="userStations" item="userStation" open="(" close=")" separator=",">
|
||||
#{userStation}
|
||||
</foreach>
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
<if test=" orderField != 'createTime' and orderField != '' and orderField != null and orderType != '' and orderType != null ">
|
||||
ORDER BY ${orderField} ${orderType}
|
||||
</if>
|
||||
<if test=" orderField == 'createTime' or orderField == '' or orderField == null or orderType == '' or orderType == null ">
|
||||
ORDER BY collectStop DESC
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getDBSpectrumListInner" resultType="org.jeecg.modules.entity.GardsSampleDataSpectrum">
|
||||
select c.sample_id sampleId,
|
||||
b.station_code stationName,
|
||||
a.detector_code detectorsName,
|
||||
c.sample_type sampleType,
|
||||
c.data_type dataType,
|
||||
c.spectral_qualifie spectralQualifie,
|
||||
c.collect_stop collectStop,
|
||||
c.acquisition_start acquisitionStart,
|
||||
c.acquisition_real_sec acquisitionRealSec,
|
||||
c.acquisition_live_sec acquisitionLiveSec,
|
||||
d.IDANALYSIS analysitId,
|
||||
d.analyst analyst,
|
||||
c.status status,
|
||||
c.input_file_name inputFileName
|
||||
FROM
|
||||
ORIGINAL.GARDS_SAMPLE_DATA c
|
||||
INNER JOIN ${dbName} d ON c.sample_id = d.sample_id
|
||||
INNER JOIN CONFIGURATION.GARDS_DETECTORS a ON c.detector_id = a.detector_id
|
||||
INNER JOIN CONFIGURATION.GARDS_STATIONS b ON c.station_id = b.station_id
|
||||
<where>
|
||||
b.type in
|
||||
<foreach collection="stationTypes" item="stationType" open="(" close=")" separator=",">
|
||||
#{stationType}
|
||||
</foreach>
|
||||
|
@ -214,6 +283,16 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="gasDetFilePath" resultType="java.lang.String">
|
||||
SELECT
|
||||
data.INPUT_FILE_NAME
|
||||
FROM
|
||||
ORIGINAL.GARDS_SAMPLE_AUX aux
|
||||
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA data ON aux.SAMPLE_ID = data.SAMPLE_ID
|
||||
WHERE data.SPECTRAL_QUALIFIE = 'FULL'
|
||||
AND aux.MEASUREMENT_ID = #{measurementId}
|
||||
</select>
|
||||
|
||||
<select id="viewComment" resultType="org.jeecg.modules.entity.vo.CommentData">
|
||||
SELECT A.ANALYST, A.COMMENTS FROM RNMAN.GARDS_ANALYSES A WHERE A.SAMPLE_ID= #{sampleId}
|
||||
</select>
|
||||
|
@ -1104,5 +1183,4 @@
|
|||
<select id="findNuclidesAnalysis" resultType="java.lang.String">
|
||||
select NAME from CONFIGURATION.GARDS_NUCL_LIB
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -15,10 +15,13 @@ import java.util.List;
|
|||
|
||||
public interface IGammaService{
|
||||
|
||||
void initValue(Integer sampleId, String dbName, String analyst, String fileName, HttpServletRequest request);
|
||||
void initValue(Integer sampleId, String dbName, String analyst, String fileName, String status, HttpServletRequest request);
|
||||
|
||||
Result gammaByDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request);
|
||||
|
||||
|
||||
Result<?> gammaByDB(String dbName, Integer sampleId, String analyst, String status, HttpServletRequest request);
|
||||
|
||||
Result gammaByFile(String fileName, HttpServletRequest request);
|
||||
|
||||
void delPHDCache(String fileName);
|
||||
|
|
|
@ -14,7 +14,9 @@ import java.util.List;
|
|||
|
||||
public interface ISpectrumAnalysisService {
|
||||
|
||||
void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request);
|
||||
void initValue(String dbName, Integer sampleId, String analyst,
|
||||
String sampleFileName, String gasFileName, String detFileName,
|
||||
String qcFileName, String status, HttpServletRequest request);
|
||||
|
||||
Result getDBSearchList(HttpServletRequest request, boolean AllUsers, String sampleType);
|
||||
|
||||
|
@ -24,6 +26,9 @@ public interface ISpectrumAnalysisService {
|
|||
|
||||
Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst, HttpServletRequest request);
|
||||
|
||||
Result<?> getDBSpectrumChart(String dbName, Integer sampleId, String analyst,
|
||||
String status, HttpServletRequest request);
|
||||
|
||||
Result getFileSpectrumChart(String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request);
|
||||
|
||||
void deleteSpectrumCacheData(String sampleFileName, HttpServletRequest request);
|
||||
|
|
|
@ -80,6 +80,7 @@ import java.util.*;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.aspectj.weaver.tools.cache.SimpleCacheFactory.path;
|
||||
import static org.jeecg.modules.base.enums.ExportTemplate.*;
|
||||
|
||||
@Service(value = "gammaService")
|
||||
|
@ -156,16 +157,27 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
private IDataService dataService;
|
||||
|
||||
@Override
|
||||
public void initValue(Integer sampleId, String dbName, String analyst, String samfileName, HttpServletRequest request) {
|
||||
public void initValue(Integer sampleId, String dbName,
|
||||
String analyst, String samfileName,
|
||||
String status, HttpServletRequest request) {
|
||||
if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) {
|
||||
gammaByDB(dbName, sampleId, analyst, request);
|
||||
gammaByDB(dbName, sampleId, analyst, status, request);
|
||||
} else {
|
||||
gammaByFile(samfileName, request);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result gammaByDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
|
||||
public Result<?> gammaByDB(String dbName, Integer sampleId,
|
||||
String analyst, String status,
|
||||
HttpServletRequest request) {
|
||||
if (StrUtil.equals(SampleStatus.FAIL.getValue(), status))
|
||||
return this.gammaByFile(sampleId);
|
||||
return this.gammaByDB(dbName, sampleId, analyst, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> gammaByDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
// 通过token获取用户名
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
|
@ -194,6 +206,10 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
if (!flag) {
|
||||
return result;
|
||||
}
|
||||
if (Objects.nonNull(phd) && !phd.isValid()) {
|
||||
result.error500("This Spectrum is invalid! it's counts are all zero");
|
||||
return result;
|
||||
}
|
||||
// 加载phd数据所需的lc,scac,baseline数据
|
||||
if (dbName.equals("auto")) {
|
||||
gammaFileUtil.SetBaseInfo(phd, "RNAUTO");
|
||||
|
@ -280,6 +296,89 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
return result;
|
||||
}
|
||||
|
||||
private Result<?> gammaByFile(Integer sampleId){
|
||||
Result result = new Result<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
String userName = sysUser.getUsername();
|
||||
String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
|
||||
String rootPath = spectrumPathProperties.getRootPath();
|
||||
String saveFilePath = spectrumPathProperties.getSaveFilePath();
|
||||
String fullPath = rootPath + saveFilePath + StringPool.SLASH + sampleFilePath;
|
||||
if (!FileUtil.exist(fullPath))
|
||||
return Result.error("Sample file does not exist!");
|
||||
String fileName = FileUtil.getName(fullPath);
|
||||
String path = FileUtil.getParent(fullPath, 1);
|
||||
// 获取当前角色的颜色配置
|
||||
Map<String, String> colorMap = sysUserColorService.initColor(userName);
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName);
|
||||
if (Objects.isNull(phd)) {
|
||||
phd = new PHDFile();
|
||||
// 加载文件内容
|
||||
boolean bRet = gammaFileUtil.loadFile(path, fileName, phd, "BetaGamma", result);
|
||||
if (!bRet) {
|
||||
return result;
|
||||
}
|
||||
if (Objects.nonNull(phd) && !phd.isValid()) {
|
||||
result.error500("This Spectrum is invalid! it's counts are all zero");
|
||||
return result;
|
||||
}
|
||||
if (!redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()) || !redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list")) {
|
||||
//读取缓存的全部核素信息
|
||||
Map<String, NuclideLines> allNuclideMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
|
||||
// 查询当前用户关联的核素信息
|
||||
List<String> userLib = new LinkedList<>();
|
||||
// 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
|
||||
userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
|
||||
if (CollectionUtils.isEmpty(userLib)) {
|
||||
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
|
||||
}
|
||||
userLib = userLib.stream().sorted().collect(Collectors.toList());
|
||||
Map<String, NuclideLines> nuclideMap = new HashMap<>();
|
||||
for (Map.Entry<String, NuclideLines> entry:allNuclideMap.entrySet()) {
|
||||
if (userLib.contains(entry.getKey())) {
|
||||
nuclideMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list", userLib);
|
||||
redisUtil.set(userName+StringPool.DASH+phd.getHeader().getSystem_type(), nuclideMap);
|
||||
}
|
||||
//缓存phd谱的核素信息
|
||||
Map<String, NuclideLines> phdNuclideMap = (Map<String, NuclideLines>) redisUtil.get(userName + StringPool.DASH + phd.getHeader().getSystem_type());
|
||||
phd.setPhdNuclideMap(phdNuclideMap);
|
||||
//读取redis缓存的计算mdc信息
|
||||
Map<String, CalMDCInfo> mdcInfoMap = (Map<String, CalMDCInfo>) redisUtil.get("mdcInfoMap-"+phd.getHeader().getSystem_type());
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
phd.setMdcInfoMap(mdcInfoMap);
|
||||
}
|
||||
}
|
||||
// 更新 ‘QC Flags’ 状态
|
||||
List<String> qcstate = gammaFileUtil.Qcstate(phd);
|
||||
map.put("QCFlag", qcstate);
|
||||
// 更新 ‘Detailed Information’ 信息
|
||||
List<String> detailedInfo = gammaFileUtil.DetailedInfo(phd.getId_sample(), phd);
|
||||
map.put("DetailedInformation", detailedInfo);
|
||||
// 更新 ACQ 模块中各时间信息
|
||||
map.put("start_time", phd.getAcq().getAcquisition_start_date() + "\n" + phd.getAcq().getAcquisition_start_time());
|
||||
map.put("real_time", String.format("%.2f", phd.getAcq().getAcquisition_real_time()));
|
||||
map.put("live_time", String.format("%.2f", phd.getAcq().getAcquisition_live_time()));
|
||||
double deadTime = (phd.getAcq().getAcquisition_real_time() - phd.getAcq().getAcquisition_live_time()) / phd.getAcq().getAcquisition_real_time();
|
||||
map.put("dead_time", String.format("%.2f", deadTime * 100));
|
||||
map.put("checkBox_updateCal", phd.getSetting().isBUpdateCal());
|
||||
map.put("bAnalyed", phd.isBAnalyed());
|
||||
map.put("peak", phd.getVPeak());
|
||||
map.put("BaseCtrls", phd.getBaseCtrls());
|
||||
List<SeriseData> differance = gammaFileUtil.Differance(phd, phd.getVPeak());
|
||||
map.put("barChart", differance);
|
||||
gammaFileUtil.UpdateChart(phd, map, colorMap);
|
||||
phdCache.put(fileName + StringPool.DASH + userName, phd);
|
||||
localCache.setPHDCache(phdCache);
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean getResultFromDB(String dbName, String userName, Integer sampleId, PHDFile phd, Result result) {
|
||||
// 判断连接的数据库
|
||||
String T_analy = "";
|
||||
|
@ -609,6 +708,10 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
if (!bRet) {
|
||||
return result;
|
||||
}
|
||||
if (Objects.nonNull(phd) && !phd.isValid()) {
|
||||
result.error500("This Spectrum is invalid! it's counts are all zero");
|
||||
return result;
|
||||
}
|
||||
if (!redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()) || !redisUtil.hasKey(userName+StringPool.DASH+phd.getHeader().getSystem_type()+"-list")) {
|
||||
//读取缓存的全部核素信息
|
||||
Map<String, NuclideLines> allNuclideMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
|
||||
|
@ -4739,10 +4842,13 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
idAnalysis = spectrumAnalysisMapper.getIdAnalysisByIdAnalyst(phd.getId_sample(), userName);
|
||||
// 写入 RNMAN数据库
|
||||
// 获取phd文件中的totalcmt信息 存入数据库
|
||||
String comments = phd.getTotalCmt().trim();
|
||||
// 如果comment的数据长度大于1024 则截取前1024部分
|
||||
if (comments.length() > 1024) {
|
||||
comments = comments.substring(0, 1024);
|
||||
String comments = null;
|
||||
if (StrUtil.isNotBlank(phd.getTotalCmt())){
|
||||
comments = phd.getTotalCmt().trim();
|
||||
// 如果comment的数据长度大于1024 则截取前1024部分
|
||||
if (comments.length() > 1024) {
|
||||
comments = comments.substring(0, 1024);
|
||||
}
|
||||
}
|
||||
// 判断idAnalysis是否为空
|
||||
if (StringUtils.isBlank(idAnalysis)) {
|
||||
|
|
|
@ -136,9 +136,11 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
|
||||
|
||||
@Override
|
||||
public void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) {
|
||||
public void initValue(String dbName, Integer sampleId, String analyst,
|
||||
String sampleFileName, String gasFileName, String detFileName,
|
||||
String qcFileName, String status, HttpServletRequest request) {
|
||||
if (StringUtils.isNotBlank(dbName) && Objects.nonNull(sampleId)) {
|
||||
getDBSpectrumChart(dbName, sampleId, analyst, request);
|
||||
getDBSpectrumChart(dbName, sampleId, analyst, status, request);
|
||||
} else {
|
||||
getFileSpectrumChart(sampleFileName, gasFileName, detFileName, qcFileName, request);
|
||||
}
|
||||
|
@ -289,7 +291,12 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
//声明分页page
|
||||
Page<GardsSampleDataSpectrum> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
|
||||
Page<GardsSampleDataSpectrum> sampleDataPage = spectrumAnalysisMapper.getDBSpectrumList(page, gardsSampleData, dbName, stationTypes, CollectStopB, AcqStartB, startTime, endTime, userStations, AllUsers, queryRequest.getField(), queryRequest.getOrder());
|
||||
String status = gardsSampleData.getStatus();
|
||||
Page<GardsSampleDataSpectrum> sampleDataPage;
|
||||
if (StrUtil.equals(SampleStatus.FAIL.getValue(), status))
|
||||
sampleDataPage = spectrumAnalysisMapper.getDBSpectrumList(page, gardsSampleData, dbName, stationTypes, CollectStopB, AcqStartB, startTime, endTime, userStations, AllUsers, queryRequest.getField(), queryRequest.getOrder());
|
||||
else
|
||||
sampleDataPage = spectrumAnalysisMapper.getDBSpectrumListInner(page, gardsSampleData, dbName, stationTypes, CollectStopB, AcqStartB, startTime, endTime, userStations, AllUsers, queryRequest.getField(), queryRequest.getOrder());
|
||||
sampleDataPage.getRecords().stream().forEach(item->{item.setDbName(tempDBName);});
|
||||
result.setSuccess(true);
|
||||
result.setResult(sampleDataPage);
|
||||
|
@ -381,6 +388,14 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> getDBSpectrumChart(String dbName, Integer sampleId, String analyst,
|
||||
String status, HttpServletRequest request) {
|
||||
if (StrUtil.equals(SampleStatus.FAIL.getValue(), status))
|
||||
return this.getFileSpectrumChart(sampleId);
|
||||
return this.getDBSpectrumChart(dbName, sampleId, analyst, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
|
@ -667,6 +682,124 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
return result;
|
||||
}
|
||||
|
||||
private Result<?> getFileSpectrumChart(Integer sampleId) {
|
||||
Result result = new Result();
|
||||
//获取用户名
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
String userName = sysUser.getUsername();
|
||||
String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
|
||||
String rootPath = spectrumPathProperties.getRootPath();
|
||||
String saveFilePath = spectrumPathProperties.getSaveFilePath();
|
||||
String prefix = rootPath + saveFilePath + StringPool.SLASH;
|
||||
|
||||
sampleFilePath = prefix + sampleFilePath;
|
||||
if (!FileUtil.exist(sampleFilePath))
|
||||
return Result.error("Sample file does not exist!");
|
||||
String sampleFileName = FileUtil.getName(sampleFilePath);
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
Map<String, Object> sampleMap = new HashMap<>();
|
||||
Map<String, Object> gasBgMap = new HashMap<>();
|
||||
Map<String, Object> detBgMap = new HashMap<>();
|
||||
Map<String, Object> qcMap = new HashMap<>();
|
||||
//页面展示结果数组
|
||||
List<GardsXeResultsSpectrum> xeResultsSpectrumList = new LinkedList<>();
|
||||
//获取本地缓存信息
|
||||
Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
|
||||
//判断是否有公用变量的缓存
|
||||
BetaDataFile betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
|
||||
//如果没有缓存过公用变量
|
||||
if (Objects.isNull(betaDataFile)) {
|
||||
betaDataFile = new BetaDataFile();
|
||||
EnergySpectrumStruct struct = getSourceData(sampleFilePath, "sample", betaDataFile);
|
||||
if (Objects.nonNull(struct)) {
|
||||
betaDataFile.setSampleStruct(struct);
|
||||
betaDataFile.setSampleFilePathName(sampleFilePath);
|
||||
betaDataFile.setSampleFileName(sampleFileName);
|
||||
sampleMap = phdFileUtil.getSourceData(struct, null, null, "sample", betaDataFile);
|
||||
sampleMap.put("fileName", betaDataFile.getSampleFileName());
|
||||
resultMap.put("sample", sampleMap);
|
||||
}
|
||||
Map<String, String> paths = this.getPaths(sampleFilePath, prefix);
|
||||
String gasFilePath = paths.get("gasFilePath");
|
||||
String detFilePath = paths.get("detFilePath");
|
||||
String qcFilePath = paths.get("qcFilePath");
|
||||
if(FileUtil.exist(gasFilePath)){
|
||||
struct = getSourceData(gasFilePath, "gas", betaDataFile);
|
||||
if (Objects.nonNull(struct)) {
|
||||
betaDataFile.setGasStruct(struct);
|
||||
betaDataFile.setGasFilePathName(gasFilePath);
|
||||
betaDataFile.setGasFileName(FileUtil.getName(gasFilePath));
|
||||
gasBgMap = phdFileUtil.getSourceData(struct, null, null, "gas", betaDataFile);
|
||||
gasBgMap.put("fileName", betaDataFile.getGasFileName());
|
||||
resultMap.put("gasBg", gasBgMap);
|
||||
}
|
||||
}
|
||||
if(FileUtil.exist(detFilePath)){
|
||||
struct = getSourceData(detFilePath, "det", betaDataFile);
|
||||
if (Objects.nonNull(struct)) {
|
||||
betaDataFile.setDetStruct(struct);
|
||||
betaDataFile.setDetFilePathName(detFilePath);
|
||||
betaDataFile.setDetFileName(FileUtil.getName(detFilePath));
|
||||
detBgMap = phdFileUtil.getSourceData(struct, null, null, "det", betaDataFile);
|
||||
detBgMap.put("fileName", betaDataFile.getDetFileName());
|
||||
resultMap.put("detBg", detBgMap);
|
||||
}
|
||||
}
|
||||
if(FileUtil.exist(qcFilePath)){
|
||||
struct = getSourceData(qcFilePath, "qc", betaDataFile);
|
||||
if (Objects.nonNull(struct)) {
|
||||
betaDataFile.setQcStruct(struct);
|
||||
betaDataFile.setQcFilePathName(qcFilePath);
|
||||
betaDataFile.setQcFileName(FileUtil.getName(qcFilePath));
|
||||
qcMap = phdFileUtil.getSourceData(struct, null, null, "qc", betaDataFile);
|
||||
qcMap.put("fileName", betaDataFile.getQcFileName());
|
||||
resultMap.put("qc", qcMap);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
xeResultsSpectrumList = betaDataFile.getXeResultsSpectrumList();
|
||||
sampleMap = loadData("sample", betaDataFile);
|
||||
sampleMap.put("fileName", betaDataFile.getSampleFileName());
|
||||
resultMap.put("sample",sampleMap);
|
||||
gasBgMap = loadData("gas", betaDataFile);
|
||||
gasBgMap.put("fileName", betaDataFile.getGasFileName());
|
||||
resultMap.put("gasBg",gasBgMap);
|
||||
detBgMap = loadData("det", betaDataFile);
|
||||
detBgMap.put("fileName", betaDataFile.getDetFileName());
|
||||
resultMap.put("detBg",detBgMap);
|
||||
qcMap = loadData("qc", betaDataFile);
|
||||
qcMap.put("fileName", betaDataFile.getQcFileName());
|
||||
resultMap.put("qc",qcMap);
|
||||
}
|
||||
phdFileUtil.getLightColor(sampleMap,gasBgMap,detBgMap,qcMap);
|
||||
//Xe
|
||||
if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)){
|
||||
for (GardsXeResultsSpectrum xeData:xeResultsSpectrumList) {
|
||||
Double conc = xeData.getConc();
|
||||
Double mdc = xeData.getMdc();
|
||||
if (conc < 0){
|
||||
xeData.setColor("red");
|
||||
} else if (0<conc && conc < mdc) {
|
||||
xeData.setColor("#ffcc30");
|
||||
} else if (conc > mdc) {
|
||||
xeData.setColor("green");
|
||||
}
|
||||
xeData.setMdc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getMdc()))));
|
||||
xeData.setConc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConc()))));
|
||||
xeData.setConcErr(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConcErr()))));
|
||||
}
|
||||
}
|
||||
resultMap.put("XeData", phdFileUtil.viewXeData(xeResultsSpectrumList));
|
||||
resultMap.put("bProcessed", betaDataFile.isBProcessed());
|
||||
resultMap.put("savedAnalysisResult", betaDataFile.isSaveAnalysisResult());
|
||||
cache.put(betaDataFile.getSampleFileName()+"-"+userName, betaDataFile);
|
||||
betaCache.setBetaCache(cache);
|
||||
result.setSuccess(true);
|
||||
result.setResult(resultMap);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getFileSpectrumChart(String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
|
@ -805,6 +938,38 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
return struct;
|
||||
}
|
||||
|
||||
/*
|
||||
获取SamplePHD对应的Gas、Det、Qc PHD文件全路径
|
||||
*/
|
||||
private Map<String, String> getPaths(String sampleFilePath, String prefix){
|
||||
Map<String, String> result = new HashMap<>();
|
||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(sampleFilePath);
|
||||
if (ObjectUtil.isNull(struct)) return result;
|
||||
String detectorCode = struct.getDetector_code();
|
||||
String collectionStartDate = struct.getCollection_start_date();
|
||||
String collectionStartTime = struct.getCollection_start_time();
|
||||
String gasBkMeasurementId = struct.getGas_bk_measurement_id();
|
||||
String detectorBkMeasurementId = struct.getDetector_bk_measurement_id();
|
||||
// 获取Gas和Det文件路径
|
||||
String detFilePath = spectrumAnalysisMapper.gasDetFilePath(detectorBkMeasurementId);
|
||||
String gasFilePath = spectrumAnalysisMapper.gasDetFilePath(gasBkMeasurementId);
|
||||
detFilePath = prefix + detFilePath;
|
||||
gasFilePath = prefix + gasFilePath;
|
||||
result.put("detFilePath", detFilePath);
|
||||
result.put("gasFilePath", gasFilePath);
|
||||
// 获取Qc文件路径
|
||||
if (StrUtil.isBlank(collectionStartDate) || StrUtil.isBlank(collectionStartTime))
|
||||
return result;
|
||||
String collectionStart = collectionStartDate + StrUtil.SPACE + collectionStartTime;
|
||||
String startDateTime = LocalDateTime
|
||||
.parse(collectionStart, DateTimeFormatter.ofPattern(DateConstant.DATE_BIAS_TIME_MS))
|
||||
.format(DateTimeFormatter.ofPattern(DateConstant.DATE_TIME));
|
||||
String qcFilePath = spectrumAnalysisMapper.getQCFilePath(detectorCode, startDateTime);
|
||||
qcFilePath = prefix + qcFilePath;
|
||||
result.put("qcFilePath", qcFilePath);
|
||||
return result;
|
||||
}
|
||||
|
||||
//加载已有数据信息
|
||||
private Map<String, Object> loadData(String type, BetaDataFile betaDataFile) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -4420,6 +4585,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
String error = "get station_id or detect_id error";
|
||||
return false;
|
||||
}
|
||||
betaDataFile.setDetectorId(detectorId.toString());
|
||||
//新增Gards_Sample_Data表数据
|
||||
sampleDataSpectrumService.saveSampleData(sourceData, stationId, detectorId, filePathName, readLines);
|
||||
//获取sampleId
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
package org.jeecg.modules.quartz.controller;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.ImportExcelUtil;
|
||||
import org.jeecg.common.util.RedisStreamUtil;
|
||||
import org.jeecg.modules.base.dto.Info;
|
||||
import org.jeecg.modules.quartz.entity.QuartzJob;
|
||||
import org.jeecg.modules.quartz.service.IQuartzJobService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sys/testana")
|
||||
@Slf4j
|
||||
@Api(tags = "定时任务接口")
|
||||
public class TestController {
|
||||
|
||||
@Autowired
|
||||
private RedisStreamUtil redisStreamUtil;
|
||||
|
||||
@GetMapping("test")
|
||||
public void test(){
|
||||
Info info = new Info();
|
||||
info.setStationId("205");
|
||||
info.setSampleId("425496");
|
||||
info.setBetaOrGamma("Gamma");
|
||||
info.setFullOrPrel("FULL");
|
||||
info.setDatasource("1");
|
||||
info.setSampleName("CAX05_001-20230624_0220_Q_FULL_299.3.PHD");
|
||||
info.setCollectionDate(LocalDateTime.now());
|
||||
Map<String, String> nuclides = MapUtil.newHashMap();
|
||||
nuclides.put("Be7","1000000");
|
||||
nuclides.put("sss","1000000");
|
||||
nuclides.put("Tl208","10");
|
||||
info.setNuclides(nuclides);
|
||||
redisStreamUtil.pushAnalysis(info);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
|
@ -13,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
|
||||
import com.google.common.io.Files;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
@ -47,9 +50,6 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
|
|||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private FTPUtil ftpUtil;
|
||||
|
||||
@Autowired
|
||||
private SpectrumPathProperties pathProperties;
|
||||
|
||||
|
@ -110,9 +110,9 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
|
|||
TransactionDefinition txDef = new DefaultTransactionDefinition();
|
||||
final TransactionStatus txStatus = transactionManager.getTransaction(txDef);
|
||||
try {
|
||||
String ftpRootPath = ftpUtil.getFtpRootPath();
|
||||
String savePath = ftpRootPath + pathProperties.getSaveFilePath() + StrUtil.SLASH;
|
||||
String logPath = ftpRootPath + pathProperties.getLogPath() + StrUtil.SLASH;
|
||||
String rootPath = pathProperties.getRootPath();
|
||||
String savePath = rootPath + pathProperties.getSaveFilePath() + StrUtil.SLASH;
|
||||
String logPath = rootPath + pathProperties.getLogPath() + StrUtil.SLASH;
|
||||
/* 删除数据库数据 */
|
||||
// 过滤掉多余的表
|
||||
String ORIGINAL = "ORIGINAL";String RNAUTO = "RNAUTO";String RNMAN = "RNMAN";
|
||||
|
@ -170,16 +170,14 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
|
|||
needDel = needDel.stream().filter(StrUtil::isNotBlank).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(needDel))
|
||||
return Result.OK("Data cleaning is complete. No files need to be cleaned!");
|
||||
// 删除FTP文件
|
||||
List<String> failList = new ArrayList<>();
|
||||
for (String path:needDel) {
|
||||
boolean success = ftpUtil.removeFiles(path);
|
||||
if (!success) {
|
||||
failList.add(path);
|
||||
}
|
||||
// 删除本地文件
|
||||
List<String> fails = new ArrayList<>();
|
||||
for (String path : needDel) {
|
||||
boolean success = FileUtil.del(path);
|
||||
if (!success) fails.add(path);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(failList))
|
||||
return Result.error("Data clearing is complete, but file clearing fails!", failList);
|
||||
if (CollUtil.isNotEmpty(fails))
|
||||
return Result.error("Data clearing is complete, but file clearing fails!", fails);
|
||||
return Result.OK("Data and file cleanup complete!");
|
||||
}catch (Exception e){
|
||||
transactionManager.rollback(txStatus);
|
||||
|
@ -215,27 +213,25 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
|
|||
Integer sampleId, String owner){
|
||||
List<String> fileList = new ArrayList<>();
|
||||
List<AnalysesDto> AnalysesDtoList = baseMapper.getAnalysis(owner, sampleId);
|
||||
if (CollectionUtils.isNotEmpty(AnalysesDtoList)) {
|
||||
for (AnalysesDto AnalysesDto:AnalysesDtoList) {
|
||||
String baselinePath = AnalysesDto.getBaselinePath();
|
||||
if (StrUtil.isNotBlank(baselinePath)) {
|
||||
fileList.add(savePath + baselinePath);
|
||||
}
|
||||
String lcPath = AnalysesDto.getLcPath();
|
||||
if (StrUtil.isNotBlank(lcPath)) {
|
||||
fileList.add(savePath + lcPath);
|
||||
}
|
||||
String scacPath = AnalysesDto.getScacPath();
|
||||
if (StrUtil.isNotBlank(scacPath)) {
|
||||
fileList.add(savePath + scacPath);
|
||||
}
|
||||
if (StrUtil.isNotBlank(AnalysesDto.getLogPath())) {
|
||||
fileList.add(logPath + AnalysesDto.getLogPath());
|
||||
}
|
||||
String reportPath = AnalysesDto.getReportPath();
|
||||
if (StrUtil.isNotBlank(reportPath)) {
|
||||
fileList.add(savePath + reportPath + FileTypeEnum.txt.getType());
|
||||
}
|
||||
for (AnalysesDto AnalysesDto:AnalysesDtoList) {
|
||||
String baselinePath = AnalysesDto.getBaselinePath();
|
||||
if (StrUtil.isNotBlank(baselinePath)) {
|
||||
fileList.add(savePath + baselinePath);
|
||||
}
|
||||
String lcPath = AnalysesDto.getLcPath();
|
||||
if (StrUtil.isNotBlank(lcPath)) {
|
||||
fileList.add(savePath + lcPath);
|
||||
}
|
||||
String scacPath = AnalysesDto.getScacPath();
|
||||
if (StrUtil.isNotBlank(scacPath)) {
|
||||
fileList.add(savePath + scacPath);
|
||||
}
|
||||
if (StrUtil.isNotBlank(AnalysesDto.getLogPath())) {
|
||||
fileList.add(logPath + AnalysesDto.getLogPath());
|
||||
}
|
||||
String reportPath = AnalysesDto.getReportPath();
|
||||
if (StrUtil.isNotBlank(reportPath)) {
|
||||
fileList.add(savePath + reportPath + FileTypeEnum.txt.getType());
|
||||
}
|
||||
}
|
||||
return fileList;
|
||||
|
|
Loading…
Reference in New Issue
Block a user