From cf9a5039e6db9d1d5963e3fe1a37d00169ec2ef7 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期三, 25 六月 2025 11:18:22 +0800
Subject: [PATCH] 验收报告修改

---
 src/main/java/com/whyc/service/ECRService.java |  134 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 116 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/whyc/service/ECRService.java b/src/main/java/com/whyc/service/ECRService.java
index 78b61b7..8326d96 100644
--- a/src/main/java/com/whyc/service/ECRService.java
+++ b/src/main/java/com/whyc/service/ECRService.java
@@ -1,8 +1,11 @@
 package com.whyc.service;
 
 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.FileDirPath;
 import com.whyc.dto.Response;
 import com.whyc.mapper.ECRMapper;
 import com.whyc.pojo.ECR;
@@ -52,7 +55,6 @@
         }
         String excelFilePath = excelDir + File.separator + originalFilename.substring(0,originalFilename.lastIndexOf(".")) + "_" + dateUnion +originalFilename.substring(originalFilename.lastIndexOf("."));
         String excelHttpUrl = excelFilePath.substring(excelDir.lastIndexOf("doc_file"+ File.separator + "ecr"));
-        multipartFile.transferTo(new File(excelFilePath));
 
         Workbook workbook = null;
         workbook = WorkbookFactory.create(inputStream);
@@ -61,12 +63,19 @@
         Sheet sheet = workbook.getSheetAt(0);
         List<ECR> ecrList = new LinkedList<>();
         ECR ecr = new ECR();
-        String numberCellValue = sheet.getRow(1).getCell(5).getStringCellValue();
-        String number = numberCellValue.substring(numberCellValue.indexOf("BG"));
+        Cell numberCell = sheet.getRow(1).getCell(5);
+        if(numberCell == null || !numberCell.getStringCellValue().contains("ECR缂栧彿")){
+            return new Response().set(1,false,"ECR缂栧彿涓嶈兘涓虹┖鎴栧崟鍏冩牸鏍煎紡涓嶈鑼�!");
+        }
+        String numberCellValue = numberCell.getStringCellValue();
+        String number = numberCellValue.substring(6).trim();
+        if(number.equals("")){
+            return new Response().set(1,false,"ECR缂栧彿涓嶈兘涓虹┖!");
+        }
 
         Cell codeCell = sheet.getRow(2).getCell(0);
-        if(codeCell == null){
-            return new Response().set(1,false,"鍙樻洿鏂欏彿涓嶈兘涓虹┖!");
+        if(codeCell == null || !codeCell.getStringCellValue().contains("鍙樻洿鏂欏彿")){
+            return new Response().set(1,false,"鍙樻洿鏂欏彿涓嶈兘涓虹┖鎴栧崟鍏冩牸鏍煎紡涓嶈鑼�!");
         }
         String codeCellValue = codeCell.getStringCellValue();
         //鍙樻洿鏂欏彿:xxx
@@ -79,8 +88,8 @@
         }
 
         Cell modelCell = sheet.getRow(2).getCell(5);
-        if(modelCell == null){
-            return new Response().set(1,false,"鍙樻洿鍨嬪彿涓嶈兘涓虹┖!");
+        if(modelCell == null || !modelCell.getStringCellValue().contains("鍙樻洿鍚嶇О/鍨嬪彿")){
+            return new Response().set(1,false,"鍙樻洿鍨嬪彿涓嶈兘涓虹┖鎴栧崟鍏冩牸鏍煎紡涓嶈鑼�!");
         }
         String modelCellValue = modelCell.getStringCellValue();
         //鍙樻洿鍚嶇О/鍨嬪彿锛歺xx
@@ -92,18 +101,55 @@
             modelSplit = modelStr.split("/");
         }
 
-        String proposeDateCellValue = sheet.getRow(2).getCell(14).getStringCellValue();
+        Cell proposeDateCell = sheet.getRow(2).getCell(14);
+        if(proposeDateCell == null || !proposeDateCell.getStringCellValue().contains("鐢宠鏃ユ湡")){
+            return new Response().set(1,false,"鐢宠鏃ユ湡涓嶈兘涓虹┖鎴栧崟鍏冩牸鏍煎紡涓嶈鑼�!");
+        }
+        String proposeDateCellValue = proposeDateCell.getStringCellValue();
         //鐢宠鏃ユ湡锛歺xx
         String proposeDateStr = proposeDateCellValue.substring(5).trim();
