123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 |
- BemsWebApplication.AirHandlingAnalysis = 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();
- // cyim 2016.08.22 : 성능분석 그래프의 경우 시간 데이타만 표시되어야 한다
- var timeBoxForSearch = BWA.SearchView.createDateTimeBox($G.TimeTypesForHourOnly, null, false);
- var chartCalorieC = BWA.Chart.Instance('chartCalorieCAIR', 'dxChart'),
- chartCalorieH = BWA.Chart.Instance('chartCalorieHAIR', 'dxChart'),
- chartAtfw = BWA.Chart.Instance('chartAtfwAIR', 'dxChart'),
- chartVOpen = BWA.Chart.Instance('chartVOpenAIR', 'dxChart'),
- chartTemperatureElectricity = BWA.Chart.Instance('chartTemperatureElectricityAIR', 'dxChart');
- //chartTemperatureCalorie = BWA.Chart.Instance('chartTemperatureCalorie', 'dxChart'),
- // chartTemperatureElectricity2 = BWA.Chart.Instance('chartTemperatureElectricity2AIR', 'dxChart');
- var chartLayout = new BWA.ChartLayout({
- divs: [[{
- id: 'airHandlingDetail'
- }, {
- id: 'calorieC',
- chartId: 'chartCalorieCAIR'
- },{
- id: 'calorieH',
- chartId: 'chartCalorieHAIR'
- },{
- id: 'atfw',
- chartId: 'chartAtfwAIR'
- }, {
- id: 'VOpen',
- chartId: 'chartVOpenAIR'
- }, {
- id: 'temperatureElectricity',
- chartId: 'chartTemperatureElectricityAIR'
- }, {
- id: 'temperatureCalorie',
- chartId: 'chartTemperatureCalorieAIR'
- }, {
- id: 'temperatureElectricity2',
- chartId: 'chartTemperatureElectricity2AIR'
- }
- ]],
- 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 }
- ]);
- // 추가 2015 04 20 hcLee ->
- var CODE = $Code,
- FuelType = CODE.FuelType,
- FT = CODE.FacilityType,
- FC = CODE.FacilityCode,
- F = CODE.Formula,
- TIT = CODE.TimeIntervalType;
- // 추가 2015 04 20 hcLee <-
- //dataMonthForBar(dataDayForBar());
- //dataDayForPie([
- // { FuelTypeName: '전기', Value: 320 },
- // { FuelTypeName: '가스', Value: 350 },
- // { FuelTypeName: '수도', Value: 360 },
- //]);
- //dataMonthForPie(dataDayForPie());
- function handleViewShown() {
- if (initialized === false) {
- var chartOption = BWA.ChartOptions.WaterCoolingAnalysis;
- //chartCalorieC = chartCalorieC(chartOption.getChartCalorieCOptions(timeBoxForSearch.type()));
- chartCalorieC = chartCalorieC(chartOption.getChart_1_Options(timeBoxForSearch.type()));
- //chartCalorieH = chartCalorieH(chartOption.getChartCalorieHOptions(timeBoxForSearch.type()));
- chartCalorieH = chartCalorieH(chartOption.getChart_2_Options(timeBoxForSearch.type()));
- chartAtfw = chartAtfw(chartOption.getChartAtfwOptions(timeBoxForSearch.type()));
- //chartVOpen = chartVOpen(chartOption.getChartVOpenOptions(timeBoxForSearch.type()));
- chartVOpen = chartVOpen(chartOption.getChart_3_Options(timeBoxForSearch.type()));
- chartTemperatureElectricity = chartTemperatureElectricity(chartOption.getTemperatureElectricityOptions(timeBoxForSearch.type()));
- //chartTemperatureCalorie = chartTemperatureCalorie(chartOption.getChartTemperatureCalorieOptions($Code.TimeType.HOUR));
- // chartTemperatureElectricity2 = chartTemperatureElectricity2(chartOption.getTemperatureElectricityOptions(timeBoxForSearch.type()));
- initialized = true;
- }
- //hcLee 2016 07 12
- timeBoxForSearch.setDefaultDate();
- var eq = BWA.DataUtil.constructEqualFilter;
- facilityDataSource.filter([
- eq('SiteId', BWA.UserInfo.SiteId()),
- 'and',
- eq('FacilityTypeId', $Code.FacilityType.AIR_HANDLING)
- ]);
- facilityDataSource.load().done(function(facilities) {
- facilitiesForSearch(facilities);
- if (_.isEmpty(facilities) === false) {
- var f = facilities[0];
- handleSelectedFacilityInSearchView(f);
- handleSearchInSearchView();
- var datagrid = $('#airHandlingDataGridViewInSearchView').dxDataGrid('instance');
- if (_.has(datagrid, 'selectRows')) {
- datagrid.selectRows(f);
- }
- }
- });
- }
- if (shouldReload) {
- //shouldReload = false;
- //dataSource.pageIndex(0);
- //dataSource.load();
- }
- function handleViewHidden() {
- var paging = BWA.ChartLayout.Paging;
- paging.sideOverlayVisible(false);
- $SearchView.visibleObservable(false); // hcLee 2015 03 23
- visiblePopup(false);
- }
- function handleViewShowing() {
- }
- function refreshList() {
- //dataSource.pageIndex(0);
- //dataSource.load();
- }
- 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) {
- //console.log(filter);
- //console.log(searchViewItems);
- if (m_Facility == null) return;
- visiblePopup(true);
- var f = m_Facility.toJS();
- facilityViewModel.fromJS(f);
- //var timeIntervalType = $Code.TimeIntervalType.QUARTERMIN;
- var timeIntervalType = timeBoxForSearch.type();
- var formula = $Code.Formula[$Code.FacilityType.AIR_HANDLING];
- var formulaIds = _.values(formula);
- var date = timeBoxForSearch.getDate();
- //utils.toast.displayTime=1000000;
- //utils.toast.show('공조기 성능분석 중 입니다. 잠시만 기다려 주세요');
- // var startDate = moment().
- 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);
- });
- // 외기 온도와 습도를 위해 추가 hcLee 2015 04 20 ->
- var commonParameters = {
- //TimeIntervalType: $Code.TimeIntervalType.QUARTERMIN,
- 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)));
- // 외기 온도와 습도를 위해 추가 hcLee 2015 04 20 <-
- //promises.push(utils.toast.show('공조기 성능분석 중 입니다. 잠시만 기다려 주세요'));
- $.when.apply(this, promises)
- .done(function (coldWaterCalories, hotWaterCalories, coldWaterAtfws,
- hotWaterAtfws, in_temperatures, out_temperatures, cold_electricities, hot_electricities,
- cold_vopen, hot_vopen,
- cold_in_temperatures, cold_out_temperatures, // 이 2개는 2015 06 15일 추가
- f_temp, f_humi, // 2015 07 10 추가
- co2, // 2015 07 10 추가
- x16, x17, x18, x19, x20,
- A21, A22, A23, A24, A25, A26,
- OUTtemperatures) {
- coldWaterCalories = coldWaterCalories[0];
- hotWaterCalories = hotWaterCalories[0];
- coldWaterAtfws = coldWaterAtfws[0];
- hotWaterAtfws = hotWaterAtfws[0];
- in_temperatures = in_temperatures[0];
- out_temperatures = out_temperatures[0];
- cold_electricities = cold_electricities[0];
- hot_electricities = hot_electricities[0];
- cold_vopen = cold_vopen[0];
- hot_vopen = hot_vopen[0];
- cold_in_temperatures = cold_in_temperatures[0];
- cold_out_temperatures = cold_out_temperatures[0];
- A21 = A21[0];
- A22 = A22[0];
- A23 = A23[0];// 급기휀 소비전력
- A24 = A24[0];// 환기휀 소비전력
- A25 = A25[0];// 급기휀 주파수
- A26 = A26[0];// 환기휀 주파수
- OUTtemperatures = OUTtemperatures[0];
- BWA.Chart.mapWithConvertingDateTime(coldWaterCalories, timeBoxForSearch.type());
- BWA.Chart.mapWithConvertingDateTime(hotWaterCalories, timeBoxForSearch.type());
- //BWA.Chart.mapWithConvertingDateTime(coldWaterAtfws);
- //BWA.Chart.mapWithConvertingDateTime(hotWaterAtfws);
- BWA.Chart.mapWithConvertingDateTime(OUTtemperatures, timeBoxForSearch.type());
- /*
- var coldWaterCalorieDataArray = _.map(coldWaterCalories, function (x) {
- return {
- DateTime: x.DateTime,
- //DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), x.DateTime),
- CV: x.Value
- };
- })
- _.each(cold_in_temperatures, function (x) {
- coldWaterCalorieDataArray.push({
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- cold_in_temp: x.Value
- });
- });
- _.each(cold_out_temperatures, function (x) {
- coldWaterCalorieDataArray.push({
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- cold_out_temp: x.Value
- });
- });
- var options = BWA.ChartOptions.WaterCoolingAnalysis.getChartCalorieCOptions(timeBoxForSearch.type());
- options.dataSource = coldWaterCalorieDataArray;
- chartCalorieC().option(options); */
- var DataArray = _.map(A21, function (x) {
- return {
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- kcal: x.Value
- };
- })
- _.each(coldWaterAtfws, function (x) {
- DataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- afw : x.Value
- });
- });
- var options = BWA.ChartOptions.WaterCoolingAnalysis.getChart_1_Options(timeBoxForSearch.type());
- options.dataSource = DataArray;
- chartCalorieC().option(options);
- // chart 2
- /* var hotWaterCalorieDataArray = _.map(hotWaterCalories, function (x) {
- return {
- DateTime: x.DateTime,
- //DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), x.DateTime),
- HV: x.Value
- };
- })
- //var calories = coldWaterCalorieDataArray.concat(hotWaterCalorieDataArray);
- _.each(in_temperatures, function (x) {
- hotWaterCalorieDataArray.push({
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- in_temp: x.Value
- });
- });
- _.each(out_temperatures, function (x) {
- hotWaterCalorieDataArray.push({
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- out_temp: x.Value
- });
- });
- //var chartOption = BWA.ChartOptions.WaterCoolingAnalysis;
- //chartOption.getChartCalorieOptions(timeBoxForSearch.type());
- //chartCalorie().option.getChartCalorieOptions(timeBoxForSearch.type())
- var options = BWA.ChartOptions.WaterCoolingAnalysis.getChartCalorieHOptions(timeBoxForSearch.type());
- //chartCalorie().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
- options.dataSource = hotWaterCalorieDataArray;
- chartCalorieH().option(options); */
- var DataArray = _.map(A22, function (x) {
- return {
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- kcal: x.Value
- };
- })
- _.each(hotWaterAtfws, function (x) {
- DataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- afw: x.Value
- });
- });
- var options = BWA.ChartOptions.WaterCoolingAnalysis.getChart_2_Options(timeBoxForSearch.type());
- options.dataSource = DataArray;
- chartCalorieH().option(options);
- var atfwDataArray = [];
- var maxValueCHV = 0;
- _.map(coldWaterAtfws, function (x) {
- atfwDataArray.push({
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- CV: x.Value
- });
- if (maxValueCHV < x.Value) maxValueCHV = x.Value;
- })
- _.map(hotWaterAtfws, function (x) {
- atfwDataArray.push({
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- HV: x.Value
- });
- if (maxValueCHV < x.Value) maxValueCHV = x.Value;
- })
- options = BWA.ChartOptions.WaterCoolingAnalysis.getChartAtfwOptions(timeBoxForSearch.type());
- //chartAtfw().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
- //maxValueCHV = 30;
- options.valueAxis[0].tickInterval = Math.round(Math.round(maxValueCHV) / 5) + 1;
- options.dataSource = atfwDataArray.concat(OUTtemperatures);
- chartAtfw().option(options); // 냉난방ATF와 외기온도관계
- //chart 4
- var DataArray = _.map(A23, function (x) {
- return {
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- inkw: x.Value
- };
- })
- _.each(A24, function (x) {
- DataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- outkw : x.Value
- });
- });
- _.each(A25, function (x) {
- DataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- inhz: x.Value
- });
- });
- _.each(A26, function (x) {
- DataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- outhz: x.Value
- });
- });
- var options = BWA.ChartOptions.WaterCoolingAnalysis.getChart_3_Options(timeBoxForSearch.type());
- options.dataSource = DataArray;
- chartVOpen().option(options);
- //chart3
- //chartTemperatureCalorie().option('dataSource', calories.concat(OUTtemperatures));
- //BWA.Chart.mapWithConvertingDateTime(cold_vopen);
- //BWA.Chart.mapWithConvertingDateTime(hot_vopen);
- /*
- var vopenDataArray = [];
- maxValueCHV = 0;
- _.map(cold_vopen, function (x) {
- vopenDataArray.push({
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- CV: x.Value
- });
- if (maxValueCHV < x.Value) maxValueCHV = x.Value;
- })
- _.map(hot_vopen, function (x) {
- vopenDataArray.push({
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- HV: x.Value
- });
- if (maxValueCHV < x.Value) maxValueCHV = x.Value;
- })
- options = BWA.ChartOptions.WaterCoolingAnalysis.getChartVOpenOptions(timeBoxForSearch.type());
- options.valueAxis[0].tickInterval = Math.round(maxValueCHV / 5) + 1;
- //chartVOpen().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
- options.dataSource = vopenDataArray.concat(OUTtemperatures);
- chartVOpen().option(options); // 냉난방ATF와 외기온도관계
- */
- //chart 5
- maxValueCHV = 0;
- var electricityDataArray = _.map(cold_electricities, function (x) {
- if (maxValueCHV < x.Value) maxValueCHV = x.Value;
- return {
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- CV: x.Value
- };
- });
- var hotelectricityDataArray = _.map(hot_electricities, function (x) {
- if (maxValueCHV < x.Value) maxValueCHV = x.Value;
- return {
- //DateTime: moment(x.DateTime).toDate(),
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- HV: x.Value
- };
- });
- options = BWA.ChartOptions.WaterCoolingAnalysis.getTemperatureElectricityOptions(timeBoxForSearch.type());
- //chartTemperatureElectricity().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
- options.valueAxis[0].tickInterval = Math.round(maxValueCHV / 5) + 1;
- electricityDataArray = electricityDataArray.concat(hotelectricityDataArray);
- options.dataSource = electricityDataArray.concat(OUTtemperatures);
- chartTemperatureElectricity().option(options);
- visiblePopup(false);
- /* msgbox.
- $("#large-indicator").dxLoadIndicator({
- height: 60,
- width: 60
- });*/
- //chartTemperatureCalorie().option('dataSource', calories.concat(OUTtemperatures));
- //chartTemperatureElectricity2().option('dataSource', electricityDataArray.concat(OUTtemperatures));
- })
- .fail(function (error) {
- //alert(error);
- visiblePopup(false);
- });
- }
- var viewModel = $.extend(BWA.CommonView.create(
- params, viewInfo, searchViewOptions, ko.observable(null),
- handleViewShown, null, handleSearchInSearchView, undefined,
- chartLayout), {
- // facility: facilityViewModel,
- viewHidden: handleViewHidden, // hcLee 2015 06 03
- refreshList: refreshList,
- viewShowing: handleViewShowing,
- scrolling: { mode: 'infinite' },
- airHandlingDataGridOptions: {
- 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;
- };
|