457ba12cbf6f24b38a9b977cae5ceeafdf8139f1.svn-base 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. BemsWebApplication.FmsfacilityTime = function (params, viewInfo) {
  2. "use strict";
  3. var endpointSelector = "";
  4. if (BemsWebApplication.config.mode == "production") {
  5. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
  6. } else {
  7. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
  8. }
  9. // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가
  10. // 팝업창뷰 보이기 속성 제어용 변수 선언
  11. var DataGridPopup_Visible = ko.observable(false);
  12. // 그래프 출력 이후 엑셀출력을 위한 팝업창을 위해 임시 저장용 배열 선언
  13. var facilityTypeDataID;
  14. var facilityTypes = ko.observableArray();
  15. var facilityTypeDataSource = BemsWebApplication.db.createDataSource('BemsFacilityType');
  16. var faclilitydataSource, dataArrayresult, resultdataArrayresult = [];
  17. var timedataSource;
  18. var Action_time = 9 //시간별 운전 시간
  19. //timedataSource 초기화 함수
  20. function Source_init() {
  21. timedataSource = [{
  22. Num: 0,
  23. Name: "",
  24. Time: 0,
  25. FacilityCode: 0,
  26. PropertyId: 0,
  27. CurrentValue: 0,
  28. D0: 0, D1: 0, D2: 0, D3: 0, D4: 0, D5: 0, D6: 0, D7: 0, D8: 0, D9: 0, D10: 0, D11: 0, D12: 0, D13: 0, D14: 0, D15: 0, D16: 0, D17: 0, D18: 0, D19: 0, D20: 0, D21: 0, D22: 0, D23: 0, D24: 0, D25: 0, D26: 0, D27: 0, D28: 0, D29: 0, D30: 0
  29. }];
  30. dataArrayresult = [{
  31. Num: 0,
  32. Name: "",
  33. FacilityCode: 0,
  34. PropertyId: 0,
  35. CurrentValue: 0,
  36. D0: 0, D1: 0, D2: 0, D3: 0, D4: 0, D5: 0, D6: 0, D7: 0, D8: 0, D9: 0, D10: 0, D11: 0, D12: 0, D13: 0, D14: 0, D15: 0, D16: 0, D17: 0, D18: 0, D19: 0, D20: 0, D21: 0, D22: 0, D23: 0, D24: 0, D25: 0, D26: 0, D27: 0, D28: 0, D29: 0, D30: 0
  37. }];
  38. }
  39. function facilitydataSourceAdd(cnt) { // 설비 개수만큼 추가
  40. for (var i = 0; i < (cnt - 1) ; i++) {
  41. timedataSource.push({
  42. Num: 0,
  43. Name: "",
  44. Time: 0,
  45. FacilityCode: 0,
  46. PropertyId: 0,
  47. CurrentValue: 0,
  48. D0: 0, D1: 0, D2: 0, D3: 0, D4: 0, D5: 0, D6: 0, D7: 0, D8: 0, D9: 0, D10: 0, D11: 0, D12: 0, D13: 0, D14: 0, D15: 0, D16: 0, D17: 0, D18: 0, D19: 0, D20: 0, D21: 0, D22: 0, D23: 0, D24: 0, D25: 0, D26: 0, D27: 0, D28: 0, D29: 0, D30: 0
  49. });
  50. }
  51. for (var i = 0; i < (cnt - 1) ; i++) {
  52. dataArrayresult.push({
  53. Num: 0,
  54. Name: "",
  55. FacilityCode: 0,
  56. PropertyId: 0,
  57. CurrentValue: 0,
  58. D0: 0, D1: 0, D2: 0, D3: 0, D4: 0, D5: 0, D6: 0, D7: 0, D8: 0, D9: 0, D10: 0, D11: 0, D12: 0, D13: 0, D14: 0, D15: 0, D16: 0, D17: 0, D18: 0, D19: 0, D20: 0, D21: 0, D22: 0, D23: 0, D24: 0, D25: 0, D26: 0, D27: 0, D28: 0, D29: 0, D30: 0
  59. });
  60. }
  61. }
  62. var facilitydataSourceCnt = 0;
  63. var faclilitydataSourceCnt = 0;
  64. var dateChar; //초기값 -6
  65. // 보일러 시설 정보 겟 함수
  66. function GetFaclilityData() {
  67. switch (facilityTypeDataID) {
  68. case $Code.FacilityType.AIR_HANDLING: //공조기
  69. Action_time = $Code.FacilityTypeActTime.AIR_HANDLING;
  70. break;
  71. case $Code.FacilityType.REFRIGERATOR://냉동기
  72. Action_time = $Code.FacilityTypeActTime.REFRIGERATOR;
  73. break;
  74. case $Code.FacilityType.REFRIGERATOR_TOP://냉각탑
  75. Action_time = $Code.FacilityTypeActTime.REFRIGERATOR_TOP;
  76. break;
  77. case $Code.FacilityType.PUMP://펌프(브라인5),(지열순환펌프, 냉수,난방용온수순환,냉각수),
  78. Action_time = $Code.FacilityTypeActTime.PUMP;
  79. break;
  80. case $Code.FacilityType.BOILER://보일러
  81. Action_time = $Code.FacilityTypeActTime.BOILER;
  82. break;
  83. }
  84. var dataSource = new DevExpress.data.DataSource({
  85. store: {
  86. type: "odata",
  87. url: endpointSelector + "/CmFacility"
  88. },
  89. requireTotalCount: true,
  90. pageSize: 100
  91. });
  92. dataSource.filter([
  93. ["SiteId", "=", BWA.UserInfo.SiteId()],
  94. "and",
  95. ["FacilityTypeId", "=", facilityTypeDataID]
  96. ]);
  97. dataSource.load()
  98. .done(function (result) {
  99. faclilitydataSourceCnt = result.length; //설비 개수
  100. faclilitydataSource = result;
  101. GetFacilityDailyData();
  102. })
  103. .fail(function (error) {
  104. utils.toast.show(error);
  105. });
  106. }
  107. // 보일러 정보 가져오기 함수
  108. function GetFacilityDailyData() {
  109. Source_init(); //timedataSource 초기화
  110. facilitydataSourceAdd(faclilitydataSourceCnt); // timedataSource 필요한 만큼 추가
  111. dateChar = $("#facility_history_calendarPicker").dxDateBox("instance").option('value');
  112. var dataSource = new DevExpress.data.DataSource({
  113. store: {
  114. type: "odata",
  115. url: endpointSelector + "/BemsMonitoringPointHistoryDaily"
  116. },
  117. requireTotalCount: true,
  118. pageSize: 20000 // 설비 6개까지
  119. });
  120. dataSource.filter([
  121. ["SiteId", "=", BWA.UserInfo.SiteId()], //사이트 아이디
  122. "and",
  123. ["FacilityTypeId", "=", facilityTypeDataID], //설비 타입
  124. "and",
  125. ["PropertyId", "=", Action_time],//변경 Action_time // 이유: 가동시간 0이 아니면 무조건 가동으로 판단
  126. "and",
  127. ["CreatedDateTime", ">=", new Date(dateChar.getFullYear(), dateChar.getMonth(), dateChar.getDate(), 0, 0, 0)],
  128. "and",
  129. ["CreatedDateTime", "<", new Date(dateChar.getFullYear(), dateChar.getMonth() + 1, dateChar.getDate(), 0, 0, 0)]
  130. ]);
  131. dataSource.sort({ getter: "FacilityCode", ASC: true }, { getter: "CreatedDateTime", ASC: true });
  132. dataSource.load()
  133. .done(function (result) {
  134. facilitydataSourceCnt = result.length;
  135. var start = 0;
  136. var day = new Date();
  137. for (var i = 0; i < faclilitydataSourceCnt; i++)//설비 개수 = 행 개수
  138. {
  139. for (var j = start; j < facilitydataSourceCnt; j++) // 가져온 데이터는 350개
  140. {
  141. if (timedataSource[i].Name == "") {
  142. for (var k = 0; k < faclilitydataSourceCnt; k++)//설비 개수 = 행 개수
  143. {
  144. if (result[j].FacilityCode == faclilitydataSource[k].FacilityCode) {
  145. timedataSource[i].Name = faclilitydataSource[k].Name;
  146. timedataSource[i].FacilityCode = faclilitydataSource[k].FacilityCode;
  147. }
  148. }
  149. }
  150. if (timedataSource[i].FacilityCode != result[j].FacilityCode)
  151. break;
  152. ONOFF_state(i, j, result);
  153. start++;
  154. }
  155. }
  156. for (var i = 0; i < timedataSource.length; i++) { //백그라운드 컬러 위해서
  157. for (var j = 1; j <= 5; j = j + 2) {
  158. if ((i % 7) == j)
  159. timedataSource[i].Num = 1;
  160. }
  161. }
  162. if (new Date(dateChar.getFullYear(), dateChar.getMonth() + 1, dateChar.getDate() - 1, 0).getDate() != 31) {
  163. for (var i = 0; i < timedataSource.length; i++)
  164. switch (new Date(dateChar.getFullYear(), dateChar.getMonth() + 1, dateChar.getDate() - 1, 0).getDate()) {
  165. case 30:
  166. $("#facility_data_list").dxDataGrid("instance").columnOption('D31', "visible", false);
  167. $("#facility_data_list").dxDataGrid("instance").columnOption('D30', "visible", false);
  168. break;
  169. case 29:
  170. $("#facility_data_list").dxDataGrid("instance").columnOption('D31', "visible", false);
  171. $("#facility_data_list").dxDataGrid("instance").columnOption('D30', "visible", false);
  172. $("#facility_data_list").dxDataGrid("instance").columnOption('D29', "visible", false);
  173. break;
  174. case 28:
  175. $("#facility_data_list").dxDataGrid("instance").columnOption('D31', "visible", false);
  176. $("#facility_data_list").dxDataGrid("instance").columnOption('D30', "visible", false);
  177. $("#facility_data_list").dxDataGrid("instance").columnOption('D29', "visible", false);
  178. $("#facility_data_list").dxDataGrid("instance").columnOption('D28', "visible", false);
  179. break;
  180. case 27:
  181. $("#facility_data_list").dxDataGrid("instance").columnOption('D31', "visible", false);
  182. $("#facility_data_list").dxDataGrid("instance").columnOption('D30', "visible", false);
  183. $("#facility_data_list").dxDataGrid("instance").columnOption('D29', "visible", false);
  184. $("#facility_data_list").dxDataGrid("instance").columnOption('D28', "visible", false);
  185. $("#facility_data_list").dxDataGrid("instance").columnOption('D27', "visible", false);
  186. break;
  187. }
  188. }
  189. GetFacilityTime();
  190. })
  191. .fail(function (error) {
  192. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  193. utils.toast.show(error);
  194. });
  195. }
  196. // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가
  197. function DataGridPopup_ButtonClick() {
  198. DataGridPopup_Visible(true);
  199. }
  200. function SEARCH_ButtonClick() {
  201. if ($("#facilityTypeData").dxSelectBox("instance").option('value') != null) {
  202. facilityTypeDataID = $("#facilityTypeData").dxSelectBox("instance").option('value');
  203. }
  204. else {
  205. utils.toast.show('조회할 설비를 선택해주세요.', 'error');
  206. return;
  207. }
  208. $("#LoadPanel").dxLoadPanel({
  209. message: '로딩 중...',
  210. showIndicator: true,
  211. visible: false
  212. });
  213. $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
  214. $("#facility_data_list").dxDataGrid("instance").columnOption('D31', "visible", true);
  215. $("#facility_data_list").dxDataGrid("instance").columnOption('D30', "visible", true);
  216. $("#facility_data_list").dxDataGrid("instance").columnOption('D29', "visible", true);
  217. $("#facility_data_list").dxDataGrid("instance").columnOption('D28', "visible", true);
  218. $("#facility_data_list").dxDataGrid("instance").columnOption('D27', "visible", true);
  219. GetFaclilityData();
  220. }
  221. function handlePopupShown() {
  222. // 데이타소스 업데이트
  223. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D31', "visible", true);
  224. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D30', "visible", true);
  225. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D29', "visible", true);
  226. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D28', "visible", true);
  227. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D27', "visible", true);
  228. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").option("dataSource", resultdataArrayresult);
  229. if (new Date(dateChar.getFullYear(), dateChar.getMonth() + 1, dateChar.getDate() - 1, 0).getDate() != 31) {
  230. for (var i = 0; i < timedataSource.length; i++)
  231. switch (new Date(dateChar.getFullYear(), dateChar.getMonth() + 1, dateChar.getDate() - 1, 0).getDate()) {
  232. case 30:
  233. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D31', "visible", false);
  234. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D30', "visible", false);
  235. break;
  236. case 29:
  237. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D31', "visible", false);
  238. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D30', "visible", false);
  239. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D29', "visible", false);
  240. break;
  241. case 28:
  242. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D31', "visible", false);
  243. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D30', "visible", false);
  244. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D29', "visible", false);
  245. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D28', "visible", false);
  246. break;
  247. case 27:
  248. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D31', "visible", false);
  249. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D30', "visible", false);
  250. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D29', "visible", false);
  251. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D28', "visible", false);
  252. $("#TimeHistoryDataGrid_Container").dxDataGrid("instance").columnOption('D27', "visible", false);
  253. break;
  254. }
  255. }
  256. // 팝업창 갱신
  257. DataGridPopup_Visible(true);
  258. }
  259. // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가
  260. function GetFacilityTime() { //가동시간 추가 함수
  261. var value = 0;
  262. for (var i = 0; i < timedataSource.length; i++)//각 일 데이터 여부 확인 7 * faclilitydataSourceCnt
  263. {
  264. if (timedataSource[i] != null)
  265. value = value + 1;
  266. }
  267. for (var i = 0; i < value; i++)//각 일 데이터 여부 확인 7 * faclilitydataSourceCnt
  268. {
  269. if (timedataSource[i].Name == "")
  270. timedataSource[i] = null;
  271. }
  272. var temp = 0;
  273. for (var i = 0; i < timedataSource.length; i++) {
  274. if (timedataSource[i] != null) {
  275. temp = i;
  276. }
  277. }
  278. timedataSource = timedataSource.slice(0, temp + 1);
  279. for (var i = 0; i < timedataSource.length; i++)//각 일 데이터 여부 확인 7 * faclilitydataSourceCnt
  280. {
  281. if (timedataSource[i] != null) {
  282. timedataSource[i].Time = timedataSource[i].D0;
  283. timedataSource[i].Time += timedataSource[i].D1;
  284. timedataSource[i].Time += timedataSource[i].D2;
  285. timedataSource[i].Time += timedataSource[i].D3;
  286. timedataSource[i].Time += timedataSource[i].D4;
  287. timedataSource[i].Time += timedataSource[i].D5;
  288. timedataSource[i].Time += timedataSource[i].D6;
  289. timedataSource[i].Time += timedataSource[i].D7;
  290. timedataSource[i].Time += timedataSource[i].D8;
  291. timedataSource[i].Time += timedataSource[i].D9;
  292. timedataSource[i].Time += timedataSource[i].D10;
  293. timedataSource[i].Time += timedataSource[i].D11;
  294. timedataSource[i].Time += timedataSource[i].D12;
  295. timedataSource[i].Time += timedataSource[i].D13;
  296. timedataSource[i].Time += timedataSource[i].D14;
  297. timedataSource[i].Time += timedataSource[i].D15;
  298. timedataSource[i].Time += timedataSource[i].D16;
  299. timedataSource[i].Time += timedataSource[i].D17;
  300. timedataSource[i].Time += timedataSource[i].D18;
  301. timedataSource[i].Time += timedataSource[i].D19;
  302. timedataSource[i].Time += timedataSource[i].D20;
  303. timedataSource[i].Time += timedataSource[i].D21;
  304. timedataSource[i].Time += timedataSource[i].D22;
  305. timedataSource[i].Time += timedataSource[i].D23;
  306. timedataSource[i].Time += timedataSource[i].D24;
  307. timedataSource[i].Time += timedataSource[i].D25;
  308. timedataSource[i].Time += timedataSource[i].D26;
  309. timedataSource[i].Time += timedataSource[i].D27;
  310. timedataSource[i].Time += timedataSource[i].D28;
  311. timedataSource[i].Time += timedataSource[i].D29;
  312. timedataSource[i].Time += timedataSource[i].D30;
  313. }
  314. }
  315. $("#facility_data_list").dxDataGrid("instance").option('dataSource', timedataSource);//병합데이터 최종 연동
  316. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  317. // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가
  318. var tempdataArrayresult = timedataSource;
  319. var cnt = 0;
  320. for (var i = 0; i < timedataSource.length; i++) {
  321. if (timedataSource[i] != null) {
  322. tempdataArrayresult[cnt] = timedataSource[i];
  323. cnt++;
  324. }
  325. }
  326. for (var i = 0; i < cnt; i++)//각 일 데이터 여부 확인
  327. {
  328. dataArrayresult[i].Name = tempdataArrayresult[i].Name + " [" + tempdataArrayresult[i].Time + "]";
  329. dataArrayresult[i].D0 = tempdataArrayresult[i].D0;
  330. dataArrayresult[i].D1 = tempdataArrayresult[i].D1;
  331. dataArrayresult[i].D2 = tempdataArrayresult[i].D2;
  332. dataArrayresult[i].D3 = tempdataArrayresult[i].D3;
  333. dataArrayresult[i].D4 = tempdataArrayresult[i].D4;
  334. dataArrayresult[i].D5 = tempdataArrayresult[i].D5;
  335. dataArrayresult[i].D6 = tempdataArrayresult[i].D6;
  336. dataArrayresult[i].D7 = tempdataArrayresult[i].D7;
  337. dataArrayresult[i].D8 = tempdataArrayresult[i].D8;
  338. dataArrayresult[i].D9 = tempdataArrayresult[i].D9;
  339. dataArrayresult[i].D10 = tempdataArrayresult[i].D10;
  340. dataArrayresult[i].D11 = tempdataArrayresult[i].D11;
  341. dataArrayresult[i].D12 = tempdataArrayresult[i].D12;
  342. dataArrayresult[i].D13 = tempdataArrayresult[i].D13;
  343. dataArrayresult[i].D14 = tempdataArrayresult[i].D14;
  344. dataArrayresult[i].D15 = tempdataArrayresult[i].D15;
  345. dataArrayresult[i].D16 = tempdataArrayresult[i].D16;
  346. dataArrayresult[i].D17 = tempdataArrayresult[i].D17;
  347. dataArrayresult[i].D18 = tempdataArrayresult[i].D18;
  348. dataArrayresult[i].D19 = tempdataArrayresult[i].D19;
  349. dataArrayresult[i].D20 = tempdataArrayresult[i].D20;
  350. dataArrayresult[i].D21 = tempdataArrayresult[i].D21;
  351. dataArrayresult[i].D22 = tempdataArrayresult[i].D22;
  352. dataArrayresult[i].D23 = tempdataArrayresult[i].D23;
  353. dataArrayresult[i].D24 = tempdataArrayresult[i].D24;
  354. dataArrayresult[i].D25 = tempdataArrayresult[i].D25;
  355. dataArrayresult[i].D26 = tempdataArrayresult[i].D26;
  356. dataArrayresult[i].D27 = tempdataArrayresult[i].D27;
  357. dataArrayresult[i].D28 = tempdataArrayresult[i].D28;
  358. dataArrayresult[i].D29 = tempdataArrayresult[i].D29;
  359. dataArrayresult[i].D30 = tempdataArrayresult[i].D30;
  360. }
  361. resultdataArrayresult = [];
  362. for (var i = 0; i < cnt; i++) {
  363. resultdataArrayresult.push({
  364. Num: 0,
  365. Name: "",
  366. FacilityCode: 0,
  367. PropertyId: 0,
  368. CurrentValue: 0,
  369. D0: 0, D1: 0, D2: 0, D3: 0, D4: 0, D5: 0, D6: 0, D7: 0, D8: 0, D9: 0, D10: 0, D11: 0, D12: 0, D13: 0, D14: 0, D15: 0, D16: 0, D17: 0, D18: 0, D19: 0, D20: 0, D21: 0, D22: 0, D23: 0, D24: 0, D25: 0, D26: 0, D27: 0, D28: 0, D29: 0, D30: 0
  370. });
  371. }
  372. for (var i = 0; i < cnt; i++) {
  373. resultdataArrayresult[i] = dataArrayresult[i];
  374. }
  375. }
  376. function ONOFF_state(i, j, result) { //시간마다 값 추가
  377. var Date = result[j].CreatedDateTime.getDate();
  378. switch (Date - 1) {
  379. case 0:
  380. timedataSource[i].D0 = Math.round(result[j].DailyValue);
  381. break;
  382. case 1:
  383. timedataSource[i].D1 = Math.round(result[j].DailyValue);
  384. break;
  385. case 2:
  386. timedataSource[i].D2 = Math.round(result[j].DailyValue);
  387. break;
  388. case 3:
  389. timedataSource[i].D3 = Math.round(result[j].DailyValue);
  390. break;
  391. case 4:
  392. timedataSource[i].D4 = Math.round(result[j].DailyValue);
  393. break;
  394. case 5:
  395. timedataSource[i].D5 = Math.round(result[j].DailyValue);
  396. break;
  397. case 6:
  398. timedataSource[i].D6 = Math.round(result[j].DailyValue);
  399. break;
  400. case 7:
  401. timedataSource[i].D7 = Math.round(result[j].DailyValue);
  402. break;
  403. case 8:
  404. timedataSource[i].D8 = Math.round(result[j].DailyValue);
  405. break;
  406. case 9:
  407. timedataSource[i].D9 = Math.round(result[j].DailyValue);
  408. break;
  409. case 10:
  410. timedataSource[i].D10 = Math.round(result[j].DailyValue);
  411. break;
  412. case 11:
  413. timedataSource[i].D11 = Math.round(result[j].DailyValue);
  414. break;
  415. case 12:
  416. timedataSource[i].D12 = Math.round(result[j].DailyValue);
  417. break;
  418. case 13:
  419. timedataSource[i].D13 = Math.round(result[j].DailyValue);
  420. break;
  421. case 14:
  422. timedataSource[i].D14 = Math.round(result[j].DailyValue);
  423. break;
  424. case 15:
  425. timedataSource[i].D15 = Math.round(result[j].DailyValue);
  426. break;
  427. case 16:
  428. timedataSource[i].D16 = Math.round(result[j].DailyValue);
  429. break;
  430. case 17:
  431. timedataSource[i].D17 = Math.round(result[j].DailyValue);
  432. break;
  433. case 18:
  434. timedataSource[i].D18 = Math.round(result[j].DailyValue);
  435. break;
  436. case 19:
  437. timedataSource[i].D19 = Math.round(result[j].DailyValue);
  438. break;
  439. case 20:
  440. timedataSource[i].D20 = Math.round(result[j].DailyValue);
  441. break;
  442. case 21:
  443. timedataSource[i].D21 = Math.round(result[j].DailyValue);
  444. break;
  445. case 22:
  446. timedataSource[i].D22 = Math.round(result[j].DailyValue);
  447. break;
  448. case 23:
  449. timedataSource[i].D23 = Math.round(result[j].DailyValue);
  450. break;
  451. case 24:
  452. timedataSource[i].D24 = Math.round(result[j].DailyValue);
  453. break;
  454. case 25:
  455. timedataSource[i].D25 = Math.round(result[j].DailyValue);
  456. break;
  457. case 26:
  458. timedataSource[i].D26 = Math.round(result[j].DailyValue);
  459. break;
  460. case 27:
  461. timedataSource[i].D27 = Math.round(result[j].DailyValue);
  462. break;
  463. case 28:
  464. timedataSource[i].D28 = Math.round(result[j].DailyValue);
  465. break;
  466. case 29:
  467. timedataSource[i].D29 = Math.round(result[j].DailyValue);
  468. break;
  469. case 30:
  470. timedataSource[i].D30 = Math.round(result[j].DailyValue);
  471. break;
  472. }
  473. }
  474. function handleViewShowing() {
  475. facilityTypeDataSource.filter([
  476. ['FacilityTypeId', '<', 99]
  477. ]);
  478. // 빌딩 데이터 로드 시점
  479. $.when(facilityTypeDataSource.load()
  480. ).done(function (result) {
  481. for (var i = 0; i < result.length; i++) {
  482. if (result[i].FacilityTypeId() == $Code.FacilityType.AIR_HANDLING || result[i].FacilityTypeId() == $Code.FacilityType.REFRIGERATOR || result[i].FacilityTypeId() == $Code.FacilityType.REFRIGERATOR_TOP || result[i].FacilityTypeId() == $Code.FacilityType.PUMP || result[i].FacilityTypeId() == $Code.FacilityType.BOILER) {
  483. facilityTypes.push(result[i]);
  484. }
  485. }
  486. });
  487. }
  488. function handleViewShown() {
  489. $SideMenu.showSideMenuIfWill(params.view);
  490. $SearchView.setPopupVisibleObservable(null);
  491. }
  492. var searchViewOptions = {
  493. }
  494. function handleSearchInSearchView() {
  495. }
  496. var viewModel = $.extend(BWA.CommonView.create(params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null, handleSearchInSearchView),
  497. {
  498. viewShown: handleViewShown,
  499. viewShowing: handleViewShowing,
  500. facility_data_list: {
  501. dataSource: timedataSource,
  502. paging: { pageSize: 28 },
  503. columns: [
  504. { dataField: 'Name', caption: '설비명칭', width: '14%', alignment: 'center', allowSorting: false },
  505. { dataField: 'Time', caption: '가동시간(분)', width: '6%', alignment: 'center', allowSorting: false },
  506. {
  507. dataField: 'D0', caption: '1일', width: '3.1%', alignment: 'center', allowSorting: false
  508. },
  509. {
  510. dataField: 'D1', caption: '2일', width: '3.1%', alignment: 'center', allowSorting: false
  511. },
  512. {
  513. dataField: 'D2', caption: '3일', width: '3.1%', alignment: 'center', allowSorting: false
  514. },
  515. {
  516. dataField: 'D3', caption: '4일', width: '3.1%', alignment: 'center', allowSorting: false
  517. },
  518. {
  519. dataField: 'D4', caption: '5일', width: '3.1%', alignment: 'center', allowSorting: false
  520. },
  521. {
  522. dataField: 'D5', caption: '6일', width: '3.1%', alignment: 'center', allowSorting: false
  523. },
  524. {
  525. dataField: 'D6', caption: '7일', width: '3.1%', alignment: 'center', allowSorting: false
  526. },
  527. {
  528. dataField: 'D7', caption: '8일', width: '3.1%', alignment: 'center', allowSorting: false
  529. },
  530. {
  531. dataField: 'D8', caption: '9일', width: '3.1%', alignment: 'center', allowSorting: false
  532. },
  533. {
  534. dataField: 'D9', caption: '10일', width: '3.1%', alignment: 'center', allowSorting: false
  535. },
  536. {
  537. dataField: 'D10', caption: '11일', width: '3.1%', alignment: 'center', allowSorting: false
  538. },
  539. {
  540. dataField: 'D11', caption: '12일', width: '3.1%', alignment: 'center', allowSorting: false
  541. },
  542. {
  543. dataField: 'D12', caption: '13일', width: '3.1%', alignment: 'center', allowSorting: false
  544. },
  545. {
  546. dataField: 'D13', caption: '14일', width: '3.1%', alignment: 'center', allowSorting: false
  547. },
  548. {
  549. dataField: 'D14', caption: '15일', width: '3.1%', alignment: 'center', allowSorting: false
  550. },
  551. {
  552. dataField: 'D15', caption: '16일', width: '3.1%', alignment: 'center', allowSorting: false
  553. },
  554. {
  555. dataField: 'D16', caption: '17일', width: '3.1%', alignment: 'center', allowSorting: false
  556. },
  557. {
  558. dataField: 'D17', caption: '18일', width: '3.1%', alignment: 'center', allowSorting: false
  559. },
  560. {
  561. dataField: 'D18', caption: '19일', width: '3.1%', alignment: 'center', allowSorting: false
  562. },
  563. {
  564. dataField: 'D19', caption: '20일', width: '3.1%', alignment: 'center', allowSorting: false
  565. },
  566. {
  567. dataField: 'D20', caption: '21일', width: '3.1%', alignment: 'center', allowSorting: false
  568. },
  569. {
  570. dataField: 'D21', caption: '22일', width: '3.1%', alignment: 'center', allowSorting: false
  571. },
  572. {
  573. dataField: 'D22', caption: '23일', width: '3.1%', alignment: 'center', allowSorting: false
  574. },
  575. {
  576. dataField: 'D23', caption: '24일', width: '3.1%', alignment: 'center', allowSorting: false
  577. },
  578. {
  579. dataField: 'D24', caption: '25일', width: '3.1%', alignment: 'center', allowSorting: false
  580. },
  581. {
  582. dataField: 'D25', caption: '26일', width: '3.1%', alignment: 'center', allowSorting: false
  583. }
  584. ,
  585. {
  586. dataField: 'D26', caption: '27일', width: '3.1%', alignment: 'center', allowSorting: false
  587. }
  588. ,
  589. {
  590. dataField: 'D27', caption: '28일', width: '3.1%', alignment: 'center', allowSorting: false
  591. }
  592. ,
  593. {
  594. dataField: 'D28', caption: '29일', width: '3.1%', alignment: 'center', allowSorting: false
  595. }
  596. ,
  597. {
  598. dataField: 'D29', caption: '30일', width: '3.1%', alignment: 'center', allowSorting: false
  599. }
  600. ,
  601. {
  602. dataField: 'D30', caption: '31일', width: '3.1%', alignment: 'center', allowSorting: false
  603. }
  604. ],
  605. onRowPrepared: function (info) {
  606. if (info.rowType != 'header')
  607. if (info.data.Num == 1)
  608. info.rowElement.css('background-color', 'rgba(206,246,245,0.4)');
  609. }
  610. },
  611. facility_history_calendarPicker: {
  612. pickerType: "calendar",
  613. formatString: "yyyy-MM",
  614. maxZoomLevel: 'year',
  615. value: new Date(),
  616. onValueChanged: function () {
  617. var today = new Date();
  618. dateChar = $("#facility_history_calendarPicker").dxDateBox("instance").option('value');
  619. if (dateChar.getFullYear() > today.getFullYear()) {
  620. utils.toast.show('선택된 날짜를 조회할수 없습니다.', 'error');
  621. } else {
  622. if (dateChar.getMonth() > today.getMonth())
  623. utils.toast.show('선택된 날짜를 조회할수 없습니다.', 'error');
  624. }
  625. }
  626. }
  627. // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가
  628. , TimeHistoryDataGridPopup_ButtonClicked: DataGridPopup_ButtonClick
  629. , search_ButtonClicked: SEARCH_ButtonClick
  630. // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가
  631. });
  632. // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가
  633. viewModel.TimeHistoryDataGridPopupOptions = {
  634. width: '1800px',
  635. height: '820px',
  636. contentTemplate: "content",
  637. showTitle: true,
  638. title: "도표",
  639. visible: DataGridPopup_Visible,
  640. dragEnabled: true,
  641. closeOnOutsideClick: true,
  642. shownAction: handlePopupShown,
  643. animation: window.utils.popup.createAnimation()
  644. };
  645. viewModel.TimeHistoryDataGridOptions = {
  646. dataSource: resultdataArrayresult,
  647. columns: [
  648. { dataField: 'Name', caption: '설비명칭[가동시간(분)]', width: '18%', alignment: 'center', allowSorting: false },
  649. { dataField: 'D0', caption: '1일', width: '3.3%', alignment: 'center', allowSorting: false },
  650. { dataField: 'D1', caption: '2일', width: '3.3%', alignment: 'center', allowSorting: false },
  651. { dataField: 'D2', caption: '3일', width: '3.3%', alignment: 'center', allowSorting: false },
  652. { dataField: 'D3', caption: '4일', width: '3.3%', alignment: 'center', allowSorting: false },
  653. { dataField: 'D4', caption: '5일', width: '3.3%', alignment: 'center', allowSorting: false },
  654. { dataField: 'D5', caption: '6일', width: '3.3%', alignment: 'center', allowSorting: false },
  655. { dataField: 'D6', caption: '7일', width: '3.3%', alignment: 'center', allowSorting: false },
  656. { dataField: 'D7', caption: '8일', width: '3.3%', alignment: 'center', allowSorting: false },
  657. { dataField: 'D8', caption: '9일', width: '3.3%', alignment: 'center', allowSorting: false },
  658. { dataField: 'D9', caption: '10일', width: '3.3%', alignment: 'center', allowSorting: false },
  659. { dataField: 'D10', caption: '11일', width: '3.3%', alignment: 'center', allowSorting: false },
  660. { dataField: 'D11', caption: '12일', width: '3.3%', alignment: 'center', allowSorting: false },
  661. { dataField: 'D12', caption: '13일', width: '3.3%', alignment: 'center', allowSorting: false },
  662. { dataField: 'D13', caption: '14일', width: '3.3%', alignment: 'center', allowSorting: false },
  663. { dataField: 'D14', caption: '15일', width: '3.3%', alignment: 'center', allowSorting: false },
  664. { dataField: 'D15', caption: '16일', width: '3.3%', alignment: 'center', allowSorting: false },
  665. { dataField: 'D16', caption: '17일', width: '3.3%', alignment: 'center', allowSorting: false },
  666. { dataField: 'D17', caption: '18일', width: '3.3%', alignment: 'center', allowSorting: false },
  667. { dataField: 'D18', caption: '19일', width: '3.3%', alignment: 'center', allowSorting: false },
  668. { dataField: 'D19', caption: '20일', width: '3.3%', alignment: 'center', allowSorting: false },
  669. { dataField: 'D20', caption: '21일', width: '3.3%', alignment: 'center', allowSorting: false },
  670. { dataField: 'D21', caption: '22일', width: '3.3%', alignment: 'center', allowSorting: false },
  671. { dataField: 'D22', caption: '23일', width: '3.3%', alignment: 'center', allowSorting: false },
  672. { dataField: 'D23', caption: '24일', width: '3.3%', alignment: 'center', allowSorting: false },
  673. { dataField: 'D24', caption: '25일', width: '3.3%', alignment: 'center', allowSorting: false },
  674. { dataField: 'D25', caption: '26일', width: '3.3%', alignment: 'center', allowSorting: false },
  675. { dataField: 'D26', caption: '27일', width: '3.3%', alignment: 'center', allowSorting: false },
  676. { dataField: 'D27', caption: '28일', width: '3.3%', alignment: 'center', allowSorting: false },
  677. { dataField: 'D28', caption: '29일', width: '3.3%', alignment: 'center', allowSorting: false },
  678. { dataField: 'D29', caption: '30일', width: '3.3%', alignment: 'center', allowSorting: false },
  679. { dataField: 'D30', caption: '31일', width: '3.3%', alignment: 'center', allowSorting: false }
  680. ],
  681. // 엑셀 출력, dx.all.debug.js / _getCellIndex /63882
  682. "export": {
  683. enabled: true,
  684. fileName: '설비별 가동시간'
  685. }
  686. };
  687. // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가
  688. viewModel.facilityTypes = facilityTypes;
  689. return viewModel;
  690. };