BemsWebApplication.PlanBoilerHistory = function (params, viewInfo) { "use strict"; var endpointSelector = ""; if (BemsWebApplication.config.mode == "production") { endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production; } else { endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local; } // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가 // 팝업창뷰 보이기 속성 제어용 변수 선언 var DataGridPopup_Visible = ko.observable(false); // 그래프 출력 이후 엑셀출력을 위한 팝업창을 위해 임시 저장용 배열 선언 var faclilitydataSource, dataArrayresult, resultdataArrayresult = []; var boilerdataSource; var Action_state = 7 // 시간별 운전 상태 확인 var Action_time = 9 //시간별 운전 시간 //boilerdataSource 초기화 함수 function Source_init() { boilerdataSource = [{ Num: 0, Year: 0, Day: "322", Name: "", Time: 3, FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "322", Name: "", Time: 3, FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "322", Name: "", Time: 3, FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "322", Name: "", Time: 3, FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "322", Name: "", Time: 3, FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "322", Name: "", Time: 3, FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "322", Name: "", Time: 3, FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 } ]; dataArrayresult = [{ Num: 0, Year: 0, Day: "321", Name: "", FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "321", Name: "", FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "321", Name: "", FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "321", Name: "", FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "321", Name: "", FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "321", Name: "", FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }, { Num: 0, Year: 0, Day: "321", Name: "", FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 } ]; } function boilerdataSourceAdd(cnt) { // 설비 개수만큼 추가 for (var i = 0; i < 7 * (cnt - 1) ; i++) { boilerdataSource.push({ Num: 0, Year: 0, Day: "322", Name: "", Time: 3, FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }); } for (var i = 0; i < 7 * (cnt - 1) ; i++) { dataArrayresult.push({ Num: 0, Year: 0, Day: "321", Name: "", FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }); } } var DataArray = ko.observableArray(); var boilerdataSourceCnt = 0; var faclilitydataSourceCnt = 0; var datachar_after = new Date(); //현재일 var dateChar = new Date(Date.parse(datachar_after) - 6 * 1000 * 60 * 60 * 24); //초기값 -6 // 보일러 시설 정보 겟 함수 function GetFaclilityData() { var dataSource = new DevExpress.data.DataSource({ store: { type: "odata", url: endpointSelector + "/CmFacility" }, requireTotalCount: true, pageSize: 10 }); dataSource.filter([ ["SiteId", "=", BWA.UserInfo.SiteId()], "and", ["FacilityTypeId", "=", $Code.FacilityType.BOILER] ]); dataSource.load() .done(function (result) { faclilitydataSourceCnt = result.length; //보일러 설비 개수 boilerdataSourceAdd(faclilitydataSourceCnt); // boilerdataSource 필요한 만큼 추가 faclilitydataSource = result; $("#boiler_history_list").dxDataGrid("instance").option('dataSource', faclilitydataSource);//병합데이터 최종 연동 }) .fail(function (error) { utils.toast.show(error); }); } // 보일러 정보 가져오기 함수 function GetBoilerDailyData() { Source_init(); //boilerdataSource 초기화 boilerdataSourceAdd(faclilitydataSourceCnt); // boilerdataSource 필요한 만큼 추가 var dataSource = new DevExpress.data.DataSource({ store: { type: "odata", url: endpointSelector + "/BemsMonitoringPointHistoryHourly" }, requireTotalCount: true, pageSize: 672 // 설비 6개까지 }); dataSource.filter([ ["SiteId", "=", BWA.UserInfo.SiteId()], //사이트 아이디 "and", ["FacilityTypeId", "=", $Code.FacilityType.BOILER], //보일러 타입 8 "and", ["PropertyId", "=", Action_time],//시간별 운전상태 기존 Action_state -> 변경 Action_time // 이유: 가동시간 0이 아니면 무조건 가동으로 판단 "and", ["CreatedDateTime", ">=", new Date(dateChar.getFullYear(), dateChar.getMonth(), dateChar.getDate(), 0, 0, 0)], "and", ["CreatedDateTime", "<=", new Date(datachar_after.getFullYear(), datachar_after.getMonth(), datachar_after.getDate(), 23, 59, 59)] ]); dataSource.sort({ getter: "FacilityCode", ASC: true }, { getter: "CreatedDateTime", ASC: true }); dataSource.load() .done(function (result) { boilerdataSourceCnt = result.length; var start = 0; var day = new Date(); var search_first_day = new Date(dateChar.getFullYear(), dateChar.getMonth(), dateChar.getDate(), 0, 0, 0); var search_last_day = new Date(datachar_after.getFullYear(), datachar_after.getMonth(), datachar_after.getDate(), 0, 0, 0); var today = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, 0, 0); var firstdaycondition = ((dateChar.getFullYear() == today.getFullYear()) && (dateChar.getMonth() == today.getMonth()) && (dateChar.getDate() == today.getDate())); //검색첫날이 오늘이면 var lastdaycondition = ((search_last_day.getFullYear() == today.getFullYear()) && (search_last_day.getMonth() == today.getMonth()) && (search_last_day.getDate() == today.getDate())); //검색 마지막이 오늘이면 var middaycondition = ((today.getTime() - search_first_day.getTime()) / (1000 * 60 * 60 * 24)) < 6;//검색기간중 오늘이 포함하면 var btMs = today.getTime() - search_first_day.getTime(); //오늘과 검색 첫날 날짜 차이 var btDay = btMs / (1000 * 60 * 60 * 24); //날짜 차이 일수 var changed = false; var insert = 0; if (lastdaycondition || firstdaycondition || middaycondition) { //검색마지막 날짜가 오늘이거나 검색 처음날이 오늘이거나 for (var i = 0; i < 7 * faclilitydataSourceCnt; i++)//7일 * 설비 개수 = 행 개수 { var lastcnt = 0; for (var j = start; j < boilerdataSourceCnt; j++) // 가져온 데이터는 350개 { if (boilerdataSource[i].Day == "322") // 초기화 데이터 { var insertmonth = result[j].CreatedDateTime.getMonth() + 1; var insertday = result[j].CreatedDateTime.getDate(); if (insertmonth > 9) { if (insertday > 9) boilerdataSource[i].Day = (insertmonth + "-" + insertday); else boilerdataSource[i].Day = (insertmonth + "-0" + insertday); } else { if (insertday > 9) boilerdataSource[i].Day = ("0" + insertmonth + "-" + insertday); else boilerdataSource[i].Day = ("0" + insertmonth + "-0" + insertday); } boilerdataSource[i].Year = result[j].CreatedDateTime.getFullYear(); for (var k = 0; k < faclilitydataSourceCnt; k++) { //보일러 개수 if (result[j].FacilityCode == faclilitydataSource[k].FacilityCode) { boilerdataSource[i].Name = faclilitydataSource[k].Name; boilerdataSource[i].FacilityCode = faclilitydataSource[k].FacilityCode; break; } } ONOFF_state(i, j, result); } if (insertmonth > 9) { if (insertday > 9) { if (boilerdataSource[i].Day == (insertmonth + "-" + insertday)) { ONOFF_state(i, j, result); } } else { if (boilerdataSource[i].Day == (insertmonth + "-0" + insertday)) { ONOFF_state(i, j, result); } } } else { if (insertday > 9) { if (boilerdataSource[i].Day == ("0" + insertmonth + "-" + insertday)) { ONOFF_state(i, j, result); } } else { if (boilerdataSource[i].Day == ("0" + insertmonth + "-0" + insertday)) { ONOFF_state(i, j, result); } } } if (((i % 7 == 6) && lastdaycondition) || firstdaycondition || (middaycondition && (i % (btDay + 1) == btDay))) {// lastcnt++; start++; if (day.getMinutes() < 15) { if (lastcnt % (day.getHours()) == 0) break; } else { if (lastcnt % (day.getHours() + 1) == 0) break; } } else { start++; if (j < boilerdataSourceCnt - 1) { if (result[j].CreatedDateTime.getDate() != result[j + 1].CreatedDateTime.getDate()) break; } } } } for (var i = 0; i < 7 * faclilitydataSourceCnt; i++) { //백그라운드 컬러 위해서 if (lastdaycondition)//검색마지막날이 오늘 7일치 for (var j = 1; j <= 5; j = j + 2) { if ((i % 7) == j) boilerdataSource[i].Num = 1; } if (firstdaycondition)//검색첫날이 오늘이면 안해도됨 { } if (middaycondition) //검색중간 오늘을 포함하면 for (var j = 1; j <= 5; j = j + 2) { if ((i % (btDay + 1)) == j) boilerdataSource[i].Num = 1; } } } else { //검색 마지막 날짜가 오늘이 아니면 7일짜리 for (var i = 0; i < 7 * faclilitydataSourceCnt; i++)//7일 * 설비 개수 = 행 개수 { for (var j = start; j < boilerdataSourceCnt; j++) // 가져온 데이터는 350개 { if (boilerdataSource[i].Day == "322") // 초기화 데이터 { var insertmonth = result[j].CreatedDateTime.getMonth() + 1; var insertday = result[j].CreatedDateTime.getDate(); if (insertmonth > 9) { if (insertday > 9) boilerdataSource[i].Day = (insertmonth + "-" + insertday); else boilerdataSource[i].Day = (insertmonth + "-0" + insertday); } else { if (insertday > 9) boilerdataSource[i].Day = ("0" + insertmonth + "-" + insertday); else boilerdataSource[i].Day = ("0" + insertmonth + "-0" + insertday); } boilerdataSource[i].Year = result[j].CreatedDateTime.getFullYear(); for (var k = 0; k < faclilitydataSourceCnt; k++) { //보일러 개수 if (result[j].FacilityCode == faclilitydataSource[k].FacilityCode) { boilerdataSource[i].Name = faclilitydataSource[k].Name; boilerdataSource[i].FacilityCode = faclilitydataSource[k].FacilityCode; break; } } ONOFF_state(i, j, result); } if (insertmonth > 9) { if (insertday > 9) { if (boilerdataSource[i].Day == (insertmonth + "-" + insertday)) { ONOFF_state(i, j, result); start++; } } else { if (boilerdataSource[i].Day == (insertmonth + "-0" + insertday)) { ONOFF_state(i, j, result); start++; } } } else { if (insertday > 9) { if (boilerdataSource[i].Day == ("0" + insertmonth + "-" + insertday)) { ONOFF_state(i, j, result); start++; } } else { if (boilerdataSource[i].Day == ("0" + insertmonth + "-0" + insertday)) { ONOFF_state(i, j, result); start++; } } } if (j < boilerdataSourceCnt - 1) { if (result[j].CreatedDateTime.getDate() != result[j + 1].CreatedDateTime.getDate()) break; } } } for (var i = 0; i < 7 * faclilitydataSourceCnt; i++) { //백그라운드 컬러 위해서 for (var j = 1; j <= 5; j = j + 2) { if ((i % 7) == j) boilerdataSource[i].Num = 1; } } } setTimeout(GetFacilityTime(), 1500);//보일러 운전 시간 가져오기 함수 }) .fail(function (error) { $("#LoadPanel").dxLoadPanel('instance').option('visible', false); utils.toast.show(error); }); } // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가 function DataGridPopup_ButtonClick() { DataGridPopup_Visible(true); } function handlePopupShown() { // 데이타소스 업데이트 $("#PlanBoilerHistoryDataGrid_Container").dxDataGrid("instance").option("dataSource", resultdataArrayresult); // 팝업창 갱신 DataGridPopup_Visible(true); } // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가 function GetFacilityTime() { //가동시간 추가 함수 var value = 0; var hourdataSource = new DevExpress.data.DataSource({ store: { type: "odata", url: endpointSelector + "/BemsMonitoringPointHistoryDaily" }, requireTotalCount: true, pageSize: 42 }); hourdataSource.filter([ ["SiteId", "=", BWA.UserInfo.SiteId()], //사이트 아이디 "and", ["FacilityTypeId", "=", $Code.FacilityType.BOILER], //보일러 타입 "and", ["PropertyId", "=", Action_time], //시간별 가동시간 "and", ["CreatedDateTime", ">=", new Date(dateChar.getFullYear(), dateChar.getMonth(), dateChar.getDate(), 0, 0, 0)], "and", ["CreatedDateTime", "<=", new Date(datachar_after.getFullYear(), datachar_after.getMonth(), datachar_after.getDate(), 23, 59, 59)] ]); hourdataSource.sort({ getter: "FacilityCode", ASC: true }, { getter: "CreatedDateTime", ASC: true }); hourdataSource.load() .done(function (result2) { var timecnt = result2.length; var start = 0; for (var i = 0; i < 7 * faclilitydataSourceCnt ; i++) { for (var j = start; j < timecnt; j++) { var insertmonth = result2[j].CreatedDateTime.getMonth() + 1; var insertday = result2[j].CreatedDateTime.getDate(); if (insertmonth > 9) { if (insertday > 9) { if ((boilerdataSource[i].Day == (insertmonth + "-" + insertday)) && (boilerdataSource[i].FacilityCode == result2[j].FacilityCode)) { boilerdataSource[i].Time = result2[j].DailyValue; start++; break; } } else { if ((boilerdataSource[i].Day == (insertmonth + "-0" + insertday)) && (boilerdataSource[i].FacilityCode == result2[j].FacilityCode)) { boilerdataSource[i].Time = result2[j].DailyValue; start++; break; } } } else { if (insertday > 9) { if ((boilerdataSource[i].Day == ("0" + insertmonth + "-" + insertday)) && (boilerdataSource[i].FacilityCode == result2[j].FacilityCode)) { boilerdataSource[i].Time = result2[j].DailyValue; start++; break; } } else { if ((boilerdataSource[i].Day == ("0" + insertmonth + "-0" + insertday)) && (boilerdataSource[i].FacilityCode == result2[j].FacilityCode)) { boilerdataSource[i].Time = result2[j].DailyValue; start++; break; } } } } } for (var i = 0; i < boilerdataSource.length; i++)//각 일 데이터 여부 확인 7 * faclilitydataSourceCnt { if (boilerdataSource[i] != null) value = value + 1; } for (var i = 0; i < value; i++)//각 일 데이터 여부 확인 7 * faclilitydataSourceCnt { if (boilerdataSource[i].Name == "") boilerdataSource[i] = null; } $("#boiler_data_list").dxDataGrid("instance").option('dataSource', boilerdataSource);//병합데이터 최종 연동 $("#LoadPanel").dxLoadPanel('instance').option('visible', false); // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가 var tempdataArrayresult = boilerdataSource; var cnt = 0; for (var i = 0; i < boilerdataSource.length; i++) { if (boilerdataSource[i] != null) { tempdataArrayresult[cnt] = boilerdataSource[i]; cnt++; } } for (var i = 0; i < cnt; i++)//각 일 데이터 여부 확인 { dataArrayresult[i].Day = tempdataArrayresult[i].Day; dataArrayresult[i].Name = tempdataArrayresult[i].Name + " [" + tempdataArrayresult[i].Time + "]"; dataArrayresult[i].T0 = ONOFF(tempdataArrayresult[i].T0); dataArrayresult[i].T1 = ONOFF(tempdataArrayresult[i].T1); dataArrayresult[i].T2 = ONOFF(tempdataArrayresult[i].T2); dataArrayresult[i].T3 = ONOFF(tempdataArrayresult[i].T3); dataArrayresult[i].T4 = ONOFF(tempdataArrayresult[i].T4); dataArrayresult[i].T5 = ONOFF(tempdataArrayresult[i].T5); dataArrayresult[i].T6 = ONOFF(tempdataArrayresult[i].T6); dataArrayresult[i].T7 = ONOFF(tempdataArrayresult[i].T7); dataArrayresult[i].T8 = ONOFF(tempdataArrayresult[i].T8); dataArrayresult[i].T9 = ONOFF(tempdataArrayresult[i].T9); dataArrayresult[i].T10 = ONOFF(tempdataArrayresult[i].T10); dataArrayresult[i].T11 = ONOFF(tempdataArrayresult[i].T11); dataArrayresult[i].T12 = ONOFF(tempdataArrayresult[i].T12); dataArrayresult[i].T13 = ONOFF(tempdataArrayresult[i].T13); dataArrayresult[i].T14 = ONOFF(tempdataArrayresult[i].T14); dataArrayresult[i].T15 = ONOFF(tempdataArrayresult[i].T15); dataArrayresult[i].T16 = ONOFF(tempdataArrayresult[i].T16); dataArrayresult[i].T17 = ONOFF(tempdataArrayresult[i].T17); dataArrayresult[i].T18 = ONOFF(tempdataArrayresult[i].T18); dataArrayresult[i].T19 = ONOFF(tempdataArrayresult[i].T19); dataArrayresult[i].T20 = ONOFF(tempdataArrayresult[i].T20); dataArrayresult[i].T21 = ONOFF(tempdataArrayresult[i].T21); dataArrayresult[i].T22 = ONOFF(tempdataArrayresult[i].T22); dataArrayresult[i].T23 = ONOFF(tempdataArrayresult[i].T23); } resultdataArrayresult = []; for (var i = 0; i < cnt; i++) { resultdataArrayresult.push({ Num: 0, Year: 0, Day: "321", Name: "", FacilityCode: 0, PropertyId: 0, CurrentValue: 0, T0: 0, T1: 0, T2: 0, T3: 0, T4: 0, T5: 0, T6: 0, T7: 0, T8: 0, T9: 0, T10: 0, T11: 0, T12: 0, T13: 0, T14: 0, T15: 0, T16: 0, T17: 0, T18: 0, T19: 0, T20: 0, T21: 0, T22: 0, T23: 0 }); } for (var i = 0; i < cnt; i++) { resultdataArrayresult[i] = dataArrayresult[i]; } }) .fail(function (error) { utils.toast.show(error); }); } function ONOFF(num) { if (num > 0) { return 'O'; } else { return 'X'; } } function ONOFF_state(i, j, result) { //시간마다 값 추가 var Month = result[j].CreatedDateTime.getMonth() + 1; var Date = result[j].CreatedDateTime.getDate(); var resultday; if (Month <= 9) { if (Date <= 9) { resultday = "0" + Month + "-" + "0" + Date; } else { resultday = "0" + Month + "-" + Date; } } else { if (Date <= 9) { resultday = Month + "-" + "0" + Date; } else { resultday = Month + "-" + Date; } } switch (result[j].CreatedDateTime.getHours()) { case 0: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T0 = result[j].CurrentValue; } break; case 1: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T1 = result[j].CurrentValue; } break; case 2: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T2 = result[j].CurrentValue; } break; case 3: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T3 = result[j].CurrentValue; } break; case 4: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T4 = result[j].CurrentValue; } break; case 5: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T5 = result[j].CurrentValue; } break; case 6: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T6 = result[j].CurrentValue; } break; case 7: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T7 = result[j].CurrentValue; } break; case 8: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T8 = result[j].CurrentValue; } break; case 9: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T9 = result[j].CurrentValue; } break; case 10: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T10 = result[j].CurrentValue; } break; case 11: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T11 = result[j].CurrentValue; } break; case 12: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T12 = result[j].CurrentValue; } break; case 13: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T13 = result[j].CurrentValue; } break; case 14: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T14 = result[j].CurrentValue; } break; case 15: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T15 = result[j].CurrentValue; } break; case 16: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T16 = result[j].CurrentValue; } break; case 17: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T17 = result[j].CurrentValue; } break; case 18: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T18 = result[j].CurrentValue; } break; case 19: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T19 = result[j].CurrentValue; } break; case 20: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T20 = result[j].CurrentValue; } break; case 21: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T21 = result[j].CurrentValue; } break; case 22: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T22 = result[j].CurrentValue; } break; case 23: if (boilerdataSource[i].Day == resultday) { boilerdataSource[i].T23 = result[j].CurrentValue; } break; } } function handleViewShowing() { Source_init(); // boilerdataSource 초기화 함수 //보일러 설비 정보 가져오기 setTimeout(GetFaclilityData(), 500); } function handleViewShown() { $("#LoadPanel").dxLoadPanel({ message: '로딩 중...', showIndicator: true, visible: false }); $("#LoadPanel").dxLoadPanel('instance').option('visible', true); $SideMenu.showSideMenuIfWill(params.view); setTimeout(GetBoilerDailyData(), 1000); var insertmonth = datachar_after.getMonth() + 1; var insertdate = datachar_after.getDate(); if (insertmonth > 9) { if (insertdate > 9) { $("#DateBox").dxTextBox({ value: "~ " + datachar_after.getFullYear() + "-" + insertmonth + "-" + insertdate, readOnly: true }); } else { $("#DateBox").dxTextBox({ value: "~ " + datachar_after.getFullYear() + "-" + insertmonth + "-0" + insertdate, readOnly: true }); } } else { if (insertdate > 9) { $("#DateBox").dxTextBox({ value: "~ " + datachar_after.getFullYear() + "-0" + insertmonth + "-" + insertdate, readOnly: true }); } else { $("#DateBox").dxTextBox({ value: "~ " + datachar_after.getFullYear() + "-0" + insertmonth + "-0" + insertdate, readOnly: true }); } } $SearchView.setPopupVisibleObservable(null); } var searchViewOptions = { } function handleSearchInSearchView() { } function cellTemplate_color(container, options) { $('') .attr('src', function () { if (options.value == 0) { return "/images/gray.png"; } else { return "/images/green.png"; } }) .appendTo(container); } var viewModel = $.extend(BWA.CommonView.create(params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null, handleSearchInSearchView), { viewShown: handleViewShown, viewShowing: handleViewShowing, boiler_history_list: { dataSource: faclilitydataSource, columns: [ { dataField: 'Name', width: '200px', alignment: 'left' } ], visible: false }, boiler_data_list: { dataSource: boilerdataSource, paging: { pageSize: 28 }, columns: [ { dataField: 'Year', caption: '연도', width: '5.6%', alignment: 'center', sortOrder: 'asc', visible: false }, { dataField: 'Day', caption: '가동일', width: '5.6%', alignment: 'center', sortOrder: 'asc' }, { dataField: 'Name', caption: '설비명칭', width: '14%', alignment: 'center', allowSorting: false }, { dataField: 'Time', caption: '가동시간(분)', width: '6%', alignment: 'center', allowSorting: false }, { dataField: 'T0', caption: '0시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T1', caption: '1시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T2', caption: '2시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T3', caption: '3시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T4', caption: '4시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T5', caption: '5시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T6', caption: '6시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T7', caption: '7시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T8', caption: '8시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T9', caption: '9시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T10', caption: '10시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T11', caption: '11시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T12', caption: '12시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T13', caption: '13시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T14', caption: '14시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T15', caption: '15시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T16', caption: '16시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T17', caption: '17시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T18', caption: '18시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T19', caption: '19시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T20', caption: '20시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T21', caption: '21시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T22', caption: '22시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } }, { dataField: 'T23', caption: '23시', width: '3.1%', alignment: 'center', allowSorting: false, cellTemplate: function (container, options) { cellTemplate_color(container, options); } } ], onRowPrepared: function (info) { if (info.rowType != 'header') if (info.data.Num == 1) info.rowElement.css('background-color', 'rgba(206,246,245,0.4)'); } }, boiler_history_calendarPicker: { pickerType: "calendar", format: "date", value: new Date(Date.parse(datachar_after) - 6 * 1000 * 60 * 60 * 24), onValueChanged: function () { var today = new Date(); dateChar = $("#boiler_history_calendarPicker").dxDateBox("instance").option('value'); if (dateChar > today) utils.toast.show('선택된 날짜를 검색할수 없습니다...', 'error'); else { datachar_after = new Date(Date.parse(dateChar) + 6 * 1000 * 60 * 60 * 24); GetBoilerDailyData(); } var insertmonth = datachar_after.getMonth() + 1; var insertdate = datachar_after.getDate(); var todaymonth = today.getMonth() + 1; var todaydate = today.getDate(); if (datachar_after < today) { if (insertmonth > 9) { if (insertdate > 9) { $("#DateBox").dxTextBox({ value: "~ " + datachar_after.getFullYear() + "-" + insertmonth + "-" + insertdate, readOnly: true }); } else { $("#DateBox").dxTextBox({ value: "~ " + datachar_after.getFullYear() + "-" + insertmonth + "-0" + insertdate, readOnly: true }); } } else { if (insertdate > 9) { $("#DateBox").dxTextBox({ value: "~ " + datachar_after.getFullYear() + "-0" + insertmonth + "-" + insertdate, readOnly: true }); } else { $("#DateBox").dxTextBox({ value: "~ " + datachar_after.getFullYear() + "-0" + insertmonth + "-0" + insertdate, readOnly: true }); } } } else { if (todaymonth > 9) { if (todaydate > 9) { $("#DateBox").dxTextBox({ value: "~ " + today.getFullYear() + "-" + todaymonth + "-" + todaydate, readOnly: true }); } else { $("#DateBox").dxTextBox({ value: "~ " + today.getFullYear() + "-" + todaymonth + "-0" + todaydate, readOnly: true }); } } else { if (todaydate > 9) { $("#DateBox").dxTextBox({ value: "~ " + today.getFullYear() + "-0" + todaymonth + "-" + todaydate, readOnly: true }); } else { $("#DateBox").dxTextBox({ value: "~ " + today.getFullYear() + "-0" + todaymonth + "-0" + todaydate, readOnly: true }); } } } } } // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가 , PlanBoilerHistoryDataGridPopup_ButtonClicked: DataGridPopup_ButtonClick // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가 }); // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가 viewModel.PlanBoilerHistoryDataGridPopupOptions = { width: '1400px', height: '820px', contentTemplate: "content", showTitle: true, title: "도표", visible: DataGridPopup_Visible, dragEnabled: true, closeOnOutsideClick: true, shownAction: handlePopupShown, animation: window.utils.popup.createAnimation() }; viewModel.PlanBoilerHistoryDataGridOptions = { dataSource: resultdataArrayresult, columns: [ { dataField: 'Day', caption: "가동일", width: '7%', alignment: 'center', sortOrder: 'asc' }, { dataField: 'Name', caption: '설비명칭[가동시간(분)]', width: '13.8%', alignment: 'center', allowSorting: false }, { dataField: 'T0', caption: '0시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T1', caption: '1시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T2', caption: '2시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T3', caption: '3시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T4', caption: '4시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T5', caption: '5시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T6', caption: '6시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T7', caption: '7시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T8', caption: '8시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T9', caption: '9시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T10', caption: '10시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T11', caption: '11시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T12', caption: '12시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T13', caption: '13시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T14', caption: '14시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T15', caption: '15시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T16', caption: '16시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T17', caption: '17시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T18', caption: '18시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T19', caption: '19시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T20', caption: '20시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T21', caption: '21시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T22', caption: '22시', width: '3.3%', alignment: 'center', allowSorting: false }, { dataField: 'T23', caption: '23시', width: '3.3%', alignment: 'center', allowSorting: false } ], // 엑셀 출력 "export": { enabled: true, fileName: '보일러 운전이력' } }; // 2018.07.24 : 그리드 도표 작업 : 팝업창 추가 return viewModel; };