Commit 644cce09 by HlQ

[add] 添加门店人数波动异常事件处理

[chg] 行分隔符修改 CRLF -> LF
1 parent ca5b6f5c
...@@ -7,34 +7,91 @@ import java.util.Arrays; ...@@ -7,34 +7,91 @@ import java.util.Arrays;
@Getter @Getter
public enum MqttMessageType { public enum MqttMessageType {
/**
* 注册
*/
REGISTER("REGISTER"), REGISTER("REGISTER"),
/**
* 升级
*/
UPGRADE("UPGRADE"), UPGRADE("UPGRADE"),
// region store + mall 共有
/**
* 客流数据中断
*/
PASSENGER_FLOW_INTERRUPT("PASSENGER_FLOW_INTERRUPT"),
/**
* 设备离线
*/
DEVICE_OFFLINE("DEVICE_OFFLINE"),
/**
* 全天分析异常
*/
REID_ANALYZE("REID_EXCEPTION"),
/**
* 设备注册次数异常
*/
DEVICE_REGISTRATION("DEVICE_REGISTRATION"),
/**
* 设备特征异常
*/
DEVICE_FEATURE("DEVICE_FEATURE"),
/**
* 人数/人次异常
*/
HEADCOUNT_RATIO("HEADCOUNT_RATIO"),
/**
* 店员识别异常
*/
STAFF_RECOGNIZE("STAFF_RECOGNIZE"),
// endregion
// region store
/**
* 门店顾客人数波动异常
*/
STORE_CUSTOMER_UNDULATE("STORE_CUSTOMER_UNDULATE"),
/**
* 门店监控点数据波动异常
*/
STORE_GATE_DATA_UNDULATE("STORE_GATE_DATA_UNDULATE"),
/**
* 门店进出匹配率异常
*/
STORE_INOUT_MATCH_RATIO("STORE_INOUT_MATCH_RATIO"),
/**
* 门店单聚类异常
*/
STORE_SINGLE_CLUSTER("STORE_SINGLE_CLUSTER"),
/**
* 门店进店率异常
*/
STORE_ENTER_RATIO("STORE_ENTER_RATIO"),
// endregion
// region mall
/**
* 广场进出客流差异异常
*/
MALL_INOUT_DIFF("MALL_INOUT_DIFF"),
/**
* 广场店铺进出差异异常
*/
MALL_SHOP_INOUT_DIFF("MALL_SHOP_INOUT_DIFF"),
/** /**
* store + mall 共有 * 广场数据波动异常
*/ */
PASSENGER_FLOW_INTERRUPT("PASSENGER_FLOW_INTERRUPT"), //客流数据中断, MALL_DATA_UNDULATE("MALL_DATA_UNDULATE"),
DEVICE_OFFLINE("DEVICE_OFFLINE"), //设备离线
REID_ANALYZE("REID_EXCEPTION"), //全天分析异常
DEVICE_REGISTRATION("DEVICE_REGISTRATION"), //设备注册次数异常
DEVICE_FEATURE("DEVICE_FEATURE"), //设备特征异常
HEADCOUNT_RATIO("HEADCOUNT_RATIO"), //人数/人次异常
STAFF_RECOGNIZE("STAFF_RECOGNIZE"), //店员识别异常
/** /**
* store * 广场外围入口数据波动异常
*/ */
STORE_CUSTOMER_UNDULATE("STORE_CUSTOMER_UNDULATE"), //门店顾客人数波动异常 MALL_GATE_DATA_UNDULATE("MALL_GATE_DATA_UNDULATE"),
STORE_GATE_DATA_UNDULATE("STORE_GATE_DATA_UNDULATE"), //门店监控点数据波动异常
STORE_INOUT_MATCH_RATIO("STORE_INOUT_MATCH_RATIO"), //门店进出匹配率异常
STORE_SINGLE_CLUSTER("STORE_SINGLE_CLUSTER"), //门店单聚类异常
STORE_ENTER_RATIO("STORE_ENTER_RATIO"), //门店进店率异常
/** /**
* mall * 广场店铺数据波动异常
*/ */
MALL_INOUT_DIFF("MALL_INOUT_DIFF"), //广场进出客流差异异常 MALL_SHOP_DATA_UNDULATE("MALL_SHOP_DATA_UNDULATE"),
MALL_SHOP_INOUT_DIFF("MALL_SHOP_INOUT_DIFF"), //广场店铺进出差异异常 // endregion
MALL_DATA_UNDULATE("MALL_DATA_UNDULATE"), //广场数据波动异常
MALL_GATE_DATA_UNDULATE("MALL_GATE_DATA_UNDULATE"), //广场外围入口数据波动异常
MALL_SHOP_DATA_UNDULATE("MALL_SHOP_DATA_UNDULATE"), //广场店铺数据波动异常
; ;
private final String type; private final String type;
......
...@@ -42,22 +42,25 @@ public class MqttClientMessageListener { ...@@ -42,22 +42,25 @@ public class MqttClientMessageListener {
String type = jsonObj.path("eventType").asText(); String type = jsonObj.path("eventType").asText();
switch (MqttMessageType.getEnumByType(type)) { switch (MqttMessageType.getEnumByType(type)) {
case MqttMessageType.REGISTER: case MqttMessageType.REGISTER:
log.info("设备注册:{}", jsonObj);
String agentUid = jsonObj.path("agentUid").asText(); String agentUid = jsonObj.path("agentUid").asText();
updateTaskByAgent(agentUid); updateTaskByAgent(agentUid);
break; break;
case MqttMessageType.PASSENGER_FLOW_INTERRUPT:
handlePassengerFlowInterrupt(jsonObj.toString());
break;
case MqttMessageType.DEVICE_OFFLINE: case MqttMessageType.DEVICE_OFFLINE:
//设备离线
handleDeviceOffline(jsonObj.toString()); handleDeviceOffline(jsonObj.toString());
break; break;
case MqttMessageType.REID_ANALYZE: case MqttMessageType.REID_ANALYZE:
//全天分析异常 handleReid(jsonObj.toString());
handleWholeDayAnalyze(jsonObj.toString());
break; break;
case MqttMessageType.PASSENGER_FLOW_INTERRUPT: // region store 事件
//客流数据中断 case STORE_CUSTOMER_UNDULATE:
handlePassengerFlowInterrupt(jsonObj.toString()); handleStoreCustomerUndulate(jsonObj.toString());
break; break;
// endregion
// region mall 事件
// endregion
default: default:
log.info("未定义的消息类型:{}, payload:{}", type, jsonObj); log.info("未定义的消息类型:{}, payload:{}", type, jsonObj);
break; break;
...@@ -67,7 +70,11 @@ public class MqttClientMessageListener { ...@@ -67,7 +70,11 @@ public class MqttClientMessageListener {
} }
} }
//下发事件 /**
* 下发事件
*
* @param agentUid agent uid
*/
private void updateTaskByAgent(String agentUid) { private void updateTaskByAgent(String agentUid) {
List<RAgentEvent> list = agentEventService.lambdaQuery() List<RAgentEvent> list = agentEventService.lambdaQuery()
.eq(RAgentEvent::getAgentUid, agentUid) .eq(RAgentEvent::getAgentUid, agentUid)
...@@ -88,22 +95,44 @@ public class MqttClientMessageListener { ...@@ -88,22 +95,44 @@ public class MqttClientMessageListener {
log.info("agent:{} topic:{} 结束下发事件监测", agentUid, topic); log.info("agent:{} topic:{} 结束下发事件监测", agentUid, topic);
} }
//设备离线上报 /**
* 设备离线上报
*
* @param payloadStr 事件记录
*/
private void handleDeviceOffline(String payloadStr) { private void handleDeviceOffline(String payloadStr) {
EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class); EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class);
recordService.save(eventRecord); recordService.save(eventRecord);
} }
//全天分析异常上报 /**
private void handleWholeDayAnalyze(String payloadStr) { * 全天分析异常上报
*
* @param payloadStr 事件记录
*/
private void handleReid(String payloadStr) {
EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class); EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class);
recordService.save(eventRecord); recordService.save(eventRecord);
} }
//客流数据中断 /**
* 客流数据中断
*
* @param payloadStr 事件记录
*/
private void handlePassengerFlowInterrupt(String payloadStr) { private void handlePassengerFlowInterrupt(String payloadStr) {
EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class); EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class);
recordService.save(eventRecord); recordService.save(eventRecord);
} }
/**
* 门店人数波动异常
*
* @param payloadStr 事件记录
*/
private void handleStoreCustomerUndulate(String payloadStr) {
EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class);
recordService.save(eventRecord);
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!