From c6beb89b7170115eada78526f87406381c931229 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 03 四月 2025 10:37:51 +0800
Subject: [PATCH] 灌溉计划发布时仅发布灌溉时长大于0的
---
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java | 266 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 243 insertions(+), 23 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 cb35271..89c086e 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,17 @@
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.VoGroupDetail;
import com.dy.pipIrrGlobal.voIr.VoGroupOne;
-import com.dy.pipIrrGlobal.voIr.VoUnit;
-import com.dy.pipIrrGlobal.voIr.VoUnitOne;
+import com.dy.pipIrrGlobal.voIr.VoGroupSimple;
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.irrigateGroup.dto.IrrigateGroup;
+import com.dy.pipIrrIrrigate.irrigateGroup.qo.QoGroup;
import com.dy.pipIrrIrrigate.result.IrrigateResultCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
@@ -31,10 +32,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 +75,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 +86,7 @@
/**
* 閫昏緫鍒犻櫎鐏屾簤鍗曞厓
+ *
* @param
* @return
*/
@@ -105,13 +104,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 +121,7 @@
/**
* 鎵归噺鍒犻櫎
+ *
* @param groupIds
* @return
*/
@@ -138,7 +138,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 +150,7 @@
/**
* 淇敼鐏屾簤鍗曞厓
+ *
* @param po
* @param bindingResult
* @return
@@ -166,14 +167,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 +208,7 @@
/**
* 鍒嗛〉鏌ヨ
+ *
* @param vo
* @return
*/
@@ -250,7 +252,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());
}
@@ -266,7 +268,7 @@
irGroupUnit.setOperator(operator);
Integer rec = Optional.ofNullable(irrigateGroupSv.addGroupUnit(irGroupUnit)).orElse(0);
if (rec == 0) {
- return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage());
+ return BaseResponseUtils.buildFail(IrrigateResultCode.GROUP_ADD_UNIT_FAIL.getMessage());
}
}
} catch (Exception e) {
@@ -277,7 +279,8 @@
}
/**
- * 杞亴缁勭Щ闄ょ亴婧夊崟鍏�
+ * 杞亴缁勭Щ闄ょ亴婧夊崟鍏�
+ *
* @param
* @return
*/
@@ -293,7 +296,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());
}
@@ -322,10 +325,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());
@@ -334,13 +342,225 @@
@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);
+ }
+
+ /**
+ * 鏂板杞亴缁勶紝鏂颁唬鐮�
+ * @param po
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path = "addIrrigateGroup", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> addIrrigateGroup(@RequestBody @Valid IrrigateGroup po, BindingResult bindingResult) {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+
+ Map map_result = irrigateGroupSv.addIrrigateGroup(po);
+ if(map_result.get("success").equals(false)) {
+ return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
+ }
+ return BaseResponseUtils.buildSuccess() ;
+ }
+
+ /**
+ * 鍒犻櫎杞亴缁勶紝鏂颁唬鐮�
+ * @param groupId
+ * @return
+ */
+ @PostMapping(path = "deleteIrrigateGroup")
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> deleteIrrigateGroup(@RequestParam(required = false) Long groupId) {
+ if(groupId == null) {
+ return BaseResponseUtils.buildErrorMsg("杞亴缁処D涓嶈兘涓虹┖");
+ }
+
+ Map map_result = irrigateGroupSv.deleteGroup(groupId);
+ if(map_result.get("success").equals(false)) {
+ return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
+ }
+ return BaseResponseUtils.buildSuccess() ;
+ }
+
+ /**
+ * 淇敼杞亴缁勶紝鏂颁唬鐮�
+ * @param po
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path = "updateIrrigateGroup", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> updateIrrigateGroup(@RequestBody @Valid IrrigateGroup po, BindingResult bindingResult){
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+
+ if(po.getGroupId() == null) {
+ return BaseResponseUtils.buildErrorMsg("杞亴缁処D涓嶈兘涓虹┖");
+ }
+
+ Map map_result = irrigateGroupSv.updateIrrigateGroup(po);
+ if(map_result.get("success").equals(false)) {
+ return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
+ }
+ return BaseResponseUtils.buildSuccess() ;
+ }
+
+ /**
+ * 鑾峰彇杞亴缁勫垪琛紝鏂颁唬鐮�
+ * @param qo
+ * @return
+ */
+ @GetMapping(path = "/getSimpleGroups")
+ @SsoAop()
+ public BaseResponse<QueryResultVo<List<VoGroupSimple>>> getSimpleGroups(QoGroup qo) {
+ try {
+ QueryResultVo<List<VoGroupSimple>> res = irrigateGroupSv.getSimpleGroups(qo);
+ return BaseResponseUtils.buildSuccess(res);
+ } catch (Exception e) {
+ log.error("鑾峰彇椤圭洰璁板綍寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鑾峰彇鍏ㄩ儴杞亴缁勶紝鏂颁唬鐮�
+ * @return
+ */
+ @GetMapping(path = "/getAllGroups")
+ @SsoAop()
+ public BaseResponse<List<VoGroupSimple>> getAllGroups() {
+ try {
+ return BaseResponseUtils.buildSuccess(irrigateGroupSv.getAllGroups());
+ } catch (Exception e) {
+ log.error("鑾峰彇椤圭洰璁板綍寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鑾峰彇杞亴缁勮鎯咃紝鏂颁唬鐮�
+ * @param groupId
+ * @return
+ */
+ @GetMapping(path = "getGroupDetail")
+ @SsoAop()
+ public BaseResponse<VoGroupDetail> getGroupDetail(@RequestParam Long groupId) {
+ if(groupId == null) {
+ return BaseResponseUtils.buildErrorMsg("杞亴缁処D涓嶈兘涓虹┖");
+ }
+
+ Map map_result = irrigateGroupSv.getGroupDetail(groupId);
+ if(map_result.get("success").equals(false)) {
+ return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
+ }
+ return BaseResponseUtils.buildSuccess(map_result.get("content")) ;
+ }
}
--
Gitblit v1.8.0