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

This commit is contained in:
nieziyan 2023-11-15 11:42:47 +08:00
commit ea129e94ab
7 changed files with 92 additions and 133 deletions

View File

@ -156,6 +156,9 @@ public class PHDFile implements Serializable {
private Map<String, NuclideActMda> mapNucActMda;
public PHDFile() {
userId = "";
xmlFilePath = "";
tmpFilePath = "";
bAnalyed = false;
isValid = true;
analy_start_time = "";

View File

@ -45,8 +45,8 @@ public class SpectrumAnalysesController {
@GetMapping("getDBSpectrumChart")
@ApiOperation(value = "查询折线图相关信息接口", notes = "查询折线图相关信息接口")
public Result getDBSpectrumChart(String dbName, Integer sampleId, HttpServletRequest request) {
return spectrumAnalysisService.getDBSpectrumChart(dbName, sampleId, request);
public Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
return spectrumAnalysisService.getDBSpectrumChart(dbName, sampleId, analyst, request);
}
@GetMapping("getFileSpectrumChart")

View File

@ -212,6 +212,10 @@ public class BetaDataFile implements Serializable {
private List<GardsCalibrationPairsSpectrum> betaCalibrationPairsList;
public BetaDataFile() {
sampleTmpPath = "";
gasTmpPath = "";
detTmpPath = "";
qcTmpPath = "";
sampleFilePathName = "";
sampleFileName = "";
gasFilePathName = "";

View File

@ -20,7 +20,7 @@ public interface ISpectrumAnalysisService {
Result getFilesBySampleFile(String fileName, HttpServletRequest request);
Result getDBSpectrumChart(String dbName, Integer sampleId, HttpServletRequest request);
Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst, HttpServletRequest request);
Result getFileSpectrumChart(String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request);

View File

@ -171,7 +171,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
gammaFileUtil.SetBaseInfo(phd, analyst);
}
// 从数据库中读取phd其他相关信息
boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result);
boolean bRet = getResultFromDB(dbName, analyst, sampleId, phd, result);
if (!redisUtil.hasKey(userName+"-"+phd.getHeader().getSystem_type())) {
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();
@ -469,7 +469,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
gammaFileUtil.SetBaseInfo(phd, analyst);
}
// 从数据库中读取phd其他相关信息
boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result);
boolean bRet = getResultFromDB(dbName, analyst, sampleId, phd, result);
if (!redisUtil.hasKey(userName+"-"+phd.getHeader().getSystem_type())) {
// 查询当前用户关联的核素信息
List<String> userLib = new LinkedList<>();

View File

@ -316,7 +316,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
@Override
public Result getDBSpectrumChart(String dbName, Integer sampleId, HttpServletRequest request) {
public Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
Result result = new Result();
//获取当前的用户名称
String userName = JwtUtil.getUserNameByToken(request);
@ -349,7 +349,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
roiResultsSpectrumList = spectrumAnalysisMapper.ReadROIResults("RNAUTO", analysisID, sampleId);
} else if (dbName.equalsIgnoreCase("man")){
dbName = "RNMAN";
analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName);
analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, analyst);
gammaCalibrationPairsList = spectrumAnalysisMapper.ReadGammaFitChannelEnergy(analysisID, sampleId);
betaCalibrationPairsList = spectrumAnalysisMapper.ReadBetaFitChannelEnergy(analysisID, sampleId);
xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults(dbName, analysisID, sampleId);
@ -1039,23 +1039,23 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
strBuffer.append(rowFormat("%sNew Beta%-43sNew Gamma%-42s", StringPool.SPACE, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sCH(x) = (%s)+(%s)*x+(%s)x*x%-24sCH(x) = (%s)+(%s)*x+(%s)x*x%-24s", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamS.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamS.getCoeff1()))),
(Objects.isNull(betaCalibrationParamS.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamS.getCoeff2()))),
(Objects.isNull(betaCalibrationParamS.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamS.getCoeff3()))),
(Objects.isNull(betaCalibrationParamES.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamES.getCoeff1()))),
(Objects.isNull(betaCalibrationParamES.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamES.getCoeff2()))),
(Objects.isNull(betaCalibrationParamES.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamES.getCoeff3()))),
StringPool.SPACE,
(Objects.isNull(gammaCalibrationParamS.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamS.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamS.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamS.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamS.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamS.getCoeff3()))),
(Objects.isNull(gammaCalibrationParamES.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamES.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamES.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamES.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamES.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamES.getCoeff3()))),
StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sE(x) = (%s)+(%s)*x+(%s)x*x%-24sE(x) = (%s)+(%s)*x+(%s)x*x%-24s", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamES.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamES.getCoeff1()))),
(Objects.isNull(betaCalibrationParamES.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamES.getCoeff2()))),
(Objects.isNull(betaCalibrationParamES.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamES.getCoeff3()))),
(Objects.isNull(betaCalibrationParamS.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamS.getCoeff1()))),
(Objects.isNull(betaCalibrationParamS.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamS.getCoeff2()))),
(Objects.isNull(betaCalibrationParamS.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamS.getCoeff3()))),
StringPool.SPACE,
(Objects.isNull(gammaCalibrationParamES.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamES.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamES.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamES.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamES.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamES.getCoeff3()))),
(Objects.isNull(gammaCalibrationParamS.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamS.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamS.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamS.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamS.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamS.getCoeff3()))),
StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
@ -1093,23 +1093,23 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
strBuffer.append(rowFormat("%sNew Beta%-43sNew Gamma%-42s", StringPool.SPACE, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sCH(x) = (%s)+(%s)*x+(%s)x*x%-24sCH(x) = (%s)+(%s)*x+(%s)x*x%-24s", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamD.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamD.getCoeff1()))),
(Objects.isNull(betaCalibrationParamD.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamD.getCoeff2()))),
(Objects.isNull(betaCalibrationParamD.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamD.getCoeff3()))),
(Objects.isNull(betaCalibrationParamED.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamED.getCoeff1()))),
(Objects.isNull(betaCalibrationParamED.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamED.getCoeff2()))),
(Objects.isNull(betaCalibrationParamED.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamED.getCoeff3()))),
StringPool.SPACE,
(Objects.isNull(gammaCalibrationParamD.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamD.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamD.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamD.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamD.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamD.getCoeff3()))),
(Objects.isNull(gammaCalibrationParamED.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamED.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamED.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamED.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamED.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamED.getCoeff3()))),
StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sE(x) = (%s)+(%s)*x+(%s)x*x%-24sE(x) = (%s)+(%s)*x+(%s)x*x%-24s", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamED.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamED.getCoeff1()))),
(Objects.isNull(betaCalibrationParamED.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamED.getCoeff2()))),
(Objects.isNull(betaCalibrationParamED.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamED.getCoeff3()))),
(Objects.isNull(betaCalibrationParamD.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamD.getCoeff1()))),
(Objects.isNull(betaCalibrationParamD.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamD.getCoeff2()))),
(Objects.isNull(betaCalibrationParamD.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamD.getCoeff3()))),
StringPool.SPACE,
(Objects.isNull(gammaCalibrationParamED.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamED.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamED.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamED.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamED.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamED.getCoeff3()))),
(Objects.isNull(gammaCalibrationParamD.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamD.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamD.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamD.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamD.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamD.getCoeff3()))),
StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());
@ -1146,23 +1146,23 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
strBuffer.append(rowFormat("%sNew Beta%-43sNew Gamma%-42s", StringPool.SPACE, StringPool.SPACE, StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sCH(x) = (%s)+(%s)*x+(%s)x*x%-24sCH(x) = (%s)+(%s)*x+(%s)x*x%-24s", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamG.getCoeff1()))),
(Objects.isNull(betaCalibrationParamG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamG.getCoeff2()))),
(Objects.isNull(betaCalibrationParamG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamG.getCoeff3()))),
(Objects.isNull(betaCalibrationParamEG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamEG.getCoeff1()))),
(Objects.isNull(betaCalibrationParamEG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamEG.getCoeff2()))),
(Objects.isNull(betaCalibrationParamEG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamEG.getCoeff3()))),
StringPool.SPACE,
(Objects.isNull(gammaCalibrationParamG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamG.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamG.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamG.getCoeff3()))),
(Objects.isNull(gammaCalibrationParamEG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamEG.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamEG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamEG.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamEG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaToUiOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamEG.getCoeff3()))),
StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(rowFormat("%sE(x) = (%s)+(%s)*x+(%s)x*x%-24sE(x) = (%s)+(%s)*x+(%s)x*x%-24s", StringPool.SPACE,
(Objects.isNull(betaCalibrationParamEG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamEG.getCoeff1()))),
(Objects.isNull(betaCalibrationParamEG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamEG.getCoeff2()))),
(Objects.isNull(betaCalibrationParamEG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamEG.getCoeff3()))),
(Objects.isNull(betaCalibrationParamG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamG.getCoeff1()))),
(Objects.isNull(betaCalibrationParamG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamG.getCoeff2()))),
(Objects.isNull(betaCalibrationParamG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getBetaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(betaCalibrationParamG.getCoeff3()))),
StringPool.SPACE,
(Objects.isNull(gammaCalibrationParamEG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamEG.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamEG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamEG.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamEG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamEG.getCoeff3()))),
(Objects.isNull(gammaCalibrationParamG.getCoeff1())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(0)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamG.getCoeff1()))),
(Objects.isNull(gammaCalibrationParamG.getCoeff2())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(1)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamG.getCoeff2()))),
(Objects.isNull(gammaCalibrationParamG.getCoeff3())?NumberFormatUtil.numberSixLen(betaDataFile.getGammaFittingParaOld().get(2)):NumberFormatUtil.numberSixLen(String.valueOf(gammaCalibrationParamG.getCoeff3()))),
StringPool.SPACE));
strBuffer.append(System.lineSeparator());
strBuffer.append(System.lineSeparator());

