添加药品速度insert接口

This commit is contained in:
mouse 2023-11-11 13:22:51 +08:00
parent d1be1673d9
commit 3436ef912d
5 changed files with 108 additions and 45 deletions

View File

@ -2,6 +2,7 @@ import common from "./common.js";
const app = common.app; const app = common.app;
const connection = common.connection; const connection = common.connection;
const m_get = common.m_get; const m_get = common.m_get;
const m_add = common.m_add;
const nowTime = common.nowTime; const nowTime = common.nowTime;
const getTable = () => app.post('/getaimedicine', function (req, res) { const getTable = () => app.post('/getaimedicine', function (req, res) {
@ -14,7 +15,7 @@ const getTable = () => app.post('/getaimedicine', function (req, res) {
connection(database).query(m_get(table, Clause, order, start, end), function (error, results, fields) { connection(database).query(m_get(table, Clause, order, start, end), function (error, results, fields) {
if (error) { if (error) {
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`); console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
connection(database).connect(); // connection(database).connect();
return res.status(500).send(error); return res.status(500).send(error);
} else { } else {
res.send(results); res.send(results);
@ -22,6 +23,24 @@ const getTable = () => app.post('/getaimedicine', function (req, res) {
}); });
}); });
const addTable = () => app.post('/addaimedicine', (req, res) => {
const database = req.body.database;
const table = `AIMedicineTable`;
const key = req.body.key;
// `name, region, area, house_type, phone, create_time, remark`;
const values = req.body.value;
// `'${v.name}', '${v.region}', '${v.area}', '${v.house_type}', '${v.phone}', '${nowTime()}', '${remark}'`;
connection(database).query(m_add(table, key, values), function (error, results, fields) {
if (error) {
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
return res.status(500).send(error);
} else {
res.send(results);
}
});
})
export default { export default {
getTable getTable,
addTable
}; };

View File

@ -2,6 +2,7 @@ import common from "./common.js";
const app = common.app; const app = common.app;
const connection = common.connection; const connection = common.connection;
const m_get = common.m_get; const m_get = common.m_get;
const m_add = common.m_add;
const nowTime = common.nowTime; const nowTime = common.nowTime;
const getTable = () => app.post('/getdoctormedicine', function (req, res) { const getTable = () => app.post('/getdoctormedicine', function (req, res) {
@ -14,7 +15,7 @@ const getTable = () => app.post('/getdoctormedicine', function (req, res) {
connection(database).query(m_get(table, Clause, order, start, end), function (error, results, fields) { connection(database).query(m_get(table, Clause, order, start, end), function (error, results, fields) {
if (error) { if (error) {
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`); console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
connection(database).connect(); // connection(database).connect();
return res.status(500).send(error); return res.status(500).send(error);
} else { } else {
res.send(results); res.send(results);
@ -22,6 +23,22 @@ const getTable = () => app.post('/getdoctormedicine', function (req, res) {
}); });
}); });
const addTable = () => app.post('/adddoctormedicine', (req, res) => {
const database = req.body.database;
const table = `DoctorMedicineTable`;
const key = req.body.key;
const values = req.body.value;
connection(database).query(m_add(table, key, values), function (error, results, fields) {
if (error) {
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
return res.status(500).send(error);
} else {
res.send(results);
}
});
})
export default { export default {
getTable getTable,
addTable
}; };

View File

@ -14,7 +14,7 @@ const getTable = () => app.post('/getfeature', function (req, res) {
connection(database).query(m_get(table, Clause, order, start, end), function (error, results, fields) { connection(database).query(m_get(table, Clause, order, start, end), function (error, results, fields) {
if (error) { if (error) {
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`); console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
connection(database).connect(); // connection(database).connect();
return res.status(500).send(error); return res.status(500).send(error);
} else { } else {
res.send(results); res.send(results);

View File

@ -28,6 +28,8 @@ connection().connect();
featureTable.getTable(); featureTable.getTable();
AIMedicineTable.getTable(); AIMedicineTable.getTable();
doctorMedicineTable.getTable(); doctorMedicineTable.getTable();
AIMedicineTable.addTable();
doctorMedicineTable.addTable();
// MedicineFeadbackInfoTable // MedicineFeadbackInfoTable
// TimingFeadbackInfoTable // TimingFeadbackInfoTable

View File

@ -82,7 +82,8 @@
<div class="right-box"> <div class="right-box">
<div class="top-btn-box"> <div class="top-btn-box">
<div class="top-left-btn-box"> <div class="top-left-btn-box">
<el-select v-model="database" filterable placeholder="Select" style="width: 100%;" @change="selectDatabase"> <el-select v-model="database" filterable placeholder="Select" style="width: 100%;"
@change="selectDatabase">
<el-option v-for="item in databaseOptions" :key="item.value" :label="item.label" <el-option v-for="item in databaseOptions" :key="item.value" :label="item.label"
:value="item.value" /> :value="item.value" />
</el-select> </el-select>
@ -168,7 +169,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref, reactive } from 'vue'; import { onMounted, ref, reactive } from 'vue';
import { ElMessageBox } from 'element-plus'; import { ElMessageBox, ElMessage } from 'element-plus';
import { dateFormater } from './date-util'; import { dateFormater } from './date-util';
import { post } from "@/axios/index"; import { post } from "@/axios/index";
import chartLine from './chart-line.vue'; import chartLine from './chart-line.vue';
@ -191,15 +192,15 @@ const databaseOptions: { value: string, label: string }[] = [
{ value: '数据模拟20231109185403', label: '模拟数据库' } { value: '数据模拟20231109185403', label: '模拟数据库' }
]; ];
const medicineCustom: any[] = [ const medicineCustom: any[] = [
{ name: '丙泊酚', plus: 0.5 }, { name: '丙泊酚', plus: 0.5, total: 50 },
{ name: '舒芬太尼', plus: 1 }, { name: '舒芬太尼', plus: 1, total: 100 },
{ name: '瑞芬太尼', plus: 0.05 }, { name: '瑞芬太尼', plus: 0.05, total: 5 },
{ name: '顺阿曲库胺', plus: 0.02 }, { name: '顺阿曲库胺', plus: 0.02, total: 2 },
{ name: '尼卡地平', plus: 1 }, { name: '尼卡地平', plus: 1, total: 100 },
{ name: '艾司洛尔', plus: 1 }, { name: '艾司洛尔', plus: 1, total: 100 },
{ name: '麻黄素', plus: 1 }, { name: '麻黄素', plus: 1, total: 100 },
{ name: '阿托品', plus: 1 }, { name: '阿托品', plus: 1, total: 100 },
{ name: '罗库溴铵', plus: 0.1 } { name: '罗库溴铵', plus: 0.1, total: 10 }
]; ];
const database = ref('数据模拟20231109185403'); const database = ref('数据模拟20231109185403');
const messageSum = ref(10); const messageSum = ref(10);
@ -267,7 +268,7 @@ function getChartData() {
function getEEG() { function getEEG() {
setTimeout(() => { setTimeout(() => {
// if (isStart.value) { // if (isStart.value) {
chartDom4.value.updateChart(0, new Date()); chartDom4.value.updateChart(0, new Date());
// } // }
getEEG(); getEEG();
}, 1000); }, 1000);
@ -275,28 +276,28 @@ function getChartData() {
function getData(callback: () => void) { function getData(callback: () => void) {
// if (isStart.value) { // if (isStart.value) {
post('/getfeature', { database: database.value, start: 0, end: 1 }, (res: any) => { post('/getfeature', { database: database.value, start: 0, end: 1 }, (res: any) => {
const obj = res.data[0] || {}; const obj = res.data[0] || {};
if (obj.ID !== chartNowData.ID) { if (obj.ID !== chartNowData.ID) {
chartNowData = obj; chartNowData = obj;
const isHR = obj.HR >= 50 && obj.HR <= 80; const isHR = obj.HR >= 50 && obj.HR <= 80;
const isSBP = obj.SBP >= 90 && obj.SBP <= 120; const isSBP = obj.SBP >= 90 && obj.SBP <= 120;
const isDBP = obj.DBP >= 60 && obj.DBP <= 90; const isDBP = obj.DBP >= 60 && obj.DBP <= 90;
// const isST = obj.ST >= -0.2 && obj.ST <= 0.2; // const isST = obj.ST >= -0.2 && obj.ST <= 0.2;
if (!isHR) unusualUpDate('心率异常'); if (!isHR) unusualUpDate('心率异常');
if (!isSBP) unusualUpDate('收缩压异常'); if (!isSBP) unusualUpDate('收缩压异常');
if (!isDBP) unusualUpDate('舒张异常'); if (!isDBP) unusualUpDate('舒张异常');
// if (!isST) unusualUpDate('ST'); // if (!isST) unusualUpDate('ST');
lungAlarm.value = Boolean(!isSBP || !isDBP); lungAlarm.value = Boolean(!isSBP || !isDBP);
// heartAlarm.value = Boolean(!isHR || !isST); // heartAlarm.value = Boolean(!isHR || !isST);
heartAlarm.value = Boolean(!isHR); heartAlarm.value = Boolean(!isHR);
chartDom1.value.updateChart([obj.BIS, obj.HR], obj.Time || obj.TIME); chartDom1.value.updateChart([obj.BIS, obj.HR], obj.Time || obj.TIME);
chartDom2.value.updateChart([obj.SBP, obj.DBP], obj.Time || obj.TIME); chartDom2.value.updateChart([obj.SBP, obj.DBP], obj.Time || obj.TIME);
chartDom3.value.updateChart([obj.SPO2, obj.TEMP], obj.Time || obj.TIME); chartDom3.value.updateChart([obj.SPO2, obj.TEMP], obj.Time || obj.TIME);
// chartDom4.value.updateChart(obj.ST, obj.Time || obj.TIME); // chartDom4.value.updateChart(obj.ST, obj.Time || obj.TIME);
} }
callback(); callback();
}) })
// } else { // } else {
// callback(); // callback();
// } // }
@ -336,13 +337,13 @@ function getTableData(e: boolean) {
for (let key in res.data[0]) { for (let key in res.data[0]) {
if (key !== 'ID' && key !== 'Phase' && key !== 'Time' && key !== 'TIME') { if (key !== 'ID' && key !== 'Phase' && key !== 'Time' && key !== 'TIME') {
i++; i++;
tableData.value.push({ num: i, name: key, speed: res.data[0][key], total: Number(res.data[0][key]), state: '正常' }); tableData.value.push({ Phase: res.data[0].Phase, num: i, name: key, speed: res.data[0][key], total: medicineCustom.find(o => o.name === key)?.total, state: '正常' });
} }
} }
} else { } else {
const defaultMedicine: string[] = ['丙泊酚', '舒芬太尼', '瑞芬太尼', '顺阿曲库胺', '尼卡地平', '艾司洛尔', '麻黄素', '阿托品']; const defaultMedicine: string[] = ['丙泊酚', '舒芬太尼', '瑞芬太尼', '顺阿曲库胺', '尼卡地平', '艾司洛尔', '麻黄素', '阿托品'];
defaultMedicine.forEach((item, index) => { defaultMedicine.forEach((item, index) => {
tableData.value.push({ num: index + 1, name: item, speed: 0, total: 0, state: '正常' }); tableData.value.push({ Phase: 1, num: index + 1, name: item, speed: 0, total: medicineCustom.find(o => o.name === item)?.total, state: '正常' });
}); });
} }
tableDataStore.value = JSON.parse(JSON.stringify(tableData.value)); tableDataStore.value = JSON.parse(JSON.stringify(tableData.value));
@ -410,13 +411,34 @@ const tableItemPlus = (e: any) => {
}; };
const tableItemMinus = (e: any) => { const tableItemMinus = (e: any) => {
const obj = medicineCustom.find(item => item.name === e.row.name) || { plus: 1 }; const obj = medicineCustom.find(item => item.name === e.row.name) || { plus: 1 };
if(!isAIDose.value && e.row.speed - obj.plus <= 0) return; if (!isAIDose.value && e.row.speed - obj.plus <= 0) return;
e.row.speed -= obj.plus; e.row.speed -= obj.plus;
if (e.row.speed < 0) e.row.speed = 0; if (e.row.speed < 0) e.row.speed = 0;
else e.row.speed = Number(e.row.speed.toFixed(2)); else e.row.speed = Number(e.row.speed.toFixed(2));
}; };
const tableItemConfirm = (e: any) => { const tableItemConfirm = (e: any) => {
tableDataStore.value[e.$index].speed = e.row.speed; tableDataStore.value[e.$index].speed = e.row.speed;
if (tableData.value.length < 1) return;
let key = `Phase`;
let value = `${tableData.value[0].Phase}`;
tableData.value.forEach(item => {
key += `, ${item.name}`;
value += `, ${item.speed}`;
});
post(isAIDose.value ? '/addaimedicine' : '/adddoctormedicine', { database: database.value, key, value }, (res: any) => {
if (res.status === 200) {
tableDataStore.value = JSON.parse(JSON.stringify(tableData.value));
ElMessage({
message: '保存成功!',
type: 'success',
});
}else {
ElMessage({
message: JSON.stringify(res),
type: 'error',
});
}
});
}; };
const tableItemCancel = (e: any) => { const tableItemCancel = (e: any) => {
e.row.speed = tableDataStore.value[e.$index].speed; e.row.speed = tableDataStore.value[e.$index].speed;
@ -681,19 +703,23 @@ onMounted(() => {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
.top-left-btn-box { .top-left-btn-box {
display: flex; display: flex;
align-items: center; align-items: center;
.el-select { .el-select {
margin-right: 10px; margin-right: 10px;
} }
} }
.el-button { .el-button {
border-radius: 16px; border-radius: 16px;
height: 31px; height: 31px;
background-color: transparent; background-color: transparent;
color: #c77000; color: #c77000;
} }
&>.el-button { &>.el-button {
border-radius: 4px; border-radius: 4px;
background-color: #f2f3f5; background-color: #f2f3f5;
@ -732,7 +758,7 @@ onMounted(() => {
video { video {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
} }
} }
@ -856,5 +882,4 @@ onMounted(() => {
} }
} }
} }
} }</style>
</style>