|
|
|
@ -14,7 +14,13 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
@ -35,7 +41,7 @@ public class DepositoryRecordController { |
|
|
|
private MaterialService materialService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CompanyService companyService; |
|
|
|
private ExcelService excelService; |
|
|
|
@Autowired |
|
|
|
private RedisTemplate<String, String> redisTemplateForHash; |
|
|
|
@Autowired |
|
|
|
@ -1554,4 +1560,55 @@ public class DepositoryRecordController { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用于下载待打印出库订单
|
|
|
|
@GetMapping("/downloadOutRecord") |
|
|
|
public void downloadOutRecord(@RequestParam Map<String,Object> map, HttpServletRequest request, HttpServletResponse response){ |
|
|
|
String token = request.getHeader("user-token"); |
|
|
|
if (token == null) { |
|
|
|
token = (String) request.getSession().getAttribute("userToken"); |
|
|
|
} |
|
|
|
UserByPort userToken = AuthenticationTokenPool.getUserToken(token); |
|
|
|
if(map.containsKey("id")){ |
|
|
|
Integer id = ObjectFormatUtil.toInteger(map.get("id")); |
|
|
|
List<String> strings = excelService.writeExcelForPrint(id, 4, userToken); |
|
|
|
List<File> files = new ArrayList<>(); |
|
|
|
for (String string : strings) { |
|
|
|
File file = new File(string); |
|
|
|
files.add(file); |
|
|
|
} |
|
|
|
ZipMultiFileUtil.zipDownload(response,"出库订单.zip",files); |
|
|
|
ZipMultiFileUtil.deleteFile(files); |
|
|
|
/*try { |
|
|
|
|
|
|
|
String path = "static/upload/materialTypeImport.xlsx"; |
|
|
|
|
|
|
|
String fileName = "materialTypeImport.xlsx"; |
|
|
|
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); |
|
|
|
response.setContentType("content-type:octet-stream"); |
|
|
|
*//* .getClassLoader() 方法是在静态文件路径添加一个/ *//*
|
|
|
|
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(path); |
|
|
|
OutputStream outputStream = response.getOutputStream(); |
|
|
|
try { |
|
|
|
byte[] buffer = new byte[1024]; |
|
|
|
int len; |
|
|
|
assert inputStream != null; |
|
|
|
while ((len = inputStream.read(buffer)) != -1) { *//* 将流中内容写出去 .*//*
|
|
|
|
outputStream.write(buffer, 0, len); |
|
|
|
} |
|
|
|
}catch (IOException e){ |
|
|
|
e.printStackTrace(); |
|
|
|
}finally { |
|
|
|
assert inputStream != null; |
|
|
|
inputStream.close(); |
|
|
|
outputStream.close(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
}*/ |
|
|
|
}else{ |
|
|
|
throw new MyException("缺少必要参数"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|