作者 钟来

模块整理

@@ -13,4 +13,5 @@ public interface CacheService { @@ -13,4 +13,5 @@ public interface CacheService {
13 boolean updateCache(Topic topic, ServerDto dto); //返回是否需要持久化 13 boolean updateCache(Topic topic, ServerDto dto); //返回是否需要持久化
14 IotDevice getIotDevice(String id); 14 IotDevice getIotDevice(String id);
15 IotTerminal getIotTerminal(String id); 15 IotTerminal getIotTerminal(String id);
  16 + void sendMsg(String channel, Object message);
16 } 17 }
@@ -199,6 +199,11 @@ public class CacheServiceImpl implements CacheService { @@ -199,6 +199,11 @@ public class CacheServiceImpl implements CacheService {
199 redisService.del(keys); 199 redisService.del(keys);
200 } 200 }
201 201
  202 + //发送消息
  203 + public void sendMsg(String channel, Object message){
  204 + redisService.sendMsg( channel, message);
  205 + }
  206 +
202 /** 207 /**
203 * 获取缓存主机key 208 * 获取缓存主机key
204 * @param client_id 209 * @param client_id
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
4 import org.slf4j.Logger; 4 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory; 5 import org.slf4j.LoggerFactory;
6 import org.springframework.data.redis.core.RedisTemplate; 6 import org.springframework.data.redis.core.RedisTemplate;
  7 +import org.springframework.data.redis.serializer.StringRedisSerializer;
7 import org.springframework.stereotype.Service; 8 import org.springframework.stereotype.Service;
8 import org.springframework.util.CollectionUtils; 9 import org.springframework.util.CollectionUtils;
9 10
@@ -22,6 +23,11 @@ public class RedisService { @@ -22,6 +23,11 @@ public class RedisService {
22 @Resource 23 @Resource
23 private RedisTemplate<String,Object> redisTemplate; 24 private RedisTemplate<String,Object> redisTemplate;
24 25
  26 + //发送消息
  27 + public void sendMsg(String channel, Object message){
  28 + redisTemplate.convertAndSend( channel, message);
  29 + }
  30 +
25 31
26 /** 32 /**
27 * @param key 33 * @param key
@@ -93,6 +93,9 @@ public class MqttCallback implements MqttCallbackExtended { @@ -93,6 +93,9 @@ public class MqttCallback implements MqttCallbackExtended {
93 terminalService.publish(TopicUtil.generateSendMessageTopic(desttopic),"1"); 93 terminalService.publish(TopicUtil.generateSendMessageTopic(desttopic),"1");
94 return; 94 return;
95 } 95 }
  96 +
  97 + cacheService.sendMsg(s.replaceAll("/",":"),new String(data));
  98 +
96 if("ONLINE".equals(topic.getTopicType().toUpperCase())) 99 if("ONLINE".equals(topic.getTopicType().toUpperCase()))
97 { 100 {
98 topic.setPayloadtype("String"); 101 topic.setPayloadtype("String");
@@ -49,7 +49,7 @@ mqtt: @@ -49,7 +49,7 @@ mqtt:
49 mqtt_usernames: 6_WP,12_BPQ,10_TLJ,NWDB_2023,WLJ_1,YWB_A700E,12_ZNZY 49 mqtt_usernames: 6_WP,12_BPQ,10_TLJ,NWDB_2023,WLJ_1,YWB_A700E,12_ZNZY
50 #订阅的topic 50 #订阅的topic
51 topics: ADD_POST,ALL_POST,DB_TOPIC_DISTRIBUTE,GET/+,online,PUT_REQ/+,READ_REQ/+ 51 topics: ADD_POST,ALL_POST,DB_TOPIC_DISTRIBUTE,GET/+,online,PUT_REQ/+,READ_REQ/+
52 - sub_clientid: '866838067732715' 52 + sub_clientid: '866838067733465'
53 topicconfig: "/{{roleid}}/{{username}}/{{clientid}}/{{payloadtype}}/{{topicType}}/{{messageid}}" 53 topicconfig: "/{{roleid}}/{{username}}/{{clientid}}/{{payloadtype}}/{{topicType}}/{{messageid}}"
54 top_return_map: '{"PUT":"PUT_REQ","READ":"READ_REQ"}' 54 top_return_map: '{"PUT":"PUT_REQ","READ":"READ_REQ"}'
55 username: sysuser 55 username: sysuser
@@ -101,4 +101,9 @@ public class CameraData { @@ -101,4 +101,9 @@ public class CameraData {
101 * 尺度之内的面积之和曲线的峰值 101 * 尺度之内的面积之和曲线的峰值
102 */ 102 */
103 private Double scaleAreaSumMax = 0.0; 103 private Double scaleAreaSumMax = 0.0;
  104 +
  105 + /**
  106 + * 尺度之内的面积之和占比
  107 + */
  108 + private Integer scaleAreaSumPercentage = 0;
104 } 109 }
@@ -44,8 +44,11 @@ public class ScaleStepMethodService { @@ -44,8 +44,11 @@ public class ScaleStepMethodService {
44 StringBuffer stringBuffer = new StringBuffer(); 44 StringBuffer stringBuffer = new StringBuffer();
45 stringBuffer.append(nowtime); 45 stringBuffer.append(nowtime);
46 stringBuffer.append(" "); 46 stringBuffer.append(" ");
  47 +
47 //如果鱼群急剧减少,就停止投料 48 //如果鱼群急剧减少,就停止投料
48 - if (((OperatingData.cameraData.getScaleAreaSumMax()*OperatingData.cameraConfig.getStopTriggeringConditions())/100)-sum>=0) 49 + Integer scaleAreaSumPercentage = new Double((sum/OperatingData.cameraData.getScaleAreaSumMax())*100).intValue();
  50 + OperatingData.cameraData.setScaleAreaSumPercentage(scaleAreaSumPercentage);
  51 + if (scaleAreaSumPercentage-OperatingData.cameraConfig.getStopTriggeringConditions()<=0)
49 { 52 {
50 Condata condata = OperatingData.feederConfig.getCondata(); 53 Condata condata = OperatingData.feederConfig.getCondata();
51 54
@@ -86,7 +89,7 @@ public class ScaleStepMethodService { @@ -86,7 +89,7 @@ public class ScaleStepMethodService {
86 } 89 }
87 90
88 //如果鱼群急剧增加,。。。 91 //如果鱼群急剧增加,。。。
89 - if (OperatingData.cameraData.getScaleAreaSumMax()-((OperatingData.cameraData.getScaleAreaSumMax()*OperatingData.cameraConfig.getStopTriggeringConditions())/100)-sum<=0) 92 + if (100-OperatingData.cameraConfig.getStopTriggeringConditions()-scaleAreaSumPercentage<=0)
90 { 93 {
91 stringBuffer.append("发现鱼群急剧增加,"); 94 stringBuffer.append("发现鱼群急剧增加,");
92 95