From 1051ab47ac671486801296ccf0ad7c0ed527d7e6 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期二, 22 四月 2025 15:23:19 +0800
Subject: [PATCH] gx优化播报延时

---
 src/samples/node-api.ts |  125 ++++++++++++++++++++++++++++++++---------
 1 files changed, 98 insertions(+), 27 deletions(-)

diff --git a/src/samples/node-api.ts b/src/samples/node-api.ts
index 0e2db2f..df6d4d2 100644
--- a/src/samples/node-api.ts
+++ b/src/samples/node-api.ts
@@ -2,49 +2,54 @@
 import { cwd } from 'process'
 import { ipcRenderer } from 'electron'
 import {creatorClient} from './sockteStomp'
+import {connect} from './socketClient'
 import {sockteStore} from '@/stores/sockteInfo'
 import { patientInfoStore } from '@/stores/patient'
+import { confingInfoStore } from '@/stores/StoresConfing'
 import os from 'os'
 // import internetAvailable  from "internet-available"
 var internetAvailable = require("internet-available")
-import { ElMessage, ElMessageBox } from 'element-plus'
+import { ElMessage, ElMessageBox, ElNotification } from 'element-plus'
 import { on } from 'events'
 
+interface ResultInfo{
+  clientCode:string;
+  commCode :string;
+  deviceType:string;
+  deviceName :string;
+  result :string;
+  resultTime :string
+}
 let deviceList=[]
 let clientCode=''
 // 主进程发送消息到渲染进程
+ipcRenderer.on('message-koa', (_event, ...args) => {
+  // console.log('koa返回http请求消息', ...args)
+  const Result:ResultInfo=args[0]
+  writeResult(Result)
+})
+ipcRenderer.on('main-process-message', (_event, ...args) => {
+  console.log('[Receive Main-process message]:', ...args)
+})
 ipcRenderer.on('main-process-message', (_event, ...args) => {
   console.log('[Receive Main-process message]:', ...args)
 })
 // 主进程获取配置项完成sockte注册和httpshu
 ipcRenderer.on('getConfigData',(_event,...args)=>{
+  console.log('----------------')
   console.log("config.json",...args)
-  if(args[0]===undefined){
-    // alert("配置文件没有写入配置,请检查配置文件 文件路径:"+args[2])
-    ElMessageBox.prompt('没有设定客户编号,请输入客户编号并保存', '警告', {
-      confirmButtonText: '保存',
-      showClose:false,
-      showCancelButton:false,
-      inputErrorMessage: 'Invalid Email',
-    })
-      .then(({ value }) => {
-        const mode={
-          clientCode:value,
-          machineName:os.hostname(),
-          screenTimeout: 300,
-          devices:[]
-        }
-        ipcRenderer.send('setConfingData',mode)
-      }) 
-    
+  if(args!==null){
+    if(args[0]===undefined){  
+      console.log('配置文件没有配置')
+    }
+    else if(args.length>0&&args[0].clientCode.length>0){
+      console.log('配置文件读取')
+      clientCode=args[0].clientCode
+      // 存放conging到仓库
+      confingInfoStore().setconfingInfo(args[0])
+    }
   }
-  else if(args.length>0&&args[0].length>0){
-    clientCode=args[0]
-    deviceList=args[1]
-    // 建立sockte 通讯
-    creatorClient(deviceList,clientCode)
-
-  }
+  
 })
 ipcRenderer.on("getScreenTimeout",(_event,args)=>{
   if(args!==undefined){
@@ -65,7 +70,73 @@
     sockteStore().setnetLink(true)
   }).catch(()=>{
     sockteStore().setnetLink(false)
+    ElNotification({
+      title: 'Success',
+      message: '网络连接成功',
+      type: 'success',
+    })
     console.log("网路链接失败")
+    ElNotification({
+      title: '异常',
+      message: '网络已断开,等待重连',
+      type: 'warning',
+    })
   })
-},10000)
+},5000)
+const writeResult=(res: ResultInfo)=>{
+  // console.log(`收到设备回传结果:类型=${res.deviceType},结果=${res.result}`)
+  ipcRenderer.invoke('logger', `收到设备回传结果:类型=${res.deviceType},结果=${res.result}`)
+  switch(res.deviceType){
+      case '读卡器':
+          console.log('读卡器收到消息')
+          if(res.clientCode!==null){
+              sockteStore().setdkqSockte(
+                  {
+                      deviceName:res.deviceName,
+                      type:"读卡器",
+                      result:res.result,
+                      resultTime:res.resultTime,
+                      state:2
+                  }
+              )
+          }
+          break
+      case "体重秤":
+          sockteStore().setweightSockte(
+              {
+                  deviceName:res.deviceName,
+                  type:"体重秤",
+                  result:Number(res.result).toString(),
+                  resultTime:res.resultTime,
+                  state:2
+              }
+          )
+          break
+      case "血压计":
+          sockteStore().setxyjSockte(
+              {
+                  deviceName:res.deviceName,
+                  type:"血压计",
+                  result:res.result,
+                  resultTime:res.resultTime,
+                  state:2
+              }
+          )
+          break
+      case "人脸识别":
+        sockteStore().setfaceSockte(
+          {
+            deviceName:res.deviceName,
+            type:"人脸识别",
+            result:res.result,
+            resultTime:res.resultTime,
+            state:2
+          }
+        )
+        break
+
+      default:
+          console.log('有配置类型没有匹配')
+  }
+}
 

--
Gitblit v1.8.0