Selaa lähdekoodia

新增 获取水肥机灌溉记录列表接口

zhaiyifei 8 kuukautta sitten
vanhempi
commit
791b4cc7af

+ 16 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/controller/IotDeviceSfController.java

@@ -406,4 +406,20 @@ public class IotDeviceSfController extends BaseController {
         return new AjaxResult(ErrorCode.SUCCESS.getCode(), "下发成功,等待设备响应结果", taskId);
     }
 
+    /**
+     * 获取水肥机灌溉记录
+     * @param
+     * @return
+     */
+    @GetMapping("/record/list")
+    public TableDataInfo getRecordList(IotSfIrrigationRecordListReqVo reqVo){
+        String devBid = reqVo.getDevBid();
+        ValidateUtil.validateDevBid(devBid);
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(devBid);
+        iotDeviceBaseFunReqVo.setMethodName("getRecordList");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        return iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+    }
+
 }

+ 35 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/domain/IotSfIrrigationRecordListReqVo.java

@@ -0,0 +1,35 @@
+package com.yunfeiyun.agmp.iotm.device.sf.domain;
+
+import com.yunfeiyun.agmp.iot.common.domain.IotBaseEntity;
+import lombok.Data;
+
+@Data
+public class IotSfIrrigationRecordListReqVo extends IotBaseEntity {
+
+    // 设备标识
+    private String devBid;
+
+    // 灌区标识
+    private String rcdGroupbid;
+
+    // 灌区名称
+    private String rcdGroupName;
+
+    // 灌溉状态 0 进行中 1 已完成
+    private String rcdStatus;
+
+    // 灌溉模式 0 手动 1 自动
+    private String rcdMode;
+
+    // 灌溉数据标识
+    private String sfdataBid;
+
+    // 开始时间
+    private String startTime;
+
+    // 结束时间
+    private String endTime;
+
+    private String tid;
+
+}

+ 35 - 8
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/IIotSfCommService.java

@@ -12,10 +12,7 @@ import com.yunfeiyun.agmp.common.utils.StringUtils;
 import com.yunfeiyun.agmp.common.utils.uuid.IdUtils;
 import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
 import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
-import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
-import com.yunfeiyun.agmp.iot.common.domain.IotDeviceconfig;
-import com.yunfeiyun.agmp.iot.common.domain.IotRunHaoSfdata;
-import com.yunfeiyun.agmp.iot.common.domain.IotSfElementfactor;
+import com.yunfeiyun.agmp.iot.common.domain.*;
 import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
 import com.yunfeiyun.agmp.iot.common.model.cmd.CmdGroupModel;
 import com.yunfeiyun.agmp.iot.common.util.dev.RunHaoSfElementUtil;
@@ -23,10 +20,7 @@ import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
 import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceBaseService;
 import com.yunfeiyun.agmp.iotm.device.common.service.impl.IotDeviceBaseServiceImpl;
 import com.yunfeiyun.agmp.iotm.device.sf.domain.*;
-import com.yunfeiyun.agmp.iotm.web.service.IIotCmdtaskService;
-import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
-import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceconfigService;
-import com.yunfeiyun.agmp.iotm.web.service.IIotSfElementfactorService;
+import com.yunfeiyun.agmp.iotm.web.service.*;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -53,6 +47,9 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
     @Autowired
     private IIotCmdtaskService iIotCmdtaskService;
 
+    @Autowired
+    private IIotSfIrrigationRecordService iIotSfIrrigationRecordService;
+
 
     public Class getTableClass(String devtypeBid) {
         Class tableClass = null;
@@ -412,4 +409,34 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
         return null;
     }
 
