java110 %!s(int64=4) %!d(string=hai) anos
pai
achega
4dc5392f34

+ 1 - 1
service-api/src/main/java/com/java110/api/kafka/FrontServiceKafka.java

@@ -53,7 +53,7 @@ public class FrontServiceKafka extends BaseController {
         JSONObject param = null;
         try {
             param = JSONObject.parseObject(record.value().toString());
-            ParkingAreaWebsocket.sendInfo(param.toJSONString(), param.getString("extPaId"));
+            ParkingAreaWebsocket.sendInfo(param.toJSONString(), param.getString("extBoxId"));
         } catch (Exception e) {
             logger.error("发送消息失败", e);
         } finally {

+ 8 - 8
service-api/src/main/java/com/java110/api/websocket/ParkingAreaWebsocket.java

@@ -22,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
  * @Version 1.0
  * add by wuxw 2020/5/25
  **/
-@ServerEndpoint("/ws/parkingArea/{paId}/{clientId}")
+@ServerEndpoint("/ws/parkingArea/{boxId}/{clientId}")
 @Component
 public class ParkingAreaWebsocket {
 
@@ -50,16 +50,16 @@ public class ParkingAreaWebsocket {
      */
     private String clientId = "";
 
-    private String paId = "";
+    private String boxId = "";
 
     /**
      * 连接建立成功调用的方法
      */
     @OnOpen
-    public void onOpen(Session session, @PathParam("clientId") String clientId, @PathParam("paId") String paId) {
+    public void onOpen(Session session, @PathParam("clientId") String clientId, @PathParam("boxId") String boxId) {
         this.session = session;
         this.clientId = clientId;
-        this.paId = paId;
+        this.boxId = boxId;
         if (webSocketMap.containsKey(clientId)) {
             webSocketMap.remove(clientId);
             webSocketMap.put(clientId, this);
@@ -101,7 +101,7 @@ public class ParkingAreaWebsocket {
      */
     @OnMessage
     public void onMessage(String message, Session session) throws Exception {
-        logger.info("用户消息:" + paId + ",客户端:" + clientId + ",报文:" + message);
+        logger.info("用户消息:" + boxId + ",客户端:" + clientId + ",报文:" + message);
         //可以群发消息
         //消息保存到数据库、redis
         if (StringUtil.isEmpty(message)) {
@@ -146,10 +146,10 @@ public class ParkingAreaWebsocket {
     /**
      * 发送设备监控信息
      */
-    public static void sendInfo(String message, String paId) throws IOException {
-        logger.info("发送消息到:" + paId + ",报文:" + message);
+    public static void sendInfo(String message, String boxId) throws IOException {
+        logger.info("发送消息到:" + boxId + ",报文:" + message);
         for (ParkingAreaWebsocket server : webSocketMap.values()) {
-            if (paId.equals(server.paId)) {
+            if (boxId.equals(server.boxId)) {
                 webSocketMap.get(server.clientId).sendMessage(message);
             }
         }

+ 26 - 3
service-common/src/main/java/com/java110/common/cmd/machine/GetCarMachineQrCodeUrl.java

@@ -21,17 +21,21 @@ import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.AbstractServiceCmdListener;
 import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.parkingBoxArea.ParkingBoxAreaDto;
 import com.java110.dto.smallWeChat.SmallWeChatDto;
+import com.java110.intf.community.IParkingBoxAreaV1InnerServiceSMO;
 import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -56,11 +60,12 @@ public class GetCarMachineQrCodeUrl extends AbstractServiceCmdListener {
 
     @Autowired
     private ISmallWeChatInnerServiceSMO smallWeChatInnerServiceSMOImpl;
-
+    @Autowired
+    private IParkingBoxAreaV1InnerServiceSMO parkingBoxAreaV1InnerServiceSMOImpl;
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含小区信息");
-        Assert.hasKeyAndValue(reqJson, "paId", "请求报文中未包含停车场");
+        Assert.hasKeyAndValue(reqJson, "boxId", "请求报文中未包含岗亭");
 
     }
 
@@ -72,11 +77,29 @@ public class GetCarMachineQrCodeUrl extends AbstractServiceCmdListener {
         smallWeChatDto.setWeChatType(SmallWeChatDto.WECHAT_TYPE_PUBLIC);
         List<SmallWeChatDto> smallWeChatDtos = smallWeChatInnerServiceSMOImpl.querySmallWeChats(smallWeChatDto);
         String ownerUrl = MappingCache.getValue("OWNER_WECHAT_URL");
-        ownerUrl += ("/#/pages/tempParkingFee/tempParkingFee?paId="+reqJson.getString("paId"));
+        ownerUrl += ("/#/pages/tempParkingFee/tempParkingFee?paId="+ getPaIds(reqJson));
         if(smallWeChatDtos != null && smallWeChatDtos.size()> 0){
             ownerUrl += ("&appId="+smallWeChatDtos.get(0).getAppId());
         }
         reqJson.put("url",ownerUrl);
         cmdDataFlowContext.setResponseEntity(ResultVo.createResponseEntity(reqJson));
     }
+
+    private String getPaIds(JSONObject reqJson) {
+        if (reqJson.containsKey("boxId") && !StringUtil.isEmpty(reqJson.getString("boxId"))) {
+            ParkingBoxAreaDto parkingBoxAreaDto = new ParkingBoxAreaDto();
+            parkingBoxAreaDto.setBoxId(reqJson.getString("boxId"));
+            parkingBoxAreaDto.setCommunityId(reqJson.getString("communityId"));
+            parkingBoxAreaDto.setDefaultArea(ParkingBoxAreaDto.DEFAULT_AREA_TRUE);
+            List<ParkingBoxAreaDto> parkingBoxAreaDtos = parkingBoxAreaV1InnerServiceSMOImpl.queryParkingBoxAreas(parkingBoxAreaDto);
+
+            if (parkingBoxAreaDtos == null || parkingBoxAreaDtos.size() < 1) {
+                throw new CmdException("未查到停车场信息");
+            }
+
+
+            return parkingBoxAreaDtos.get(0).getPaId();
+        }
+        return "";
+    }
 }