push.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /**
  2. * mcare_admin_push
  3. */
  4. var mcare_admin_push = function(){
  5. //상속
  6. mcare_admin.call(this);
  7. var self = this;
  8. //변수
  9. var $userId = $("#userId"),
  10. $msgNoValue = $("#msgNoValue"),
  11. $whenValue = $("#whenValue"),
  12. $whereValue = $("#whereValue"),
  13. $whatValue = $("#whatValue"),
  14. $howValue = $("#howValue"),
  15. $resultMsg = $("#resultMsg"),
  16. $sendPushBtn = $("#sendPush");
  17. $crudServiceBaseUrl = contextPath + "/admin/push";
  18. /**
  19. * 객체 초기화
  20. */
  21. this.init = function(){
  22. addEvent();
  23. };
  24. /**
  25. * 이벤트 등록
  26. */
  27. var addEvent = function(){
  28. // 메시지 보내기 이벤트
  29. $sendPushBtn.on("click", function(e) {
  30. sendPushMessage(e);
  31. });
  32. };
  33. /**
  34. * 문자열 처리용
  35. */
  36. String.format = function() {
  37. // The string containing the format items (e.g. "{0}")
  38. // will and always has to be the first argument.
  39. var theString = arguments[0];
  40. // start with the second argument (i = 1)
  41. for (var i = 1; i < arguments.length; i++) {
  42. // "gm" = RegEx options for Global search (more than one instance)
  43. // and for Multiline search
  44. var regEx = new RegExp("\\{" + (i - 1) + "\\}", "gm");
  45. theString = theString.replace(regEx, arguments[i]);
  46. }
  47. return theString;
  48. };
  49. var sendPushMessage = function(e) {
  50. var item = {};
  51. var message = "";
  52. item['userId'] = $userId.val();
  53. item['msgNoValue'] = $msgNoValue.val();
  54. item['whenValue'] = $whenValue.val();
  55. item['whereValue'] = $whereValue.val();
  56. item['whatValue'] = $whatValue.val();
  57. item['howValue'] = $howValue.val();
  58. // 접수단계 - 01 ===================================================
  59. // 기간계/접수/예약/상황안내
  60. if(item['msgNoValue'] == 'MA-10-05-40') {
  61. // 10시, 내과에 예약 있습니다
  62. message = String.format("{0}, {1}에 {2} 있습니다.", item['whenValue'], item['whereValue'], item['whatValue']);
  63. }
  64. // 모바일/접수/도착/상황안내
  65. else if(item['msgNoValue'] == 'MM-10-01-40') {
  66. // 내과에 도착확인 되었습니다.
  67. message = String.format("{0}에 도착확인 되었습니다.", item['whereValue']);
  68. }
  69. // 모바일/접수/도착/요청
  70. else if(item['msgNoValue'] == 'MM-10-01-10') {
  71. // 내과에 오셔서 도착을 알려주세요
  72. message = String.format("{0}에 오셔서 도착을 알려주세요.", item['whereValue']);
  73. }
  74. // 앱/접수/번호표/선택
  75. else if(item['msgNoValue'] == 'MA-10-02-20') {
  76. // 진료를 위해 원무과 접수창구의 번호표를 발급받으시겠습니까? [번호표발급]
  77. message = String.format("진료를 위해 {0} {1} 창구의 번호표를 발급받으시겠습니까? [번호표발급]", item['whereValue'], item['whatValue']);
  78. }
  79. // 모바일/접수/번호표/상황안내
  80. else if(item['msgNoValue'] == 'MM-10-02-40') {
  81. // 대기번호 xx번, 현재 대기인원 yy명 입니다.
  82. message = String.format("대기번호 {0}번, 현재 대기인원 {1}명 입니다.", item['whatValue'], item['howValue']);
  83. }
  84. // 기간계/접수/번호표/세부위치
  85. else if(item['msgNoValue'] == 'ML-10-02-31') {
  86. // n번 창구로 방문하세요
  87. message = String.format("{0}님, {1}번 창구로 방문하세요.", item['userId'], item['whereValue']);
  88. }
  89. //
  90. // 진료단계 - 02 ===================================================
  91. // 기간계/진료/진료/길안내
  92. else if(item['msgNoValue'] == 'ML-20-03-30') {
  93. // 내과로 가세요
  94. message = String.format("{0}로 가세요. [길안내]", item['whereValue']);
  95. }
  96. // 기간계/진료/진료/상황안내
  97. else if(item['msgNoValue'] == 'ML-20-03-40') {
  98. // 내과는 현재 10분 지연되고 있습니다
  99. message = String.format("{0}는 현재 {1}분 지연되고 있습니다. [진료대기시간조회]", item['whereValue'], item['whenValue']);
  100. }
  101. // 기간계/진료/진료/세부위치
  102. else if(item['msgNoValue'] == 'ML-20-03-31') {
  103. // 홍길동님, 내과 5번방으로 오세요
  104. message = String.format("{0}님, {1}에 오세요.", item['userId'], item['whereValue']);
  105. }
  106. // 기간계/진료/수납/길안내
  107. else if(item['msgNoValue'] == 'ML-20-04-30') {
  108. // 내시경실로 가세요
  109. message = String.format("수납 후 {0}으로 가세요. [길안내]", item['whereValue']); // ==> 여기에 도착알림 해야하나? 안함
  110. }
  111. //
  112. // 수납단계 - 03 ===================================================
  113. // 기간계/수납/수납/길안내
  114. else if(item['msgNoValue'] == 'ML-30-04-30') {
  115. // 진료가 완료되었습니다. 수납해주세요.
  116. message = String.format("진료가 완료되었습니다. 수납해주세요. [수납위치안내]", item['whereValue']);
  117. }
  118. //
  119. // 귀가단계 - 04 ===================================================
  120. // 앱/귀가/주차/상황안내
  121. else if(item['msgNoValue'] == 'MA-40-07-40') {
  122. // 등록된 차량번호는 xxx입니다.
  123. message = String.format("등록된 차량번호는 {0}입니다. [차량번호관리]", item['whatValue']);
  124. }
  125. // 모바일/귀가/예약/상황안내
  126. else if(item['msgNoValue'] == 'MA-40-05-40') {
  127. // 다음 내원일은 xxxx년 xx월 xx일 입니다.
  128. message = String.format("다음 내원일은 {0}입니다. [예약내역조회]", item['whenValue']);
  129. }
  130. // 기간계/귀가/조제/상황안내
  131. else if(item['msgNoValue'] == 'ML-40-06-40') {
  132. // 원내약국에 약이 조제완료되었습니다.
  133. message = String.format("{0}에 약이 조제완료되었습니다. [길안내]", item['whereValue']);
  134. }
  135. else {
  136. message = String.format("{0} {1} {2} {3} {4} {5}",
  137. item['userId'], item['msgNoValue'], item['whenValue'], item['whereValue'], item['whatValue'], item['howValue']);
  138. }
  139. $resultMsg.text(message);
  140. console.log(message);
  141. /*
  142. $.ajax({
  143. url : $crudServiceBaseUrl + '/sendPush.json',
  144. type : "POST",
  145. data : JSON.stringify(item),
  146. contentType:"application/json; charset=utf-8",
  147. dataType:"json",
  148. success : function(data) {
  149. if(data.msg != null) {
  150. alert("수행 중 에러가 발생하였습니다. ");
  151. }
  152. alert("염려마세요. 잘 끝났습니다. ");
  153. }
  154. });
  155. */
  156. };
  157. };