ke
2024-05-20 9de7f6c737a6370888564add8cc0e2be9f196329
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/word/controller/DownTemplateController.java
@@ -4,6 +4,7 @@
import cn.gistack.sm.sjztmd.util.MyDateUtils;
import cn.gistack.sm.sjztmd.word.service.ISjztmdService;
import cn.gistack.sm.sjztmd.word.util.BriefReportUtil;
import cn.gistack.sm.sjztmd.word.util.ExcelUtil;
import cn.gistack.sm.sjztmd.word.util.WordUtil;
import cn.gistack.sm.sjztmd.word.vo.*;
@@ -11,6 +12,7 @@
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -43,6 +45,13 @@
   private final ISjztmdService sjztmdService;
   @GetMapping(value = "/getBriefReport")
   public R getBriefReport() {
      //获取总览、大中库、明细数据
      List<TotalInfo> totalList = sjztmdService.getTotalInfo("");
      return R.data(BriefReportUtil.formatTotalInfo(totalList));
   }
   @GetMapping("/download/{resGuid}")
   public ResponseEntity genera(HttpServletResponse response, @PathVariable String resGuid) throws Exception {
      HashMap<String,Object> obj = sjztmdService.getTbWordVO(resGuid);
@@ -65,8 +74,8 @@
   @GetMapping("/download/overFloodInfo")
   public ResponseEntity overFloodInfo(String isShow) throws Exception{
      String time = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
      String fileName =  time+ "全省水库防汛情况.docx";
      String time = new SimpleDateFormat("yyyy日MM月dd日HH时").format(new Date());
      String fileName =  time+ "报汛文件.docx";
      String fileNameURL = URLEncoder.encode(fileName, "UTF-8");
      //获取总览、大中库、明细数据
      List<TotalInfo> totalList = sjztmdService.getTotalInfo(isShow);
@@ -102,7 +111,7 @@
      // 将临时文件添加到响应中,以便用户下载
      return ResponseEntity.ok()
         .contentType(MediaType.valueOf("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) // 设置响应的内容类型为二进制流(octet stream)
         .header("Content-Disposition", "attachment; filename=\"" + fileNameURL) // 设置响应的Content-Disposition头,以便浏览器提示用户下载文件
         .header("Content-Disposition", "attachment; filename=" + fileNameURL) // 设置响应的Content-Disposition头,以便浏览器提示用户下载文件
         .body(resource); // 将InputStreamResource对象作为响应体
   }