From 2f6c4f91e2cace4973770819e58651c1a643e0db Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期六, 14 六月 2025 14:31:00 +0800 Subject: [PATCH] 产品验收管理上传和查询 --- src/main/java/com/whyc/service/BomAcceptanceService.java | 178 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 140 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/whyc/service/BomAcceptanceService.java b/src/main/java/com/whyc/service/BomAcceptanceService.java index 0b09f56..9d74aac 100644 --- a/src/main/java/com/whyc/service/BomAcceptanceService.java +++ b/src/main/java/com/whyc/service/BomAcceptanceService.java @@ -1,6 +1,7 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.whyc.dto.Response; @@ -28,7 +29,138 @@ //涓婁紶浜у搧楠屾敹淇℃伅 public Response uploadBomAcceptance(MultipartFile fileLeft, MultipartFile fileRight, MultipartFile fileFront, MultipartFile fileBack - ,MultipartFile Agreement, List<MultipartFile> multipartFileList, BomAcceptance bomAcceptance) throws IOException { + ,MultipartFile agreement, List<MultipartFile> multipartFileList, BomAcceptance bomAcceptance) throws IOException { + Date date = new Date(); + bomAcceptance.setCreateTime(date); + long time = date.getTime(); + String rootFile = CommonUtil.getRootFile(); + //閰嶄欢瀛樺偍 + if(multipartFileList!=null && multipartFileList.size()!=0){ + String spareDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "spare" + File.separator; + String spareDir = rootFile + spareDirSuffix; + File fileDir = new File(spareDir); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + for (int i = 0; i < multipartFileList.size(); i++) { + MultipartFile multipartFile = multipartFileList.get(i); + //瀛樺偍鏂囦欢 + String originalFilename = multipartFile.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String sparePath = spareDir + fileName + suffix; + File file = new File(sparePath); + multipartFile.transferTo(file); + } + bomAcceptance.setSparePicpart(spareDirSuffix); + } + String devDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "dev" + File.separator; + String devDir = rootFile + devDirSuffix; + //宸﹁鍥� + if(fileLeft!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = fileLeft.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = devDir + fileName + suffix; + createFilefolderIFNotExist(path); + fileLeft.transferTo(new File(path)); + bomAcceptance.setDevPicleft("doc_file" + File.separator + devDirSuffix+originalFilename); + } + //鍙宠鍥� + if(fileRight!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = fileRight.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = devDir + fileName + suffix; + createFilefolderIFNotExist(path); + fileRight.transferTo(new File(path)); + bomAcceptance.setDevPicright("doc_file" + File.separator + devDirSuffix+originalFilename); + } + //姝i潰鍥� + if(fileFront!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = fileFront.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = devDir + fileName + suffix; + createFilefolderIFNotExist(path); + fileFront.transferTo(new File(path)); + bomAcceptance.setDevPicfront("doc_file" + File.separator + devDirSuffix+originalFilename); + } + //鍚庨潰鍥� + if(fileBack!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = fileBack.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = devDir + fileName + suffix; + createFilefolderIFNotExist(path); + fileBack.transferTo(new File(path)); + bomAcceptance.setDevPicback("doc_file" + File.separator + devDirSuffix+originalFilename); + } + String agreeDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "agree" + File.separator; + String agreeDir = rootFile + agreeDirSuffix; + //鍗忚 + if(agreement!=null){ + //瀛樺偍鏂囦欢 + String originalFilename = agreement.getOriginalFilename(); + String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); + String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); + String path = agreeDir + fileName + suffix; + createFilefolderIFNotExist(path); + agreement.transferTo(new File(path)); + bomAcceptance.setBomAgreement("doc_file" + File.separator + agreeDirSuffix+originalFilename); + } + mapper.insert(bomAcceptance); + return new Response().set(1,true,"涓婁紶鎴愬姛"); + } + //鏌ヨ浜у搧楠屾敹淇℃伅 + public Response getBomAcceptance(BomAcceptance bomAcceptance, int pageNum, int pageSize) { + PageHelper.startPage(pageNum,pageSize); + QueryWrapper wrapper=new QueryWrapper(); + if(bomAcceptance.getDirectName()!=null){ + wrapper.like("direct_name",bomAcceptance.getDirectName()); + } + if(bomAcceptance.getBomSeries()!=null){ + wrapper.like("bom_series",bomAcceptance.getBomSeries()); + } + if(bomAcceptance.getBomModel()!=null){ + wrapper.like("bom_model",bomAcceptance.getBomModel()); + } + if(bomAcceptance.getBomVersion()!=null){ + wrapper.like("bom_version",bomAcceptance.getBomVersion()); + } + if(bomAcceptance.getCreateTime()!=null){ + wrapper.ge("create_time",bomAcceptance.getCreateTime()); + } + if(bomAcceptance.getCreateTime1()!=null){ + wrapper.le("create_time",bomAcceptance.getCreateTime1()); + } + List<BomAcceptance> list = mapper.selectList(wrapper); + String rootFile = CommonUtil.getRootFile();//涓昏矾寰� + if(list!=null&&list.size()>0){ + for (BomAcceptance acceptance:list) { + String filePath=rootFile+acceptance.getSparePicpart(); + acceptance.setSparePicpart("doc_file"+File.separator+acceptance.getSparePicpart()); + //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚� + acceptance.setNameList(FileUtil.getFileNameWithOutDirectory(filePath)); + } + } + PageInfo pageInfo=new PageInfo(list); + return new Response().setII(1,list.size()>0,pageInfo,"鏌ヨ浜у搧楠屾敹淇℃伅"); + } + //鍒犻櫎浜у搧楠屾敹淇℃伅 + public Response delBomAcceptance(int num) { + UpdateWrapper wrapper=new UpdateWrapper(); + wrapper.eq("num",num); + int bl=mapper.delete(wrapper); + return new Response().setII(1,bl>0,bl,"鍒犻櫎浜у搧楠屾敹淇℃伅"); + } + //缂栬緫浜у搧楠屾敹淇℃伅 + public Response updateBomAcceptance(MultipartFile fileLeft, MultipartFile fileRight, MultipartFile fileFront, MultipartFile fileBack + , MultipartFile agreement, List<MultipartFile> multipartFileList, BomAcceptance bomAcceptance) throws IOException { Date date = new Date(); long time = date.getTime(); String rootFile = CommonUtil.getRootFile(); @@ -101,49 +233,19 @@ String agreeDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "agree" + File.separator; String agreeDir = rootFile + agreeDirSuffix; //鍗忚 - if(Agreement!=null){ + if(agreement!=null){ //瀛樺偍鏂囦欢 - String originalFilename = Agreement.getOriginalFilename(); + String originalFilename = agreement.getOriginalFilename(); String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); String path = agreeDir + fileName + suffix; createFilefolderIFNotExist(path); - Agreement.transferTo(new File(path)); + agreement.transferTo(new File(path)); bomAcceptance.setBomAgreement("doc_file" + File.separator + agreeDirSuffix+originalFilename); } - mapper.insert(bomAcceptance); - return new Response().set(1,true,"涓婁紶鎴愬姛"); - } - //鏌ヨ浜у搧楠屾敹淇℃伅 - public Response getBomAcceptance(BomAcceptance bomAcceptance, int pageNum, int pageSize) { - PageHelper.startPage(pageNum,pageSize); - QueryWrapper wrapper=new QueryWrapper(); - if(bomAcceptance.getDirectName()!=null){ - wrapper.like("direct_name",bomAcceptance.getDirectName()); - } - if(bomAcceptance.getBomSeries()!=null){ - wrapper.like("bom_series",bomAcceptance.getBomSeries()); - } - if(bomAcceptance.getBomModel()!=null){ - wrapper.like("bom_model",bomAcceptance.getBomModel()); - } - if(bomAcceptance.getCreateTime()!=null){ - wrapper.ge("create_time",bomAcceptance.getCreateTime()); - } - if(bomAcceptance.getCreateTime1()!=null){ - wrapper.le("create_time",bomAcceptance.getCreateTime1()); - } - List<BomAcceptance> list = mapper.selectList(wrapper); - String rootFile = CommonUtil.getRootFile();//涓昏矾寰� - if(list!=null&&list.size()>0){ - for (BomAcceptance acceptance:list) { - String filePath=rootFile+acceptance.getSparePicpart(); - acceptance.setSparePicpart("doc_file"+File.separator+acceptance.getSparePicpart()); - //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚� - acceptance.setNameList(FileUtil.getFileNameWithOutDirectory(filePath)); - } - } - PageInfo pageInfo=new PageInfo(list); - return new Response().setII(1,list.size()>0,pageInfo,"鏌ヨ浜у搧楠屾敹淇℃伅"); + UpdateWrapper wrapper=new UpdateWrapper(); + wrapper.eq("num",bomAcceptance.getNum()); + mapper.update(bomAcceptance,wrapper); + return new Response().set(1,true,"缂栬緫鎴愬姛"); } } \ No newline at end of file -- Gitblit v1.9.1