Commit 440782b89aa143381d766beebed003831d4efd05
Merge branch 'release/customer/2025/五彩' of http://git.xlyprint.cn/qiangmj/ebc-Me…
…s into release/customer/2025/五彩
Showing
2 changed files
with
41 additions
and
5 deletions
src/mes/common/commonOperationBarComponent/index.js
| @@ -1138,7 +1138,7 @@ const CommonOperationBarComponent = basProps => { | @@ -1138,7 +1138,7 @@ const CommonOperationBarComponent = basProps => { | ||
| 1138 | searchProductProps.componentStyle = { width: 230 }; | 1138 | searchProductProps.componentStyle = { width: 230 }; |
| 1139 | } | 1139 | } |
| 1140 | } | 1140 | } |
| 1141 | -console.log(searchProductProps, 'searchProductProps'); | 1141 | + |
| 1142 | 1142 | ||
| 1143 | const handleBtnSearch = () => { | 1143 | const handleBtnSearch = () => { |
| 1144 | const { sModelsId } = props; | 1144 | const { sModelsId } = props; |
src/models/app.js
| @@ -582,12 +582,12 @@ export default { | @@ -582,12 +582,12 @@ export default { | ||
| 582 | if (userinfo.sUserLoginType) { | 582 | if (userinfo.sUserLoginType) { |
| 583 | url = `${config.ws_host}websocket/${userinfo.sId}?sLoginType=${userinfo.sUserLoginType}`; | 583 | url = `${config.ws_host}websocket/${userinfo.sId}?sLoginType=${userinfo.sUserLoginType}`; |
| 584 | } | 584 | } |
| 585 | - if (reStart || true) { | 585 | + if (true) { |
| 586 | // const webSocket = yield select(state => state.app.webSocket); | 586 | // const webSocket = yield select(state => state.app.webSocket); |
| 587 | // if (webSocket === null) { | 587 | // if (webSocket === null) { |
| 588 | // return null; | 588 | // return null; |
| 589 | // } | 589 | // } |
| 590 | - url = `${config.ws_host}websocket/${userinfo.sId}?reStart=true`; | 590 | + url = `${config.ws_host}websocket/${userinfo.sId}?reStart=true&createTime=${new Date().getTime()}`; |
| 591 | if (userinfo.sUserLoginType) { | 591 | if (userinfo.sUserLoginType) { |
| 592 | url = `${config.ws_host}websocket/${userinfo.sId}?reStart=true&createTime=${new Date().getTime()}&sLoginType=${userinfo.sUserLoginType}`; | 592 | url = `${config.ws_host}websocket/${userinfo.sId}?reStart=true&createTime=${new Date().getTime()}&sLoginType=${userinfo.sUserLoginType}`; |
| 593 | } | 593 | } |
| @@ -598,6 +598,38 @@ export default { | @@ -598,6 +598,38 @@ export default { | ||
| 598 | start(ws, config1); | 598 | start(ws, config1); |
| 599 | }; | 599 | }; |
| 600 | const start = (ws, config1) => { | 600 | const start = (ws, config1) => { |
| 601 | + if (!ws.originalSend) { | ||
| 602 | + ws.originalSend = ws.send.bind(ws); | ||
| 603 | + } | ||
| 604 | + ws.send = (...args) => { | ||
| 605 | + const value = utils.convertStrToObj(args[0], {}); | ||
| 606 | + const { | ||
| 607 | + key, | ||
| 608 | + flag, | ||
| 609 | + sendFrom, | ||
| 610 | + sId, | ||
| 611 | + } = value; | ||
| 612 | + if ((key && flag && !['release', 'noAction'].includes(flag) && sendFrom && sId) || flag === 'connectTest') { | ||
| 613 | + // 3s内没返回消息,则重新创建ws,重新发送 | ||
| 614 | + clearTimeout(window.wsTimer); | ||
| 615 | + window.wsTimer = setTimeout(() => { | ||
| 616 | + console.log('================超时未收到WebSocket消息,重新创建ws并发送信息======================'); | ||
| 617 | + window.wsHistoryArgs = args; | ||
| 618 | + ws.onmessageTmp && (window.onmessageTmp = ws.onmessageTmp); | ||
| 619 | + dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } }); | ||
| 620 | + }, 3000); | ||
| 621 | + } | ||
| 622 | + ws.originalSend.apply(ws, args); | ||
| 623 | + }; | ||
| 624 | + | ||
| 625 | + if (window.wsHistoryArgs) { | ||
| 626 | + ws.send(...window.wsHistoryArgs); | ||
| 627 | + window.wsHistoryArgs = undefined; | ||
| 628 | + } | ||
| 629 | + if (window.onmessageTmp) { | ||
| 630 | + ws.onmessageTmp = window.onmessageTmp; | ||
| 631 | + window.onmessageTmp = undefined; | ||
| 632 | + } | ||
| 601 | config1.timerServer = setTimeout(() => { | 633 | config1.timerServer = setTimeout(() => { |
| 602 | const message = { sendFrom: userinfo.sId, connectTest: 'test' }; // param 存放其它参数 keyName 需要放入Redis的数据key,keyValue 需要放入Redis的数据key 的值 | 634 | const message = { sendFrom: userinfo.sId, connectTest: 'test' }; // param 存放其它参数 keyName 需要放入Redis的数据key,keyValue 需要放入Redis的数据key 的值 |
| 603 | ws.send(JSON.stringify(message)); | 635 | ws.send(JSON.stringify(message)); |
| @@ -618,8 +650,7 @@ export default { | @@ -618,8 +650,7 @@ export default { | ||
| 618 | } | 650 | } |
| 619 | }; | 651 | }; |
| 620 | // 全局通用的自定义onmessage的方法 | 652 | // 全局通用的自定义onmessage的方法 |
| 621 | - ws.homeAction = (msg) => { | ||
| 622 | - clearTimeout(window.wsTimer); | 653 | + ws.homeAction = msg => { |
| 623 | const rtmsg = JSON.parse(msg.data); | 654 | const rtmsg = JSON.parse(msg.data); |
| 624 | if (false && rtmsg.action === 'showImg' && location.pathname.indexOf('/indexOee') < 0) { | 655 | if (false && rtmsg.action === 'showImg' && location.pathname.indexOf('/indexOee') < 0) { |
| 625 | const msgData = JSON.parse(msg.data); | 656 | const msgData = JSON.parse(msg.data); |
| @@ -688,10 +719,15 @@ export default { | @@ -688,10 +719,15 @@ export default { | ||
| 688 | } else if (rtmsg.action === 'showErroMsg') { | 719 | } else if (rtmsg.action === 'showErroMsg') { |
| 689 | console.log('=====msgData', msgData); | 720 | console.log('=====msgData', msgData); |
| 690 | message.error(msgData.msg); | 721 | message.error(msgData.msg); |
| 722 | + } else if (window.tempWsAction) { | ||
| 723 | + window.tempWsAction(msg); | ||
| 691 | } | 724 | } |
| 692 | }; | 725 | }; |
| 693 | ws.onmessage = (msg) => { | 726 | ws.onmessage = (msg) => { |
| 727 | + clearTimeout(window.wsTimer); | ||
| 728 | + window.xlyWsTimerFun && window.xlyWsTimerFun(); | ||
| 694 | reset(ws, config); | 729 | reset(ws, config); |
| 730 | + ws.onmessageTmp?.(msg); | ||
| 695 | ws.homeAction(msg); | 731 | ws.homeAction(msg); |
| 696 | }; | 732 | }; |
| 697 | ws.onclose = (e) => { | 733 | ws.onclose = (e) => { |