| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | 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.LinkedList; |
| | |
| | | return new Response().setII(1,list!=null,pageInfo,"返回数据"); |
| | | }*/ |
| | | //产品下载(产品id和版本) |
| | | public void downloadProduct(HttpServletRequest req, HttpServletResponse resp, int productId , int version) { |
| | | public void downloadProduct(HttpServletRequest req, HttpServletResponse resp, int productId , int version |
| | | , @RequestParam String oprateReason, @RequestParam String oprateInfo) { |
| | | HSSFWorkbook wb = new HSSFWorkbook(); |
| | | //读取产品信息 |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | |
| | | withOutDwg+=File.separator+"standard"+File.separator+version; |
| | | } |
| | | //生成excel并将dwg文件放在同一报下压缩 |
| | | creatBomExcel(req,resp,product,endList,wb,withOutDwg); |
| | | //记录日志 |
| | | DocUser docUser= ActionUtil.getUser(); |
| | | String operationDetail="具体产品信息为:"+product.toString(); |
| | | String opreationMsg="执行了最新版产品下载操作"; |
| | | String terminalIp=req.getRemoteAddr(); |
| | | logService.recordOperationLog(docUser.getId(),docUser.getName(), UserOperation.TYPE_DOWNLOAD.getType(),new Date(),terminalIp,opreationMsg,operationDetail); |
| | | creatBomExcel(req,resp,product,endList,wb,withOutDwg,ActionUtil.sdfwithALL.format(product.getVersionTime()),oprateReason,oprateInfo); |
| | | } |
| | | |
| | | |
| | | //根据产品信息创建excel表格并存放在指定目录 |
| | | private void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,Product product,List list, HSSFWorkbook wb,String withOutDwg){ |
| | | private void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,Product product,List list, HSSFWorkbook wb,String withOutDwg |
| | | , String oprateVersion, @RequestParam String oprateReason, @RequestParam String oprateInfo){ |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=""; |
| | | String excelName=""; |
| | |
| | | ZipUtils.toZip(rootFace, forootFace,true); |
| | | |
| | | // 转码防止乱码 |
| | | resp.addHeader("Content-Disposition", "attachment;filename=" |
| | | /*resp.addHeader("Content-Disposition", "attachment;filename=" |
| | | + new String(excelName.getBytes("UTF-8"), "ISO8859-1") |
| | | + ".zip"); |
| | | + ".zip");*/ |
| | | resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode (excelName+".zip", "utf-8")); |
| | | OutputStream out = resp.getOutputStream(); |
| | | FileInputStream in = new FileInputStream(rootFace+".zip"); |
| | | int len=0; |
| | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //记录日志 |
| | | logService.recordOperationLogDownLoad(ActionUtil.getUser().getId(),ActionUtil.getUser().getName(), UserOperation.TYPE_DOWNLOAD_PRODUCT.getType(),new Date(),req.getRemoteAddr() |
| | | ,excelName+".zip",rootFace+".zip",oprateReason,oprateInfo,oprateVersion); |
| | | } |
| | | //查询所有产品中没有与指定散装件关联的子件 |
| | | public Response getAllSubWithOutMaterial(int materialId) { |