BusinessConfig.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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.29";
  49. static int versionNo = 29;
  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. // 设置护理的tcpModel
  108. void setNursingTcpModel(TcpModel source);
  109. /**
  110. * 设置增援按钮是否可用
  111. */
  112. void setBtnHelpVisible(bool visible);
  113. /**
  114. * 取消 增援一分钟后自动取消
  115. */
  116. void cancelAutoBtnHelpTimer();
  117. // 设置调试的按键框
  118. void setCheckbox(std::string check);
  119. // 查询取消呼叫的tid
  120. std::string getCencalByDoorTid();
  121. enum CallFinishType {
  122. CANCEL,
  123. REJECT,
  124. CANCEL_BY_DOOR,
  125. BUSY,
  126. HANDOFF,
  127. FAILED,
  128. ACCEPT,
  129. A1CLICK,
  130. KEY6_CLICK,
  131. };
  132. void callActivityFinish(CallFinishType type);
  133. void buildSIP(std::string toSipId);
  134. void acceptSIP();
  135. void sendVoiceTcp(std::string action, TcpModel model, int toId);
  136. class PartSetting{
  137. public:
  138. inline static int id;
  139. inline static std::string unionId;
  140. inline static int partId;
  141. inline static std::string dayStart;
  142. inline static int dayLight;
  143. inline static int dayVol;
  144. inline static int dayRingVol;
  145. inline static int dayRingTimes;
  146. inline static int dayNurseLed;
  147. inline static int dayDoorVol;
  148. inline static int dayBedVol;
  149. inline static int dayTransferBoxVol;
  150. inline static int dayTransferBoxSystemVol;
  151. inline static std::string nightStart;
  152. inline static int nightLight;
  153. inline static int nightVol;
  154. inline static int nightRingVol;
  155. inline static int nightRingTimes;
  156. inline static int nightNurseLed;
  157. inline static int nightDoorVol;
  158. inline static int nightBedVol;
  159. inline static int nightTransferBoxVol;
  160. inline static int nightTransferBoxSystemVol;
  161. inline static int sleepSecondsNurse;
  162. inline static int sleepSecondsDoor;
  163. inline static int sleepSecondsBed;
  164. inline static int sipOvertime;
  165. inline static int transferDuration;
  166. inline static int transferDurationLeader;
  167. inline static int communicationModeBed;
  168. inline static int communicationModeNurse;
  169. inline static int communicationModeMobile;
  170. inline static int customizeRoleCallFirst;
  171. inline static int customizeRoleCallSecond;
  172. inline static int customizeRoleCallThird;
  173. inline static int customizeRoleCallFourth;
  174. inline static int customizeRoleCallFifth;
  175. inline static int customizeHospitalCallFirst;
  176. inline static std::string customizeHospitalCallFirstName;
  177. inline static int customizeHospitalCallSecond;
  178. inline static std::string customizeHospitalCallSecondName;
  179. inline static int customizeHospitalCallThird;
  180. inline static std::string customizeHospitalCallThirdName;
  181. inline static std::string doctorTitle;
  182. inline static int doctorValid;
  183. inline static std::string nurseTitle;
  184. inline static int nurseValid;
  185. inline static std::string doorNurseTitle;
  186. inline static int doorNurseValid;
  187. inline static std::string doorNursingTitle;
  188. inline static int doorNursingValid;
  189. inline static int upSeconds;
  190. inline static int autoAccept;
  191. inline static bool boardShowEmptyBed;
  192. inline static int eventForward;
  193. inline static std::string nursingColorRgb;
  194. inline static int twoColorDoorLightValid;
  195. inline static std::string qrUrl;
  196. inline static int screenLight;
  197. inline static int roomCallBed;
  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 warnText = "warnText";
  227. class CallingStatus{
  228. public:
  229. virtual ~CallingStatus();
  230. static CallingStatus* instance();
  231. void setBusy(bool busy);
  232. void setTcpModel(TcpModel tcpModel);
  233. void clearTcpModel();
  234. static bool busy();
  235. TcpModel getTcpModel();
  236. long getInteractionId();
  237. private:
  238. CallingStatus();
  239. private:
  240. std::atomic<bool> _busy;
  241. TcpModel _tcpModel;
  242. long _interactionId;
  243. };
  244. class TcpCallback{
  245. public:
  246. std::string tid;
  247. std::string jsonStr;
  248. std::function<void(Json::Value json)> onSuccess;
  249. std::function<void(Json::Value json)> onFalied;
  250. };
  251. class TcpCacheManager{
  252. public:
  253. virtual ~TcpCacheManager();
  254. static TcpCacheManager* instance();
  255. void setFunc(std::string tid, TcpCallback callback);
  256. TcpCallback getFunc(std::string tid);
  257. private:
  258. TcpCacheManager();
  259. private:
  260. std::map<std::string, TcpCallback> cb;
  261. };
  262. static std::string appUpdate = "appUpdate";
  263. #endif /* JNI_SERVICE_BUSINESSCONFIG_H_ */