From af432a8495b163da3bbdef7d7d6c44014396651f Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期六, 14 六月 2025 18:29:05 +0800 Subject: [PATCH] 跳转详情 --- src/main/java/com/whyc/service/BomAcceptanceService.java | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 156 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/whyc/service/BomAcceptanceService.java b/src/main/java/com/whyc/service/BomAcceptanceService.java index dd12aff..7a29d8a 100644 --- a/src/main/java/com/whyc/service/BomAcceptanceService.java +++ b/src/main/java/com/whyc/service/BomAcceptanceService.java @@ -21,8 +21,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.io.IOException; +import java.io.*; +import java.net.URLEncoder; import java.util.Date; import java.util.List; @@ -289,11 +289,11 @@ } //鐢熸垚excel private void creatBomAcceptanceExcel(HttpServletRequest req, HttpServletResponse resp, BomAcceptance bomAcceptance) { + String fileName="浜у搧楠屾敹淇℃伅璁板綍"; //鍒涘缓鍗曚釜sheet HSSFWorkbook wb = new HSSFWorkbook(); //瀛椾綋鏍煎紡-鍔犵矖 HSSFCellStyle cellStyle = wb.createCellStyle(); - cellStyle.setFillForegroundColor(IndexedColors.GOLD.getIndex());//娣诲姞鍓嶆櫙鑹�,鍐呭鐪嬬殑娓呮 cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); HSSFFont font = wb.createFont(); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); @@ -303,11 +303,162 @@ sheet.setDefaultRowHeight((short)(1000)); //鍥剧墖鍏冪礌 HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); - HSSFRow row=sheet.createRow(1); + int rowNum=0; + HSSFRow row=sheet.createRow(rowNum); HSSFCell cell=row.createCell(0); cell=row.createCell(0); cell.setCellValue("浜у搧楠屾敹淇℃伅璁板綍"); cell.setCellStyle(cellStyle); - } + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("鐮斿彂璐熻矗浜�"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getDirectName()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("浜у搧绯诲垪"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getBomSeries()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("浜у搧鍨嬪彿"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getBomModel()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("浜у搧鐗堟湰鍙�"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getBomVersion()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("鎶�鏈寚鏍�"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getDevParam()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("鎶�鏈寚鏍�"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getStandParam()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("闀縳瀹絰楂�(mm)"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getBomSize()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("涓绘満鍑�閲�(KG)"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getDevWeight()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("鏁存満鍏ㄩ噸(鍚寘瑁呯锛岄厤浠�)(KG)"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getDevWeightAll()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("涓绘満鐓х墖(宸︿晶鍥撅紝姝i潰鍥撅紝鍙充晶鍥撅紝鍚庨潰鍥�)"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getDevWeightAll()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("閰嶄欢鐓х墖"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getDevWeightAll()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("閰嶄欢鍨嬪彿瑙勬牸"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + cell.setCellValue(bomAcceptance.getSparePartmodel()); + cell.setCellStyle(cellStyle); + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("绔彛鍗忚鏂囨湰"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + String agreement=bomAcceptance.getBomAgreement(); + cell.setCellValue(agreement); + cell.setCellStyle(cellStyle); + //灏嗘枃浠跺瓨鍒版寚瀹氫綅缃� + OutputStream os = null; + try { + os = resp.getOutputStream(); + } catch (IOException e) { + e.printStackTrace(); + } + try { + resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode (fileName+ ".xls", "utf-8")); + resp.setCharacterEncoding("UTF-8"); + //涓嶄繚瀛樼紦瀛樹俊鎭笌response.reset鍚屾牱鏁堟灉 + resp.addHeader("Pragma", "no-cache"); + resp.addHeader("Cache-Control", "no-cache"); + wb.write(os); + os.flush(); + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + //璺宠浆璇︽儏 + public Response getBomAcceptanceByNum(int num) { + String rootFile = CommonUtil.getRootFile(); + //璇诲彇浜у搧淇℃伅 + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("num",num); + wrapper.last("limit 1"); + BomAcceptance bomAcceptance=mapper.selectOne(wrapper); + String filePath=rootFile+bomAcceptance.getSparePicpart(); + bomAcceptance.setSparePicpart("doc_file"+File.separator+bomAcceptance.getSparePicpart()); + //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚� + bomAcceptance.setNameList(FileUtil.getFileNameWithOutDirectory(filePath)); + return new Response().set(1,bomAcceptance,"璺宠浆璇︽儏"); + } } \ No newline at end of file -- Gitblit v1.9.1