BusinessConfig.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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_SLEEP_TIME "sleep_time"
  30. #define STORE_DAY_START "day_start"
  31. #define STORE_DAY_LIGHT "day_light"
  32. #define STORE_DAY_VOL "day_vol"
  33. #define STORE_DAY_RING_TIMES "day_ring_times"
  34. #define STORE_NIGHT_START "night_start"
  35. #define STORE_NIGHT_LIGHT "night_light"
  36. #define STORE_NIGHT_VOL "night_vol"
  37. #define STORE_NIGHT_RING_TIMES "night_ring_times"
  38. #define STORE_DOCTOR_TITLE "doctor_title"
  39. #define STORE_DOCTOR_VISIBLE "doctor_visible"
  40. #define STORE_NURSE_TITLE "nurse_title"
  41. #define STORE_NURSE_VISIBLE "nurse_visible"
  42. #define STORE_NURSING_COLOR_RGB "nursing_color_rgb"
  43. #define STORE_NURSING_TYPE "nursing_type" // 护理的状态,如果是true,那就在护理中,如果是false,那就不在护理中
  44. #define STORE_AUDO_ANSWER "auto_answer"
  45. #define STORE_SCREEN_LIGHT "screen_light"
  46. #define SIGNAL_TYPE "TCP" //TCP,SIP
  47. static std::string version = "v1.0.25";
  48. static int versionNo = 25;
  49. static std::string serverIP = "172.28.100.100";
  50. static std::string tcpIP = "172.28.100.100";
  51. static int serverHttpPort = 8006;
  52. static int serverTcpPort = 5086;
  53. static std::string getHttpGateway(){
  54. std::string sserverIP = StoragePreferences::getString(STORE_GATEWAY, serverIP);
  55. int sserverHttpPort = StoragePreferences::getInt(STORE_HTTP_PORT, serverHttpPort);
  56. char gateWay[100];
  57. sprintf(gateWay,"http://%s:%d",sserverIP.c_str(),sserverHttpPort);
  58. LOGD("getHttpGateway %s",gateWay);
  59. return gateWay;
  60. }
  61. static std::string getTcpGateway(){
  62. std::string sserverIP = StoragePreferences::getString(STORE_TCP_LOCAL_IP, tcpIP);
  63. StoragePreferences::putInt(STORE_TCP_PORT, serverTcpPort);
  64. int sserverTcpPort = StoragePreferences::getInt(STORE_TCP_PORT, serverTcpPort);
  65. char gateWay[100];
  66. sprintf(gateWay,"%s:%d",sserverIP.c_str(),sserverTcpPort);
  67. LOGD("getTcpGateway %s",gateWay);
  68. return gateWay;
  69. }
  70. static std::string getVersion() {
  71. LOGD("version -> %s",version);
  72. return version;
  73. }
  74. static int getVersionNo() {
  75. LOGD("versionNo -> %d", versionNo);
  76. return versionNo;
  77. }
  78. /**
  79. * 设置科室名称
  80. */
  81. void NavibarSetPartName(const std::string& partName);
  82. // 传入时间,获取时间的总秒数
  83. int getTime(char* timeStr);
  84. // 门灯还原
  85. void doorLampRestoration();
  86. /**
  87. * 刷新设备数据
  88. */
  89. void dataRefresh();
  90. // 获取科室设置
  91. void getPartSetting();
  92. // 获取息屏定时任务
  93. bool getSleepTimerRegistered();
  94. // 设置是否开启息屏定时任务
  95. void setSleepTimerRegistered(bool result);
  96. // 设置顶上颜色
  97. void setPartNameAndDateColor(uint32_t color);
  98. // 设置ui3界面的颜色
  99. void setUi3BgColor(uint32_t color);
  100. // 设置调试的按键框
  101. void setCheckbox(std::string check);
  102. enum CallFinishType {
  103. CANCEL,
  104. REJECT,
  105. CANCEL_BY_DOOR,
  106. BUSY,
  107. HANDOFF,
  108. FAILED,
  109. ACCEPT,
  110. A1CLICK,
  111. KEY6_CLICK,
  112. };
  113. void callActivityFinish(CallFinishType type);
  114. void buildSIP(std::string toSipId);
  115. void acceptSIP();
  116. void sendVoiceTcp(std::string action, TcpModel model, int toId);
  117. class PartSetting{
  118. public:
  119. inline static int id;
  120. inline static std::string unionId;
  121. inline static int partId;
  122. inline static std::string dayStart;
  123. inline static int dayLight;
  124. inline static int dayVol;
  125. inline static int dayRingVol;
  126. inline static int dayRingTimes;
  127. inline static int dayNurseLed;
  128. inline static int dayDoorVol;
  129. inline static int dayBedVol;
  130. inline static int dayTransferBoxVol;
  131. inline static int dayTransferBoxSystemVol;
  132. inline static std::string nightStart;
  133. inline static int nightLight;
  134. inline static int nightVol;
  135. inline static int nightRingVol;
  136. inline static int nightRingTimes;
  137. inline static int nightNurseLed;
  138. inline static int nightDoorVol;
  139. inline static int nightBedVol;
  140. inline static int nightTransferBoxVol;
  141. inline static int nightTransferBoxSystemVol;
  142. inline static int sleepSecondsNurse;
  143. inline static int sleepSecondsDoor;
  144. inline static int sleepSecondsBed;
  145. inline static int sipOvertime;
  146. inline static int transferDuration;
  147. inline static int transferDurationLeader;
  148. inline static int communicationModeBed;
  149. inline static int communicationModeNurse;
  150. inline static int communicationModeMobile;
  151. inline static int customizeRoleCallFirst;
  152. inline static int customizeRoleCallSecond;
  153. inline static int customizeRoleCallThird;
  154. inline static int customizeRoleCallFourth;
  155. inline static int customizeRoleCallFifth;
  156. inline static int customizeHospitalCallFirst;
  157. inline static std::string customizeHospitalCallFirstName;
  158. inline static int customizeHospitalCallSecond;
  159. inline static std::string customizeHospitalCallSecondName;
  160. inline static int customizeHospitalCallThird;
  161. inline static std::string customizeHospitalCallThirdName;
  162. inline static std::string doctorTitle;
  163. inline static int doctorValid;
  164. inline static std::string nurseTitle;
  165. inline static int nurseValid;
  166. inline static std::string doorNurseTitle;
  167. inline static int doorNurseValid;
  168. inline static std::string doorNursingTitle;
  169. inline static int doorNursingValid;
  170. inline static int upSeconds;
  171. inline static int autoAccept;
  172. inline static bool boardShowEmptyBed;
  173. inline static int eventForward;
  174. inline static std::string nursingColorRgb;
  175. inline static int twoColorDoorLightValid;
  176. inline static std::string qrUrl;
  177. inline static int screenLight;
  178. };
  179. class BabySex {
  180. public:
  181. inline static std::string boy = "boy";
  182. inline static std::string girl = "girl";
  183. inline static std::string twins_boy = "twins_boy";
  184. inline static std::string twins_girl = "twins_girl";
  185. inline static std::string twins_boy_and_girl = "twins_boy_and_girl";
  186. };
  187. /**
  188. * 是否白天
  189. */
  190. static bool checkIsDay(){
  191. struct tm *t = TimeHelper::getDateTime();
  192. //获得当前日期
  193. char cDate[20];
  194. sprintf(cDate,"%d-%02d-%02d",
  195. 1900 + t->tm_year, 1+ t->tm_mon, t->tm_mday);
  196. std::string cDateStr = cDate;
  197. //组合白天与黑夜开始时间
  198. std::string dayStart = cDateStr + StoragePreferences::getString(STORE_DAY_START, " 07:00:00");
  199. std::string nightStart = cDateStr + StoragePreferences::getString(STORE_NIGHT_START, " 18:00:00");
  200. //LOGD("dayStart %s . nightStart %s", dayStart.c_str(), nightStart.c_str());
  201. time_t tDayStart = TimeHelper::StringToDatetime(dayStart);
  202. time_t tNightStart = TimeHelper::StringToDatetime(nightStart);
  203. time_t currentTime = mktime(t) - 28800;
  204. if (currentTime>=tDayStart && currentTime<= tNightStart){
  205. return true;
  206. }
  207. return false;
  208. //LOGD("tiDayStart %ld . tNightStart %ld . currentTime %ld", tDayStart, tNightStart, currentTime);
  209. }
  210. static std::string isOutgoing = "isOutgoing";
  211. static std::string audioOnly = "audioOnly";
  212. static std::string toIdStr = "toIdStr";
  213. static std::string callName = "callName";
  214. static std::string warnText = "warnText";
  215. class CallingStatus{
  216. public:
  217. virtual ~CallingStatus();
  218. static CallingStatus* instance();
  219. void setBusy(bool busy);
  220. void setTcpModel(TcpModel tcpModel);
  221. void clearTcpModel();
  222. static bool busy();
  223. TcpModel getTcpModel();
  224. long getInteractionId();
  225. private:
  226. CallingStatus();
  227. private:
  228. std::atomic<bool> _busy;
  229. TcpModel _tcpModel;
  230. long _interactionId;
  231. };
  232. class TcpCallback{
  233. public:
  234. std::string tid;
  235. std::string jsonStr;
  236. std::function<void(Json::Value json)> onSuccess;
  237. std::function<void(Json::Value json)> onFalied;
  238. };
  239. class TcpCacheManager{
  240. public:
  241. virtual ~TcpCacheManager();
  242. static TcpCacheManager* instance();
  243. void setFunc(std::string tid, TcpCallback callback);
  244. TcpCallback getFunc(std::string tid);
  245. private:
  246. TcpCacheManager();
  247. private:
  248. std::map<std::string, TcpCallback> cb;
  249. };
  250. static std::string appUpdate = "appUpdate";
  251. #endif /* JNI_SERVICE_BUSINESSCONFIG_H_ */