Merge remote-tracking branch 'origin/hospital_version' into hospital_version
This commit is contained in:
commit
f801b8d517
@ -7,6 +7,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||||||
import com.ruoyi.script.entity.PatientScript;
|
import com.ruoyi.script.entity.PatientScript;
|
||||||
import com.ruoyi.script.service.PatientScriptService;
|
import com.ruoyi.script.service.PatientScriptService;
|
||||||
import com.ruoyi.script.util.ShellUtil;
|
import com.ruoyi.script.util.ShellUtil;
|
||||||
|
import freemarker.template.TemplateException;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -50,7 +51,7 @@ public class PatientScriptController2 extends BaseController {
|
|||||||
* @return 新增结果
|
* @return 新增结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public AjaxResult insert(@RequestBody PatientScript patientScript) throws IOException, InterruptedException {
|
public AjaxResult insert(@RequestBody PatientScript patientScript) throws IOException, InterruptedException, TemplateException {
|
||||||
patientScript.setIsAll("0");
|
patientScript.setIsAll("0");
|
||||||
return toAjax(this.patientScriptService.save(patientScript));
|
return toAjax(this.patientScriptService.save(patientScript));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.script.service;
|
package com.ruoyi.script.service;
|
||||||
|
|
||||||
import com.ruoyi.script.entity.PatientScript;
|
import com.ruoyi.script.entity.PatientScript;
|
||||||
|
import freemarker.template.TemplateException;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -15,7 +16,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface PatientScriptService {
|
public interface PatientScriptService {
|
||||||
List<PatientScript> selectList(PatientScript patientScript);
|
List<PatientScript> selectList(PatientScript patientScript);
|
||||||
Boolean save(PatientScript patientScript) throws IOException, InterruptedException;
|
Boolean save(PatientScript patientScript) throws IOException, InterruptedException, TemplateException;
|
||||||
Boolean save2(PatientScript patientScript) throws IOException, InterruptedException;
|
Boolean save2(PatientScript patientScript) throws IOException, InterruptedException;
|
||||||
|
|
||||||
Boolean removeByIds(List<Long> idList);
|
Boolean removeByIds(List<Long> idList);
|
||||||
|
@ -17,6 +17,7 @@ import com.ruoyi.script.mapper.PatientScriptMapper;
|
|||||||
import com.ruoyi.script.service.PatientScriptService;
|
import com.ruoyi.script.service.PatientScriptService;
|
||||||
import com.ruoyi.script.util.ShellUtil;
|
import com.ruoyi.script.util.ShellUtil;
|
||||||
import com.ruoyi.script.util.Word2PdfUtil;
|
import com.ruoyi.script.util.Word2PdfUtil;
|
||||||
|
import freemarker.template.TemplateException;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.sevenzipjbinding.ExtractOperationResult;
|
import net.sf.sevenzipjbinding.ExtractOperationResult;
|
||||||
@ -188,99 +189,97 @@ public class PatientScriptServiceImpl implements PatientScriptService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean save(PatientScript patientScript) throws IOException, InterruptedException {
|
public Boolean save(PatientScript patientScript) throws IOException, InterruptedException, TemplateException {
|
||||||
|
try {
|
||||||
patientScript.setStatus("生成中");
|
patientScript.setStatus("生成中");
|
||||||
scriptMapper.updateStatus(patientScript);
|
scriptMapper.updateStatus(patientScript);
|
||||||
|
patientScript = scriptMapper.getById(Long.valueOf(patientScript.getId()));
|
||||||
// 多任务同时处理
|
// 多任务同时处理
|
||||||
taskExecutor.execute(new Runnable() {
|
|
||||||
@SneakyThrows
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
if (!patientScript.getType().equals("mri")){
|
|
||||||
String unique_id = generateOtp();
|
|
||||||
String playground = "playground"+unique_id;
|
|
||||||
String format = DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
||||||
//判断是zip还是rar
|
|
||||||
if (patientScript.getFilePath().endsWith(".zip")){
|
|
||||||
unzip(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据");
|
|
||||||
}else if (patientScript.getFilePath().endsWith(".rar")){
|
|
||||||
unRar(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据",null);
|
|
||||||
}
|
|
||||||
Map<String, Object> shMap = new LinkedHashMap<>();
|
|
||||||
shMap.put("outPath",format+"/output-"+unique_id);
|
|
||||||
shMap.put("filePath", patientScript.getFilePath());
|
|
||||||
shMap.put("subId",unique_id);
|
|
||||||
shMap.put("playground",format+"/"+playground);
|
|
||||||
shMap.put("fmriFileMb",format+"/"+playground+"/preprocessed/sub-001/func/sub-001_task-rest_space-MNI152NLin2009cAsym_boldref.nii.gz");
|
|
||||||
shMap.put("fmriRegOutFile",format+"/output-"+unique_id+"/bold_2_struct.mat");
|
|
||||||
shMap.put("fmriFileDpp",format+"/"+playground+"/preprocessed/sub-001/func/sub-001_task-rest_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz");
|
|
||||||
shMap.put("fmriR2t1OutFile",format+"/output-"+unique_id+"/reg2_Template.nii.gz");
|
|
||||||
shMap.put("smriFileMb",format+"/"+playground+"/preprocessed/sub-001/anat/sub-001_space-MNI152NLin2009cAsym_desc-preproc_T1w.nii.gz");
|
|
||||||
shMap.put("smriOutFile",format+"/output-"+unique_id+"/anat2_Template.nii.gz");
|
|
||||||
String fmriOutPath = "/data/"+format+"/output-"+unique_id+"/fmriOut/";
|
|
||||||
shMap.put("fmriOutPath",fmriOutPath);
|
|
||||||
shMap.put("matrixPath","/data/"+format+"/output-"+unique_id+"/");
|
|
||||||
String shPath="/data/"+format+"/cpac"+"-"+unique_id+".sh";
|
|
||||||
String dealDataSh="/data/"+format+"/dealData"+"-"+unique_id+".sh";
|
|
||||||
String imgPath="/data/"+format+"/img"+"-"+unique_id+".sh";
|
|
||||||
String alignPath="/data/"+format+"/align"+"-"+unique_id+".py";
|
|
||||||
shMap.put("alignPath",alignPath);
|
|
||||||
shMap.put("fucDataPath",format+"/output-"+unique_id+"/reg2_Template.nii.gz");
|
|
||||||
//创建alignPy
|
|
||||||
createFile(shMap, alignPath,"alignTemplate.ftl");
|
|
||||||
//创建处理数据脚本
|
|
||||||
createFile(shMap, dealDataSh,"dealData.ftl");
|
|
||||||
//创建图片生成脚本
|
|
||||||
createFile(shMap, imgPath,"imgSh.ftl");
|
|
||||||
//创建路径
|
|
||||||
File folder = new File(fmriOutPath);
|
|
||||||
if (!folder.exists()) { // 检查文件夹是否已存在
|
|
||||||
boolean created = folder.mkdirs(); // 创建文件夹
|
|
||||||
if (created) {
|
|
||||||
System.out.println("文件夹创建成功!");
|
|
||||||
} else {
|
|
||||||
System.out.println("文件夹创建失败!");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
System.out.println("文件夹已存在,无需再次创建!");
|
|
||||||
}
|
|
||||||
//处理数据处理格式
|
|
||||||
ShellUtil.execCmd("dos2unix "+dealDataSh);
|
|
||||||
shUtil(dealDataSh,patientScript);
|
|
||||||
if (StringUtils.isEmpty(patientScript.getPatientAge())){
|
|
||||||
patientScript.setPatientAge("0");
|
|
||||||
}
|
|
||||||
shMap.put("tr",patientScript.getRepetitionTime());
|
|
||||||
shMap.put("age",patientScript.getPatientAge());
|
|
||||||
//创建总脚本
|
|
||||||
createFile(shMap, shPath,"cpacSh.ftl");
|
|
||||||
scriptMapper.updateStatus(patientScript);
|
|
||||||
//处理脚本文件格式
|
|
||||||
ShellUtil.execCmd("dos2unix "+shPath);
|
|
||||||
ShellUtil.execCmd("dos2unix "+imgPath);
|
|
||||||
String status=shUtil(shPath,patientScript);
|
|
||||||
|
|
||||||
//再处理图片的生成
|
if (!patientScript.getType().equals("mri")){
|
||||||
//处理脚本文件格式
|
String unique_id = generateOtp();
|
||||||
|
String playground = "playground"+unique_id;
|
||||||
|
String format = DateUtil.format(new Date(), "yyyy-MM-dd");
|
||||||
|
//判断是zip还是rar
|
||||||
|
if (patientScript.getFilePath().endsWith(".zip")){
|
||||||
|
unzip(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据");
|
||||||
|
}else if (patientScript.getFilePath().endsWith(".rar")){
|
||||||
|
unRar(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据",null);
|
||||||
|
}
|
||||||
|
Map<String, Object> shMap = new LinkedHashMap<>();
|
||||||
|
shMap.put("outPath",format+"/output-"+unique_id);
|
||||||
|
shMap.put("filePath", patientScript.getFilePath());
|
||||||
|
shMap.put("subId",unique_id);
|
||||||
|
shMap.put("playground",format+"/"+playground);
|
||||||
|
shMap.put("fmriFileMb",format+"/"+playground+"/preprocessed/sub-001/func/sub-001_task-rest_space-MNI152NLin2009cAsym_boldref.nii.gz");
|
||||||
|
shMap.put("fmriRegOutFile",format+"/output-"+unique_id+"/bold_2_struct.mat");
|
||||||
|
shMap.put("fmriFileDpp",format+"/"+playground+"/preprocessed/sub-001/func/sub-001_task-rest_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz");
|
||||||
|
shMap.put("fmriR2t1OutFile",format+"/output-"+unique_id+"/reg2_Template.nii.gz");
|
||||||
|
shMap.put("smriFileMb",format+"/"+playground+"/preprocessed/sub-001/anat/sub-001_space-MNI152NLin2009cAsym_desc-preproc_T1w.nii.gz");
|
||||||
|
shMap.put("smriOutFile",format+"/output-"+unique_id+"/anat2_Template.nii.gz");
|
||||||
|
String fmriOutPath = "/data/"+format+"/output-"+unique_id+"/fmriOut/";
|
||||||
|
shMap.put("fmriOutPath",fmriOutPath);
|
||||||
|
shMap.put("matrixPath","/data/"+format+"/output-"+unique_id+"/");
|
||||||
|
String shPath="/data/"+format+"/cpac"+"-"+unique_id+".sh";
|
||||||
|
String dealDataSh="/data/"+format+"/dealData"+"-"+unique_id+".sh";
|
||||||
|
String imgPath="/data/"+format+"/img"+"-"+unique_id+".sh";
|
||||||
|
String alignPath="/data/"+format+"/align"+"-"+unique_id+".py";
|
||||||
|
shMap.put("alignPath",alignPath);
|
||||||
|
shMap.put("fucDataPath",format+"/output-"+unique_id+"/reg2_Template.nii.gz");
|
||||||
|
//创建alignPy
|
||||||
|
createFile(shMap, alignPath,"alignTemplate.ftl");
|
||||||
|
//创建处理数据脚本
|
||||||
|
createFile(shMap, dealDataSh,"dealData.ftl");
|
||||||
|
//创建图片生成脚本
|
||||||
|
createFile(shMap, imgPath,"imgSh.ftl");
|
||||||
|
//创建路径
|
||||||
|
File folder = new File(fmriOutPath);
|
||||||
|
if (!folder.exists()) { // 检查文件夹是否已存在
|
||||||
|
boolean created = folder.mkdirs(); // 创建文件夹
|
||||||
|
if (created) {
|
||||||
|
System.out.println("文件夹创建成功!");
|
||||||
|
} else {
|
||||||
|
System.out.println("文件夹创建失败!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("文件夹已存在,无需再次创建!");
|
||||||
|
}
|
||||||
|
//处理数据处理格式
|
||||||
|
ShellUtil.execCmd("dos2unix "+dealDataSh);
|
||||||
|
shUtil(dealDataSh,patientScript);
|
||||||
|
if (StringUtils.isEmpty(patientScript.getPatientAge())){
|
||||||
|
patientScript.setPatientAge("0");
|
||||||
|
}
|
||||||
|
shMap.put("tr",patientScript.getRepetitionTime());
|
||||||
|
shMap.put("age",patientScript.getPatientAge());
|
||||||
|
//创建总脚本
|
||||||
|
createFile(shMap, shPath,"cpacSh.ftl");
|
||||||
|
scriptMapper.updateStatus(patientScript);
|
||||||
|
//处理脚本文件格式
|
||||||
|
ShellUtil.execCmd("dos2unix "+shPath);
|
||||||
|
ShellUtil.execCmd("dos2unix "+imgPath);
|
||||||
|
String status=shUtil(shPath,patientScript);
|
||||||
|
|
||||||
ShellUtil.execCmd("sh "+imgPath);
|
//再处理图片的生成
|
||||||
//处理脑区信息
|
//处理脚本文件格式
|
||||||
patientScript.setResImage("/data/"+format+"/output-"+unique_id+"/Net.jpg");
|
|
||||||
patientScript.setStatus(status);
|
|
||||||
scriptMapper.updateStatus(patientScript);
|
|
||||||
|
|
||||||
}
|
ShellUtil.execCmd("sh "+imgPath);
|
||||||
}catch (Exception e){
|
//处理脑区信息
|
||||||
log.error(e.getMessage());
|
patientScript.setResImage("/data/"+format+"/output-"+unique_id+"/Net.jpg");
|
||||||
patientScript.setStatus("生成异常");
|
patientScript.setStatus(status);
|
||||||
scriptMapper.updateStatus(patientScript);
|
scriptMapper.updateStatus(patientScript);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage());
|
||||||
|
patientScript.setStatus("生成异常");
|
||||||
|
scriptMapper.updateStatus(patientScript);
|
||||||
|
}finally {
|
||||||
|
if (patientScript.getStatus().equals("生成中")){
|
||||||
|
patientScript.setStatus("生成异常");
|
||||||
|
}
|
||||||
|
scriptMapper.updateStatus(patientScript);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@ -703,7 +702,7 @@ public class PatientScriptServiceImpl implements PatientScriptService {
|
|||||||
|
|
||||||
// 每半小时执行一次
|
// 每半小时执行一次
|
||||||
@Scheduled(cron = "0 0/3 * * * ?")
|
@Scheduled(cron = "0 0/3 * * * ?")
|
||||||
public void scanData() throws IOException, InterruptedException {
|
public void scanData() throws IOException, InterruptedException, TemplateException {
|
||||||
PatientScript patientScript =new PatientScript();
|
PatientScript patientScript =new PatientScript();
|
||||||
patientScript.setStatus("生成中");
|
patientScript.setStatus("生成中");
|
||||||
List<PatientScript> patientScripts = scriptMapper.selectList(patientScript);
|
List<PatientScript> patientScripts = scriptMapper.selectList(patientScript);
|
||||||
|
@ -8,7 +8,7 @@ import java.io.*;
|
|||||||
|
|
||||||
public class ShellUtil {
|
public class ShellUtil {
|
||||||
|
|
||||||
public static String shUtil(String commandStr,PatientScript patientScript) throws IOException, InterruptedException {
|
public static String shUtil(String commandStr,PatientScript patientScript) throws Exception {
|
||||||
String resInfo="异常";
|
String resInfo="异常";
|
||||||
System.out.println("commandStr: " + commandStr);
|
System.out.println("commandStr: " + commandStr);
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(commandStr);
|
ProcessBuilder processBuilder = new ProcessBuilder(commandStr);
|
||||||
@ -82,6 +82,11 @@ public class ShellUtil {
|
|||||||
resInfo= "正常";
|
resInfo= "正常";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (line.contains("检查数据完整性")){
|
||||||
|
throw new Exception("生成异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="scanTime" column="scan_time" />
|
<result property="scanTime" column="scan_time" />
|
||||||
<result property="scanPosition" column="scan_position" />
|
<result property="scanPosition" column="scan_position" />
|
||||||
<result property="scanDoctor" column="scan_doctor" />
|
<result property="scanDoctor" column="scan_doctor" />
|
||||||
<result property="filePath" column="filePath" />
|
<result property="filePath" column="file_path" />
|
||||||
<result property="repetitionTime" column="repetition_time" />
|
<result property="repetitionTime" column="repetition_time" />
|
||||||
<result property="scanningOrder" column="scanning_order" />
|
<result property="scanningOrder" column="scanning_order" />
|
||||||
<result property="sliceNumber" column="slice_number" />
|
<result property="sliceNumber" column="slice_number" />
|
||||||
|
Loading…
Reference in New Issue
Block a user