|
@@ -3,6 +3,8 @@
|
|
|
*/
|
|
|
package com.jeeplus.modules.workstaff.service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.text.ParseException;
|
|
@@ -14,6 +16,7 @@ import java.util.Map;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import com.jeeplus.common.bos.BOSClientUtil;
|
|
|
import com.jeeplus.common.config.Global;
|
|
|
import com.jeeplus.common.oss.OSSClientUtil;
|
|
|
import com.jeeplus.common.utils.DateUtils;
|
|
@@ -111,42 +114,59 @@ public class WorkStaffEducationService extends CrudService<WorkStaffEducationDao
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
- public String uploadFile(MultipartFile file, String filePath) {
|
|
|
- if (file != null && !file.isEmpty() &&file.getSize()>0) {
|
|
|
- String key = "";
|
|
|
- if (StringUtils.isNotBlank(filePath)) {
|
|
|
- String aliyunUrl = Global.getAliyunUrl();
|
|
|
- String aliDownloadUrl = Global.getAliDownloadUrl();
|
|
|
- String cons = "";
|
|
|
- if (filePath.contains(aliyunUrl)) {
|
|
|
- cons = aliyunUrl;
|
|
|
- } else if (filePath.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")) {
|
|
|
- cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
- } else {
|
|
|
- cons = aliDownloadUrl;
|
|
|
- }
|
|
|
- String[] arr = filePath.split(cons + "/");
|
|
|
- key = arr[1];
|
|
|
- }
|
|
|
- try {
|
|
|
- OSSClientUtil ossUtil1 = new OSSClientUtil();
|
|
|
- if (StringUtils.isNotBlank(key)) {
|
|
|
- ossUtil1.deleteSingleObject(key);
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- logger.error("oss删除文件失败!");
|
|
|
- }
|
|
|
- try {
|
|
|
- OSSClientUtil ossUtil = new OSSClientUtil();
|
|
|
- String path = Global.getStaffBasicFilePath()+ DateUtils.formatDate(new Date(),null)+"/";
|
|
|
- String newName = System.currentTimeMillis()+"-"+file.getOriginalFilename();
|
|
|
- ossUtil.uploadFile2OSS(file.getInputStream(),path,newName);
|
|
|
- return Global.getAliDownloadUrl() + "/" + path + newName;
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("oss上传文件失败!");
|
|
|
+// public String uploadFile(MultipartFile file, String filePath) {
|
|
|
+// if (file != null && !file.isEmpty() &&file.getSize()>0) {
|
|
|
+// String key = "";
|
|
|
+// if (StringUtils.isNotBlank(filePath)) {
|
|
|
+// String aliyunUrl = Global.getAliyunUrl();
|
|
|
+// String aliDownloadUrl = Global.getAliDownloadUrl();
|
|
|
+// String cons = "";
|
|
|
+// if (filePath.contains(aliyunUrl)) {
|
|
|
+// cons = aliyunUrl;
|
|
|
+// } else if (filePath.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")) {
|
|
|
+// cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
+// } else {
|
|
|
+// cons = aliDownloadUrl;
|
|
|
+// }
|
|
|
+// String[] arr = filePath.split(cons + "/");
|
|
|
+// key = arr[1];
|
|
|
+// }
|
|
|
+// try {
|
|
|
+// OSSClientUtil ossUtil1 = new OSSClientUtil();
|
|
|
+// if (StringUtils.isNotBlank(key)) {
|
|
|
+// ossUtil1.deleteSingleObject(key);
|
|
|
+// }
|
|
|
+// }catch (Exception e){
|
|
|
+// logger.error("oss删除文件失败!");
|
|
|
+// }
|
|
|
+// try {
|
|
|
+// OSSClientUtil ossUtil = new OSSClientUtil();
|
|
|
+// String path = Global.getStaffBasicFilePath()+ DateUtils.formatDate(new Date(),null)+"/";
|
|
|
+// String newName = System.currentTimeMillis()+"-"+file.getOriginalFilename();
|
|
|
+// ossUtil.uploadFile2OSS(file.getInputStream(),path,newName);
|
|
|
+// return Global.getAliDownloadUrl() + "/" + path + newName;
|
|
|
+// } catch (Exception e) {
|
|
|
+// logger.error("oss上传文件失败!");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return filePath;
|
|
|
+// }
|
|
|
+
|
|
|
+ public String uploadFile(MultipartFile file, String filePath){
|
|
|
+ String date = DateUtils.formatDate(new Date(),"yyMMddHHmm");
|
|
|
+ try {
|
|
|
+ if (file != null && file.getSize() > 0) {
|
|
|
+ String path = new StringBuilder("/employeeInfo/").append(date)
|
|
|
+ .append(file.getOriginalFilename()).toString();
|
|
|
+ InputStream inputStream = file.getInputStream();
|
|
|
+ BOSClientUtil bosClientUtil = new BOSClientUtil();
|
|
|
+ String url = bosClientUtil.upload(path, inputStream);
|
|
|
+ return url;
|
|
|
}
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error("上传文件失败!");
|
|
|
}
|
|
|
- return filePath;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
public void query(WorkStaffBasicInfo workStaffBasicInfo) {
|