From e706b848e0a32628e869b312bb5d1557d0030dcc Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 10 七月 2024 18:07:31 +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, 69 insertions(+), 4 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 7694fbb..f94e15f 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
@@ -85,6 +85,7 @@
/**
* 閫昏緫鍒犻櫎鐏屾簤鍗曞厓
+ *
* @param
* @return
*/
@@ -119,6 +120,7 @@
/**
* 鎵归噺鍒犻櫎
+ *
* @param groupIds
* @return
*/
@@ -147,6 +149,7 @@
/**
* 淇敼鐏屾簤鍗曞厓
+ *
* @param po
* @param bindingResult
* @return
@@ -163,7 +166,7 @@
@PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
@Transactional(rollbackFor = Exception.class)
@SsoAop()
- public BaseResponse<Boolean> update(@RequestBody @Valid IrIrrigateGroup po, BindingResult bindingResult){
+ public BaseResponse<Boolean> update(@RequestBody @Valid IrIrrigateGroup po, BindingResult bindingResult) {
if (bindingResult != null && bindingResult.hasErrors()) {
return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
@@ -204,6 +207,7 @@
/**
* 鍒嗛〉鏌ヨ
+ *
* @param vo
* @return
*/
@@ -247,7 +251,7 @@
@PostMapping(path = "add_unit", consumes = MediaType.APPLICATION_JSON_VALUE)
@Transactional(rollbackFor = Exception.class)
@SsoAop()
- public BaseResponse<Boolean> addGroupUnit(@RequestBody @Valid Map<String,Object> 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());
}
@@ -274,7 +278,8 @@
}
/**
- * 杞亴缁勭Щ闄ょ亴婧夊崟鍏�
+ * 杞亴缁勭Щ闄ょ亴婧夊崟鍏�
+ *
* @param
* @return
*/
@@ -290,7 +295,7 @@
@PostMapping(path = "remove_unit")
@Transactional(rollbackFor = Exception.class)
@SsoAop()
- public BaseResponse<Boolean> deleteGroupUnit(@RequestBody @Valid Map<String,Object> 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());
}
@@ -350,4 +355,64 @@
return BaseResponseUtils.buildException(e.getMessage());
}
}
+
+
+ /**
+ * 淇敼杞亴缁勭粦瀹氱殑鐏屾簤鍗曞厓
+ *
+ * @param po 杞亴缁勭亴婧夊崟鍏冧腑闂磋〃
+ * @param bindingResult
+ * @return 娣诲姞鏄惁鎴愬姛
+ */
+ @Operation(summary = "淇敼杞亴缁勭粦瀹氱殑鐏屾簤鍗曞厓", description = "淇敼杞亴缁勭粦瀹氱殑鐏屾簤鍗曞厓")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @PostMapping(path = "updateBindUnits", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> updateBindUnits(@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<String> newUnitIds = (List<String>) po.get("unitIds");
+ List<Long> oldUnitIds = irrigateGroupSv.getGroupBindUnits(groupId);
+
+ IrGroupUnit irGroupUnit = new IrGroupUnit();
+ irGroupUnit.setGroupId(groupId);
+ irGroupUnit.setOperator(operator);
+ try {
+ for (int j = 0; j < oldUnitIds.size(); j++) {
+ Long oldUnitId = oldUnitIds.get(j);
+ if (!newUnitIds.toString().contains(oldUnitId.toString())) {
+ irGroupUnit.setUnitId(oldUnitId);
+ Integer rec = Optional.ofNullable(irrigateGroupSv.deleteGroupUnit(irGroupUnit)).orElse(0);
+ if (rec == 0) {
+ return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage());
+ }
+ }
+ }
+ for (int i = 0; i < newUnitIds.size(); i++) {
+ Long newUnitId = Long.parseLong(newUnitIds.get(i));
+ if (!oldUnitIds.toString().contains(newUnitId.toString())) {
+ irGroupUnit.setUnitId(newUnitId);
+ 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);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
}
--
Gitblit v1.8.0