diff --git a/ruoyi-admin/src/main/java/com/ruoyi/script/service/impl/PatientScriptServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/script/service/impl/PatientScriptServiceImpl.java index 11ffcc2..ce874bf 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/script/service/impl/PatientScriptServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/script/service/impl/PatientScriptServiceImpl.java @@ -14,28 +14,18 @@ import com.ruoyi.script.mapper.PatientScriptMapper; import com.ruoyi.script.service.PatientScriptService; import com.ruoyi.script.util.ShellUtil; import com.ruoyi.script.util.Word2PdfUtil; -import com.ruoyi.script.util.WordToPdfConverter; -import com.ruoyi.script.util.WorldToPdf; import lombok.SneakyThrows; -import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; -import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipFile; -import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.*; -import java.nio.channels.FileChannel; -import java.nio.channels.FileLock; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; @@ -44,8 +34,6 @@ import java.util.List; import java.util.concurrent.Executor; import static com.ruoyi.script.util.ShellUtil.shUtil; -import static com.ruoyi.script.util.WordToPdfConverter.convertToPdf; -import static com.ruoyi.script.util.WordToPdfConverter.replacePlaceholders; import static com.ruoyi.script.util.YmlUtil.createFile; import static com.ruoyi.system.util.pdfUtil.PdfUtil.chineseFont; import static com.ruoyi.system.util.pdfUtil.PdfUtil.getImageFromInputStream; @@ -947,22 +935,34 @@ public class PatientScriptServiceImpl implements PatientScriptService { } String resInfo = patientScript.getResInfo(); + String[] resList = resInfo.split("&*&*&"); String[] brainList ={}; //分类信息 Map<String,Integer> classMap = new HashMap<>(); - String[] correlationList ={}; + String[] StrongCorrelationList ={}; + String[] weakCorrelationList ={}; List<String> msgList = new ArrayList<>(); if (resInfo.contains("brain_regions:")){ - String[] split = resInfo.split("', '"); - String replace = split[0].replace("('brain_regions:", ""); + String[] split = resInfo.split("&*&*&"); + String replace = split[0].replace("brain_regions:", ""); brainList = replace.split(","); } - if (resInfo.contains("correlation:")){ - String[] split = resInfo.split("', '"); - String replace = split[1].replace("correlation:", "").replace("')",""); - correlationList = replace.split(","); + for (String tempStr : resList) { + if (tempStr.contains("correlation_enhanced:")){ + try { + String replace = tempStr.replace("correlation_enhanced:", ""); + StrongCorrelationList = replace.split(","); + }catch (Exception ignored){} + } + if (tempStr.contains("correlation_weakened:")){ + try { + String replace = tempStr.replace("correlation_weakened:", ""); + weakCorrelationList = replace.split(","); + }catch (Exception ignored){} + } } + for (String key : brainList) { key = key.replaceAll(" ",""); try { @@ -1028,31 +1028,36 @@ public class PatientScriptServiceImpl implements PatientScriptService { placeholders.put("brainInfo",brainInfo); - String joinInfo = ""; - for (int i = 0; i < correlationList.length; i++) { - if (i==correlationList.length-1){ - joinInfo= joinInfo+correlationList[i]; + String strongJoinInfo = ""; + for (int i = 0; i < StrongCorrelationList.length; i++) { + if (i==StrongCorrelationList.length-1){ + strongJoinInfo= strongJoinInfo+StrongCorrelationList[i]; }else { - joinInfo= joinInfo+correlationList[i]+"\n"; + strongJoinInfo= strongJoinInfo+StrongCorrelationList[i]+"\n"; } } - placeholders.put("joinInfo",joinInfo); - final String[] diagInfo = {""}; + + String weakJoinInfo = ""; + for (int i = 0; i < weakCorrelationList.length; i++) { + if (i==weakCorrelationList.length-1){ + weakJoinInfo= weakJoinInfo+weakCorrelationList[i]; + }else { + weakJoinInfo= weakJoinInfo+weakCorrelationList[i]+"\n"; + } + } + placeholders.put("strongJoinInfo",strongJoinInfo); + placeholders.put("weakJoinInfo",weakJoinInfo); + final String[] diagInfo = {"1.大脑解剖区域分布:"}; classMap.forEach((item, index)->{ diagInfo[0] = diagInfo[0] +index+"个属于"+item+","; }); int idx = diagInfo[0].lastIndexOf(","); diagInfo[0] = diagInfo[0].substring(0,idx); - diagInfo[0]=diagInfo[0]+"。"+"\n"; + diagInfo[0]=diagInfo[0]+"。"+"\n2.个体化大脑影像学差异的脑区功能解读: \n"; for (int i = 0; i < msgList.size(); i++) { - if (i==msgList.size()-1){ - diagInfo[0]= diagInfo[0]+" "+msgList.get(i); - }else { - diagInfo[0]= diagInfo[0]+" "+msgList.get(i)+"\n"; - } + diagInfo[0]= diagInfo[0]+" "+(i+1)+") "+msgList.get(i)+"\n"; } - placeholders.put("diagInfo", " 异常脑区中,"+diagInfo[0]); - placeholders.put("resInfo", patientScript.getResInfo().equals("异常")?"孤独症谱系障碍":"正常发育个体"); + placeholders.put("diagInfo", diagInfo[0]); placeholders.put("zdDoctor", patientScript.getZdDoctor()); placeholders.put("shDoctor", patientScript.getShDoctor()); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/script/util/ShellUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/script/util/ShellUtil.java index 87c4a6f..5005063 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/script/util/ShellUtil.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/script/util/ShellUtil.java @@ -25,10 +25,12 @@ public class ShellUtil { if (line.contains("brain_regions")||line.contains("correlation")){ String resInfo1 = patientScript.getResInfo(); - if (null==resInfo1){ - resInfo1=""; + if (StringUtils.isEmpty(resInfo1)){ + resInfo1=line; + }else{ + resInfo1=resInfo1+"&*&*&"+line; } - resInfo1=resInfo1+"&*&*&"+line; + patientScript.setResInfo(resInfo1); } if (line.contains("result===")){ diff --git a/ruoyi-admin/src/main/resources/static/mriTemp.docx b/ruoyi-admin/src/main/resources/static/mriTemp.docx index 0884d7a..540d446 100644 Binary files a/ruoyi-admin/src/main/resources/static/mriTemp.docx and b/ruoyi-admin/src/main/resources/static/mriTemp.docx differ