BusinessConfig.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. #define SIGNAL_TYPE "TCP" //TCP,SIP
  45. static std::string version = "v1.0.5";
  46. static int versionNo = 5;
  47. static std::string serverIP = "172.28.100.100";
  48. static std::string tcpIP = "172.28.100.100";
  49. static int serverHttpPort = 8006;
  50. static int serverTcpPort = 5086;
  51. static std::string getHttpGateway(){
  52. std::string sserverIP = StoragePreferences::getString(STORE_GATEWAY, serverIP);
  53. int sserverHttpPort = StoragePreferences::getInt(STORE_HTTP_PORT, serverHttpPort);
  54. char gateWay[100];
  55. sprintf(gateWay,"http://%s:%d",sserverIP.c_str(),sserverHttpPort);
  56. LOGD("getHttpGateway %s",gateWay);
  57. return gateWay;
  58. }
  59. static std::string getTcpGateway(){
  60. std::string sserverIP = StoragePreferences::getString(STORE_TCP_LOCAL_IP, tcpIP);
  61. StoragePreferences::putInt(STORE_TCP_PORT, serverTcpPort);
  62. int sserverTcpPort = StoragePreferences::getInt(STORE_TCP_PORT, serverTcpPort);
  63. char gateWay[100];
  64. sprintf(gateWay,"%s:%d",sserverIP.c_str(),sserverTcpPort);
  65. LOGD("getTcpGateway %s",gateWay);
  66. return gateWay;
  67. }
  68. static std::string getVersion() {
  69. LOGD("version -> %s",version);
  70. return version;
  71. }
  72. static int getVersionNo() {
  73. LOGD("versionNo -> %d", versionNo);
  74. return versionNo;
  75. }
  76. /**
  77. * 设置科室名称
  78. */
  79. void NavibarSetPartName(const std::string& partName);
  80. /**
  81. * 设置床位区块颜色和文字
  82. */
  83. void SetPainterInfo(uint32_t bgColor, const std::string& msg);
  84. void setReinforce(bool result);
  85. void setHelpButton(const char *pPicPath, bool isTouchable);
  86. /**
  87. * 刷新设备数据
  88. */
  89. void dataRefresh();
  90. // 获取科室设置
  91. void getPartSetting();
  92. // 获取息屏定时任务
  93. bool getSleepTimerRegistered();
  94. // 设置是否开启息屏定时任务
  95. void setSleepTimerRegistered(bool result);
  96. // 设置护理的tcpModel
  97. void setNursingTcpModel(TcpModel source);
  98. /**
  99. * 设置增援按钮是否可用
  100. */
  101. void setBtnHelpVisible(bool visible);
  102. /**
  103. * 取消 增援一分钟后自动取消
  104. */
  105. void cancelAutoBtnHelpTimer();
  106. enum CallFinishType {
  107. CANCEL,
  108. REJECT,
  109. BUSY,
  110. HANDOFF,
  111. FAILED,
  112. ACCEPT,
  113. A1CLICK,
  114. KEY6_CLICK,
  115. };
  116. void callActivityFinish(CallFinishType type);
  117. void buildSIP(std::string toSipId);
  118. void acceptSIP();
  119. void sendVoiceTcp(std::string action, TcpModel model, int toId);
  120. class PartSetting{
  121. public:
  122. inline static int id;
  123. inline static std::string unionId;
  124. inline static int partId;
  125. inline static std::string dayStart;
  126. inline static int dayLight;
  127. inline static int dayVol;
  128. inline static int dayRingVol;
  129. inline static int dayRingTimes;
  130. inline static int dayNurseLed;
  131. inline static int dayDoorVol;
  132. inline static int dayBedVol;
  133. inline static int dayTransferBoxVol;
  134. inline static int dayTransferBoxSystemVol;
  135. inline static std::string nightStart;
  136. inline static int nightLight;
  137. inline static int nightVol;
  138. inline static int nightRingVol;
  139. inline static int nightRingTimes;
  140. inline static int nightNurseLed;
  141. inline static int nightDoorVol;
  142. inline static int nightBedVol;
  143. inline static int nightTransferBoxVol;
  144. inline static int nightTransferBoxSystemVol;
  145. inline static int sleepSecondsNurse;
  146. inline static int sleepSecondsDoor;
  147. inline static int sleepSecondsBed;
  148. inline static int sipOvertime;
  149. inline static int transferDuration;
  150. inline static int transferDurationLeader;
  151. inline static int communicationModeBed;
  152. inline static int communicationModeNurse;
  153. inline static int communicationModeMobile;
  154. inline static int customizeRoleCallFirst;
  155. inline static int customizeRoleCallSecond;
  156. inline static int customizeRoleCallThird;
  157. inline static int customizeRoleCallFourth;
  158. inline static int customizeRoleCallFifth;
  159. inline static int customizeHospitalCallFirst;
  160. inline static std::string customizeHospitalCallFirstName;
  161. inline static int customizeHospitalCallSecond;
  162. inline static std::string customizeHospitalCallSecondName;
  163. inline static int customizeHospitalCallThird;
  164. inline static std::string customizeHospitalCallThirdName;
  165. inline static std::string doctorTitle;
  166. inline static int doctorValid;
  167. inline static std::string nurseTitle;
  168. inline static int nurseValid;
  169. inline static std::string doorNurseTitle;
  170. inline static int doorNurseValid;
  171. inline static std::string doorNursingTitle;
  172. inline static int doorNursingValid;
  173. inline static int upSeconds;
  174. inline static int autoAccept;
  175. inline static bool boardShowEmptyBed;
  176. inline static int eventForward;
  177. inline static std::string nursingColorRgb;
  178. inline static int twoColorDoorLightValid;
  179. inline static std::string qrUrl;
  180. };
  181. /**
  182. * 是否白天
  183. */
  184. static bool checkIsDay(){
  185. struct tm *t = TimeHelper::getDateTime();
  186. //获得当前日期
  187. char cDate[20];
  188. sprintf(cDate,"%d-%02d-%02d",
  189. 1900 + t->tm_year, 1+ t->tm_mon, t->tm_mday);
  190. std::string cDateStr = cDate;
  191. //组合白天与黑夜开始时间
  192. std::string dayStart = cDateStr + StoragePreferences::getString(STORE_DAY_START, " 07:00:00");
  193. std::string nightStart = cDateStr + StoragePreferences::getString(STORE_NIGHT_START, " 18:00:00");
  194. //LOGD("dayStart %s . nightStart %s", dayStart.c_str(), nightStart.c_str());
  195. time_t tDayStart = TimeHelper::StringToDatetime(dayStart);
  196. time_t tNightStart = TimeHelper::StringToDatetime(nightStart);
  197. time_t currentTime = mktime(t) - 28800;
  198. if (currentTime>=tDayStart && currentTime<= tNightStart){
  199. return true;
  200. }
  201. return false;
  202. //LOGD("tiDayStart %ld . tNightStart %ld . currentTime %ld", tDayStart, tNightStart, currentTime);
  203. }
  204. static std::string isOutgoing = "isOutgoing";
  205. static std::string audioOnly = "audioOnly";
  206. static std::string toIdStr = "";
  207. static std::string callName = "";
  208. class CallingStatus{
  209. public:
  210. virtual ~CallingStatus();
  211. static CallingStatus* instance();
  212. void setBusy(bool busy);
  213. void setTcpModel(TcpModel tcpModel);
  214. void clearTcpModel();
  215. static bool busy();
  216. TcpModel getTcpModel();
  217. long getInteractionId();
  218. private:
  219. CallingStatus();
  220. private:
  221. std::atomic<bool> _busy;
  222. TcpModel _tcpModel;
  223. long _interactionId;
  224. };
  225. class TcpCallback{
  226. public:
  227. std::string tid;
  228. std::string jsonStr;
  229. std::function<void(Json::Value json)> onSuccess;
  230. std::function<void(Json::Value json)> onFalied;
  231. };
  232. class TcpCacheManager{
  233. public:
  234. virtual ~TcpCacheManager();
  235. static TcpCacheManager* instance();
  236. void setFunc(std::string tid, TcpCallback callback);
  237. TcpCallback getFunc(std::string tid);
  238. private:
  239. TcpCacheManager();
  240. private:
  241. std::map<std::string, TcpCallback> cb;
  242. };
  243. static std::string appUpdate = "appUpdate";
  244. #endif /* JNI_SERVICE_BUSINESSCONFIG_H_ */