alarm-popup.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. 
  2. BWA.AlarmInfo = {
  3. Alarm_Image_Change: ko.observable(false)
  4. };
  5. $(function () {
  6. 'use strict';
  7. var AlarmPopupVisible = ko.observable(false);
  8. BWA.AlarmPopup = {
  9. AlarmPopupOptions: {
  10. visible: AlarmPopupVisible,
  11. width: '1400px',
  12. height: '850px', // cyim 2017.05.30 : 테스트 결과 Devextreme 버그임. px 로 지정하면 초기 출력시 정확하게 가운데에 있지만, auto 설정시 화면아래에 위치하게 됨
  13. contentTemplate: "content",
  14. showTitle: true,
  15. title: "알람정보",
  16. dragEnabled: false,
  17. closeOnOutsideClick: false,
  18. shadingColor: 'rgba(0,0,0,0.0)',
  19. shownAction: handlePopupShown,
  20. animation: window.utils.popup.createAnimation()
  21. },
  22. AlarmPopupOpen: function() {
  23. AlarmPopupVisible(true);
  24. },
  25. AlarmPopupCheckOptions: {
  26. visible: false,
  27. width: '400px',
  28. height: '400px', // cyim 2017.05.30 : 테스트 결과 Devextreme 버그임. px 로 지정하면 초기 출력시 정확하게 가운데에 있지만, auto 설정시 화면아래에 위치하게 됨
  29. contentTemplate: "content",
  30. showTitle: true,
  31. title: "조치방법",
  32. dragEnabled: false,
  33. closeOnOutsideClick: false,
  34. shadingColor: 'rgba(0,0,0,0.0)',
  35. //shownAction: handlePopupShown,
  36. animation: window.utils.popup.createAnimation()
  37. },
  38. }
  39. // 알람 정보 저장
  40. var DataArrayInfo = [];
  41. // 팝업 생성되면서 실행
  42. function handlePopupShown() {
  43. // dxLoadPanel 패널
  44. $("#LoadPanel").dxLoadPanel({
  45. message: '전체 알람 해제중...',
  46. showIndicator: true,
  47. visible: false
  48. });
  49. $("#Button_StopAlarm").dxButton({
  50. text: "전체 알람 해제",
  51. onClick: function () {
  52. var num = DataArrayInfo.length;
  53. if (num == 0) {
  54. // 에러 발생
  55. utils.toast.show('해제 할 알람 정보가 없습니다.', 'error');
  56. return;
  57. }
  58. DevExpress.ui.dialog.confirm("전체 알람 해제 하시겠습니까?", "전체 알람 해제").done(function (dialogResult) {
  59. if (dialogResult)
  60. {
  61. // 전체 알람 해제 버튼 비활성화
  62. $("#Button_StopAlarm").dxButton('instance').option('disabled', true);
  63. // dxLoadPanel 패널 시작
  64. $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
  65. // 알람 버튼 색 컬러 변경 정지
  66. BWA.AlarmInfo.Alarm_Image_Change = false;
  67. var index = 0;
  68. for (var i = 0; i < num; i++) {
  69. BWA.db.BemsAlarmLog.update({
  70. SiteId: DataArrayInfo[i].SiteId(),
  71. FacilityTypeId: DataArrayInfo[i].FacilityTypeId(),
  72. FacilityCode: DataArrayInfo[i].FacilityCode(),
  73. PropertyId: DataArrayInfo[i].PropertyId(),
  74. FormulaId: DataArrayInfo[i].FormulaId(),
  75. CreatedDateTime: DataArrayInfo[i].CreatedDateTime()
  76. },
  77. {
  78. Conform: true // 확인함
  79. }).done(function () {
  80. index++;
  81. if (num == index) {
  82. // 데이터 갱신
  83. DataArrayInfo = [];
  84. $("#gridContainer_alarm").dxDataGrid("instance").option("dataSource", DataArrayInfo);
  85. // 전체 알람 해제 버튼 활성화
  86. $("#Button_StopAlarm").dxButton('instance').option('disabled', false);
  87. // dxLoadPanel 패널 종료
  88. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  89. }
  90. }).fail(function () {
  91. index++;
  92. if (num == index) {
  93. // 전체 알람 해제 버튼 활성화
  94. $("#Button_StopAlarm").dxButton('instance').option('disabled', false);
  95. // dxLoadPanel 패널 종료
  96. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  97. // 에러 발생
  98. utils.toast.show('전체 알람 해제시 에러가 발생하였습니다.', 'error');
  99. }
  100. });
  101. }
  102. }
  103. });
  104. }
  105. });
  106. // 그리드 세팅
  107. $("#gridContainer_alarm").dxDataGrid({
  108. rowAlternationEnabled: true,
  109. paging: {
  110. pageSize: 21
  111. },
  112. columns: [
  113. { dataField: 'CreatedDateTime', caption: '날짜', width: '12%', alignment: 'center', dataType: 'date', format: 'yyyy-MM-dd HH:mm:ss', sortOrder: 'asc', },
  114. { dataField: 'Type', caption: '타입', width: '5%', alignment: 'center' },
  115. { dataField: 'FacilityName', caption: '설비명칭', width: '20%', alignment: 'center' },
  116. { dataField: 'PropertyName', caption: '관제점(분석요소)', width: '20%', alignment: 'center' },
  117. { dataField: 'CurrentValue', caption: '값', width: '8%', alignment: 'center' },
  118. { dataField: 'UpperLimit', caption: '기준상한(이상)', width: '9%', alignment: 'center' },
  119. { dataField: 'LowerLimit', caption: '기준하한(이하)', width: '9%', alignment: 'center' },
  120. { dataField: 'SMSResult', caption: 'SMS 결과', width: '6%', alignment: 'center' },
  121. { dataField: 'EmailResult', caption: 'Email 결과', width: '6%', alignment: 'center' },
  122. { dataField: 'Check', caption: '조치방법', width: '5%', alignment: 'center' },
  123. // 아래 visible 속성을 true를 준 이유는 조치방법 확인을 클릭했을때, SiteId 등의 값을 읽어오지 못해서다
  124. { dataField: 'SiteId', visible: true },
  125. { dataField: 'FacilityTypeId', visible: true },
  126. { dataField: 'FacilityCode', visible: true },
  127. { dataField: 'PropertyId', visible: true },
  128. { dataField: 'FormulaId', visible: true },
  129. ],
  130. //dataSource: setDataSource,
  131. onCellClick: function (object) {
  132. if (object.columnIndex == 9) {
  133. var DataArrayInfo = object.values;
  134. var SiteId = DataArrayInfo[10];
  135. var FacilityTypeId = DataArrayInfo[11];
  136. var FacilityCode = DataArrayInfo[12];
  137. var PropertyId = DataArrayInfo[13];
  138. var FormulaId = DataArrayInfo[14];
  139. // 조치 방법
  140. $("#PopupAlarmCheck").dxPopup('instance').option('visible', true);
  141. var BemsAlarmSettingDataSource = BemsWebApplication.db.createDataSource('BemsAlarmSetting');
  142. BemsAlarmSettingDataSource.filter([
  143. ['SiteId', '=', parseInt(SiteId)],
  144. 'and',
  145. ['FacilityTypeId', '=', parseInt(FacilityTypeId)],
  146. 'and',
  147. ['FacilityCode', '=', parseInt(FacilityCode)],
  148. 'and',
  149. ['PropertyId', '=', parseInt(PropertyId)],
  150. 'and',
  151. ['FormulaId', '=', parseInt(FormulaId)]
  152. ]);
  153. BemsAlarmSettingDataSource.load().done(function (result) {
  154. _.each(result, function (x) {
  155. $("#TextArea_Check").dxTextArea({
  156. disabled: true,
  157. value: x.Content
  158. });
  159. });
  160. })
  161. }
  162. },
  163. });
  164. var BemsAlarmLogDataSource = BemsWebApplication.DataUtil.createDataSource({
  165. dataSourceOptions: {
  166. select: [
  167. 'CreatedDateTime', 'BemsAlarmSetting/FacilityName', 'BemsAlarmSetting/PointName', 'CurrentValue', 'BemsAlarmSetting/UpperLimit', 'BemsAlarmSetting/LowerLimit', 'SMSResult', 'EmailResult',
  168. 'SiteId', 'FacilityTypeId', 'FacilityCode', 'PropertyId', 'FormulaId'
  169. ],
  170. expand: ['BemsAlarmSetting'],
  171. extendOptions: {
  172. forceOriginalField: true,
  173. alterNames: {
  174. 'BemsAlarmSetting/FacilityName': 'FacilityName',
  175. 'BemsAlarmSetting/PointName': 'PointName',
  176. 'BemsAlarmSetting/UpperLimit': 'UpperLimit',
  177. 'BemsAlarmSetting/LowerLimit': 'LowerLimit'
  178. }
  179. },
  180. filter: [
  181. ['SiteId', '=', BWA.UserInfo.SiteId()],
  182. 'and',
  183. ['Conform', '=', false]
  184. ]
  185. }
  186. }, 'BemsAlarmLog');
  187. BemsAlarmLogDataSource.load().done(function (result) {
  188. if(result.length == 0)
  189. {
  190. // 알람 버튼 색 컬러 변경 정지
  191. BWA.AlarmInfo.Alarm_Image_Change = false;
  192. }
  193. DataArrayInfo = []; // 초기화
  194. _.each(result, function (x) {
  195. var temp = '';
  196. if (x.FormulaId() != 0) {
  197. temp = '성능분석';
  198. }
  199. else {
  200. if (x.FacilityTypeId() == 99) {
  201. temp = '가상시설';
  202. }
  203. else {
  204. temp = '일반시설';
  205. }
  206. }
  207. DataArrayInfo.push({
  208. CreatedDateTime: x.CreatedDateTime,
  209. Type: temp,
  210. FacilityName: x.FacilityName,
  211. PropertyName: x.PointName,
  212. CurrentValue: x.CurrentValue,
  213. UpperLimit: x.UpperLimit,
  214. LowerLimit: x.LowerLimit,
  215. SMSResult: x.SMSResult,
  216. EmailResult: x.EmailResult,
  217. Check: "확인",
  218. SiteId: x.SiteId,
  219. FacilityTypeId: x.FacilityTypeId,
  220. FacilityCode: x.FacilityCode,
  221. PropertyId: x.PropertyId,
  222. FormulaId: x.FormulaId
  223. });
  224. });
  225. $("#gridContainer_alarm").dxDataGrid("instance").option("dataSource", DataArrayInfo);
  226. })
  227. //var setDataSource = new Array();
  228. //var setData = {
  229. // "CreatedDateTime": "2018-05-03 14:00:00", "Type": "", "FacilityName": "", "PropertyName": "", "CurrentValue": 0, "UpperLimit": 0, "LowerLimit": 0, "Chekck": "",
  230. // "SiteId": 0, "FacilityTypeId": 0, "FacilityCode": 0, "PropertyId": 0, "FormulaId": 0
  231. //};
  232. //setData.CreatedDateTime = "2018-05-03 14:00:00";
  233. //setData.Type = "성능분석";
  234. //setData.FacilityName = "공조기_AHU - 101";
  235. //setData.PropertyName = "난방ATF";
  236. //setData.CurrentValue = 10;
  237. //setData.UpperLimit = 10;
  238. //setData.LowerLimit = 5;
  239. //setData.Chekck = "확인";
  240. //setDataSource.push(setData);
  241. }
  242. });