空表插入优化
This commit is contained in:
		
							parent
							
								
									6e0c61ca0d
								
							
						
					
					
						commit
						a3a9224791
					
				| @ -96,6 +96,9 @@ export async function initTable() { | ||||
| export function sqlInsertCommonFn(tableName, resultArr, delFlag = true) { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     DB.clearTable(tableName).then((res) => { | ||||
|       if(!resultArr?.length){ | ||||
|         return | ||||
|       } | ||||
|       let INSERT_SQL = "INSERT INTO " + tableName | ||||
|         + " (" + map[tableName].ACCOUNT_TABLE.columns.toString() + ") VALUES " | ||||
| 
 | ||||
|  | ||||
| @ -88,69 +88,7 @@ export async function getTCP(flag=false) { | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
|   return | ||||
|   getSyncData('IpConfigTable').then(async (result: Array<any>) => { | ||||
| 
 | ||||
|     console.log('result222', JSON.stringify(result)) | ||||
|     if (result.length) { | ||||
|       if (globalThis.TcpClient && globalThis.TcpClient.closeTcp) { | ||||
|         globalThis.TcpClient.closeTcp(async () => { | ||||
|           // const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
 | ||||
|           // globalThis.TcpClient = tcpClient
 | ||||
|           setTimeout(async () => { | ||||
|             await globalThis.TcpClient.rebindTcp(result[0].tcplocalIp, result[0].tcplocalIpPort, result[0].tcpOppositeIp, result[0].tcpOppositePort) | ||||
|             await globalThis.TcpClient.connectTcp() | ||||
|             await globalThis.TcpClient.sendMsg('1002') //1002
 | ||||
|             globalThis.TcpClient.onError((val) => { | ||||
|               setTimeout(() => { | ||||
|                 getTCP() | ||||
|               }, 1000) | ||||
|             }) | ||||
|             await globalThis.TcpClient.onMessage((val) => { | ||||
|               setTimeout(() => { | ||||
|                 globalThis.TcpClient.sendMsg('1002') //1002
 | ||||
|                 if (val) { | ||||
|                   // const msg=val.substring(5,val.length-1)
 | ||||
|                   console.log('socketTag[PLC.UdpClient] status:', globalThis.udpClient.getStatus()) | ||||
|                   globalThis.udpClient?.sendMsg(val) | ||||
|                 } | ||||
|               }, 1000) | ||||
| 
 | ||||
|             }) | ||||
|           }, 2000) | ||||
|         }) | ||||
| 
 | ||||
|       } | ||||
|       else { | ||||
|         const tcpClient: TcpClient = new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort, result[0].tcpOppositeIp, result[0].tcpOppositePort) | ||||
|         globalThis.TcpClient = tcpClient | ||||
|         await globalThis.TcpClient.bindTcp() | ||||
|         await globalThis.TcpClient.connectTcp() | ||||
|         await globalThis.TcpClient.sendMsg('1002') //1002
 | ||||
|         globalThis.TcpClient.onError((val) => { | ||||
|           setTimeout(() => { | ||||
|             getTCP() | ||||
|           }, 1000) | ||||
|         }) | ||||
|         await globalThis.TcpClient.onMessage((val) => { | ||||
|           hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val)); | ||||
|           setTimeout(() => { | ||||
|             globalThis.TcpClient.sendMsg('1002') //1002
 | ||||
|             if (val && globalThis.udpClient?.sendMsg) { | ||||
|               globalThis.udpClient?.sendMsg(val) | ||||
|             } | ||||
|           }, 1000) | ||||
| 
 | ||||
|         }) | ||||
|       } | ||||
|       // globalThis.udpClient = new UdpClient(result[0].localIp, result[0].localIpPort,result[0].oppositeIp,result[0].oppositeIpPort)
 | ||||
| 
 | ||||
|     } else { | ||||
|       globalThis.TcpClient = {} | ||||
|       globalThis.TcpClient.onMessage = () => { | ||||
|       } | ||||
|     } | ||||
|   }) | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -192,10 +192,7 @@ export default class TcpClient { | ||||
|             duration: 2000 | ||||
|           }); | ||||
|         } | ||||
|         this.writeLog({ | ||||
|           time:dateFormat(new Date()), | ||||
|           message: `${TAG} tcp信号丢失`, | ||||
|         }) | ||||
| 
 | ||||
|         globalThis.tcpUdpError = true; | ||||
|       },3000) | ||||
|       // callback(value.message)
 | ||||
|  | ||||
| @ -1,15 +1,13 @@ | ||||
| { | ||||
|   "lockfileVersion": 2, | ||||
|   "lockfileVersion": 1, | ||||
|   "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", | ||||
|   "specifiers": { | ||||
|     "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6" | ||||
|   }, | ||||
|   "packages": { | ||||
|     "@ohos/hypium@1.0.6": { | ||||
|       "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", | ||||
|       "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==", | ||||
|       "registryType": "ohpm", | ||||
|       "shasum": "3f5fed65372633233264b3447705b0831dfe7ea1" | ||||
|       "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", | ||||
|       "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" | ||||
|     } | ||||
|   } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user