BusinessConfig.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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.19";
  48. static int versionNo = 19;
  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. // 查询呼叫、增援、sos列表
  85. Json::Value getPainterInfoList();
  86. // 门灯还原
  87. void doorLampRestoration();
  88. /**
  89. * 设置床位区块颜色和文字
  90. */
  91. void setPainterInfo(int deviceId, uint32_t bgColor, const std::string& msg, const std::string type, const std::string handle, int endTime);
  92. // 设置增援状态
  93. void setReinforce(bool result);
  94. // 设置增援按钮
  95. void setHelpButton(const char *pPicPath, bool isTouchable);
  96. /**
  97. * 刷新设备数据
  98. */
  99. void dataRefresh();
  100. // 获取科室设置
  101. void getPartSetting();
  102. // 获取息屏定时任务
  103. bool getSleepTimerRegistered();
  104. // 设置是否开启息屏定时任务
  105. void setSleepTimerRegistered(bool result);
  106. // 设置是否开启重启定时任务
  107. void setRestartTimerRegistered(bool result);
  108. // 设置护理的tcpModel
  109. void setNursingTcpModel(TcpModel source);
  110. /**
  111. * 设置增援按钮是否可用
  112. */
  113. void setBtnHelpVisible(bool visible);
  114. /**
  115. * 取消 增援一分钟后自动取消
  116. */
  117. void cancelAutoBtnHelpTimer();
  118. enum CallFinishType {
  119. CANCEL,
  120. REJECT,
  121. CANCEL_BY_DOOR,
  122. BUSY,
  123. HANDOFF,
  124. FAILED,
  125. ACCEPT,
  126. A1CLICK,
  127. KEY6_CLICK,
  128. };
  129. void callActivityFinish(CallFinishType type);
  130. void buildSIP(std::string toSipId);
  131. void acceptSIP();
  132. void sendVoiceTcp(std::string action, TcpModel model, int toId);
  133. class PartSetting{
  134. public:
  135. inline static int id;
  136. inline static std::string unionId;
  137. inline static int partId;
  138. inline static std::string dayStart;
  139. inline static int dayLight;
  140. inline static int dayVol;
  141. inline static int dayRingVol;
  142. inline static int dayRingTimes;
  143. inline static int dayNurseLed;
  144. inline static int dayDoorVol;
  145. inline static int dayBedVol;
  146. inline static int dayTransferBoxVol;
  147. inline static int dayTransferBoxSystemVol;
  148. inline static std::string nightStart;
  149. inline static int nightLight;
  150. inline static int nightVol;
  151. inline static int nightRingVol;
  152. inline static int nightRingTimes;
  153. inline static int nightNurseLed;
  154. inline static int nightDoorVol;
  155. inline static int nightBedVol;
  156. inline static int nightTransferBoxVol;
  157. inline static int nightTransferBoxSystemVol;
  158. inline static int sleepSecondsNurse;
  159. inline static int sleepSecondsDoor;
  160. inline static int sleepSecondsBed;
  161. inline static int sipOvertime;
  162. inline static int transferDuration;
  163. inline static int transferDurationLeader;
  164. inline static int communicationModeBed;
  165. inline static int communicationModeNurse;
  166. inline static int communicationModeMobile;
  167. inline static int customizeRoleCallFirst;
  168. inline static int customizeRoleCallSecond;
  169. inline static int customizeRoleCallThird;
  170. inline static int customizeRoleCallFourth;
  171. inline static int customizeRoleCallFifth;
  172. inline static int customizeHospitalCallFirst;
  173. inline static std::string customizeHospitalCallFirstName;
  174. inline static int customizeHospitalCallSecond;
  175. inline static std::string customizeHospitalCallSecondName;
  176. inline static int customizeHospitalCallThird;
  177. inline static std::string customizeHospitalCallThirdName;
  178. inline static std::string doctorTitle;
  179. inline static int doctorValid;
  180. inline static std::string nurseTitle;
  181. inline static int nurseValid;
  182. inline static std::string doorNurseTitle;
  183. inline static int doorNurseValid;
  184. inline static std::string doorNursingTitle;
  185. inline static int doorNursingValid;
  186. inline static int upSeconds;
  187. inline static int autoAccept;
  188. inline static bool boardShowEmptyBed;
  189. inline static int eventForward;
  190. inline static std::string nursingColorRgb;
  191. inline static int twoColorDoorLightValid;
  192. inline static std::string qrUrl;
  193. inline static int screenLight;
  194. };
  195. /**
  196. * 是否白天
  197. */
  198. static bool checkIsDay(){
  199. struct tm *t = TimeHelper::getDateTime();
  200. //获得当前日期
  201. char cDate[20];
  202. sprintf(cDate,"%d-%02d-%02d",
  203. 1900 + t->tm_year, 1+ t->tm_mon, t->tm_mday);
  204. std::string cDateStr = cDate;
  205. //组合白天与黑夜开始时间
  206. std::string dayStart = cDateStr + StoragePreferences::getString(STORE_DAY_START, " 07:00:00");
  207. std::string nightStart = cDateStr + StoragePreferences::getString(STORE_NIGHT_START, " 18:00:00");
  208. //LOGD("dayStart %s . nightStart %s", dayStart.c_str(), nightStart.c_str());
  209. time_t tDayStart = TimeHelper::StringToDatetime(dayStart);
  210. time_t tNightStart = TimeHelper::StringToDatetime(nightStart);
  211. time_t currentTime = mktime(t) - 28800;
  212. if (currentTime>=tDayStart && currentTime<= tNightStart){
  213. return true;
  214. }
  215. return false;
  216. //LOGD("tiDayStart %ld . tNightStart %ld . currentTime %ld", tDayStart, tNightStart, currentTime);
  217. }
  218. static std::string isOutgoing = "isOutgoing";
  219. static std::string audioOnly = "audioOnly";
  220. static std::string toIdStr = "toIdStr";
  221. static std::string callName = "callName";
  222. static std::string warnText = "warnText";
  223. class CallingStatus{
  224. public:
  225. virtual ~CallingStatus();
  226. static CallingStatus* instance();
  227. void setBusy(bool busy);
  228. void setTcpModel(TcpModel tcpModel);
  229. void clearTcpModel();
  230. static bool busy();
  231. TcpModel getTcpModel();
  232. long getInteractionId();
  233. private:
  234. CallingStatus();
  235. private:
  236. std::atomic<bool> _busy;
  237. TcpModel _tcpModel;
  238. long _interactionId;
  239. };
  240. class TcpCallback{
  241. public:
  242. std::string tid;
  243. std::string jsonStr;
  244. std::function<void(Json::Value json)> onSuccess;
  245. std::function<void(Json::Value json)> onFalied;
  246. };
  247. class TcpCacheManager{
  248. public:
  249. virtual ~TcpCacheManager();
  250. static TcpCacheManager* instance();
  251. void setFunc(std::string tid, TcpCallback callback);
  252. TcpCallback getFunc(std::string tid);
  253. private:
  254. TcpCacheManager();
  255. private:
  256. std::map<std::string, TcpCallback> cb;
  257. };
  258. static std::string appUpdate = "appUpdate";
  259. #endif /* JNI_SERVICE_BUSINESSCONFIG_H_ */