Przeglądaj źródła

新增 编辑要素接口

zhaiyifei 8 miesięcy temu
rodzic
commit
4a3366963f

+ 22 - 4
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/controller/IotDeviceSfController.java

@@ -15,10 +15,7 @@ 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.IotDeviceDataListReqVo;
 import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceCommonService;
-import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfConfigCmdReqVo;
-import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfElementfactorAddReqVo;
-import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfElementfactorBatchAddReqVo;
-import com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfElementfactorListReqVo;
+import com.yunfeiyun.agmp.iotm.device.sf.domain.*;
 import com.yunfeiyun.agmp.iotm.util.ValidateUtil;
 import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListReqVo;
 import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDeviceListResVo;
@@ -301,6 +298,7 @@ public class IotDeviceSfController extends BaseController {
      * @return
      * @throws Exception
      */
+    @Transactional(rollbackFor = Exception.class)
     @PostMapping("/config/edit")
     public AjaxResult editConfig(@RequestBody IotSfConfigCmdReqVo reqVo) {
         log.info("【{}】【水肥机】【发水肥机设备设置指令】客户id {}", LogCore.getSeq(), getCustomerId());
@@ -315,6 +313,26 @@ public class IotDeviceSfController extends BaseController {
 
         return new AjaxResult(ErrorCode.SUCCESS.getCode(), "下发成功,等待设备响应结果", taskId);
     }
+
+    /**
+     * 新增要素
+     * 该接口用于添加新的泵类要素,接收相关参数并调用通用设备功能服务进行处理。
+     *
+     * @param reqVo 包含设备添加请求的参数,包括设备标识(devBid)等
+     * @return 返回操作结果的表格数据信息
+     * @throws ValidateException 如果设备标识(devBid)无效,则抛出ValidateException异常
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @PostMapping("/ele/edit")
+    public AjaxResult elementEdit(@RequestBody IotSfElementfactorEditReqVo reqVo){
+        ValidateUtil.validateDevBid(reqVo.getDevBid());
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("elementEdit");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        int status = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+        return toAjax(status);
+    }
 //
 //    /**
 //     * 下发水肥机指令

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

@@ -0,0 +1,35 @@
+package com.yunfeiyun.agmp.iotm.device.sf.domain;
+
+import com.yunfeiyun.agmp.iot.common.domain.IotBaseEntity;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 水肥机要素
+ */
+@Data
+public class IotSfElementfactorEditReqVo extends IotBaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /** 业务标识 */
+    private String sfBid;
+
+    /** 设备编号 */
+    private String devBid;
+
+    /** 显示名称 */
+    private String sfDisplayname;
+
+    /** 排序字段 默认0 */
+    private int sfSequence;
+
+    /** 纬度 */
+    private BigDecimal sfLat;
+    /** 经度 */
+    private BigDecimal sfLng;
+
+    /** 地址 */
+    private String sfAddress;
+
+}

+ 40 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/IIotSfCommService.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
 import com.yunfeiyun.agmp.common.constant.ErrorCode;
 import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
 import com.yunfeiyun.agmp.common.log.LogCore;
+import com.yunfeiyun.agmp.common.utils.DateUtils;
 import com.yunfeiyun.agmp.common.utils.JSONUtils;
 import com.yunfeiyun.agmp.common.utils.SecurityUtils;
 import com.yunfeiyun.agmp.common.utils.StringUtils;
@@ -331,4 +332,43 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
         return null;
     }
 