-        Date proposeDate = DateUtil.YYYY_MM_DD_UNION.parse(proposeDateStr);
-
-        String proposerCellValue = sheet.getRow(2).getCell(22).getStringCellValue();
+        if(proposeDateStr.equals("")){
+            return new Response().set(1,false,"鐢宠鏃ユ湡涓嶈兘涓虹┖!");
+        }
+        Date proposeDate;
+        try {
+            if(proposeDateStr.contains(".")){
+                proposeDate = DateUtil.YYYY_MM_DD_UNION2.parse(proposeDateStr);
+            }else if(proposeDateStr.contains("-")){
+                proposeDate = DateUtil.YYYY_MM_DD_UNION3.parse(proposeDateStr);
+            }else if(proposeDateStr.contains("/")){
+                proposeDate = DateUtil.YYYY_MM_DD_UNION4.parse(proposeDateStr);
+            }else {
+                proposeDate = DateUtil.YYYY_MM_DD_UNION.parse(proposeDateStr);
+            }
+        }catch (ParseException e){
+            return new Response().set(1,false,"鐢宠鏃ユ湡鏍煎紡閿欒!");
+        }
+        Cell proposerCell = sheet.getRow(2).getCell(22);
+        if(proposerCell == null || !proposerCell.getStringCellValue().contains("鐢宠浜�")){
+            return new Response().set(1,false,"鐢宠浜轰笉鑳戒负绌烘垨鍗曞厓鏍兼牸寮忎笉瑙勮寖!");
+        }
+        String proposerCellValue = proposerCell.getStringCellValue();
         //鐢宠浜猴細xxx
         String proposer = proposerCellValue.substring(4).trim();
+        if(proposer.equals("")){
+            return new Response().set(1,false,"鐢宠浜轰笉鑳戒负绌�!");
+        }
 
-        String parentModel = sheet.getRow(3).getCell(0).getStringCellValue().substring(10).trim();
+        Cell parentModelCell = sheet.getRow(3).getCell(0);
+        if(parentModelCell == null || !parentModelCell.getStringCellValue().contains("鍙樻洿鎵�灞炴満鍨�/绯诲垪")){
+            return new Response().set(1,false,"鐗╂枡鎵�灞炲瀷鍙蜂笉鑳戒负绌烘垨鍗曞厓鏍兼牸寮忎笉瑙勮寖!");
+        }
+        String parentModel = parentModelCell.getStringCellValue().substring(10).trim();
+        if(parentModel.equals("")){
+            return new Response().set(1,false,"鐗╂枡鎵�灞炲瀷鍙蜂笉鑳戒负绌�!");
+        }
 
-        String changeDescriptionCellValue = sheet.getRow(4).getCell(0).getStringCellValue();
+        Cell changeDescriptionCell = sheet.getRow(4).getCell(0);
+        if(changeDescriptionCell == null || changeDescriptionCell.getStringCellValue().trim().equals("")){
+            return new Response().set(1,false,"鍙樻洿鎻忚堪涓嶈兘涓虹┖!");
+        }
+        String changeDescriptionCellValue = changeDescriptionCell.getStringCellValue();
 
         //鐢宠鍙樻洿褰掔被:index浠�16-22,琚�変腑鐨勬爣璇嗕负鈻燚.鍝佽川鏀瑰杽
         StringBuilder changeTypeBuilder = new StringBuilder();
@@ -175,6 +221,11 @@
         if(solutionCellValue.contains("鈻�")){
             String solutionStr = solutionCellValue.split("鈻�")[1];
             solution = solutionStr.split("\\.")[1];
+            if(solution.contains("鈻�")){
+                solution = solution.split("鈻�")[0];
+            }
+        }else{
+            return new Response().set(1,false,"澶勭悊鏂瑰紡蹇呴』閫変腑涓�椤�!");
         }
 
         //鍏堝皢鍏卞悓灞炴�ц祴鍊肩粰鍩虹瀵硅薄
@@ -199,6 +250,15 @@
             ecrTemp.setSubModel(modelSplit[i]);
             ecrList.add(ecrTemp);
         }
+        //鎻愪氦涔嬪墠鍏堟牎楠屾祦姘村彿鏄惁瀛樺湪
+        QueryWrapper<ECR> query = Wrappers.query();
+        query.eq("number",ecrList.get(0).getNumber()).last(" limit 1");
+        ECR ecrNumberObj = mapper.selectOne(query);
+        if(ecrNumberObj!= null) {
+            return new Response().set(1,false,"ecr缂栧彿宸插瓨鍦�");
+        }
+        //瀛樺偍鎿嶄綔鎵ц
+        multipartFile.transferTo(new File(excelFilePath));
         mapper.insertBatchSomeColumn(ecrList);
 
         return new Response().set(1,true,"瀵煎叆瀹屾垚");
