From 79033ac6b1a23fe8d5a9cbeefab2474cb1b77bef Mon Sep 17 00:00:00 2001 From: anthonywj Date: Fri, 11 Aug 2023 09:42:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=86=E6=94=AF=E5=A4=87?= =?UTF-8?q?=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/inout/IoCheckInoutService.java | 2 + .../api/service/sync/WebSocketComponent.java | 65 ++++++++++--------- src/main/resources/application-dev.yml | 2 +- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java b/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java index 10fb1a063..079d0d683 100644 --- a/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java +++ b/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java @@ -540,6 +540,8 @@ public class IoCheckInoutService { orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST); orderEntity.setUpdateTime(new Date()); orderService.update(orderEntity); + + //生成缺失码 genLostCode(orderEntity.getBillNo()); checkThird(orderEntity); diff --git a/src/main/java/com/glxp/api/service/sync/WebSocketComponent.java b/src/main/java/com/glxp/api/service/sync/WebSocketComponent.java index 0efc43240..eb809f0c9 100644 --- a/src/main/java/com/glxp/api/service/sync/WebSocketComponent.java +++ b/src/main/java/com/glxp/api/service/sync/WebSocketComponent.java @@ -1,5 +1,6 @@ package com.glxp.api.service.sync; +import cn.hutool.core.thread.ThreadUtil; import com.glxp.api.constant.SocketMsgType; import com.glxp.api.dao.system.SyncDataSetDao; import com.glxp.api.entity.system.SyncDataSetEntity; @@ -30,43 +31,45 @@ public class WebSocketComponent implements CommandLineRunner { @Override public void run(String... args) throws Exception { - - SyncDataSetEntity syncDataSetEntity = syncDataSetDao.selectSet(); - String ip = syncDataSetEntity.getSyncIp(); - ip = ip.replace("http://", ""); + ThreadUtil.execAsync(() -> { + SyncDataSetEntity syncDataSetEntity = syncDataSetDao.selectSet(); + String ip = syncDataSetEntity.getSyncIp(); + ip = ip.replace("http://", ""); // ip = ip.replace("/SP_SYNC_SERVER", ""); - try { - SpsWebSocketClient client = new SpsWebSocketClient("ws://" + ip + "/sps/web/sync/2/" + socketToken); - client.setSocketMsgService(socketMsgService); - initConnect(client); - //等待服务端响应 - while (!client.getReadyState().equals(ReadyState.OPEN)) { - log.info("连接中···请稍后"); - Thread.sleep(1000); - } - //等待WebSocket服务端响应 - String message = null; - while (true) { - while ((message = client.getExcptMessage()) == null) { - log.info("已连接,等待接收数据--------"); + try { + SpsWebSocketClient client = new SpsWebSocketClient("ws://" + ip + "/sps/web/sync/2/" + socketToken); + client.setSocketMsgService(socketMsgService); + initConnect(client); + //等待服务端响应 + while (!client.getReadyState().equals(ReadyState.OPEN)) { + log.info("连接中···请稍后"); Thread.sleep(1000); - if (client.isClosed()) { - initConnect(client); - } } - if (message.equals(SocketMsgType.DL_ALL_DATA)) { - heartTaskService.pullData(); + //等待WebSocket服务端响应 + String message = null; + while (true) { + while ((message = client.getExcptMessage()) == null) { + log.info("已连接,等待接收数据--------"); + Thread.sleep(1000); + if (client.isClosed()) { + initConnect(client); + } + } + if (message.equals(SocketMsgType.DL_ALL_DATA)) { + heartTaskService.pullData(); + } + //打印服务端返回的数据 + log.info("成功获取数据:" + message); } - //打印服务端返回的数据 - log.info("成功获取数据:" + message); - } - } catch (URISyntaxException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } + } catch (URISyntaxException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); + } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index eb5bb58de..d6d7df54e 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -4,7 +4,7 @@ server: spring: datasource: driver-class-name: com.p6spy.engine.spy.P6SpyDriver - jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_pzh?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_pt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true username: root password: 123456 hikari: