| | |
| | | /** |
| | | * 上传文件 |
| | | */ |
| | | public <T> List<MetaFileEntity> uploadData(T t, String path, HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | public <T> List<MetaFileEntity> uploadData(T t, String path, boolean isGetGuid, HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | StandardMultipartHttpServletRequest request = (StandardMultipartHttpServletRequest) req; |
| | | req.setCharacterEncoding("utf-8"); |
| | | res.setContentType("application/json;charset=utf-8"); |
| | |
| | | setEntity(t, request); |
| | | } |
| | | |
| | | return getFiles(path, request); |
| | | return getFiles(path, isGetGuid, request); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 获取文件 |
| | | */ |
| | | public List<MetaFileEntity> getFiles(String subPath, StandardMultipartHttpServletRequest req) throws Exception { |
| | | public List<MetaFileEntity> getFiles(String subPath, boolean isGetGuid, StandardMultipartHttpServletRequest req) throws Exception { |
| | | List<MetaFileEntity> list = new ArrayList<>(); |
| | | |
| | | String path = pathHelper.getTempPath(subPath); |
| | |
| | | mf.setPath(path + File.separator + mf.getName()); |
| | | |
| | | file.transferTo(new File(mf.getPath())); |
| | | mf.setGuid(FileHelper.getFileMd5(mf.getPath())); |
| | | if (isGetGuid) { |
| | | mf.setGuid(FileHelper.getFileMd5(mf.getPath())); |
| | | } |
| | | |
| | | list.add(mf); |
| | | } |
| | |
| | | } |
| | | |
| | | List<MetaFileEntity> list = new ArrayList<>(); |
| | | List<DirEntity> dirs = dirService.selectDirRecursive(dir.getName()); |
| | | List<DirEntity> dirs = dirService.selectRecursiveById(dir.getId()); |
| | | for (MetaFileEntity meta : metas) { |
| | | meta.setEventid(StringHelper.getGuid()); |
| | | meta.setDircode(dir.getCode()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建源数据文件实体类 |
| | | * 创建元数据文件实体类 |
| | | */ |
| | | private MetaFileEntity createMetaFileEntity(MetaFileEntity meta) { |
| | | MetaFileEntity mf = new MetaFileEntity(); |
| | |
| | | filePath = filePath.replace("/", "\\"); |
| | | } |
| | | |
| | | fileName = fileName.toLowerCase(); |
| | | filePath = filePath.toLowerCase(); |
| | | for (DirEntity entity : dirs) { |
| | | if (filePath.contains(entity.getFullName() + "\\" + fileName)) { |
| | | if (filePath.contains(entity.getFullName().toLowerCase() + "\\" + fileName)) { |
| | | return entity.getCode(); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 设置源数据文件的类型 |
| | | * 设置元数据文件的类型 |
| | | */ |
| | | private void setMetaType(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |
| | |
| | | * Enumeration<String> attributes = req.getAttributeNames(); |
| | | */ |
| | | public Map<String, String> getParams(StandardMultipartHttpServletRequest req) { |
| | | Map<String, String> map = new HashMap<String, String>(3); |
| | | Map<String, String> map = new HashMap<>(3); |
| | | |
| | | Enumeration<String> enumeration = req.getParameterNames(); |
| | | while (enumeration.hasMoreElements()) { |