From bfa320956f20988fe671b0c4d25aa82fe766a98d Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期一, 23 六月 2025 20:17:51 +0800
Subject: [PATCH] 验收报告添加信息

---
 src/main/java/com/whyc/pojo/BomAcceptance.java                 |   21 +++
 src/main/java/com/whyc/service/BomAcceptanceService.java       |  281 +++++++++++++++++++++++++++++++++++++++++++++-
 src/main/java/com/whyc/controller/BomAcceptanceController.java |   20 ++
 3 files changed, 312 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/whyc/controller/BomAcceptanceController.java b/src/main/java/com/whyc/controller/BomAcceptanceController.java
index 17bee6b..ae197e1 100644
--- a/src/main/java/com/whyc/controller/BomAcceptanceController.java
+++ b/src/main/java/com/whyc/controller/BomAcceptanceController.java
@@ -31,10 +31,16 @@
     @PostMapping("uploadBomAcceptance")
     public Response uploadBomAcceptance(@RequestParam(required = false) MultipartFile fileLeft,@RequestParam(required = false) MultipartFile fileRight
             ,@RequestParam(required = false) MultipartFile fileFront,@RequestParam(required = false) MultipartFile fileBack
-            ,@RequestParam(required = false) MultipartFile agreement
-            ,@RequestPart(required = false) List<MultipartFile> multipartFileList, @RequestParam String feedbackJson) throws IOException {
+            ,@RequestParam(required = false) MultipartFile agreement,@RequestParam(required = false) MultipartFile bomManual
+            ,@RequestParam(required = false) MultipartFile testReport,@RequestParam(required = false) MultipartFile icdFile
+            ,@RequestParam(required = false) MultipartFile cadPicpart,@RequestParam(required = false) MultipartFile namePlate
+            ,@RequestPart(required = false) List<MultipartFile> multipartFileList,@RequestPart(required = false) List<MultipartFile> installCasePics
+            ,@RequestParam String feedbackJson) throws IOException {
         BomAcceptance bomAcceptance = ActionUtil.getGson().fromJson(feedbackJson, BomAcceptance.class);
-        return service.uploadBomAcceptance(fileLeft,fileRight,fileFront,fileBack,agreement,multipartFileList,bomAcceptance);
+        return service.uploadBomAcceptance(fileLeft,fileRight,fileFront,fileBack
+                ,agreement,bomManual,testReport,icdFile,cadPicpart,namePlate
+                ,multipartFileList,installCasePics
+                ,bomAcceptance);
     }
 
     @ApiOperation("鏌ヨ浜у搧楠屾敹淇℃伅")
@@ -60,12 +66,18 @@
         return service.updateDevPic(filePic,num,picNum);
     }
 
-    @ApiOperation(value = "缂栬緫澶氫釜鍥剧墖涓婁紶")
+    @ApiOperation(value = "缂栬緫閰嶄欢鍥惧涓浘鐗囦笂浼�")
     @PostMapping("updatePartPic")
     public Response updatePartPic(@RequestPart(required = false) List<MultipartFile> multipartFileList,@RequestParam int num) throws IOException {
         return service.updatePartPic(multipartFileList,num);
     }
 
