| | |
| | | @ApiOperation(value = "上传元数据") |
| | | @ResponseBody |
| | | @PostMapping(value = "/uploadMetaData") |
| | | public ResponseMsg<Object> uploadMetaData(HttpServletRequest req, HttpServletResponse res) { |
| | | public ResponseMsg<Object> uploadMetaData(String path, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | MetaEntity me = new MetaEntity(); |
| | | List<MetaFileEntity> list = uploaderService.uploadData(me, ue, req, res); |
| | | if (list.size() == 0 || me.getDirid() == 0) { |
| | | List<MetaFileEntity> list = uploaderService.uploadData(null, ue, req, res); |
| | | if (list.size() == 0) { |
| | | return fail("没有找到上传数据", null); |
| | | } |
| | | |
| | |
| | | /** |
| | | * 获取临时路径 |
| | | */ |
| | | public String getTempPath(int id) { |
| | | String tempName = StringHelper.YMD__FORMAT.format(new Date()); |
| | | public String getTempPath() { |
| | | String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date()); |
| | | String tempPath = config.getTempPath(); |
| | | String path = tempPath + File.separator + tempName + id; |
| | | String path = tempPath + File.separator + tempName; |
| | | |
| | | File file = new File(path); |
| | | if (!file.exists() && !file.isDirectory()) { |
| | |
| | | |
| | | private final static Log log = LogFactory.getLog(CommonsFileuploadService.class); |
| | | |
| | | public Object fileUpload(UserEntity ue, HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | public Object fileUpload(HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | List<FileItem> items = getFileItem(req, res); |
| | | |
| | | return copeFileItems(ue, items, req); |
| | | return copeFileItems(items, req); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 处理解析内容:处理普通表单域和文件表单域 |
| | | */ |
| | | private Object copeFileItems(UserEntity ue, List<FileItem> items, HttpServletRequest req) throws Exception { |
| | | private Object copeFileItems(List<FileItem> items, HttpServletRequest req) throws Exception { |
| | | Map<String, String> map = new HashMap<String, String>(3); |
| | | List<FileInfoEntity> list = new ArrayList<FileInfoEntity>(); |
| | | |
| | | String path = pathHelper.getTempPath(ue.getId()); |
| | | String path = pathHelper.getTempPath(); |
| | | for (FileItem item : items) { |
| | | if (item.isFormField()) { |
| | | String key = item.getFieldName(); |
| | |
| | | |
| | | // 传输文件 |
| | | String oldName = file.getOriginalFilename(); |
| | | String filePath = pathHelper.getTempPath(ue.getId()) + File.separator + oldName; |
| | | String filePath = pathHelper.getTempPath() + File.separator + oldName; |
| | | File newFile = new File(filePath); |
| | | file.transferTo(newFile); |
| | | double sizes = FileHelper.sizeToMb(file.getSize()); |
| | |
| | | if (t != null) { |
| | | setEntity(t, req); |
| | | } |
| | | List<MetaFileEntity> list = getFiles(ue, req); |
| | | List<MetaFileEntity> list = getFiles(req); |
| | | |
| | | return list; |
| | | } |
| | |
| | | /** |
| | | * 获取文件 |
| | | */ |
| | | private List<MetaFileEntity> getFiles(UserEntity ue, StandardMultipartHttpServletRequest req) throws Exception { |
| | | private List<MetaFileEntity> getFiles(StandardMultipartHttpServletRequest req) throws Exception { |
| | | List<MetaFileEntity> list = new ArrayList<MetaFileEntity>(); |
| | | |
| | | String path = pathHelper.getTempPath(ue.getId()); |
| | | String path = pathHelper.getTempPath(); |
| | | Iterator<String> iterator = req.getFileNames(); |
| | | while (iterator.hasNext()) { |
| | | MultipartFile file = req.getFile(iterator.next()); |
| | |
| | | Field[] fields = entity.getClass().getDeclaredFields(); |
| | | for (Field field : fields) { |
| | | try { |
| | | if (field.getName() == "serialVersionUID") { |
| | | if ("serialVersionUID".equals(field.getName())) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | * @throws Exception 异常 |
| | | */ |
| | | public String downloadShp(UserEntity ue, List<MarkJsonEntity> list, HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | String parent = pathHelper.getTempPath(ue.getId()); |
| | | String parent = pathHelper.getTempPath(); |
| | | |
| | | String path = createShapeFiles(ue, list, parent); |
| | | File[] files = new File(path).listFiles(); |