@@ -230,6 +290,13 @@
             ecrTemp.setSubModel(subModelSplit[i]);
             ecrList.add(ecrTemp);
         }
+        //鎻愪氦涔嬪墠鍏堟牎楠屾祦姘村彿鏄惁瀛樺湪
+        QueryWrapper<ECR> query = Wrappers.query();
+        query.eq("number",ecrList.get(0).getNumber()).last(" limit 1");
+        ECR ecrNumberObj = mapper.selectOne(query);
+        if(ecrNumberObj!= null) {
+            return new Response().set(1,false,"ecr缂栧彿宸插瓨鍦�");
+        }
         mapper.insertBatchSomeColumn(ecrList);
         return new Response().set(1,true,"瀵煎叆瀹屾垚");
     }
@@ -248,7 +315,7 @@
         }
         wrapper.ge("create_time",createTime);
         wrapper.le("create_time",createTime1);
-        wrapper.orderByAsc("number");
+        wrapper.orderByDesc("create_time");
         List list=mapper.selectList(wrapper);
         PageInfo pageInfo=new PageInfo(list);
         return new Response().setII(1,list.size()>0,pageInfo,"鏌ヨECR璁板綍");
@@ -264,9 +331,17 @@
         return list;
     }
 
-    public void exportExcel(HttpServletResponse response) {
-        //鏌ヨ鎵�鏈�
-        List<ECR> ecrList = mapper.selectList(null);
+    public void exportExcel(HttpServletResponse response, List<Integer> ids) {
+        List<ECR> ecrList;
+        if(ids == null) {
+            //鏌ヨ鎵�鏈�
+            ecrList = mapper.selectList(null);
+        }else{
+            //鏌ヨids鐨勮褰�
+            QueryWrapper<ECR> query = Wrappers.query();
+            query.in("id",ids);
+            ecrList = mapper.selectList(query);
+        }
         int size = ecrList.size();
         //ECR缂栧彿,鐢宠鏃ユ湡,鐢宠浜�,鍙樻洿鎻忚堪,鍙樻洿鏂欏彿,鍙樻洿鍨嬪彿,鍙樻洿鎵�灞炲瀷鍙�,澶勭悊鏂瑰紡,鍒涘缓鏃堕棿
         String[] title = new String[]{"骞翠唤","ECR缂栧彿","鐢宠鏃ユ湡","鐢宠浜�","鍙樻洿鎻忚堪","鍙樻洿鏂欏彿","鍙樻洿鍨嬪彿","鍙樻洿鎵�灞炲瀷鍙�","澶勭悊鏂瑰紡","鍒涘缓鏃堕棿"};
@@ -288,7 +363,30 @@
             values[i][8] = ecr.getSolution();
             values[i][9] = DateUtil.YYYY_MM_DD_HH_MM_SS.format(ecr.getCreateTime());
         }
-        String dateFormat = DateUtil.YYYY_MM_DD_HH_MM_SS.format(new Date());
+        String dateFormat = DateUtil.YYYY_MM_DD_HH_MM_SS2.format(new Date());
         ExcelUtil.exportExcel("鍙樻洿璁板綍娓呭崟_"+dateFormat,"娓呭崟",title,values,null,response);
     }
+    //鍒犻櫎ECR璁板綍
+    public Response deleteEcr(String number, String filePath) {
+        if(!(filePath==null||filePath.isEmpty())){
+            String fileDirName = FileDirPath.getFileDirName();
+            File file = new File(fileDirName+File.separator+filePath);
+            if(!file.isDirectory()){
+                file.delete();
+            }
+        }
+        //鍒犻櫎琛ㄨ褰�
+        UpdateWrapper wrapper=new UpdateWrapper();
+        wrapper.eq("number",number);
+        int delFlag=mapper.delete(wrapper);
+        return new Response().set(1,delFlag>0,"鍒犻櫎ECR");
+    }
+    //鍙嶉涓嬫媺鏌ヨECR璁板綍
+    public Response searchEcrInFeedback() {
+        QueryWrapper wrapper=new QueryWrapper();
+        wrapper.select("distinct number");
+        wrapper.orderByDesc("create_time");
+        List list=mapper.selectList(wrapper);
+        return new Response().setII(1,list.size()>0,list,"鏌ヨECR璁板綍");
+    }
 }

--
Gitblit v1.9.1