whycxzp
2022-09-21 386249a71cdfab885ece64c0442fe366ac661392
产品附件更新和物料编码格式处理
2个文件已修改
37 ■■■■■ 已修改文件
src/main/java/com/whyc/service/ProductService.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/SoftwareService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductService.java
@@ -3,7 +3,6 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.FileUrlDTO;
import com.whyc.dto.Response;
@@ -444,7 +443,7 @@
        }else {
            File file = new File(fileUrl);
            List<String> fileUrlList = new LinkedList<>();
            List<String> dwgUrlList = null;
            List<String> excelExcludeUrlList = null;
            List<String> picUrlList = null;
            //存于物料下,bom内有对应
            List<String> materialUrlList = new LinkedList<>();
@@ -455,17 +454,17 @@
            fileUrlList = FileUtil.getStaticFilePath(file, fileUrlList);
            //图纸dwg 子件/产品
            dwgUrlList = fileUrlList.stream().filter(url -> url.contains(".dwg")).collect(Collectors.toList());
            excelExcludeUrlList = fileUrlList.stream().filter(url -> !(url.contains(".xls") || url.contains(".xlsx"))).collect(Collectors.toList());
            picUrlList = fileUrlList.stream().filter(url -> url.contains(".png") || url.contains(".jpeg")).collect(Collectors.toList());
            List<ProductBom> finalBomList = bomList;
            dwgUrlList.forEach(dwgUrl -> {
            excelExcludeUrlList.forEach(excelExcludeUr -> {
                boolean existFlag = false;
                for (ProductBom bom : finalBomList) {
                    String filename = dwgUrl.substring(dwgUrl.lastIndexOf(File.separator) + 1, dwgUrl.length() - 4);
                    String fileFullName = dwgUrl.substring(dwgUrl.lastIndexOf(File.separator) + 1);
                    if (bom.getSubModel().toUpperCase().equals(filename.toUpperCase())) {
                        materialUrlList.add(dwgUrl);
                    String filename = excelExcludeUr.substring(excelExcludeUr.lastIndexOf(File.separator) + 1, excelExcludeUr.length() - 4);
                    String fileFullName = excelExcludeUr.substring(excelExcludeUr.lastIndexOf(File.separator) + 1);
                    if (bom.getSubModel().toUpperCase().equals(filename.toUpperCase()) && excelExcludeUr.substring(excelExcludeUr.lastIndexOf(".")+1).equals("dwg")) {
                        materialUrlList.add(excelExcludeUr);
                        existFlag = true;
@@ -475,7 +474,7 @@
                    }
                }
                if (!existFlag) {
                    productUrlList.add(dwgUrl);
                    productUrlList.add(excelExcludeUr);
                }
            });
@@ -514,10 +513,10 @@
                materialFile.mkdirs();
            }
            productUrlList.forEach(productUrl -> {
                String dwgName = productUrl.substring(productUrl.lastIndexOf(File.separator) + 1, productUrl.length() - 4);
                String fileName = productUrl.substring(productUrl.lastIndexOf(File.separator) + 1);
                try {
                    FileCopyUtils.copy(new File(productUrl), new File(productDir + File.separator + dwgName + ".dwg"));
                    FileCopyUtils.copy(new File(productUrl), new File(productDir + File.separator + fileName));
                } catch (IOException e) {
                    e.printStackTrace();
                }
src/main/java/com/whyc/service/SoftwareService.java
@@ -100,7 +100,21 @@
            //取第3列,第5列
            Cell cell = sheet.getRow(8 + i).getCell(2);
            cell.setCellType(Cell.CELL_TYPE_STRING);
            software.setApplyMaterialCode(cell.getStringCellValue());
            String stringCellValue = cell.getStringCellValue();
            int length = stringCellValue.length();
            if(length == 9){
                stringCellValue = "0"+stringCellValue;
            }else if(length < 9){
                int centerZeroNum = 10 - length -1;
                StringBuilder centerZeroStr = new StringBuilder();
                for (int j = 0; j < centerZeroNum; j++) {
                    centerZeroStr.append("0");
                }
                String strFront = stringCellValue.substring(0, 3);
                String strBehind = stringCellValue.substring(3);
                stringCellValue = "0"+strFront+centerZeroStr+strBehind;
            }
            software.setApplyMaterialCode(stringCellValue);
            software.setApplyModel(sheet.getRow(8+i).getCell(4).getStringCellValue());
            softwareList.add(software);