+    /**
+     * 获取灌溉记录列表
+     *
+     * @param reqVo 包含设备添加请求的参数,包括设备标识(devBid)等
+     * @param reqVo
+     */
+    public TableDataInfo getRecordList(IotSfIrrigationRecordListReqVo reqVo) {
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(ErrorCode.SUCCESS.getCode());
+        rspData.setMsg(ErrorCode.SUCCESS.getMessage());
+        rspData.setData(new ArrayList<>());
+        rspData.setTotal(0);
+
+        String devBid = reqVo.getDevBid();
+        if (StringUtils.isEmpty(devBid)) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
+        }
+        IotDevice iotDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
+        if (iotDevice == null) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
+        }
+
+        List<IotSfIrrigationRecord> recordList = iIotSfIrrigationRecordService.selectIrrigationRecordList(reqVo);
+        if (recordList != null && !recordList.isEmpty()){
+            rspData.setData(recordList);
+            rspData.setTotal(recordList.size());
+        }
+        return rspData;
+    }
+
 }

+ 64 - 7
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/impl/IotRunHaoSfServiceImpl.java

@@ -13,6 +13,8 @@ import com.yunfeiyun.agmp.iot.common.constant.devicetype.ServiceNameConst;
 import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
 import com.yunfeiyun.agmp.iot.common.domain.IotRunHaoSfdata;
 import com.yunfeiyun.agmp.iot.common.domain.IotSfElementfactor;
+import com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord;
+import com.yunfeiyun.agmp.iot.common.enums.EnumIrrigationRecord;
 import com.yunfeiyun.agmp.iot.common.enums.EnumSfElementType;
 import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
 import com.yunfeiyun.agmp.iot.common.service.MongoService;
@@ -22,6 +24,7 @@ import com.yunfeiyun.agmp.iotm.device.sf.domain.*;
 import com.yunfeiyun.agmp.iotm.device.sf.service.IIotSfCommService;
 import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
 import com.yunfeiyun.agmp.iotm.web.service.IIotSfElementfactorService;
+import com.yunfeiyun.agmp.iotm.web.service.IIotSfIrrigationRecordService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,6 +48,15 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
     @Autowired
     private MongoService mongoService;
 
+    @Autowired
+    private IIotSfIrrigationRecordService iotSfIrrigationRecordService;
+
+    /**
+     * 获取设备状态
+     *
+     * @param reqVo 请求参数,包含设备标识(devBid)等信息
+    **/
+
     private String getDataValue(JSONObject dataJson, String key){
         String v = dataJson.getString(key);
         if("true".equals(v)){
@@ -363,6 +375,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
                 }catch (Exception e){}
             }
         }
+        runStatus.put("sfdataBid", iotRunHaoSfdata.getSfdataBid());
         return runStatus;
     }
 
@@ -738,12 +751,12 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
                     if(childType == null || !typeSet.contains(childType)){
                         continue;
                     }
-                    sfTypeValueMap.put(childType, Math.max(sfTypeValueMap.getOrDefault(childType, 0), Integer.parseInt(child.getValue())));
+                    sfTypeValueMap.put(childType, sfTypeValueMap.getOrDefault(childType, 0) + Integer.parseInt(child.getValue()));
                     sfTypeMap.put(child.getSfCode(), childType);
                 }
             }
             if(typeSet.contains(elementType)){
-                sfTypeValueMap.put(elementType, Math.max(sfTypeValueMap.getOrDefault(elementType, 0), Integer.parseInt(element.getValue())));
+                sfTypeValueMap.put(elementType, sfTypeValueMap.getOrDefault(elementType, 0) + Integer.parseInt(element.getValue()));
                 sfTypeMap.put(element.getSfCode(), elementType);
             }
         }
