From e9ef9bfe411bda655f6231f3213cb09039b9dbb7 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期一, 27 十一月 2023 09:22:21 +0800
Subject: [PATCH] 更新识别逻辑 定时

---
 src/views/home/index.vue |  257 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 163 insertions(+), 94 deletions(-)

diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 889188e..d35609a 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -18,25 +18,39 @@
                     </div>
                 </div>
                 <div style="width: 100%; height: 20%;" >
-                    <div style="font-size: 2rem; color: #FFFFFF;margin-left: 1rem;" >
+                    <div style="font-size: 2rem; color: #FFFFFF;margin-left: 0.5rem;" >
                       {{timeShidaun}}
                     </div>
                 </div>
-                <div style="width: 100%; height: 25%;padding-top: 0.5rem;" >
-                    <div style="font-size: 2.5rem; color: #FFFFFF;margin-left: 1rem;">{{ patientInfo.name }}</div>
+                <div style="width: 100%; height: 30%;" >
+                    <div style="font-size: 2.5rem; color: #FFFFFF;margin-left: 0.5rem;">{{ patientInfo.name }}</div>
                 </div>
-                <div style="width: 100%; height: 25%; padding-top: 1rem;">
-                    <div style="font-size: 1.5rem;  color: #FFFFFF;margin-left: 1rem;">透析号:{{ patientInfo.hemoCode }}</div>
+                <div style="width: 100%; height: 20%;">
+                    <div style="font-size: 1.5rem;  color: #FFFFFF;margin-left: 0.5rem;">透析号:{{ patientInfo.hemoCode }}</div>
                 </div>
+                <div v-if="is_ce_wen" style="width: 100%; height: 20%;">
+                    <div style="font-size: 1.5rem;  color: #FFFFFF;margin-left: 0.5rem;">
+                      体温:<span v-if="dangqian_wendu>30">{{dangqian_wendu}}°C</span>
+                      <span v-else>      /</span>
+                    </div>
+                </div> 
               </el-col>
             </el-row> 
             <el-row style="height: 30%;background: rgba(243, 247, 243, 0.3);border-radius: 8px; margin-top: 5%; font-size: 2rem;">
       
               <div style="height: 25%; line-height: 100%; width: 100%;color: #FFFFFF; "   >
-                <div  style="width: 200px; font-size: 2rem; text-align: center; height: 63px; line-height: 63px;background: #2CAAFD;border-radius: 0px 8px 0px 50px;float:right">签到时间</div>
+                <div v-if="patientInfo.isAfterMed===0"   style="width: 200px; font-size: 2rem; text-align: center; height: 63px; line-height: 63px;background: #2CAAFD;border-radius: 0px 8px 0px 50px;float:right">
+                  签到时间
+                </div>
+                <div v-if="patientInfo.isAfterMed===1"   style="width: 200px; font-size: 2rem; text-align: center; height: 63px; line-height: 63px;background: #2CAAFD;border-radius: 0px 8px 0px 50px;float:right">
+                  下次透析时间
+                </div>
               </div>
-              <div style="height: 75%; line-height: 100%; width: 100%;color: #FFFFFF; padding-top: 35px; padding-left: 20px; ">
+              <div v-if="patientInfo.isAfterMed===0" style="height: 75%; line-height: 100%; width: 100%;color: #FFFFFF; padding-top: 35px; padding-left: 20px; ">
                   <div >{{date}}</div>
+              </div>
+              <div v-else style="height: 75%; line-height: 100%; width: 100%;color: #FFFFFF; padding-top: 35px; padding-left: 20px; ">
+                  <div v-if="patientInfo.nextRecordDate!==''&&patientInfo.nextRecordDate!==null">{{patientInfo.nextRecordDate.substring(0,11)}}</div>
               </div>
             </el-row>
           </el-col>
@@ -106,14 +120,16 @@
             <div style="height: 48%; margin-top: 4%;">
               <div style="height: 25%;">
                 <div class="textjuzhong" style="background: #65AAF6; font-size: 2rem; color: #FFFFFF;">
-                  <template v-if="configData.deviceType==='体重秤'">目标脱水量(L)</template>
+                  <template v-if="configData.deviceType==='体重秤'&&patientInfo.isAfterMed===0">目标脱水量(L)</template>
+                  <template v-if="configData.deviceType==='体重秤'&&patientInfo.isAfterMed===1">实际超滤量(L)</template>
                   <template v-if="configData.deviceType==='血压计'">透前脉搏(次/分)</template>
                   
                 </div>
               </div>
               <div style="height: 75%;">
                 <div class="textjuzhong" style="background: rgba(243, 247, 243, 0.3); font-size: 6rem; font-weight: 800; color: #65AAF6;">
-                  <template v-if="configData.deviceType==='体重秤'">{{aimTSL}}</template>
+                  <template v-if="configData.deviceType==='体重秤'&&patientInfo.isAfterMed===0">{{aimTSL}}</template>
+                  <template v-if="configData.deviceType==='体重秤'&&patientInfo.isAfterMed===1">{{patientInfo.actuallyClliang}}</template>
                   <template v-if="configData.deviceType==='血压计'">{{mai_bu}}</template>
                 </div>
               </div>
@@ -140,11 +156,12 @@
                 </div>
               </div>
               <div style="height: 75%;">
-                <div style="background: rgba(243, 247, 243, 0.3); height: 100%; width: 100%; font-size: 1.3rem; font-weight: 800; color: #FFFFFF;">
-                  <div class="textjuzhong" style="height: 25%;  width: 100%;">干体重  {{patientInfo.pureWeight}}  kg</div>
-                  <div class="textjuzhong" style="height: 25%;  width: 100%;">透析器  {{patientInfo.txq}}</div>
-                  <div class="textjuzhong" style="height: 25%;  width: 100%;">治疗模式  {{patientInfo.medMethod}}</div>
-                  <div class="textjuzhong" style="height: 25%;  width: 100%;">灌流器  {{patientInfo.glq}}</div>
+                <div style="background: rgba(243, 247, 243, 0.3); height: 100%; width: 100%; font-size: 2.5rem; line-height: 4.5rem; font-weight: 800; color: #FFFFFF; text-align: center;padding-top: 1rem;">
+                  <span style="font-size: 4rem; color:#DFB144 ; " >干体重  {{patientInfo.pureWeight}}kg</span>
+                  <br>
+                  <span > 透析器:{{patientInfo.txq}}</span>
+                  <span > 治疗模式:{{patientInfo.medMethod}}</span>
+                  <span > 灌流器:{{patientInfo.glq}}</span>
                 </div>
               </div>
           </el-col>
@@ -158,13 +175,11 @@
             </el-col>
             <el-col :span="12" >
               <el-row>
-                <el-col :span="23" style="text-align: right; line-height: 67px;padding-right: 0px; font-size: 40px;font-weight: 400;color: #EB6F1C;">
-                  <div>{{clockNum}}S</div>
-                </el-col>
-                <el-col :span="1" style="padding-right: 10px;" class="divinput">
-                  <el-input  v-model="inputCode" ref="inputRef" id="inputCode" style="width: 0px; height: 0px;"  @change="inputChabge"
+                <el-col   :span="24" style="text-align: right; line-height: 67px;padding-right: 0px; font-size: 40px;font-weight: 400;color: #EB6F1C;">
+                  <div v-if="!dialogVisible">{{clockNum}}S</div>
+                  <el-input   v-else  v-model="inputCode" ref="inputRef" id="inputCode"  style="width: 200px; height: 40px;ime-mode:active"  @change="inputChabge"
                     placeholder="请输入患者卡号或扫描条码" />
-                  </el-col>
+                </el-col>
               </el-row>
             </el-col>
           </el-row>
@@ -186,9 +201,9 @@
           </div>
         </div>
     </div>
-    <el-dialog title="提示" v-model="netLink" width="30%">
+    <!-- <el-dialog title="提示" v-model="netLink" width="30%">
       <span>无法链接到网络!</span>
-    </el-dialog>
+    </el-dialog> -->
   </div>
 </template>
 <script setup lang="ts">
@@ -201,16 +216,27 @@
 import Speech from 'speak-tts'
 import { reactive,computed, toRefs, onMounted, watch, ref } from "vue"
 import { sendPationCodeApi } from '../../samples/httpApi'
-import { formatDate } from '@/utils/formatTime'
+import { formatDate,jgTime } from '@/utils/formatTime'
 import { confingInfoStore } from '@/stores/StoresConfing'
 import {base64toFile} from '@/samples/faceApi'
+import{initPort} from '@/samples/portApi'
+import{initPort as oumulongHbp9030 } from '@/samples/deviceApi/oumulong-HBP-9030'
+import{initPort as  TM2655VP} from '@/samples/deviceApi/TM2655VP'
+import{initPort as zhiRongT605 } from '@/samples/deviceApi/zhiRongT605'
+import{initPort as taiHengM523 } from '@/samples/deviceApi/taiHengM523'
+import{initPort as XK3190A12 } from '@/samples/deviceApi/XK3190A12'
+// 读取体重文件
+import{toDataTz,todatatzs } from '@/samples/deviceApi/seca101'
 import { ElLoading, ElMessage } from 'element-plus'
+import { el } from 'element-plus/es/locale'
+import { Console } from 'console'
 let trackerTask: any = null;
+let lsDateTime:any=new Date()
 // 标识用的画布
 const myCanvas = ref<HTMLCanvasElement | null>(null);
 let imgSrc:'';
 const msg = ref<string>("没识别到人脸...");
-// 实例人脸检查器
+// 实例人脸检查器                    ObjectTracker
 const myTracker: any = new tracking.ObjectTracker("face");
 myTracker.setInitialScale(4);
 myTracker.setStepSize(2);
@@ -222,22 +248,29 @@
     context.clearRect(0, 0, myCanvas.value.width, myCanvas.value.height);
   }
   if (event.data.length === 0) {
+    // console.log('没有监测到---')
     msg.value = "没识别到人脸...";
-  } else if(event.data.length === 1) {
+  } else if(event.data.length >= 1){
     trackerTask.stop();
     msg.value = "检测到人脸";
+    console.log('监测到人脸2样')
+    console.log(event.data)
     const myCanvas = document.getElementById("myCanvas");// 
     const thisContext = myCanvas?.getContext("2d");
     const myVideo = document.querySelector("#myVideo") as HTMLVideoElement;
     thisContext.drawImage(myVideo, 0,0, 250, 200);
     imgSrc = myCanvas?.toDataURL('image/png');
+    const X= jgTime(lsDateTime,new Date())
+    
     // 转文件
     // 识别框显示才能到传阿里云识别
-    if(dialogVisible.value){
+    if(dialogVisible.value&&X>configData.value.face_push){
+      lsDateTime=new Date()
+      console.log(X,'上传阿里识别间隔')
       base64toFile(imgSrc)
     }
     setTimeout(() => {
-      console.log(configData.value.face_push+'秒跑一次人脸识别')
+      // console.log(configData.value.face_push+'秒跑一次人脸识别')
       trackerTask.run();
     }, configData.value.face_push*1000);
     // @ts-ignore
@@ -260,6 +293,8 @@
 let patientCodeLs = ''
 // 临时血压
 let patientCodeLsXy = ''
+// 测温是否开启
+const is_ce_wen=ref()
 const isUseFaceRecogService = ref(false)
 const fasongNum=ref(0)
 const caozuo=ref(0)// 点击10下才能关闭
@@ -294,8 +329,16 @@
     ipcRenderer.invoke('logger', '网络已经断开')
   }else{
     ipcRenderer.invoke('logger', '网络已经恢复')
+   
   }
   return !sockte.netLink
+})
+watch(netLink,()=>{
+  if(!netLink.value){
+    ElMessage.success('网络已经连接')
+  }else{
+    ElMessage.warning('网络已断开,等待重连')
+  }
 })
 
 // 体重
@@ -318,61 +361,15 @@
 const patientInfo = computed(() => {
   return patientInfoStore().patientInfo
 })
