采购开票文件名字修改

product
chuang 2 years ago
parent 217aba12f4
commit 1ded097a61

@ -49,9 +49,9 @@ public interface PurchaseorderitemService extends IService<PurchaseorderitemEnti
List<PurchasebackitemEntity> GetPurchasebackitemList(String id); List<PurchasebackitemEntity> GetPurchasebackitemList(String id);
List<CollectionpoEntity> GetCollectionitemList(String id); List<CollectionpoEntity> GetCollectionitemList(String id);
void getVehicle(List<HashMap<String, Object>> vehicleInfo, String templateFilePath) throws Exception; void getVehicle(List<HashMap<String, Object>> vehicleInfo, String templateFilePath,String settlements) throws Exception;
void getZIP(String templateFilePath, HttpServletResponse response) throws Exception; void getZIP(String templateFilePath, HttpServletResponse response,String settlements) throws Exception;
Map<String, Object> importPreview(List<PurchaseorderDTO> purchaseorderList); Map<String, Object> importPreview(List<PurchaseorderDTO> purchaseorderList);

@ -149,9 +149,9 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
@Autowired @Autowired
private Receiptin_item0Service receiptin_item0Service; private Receiptin_item0Service receiptin_item0Service;
public void getExcel(List<HashMap<String, Object>> list, String templateFilePath) throws Exception { public void getExcel(List<HashMap<String, Object>> list, String templateFilePath,String settlements) throws Exception {
//声明要创建的文件名 //声明要创建的文件名
String filename = templateFilePath + "\\废钢收货明细表.xls"; String filename = templateFilePath + "\\废钢收货明细表("+settlements+"吨).xls";
//创建 HSSFWorkbook 类的实例 //创建 HSSFWorkbook 类的实例
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream(filename); FileOutputStream fileOut = new FileOutputStream(filename);
@ -430,7 +430,7 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
* @param templateFilePath * @param templateFilePath
* @throws Exception * @throws Exception
*/ */
public void getPdf(LambdaQueryWrapper<PurchaseorderitemEntity> wrapper, String templateFilePath) throws Exception { public void getPdf(LambdaQueryWrapper<PurchaseorderitemEntity> wrapper, String templateFilePath,String settlements) throws Exception {
for (HashMap<String, Object> orderMap : purchaseorderitemMapper.getPdfInfo(wrapper)) { for (HashMap<String, Object> orderMap : purchaseorderitemMapper.getPdfInfo(wrapper)) {
byte[] bytes = null; byte[] bytes = null;
HttpHeaders headers = null; HttpHeaders headers = null;
@ -460,7 +460,7 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
// word模板 // word模板
out = exportPdf.createPdf(map, "test.ftl", "/templates/export"); out = exportPdf.createPdf(map, "test.ftl", "/templates/export");
bytes = out.toByteArray(); bytes = out.toByteArray();
String fileName = "废钢采购订单(" + map.get("supplierName") + ").pdf"; String fileName = "废钢采购订单(" + map.get("supplierName") + settlements+").pdf";
// fileName = URLEncoder.encode(fileName, "utf-8"); // fileName = URLEncoder.encode(fileName, "utf-8");
// 存在本地文件中 // 存在本地文件中
@ -509,7 +509,7 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
* @throws Exception * @throws Exception
* @TODO word * @TODO word
*/ */
public void getWord(List<HashMap<String, Object>> list, String templateFilePath) throws Exception { public void getWord(List<HashMap<String, Object>> list, String templateFilePath,String settlements) throws Exception {
// 创建一个新的word文件 // 创建一个新的word文件
Document document = new Document(); Document document = new Document();
Section section = document.addSection(); Section section = document.addSection();
@ -579,7 +579,7 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
} }
} }
//生成word文档 //生成word文档
document.saveToFile(templateFilePath + "废钢收获榜单照片(" + titleStr + ").docx", FileFormat.Docx_2013); document.saveToFile(templateFilePath + "废钢收获榜单照片(" + titleStr +settlements+"吨).docx", FileFormat.Docx_2013);
document.close(); document.close();
log.warn("word文档生成成功"); log.warn("word文档生成成功");
} }
@ -599,11 +599,11 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
List<HashMap<String, Object>> vehicleInfo = purchaseorderitemMapper.getVehicleInfo(wrapper); List<HashMap<String, Object>> vehicleInfo = purchaseorderitemMapper.getVehicleInfo(wrapper);
List<HashMap<String, Object>> titleInfo = purchaseorderitemMapper.getTitleInfo(wrapper); List<HashMap<String, Object>> titleInfo = purchaseorderitemMapper.getTitleInfo(wrapper);
String settlement = String.valueOf(titleInfo.get(0).get("settlement")); String settlement = String.valueOf(titleInfo.get(0).get("settlement"));
this.getPdf(wrapper, templateFilePath); this.getPdf(wrapper, templateFilePath,settlement);
this.getWord(info, templateFilePath); this.getWord(info, templateFilePath,settlement);
this.getExcel(info, templateFilePath); this.getExcel(info, templateFilePath,settlement);
this.getVehicle(vehicleInfo, templateFilePath); this.getVehicle(vehicleInfo, templateFilePath,settlement);
this.getZIP(templateFilePath, response); this.getZIP(templateFilePath, response,settlement);
} else { } else {
log.error("采购订单号出错!查不到该采购订单!"); log.error("采购订单号出错!查不到该采购订单!");
} }
@ -1245,7 +1245,7 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
} }
@Override @Override
public void getVehicle(List<HashMap<String, Object>> vehicleInfo, String templateFilePath) throws Exception { public void getVehicle(List<HashMap<String, Object>> vehicleInfo, String templateFilePath,String settlements) throws Exception {
// BufferedInputStream input = null; // BufferedInputStream input = null;
// BufferedOutputStream out = null; // BufferedOutputStream out = null;
if (vehicleInfo != null && vehicleInfo.size() > 0) { if (vehicleInfo != null && vehicleInfo.size() > 0) {
@ -1264,14 +1264,14 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
String s1 = (i+1) + "-" + s2 + s3 + s4; String s1 = (i+1) + "-" + s2 + s3 + s4;
File outImg = new File(templateFilePath + "vehicle\\" + s1 + "\\" + UUID.randomUUID().toString().replaceAll("-", "") + ".png"); File outImg = new File(templateFilePath + "车辆信息照片"+settlements+"吨\\" + s1 + "\\" + UUID.randomUUID().toString().replaceAll("-", "") + ".png");
File parentFile = outImg.getParentFile(); File parentFile = outImg.getParentFile();
if (!parentFile.exists()) { if (!parentFile.exists()) {
parentFile.mkdirs(); parentFile.mkdirs();
} }
// log.warn(templateFilePath+s1+"\\"+"vehicle\\"+ UUID.randomUUID().toString().replaceAll("-", "")+".png"); // log.warn(templateFilePath+s1+"\\"+"vehicle\\"+ UUID.randomUUID().toString().replaceAll("-", "")+".png");
// //
FileCopy.copyFile(vehicleImg, templateFilePath + "vehicle\\" + s1 + "\\"); FileCopy.copyFile(vehicleImg, templateFilePath + "车辆信息照片"+settlements+"吨\\" + s1 + "\\");
// input = new BufferedInputStream(new FileInputStream(vehicleImg)); // input = new BufferedInputStream(new FileInputStream(vehicleImg));
// out = new BufferedOutputStream(new FileOutputStream(outImg)); // out = new BufferedOutputStream(new FileOutputStream(outImg));
// byte[] bys = new byte[1024]; // byte[] bys = new byte[1024];
@ -1290,7 +1290,7 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
} }
@Override @Override
public void getZIP(String templateFilePath, HttpServletResponse response) throws Exception { public void getZIP(String templateFilePath, HttpServletResponse response,String settlements) throws Exception {
OutputStream toClient = null; OutputStream toClient = null;
String s = null; String s = null;
File file1 = null; File file1 = null;
@ -1312,7 +1312,7 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
fis.read(buffer); fis.read(buffer);
fis.close(); fis.close();
response.reset(); response.reset();
String excelTitle = "历史数据"; String excelTitle = settlements+"吨收货资料";
String fileName = URLEncoder.encode(excelTitle, "UTF-8").replaceAll("\\+", "%20"); String fileName = URLEncoder.encode(excelTitle, "UTF-8").replaceAll("\\+", "%20");
// 设置response的Header // 设置response的Header
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".zip"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".zip");

Loading…
Cancel
Save