123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- BemsWebApplication.PlanConsumeRegression = function (params) {
-
- return {
- viewShown: function () {
- $("#Popup").dxPopup({
- visible: false,
- width: '700px',
- height: '100px', // cyim 2017.05.30 : 테스트 결과 Devextreme 버그임. px 로 지정하면 초기 출력시 정확하게 가운데에 있지만, auto 설정시 화면아래에 위치하게 됨
- contentTemplate: "content",
- showTitle: true,
- title: "설정",
- dragEnabled: true,
- closeOnOutsideClick: false,
- shadingColor: 'rgba(0,0,0,0.0)',
- shownAction: handlePopupShown,
- animation: window.utils.popup.createAnimation()
- });
- $("#Button_PredictionConfig").dxButton({
- text: "설정",
- onClick: function () {
- // 팝업 출력
- $("#Popup").dxPopup('instance').option('visible', true);
- }
- });
- // 팝업 생성되면서 실행
- function handlePopupShown() {
- var BemsEnergyDailyRegression = BemsWebApplication.db.createDataSource('BemsEnergyDailyRegression');
- BemsEnergyDailyRegression.filter([
- ['SiteId', '=', BWA.UserInfo.SiteId()],
- ]);
- BemsEnergyDailyRegression.load().done(function (result) {
- var EnableRegression = false;
- _.each(result, function (x) {
- EnableRegression = x.IsRegression()
- });
- $("#Switch_Regression").dxSwitch({
- value: EnableRegression
- });
- $("#Button_Save").dxButton({
- text: "저장",
- onClick: function () {
- var EnableRegression = $("#Switch_Regression").dxSwitch('instance').option('value');
- BWA.db.BemsEnergyDailyRegression.update({
- SiteId: BWA.UserInfo.SiteId()
- }, {
- IsRegression: EnableRegression
- }).done(function () {
- utils.toast.show('저장에 성공하였습니다.');
- }).fail(function () {
- utils.toast.show('저장에 실패하였습니다.', 'error');
- });
- }
- });
- });
- }
- var DataArrayInfoForGrid = new Array();
- var DataArrayInfo = new Array();
- var BemsEnergyDailyRegression = BemsWebApplication.db.createDataSource('BemsEnergyDailyRegression');
- BemsEnergyDailyRegression.filter([
- ['SiteId', '=', BWA.UserInfo.SiteId()],
- ]);
- BemsEnergyDailyRegression.load().done(function (result) {
- _.each(result, function (x) {
- DataArrayInfoForGrid.push({
- Type: '주중',
- Electricity: x.Weekday_Power_Temp(),
- Gas: x.Weekday_Gas_Temp(),
- Water: x.Weekday_Water_Temp()
- });
- DataArrayInfoForGrid.push({
- Type: '휴일',
- Electricity: x.Holiday_Power_Temp(),
- Gas: x.Holiday_Gas_Temp(),
- Water: x.Holiday_Water_Temp()
- });
- });
- $("#Grid_RegressionInfo").dxDataGrid({
- dataSource: DataArrayInfoForGrid,
- rowAlternationEnabled: true,
- columns: [
- { dataField: 'Type', caption: '주중/주말', width: '10%', alignment: 'center' },
- { dataField: 'Electricity', caption: '전기', width: '30%', alignment: 'center' },
- { dataField: 'Gas', caption: '가스', width: '30%', alignment: 'center' },
- { dataField: 'Water', caption: '수도', width: '30%', alignment: 'center' }
- ],
- paging: {
- enabled: true,
- pageIndex: 0,
- pageSize: 20,
- }
- });
- });
- $("#NumberBox_TodayMeanT").dxNumberBox({
- value: null
- });
- $("#NumberBox_TodayHDD").dxNumberBox({
- value: null
- });
- $("#NumberBox_TodayCDD").dxNumberBox({
- value: null
- });
- $("#NumberBox_TomorrowMeanT").dxNumberBox({
- value: null
- });
- $("#NumberBox_TomorrowHDD").dxNumberBox({
- value: null
- });
- $("#NumberBox_TomorrowCDD").dxNumberBox({
- value: null
- });
- $("#NumberBox_TodayPowerPrediction").dxNumberBox({
- value: null
- });
- $("#NumberBox_TodayGasPrediction").dxNumberBox({
- value: null
- });
- $("#NumberBox_TodayWaterPrediction").dxNumberBox({
- value: null
- });
- $("#NumberBox_TomorrowPowerPrediction").dxNumberBox({
- value: null
- });
- $("#NumberBox_TomorrowGasPrediction").dxNumberBox({
- value: null
- });
- $("#NumberBox_TomorrowWaterPrediction").dxNumberBox({
- value: null
- });
- // 오늘
- var date = new Date();
- var dd = date.getDate();
- var mm = date.getMonth() + 1; //January is 0!
- var yyyy = date.getFullYear();
- var today = new Date(yyyy + '-' + mm + '-' + dd + ' 00:00:00');
- // 내일
- date.setDate(date.getDate() + 1);
- var temp_dd = date.getDate();
- var temp_mm = date.getMonth() + 1; //January is 0!
- var temp_yyyy = date.getFullYear();
- var tomorrow = new Date(temp_yyyy + '-' + temp_mm + '-' + temp_dd + ' 00:00:00');
- $("#TodayMeanT").html(dd + "일 평균 온도");
- $("#TodayHDD").html(dd + "일 HDD");
- $("#TodayCDD").html(dd + "일 CDD");
- $("#TodayPowerPrediction").html(dd + "일 전력 사용량 예측(KWh)");
- $("#TodayGasPrediction").html(dd + "일 가스 사용량 예측(m3)");
- $("#TodayWaterPrediction").html(dd + "일 수도 사용량 예측(m3)");
- $("#TomorrowMeanT").html(temp_dd + "일 평균 온도");
- $("#TomorrowHDD").html(temp_dd + "일 HDD");
- $("#TomorrowCDD").html(temp_dd + "일 CDD");
- $("#TomorrowPowerPrediction").html(temp_dd + "일 전력 사용량 예측(KWh)");
- $("#TomorrowGasPrediction").html(temp_dd + "일 가스 사용량 예측(m3)");
- $("#TomorrowWaterPrediction").html(temp_dd + "일 수도 사용량 예측(m3)");
- var toe_power = '';
- var toe_gas = '';
- var BemsFactorToe = BemsWebApplication.db.createDataSource('BemsFactorToe');
- BemsFactorToe.load().done(function (result) {
- // toe 정보
- var num = 1;
- _.each(result, function (x) {
- if (num == 1) toe_power = x.TotalFactor();
- if (num == 2) toe_gas = x.TotalFactor();
- num++;
- });
- var BemsEnergyDaily = BemsWebApplication.db.createDataSource('BemsEnergyDaily');
- BemsEnergyDaily.filter([
- ['SiteId', '=', BWA.UserInfo.SiteId()],
- ['BuildingId', '=', 1],
- ['ServiceTypeId', '=', 1],
- ['FuelTypeId', '=', 1],
- ['CreatedDate', '=', today]
- ]);
- BemsEnergyDaily.load().done(function (result) {
- _.each(result, function (x) {
- $("#NumberBox_TodayMeanT").dxNumberBox({ value: x.MeanT() });
- $("#NumberBox_TodayHDD").dxNumberBox({ value: x.HDD() });
- $("#NumberBox_TodayCDD").dxNumberBox({ value: x.CDD() });
- $("#NumberBox_TodayPowerPrediction").dxNumberBox({ value: parseFloat(x.Prediction_Regression()).toFixed(2) });
- });
- });
- // 가스
- BemsEnergyDaily.filter([
- ['SiteId', '=', BWA.UserInfo.SiteId()],
- ['BuildingId', '=', 1],
- ['ServiceTypeId', '=', 1],
- ['FuelTypeId', '=', 2], // 가스
- ['CreatedDate', '=', today]
- ]);
- BemsEnergyDaily.load().done(function (result) {
- _.each(result, function (x) {
- // 가스는 환산해서 보여준다
- var gas_m3 = x.Prediction_Regression() * toe_power / toe_gas;
- $("#NumberBox_TodayGasPrediction").dxNumberBox({ value: gas_m3.toFixed(2) });
- });
- });
- // 수도
- BemsEnergyDaily.filter([
- ['SiteId', '=', BWA.UserInfo.SiteId()],
- ['BuildingId', '=', 1],
- ['ServiceTypeId', '=', 1],
- ['FuelTypeId', '=', 3], // 수도
- ['CreatedDate', '=', today]
- ]);
- BemsEnergyDaily.load().done(function (result) {
- _.each(result, function (x) {
- $("#NumberBox_TodayWaterPrediction").dxNumberBox({ value: parseFloat(x.Prediction_Regression()).toFixed(2) });
- });
- });
- BemsEnergyDaily.filter([
- ['SiteId', '=', BWA.UserInfo.SiteId()],
- ['BuildingId', '=', 1],
- ['ServiceTypeId', '=', 1],
- ['FuelTypeId', '=', 1],
- ['CreatedDate', '=', tomorrow]
- ]);
- BemsEnergyDaily.load().done(function (result) {
- _.each(result, function (x) {
- $("#NumberBox_TomorrowMeanT").dxNumberBox({ value: x.MeanT() });
- $("#NumberBox_TomorrowHDD").dxNumberBox({ value: x.HDD() });
- $("#NumberBox_TomorrowCDD").dxNumberBox({ value: x.CDD() });
- $("#NumberBox_TomorrowPowerPrediction").dxNumberBox({ value: parseFloat(x.Prediction_Regression()).toFixed(2) });
- });
- });
- // 가스
- BemsEnergyDaily.filter([
- ['SiteId', '=', BWA.UserInfo.SiteId()],
- ['BuildingId', '=', 1],
- ['ServiceTypeId', '=', 1],
- ['FuelTypeId', '=', 2], // 가스
- ['CreatedDate', '=', tomorrow]
- ]);
- BemsEnergyDaily.load().done(function (result) {
- _.each(result, function (x) {
- // 가스는 환산해서 보여준다
- var gas_m3 = x.Prediction_Regression() * toe_power / toe_gas;
- $("#NumberBox_TomorrowGasPrediction").dxNumberBox({ value: gas_m3.toFixed(2) });
- });
- });
- // 수도
- BemsEnergyDaily.filter([
- ['SiteId', '=', BWA.UserInfo.SiteId()],
- ['BuildingId', '=', 1],
- ['ServiceTypeId', '=', 1],
- ['FuelTypeId', '=', 3], // 수도
- ['CreatedDate', '=', tomorrow]
- ]);
- BemsEnergyDaily.load().done(function (result) {
- _.each(result, function (x) {
- $("#NumberBox_TomorrowWaterPrediction").dxNumberBox({ value: parseFloat(x.Prediction_Regression()).toFixed(2) });
- });
- });
- });
- $SideMenu.showSideMenuIfWill(params.view);
-
- }
- }
- };
|