From ae844683ede273edad59085227e36ae3ce02de06 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期二, 22 十月 2024 09:25:30 +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 | 176 +++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 148 insertions(+), 28 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 fd7145e..aaed9d3 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
@@ -5,16 +5,13 @@
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.common.webUtil.ResultCodeMsg;
+import com.dy.pipIrrGlobal.pojoIr.IrGroupClient;
import com.dy.pipIrrGlobal.pojoIr.IrGroupUnit;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup;
-import com.dy.pipIrrGlobal.pojoIr.IrIrrigateUnit;
import com.dy.pipIrrGlobal.voIr.VoGroup;
import com.dy.pipIrrGlobal.voIr.VoGroupOne;
-import com.dy.pipIrrGlobal.voIr.VoUnit;
-import com.dy.pipIrrGlobal.voIr.VoUnitOne;
import com.dy.pipIrrGlobal.voSe.VoActiveCard;
-import com.dy.pipIrrIrrigate.irrigateUnit.IrrigateUnitSv;
-import com.dy.pipIrrIrrigate.irrigateGroup.QueryVo;
+import com.dy.pipIrrIrrigate.irrigateGroup.dto.GroupClient;
import com.dy.pipIrrIrrigate.result.IrrigateResultCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
@@ -31,10 +28,7 @@
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
/**
* @author :WuZeYu
@@ -77,7 +71,7 @@
try {
Integer rec = Optional.ofNullable(irrigateGroupSv.addIrrigateGroup(po)).orElse(0);
if (rec == 0) {
- return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage());
+ return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_GROUP_FAIL.getMessage());
}
} catch (Exception e) {
log.error("鍒涘缓杞亴缁勫紓甯�", e);
@@ -88,6 +82,7 @@
/**
* 閫昏緫鍒犻櫎鐏屾簤鍗曞厓
+ *
* @param
* @return
*/
@@ -105,13 +100,13 @@
@SsoAop()
public BaseResponse<Boolean> delete(@RequestBody Map map) {
if (map == null || map.size() <= 0) {
- BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage());
+ BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_GROUP_ID.getMessage());
}
Long groupId = Long.parseLong(map.get("id").toString());
try {
Integer rows = irrigateGroupSv.deleteIrrigateGroup(groupId);
if (rows == 0) {
- return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage());
+ return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_GROUP_FAIL.getMessage());
}
} catch (Exception e) {
log.error("鍒犻櫎杞亴缁勫紓甯�", e);
@@ -122,6 +117,7 @@
/**
* 鎵归噺鍒犻櫎
+ *
* @param groupIds
* @return
*/
@@ -138,7 +134,7 @@
try {
Integer rows = irrigateGroupSv.deleteIrrigateGroup(groupId);
if (rows == 0) {
- return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage());
+ return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_GROUP_FAIL.getMessage());
}
} catch (Exception e) {
log.error("鍒犻櫎杞亴缁勫紓甯�", e);
@@ -150,6 +146,7 @@
/**
* 淇敼鐏屾簤鍗曞厓
+ *
* @param po
* @param bindingResult
* @return
@@ -166,14 +163,14 @@
@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());
}
try {
Integer rec = Optional.ofNullable(irrigateGroupSv.updateIrrigateGroup(po)).orElse(0);
if (rec == 0) {
- return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_PROJECT_FAIL.getMessage());
+ return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_GROUP_FAIL.getMessage());
}
} catch (Exception e) {
log.error("淇敼杞亴缁勫紓甯�", e);
@@ -207,6 +204,7 @@
/**
* 鍒嗛〉鏌ヨ
+ *
* @param vo
* @return
*/
@@ -250,14 +248,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.GROUP_ADD_UNIT_FAIL.getMessage());
+ }
}
} catch (Exception e) {
log.error("杞亴缁勬坊鍔犵亴婧夊崟鍏冨紓甯�", e);
@@ -267,7 +275,8 @@
}
/**
- * 閫昏緫鍒犻櫎 杞亴缁勭Щ闄ょ亴婧夊崟鍏�
+ * 杞亴缁勭Щ闄ょ亴婧夊崟鍏�
+ *
* @param
* @return
*/
@@ -283,15 +292,26 @@
@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());
@@ -301,10 +321,15 @@
@GetMapping(path = "bind_units")
@SsoAop()
- public BaseResponse<List<Long>> getGroupBindUnits(Long id) {
+ public BaseResponse<List<String>> getGroupBindUnits(Long id) {
try {
List<Long> res = irrigateGroupSv.getGroupBindUnits(id);
- return BaseResponseUtils.buildSuccess(res);
+ ArrayList<Object> list = new ArrayList<>();
+ for (int i = 0; i < res.size(); i++) {
+ String aLong = res.get(i).toString();
+ list.add(aLong);
+ }
+ return BaseResponseUtils.buildSuccess(list);
} catch (Exception e) {
log.error("鑾峰彇涓�涓疆鐏岀粍缁戝畾鐏屾簤鍗曞厓璁板綍寮傚父", e);
return BaseResponseUtils.buildException(e.getMessage());
@@ -313,13 +338,108 @@
@GetMapping(path = "notBind_units")
@SsoAop()
- public BaseResponse<List<Long>> getNotBindUnits() {
+ public BaseResponse<List<String>> getNotBindUnits() {
try {
List<Long> res = irrigateGroupSv.getNotBindUnits();
- return BaseResponseUtils.buildSuccess(res);
+ ArrayList<Object> list = new ArrayList<>();
+ for (int i = 0; i < res.size(); i++) {
+ String aLong = res.get(i).toString();
+ list.add(aLong);
+ }
+ return BaseResponseUtils.buildSuccess(list);
} catch (Exception e) {
log.error("鑾峰彇鏈粦瀹氳疆鐏岀粍鐨勭亴婧夊崟鍏僫d璁板綍寮傚父", e);
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);
+ }
+
+ /**
+ * 杞亴缁勫叧鑱斿啘鎴�
+ * @param po
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path = "add_group_client", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> addGroupClient(@RequestBody @Valid GroupClient po, BindingResult bindingResult) {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ IrGroupClient irGroupClient = new IrGroupClient();
+ irGroupClient.setGroupId(po.getGroupId());
+ irGroupClient.setClientId(po.getClientId());
+ irGroupClient.setOperator(po.getOperator());
+ irGroupClient.setOperateTime(new Date());
+
+ try {
+ Long rec = Optional.ofNullable(irrigateGroupSv.addGroupClient(irGroupClient)).orElse(0L);
+ if (rec == 0) {
+ return BaseResponseUtils.buildErrorMsg(IrrigateResultCode.GRPUP_ASSOCIATE_CLIENT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
}
--
Gitblit v1.8.0