From 8539cf87a03569783e05d544cf420696407cc3f3 Mon Sep 17 00:00:00 2001 From: 13405411873 <1994398261@qq.com> Date: Mon, 14 Apr 2025 23:42:59 +0800 Subject: [PATCH] =?UTF-8?q?bug=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PatientScriptController.java | 5 +- .../script/service/PatientScriptService.java | 3 + .../impl/PatientScriptServiceImpl.java | 67 +- .../mapper/system/PatientScriptMapper.xml | 1 + ruoyi-ui/src/views/system/shMenu/index.vue | 594 ++++++++++-------- 5 files changed, 390 insertions(+), 280 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/script/controller/PatientScriptController.java b/ruoyi-admin/src/main/java/com/ruoyi/script/controller/PatientScriptController.java index ca4366b..44e96da 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/script/controller/PatientScriptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/script/controller/PatientScriptController.java @@ -56,9 +56,8 @@ public class PatientScriptController extends BaseController { * @return 新增结果 */ @PostMapping("/add") - public AjaxResult insert(@RequestBody PatientScript patientScript) throws IOException, InterruptedException { - patientScript.setIsAll("1"); - return toAjax(this.patientScriptService.save(patientScript)); + public AjaxResult insert(@RequestBody List patientScripts) throws IOException, InterruptedException { + return toAjax(this.patientScriptService.saveBatch(patientScripts)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/script/service/PatientScriptService.java b/ruoyi-admin/src/main/java/com/ruoyi/script/service/PatientScriptService.java index 923ba53..7b54084 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/script/service/PatientScriptService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/script/service/PatientScriptService.java @@ -25,5 +25,8 @@ public interface PatientScriptService { void exportReport2(HttpServletResponse response, Long reportId) throws Exception; + Boolean saveBatch(List patientScripts) ; + + } 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 b186c70..926c4fb 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 @@ -1,5 +1,6 @@ package com.ruoyi.script.service.impl; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import com.deepoove.poi.XWPFTemplate; import com.deepoove.poi.data.Pictures; @@ -9,6 +10,7 @@ import com.itextpdf.text.pdf.BaseFont; import com.itextpdf.text.pdf.PdfChunk; import com.itextpdf.text.pdf.PdfContentByte; import com.itextpdf.text.pdf.PdfWriter; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.script.entity.MriInfo; import com.ruoyi.script.entity.PatientScript; import com.ruoyi.script.mapper.PatientScriptMapper; @@ -30,6 +32,7 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -185,26 +188,23 @@ public class PatientScriptServiceImpl implements PatientScriptService { @Override public Boolean save(PatientScript patientScript) throws IOException, InterruptedException { - patientScript.setCreateId(1110L); - patientScript.setCreateTime(new Date()); patientScript.setStatus("生成中"); - // 此处可以根据插入的实体信息,使用自己的方式获取生成的 ID 值 - scriptMapper.addData(patientScript); // 多任务同时处理 taskExecutor.execute(new Runnable() { @SneakyThrows @Override public void run() { - 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); - } + 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 shMap = new LinkedHashMap<>(); shMap.put("outPath",format+"/output-"+unique_id); shMap.put("filePath", patientScript.getFilePath()); @@ -269,6 +269,11 @@ public class PatientScriptServiceImpl implements PatientScriptService { scriptMapper.updateStatus(patientScript); } + }catch (Exception e){ + patientScript.setStatus("生成异常"); + scriptMapper.updateStatus(patientScript); + } + } }); @@ -680,6 +685,40 @@ public class PatientScriptServiceImpl implements PatientScriptService { } + + @Override + public Boolean saveBatch(List patientScripts) { + for (PatientScript patientScript : patientScripts) { + patientScript.setIsAll("1"); + patientScript.setStatus("待生成"); + patientScript.setCreateId(SecurityUtils.getUserId()); + patientScript.setCreateTime(new Date()); + scriptMapper.addData(patientScript); + } + return true; + } + + // 每半小时执行一次 + @Scheduled(cron = "0 0/3 * * * ?") + public void scanData() throws IOException, InterruptedException { + PatientScript patientScript =new PatientScript(); + patientScript.setStatus("生成中"); + List patientScripts = scriptMapper.selectList(patientScript); + if (CollectionUtil.isNotEmpty(patientScripts)){ + return; + } + PatientScript patientScript2 =new PatientScript(); + patientScript2.setStatus("待生成"); + List patientScriptList = scriptMapper.selectList(patientScript2); + //获取最后一个 + if (CollectionUtil.isNotEmpty(patientScriptList)){ + PatientScript patientScript1 = patientScriptList.get(patientScriptList.size() - 1); + this.save(patientScript1); + } + + + } + @Override public void exportReport(HttpServletResponse response, Long reportId) throws Exception { PatientScript patientScript = scriptMapper.getById(reportId); diff --git a/ruoyi-admin/src/main/resources/mapper/system/PatientScriptMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/PatientScriptMapper.xml index 5fbb438..a0ff002 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/PatientScriptMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/PatientScriptMapper.xml @@ -59,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and patient_card like concat('%',#{patientCard},'%') and scan_doctor like concat('%',#{scanDoctor},'%') and is_all= #{isAll} + and status= #{status} order by create_time desc diff --git a/ruoyi-ui/src/views/system/shMenu/index.vue b/ruoyi-ui/src/views/system/shMenu/index.vue index 38b612d..a12ea74 100644 --- a/ruoyi-ui/src/views/system/shMenu/index.vue +++ b/ruoyi-ui/src/views/system/shMenu/index.vue @@ -78,109 +78,141 @@ - - + +
+ + - - +
+
患者{{index+1}}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 删除 +
+
+
+ + 添加行 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - +
+ + - +