+    @ApiOperation(value = "缂栬緫鐜板満瀹夎鍥剧墖澶氫釜鍥剧墖涓婁紶")
+    @PostMapping("updateInstallPic")
+    public Response updateInstallPic(@RequestPart(required = false) List<MultipartFile> multipartFileList,@RequestParam int num) throws IOException {
+        return service.updateInstallPic(multipartFileList,num);
+    }
+
     @ApiOperation(value = "鍒犻櫎鍥�")
     @PostMapping("delPic")
     public Response delPic(@RequestParam int num,@RequestParam int picNum,@RequestParam String picUrl){
diff --git a/src/main/java/com/whyc/pojo/BomAcceptance.java b/src/main/java/com/whyc/pojo/BomAcceptance.java
index 9ba37a0..9b6fa2c 100644
--- a/src/main/java/com/whyc/pojo/BomAcceptance.java
+++ b/src/main/java/com/whyc/pojo/BomAcceptance.java
@@ -83,6 +83,27 @@
     @ApiModelProperty(value = "鍗忚鏂囨湰璺緞")
     private String bomAgreement;
 
+    @ApiModelProperty(value = "璇存槑涔�(鏂囦欢)")
+    private String bomManual;
+
+    @ApiModelProperty(value = "妫�娴嬫姤鍛�(鏂囦欢)")
+    private String testReport;
+
+    @ApiModelProperty(value = "ICD鏂囦欢")
+    private String icdFile;
+
+    @ApiModelProperty(value = "鏂藉伐鍥剧焊(鏂囦欢)")
+    private String cadPicpart;
+
+    @ApiModelProperty(value = "閾墝淇℃伅(鏂囦欢)")
+    private String namePlate;
+
+    @ApiModelProperty(value = "鐜板満瀹夎妗堜緥鐓х墖(鏂囦欢)")
+    private String installPic;
+
+    @TableField(exist = false)
+    private List<String> installList;
+
     @ApiModelProperty("鍒涘缓鏃堕棿")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     private Date createTime;
diff --git a/src/main/java/com/whyc/service/BomAcceptanceService.java b/src/main/java/com/whyc/service/BomAcceptanceService.java
index eafeab5..c189711 100644
--- a/src/main/java/com/whyc/service/BomAcceptanceService.java
+++ b/src/main/java/com/whyc/service/BomAcceptanceService.java
@@ -41,7 +41,10 @@
 
     //涓婁紶浜у搧楠屾敹淇℃伅
     public Response uploadBomAcceptance(MultipartFile fileLeft, MultipartFile fileRight, MultipartFile fileFront, MultipartFile fileBack
-            ,MultipartFile agreement, List<MultipartFile> multipartFileList, BomAcceptance bomAcceptance) throws IOException {
+            ,MultipartFile agreement,MultipartFile bomManual,MultipartFile testReport
+            ,MultipartFile icdFile,MultipartFile cadPicpart,MultipartFile namePlate
+            , List<MultipartFile> multipartFileList,List<MultipartFile> installCasePics
+            , BomAcceptance bomAcceptance) throws IOException {
         Date date = new Date();
         bomAcceptance.setCreateTime(date);
         long time = date.getTime();
@@ -66,6 +69,27 @@
             }
             bomAcceptance.setSparePicpart(spareDirSuffix);
         }
+        //鐜板満瀹夎妗堜緥鐓х墖
+        if(installCasePics!=null && installCasePics.size()!=0){
+            String installCasePicDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "install" + File.separator;
+            String installCasePicDir = rootFile + installCasePicDirSuffix;
+            File fileDir = new File(installCasePicDir);
+            if (!fileDir.exists()) {
+                fileDir.mkdirs();
+            }
+            for (int i = 0; i < installCasePics.size(); i++) {
+                MultipartFile multipartFile = installCasePics.get(i);
+                //瀛樺偍鏂囦欢
+                String originalFilename = multipartFile.getOriginalFilename();
+                String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+                String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+                String sparePath = installCasePicDir + fileName + suffix;
+                File file = new File(sparePath);
+                multipartFile.transferTo(file);
+            }
+            bomAcceptance.setInstallPic(installCasePicDirSuffix);
+        }
+
         String devDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "dev" + File.separator;
         String devDir = rootFile + devDirSuffix;
         //宸﹁鍥�
@@ -125,6 +149,71 @@
             agreement.transferTo(new File(path));
             bomAcceptance.setBomAgreement("doc_file" + File.separator + agreeDirSuffix+originalFilename);
         }
