BusinessConfig.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /*
  2. * BusinessConfig.h
  3. *
  4. * Created on: 2022年9月29日
  5. * Author: Allen
  6. */
  7. #include <string.h>
  8. #include <time.h>
  9. #include "storage/StoragePreferences.h"
  10. #include "utils/BrightnessHelper.h"
  11. #include "utils/TimeHelper.h"
  12. #include "utils/Log.h"
  13. #include <atomic>
  14. #include "net/tcp_client.h"
  15. #include "net/tcp_model.h"
  16. #include <map>
  17. #ifndef JNI_SERVICE_BUSINESSCONFIG_H_
  18. #define JNI_SERVICE_BUSINESSCONFIG_H_
  19. #define STORE_DEVICE_ID "device_id"
  20. #define STORE_DEVICE_TYPE "device_type"
  21. #define STORE_PARTID "part_id"
  22. #define STORE_PARTNAME "part_name"
  23. #define STORE_CUSTOMER_ID "customer_id"
  24. #define STORE_GATEWAY "gateway"
  25. #define STORE_HTTP_PORT "http_port"
  26. #define STORE_TCP_LOCAL_IP "tcp_local_ip"
  27. #define STORE_TCP_PORT "tcp_port"
  28. #define STORE_SIGNAL_TYPE "signal_type" //语音信令方式, TCP、SIP
  29. #define STORE_DAY_OR_NIGHT "day_or_night" // bool值,true就是白天,false就是晚上
  30. #define STORE_SLEEP_TIME "sleep_time"
  31. #define STORE_DAY_START "day_start"
  32. #define STORE_DAY_LIGHT "day_light"
  33. #define STORE_DAY_VOL "day_vol"
  34. #define STORE_DAY_RING_TIMES "day_ring_times"
  35. #define STORE_NIGHT_START "night_start"
  36. #define STORE_NIGHT_LIGHT "night_light"
  37. #define STORE_NIGHT_VOL "night_vol"
  38. #define STORE_NIGHT_RING_TIMES "night_ring_times"
  39. #define STORE_DOCTOR_TITLE "doctor_title"
  40. #define STORE_DOCTOR_VISIBLE "doctor_visible"
  41. #define STORE_NURSE_TITLE "nurse_title"
  42. #define STORE_NURSE_VISIBLE "nurse_visible"
  43. #define STORE_AUDO_ANSWER "auto_answer"
  44. static std::string version = "v1.0.9";
  45. static int versionNo = 65;
  46. static std::string serverIP = "172.28.100.100";
  47. static std::string tcpIP = "172.28.100.100";
  48. static int serverHttpPort = 8006;
  49. static int serverTcpPort = 5086;
  50. static std::string getHttpGateway(){
  51. std::string sserverIP = StoragePreferences::getString(STORE_GATEWAY, serverIP);
  52. int sserverHttpPort = StoragePreferences::getInt(STORE_HTTP_PORT, serverHttpPort);
  53. char gateWay[100];
  54. sprintf(gateWay,"http://%s:%d",sserverIP.c_str(),sserverHttpPort);
  55. LOGD("getHttpGateway %s",gateWay);
  56. return gateWay;
  57. }
  58. static std::string getTcpGateway(){
  59. std::string sserverIP = StoragePreferences::getString(STORE_TCP_LOCAL_IP, tcpIP);
  60. StoragePreferences::putInt(STORE_TCP_PORT, serverTcpPort);
  61. int sserverTcpPort = StoragePreferences::getInt(STORE_TCP_PORT, serverTcpPort);
  62. char gateWay[100];
  63. sprintf(gateWay,"%s:%d",sserverIP.c_str(),sserverTcpPort);
  64. LOGD("getTcpGateway %s",gateWay);
  65. return gateWay;
  66. }
  67. static std::string getVersion() {
  68. LOGD("version -> %s",version);
  69. return version;
  70. }
  71. static int getVersionNo() {
  72. LOGD("versionNo -> %d", versionNo);
  73. return versionNo;
  74. }
  75. /**
  76. * 设置科室名称
  77. */
  78. void NavibarSetPartName(const std::string& partName);
  79. /**
  80. * 设置床位区块颜色和文字
  81. */
  82. void SetPainterInfo(uint32_t bgColor, const std::string& msg);
  83. void setReinforce(bool result);
  84. /**
  85. * 刷新设备数据
  86. */
  87. void dataRefresh();
  88. // 获取科室设置
  89. void getPartSetting();
  90. // 获取息屏定时任务
  91. bool getSleepTimerRegistered();
  92. // 设置是否开启息屏定时任务
  93. void setSleepTimerRegistered(bool result);
  94. // 设置护理的tcpModel
  95. void setNursingTcpModel(TcpModel source);
  96. /**
  97. * 设置增援按钮是否可用
  98. */
  99. void setBtnHelpVisible(bool visible);
  100. /**
  101. * 取消 增援一分钟后自动取消
  102. */
  103. void cancelAutoBtnHelpTimer();
  104. enum CallFinishType {
  105. CANCEL,
  106. REJECT,
  107. BUSY,
  108. HANDOFF,
  109. FAILED,
  110. ACCEPT,
  111. A1CLICK,
  112. KEY6_CLICK,
  113. };
  114. void callActivityFinish(CallFinishType type);
  115. void buildSIP(std::string toSipId);
  116. void acceptSIP();
  117. void sendVoiceTcp(std::string action, TcpModel model, int toId);
  118. class PartSetting{
  119. public:
  120. inline static int id;
  121. inline static std::string unionId;
  122. inline static int partId;
  123. inline static std::string dayStart;
  124. inline static int dayLight;
  125. inline static int dayVol;
  126. inline static int dayRingVol;
  127. inline static int dayRingTimes;
  128. inline static int dayNurseLed;
  129. inline static int dayDoorVol;
  130. inline static int dayBedVol;
  131. inline static int dayTransferBoxVol;
  132. inline static int dayTransferBoxSystemVol;
  133. inline static std::string nightStart;
  134. inline static int nightLight;
  135. inline static int nightVol;
  136. inline static int nightRingVol;
  137. inline static int nightRingTimes;
  138. inline static int nightNurseLed;
  139. inline static int nightDoorVol;
  140. inline static int nightBedVol;
  141. inline static int nightTransferBoxVol;
  142. inline static int nightTransferBoxSystemVol;
  143. inline static int sleepSecondsNurse;
  144. inline static int sleepSecondsDoor;
  145. inline static int sleepSecondsBed;
  146. inline static int sipOvertime;
  147. inline static int transferDuration;
  148. inline static int transferDurationLeader;
  149. inline static int communicationModeBed;
  150. inline static int communicationModeNurse;
  151. inline static int communicationModeMobile;
  152. inline static int customizeRoleCallFirst;
  153. inline static int customizeRoleCallSecond;
  154. inline static int customizeRoleCallThird;
  155. inline static int customizeRoleCallFourth;
  156. inline static int customizeRoleCallFifth;
  157. inline static int customizeHospitalCallFirst;
  158. inline static std::string customizeHospitalCallFirstName;
  159. inline static int customizeHospitalCallSecond;
  160. inline static std::string customizeHospitalCallSecondName;
  161. inline static int customizeHospitalCallThird;
  162. inline static std::string customizeHospitalCallThirdName;
  163. inline static std::string doctorTitle;
  164. inline static int doctorValid;
  165. inline static std::string nurseTitle;
  166. inline static int nurseValid;
  167. inline static std::string doorNurseTitle;
  168. inline static int doorNurseValid;
  169. inline static std::string doorNursingTitle;
  170. inline static int doorNursingValid;
  171. inline static int upSeconds;
  172. inline static int autoAccept;
  173. inline static bool boardShowEmptyBed;
  174. inline static int eventForward;
  175. inline static std::string nursingColorRgb;
  176. inline static int twoColorDoorLightValid;
  177. inline static std::string qrUrl;
  178. };
  179. /**
  180. * 是否白天
  181. */
  182. static bool checkIsDay(){
  183. struct tm *t = TimeHelper::getDateTime();
  184. //获得当前日期
  185. char cDate[20];
  186. sprintf(cDate,"%d-%02d-%02d",
  187. 1900 + t->tm_year, 1+ t->tm_mon, t->tm_mday);
  188. std::string cDateStr = cDate;
  189. //组合白天与黑夜开始时间
  190. std::string dayStart = cDateStr + StoragePreferences::getString(STORE_DAY_START, " 07:00:00");
  191. std::string nightStart = cDateStr + StoragePreferences::getString(STORE_NIGHT_START, " 18:00:00");
  192. //LOGD("dayStart %s . nightStart %s", dayStart.c_str(), nightStart.c_str());
  193. time_t tDayStart = TimeHelper::StringToDatetime(dayStart);
  194. time_t tNightStart = TimeHelper::StringToDatetime(nightStart);
  195. time_t currentTime = mktime(t) - 28800;
  196. if (currentTime>=tDayStart && currentTime<= tNightStart){
  197. return true;
  198. }
  199. return false;
  200. //LOGD("tiDayStart %ld . tNightStart %ld . currentTime %ld", tDayStart, tNightStart, currentTime);
  201. }
  202. static std::string isOutgoing = "isOutgoing";
  203. static std::string audioOnly = "audioOnly";
  204. class CallingStatus{
  205. public:
  206. virtual ~CallingStatus();
  207. static CallingStatus* instance();
  208. void setBusy(bool busy);
  209. void setTcpModel(TcpModel tcpModel);
  210. void clearTcpModel();
  211. static bool busy();
  212. TcpModel getTcpModel();
  213. long getInteractionId();
  214. private:
  215. CallingStatus();
  216. private:
  217. std::atomic<bool> _busy;
  218. TcpModel _tcpModel;
  219. long _interactionId;
  220. };
  221. class TcpCallback{
  222. public:
  223. std::string tid;
  224. std::string jsonStr;
  225. std::function<void(Json::Value json)> onSuccess;
  226. std::function<void(Json::Value json)> onFalied;
  227. };
  228. class TcpCacheManager{
  229. public:
  230. virtual ~TcpCacheManager();
  231. static TcpCacheManager* instance();
  232. void setFunc(std::string tid, TcpCallback callback);
  233. TcpCallback getFunc(std::string tid);
  234. private:
  235. TcpCacheManager();
  236. private:
  237. std::map<std::string, TcpCallback> cb;
  238. };
  239. static std::string appUpdate = "appUpdate";
  240. #endif /* JNI_SERVICE_BUSINESSCONFIG_H_ */