|
|
|
|
@ -13,13 +13,14 @@ import com.zhehekeji.web.pojo.stock.StockExportExcel;
|
|
|
|
|
import com.zhehekeji.web.service.StockService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
|
|
import org.springframework.util.ResourceUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
@ -43,6 +44,28 @@ public class StockController {
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/export/model")
|
|
|
|
|
@ApiOperation(value = "库存模板下载")
|
|
|
|
|
public void download(HttpServletResponse response) throws IOException {
|
|
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
|
|
byte[] buffer = new byte[4096];
|
|
|
|
|
int n;
|
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
|
|
|
|
String fileName = URLEncoder.encode("库存模板", "UTF-8");
|
|
|
|
|
response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx");
|
|
|
|
|
ClassPathResource classPathResource = new ClassPathResource("库存模板.xlsx");
|
|
|
|
|
InputStream in = classPathResource.getInputStream();
|
|
|
|
|
while ((n = in.read(buffer)) > 0) {
|
|
|
|
|
os.write(buffer, 0, n);
|
|
|
|
|
}
|
|
|
|
|
os.flush();
|
|
|
|
|
os.close();
|
|
|
|
|
response.flushBuffer();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
@ApiOperation(value = "盘点页面 返回map key:货架号 value:库存信息")
|
|
|
|
|
public Result<Map<String, List<Stock>>> stockByStreet(@RequestParam(required = true) Integer streetId) {
|
|
|
|
|
|