lxw
2022-08-30 5122701af4ecb76d6cc05655ba64ab07622eb51e
历史版本查看需要加软件
2个文件已修改
60 ■■■■ 已修改文件
src/main/java/com/whyc/service/ProductBomHistoryService.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductBomService.java 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductBomHistoryService.java
@@ -122,8 +122,14 @@
        HSSFFont font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        cellStyle.setFont(font);
        String withOutDwg="doc_file/product"+File.separator+pHistory.getParentModel();
        if(pHistory.getCustomCode()!=null&&!pHistory.getCustomCode().isEmpty()){
            withOutDwg+=File.separator+pHistory.getCustomCode()+File.separator+version;
        }else{
            withOutDwg+=File.separator+"standard"+File.separator+version;
        }
        //生成excel并将dwg文件放在同一报下压缩
        creatBomHsitoryExcel(req,resp,pHistory,endList,wb);
        creatBomHsitoryExcel(req,resp,pHistory,endList,wb,withOutDwg);
        //记录日志
        DocUser docUser= ActionUtil.getUser();
        String operationDetail="具体产品为:"+pHistory.toString();
@@ -132,7 +138,7 @@
        logService.recordOperationLog(docUser.getId(),docUser.getName(), UserOperation.TYPE_DOWNLOAD.getType(),new Date(),terminalIp,opreationMsg,operationDetail);
    }
    //根据产品信息创建excel表格并存放在指定目录
    public void creatBomHsitoryExcel(HttpServletRequest req, HttpServletResponse resp,ProductHistory pHistory,List<ProductBomHistory> list, HSSFWorkbook wb){
    public void creatBomHsitoryExcel(HttpServletRequest req, HttpServletResponse resp,ProductHistory pHistory,List<ProductBomHistory> list, HSSFWorkbook wb,String withOutDwg){
        String fileDirName = FileDirPath.getFileDirName();
        String rootFace="";
        String excelName="";
@@ -174,6 +180,9 @@
        if(!destfile.exists()) {
            destfile.mkdir();
        }
        //将没有管理BOM的dwg文件拷贝下载
        withOutDwg=fileDirName+File.separator+withOutDwg;
        bomService.copyDir(withOutDwg,rootFace);
        //将选中的文件存入指定目录下打包下载
        if(list!=null&&list.size()>0){
            for (int i=0;i<list.size();i++) {
src/main/java/com/whyc/service/ProductBomService.java
@@ -165,7 +165,28 @@
            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);
    }
@@ -191,11 +212,6 @@
    //产品下载(产品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);
@@ -216,8 +232,15 @@
                }
            }
        });
        //将没有管理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();
@@ -228,10 +251,16 @@
    //根据产品信息创建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);
@@ -274,6 +303,9 @@
        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++) {
@@ -284,6 +316,7 @@
                    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());