c7dea5afd0f10c0ba0da823fd6703934f78f5566.svn-base 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. 
  2. BemsWebApplication.AlarmLog = function (params, viewInfo) {
  3. "use strict";
  4. // 알람 정보 저장
  5. var DataArrayInfo = [];
  6. var now = new Date();
  7. function BemsAlarmLogDataSourceLoad(startday, endday) {
  8. var BemsAlarmLogDataSource = BemsWebApplication.DataUtil.createDataSource({
  9. dataSourceOptions: {
  10. select: [
  11. 'CreatedDateTime', 'BemsAlarmSetting/FacilityName', 'BemsAlarmSetting/PointName', 'CurrentValue', 'BemsAlarmSetting/UpperLimit', 'BemsAlarmSetting/LowerLimit', 'SMSResult', 'EmailResult',
  12. 'SiteId', 'FacilityTypeId', 'FacilityCode', 'PropertyId', 'FormulaId', 'Conform'
  13. ],
  14. expand: ['BemsAlarmSetting'],
  15. extendOptions: {
  16. forceOriginalField: true,
  17. alterNames: {
  18. 'BemsAlarmSetting/FacilityName': 'FacilityName',
  19. 'BemsAlarmSetting/PointName': 'PointName',
  20. 'BemsAlarmSetting/UpperLimit': 'UpperLimit',
  21. 'BemsAlarmSetting/LowerLimit': 'LowerLimit'
  22. }
  23. },
  24. filter: [
  25. ['SiteId', '=', BWA.UserInfo.SiteId()],
  26. 'and',
  27. ['CreatedDateTime', '>=', startday],
  28. 'and',
  29. ['CreatedDateTime', '<=', endday]]
  30. }
  31. }, 'BemsAlarmLog');
  32. BemsAlarmLogDataSource.load().done(function (result) {
  33. if (result.length == 0) {
  34. // 알람 버튼 색 컬러 변경 정지
  35. BWA.AlarmInfo.Alarm_Image_Change = false;
  36. }
  37. DataArrayInfo = []; // 초기화
  38. _.each(result, function (x) {
  39. var temp_conform;
  40. var temp = '';
  41. if (x.FormulaId() != 0) {
  42. temp = '성능분석';
  43. }
  44. else {
  45. if (x.FacilityTypeId() == 99) {
  46. temp = '가상시설';
  47. }
  48. else {
  49. temp = '일반시설';
  50. }
  51. }
  52. if (x.Conform())
  53. temp_conform = "ON";
  54. else
  55. temp_conform = "OFF";
  56. DataArrayInfo.push({
  57. CreatedDateTime: x.CreatedDateTime,
  58. Type: temp,
  59. FacilityName: x.FacilityName,
  60. PropertyName: x.PointName,
  61. CurrentValue: x.CurrentValue,
  62. UpperLimit: x.UpperLimit,
  63. LowerLimit: x.LowerLimit,
  64. SMSResult: x.SMSResult,
  65. EmailResult: x.EmailResult,
  66. Conform: temp_conform,
  67. SiteId: x.SiteId,
  68. FacilityTypeId: x.FacilityTypeId,
  69. FacilityCode: x.FacilityCode,
  70. PropertyId: x.PropertyId,
  71. FormulaId: x.FormulaId
  72. });
  73. });
  74. $("#gridContainer_alarm1").dxDataGrid("instance").option("dataSource", DataArrayInfo);
  75. })
  76. }
  77. function handleViewShown() {
  78. var tmpDate = new Date();
  79. var endDay = tmpDate.getDate();
  80. var startday = new Date(tmpDate.getFullYear(), tmpDate.getMonth(), endDay-7, 0, 0, 0, 0);
  81. var endday = new Date(tmpDate.getFullYear(), tmpDate.getMonth(), endDay, 23, 59, 59, 0);
  82. $("#startDate").dxDateBox("instance").option('value', startday);
  83. $("#endDate").dxDateBox("instance").option('value', endday);
  84. $("#gridContainer_alarm1").dxDataGrid({
  85. rowAlternationEnabled: true,
  86. paging: {
  87. pageSize: 16
  88. },
  89. columns: [
  90. {
  91. dataField: 'CreatedDateTime', caption: '날짜', width: '12%', alignment: 'center', sortOrder: 'desc', dataType: "shortDate", format: "yyyy-MM-dd hh:mm:ss",
  92. customizeText: function (cellInfo) {
  93. return cellInfo.valueText;
  94. }
  95. },
  96. {
  97. dataField: 'Type', caption: '타입', width: '5%', alignment: 'center'
  98. },
  99. {
  100. dataField: 'FacilityName', caption: '설비명칭', width: '20%', alignment: 'center'
  101. },
  102. {
  103. dataField: 'PropertyName', caption: '관제점(분석요소)', width: '20%', alignment: 'center'
  104. },
  105. {
  106. dataField: 'CurrentValue', caption: '값', width: '8%', alignment: 'center'
  107. },
  108. {
  109. dataField: 'UpperLimit', caption: '기준상한(이상)', width: '8%', alignment: 'center'
  110. },
  111. {
  112. dataField: 'LowerLimit', caption: '기준하한(이하)', width: '8%', alignment: 'center'
  113. },
  114. {
  115. dataField: 'SMSResult', caption: 'SMS 결과', width: '5.5%', alignment: 'center'
  116. },
  117. {
  118. dataField: 'EmailResult', caption: 'Email 결과', width: '6.5%', alignment: 'center'
  119. },
  120. {
  121. dataField: 'Conform', caption: '알람해제', width: '7%', alignment: 'center'
  122. },
  123. // 아래 visible 속성을 true를 준 이유는 조치방법 확인을 클릭했을때, SiteId 등의 값을 읽어오지 못해서다
  124. {
  125. dataField: 'SiteId', visible: false
  126. },
  127. {
  128. dataField: 'FacilityTypeId', visible: false
  129. },
  130. {
  131. dataField: 'FacilityCode', visible: false
  132. },
  133. {
  134. dataField: 'PropertyId', visible: false
  135. },
  136. { dataField: 'FormulaId', visible: false },
  137. ],
  138. // 2019.04.17 엑셀 출력 기능 추가 ~~~
  139. "export": {
  140. enabled: true,
  141. fileName: '알람 로그 내역'
  142. }
  143. // ~~~ 2019.04.17 엑셀 출력 기능 추가
  144. });
  145. BemsAlarmLogDataSourceLoad(startday, endday);
  146. }
  147. var searchViewOptions = {
  148. }
  149. function handleSearchInSearchView() {
  150. }
  151. var viewModel = $.extend(BWA.CommonView.create(params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null, handleSearchInSearchView),
  152. {
  153. startDate: {
  154. pickerType: "calendar",
  155. value: now,
  156. formatString: "yyyy년 MM월 dd일",
  157. maxZoomLevel: "month",
  158. width: "12%"
  159. },
  160. endDate: {
  161. pickerType: "calendar",
  162. value: now,
  163. formatString: "yyyy년 MM월 dd일",
  164. maxZoomLevel: "month",
  165. width: "12%"
  166. },
  167. modifyButtonClicked: function () {
  168. var startDate = $("#startDate").dxDateBox("instance").option('value');
  169. var endDate = $("#endDate").dxDateBox("instance").option('value');
  170. var endday = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate(), 23, 59, 59, 0);
  171. BemsAlarmLogDataSourceLoad(startDate, endday);
  172. }
  173. });
  174. return viewModel;
  175. };