|
@@ -1,18 +1,28 @@
|
|
|
package com.fdkankan.manage.test;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import com.fdkankan.manage.common.ResultCode;
|
|
|
import com.fdkankan.manage.common.ResultData;
|
|
|
import com.fdkankan.common.util.SecurityUtil;
|
|
|
import com.fdkankan.manage.common.FilePath;
|
|
|
+import com.fdkankan.manage.exception.BusinessException;
|
|
|
import com.fdkankan.manage.httpClient.service.LaserService;
|
|
|
import com.fdkankan.manage.util.Dateutils;
|
|
|
+import com.fdkankan.manage.util.ExcelUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
+@RequestMapping("/test")
|
|
|
public class TestController {
|
|
|
|
|
|
@RequestMapping("/test")
|
|
@@ -20,8 +30,26 @@ public class TestController {
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- System.out.println( SecurityUtil.MD5("E\u0005\u0015\u000EG107"));
|
|
|
+ /**
|
|
|
+ * 导入excel
|
|
|
+ * type 0 入库模板, 1出库模板 ,2 客户关联模板
|
|
|
+ */
|
|
|
+ @PostMapping("/uploadExcel")
|
|
|
+ public ResultData uploadExcel(@RequestParam(required = false) MultipartFile file) throws IOException {
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+ assert originalFilename != null;
|
|
|
+ String fileType=originalFilename.substring(originalFilename.lastIndexOf(".")+1);
|
|
|
+ if (!fileType.equalsIgnoreCase("xlsx")) {
|
|
|
+ throw new BusinessException(ResultCode.FILE_TYPE_ERROR);
|
|
|
+ }
|
|
|
+ List<HashMap<Integer, String>> excelRowList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ excelRowList = ExcelUtil.getExcelRowList(file);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new BusinessException(ResultCode.TEMPLATE_TYPE_ERROR);
|
|
|
+ }
|
|
|
+ System.out.println(excelRowList);
|
|
|
+ return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
}
|