소스 검색

晋掌柜webSocket通信加地址

helixiao 2 년 전
부모
커밋
7481706100

+ 5 - 2
src/main/java/com/ydtech/modules/admin/controller/websocket/WebSocketServer.java

@@ -64,7 +64,8 @@ public class WebSocketServer {
         String userId = jsonObject.getString("userId");
         String longitude = jsonObject.getString("longitude");
         String latitude = jsonObject.getString("latitude");
-        saveLocationData(userId, latitude, longitude);
+        String address = jsonObject.getString("address");
+        saveLocationData(userId, latitude, longitude,address);
         log.info("服务端收到消息:{} ,主体:{}", message, userId);
         session.getAsyncRemote().sendText("服务端已收到信息:" + message);
     }
@@ -84,7 +85,7 @@ public class WebSocketServer {
         this.session.getAsyncRemote().sendText(message);
     }
 
-    public void saveLocationData(String userId, String latitude, String longitude) {
+    public void saveLocationData(String userId, String latitude, String longitude,String address) {
         SysGeographyPositionRecordService sysGeographyPositionRecordService = SpringContextUtils.getBean(SysGeographyPositionRecordService.class);
 
         SysGeographyPositionService sysGeographyPositionService= SpringContextUtils.getBean(SysGeographyPositionService.class);
@@ -98,6 +99,7 @@ public class WebSocketServer {
             sysGeographyPosition.setUserName(sysUser.getName());
             sysGeographyPosition.setLatitude(latitude);
             sysGeographyPosition.setLongitude(longitude);
+            sysGeographyPosition.setAddress(address);
             sysGeographyPosition.setCreateTime(new Date());
             sysGeographyPosition.setCreateBy(sysUser.getName());
             sysGeographyPositionService.save(sysGeographyPosition);
@@ -109,6 +111,7 @@ public class WebSocketServer {
             //存在更新
             sysGeographyPosition1.setLongitude(longitude);
             sysGeographyPosition1.setLatitude(latitude);
+            sysGeographyPosition1.setAddress(address);
             sysGeographyPosition1.setCreateTime(new Date());
             sysGeographyPositionService.updateById(sysGeographyPosition1);
             SysGeographyPositionRecord sysGeographyPositionRecord = BeanUtil.copyProperties(sysGeographyPosition1, SysGeographyPositionRecord.class);

+ 4 - 0
src/main/java/com/ydtech/modules/admin/model/SysGeographyPosition.java

@@ -32,6 +32,10 @@ public class SysGeographyPosition implements Serializable {
      * 纬度
      */
     private String latitude;
+    /**
+     * 地址
+     */
+    private String address;
     /**
      * 创建时间
      */

+ 4 - 0
src/main/java/com/ydtech/modules/admin/model/SysGeographyPositionRecord.java

@@ -37,6 +37,10 @@ public class SysGeographyPositionRecord implements Serializable {
      * 纬度
      */
     private String latitude;
+    /**
+     * 地址
+     */
+    private String address;
     /**
      * 创建时间
      */