From ee5d1510c87dbf40e532ee41ea88d11d445dce77 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期二, 29 十月 2024 21:12:07 +0800
Subject: [PATCH] 更新输出git ;
---
app.js | 104 +++++++++++++++++++++++++++++++++++-----------------
1 files changed, 70 insertions(+), 34 deletions(-)
diff --git a/app.js b/app.js
index bc1dd9d..143f9dc 100644
--- a/app.js
+++ b/app.js
@@ -2,6 +2,7 @@
const bodyParser = require('body-parser');
const mysql = require('mysql2');
const fs = require('fs').promises;
+const fs2=require('fs')
const path = require('path');
const moment = require('moment')
// 转成能识别的url
@@ -46,7 +47,14 @@
return new facebody20191230.default(config);
}
app.get('/',async(req,res)=>{
- res.send('设备交换患者信息');
+ const filePath = path.join(__dirname, 'public', 'index.html');
+ fs2.readFile(filePath, 'utf8', (err, data) => {
+ if (err) {
+ res.status(500).send('Error reading file');
+ return;
+ }
+ res.send(data);
+ });
})
// 定义 /webuser 路由处理器 用患者code 换信息
app.post('/webuser', async (req, res) => {
@@ -139,33 +147,27 @@
if (rows.length > 0) {
const user = rows[0];
response = {
- retCode: "1",
- uinfo: {
- title: user.client_code,
- cardID: user.code,
- userNum: user.patient_no,
+ recode: 2001,
+ userinfo: {
name: user.patient_name,
sex: user.patient_gender === 0 ? '男' : '女',
age: getAgeFromIdCard(user.patient_identity_no),
- headimgurl: user.patient_avatar_icon,
- imgBaseData: '',
+ usernum: user.code, //这个是数据返回会携带回来UID
+ address: user.patient_address,
remark: '患者人脸识别111'
},
- dbinfo: {}, // 如果没有需要更新的数据库信息,可以保持空
- msg: "success"
+ remsg: "success"
};
- // res.json(response);
} else {
response = {
- retCode: "0",
- msg: "没有找到患者,请先检查患者code"
+ retcode: 1001,
+ remsg: "没有找到患者,请先检查患者code"
};
- // res.json(response);
}
} else {
response = {
- retCode: "0",
- msg: "没有找到患者,请先检查患者code"
+ retcode: 1001,
+ remsg: "没有找到患者,请先检查患者code"
};
}
res.json(response);
@@ -219,7 +221,7 @@
/**
* patientId={patientId}
*/
-app.post('/getpatientInfo',async(req,res)=>{
+app.get('/getpatientInfo',async(req,res)=>{
// 使用req.query访问查询字符串参数
const patientId = req.query.patientid;
const mode={"action":'getpatientInfo',"patientId":patientId}
@@ -233,18 +235,24 @@
if (rows.length > 0) {
const user = rows[0];
const response = {
- retCode: "1",
- result: {
+ code: "1",
+ result:[ {
patientId: user.code,
fullName: user.patient_name,
gender: user.patient_gender,
age: getAgeFromIdCard(user.patient_identity_no),
- // phoneNum:user.
- headimgurl: user.patient_avatar_icon,
- imgBaseData: '',
- remark: ''
- },
- dbinfo: {}, // 如果没有需要更新的数据库信息,可以保持空
+ phoneNum:user.patient_mobile,
+ address: user.patient_avatar_icon,
+ idType: user.patient_identity_type,
+ idNum: user.patient_identity_no,
+ height:'',
+ weight:'',
+ requestDoctor:'',
+ requestDept :"",
+ examDoctor:'',
+ examDept:"",
+ diagnosisDoctor:''
+ }],
msg: "success"
};
res.json(response);
@@ -268,6 +276,21 @@
console
})
+/**
+ * PostCheckExam 病人信息及检测结果以JSON的形式回传至服务器
+ */
+app.post('/PostCheckExam',async(req,res)=>{
+ const mode=req.body
+ if(mode){
+ logHttps(mode)
+ }else{
+ mode.action='hahhaha'
+ logHttps(mode)
+ }
+ res.status(400).json({ retCode: "-1", msg: "kankan" });
+
+
+})
// 启动服务器
app.listen(port, async () => {
console.log(`Server running at http://localhost:${port}/`);
@@ -289,7 +312,7 @@
await fs.writeFile(outputPath, buffer);
const ossUrl = await getOssUrl(outputPath)
// 删除本地图片
- // delImg(outputPath)
+ delImg(outputPath)
console.log('File saved to', outputPath);
console.log(`得到ossUrl=${ossUrl}`)
return ossUrl
@@ -312,7 +335,6 @@
await fs.mkdir(directory, { recursive: true });
} catch (err) {
console.error('Error creating directory:', err);
- throw err;
}
}
// 将文件上传到阿里的oss
@@ -328,14 +350,28 @@
let sqlStr=`INSERT INTO system_log (id, code, url, parameter) VALUES (0, '', '${mode.action}', '${JSON.stringify(mode)}')`
pool.promise().query(sqlStr)
}catch (err) {
- console.error('Error creating directory2222:', err);
- throw err;
+ console.error('访问日志记录错误:', err);
}
}
// 插入数据
const installData=async (mode)=>{
try{
- let sqlStr=`INSERT INTO patient_rtcf_result (id, code, patient_code,`+
+ let selectSql=`SELECT * FROM patient_rtcf_result WHERE code='${mode.occurTime}'`
+ const [rows] = await pool.promise().query(selectSql);
+ if(rows.length>0){
+ let updateSql=''
+ if(mode.BF){
+ updateSql=`UPDATE patient_rtcf_result SET rtcf_json_bf ='${JSON.stringify(mode.BF)}'`
+ }else if (mode.BMI){
+ updateSql=`UPDATE patient_rtcf_result SET rtcf_json_bmi ='${JSON.stringify(mode.BMI)}'`
+ }
+ if(updateSql){
+ console.log(`-------------------------更新${updateSql}---------`)
+ console.log(updateSql)
+ await pool.promise().query(updateSql)
+ }
+ }else{
+ let sqlStr=`INSERT INTO patient_rtcf_result (id, code, patient_code,`+
`comm_time,rtcf_json_bmi,`+
`rtcf_json_bp,`+
`rtcf_json_bf,`+
@@ -353,15 +389,15 @@
`rtcf_json_fei,`+
`rtcf_jiu,`+
`rtcf_gmd)`+
- `VALUES (0, '', '${mode.UID}', '${moment(new Date()).format('YYYY-MM-DD HH:mm:ss')}','${JSON.stringify(mode.BMI)}',`+
+ `VALUES (0, '${mode.occurTime}', '${mode.UID}', '${moment(new Date()).format('YYYY-MM-DD HH:mm:ss')}','${JSON.stringify(mode.BMI)}',`+
`'${JSON.stringify(mode.BP)}','${JSON.stringify(mode.BF)}','${JSON.stringify(mode.temp)}','${JSON.stringify(mode.bo)}',`+
`'${JSON.stringify(mode.bs)}','${JSON.stringify(mode.whr)}','${JSON.stringify(mode.ncg)}','${JSON.stringify(mode.zytz)}',`+
`'${JSON.stringify(mode.ecg)}','${JSON.stringify(mode.xzsx)}','${JSON.stringify(mode.eye)}',`+
`'${JSON.stringify(mode.sds)}','${JSON.stringify(mode.thxhdb)}','${JSON.stringify(mode.fei)}','${JSON.stringify(mode.jiu)}','${JSON.stringify(mode.gmd)}')`
-
- console.log('-------------------')
console.log(sqlStr)
- await pool.promise().query(sqlStr)
+ await pool.promise().query(sqlStr)
+ }
+
}catch(err){
console.log('数据写入异常')
}
--
Gitblit v1.8.0