模版下载

This commit is contained in:
jing's 2023-12-10 22:05:39 +08:00
parent 314f98c468
commit e9dbda664a
4 changed files with 36 additions and 15 deletions

View File

@ -25,6 +25,7 @@ import com.nflg.product.bomnew.service.aggreg.PublishMaterialService;
import io.swagger.annotations.ApiParam;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -32,10 +33,10 @@ import com.nflg.product.base.core.api.BaseApi;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@ -387,24 +388,36 @@ public class OptionalEbomApi extends BaseApi {
@GetMapping("downDeviceExcelTemplate")
@ApiOperation("导入数据模版下载")
public void downImportExcelTemplate(HttpServletResponse response ) throws Exception {
try {
//获取要下载的模板名称
String fileName = "importDataTemplate.xlsx";
EasyExcelUtil.setExportHeader(response,"移动破数据导入模版");
//模板文件存放路径
String filePath = getClass().getResource("/template/"+fileName).getPath();
//IO流处理模板
FileInputStream input = new FileInputStream(filePath);
OutputStream out = response.getOutputStream();
byte[] b = new byte[2048];
int len;
ClassPathResource resource = new ClassPathResource("template/importDataTemplate.xlsx");
InputStream input = resource.getInputStream();
EasyExcelUtil.setExportHeader(response,"移动破数据导入模版");
//IO流处理模板
OutputStream out = response.getOutputStream();
byte[] b = new byte[1024];
int len;
int size=0;
while ((len = input.read(b)) != -1) {
out.write(b,0,len);
size+=len;
}
//返回请求访问的结果
response.setHeader("Content-Length", String.valueOf(input.getChannel().size()));
response.setHeader("Content-Length", String.valueOf(size));
out.close();
input.close();
out.flush();
} catch (Exception e) {
}

View File

@ -53,6 +53,14 @@ public class ExportDeviceHelper {
}
public static class ColumnMergeStrategy implements CellWriteHandler {

View File

@ -17,11 +17,11 @@ public class OptionalMbomMaterialListQuery extends BasePageQuery implements S
@ApiModelProperty(value = "开始时间")
private Date startDate;
private String startDate;
@ApiModelProperty(value = "结束时间")
private Date endDate;
private String endDate;
/**
* 物料编码