修复 文件不能存在
This commit is contained in:
parent
b391148e26
commit
01ab7a07f7
|
|
@ -42,6 +42,7 @@ public class KeywordSearchHandler {
|
|||
Page page = new Page();
|
||||
page.setSize(maxCount);
|
||||
LambdaQueryWrapper<ProductInfoDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.select(ProductInfoDO::getCode, ProductInfoDO::getBrandId,BaseDO::getDeleted);
|
||||
if(FuncUtil.isNotEmpty(keyword)){
|
||||
queryWrapper.like(ProductInfoDO::getCode, keyword);
|
||||
}
|
||||
|
|
@ -49,7 +50,7 @@ public class KeywordSearchHandler {
|
|||
queryWrapper.eq(ProductInfoDO::getBrandId, filter);
|
||||
}
|
||||
queryWrapper.eq(BaseDO::getDeleted,false);
|
||||
queryWrapper.groupBy(ProductInfoDO::getCode);
|
||||
queryWrapper.groupBy(ProductInfoDO::getCode,BaseDO::getDeleted,ProductInfoDO::getBrandId);
|
||||
Page<ProductInfoDO> page1 = productInfoMapper.selectPage(page, queryWrapper);
|
||||
List<ProductInfoDO> records = page1.getRecords();
|
||||
List<KeywordResultVO> res = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -1259,31 +1259,36 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
throw exception(ErrorCodeConstants.SALE_ORDER_NOT_FILE_EXPORT);
|
||||
}
|
||||
|
||||
String zipFileName = StrUtil.format(pathUrl + "/订单稿件_{}", new Date().getTime());
|
||||
String zipFileName = StrUtil.format(targetPath + "/订单稿件_{}.zip", new Date().getTime());
|
||||
|
||||
// 压缩到的位置
|
||||
File zipFile = new File(zipFileName + ".zip");
|
||||
File zipFile = new File(zipFileName);
|
||||
if(zipFile.exists()){
|
||||
System.out.println("文件:"+zipFileName);
|
||||
ZipUtil.zip(zipFile, false, files.toArray(new File[files.size()]));
|
||||
|
||||
ZipUtil.zip(zipFile, false, files.toArray(new File[files.size()]));
|
||||
// 设置响应类型
|
||||
//response.setContentType("application/pdf");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(zipFile.getName(), "UTF-8"));
|
||||
|
||||
// 设置响应类型
|
||||
//response.setContentType("application/pdf");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(zipFile.getName(), "UTF-8"));
|
||||
|
||||
// 输出PDF到响应输出流
|
||||
// 将文件内容写入响应流
|
||||
try (InputStream inputStream = new FileInputStream(zipFile)) {
|
||||
IoUtil.copy(inputStream, response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
// 异常处理
|
||||
log.info("导出销售合约写入流失败,{}", e.getMessage());
|
||||
}
|
||||
// 导出完删除
|
||||
delFiles.add(zipFileName);
|
||||
for (String delFile : delFiles) {
|
||||
FileUtil.del(delFile);
|
||||
// 输出PDF到响应输出流
|
||||
// 将文件内容写入响应流
|
||||
try (InputStream inputStream = new FileInputStream(zipFile)) {
|
||||
IoUtil.copy(inputStream, response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
// 异常处理
|
||||
log.info("写入流失败,{}", e.getMessage());
|
||||
}
|
||||
// 导出完删除
|
||||
delFiles.add(zipFileName);
|
||||
for (String delFile : delFiles) {
|
||||
FileUtil.del(delFile);
|
||||
}
|
||||
}else {
|
||||
System.out.println("文件不存在");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue