| | |
| | | package com.ld.igds.oa.view; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import java.util.*; |
| | | |
| | | import com.bstek.dorado.uploader.UploadFile; |
| | | import com.bstek.dorado.uploader.annotation.FileResolver; |
| | | import com.ld.igds.file.CoreFileService; |
| | | import com.ld.igds.models.*; |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String delArchives(OAArchives data) { |
| | | public String delArchives(OAArchives data) throws Exception { |
| | | List<FileInfo> list = data.getFileData(); |
| | | if (!list.isEmpty()) { |
| | | String fileId = list.get(0).getFileId(); |
| | | Date createTime = list.get(0).getCreateTime(); |
| | | if (null == createTime) { |
| | | createTime = new Date(); |
| | | } |
| | | |
| | | File file = new File(fileService.getCommonFilePath(createTime), fileId); |
| | | |
| | | if (!file.exists()) { |
| | | return "删除失败,系统未找到当前附件"; |
| | | } |
| | | |
| | | file.delete(); |
| | | fileService.delFile(fileId); |
| | | } |
| | | return service.delArchives(data); |
| | | } |
| | | |
| | | /** |
| | | * oaPR#uploadFile |
| | | * |
| | | * @param file |
| | | * @param parameter |
| | | * @return fileId 新文件ID包含文件后缀 |
| | | */ |
| | | @FileResolver |
| | | public String uploadFile(UploadFile file, Map<String, Object> parameter) { |
| | | String fileId = null; |
| | | String mark = (String) parameter.get("mark"); |
| | | if ("NO_UPLOAD".equals(mark)) { |
| | | return null; |
| | | } |
| | | try { |
| | | |
| | | String basePath = fileService.getCommonFilePath(null); |
| | | |
| | | fileId = ContextUtil.getTimeId(1000) |
| | | + file.getFileName().substring( |
| | | file.getFileName().lastIndexOf(".")); |
| | | |
| | | file.transferTo(new File(basePath + fileId)); |
| | | |
| | | } catch (IllegalStateException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return fileId; |
| | | } |
| | | |
| | | // =====================资产管理=====================// |
| | | |
| | | /** |