View File

@ -37,49 +37,21 @@ public class ReadLineUtil {
private String encoding;
public Map<String, Object> readLine(String filePath, String header){
//连接ftp
FTPClient ftpClient = ftpUtil.LoginFTP();
//判断ftp是否连接成功
if (Objects.isNull(ftpClient)){
throw new RuntimeException("ftp connection failed!");
}
InputStream iStream = null;
File file = null;
try {
ftpClient.enterLocalPassiveMode();
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1);
String parameterFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH));
filePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath;
file = ftpUtil.downloadFile(filePath, "betaGamma");
//判断文件路径是否为空
if (StringUtils.isNotBlank(parameterFilePath)){
//在当前工作路径下读取文件
ftpClient.changeWorkingDirectory(parameterFilePath);
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding(encoding);
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
if (CollectionUtils.isNotEmpty(ftpFiles)){
for (FTPFile ftpFile:ftpFiles) {
if (ftpFile.getName().equals(fileName)){
//读取ftp文件的输入流
iStream=ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件
file = File.createTempFile("betaGamma", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(iStream, file);
List<String> allLines = FileUtils.readLines(file, encoding);
if (CollectionUtils.isNotEmpty(allLines)) {
//遍历所有的行
for (String nowLine:allLines) {
//判断当前行是否含有传递的头部信息
if (nowLine.contains(header)){
List<String> otherLines = allLines.subList(allLines.indexOf(nowLine)+1, allLines.size());
Map<String, Object> map = this.readValue(otherLines, header);
iStream.close();
return map;
}
}
}
if (Objects.nonNull(file)){
List<String> allLines = FileUtils.readLines(file, encoding);
if (CollectionUtils.isNotEmpty(allLines)) {
//遍历所有的行
for (String nowLine:allLines) {
//判断当前行是否含有传递的头部信息
if (nowLine.contains(header)){
List<String> otherLines = allLines.subList(allLines.indexOf(nowLine)+1, allLines.size());
Map<String, Object> map = this.readValue(otherLines, header);
return map;
}
}
}
@ -87,18 +59,8 @@ public class ReadLineUtil {
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(iStream)){
iStream.close();
}
if (Objects.nonNull(file)) {
file.delete();
}
} catch (IOException e) {
throw new RuntimeException(e);
if (Objects.nonNull(file)) {
file.delete();
}
}
return Collections.emptyMap();
@ -181,51 +143,38 @@ public class ReadLineUtil {
}
public Result readFtpFile(String filePath, HttpServletResponse response){
// 连接FTP
FTPClient ftpClient = ftpUtil.LoginFTP();
// 判断FTP是否连接成功
if (Objects.isNull(ftpClient)){
throw new RuntimeException(Prompt.FTP_ERR);
}
OutputStream outputStream = null;
InputStream inputStream = null;
try {
filePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath;
// 切换工作目录为 /
ftpClient.changeWorkingDirectory(SymbolConstant.SINGLE_SLASH);
// 判断FTP服务器上是否存在此文件
String[] files = ftpClient.listNames(filePath);
if (ArrayUtil.isEmpty(files)){
String message = "File ["+filePath+"] does not exist!";
log.error(message);
return Result.error(message);
}
// 存在多个文件名表示此路径为目录而非文件
if (ArrayUtil.length(files) > 1){
String message = "["+filePath+"] There are multiple files, possibly one directory!";
log.error(message);
return Result.error(message);
}
// // 切换工作目录为 /
// ftpClient.changeWorkingDirectory(SymbolConstant.SINGLE_SLASH);
// // 判断FTP服务器上是否存在此文件
// String[] files = ftpClient.listNames(filePath);
// if (ArrayUtil.isEmpty(files)){
// String message = "File ["+filePath+"] does not exist!";
// log.error(message);
// return Result.error(message);
// }
// // 存在多个文件名表示此路径为目录而非文件
// if (ArrayUtil.length(files) > 1){
// String message = "["+filePath+"] There are multiple files, possibly one directory!";
// log.error(message);
// return Result.error(message);
// }
// 获取文件名
String fileName = FileUtil.getName(filePath);
// 在当前工作路径下读取文件
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding(encoding);
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
inputStream = ftpClient.retrieveFileStream(filePath);
// // 在当前工作路径下读取文件
// ftpClient.enterLocalPassiveMode();
// ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// // 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
// ftpClient.setControlEncoding(encoding);
// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
inputStream = ftpUtil.downloadFileStream(filePath);
outputStream = ExportUtil.stream(response,fileName);
// 缓冲区大小
byte[] buffer = new byte[4096];
int bytesRead;
// 将文件输出流写入到输出流中
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
@ -236,9 +185,12 @@ public class ReadLineUtil {
return Result.error(e.getMessage());
}finally {
try {
if (ObjectUtil.isNotNull(inputStream))inputStream.close();
if (ObjectUtil.isNotNull(outputStream))outputStream.close();
ftpClient.disconnect();
if (ObjectUtil.isNotNull(inputStream)) {
inputStream.close();
}
if (ObjectUtil.isNotNull(outputStream)) {
outputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}