Просмотр исходного кода

新增 气象站预警手动触发接口

zhaiyifei 9 месяцев назад
Родитель
Сommit
0bd059739e

+ 15 - 2
src/main/java/com/yunfeiyun/agmp/iots/device/controller/TestController.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
 import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
 import com.yunfeiyun.agmp.common.utils.DateUtils;
 import com.yunfeiyun.agmp.common.utils.JSONUtils;
+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;
@@ -600,13 +601,25 @@ public class TestController {
 
     @PostMapping("/warn")
     public AjaxResult warnQxzTest(@RequestBody WarnTestReq req) throws Exception {
-        String devBid = req.getDevBid();
+        String devCode = req.getDevCode();
         JSONObject data = req.getData();
+
+        if(StringUtils.isEmpty(devCode)) {
+            throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备编码为空");
+        }
+
         if(data == null) {
             throw new IotBizException(IotErrorCode.FAILURE.getCode(), "数据为空");
         }
 
-        IotDevice iotDevice = iotDeviceService.selectIotDeviceByDevBid(devBid);
+        List<IotDevice> iotDeviceList = iotDeviceService.selectIotDeviceByDevCode(devCode);
+        if (iotDeviceList == null || iotDeviceList.isEmpty()) {
+            throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备不存在");
+        }
+        if(iotDeviceList.size() > 1) {
+            throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备不唯一");
+        }
+        IotDevice iotDevice = iotDeviceList.get(0);
         if (iotDevice == null) {
             throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备不存在");
         }

+ 1 - 1
src/main/java/com/yunfeiyun/agmp/iots/device/domain/WarnTestReq.java

@@ -8,7 +8,7 @@ public class WarnTestReq {
     /**
      * 设备ID
      */
-    private String devBid;
+    private String devCode;
 
     /**
      * 设备数据

+ 2 - 0
src/main/java/com/yunfeiyun/agmp/iots/device/mapper/IotDeviceMapper.java

@@ -27,6 +27,8 @@ public interface IotDeviceMapper {
 
     IotDevice selectIotDeviceByDevBid(String devBid);
 
+    List<IotDevice> selectIotDeviceByDevCode(String devCode);
+
     List<IotDevice> selectIotDeviceByDevBidList(List<String> devBidList);
     List<IotDevice> selectIotDeviceByDevTypeBidList(List<String> devTypeBidList);
 

+ 2 - 0
src/main/java/com/yunfeiyun/agmp/iots/service/IIotDeviceService.java

@@ -45,6 +45,8 @@ public interface IIotDeviceService {
      */
     List<IotDevice> selectIotDeviceByDevBidList(List<String> devBidList);
 
+    List<IotDevice> selectIotDeviceByDevCode(String devCode);
+
     /**
      * 根据设备标识列表批量查询设备map
      *

+ 5 - 0
src/main/java/com/yunfeiyun/agmp/iots/service/impl/IotDeviceServiceImpl.java

@@ -126,6 +126,11 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
         return iotDeviceMapper.selectIotDeviceByDevBidList(devBidList);
     }
 
+    @Override
+    public List<IotDevice> selectIotDeviceByDevCode(String devCode) {
+        return iotDeviceMapper.selectIotDeviceByDevCode(devCode);
+    }
+
     /**
      * 根据设备标识列表批量查询设备map
      *

+ 7 - 0
src/main/resources/mapper/IotDeviceMapper.xml

@@ -54,6 +54,13 @@
         </where>
     </select>
 
+    <select id="selectIotDeviceByDevCode" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
+        <include refid="selectIotDeviceVo"/>
+        <where>
+            devCode = #{devCode} and devDelstatus = '0'
+        </where>
+    </select>
+
     <select id="selectIotDeviceByDevBidList" parameterType="java.util.List"
             resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
         <include refid="selectIotDeviceVo"/>