From e8937f27fce194d015ce6c27d286e7fc89f5e580 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 23 四月 2025 17:29:47 +0800
Subject: [PATCH] 查询开关阀记录相关修改

---
 pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitSv.java |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 108 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitSv.java
index 3ce61e4..3ad9207 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateUnit/IrrigateUnitSv.java
@@ -1,7 +1,21 @@
 package com.dy.pipIrrIrrigate.irrigateUnit;
 
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.daoIr.IrGroupUnitMapper;
+import com.dy.pipIrrGlobal.daoIr.IrIrrigateUnitMapper;
+import com.dy.pipIrrGlobal.daoIr.IrUnitClientMapper;
+import com.dy.pipIrrGlobal.pojoIr.IrIrrigateUnit;
+import com.dy.pipIrrGlobal.pojoIr.IrUnitClient;
+import com.dy.pipIrrGlobal.voIr.VoUnit;
+import com.dy.pipIrrGlobal.voIr.VoUnitOne;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.common.utils.PojoUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author :WuZeYu
@@ -12,4 +26,98 @@
 @Slf4j
 @Service
 public class IrrigateUnitSv {
+    @Autowired
+    private IrIrrigateUnitMapper irIrrigateUnitMapper;
+    @Autowired
+    private IrGroupUnitMapper irGroupUnitMapper;
+
+    @Autowired
+    private IrUnitClientMapper irUnitClientMapper;
+
+    /**
+     * 鍒涘缓鐏屾簤鍗曞厓
+     *
+     * @param po
+     * @return
+     */
+    public Integer addIrrigateUnit(IrIrrigateUnit po) {
+        po.setOperateDt(new Date());
+        po.setDeleted((byte) 0);
+        int rows = irIrrigateUnitMapper.insertSelective(po);
+        if (rows == 0) {
+            return 0;
+        }
+        return 1;
+    }
+
+    /**
+     * 鍒犻櫎鐏屾簤鍗曞厓
+     *
+     * @param id
+     */
+    public Integer deleteUnit(Long id) {
+        int rows = irIrrigateUnitMapper.deleteLogicById(id);
+        irGroupUnitMapper.deleteByUnitId(id);
+        if (rows == 0) {
+            return 0;
+        }
+        return 1;
+    }
+
+    /**
+     * 淇敼鐏屾簤鍗曞厓
+     * @param po
+     * @return
+     */
+    public Integer updateUnit(IrIrrigateUnit po){
+        po.setOperateDt(new Date());
+        int rows = irIrrigateUnitMapper.updateByPrimaryKeySelective(po);
+        if (rows == 0){
+            return 0;
+        }
+        return 1;
+    }
+
+    /**
+     * 鑾峰彇涓�涓亴婧夊崟鍏�
+     * @param id
+     * @return
+     */
+    public VoUnitOne selectById(Long id){
+        VoUnitOne unit = irIrrigateUnitMapper.selectById(id);
+        return unit;
+    }
+
+    /**
+     * 鍒嗛〉鏌ヨ椤圭洰
+     * @param queryVo
+     * @return
+     */
+    public QueryResultVo<List<VoUnit>> getUnits(QueryVo queryVo){
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+        Long itemTotal = irIrrigateUnitMapper.getRecordCount(params);
+
+        QueryResultVo<List<VoUnit>> rsVo = new QueryResultVo<>();
+        rsVo.pageSize = queryVo.pageSize;
+        rsVo.pageCurr = queryVo.pageCurr;
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = irIrrigateUnitMapper.getUnits(params);
+        return rsVo;
+    }
+
+    //鐏屾簤鍗曞厓鍒嗛厤锛堝啘鎴风鍦帮級
+    public Long addUnitClient(IrUnitClient po) {
+        irUnitClientMapper.insert(po);
+        return po.getId();
+    }
+
+    /**
+     * 鍒犻櫎鐏屾簤鍗曞厓涓庡啘鎴峰叧鑱�
+     * @param id
+     * @return
+     */
+    public Integer deleteUnitClient(Long id) {
+        return irUnitClientMapper.deleteByPrimaryKey(id);
+    }
+
 }

--
Gitblit v1.8.0