| | |
| | | String pictureName=""; |
| | | //将选中的文件存入指定目录下打包下载 |
| | | if(pictureUrls!=null&&pictureUrls.size()>0){ |
| | | for (String picUrl:pictureUrls) { |
| | | for (int i=0;i<pictureUrls.size();i++) { |
| | | String picUrl=pictureUrls.get(i); |
| | | pictureName+=picUrl.substring(picUrl.lastIndexOf("\\")+1)+","; |
| | | File sourceFile=new File(fileDirName+ File.separator+picUrl); |
| | | copyFile(sourceFile,rootFace); |
| | |
| | | } |
| | | in.close(); |
| | | out.close(); |
| | | file.delete(); |
| | | file.delete();//删除压缩文件 |
| | | ZipUtils.delDir(rootFace); |
| | | } catch (FileNotFoundException | UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | |
| | | File destfile = new File(dest); |
| | | if(!destfile.exists()) { |
| | | destfile.mkdir(); |
| | | } |
| | | }/*else{ |
| | | if(i==0){ |
| | | ZipUtils.delDir(dest); |
| | | } |
| | | }*/ |
| | | //source是文件,则用字节输入输出流复制文件 |
| | | try { |
| | | if(source.isFile()){ |
| | |
| | | return new Response().setII(1,list!=null?true:false,list,"返回数据"); |
| | | } |
| | | //产品打包下载 |
| | | public Response downloadBom(HttpServletRequest req, HttpServletResponse resp, String parentModel) { |
| | | public void downloadBom(HttpServletRequest req, HttpServletResponse resp, String parentModel) { |
| | | HSSFWorkbook wb = new HSSFWorkbook(); |
| | | //字体格式-加粗 |
| | | HSSFCellStyle cellStyle = wb.createCellStyle(); |
| | |
| | | List<ProductBom> list=mapper.selectList(wrapper); |
| | | //生成excel并将dwg文件放在同一报下压缩 |
| | | creatBomExcel(req,resp,list,wb); |
| | | return new Response().setII(1,true,"",""); |
| | | //记录日志 |
| | | DocUser docUser= ActionUtil.getUser(); |
| | | String operationDetail="具体产品母料型号为:"+parentModel; |
| | | String opreationMsg="执行了最新版产品下载操作"; |
| | | String terminalIp=req.getRemoteAddr(); |
| | | logService.recordOperationLog(docUser.getId(),docUser.getName(), UserOperation.TYPE_DOWNLOAD.getType(),new Date(),terminalIp,opreationMsg,operationDetail); |
| | | } |
| | | //根据产品信息创建excel表格并存放在指定目录 |
| | | public void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,List<ProductBom> list, HSSFWorkbook wb){ |
| | | public void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,List list, HSSFWorkbook wb){ |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=fileDirName+ File.separator+"downLoad"; |
| | | String rootFace=""; |
| | | String pictureName=""; |
| | | String excelName=""; |
| | | //创建单个sheet |
| | | HSSFSheet sheet = wb.createSheet("bom信息"); |
| | | sheet.setColumnWidth(16,6000); |
| | | sheet.setDefaultRowHeight((short)(1000)); |
| | | //图片元素 |
| | | HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); |
| | | int rownum = 1; |
| | |
| | | //将选中的文件存入指定目录下打包下载 |
| | | if(list!=null&&list.size()>0){ |
| | | for (int i=0;i<list.size();i++) { |
| | | ProductBom bom=list.get(i); |
| | | ProductBom bom= (ProductBom) list.get(i); |
| | | String dwgUrl=bom.getDwgUrl(); |
| | | excelName=bom.getParentCode(); |
| | | if(i==0){ |
| | | excelName=bom.getParentCode(); |
| | | rootFace=fileDirName+File.separator+excelName; |
| | | File destfile = new File(rootFace); |
| | | if(!destfile.exists()) { |
| | | destfile.mkdir(); |
| | | } |
| | | } |
| | | if((dwgUrl!=null)&&(!dwgUrl.isEmpty())){ |
| | | pictureName+=dwgUrl.substring(dwgUrl.lastIndexOf("\\")+1)+","; |
| | | File sourceFile=new File(fileDirName+ File.separator+dwgUrl); |
| | | copyFile(sourceFile,rootFace); |
| | | } |
| | | Row row=sheet.createRow(rownum+i+1); |
| | | row.setHeight((short)(1500)); |
| | | //row.setHeight((short)(1500)); |
| | | sheet.getRow(rownum+i+1).createCell(1).setCellValue(i+1); |
| | | sheet.getRow(rownum+i+1).createCell(2).setCellValue(bom.getParentCode()); |
| | | sheet.getRow(rownum+i+1).createCell(3).setCellValue(bom.getParentName()); |
| | |
| | | } |
| | | } |
| | | } |
| | | try { |
| | | try { |
| | | File file=new File(rootFace+".zip"); |
| | | FileOutputStream forootFace = new FileOutputStream(file); |
| | | ZipUtils.toZip(rootFace, forootFace,true); |
| | |
| | | in.close(); |
| | | out.close(); |
| | | file.delete(); |
| | | ZipUtils.delDir(rootFace); |
| | | } catch (FileNotFoundException | UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |