Commit e57b6b6f4609b36743f8c6a68872bf47282ebe3c

Authored by Min
1 parent f7edf172

1.app心跳包 定时去检查当前WebSocket连接状态,如果是打开状态,则先发送消息;如果websoket关闭了,则重新建立连接

src/components/Common/CommonListEvent.js
@@ -1750,6 +1750,9 @@ export default (ChildComponent) => { @@ -1750,6 +1750,9 @@ export default (ChildComponent) => {
1750 const iConfigIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === sNotRepeatColumn); 1750 const iConfigIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === sNotRepeatColumn);
1751 const sNotRepeatShowName = iConfigIndex > -1 ? slaveConfig.gdsconfigformslave[iConfigIndex].showName : ''; 1751 const sNotRepeatShowName = iConfigIndex > -1 ? slaveConfig.gdsconfigformslave[iConfigIndex].showName : '';
1752 message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseSame') + sNotRepeatShowName); // 请选择相同 1752 message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseSame') + sNotRepeatShowName); // 请选择相同
  1753 + this.props.onSaveState({
  1754 + loading: false,
  1755 + });
1753 return; 1756 return;
1754 } 1757 }
1755 } 1758 }
@@ -1780,33 +1783,33 @@ export default (ChildComponent) => { @@ -1780,33 +1783,33 @@ export default (ChildComponent) => {
1780 this.props.app.webSocket.onmessageTmp = (msg) => { 1783 this.props.app.webSocket.onmessageTmp = (msg) => {
1781 const rtmsg = JSON.parse(msg.data); 1784 const rtmsg = JSON.parse(msg.data);
1782 if (rtmsg.action === 'execute') { 1785 if (rtmsg.action === 'execute') {
1783 - if (rtmsg.msg === 'continue') {  
1784 - const { formRoute } = this.state;  
1785 - if (commonUtils.isNotEmptyArr(copyToData)) {  
1786 - copyTo.name = name;  
1787 - copyTo.config = copyToConfig;  
1788 - if (name !== 'BtnCopyTo.workOrderToWorkOrder' && !name.includes('BtnCopyTo.tmpInfo') && !name.includes('btncopyto.tmpinfobysql')) {  
1789 - copyTo.masterData = copyToData[0];  
1790 - copyTo.slaveData = copyToData;  
1791 - copyTo.copyOtherData = addcopyOther;  
1792 - copyTo.srcFormRoute = this.props.formRoute; /* 未清来源路由 */  
1793 - }  
1794 - copyTo.copyToDataSid = sId?.split(',');  
1795 - dispatch({  
1796 - type: 'content/onRouter',  
1797 - payload: {  
1798 - url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRoute}`, /* 接口地址 */  
1799 - copyTo,  
1800 - refresh: getData.bind(this, slaveConfig, slaveFilterCondition, commonUtils.isEmpty(slavePagination) ? 0 : slavePagination.current, slavePagination.pageSize, slaveOrderBy, isRefresh, undefined, undefined, treeFilterCondition),  
1801 - sSrcModelsId: this.props.sModelsId,  
1802 - },  
1803 - });  
1804 - } else {  
1805 - message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择数据 1786 + if (rtmsg.msg !== 'continue') {
  1787 + message.warning(rtmsg.handlers + commonFunc.showMessage(app.commonConst, 'InOperation'));/* 在操作,请稍后再操作! */
  1788 + }
  1789 + const { formRoute } = this.state;
  1790 + if (commonUtils.isNotEmptyArr(copyToData)) {
  1791 + copyTo.name = name;
  1792 + copyTo.config = copyToConfig;
  1793 + if (name !== 'BtnCopyTo.workOrderToWorkOrder' && !name.includes('BtnCopyTo.tmpInfo') && !name.includes('btncopyto.tmpinfobysql')) {
  1794 + copyTo.masterData = copyToData[0];
  1795 + copyTo.slaveData = copyToData;
  1796 + copyTo.copyOtherData = addcopyOther;
  1797 + copyTo.srcFormRoute = this.props.formRoute; /* 未清来源路由 */
1806 } 1798 }
  1799 + copyTo.copyToDataSid = sId?.split(',');
  1800 + dispatch({
  1801 + type: 'content/onRouter',
  1802 + payload: {
  1803 + url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRoute}`, /* 接口地址 */
  1804 + copyTo,
  1805 + refresh: getData.bind(this, slaveConfig, slaveFilterCondition, commonUtils.isEmpty(slavePagination) ? 0 : slavePagination.current, slavePagination.pageSize, slaveOrderBy, isRefresh, undefined, undefined, treeFilterCondition),
  1806 + sSrcModelsId: this.props.sModelsId,
  1807 + },
  1808 + });
1807 } else { 1809 } else {
1808 - message.warning(rtmsg.handlers + commonFunc.showMessage(app.commonConst, 'InOperation'));/* 在操作,请稍后再操作! */ 1810 + message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择数据
1809 } 1811 }
  1812 +
1810 } 1813 }
1811 }; 1814 };
1812 let sId = sIdArray.toString(); 1815 let sId = sIdArray.toString();
@@ -1815,21 +1818,46 @@ export default (ChildComponent) => { @@ -1815,21 +1818,46 @@ export default (ChildComponent) => {
1815 const values = { sSlaveId: sId }; 1818 const values = { sSlaveId: sId };
1816 const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data; 1819 const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
1817 if (dataReturn.code === 1) { 1820 if (dataReturn.code === 1) {
1818 - const sendSocketMessage = this.props.handleSendSocketMessage;  
1819 - if (sIdArray?.length > 10) {  
1820 - sId = sIdArray?.[0];  
1821 - }  
1822 - if (dataReturn.dataset.rows.length > 0) {  
1823 - confirm({  
1824 - title: commonFunc.showMessage(app.commonConst, 'beUsedToNew'), /* 单据已存在,是否填写新单据 */  
1825 - onOk() {  
1826 - sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null);  
1827 - },  
1828 - onCancel() {  
1829 - },  
1830 - }); 1821 + if (commonUtils.isNotEmptyArr(copyToData) && copyToData.length > 0) { /* 复制到数据大于200 就不走websoket */
  1822 + if (commonUtils.isNotEmptyArr(copyToData)) {
  1823 + copyTo.name = name;
  1824 + copyTo.config = copyToConfig;
  1825 + copyTo.srcFormRoute = this.props.formRoute; /* 未清来源路由 */
  1826 + if (name !== 'BtnCopyTo.workOrderToWorkOrder' && !name.includes('BtnCopyTo.tmpInfo') && !name.includes('ByQuo')
  1827 + && !name?.toLowerCase()?.includes('tmpinfobysql')
  1828 + && !name.includes('ByOrder') && !name.includes('ByWork')) {
  1829 + copyTo.masterData = copyToData[0];
  1830 + copyTo.slaveData = copyToData;
  1831 + copyTo.copyOtherData = addcopyOther;
  1832 + }
  1833 + dispatch({
  1834 + type: 'content/onRouter',
  1835 + payload: {
  1836 + url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRoute}`, /* 接口地址 */
  1837 + copyTo,
  1838 + refresh: getData.bind(this, slaveConfig, slaveFilterCondition, commonUtils.isEmpty(slavePagination) ? 0 : slavePagination.current, slavePagination.pageSize, slaveOrderBy, isRefresh, undefined, undefined, treeFilterCondition),
  1839 + },
  1840 + });
  1841 + } else {
  1842 + message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择数据
  1843 + }
1831 } else { 1844 } else {
1832 - sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null); 1845 + const sendSocketMessage = this.props.handleSendSocketMessage;
  1846 + if (sIdArray?.length > 10) {
  1847 + sId = sIdArray?.[0];
  1848 + }
  1849 + if (dataReturn.dataset.rows.length > 0) {
  1850 + confirm({
  1851 + title: commonFunc.showMessage(app.commonConst, 'beUsedToNew'), /* 单据已存在,是否填写新单据 */
  1852 + onOk() {
  1853 + sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null);
  1854 + },
  1855 + onCancel() {
  1856 + },
  1857 + });
  1858 + } else {
  1859 + sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null);
  1860 + }
1833 } 1861 }
1834 } else { 1862 } else {
1835 this.props.getServiceError(dataReturn); 1863 this.props.getServiceError(dataReturn);
src/components/Common/commonKeyUp.js
@@ -41,7 +41,6 @@ export function getKeyUpEvent(name, sFieldName, tableConfig, masterData, tableDa @@ -41,7 +41,6 @@ export function getKeyUpEvent(name, sFieldName, tableConfig, masterData, tableDa
41 const sAssignField = tableConfig.gdsconfigformslave[iConfigIndex].sOnChangeAssignField; 41 const sAssignField = tableConfig.gdsconfigformslave[iConfigIndex].sOnChangeAssignField;
42 const sButtonParam = tableConfig.gdsconfigformslave[iConfigIndex].sButtonParam; /* 设置多级联动 */ 42 const sButtonParam = tableConfig.gdsconfigformslave[iConfigIndex].sButtonParam; /* 设置多级联动 */
43 43
44 - console.log('sAssignField:', sAssignField);  
45 44
46 // 根据赋值字段类型分发处理逻辑 45 // 根据赋值字段类型分发处理逻辑
47 /* keyUp联动其他表 */ 46 /* keyUp联动其他表 */
@@ -500,7 +499,7 @@ function formatTableData(originObj) { @@ -500,7 +499,7 @@ function formatTableData(originObj) {
500 if (originObj == null || typeof originObj !== 'object') { 499 if (originObj == null || typeof originObj !== 'object') {
501 return {}; 500 return {};
502 } 501 }
503 - 502 +
504 const newObj = {}; 503 const newObj = {};
505 // 遍历原始对象的键值对 504 // 遍历原始对象的键值对
506 Object.entries(originObj).forEach(([key, value]) => { 505 Object.entries(originObj).forEach(([key, value]) => {
src/components/IndexCenter/IndexCenter.js
@@ -784,7 +784,7 @@ class IndexCenter extends Component { @@ -784,7 +784,7 @@ class IndexCenter extends Component {
784 .replace('{token}', token) 784 .replace('{token}', token)
785 .replace('{ipAddress}', addressStr) 785 .replace('{ipAddress}', addressStr)
786 .replace('{ipPadAddress}', ipPadAddress) : ''; 786 .replace('{ipPadAddress}', ipPadAddress) : '';
787 - console.log('iframeUrl', iframeUrl); 787 +
788 788
789 const ExtraWrap = ( 789 const ExtraWrap = (
790 <div className={styles.extraWrap}> 790 <div className={styles.extraWrap}>
src/models/app.js
@@ -567,6 +567,8 @@ export default { @@ -567,6 +567,8 @@ export default {
567 }, 567 },
568 /** 返回新页签 */ 568 /** 返回新页签 */
569 *createWebSocket({ payload }, { put, select }) { 569 *createWebSocket({ payload }, { put, select }) {
  570 + // console.log("WebSocket 功能已被禁用");
  571 + // return null;
570 const { reStart, dispatch } = payload; 572 const { reStart, dispatch } = payload;
571 const userinfo = yield select(state => state.app.userinfo); 573 const userinfo = yield select(state => state.app.userinfo);
572 let url = `${config.ws_host}websocket/${userinfo.sId}`; 574 let url = `${config.ws_host}websocket/${userinfo.sId}`;
@@ -714,11 +716,11 @@ export default { @@ -714,11 +716,11 @@ export default {
714 } else { 716 } else {
715 dispatch({ type: "app/throwError", payload: { code: -2, msg: rtmsg.msg } }); 717 dispatch({ type: "app/throwError", payload: { code: -2, msg: rtmsg.msg } });
716 } 718 }
717 - } else if (rtmsg.action === "kpimodle") { 719 + } else if (rtmsg.action === "kpi1modle") {
718 // 主页数据 720 // 主页数据
719 const msgData = JSON.parse(msg.data); 721 const msgData = JSON.parse(msg.data);
720 dispatch({ type: "app/saveKpiData", payload: { kpiData: msgData.msg } }); 722 dispatch({ type: "app/saveKpiData", payload: { kpiData: msgData.msg } });
721 - } else if (rtmsg.action === "workMsg") { 723 + } else if (rtmsg.action === "wor2kMsg") {
722 // 工单系统消息 724 // 工单系统消息
723 const msgData = JSON.parse(msg.data); 725 const msgData = JSON.parse(msg.data);
724 dispatch({ type: "app/saveWorkMsg", payload: { workMsg: msgData.msg } }); 726 dispatch({ type: "app/saveWorkMsg", payload: { workMsg: msgData.msg } });
src/routes/indexPage.js
@@ -26,34 +26,34 @@ function IndexPage({ app }) { @@ -26,34 +26,34 @@ function IndexPage({ app }) {
26 }; 26 };
27 }, []); 27 }, []);
28 28
29 - const { webSocket, userinfo } = app;  
30 - const { sId } = userinfo;  
31 - const testMsg = JSON.stringify({ flag: "connectTest", sId: "test", sendFrom: sId });  
32 -  
33 - const timer = useRef(null);  
34 -  
35 - const { url } = webSocket || {};  
36 - const wsRef = useRef(webSocket);  
37 - const xlyWsTimerFun = () => {  
38 - clearInterval(timer.current);  
39 - // 重新启动定时器  
40 - timer.current = setInterval(() => {  
41 - if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {  
42 - wsRef.current.send(testMsg);  
43 - }  
44 - }, 20000);  
45 - }  
46 - useEffect(() => {  
47 - if (url) {  
48 - wsRef.current = webSocket;  
49 - xlyWsTimerFun();  
50 - window.xlyWsTimerFun = xlyWsTimerFun;  
51 - }  
52 - return () => {  
53 - window.xlyWsTimerFun = null;  
54 - clearInterval(timer.current);  
55 - };  
56 - }, [url]); 29 + // const { webSocket, userinfo } = app;
  30 + // const { sId } = userinfo;
  31 + // const testMsg = JSON.stringify({ flag: "connectTest", sId: "test", sendFrom: sId });
  32 + //
  33 + // const timer = useRef(null);
  34 + //
  35 + // const { url } = webSocket || {};
  36 + // const wsRef = useRef(webSocket);
  37 + // const xlyWsTimerFun = () => {
  38 + // clearInterval(timer.current);
  39 + // // 重新启动定时器
  40 + // timer.current = setInterval(() => {
  41 + // if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
  42 + // wsRef.current.send(testMsg);
  43 + // }
  44 + // }, 20000);
  45 + // }
  46 + // useEffect(() => {
  47 + // if (url) {
  48 + // wsRef.current = webSocket;
  49 + // xlyWsTimerFun();
  50 + // window.xlyWsTimerFun = xlyWsTimerFun;
  51 + // }
  52 + // return () => {
  53 + // window.xlyWsTimerFun = null;
  54 + // clearInterval(timer.current);
  55 + // };
  56 + // }, [url]);
57 57
58 // 根据用户语言选择对应的语言包 58 // 根据用户语言选择对应的语言包
59 const getLocale = () => { 59 const getLocale = () => {