|
@@ -62,7 +62,12 @@ public class MqttCallbackHandler {
|
|
|
registerHandler_LP(msgDto);
|
|
|
break;
|
|
|
}
|
|
|
- // 设备上传信息
|
|
|
+ // 设备上传定位信息
|
|
|
+ case Constant.M_CODE_UPLOAD_LOCATION_INFO_LP: {
|
|
|
+ uploadLocationInfoLPHandler(topic, msgDto);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ // 设备上传基本信息
|
|
|
case Constant.M_CODE_UPLOAD_INFO_LP: {
|
|
|
uploadDeviceInfoLPHandler(topic, msgDto);
|
|
|
break;
|
|
@@ -133,7 +138,7 @@ public class MqttCallbackHandler {
|
|
|
deviceLp = new DeviceLp();
|
|
|
deviceLp.setNum(num);
|
|
|
deviceLp.setClientId(Constant.LP_DEVICE_ID_PREFIX + num);
|
|
|
- deviceLp.setPassword(MD5Util.MD5Encode(num));
|
|
|
+ deviceLp.setPassword(MD5Util.encodeCut(num));
|
|
|
deviceLp.setGroup(obj.getString("group"));
|
|
|
deviceLpService.save(deviceLp);
|
|
|
}
|
|
@@ -174,12 +179,38 @@ public class MqttCallbackHandler {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 处理设备信息上传
|
|
|
+ * 处理设备定位信息上传
|
|
|
+ * 路牌
|
|
|
+ */
|
|
|
+ private void uploadLocationInfoLPHandler(String topic, MqttMsgDto msg) {
|
|
|
+ try {
|
|
|
+ String num = topic.split("IMEI")[1];
|
|
|
+ DeviceLp deviceLp = new DeviceLp();
|
|
|
+ deviceLp.setMode(msg.getInt("mode"));
|
|
|
+ deviceLp.setLng(msg.getString("lng"));
|
|
|
+ deviceLp.setLat(msg.getString("lat"));
|
|
|
+ //转换后的坐标
|
|
|
+ String[] gcj = CoordTransformUtil.wgs84toGcj02(deviceLp.getLng(), deviceLp.getLat());
|
|
|
+ deviceLp.setLngGcj(gcj[0]);
|
|
|
+ deviceLp.setLatGcj(gcj[1]);
|
|
|
+ // 逆地理位置解析
|
|
|
+ deviceLp.setSite(GaoDeApiUtil.regeo(deviceLp.getLngGcj(), deviceLp.getLatGcj()));
|
|
|
+ // 保存基本信息
|
|
|
+ deviceLpService.updateByNum(deviceLp, num);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new ApiRuntimeException("处理路牌设备上传定位信息出错");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理设备基本信息上传
|
|
|
* 路牌
|
|
|
*/
|
|
|
private void uploadDeviceInfoLPHandler(String topic, MqttMsgDto msg) {
|
|
|
try {
|
|
|
String num = topic.split("IMEI")[1];
|
|
|
+ setService.getDeviceLocation_LP(num);
|
|
|
//如果远程设备的信息与数据库的信息不一致,则发送消息更新远程信息
|
|
|
DeviceLp dbDevice = deviceLpService.getByNum(num);
|
|
|
System.out.println(dbDevice.getWakeInt());
|
|
@@ -189,6 +220,7 @@ public class MqttCallbackHandler {
|
|
|
setService.updateDevice_LP(num, dbDevice.getWakeInt(), dbDevice.getThresh());
|
|
|
}
|
|
|
DeviceLp deviceLp = new DeviceLp();
|
|
|
+ deviceLp.setDataType(msg.getString("datetype"));
|
|
|
deviceLp.setBattery(msg.getString("batterynum"));
|
|
|
deviceLp.setS4g(msg.getString("s4g"));
|
|
|
deviceLp.setX(msg.getString("x"));
|
|
@@ -198,20 +230,11 @@ public class MqttCallbackHandler {
|
|
|
deviceLp.setAngley(msg.getString("angley"));
|
|
|
deviceLp.setAnglez(msg.getString("anglez"));
|
|
|
deviceLp.setTemp(msg.getString("temp"));
|
|
|
- deviceLp.setLon(msg.getString("lon"));
|
|
|
- deviceLp.setLat(msg.getString("lat"));
|
|
|
- deviceLp.setUpdateTime(LocalDateTime.now());
|
|
|
- //转换后的坐标
|
|
|
- String[] gcj = CoordTransformUtil.wgs84toGcj02(deviceLp.getLon(), deviceLp.getLat());
|
|
|
- deviceLp.setLonGcj(gcj[0]);
|
|
|
- deviceLp.setLatGcj(gcj[1]);
|
|
|
- // 逆地理位置解析
|
|
|
- deviceLp.setSite(GaoDeApiUtil.regeo(deviceLp.getLonGcj(), deviceLp.getLatGcj()));
|
|
|
- // 保存位置信息
|
|
|
+ // 保存基本信息
|
|
|
deviceLpService.updateByNum(deviceLp, num);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- throw new ApiRuntimeException("处理设备上传位置定位信息出错");
|
|
|
+ throw new ApiRuntimeException("处理路牌设备上传基本信息出错");
|
|
|
}
|
|
|
}
|
|
|
|