BusinessConfig.h 8.5 KB

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