123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637 |
- BemsWebApplication.IceStoreAirAnalysis = function(params, viewInfo) {
- "use strict";
- var initialized = false,
- shouldReload = false,
- datagrid = null,
- currentTabIndex = ko.observable(0),
- facilityViewModel = new BWA.CmFacilityViewModel(),
- dataSource;
- var m_Facility;
- var multiViewItems = [{
- template: 'mainCharts'
- }, {
- template: 'subCharts'
- }
- ];
-
- var facilityDataSource = BWA.db.createDataSource('CmFacility'),
- facilitiesForSearch = ko.observableArray(),
- facilityCodeForSearch = ko.observable(0),
- deferredForSearch = new $.Deferred();
- var visiblePopup = ko.observable(false);
- var dataCalorie = ko.observableArray(),
- dataAtfw = ko.observableArray(),
- dataTemperatureCalorie = ko.observableArray(),
- dataTemperatureElectricity = ko.observableArray()
- ;
- var formulaGet = new BWA.Chart.FormulaGet(BWA.UserInfo.SiteId());
-
-
- var timeBoxForSearch = BWA.SearchView.createDateTimeBox($G.TimeTypesForHourOnly, null, false);
- var chartCOP = BWA.Chart.Instance('chartCOPISA', 'dxChart'),
- chartCOPout = BWA.Chart.Instance('chartCOPoutISA', 'dxChart'),
- chartStoreLoad = BWA.Chart.Instance('chartStoreLoadISA', 'dxChart'),
- chartCOPLoad = BWA.Chart.Instance('chartCOPLoadISA', 'dxChart');
-
- var chartLayout = new BWA.ChartLayout({
- divs: [[{
- id: 'IceStoreAirDetail'
- }, {
- id: 'COP',
- chartId: 'chartCOPISA'
- }, {
- id: 'COPout',
- chartId: 'chartCOPoutISA'
- }, {
- id: 'StoreLoad',
- chartId: 'chartStoreLoadISA'
- }, {
- id: 'COPLoad',
- chartId: 'chartCOPLoadISA'
- }, {
- id: 'ColdCOP',
- chartId: 'chartColdCOPISA'
- }, {
- id: 'KCAL',
- chartId: 'chartKCALISA'
- }, {
- id: 'Effi',
- chartId: 'chartEffiISA'
- }, {
- id: 'Approch',
- chartId: 'chartApprochISA'
- }
- ]
- ],
- multiViewOptions: {
- viewIndex: currentTabIndex,
-
- viewCount: 1
- }
- });
- var m = moment();
- dataCalorie([
- { DateTime: new Date(m.year(), m.month(), 1), Value: 50 },
- { DateTime: new Date(m.year(), m.month(), 2), Value: 50 },
- { DateTime: new Date(m.year(), m.month(), 3), Value: 60 },
- { DateTime: new Date(m.year(), m.month(), 4), Value: 80 },
- { DateTime: new Date(m.year(), m.month(), 5), Value: 100 },
- { DateTime: new Date(m.year(), m.month(), 6), Value: 40, },
- { DateTime: new Date(m.year(), m.month(), 7), Value: 120 },
- { DateTime: new Date(m.year(), m.month(), 31), Value: 120 }
- ]);
-
- var CODE = $Code,
- FuelType = CODE.FuelType,
- FT = CODE.FacilityType,
- FC = CODE.FacilityCode,
- F = CODE.Formula,
- TIT = CODE.TimeIntervalType;
-
-
-
-
-
-
-
-
- function handleViewShown() {
- if (initialized === false) {
- var chartOption = BWA.ChartOptions.IceStoreAirAnalysis;
- chartCOP = chartCOP(chartOption.getChartCOPOptions($Code.TimeType.HOUR));
- chartCOPout = chartCOPout(chartOption.getChartCOPoutOptions($Code.TimeType.HOUR));
- chartStoreLoad = chartStoreLoad(chartOption.getChartStoreLoadOptions($Code.TimeType.HOUR));
- chartCOPLoad = chartCOPLoad(chartOption.getChartCOPOptions2($Code.TimeType.HOUR));
-
-
- initialized = true;
- }
-
- timeBoxForSearch.setDefaultDate();
- var eq = BWA.DataUtil.constructEqualFilter;
- facilityDataSource.filter([
- eq('SiteId', BWA.UserInfo.SiteId()),
- 'and',
- eq('FacilityTypeId', $Code.FacilityType.ICESTOREAIR)
- ]);
- facilityDataSource.load().done(function(facilities) {
- facilitiesForSearch(facilities);
- if (_.isEmpty(facilities) === false) {
- var f = facilities[0];
- handleSelectedFacilityInSearchView(f);
- handleSearchInSearchView();
- var datagrid = $('#IceStoreAirDataGridViewInSearchView').dxDataGrid('instance');
- if (_.has(datagrid, 'selectRows')) {
- datagrid.selectRows(f);
- }
- }
- });
- }
- if (shouldReload) {
-
-
-
- }
- function handleViewHidden() {
-
-
-
- var paging = BWA.ChartLayout.Paging;
- paging.sideOverlayVisible(false);
-
-
- $SearchView.visibleObservable(false);
- visiblePopup(false);
- }
- function handleViewShowing() {
- }
- function refreshList() {
-
-
- }
- var searchViewOptions = {
- searchViewItems: [
- { id: 'FacilityCode', ignoreValue: 0, defaultValue: 0, value: facilityCodeForSearch, dataSource: facilitiesForSearch },
- ],
- promiseDataInSearchView: deferredForSearch.promise()
- };
- function handleSelectedFacilityInSearchView(facility) {
- m_Facility = facility;
- return;
- }
- function handleSearchInSearchView(filter, searchViewItems) {
-
-
- if (m_Facility == null) return;
- visiblePopup(true);
- var f = m_Facility.toJS();
- facilityViewModel.fromJS(f);
-
- var timeIntervalType = timeBoxForSearch.type();
- var formula = $Code.Formula[$Code.FacilityType.ICESTOREAIR];
- var formulaIds = _.values(formula);
- var date = timeBoxForSearch.getDate();
-
- var promises = [];
- _.each(formulaIds, function (formulaId) {
- var p = formulaGet.apiGet({
- FacilityTypeId: f.FacilityTypeId,
- FacilityCode: f.FacilityCode,
- FormulaId: formulaId,
- TimeIntervalType: timeIntervalType,
- StartDate: date.startDate,
- EndDate: date.endDate
- });
- promises.push(p);
- });
-
- var commonParameters = {
-
- TimeIntervalType: timeIntervalType,
- StartDate: date.startDate,
- EndDate: date.endDate
- };
- var temperatureParameters = {
- FacilityTypeId: FT.OUTDOOR,
- FacilityCode: FC.OUTDOOR,
- FormulaId: F[FT.OUTDOOR].TEMPERATURE,
- };
- var humidityParameters = _.extend({}, temperatureParameters, {
- FormulaId: F[FT.OUTDOOR].HUMIDITY,
- });
- promises.push(formulaGet.apiGet(_.extend(temperatureParameters, commonParameters)));
- promises.push(formulaGet.apiGet(_.extend(humidityParameters, commonParameters)));
- $.when.apply(this, promises)
- .done(function (cold_av, effi, load, cold_kcal, vline_kcal, elec, sw, COP, input_temp, out_temp, h_temp, approch, kcal,
- // 2016 02 29 추가
- cop1, cop2, load1, load2,
- OUTtemperatures, humidities) {
- cold_av = cold_av[0];
- effi = effi[0];
- load = load[0];
- cold_kcal = cold_kcal[0];
- vline_kcal = vline_kcal[0];
- elec = elec[0];
- sw = sw[0];
- COP = COP[0];
- input_temp = input_temp[0];
- out_temp = out_temp[0];
- h_temp = h_temp[0];
- approch = approch[0];
- kcal = kcal[0];
- cop1 = cop1[0];
- cop2 = cop2[0];
- load1 = load1[0];
- load2 = load2[0];
-
- var COPDataArray = [];
- _.each(COP, function (x) {
- COPDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- cop: x.Value
- });
- });
-
-
- _.each(elec, function (x) {
- COPDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- elec: x.Value
- });
- });
-
- var options = BWA.ChartOptions.IceStoreAirAnalysis.getChartCOPOptions(timeBoxForSearch.type());
-
- options.dataSource = COPDataArray;
- chartCOP().option(options);
-
- var COPoutDataArray = [];
- var maxValue = 0;
-
-
- _.each(kcal, function (x) {
- COPoutDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- kcal: x.Value
- });
- if (maxValue < x.Value) maxValue = x.Value;
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- options = BWA.ChartOptions.IceStoreAirAnalysis.getChartKCALoutOptions(timeBoxForSearch.type());
-
-
- options.dataSource = COPoutDataArray;
- chartCOPout().option(options);
-
-
- var dataArray = BWA.Chart.getRelationDataArrayOnDateTime(
- kcal, load1, 'kcal', 'load1');
- var dataArray2 = BWA.Chart.getRelationDataArrayOnDateTime(
- kcal, load2, 'kcal', 'load2');
- _.each(dataArray2, function (x) {
- dataArray.push(x);
- });
- options = BWA.ChartOptions.IceStoreAirAnalysis.getChartStoreLoadOptions(timeBoxForSearch.type());
- options.dataSource = dataArray;
- chartStoreLoad().option(options);
-
-
- dataArray = [];
- _.each(cop1, function (x) {
- dataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- cop1: x.Value
- });
- });
- _.each(cop2, function (x) {
- dataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- cop2: x.Value
- });
- });
- _.each(kcal, function (x) {
- dataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- kcal : x.Value
- });
- });
- var options = BWA.ChartOptions.IceStoreAirAnalysis.getChartCOPOptions2(timeBoxForSearch.type());
- options.dataSource = dataArray;
- chartCOPLoad().option(options);
-
-
- visiblePopup(false);
- return;
-
- var ColdCOPDataArray = [];
- _.each(input_temp, function (x) {
- ColdCOPDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- temp: x.Value
- });
- });
- _.each(COP, function (x) {
- ColdCOPDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- cop: x.Value
- });
- });
- _.each(load, function (x) {
- ColdCOPDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- load: x.Value
- });
- });
-
- options = BWA.ChartOptions.IceStoreAirAnalysis.getChartColdCOPOptions(timeBoxForSearch.type());
-
- options.dataSource = ColdCOPDataArray;
- chartColdCOP().option(options);
-
- var KCALDataArray = [];
- _.each(cold_kcal, function (x) {
- KCALDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- cold_kcal: x.Value
- });
- });
- _.each(vline_kcal, function (x) {
- KCALDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- vline_kcal: x.Value
- });
- });
-
- options = BWA.ChartOptions.IceStoreAirAnalysis.getChartKCALOptions(timeBoxForSearch.type());
-
- options.dataSource = KCALDataArray;
- chartKCAL().option(options);
-
- var EffiDataArray = [];
- _.each(effi, function (x) {
- EffiDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- effi: x.Value
- });
- });
- _.each(sw, function (x) {
- EffiDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- sw: x.Value
- });
- });
-
- options = BWA.ChartOptions.IceStoreAirAnalysis.getChartEffiOptions(timeBoxForSearch.type());
-
- options.dataSource = EffiDataArray;
- chartEffi().option(options);
-
- var ApproDataArray = [];
- _.each(approch, function (x) {
- ApproDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- approch: x.Value
- });
- });
- _.each(h_temp, function (x) {
- ApproDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- h_temp: x.Value
- });
- });
- _.each(input_temp, function (x) {
- ApproDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- in_temp: x.Value
- });
- });
- _.each(out_temp, function (x) {
- ApproDataArray.push({
-
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- out_temp: x.Value
- });
- });
-
- options = BWA.ChartOptions.IceStoreAirAnalysis.getChartApprochOptions(timeBoxForSearch.type());
-
- options.dataSource = ApproDataArray;
- chartApproch().option(options);
-
- visiblePopup(false);
-
-
-
- })
- .fail(function (error) {
-
- visiblePopup(false);
- });
- }
- var viewModel = $.extend(BWA.CommonView.create(
- params, viewInfo, searchViewOptions, ko.observable(null),
- handleViewShown, null, handleSearchInSearchView, undefined,
- chartLayout), {
- refreshList: refreshList,
- viewHidden: handleViewHidden,
- viewShowing: handleViewShowing,
- scrolling: { mode: 'infinite' },
- IceStoreAirDataGridOptions: {
- dataSource: facilitiesForSearch,
- columns: [
- { dataField: 'Name', caption: $G('facilityName'), width: '100%', alignment: 'left' }
- ],
- filterRow: {
- visible: true,
- showOperationChooser: false
- },
- selection: {
- mode: 'single'
- },
- rowClick: function(clickRow) {
- handleSelectedFacilityInSearchView(clickRow.data);
- }
- },
- contentReadyAction: function(e) {
- datagrid = e.component;
- }
- });
- viewModel.timeBoxForSearch = timeBoxForSearch;
- viewModel.currentTabIndex = currentTabIndex;
- viewModel.multiViewItems = [{
- facility: facilityViewModel,
- template: 'mainCharts'
- }, {
- template: 'subCharts'
- }
- ];
- $HourGlassPopup(viewModel, visiblePopup);
- return viewModel;
- };
|