From 230d545b463b48febcce58d54ca03382f8e657ae Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期三, 15 十一月 2023 18:02:50 +0800
Subject: [PATCH] Changes13
---
mes-technology/src/main/java/com/chinaztt/mes/technology/controller/StructureController.java | 68 ++++++++++++++++++----------------
1 files changed, 36 insertions(+), 32 deletions(-)
diff --git a/mes-technology/src/main/java/com/chinaztt/mes/technology/controller/StructureController.java b/mes-technology/src/main/java/com/chinaztt/mes/technology/controller/StructureController.java
index 081b37e..cace20d 100644
--- a/mes-technology/src/main/java/com/chinaztt/mes/technology/controller/StructureController.java
+++ b/mes-technology/src/main/java/com/chinaztt/mes/technology/controller/StructureController.java
@@ -19,29 +19,30 @@
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
-import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaztt.mes.basic.util.DictUtils;
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
-import com.chinaztt.mes.technology.excel.*;
import com.chinaztt.mes.technology.dto.StructureDTO;
import com.chinaztt.mes.technology.entity.StructureComponent;
+import com.chinaztt.mes.technology.excel.StructureData;
+import com.chinaztt.mes.technology.excel.StructureUploadListener;
import com.chinaztt.mes.technology.service.StructureService;
import com.chinaztt.ztt.admin.api.entity.SysDictItem;
import com.chinaztt.ztt.admin.api.feign.RemoteDictService;
import com.chinaztt.ztt.common.core.util.R;
import com.chinaztt.ztt.common.log.annotation.SysLog;
+import com.chinaztt.ztt.common.security.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
@@ -61,6 +62,8 @@
private final StructureService structureService;
private final DictUtils dictUtils;
+ private RedisTemplate redisTemplate;
+
/**
* 妯潃瀵煎叆鐨勫鍏ユ柟寮�
*
@@ -69,17 +72,16 @@
*/
@PostMapping("/uploadExt")
public R uploadExt(@RequestParam("file") MultipartFile file) {
+ String key = "syncStructure_lock" + SecurityUtils.getUser().getId();
+ if (redisTemplate.hasKey(key)) {
+ throw new RuntimeException("鏈夊鍏ヤ换鍔℃鍦ㄥ鐞�");
+ }
ExcelReader excelReader = null;
try {
- ExcelReaderBuilder excelReaderBuilder = EasyExcel.read(file.getInputStream());
- excelReader = excelReaderBuilder.build();
- List<ReadSheet> sheets = excelReader.excelExecutor().sheetList();
- List<ReadSheet> readSheetList = new ArrayList<>();
- for (ReadSheet sheet : sheets) {
- ReadSheet readSheet = EasyExcel.readSheet(sheet.getSheetName()).registerReadListener(new StructureUploadExtListener(structureService)).build();
- readSheetList.add(readSheet);
- }
- excelReader.read(readSheetList);
+ excelReader = EasyExcel.read(file.getInputStream(), StructureData.class, new StructureUploadListener(structureService)).build();
+ ReadSheet readSheet = EasyExcel.readSheet(0).build();
+ ReadSheet readSheet2 = EasyExcel.readSheet(1).build();
+ excelReader.read(readSheet,readSheet2);
} catch (IOException e) {
e.printStackTrace();
return R.failed(e.getMessage());
@@ -96,26 +98,27 @@
* 绔栫潃瀵煎叆
*
* @param file
- * @return
- */
- @PostMapping("/upload")
- public R simpleRead(@RequestParam("file") MultipartFile file) {
- ExcelReader excelReader = null;
- try {
- excelReader = EasyExcel.read(file.getInputStream(), StructureData.class, new StructureUploadListener(structureService, dictUtils)).build();
- ReadSheet readSheet = EasyExcel.readSheet(0).build();
- excelReader.read(readSheet);
- } catch (IOException e) {
- e.printStackTrace();
- return R.failed(e.getMessage());
- } finally {
- if (excelReader != null) {
- // 杩欓噷鍗冧竾鍒繕璁板叧闂紝璇荤殑鏃跺�欎細鍒涘缓涓存椂鏂囦欢锛屽埌鏃剁鐩樹細宕╃殑
- excelReader.finish();
- }
- }
- return R.ok();
- }
+// * @return
+// */
+// @PostMapping("/upload")
+// public R simpleRead(@RequestParam("file") MultipartFile file) {
+// ExcelReader excelReader = null;
+// try {
+// excelReader = EasyExcel.read(file.getInputStream(), StructureData.class, new StructureUploadListener(structureService)).build();
+// ReadSheet readSheet = EasyExcel.readSheet(0).build();
+// ReadSheet readSheet2 = EasyExcel.readSheet(1).build();
+// excelReader.read(readSheet,readSheet2);
+// } catch (IOException e) {
+// e.printStackTrace();
+// return R.failed(e.getMessage());
+// } finally {
+// if (excelReader != null) {
+// // 杩欓噷鍗冧竾鍒繕璁板叧闂紝璇荤殑鏃跺�欎細鍒涘缓涓存椂鏂囦欢锛屽埌鏃剁鐩樹細宕╃殑
+// excelReader.finish();
+// }
+// }
+// return R.ok();
+// }
/**
* 鏍规嵁闆朵欢鍙锋煡璇㈤粯璁OM
@@ -195,6 +198,7 @@
@PostMapping
@PreAuthorize("@pms.hasPermission('technology_structure_add')")
public R save(@RequestBody StructureDTO structure) {
+ System.out.println("===========================>"+structure);
return structureService.fullSave(structure);
}
--
Gitblit v1.9.3