From 10c3d3300cce0ccef45b9db8865b61999385158b Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期一, 23 六月 2025 21:53:42 +0800
Subject: [PATCH] 验收报告查询修改

---
 src/main/java/com/whyc/controller/MaterialController.java |  160 ++++++++++++++++++-----------------------------------
 1 files changed, 54 insertions(+), 106 deletions(-)

diff --git a/src/main/java/com/whyc/controller/MaterialController.java b/src/main/java/com/whyc/controller/MaterialController.java
index ecd5d62..a6967d0 100644
--- a/src/main/java/com/whyc/controller/MaterialController.java
+++ b/src/main/java/com/whyc/controller/MaterialController.java
@@ -1,28 +1,19 @@
 package com.whyc.controller;
 
 import com.whyc.dto.Response;
-import com.whyc.pojo.DocUser;
 import com.whyc.pojo.Material;
-import com.whyc.pojo.MaterialApproving;
 import com.whyc.service.MaterialService;
 import com.whyc.util.ActionUtil;
-import com.whyc.util.CommonUtil;
-import com.whyc.util.FileUtil;
-import com.whyc.util.Zip4jUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.ss.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.File;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
+import java.util.Arrays;
 import java.util.List;
 
 @Api(tags = "鐗╂枡绠$悊")
@@ -63,103 +54,60 @@
     @PostMapping("zipParse")
     @ApiOperation("zip瑙f瀽")
     public Response zipParse(MultipartFile file) throws IOException, InvalidFormatException {
-        List<MaterialApproving> list = new LinkedList<>();
-        Response response = new Response();
-        //妫�鏌ユ槸鍚︿负zip
-        boolean isZip = Zip4jUtil.checkZipFileParam(file);
-        if(!isZip){
-            return response.set(1,false,"涓婁紶鐨勬枃浠舵牸寮忎笉鏄痾ip");
-        }
-        //zip瀛樺偍璺緞:doc_file/material_submit/${username}/{dateFormat}/${timeStamp}
-        String rootFile = CommonUtil.getRootFile();
-        DocUser user = ActionUtil.getUser();
-        String dateFormat = new SimpleDateFormat("YYYY-MM").format(new Date());
-        long timeStamp = System.currentTimeMillis();
-        String filePath = rootFile + File.separator + "material_submit" + File.separator + user.getName() + File.separator + dateFormat+ File.separator + timeStamp;
-        File parentFile = new File(filePath);
-        String originalFilename = file.getOriginalFilename();
-        File zipFile = new File(filePath+File.separator+ originalFilename);
-        if(!zipFile.exists()){
-            zipFile.mkdirs();
-        }
-        file.transferTo(zipFile);
-        //瑙e帇鏂囦欢澶�
-        Zip4jUtil.unPackZip(zipFile,null,filePath);
-        //閬嶅巻瑙e帇鍚庣殑鏂囦欢澶硅矾寰�,瑙f瀽excel
-        System.out.println(filePath);
-        List<String> fileList = new ArrayList<>();
-        fileList = FileUtil.getStaticFilePath(parentFile,fileList);
-        for (int i = 0; i < fileList.size(); i++) {
-            String fileTempUrl = fileList.get(i);
-            //鏌ヨ鍒皒ls鏁版嵁
-            if(fileTempUrl.contains(".xls")){
-                File fileTemp = new File(fileTempUrl);
-                Workbook workbook = null;
-                workbook = WorkbookFactory.create(fileTemp);
-                List<? extends PictureData> allPictures = workbook.getAllPictures();
-                //鍙栫涓�涓猻heet琛�
-                Sheet sheet = workbook.getSheetAt(0);
-                int lastRowNum = sheet.getLastRowNum();
-                //鍙栫涓夎,骞朵互绗笁琛屽紑濮�
-                Row rowTemp = sheet.getRow(1);
-                short lastCellNum = rowTemp.getLastCellNum();
-                //鍏堝崟鐙幏鍙栦骇鍝佸瀷鍙峰拰鐗堟湰鍙�/鍒嗙被
-                Row row = sheet.getRow(1);
-                String type = row.getCell(1).getStringCellValue();
+        return service.zipParse(file);
+    }
 
-                Row row2 = sheet.getRow(2);
-                String productModel = row2.getCell(5).getStringCellValue();
-                Row row3 = sheet.getRow(3);
-                String productVersion = row3.getCell(5).getStringCellValue();
-                for (int l = 8; l < lastRowNum-1; l++) {
-                    Cell cellTemp = sheet.getRow(l).getCell(1);
-                    cellTemp.setCellType(Cell.CELL_TYPE_STRING);
-                    if(cellTemp.getStringCellValue().equals("")){
-                        break;
-                    }
-                    MaterialApproving approving = new MaterialApproving();
-                    approving.setCreateDate(new Date());
+    @ApiOperation(value = "鏍规嵁鐗╂枡id鏌ヨ杩斿洖闄勪欢鏂囦欢澶逛笅鎵�鏈夌殑鏂囦欢鍒楄〃",notes = "9.3淇敼鍚庝娇鐢�")
+    @GetMapping("getAttachByMaterialId")
+    public Response getAttachByMaterialId(@RequestParam int materialId){
+        return service.getAttachByMaterialId(materialId);
+    }
 
-                    for (int m = 2; m < lastCellNum; m++) {
-                        row = sheet.getRow(l);
-                        Cell cell = row.getCell(m);
-                        String cellValue = null;
-                        int cellValueInt = 0;
-                        Double cellValueDouble = null;
-                        if(m == 3){
-                            //cellValueDouble = cell.getNumericCellValue();
-                            //DecimalFormat decimalFormat = new DecimalFormat("0");
-                            //cellValue = decimalFormat.format(cellValueDouble);
-                            cell.setCellType(Cell.CELL_TYPE_STRING);
-                            cellValue = cell.getStringCellValue();
-                        }
-                        else if(m ==7){
-                            cellValueDouble = cell.getNumericCellValue();
-                        }
-                        else {
-                            cellValue = cell.getStringCellValue();
-                        }
 
-                        switch (m){
-                            case 2:{approving.setCategory(cellValue);}break;
-                            case 3:{approving.setSubCode(cellValue);}break;
-                            case 4:{approving.setSubName(cellValue);}break;
-                            case 5:{approving.setSubModel(cellValue);}break;
-                            case 6:{approving.setUnit(cellValue);}break;
-                            case 7:{approving.setQuantity(cellValueDouble.intValue());}break;
-                            case 8:{approving.setProducer(cellValue);}break;
-                            case 9:{approving.setNotes(cellValue);}break;
-                        }
-                    }
-                    list.add(approving);
-                }
-            }
-        }
-        for (MaterialApproving MaterialApproving : list) {
-            if(MaterialApproving.getSubName()==null ||MaterialApproving.getSubName().equals("")){
-                return response.set(1,false,"鎷掔粷瑙f瀽,excel鏂囦欢涓褰曞寘鍚悕绉颁负绌虹殑璁板綍");
-            }
-        }
-        return response.setII(1,true,list,filePath);
+    @ApiOperation(value = "鏍规嵁鐗╂枡鍨嬪彿锛�'-','_'涔嬪墠鐨勯儴鍒嗭級鏌ヨ鐗╂枡鐨勫巻鍙茬増鏈�",notes = "9.3淇敼鍚庝娇鐢�")
+    @GetMapping("getMaterialVersion")
+    public Response getMaterialVersion(@RequestParam String subModel){
+        return service.getMaterialVersion(subModel);
+    }
+
+    @ApiOperation(value = "鏍规嵁鐗╂枡id鏌ヨ鐗╂枡淇℃伅",notes = "9.3淇敼鍚庝娇鐢�")
+    @GetMapping("getMaterialById")
+    public Response getMaterialById(@RequestParam int materialId){
+        return service.getMaterialById(materialId);
+    }
+
+    /**鐗╂枡id-鐗╂枡缂栫爜-鐗╂枡鍨嬪彿*/
+    @ApiOperation(value = "杩藉姞闄勪欢",notes = "materialStr涓簀son瀛楃涓�,鍖呭惈id,subCode,subModel")
+    @PostMapping("attachment")
+    public Response addAttachment(@RequestParam String materialStr, @RequestParam MultipartFile... file) throws IOException {
+        Material material = ActionUtil.getGson().fromJson(materialStr, Material.class);
+        List<MultipartFile> multipartFileList = Arrays.asList(file);
+        return service.addAttachment(multipartFileList,material);
+    }
+
+    @ApiOperation("鐗╂枡鍥剧焊瀵规瘮")
+    @GetMapping("dwgCompare")
+    public Response dwgCompare(@RequestParam int materialId,@RequestParam int materialId2) throws IOException {
+        return service.dwgCompare(materialId,materialId2);
+    }
+
+    /**鐗╂枡id-鐗╂枡缂栫爜-鐗╂枡鍨嬪彿*/
+    @ApiOperation(value = "鏇存柊鍥剧墖鎴栬�呭浘绾�",notes = "materialStr涓簀son瀛楃涓�,鍖呭惈id,subCode,subModel")
+    @PutMapping("picOrDwg")
+    public Response updatePicOrDwg(@RequestParam String materialStr, @RequestPart MultipartFile file) throws IOException {
+        Material material = ActionUtil.getGson().fromJson(materialStr, Material.class);
+        return service.updatePicOrDwg(file,material);
+    }
+
+    @PostMapping("checkNaming")
+    @ApiOperation("鍛藉悕瑙勮寖鏍¢獙")
+    public void checkNaming( HttpServletResponse response,@RequestParam MultipartFile file) throws IOException, InvalidFormatException {
+        service.checkNaming(file.getInputStream(),response);
+    }
+
+    @ApiOperation("鐗╂枡鎺ㄩ�佸脊绐椾娇鐢�")
+    @GetMapping("getMaterialDialog")
+    public Response getMaterialDialog(@RequestParam String subCode,@RequestParam String subName,@RequestParam String subModel)  {
+        return service.getMaterialDialog(subCode,subName,subModel);
     }
 }

--
Gitblit v1.9.1