|
@@ -21,7 +21,6 @@ import com.hwrj.cloud.admin.util.EasyExcelUtil;
|
|
|
import com.hwrj.cloud.admin.util.OrderNo;
|
|
|
import com.hwrj.cloud.admin.util.UploadFileUtil;
|
|
|
import com.hwrj.cloud.common.api.CommonResult;
|
|
|
-import com.hwrj.cloud.common.exception.GlobalException;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -35,7 +34,10 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+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.File;
|
|
@@ -72,6 +74,7 @@ public class UploadCompanyInfoAndProductController {
|
|
|
@ApiImplicitParam(name = "compName", value = "公司名称", required = false)
|
|
|
})
|
|
|
@PostMapping("/upload")
|
|
|
+ @Transactional
|
|
|
public CommonResult readFile(@RequestParam(value = "paths") String paths, @RequestParam(value = "type") String type, @RequestParam(value = "compName", required = false) String compName) {
|
|
|
|
|
|
if ("1".equals(type)) {
|
|
@@ -168,7 +171,12 @@ public class UploadCompanyInfoAndProductController {
|
|
|
infoFile.setFileStatus(0);
|
|
|
String imgName = br + s;
|
|
|
str = str.toLowerCase();
|
|
|
- String[] split = str.split("\\.");
|
|
|
+ String[] split = null;
|
|
|
+ try {
|
|
|
+ split = str.split("\\.");
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("获取文件后缀出错!=======>" + split);
|
|
|
+ }
|
|
|
imgName = imgName + "." + split[1];
|
|
|
String filePath = path + "\\" + str;
|
|
|
infoFile.setFileUrl(url + imgName);
|
|
@@ -270,7 +278,12 @@ public class UploadCompanyInfoAndProductController {
|
|
|
for (int i = 0; i < file.size(); i++) {
|
|
|
String oldFileName = file.get(i);
|
|
|
String s = OrderNo.NextOrderNo();
|
|
|
- String[] split = oldFileName.split("\\.");
|
|
|
+ String[] split = null;
|
|
|
+ try {
|
|
|
+ split = oldFileName.split("\\.");
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("获取文件后缀出错!=======>" + split);
|
|
|
+ }
|
|
|
String fileName = br + s + "." + split[1];
|
|
|
uploadFileUtil.uploadLocalFile(path + "\\" + oldFileName, fileName);
|
|
|
if (i > 0) {
|
|
@@ -366,7 +379,12 @@ public class UploadCompanyInfoAndProductController {
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
for (String s : file) {
|
|
|
String fs = br + OrderNo.NextOrderNo();
|
|
|
- String[] split = s.split("\\.");
|
|
|
+ String[] split = null;
|
|
|
+ try {
|
|
|
+ split = s.split("\\.");
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("获取文件后缀出错!=======>" + split);
|
|
|
+ }
|
|
|
fs = fs + "." + split[1];
|
|
|
uploadFileUtil.uploadLocalFile(upPath + "\\" + s, fs);
|
|
|
if (s.contains("首图")) {
|
|
@@ -496,7 +514,7 @@ public class UploadCompanyInfoAndProductController {
|
|
|
list = EasyExcelUtil.readExcel(file, new UmsMemberOriginExcel(), 2, 2);
|
|
|
} catch (IOException e) {
|
|
|
//e.printStackTrace();
|
|
|
- throw new GlobalException(1, "上传文件错误!");
|
|
|
+ throw new RuntimeException("上传文件错误!");
|
|
|
}
|
|
|
if (list != null && list.size() > 0) {
|
|
|
for (Object obj : list) {
|
|
@@ -558,7 +576,7 @@ public class UploadCompanyInfoAndProductController {
|
|
|
list = EasyExcelUtil.readExcel(file, new PmsProductExcel(), 3, 2);
|
|
|
} catch (IOException e) {
|
|
|
//e.printStackTrace();
|
|
|
- throw new GlobalException(1, "上传文件错误!");
|
|
|
+ throw new RuntimeException("上传文件错误!");
|
|
|
}
|
|
|
if (list != null && list.size() > 0) {
|
|
|
for (Object obj : list) {
|