fix:解决Gamma default params表有空的value报错问题
This commit is contained in:
parent
0e4b4039e3
commit
f41a8dad0c
|
@ -8,6 +8,7 @@ import org.jeecg.modules.service.IGardsGammaDefaultParamsService;
|
|||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -19,7 +20,7 @@ public class GardsGammaDefaultParamsServiceImpl extends ServiceImpl<GardsGammaDe
|
|||
public Map<String, String> mapSetting() {
|
||||
Map<String, String> paramsMap = list().stream()
|
||||
.collect(Collectors.toMap(GardsGammaDefaultParams::getName,
|
||||
GardsGammaDefaultParams::getValue));
|
||||
v->v.getValue() == null ? "" : v.getValue()));
|
||||
return paramsMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1515,10 +1515,14 @@ public class GammaFileUtil {
|
|||
try {
|
||||
String phdStr = mapper.writeValueAsString(phd);
|
||||
String mapLinesStr = mapper.writeValueAsString(mapLines);
|
||||
|
||||
//解析获取临时文件信息
|
||||
File tmpFile = this.analyzeFile(phd.getFilepath());
|
||||
String analyseSpectrum = CalValuesHandler.analyseSpectrum(phdStr, mapLinesStr, "");
|
||||
JSONObject jsonObject = JSONObject.parseObject(analyseSpectrum);
|
||||
String jsonString = jsonObject.toJSONString();
|
||||
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -4206,5 +4210,40 @@ public class GammaFileUtil {
|
|||
}
|
||||
return file;
|
||||
}
|
||||
public File analyzeFile(String path) {
|
||||
//连接ftp
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
InputStream inputStream = null;
|
||||
File file = null;
|
||||
try {
|
||||
//被动模式
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
//设置文件类型--二进制文件
|
||||
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
||||
//
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
inputStream = ftpClient.retrieveFileStream(path);
|
||||
if (Objects.nonNull(inputStream)){
|
||||
file = File.createTempFile("tmp", null);
|
||||
//将ftp文件的输入流复制给临时文件
|
||||
FileUtils.copyInputStreamToFile(inputStream, file);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(ftpClient)){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
if (Objects.nonNull(inputStream)){
|
||||
inputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.controller;
|
|||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.hdgf.pointers.Pointer;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.base.BaseMap;
|
||||
import org.jeecg.common.constant.GlobalConstants;
|
||||
|
@ -19,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("gamma")
|
||||
|
|
|
@ -213,6 +213,7 @@ public class GammaServiceImpl implements IGammaService {
|
|||
|
||||
@Override
|
||||
public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) {
|
||||
long l = System.currentTimeMillis();
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -227,14 +228,22 @@ public class GammaServiceImpl implements IGammaService {
|
|||
}
|
||||
String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
|
||||
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
|
||||
System.out.println("loadFile之前>>>>"+(System.currentTimeMillis() - l));
|
||||
l = System.currentTimeMillis();
|
||||
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
|
||||
System.out.println("loadFile>>>>"+(System.currentTimeMillis() - l));
|
||||
if (!flag){
|
||||
return result;
|
||||
}
|
||||
l = System.currentTimeMillis();
|
||||
//声明基础数组信息
|
||||
gammaFileUtil.SetBaseInfo(phd);
|
||||
System.out.println("SetBaseInfo>>>>"+(System.currentTimeMillis() - l));
|
||||
l = System.currentTimeMillis();
|
||||
//从数据库中读取相关信息
|
||||
boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result);
|
||||
System.out.println("getResultFromDB>>>>"+(System.currentTimeMillis() - l));
|
||||
l = System.currentTimeMillis();
|
||||
if (!bRet){
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public class CalculateStationData {
|
|||
try {
|
||||
//文件路径
|
||||
String filePath = parameterFilePath+ File.separator +"parameter.xml";
|
||||
filePath = "F:\\RunSoftware\\ARMD1.0.4\\SystemManager.xml";
|
||||
//声明一个实体类存储参数信息
|
||||
RateParam mRateParam = new RateParam();
|
||||
//创建一个文档解析器工厂
|
||||
|
|
Loading…
Reference in New Issue
Block a user