123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588 |
- BemsWebApplication.HeatExchangerAnalysis = 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 chartEffi = BWA.Chart.Instance('chartEffiHEA', 'dxChart'),
- chartAV = BWA.Chart.Instance('chartAVHEA', 'dxChart'),
- chartPump = BWA.Chart.Instance('chartPumpHEA', 'dxChart'),
- chartATF = BWA.Chart.Instance('chartATFHEA', 'dxChart');
- var chartLayout = new BWA.ChartLayout({
- divs: [[{
- id: 'HeatExchangerDetail'
- }, {
- id: 'Effi',
- chartId: 'chartEffiHEA'
- }, {
- id: 'AV',
- chartId: 'chartAVHEA'
- }, {
- id: 'Pump',
- chartId: 'chartPumpHEA'
- }, {
- id: 'ATF',
- chartId: 'chartATFHEA'
- }
- ]],
- multiViewOptions: {
- viewIndex: currentTabIndex,
- viewCount: 1
- }
- });
-
-
- var DataGridPopup_Visible = ko.observable(false);
-
- var dataArrayresult = ko.observableArray();
-
- 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.HeatExchangerAnalysis;
-
- chartEffi = chartEffi(chartOption.getChart_1_Options($Code.TimeType.HOUR));
-
- chartAV = chartAV(chartOption.getChart_2_Options($Code.TimeType.HOUR));
- chartPump = chartPump(chartOption.getChart_3_Options($Code.TimeType.HOUR));
-
- chartATF = chartATF(chartOption.getChart_4_Options($Code.TimeType.HOUR));
- initialized = true;
- }
-
- timeBoxForSearch.setDefaultDate();
- var eq = BWA.DataUtil.constructEqualFilter;
- facilityDataSource.filter([
- eq('SiteId', BWA.UserInfo.SiteId()),
- 'and',
- eq('FacilityTypeId', $Code.FacilityType.EARTH)
- ]);
- facilityDataSource.load().done(function(facilities) {
- facilitiesForSearch(facilities);
- if (_.isEmpty(facilities) === false) {
- var f = facilities[0];
- handleSelectedFacilityInSearchView(f);
- handleSearchInSearchView();
- var datagrid = $('#HeatExchangerDataGridViewInSearchView').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.EARTH];
- 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 (cop, load, in_temp, out_temp, kw, green, OUTtemperatures, humidities) {
- cop = cop[0];
- load = load[0];
- in_temp = in_temp[0];
- out_temp = out_temp[0];
- kw = kw[0];
-
-
- var maxValuecops = 0;
- _.each(cop, function (x) {
- if (maxValuecops < x.Value) maxValuecops = x.Value;
- });
- var EffiDataArray = BWA.Chart.mapNewWithConvertingDateTime(cop, timeBoxForSearch.type());
- _.each(OUTtemperatures[0], function (x) {
- EffiDataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- Temperature: x.Value
- });
- });
- _.each(humidities[0], function (x) {
- EffiDataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- Humidity: x.Value
- });
- });
- var options = BWA.ChartOptions.HeatExchangerAnalysis.getChart_1_Options(timeBoxForSearch.type());
- options.valueAxis[0].tickInterval = Math.round(maxValuecops / 5) + 1;
- options.dataSource = EffiDataArray;
- chartEffi().option(options);
-
-
-
- var dataArray = BWA.Chart.getRelationDataArrayOnDateTime(cop, load, 'cop', 'load');
- var options = BWA.ChartOptions.HeatExchangerAnalysis.getChart_2_Options(timeBoxForSearch.type());
-
- options.dataSource = dataArray;
- chartAV().option(options);
-
-
- var maxValuecops = 0;
- _.each(load, function (x) {
- if (maxValuecops < x.Value) maxValuecops = x.Value;
- });
- EffiDataArray = BWA.Chart.mapNewWithConvertingDateTime(load, timeBoxForSearch.type());
-
-
-
-
-
-
-
-
-
-
-
-
- var options = BWA.ChartOptions.HeatExchangerAnalysis.getChart_3_Options(timeBoxForSearch.type());
-
- options.dataSource = EffiDataArray;
- chartPump().option(options);
-
- var DataArray_temp = [], DataArray_temp1 = [], DataArray_temp2 = [], DataArray_temp3 = [];
- EffiDataArray = BWA.Chart.mapNewWithConvertingDateTime(kw, timeBoxForSearch.type());
- DataArray_temp = BWA.Chart.mapNewWithConvertingDateTime(kw, timeBoxForSearch.type());
- _.each(in_temp, function (x) {
- EffiDataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- in_temp: x.Value
- });
- });
- _.each(out_temp, function (x) {
- EffiDataArray.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- out_temp: x.Value
- });
- });
- _.each(in_temp, function (x) {
- DataArray_temp1.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString($Code.TimeType.QUARTERMIN, moment(x.DateTime).toDate()),
- in_temp: x.Value
- });
- });
- _.each(out_temp, function (x) {
- DataArray_temp2.push({
- DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
- out_temp: x.Value
- });
- });
- var array_length_size = Math.max(DataArray_temp.length, DataArray_temp1.length, DataArray_temp2.length);
-
- if (DataArray_temp.length == DataArray_temp1.length && DataArray_temp1.length == DataArray_temp2.length) {
- for (var i = 0; i < array_length_size; i++) {
- DataArray_temp3.push(
- {
- DateTime: DataArray_temp1[i].DateTime,
- 'kw': DataArray_temp[i].Value,
- 'in_temp': DataArray_temp1[i].in_temp,
- 'out_temp': DataArray_temp2[i].out_temp,
- });
- }
- }
- var options = BWA.ChartOptions.HeatExchangerAnalysis.getChart_4_Options(timeBoxForSearch.type());
-
- options.dataSource = EffiDataArray;
-
- dataArrayresult = DataArray_temp3;
- chartATF().option(options);
- visiblePopup(false);
- })
- .fail(function (error) {
- visiblePopup(false);
- });
- }
-
- function DataGridPopup_ButtonClick() {
- DataGridPopup_Visible(true);
- }
- function handlePopupShown() {
-
- $("#HeatExchangerDataGrid_Container").dxDataGrid("instance").option("dataSource", dataArrayresult);
-
- DataGridPopup_Visible(true);
- }
- 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' },
- HeatExchangerDataGridOptions: {
- 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;
- }
-
- , HeatExchangerDataGridPopup_ButtonClicked: DataGridPopup_ButtonClick
-
- });
-
- viewModel.HeatExchangerDataGridPopupOptions = {
- width: '480px',
- height: '750px',
- contentTemplate: "content",
- showTitle: true,
- title: "도표",
- visible: DataGridPopup_Visible,
- dragEnabled: true,
- closeOnOutsideClick: true,
- shownAction: handlePopupShown,
- animation: window.utils.popup.createAnimation()
- };
-
- viewModel.timeBoxForSearch = timeBoxForSearch;
- viewModel.currentTabIndex = currentTabIndex;
- viewModel.multiViewItems = [{
- facility: facilityViewModel,
- template: 'mainCharts'
- }, {
- template: 'subCharts'
- }
- ];
- $HourGlassPopup(viewModel, visiblePopup);
-
- viewModel.HeatExchangerDataGridOptions1 = {
- dataSource: dataArrayresult,
- paging: { pageSize: 17 },
- columns: [
- { dataField: 'DateTime', caption: "날짜", width: '31%', alignment: 'center', },
- { dataField: 'kw', caption: "소비전력", width: '23%', alignment: 'center', format: 'fixedPoint', precision: 2 },
- { dataField: 'in_temp', caption: "공급온도", width: '23%', alignment: 'center', format: 'fixedPoint', precision: 2 },
- { dataField: 'out_temp', caption: "환수온도", width: '23%', alignment: 'center', format: 'fixedPoint', precision: 2 }
- ],
-
- "export": {
- enabled: true,
- fileName: '지열시스템 성능분석'
- }
- };
-
- return viewModel;
- };
|