BusinessConfig.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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_NURSING_INTERACTION_ID "nursing_interaction_id" // 护理的交互记录id
  45. #define STORE_AUDO_ANSWER "auto_answer"
  46. #define STORE_SCREEN_LIGHT "screen_light"
  47. #define STORE_ROOM_CALL_BED "room_call_bed"
  48. #define STORE_LIGHT "light"
  49. #define STORE_VOLUME "volume"
  50. #define SIGNAL_TYPE "TCP" //TCP,SIP
  51. #define STORE_VOLUME_NATIVE "volume_native"
  52. #define STORE_GAIN_SIZE "gain_size"
  53. #define STORE_MAC_ADDR "mac_addr"
  54. static std::string version = "v1.0.35";
  55. static int versionNo = 35;
  56. static std::string serverIP = "172.28.100.100";
  57. static std::string tcpIP = "172.28.100.100";
  58. static int serverHttpPort = 8006;
  59. static int serverTcpPort = 5086;
  60. static std::string getHttpGateway(){
  61. std::string sserverIP = StoragePreferences::getString(STORE_GATEWAY, serverIP);
  62. int sserverHttpPort = StoragePreferences::getInt(STORE_HTTP_PORT, serverHttpPort);
  63. char gateWay[100];
  64. sprintf(gateWay,"http://%s:%d",sserverIP.c_str(),sserverHttpPort);
  65. LOGD("getHttpGateway %s",gateWay);
  66. return gateWay;
  67. }
  68. static std::string getTcpGateway(){
  69. std::string sserverIP = StoragePreferences::getString(STORE_TCP_LOCAL_IP, tcpIP);
  70. StoragePreferences::putInt(STORE_TCP_PORT, serverTcpPort);
  71. int sserverTcpPort = StoragePreferences::getInt(STORE_TCP_PORT, serverTcpPort);
  72. char gateWay[100];
  73. sprintf(gateWay,"%s:%d",sserverIP.c_str(),sserverTcpPort);
  74. LOGD("getTcpGateway %s",gateWay);
  75. return gateWay;
  76. }
  77. static std::string getVersion() {
  78. LOGD("version -> %s",version);
  79. return version;
  80. }
  81. static int getVersionNo() {
  82. LOGD("versionNo -> %d", versionNo);
  83. return versionNo;
  84. }
  85. /**
  86. * 设置科室名称
  87. */
  88. void NavibarSetPartName(const std::string& partName);
  89. // 传入时间,获取时间的总秒数
  90. int getTime(char* timeStr);
  91. // 门灯还原
  92. //void doorLampRestoration();
  93. void lightControl(std::string typeStr, std::string lightColorStr);
  94. /**
  95. * 刷新设备数据
  96. */
  97. void dataRefresh();
  98. // 获取科室设置
  99. void getPartSetting();
  100. // 获取息屏定时任务
  101. bool getSleepTimerRegistered();
  102. // 设置是否开启息屏定时任务
  103. void setSleepTimerRegistered(bool result);
  104. // 设置callTid
  105. void setCallTid(std::string tid);
  106. // 设置调试的按键框
  107. void setCheckbox(std::string check);
  108. void setIsLight(bool _isLight);
  109. // 控制呼叫床位按钮是否显示
  110. void callBedButtonSetVisible();
  111. Json::Value getFrame();
  112. void helpResopnseFoFunctionActivity();
  113. void logoutMedicalCare();
  114. void setNursingEnd();
  115. void setNursing(bool setNursing);
  116. const bool checkAddr(std::string addr);
  117. enum CallFinishType {
  118. CANCEL,
  119. REJECT,
  120. CANCEL_BY_DOOR,
  121. BUSY,
  122. HANDOFF,
  123. FAILED,
  124. ACCEPT,
  125. A1CLICK,
  126. KEY6_CLICK,
  127. };
  128. void callActivityFinish(CallFinishType type);
  129. void buildSIP(std::string toSipId);
  130. void acceptSIP();
  131. void sendVoiceTcp(std::string action, TcpModel model, int toId);
  132. class PartSetting{
  133. public:
  134. inline static int id;
  135. inline static std::string unionId;
  136. inline static int partId;
  137. inline static std::string dayStart;
  138. inline static int dayLight;
  139. inline static int dayVol;
  140. inline static int dayRingVol;
  141. inline static int dayRingTimes;
  142. inline static int dayNurseLed;
  143. inline static int dayDoorVol;
  144. inline static int dayBedVol;
  145. inline static int dayTransferBoxVol;
  146. inline static int dayTransferBoxSystemVol;
  147. inline static std::string nightStart;
  148. inline static int nightLight;
  149. inline static int nightVol;
  150. inline static int nightRingVol;
  151. inline static int nightRingTimes;
  152. inline static int nightNurseLed;
  153. inline static int nightDoorVol;
  154. inline static int nightBedVol;
  155. inline static int nightTransferBoxVol;
  156. inline static int nightTransferBoxSystemVol;
  157. inline static int sleepSecondsNurse;
  158. inline static int sleepSecondsDoor;
  159. inline static int sleepSecondsBed;
  160. inline static int sipOvertime;
  161. inline static int transferDuration;
  162. inline static int transferDurationLeader;
  163. inline static int communicationModeBed;
  164. inline static int communicationModeNurse;
  165. inline static int communicationModeMobile;
  166. inline static int customizeRoleCallFirst;
  167. inline static int customizeRoleCallSecond;
  168. inline static int customizeRoleCallThird;
  169. inline static int customizeRoleCallFourth;
  170. inline static int customizeRoleCallFifth;
  171. inline static int customizeHospitalCallFirst;
  172. inline static std::string customizeHospitalCallFirstName;
  173. inline static int customizeHospitalCallSecond;
  174. inline static std::string customizeHospitalCallSecondName;
  175. inline static int customizeHospitalCallThird;
  176. inline static std::string customizeHospitalCallThirdName;
  177. inline static std::string doctorTitle;
  178. inline static int doctorValid;
  179. inline static std::string nurseTitle;
  180. inline static int nurseValid;
  181. inline static std::string doorNurseTitle;
  182. inline static int doorNurseValid;
  183. inline static std::string doorNursingTitle;
  184. inline static int doorNursingValid;
  185. inline static int upSeconds;
  186. inline static int autoAccept;
  187. inline static bool boardShowEmptyBed;
  188. inline static int eventForward;
  189. inline static std::string nursingColorRgb;
  190. inline static int twoColorDoorLightValid;
  191. inline static std::string qrUrl;
  192. inline static int screenLight;
  193. inline static int roomCallBed;
  194. inline static int linuxBedVolumeNative;
  195. inline static int linuxBedGainSize;
  196. inline static int linuxDoorVolumeNative;
  197. inline static int linuxDoorGainSize;
  198. };
  199. /**
  200. * 是否白天
  201. */
  202. static bool checkIsDay(){
  203. struct tm *t = TimeHelper::getDateTime();
  204. //获得当前日期
  205. char cDate[20];
  206. sprintf(cDate,"%d-%02d-%02d",
  207. 1900 + t->tm_year, 1+ t->tm_mon, t->tm_mday);
  208. std::string cDateStr = cDate;
  209. //组合白天与黑夜开始时间
  210. std::string dayStart = cDateStr + StoragePreferences::getString(STORE_DAY_START, " 07:00:00");
  211. std::string nightStart = cDateStr + StoragePreferences::getString(STORE_NIGHT_START, " 18:00:00");
  212. //LOGD("dayStart %s . nightStart %s", dayStart.c_str(), nightStart.c_str());
  213. time_t tDayStart = TimeHelper::StringToDatetime(dayStart);
  214. time_t tNightStart = TimeHelper::StringToDatetime(nightStart);
  215. time_t currentTime = mktime(t) - 28800;
  216. if (currentTime>=tDayStart && currentTime<= tNightStart){
  217. return true;
  218. }
  219. return false;
  220. //LOGD("tiDayStart %ld . tNightStart %ld . currentTime %ld", tDayStart, tNightStart, currentTime);
  221. }
  222. static std::string isOutgoing = "isOutgoing";
  223. static std::string audioOnly = "audioOnly";
  224. static std::string toIdStr = "toIdStr";
  225. static std::string callName = "callName";
  226. static std::string functionWindows = "functionWindows";
  227. static std::string functionText = "functionText";
  228. static std::string nursingText = "nursingText";
  229. static std::string warnText = "warnText";
  230. class CallingStatus{
  231. public:
  232. virtual ~CallingStatus();
  233. static CallingStatus* instance();
  234. void setBusy(bool busy);
  235. void setTcpModel(TcpModel tcpModel);
  236. void clearTcpModel();
  237. static bool busy();
  238. TcpModel getTcpModel();
  239. long getInteractionId();
  240. private:
  241. CallingStatus();
  242. private:
  243. std::atomic<bool> _busy;
  244. TcpModel _tcpModel;
  245. long _interactionId;
  246. };
  247. class TcpCallback{
  248. public:
  249. std::string tid;
  250. std::string jsonStr;
  251. std::function<void(Json::Value json)> onSuccess;
  252. std::function<void(Json::Value json)> onFalied;
  253. };
  254. class TcpCacheManager{
  255. public:
  256. virtual ~TcpCacheManager();
  257. static TcpCacheManager* instance();
  258. void setFunc(std::string tid, TcpCallback callback);
  259. TcpCallback getFunc(std::string tid);
  260. private:
  261. TcpCacheManager();
  262. private:
  263. std::map<std::string, TcpCallback> cb;
  264. };
  265. static std::string appUpdate = "appUpdate";
  266. #endif /* JNI_SERVICE_BUSINESSCONFIG_H_ */