| 
					
				 | 
			
			
				@@ -1,10 +1,12 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.jjt.biz.controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.deepoove.poi.XWPFTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.github.pagehelper.PageHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.biz.domain.BizModel; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.biz.domain.BizObj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.biz.service.IBizModelService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.biz.util.DataUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.jjt.biz.vo.CheckExportVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.biz.vo.CheckVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.biz.vo.ScoreVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.common.annotation.Log; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -25,6 +27,8 @@ import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.servlet.http.HttpServletResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.net.URLEncoder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.format.DateTimeFormatter; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -321,6 +325,42 @@ public class BizModelController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return AjaxResult.success(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiOperation("一健巡检--导出报告") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping("/check/export") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void checkExport(HttpServletResponse response) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CheckExportVO vo = new CheckExportVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        vo.mock(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 定义模板对应的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HashMap<String, Object> data = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        data.put("test", "测试dsx哈"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (int i = 1; i <= 28; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            data.put("l" + i, vo.getLeft()[i - 1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            data.put("r" + i, vo.getRight()[i - 1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 渲染模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("tpl/check.docx"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             OutputStream outputStream = new BufferedOutputStream(response.getOutputStream()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             ByteArrayOutputStream out = new ByteArrayOutputStream();) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 写出到文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            XWPFTemplate template = XWPFTemplate.compile(inputStream).render(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            template.writeAndClose(out); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 清空response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response.reset(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 设置response的Header 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response.setCharacterEncoding("UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //Content-Disposition的作用:告知浏览器以何种方式显示响应返回的文件,用浏览器打开还是以附件的形式下载到本地保存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //attachment表示以附件方式下载 inline表示在线打开 "Content-Disposition: inline; filename=文件名.mp3" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // filename表示文件的默认名称,因为网络传输只支持URL编码的相关支付,因此需要将文件名URL编码后进行传输,前端收到后需要反编码才能获取到真正的名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("新一代电力交易平台巡检报告" + DateUtils.dateTimeNow() + ".docx", "UTF-8")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response.setContentType("application/octet-stream"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            outputStream.write(out.toByteArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            outputStream.flush(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new RuntimeException(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ApiOperation("一健巡检--查看报告分类明细") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @GetMapping("/check/proj/{id}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public AjaxResult checkProj(@PathVariable("id") Long id) { 
			 |