From 090fc1f6d92f438ba2bd5c124ab0b9715bd3cbbb Mon Sep 17 00:00:00 2001 From: whycxzp <perryhsu@163.com> Date: 星期一, 08 八月 2022 16:51:04 +0800 Subject: [PATCH] bom表审批 --- src/main/java/com/whyc/service/ProductBomApprovingService.java | 66 +++++++++++++++++++++++++-------- 1 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/whyc/service/ProductBomApprovingService.java b/src/main/java/com/whyc/service/ProductBomApprovingService.java index 0cb8d8f..3689bfb 100644 --- a/src/main/java/com/whyc/service/ProductBomApprovingService.java +++ b/src/main/java/com/whyc/service/ProductBomApprovingService.java @@ -115,7 +115,7 @@ public Response zipParse(MultipartFile file) throws IOException, InvalidFormatException { List<ProductBomApproving> list = new LinkedList<>(); - List<ProductBomApproving> referenceList = new LinkedList<>(); + List<ProductBomApproving> bomList = new LinkedList<>(); Response response = new Response(); //妫�鏌ユ槸鍚︿负zip boolean isZip = Zip4jUtil.checkZipFileParam(file); @@ -145,12 +145,13 @@ List<FileUrlDTO> dwgExistsList = getDwgList(fileList); for (int i = 0; i < fileList.size(); i++) { String fileTempUrl = fileList.get(i); - //鏌ヨ鍒颁富鍙傝�冭〃鐨勬暟鎹� + //鏌ヨ鍒伴渶涓婁紶鐨刡om鏁版嵁 if(fileTempUrl.contains(".xls") && fileTempUrl.contains("(BOM)-erp")){ Workbook workbook = null; InputStream inputStream = new FileInputStream(new File(fileTempUrl)); workbook = WorkbookFactory.create(inputStream); inputStream.close(); + List<? extends PictureData> allPictures = workbook.getAllPictures(); //鍙栫涓�涓猻heet琛� Sheet sheet = workbook.getSheetAt(0); int lastRowNum = sheet.getLastRowNum(); @@ -174,7 +175,21 @@ case 2:{bomApproving.setParentName(cellValue);}break; case 3:{bomApproving.setParentModel(cellValue);}break; case 4:{bomApproving.setCategory(cellValue);}break; - case 5:{bomApproving.setSubCode(cellValue);}break; + case 5:{ + bomApproving.setSubCode(cellValue); + //鍒ゆ柇鍥剧焊鏌ョ湅鏄惁瀛樺湪 + bomApproving.setDwgExist(0); + String dwgFileName = cellValue+".dwg"; + for (int n = 0; n < dwgExistsList.size(); n++) { + FileUrlDTO fileUrlDTO = dwgExistsList.get(n); + if(dwgFileName.equals(fileUrlDTO.getFileName())){ + //瀛樺湪 + bomApproving.setDwgExist(1); + bomApproving.setDwgUrl(fileUrlDTO.getHttpFileUrl()); + break; + } + } + }break; case 6:{bomApproving.setSubName(cellValue);}break; case 7:{bomApproving.setSubModel(cellValue);}break; case 8:{bomApproving.setUnit(cellValue);}break; @@ -184,12 +199,35 @@ case 12:{bomApproving.setThickness(cellValue);}break; case 13:{bomApproving.setSurfaceDetail(cellValue);}break; case 14:{bomApproving.setNotes(cellValue);}break; + case 15:{ + //鍥剧墖,浠�0寮�濮�,鍒板浘鐗噑ize涓烘 + int m = i-2; + if(m<allPictures.size()){ + PictureData pictureData = allPictures.get(k); + //鍥剧墖瀛樺偍 product_approving/username/2022-07/ + String approvingPath = rootFile + File.separator + "product_approving" + File.separator + user.getName() + File.separator + dateFormat; + File provingFile = new File(approvingPath); + if(!provingFile.exists()){ + provingFile.mkdirs(); + } + String suffix = pictureData.suggestFileExtension(); + String picturePath = approvingPath + File.separator + bomApproving.getSubModel() + "." + suffix; + String picturePathFront = "doc_file" + File.separator + "product_approving" + File.separator + user.getName() + File.separator + dateFormat + File.separator + bomApproving.getSubModel() + "." + suffix; + byte[] data = pictureData.getData(); + FileOutputStream fileOutputStream = null; + File pictureFile = new File(picturePath); + fileOutputStream = new FileOutputStream(pictureFile); + fileOutputStream.write(data); + + bomApproving.setPictureUrl(picturePathFront); + } + }break; } } - referenceList.add(bomApproving); + bomList.add(bomApproving); } } - //杩欎釜鏄瓙琛ㄦ暟鎹�,闇�瑕佹彁浜ゅ鎵� + //杩欎釜鏄瓙琛ㄦ暟鎹�,鐢ㄥ仛瀵规瘮鏍¢獙 else if(fileTempUrl.contains(".xls")){ File fileTemp = new File(fileTempUrl); Workbook workbook = null; @@ -299,37 +337,33 @@ //閫氳繃鍖呭悕,鏌ヨ宸ュ崟娴佺▼瀹℃壒鏍囬 //String nextTitle = mainService.getNextTitle(originalFilename); - //闇�鎻愪氦瀹℃壒鐨勮褰�,閫愭潯瀵规瘮鍙傝�冭〃,瀛愭枡缂栫爜/瀛愭枡鍨嬪彿/瀛愭枡鏁伴噺 + //瀛愯〃,閫愭潯瀵规瘮bom琛�,瀛愭枡缂栫爜/瀛愭枡鍨嬪彿/瀛愭枡鏁伴噺 for (ProductBomApproving sub:list){ String subCode = sub.getSubCode(); String subModel = sub.getSubModel(); Integer quantity = sub.getQuantity(); String excelName = sub.getExcelName(); boolean exists = false; - for (ProductBomApproving reference:referenceList){ + for (ProductBomApproving reference:bomList){ if(subCode.equals(reference.getSubCode())){ exists = true; if(subModel.equals(reference.getSubModel())){ if(quantity.intValue() == reference.getQuantity()){ break; }else{ - return response.set(1,false,excelName+"涓揣鍝佺紪鐮�:"+subCode+"瀵瑰簲鐨勬暟閲�:"+quantity+"鍦ㄥ弬鑰僢om琛ㄤ腑涓嶆纭�"); + return response.set(1,false,excelName+"涓揣鍝佺紪鐮�:"+subCode+"瀵瑰簲鐨勬暟閲�:"+quantity+"鍦╞om琛ㄤ腑涓嶆纭�"); } }else{ - return response.set(1,false,excelName+"涓揣鍝佺紪鐮�:"+subCode+"瀵瑰簲鐨勮鏍煎瀷鍙�:"+subModel+"鍦ㄥ弬鑰僢om琛ㄤ腑涓嶆纭�"); + return response.set(1,false,excelName+"涓揣鍝佺紪鐮�:"+subCode+"瀵瑰簲鐨勮鏍煎瀷鍙�:"+subModel+"鍦╞om琛ㄤ腑涓嶆纭�"); } } } if(!exists){ - return response.set(1,false,excelName+"涓揣鍝佺紪鐮�:"+subCode+"鍦ㄥ弬鑰僢om琛ㄤ腑涓嶅瓨鍦�"); + return response.set(1,false,excelName+"涓揣鍝佺紪鐮�:"+subCode+"鍦╞om琛ㄤ腑涓嶅瓨鍦�"); } - ProductBomApproving reference = referenceList.get(0); - sub.setParentCode(reference.getParentCode()); - sub.setParentModel(reference.getParentModel()); - sub.setParentName(reference.getParentName()); - }; + } String nextTitle = originalFilename.substring(0,originalFilename.lastIndexOf(".")); - return response.setIII(1,true,list,nextTitle,"瑙f瀽瀹屾垚"); + return response.setIII(1,true,bomList,nextTitle,"瑙f瀽瀹屾垚"); } private List<FileUrlDTO> getDwgList(List<String> fileList) { -- Gitblit v1.9.1