| | |
| | | import com.bstek.dorado.uploader.annotation.FileResolver; |
| | | import com.fzzy.igds.service.FileService; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.config.FrameworkConfig; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang.time.DateFormatUtils; |
| | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * @Description Dorado7 附件上传公共管理层 |
| | |
| | | @FileResolver |
| | | public String imgFile(UploadFile file, Map<String, Object> parameter) { |
| | | |
| | | String fileId = null; |
| | | String filePath = null; |
| | | try { |
| | | |
| | | String basePath = fileService.getFileSavePath("DEPT"); |
| | | |
| | | fileId = "aerial-" + ContextUtil.subDeptId(null) |
| | | //新文件名 |
| | | String fileId = "aerial-" + ContextUtil.subDeptId(null) |
| | | + file.getFileName().substring( |
| | | file.getFileName().lastIndexOf(".")); |
| | | //文件全路径 |
| | | filePath = basePath + fileId; |
| | | //保存 |
| | | file.transferTo(new File(filePath)); |
| | | |
| | | file.transferTo(new File(basePath + fileId)); |
| | | //替换后文件全路径 |
| | | filePath = filePath.replace(FrameworkConfig.getProfile(), "/profile/"); |
| | | |
| | | } catch (IllegalStateException e) { |
| | | e.printStackTrace(); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return fileId; |
| | | return filePath; |
| | | } |
| | | |
| | | /** |
| | |
| | | return newFileName; |
| | | } |
| | | |
| | | /** |
| | | * 上传出入库导入Excel模板 |
| | | * fileUploadManage#uploadExcel |
| | | * @param file |
| | | * @param parameter |
| | | * @return |
| | | */ |
| | | @FileResolver |
| | | public String uploadExcel(UploadFile file, Map<String, Object> parameter) { |
| | | String newFileName = null; |
| | | try { |
| | | String basePath = fileService.getFileSavePath("TEMP"); |
| | | |
| | | newFileName = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss"); |
| | | newFileName = "EXCEL" + "_" + newFileName; |
| | | |
| | | // 文件后缀名 |
| | | String suffixName = file.getFileName().substring(file.getFileName().lastIndexOf(".")); |
| | | |
| | | // 合成新的文件名 |
| | | newFileName = newFileName + suffixName; |
| | | file.transferTo(new File(basePath + newFileName)); |
| | | |
| | | } catch (IllegalStateException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return newFileName; |
| | | } |
| | | } |