| | |
| | | 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.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.util.*; |
| | | |
| | |
| | | if(list.size()==0){ |
| | | return Result.error("伦理审查id无相关数据"); |
| | | } |
| | | EthicalreviewopinionsStateTotalVO stateTotalVO=serviceEthicalreviewopinionsService.stateTotalAll(nitiateId); |
| | | 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(); |
| | | if(ObjectUtils.isNotEmpty(row.getSigin())){ |
| | | // byte[] imageBytes = Files.readAllBytes(Paths.get(row.getSigin())); |
| | | // sgin=Base64.getEncoder().encodeToString(imageBytes); |
| | | HttpURLConnection connection = null; |
| | | InputStream inputStream = null; |
| | | ByteArrayOutputStream outputStream = null; |
| | | try { |
| | | URL url = new URL(row.getSigin()); |
| | | connection = (HttpURLConnection) url.openConnection(); |
| | | connection.setRequestMethod("GET"); |
| | | connection.setConnectTimeout(5000); |
| | | connection.setReadTimeout(5000); |
| | | |
| | | if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { |
| | | sgin=""; |
| | | } |
| | | |
| | | inputStream = connection.getInputStream(); |
| | | outputStream = new ByteArrayOutputStream(); |
| | | |
| | | byte[] buffer = new byte[1024]; |
| | | int bytesRead; |
| | | while ((bytesRead = inputStream.read(buffer)) != -1) { |
| | | outputStream.write(buffer, 0, bytesRead); |
| | | } |
| | | |
| | | byte[] imageBytes = outputStream.toByteArray(); |
| | | sgin= Base64.getEncoder().encodeToString(imageBytes); |
| | | }catch (Exception e){ |
| | | sgin=""; |
| | | }finally { |
| | | if (inputStream != null) { |
| | | try { |
| | | inputStream.close(); |
| | | } catch (IOException e) { |
| | | |
| | | } |
| | | } |
| | | if (outputStream != null) { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | |
| | | } |
| | | } |
| | | if (connection != null) { |
| | | connection.disconnect(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | if(expName.length()==2) expName=expName.substring(0,1)+" "+expName.substring(1); |
| | | if(row.getReceiveStatus().equals("1"))State="已同意"; |
| | | else if(row.getReceiveStatus().equals("2")) State="不同意"; |
| | |
| | | " <w:tc><w:tcPr></w:tcPr>\n" + |
| | | " <w:p wsp:rsidR=\"00425E28\" wsp:rsidRPr=\"00CB3FB5\" wsp:rsidRDefault=\"00AC7CCA\" wsp:rsidP=\"00CB3FB5\">\n" + |
| | | " <w:r wsp:rsidRPr=\"00737357\">\n" + |
| | | " <w:t>【委员审批】"+expName+" "+State+" </w:t></w:r>\n" + |
| | | " <w:spacing w:line=\"480\" w:line-rule=\"auto\"/><w:t>【委员审批】"+expName+" "+State+" </w:t></w:r>\n" + |
| | | " </w:p>\n" + |
| | | " </w:tc>\n" + |
| | | " <w:tc><w:tcPr></w:tcPr>\n" + |
| | | " <w:p wsp:rsidR=\"00425E28\" wsp:rsidRPr=\"00CB3FB5\" wsp:rsidRDefault=\"00AC7CCA\" wsp:rsidP=\"00CB3FB5\">\n" + |
| | | " <w:r wsp:rsidRPr=\"00737357\">\n" + |
| | | " <w:t>签名:</w:t></w:r>\n" + |
| | | " <w:r wsp:rsidR=\"00421BE1\">\n" + |
| | | " <w:pict>\n" + |
| | | " <w:binData w:name=\"wordml://03000001.png\" xml:space=\"preserve\"> </w:binData>\n" + |
| | | " <v:shape style=\"width:50pt;height:20pt\"><v:imagedata src=\"wordml://03000001.png\" o:title=\"my签字\"/></v:shape>\n" + |
| | | " </w:pict>\n" + |
| | | " </w:r>\n" + |
| | | " <w:r wsp:rsidR=\"00421BE1\">\n" ; |
| | | if(sgin.length()>10) { |
| | | committeeOpinion +="<w:pict><w:binData w:name=\"wordml://03000001.png\" xml:space=\"preserve\">\n" + sgin + "\n" + |
| | | "</w:binData><v:shape style=\"width:50pt;height:20pt\"><v:imagedata src=\"wordml://03000001.png\" o:title=\"\"/></v:shape></w:pict>\n" ; |
| | | } |
| | | committeeOpinion += " </w:r>\n" + |
| | | " </w:p>\n" + |
| | | " </w:tc>\n" + |
| | | " <w:tc><w:tcPr></w:tcPr>\n" + |
| | | " <w:p wsp:rsidR=\"00425E28\" wsp:rsidRPr=\"00CB3FB5\" wsp:rsidRDefault=\"00AC7CCA\" wsp:rsidP=\"00CB3FB5\">\n" + |
| | | " <w:r wsp:rsidRPr=\"00737357\"><w:t>2026-05-18 15:36:01</w:t></w:r></w:p>\n" + |
| | | " <w:spacing w:line=\"480\" w:line-rule=\"auto\"/><w:r wsp:rsidRPr=\"00737357\"><w:t>"+DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",row.getConclusiontime())+"</w:t></w:r></w:p>\n" + |
| | | " </w:tc>\n" + |
| | | " </w:tr>"; |
| | | committeeOpinion += " <w:p wsp:rsidR=\"00EE26D5\" wsp:rsidRPr=\"00737357\" wsp:rsidRDefault=\"0030540D\" wsp:rsidP=\"00EE26D5\"><w:pPr><w:rPr><w:rFonts w:ascii=\"宋体\" w:h-ansi=\"宋体\" w:cs=\"宋体\"/><wx:font\n" + |
| | | " wx:val=\"宋体\"/><w:sz-cs w:val=\"21\"/></w:rPr></w:pPr>\n" + |
| | | " <w:r wsp:rsidR=\"00EE26D5\" wsp:rsidRPr=\"00737357\" >\n" + |
| | | " <v:shape style=\"width:500pt;\"> <w:t>【委员审批】"+expName+" "+State+" </w:t></v:shape></w:r>\n" + |
| | | " <w:r wsp:rsidR=\"00EE26D5\" wsp:rsidRPr=\"00737357\">\n" + |
| | | " <w:t> 签名:</w:t></w:r>\n" + |
| | | " <w:r wsp:rsidR=\"00EE26D5\" wsp:rsidRPr=\"00737357\">\n" + |
| | | " <w:pict>\n" + |
| | | " <w:binData w:name=\"wordml://img"+id+".png\" xml:space=\"preserve\">"+sgin+" </w:binData>\n" + |
| | | " <v:shape id=\"_x0000_"+id+"\" type=\"#_x0000_t75\" style=\"width:50pt;height:20pt\"><v:imagedata src=\"wordml://_x0000_"+id+".png\" o:title=\"签字\"/></v:shape></w:pict></w:r>\n" + |
| | | " <w:r wsp:rsidR=\"00737357\" wsp:rsidRPr=\"00737357\">\n" + |
| | | " <w:t> "+ DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",row.getConclusiontime())+"</w:t></w:r></w:p>"; |
| | | } |
| | | } |
| | | content=content.replace("$committeeOpinion",committeeOpinion);//委员会意见 |
| | | content=content.replace("$dateContent",DateUtils.parseDateToStr("yyyy年MM月dd日",new Date()));//日期 |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | 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"); |