Commit f942a2f2 by levphon

工单相关-下载工单图片

1 parent 607ce2c9
...@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -57,6 +58,14 @@ public class WorkOrderController { ...@@ -57,6 +58,14 @@ public class WorkOrderController {
@ApiOperation(value = "工单照片导出") @ApiOperation(value = "工单照片导出")
@GetMapping(value = "/batchExportPics") @GetMapping(value = "/batchExportPics")
public void batchExportPics(HttpServletResponse response, WorkOrderSearch search) throws IOException { public void batchExportPics(HttpServletResponse response, WorkOrderSearch search) throws IOException {
String filename = new String(DateUtils.formatSerial(new Date()).getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + ".zip";
response.reset();
response.setHeader("Content-Disposition", "attachment;filename=" + filename);
response.setContentType("application/octet-stream; charset=utf-8");
response.setCharacterEncoding("UTF-8");
if (CollectionUtils.isEmpty(search.getOrderIds())) { if (CollectionUtils.isEmpty(search.getOrderIds())) {
throw new AdminException("参数为空"); throw new AdminException("参数为空");
} }
......
...@@ -38,6 +38,7 @@ import org.springframework.stereotype.Service; ...@@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -106,11 +107,18 @@ public class WorkOrderService { ...@@ -106,11 +107,18 @@ public class WorkOrderService {
List<WorkOrderDocs> woDocs = docsMap.get(wv.getWorkOrderId()); List<WorkOrderDocs> woDocs = docsMap.get(wv.getWorkOrderId());
String vinPath = wv.getVin() + File.separator;
ZipEntry vinDir = new ZipEntry(vinPath);
if (CollectionUtils.isNotEmpty(woDocs)) { if (CollectionUtils.isNotEmpty(woDocs)) {
zos.putNextEntry(vinDir);
for (WorkOrderDocs doc : woDocs) { for (WorkOrderDocs doc : woDocs) {
byte[] bytes = HttpUtils.downloadBytes(doc.getPath()); byte[] bytes = HttpUtils.downloadBytes(doc.getPath());
zos.putNextEntry(new ZipEntry(doc.getName())); zos.putNextEntry(new ZipEntry(vinPath + doc.getName()));
zos.write(bytes, 0, bytes.length); zos.write(bytes, 0, bytes.length);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!