From cf9a5039e6db9d1d5963e3fe1a37d00169ec2ef7 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期三, 25 六月 2025 11:18:22 +0800 Subject: [PATCH] 验收报告修改 --- src/main/java/com/whyc/service/BomAcceptanceService.java | 815 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 807 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/whyc/service/BomAcceptanceService.java b/src/main/java/com/whyc/service/BomAcceptanceService.java index 0b09f56..bf5844f 100644 --- a/src/main/java/com/whyc/service/BomAcceptanceService.java +++ b/src/main/java/com/whyc/service/BomAcceptanceService.java @@ -1,6 +1,7 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.whyc.dto.Response; @@ -8,14 +9,26 @@ import com.whyc.pojo.BOMFeedback; import com.whyc.pojo.BomAcceptance; import com.whyc.pojo.DefectiveProducts; +import com.whyc.pojo.ProductHistory; +import com.whyc.util.ActionUtil; import com.whyc.util.CommonUtil; import com.whyc.util.FileUtil; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.util.CellRangeAddress; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; -import java.io.File; -import java.io.IOException; +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.URLEncoder; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -28,8 +41,12 @@ //涓婁紶浜у搧楠屾敹淇℃伅 public Response uploadBomAcceptance(MultipartFile fileLeft, MultipartFile fileRight, MultipartFile fileFront, MultipartFile fileBack - ,MultipartFile Agreement, List<MultipartFile> multipartFileList, BomAcceptance bomAcceptance) throws IOException { + ,MultipartFile agreement,MultipartFile bomManual,MultipartFile testReport + ,MultipartFile icdFile,MultipartFile cadPicpart,MultipartFile namePlate + , List<MultipartFile> multipartFileList,List<MultipartFile> installCasePics + , BomAcceptance bomAcceptance) throws IOException { Date date = new Date(); + bomAcceptance.setCreateTime(date); long time = date.getTime(); String rootFile = CommonUtil.getRootFile(); //閰嶄欢瀛樺偍 @@ -52,6 +69,27 @@ } bomAcceptance.setSparePicpart(spareDirSuffix); } + //鐜板満瀹夎妗堜緥鐓х墖 + if(installCasePics!=null && installCasePics.size()!=0){ + String installCasePicDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "install" + File.separator; + String installCasePicDir = rootFile + installCasePicDirSuffix; + File fileDir = new File(installCasePicDir); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + for (int i = 0; i < installCasePics.size(); i++) { + MultipartFile multipartFile = installCasePics.get(i); + //瀛樺偍鏂囦欢 + String originalFilename = multipartFile.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String sparePath = installCasePicDir + fileName + suffix; + File file = new File(sparePath); + multipartFile.transferTo(file); + } + bomAcceptance.setInstallPic(installCasePicDirSuffix); + } + String devDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "dev" + File.separator; String devDir = rootFile + devDirSuffix; //宸﹁鍥� @@ -101,15 +139,80 @@ String agreeDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "agree" + File.separator; String agreeDir = rootFile + agreeDirSuffix; //鍗忚 - if(Agreement!=null){ + if(agreement!=null){ //瀛樺偍鏂囦欢 - String originalFilename = Agreement.getOriginalFilename(); + String originalFilename = agreement.getOriginalFilename(); String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); String path = agreeDir + fileName + suffix; createFilefolderIFNotExist(path); - Agreement.transferTo(new File(path)); + agreement.transferTo(new File(path)); bomAcceptance.setBomAgreement("doc_file" + File.separator + agreeDirSuffix+originalFilename); + } + String bomManualDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "bomManual" + File.separator; + String bomManualDir = rootFile + bomManualDirSuffix; + //璇存槑涔�(鏂囦欢) + if(bomManual!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = bomManual.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = bomManualDir + fileName + suffix; + createFilefolderIFNotExist(path); + bomManual.transferTo(new File(path)); + bomAcceptance.setBomManual("doc_file" + File.separator + bomManualDirSuffix+originalFilename); + } + String testReportDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "testReport" + File.separator; + String testReportDir = rootFile + testReportDirSuffix; + //妫�娴嬫姤鍛�(鏂囦欢) + if(testReport!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = testReport.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = testReportDir + fileName + suffix; + createFilefolderIFNotExist(path); + testReport.transferTo(new File(path)); + bomAcceptance.setTestReport("doc_file" + File.separator + testReportDirSuffix+originalFilename); + } + String icdFileDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "icdFile" + File.separator; + String icdFileDir = rootFile + icdFileDirSuffix; + //ICD鏂囦欢 + if(icdFile!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = icdFile.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = icdFileDir + fileName + suffix; + createFilefolderIFNotExist(path); + icdFile.transferTo(new File(path)); + bomAcceptance.setIcdFile("doc_file" + File.separator + icdFileDirSuffix+originalFilename); + } + String cadPicpartDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "cadPicpart" + File.separator; + String cadPicpartDir = rootFile + cadPicpartDirSuffix; + //鏂藉伐鍥剧焊(鏂囦欢) + if(cadPicpart!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = cadPicpart.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = cadPicpartDir + fileName + suffix; + createFilefolderIFNotExist(path); + cadPicpart.transferTo(new File(path)); + bomAcceptance.setCadPicpart("doc_file" + File.separator + cadPicpartDirSuffix+originalFilename); + } + String namePlateDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "namePlate" + File.separator; + String namePlateDir = rootFile + namePlateDirSuffix; + //閾墝淇℃伅(鏂囦欢) + if(namePlate!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = namePlate.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = namePlateDir + fileName + suffix; + createFilefolderIFNotExist(path); + namePlate.transferTo(new File(path)); + bomAcceptance.setNamePlate("doc_file" + File.separator + namePlateDirSuffix+originalFilename); } mapper.insert(bomAcceptance); return new Response().set(1,true,"涓婁紶鎴愬姛"); @@ -127,23 +230,719 @@ if(bomAcceptance.getBomModel()!=null){ wrapper.like("bom_model",bomAcceptance.getBomModel()); } + if(bomAcceptance.getBomVersion()!=null){ + wrapper.like("bom_version",bomAcceptance.getBomVersion()); + } if(bomAcceptance.getCreateTime()!=null){ wrapper.ge("create_time",bomAcceptance.getCreateTime()); } if(bomAcceptance.getCreateTime1()!=null){ wrapper.le("create_time",bomAcceptance.getCreateTime1()); } + wrapper.orderByDesc("create_time"); List<BomAcceptance> list = mapper.selectList(wrapper); String rootFile = CommonUtil.getRootFile();//涓昏矾寰� if(list!=null&&list.size()>0){ for (BomAcceptance acceptance:list) { - String filePath=rootFile+acceptance.getSparePicpart(); + String sparefilePath=rootFile+acceptance.getSparePicpart(); acceptance.setSparePicpart("doc_file"+File.separator+acceptance.getSparePicpart()); //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚� - acceptance.setNameList(FileUtil.getFileNameWithOutDirectory(filePath)); + acceptance.setNameList(FileUtil.getFileNameWithOutDirectory(sparefilePath)); + + String installfilePath=rootFile+acceptance.getInstallPic(); + acceptance.setInstallPic("doc_file"+File.separator+acceptance.getInstallPic()); + //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚� + acceptance.setInstallList(FileUtil.getFileNameWithOutDirectory(installfilePath)); } } PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list.size()>0,pageInfo,"鏌ヨ浜у搧楠屾敹淇℃伅"); } + //鍒犻櫎浜у搧楠屾敹淇℃伅 + public Response delBomAcceptance(int num) { + UpdateWrapper wrapper=new UpdateWrapper(); + wrapper.eq("num",num); + int bl=mapper.delete(wrapper); + return new Response().setII(1,bl>0,bl,"鍒犻櫎浜у搧楠屾敹淇℃伅"); + } + //缂栬緫浜у搧楠屾敹淇℃伅 + public Response updateBomAcceptance(BomAcceptance bomAcceptance) { + UpdateWrapper wrapper=new UpdateWrapper(); + wrapper.eq("num",bomAcceptance.getNum()); + if(bomAcceptance.getDirectName()!=null){ + wrapper.set("direct_name",bomAcceptance.getDirectName()); + } + if(bomAcceptance.getBomSeries()!=null){ + wrapper.set("bom_series",bomAcceptance.getBomSeries()); + } + if(bomAcceptance.getBomModel()!=null){ + wrapper.set("bom_model",bomAcceptance.getBomModel()); + } + if(bomAcceptance.getDevParam()!=null){ + wrapper.set("dev_param",bomAcceptance.getDevParam()); + } + if(bomAcceptance.getStandParam()!=null){ + wrapper.set("stand_param",bomAcceptance.getStandParam()); + } + if(bomAcceptance.getBomSize()!=null){ + wrapper.set("bom_size",bomAcceptance.getBomSize()); + } + if(bomAcceptance.getDevWeight()!=null){ + wrapper.set("dev_weight",bomAcceptance.getDevWeight()); + } + if(bomAcceptance.getDevWeightAll()!=null){ + wrapper.set("dev_weight_all",bomAcceptance.getDevWeightAll()); + } + if(bomAcceptance.getSparePartmodel()!=null){ + wrapper.set("spare_partmodel",bomAcceptance.getSparePartmodel()); + } + if(bomAcceptance.getBomVersion()!=null){ + wrapper.set("bom_version",bomAcceptance.getBomVersion()); + } + + mapper.update(null,wrapper); + return new Response().set(1,true,"缂栬緫鎴愬姛"); + } + //鍒犻櫎鍥� + public Response delPic(int num, int picNum,String picUrl) { + UpdateWrapper wrapper=new UpdateWrapper(); + wrapper.eq("num",num); + if(picNum==1){ + wrapper.set("dev_picleft",""); + } + if(picNum==2){ + wrapper.set("dev_picright",""); + } + if(picNum==3){ + wrapper.set("dev_picfront",""); + } + if(picNum==4){ + wrapper.set("dev_picback",""); + } + /*if(picNum==5){ + wrapper.set("spare_picpart",newPicUrl); + }*/ + if(picNum==6){ + wrapper.set("bom_agreement",""); + } + if(picNum==7){ + wrapper.set("bom_manual",""); + } + if(picNum==8){ + wrapper.set("test_report",""); + } + if(picNum==9){ + wrapper.set("icd_file",""); + } + if(picNum==10){ + wrapper.set("cad_picpart",""); + } + if(picNum==11){ + wrapper.set("name_plate",""); + } + /*if(picNum==12){ + wrapper.set("install_pic",newPicUrl); + }*/ + int flag=0; + if(picNum!=12&&picNum!=5){//鏂囦欢鏃朵慨鏀硅〃鐨勮褰� + mapper.update(null,wrapper); + flag=1; + }else{ + String rootFile = CommonUtil.getRootFile();//涓昏矾寰� + picUrl=picUrl.replace("doc_file\\acceptance_bom",""); + String picPath=rootFile+File.separator+"acceptance_bom"+File.separator+picUrl; + if(picNum==5){ + //鍒ゆ柇鏂囦欢璺緞鏄惁鍖呭惈spare + if(picPath.contains("spare")){ + File file = new File(picPath); + if(file.isFile()){ + //鍒犻櫎鍥剧墖 + FileUtil.deleteFile(file); + flag=1; + } + } + } + if(picNum==12){ + //鍒ゆ柇鏂囦欢璺緞鏄惁鍖呭惈install + if(picPath.contains("install")){ + File file = new File(picPath); + if(file.isFile()){ + //鍒犻櫎鍥剧墖 + FileUtil.deleteFile(file); + flag=1; + } + } + } + } + return new Response().set(1,flag>0,flag>0?"鍒犻櫎鍥剧墖鎴愬姛":"鍒犻櫎鍥剧墖澶辫触,璺緞涓嶆纭�"); + } + //缂栬緫鍗曚釜鍥剧墖涓婁紶 + public Response updateDevPic(MultipartFile filePic, int num,int picNum) throws IOException { + Date date = new Date(); + long time = date.getTime(); + String rootFile = CommonUtil.getRootFile(); + String devDirSuffix = "acceptance_bom" + File.separator + time + File.separator; + if(picNum==1){ + devDirSuffix=devDirSuffix+"dev"+ File.separator; + } + if(picNum==2){ + devDirSuffix=devDirSuffix+"dev"+ File.separator; + } + if(picNum==3){ + devDirSuffix=devDirSuffix+"dev"+ File.separator; + } + if(picNum==4){ + devDirSuffix=devDirSuffix+"dev"+ File.separator; + } + if(picNum==6){ + devDirSuffix=devDirSuffix+"agree"+ File.separator; + } + if(picNum==7){ + devDirSuffix=devDirSuffix+"bomManual"+ File.separator; + } + if(picNum==8){ + devDirSuffix=devDirSuffix+"testReport"+ File.separator; + } + if(picNum==9){ + devDirSuffix=devDirSuffix+"icdFile"+ File.separator; + } + if(picNum==10){ + devDirSuffix=devDirSuffix+"cadPicpart"+ File.separator; + } + if(picNum==11){ + devDirSuffix=devDirSuffix+"namePlate"+ File.separator; + } + String devDir = rootFile + devDirSuffix; + if(filePic!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = filePic.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = devDir + fileName + suffix; + createFilefolderIFNotExist(path); + filePic.transferTo(new File(path)); + String devFile="doc_file" + File.separator + devDirSuffix+originalFilename; + UpdateWrapper wrapper=new UpdateWrapper(); + if(picNum==1){ + wrapper.set("dev_picleft",devFile); + } + if(picNum==2){ + wrapper.set("dev_picright",devFile); + } + if(picNum==3){ + wrapper.set("dev_picfront",devFile); + } + if(picNum==4){ + wrapper.set("dev_picback",devFile); + } + if(picNum==6){ + wrapper.set("bom_agreement",devFile); + } + if(picNum==7){ + wrapper.set("bom_manual",devFile); + } + if(picNum==8){ + wrapper.set("test_report",devFile); + } + if(picNum==9){ + wrapper.set("icd_file",devFile); + } + if(picNum==10){ + wrapper.set("cad_picpart",devFile); + } + if(picNum==11){ + wrapper.set("name_plate",devFile); + } + wrapper.eq("num",num); + mapper.update(null,wrapper); + return new Response().set(1,true,"涓婁紶鏂板浘鐗囨垚鍔�"); + }else{ + return new Response().set(1,false,"鍥剧墖涓嶅瓨鍦�"); + } + } + //缂栬緫澶氫釜鍥剧墖涓婁紶 + public Response updatePartPic(List<MultipartFile> multipartFileList, int num) throws IOException { + String rootFile = CommonUtil.getRootFile(); + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("num",num); + wrapper.last("limit 1"); + BomAcceptance bomAcceptance=mapper.selectOne(wrapper); + String picUrl=bomAcceptance.getSparePicpart(); + String spareUrl=""; + if(picUrl==null||picUrl.isEmpty()){ + long time =new Date().getTime(); + spareUrl= "acceptance_bom" + File.separator + time + File.separator+ "spare" + File.separator; + String spareDir = rootFile + spareUrl; + File fileDir = new File(spareDir); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + }else{ + spareUrl=picUrl; + String spareDir = rootFile + spareUrl; + File fileDir = new File(spareDir); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + } + //閰嶄欢瀛樺偍 + if(multipartFileList!=null && multipartFileList.size()!=0){ + for (int i = 0; i < multipartFileList.size(); i++) { + MultipartFile multipartFile = multipartFileList.get(i); + //瀛樺偍鏂囦欢 + String originalFilename = multipartFile.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String sparePath = rootFile+spareUrl + fileName + suffix; + File file = new File(sparePath); + multipartFile.transferTo(file); + //濡傛灉鍘熻矾寰勪负绌� + if(picUrl==null||picUrl.isEmpty()){ + UpdateWrapper wrapper1=new UpdateWrapper(); + wrapper1.set("spare_picpart",spareUrl); + wrapper1.eq("num",num); + mapper.update(null,wrapper1); + } + } + return new Response().set(1,true,"涓婁紶鎴愬姛"); + }else{ + return new Response().set(1,false,"鍥剧墖涓嶅瓨鍦�"); + } + } + //缂栬緫鐜板満瀹夎鍥剧墖澶氫釜鍥剧墖涓婁紶 + public Response updateInstallPic(List<MultipartFile> multipartFileList, int num) throws IOException { + String rootFile = CommonUtil.getRootFile(); + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("num",num); + wrapper.last("limit 1"); + BomAcceptance bomAcceptance=mapper.selectOne(wrapper); + String picUrl=bomAcceptance.getInstallPic(); + String installUrl=""; + if(picUrl==null||picUrl.isEmpty()){ + long time =new Date().getTime(); + installUrl= "acceptance_bom" + File.separator + time + File.separator+ "install" + File.separator; + String spareDir = rootFile + installUrl; + File fileDir = new File(spareDir); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + }else{ + installUrl=picUrl; + String spareDir = rootFile + installUrl; + File fileDir = new File(spareDir); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + } + //閰嶄欢瀛樺偍 + if(multipartFileList!=null && multipartFileList.size()!=0){ + for (int i = 0; i < multipartFileList.size(); i++) { + MultipartFile multipartFile = multipartFileList.get(i); + //瀛樺偍鏂囦欢 + String originalFilename = multipartFile.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String installPath = rootFile+installUrl + fileName + suffix; + File file = new File(installPath); + multipartFile.transferTo(file); + //濡傛灉鍘熻矾寰勪负绌� + if(picUrl==null||picUrl.isEmpty()){ + UpdateWrapper wrapper1=new UpdateWrapper(); + wrapper1.set("install_pic",installUrl); + wrapper1.eq("num",num); + mapper.update(null,wrapper1); + } + } + return new Response().set(1,true,"涓婁紶鎴愬姛"); + }else{ + return new Response().set(1,false,"鍥剧墖涓嶅瓨鍦�"); + } + } + + //瀵煎嚭浜у搧楠屾敹淇℃伅 + public void downloadBomAcceptance(HttpServletRequest req, HttpServletResponse resp, int num) { + //璇诲彇浜у搧淇℃伅 + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("num",num); + wrapper.last("limit 1"); + BomAcceptance bomAcceptance=mapper.selectOne(wrapper); + //鐢熸垚excel + creatBomAcceptanceExcel(resp,bomAcceptance); + } + //鐢熸垚excel + private void creatBomAcceptanceExcel( HttpServletResponse resp, BomAcceptance bomAcceptance) { + String rootFile = CommonUtil.getRootFile(); + List<String> sparePicList=new ArrayList<>(); + if(bomAcceptance.getSparePicpart()!=null||!bomAcceptance.getSparePicpart().isEmpty()){ + String filePath=rootFile+bomAcceptance.getSparePicpart(); + //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚� + sparePicList=FileUtil.getFileNameWithOutDirectory(filePath); + } + List<String> installPicList=new ArrayList<>(); + if(bomAcceptance.getInstallPic()!=null||!bomAcceptance.getInstallPic().isEmpty()){ + String filePath=rootFile+bomAcceptance.getInstallPic(); + //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚� + installPicList=FileUtil.getFileNameWithOutDirectory(filePath); + } + + String devRoot=rootFile.replace("doc_file", ""); + List<String> devPicList=new ArrayList<>(); + devPicList.add(bomAcceptance.getDevPicleft()); + devPicList.add(bomAcceptance.getDevPicfront()); + devPicList.add(bomAcceptance.getDevPicright()); + devPicList.add(bomAcceptance.getDevPicback()); + + String fileName="浜у搧楠屾敹淇℃伅璁板綍"; + //鍒涘缓鍗曚釜sheet + HSSFWorkbook wb = new HSSFWorkbook(); + //瀛椾綋鏍煎紡-鍔犵矖 + HSSFCellStyle cellStyle = wb.createCellStyle(); + cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); + cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); + + cellStyle.setBorderBottom(BorderStyle.THICK); + cellStyle.setBorderLeft(BorderStyle.THICK); + cellStyle.setBorderRight(BorderStyle.THICK); + cellStyle.setBorderTop(BorderStyle.THICK); + + HSSFFont font = wb.createFont(); + font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + cellStyle.setFont(font); + HSSFSheet sheet = wb.createSheet("浜у搧楠屾敹淇℃伅璁板綍"); + sheet.setColumnWidth(0,10000); + if(sparePicList!=null&&sparePicList.size()>0){ + int length = sparePicList.size(); + length=length>5?length:4; + for (int i = 1; i < length+1; i++){ + sheet.setColumnWidth(i,5000); + } + } + sheet.setDefaultRowHeight((short)(1000)); + //鍥剧墖鍏冪礌 + HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); + int rowNum=0; + HSSFRow row=sheet.createRow(rowNum); + HSSFCell cell=row.createCell(0); + cell.setCellValue("浜у搧楠屾敹淇℃伅璁板綍琛�"); + cell.setCellStyle(cellStyle); + sheet.addMergedRegion(new CellRangeAddress(0,0,0,1)); + + 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); + sheet.addMergedRegion(new CellRangeAddress(4,5,0,0)); + + 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); + if(devPicList!=null&&devPicList.size()>0){ + ByteArrayOutputStream byteArrayOut = null; + for(int i=0;i<devPicList.size();i++){ + String picUrl=devPicList.get(i); + if(picUrl.length()==0){ + continue; + } + try { + byteArrayOut = new ByteArrayOutputStream(); + String path=devRoot+File.separator+picUrl; + BufferedImage bufferImg = ImageIO.read(new FileInputStream(new File(path))); + ImageIO.write(bufferImg, "png", byteArrayOut); + //anchor涓昏鐢ㄤ簬璁剧疆鍥剧墖鐨勫睘鎬� + HSSFClientAnchor anchor = new HSSFClientAnchor(50, 20, 1000, 230,(short) (i+1), rowNum, (short) (i+1), rowNum); + anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE); + //鎻掑叆鍥剧墖 + patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); + } catch (IOException e) { + e.printStackTrace(); + }finally { + if (byteArrayOut != null) { + try { + byteArrayOut.close(); + } catch (IOException e) { + System.out.println("鍏抽棴ByteArrayOutputStream澶辫触"); + } + } + } + } + } + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("閰嶄欢鐓х墖"); + cell.setCellStyle(cellStyle); + if(sparePicList!=null&&sparePicList.size()>0){ + ByteArrayOutputStream byteArrayOut = null; + for(int i=0;i<sparePicList.size();i++){ + String picUrl=sparePicList.get(i); + try { + byteArrayOut = new ByteArrayOutputStream(); + String path=rootFile+File.separator+bomAcceptance.getSparePicpart()+File.separator+picUrl; + BufferedImage bufferImg = ImageIO.read(new FileInputStream(new File(path))); + ImageIO.write(bufferImg, "png", byteArrayOut); + //anchor涓昏鐢ㄤ簬璁剧疆鍥剧墖鐨勫睘鎬� + HSSFClientAnchor anchor = new HSSFClientAnchor(50, 20, 1000, 230,(short) (i+1), rowNum, (short) (i+1), rowNum); + anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE); + //鎻掑叆鍥剧墖 + patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); + } catch (IOException e) { + e.printStackTrace(); + }finally { + if (byteArrayOut != null) { + try { + byteArrayOut.close(); + } catch (IOException e) { + System.out.println("鍏抽棴ByteArrayOutputStream澶辫触"); + } + } + } + } + } + + 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); + if(bomAcceptance.getBomAgreement()!=null&&bomAcceptance.getBomAgreement().length()>0){ + String agreement=bomAcceptance.getBomAgreement(); + String agreementName = agreement.substring(agreement.lastIndexOf(File.separator)+1); + agreementName = agreementName.substring(0,agreementName.lastIndexOf(".")); + cell.setCellValue(agreementName); + cell.setCellStyle(cellStyle); + } + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("璇存槑涔�"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + if(bomAcceptance.getBomManual()!=null&&bomAcceptance.getBomManual().length()>0){ + String bomManual=bomAcceptance.getBomManual(); + String bomManualName = bomManual.substring(bomManual.lastIndexOf(File.separator)+1); + bomManualName = bomManualName.substring(0,bomManualName.lastIndexOf(".")); + cell.setCellValue(bomManualName); + cell.setCellStyle(cellStyle); + } + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("妫�娴嬫姤鍛�"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + if(bomAcceptance.getTestReport()!=null&&bomAcceptance.getTestReport().length()>0){ + String testReport=bomAcceptance.getTestReport(); + String testReportName = testReport.substring(testReport.lastIndexOf(File.separator)+1); + testReportName = testReportName.substring(0,testReportName.lastIndexOf(".")); + cell.setCellValue(testReportName); + cell.setCellStyle(cellStyle); + } + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("ICD鏂囦欢"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + if(bomAcceptance.getIcdFile()!=null&&bomAcceptance.getIcdFile().length()>0){ + String icdFile=bomAcceptance.getTestReport(); + String icdFileName = icdFile.substring(icdFile.lastIndexOf(File.separator)+1); + icdFileName = icdFileName.substring(0,icdFileName.lastIndexOf(".")); + cell.setCellValue(icdFileName); + cell.setCellStyle(cellStyle); + } + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("鏂藉伐鍥剧焊"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + if(bomAcceptance.getCadPicpart()!=null&&bomAcceptance.getCadPicpart().length()>0){ + String cadPicpart=bomAcceptance.getCadPicpart(); + String cadPicpartName = cadPicpart.substring(cadPicpart.lastIndexOf(File.separator)+1); + cadPicpartName = cadPicpartName.substring(0,cadPicpartName.lastIndexOf(".")); + cell.setCellValue(cadPicpartName); + cell.setCellStyle(cellStyle); + } + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("閾墝淇℃伅"); + cell.setCellStyle(cellStyle); + cell=row.createCell(1); + if(bomAcceptance.getNamePlate()!=null&&bomAcceptance.getNamePlate().length()>0){ + String namePlate=bomAcceptance.getNamePlate(); + String namePlateName = namePlate.substring(namePlate.lastIndexOf(File.separator)+1); + namePlateName = namePlateName.substring(0,namePlateName.lastIndexOf(".")); + cell.setCellValue(namePlateName); + cell.setCellStyle(cellStyle); + } + + rowNum++; + row=sheet.createRow(rowNum); + cell=row.createCell(0); + cell.setCellValue("鐜板満瀹夎妗堜緥鐓х墖"); + cell.setCellStyle(cellStyle); + if(installPicList!=null&&installPicList.size()>0){ + ByteArrayOutputStream byteArrayOut = null; + for(int i=0;i<installPicList.size();i++){ + String picUrl=installPicList.get(i); + try { + byteArrayOut = new ByteArrayOutputStream(); + String path=rootFile+File.separator+bomAcceptance.getInstallPic()+File.separator+picUrl; + BufferedImage bufferImg = ImageIO.read(new FileInputStream(new File(path))); + ImageIO.write(bufferImg, "png", byteArrayOut); + //anchor涓昏鐢ㄤ簬璁剧疆鍥剧墖鐨勫睘鎬� + HSSFClientAnchor anchor = new HSSFClientAnchor(50, 20, 1000, 230,(short) (i+1), rowNum, (short) (i+1), rowNum); + anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE); + //鎻掑叆鍥剧墖 + patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); + } catch (IOException e) { + e.printStackTrace(); + }finally { + if (byteArrayOut != null) { + try { + byteArrayOut.close(); + } catch (IOException e) { + System.out.println("鍏抽棴ByteArrayOutputStream澶辫触"); + } + } + } + } + } + + //灏嗘枃浠跺瓨鍒版寚瀹氫綅缃� + 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 sparefilePath=rootFile+bomAcceptance.getSparePicpart(); + bomAcceptance.setSparePicpart("doc_file"+File.separator+bomAcceptance.getSparePicpart()); + //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚� + bomAcceptance.setNameList(FileUtil.getFileNameWithOutDirectory(sparefilePath)); + + String installfilePath=rootFile+bomAcceptance.getInstallPic(); + bomAcceptance.setInstallPic("doc_file"+File.separator+bomAcceptance.getInstallPic()); + //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚� + bomAcceptance.setInstallList(FileUtil.getFileNameWithOutDirectory(installfilePath)); + return new Response().set(1,bomAcceptance,"璺宠浆璇︽儏"); + } + } \ No newline at end of file -- Gitblit v1.9.1