+        String bomManualDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "bomManual" + File.separator;
+        String bomManualDir = rootFile + bomManualDirSuffix;
+        //璇存槑涔�(鏂囦欢)
+        if(bomManual!=null){
+            //瀛樺偍鏂囦欢
+            String originalFilename = bomManual.getOriginalFilename();
+            String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+            String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String path = bomManualDir + fileName + suffix;
+            createFilefolderIFNotExist(path);
+            bomManual.transferTo(new File(path));
+            bomAcceptance.setBomManual("doc_file" + File.separator + bomManualDirSuffix+originalFilename);
+        }
+        String testReportDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "testReport" + File.separator;
+        String testReportDir = rootFile + testReportDirSuffix;
+        //妫�娴嬫姤鍛�(鏂囦欢)
+        if(testReport!=null){
+            //瀛樺偍鏂囦欢
+            String originalFilename = testReport.getOriginalFilename();
+            String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+            String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String path = testReportDir + fileName + suffix;
+            createFilefolderIFNotExist(path);
+            testReport.transferTo(new File(path));
+            bomAcceptance.setTestReport("doc_file" + File.separator + testReportDirSuffix+originalFilename);
+        }
+        String icdFileDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "icdFile" + File.separator;
+        String icdFileDir = rootFile + icdFileDirSuffix;
+        //ICD鏂囦欢
+        if(icdFile!=null){
+            //瀛樺偍鏂囦欢
+            String originalFilename = icdFile.getOriginalFilename();
+            String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+            String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String path = icdFileDir + fileName + suffix;
+            createFilefolderIFNotExist(path);
+            icdFile.transferTo(new File(path));
+            bomAcceptance.setIcdFile("doc_file" + File.separator + icdFileDirSuffix+originalFilename);
+        }
+        String cadPicpartDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "cadPicpart" + File.separator;
+        String cadPicpartDir = rootFile + cadPicpartDirSuffix;
+        //鏂藉伐鍥剧焊(鏂囦欢)
+        if(cadPicpart!=null){
+            //瀛樺偍鏂囦欢
+            String originalFilename = cadPicpart.getOriginalFilename();
+            String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+            String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String path = cadPicpartDir + fileName + suffix;
+            createFilefolderIFNotExist(path);
+            cadPicpart.transferTo(new File(path));
+            bomAcceptance.setCadPicpart("doc_file" + File.separator + cadPicpartDirSuffix+originalFilename);
+        }
+        String namePlateDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "namePlate" + File.separator;
+        String namePlateDir = rootFile + namePlateDirSuffix;
+        //閾墝淇℃伅(鏂囦欢)
+        if(namePlate!=null){
+            //瀛樺偍鏂囦欢
+            String originalFilename = namePlate.getOriginalFilename();
+            String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+            String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String path = namePlateDir + fileName + suffix;
+            createFilefolderIFNotExist(path);
+            namePlate.transferTo(new File(path));
+            bomAcceptance.setNamePlate("doc_file" + File.separator + namePlateDirSuffix+originalFilename);
+        }
         mapper.insert(bomAcceptance);
         return new Response().set(1,true,"涓婁紶鎴愬姛");
     }
@@ -154,10 +243,15 @@
         String rootFile = CommonUtil.getRootFile();//涓昏矾寰�
         if(list!=null&&list.size()>0){
             for (BomAcceptance acceptance:list) {
-                String filePath=rootFile+acceptance.getSparePicpart();
+                String sparefilePath=rootFile+acceptance.getSparePicpart();
                 acceptance.setSparePicpart("doc_file"+File.separator+acceptance.getSparePicpart());
                 //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚�
-                acceptance.setNameList(FileUtil.getFileNameWithOutDirectory(filePath));
+                acceptance.setNameList(FileUtil.getFileNameWithOutDirectory(sparefilePath));
+
+                String installfilePath=rootFile+acceptance.getInstallPic();
+                acceptance.setInstallPic("doc_file"+File.separator+acceptance.getInstallPic());
+                //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚�
+                acceptance.setInstallList(FileUtil.getFileNameWithOutDirectory(installfilePath));
             }
         }
         PageInfo  pageInfo=new PageInfo(list);
@@ -230,6 +324,24 @@
         if(picNum==6){
             wrapper.set("bom_agreement",newPicUrl);
         }
+        if(picNum==7){
+            wrapper.set("bom_manual",newPicUrl);
+        }
+        if(picNum==8){
+            wrapper.set("test_report",newPicUrl);
+        }
+        if(picNum==9){
+            wrapper.set("icd_file",newPicUrl);
+        }
+        if(picNum==10){
+            wrapper.set("cad_picpart",newPicUrl);
+        }
+        if(picNum==11){
+            wrapper.set("name_plate",newPicUrl);
+        }
+        if(picNum==12){
+            wrapper.set("install_pic",newPicUrl);
+        }
         int flag=mapper.update(null,wrapper);
         if(flag>0&&picUrl.length()>0){
             String rootFile = CommonUtil.getRootFile();//涓昏矾寰�
@@ -265,7 +377,21 @@
         if(picNum==6){
             picUrl=bomAcceptance.getBomAgreement();
         }
-       //鍚庨潰鍥�
+        if(picNum==7){
+            picUrl=bomAcceptance.getBomManual();
+        }
+        if(picNum==8){
+            picUrl=bomAcceptance.getTestReport();
+        }
+        if(picNum==9){
+            picUrl=bomAcceptance.getIcdFile();
+        }
+        if(picNum==10){
+            picUrl=bomAcceptance.getCadPicpart();
+        }
+        if(picNum==11){
+            picUrl=bomAcceptance.getNamePlate();
+        }
         if(filePic!=null){
             //瀛樺偍鏂囦欢
             String originalFilename = filePic.getOriginalFilename();
@@ -307,6 +433,32 @@
             return new Response().set(1,false,"鍥剧墖涓嶅瓨鍦�");
         }
     }