@@ -772,13 +785,13 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
                 if(elementType == EnumSfElementType.WATER_SOURCE && Objects.equals(v, "1")){
                     // 请先打开阀
                     Integer va = sfTypeValueMap.get(EnumSfElementType.SOLENOID_VALVE);
-                    if(va != 1){
+                    if(va == 0){
                         throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"请先打开阀门");
                     }
                 }else if(elementType == EnumSfElementType.FERTILIZER){
                     Integer va = sfTypeValueMap.get(EnumSfElementType.SUCTION);
                     if(Objects.equals(v, "1")){
-                        if(va != 1){
+                        if(va == 0){
                             throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"请先打开肥阀");
                         }
                     }else {
@@ -787,10 +800,14 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
                         }
                     }
                 }else if(elementType == EnumSfElementType.SOLENOID_VALVE && Objects.equals(v, "0")){
-                    Integer va = sfTypeValueMap.get(EnumSfElementType.WATER_SOURCE);
-                    if(va != 0){
-                        throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"请先关闭水源泵");
+                    Integer sova = sfTypeValueMap.get(EnumSfElementType.SOLENOID_VALVE);
+                    if(sova - 1 <= 0){
+                        Integer va = sfTypeValueMap.get(EnumSfElementType.WATER_SOURCE);
+                        if(va != 0){
+                            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"请先关闭水源泵");
+                        }
                     }
+
                 }
             }
         }
@@ -962,6 +979,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
             throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "未配置灌溉设备");
         }
 
+        List<IotSfElementfactorAlreadyListResVo> groupList = new ArrayList<>();
         JSONObject sendJson = new JSONObject();
         for(IotSfElementfactorAlreadyListResVo elementfactor : elementfactorList){
             String sfCode = elementfactor.getSfCode();
@@ -972,6 +990,7 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
                 throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "灌区未配置阀,无法开始灌溉");
             }
             sendJson.put(sfCode, "1");
+            groupList.add(elementfactor);
         }
         if(sendJson.isEmpty()){
             throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "请先选择灌区");
@@ -998,6 +1017,44 @@ public class IotRunHaoSfServiceImpl extends IIotSfCommService {
             }
         }
 
+        String tid = SecurityUtils.getTid();
+        String userId = SecurityUtils.getUserId();
+        String userLoginName = SecurityUtils.getLoginLogName();
+        String rcdStartdate = DateUtils.dateTimeNow();
+        List<IotSfIrrigationRecord> irrigationRecordList = new ArrayList<>();
+        for(IotSfElementfactorAlreadyListResVo group : groupList){
+            StringBuilder rcdContent = new StringBuilder();
+            List<IotSfElementfactorAlreadyListResVo> childrenList = group.getChildrenList();
+            for(IotSfElementfactorAlreadyListResVo child : childrenList){
+                rcdContent.append(child.getSfDisplayname()).append(",");
+            }
+            if(rcdContent.length() > 0){
+                rcdContent.deleteCharAt(rcdContent.length() - 1);
+            }
+            rcdContent.append(EnumIrrigationRecord.STATUS_RUNNING.getName());
+
+            IotSfIrrigationRecord record = new IotSfIrrigationRecord();
+            record.setRcdBid(record.getUUId());
+            record.setDevBid(devBid);
+            record.setRcdGroupbid(group.getSfBid());
+            record.setRcdGroupName(group.getSfDisplayname());
+            record.setRcdStatus(EnumIrrigationRecord.STATUS_RUNNING.getCode());
+            record.setRcdMode(EnumIrrigationRecord.MODE_AUTO.getCode());
+            record.setRcdContent(rcdContent.toString());
+            record.setSfdataBid(runStatusData.getString("sfdataBid"));
+            record.setRcdCreator(userId);
+            record.setRcdCreatorName(userLoginName);
+            record.setRcdStartdate(rcdStartdate);
+            record.setRcdCreateddate(rcdStartdate);
+            record.setTid(tid);
+
+            irrigationRecordList.add(record);
+        }
+
+        if(!irrigationRecordList.isEmpty()){
+            iotSfIrrigationRecordService.batchInsertIotSfIrrigationRecord(irrigationRecordList);
+        }
+
         IotSfConfigCmdReqVo cmdReqVo = new IotSfConfigCmdReqVo();
         cmdReqVo.setDevBid(devBid);
         cmdReqVo.setCmd(CmdDef.RunHaoSfCmdDef.CMD_CONFIG);

+ 25 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/mapper/IotSfIrrigationRecordMapper.java

