34
chenyc
2024-11-04 1accdfa68eab3576c6d8647f12bed8155dad329a
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
@@ -45,9 +46,28 @@
    config.endpoint = `facebody.cn-shanghai.aliyuncs.com`;
    return new facebody20191230.default(config);
}
app.get('/',async(req,res)=>{
    res.send('设备交换患者信息333');
})
app.get('/', (req, res) => {
    const title = '岱特智能'; // 动态设置标题
    const html = `
      <!DOCTYPE html>
      <html lang="zh-CN">
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <title>${title}</title>
      </head>
      <body>
      <iframe
        src="https://udify.app/chatbot/irsmISE8DBCWAhxz"
        style="width: 100%; height: 100%; min-height: 700px"
        frameborder="0"
        allow="microphone">
      </iframe>
      </body>
      </html>
    `;
    res.send(html);
  });
// 定义 /webuser 路由处理器  用患者code 换信息
app.post('/webuser', async (req, res) => {
    const mode=req.body
@@ -192,20 +212,22 @@
    const action = req.body.action;
    const deviceID = req.body.deviceID;
    const mode=req.body
    mode.action='webResults'
    logHttps(mode)
    console.log('----------')
    try {
        const datas=mode.datas
        datas.forEach(async element => {
            await installData(element)
        });
        response = {
            retCode: "1",
            msg: "成功"
            recode: "2000",
            remsg: "成功"
        };
        res.json(response)
       
    }catch(err){
        res.status(400).json({ retCode: "-1", msg: "Invalid request parameters" });
        res.status(4000).json({ retCode: "-1", msg: "Invalid request parameters" });
    }
    
})
@@ -340,6 +362,7 @@
const logHttps=(mode)=>{
    try{
        let sqlStr=`INSERT INTO system_log (id, code, url, parameter) VALUES (0, '', '${mode.action}', '${JSON.stringify(mode)}')`
        console.log(sqlStr)
        pool.promise().query(sqlStr)
    }catch (err) {
        console.error('访问日志记录错误:', err);