水质增加水质级别评定标准文件下载
parent
ecc01a9c28
commit
3e3944fa3d
|
|
@ -1,5 +1,6 @@
|
||||||
package com.gunshi.project.xyt.controller;
|
package com.gunshi.project.xyt.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.resource.ClassPathResource;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
|
@ -37,7 +38,15 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -180,4 +189,33 @@ public class OsmoticWaterRController {
|
||||||
List<OsmoticWaterRVo> vos = ConvertUtil.entityToVoList(this.list(osmoticWaterR).getData(), OsmoticWaterRVo.class);
|
List<OsmoticWaterRVo> vos = ConvertUtil.entityToVoList(this.list(osmoticWaterR).getData(), OsmoticWaterRVo.class);
|
||||||
ExcelUtil.exportExcel(vos, filename, OsmoticWaterRVo.class, response, "水质整编表");
|
ExcelUtil.exportExcel(vos, filename, OsmoticWaterRVo.class, response, "水质整编表");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "文件下载")
|
||||||
|
@PostMapping("/downloadFile")
|
||||||
|
@CrossOrigin
|
||||||
|
public void downloadFile(HttpServletResponse response) throws IOException {
|
||||||
|
ClassPathResource classPathResource = new ClassPathResource("/doc/2002年6月1日_GB3838-2002地表水环境质量标准.pdf");
|
||||||
|
File file = classPathResource.getFile();
|
||||||
|
if (!file.exists()) {
|
||||||
|
new IllegalArgumentException("文件不存在!");
|
||||||
|
}
|
||||||
|
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(file.getName(), "UTF-8"));
|
||||||
|
BufferedInputStream inputStream = null;
|
||||||
|
OutputStream outputStream = null;
|
||||||
|
try {
|
||||||
|
inputStream = new BufferedInputStream(new FileInputStream(file));
|
||||||
|
outputStream = response.getOutputStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len = 0;
|
||||||
|
while ((len = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
inputStream.close();
|
||||||
|
outputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue