1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279 |
- #pragma once
- #include "uart/ProtocolSender.h"
- #include "net/NetManager.h"
- #include "storage/StoragePreferences.h"
- #include "net/net.h"
- #include <system/Thread.h>
- #include "restclient-cpp/restclient.h"
- #include "curl/curl.h"
- #include <algorithm>
- #include "service/BusinessConfig.h"
- #include "core/sip_config.h"
- #include "manager/LanguageManager.h"
- #include "core/utilities.h"
- #include <string>
- #include <regex>
- #include "zkaudio.h"
- #include "base/strings.hpp"
- #include "base/http_client.h"
- #include "os/UpgradeMonitor.h"
- #include "core/update_assistant.h"
- #include "utils/TimeHelper.h"
- #include "utils/StringHelper.h"
- #define ETHERNETMANAGER NETMANAGER->getEthernetManager()
- #define WIFIMANAGER NETMANAGER->getWifiManager()
- /*
- *此文件由GUI工具生成
- *文件功能:用于处理用户的逻辑相应代码
- *功能说明:
- *========================onButtonClick_XXXX
- 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[ID值]名称,
- 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
- *========================onSlideWindowItemClick_XXXX(int index)
- 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
- 如slideWindow1;index 代表按下图标的偏移值
- *========================onSeekBarChange_XXXX(int progress)
- 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
- 如SeekBar1;progress 代表当前的进度值
- *========================ogetListItemCount_XXXX()
- 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[ID值]名称,
- 如List1;返回值为当前列表的总条数
- *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
- 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[ID值]名称,
- 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
- *========================常用接口===============
- *LOGD(...) 打印调试信息的接口
- *mTextXXXPtr->setText("****") 在控件TextXXX上显示文字****
- *mButton1Ptr->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
- *mSeekBarPtr->setProgress(12) 在控件mSeekBar上将进度调整到12
- *mListView1Ptr->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
- *mDashbroadView1Ptr->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
- *
- * 在Eclipse编辑器中 使用 “alt + /” 快捷键可以打开智能提示
- */
- static bool dataInit = false; // false表示需要从数据库里获取数据,true表示从缓存里获取数据
- PartSetting partSetting;
- Json::Value frameRoom;
- Json::Value frameBedList;
- Json::Value frameInfo; // 缓存房间名字等
- Json::Value rightTitleInfo; // 缓存分机右边医生和护士标题
- Json::Value painterInfo;
- Json::Value painterInfoList;
- static bool serverInfo = true; // 判断是否需要从服务器获取服务器信息,第一次要,后续不要
- static int inBedCount = 0;
- static int emptyBedCount = 0;
- static int mainThemeInt = StoragePreferences::getInt(STORE_THEME, defaultThemeInt);
- static int mainModeInt = StoragePreferences::getInt(STORE_MODE, defaultModeInt);
- static string handle1Mac = StoragePreferences::getString(STORE_MAC_ADDR, std::string(ETHERNETMANAGER->getMacAddr())) + ":h1";
- static string handle2Mac = StoragePreferences::getString(STORE_MAC_ADDR, std::string(ETHERNETMANAGER->getMacAddr())) + ":h2";
- static string handle3Mac = StoragePreferences::getString(STORE_MAC_ADDR, std::string(ETHERNETMANAGER->getMacAddr())) + ":h3";
- static string handle4Mac = StoragePreferences::getString(STORE_MAC_ADDR, std::string(ETHERNETMANAGER->getMacAddr())) + ":h4";
- static string handle5Mac = StoragePreferences::getString(STORE_MAC_ADDR, std::string(ETHERNETMANAGER->getMacAddr())) + ":h5";
- static string handle6Mac = StoragePreferences::getString(STORE_MAC_ADDR, std::string(ETHERNETMANAGER->getMacAddr())) + ":h6";
- static int handle1Id = 0;
- static int handle2Id = 0;
- static int handle3Id = 0;
- static int handle4Id = 0;
- static int handle5Id = 0;
- static int handle6Id = 0;
- #define HELP_TIMER_HANDLE 3 // 增援的定时器id
- #define EVENT_TIME_HANDLE 8 // 事件定时器
- #define SLEEP_STRAT_TIME_HANDLE 9 // 息屏
- void setMainTheme() {
- LOGD("mainThemeInt =====> %d", mainThemeInt);
- if (mainThemeInt == 1) {
- mRoomPainterPtr->setBackgroundPic("/main/fang-bg.png");
- mRoomPrcPainterPtr->setBackgroundPic("/main/fang.png");
- mInBedNumTextViewPtr->setTextColor(buleDeepColour);
- mInBedPicPainterPtr->setBackgroundPic("/main/chuang-l.png");
- }
- else if (mainThemeInt == 2) {
- mRoomPainterPtr->setBackgroundPic("/main/fang-bg-pink.png");
- mRoomPrcPainterPtr->setBackgroundPic("/main/fang-pink.png");
- mInBedNumTextViewPtr->setTextColor(redDeepColour);
- mInBedPicPainterPtr->setBackgroundPic("/main/chuang-l-pink.png");
- }
- }
- void setMainMode() {
- if (mainModeInt == 3) {
- mDirectorPainterPtr->setVisible(true);
- mDirectLinePainterPtr->setVisible(true);
- mDirectorTitleTextViewPtr->setVisible(true);
- mDirectorTextViewPtr->setVisible(true);
- mNurseHeadPainterPtr->setVisible(true);
- mNurseHeadLinePainterPtr->setVisible(true);
- mNurseTitleTextViewPtr->setVisible(true);
- mNurseHeadTextViewPtr->setVisible(true);
- }
- }
- int getHandleId(int id) {
- if (id == 1) {
- return handle1Id;
- }
- else if (id == 2) {
- return handle2Id;
- }
- else if (id == 3) {
- return handle3Id;
- }
- else if (id == 4) {
- return handle4Id;
- }
- else if (id == 5) {
- return handle5Id;
- }
- else if (id == 6) {
- return handle6Id;
- }
- return 0;
- }
- bool isHandleId(int id) {
- if (id == handle1Id || id == handle2Id || id == handle3Id || id == handle4Id || id == handle5Id || id == handle6Id) {
- return true;
- }
- return false;
- }
- static net::Conn* udpConn;
- class UdpThread: public Thread {
- public:
- static void getServerInfo(){
- string url = getHttpGateway() + "/ncs_url/server_info";
- LOGD("请求服务器信息. url = %s", url.c_str());
- //发起HTTP GET请求
- RestClient::Response r = RestClient::get(url);
- //解析json
- Json::Reader reader;
- Json::Value root;
- if (reader.parse(r.body, root, false)){
- // http
- StoragePreferences::putString(STORE_GATEWAY, root["http_local_ip"].asString());
- StoragePreferences::putInt(STORE_HTTP_PORT, root["http_port"].asInt());
- // tcp
- StoragePreferences::putString(STORE_TCP_LOCAL_IP, root["tcp_local_ip"].asString());
- StoragePreferences::putInt(STORE_TCP_PORT, root["tcp_port"].asInt());
- // sip
- StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());
- StoragePreferences::putInt(SIP_REG_PORT, root["sip_port"].asInt());
- serverInfo = false; // 只有请求成功了,才不需要重复请求
- }
- }
- static void getDeviceInfo(){
- if (dataInit){
- getFrameInfo();
- getBedCount();
- setDirectorAndHeadNurse();
- return;
- }
- if (!isConnectServer()) {
- return;
- }
- string url = getHttpGateway() + "/deviceRoom/get_device_by_eth_mac/" + StoragePreferences::getString(STORE_MAC_ADDR, std::string(ETHERNETMANAGER->getMacAddr()));
- LOGD("请求设备信息. url = %s", url.c_str());
- //发起HTTP GET请求
- RestClient::Response r = RestClient::get(url);
- LOGD("获得设备信息. result = %s", r.body.c_str());
- //解析json
- Json::Reader reader;
- Json::Value root;
- if (reader.parse(r.body, root, false)){
- string partName = root["part_display"].asString();
- StoragePreferences::putString(STORE_PARTNAME,partName);
- NavibarSetPartName(partName);
- //设备
- StoragePreferences::putInt(STORE_DEVICE_ID, root["id"].asInt());
- StoragePreferences::putInt(STORE_DEVICE_TYPE, root["device_type"].asInt());
- //SIP存储
- // StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString()); // 应该去找配置文件里的sip-ip
- StoragePreferences::putString(SIP_REG_ACCOUNT,root["sip_id"].asString());
- StoragePreferences::putString(SIP_REG_PASSWORD, root["sip_password"].asString());
- frameInfo["frame_id"] = root["frame_id"].asInt();
- frameInfo["full_name"] = root["full_name"].asString();
- frameInfo["part_id"] = root["part_id"].asInt();
- getFrameInfo();
- //获取科室设置
- string partId = root["part_id"].asString();
- StoragePreferences::putString(STORE_PARTID, partId);
- getPartSetting(partId);
- getVersion();
- getNfcInteraction();
- }
- }
- // 读取空间缓存的数据
- static void getFrameInfo() {
- mRoomNameTextViewPtr->setText(frameInfo["full_name"].asString());
- }
- static void getFrameRoom(int frame_id) {
- string url = getHttpGateway() + "/deviceRoom/get_frame_room/" + to_string(frame_id);
- LOGD("请求房间信息. url = %s", url.c_str());
- //发起HTTP GET请求
- RestClient::Response r = RestClient::get(url);
- LOGD("获得房间信息. result = %s", r.body.c_str());
- //解析json
- Json::Reader reader;
- Json::Value root;
- if (reader.parse(r.body, root, false)){
- frameRoom = root;
- frameBedList = root["frame_bed_list"];
- inBedCount = 0;
- emptyBedCount = 0;
- if (frameBedList.size() > 0) {
- for (int i = 0; i < frameBedList.size(); i++) {
- string customerId = frameBedList[i]["customer_id"].asString();
- if (customerId != "") {
- inBedCount += 1;
- }
- string bedDeviceMac = frameBedList[i]["bed_device_mac"].asString();
- StringHelper::toLowerCase(bedDeviceMac);
- if (bedDeviceMac == handle1Mac) {
- handle1Id = frameBedList[i]["bed_device_id"].asInt();
- }
- else if (bedDeviceMac == handle2Mac) {
- handle2Id = frameBedList[i]["bed_device_id"].asInt();
- }
- else if (bedDeviceMac == handle3Mac) {
- handle3Id = frameBedList[i]["bed_device_id"].asInt();
- }
- else if (bedDeviceMac == handle4Mac) {
- handle4Id = frameBedList[i]["bed_device_id"].asInt();
- }
- else if (bedDeviceMac == handle5Mac) {
- handle5Id = frameBedList[i]["bed_device_id"].asInt();
- }
- else if (bedDeviceMac == handle6Mac) {
- handle6Id = frameBedList[i]["bed_device_id"].asInt();
- }
- }
- emptyBedCount = frameBedList.size() - inBedCount;
- getBedCount();
- }
- if (mBedListViewPtr != NULL) {
- if (mainModeInt == 1) {
- mBedListViewPtr->refreshListView();
- }
- else if (mainModeInt == 2) {
- if (frameBedList.size() <= 3) {
- mBedListViewPtr->refreshListView();
- mBedListViewPtr->setVisible(true);
- mBedListView2Ptr->setVisible(false);
- mBedListView3Ptr->setVisible(false);
- }
- else if (frameBedList.size() > 3 && frameBedList.size() <= 6) {
- mBedListView2Ptr->refreshListView();
- mBedListViewPtr->setVisible(false);
- mBedListView2Ptr->setVisible(true);
- mBedListView3Ptr->setVisible(false);
- }
- else {
- mBedListView3Ptr->refreshListView();
- mBedListViewPtr->setVisible(false);
- mBedListView2Ptr->setVisible(false);
- mBedListView3Ptr->setVisible(true);
- }
- }
- else if (mainModeInt == 3) {
- mBedListView4Ptr->refreshListView();
- mBedListViewPtr->setVisible(false);
- mBedListView4Ptr->setVisible(true);
- }
- }
- }
- }
- static void getBedCount() {
- if (mActivityPtr == NULL) {
- return;
- }
- mInBedNumTextViewPtr->setText(inBedCount);
- mEmptyBedNumTextViewPtr->setText(emptyBedCount);
- }
- // 将医生和护士别称缓存起来
- static void setRightTitle(Json::Value partSetting) {
- rightTitleInfo["doctor_title"] = partSetting["doctor_title"].asString();
- rightTitleInfo["doctor_valid"] = partSetting["doctor_valid"].asInt();
- rightTitleInfo["nurse_title"] = partSetting["nurse_title"].asString();
- rightTitleInfo["nurse_valid"] = partSetting["nurse_valid"].asInt();
- }
- static void setDirectorAndHeadNurse() {
- mDirectorTextViewPtr->setText(partSetting.partDirector);
- mNurseHeadTextViewPtr->setText(partSetting.partNurseHead);
- }
- static void getPartSetting(string partId){
- string url = getHttpGateway() + "/deviceBed/getPartSetting/" + partId;
- LOGD("请求科室信息. url = %s", url.c_str());
- //发起HTTP GET请求
- RestClient::Response r = RestClient::get(url);
- LOGD("获得科室信息. result = %s", r.body.c_str());
- //解析json
- Json::Reader reader;
- Json::Value root;
- if (reader.parse(r.body, root, false)){
- partSetting.partId = root["part_id"].asInt();
- partSetting.dayStart = root["day_start"].asString();
- partSetting.dayLight = root["day_light"].asInt();
- partSetting.dayVol = root["day_vol"].asInt();
- partSetting.dayRingVol = root["day_ring_vol"].asInt();
- partSetting.dayRingTimes = root["day_ring_times"].asInt();
- partSetting.dayNurseLed = root["day_nurse_led"].asInt();
- partSetting.dayDoorVol = root["day_door_vol"].asInt();
- partSetting.dayBedVol = root["day_bed_vol"].asInt();
- partSetting.dayTransferBoxVol = root["day_transfer_box_vol"].asInt();
- partSetting.dayTransferBoxSystemVol = root["day_transfer_box_system_vol"].asInt();
- partSetting.nightStart = root["night_start"].asString();
- partSetting.nightLight = root["night_light"].asInt();
- partSetting.nightVol = root["night_vol"].asInt();
- partSetting.nightRingVol = root["night_ring_vol"].asInt();
- partSetting.nightRingTimes = root["night_ring_times"].asInt();
- partSetting.nightNurseLed = root["night_nurse_led"].asInt();
- partSetting.nightDoorVol = root["night_door_vol"].asInt();
- partSetting.nightBedVol = root["night_bed_vol"].asInt();
- partSetting.nightTransferBoxVol = root["night_transfer_box_vol"].asInt();
- partSetting.nightTransferBoxSystemVol = root["night_transfer_box_system_vol"].asInt();
- partSetting.sleepSecondsNurse = root["sleep_seconds_nurse"].asInt();
- partSetting.sleepSecondsDoor = root["sleep_seconds_door"].asInt();
- partSetting.sleepSecondsBed = root["sleep_seconds_bed"].asInt();
- partSetting.sipOvertime = root["sip_overtime"].asInt();
- partSetting.transferDuration = root["transfer_duration"].asInt();
- partSetting.transferDurationLeader = root["transfer_duration_leader"].asInt();
- partSetting.communicationModeBed = root["communication_mode_bed"].asInt();
- partSetting.communicationModeNurse = root["communication_mode_nurse"].asInt();
- partSetting.communicationModeMobile = root["communication_model_mobile"].asInt();
- partSetting.customizeRoleCallFirst = root["customize_role_call_first"].asInt();
- partSetting.customizeRoleCallSecond = root["customize_role_call_second"].asInt();
- partSetting.customizeRoleCallThird = root["customize_role_call_third"].asInt();
- partSetting.customizeRoleCallFourth = root["customize_role_call_fourth"].asInt();
- partSetting.customizeRoleCallFifth = root["customize_role_call_fifth"].asInt();
- partSetting.customizeHospitalCallFirst = root["customize_hospital_call_first"].asInt();
- partSetting.customizeHospitalCallFirstName = root["customize_hospital_call_first_name"].asString();
- partSetting.customizeHospitalCallSecond = root["customize_hospital_call_second"].asInt();
- partSetting.customizeHospitalCallSecondName = root["customize_hospital_second_name"].asString();
- partSetting.customizeHospitalCallThird = root["customize_hospital_call_third"].asInt();
- partSetting.customizeHospitalCallThirdName = root["customize_hospital_call_third_name"].asString();
- partSetting.doctorTitle = root["doctor_title"].asString();
- partSetting.doctorValid = root["doctor_valid"].asInt();
- partSetting.nurseTitle = root["nurse_title"].asString();
- partSetting.nurseValid = root["nurse_valid"].asInt();
- partSetting.doorNurseTitle = root["door_nurse_title"].asString();
- partSetting.doorNurseValid = root["door_nurse_valid"].asInt();
- partSetting.doorNursingTitle = root["door_nursing_title"].asString();
- partSetting.doorNursingValid = root["door_nursing_valid"].asInt();
- partSetting.partDirector = root["part_director"].asString();
- partSetting.partNurseHead = root["part_nurse_head"].asString();
- partSetting.upSeconds = root["up_seconds"].asInt();
- partSetting.autoAccept = root["auto_accept"].asInt();
- partSetting.eventForward = root["event_forward"].asInt();
- partSetting.nursingColorRgb = root["nursing_color_rgb"].asString();
- partSetting.twoColorDoorLightValid = root["two_color_door_light_valid"].asInt();
- partSetting.qrUrl = root["qr_url"].asString();
- partSetting.screenLight = root["screen_light"].asInt();
- partSetting.roomCallBed = root["room_call_bed"].asInt();
- partSetting.autoPosition = root["auto_position"].asInt();
- partSetting.customerAgeHiddenOnDoor = root["customer_age_hidden_on_door"].asInt();
- if (root.isMember("linux_bed_volume_native")) {
- partSetting.linuxDoorVolumeNative = root["linux_door_volume_native"].asInt();
- partSetting.linuxDoorGainSize = root["linux_door_gain_size"].asInt();
- zk_audio_input_set_volume_native(0, 0);
- zk_audio_input_set_volume_native(1, partSetting.linuxDoorVolumeNative);
- GetTelephone()->SetInputPcmGainSize(partSetting.linuxDoorGainSize);
- StoragePreferences::putInt(STORE_VOLUME_NATIVE, partSetting.linuxDoorVolumeNative);
- StoragePreferences::putInt(STORE_GAIN_SIZE, partSetting.linuxDoorGainSize);
- }
- if (root.isMember("device_button_function")) {
- clearDeviceButtonFunction();
- string deviceButtonFunctionStr = root["device_button_function"].asString();
- if (deviceButtonFunctionStr != "") {
- deviceButtonFunctionStr = std::regex_replace(deviceButtonFunctionStr, std::regex(">"), ">");
- deviceButtonFunctionStr = std::regex_replace(deviceButtonFunctionStr, std::regex("<"), "<");
- partSetting.deviceButtonFunction = deviceButtonFunctionStr;
- setDeviceButtonFunction(deviceButtonFunctionStr);
- }
- }
- StoragePreferences::putString(STORE_DAY_START, partSetting.dayStart);
- StoragePreferences::putInt(STORE_DAY_LIGHT,partSetting.dayLight);
- StoragePreferences::putInt(STORE_DAY_VOL,partSetting.dayDoorVol);
- StoragePreferences::putInt(STORE_DAY_RING_TIMES,partSetting.dayRingTimes);
- StoragePreferences::putString(STORE_NIGHT_START, partSetting.nightStart);
- StoragePreferences::putInt(STORE_NIGHT_LIGHT,partSetting.nightLight);
- StoragePreferences::putInt(STORE_NIGHT_VOL,partSetting.nightDoorVol);
- StoragePreferences::putInt(STORE_NIGHT_RING_TIMES,partSetting.nightRingTimes);
- StoragePreferences::putInt(STORE_SLEEP_TIME, partSetting.sleepSecondsDoor);
- StoragePreferences::putString(STORE_DOCTOR_TITLE, partSetting.doctorTitle);
- StoragePreferences::putBool(STORE_DOCTOR_VISIBLE, partSetting.doctorValid==1);
- StoragePreferences::putString(STORE_NURSE_TITLE, partSetting.nurseTitle);
- StoragePreferences::putBool(STORE_NURSE_VISIBLE, partSetting.nurseValid==1);
- StoragePreferences::putString(STORE_NURSING_COLOR_RGB, partSetting.nursingColorRgb);
- StoragePreferences::putBool(STORE_AUDO_ANSWER, partSetting.autoAccept==1);
- StoragePreferences::putInt(STORE_SCREEN_LIGHT, partSetting.screenLight);
- StoragePreferences::putInt(STORE_ROOM_CALL_BED, partSetting.roomCallBed);
- StoragePreferences::putInt(STORE_AUTO_POSITION, partSetting.autoPosition);
- setRightTitle(root);
- // callBedButtonSetVisible();
- setDirectorAndHeadNurse();
- getFrameRoom(frameInfo["frame_id"].asInt());
- dataInit = true;
- }
- }
- static void getVersion() {
- std::string url = getHttpGateway() + "/deviceRoom/get_app_version?device_type=303&part_id=" + StoragePreferences::getString(STORE_PARTID, "");
- std::string content_type = std::string("application/json");
- LOGD("请求版本信息. url = %s", url.c_str());
- //发起HTTP POST请求
- RestClient::Response r = RestClient::post(url, content_type, "");
- if (r.code != 200) {
- LOGD("请求版本信息-> 错误代码: %d", r.code);
- return;
- }
- LOGD("获得版本信息. result = %s", r.body.c_str());
- //解析json
- Json::Reader reader;
- Json::Value root;
- if(reader.parse(r.body, root, false)) {
- int currentVersionNo = getVersionNo();
- int responseVersionNo = root["version_no"].asInt();
- std::string responseVersion = root["version_code"].asString();
- LOGD("服务器版本 : %s %d, 当前设备版本: %d", responseVersion.c_str(), responseVersionNo, currentVersionNo);
- if (currentVersionNo < responseVersionNo) {
- Intent* intent = new Intent();
- intent->putExtra(appUpdate, "true");
- EASYUICONTEXT->openActivity("updateActivity", intent);
- }
- }
- }
- static void getNfcInteraction() {
- std::string url = getHttpGateway() + "/deviceRoom/get_nfc_interaction_end_time_is_null/" + to_string(StoragePreferences::getInt(STORE_DEVICE_ID,0));
- LOGD("请求未完成的nfc记录. url = %s", url.c_str());
- //发起HTTP POST请求
- RestClient::Response r = RestClient::get(url);
- if (r.code != 200) {
- LOGD("请求未完成的nfc记录-> 错误代码: %d", r.code);
- return;
- }
- LOGD("获得未完成的nfc记录. result = %s", r.body.c_str());
- //解析json
- Json::Reader reader;
- Json::Value root;
- if(reader.parse(r.body, root, false)) {
- int clerkId = 0;
- for (int i = 0; i < root.size(); i++) {
- if (root[i]["components_type"].asCString() == TcpType::AUTH) {
- clerkId = root[i]["clerk_id"].asInt();
- setClerk(root[i]["clerk_name"].asCString(), root[i]["pass_no"].asCString(), root[i]["id"].asInt());
- }
- else if (root[i]["components_type"].asString() == "POSITION_COMPONENT") {
- setPosistionItId(root[i]["id"].asInt());
- setPositionButton(true);
- }
- else if (root[i]["components_type"].asString() == "ROOMCHECK_COMPONENT") {
- setRoomCheckItId(root[i]["id"].asInt());
- setRoomPatrolButton(true);
- }
- else if (root[i]["components_type"].asString() == "SCREEN_TIP_SET_COMPONENT") {
- time_t now = TimeHelper::getDateline();
- if (now <= 0) {
- continue;
- }
- Json::Reader Reader;
- Json::Value operationData;
- Reader.parse(root[i]["operation_data"].asString(), operationData);
- int seconds = operationData["seconds"].asInt();
- if (now - root[i]["start_time"].asInt() < seconds) {
- setPromptTimeItId(root[i]["id"].asInt());
- Intent* intent = new Intent();
- intent->putExtra(promptText2, operationData["tips"].asString());
- intent->putExtra(promptTime2, to_string(seconds - (now - root[i]["start_time"].asInt())));
- EASYUICONTEXT->openActivity("promptActivity", intent);
- }
- else {
- sendPromptQuit(root[i]["id"].asInt());
- }
- }
- }
- if (clerkId != 0) {
- goCare();
- }
- }
- }
- /**
- * 线程创建成功后会调用该函数,可以在该函数中做一些初始化操作
- * return true 继续线程
- * false 退出线程
- */
- virtual bool readyToRun() {
- LOGD("Thread 已经创建完成");
- return true;
- }
- /**
- * 线程循环函数
- *
- * return true 继续线程循环
- * false 推出线程
- */
- virtual bool threadLoop() {
- LOGD("线程循环函数");
- //检查是否有退出线程的请求,如果有,则返回false,立即退出线程
- if (exitPending()) {
- return false;
- }
- udpConn = net::Dial("udp", "192.168.1.255:10010");
- if (udpConn) {
- byte buf[1024] = {0};
- const char* req = "search_server";
- //发送
- udpConn->Write((byte*)req, strlen(req));
- while (true && !exitPending()) {
- //读取,超时10*1000毫秒
- int n = udpConn->Read(buf, sizeof(buf) - 1, 10*1000);
- if (n > 0) {
- buf[n] = 0;
- char serverStr[1024];
- sprintf(serverStr,"%s",buf);
- LOGD("读取 %d字节: %s", n, serverStr);
- //解析json
- Json::Reader reader;
- Json::Value root;
- if (reader.parse(serverStr, root, false)){
- if (root.isMember("success") && root["success"].asBool()){
- serverIP = root["data"]["third_server"].asString();
- serverHttpPort = root["data"]["third_server_port"].asInt();
- StoragePreferences::putString(STORE_GATEWAY, serverIP);
- StoragePreferences::putInt(STORE_HTTP_PORT, serverHttpPort);
- //先获取服务器信息
- //getServerInfo();
- //就当在获取服务器信息完成后获取用户信息,这里测试用
- //getCustomerInfo();
- //退出UDP线程
- pthread_exit(NULL);
- break;
- }
- }
- } else if (n == 0) {
- LOGD("连接正常断开");
- break;
- } else if (n == net::E_TIMEOUT) {
- udpConn->Write((byte*)req, strlen(req));
- LOGD("读取超时");
- } else {
- LOGD("出错");
- break;
- }
- }
- //关闭连接
- udpConn->Close();
- //释放内存
- delete udpConn;
- udpConn = NULL;
- }
- //返回真,继续下次线程循环
- return true;
- }
- };
- static UdpThread udp_thread;
- std::string getFrameFullName() {
- if (frameInfo.isMember("full_name")) {
- return frameInfo["full_name"].asString();
- }
- else {
- return "";
- }
- }
- Json::Value getFrame() {
- return frameRoom;
- }
- // 收到tcp的时候,刷新数据
- void dataRefresh() {
- LOGD("DATA-REFRESH, 数据刷新");
- if (mActivityPtr == NULL) {
- return;
- }
- if (serverInfo) {
- udp_thread.getServerInfo();
- }
- dataInit = false;
- udp_thread.getDeviceInfo();
- mBedListViewPtr->refreshListView();
- }
- void getPartSetting() {
- udp_thread.getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
- }
- /**
- * 注册定时器
- * 填充数组用于注册定时器
- * 注意:id不能重复
- */
- static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
- //{0, 6000}, //定时器id=0, 时间间隔6秒
- //{1, 1000},
- };
- /**
- * 当界面构造时触发
- */
- static void onUI_init(){
- //run("this is thread name");
- //测试用
- LOGD("进入mainLogic页面, 触发 onUI_init");
- if(serverInfo && isConnectServer()) { // 如果是false,就是不需要
- udp_thread.getServerInfo();
- }
- udp_thread.getDeviceInfo();
- setMainMode();
- }
- /**
- * 当切换到该界面时触发
- */
- static void onUI_intent(const Intent *intentPtr) {
- if (intentPtr != NULL) {
- }
- }
- /*
- * 当界面显示时触发
- */
- static void onUI_show() {
- EASYUICONTEXT->showStatusBar();
- EASYUICONTEXT->showNaviBar();
- setMainTheme();
- }
- /*
- * 当界面隐藏时触发
- */
- static void onUI_hide() {
- }
- /*
- * 当界面完全退出时触发
- */
- static void onUI_quit() {
- //pthread_exit(NULL);
- }
- /**
- * 串口数据回调接口
- */
- static void onProtocolDataUpdate(const SProtocolData &data) {
- }
- /**
- * 定时器触发函数
- * 不建议在此函数中写耗时操作,否则将影响UI刷新
- * 参数: id
- * 当前所触发定时器的id,与注册时的id相同
- * 返回值: true
- * 继续运行当前定时器
- * false
- * 停止运行当前定时器
- */
- static bool onUI_Timer(int id){
- switch (id) {
- default:
- break;
- }
- return true;
- }
- /**
- * 有新的触摸事件时触发
- * 参数:ev
- * 新的触摸事件
- * 返回值:true
- * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
- * false
- * 触摸事件将继续传递到控件上
- */
- static bool onmainActivityTouchEvent(const MotionEvent &ev) {
- switch (ev.mActionStatus) {
- case MotionEvent::E_ACTION_DOWN://触摸按下
- //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
- break;
- case MotionEvent::E_ACTION_MOVE://触摸滑动
- break;
- case MotionEvent::E_ACTION_UP: //触摸抬起
- break;
- default:
- break;
- }
- return false;
- }
- static int getListItemCount_BedListView(const ZKListView *pListView) {
- //LOGD("getListItemCount_BedListView !\n");
- return frameBedList.size();
- }
- static void obtainListItemData_BedListView(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
- //LOGD(" obtainListItemData_ BedListView !!!\n");
- if (frameBedList.size() > 0) {
- ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem);
- ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem);
- ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem);
- ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem);
- ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitileSubItem);
- ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem);
- ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem);
- ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem);
- ZKListView::ZKListSubItem* affair = pListItem->findSubItemByID(ID_MAIN_AffairSubItem);
- ZKListView::ZKListSubItem* event = pListItem->findSubItemByID(ID_MAIN_EventSubItem);
- if (mainModeInt == 2) {
- if (frameBedList.size() > 3) {
- return;
- }
- }
- if (mainThemeInt == 1) {
- bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
- }
- else if (mainThemeInt == 2) {
- bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
- }
- string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
- if (frameBedName == "") {
- bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
- } else {
- int nPos = frameBedName.find("-");
- if (nPos != -1) {
- frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
- }
- bedNum->setText(frameBedName);
- }
- // 用户相关
- string customerName = frameBedList[index]["customer_name"].asString();
- if (customerName == "") {
- name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
- } else {
- name->setText(customerName);
- }
- age->setText(frameBedList[index]["customer_age_unit"].asString() + ": " + frameBedList[index]["customer_age"].asString());
- // if (partSetting.customerAgeHiddenOnDoor != 0) {
- // sex->setText("*****");
- // sex->setTextColor(0x37B643);
- // sex->setBackgroundPic("9/lightGreen.9.png");
- // }
- // else {
- // string customerSex = frameBedList[index]["customer_sex"].asString();
- // if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
- // sex->setText(LANGUAGEMANAGER->getValue("Woman"));
- // sex->setTextColor(0xFF9F9F);
- // sex->setBackgroundPic("9/lightRed.9.png");
- // }
- // else if (customerSex == "1") {
- // sex->setText(LANGUAGEMANAGER->getValue("Man"));
- // sex->setTextColor(0x3A78EF);
- // sex->setBackgroundPic("9/lightBlue.9.png");
- // }
- // else {
- // sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
- // sex->setTextColor(0x37B643);
- // sex->setBackgroundPic("9/lightGreen.9.png");
- // }
- // }
- // 医生护士相关
- if (rightTitleInfo["doctor_valid"] != 1){
- doctorTitle->setVisible(false);
- } else {
- doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
- }
- if (rightTitleInfo["nurse_valid"] != 1){
- nurseTitle->setVisible(false);
- } else {
- nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
- }
- doctor->setText(frameBedList[index]["doctor_name"].asString());
- nurse->setText(frameBedList[index]["nurse_name"].asString());
- if (frameBedList[index]["bed_device_id"].asString() == "") {
- affair->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/main/affair2_grey.png");
- }
- else {
- affair->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/main/affair2.png");
- }
- // // 护理项相关
- // Json::Value nurseConfigList = frameBedList[index]["nurse_config_dtos"];
- // if (nurseConfigList.size() > 0) {
- // for (int i = 0; i < 5; i++) {
- // int nurseConfigColorNumber = ID_MAIN_NurseConfigColor1 + i;
- // int nurseConfigNumber = ID_MAIN_NurseConfig1 + i * 2;
- // int nurseOptionNumber = ID_MAIN_NurseOption1 + i * 2;
- // if (nurseConfigList.size() >= i) {
- // //颜色
- // string nurseConfigColot = nurseConfigList[i]["nurse_color_rbg"].asString();
- // uint32_t bgColor = 0xFFC0C0C0;
- // if (nurseConfigColot != "") {
- // string rgbStr = "FF" + nurseConfigColot;
- // transform(rgbStr.begin(), rgbStr.end(), rgbStr.begin(), ::toupper);
- // bgColor = strtoul(("0x" + rgbStr).c_str(), NULL,16);
- // }
- // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(bgColor);
- // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
- // string nurseOptionName = nurseConfigList[i]["nurse_option_name"].asString();
- // if (nurseOptionName == "") {
- // nurseOptionName = LANGUAGEMANAGER->getValue("None");
- // }
- // pListItem->findSubItemByID(nurseOptionNumber)->setText(nurseOptionName);
- //
- // } else {
- // //颜色
- // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
- // pListItem->findSubItemByID(nurseOptionNumber)->setText(LANGUAGEMANAGER->getValue("None"));
- // }
- // }
- // }
- // else {
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor1)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor2)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor3)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor4)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor5)->setBackgroundColor(0xFFC0C0C0);
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig1)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig2)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig3)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig4)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseConfig5)->setText("");
- // pListItem->findSubItemByID(ID_MAIN_NurseOption1)->setText(LANGUAGEMANAGER->getValue("None"));
- // pListItem->findSubItemByID(ID_MAIN_NurseOption2)->setText(LANGUAGEMANAGER->getValue("None"));
- // pListItem->findSubItemByID(ID_MAIN_NurseOption3)->setText(LANGUAGEMANAGER->getValue("None"));
- // pListItem->findSubItemByID(ID_MAIN_NurseOption4)->setText(LANGUAGEMANAGER->getValue("None"));
- // pListItem->findSubItemByID(ID_MAIN_NurseOption5)->setText(LANGUAGEMANAGER->getValue("None"));
- // }
- }
- }
- static void onListItemClick_BedListView(ZKListView *pListView, int index, int id) {
- LOGD(" onListItemClick_ BedListView !!!\n");
- if (frameBedList[index]["bed_device_id"].asString() == "") {
- // Intent* intent = new Intent();
- // intent->putExtra(functionWindows, "warn");
- // intent->putExtra(warnText, LANGUAGEMANAGER->getValue("NotBedDevice"));
- // EASYUICONTEXT->openActivity("functionActivity", intent);
- return;
- }
- if (id == ID_MAIN_EventSubItem) {
- LOGD("触发事件按钮,index ===> %d", index);
- string _customerId = frameBedList[index]["customer_id"].asString();
- string _deviceId = frameBedList[index]["bed_device_id"].asString();
- Intent* intent = new Intent();
- intent->putExtra(transmitDeviceId, _deviceId);
- intent->putExtra(transmitCustomerId, _customerId);
- EASYUICONTEXT->openActivity("interactionActivity", intent);
- }
- else if (id == ID_MAIN_AffairSubItem) {
- LOGD("触发事务按钮,index ===> %d", index);
- string _customerId = frameBedList[index]["customer_id"].asString();
- string _deviceId = frameBedList[index]["bed_device_id"].asString();
- Intent* intent = new Intent();
- intent->putExtra(transmitDeviceId, _deviceId);
- intent->putExtra(transmitCustomerId, _customerId);
- EASYUICONTEXT->openActivity("customerAffairActivity", intent);
- }
- }
- static int getListItemCount_BedListView2(const ZKListView *pListView) {
- //LOGD("getListItemCount_BedListView2 !\n");
- return frameBedList.size();
- }
- static void obtainListItemData_BedListView2(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
- //LOGD(" obtainListItemData_ BedListView2 !!!\n");
- if (mainModeInt == 2) {
- if (frameBedList.size() <= 3 || frameBedList.size() > 6) {
- return;
- }
- }
- if (frameBedList.size() > 0) {
- ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem2);
- ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem2);
- ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem2);
- ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem2);
- ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem2);
- ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem2);
- ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem2);
- ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem2);
- if (mainThemeInt == 1) {
- bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
- }
- else if (mainThemeInt == 2) {
- bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
- }
- string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
- if (frameBedName == "") {
- bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
- } else {
- int nPos = frameBedName.find("-");
- if (nPos != -1) {
- frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
- }
- bedNum->setText(frameBedName);
- }
- // 用户相关
- string customerName = frameBedList[index]["customer_name"].asString();
- if (customerName == "") {
- name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
- } else {
- name->setText(customerName);
- }
- if (partSetting.customerAgeHiddenOnDoor != 0) {
- if (frameBedList[index]["customer_age"].asString() == "") {
- age->setText("");
- } else {
- age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
- }
- }
- else {
- age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
- }
- string customerSex = frameBedList[index]["customer_sex"].asString();
- if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
- sex->setText(LANGUAGEMANAGER->getValue("Woman"));
- sex->setTextColor(0xFF9F9F);
- sex->setBackgroundPic("9/lightRed.9.png");
- }
- else if (customerSex == "1") {
- sex->setText(LANGUAGEMANAGER->getValue("Man"));
- sex->setTextColor(0x3A78EF);
- sex->setBackgroundPic("9/lightBlue.9.png");
- }
- else if (customerSex == "") {
- sex->setText(customerSex);
- sex->setTextColor(0x37B643);
- sex->setBackgroundPic("9/lightGreen.9.png");
- }
- else {
- sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
- sex->setTextColor(0x37B643);
- sex->setBackgroundPic("9/lightGreen.9.png");
- }
- // 医生护士相关
- if (rightTitleInfo["doctor_valid"] != 1){
- doctorTitle->setVisible(false);
- } else {
- doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
- }
- if (rightTitleInfo["nurse_valid"] != 1){
- nurseTitle->setVisible(false);
- } else {
- nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
- }
- doctor->setText(frameBedList[index]["doctor_name"].asString());
- nurse->setText(frameBedList[index]["nurse_name"].asString());
- }
- }
- static void onListItemClick_BedListView2(ZKListView *pListView, int index, int id) {
- //LOGD(" onListItemClick_ BedListView2 !!!\n");
- }
- static int getListItemCount_BedListView3(const ZKListView *pListView) {
- //LOGD("getListItemCount_BedListView3 !\n");
- return frameBedList.size();
- }
- static void obtainListItemData_BedListView3(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
- //LOGD(" obtainListItemData_ BedListView3 !!!\n");
- if (mainModeInt == 2) {
- if (frameBedList.size() <= 6) {
- return;
- }
- }
- if (frameBedList.size() > 0) {
- ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem3);
- ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem3);
- ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem3);
- ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem3);
- ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem3);
- ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem3);
- ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem3);
- ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem3);
- if (mainThemeInt == 1) {
- bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
- }
- else if (mainThemeInt == 2) {
- bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
- }
- string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
- if (frameBedName == "") {
- bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
- } else {
- int nPos = frameBedName.find("-");
- if (nPos != -1) {
- frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
- }
- bedNum->setText(frameBedName);
- }
- // 用户相关
- string customerName = frameBedList[index]["customer_name"].asString();
- if (customerName == "") {
- name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
- } else {
- name->setText(customerName);
- }
- if (partSetting.customerAgeHiddenOnDoor != 0) {
- if (frameBedList[index]["customer_age"].asString() == "") {
- age->setText("");
- } else {
- age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
- }
- }
- else {
- age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
- }
- string customerSex = frameBedList[index]["customer_sex"].asString();
- if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
- sex->setText(LANGUAGEMANAGER->getValue("Woman"));
- sex->setTextColor(0xFF9F9F);
- sex->setBackgroundPic("9/lightRed.9.png");
- }
- else if (customerSex == "1") {
- sex->setText(LANGUAGEMANAGER->getValue("Man"));
- sex->setTextColor(0x3A78EF);
- sex->setBackgroundPic("9/lightBlue.9.png");
- }
- else if (customerSex == "") {
- sex->setText(customerSex);
- sex->setTextColor(0x37B643);
- sex->setBackgroundPic("9/lightGreen.9.png");
- }
- else {
- sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
- sex->setTextColor(0x37B643);
- sex->setBackgroundPic("9/lightGreen.9.png");
- }
- // 医生护士相关
- if (rightTitleInfo["doctor_valid"] != 1){
- doctorTitle->setVisible(false);
- } else {
- doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
- }
- if (rightTitleInfo["nurse_valid"] != 1){
- nurseTitle->setVisible(false);
- } else {
- nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
- }
- doctor->setText(frameBedList[index]["doctor_name"].asString());
- nurse->setText(frameBedList[index]["nurse_name"].asString());
- }
- }
- static void onListItemClick_BedListView3(ZKListView *pListView, int index, int id) {
- //LOGD(" onListItemClick_ BedListView3 !!!\n");
- }
- static int getListItemCount_BedListView4(const ZKListView *pListView) {
- //LOGD("getListItemCount_BedListView4 !\n");
- return frameBedList.size();
- }
- static void obtainListItemData_BedListView4(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
- //LOGD(" obtainListItemData_ BedListView4 !!!\n");
- if (mainModeInt == 3 && frameBedList.size()> 0) {
- ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem4);
- ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem4);
- ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem4);
- ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem4);
- ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem4);
- ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem4);
- ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem4);
- ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem4);
- if (mainThemeInt == 1) {
- bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
- }
- else if (mainThemeInt == 2) {
- bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
- }
- string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
- if (frameBedName == "") {
- bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
- } else {
- int nPos = frameBedName.find("-");
- if (nPos != -1) {
- frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
- }
- bedNum->setText(frameBedName);
- }
- // 用户相关
- string customerName = frameBedList[index]["customer_name"].asString();
- if (customerName == "") {
- name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
- } else {
- name->setText(customerName);
- }
- if (partSetting.customerAgeHiddenOnDoor != 0) {
- if (frameBedList[index]["customer_age"].asString() == "") {
- age->setText("");
- } else {
- age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
- }
- sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
- sex->setTextColor(0x37B643);
- sex->setBackgroundPic("9/lightGreen.9.png");
- }
- else {
- age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
- string customerSex = frameBedList[index]["customer_sex"].asString();
- if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
- sex->setText(LANGUAGEMANAGER->getValue("Woman"));
- sex->setTextColor(0xFF9F9F);
- sex->setBackgroundPic("9/lightRed.9.png");
- }
- else if (customerSex == "1") {
- sex->setText(LANGUAGEMANAGER->getValue("Man"));
- sex->setTextColor(0x3A78EF);
- sex->setBackgroundPic("9/lightBlue.9.png");
- }
- else {
- sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
- sex->setTextColor(0x37B643);
- sex->setBackgroundPic("9/lightGreen.9.png");
- }
- }
- // 医生护士相关
- if (rightTitleInfo["doctor_valid"] != 1){
- doctorTitle->setVisible(false);
- } else {
- doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
- }
- if (rightTitleInfo["nurse_valid"] != 1){
- nurseTitle->setVisible(false);
- } else {
- nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
- }
- doctor->setText(frameBedList[index]["doctor_name"].asString());
- nurse->setText(frameBedList[index]["nurse_name"].asString());
- }
- }
- static void onListItemClick_BedListView4(ZKListView *pListView, int index, int id) {
- //LOGD(" onListItemClick_ BedListView4 !!!\n");
- }
|