From cb9fbcd27a288d0c61d85fa13ff5fc8eb1f4deab Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期六, 18 三月 2023 16:44:56 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/data/upload/UploadController.java | 72 +++++++++++++++++++++++++++++++---- 1 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/lf/server/controller/data/upload/UploadController.java b/src/main/java/com/lf/server/controller/data/upload/UploadController.java index 02435a3..28ff4cf 100644 --- a/src/main/java/com/lf/server/controller/data/upload/UploadController.java +++ b/src/main/java/com/lf/server/controller/data/upload/UploadController.java @@ -3,11 +3,14 @@ import com.lf.server.annotation.SysLog; import com.lf.server.entity.all.ResponseMsg; import com.lf.server.entity.all.StaticData; +import com.lf.server.entity.ctrl.KeyValueEntity; import com.lf.server.entity.data.DirEntity; +import com.lf.server.entity.data.MetaEntity; import com.lf.server.entity.data.MetaFileEntity; import com.lf.server.entity.data.VerEntity; import com.lf.server.entity.sys.UserEntity; import com.lf.server.helper.StringHelper; +import com.lf.server.service.all.UploadAttachService; import com.lf.server.service.data.UploadService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -31,6 +34,9 @@ @Autowired UploadService uploadService; + @Autowired + UploadAttachService uploadAttachService; + @SysLog() @ApiOperation(value = "鏌ヨ璺緞") @GetMapping(value = "/selectPath") @@ -40,7 +46,8 @@ return success(pathName); } catch (Exception ex) { - return fail(ex.getMessage(), null); + log.error(ex.getMessage(), ex); + return fail(ex, null); } } @@ -53,14 +60,61 @@ @PostMapping(value = "/uploadFiles") public ResponseMsg<Object> uploadFiles(String path, HttpServletRequest req, HttpServletResponse res) { try { - List<MetaFileEntity> list = uploadService.uploadData(null, path, req, res); + List<MetaFileEntity> list = uploadService.uploadData(null, path, false, req, res); if (null == list || list.isEmpty()) { return fail("娌℃湁鎵惧埌涓婁紶鏂囦欢", null); } + uploadService.copePath(list); + return success(list); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); + } + } + + /** + * 鎺ユ敹鏁扮粍1锛欯RequestParam(value = "ids")List<Integer> ids + * &ids=1209&ids=1180&ids=1387 + * 鎺ユ敹鏁版嵁2锛欼nteger[] ids + * formData.append("ids", 1209); formData.append("ids", 1180); formData.append("ids", 1387); + */ + @SysLog() + @ApiOperation(value = "涓婁紶Excel闄勪欢") + @ApiImplicitParams({ + @ApiImplicitParam(name = "path", value = "璺緞", dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "ids", value = "鍏冩暟鎹泦鍚�", dataType = "Integer", paramType = "query") + }) + @ResponseBody + @PostMapping(value = "/uploadXlsAnnex") + public ResponseMsg<Object> uploadXlsAnnex(String path, Integer[] ids, HttpServletRequest req, HttpServletResponse res) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue == null) { + return fail("鐢ㄦ埛鏈櫥褰�", null); + } + if (null == ids || ids.length == 0) { + return fail("鎵句笉鍒板厓鏁版嵁鐨処D闆嗗悎"); + } + + List<MetaEntity> ms = metaService.selectXlsAnnex(ids, UploadAttachService.getTabs()); + if (null == ms || ms.isEmpty()) { + return fail("鎵句笉鍒拌涓婁紶闄勪欢鐨勫厓鏁版嵁"); + } + + List<MetaFileEntity> list = uploadService.uploadData(null, path, false, req, res); + if (null == list || list.isEmpty()) { + return fail("娌℃湁鎵惧埌涓婁紶鏂囦欢", null); + } + + List<KeyValueEntity> rs = uploadAttachService.uploadXlsAnnex(ue, ms, list, path); + if (null == rs || rs.size() == 0) { + return fail("娌℃湁瑕佹洿鏂扮殑鍏冩暟鎹�"); + } + + return success(rs); + } catch (Exception ex) { + return fail(ex, null); } } @@ -72,11 +126,11 @@ @GetMapping(value = "/selectFiles") public ResponseMsg<List<MetaFileEntity>> selectFiles(String path) { try { - List<MetaFileEntity> list = uploadService.selectFiles(path, StaticData.ALL_EXTENSION); + List<MetaFileEntity> list = uploadService.selectFiles(path); return success(list); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -101,7 +155,7 @@ return success("鎴愬姛", rows); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -136,7 +190,7 @@ return success(list); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -161,7 +215,7 @@ return success("鎴愬姛", list); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -181,7 +235,7 @@ return success(count); } catch (Exception ex) { - return fail(ex.getMessage(), -1); + return fail(ex, -1); } } } -- Gitblit v1.9.3