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