@@ -0,0 +1,25 @@
+package com.yunfeiyun.agmp.iotm.web.mapper;
+
+import com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord;
+import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfIrrigationRecordListReqVo;
+
+import java.util.List;
+
+public interface IotSfIrrigationRecordMapper {
+    // 添加灌溉记录
+    public int insertIrrigationRecord(IotSfIrrigationRecord record);
+
+    public int batchInsertIotSfIrrigationRecord(List<IotSfIrrigationRecord> recordList);
+
+    // 根据唯一标识查询灌溉记录
+    public IotSfIrrigationRecord selectIrrigationRecordByBid(String rcdBid);
+
+    // 更新灌溉记录
+    public int updateIrrigationRecord(IotSfIrrigationRecord record);
+
+//    // 删除灌溉记录
+//    public void deleteIrrigationRecord(String rcdBid);
+
+    // 查询所有灌溉记录
+    public List<IotSfIrrigationRecord> selectIrrigationRecordList(IotSfIrrigationRecordListReqVo record);
+}

+ 25 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotSfIrrigationRecordService.java

@@ -0,0 +1,25 @@
+package com.yunfeiyun.agmp.iotm.web.service;
+
+import com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord;
+import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfIrrigationRecordListReqVo;
+
+import java.util.List;
+
+public interface IIotSfIrrigationRecordService {
+    // 添加灌溉记录
+    public int insertIrrigationRecord(IotSfIrrigationRecord record);
+
+    public int batchInsertIotSfIrrigationRecord(List<IotSfIrrigationRecord> recordList);
+
+    // 根据唯一标识查询灌溉记录
+    public IotSfIrrigationRecord selectIrrigationRecordByBid(String rcdBid);
+
+    // 更新灌溉记录
+    public int updateIrrigationRecord(IotSfIrrigationRecord record);
+
+    // 删除灌溉记录
+    public void deleteIrrigationRecord(String rcdBid);
+
+    // 查询所有灌溉记录
+    public List<IotSfIrrigationRecord> selectIrrigationRecordList(IotSfIrrigationRecordListReqVo record);
+}

+ 54 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotSfIrrigationRecordServiceImpl.java

@@ -0,0 +1,54 @@
+package com.yunfeiyun.agmp.iotm.web.service.impl;
+
+import com.yunfeiyun.agmp.common.utils.SecurityUtils;
+import com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord;
+import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfIrrigationRecordListReqVo;
+import com.yunfeiyun.agmp.iotm.web.mapper.IotSfIrrigationRecordMapper;
+import com.yunfeiyun.agmp.iotm.web.service.IIotSfIrrigationRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class IotSfIrrigationRecordServiceImpl implements IIotSfIrrigationRecordService {
+
+    @Autowired
+    private IotSfIrrigationRecordMapper irrigationRecordMapper;
+
+    @Override
+    public int insertIrrigationRecord(IotSfIrrigationRecord record) {
+        record.setTid(SecurityUtils.getTid());
+        return irrigationRecordMapper.insertIrrigationRecord(record);
+    }
+
+    @Override
+    public int batchInsertIotSfIrrigationRecord(List<IotSfIrrigationRecord> recordList) {
+        for (IotSfIrrigationRecord record : recordList) {
+            record.setTid(SecurityUtils.getTid());
+        }
+        return irrigationRecordMapper.batchInsertIotSfIrrigationRecord(recordList);
+    }
+
+    @Override
+    public IotSfIrrigationRecord selectIrrigationRecordByBid(String rcdBid) {
+        return irrigationRecordMapper.selectIrrigationRecordByBid(rcdBid);
+    }
+
+    @Override
+    public int updateIrrigationRecord(IotSfIrrigationRecord record) {
+        record.setTid(SecurityUtils.getTid());
+        return irrigationRecordMapper.updateIrrigationRecord(record);
+    }
+
+    @Override
+    public void deleteIrrigationRecord(String rcdBid) {
+
+    }
+
+    @Override
+    public List<IotSfIrrigationRecord> selectIrrigationRecordList(IotSfIrrigationRecordListReqVo record) {
+        record.setTid(SecurityUtils.getTid());
+        return irrigationRecordMapper.selectIrrigationRecordList(record);
+    }
+}

