| | |
| | | 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); |
| | | copyFile(sourceFile,rootFace,i); |
| | | } |
| | | } |
| | | String timeStr= ActionUtil.sdfwithFTP.format(new Date()); |
| | |
| | | in.close(); |
| | | out.close(); |
| | | file.delete();//删除压缩文件 |
| | | ZipUtils.delDir(rootFace);//删除文件夹 |
| | | } catch (FileNotFoundException | UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | |
| | | } |
| | | |
| | | //将选中的文件存入指定目录下 |
| | | public void copyFile(File source,String dest ){ |
| | | public void copyFile(File source,String dest,int i ){ |
| | | //创建目的地文件夹 |
| | | File destfile = new File(dest); |
| | | if(!destfile.exists()) { |
| | | destfile.mkdir(); |
| | | }else{ |
| | | if(i==0){ |
| | | ZipUtils.delDir(dest); |
| | | } |
| | | } |
| | | //source是文件,则用字节输入输出流复制文件 |
| | | try { |
| | |
| | | wrapper.eq("parent_model",parentModel); |
| | | List<ProductBom> list=mapper.selectList(wrapper); |
| | | //生成excel并将dwg文件放在同一报下压缩 |
| | | creatBomExcel(req,resp,list,wb); |
| | | creatBomExcel(req,resp,list,wb,parentModel); |
| | | } |
| | | //根据产品信息创建excel表格并存放在指定目录 |
| | | public void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,List<ProductBom> list, HSSFWorkbook wb){ |
| | | public void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,List<ProductBom> list, HSSFWorkbook wb, String parentModel){ |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=fileDirName+ File.separator+"downLoad"; |
| | | String rootFace=fileDirName+ File.separator+parentModel; |
| | | String pictureName=""; |
| | | String excelName=""; |
| | | //创建单个sheet |
| | |
| | | if((dwgUrl!=null)&&(!dwgUrl.isEmpty())){ |
| | | pictureName+=dwgUrl.substring(dwgUrl.lastIndexOf("\\")+1)+","; |
| | | File sourceFile=new File(fileDirName+ File.separator+dwgUrl); |
| | | copyFile(sourceFile,rootFace); |
| | | copyFile(sourceFile,rootFace,i); |
| | | } |
| | | Row row=sheet.createRow(rownum+i+1); |
| | | row.setHeight((short)(1500)); |
| | |
| | | } |
| | | } |
| | | } |
| | | 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) { |