BusinessConfig.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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.12";
  46. static int versionNo = 12;
  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. CANCEL_BY_DOOR,
  110. BUSY,
  111. HANDOFF,
  112. FAILED,
  113. ACCEPT,
  114. A1CLICK,
  115. KEY6_CLICK,
  116. };
  117. void callActivityFinish(CallFinishType type);
  118. void buildSIP(std::string toSipId);
  119. void acceptSIP();
  120. void sendVoiceTcp(std::string action, TcpModel model, int toId);
  121. class PartSetting{
  122. public:
  123. inline static int id;
  124. inline static std::string unionId;
  125. inline static int partId;
  126. inline static std::string dayStart;
  127. inline static int dayLight;
  128. inline static int dayVol;
  129. inline static int dayRingVol;
  130. inline static int dayRingTimes;
  131. inline static int dayNurseLed;
  132. inline static int dayDoorVol;
  133. inline static int dayBedVol;
  134. inline static int dayTransferBoxVol;
  135. inline static int dayTransferBoxSystemVol;
  136. inline static std::string nightStart;
  137. inline static int nightLight;
  138. inline static int nightVol;
  139. inline static int nightRingVol;
  140. inline static int nightRingTimes;
  141. inline static int nightNurseLed;
  142. inline static int nightDoorVol;
  143. inline static int nightBedVol;
  144. inline static int nightTransferBoxVol;
  145. inline static int nightTransferBoxSystemVol;
  146. inline static int sleepSecondsNurse;
  147. inline static int sleepSecondsDoor;
  148. inline static int sleepSecondsBed;
  149. inline static int sipOvertime;
  150. inline static int transferDuration;
  151. inline static int transferDurationLeader;
  152. inline static int communicationModeBed;
  153. inline static int communicationModeNurse;
  154. inline static int communicationModeMobile;
  155. inline static int customizeRoleCallFirst;
  156. inline static int customizeRoleCallSecond;
  157. inline static int customizeRoleCallThird;
  158. inline static int customizeRoleCallFourth;
  159. inline static int customizeRoleCallFifth;
  160. inline static int customizeHospitalCallFirst;
  161. inline static std::string customizeHospitalCallFirstName;
  162. inline static int customizeHospitalCallSecond;
  163. inline static std::string customizeHospitalCallSecondName;
  164. inline static int customizeHospitalCallThird;
  165. inline static std::string customizeHospitalCallThirdName;
  166. inline static std::string doctorTitle;
  167. inline static int doctorValid;
  168. inline static std::string nurseTitle;
  169. inline static int nurseValid;
  170. inline static std::string doorNurseTitle;
  171. inline static int doorNurseValid;
  172. inline static std::string doorNursingTitle;
  173. inline static int doorNursingValid;
  174. inline static int upSeconds;
  175. inline static int autoAccept;
  176. inline static bool boardShowEmptyBed;
  177. inline static int eventForward;
  178. inline static std::string nursingColorRgb;
  179. inline static int twoColorDoorLightValid;
  180. inline static std::string qrUrl;
  181. };
  182. /**
  183. * 是否白天
  184. */
  185. static bool checkIsDay(){
  186. struct tm *t = TimeHelper::getDateTime();
  187. //获得当前日期
  188. char cDate[20];
  189. sprintf(cDate,"%d-%02d-%02d",
  190. 1900 + t->tm_year, 1+ t->tm_mon, t->tm_mday);
  191. std::string cDateStr = cDate;
  192. //组合白天与黑夜开始时间
  193. std::string dayStart = cDateStr + StoragePreferences::getString(STORE_DAY_START, " 07:00:00");
  194. std::string nightStart = cDateStr + StoragePreferences::getString(STORE_NIGHT_START, " 18:00:00");
  195. //LOGD("dayStart %s . nightStart %s", dayStart.c_str(), nightStart.c_str());
  196. time_t tDayStart = TimeHelper::StringToDatetime(dayStart);
  197. time_t tNightStart = TimeHelper::StringToDatetime(nightStart);
  198. time_t currentTime = mktime(t) - 28800;
  199. if (currentTime>=tDayStart && currentTime<= tNightStart){
  200. return true;
  201. }
  202. return false;
  203. //LOGD("tiDayStart %ld . tNightStart %ld . currentTime %ld", tDayStart, tNightStart, currentTime);
  204. }
  205. static std::string isOutgoing = "isOutgoing";
  206. static std::string audioOnly = "audioOnly";
  207. static std::string toIdStr = "toIdStr";
  208. static std::string callName = "callName";
  209. static std::string warnText = "warnText";
  210. class CallingStatus{
  211. public:
  212. virtual ~CallingStatus();
  213. static CallingStatus* instance();
  214. void setBusy(bool busy);
  215. void setTcpModel(TcpModel tcpModel);
  216. void clearTcpModel();
  217. static bool busy();
  218. TcpModel getTcpModel();
  219. long getInteractionId();
  220. private:
  221. CallingStatus();
  222. private:
  223. std::atomic<bool> _busy;
  224. TcpModel _tcpModel;
  225. long _interactionId;
  226. };
  227. class TcpCallback{
  228. public:
  229. std::string tid;
  230. std::string jsonStr;
  231. std::function<void(Json::Value json)> onSuccess;
  232. std::function<void(Json::Value json)> onFalied;
  233. };
  234. class TcpCacheManager{
  235. public:
  236. virtual ~TcpCacheManager();
  237. static TcpCacheManager* instance();
  238. void setFunc(std::string tid, TcpCallback callback);
  239. TcpCallback getFunc(std::string tid);
  240. private:
  241. TcpCacheManager();
  242. private:
  243. std::map<std::string, TcpCallback> cb;
  244. };
  245. static std::string appUpdate = "appUpdate";
  246. #endif /* JNI_SERVICE_BUSINESSCONFIG_H_ */