From 2e8dbfd630915a262bebc18ab1272af6f6be5760 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期三, 20 五月 2026 16:32:41 +0800
Subject: [PATCH] yxh,java1.8适配

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceEthicalreviewopinionsController.java |   37 ++++++++++++++++++++++++++-----------
 1 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceEthicalreviewopinionsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceEthicalreviewopinionsController.java
index 1aa846f..a5abf64 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceEthicalreviewopinionsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceEthicalreviewopinionsController.java
@@ -31,12 +31,14 @@
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.poi.ss.formula.functions.Now;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.io.*;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.*;
 
@@ -186,31 +188,36 @@
      */
     @ApiOperation("閬椾綋鍣ㄥ畼鑾峰彇浼︾悊瀹℃煡琛�")
     @GetMapping(value = "/download")
-    public Result downloadInfo(String nitiateId) throws IOException {
-        if(ObjectUtils.isEmpty(nitiateId)){
+    public Result downloadInfo(String initiateId) throws IOException {
+        if(ObjectUtils.isEmpty(initiateId)){
             return Result.error("nitiateId浼︾悊瀹℃煡id涓嶈兘涓虹┖");
         }
         EthicalReviewVO reviewVO =new EthicalReviewVO();
-        reviewVO.setNitiateId(nitiateId);
+        reviewVO.setNitiateId(initiateId);
         List<EthicalReviewVO> list = serviceEthicalreviewopinionsService.selectVOList(reviewVO);
         if(list.size()==0){
             return Result.error("浼︾悊瀹℃煡id鏃犵浉鍏虫暟鎹�");
         }
+        EthicalreviewopinionsStateTotalVO  stateTotalVO=serviceEthicalreviewopinionsService.stateTotalAll(initiateId);
         String filePath = getClass().getResource("/template/").getPath();
         if(filePath.substring(0,1).equals("/"))
             filePath=filePath.substring(1);
         String content ="";
         Template t = null;
         try {
-            content = Files.readString(Paths.get(filePath+"閬椾綋鍣ㄥ畼鑾峰彇浼︾悊瀹℃煡琛ㄩ椤�.xml"), StandardCharsets.UTF_8);
+//            content = Files.readString(Paths.get(filePath+"閬椾綋鍣ㄥ畼鑾峰彇浼︾悊瀹℃煡琛ㄩ椤�.xml"), StandardCharsets.UTF_8);
+            Path path = Paths.get(filePath + "閬椾綋鍣ㄥ畼鑾峰彇浼︾悊瀹℃煡琛ㄩ椤�.xml");
+            byte[] bytes = Files.readAllBytes(path);
+            content = new String(bytes, StandardCharsets.UTF_8);
             String name=list.get(0).getName()+"锛堜綇闄㈠彿锛�"+list.get(0).getInpatientno()+"锛�";
             content=content.replace("$name",name);//椤圭洰鍚嶇О
-            content=content.replace("$inCount","16");//鍒颁細濮斿憳
+
+            content=content.replace("$inCount",stateTotalVO.getInCount());//鍒颁細濮斿憳
             content=content.replace("$avoidCount","0");//鍥為伩濮斿憳
-            content=content.replace("$agreeCount","15");//鍚屾剰
-            content=content.replace("$updateAgreeCount","2");//淇敼鍚庡悓鎰�
-            content=content.replace("$disagreeCount","3");//涓嶅悓鎰�
-            content=content.replace("$abstentionCount","4");//寮冩潈
+            content=content.replace("$agreeCount",stateTotalVO.getAgreeCount());//鍚屾剰
+            content=content.replace("$updateAgreeCount",stateTotalVO.getRejectCount());//淇敼鍚庡悓鎰�
+            content=content.replace("$disagreeCount",stateTotalVO.getDisagreeCount());//涓嶅悓鎰�
+            content=content.replace("$abstentionCount",stateTotalVO.getWaiveCount());//寮冩潈
             String committeeOpinion="";
             for (EthicalReviewVO row:list) {
                 String State="",sgin="",id=row.getId()+"",expName=row.getExpertname();
@@ -251,12 +258,13 @@
                         "        </w:tr>";
                }
             content=content.replace("$committeeOpinion",committeeOpinion);//濮斿憳浼氭剰瑙�
+            content=content.replace("$dateContent",DateUtils.parseDateToStr("yyyy骞碝M鏈坉d鏃�",new Date()));//鏃ユ湡
 
         } catch (Exception e) {
             e.printStackTrace();
         }
         String newTime = String.valueOf(Calendar.getInstance().getTimeInMillis());
-        String name = "閬椾綋鍣ㄥ畼鑾峰彇浼︾悊瀹℃煡琛╛"+nitiateId+"_" +  newTime;
+        String name = "閬椾綋鍣ㄥ畼鑾峰彇浼︾悊瀹℃煡琛╛"+initiateId+"_" +  newTime;
 
         String filePathData =RuoYiConfig.getProfile() + "/download/wordtemplate";
         //鍒涘缓鏂囦欢澶�
@@ -264,12 +272,19 @@
         if (!folderPath.exists()) {
             folderPath.mkdirs();
         }
-
+/*
         try {
             Files.writeString(Paths.get(filePathData+ "/" + name + ".doc"),content);
         } catch (Exception e1) {
             e1.printStackTrace();
         }
+*/
+        try {
+            Path path = Paths.get(filePathData + "/" + name + ".doc");
+            Files.write(path, content.getBytes(StandardCharsets.UTF_8));
+        } catch (Exception e1) {
+            e1.printStackTrace();
+        }
 
         Map<String, Object> map = new HashMap<>();
         map.put("downloadUrl", "/download/wordtemplate/" + name + ".doc");

--
Gitblit v1.9.3