+    //缂栬緫鐜板満瀹夎鍥剧墖澶氫釜鍥剧墖涓婁紶
+    public Response updateInstallPic(List<MultipartFile> multipartFileList, int num) throws IOException {
+        String rootFile = CommonUtil.getRootFile();
+        QueryWrapper wrapper=new QueryWrapper();
+        wrapper.eq("num",num);
+        wrapper.last("limit 1");
+        BomAcceptance bomAcceptance=mapper.selectOne(wrapper);
+        String picUrl=bomAcceptance.getInstallPic();
+        //閰嶄欢瀛樺偍
+        if(multipartFileList!=null && multipartFileList.size()!=0){
+            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 installPath = rootFile+picUrl + fileName + suffix;
+                File file = new File(installPath);
+                multipartFile.transferTo(file);
+            }
+            return new Response().set(1,true,"涓婁紶鎴愬姛");
+        }else{
+            return new Response().set(1,false,"鍥剧墖涓嶅瓨鍦�");
+        }
+    }
+
     //瀵煎嚭浜у搧楠屾敹淇℃伅
     public void downloadBomAcceptance(HttpServletRequest req, HttpServletResponse resp, int num) {
         //璇诲彇浜у搧淇℃伅
@@ -326,12 +478,20 @@
             //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚�
             sparePicList=FileUtil.getFileNameWithOutDirectory(filePath);
         }
+        List<String> installPicList=new ArrayList<>();
+        if(bomAcceptance.getInstallPic()!=null||!bomAcceptance.getInstallPic().isEmpty()){
+            String filePath=rootFile+bomAcceptance.getInstallPic();
+            //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚�
+            installPicList=FileUtil.getFileNameWithOutDirectory(filePath);
+        }
+
         String devRoot=rootFile.replace("doc_file", "");
         List<String> devPicList=new ArrayList<>();
         devPicList.add(bomAcceptance.getDevPicleft());
         devPicList.add(bomAcceptance.getDevPicfront());
         devPicList.add(bomAcceptance.getDevPicright());
         devPicList.add(bomAcceptance.getDevPicback());
+
         String fileName="浜у搧楠屾敹淇℃伅璁板綍";
         //鍒涘缓鍗曚釜sheet
         HSSFWorkbook wb = new HSSFWorkbook();
@@ -542,6 +702,109 @@
             cell.setCellStyle(cellStyle);
         }
 
