|
@ -1,5 +1,7 @@ |
|
|
package com.zc.business.message.device.handler; |
|
|
package com.zc.business.message.device.handler; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.zc.business.domain.DcDevice; |
|
|
import com.zc.business.domain.DcDevice; |
|
|
import com.zc.business.service.IDcDeviceService; |
|
|
import com.zc.business.service.IDcDeviceService; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
@ -14,11 +16,42 @@ import java.util.stream.Collectors; |
|
|
@Service |
|
|
@Service |
|
|
public class DeviceMessageHandler { |
|
|
public class DeviceMessageHandler { |
|
|
|
|
|
|
|
|
|
|
|
enum ProductType { |
|
|
|
|
|
// 摄像头检测事件
|
|
|
|
|
|
CAMERA_DETECTION_EVENT("video-event"), |
|
|
|
|
|
// 情报板
|
|
|
|
|
|
VARIABLE_MESSAGE_SIGN("7877"), |
|
|
|
|
|
|
|
|
|
|
|
// 行车诱导
|
|
|
|
|
|
TRAFFIC_GUIDANCE("8866"), |
|
|
|
|
|
|
|
|
|
|
|
// 气象检测器
|
|
|
|
|
|
WEATHER_DETECTOR("zc-meteorological"), |
|
|
|
|
|
|
|
|
|
|
|
// 设备箱
|
|
|
|
|
|
ZC_SHE_BEI_XIANG("zc-shebeixiang-1883"), |
|
|
|
|
|
|
|
|
|
|
|
// 一站式情况调查产品
|
|
|
|
|
|
STANDARD_JTT("zc-yzsqkdc-3131") |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
private final String value; |
|
|
|
|
|
|
|
|
|
|
|
ProductType(String value) { |
|
|
|
|
|
this.value = value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String value() { |
|
|
|
|
|
return this.value; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private IDcDeviceService dcDeviceService; |
|
|
private IDcDeviceService dcDeviceService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 更新设备状态 |
|
|
* 更新设备状态 |
|
|
|
|
|
* |
|
|
* @param msg 物联设备id集合 |
|
|
* @param msg 物联设备id集合 |
|
|
* @param state 设备状态 0 异常 1 正常 |
|
|
* @param state 设备状态 0 异常 1 正常 |
|
|
*/ |
|
|
*/ |
|
@ -34,4 +67,21 @@ public class DeviceMessageHandler { |
|
|
// 批量更新设备状态
|
|
|
// 批量更新设备状态
|
|
|
dcDeviceService.batchUpdate(dcDevices); |
|
|
dcDeviceService.batchUpdate(dcDevices); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 消息处理 |
|
|
|
|
|
* 1-事件消息 |
|
|
|
|
|
* 2-属性读取回复 |
|
|
|
|
|
*/ |
|
|
|
|
|
public void handle(String msg) { |
|
|
|
|
|
JSONObject data = JSON.parseObject(msg, JSONObject.class); |
|
|
|
|
|
|
|
|
|
|
|
// 产品id
|
|
|
|
|
|
String productId = data.getJSONObject("headers").getString("productId"); |
|
|
|
|
|
|
|
|
|
|
|
// 摄像头检测事件
|
|
|
|
|
|
if (productId.equals(ProductType.CAMERA_DETECTION_EVENT.value)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|