|
@@ -3,6 +3,7 @@
|
|
|
*/
|
|
|
package com.jeeplus.modules.workstaff.service;
|
|
|
|
|
|
+import java.io.InputStream;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
import java.lang.reflect.Method;
|
|
@@ -14,6 +15,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;
|
|
@@ -106,42 +108,21 @@ public class WorkStaffTitleService extends CrudService<WorkStaffTitleDao, WorkSt
|
|
|
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 ossUtil1 = new OSSClientUtil();
|
|
|
- String path = Global.getStaffBasicFilePath()+ DateUtils.formatDate(new Date(),null)+"/";
|
|
|
- String newName = System.currentTimeMillis()+"-"+file.getOriginalFilename();
|
|
|
- ossUtil1.uploadFile2OSS(file.getInputStream(),path,newName);
|
|
|
- return Global.getAliDownloadUrl() + "/" + path + newName;
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("oss上传文件失败!");
|
|
|
+ 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) {
|