From 42f5453644c41d3b6ac9e381f931efdfc9da8178 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期一, 27 五月 2024 16:09:56 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java | 73 +++++++++++++++++++++++++++++------- 1 files changed, 59 insertions(+), 14 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java index 092c73d..cb35271 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java @@ -100,16 +100,16 @@ schema = @Schema(implementation = Boolean.class))} ) }) - @GetMapping(path = "delete") + @PostMapping(path = "delete") @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> delete( Long id) { - if (id == null ) { + public BaseResponse<Boolean> delete(@RequestBody Map map) { + if (map == null || map.size() <= 0) { BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage()); } -// Long groupId = Long.parseLong(map.get("id").toString()); + Long groupId = Long.parseLong(map.get("id").toString()); try { - Integer rows = irrigateGroupSv.deleteIrrigateGroup(id); + Integer rows = irrigateGroupSv.deleteIrrigateGroup(groupId); if (rows == 0) { return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage()); } @@ -250,14 +250,24 @@ @PostMapping(path = "add_unit", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> addGroupUnit(@RequestBody @Valid IrGroupUnit po, BindingResult bindingResult) { + public BaseResponse<Boolean> addGroupUnit(@RequestBody @Valid Map<String,Object> po, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } + Long groupId = Long.parseLong(po.get("groupId").toString()); + Long operator = Long.parseLong(po.get("operator").toString()); + List<Long> unitIds = (List<Long>) po.get("unitIds"); try { - Integer rec = Optional.ofNullable(irrigateGroupSv.addGroupUnit(po)).orElse(0); - if (rec == 0) { - return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage()); + for (int i = 0; i < unitIds.size(); i++) { + Long unitId = unitIds.get(i); + IrGroupUnit irGroupUnit = new IrGroupUnit(); + irGroupUnit.setGroupId(groupId); + irGroupUnit.setUnitId(unitId); + irGroupUnit.setOperator(operator); + Integer rec = Optional.ofNullable(irrigateGroupSv.addGroupUnit(irGroupUnit)).orElse(0); + if (rec == 0) { + return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage()); + } } } catch (Exception e) { log.error("杞亴缁勬坊鍔犵亴婧夊崟鍏冨紓甯�", e); @@ -267,7 +277,7 @@ } /** - * 閫昏緫鍒犻櫎 杞亴缁勭Щ闄ょ亴婧夊崟鍏� + * 杞亴缁勭Щ闄ょ亴婧夊崟鍏� * @param * @return */ @@ -283,19 +293,54 @@ @PostMapping(path = "remove_unit") @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> deleteGroupUnit(@RequestBody @Valid IrGroupUnit po, BindingResult bindingResult) { + public BaseResponse<Boolean> deleteGroupUnit(@RequestBody @Valid Map<String,Object> po, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } + Long groupId = Long.parseLong(po.get("groupId").toString()); + Long operator = Long.parseLong(po.get("operator").toString()); + List<Long> unitIds = (List<Long>) po.get("unitIds"); try { - Integer rec = Optional.ofNullable(irrigateGroupSv.deleteGroupUnit(po)).orElse(0); - if (rec == 0) { - return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage()); + for (int i = 0; i < unitIds.size(); i++) { + Long unitId = unitIds.get(i); + IrGroupUnit irGroupUnit = new IrGroupUnit(); + irGroupUnit.setGroupId(groupId); + irGroupUnit.setUnitId(unitId); + irGroupUnit.setOperator(operator); + Integer rec = Optional.ofNullable(irrigateGroupSv.deleteGroupUnit(irGroupUnit)).orElse(0); + if (rec == 0) { + return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage()); + } } + } catch (Exception e) { log.error("杞亴缁勭Щ闄ょ亴婧夊崟鍏冨紓甯�", e); return BaseResponseUtils.buildException(e.getMessage()); } return BaseResponseUtils.buildSuccess(true); } + + @GetMapping(path = "bind_units") + @SsoAop() + public BaseResponse<List<Long>> getGroupBindUnits(Long id) { + try { + List<Long> res = irrigateGroupSv.getGroupBindUnits(id); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇涓�涓疆鐏岀粍缁戝畾鐏屾簤鍗曞厓璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + @GetMapping(path = "notBind_units") + @SsoAop() + public BaseResponse<List<Long>> getNotBindUnits() { + try { + List<Long> res = irrigateGroupSv.getNotBindUnits(); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇鏈粦瀹氳疆鐏岀粍鐨勭亴婧夊崟鍏僫d璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } } -- Gitblit v1.8.0