Commit b53bc006 authored by jiaorz's avatar jiaorz

修改交还车列表bug

parent 465f130c
......@@ -26,10 +26,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
......@@ -362,14 +360,31 @@ public class VehicleCountRecordBiz extends BaseBiz<VehicleCountRecordMapper, Veh
}
}
public void export(ExcelParamDto excelParamDto) {
public void export(HttpServletResponse response, ExcelParamDto excelParamDto) {
ExcelExport ee1 = new ExcelExport();
ee1.addSheetByArray(excelParamDto.getName(), excelParamDto.getData(), excelParamDto.getHeader());
OutputStream fis;
try {
fis = new FileOutputStream("D:\\" + excelParamDto.getName() + ".xlsx");
fis = new FileOutputStream( "/data/temp/"+ excelParamDto.getName() + ".xlsx");
ee1.getWorkbook().write(fis);
// 下载本地文件
String fileName = excelParamDto.getName() + ".xlsx"; // 文件的默认保存名
// 读到流中
InputStream inStream = new FileInputStream("d:/" + fileName);// 文件的存放路径
// 设置输出的格式
response.reset();
response.setContentType("bin");
response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
// 循环取出流中的数据
byte[] b = new byte[100];
int len;
try {
while ((len = inStream.read(b)) > 0)
response.getOutputStream().write(b, 0, len);
inStream.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
......
......@@ -7,6 +7,8 @@ import com.xxfc.platform.vehicle.pojo.ExcelParamDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
@RestController
@RequestMapping(value = "/vehicleCount")
public class VehicleCountRecordController {
......@@ -26,8 +28,8 @@ public class VehicleCountRecordController {
}
@PostMapping("/app/unauth/export")
public ObjectRestResponse export(@RequestBody ExcelParamDto excelParamDto) {
vehicleCountRecordBiz.export(excelParamDto);
public ObjectRestResponse export(HttpServletResponse response, @RequestBody ExcelParamDto excelParamDto) {
vehicleCountRecordBiz.export(response, excelParamDto);
return ObjectRestResponse.succ();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment