From 83c3fd352439e8f8c5858aaa8190e6ea33e2722d Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期一, 13 五月 2024 16:41:38 +0800
Subject: [PATCH] tianjia

---
 src/stores/StoresConfing.ts        |    6 +
 imgs/1708401609822.png             |    0 
 src/samples/deviceApi/RBP-9000c.ts |   54 ++++++++++
 imgs/1714623164195.png             |    0 
 src/views/home/index.vue           |   60 ++++++++++-
 imgs/1714136810634.png             |    0 
 imgs/1714547526334.png             |    0 
 imgs/1708401590338.png             |    0 
 imgs/1708401603596.png             |    0 
 imgs/1714440248953.png             |    0 
 src/samples/faceApi.ts             |   73 +++++++++++++-
 src/samples/deviceApi/mbp-9020.ts  |   61 ++++++++++++
 imgs/1708401593426.png             |    0 
 imgs/1714634878093.png             |    0 
 src/samples/deviceApi/XK3190A12.ts |    4 
 src/utils/formatTime.ts            |    1 
 16 files changed, 245 insertions(+), 14 deletions(-)

diff --git a/imgs/1708401590338.png b/imgs/1708401590338.png
new file mode 100644
index 0000000..76fa038
--- /dev/null
+++ b/imgs/1708401590338.png
Binary files differ
diff --git a/imgs/1708401593426.png b/imgs/1708401593426.png
new file mode 100644
index 0000000..091afb3
--- /dev/null
+++ b/imgs/1708401593426.png
Binary files differ
diff --git a/imgs/1708401603596.png b/imgs/1708401603596.png
new file mode 100644
index 0000000..3f075d6
--- /dev/null
+++ b/imgs/1708401603596.png
Binary files differ
diff --git a/imgs/1708401609822.png b/imgs/1708401609822.png
new file mode 100644
index 0000000..b352a76
--- /dev/null
+++ b/imgs/1708401609822.png
Binary files differ
diff --git a/imgs/1714136810634.png b/imgs/1714136810634.png
new file mode 100644
index 0000000..f34364d
--- /dev/null
+++ b/imgs/1714136810634.png
Binary files differ
diff --git a/imgs/1714440248953.png b/imgs/1714440248953.png
new file mode 100644
index 0000000..923a2cd
--- /dev/null
+++ b/imgs/1714440248953.png
Binary files differ
diff --git a/imgs/1714547526334.png b/imgs/1714547526334.png
new file mode 100644
index 0000000..f24663b
--- /dev/null
+++ b/imgs/1714547526334.png
Binary files differ
diff --git a/imgs/1714623164195.png b/imgs/1714623164195.png
new file mode 100644
index 0000000..a580322
--- /dev/null
+++ b/imgs/1714623164195.png
Binary files differ
diff --git a/imgs/1714634878093.png b/imgs/1714634878093.png
new file mode 100644
index 0000000..a0f1f17
--- /dev/null
+++ b/imgs/1714634878093.png
Binary files differ
diff --git a/src/samples/deviceApi/RBP-9000c.ts b/src/samples/deviceApi/RBP-9000c.ts
new file mode 100644
index 0000000..1a99da9
--- /dev/null
+++ b/src/samples/deviceApi/RBP-9000c.ts
@@ -0,0 +1,54 @@
+// 脉搏波 rbp-9000c 115200 
+import { ElMessage } from 'element-plus'
+const { SerialPort } = require('serialport')
+const { DelimiterParser } = require('@serialport/parser-delimiter')
+const { ByteLengthParser } = require('@serialport/parser-byte-length')
+import {sockteStore} from '@/stores/sockteInfo'
+
+
+const initPort=(path:String,baudRate:Number)=>{
+    const serialport  = new SerialPort({ path, baudRate }, (err: any) => {
+        if (err) {
+            console.log(err)
+            ElMessage({
+                message: '端口打开失败!',
+                type: 'error',
+            })
+            console.log(err)
+        }else{
+            ElMessage({
+                message: 'rbp-9000c端口打开成功',
+                type: 'success',
+            })
+        } 
+    })
+    serialport.on("close",(err: any)=>{
+        console.log('端口异常端口链接断开')
+        console.log(err)
+    })
+    // 解析分割数据流   AA 80 09 0F 01 06 00 17 05 0E 10 11 0F 00 8D 00 44 00 56 8C
+    //AA 80 09 0F 01 06 00 17 05 0E 0F 37 37 00 74 00 46 00 50 70
+    const parser = serialport.pipe(new ByteLengthParser({ length: 20 }))
+    parser.on('data', (value: string | any[])=>{
+        console.log(value.toString())
+        const str=value.toString()
+        const list=str.split(',')
+        console.log(list)
+        if(list.length===11){
+            sockteStore().setxyjSockte(
+              {
+                  deviceName:'HBP-9030',
+                  type:"血压计",
+                  result:list[14]+','+list[16]+','+list[18],
+                  resultTime:new Date().toString(),
+                  state:2
+              }
+          )
+        }
+        
+    })
+}
+
+export {
+    initPort,
+}
diff --git a/src/samples/deviceApi/XK3190A12.ts b/src/samples/deviceApi/XK3190A12.ts
index f270234..72c695d 100644
--- a/src/samples/deviceApi/XK3190A12.ts
+++ b/src/samples/deviceApi/XK3190A12.ts
@@ -40,12 +40,16 @@
     //
     //
     // 77 6E 30 30 30 30 30 2E 30 6B 67 0D 0A
+    // 77 6E 30 30 30 30 32 38 2E 36 6B 67 0D 0A
+    // 77 6E 30 30 30 30 32 38 2E 36 6B 67 0D 0A
+    //wn000016.6kg
     const parser = serialport.pipe(new DelimiterParser({ delimiter:Buffer.from([107,103,13,10]),includeDelimiter:true }))
     parser.on('data', (value: string | any[])=>{
         console.log(value.toString())
         const str=value.toString()
         // 截取结果
         const list=str.substring(2,10) 
+        console.log(list)
         if(Number(list)>20){
             // 判断是否相等 相等加一
             if(list===lisijieguo){
diff --git a/src/samples/deviceApi/mbp-9020.ts b/src/samples/deviceApi/mbp-9020.ts
new file mode 100644
index 0000000..ec61820
--- /dev/null
+++ b/src/samples/deviceApi/mbp-9020.ts
@@ -0,0 +1,61 @@
+// 欧姆龙 HBP-9030 115200 
+import { ElMessage } from 'element-plus'
+const { SerialPort } = require('serialport')
+const { DelimiterParser } = require('@serialport/parser-delimiter')
+const { ReadyParser } = require('@serialport/parser-ready')
+import {sockteStore} from '@/stores/sockteInfo'
+
+const initPort=(path:String,baudRate:Number)=>{
+    console.log('初始化打开mbp9020血压计端口')
+    const serialport  = new SerialPort({ path, baudRate }, (err: any) => {
+        if (err) {
+            console.log(err)
+            ElMessage({
+                message: 'mbp9020血压计端口打开失败!',
+                type: 'error',
+            })
+            console.log(err)
+        }else{
+            ElMessage({
+                message: 'mbp9020血压计端口打开成功',
+                type: 'success',
+            })
+        } 
+    })
+    serialport.on("close",(err: any)=>{
+        console.log('mbp9020血压计端口异常端口链接断开')
+        console.log(err)
+    })
+    // 解析分割数据流
+    //bp,99999999999999999999,2024/04/26,20:41,116,083,067,099,1
+    //
+    //
+    //
+    //
+    //
+    // 62 702C 39 39 39 39 39 39 39 39 39 39 39 3939 39 39 39 39 39 39 39 2C 32 30 32 34 2F 30 34 2F32 36 2C 32 30 3A 34 36 2C 31 31 38 2C 30 38 31 2C30 36 33 2C 30 39 35 2C 30 0D
+    const parser = serialport.pipe(new DelimiterParser({ delimiter:Buffer.from([13]),includeDelimiter:true }))
+    parser.on('data', (value: string | any[])=>{
+        console.log(value.toString())
+        const str=value.toString()
+        const list=str.split(',')
+        console.log(list)
+        if(list.length>=5&&list[0].search('bp')!==-1){
+            sockteStore().setxyjSockte(
+                {
+                    deviceName:'mbp9020',
+                    type:"血压计",
+                    result:list[4]+','+list[6]+','+list[7],
+                    resultTime:new Date().toString(),
+                    state:2
+                }
+            )
+        }else{
+            console.log('数据格式不对')
+        }
+    }) // all data after READY is received
+}
+
+export {
+    initPort,
+}
diff --git a/src/samples/faceApi.ts b/src/samples/faceApi.ts
index d7a8d3e..aa513e6 100644
--- a/src/samples/faceApi.ts
+++ b/src/samples/faceApi.ts
@@ -44,6 +44,7 @@
  * @param path 图片路径
  */
 const  faceShibie= async(path:any)=>{
+  console.log('文件路径',path)
   const fileStream = fs.createReadStream(path);
   let client=createClient()
   // 通过本地文件
@@ -86,22 +87,70 @@
     delImg(path)
   })
 }
+// 验证---逻辑
+const yanzhengimg=async(path:any)=>{
+  console.log('文件路径--逻辑',path)
+  const fileStream = fs.createReadStream(path);
+  let client=createClient()
+  // 通过本地文件
+  const facedata= confingInfoStore().confingInfo.face_database
+  const faceScore=confingInfoStore().confingInfo.face_score
+  let searchFaceAdvanceRequest = new $facebody20191230.SearchFaceAdvanceRequest();
+  searchFaceAdvanceRequest.imageUrlObject = fileStream;
+  searchFaceAdvanceRequest.dbName = facedata
+  searchFaceAdvanceRequest.limit = 2;
+  let runtime = new $Util.RuntimeOptions({ });
+  client.searchFaceAdvance(searchFaceAdvanceRequest, runtime).then(re=>{
+    if(re.statusCode===200){
+      const matchList=re.body.data?.matchList
+      // console.log('得到的人脸库')
+      console.log(matchList)
+      if(matchList?.length>0){
+        const faceItems =matchList[0].faceItems
+        if(faceItems?.length===0){
+          console.log('没有找到患者对应的人脸')
+          return false
+        }
+        if(faceItems[0].score>=faceScore){
+          const entityId=faceItems[0].entityId
+          console.log(entityId,'得到了人脸识别id,存患者code到vuex')
+          sockteStore().setfaceSockte({
+            deviceType: "人脸识别",
+            deviceName: "人脸识别",
+            result: entityId,
+            resultTime: ''
+          })
+        }else{
+          console.log('没有找到患者对应的人脸')
+        }
+      }
+
+    }
+  }).finally(()=>{
+    // console.log('---------------都要执行的')
+     // 删除图片
+    // delImg(path)
+  })
+}
 const faceApiCheck=async(path:any)=>{
   fs.readFile(path, (err, data) => {
     if (err) throw err;
       let blobFile = new File([data], 'name.png', {type:"image/png"})
       console.log(blobFile)
       const formData = new FormData() // 下面有备注
-      formData.append('File1', blobFile)
+      formData.append('file', blobFile)
       checkUploadFile(formData).then(re=>{
-        console.log('-----')
+          console.log('-----',re)
+      }).finally(()=>{
+          // 删除图片
+          delImg(path)
       })
   })
   
 
 
-}
-// base64z转文件后验证
+  }
+  // base64z转文件后验证
 const base64toFile = (dataurl:any,filename='file') =>  {
   if (!fs.existsSync('./imgs')) {
     fs.mkdir('./imgs', (err) => {
@@ -118,12 +167,20 @@
      if (err) {
        console.log(err);
      } else {
-     
       //  console.log('写入成功!验证阿里', path);
        // getOssUrl(path)
        // 验证图片
-       faceShibie(path)
-      //  faceApiCheck(path)
+       // 是否本地识别
+       const isLanFace= confingInfoStore().confingInfo.isLanFace
+       if(isLanFace){
+        //本地识别
+        faceApiCheck(path)
+       }else{
+        //阿里验证外网
+        faceShibie(path)
+       }
+       
+       
      }
    })
 }
@@ -137,7 +194,9 @@
     }
   })
 }
+
 export {
+  yanzhengimg,
   createClient,
   faceShibie,
   base64toFile
diff --git a/src/stores/StoresConfing.ts b/src/stores/StoresConfing.ts
index a929c66..12541ed 100644
--- a/src/stores/StoresConfing.ts
+++ b/src/stores/StoresConfing.ts
@@ -2,6 +2,7 @@
 import { ref } from 'vue'
 export const confingInfoStore =defineStore('confingInfo',()=>{
     const confingInfo=ref({
+        isLanFace:false,
         screenTimeout: 150,
         isUseFaceRecogService: true,
         deviceType:"血压计",
@@ -10,6 +11,7 @@
         timeJg:10000,
         base_api:"",
         face_push:3,
+        imgHeight:200,
         // 播报定时
         BobaoJg:4,
         beginWorkTime:5,
@@ -46,6 +48,10 @@
         if(info.BobaoJg===undefined){
             confingInfo.value.BobaoJg=4
         }
+        // 
+        if(info.isLanFace===undefined){
+            confingInfo.value.isLanFace=true
+        }
     }
     return {confingInfo,setconfingInfo}
 })
\ No newline at end of file
diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts
index 3c7221c..68ee6f6 100644
--- a/src/utils/formatTime.ts
+++ b/src/utils/formatTime.ts
@@ -232,3 +232,4 @@
     else return true
 }
 
+
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index d656ad0..5edebf7 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -9,7 +9,7 @@
                         <img class="image_1"  style="margin-left: 20px;display: inline-block;"  referrerpolicy="no-referrer" src="@/assets/logo.png" />
                     
                     </div>
-                      <div class="titlecss">自助签到系统</div>
+                      <div @click="yanzhengTUpian" class="titlecss">自助签到系统</div>
                 </div> 
             </el-col>
             <el-col v-if="dialogVisible" :span="12" style="text-align: right;padding-top: 10px;">
@@ -239,6 +239,20 @@
            返回
           </div>
         </div>
+        <el-dialog
+            v-model="centerDialogVisible"
+            title=""
+            width="40%"
+            align-center
+        >
+            <span>
+              <div>
+                  找到该程序根目录下imgs/1708401593426.png下路径 把图片名改成一致 就可以测试了,
+              </div>
+                
+                <el-button @click="yanzhengTUpianClick">验证</el-button>
+            </span>
+        </el-dialog>
     
    
   </div>
@@ -259,7 +273,7 @@
 import { sendPationCodeApi } from '../../samples/httpApi'
 import { formatDate,jgTime,isworkTime } from '@/utils/formatTime'
 import { confingInfoStore } from '@/stores/StoresConfing'
-import {base64toFile} from '@/samples/faceApi'
+import {base64toFile,yanzhengimg} 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'
@@ -268,15 +282,19 @@
 import{initPort as taiHengM523 } from '@/samples/deviceApi/taiHengM523'
 import{initPort as XK3190A12 } from '@/samples/deviceApi/XK3190A12'
 import {initPort as mbp7000} from '@/samples/deviceApi/mbp7000'
+import {initPort as mbp9020} from '@/samples/deviceApi/mbp-9020'
+import {initPort as rbp9000c} from '@/samples/deviceApi/RBP-9000c'
+
 import {initPort as M503} from '@/samples/deviceApi/M503'
 import {initPort as seca102} from '@/samples/deviceApi/seca102'
 // 引入模块
 import config from '../../../package.json'
+import { Delete, Download, Plus, ZoomIn } from '@element-plus/icons-vue'
 
 
 // 读取体重文件
 import{todatatzs } from '@/samples/deviceApi/seca101'
-import {ElMessage } from 'element-plus'
+import {ElMessage, UploadFile, UploadInstance, UploadProps } from 'element-plus'
 const { proxy } = getCurrentInstance() as any;
 // 人脸检测对象
 const options = new SsdMobilenetv1Options({
@@ -319,7 +337,22 @@
 const gao_ya=ref("")//高压
 const di_ya=ref("")//低压
 const  mai_bu=ref("")//脉搏,
-
+const tupianpath=ref('') //验证图片地址
+const centerDialogVisible=ref(false)
+const uploadRef = ref<UploadInstance>()
+const fileList=ref([])
+const imageUrl = ref('') 
+const dialogImageUrl = ref('')
+// 打开图片验证
+const yanzhengTUpian=()=>{
+  
+  centerDialogVisible.value=true
+}
+//验证图片
+const yanzhengTUpianClick=()=>{
+  const path = './imgs/1708401593426.png'
+  yanzhengimg(path)
+}
 const tzjs=computed(()=>{
   if(weightInfo.value.result!=='0'&&weightInfo.value.result!==undefined&&weightInfo.value.result!==null){
     return (patientInfo.value.preWeight-Number(weightInfo.value.result)).toFixed(1)
@@ -911,7 +944,12 @@
 }
 const updateChengxu=()=>{
   console.log('检查更新')
-  ipcRenderer.invoke("check-update");
+  if(configData.value.isLanFace){
+    console.log('是内网不能检查更新')
+  }else{
+    ipcRenderer.invoke("check-update");
+  }
+ 
 }
 onMounted(() => {
   console.log('页面初始化', os.hostname())
@@ -933,6 +971,11 @@
         TM2655VP(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
       }else if(configData.value.xyj_type==='mbp7000'){
         mbp7000(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
+      }else if(configData.value.xyj_type==='mbp9020'){
+        mbp9020(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
+      }
+      else if(configData.value.xyj_type==='RBP-9000c'){
+        rbp9000c(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
       }
       else{
         oumulongHbp9030(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
@@ -1046,7 +1089,10 @@
   const resizedResult = resizeResults(result, dims)
   const box = resizedResult.box
   // 不要小头像
-  if(box._height<120) return detectFace()
+  console.log('000')
+  const h=configData.value.imgHeight===undefined?140:configData.value.imgHeight
+  console.log('000',h)
+  if(box._height<h) return detectFace()
   //检测框是否在取景框内
   // if (!checkInViewFinder(box)) return detectFace()
   // drawViewFinder()
@@ -1072,7 +1118,7 @@
   // console.log(image)
   if(dialogVisible.value&&X>configData.value.face_push&&isworkTime(new Date())){
     lsDateTime=new Date()
-    console.log(X,'上传阿里识别间隔')
+    console.log(X,'上传图片间隔')
     base64toFile(image)
   }
   return detectFace()

--
Gitblit v1.8.0