|
|
|
|
@ -22,6 +22,7 @@ import Navbar from "@/components/navbar/navbar";
|
|
|
|
|
import PopupCountdown from "@/components/popup/popup-countdown";
|
|
|
|
|
import PopupStepTips from "@/components/popup/popup-step-tips";
|
|
|
|
|
import PopupConfirm from "@/components/popup/popup-confirm";
|
|
|
|
|
import PopupAlert from "@/components/popup/popup-alert";
|
|
|
|
|
/* 公共组件 END */
|
|
|
|
|
|
|
|
|
|
/* 本页组件 */
|
|
|
|
|
@ -48,15 +49,10 @@ import {
|
|
|
|
|
deviceCommandSamples,
|
|
|
|
|
bleCommandSamples,
|
|
|
|
|
} from "@/components/bluetoot/connection/test";
|
|
|
|
|
import {
|
|
|
|
|
s_to_s,
|
|
|
|
|
s_to_m,
|
|
|
|
|
minSecToS,
|
|
|
|
|
s_to_ms,
|
|
|
|
|
isNeedToUpdate,
|
|
|
|
|
} from "@/utils/util";
|
|
|
|
|
import { s_to_s, s_to_m, minSecToS, s_to_ms, sleep } from "@/utils/util";
|
|
|
|
|
import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100";
|
|
|
|
|
import commandMap from "@/utils/commandMap";
|
|
|
|
|
|
|
|
|
|
const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WL200", "WL200");
|
|
|
|
|
|
|
|
|
|
let currentTimeTimer: any = null; // 当前项目时间定时器
|
|
|
|
|
@ -154,6 +150,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
/** 连接设备 End */
|
|
|
|
|
|
|
|
|
|
/** 护理过程 */
|
|
|
|
|
isCanClick: false, // 是否可以点击开始按钮
|
|
|
|
|
isStandStatus: false, // 当前模式是否舱体/支架模式
|
|
|
|
|
isShowStepTips: false, // 是否显示介绍步骤弹窗
|
|
|
|
|
isConnectionBlutoot: true, // 是否已连接蓝牙
|
|
|
|
|
@ -190,9 +187,18 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
// 最后执行步骤位置
|
|
|
|
|
endPlace: "",
|
|
|
|
|
currentTime: "01:00",
|
|
|
|
|
|
|
|
|
|
// 通用错误提示
|
|
|
|
|
isShowErrorTipsText: false, // 护理模式切换错误弹窗
|
|
|
|
|
errorTipsText: "", // 护理模式切换错误提示
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
hadGotInstrumentHistoryData = false; // 已缓存仪器历史数据
|
|
|
|
|
|
|
|
|
|
// 不涉及渲染的页面变量
|
|
|
|
|
workStatus: any = ""; // 工作状态
|
|
|
|
|
WL200NursingHistory: any = null; // 护理缓存历史
|
|
|
|
|
hadCheckReport = false; // 是否已检查仪器护理记录
|
|
|
|
|
hadGotInstrumentHistoryData = false; // 是否已缓存仪器历史数据
|
|
|
|
|
|
|
|
|
|
async onLoad() {
|
|
|
|
|
// 保持屏幕常亮
|
|
|
|
|
@ -236,10 +242,8 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
// 开发者工具
|
|
|
|
|
const platform = Taro.getSystemInfoSync().platform;
|
|
|
|
|
|
|
|
|
|
//开发者工具
|
|
|
|
|
if (platform !== "devtools") {
|
|
|
|
|
// 初始化蓝牙
|
|
|
|
|
// 仅手机端初始化蓝牙
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -282,6 +286,8 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
isShowCountdown: false,
|
|
|
|
|
});
|
|
|
|
|
console.log(commandMap.WL200Command, "监听到蓝牙断开, 打开断开提示");
|
|
|
|
|
|
|
|
|
|
this.workStatus = "";
|
|
|
|
|
// 显示蓝牙断开弹窗
|
|
|
|
|
// this.setState({
|
|
|
|
|
// workStatus: "",
|
|
|
|
|
@ -405,8 +411,33 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
};
|
|
|
|
|
// 弹窗确定切换护理模式
|
|
|
|
|
confirmModeSwitchBtn = () => {
|
|
|
|
|
let { SwitchActiveModeItem } = this.state;
|
|
|
|
|
let { SwitchActiveModeItem, ActiveModeItem, isStandStatus } = this.state;
|
|
|
|
|
let modeArray = ["all", "visor", "cabin", "yimeish"];
|
|
|
|
|
// 切换护理模式时,需判断舱体和面罩是否切换
|
|
|
|
|
if (SwitchActiveModeItem.isCabinMode !== ActiveModeItem.isCabinMode) {
|
|
|
|
|
if (SwitchActiveModeItem.isCabinMode === 1) {
|
|
|
|
|
// 判断舱体是否连接成功
|
|
|
|
|
if (!isStandStatus) {
|
|
|
|
|
console.log(
|
|
|
|
|
"检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源"
|
|
|
|
|
);
|
|
|
|
|
this.openErrorTipsText(
|
|
|
|
|
"检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源"
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 判断舱体是否断开连接
|
|
|
|
|
if (isStandStatus) {
|
|
|
|
|
console.log("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体");
|
|
|
|
|
this.openErrorTipsText(
|
|
|
|
|
"检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
ModeType: modeArray[SwitchActiveModeItem.modeClass],
|
|
|
|
|
});
|
|
|
|
|
@ -420,6 +451,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
// //0未定义(全部) 1面罩模式 2舱体模式 3医美术后
|
|
|
|
|
let modeArray = ["all", "visor", "cabin", "yimeish"];
|
|
|
|
|
let modeClass = this.state.ActiveModeItem.modeClass;
|
|
|
|
|
this.workStatus = "pause";
|
|
|
|
|
this.setState({
|
|
|
|
|
ModeType: modeArray[modeClass],
|
|
|
|
|
isShowNurse: true,
|
|
|
|
|
@ -434,9 +466,25 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
};
|
|
|
|
|
/** 开始护理按钮:点击开始,页面进行到下一步 */
|
|
|
|
|
onStartNurse = async () => {
|
|
|
|
|
let { isCanClick } = this.state;
|
|
|
|
|
if (isCanClick) {
|
|
|
|
|
// 开发者工具
|
|
|
|
|
// const platform = Taro.getSystemInfoSync().platform;
|
|
|
|
|
// if (platform === "devtools") {
|
|
|
|
|
// // 仅开发者工具,直接运行
|
|
|
|
|
// this.stepNext();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
let { isStandStatus, ActiveModeItem } = this.state;
|
|
|
|
|
if (isStandStatus && ActiveModeItem.isCabinMode) {
|
|
|
|
|
this.stepNext();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (isStandStatus) {
|
|
|
|
|
console.log("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体");
|
|
|
|
|
this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体");
|
|
|
|
|
} else {
|
|
|
|
|
this.showTips(
|
|
|
|
|
"检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
/** 切换光照 */
|
|
|
|
|
@ -470,44 +518,23 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
case "SendMatchCode":
|
|
|
|
|
if (jsonStatus.matchedSuccess) {
|
|
|
|
|
console.log("设备配对成功");
|
|
|
|
|
this.setState({
|
|
|
|
|
facialMaskConnectStatus: true,
|
|
|
|
|
});
|
|
|
|
|
// log.info(commandMap.WL200Command, "配对成功");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上了
|
|
|
|
|
case "BleStatusSync":
|
|
|
|
|
console.log("BleStatusSync", jsonStatus);
|
|
|
|
|
console.log("BleStatusSync 附属设备状态主动上报", jsonStatus);
|
|
|
|
|
switch (jsonStatus.connectMessage?.deviceName) {
|
|
|
|
|
// 附属设备是否WL200
|
|
|
|
|
// case "WL200":
|
|
|
|
|
// console.log(
|
|
|
|
|
// "BleStatusSync 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上",
|
|
|
|
|
// jsonStatus.connectMessage?.connectType == "CONNECTED"
|
|
|
|
|
// );
|
|
|
|
|
// if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
|
|
|
|
|
// // 已连接WL200
|
|
|
|
|
// this.setState({ isConnectionBlutoot: true });
|
|
|
|
|
|
|
|
|
|
// // 附属设备连接成功,如何区分是哪个设备?
|
|
|
|
|
// this.setState({
|
|
|
|
|
// facialMaskConnectStatus: 1, // 面罩已连接
|
|
|
|
|
// });
|
|
|
|
|
// deviceToolKitInstance = deviceToolKitInstanceWL200;
|
|
|
|
|
// } else {
|
|
|
|
|
// // WL200连接失败
|
|
|
|
|
// // deviceToolKitInstance = deviceToolKitInstanceWE100;
|
|
|
|
|
// // // TODO 护理中(step==2)时, 如果断开, 可能需要暂停
|
|
|
|
|
// console.log("WL200连接失败或断开");
|
|
|
|
|
// this.setState({
|
|
|
|
|
// facialMaskConnectStatus: 0,
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
// 附属设备是否连接支架
|
|
|
|
|
case "Stand":
|
|
|
|
|
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
|
|
|
|
|
this.setState({
|
|
|
|
|
isStandStatus: true,
|
|
|
|
|
isCanClick: this.state.isCabinMode === 1,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
@ -518,22 +545,22 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
//小程序主动问主机,现在链接了哪些附属设备,这时候主机给小程序的回复消息
|
|
|
|
|
case "QueryMatchStatus":
|
|
|
|
|
const isStandDevice =
|
|
|
|
|
jsonStatus?.subDeviceList?.includes("Stand") || false;
|
|
|
|
|
console.log("QueryMatchStatus 设备回复小程序", jsonStatus);
|
|
|
|
|
|
|
|
|
|
const isStandDevice = jsonStatus?.subDeviceList?.includes("Stand");
|
|
|
|
|
deviceToolKitInstance = deviceToolKitInstanceWL200;
|
|
|
|
|
|
|
|
|
|
console.log("支架是否链接", isStandDevice);
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
isStandStatus: isStandDevice,
|
|
|
|
|
isCanClick: this.state.isCabinMode === 1,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 连上面罩后, 获取仪器记录, 与缓存信息对比,
|
|
|
|
|
// 连上面罩后, 获取仪器记录, 与缓存信息对比
|
|
|
|
|
if (!this.hadGotInstrumentHistoryData) {
|
|
|
|
|
// 查询护理记录
|
|
|
|
|
this.getInstrumentHistoryData();
|
|
|
|
|
// 如果不延时, 无法获取到仪器状态
|
|
|
|
|
|
|
|
|
|
// 查询仪器状态
|
|
|
|
|
const queryDeviceArrayBuffer = deviceToolKitInstance.toBleCommand(
|
|
|
|
|
bleCommandSamples.queryDeviceStatus as any
|
|
|
|
|
);
|
|
|
|
|
@ -561,11 +588,11 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
"onBLECharacteristicValueChange jsonStatus => ",
|
|
|
|
|
jsonStatus
|
|
|
|
|
);
|
|
|
|
|
// log.info(commandMap.WL200Command, 'onBLECharacteristicValueChange jsonStatus =>', jsonStatus);
|
|
|
|
|
if (!jsonStatus || jsonStatus == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// end 和 endWork 都是护理结束, endWork不关机, end 关机, 对小程序而已处理流程都一样
|
|
|
|
|
this.workStatus = jsonStatus.workStatus; // 记录工作状态
|
|
|
|
|
// end 和 endWork 都是护理结束, endWork不关机, end 关机, 对小程序而言处理流程都一样
|
|
|
|
|
if (jsonStatus.workStatus && jsonStatus.workStatus == "endWork") {
|
|
|
|
|
jsonStatus.workStatus = "end";
|
|
|
|
|
console.log(jsonStatus.workStatus, "护理结束");
|
|
|
|
|
@ -579,7 +606,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "DeviceControl":
|
|
|
|
|
console.log("小程序控制设备,给设备发送指令", jsonStatus);
|
|
|
|
|
console.log("打印小程序控制设备,给设备发送的指令", jsonStatus);
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// console.log("currentTime", this.state.currentTime);
|
|
|
|
|
// });
|
|
|
|
|
@ -590,11 +617,11 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
"设备主动上报给小程序的指令 一般是工作状态改变",
|
|
|
|
|
jsonStatus
|
|
|
|
|
);
|
|
|
|
|
this.workStatus = jsonStatus.workStatus;
|
|
|
|
|
this.setState({
|
|
|
|
|
Electricity: jsonStatus.battery,
|
|
|
|
|
// fr200Electricity: jsonStatus.battery,
|
|
|
|
|
matrixElectricity: jsonStatus.matrixBattery,
|
|
|
|
|
workStatus: jsonStatus.workStatus,
|
|
|
|
|
workMode: jsonStatus?.workMode,
|
|
|
|
|
});
|
|
|
|
|
// 判断是否在step == 2(护理中)
|
|
|
|
|
@ -665,12 +692,13 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
// totalSeconds: 0
|
|
|
|
|
// workMode: "BrightenStand"
|
|
|
|
|
console.log("当前面罩报告 currentMaskReportInfo", jsonStatus);
|
|
|
|
|
// if (!this.state.hadCheckReport) {
|
|
|
|
|
// this.state.hadCheckReport = true;
|
|
|
|
|
// that.checkInstrumentRecord(jsonStatus);
|
|
|
|
|
// } else {
|
|
|
|
|
// that.setWL200NursingHistory(jsonStatus);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (!this.hadCheckReport) {
|
|
|
|
|
this.hadCheckReport = true;
|
|
|
|
|
this.checkInstrumentRecord(jsonStatus);
|
|
|
|
|
} else {
|
|
|
|
|
this.setWL200NursingHistory(jsonStatus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
@ -711,7 +739,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//待完善,以后同步设备数据到小程序的事件,在这个事件里判断是否需要更新页面(是否需要触发setData)
|
|
|
|
|
/** 同步设备运行信息:运行时间 */
|
|
|
|
|
updateDeviceSyncData = (newData, jsonStatus) => {
|
|
|
|
|
DeviceSyncData = {
|
|
|
|
|
...DeviceSyncData,
|
|
|
|
|
@ -818,7 +846,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
isShowCountdown: false,
|
|
|
|
|
});
|
|
|
|
|
if (nowModeItem?.isCabinMode && step == 2) {
|
|
|
|
|
opts.currentTime = nowModeItem.modeTime;
|
|
|
|
|
opts.currentTime = nowModeItem.modeTimeStr;
|
|
|
|
|
} else if (!nowModeItem?.isCabinMode && step == 2) {
|
|
|
|
|
// fix: 启动非支架模式倒计时时,连上支架,仪器的状态变为standby
|
|
|
|
|
opts.step = 1;
|
|
|
|
|
@ -846,7 +874,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (nowModeItem) {
|
|
|
|
|
opts.currentTime = nowModeItem.modeTime;
|
|
|
|
|
opts.currentTime = nowModeItem.modeTimeStr;
|
|
|
|
|
}
|
|
|
|
|
// startSettingCountDown 用于标记打开了倒计时loading
|
|
|
|
|
if (!this.state.isShowCountdown) {
|
|
|
|
|
@ -879,7 +907,6 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
isShowCountdown: false,
|
|
|
|
|
});
|
|
|
|
|
if (ActiveModeItem.isCabinMode) {
|
|
|
|
|
// this.onPauseTap();
|
|
|
|
|
this.setState({
|
|
|
|
|
title: "暂停护理",
|
|
|
|
|
isStopNurse: true,
|
|
|
|
|
@ -887,10 +914,6 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
end: () => {
|
|
|
|
|
// 仪器返回护理结束, 支架模式不需要了
|
|
|
|
|
// if (modeItem.isCabinMode) {
|
|
|
|
|
// this.onPauseTap();
|
|
|
|
|
// }
|
|
|
|
|
// 已进入了报告阶段, 防止重复进入, 主要防止在手动点击结束护理接收到仪器消息
|
|
|
|
|
console.log("END 护理结束");
|
|
|
|
|
clearInterval(currentTimeTimer);
|
|
|
|
|
@ -920,7 +943,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
if (isAuto == true) {
|
|
|
|
|
// 仪器自动上报完成, 直接上报并跳转报告页
|
|
|
|
|
clearInterval(currentTimeTimer);
|
|
|
|
|
const isEnough = this.checkTime();
|
|
|
|
|
const isEnough = this.checkNurseTime();
|
|
|
|
|
if (isEnough && !this.state.endPlace) {
|
|
|
|
|
this.setState({
|
|
|
|
|
endPlace: "report",
|
|
|
|
|
@ -933,23 +956,6 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
isInTimeScope(start, end, targetMinute, targetSecond) {
|
|
|
|
|
const startTime = dayjs().set("minute", start).set("second", 0);
|
|
|
|
|
const endTime = dayjs().set("minute", end).set("second", 0);
|
|
|
|
|
const targetTime = dayjs()
|
|
|
|
|
.set("minute", targetMinute)
|
|
|
|
|
.set("second", targetSecond); // 要判断的时间,这里使用当前时间作为示例
|
|
|
|
|
let inTime = false;
|
|
|
|
|
if (
|
|
|
|
|
(targetTime.isAfter(startTime) && targetTime.isBefore(endTime)) ||
|
|
|
|
|
targetTime.isSame(startTime) ||
|
|
|
|
|
targetTime.isSame(endTime)
|
|
|
|
|
) {
|
|
|
|
|
inTime = true;
|
|
|
|
|
}
|
|
|
|
|
return inTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重置计时器
|
|
|
|
|
resetTimer = () => {
|
|
|
|
|
// 切换模式后, 需要重新设置计时器, 以防进行中的计时器
|
|
|
|
|
@ -1030,9 +1036,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
this.state;
|
|
|
|
|
let newWorkStatus =
|
|
|
|
|
workStatus ||
|
|
|
|
|
(this.state.workStatus == MODE_WORKING_ENUM.WORKING
|
|
|
|
|
? "pause"
|
|
|
|
|
: "working");
|
|
|
|
|
(this.workStatus == MODE_WORKING_ENUM.WORKING ? "pause" : "working");
|
|
|
|
|
if (isBtnClick && newWorkStatus == "working") {
|
|
|
|
|
// 舱体模式
|
|
|
|
|
if (ActiveModeItem.isCabinMode === 1 && !isStandStatus) {
|
|
|
|
|
@ -1052,7 +1056,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
// // 工作状态,开始组合模式
|
|
|
|
|
// if (
|
|
|
|
|
// this.state.ActiveModeItem.combineData.length &&
|
|
|
|
|
// this.state.workStatus == MODE_WORKING_ENUM.WORKING
|
|
|
|
|
// this.workStatus == MODE_WORKING_ENUM.WORKING
|
|
|
|
|
// ) {
|
|
|
|
|
// this.startCombinationMode();
|
|
|
|
|
// }
|
|
|
|
|
@ -1069,9 +1073,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
sendCommand({
|
|
|
|
|
value: pauseArrayBuffer,
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.setState({
|
|
|
|
|
workStatus: newWorkStatus,
|
|
|
|
|
});
|
|
|
|
|
this.workStatus = newWorkStatus;
|
|
|
|
|
this.resetTimer();
|
|
|
|
|
console.info(
|
|
|
|
|
`handleWorkStatus 发送${newWorkStatus}指令成功 参数为 =>`,
|
|
|
|
|
@ -1159,7 +1161,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
this.PostNursingLogClock();
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// //TODO IOS关闭蓝牙太快导致关机指令没发出去,暂时这么解决
|
|
|
|
|
// const isEnough = this.checkTime();
|
|
|
|
|
// const isEnough = this.checkNurseTime();
|
|
|
|
|
// if (!isEnough) {
|
|
|
|
|
// Taro.showModal({
|
|
|
|
|
// title: "提示",
|
|
|
|
|
@ -1185,8 +1187,8 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
// }, 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查时间是否达标
|
|
|
|
|
checkTime() {
|
|
|
|
|
/** 检查时间是否达标仪器最低护理时间 */
|
|
|
|
|
checkNurseTime() {
|
|
|
|
|
const { currentDevice, ActiveModeItem } = this.state;
|
|
|
|
|
const currentScene = ActiveModeItem;
|
|
|
|
|
let sceneTime = minSecToS(currentScene.modeTimeStr);
|
|
|
|
|
@ -1201,10 +1203,27 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** 检查时间是否达标仪器最低护理时间 */
|
|
|
|
|
isCheckNurseTime(deviceItem, ModeItem) {
|
|
|
|
|
const currentScene = ModeItem;
|
|
|
|
|
let sceneTime = minSecToS(currentScene.modeTimeStr);
|
|
|
|
|
const timeRemaining = sceneTime - minSecToS(this.state.currentTime); // 当前模式已运行时间
|
|
|
|
|
|
|
|
|
|
let nursingTimeStr = deviceItem?.nursingTimeStr;
|
|
|
|
|
let nursingTime = nursingTimeStr ? minSecToS(nursingTimeStr) : 60; // 设备生成护理记录至少需要运行时间
|
|
|
|
|
|
|
|
|
|
if (timeRemaining >= nursingTime) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*** 护理记录 START ***/
|
|
|
|
|
/** 小程序查询护理记录 */
|
|
|
|
|
getInstrumentHistoryData() {
|
|
|
|
|
this.hadGotInstrumentHistoryData = true;
|
|
|
|
|
console.log("发送获取currentMaskReportInfo指令");
|
|
|
|
|
console.log("发送指令currentMaskReportInfo 获取设备护理记录");
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
const queryCurrentMaskReportInfoBuffer =
|
|
|
|
|
deviceToolKitInstance.toBleCommand({
|
|
|
|
|
@ -1215,9 +1234,149 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
});
|
|
|
|
|
}, 3000);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @title 检查护理记录
|
|
|
|
|
* @description
|
|
|
|
|
* 1.判断是否存在工作状态:如果不存在,则等待两秒用于连接设备与赋值,再执行后面的代码
|
|
|
|
|
*
|
|
|
|
|
* 2.判断是否已存在缓存的护理记录:如果没有历史,则缓存
|
|
|
|
|
*
|
|
|
|
|
* 3.判断是否当天(如果不是当天,则删除记录)
|
|
|
|
|
*
|
|
|
|
|
* 4.判断设备状态-未运行/已完成/待机
|
|
|
|
|
* 4-1.已有缓存护理记录,判断ID一致,同步时间。若主动结束,需判断时间是否满足仪器最低护理时间,满足直接跳转护理报告页;不满足需提示不满足,回到首页
|
|
|
|
|
* 4-2.已有缓存护理记录,判断ID不一致(同步异常)。直接提交,固定设置为一分钟。
|
|
|
|
|
*
|
|
|
|
|
* 5.判断设备状态-运行中
|
|
|
|
|
* 正常执行逻辑
|
|
|
|
|
*
|
|
|
|
|
* */
|
|
|
|
|
checkInstrumentRecord = async (jsonStatus: any) => {
|
|
|
|
|
let { currentDevice, ActiveModeItem, ModeList } = this.state;
|
|
|
|
|
if (jsonStatus) {
|
|
|
|
|
}
|
|
|
|
|
// 1.判断是否存在工作状态:如果不存在,则等待两秒用于连接设备与赋值,再执行后面的代码
|
|
|
|
|
if (!this.workStatus) {
|
|
|
|
|
await sleep(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2.判断是否已存在缓存的护理记录:如果没有历史,则缓存
|
|
|
|
|
let workStatus = this.workStatus;
|
|
|
|
|
let WL200NursingHistory = this.WL200NursingHistory;
|
|
|
|
|
if (!this.WL200NursingHistory) {
|
|
|
|
|
console.log("小程序缓存没有数据, 忽略");
|
|
|
|
|
if (
|
|
|
|
|
workStatus == MODE_WORKING_ENUM.WORKING ||
|
|
|
|
|
workStatus == MODE_WORKING_ENUM.PAUSE
|
|
|
|
|
) {
|
|
|
|
|
// 缓存没有数据, 要存缓存
|
|
|
|
|
this.setWL200NursingHistory(jsonStatus);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3.判断是否当天(如果不是当天,则删除记录)
|
|
|
|
|
if (!dayjs().isSame(WL200NursingHistory?.createDate, "day")) {
|
|
|
|
|
console.log("小程序缓存有数据,但是不是当天数据,忽略");
|
|
|
|
|
this.rmWL200NursingHistory(WL200NursingHistory);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 仪器缓存模式,判断是否存在于现有模式中
|
|
|
|
|
let recordModeItem = ModeList.find((item) => {
|
|
|
|
|
return item.id == WL200NursingHistory.id;
|
|
|
|
|
});
|
|
|
|
|
if (!WL200NursingHistory || !recordModeItem) {
|
|
|
|
|
console.log("仪器有数据, 但是缓存没有数据, 忽略");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let sceneTime = minSecToS(ActiveModeItem.modeTimeStr);
|
|
|
|
|
// 4.判断设备状态-未运行/已完成/待机
|
|
|
|
|
if (
|
|
|
|
|
workStatus == MODE_WORKING_ENUM.STANDBY ||
|
|
|
|
|
workStatus == MODE_WORKING_ENUM.END ||
|
|
|
|
|
!workStatus
|
|
|
|
|
) {
|
|
|
|
|
// 判断id是否一致, 一致的话则生成护理报表
|
|
|
|
|
if (jsonStatus.id == WL200NursingHistory.id) {
|
|
|
|
|
console.log("id一致, 设备没有运行/已完成/待机");
|
|
|
|
|
let totalSeconds = jsonStatus.totalSeconds; // 从仪器上获取的使用时间
|
|
|
|
|
let neededTotalSeconds = jsonStatus.neededTotalSeconds; // 从仪器上获取的使用时间
|
|
|
|
|
console.log(
|
|
|
|
|
"从仪器上获取的使用时间 neededTotalSeconds",
|
|
|
|
|
neededTotalSeconds
|
|
|
|
|
);
|
|
|
|
|
let nursingTimeStr = currentDevice?.nursingTimeStr;
|
|
|
|
|
let nursingTime = nursingTimeStr ? minSecToS(nursingTimeStr) : 60; // 设备生成护理记录至少需要运行时间
|
|
|
|
|
|
|
|
|
|
if (totalSeconds < nursingTime) {
|
|
|
|
|
console.log("护理时间不足,弹出提示");
|
|
|
|
|
// todo
|
|
|
|
|
this.rmWL200NursingHistory(WL200NursingHistory);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 删除WL200护理历史
|
|
|
|
|
rmWL200NursingHistory(WL200NursingHistory, hard = false) {}
|
|
|
|
|
let params = {
|
|
|
|
|
instrumentId: currentDevice.id,
|
|
|
|
|
instrumentName: currentDevice.name,
|
|
|
|
|
modeId: ActiveModeItem.id,
|
|
|
|
|
modeName: ActiveModeItem.modeName,
|
|
|
|
|
nursingTime: ActiveModeItem.modeTimeStr,
|
|
|
|
|
};
|
|
|
|
|
let res: any = await this.PostNursingLogClock(params);
|
|
|
|
|
console.log("res", res);
|
|
|
|
|
this.rmWL200NursingHistory(WL200NursingHistory);
|
|
|
|
|
} else {
|
|
|
|
|
// ID不一致,同步异常,统一提交一分钟
|
|
|
|
|
let params = {
|
|
|
|
|
instrumentId: currentDevice.id,
|
|
|
|
|
instrumentName: currentDevice.name,
|
|
|
|
|
modeId: ActiveModeItem.id,
|
|
|
|
|
modeName: ActiveModeItem.modeName,
|
|
|
|
|
nursingTime: "01:00",
|
|
|
|
|
};
|
|
|
|
|
let res: any = await this.PostNursingLogClock(params);
|
|
|
|
|
console.log("res", res);
|
|
|
|
|
this.rmWL200NursingHistory(WL200NursingHistory);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 5.判断设备状态-运行中 正常逻辑,这里不做处理,如果用户操作,则按正常流程判断
|
|
|
|
|
console.log("同步异常,但设备运行中");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
/** 设置WL200护理历史 */
|
|
|
|
|
setWL200NursingHistory = (jsonStatus: any) => {};
|
|
|
|
|
/** 删除WL200护理历史 */
|
|
|
|
|
rmWL200NursingHistory = (WL200NursingHistory, hard = false) => {
|
|
|
|
|
const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
|
|
|
|
|
if (nowWL200NursingHistory.id == WL200NursingHistory.id) {
|
|
|
|
|
Taro.removeStorageSync("WL200NursingHistory");
|
|
|
|
|
} else if (hard) {
|
|
|
|
|
Taro.removeStorageSync("WL200NursingHistory");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 提交护理记录 */
|
|
|
|
|
PostNursingLogClock = async (data: any) => {
|
|
|
|
|
let { currentDevice, ActiveModeItem } = this.state;
|
|
|
|
|
let params = {};
|
|
|
|
|
if (data) {
|
|
|
|
|
params = data;
|
|
|
|
|
} else {
|
|
|
|
|
params = {
|
|
|
|
|
instrumentId: currentDevice.id,
|
|
|
|
|
instrumentName: currentDevice.name,
|
|
|
|
|
modeId: ActiveModeItem.id,
|
|
|
|
|
modeName: ActiveModeItem.modeName,
|
|
|
|
|
nursingTime: ActiveModeItem.modeTimeStr,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let res: any = await InstrumentInfo.apiNursingLog.addLog(params);
|
|
|
|
|
console.log("PostNursingLogClock", res);
|
|
|
|
|
};
|
|
|
|
|
/*** 护理记录 END ***/
|
|
|
|
|
|
|
|
|
|
//蓝牙断开连接处理
|
|
|
|
|
bluetoothDisconnectProcessing() {
|
|
|
|
|
@ -1231,14 +1390,14 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取护理时间组合
|
|
|
|
|
/** 获取护理时间组合 */
|
|
|
|
|
getServiceTimeData() {
|
|
|
|
|
const { ActiveModeItem } = this.state;
|
|
|
|
|
let serviceData = ActiveModeItem.serviceData.map((item) => {
|
|
|
|
|
// let totalWorkingMinutes = parseInt(item.modeTimeStr.split(":")[0]); // 仅分钟数
|
|
|
|
|
// let totalWorkingSeconds = parseInt(item.modeTimeStr.split(":")[1]); // 仅秒数
|
|
|
|
|
let totalWorkingMinutes = 1; // 仅分钟数
|
|
|
|
|
let totalWorkingSeconds = 0; // 仅秒数
|
|
|
|
|
let totalWorkingMinutes = parseInt(item.modeTimeStr.split(":")[0]); // 仅分钟数
|
|
|
|
|
let totalWorkingSeconds = parseInt(item.modeTimeStr.split(":")[1]); // 仅秒数
|
|
|
|
|
// let totalWorkingMinutes = 1; // 仅分钟数
|
|
|
|
|
// let totalWorkingSeconds = 0; // 仅秒数
|
|
|
|
|
return {
|
|
|
|
|
totalWorkingMinutes,
|
|
|
|
|
totalWorkingSeconds,
|
|
|
|
|
@ -1246,7 +1405,7 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
});
|
|
|
|
|
return serviceData;
|
|
|
|
|
}
|
|
|
|
|
// 设置护理时间组合
|
|
|
|
|
/** 设置护理时间组合 */
|
|
|
|
|
setServiceTimeData() {
|
|
|
|
|
let ServiceTimeData = this.getServiceTimeData();
|
|
|
|
|
|
|
|
|
|
@ -1280,17 +1439,9 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
});
|
|
|
|
|
console.log("组合时间ModeStepTimeArray", ModeStepTimeArray);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 组合模式 */
|
|
|
|
|
// 获取自定义组合模式原数组
|
|
|
|
|
getOriginModesArray = () => {
|
|
|
|
|
const { ModeList, ActiveModeItem } = this.state;
|
|
|
|
|
const combineIds = ActiveModeItem.combineData.map(
|
|
|
|
|
(item) => item.combineModeId
|
|
|
|
|
);
|
|
|
|
|
let modesArray = ModeList.filter((item) => combineIds.includes(item.id));
|
|
|
|
|
return modesArray;
|
|
|
|
|
};
|
|
|
|
|
// 获取自定义组合模式数组
|
|
|
|
|
/** 获取自定义组合模式数组 */
|
|
|
|
|
getCustomModesArray = () => {
|
|
|
|
|
const { ModeList, ActiveModeItem } = this.state;
|
|
|
|
|
const combineIds = ActiveModeItem.combineData.map(
|
|
|
|
|
@ -1378,21 +1529,19 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
};
|
|
|
|
|
/** 弹窗 END*/
|
|
|
|
|
|
|
|
|
|
/** 护理记录 */
|
|
|
|
|
// apiClock
|
|
|
|
|
PostNursingLogClock = async () => {
|
|
|
|
|
let { currentDevice, ActiveModeItem } = this.state;
|
|
|
|
|
let params = {
|
|
|
|
|
instrumentId: currentDevice.id,
|
|
|
|
|
instrumentName: currentDevice.name,
|
|
|
|
|
modeId: ActiveModeItem.id,
|
|
|
|
|
modeName: ActiveModeItem.modeName,
|
|
|
|
|
nursingTime: ActiveModeItem.modeTime,
|
|
|
|
|
};
|
|
|
|
|
let res: any = await InstrumentInfo.apiNursingLog.addLog(params);
|
|
|
|
|
console.log("PostNursingLogClock", res);
|
|
|
|
|
// 打开通用错误弹窗
|
|
|
|
|
openErrorTipsText = (str) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
isShowErrorTipsText: true,
|
|
|
|
|
errorTipsText: str,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
// 关闭通用错误弹窗
|
|
|
|
|
closeErrorTipsText = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
isShowErrorTipsText: false,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
/** 护理记录 End */
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
let {
|
|
|
|
|
@ -1421,6 +1570,8 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
isEndCarePlan,
|
|
|
|
|
currentTime,
|
|
|
|
|
facialMaskConnectStatus,
|
|
|
|
|
isShowErrorTipsText,
|
|
|
|
|
errorTipsText,
|
|
|
|
|
} = this.state;
|
|
|
|
|
return (
|
|
|
|
|
<Block>
|
|
|
|
|
@ -1476,6 +1627,19 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
close={this.closeStepTips}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<PopupAlert
|
|
|
|
|
isShow={isShowErrorTipsText}
|
|
|
|
|
isClose
|
|
|
|
|
zIndex={10020}
|
|
|
|
|
myClassName="level-up"
|
|
|
|
|
title="提示"
|
|
|
|
|
content={errorTipsText}
|
|
|
|
|
confirmButtonText="知道了"
|
|
|
|
|
textAlgin="center"
|
|
|
|
|
close={this.closeErrorTipsText}
|
|
|
|
|
confirm={this.closeErrorTipsText}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<View>
|
|
|
|
|
|