GammaFileUtil修改文件内容获取错误问题

NameStandUtil修改文件路径错误问题
修改Gamma模块saveToDB接口
This commit is contained in:
qiaoqinzheng 2023-09-20 17:13:23 +08:00
parent 5e5474eb2f
commit bec2a892a1
5 changed files with 34 additions and 32 deletions

View File

@ -2804,7 +2804,7 @@ public class GammaFileUtil {
String subDirSavePath = ""; String subDirSavePath = "";
subDirSavePath+=nameStandUtil.GetSysTemSubdir(fileAnlyse.getHeader().getSystem_type()); subDirSavePath+=nameStandUtil.GetSysTemSubdir(fileAnlyse.getHeader().getSystem_type());
subDirSavePath+=nameStandUtil.GetDateTypeSubdir(dataType); subDirSavePath+=nameStandUtil.GetDateTypeSubdir(dataType);
Map<String, String> fileNames = nameStandUtil.NameStandard(subDirSavePath, fileAnlyse); Map<String, String> fileNames = nameStandUtil.NameStandard(fileAnlyse);
String lcName = fileNames.get("lc"); String lcName = fileNames.get("lc");
String scacName = fileNames.get("scac"); String scacName = fileNames.get("scac");
String baselineName = fileNames.get("baseline"); String baselineName = fileNames.get("baseline");

View File

@ -20,15 +20,15 @@ public class NameStandUtil {
public String GetSysTemSubdir(String systemType) { public String GetSysTemSubdir(String systemType) {
StringBuffer path = new StringBuffer(); StringBuffer path = new StringBuffer();
if(systemType.contains(SystemType.BETA.getType())) { if(systemType.contains(SystemType.BETA.getType())) {
path.append(StringPool.SLASH+"Spectrum"); path.append("Spectrum");
path.append(StringPool.SLASH+"Xenon"); path.append(StringPool.SLASH+"Xenon");
path.append(StringPool.SLASH+"Sauna"); path.append(StringPool.SLASH+"Sauna");
} else if(systemType.contains(SystemType.GAMMA.getType())) { } else if(systemType.contains(SystemType.GAMMA.getType())) {
path.append(StringPool.SLASH+"Spectrum"); path.append("Spectrum");
path.append(StringPool.SLASH+"Xenon"); path.append(StringPool.SLASH+"Xenon");
path.append(StringPool.SLASH+"Spalax"); path.append(StringPool.SLASH+"Spalax");
} else if(systemType.contains(SystemType.PARTICULATE.getType())) { } else if(systemType.contains(SystemType.PARTICULATE.getType())) {
path.append(StringPool.SLASH+"Spectrum"); path.append("Spectrum");
path.append(StringPool.SLASH+"Particulates"); path.append(StringPool.SLASH+"Particulates");
} }
return path.toString(); return path.toString();
@ -78,9 +78,9 @@ public class NameStandUtil {
return path.toString(); return path.toString();
} }
public Map<String, String> NameStandard(String path, PHDFile fileAnlyse) { public Map<String, String> NameStandard(PHDFile fileAnlyse) {
String suffix = GetSuffix(fileAnlyse.getMsgInfo().getData_type(),fileAnlyse.getHeader().getSystem_type(),fileAnlyse.getHeader().getSpectrum_quantity(),String.valueOf(fileAnlyse.getAcq().getAcquisition_live_time())); String suffix = GetSuffix(fileAnlyse.getMsgInfo().getData_type(),fileAnlyse.getHeader().getSystem_type(),fileAnlyse.getHeader().getSpectrum_quantity(),String.valueOf(fileAnlyse.getAcq().getAcquisition_live_time()));
Map<String, String> fileNames = NameStandardByName(path, fileAnlyse.getFilename(), fileAnlyse.getHeader().getMeasurement_id(),suffix); Map<String, String> fileNames = NameStandardByName(fileAnlyse.getFilename(), fileAnlyse.getHeader().getMeasurement_id(),suffix);
return fileNames; return fileNames;
} }
@ -117,13 +117,12 @@ public class NameStandUtil {
return rData; return rData;
} }
public Map<String, String> NameStandardByName(String path, String fileName, String dateTimeFormat, String suffix) { public Map<String, String> NameStandardByName(String fileName, String dateTimeFormat, String suffix) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
String StandardFileName=""; String StandardFileName="";
String measurementName = GetFileNameFromDateTime(dateTimeFormat, suffix); String measurementName = GetFileNameFromDateTime(dateTimeFormat, suffix);
String fileDir = path + StringPool.SLASH;
if(measurementName != fileName) { if(measurementName != fileName) {
StandardFileName = fileDir+measurementName; StandardFileName = measurementName;
} }
String fileSuffix = "PHD"; String fileSuffix = "PHD";
@ -133,11 +132,11 @@ public class NameStandUtil {
String m_logfileName = StandardFileName; String m_logfileName = StandardFileName;
String m_reportFileName = StandardFileName; String m_reportFileName = StandardFileName;
m_lcFileName.replace(fileSuffix,"lc"); m_lcFileName = m_lcFileName.replace(fileSuffix,"lc");
m_baseLineFileName.replace(fileSuffix,"baseline"); m_baseLineFileName = m_baseLineFileName.replace(fileSuffix,"baseline");
m_scacFileName.replace(fileSuffix,"scac"); m_scacFileName = m_scacFileName.replace(fileSuffix,"scac");
m_logfileName.replace(fileSuffix,"log"); m_logfileName = m_logfileName.replace(fileSuffix,"log");
m_reportFileName.replace("."+fileSuffix,"_rpt"); m_reportFileName = m_reportFileName.replace("."+fileSuffix,"_rpt");
String m_saveFileName = StandardFileName; String m_saveFileName = StandardFileName;
@ -189,7 +188,7 @@ public class NameStandUtil {
//添加文件名日期 //添加文件名日期
List<String> dateSub = GetSubDirByFileName(saveFileName); List<String> dateSub = GetSubDirByFileName(saveFileName);
for(int pos=0;pos<dateSub.size();pos++) { for(int pos=0;pos<dateSub.size();pos++) {
input_file_name=input_file_name+dateSub.get(pos)+StringPool.SLASH; input_file_name=input_file_name+StringPool.SLASH+dateSub.get(pos);
} }
return input_file_name; return input_file_name;
} }

View File

@ -35,6 +35,7 @@ import org.jeecg.modules.service.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
@ -2799,13 +2800,17 @@ public class GammaServiceImpl implements IGammaService {
} }
@Override @Override
@Transactional
public Result saveToDB(String fileName, HttpServletRequest request) { public Result saveToDB(String fileName, HttpServletRequest request) {
Result result = new Result(); Result result = new Result();
String userName = JwtUtil.getUserNameByToken(request); String userName = JwtUtil.getUserNameByToken(request);
boolean bRet = true; boolean bRet = true;
boolean needUploadSpec = false;
Cache<String, PHDFile> phdCache = localCache.getPHDCache(); Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName); PHDFile phd = phdCache.getIfPresent(fileName);
if (Objects.isNull(phd)) {
result.error500("请先解析文件!");
return result;
}
//查看分析员是否有权限操作当前台站信息 //查看分析员是否有权限操作当前台站信息
//判断当前分析员是否有过排班任务 //判断当前分析员是否有过排班任务
Integer stationId = spectrumAnalysisMapper.getStationId(phd.getHeader().getSite_code()); Integer stationId = spectrumAnalysisMapper.getStationId(phd.getHeader().getSite_code());
@ -2837,8 +2842,7 @@ public class GammaServiceImpl implements IGammaService {
phd.setStatus(sampleData.getStatus()); phd.setStatus(sampleData.getStatus());
} else { } else {
//如果sampleData为空 存储数据 //如果sampleData为空 存储数据
needUploadSpec = SaveSampleToDB(phd, middleData.analyses_save_filePath); bRet = SaveSampleToDB(phd, middleData.analyses_save_filePath);
bRet = needUploadSpec;
} }
if(!bRet) { if(!bRet) {
result.error500("The Database hasn't this Spectrum("+phd.getFilename()+") and Insert it to Database failed."); result.error500("The Database hasn't this Spectrum("+phd.getFilename()+") and Insert it to Database failed.");
@ -2931,6 +2935,7 @@ public class GammaServiceImpl implements IGammaService {
return result; return result;
} }
@Transactional
public boolean SaveSampleToDB(PHDFile phd, String input_file_name) { public boolean SaveSampleToDB(PHDFile phd, String input_file_name) {
boolean bRet = true; boolean bRet = true;
String sit_det_code = phd.getHeader().getSite_code(); String sit_det_code = phd.getHeader().getSite_code();

View File

@ -113,7 +113,7 @@ public class GardsSampleDataSpectrumServiceImpl extends ServiceImpl<GardsSampleD
throw new RuntimeException(e); throw new RuntimeException(e);
} }
String acq_stop = DateUtils.formatDate(new Date(acq_stop_dt), "yyyy/MM/dd HH:mm:ss"); String acq_stop = DateUtils.formatDate(new Date(acq_stop_dt), "yyyy/MM/dd HH:mm:ss");
String data_type = (StringUtils.isBlank(phd.getMsgInfo().getData_type())? "":phd.getMsgInfo().getData_type()); String data_type = phd.getMsgInfo().getData_type().substring(0, 1);
GardsSampleData sampleData = new GardsSampleData(); GardsSampleData sampleData = new GardsSampleData();
try { try {
sampleData.setSiteDetCode(phd.getHeader().getDetector_code()); sampleData.setSiteDetCode(phd.getHeader().getDetector_code());

View File

@ -33,8 +33,7 @@ public class GardsSampleDescriptionSpectrumServiceImpl extends ServiceImpl<Gards
@Transactional @Transactional
public boolean saveSampleDescriptionGamma(PHDFile phd, Integer sampleId) { public boolean saveSampleDescriptionGamma(PHDFile phd, Integer sampleId) {
boolean bRet = false; boolean bRet = false;
if(StringUtils.isNotBlank(phd.getOriTotalCmt())) { String t_cmt = StringUtils.isNotBlank(phd.getOriTotalCmt())?phd.getOriTotalCmt():"";
String t_cmt = phd.getOriTotalCmt();
if(t_cmt.length() > 1024){ if(t_cmt.length() > 1024){
t_cmt = t_cmt.substring(0, 1024); t_cmt = t_cmt.substring(0, 1024);
} }
@ -45,7 +44,6 @@ public class GardsSampleDescriptionSpectrumServiceImpl extends ServiceImpl<Gards
if (insert>0) { if (insert>0) {
bRet = true; bRet = true;
} }
}
return bRet; return bRet;
} }