| | |
| | | return new Response().setII(1,list.size()>0?true:false,pageInfo,"数据返回"); |
| | | } |
| | | //图纸文件下载 |
| | | public void downloadCadDrawer(HttpServletRequest req, HttpServletResponse resp, ArrayList<String> pictureUrls) { |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=fileDirName+ File.separator+"downLoad"; |
| | | String pictureName=""; |
| | | //将选中的文件存入指定目录下打包下载 |
| | | if(pictureUrls!=null&&pictureUrls.size()>0){ |
| | | 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); |
| | | } |
| | | } |
| | | String timeStr= ActionUtil.sdfwithFTP.format(new Date()); |
| | | try { |
| | | File file=new File(rootFace+".zip"); |
| | | FileOutputStream forootFace = new FileOutputStream(file); |
| | | ZipUtils.toZip(rootFace, forootFace,true); |
| | | // 转码防止乱码 |
| | | resp.addHeader("Content-Disposition", "attachment;filename=" |
| | | + new String(timeStr.getBytes("UTF-8"), "ISO8859-1") |
| | | + ".zip"); |
| | | OutputStream out = resp.getOutputStream(); |
| | | FileInputStream in = new FileInputStream(rootFace+".zip"); |
| | | int len=0; |
| | | byte[] buffer =new byte[1024]; |
| | | //7. 将缓冲区中的数据输出 |
| | | while ((len=in.read(buffer))>0){ |
| | | out.write(buffer,0,len); |
| | | } |
| | | in.close(); |
| | | out.close(); |
| | | file.delete();//删除压缩文件 |
| | | ZipUtils.delDir(rootFace); |
| | | } catch (FileNotFoundException | UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | public void downloadCadDrawer(HttpServletRequest req, HttpServletResponse resp, List<ProductBom> boms) { |
| | | HSSFWorkbook wb = new HSSFWorkbook(); |
| | | //字体格式-加粗 |
| | | HSSFCellStyle cellStyle = wb.createCellStyle(); |
| | | HSSFFont font = wb.createFont(); |
| | | font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); |
| | | cellStyle.setFont(font); |
| | | //生成excel并将dwg文件放在同一报下压缩 |
| | | creatBomExcel(req,resp,boms,wb); |
| | | //记录日志 |
| | | DocUser docUser= ActionUtil.getUser(); |
| | | String operationDetail="具体图纸为:"+pictureName.substring(0,pictureName.lastIndexOf(",")); |
| | | String operationDetail="具体图纸为数量:"+boms.size(); |
| | | String opreationMsg="执行了文件打包下载操作"; |
| | | String terminalIp=req.getRemoteAddr(); |
| | | logService.recordOperationLog(docUser.getId(),docUser.getName(), UserOperation.TYPE_DOWNLOAD.getType(),new Date(),terminalIp,opreationMsg,operationDetail); |
| | |
| | | public void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,List list, HSSFWorkbook wb){ |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=""; |
| | | String pictureName=""; |
| | | String excelName=""; |
| | | //创建单个sheet |
| | | HSSFSheet sheet = wb.createSheet("bom信息"); |
| | |
| | | } |
| | | } |
| | | if((dwgUrl!=null)&&(!dwgUrl.isEmpty())){ |
| | | pictureName+=dwgUrl.substring(dwgUrl.lastIndexOf("\\")+1)+","; |
| | | File sourceFile=new File(fileDirName+ File.separator+dwgUrl); |
| | | copyFile(sourceFile,rootFace); |
| | | } |