+        rowNum++;
+        row=sheet.createRow(rowNum);
+        cell=row.createCell(0);
+        cell.setCellValue("璇存槑涔�");
+        cell.setCellStyle(cellStyle);
+        cell=row.createCell(1);
+        if(bomAcceptance.getBomManual()!=null&&bomAcceptance.getBomManual().length()>0){
+            String bomManual=bomAcceptance.getBomManual();
+            String bomManualName = bomManual.substring(bomManual.lastIndexOf(File.separator)+1);
+            bomManualName = bomManualName.substring(0,bomManualName.lastIndexOf("."));
+            cell.setCellValue(bomManualName);
+            cell.setCellStyle(cellStyle);
+        }
+
+        rowNum++;
+        row=sheet.createRow(rowNum);
+        cell=row.createCell(0);
+        cell.setCellValue("妫�娴嬫姤鍛�");
+        cell.setCellStyle(cellStyle);
+        cell=row.createCell(1);
+        if(bomAcceptance.getTestReport()!=null&&bomAcceptance.getTestReport().length()>0){
+            String testReport=bomAcceptance.getTestReport();
+            String testReportName = testReport.substring(testReport.lastIndexOf(File.separator)+1);
+            testReportName = testReportName.substring(0,testReportName.lastIndexOf("."));
+            cell.setCellValue(testReportName);
+            cell.setCellStyle(cellStyle);
+        }
+
+        rowNum++;
+        row=sheet.createRow(rowNum);
+        cell=row.createCell(0);
+        cell.setCellValue("ICD鏂囦欢");
+        cell.setCellStyle(cellStyle);
+        cell=row.createCell(1);
+        if(bomAcceptance.getIcdFile()!=null&&bomAcceptance.getIcdFile().length()>0){
+            String icdFile=bomAcceptance.getTestReport();
+            String icdFileName = icdFile.substring(icdFile.lastIndexOf(File.separator)+1);
+            icdFileName = icdFileName.substring(0,icdFileName.lastIndexOf("."));
+            cell.setCellValue(icdFileName);
+            cell.setCellStyle(cellStyle);
+        }
+
+        rowNum++;
+        row=sheet.createRow(rowNum);
+        cell=row.createCell(0);
+        cell.setCellValue("鏂藉伐鍥剧焊");
+        cell.setCellStyle(cellStyle);
+        cell=row.createCell(1);
+        if(bomAcceptance.getCadPicpart()!=null&&bomAcceptance.getCadPicpart().length()>0){
+            String cadPicpart=bomAcceptance.getCadPicpart();
+            String cadPicpartName = cadPicpart.substring(cadPicpart.lastIndexOf(File.separator)+1);
+            cadPicpartName = cadPicpartName.substring(0,cadPicpartName.lastIndexOf("."));
+            cell.setCellValue(cadPicpartName);
+            cell.setCellStyle(cellStyle);
+        }
+
+        rowNum++;
+        row=sheet.createRow(rowNum);
+        cell=row.createCell(0);
+        cell.setCellValue("閾墝淇℃伅");
+        cell.setCellStyle(cellStyle);
+        cell=row.createCell(1);
+        if(bomAcceptance.getNamePlate()!=null&&bomAcceptance.getNamePlate().length()>0){
+            String namePlate=bomAcceptance.getNamePlate();
+            String namePlateName = namePlate.substring(namePlate.lastIndexOf(File.separator)+1);
+            namePlateName = namePlateName.substring(0,namePlateName.lastIndexOf("."));
+            cell.setCellValue(namePlateName);
+            cell.setCellStyle(cellStyle);
+        }
+
+        rowNum++;
+        row=sheet.createRow(rowNum);
+        cell=row.createCell(0);
+        cell.setCellValue("鐜板満瀹夎妗堜緥鐓х墖");
+        cell.setCellStyle(cellStyle);
+        if(installPicList!=null&&installPicList.size()>0){
+            ByteArrayOutputStream byteArrayOut = null;
+            for(int i=0;i<installPicList.size();i++){
+                String picUrl=installPicList.get(i);
+                try {
+                    byteArrayOut = new ByteArrayOutputStream();
+                    String path=rootFile+File.separator+bomAcceptance.getInstallPic()+File.separator+picUrl;
+                    BufferedImage bufferImg = ImageIO.read(new FileInputStream(new File(path)));
+                    ImageIO.write(bufferImg, "png", byteArrayOut);
+                    //anchor涓昏鐢ㄤ簬璁剧疆鍥剧墖鐨勫睘鎬�
+                    HSSFClientAnchor anchor = new HSSFClientAnchor(50, 20, 1000, 230,(short) (i+1), rowNum, (short) (i+1), rowNum);
+                    anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE);
+                    //鎻掑叆鍥剧墖
+                    patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }finally {
+                    if (byteArrayOut != null) {
+                        try {
+                            byteArrayOut.close();
+                        } catch (IOException e) {
+                            System.out.println("鍏抽棴ByteArrayOutputStream澶辫触");
+                        }
+                    }
+                }
+            }
+        }
+
         //灏嗘枃浠跺瓨鍒版寚瀹氫綅缃�
         OutputStream os = null;
         try {
@@ -570,10 +833,16 @@
         wrapper.eq("num",num);
         wrapper.last("limit 1");
         BomAcceptance bomAcceptance=mapper.selectOne(wrapper);
-        String filePath=rootFile+bomAcceptance.getSparePicpart();
+        String sparefilePath=rootFile+bomAcceptance.getSparePicpart();
         bomAcceptance.setSparePicpart("doc_file"+File.separator+bomAcceptance.getSparePicpart());
         //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚�
-        bomAcceptance.setNameList(FileUtil.getFileNameWithOutDirectory(filePath));
+        bomAcceptance.setNameList(FileUtil.getFileNameWithOutDirectory(sparefilePath));
+
+        String installfilePath=rootFile+bomAcceptance.getInstallPic();
+        bomAcceptance.setInstallPic("doc_file"+File.separator+bomAcceptance.getInstallPic());
+        //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚�
+        bomAcceptance.setInstallList(FileUtil.getFileNameWithOutDirectory(installfilePath));
         return new Response().set(1,bomAcceptance,"璺宠浆璇︽儏");
     }
+
 }
\ No newline at end of file

--
Gitblit v1.9.1