+const dangqian_wendu=computed(()=>{
+  return sockte.wendu
+})
 // 计数
 const viewNumber = computed(() => {
   return patientInfoStore().viewNumber
 })
 const settime = () => {
-  // 计数倒计时
   clockNum.value = patientInfoStore().viewNumber
-  // 清除定时器
-  clearInterval(timerNum.value)
-  timer = setInterval(() => {
-    if (clockNum.value > 0) {
-      clockNum.value--
-    }
-    else {
-      clearInterval(timer)
-      clockNum.value = patientInfoStore().viewNumber
-      patientInfoStore().setpatientInfo({
-        id: 0,
-        code: '',
-        name: '',
-        patientAvatarIcon: '',
-        deviceCode: '',
-        hemoCode: '',
-        pureWeight: '',
-        datetime: ''
-      })
-      sockteStore().setweightSockte({
-        type: '体重秤',
-        deviceName: '',
-        result: '0',
-        resultTime: '',
-        state: 2
-      })
-      sockteStore().setxyjSockte({
-        type: '血压计',
-        deviceName: '',
-        result: '',
-        resultTime: '',
-        state: 2
-      })
-      sockteStore().setfaceSockte({
-        type: '人脸识别',
-        deviceName: '',
-        result: '',
-        resultTime: '',
-        state: 2
-      })
-      aimTSL.value = ''
-      gao_ya.value = ''
-      di_ya.value = ''
-      mai_bu.value = ''
-    }
-  }, 1000)
-  // 记录定时器
-  timerNum.value = timer
 }
 //发送消除某些状态
 const fuxuan=()=>{
@@ -436,14 +433,17 @@
     patientCodeLsXy = ''
     aimTSL.value = ''
       // 定时数秒器
-    settime()
+   
     if (patientInfo.value.id !== 0 && patientInfo.value.name !== '' && patientInfo.value.isScheduled === 1) {
+      settime()
+      // 人脸识别成功后 1查看是否开启测温
       // console.log(`患者信息识别成功:${patientInfo.value.name}`)
       ipcRenderer.invoke('logger', `患者信息识别成功:${patientInfo.value.name}`)
       let str = `${patientInfo.value.name}识别成功。床号:${patientInfo.value.deviceNo}`
       dialogVisible.value = false
       speech.value?.speak({ text: str }).then(() => {
       })
+
       sockteStore().setweightSockte({
         type: "体重秤",
         state: 2,
@@ -458,6 +458,9 @@
         result: "",
         resultTime: ""
       })
+     
+     
+      
 
     }
     // 没有找到患者
@@ -471,6 +474,7 @@
     }
     // 没有排班
     else if (patientInfo.value.isScheduled === 0) {
+      settime()
       ipcRenderer.invoke('logger', `患者没有排班:${patientInfo.value.name}`)
       // console.log( `患者没有排班:${patientInfo.value.name}`)
       //关闭人脸弹框
@@ -511,13 +515,14 @@
           bloodPressure: ''
         }
         if (patientCodeLs !== mode.patientCode) {
+          settime()
+          // 定时数秒器
           const tt = mode.weight.replace('.', '点')
-          speech.value?.speak({ text: `称重完成,${tt}kg` }).then(() => {
+          speech.value?.speak({ text: `称重完成,${tt}千克` }).then(() => {
             console.log("播报完成...")
           })
           patientCodeLs = mode.patientCode
           fasongNum.value=0
-          // console.log(`开始发送结果到服务器:患者:${patientInfo.value.name},体重结果:${weightInfo.value.result}`)
           ipcRenderer.invoke('logger', `开始发送结果到服务器:患者:${patientInfo.value.name},体重结果:${weightInfo.value.result}`)
           console.log(`开始发送结果到服务器:患者:${patientInfo.value.name},体重结果:${weightInfo.value.result}`)
           sundModeTz()
@@ -532,7 +537,11 @@
         }else if(Number(patientInfo.value.pureWeight) !== 0&&patientInfo.value.isAfterMed===1 && patientInfo.value.preWeight>10){
           aimTSL.value = (Number(patientInfo.value.preWeight)- Number(patientInfo.value.pureWeight) - Number(patientInfo.value.clothesWeight)).toFixed(2)
         }
-      }
+    }else if(patientInfo.value.code===''&&weightInfo.value.result !== "0"){
+      speech.value?.speak({ text: "没有识别的患者,请先验证患者" }).then(() => {
+        // console.log("播报完成...")
+      })
+    }
   }
 );
 // 血压发送了变化
@@ -566,6 +575,8 @@
         fasongNum.value=0
         // console.log(`开始发送结果到服务器:患者:${patientInfo.value.name},血压结果:${mode.bloodPressure}`)
         ipcRenderer.invoke('logger', `开始发送结果到服务器:患者:${patientInfo.value.name},血压结果:${mode.bloodPressure}`)
+        // 定时数秒器
+        settime()
         sundModeXyj()
       }
     } else {
@@ -581,15 +592,16 @@
     weight: weightInfo.value.result,
     bloodPressure: ''
   }
