bug 处理
This commit is contained in:
parent
70d3ab00f2
commit
e6eadcb074
@ -44,8 +44,23 @@ public class ShellUtil {
|
||||
|
||||
Process process = processBuilder.start();
|
||||
|
||||
// 复用原有的业务逻辑处理
|
||||
resInfo = processScriptOutput(process, patientScript, resInfo);
|
||||
// 处理标准输出
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String outputLine;
|
||||
System.out.println("=== Standard Output ===");
|
||||
while ((outputLine = reader.readLine()) != null) {
|
||||
System.out.println(outputLine);
|
||||
// 将输出传递给业务逻辑处理方法
|
||||
processSingleOutputLine(outputLine, patientScript, resInfo);
|
||||
}
|
||||
|
||||
// 处理错误输出
|
||||
BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||
String errorLine;
|
||||
System.err.println("=== Error Output ===");
|
||||
while ((errorLine = errorReader.readLine()) != null) {
|
||||
System.err.println(errorLine);
|
||||
}
|
||||
|
||||
// 等待命令执行完成
|
||||
int exitCode = process.waitFor();
|
||||
@ -62,90 +77,83 @@ public class ShellUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理脚本输出,复用原有的业务逻辑
|
||||
* @param process 进程对象
|
||||
* 处理单行输出,复用原有的业务逻辑
|
||||
* @param line 输出行
|
||||
* @param patientScript 患者脚本对象
|
||||
* @param resInfo 结果信息
|
||||
* @return 更新后的结果信息
|
||||
* @throws Exception 处理异常
|
||||
*/
|
||||
private static String processScriptOutput(Process process, PatientScript patientScript, String resInfo) throws Exception {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
if (line.contains("\"tr\"") && line.contains("{") && line.contains("}")) {
|
||||
System.out.println(line + "tr11111111************************************************************");
|
||||
JSONObject jsonObject = JSONObject.parseObject(line);
|
||||
patientScript.setRepetitionTime(jsonObject.get("tr").toString());
|
||||
}
|
||||
private static void processSingleOutputLine(String line, PatientScript patientScript, String resInfo) throws Exception {
|
||||
if (line.contains("\"tr\"") && line.contains("{") && line.contains("}")) {
|
||||
System.out.println(line + "tr11111111************************************************************");
|
||||
JSONObject jsonObject = JSONObject.parseObject(line);
|
||||
patientScript.setRepetitionTime(jsonObject.get("tr").toString());
|
||||
}
|
||||
|
||||
if (line.contains("姓名")) {
|
||||
System.out.println(line + "姓名************************************************************");
|
||||
String[] parts = line.split(":");
|
||||
if (parts.length > 1) {
|
||||
String name = parts[1].trim();
|
||||
if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(patientScript.getPatientName()) && !name.equals("Unknown")) {
|
||||
patientScript.setPatientName(name);
|
||||
}
|
||||
if (line.contains("姓名")) {
|
||||
System.out.println(line + "姓名************************************************************");
|
||||
String[] parts = line.split(":");
|
||||
if (parts.length > 1) {
|
||||
String name = parts[1].trim();
|
||||
if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(patientScript.getPatientName()) && !name.equals("Unknown")) {
|
||||
patientScript.setPatientName(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (line.contains("性别")) {
|
||||
System.out.println(line + "性别************************************************************");
|
||||
String[] parts = line.split(":");
|
||||
if (parts.length > 1) {
|
||||
String sex = parts[1].trim();
|
||||
if (StringUtils.isNotEmpty(sex) && StringUtils.isEmpty(patientScript.getPatientSex()) && !sex.equals("Unknown")) {
|
||||
if ("男".equals(sex)) {
|
||||
patientScript.setPatientSex("男");
|
||||
} else {
|
||||
patientScript.setPatientSex("女");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (line.contains("年龄")) {
|
||||
System.out.println(line + "年龄************************************************************");
|
||||
String[] parts = line.split(":");
|
||||
if (parts.length > 1) {
|
||||
String age = parts[1].trim();
|
||||
if (StringUtils.isNotEmpty(age) && StringUtils.isEmpty(patientScript.getPatientAge()) && !age.equals("Unknown")) {
|
||||
// 去除非数字字符
|
||||
String numericAge = age.replaceAll("[^0-9]", "");
|
||||
// 将字符串转换为整数
|
||||
int ageInt = Integer.parseInt(numericAge);
|
||||
// 设置年龄
|
||||
patientScript.setPatientAge(String.valueOf(ageInt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (line.contains("brain_regions") || line.contains("correlation")) {
|
||||
String resInfo1 = patientScript.getResInfo();
|
||||
if (StringUtils.isEmpty(resInfo1)) {
|
||||
resInfo1 = line;
|
||||
} else {
|
||||
resInfo1 = resInfo1 + "&*&*&" + line;
|
||||
}
|
||||
patientScript.setResInfo(resInfo1);
|
||||
}
|
||||
|
||||
if (line.contains("result===")) {
|
||||
System.out.println(line + "result1************************************************************");
|
||||
if (line.contains("1")) {
|
||||
resInfo = "异常";
|
||||
} else {
|
||||
resInfo = "正常";
|
||||
}
|
||||
}
|
||||
|
||||
if (line.contains("检查数据完整性")) {
|
||||
throw new Exception("生成异常");
|
||||
}
|
||||
}
|
||||
return resInfo;
|
||||
|
||||
if (line.contains("性别")) {
|
||||
System.out.println(line + "性别************************************************************");
|
||||
String[] parts = line.split(":");
|
||||
if (parts.length > 1) {
|
||||
String sex = parts[1].trim();
|
||||
if (StringUtils.isNotEmpty(sex) && StringUtils.isEmpty(patientScript.getPatientSex()) && !sex.equals("Unknown")) {
|
||||
if ("男".equals(sex)) {
|
||||
patientScript.setPatientSex("男");
|
||||
} else {
|
||||
patientScript.setPatientSex("女");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (line.contains("年龄")) {
|
||||
System.out.println(line + "年龄************************************************************");
|
||||
String[] parts = line.split(":");
|
||||
if (parts.length > 1) {
|
||||
String age = parts[1].trim();
|
||||
if (StringUtils.isNotEmpty(age) && StringUtils.isEmpty(patientScript.getPatientAge()) && !age.equals("Unknown")) {
|
||||
// 去除非数字字符
|
||||
String numericAge = age.replaceAll("[^0-9]", "");
|
||||
// 将字符串转换为整数
|
||||
int ageInt = Integer.parseInt(numericAge);
|
||||
// 设置年龄
|
||||
patientScript.setPatientAge(String.valueOf(ageInt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (line.contains("brain_regions") || line.contains("correlation")) {
|
||||
String resInfo1 = patientScript.getResInfo();
|
||||
if (StringUtils.isEmpty(resInfo1)) {
|
||||
resInfo1 = line;
|
||||
} else {
|
||||
resInfo1 = resInfo1 + "&*&*&" + line;
|
||||
}
|
||||
patientScript.setResInfo(resInfo1);
|
||||
}
|
||||
|
||||
if (line.contains("result===")) {
|
||||
System.out.println(line + "result1************************************************************");
|
||||
if (line.contains("1")) {
|
||||
resInfo = "异常";
|
||||
} else {
|
||||
resInfo = "正常";
|
||||
}
|
||||
}
|
||||
|
||||
if (line.contains("检查数据完整性")) {
|
||||
throw new Exception("生成异常");
|
||||
}
|
||||
}
|
||||
|
||||
public static void execCmd(String cmd) throws IOException {
|
||||
@ -190,4 +198,5 @@ public class ShellUtil {
|
||||
// ... existing code ...
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user