Fixiaobai
2023-11-09 3059430a0db3f75426e435c06090358646fc3792
mes-technology/src/main/java/com/chinaztt/mes/technology/controller/StructureController.java
@@ -32,9 +32,11 @@
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;
@@ -60,6 +62,8 @@
   private final StructureService structureService;
   private final DictUtils dictUtils;
   private RedisTemplate redisTemplate;
   /**
    * 横着导入的导入方式
    *
@@ -68,6 +72,10 @@
    */
   @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 {
         excelReader = EasyExcel.read(file.getInputStream(), StructureData.class, new StructureUploadListener(structureService)).build();