+ 120 - 0
src/main/resources/mapper/IotSfIrrigationRecordMapper.xml

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.yunfeiyun.agmp.iotm.web.mapper.IotSfIrrigationRecordMapper">
+
+    <insert id="insertIrrigationRecord" parameterType="com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord">
+        INSERT INTO IotSfIrrigationRecord
+            <trim prefix="(" suffix=")" suffixOverrides=",">
+                <if test="rcdBid != null">rcdBid,</if>
+                <if test="devBid != null">devBid,</if>
+                <if test="rcdContent != null">rcdContent,</if>
+                <if test="rcdGroupbid != null">rcdGroupbid,</if>
+                <if test="rcdGroupName!= null">rcdGroupName,</if>
+                <if test="rcdStatus!= null">rcdStatus,</if>
+                <if test="rcdMode!= null">rcdMode,</if>
+                <if test="sfdataBid!= null">sfdataBid,</if>
+                <if test="rcdFlow!= null">rcdFlow,</if>
+                <if test="rcdCreator!= null">rcdCreator,</if>
+                <if test="rcdStartdate!= null">rcdStartdate,</if>
+                <if test="rcdEnddate!= null">rcdEnddate,</if>
+                <if test="rcdCreatorName!= null">rcdCreatorName,</if>
+                <if test="rcdCreateddate!= null">rcdCreateddate,</if>
+                <if test="tid!= null">tid,</if>
+            </trim>
+            <trim prefix="values (" suffix=")" suffixOverrides=",">
+                <if test="rcdBid!= null">#{rcdBid},</if>
+                <if test="devBid!= null">#{devBid},</if>
+                <if test="rcdContent!= null">#{rcdContent},</if>
+                <if test="rcdGroupbid!= null">#{rcdGroupbid},</if>
+                <if test="rcdGroupName!= null">#{rcdGroupName},</if>
+                <if test="rcdStatus!= null">#{rcdStatus},</if>
+                <if test="rcdMode!= null">#{rcdMode},</if>
+                <if test="sfdataBid!= null">#{sfdataBid},</if>
+                <if test="rcdFlow!= null">#{rcdFlow},</if>
+                <if test="rcdCreator!= null">#{rcdCreator},</if>
+                <if test="rcdStartdate!= null">#{rcdStartdate},</if>
+                <if test="rcdEnddate!= null">#{rcdEnddate},</if>
+                <if test="rcdCreatorName!= null">#{rcdCreatorName},</if>
+                <if test="rcdCreateddate!= null">#{rcdCreateddate},</if>
+                <if test="tid!= null">#{tid},</if>
+            </trim>
+    </insert>
+    <insert id="batchInsertIotSfIrrigationRecord">
+        <foreach collection="list" item="item" separator=";">
+            INSERT INTO IotSfIrrigationRecord
+            <trim prefix="(" suffix=")" suffixOverrides=",">
+                <if test="item.rcdBid!= null">rcdBid,</if>
+                <if test="item.devBid!= null">devBid,</if>
+                <if test="item.rcdContent!= null">rcdContent,</if>
+                <if test="item.rcdGroupbid!= null">rcdGroupbid,</if>
+                <if test="item.rcdGroupName!= null">rcdGroupName,</if>
+                <if test="item.rcdStatus!= null">rcdStatus,</if>
+                <if test="item.rcdMode!= null">rcdMode,</if>
+                <if test="item.sfdataBid!= null">sfdataBid,</if>
+                <if test="item.rcdFlow!= null">rcdFlow,</if>
+                <if test="item.rcdCreator!= null">rcdCreator,</if>
+                <if test="item.rcdStartdate!= null">rcdStartdate,</if>
+                <if test="item.rcdEnddate!= null">rcdEnddate,</if>
+                <if test="item.rcdCreatorName!= null">rcdCreatorName,</if>
+                <if test="item.rcdCreateddate!= null">rcdCreateddate,</if>
+                <if test="item.tid!= null">tid,</if>
+            </trim>
+            <trim prefix="values (" suffix=")" suffixOverrides=",">
+                <if test="item.rcdBid!= null">#{item.rcdBid},</if>
+                <if test="item.devBid!= null">#{item.devBid},</if>
+                <if test="item.rcdContent!= null">#{item.rcdContent},</if>
+                <if test="item.rcdGroupbid!= null">#{item.rcdGroupbid},</if>
+                <if test="item.rcdGroupName!= null">#{item.rcdGroupName},</if>
+                <if test="item.rcdStatus!= null">#{item.rcdStatus},</if>
+                <if test="item.rcdMode!= null">#{item.rcdMode},</if>
+                <if test="item.sfdataBid!= null">#{item.sfdataBid},</if>
+                <if test="item.rcdFlow!= null">#{item.rcdFlow},</if>
+                <if test="item.rcdCreator!= null">#{item.rcdCreator},</if>
+                <if test="item.rcdStartdate!= null">#{item.rcdStartdate},</if>
+                <if test="item.rcdEnddate!= null">#{item.rcdEnddate},</if>
+                <if test="item.rcdCreatorName!= null">#{item.rcdCreatorName},</if>
+                <if test="item.rcdCreateddate!= null">#{item.rcdCreateddate},</if>
+                <if test="item.tid!= null">#{item.tid},</if>
+            </trim>
+        </foreach>
+    </insert>
+
+    <update id="updateIrrigationRecord" parameterType="com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord">
+        UPDATE IotSfIrrigationRecord
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="rcdContent!= null">rcdContent = #{rcdContent},</if>
+            <if test="rcdStatus!= null">rcdStatus = #{rcdStatus},</if>
+            <if test="rcdFlow!= null">rcdFlow = #{rcdFlow},</if>
+            <if test="rcdEnddate!= null">rcdEnddate = #{rcdEnddate},</if>
+        </trim>
+        where rcdBid = #{rcdBid} and tid = #{tid}
+    </update>
+
+    <select id="selectIrrigationRecordByBid" parameterType="com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord"
+            resultType="com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord">
+        SELECT rcdBid, devBid, rcdContent, rcdGroupbid, rcdGroupName, rcdStatus, rcdMode, sfdataBid, rcdFlow, rcdCreator,
+            rcdStartdate, rcdEnddate, rcdCreatorName, rcdCreateddate, tid
+        FROM IotSfIrrigationRecord
+        where rcdBid = #{rcdBid}
+    </select>
+
+    <select id="selectIrrigationRecordList" parameterType="IotSfIrrigationRecordListReqVo"
+            resultType="com.yunfeiyun.agmp.iot.common.domain.IotSfIrrigationRecord">
+        SELECT rcdBid, devBid, rcdContent, rcdGroupbid, rcdGroupName, rcdStatus, rcdMode, sfdataBid, rcdFlow, rcdCreator,
+            rcdStartdate, rcdEnddate, rcdCreatorName, rcdCreateddate, tid
+        FROM IotSfIrrigationRecord
+        <where>
+            tid = #{tid}
+            <if test="devBid!= null and devBid!= ''"> and devBid = #{devBid}</if>
+            <if test="rcdGroupbid!= null and rcdGroupbid!= ''"> and rcdGroupbid = #{rcdGroupbid}</if>
+            <if test="rcdGroupName!= null and rcdGroupName!= ''"> and rcdGroupName = #{rcdGroupName}</if>
+            <if test="rcdStatus!= null and rcdStatus!= ''"> and rcdStatus = #{rcdStatus}</if>
+            <if test="rcdMode!= null and rcdMode!= ''"> and rcdMode = #{rcdMode}</if>
+            <if test="startTime!= null and startTime!= ''"> and rcdStartdate <![CDATA[ >= ]]> #{startTime}</if>
+            <if test="endTime!= null and endTime!= ''"> and rcdStartdate <![CDATA[ <= ]]> #{endTime}</if>
+        </where>
+        order by rcdCreateddate desc
+    </select>
+</mapper>