From 6b81463956244414475df449d3f3a773a3839d44 Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期二, 21 二月 2023 10:10:20 +0800
Subject: [PATCH] ecr更新

---
 src/main/java/com/whyc/service/ECRService.java |   36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/whyc/service/ECRService.java b/src/main/java/com/whyc/service/ECRService.java
index 8121989..fc8c1d9 100644
--- a/src/main/java/com/whyc/service/ECRService.java
+++ b/src/main/java/com/whyc/service/ECRService.java
@@ -11,8 +11,11 @@
 import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.text.ParseException;
@@ -26,7 +29,26 @@
     @Resource
     private ECRMapper mapper;
 
-    public Response ecrImportByExcel(InputStream inputStream) throws IOException, InvalidFormatException, ParseException {
+    @Transactional
+    public Response ecrImportByExcel(MultipartFile multipartFile) throws IOException, InvalidFormatException, ParseException {
+        InputStream inputStream = multipartFile.getInputStream();
+        //瀛樺偍excel
+        String originalFilename = multipartFile.getOriginalFilename();
+        Date date = new Date();
+        String dateUnion = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(date);
+        //瀛樺偍璺緞
+        String rootFile = CommonUtil.getRootFile();
+        String excelDir = rootFile + "ecr";
+        File excelDirFile = new File(excelDir);
+        if(!excelDirFile.exists()){
+            excelDirFile.mkdirs();
+        }
+        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));
+
+        int a = 0;
+        int b = 3/a;
         Workbook workbook = null;
         workbook = WorkbookFactory.create(inputStream);
         inputStream.close();
@@ -65,6 +87,8 @@
         String proposerCellValue = sheet.getRow(2).getCell(22).getStringCellValue();
         //鐢宠浜猴細xxx
         String proposer = proposerCellValue.substring(4).trim();
+
+        String parentModel = sheet.getRow(3).getCell(0).getStringCellValue().substring(10).trim();
 
         String changeDescriptionCellValue = sheet.getRow(4).getCell(0).getStringCellValue();
 
@@ -127,7 +151,7 @@
             }
         }
         String changeType = changeTypeBuilder.toString();
-        String changeDescription = changeDescriptionCellValue + "\n"+changeType;
+        String changeDescription = changeDescriptionCellValue + "\n鍙樻洿鍘熷洜绫诲埆:"+changeType;
 
         //澶勭悊鏂瑰紡,澶勭悊鏂瑰紡:
         //鈻�1.鎶ュ簾.  鈻�2. 鐢ㄥ畬涓烘  鈻�3. 閲嶅伐(鍙�)
@@ -146,13 +170,15 @@
         ecr.setProposer(proposer);
         ecr.setChangeDescription(changeDescription);
         ecr.setSolution(solution);
-        ecr.setCreateTime(new Date());
+        ecr.setCreateTime(date);
+        ecr.setExcelFile(excelHttpUrl);
+        ecr.setParentModel(parentModel);
         //璧嬪�肩粰鍏蜂綋瀵硅薄
         for (int i = 0; i < codeSplit.length; i++) {
             ECR ecrTemp = new ECR();
             BeanUtils.copyProperties(ecr,ecrTemp);
-            ecrTemp.setCode(CommonUtil.codeAutoFill(codeSplit[i]));
-            ecrTemp.setModel(modelSplit[i]);
+            ecrTemp.setSubCode(CommonUtil.codeAutoFill(codeSplit[i]));
+            ecrTemp.setSubModel(modelSplit[i]);
             ecrList.add(ecrTemp);
         }
         mapper.insertBatchSomeColumn(ecrList);

--
Gitblit v1.9.1