+  if(dangqian_wendu.value>30){
+    mode.temperature=dangqian_wendu.value
+  }
   fasongNum.value++
   ipcRenderer.invoke('logger', `患者结果上传,第${fasongNum.value}次`)
   ipcRenderer.invoke('logger', '参数:'+JSON.stringify(mode))
   updatePatient(mode).then(re=>{
     ElMessage.success('结果发送成功')
     ipcRenderer.invoke('logger', '结果上传成功')
-    setTimeout(() => {
-      fuxuan()
-    },configData.value.timeJg)
+    clockNum.value = Number(configData.value.timeJg/1000)
     return false
   }).catch(re=>{
     ElMessage('结果发送失败')
@@ -610,15 +622,17 @@
     weight: '',
     bloodPressure: xyjInfo.value.result
   }
+  if(dangqian_wendu.value>30){
+    mode.temperature=dangqian_wendu.value
+  }
   fasongNum.value++
   ipcRenderer.invoke('logger', `患者结果上传,第${fasongNum.value}次`)
   ipcRenderer.invoke('logger', '参数:'+JSON.stringify(mode))
   updatePatient(mode).then(re=>{
     ElMessage.success('结果发送成功')
     ipcRenderer.invoke('logger', '结果上传成功')
-    setTimeout(() => {
-      fuxuan()
-    },configData.value.timeJg)
+    // 倒计时结果显示
+    clockNum.value = Number(configData.value.timeJg/1000)
     return false
   }).catch(re=>{
     ElMessage('结果发送失败')
@@ -663,10 +677,23 @@
 );
 // 文本框点击事件
 const inputChabge = () => {
-  sendPationCodeApi(inputCode.value)
-  setTimeout(function () {
-    inputCode.value = ''
-  }, 1000)
+  console.log(inputCode.value.substring(0,4)==='1553')
+  // 更具沅江肾病医院的二维码匹配
+  if(inputCode.value.substring(0,4)==='1553'){
+    const list=inputCode.value.split(':')
+    console.log(list)
+    sendPationCodeApi(list[1])
+    setTimeout(function () {
+      inputCode.value = ''
+    }, 5000)
+  }else{
+    sendPationCodeApi(inputCode.value)
+    setTimeout(function () {
+      inputCode.value = ''
+    }, 5000)
+  }
+ 
+  
 }
 // 点击10下关闭程序
 const guyanbi = () => {
@@ -676,12 +703,43 @@
   }
 }
 onMounted(() => {
+  console.log(0%5)
   console.log('页面初始化', os.hostname())
   setTimeout(()=>{
-    console.log('5秒后执行')
+    
+    console.log('8秒后执行')
     console.log('打印设置文件')
     console.log(configData.value)
-      // 是否开启脸识别
+    is_ce_wen.value=configData.value.Is_ce_wen
+    if(is_ce_wen.value){
+      initPort(configData.value.portPath,configData.value.baudRate)
+    }
+    // 是否开启血压计联机
+    if(configData.value.Is_xyj){
+      if(configData.value.xyj_type==='TM2655'){
+        TM2655VP(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
+      }else{
+        oumulongHbp9030(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
+      } 
+    }
+    // 是否开启志荣体重秤联机
+    if(configData.value.Is_tzc){
+      //台衡M523
+      if(configData.value.tzc_type==='taiHengM523'){
+        taiHengM523(configData.value.tzcPortPath,configData.value.tzcBaudRate)
+      }
+      // seca101读取文件
+      else if(configData.value.tzc_type==='seca101'){
+        console.log('体重是读取文件')
+      }// 耀华XK3190-A12 
+      else if(configData.value.tzc_type==='XK3190-A12'){
+        XK3190A12(configData.value.tzcPortPath,configData.value.tzcBaudRate)
+      }
+      else{
+        zhiRongT605(configData.value.tzcPortPath,configData.value.tzcBaudRate)
+      }
+    }
+    // 是否开启脸识别
     isUseFaceRecogService.value = configData.value.isUseFaceRecogService
     console.log('人脸识别',isUseFaceRecogService.value)
     if (isUseFaceRecogService.value) {
@@ -694,7 +752,11 @@
     }
     clockNum.value = patientInfoStore().viewNumber
     setInterval(function () {
-      inputRef.value.focus();
+      clockNum.value--
+      if(clockNum.value===0){
+        fuxuan()
+      }
+      
       date.value=formatDate(new Date(),'YYYY-mm-dd HH:MM')
       if(Number(date.value.substring(11,13))<12){
         timeShidaun.value='上午好!'
@@ -703,6 +765,13 @@
       }else {
         timeShidaun.value='晚上好!'
       }
+      // 验证人脸识别已经通过但是还没有体重数据主动获取数据
+      if(patientInfo.value.name!==''&&weightInfo.value.result==='0'&&configData.value.Is_tzc){
+        console.log('主动获取体重')
+        todatatzs(patientInfo.value.datetime)
+      }
+      inputRef.value.focus();
+
     }, 1000)
     speech.value = new Speech();
     speech.value?.setLanguage('zh-CN')
@@ -789,7 +858,7 @@
   border-radius: 50px 0px 0px 50px;
   position: fixed;
   right: 0;
- 
 }
+  :v-deep .el-input__inner {background-color: transparent !important;}
 </style>
 

--
Gitblit v1.8.0