Forráskód Böngészése

新增 水肥机要素删除接口

zhaiyifei 9 hónapja
szülő
commit
e64ac0dd85

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

@@ -3,7 +3,10 @@ package com.yunfeiyun.agmp.iotm.device.sf.controller;
 import cn.hutool.core.exceptions.ValidateException;
 import cn.hutool.core.exceptions.ValidateException;
 import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
 import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
 import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
 import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
+import com.yunfeiyun.agmp.common.utils.StringUtils;
+import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
 import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
 import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
+import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
 import com.yunfeiyun.agmp.iotm.common.controller.BaseController;
 import com.yunfeiyun.agmp.iotm.common.controller.BaseController;
 import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceBaseFunReqVo;
 import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceBaseFunReqVo;
 import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceCommonService;
 import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceCommonService;
@@ -13,6 +16,7 @@ import com.yunfeiyun.agmp.iotm.util.ValidateUtil;
 import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListReqVo;
 import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListReqVo;
 import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDeviceListResVo;
 import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDeviceListResVo;
 import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
 import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
+import com.yunfeiyun.agmp.iotm.web.service.IIotSfElementfactorService;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
@@ -36,6 +40,9 @@ public class IotDeviceSfController extends BaseController {
     @Autowired
     @Autowired
     private IotDeviceCommonService iotDeviceCommonService;
     private IotDeviceCommonService iotDeviceCommonService;
 
 
+    @Autowired
+    private IIotSfElementfactorService iotSfElementfactorService;
+
     /**
     /**
      * 水肥设备列表
      * 水肥设备列表
      * /list  所有设备
      * /list  所有设备
@@ -116,4 +123,23 @@ public class IotDeviceSfController extends BaseController {
         int status = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
         int status = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
         return toAjax(status);
         return toAjax(status);
     }
     }
+
+
+    /**
+     * 删除要素接口
+     * 根据传入的要素标识删除对应的要素信息
+     *
+     * @param sfBid 要素标识,用于唯一确定要删除的要素
+     * @return AjaxResult 操作结果,包含状态码和消息
+     * @throws IotBizException 如果要素标识为空,则抛出IotBizException异常
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @DeleteMapping("/ele/delete/{sfBid}")
+    public AjaxResult elementDelete(@PathVariable String sfBid){
+        if(StringUtils.isEmpty(sfBid)){
+            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "要素标识不能为空");
+        }
+        int status = iotSfElementfactorService.deleteIotSfElementfactorBySfBid(sfBid);
+        return toAjax(status);
+    }
 }
 }

+ 9 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/mapper/IotSfElementfactorMapper.java

@@ -27,4 +27,13 @@ public interface IotSfElementfactorMapper {
      */
      */
     public int batchInsertIotSfElementfactor(List<IotSfElementfactor> factorList);
     public int batchInsertIotSfElementfactor(List<IotSfElementfactor> factorList);
 
 
+
+    /**
+     * 删除水肥机要素
+     *
+     * @param sfBid 水肥机要素ID
+     * @return 结果
+     */
+    public int deleteIotSfElementfactorBySfBid(String sfBid);
+
 }
 }

+ 8 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotSfElementfactorService.java

@@ -34,6 +34,14 @@ public interface IIotSfElementfactorService {
      */
      */
     public int batchInsertIotSfElementfactor(List<IotSfElementfactor> factorList);
     public int batchInsertIotSfElementfactor(List<IotSfElementfactor> factorList);
 
 
+    /**
+     * 删除水肥机要素
+     *
+     * @param sfBid 水肥机要素ID
+     * @return 结果
+     */
+    public int deleteIotSfElementfactorBySfBid(String sfBid);
+
 //    /**
 //    /**
 //     * 查询已配置要素列表
 //     * 查询已配置要素列表
 //     * @param reqVo
 //     * @param reqVo

+ 11 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotSfElementfactorServiceImpl.java

@@ -47,6 +47,17 @@ public class IotSfElementfactorServiceImpl implements IIotSfElementfactorService
         return iotSfElementfactorMapper.batchInsertIotSfElementfactor(factorList);
         return iotSfElementfactorMapper.batchInsertIotSfElementfactor(factorList);
     }
     }
 
 
+    /**
+     * 删除水肥机要素
+     *
+     * @param sfBid 水肥机要素ID
+     * @return 结果
+     */
+    @Override
+    public int deleteIotSfElementfactorBySfBid(String sfBid) {
+        return iotSfElementfactorMapper.deleteIotSfElementfactorBySfBid(sfBid);
+    }
+
 //    /**
 //    /**
 //     * 查询已配置要素列表
 //     * 查询已配置要素列表
 //     *
 //     *

+ 5 - 1
src/main/resources/mapper/IotSfElementfactorMapper.xml

@@ -32,7 +32,7 @@
         </where>
         </where>
     </select>
     </select>
 
 
-    <insert id="batchInsertIotSfElementfactor">
+    <insert id="batchInsertIotSfElementfactor" parameterType="IotSfElementfactor">
         INSERT INTO IotSfElementfactor (id, sfBid, devBid, sfType, sfCode, sfName, sfDisplayname, sfParentBid, sfSequence,
         INSERT INTO IotSfElementfactor (id, sfBid, devBid, sfType, sfCode, sfName, sfDisplayname, sfParentBid, sfSequence,
             tid, sfCreatedDate, sfCreator, sfModifieddate, sfModifier)
             tid, sfCreatedDate, sfCreator, sfModifieddate, sfModifier)
         VALUES
         VALUES
@@ -42,4 +42,8 @@
         </foreach>
         </foreach>
     </insert>
     </insert>
 
 
+    <delete id="deleteIotSfElementfactorBySfBid" parameterType="string">
+        DELETE FROM IotSfElementfactor WHERE sfBid = #{sfBid} OR sfParentBid = #{sfBid}
+    </delete>
+
 </mapper>
 </mapper>