| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | //文件夹的拷贝 |
| | | public void copyDir(String sourcePathDir, String newPathDir) { |
| | | File start = new File(sourcePathDir); |
| | | File end = new File(newPathDir); |
| | | if(!start.exists()) { |
| | | start.mkdir(); |
| | | } |
| | | String[] filePath = start.list();//获取该文件夹下的所有文件以及目录的名字 |
| | | if(!end.exists()) { |
| | | end.mkdir(); |
| | | } |
| | | if(filePath.length>=0){ |
| | | for(String temp : filePath) { |
| | | //添加满足情况的条件 |
| | | if(new File(sourcePathDir + File.separator + temp ).isFile()) { |
| | | //为文件则进行拷贝 |
| | | copyFile(new File(sourcePathDir + File.separator + temp ), newPathDir ); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | public void updateUrl(List<ProductBomApproving> fileBomApprovingList) { |
| | | mapper.updateUrl(fileBomApprovingList); |
| | | } |
| | |
| | | //产品下载(产品id和版本) |
| | | public void downloadProduct(HttpServletRequest req, HttpServletResponse resp, int productId , int version) { |
| | | HSSFWorkbook wb = new HSSFWorkbook(); |
| | | //字体格式-加粗 |
| | | HSSFCellStyle cellStyle = wb.createCellStyle(); |
| | | HSSFFont font = wb.createFont(); |
| | | font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); |
| | | cellStyle.setFont(font); |
| | | //读取产品信息 |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("id",productId); |
| | |
| | | } |
| | | } |
| | | }); |
| | | //将没有管理BOM的dwg文件拷贝下载 |
| | | String withOutDwg="doc_file/product"+File.separator+product.getParentModel(); |
| | | if(product.getCustomCode()!=null&&!product.getCustomCode().isEmpty()){ |
| | | withOutDwg+=File.separator+product.getCustomCode()+File.separator+version; |
| | | }else{ |
| | | withOutDwg+=File.separator+"standard"+File.separator+version; |
| | | } |
| | | //生成excel并将dwg文件放在同一报下压缩 |
| | | creatBomExcel(req,resp,product,endList,wb,"bom"); |
| | | creatBomExcel(req,resp,product,endList,wb,"bom",withOutDwg); |
| | | //记录日志 |
| | | DocUser docUser= ActionUtil.getUser(); |
| | | String operationDetail="具体产品信息为:"+product.toString(); |
| | |
| | | |
| | | |
| | | //根据产品信息创建excel表格并存放在指定目录 |
| | | private void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,Product product,List list, HSSFWorkbook wb,String type){ |
| | | private void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,Product product,List list, HSSFWorkbook wb,String type,String withOutDwg){ |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=""; |
| | | String excelName=""; |
| | | //字体格式-加粗 |
| | | HSSFCellStyle cellStyle = wb.createCellStyle(); |
| | | HSSFFont font = wb.createFont(); |
| | | font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); |
| | | font.setColor(HSSFFont.COLOR_RED); |
| | | cellStyle.setFont(font); |
| | | //创建单个sheet |
| | | HSSFSheet sheet = wb.createSheet("产品信息"); |
| | | sheet.setColumnWidth(1,5000); |
| | |
| | | if(!destfile.exists()) { |
| | | destfile.mkdir(); |
| | | } |
| | | //将没有管理BOM的dwg文件拷贝下载 |
| | | withOutDwg=fileDirName+File.separator+withOutDwg; |
| | | copyDir(withOutDwg,rootFace); |
| | | //将选中的文件存入指定目录下打包下载 |
| | | if(list!=null&&list.size()>0){ |
| | | for (int i=0;i<list.size();i++) { |
| | |
| | | copyFile(sourceFile,rootFace); |
| | | } |
| | | Row row=sheet.createRow(rownum+i+1); |
| | | row.setRowStyle(cellStyle); |
| | | sheet.getRow(rownum+i+1).createCell(1).setCellValue(i+1); |
| | | sheet.getRow(rownum+i+1).createCell(2).setCellValue(product.getParentCode()); |
| | | sheet.getRow(rownum+i+1).createCell(3).setCellValue(product.getParentName()); |