| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086 | BemsWebApplication.FmsfacilityTime = 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;            $("#facilitytime_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() {        // 데이타소스 업데이트        $("#FmsfacilityTimeDataGrid_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;            }            $("#facilitytime_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) {        $('<img />')       .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,            facilitytime_history_list: {                dataSource: faclilitydataSource,                columns: [                    { dataField: 'Name', width: '200px', alignment: 'left' }                ],                visible: false            },            facilitytime_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)');                }            },            fms_facilitytime_calendarPicker: {                pickerType: "calendar",                format: "date",                value: new Date(Date.parse(datachar_after) - 6 * 1000 * 60 * 60 * 24),                onValueChanged: function () {                    var today = new Date();                    dateChar = $("#fms_facilitytime_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 : 그리드 도표 작업 : 팝업창 추가            , FmsfacilityTimeDataGridPopup_ButtonClicked: DataGridPopup_ButtonClick            //  2018.07.24  : 그리드 도표 작업 : 팝업창 추가        });    //  2018.07.24 : 그리드 도표 작업 : 팝업창 추가    viewModel.FmsfacilityTimeDataGridPopupOptions = {        width: '1400px',        height: '820px',        contentTemplate: "content",        showTitle: true,        title: "도표",        visible: DataGridPopup_Visible,        dragEnabled: true,        closeOnOutsideClick: true,        shownAction: handlePopupShown,        animation: window.utils.popup.createAnimation()    };    viewModel.FmsfacilityTimeDataGridOptions = {        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;};
 |