From c3d51f9ba3300b60261d13a5b0b4f7402bba0ee0 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 02 四月 2025 08:30:00 +0800
Subject: [PATCH] 修改轮灌组接口、分页获取轮灌组接口、获取全部轮灌组接口、获取轮灌组详情接口
---
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateGroupMapper.java | 8 +
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java | 94 +++++++++++++++
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml | 2
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupDetail.java | 32 +++++
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/qo/QoGroup.java | 21 +++
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml | 80 ++++++++++---
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupSimple.java | 4
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java | 78 +++++++++++++
8 files changed, 296 insertions(+), 23 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateGroupMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateGroupMapper.java
index eaa0a00..9ee8d84 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateGroupMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigateGroupMapper.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup;
import com.dy.pipIrrGlobal.voIr.VoGroup;
+import com.dy.pipIrrGlobal.voIr.VoGroupDetail;
import com.dy.pipIrrGlobal.voIr.VoGroupOne;
import com.dy.pipIrrGlobal.voIr.VoGroupSimple;
import org.apache.ibatis.annotations.Mapper;
@@ -65,4 +66,11 @@
* @return
*/
List<VoGroupSimple> getSimpleGroups(Map<?, ?> params);
+
+ /**
+ * 鏍规嵁杞亴缁処D鑾峰彇杞亴缁勮鎯�
+ * @param groupId
+ * @return
+ */
+ VoGroupDetail getGroupDetail(Long groupId);
}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupDetail.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupDetail.java
new file mode 100644
index 0000000..1b1c6e0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupDetail.java
@@ -0,0 +1,32 @@
+package com.dy.pipIrrGlobal.voIr;
+
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import lombok.Data;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2025-03-31 17:10
+ * @LastEditTime 2025-03-31 17:10
+ * @Description 杞亴缁勮鎯呰鍥惧璞�
+ */
+
+@Data
+@JsonPropertyOrder({"groupCode", "defaultDuration", "intakes"})
+public class VoGroupDetail {
+ public static final long serialVersionUID = 202503311711001L;
+
+ /**
+ * 杞亴缁勭紪鐮�
+ */
+ private String groupCode;
+
+ /**
+ * 榛樿鐏屾簤鏃堕暱
+ */
+ private Integer defaultDuration;
+
+ /**
+ * 鍙栨按鍙e垪琛�
+ */
+ private String intakes;
+}
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupSimple.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupSimple.java
index 19a1c83..d8c1232 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupSimple.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoGroupSimple.java
@@ -25,12 +25,12 @@
private Long groupId;
/**
- * 杞亴缁勭紪鐮�
+ * 杞亴缁勫悕绉�
*/
private String groupCode;
/**
- * 鐏屾簤鍗曞厓鏁伴噺
+ * 鍙栨按鍙f暟閲�
*/
private Integer intakeCount;
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml
index 5a23b4d..ae82b5c 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml
@@ -230,16 +230,23 @@
<!--鏍规嵁鎸囧畾鏉′欢鑾峰彇杞亴缁勮褰曟暟-->
<select id="getSimpleGroupCount" resultType="java.lang.Long">
SELECT COUNT(*) AS recordCount
+<!-- FROM ir_irrigate_group grp-->
+<!-- INNER JOIN ir_project_group pg ON pg.group_id = grp.id-->
+<!-- INNER JOIN ir_project pro ON pg.project_id = pro.id-->
+<!-- <where>-->
+<!-- AND grp.deleted = 0-->
+
+<!-- <if test="projectId != null and projectId != ''">-->
+<!-- AND pro.id = #{projectId}-->
+<!-- </if>-->
+
+<!-- <if test="groupCode != null and groupCode != ''">-->
+<!-- AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%')-->
+<!-- </if>-->
+<!-- </where>-->
FROM ir_irrigate_group grp
- INNER JOIN ir_project_group pg ON pg.group_id = grp.id
- INNER JOIN ir_project pro ON pg.project_id = pro.id
<where>
AND grp.deleted = 0
-
- <if test="projectId != null and projectId != ''">
- AND pro.id = #{projectId}
- </if>
-
<if test="groupCode != null and groupCode != ''">
AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%')
</if>
@@ -248,31 +255,64 @@
<!--鏍规嵁鎸囧畾鏉′欢鑾峰彇杞亴缁勫垪琛�-->
<select id="getSimpleGroups" resultType="com.dy.pipIrrGlobal.voIr.VoGroupSimple">
+<!-- SELECT-->
+<!-- grp.id AS groupId,-->
+<!-- grp.group_code AS groupCode,-->
+<!-- (SELECT COUNT(*) FROM ir_group_intake WHERE group_id = grp.id) AS intakeCount,-->
+<!-- grp.default_duration AS defaultDuration,-->
+<!-- pg.sort-->
+<!-- FROM ir_irrigate_group grp-->
+<!-- INNER JOIN ir_project_group pg ON pg.group_id = grp.id-->
+<!-- INNER JOIN ir_project pro ON pg.project_id = pro.id-->
+<!-- <where>-->
+<!-- AND grp.deleted = 0-->
+
+<!-- <if test="projectId != null and projectId != ''">-->
+<!-- AND pro.id = #{projectId}-->
+<!-- </if>-->
+
+<!-- <if test="groupCode != null and groupCode != ''">-->
+<!-- AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%')-->
+<!-- </if>-->
+<!-- </where>-->
+<!-- ORDER BY pg.sort-->
SELECT
- grp.id AS groupId,
- grp.group_code AS groupCode,
- (SELECT COUNT(*) FROM ir_group_intake WHERE group_id = grp.id) AS intakeCount,
- grp.default_duration AS defaultDuration,
- pg.sort
+ grp.id AS groupId,
+ grp.group_code AS groupCode,
+ (SELECT COUNT(*) FROM ir_group_intake WHERE group_id = grp.id) AS intakeCount,
+ grp.default_duration AS defaultDuration,
+ 0 as sort
FROM ir_irrigate_group grp
- INNER JOIN ir_project_group pg ON pg.group_id = grp.id
- INNER JOIN ir_project pro ON pg.project_id = pro.id
<where>
AND grp.deleted = 0
-
- <if test="projectId != null and projectId != ''">
- AND pro.id = #{projectId}
- </if>
-
<if test="groupCode != null and groupCode != ''">
AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%')
</if>
</where>
- ORDER BY pg.sort
+ ORDER BY grp.operate_time DESC
<trim prefix="limit ">
<if test="start != null and count != null">
#{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
</if>
</trim>
</select>
+
+ <select id="getGroupDetail" resultType="com.dy.pipIrrGlobal.voIr.VoGroupDetail">
+ SELECT
+ groupCode,
+ defaultDuration,
+ GROUP_CONCAT(intakeId) AS intakes
+ FROM
+ (
+ SELECT
+ grp.group_code AS groupCode,
+ grp.default_duration AS defaultDuration,
+ inta.id AS intakeId
+ FROM ir_irrigate_group grp
+ INNER JOIN ir_group_intake gi ON gi.group_id = grp.id
+ INNER JOIN pr_intake inta ON inta.id = gi.intake_id
+ WHERE grp.deleted = 0 AND grp.id = #{groupId}
+ ) irrigateGroup
+ GROUP BY groupCode,defaultDuration
+ </select>
</mapper>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml
index 304156e..eb9c488 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml
@@ -322,7 +322,7 @@
FROM ir_project pro
INNER JOIN ir_project_group pg ON pg.project_id = pro.id
INNER JOIN ir_irrigate_group grp ON grp.id = pg.group_id
- WHERE pro.id = #{projectId}
+ WHERE pro.deleted = 0 AND pro.id = #{projectId}
) project
GROUP BY projectName
</select>
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 349b3cd..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
@@ -9,10 +9,13 @@
import com.dy.pipIrrGlobal.pojoIr.IrGroupUnit;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup;
import com.dy.pipIrrGlobal.voIr.VoGroup;
+import com.dy.pipIrrGlobal.voIr.VoGroupDetail;
import com.dy.pipIrrGlobal.voIr.VoGroupOne;
+import com.dy.pipIrrGlobal.voIr.VoGroupSimple;
import com.dy.pipIrrGlobal.voSe.VoActiveCard;
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;
@@ -485,4 +488,79 @@
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")) ;
+ }
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java
index 61962f8..1419aa1 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java
@@ -10,8 +10,11 @@
import com.dy.pipIrrGlobal.pojoIr.IrGroupUnit;
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup;
import com.dy.pipIrrGlobal.voIr.VoGroup;
+import com.dy.pipIrrGlobal.voIr.VoGroupDetail;
import com.dy.pipIrrGlobal.voIr.VoGroupOne;
+import com.dy.pipIrrGlobal.voIr.VoGroupSimple;
import com.dy.pipIrrIrrigate.irrigateGroup.dto.IrrigateGroup;
+import com.dy.pipIrrIrrigate.irrigateGroup.qo.QoGroup;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +36,7 @@
public class IrrigateGroupSv {
@Autowired
private IrIrrigateGroupMapper irIrrigateGroupMapper;
+
@Autowired
private IrGroupUnitMapper irGroupUnitMapper;
@@ -249,4 +253,94 @@
return map;
}
}
+
+ /**
+ * 淇敼杞亴缁�
+ * @param po
+ * @return
+ */
+ public Map updateIrrigateGroup(IrrigateGroup po) {
+ Long groupId = po.getGroupId();
+ Map map_deleteGroup = deleteGroup(groupId);
+ if(map_deleteGroup.get("success").equals(false)) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", map_deleteGroup.get("msg").toString());
+ map.put("content", null);
+ return map;
+ }
+
+ Map map_addGroup = addIrrigateGroup(po);
+ if(map_addGroup.get("success").equals(false)) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", map_addGroup.get("msg").toString());
+ map.put("content", null);
+ return map;
+ }
+
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "淇敼杞亴缁勬垚鍔�");
+ map.put("content", null);
+ return map;
+ }
+
+ /**
+ * 鏌ヨ杞亴缁勫垪琛�
+ * @param queryVo
+ * @return
+ */
+ public QueryResultVo<List<VoGroupSimple>> getSimpleGroups(QoGroup queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ Long itemTotal = irIrrigateGroupMapper.getSimpleGroupCount(params);
+
+ QueryResultVo<List<VoGroupSimple>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = queryVo.pageSize;
+ rsVo.pageCurr = queryVo.pageCurr;
+ rsVo.calculateAndSet(itemTotal, params);
+ rsVo.obj = irIrrigateGroupMapper.getSimpleGroups(params);
+ return rsVo;
+ }
+
+ /**
+ * 鏌ヨ鍏ㄩ儴杞亴缁�
+ * @return
+ */
+ public List<VoGroupSimple> getAllGroups() {
+ //Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ //Long itemTotal = irIrrigateGroupMapper.getSimpleGroupCount(params);
+
+ //QueryResultVo<List<VoGroupSimple>> rsVo = new QueryResultVo<>();
+ //rsVo.pageSize = queryVo.pageSize;
+ //rsVo.pageCurr = queryVo.pageCurr;
+ //rsVo.calculateAndSet(itemTotal, params);
+ //rsVo.obj = irIrrigateGroupMapper.getSimpleGroups(null);
+ //return rsVo;
+
+ return irIrrigateGroupMapper.getSimpleGroups(null);
+ }
+
+ /**
+ * 鑾峰彇杞亴缁勮鎯�
+ * @param groupId
+ * @return
+ */
+ public Map getGroupDetail(Long groupId) {
+ try {
+ VoGroupDetail voGroupDetail = irIrrigateGroupMapper.getGroupDetail(groupId);
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "鑾峰彇杞亴缁勮鎯呮垚鍔�");
+ map.put("content", voGroupDetail);
+ return map;
+ } catch (Exception e) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鑾峰彇杞亴缁勮鎯呭け璐�");
+ map.put("content", null);
+ return map;
+ }
+ }
+
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/qo/QoGroup.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/qo/QoGroup.java
new file mode 100644
index 0000000..c528d15
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/qo/QoGroup.java
@@ -0,0 +1,21 @@
+package com.dy.pipIrrIrrigate.irrigateGroup.qo;
+
+import com.dy.common.webUtil.QueryConditionVo;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2025-03-31 16:02
+ * @LastEditTime 2025-03-31 16:02
+ * @Description 杞亴缁勬煡璇㈠璞�
+ */
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class QoGroup extends QueryConditionVo {
+ /**
+ * 杞亴缁勭紪鐮�
+ */
+ private String groupCode;
+}
--
Gitblit v1.8.0