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

Merge remote-tracking branch 'origin/master'

liuyaowen 1 год назад
Родитель
Сommit
f6299080ab

+ 11 - 7
src/main/java/com/yunfeiyun/agmp/iots/core/manager/MqttManager.java

@@ -106,18 +106,22 @@ public class MqttManager {
         log.info("【创建MqttCore实例】 mqttCore: {} connectionId:{} devSize:{}", mqttCore,connectionId,devices.size());
         List<MqttTopicValue> mqttTopicValues=new ArrayList<>();
         for(IotDevice iotDevice:devices){
-            MqttTopicValue mqttTopicValue=new MqttTopicValue();
-            mqttTopicValue.setDevCode(iotDevice.getDevCode());
-            mqttTopicValue.setDevId(iotDevice.getDevBid());
-            mqttTopicValue.setTopic(deviceTopicService.getTopic(serviceName, iotDevice.getDevCode()));
-            mqttTopicValues.add(mqttTopicValue);
+
+            String[] topics= deviceTopicService.getTopic(serviceName, iotDevice.getDevCode());
+            for(String s: topics){
+                MqttTopicValue mqttTopicValue=new MqttTopicValue();
+                mqttTopicValue.setDevCode(iotDevice.getDevCode());
+                mqttTopicValue.setDevId(iotDevice.getDevBid());
+                mqttTopicValue.setTopic(s);
+                mqttTopicValues.add(mqttTopicValue);
+            }
+
         }
 
         String[] topics=new String[mqttTopicValues.size()];
         if(mqttTopicValues!=null&&!mqttTopicValues.isEmpty()){
-            for(int i=0;i<devices.size();i++){
+            for(int i=0;i<mqttTopicValues.size();i++){
                 topics[i]=mqttTopicValues.get(i).getTopic();
-                System.out.println("xxxxxxxxxxxxxxxxxxxxx"+mqttTopicValues.get(i).getTopic());
             }
            cfgYf.setSubTopic(topics);
         }

+ 2 - 2
src/main/java/com/yunfeiyun/agmp/iots/core/mqtt/DeviceTopicService.java

@@ -101,7 +101,7 @@ public class DeviceTopicService {
         }
     }
 
-    public String getTopic(String serviceName,String deviceCode) {
+    public String[] getTopic(String serviceName,String deviceCode) {
         if(StringUtils.isEmpty(deviceCode)){
             return null;
         }
@@ -111,7 +111,7 @@ public class DeviceTopicService {
         MqttTopicValue mqttTopicValue=new MqttTopicValue();
         mqttTopicValue.setDevCode(deviceCode);
         mqttTopicValues.add(mqttTopicValue);
-        return getBatchTopic(serviceName,mqttTopicValues)[0];
+        return getBatchTopic(serviceName,mqttTopicValues);
     }
 
     private String[] getHKBatchSubTopic() {

+ 11 - 1
src/main/java/com/yunfeiyun/agmp/iots/device/serviceImp/IotCbdImgService.java

@@ -209,7 +209,17 @@ public class IotCbdImgService {
         String cbdimgBid = contentObject.getString("cbdimgBid");
         String cbdrecogType = contentObject.getString("cbdrecogType");
 
-        JSONObject recogeData = getRecogeResult(cbdimgBid, cbdrecogType);
+        JSONObject recogeData=null;
+        try{
+             recogeData = getRecogeResult(cbdimgBid, cbdrecogType);
+
+        }catch (Exception e){
+            log.error("{}",e);
+
+        }
+        if(recogeData==null){
+            recogeData=new JSONObject();
+        }
         String cbdrecogResult = this.getJsonData("Result", recogeData);
         String cbdrecogResultB = this.getJsonData("Result_b", recogeData);
         String cbdimgAddrB = this.getJsonData("Result_image_b", recogeData);

+ 1 - 1
src/main/java/com/yunfeiyun/agmp/iots/mq/listener/IotmBaseDataChannelAwareMessageListener.java

@@ -87,7 +87,7 @@ public class IotmBaseDataChannelAwareMessageListener implements ChannelAwareMess
             channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
         } catch (IOException e) {
             // 处理异常,例如重新入队或拒绝消息
-            channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
+            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
         }
     }
 }

+ 7 - 7
src/main/resources/mapper/IotPestMapper.xml

@@ -3,11 +3,11 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yunfeiyun.agmp.iots.device.mapper.IotPestMapper">
-    
+
     <resultMap type="IotPest" id="IotPestResult">
         <result property="id"    column="id"    />
         <result property="pestBid"    column="pestBid"    />
-        <result property="cId"    column="cId"    />
+        <result property="tid"    column="tid"    />
         <result property="pestName"    column="pestName"    />
         <result property="pestId"    column="pestId"    />
         <result property="pestRemark"    column="pestRemark"    />
@@ -20,14 +20,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectIotPestVo">
-        select id, pestBid, cId, pestName, pestId, pestRemark, pestCreator, pestModifier, pestModifieddate, pestCreatedDate, pestDelstatus, pestInsertType from IotPest
+        select id, pestBid, tid, pestName, pestId, pestRemark, pestCreator, pestModifier, pestModifieddate, pestCreatedDate, pestDelstatus, pestInsertType from IotPest
     </sql>
     <insert id="insertPest">
-        insert into IotPest (id, pestBid, cId, pestName, pestId, pestRemark, pestCreator, pestModifier, pestModifieddate, pestCreatedDate, pestDelstatus, pestInsertType) values
+        insert into IotPest (id, pestBid, tid, pestName, pestId, pestRemark, pestCreator, pestModifier, pestModifieddate, pestCreatedDate, pestDelstatus, pestInsertType) values
         (
         #{id},
         #{pestBid},
-        #{cId},
+        #{tid},
         #{pestName},
         #{pestId},
         #{pestRemark},
@@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>
             pestDelstatus = 0
             <if test="pestBid != null  and pestBid != ''"> and pestBid = #{pestBid}</if>
-            <if test="cId != null  and cId != ''"> and cId = #{cId}</if>
+            <if test="tid != null  and tid != ''"> and tid = #{tid}</if>
             <if test="pestName != null  and pestName != ''"> and pestName like concat('%', #{pestName}, '%')</if>
             <if test="pestId != null  and pestId != ''"> and pestId = #{pestId}</if>
             <if test="pestInsertType != null  and pestInsertType != ''"> and pestInsertType = #{pestInsertType}</if>
@@ -57,4 +57,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectIotPestVo"/>
         where pestDelstatus = 0 and pestBid = #{pestBid}
     </select>
-</mapper>
+</mapper>