+    /**
+     * 要素编辑
+     *
+     * @param reqVo 包含设备添加请求的参数,包括设备标识(devBid)等
+     */
+    public int elementEdit(IotSfElementfactorEditReqVo reqVo) {
+        String devBid = reqVo.getDevBid();
+        String sfBid = reqVo.getSfBid();
+        String sfDisplayname = reqVo.getSfDisplayname();
+
+        if (StringUtils.isEmpty(devBid)) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
+        }
+        if (StringUtils.isEmpty(sfDisplayname)) {
+            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "要素名称不能为空");
+        }
+        IotDevice iotDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
+        if (iotDevice == null) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
+        }
+        if (StringUtils.isEmpty(sfBid)) {
+            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "要素标识不能为空");
+        }
+
+        IotSfElementfactor iotSfElementfactor = iotSfElementfactorService.selectIotSfElementfactorBySfBid(sfBid);
+        if (iotSfElementfactor == null) {
+            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "要素不存在");
+        }
+
+        iotSfElementfactor.setSfDisplayname(sfDisplayname);
+        iotSfElementfactor.setSfAddress(reqVo.getSfAddress());
+        iotSfElementfactor.setSfLat(reqVo.getSfLat());
+        iotSfElementfactor.setSfLng(reqVo.getSfLng());
+        iotSfElementfactor.setSfSequence(reqVo.getSfSequence());
+        iotSfElementfactor.setSfModifieddate(DateUtils.dateTimeNow());
+        iotSfElementfactor.setSfModifier(SecurityUtils.getUserId());
+        return iotSfElementfactorService.updateIotSfElementfactor(iotSfElementfactor);
+    }
+
 }

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

@@ -44,4 +44,12 @@ public interface IotSfElementfactorMapper {
      */
     public IotSfElementfactor selectIotSfElementfactorBySfBid(String sfBid);
 
+    /**
+     * 更新水肥机要素
+     *
+     * @param elementfactor 水肥机要素
+     * @return 结果
+     */
+    public int updateIotSfElementfactor(IotSfElementfactor elementfactor);
+
 }

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

@@ -62,6 +62,14 @@ public interface IIotSfElementfactorService {
     public int batchInsertIotSfElementfactor(List<IotSfElementfactor> factorList);
 
     /**
+     * 更新水肥机要素
+     *
+     * @param elementfactor 水肥机要素
+     * @return 结果
+     */
+    public int updateIotSfElementfactor(IotSfElementfactor elementfactor);
+
+    /**
      * 删除水肥机要素
      *
      * @param sfBid 水肥机要素ID

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

@@ -59,6 +59,17 @@ public class IotSfElementfactorServiceImpl implements IIotSfElementfactorService
     }
 
     /**
+     * 更新水肥机要素
+     *
+     * @param elementfactor 水肥机要素
+     * @return 结果
+     */
+    @Override
+    public int updateIotSfElementfactor(IotSfElementfactor elementfactor) {
+        return iotSfElementfactorMapper.updateIotSfElementfactor(elementfactor);
+    }
+
+    /**
      * 删除水肥机要素
      *
      * @param sfBid 水肥机要素ID

+ 14 - 0
src/main/resources/mapper/IotSfElementfactorMapper.xml

@@ -4,6 +4,20 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yunfeiyun.agmp.iotm.web.mapper.IotSfElementfactorMapper">
 
+    <update id="updateIotSfElementfactor" parameterType="IotSfElementfactor">
+        UPDATE IotSfElementfactor
+        <set>
+            <if test="sfDisplayname!= null and sfDisplayname!= ''">sfDisplayname = #{sfDisplayname},</if>
+            <if test="sfSequence!= null and sfSequence!= ''">sfSequence = #{sfSequence},</if>
+            <if test="sfLng!= null and sfLng!= ''">sfLng = #{sfLng},</if>
+            <if test="sfLat!= null and sfLat!= ''">sfLat = #{sfLat},</if>
+            <if test="sfAddress!= null and sfAddress!= ''">sfAddress = #{sfAddress},</if>
+            <if test="sfModifieddate!= null and sfModifieddate!= ''">sfModifieddate = #{sfModifieddate},</if>
+            <if test="sfModifier!= null and sfModifier!= ''">sfModifier = #{sfModifier},</if>
+        </set>
+        WHERE sfBid = #{sfBid}
+    </update>
+
     <select id="selectIotSfElementfactorList" parameterType="com.yunfeiyun.agmp.iotm.device.sf.domain.IotSfElementfactorListReqVo"
             resultType="com.yunfeiyun.agmp.iot.common.domain.IotSfElementfactor" >
         SELECT sf.id, sf.sfBid, sf.devBid, sf.sfType, sf.sfCode, sf.sfName, sf.sfDisplayname, sf.sfParentBid, sf.sfSequence,