5159c56c7cbb13a02e71829921c6dfdfa61d95f0.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. BemsWebApplication.PlanConsumeRegression = function (params) {
  2. return {
  3. viewShown: function () {
  4. $("#Popup").dxPopup({
  5. visible: false,
  6. width: '700px',
  7. height: '100px', // cyim 2017.05.30 : 테스트 결과 Devextreme 버그임. px 로 지정하면 초기 출력시 정확하게 가운데에 있지만, auto 설정시 화면아래에 위치하게 됨
  8. contentTemplate: "content",
  9. showTitle: true,
  10. title: "설정",
  11. dragEnabled: true,
  12. closeOnOutsideClick: false,
  13. shadingColor: 'rgba(0,0,0,0.0)',
  14. shownAction: handlePopupShown,
  15. animation: window.utils.popup.createAnimation()
  16. });
  17. $("#Button_PredictionConfig").dxButton({
  18. text: "설정",
  19. onClick: function () {
  20. // 팝업 출력
  21. $("#Popup").dxPopup('instance').option('visible', true);
  22. }
  23. });
  24. // 팝업 생성되면서 실행
  25. function handlePopupShown() {
  26. var BemsEnergyDailyRegression = BemsWebApplication.db.createDataSource('BemsEnergyDailyRegression');
  27. BemsEnergyDailyRegression.filter([
  28. ['SiteId', '=', BWA.UserInfo.SiteId()],
  29. ]);
  30. BemsEnergyDailyRegression.load().done(function (result) {
  31. var EnableRegression = false;
  32. _.each(result, function (x) {
  33. EnableRegression = x.IsRegression()
  34. });
  35. $("#Switch_Regression").dxSwitch({
  36. value: EnableRegression
  37. });
  38. $("#Button_Save").dxButton({
  39. text: "저장",
  40. onClick: function () {
  41. var EnableRegression = $("#Switch_Regression").dxSwitch('instance').option('value');
  42. BWA.db.BemsEnergyDailyRegression.update({
  43. SiteId: BWA.UserInfo.SiteId()
  44. }, {
  45. IsRegression: EnableRegression
  46. }).done(function () {
  47. utils.toast.show('저장에 성공하였습니다.');
  48. }).fail(function () {
  49. utils.toast.show('저장에 실패하였습니다.', 'error');
  50. });
  51. }
  52. });
  53. });
  54. }
  55. var DataArrayInfoForGrid = new Array();
  56. var DataArrayInfo = new Array();
  57. var BemsEnergyDailyRegression = BemsWebApplication.db.createDataSource('BemsEnergyDailyRegression');
  58. BemsEnergyDailyRegression.filter([
  59. ['SiteId', '=', BWA.UserInfo.SiteId()],
  60. ]);
  61. BemsEnergyDailyRegression.load().done(function (result) {
  62. _.each(result, function (x) {
  63. DataArrayInfoForGrid.push({
  64. Type: '주중',
  65. Electricity: x.Weekday_Power_Temp(),
  66. Gas: x.Weekday_Gas_Temp(),
  67. Water: x.Weekday_Water_Temp()
  68. });
  69. DataArrayInfoForGrid.push({
  70. Type: '휴일',
  71. Electricity: x.Holiday_Power_Temp(),
  72. Gas: x.Holiday_Gas_Temp(),
  73. Water: x.Holiday_Water_Temp()
  74. });
  75. });
  76. $("#Grid_RegressionInfo").dxDataGrid({
  77. dataSource: DataArrayInfoForGrid,
  78. rowAlternationEnabled: true,
  79. columns: [
  80. { dataField: 'Type', caption: '주중/주말', width: '10%', alignment: 'center' },
  81. { dataField: 'Electricity', caption: '전기', width: '30%', alignment: 'center' },
  82. { dataField: 'Gas', caption: '가스', width: '30%', alignment: 'center' },
  83. { dataField: 'Water', caption: '수도', width: '30%', alignment: 'center' }
  84. ],
  85. paging: {
  86. enabled: true,
  87. pageIndex: 0,
  88. pageSize: 20,
  89. }
  90. });
  91. });
  92. $("#NumberBox_TodayMeanT").dxNumberBox({
  93. value: null
  94. });
  95. $("#NumberBox_TodayHDD").dxNumberBox({
  96. value: null
  97. });
  98. $("#NumberBox_TodayCDD").dxNumberBox({
  99. value: null
  100. });
  101. $("#NumberBox_TomorrowMeanT").dxNumberBox({
  102. value: null
  103. });
  104. $("#NumberBox_TomorrowHDD").dxNumberBox({
  105. value: null
  106. });
  107. $("#NumberBox_TomorrowCDD").dxNumberBox({
  108. value: null
  109. });
  110. $("#NumberBox_TodayPowerPrediction").dxNumberBox({
  111. value: null
  112. });
  113. $("#NumberBox_TodayGasPrediction").dxNumberBox({
  114. value: null
  115. });
  116. $("#NumberBox_TodayWaterPrediction").dxNumberBox({
  117. value: null
  118. });
  119. $("#NumberBox_TomorrowPowerPrediction").dxNumberBox({
  120. value: null
  121. });
  122. $("#NumberBox_TomorrowGasPrediction").dxNumberBox({
  123. value: null
  124. });
  125. $("#NumberBox_TomorrowWaterPrediction").dxNumberBox({
  126. value: null
  127. });
  128. // 오늘
  129. var date = new Date();
  130. var dd = date.getDate();
  131. var mm = date.getMonth() + 1; //January is 0!
  132. var yyyy = date.getFullYear();
  133. var today = new Date(yyyy + '-' + mm + '-' + dd + ' 00:00:00');
  134. // 내일
  135. date.setDate(date.getDate() + 1);
  136. var temp_dd = date.getDate();
  137. var temp_mm = date.getMonth() + 1; //January is 0!
  138. var temp_yyyy = date.getFullYear();
  139. var tomorrow = new Date(temp_yyyy + '-' + temp_mm + '-' + temp_dd + ' 00:00:00');
  140. $("#TodayMeanT").html(dd + "일 평균 온도");
  141. $("#TodayHDD").html(dd + "일 HDD");
  142. $("#TodayCDD").html(dd + "일 CDD");
  143. $("#TodayPowerPrediction").html(dd + "일 전력 사용량 예측(KWh)");
  144. $("#TodayGasPrediction").html(dd + "일 가스 사용량 예측(m3)");
  145. $("#TodayWaterPrediction").html(dd + "일 수도 사용량 예측(m3)");
  146. $("#TomorrowMeanT").html(temp_dd + "일 평균 온도");
  147. $("#TomorrowHDD").html(temp_dd + "일 HDD");
  148. $("#TomorrowCDD").html(temp_dd + "일 CDD");
  149. $("#TomorrowPowerPrediction").html(temp_dd + "일 전력 사용량 예측(KWh)");
  150. $("#TomorrowGasPrediction").html(temp_dd + "일 가스 사용량 예측(m3)");
  151. $("#TomorrowWaterPrediction").html(temp_dd + "일 수도 사용량 예측(m3)");
  152. var toe_power = '';
  153. var toe_gas = '';
  154. var BemsFactorToe = BemsWebApplication.db.createDataSource('BemsFactorToe');
  155. BemsFactorToe.load().done(function (result) {
  156. // toe 정보
  157. var num = 1;
  158. _.each(result, function (x) {
  159. if (num == 1) toe_power = x.TotalFactor();
  160. if (num == 2) toe_gas = x.TotalFactor();
  161. num++;
  162. });
  163. var BemsEnergyDaily = BemsWebApplication.db.createDataSource('BemsEnergyDaily');
  164. BemsEnergyDaily.filter([
  165. ['SiteId', '=', BWA.UserInfo.SiteId()],
  166. ['BuildingId', '=', 1],
  167. ['ServiceTypeId', '=', 1],
  168. ['FuelTypeId', '=', 1],
  169. ['CreatedDate', '=', today]
  170. ]);
  171. BemsEnergyDaily.load().done(function (result) {
  172. _.each(result, function (x) {
  173. $("#NumberBox_TodayMeanT").dxNumberBox({ value: x.MeanT() });
  174. $("#NumberBox_TodayHDD").dxNumberBox({ value: x.HDD() });
  175. $("#NumberBox_TodayCDD").dxNumberBox({ value: x.CDD() });
  176. $("#NumberBox_TodayPowerPrediction").dxNumberBox({ value: parseFloat(x.Prediction_Regression()).toFixed(2) });
  177. });
  178. });
  179. // 가스
  180. BemsEnergyDaily.filter([
  181. ['SiteId', '=', BWA.UserInfo.SiteId()],
  182. ['BuildingId', '=', 1],
  183. ['ServiceTypeId', '=', 1],
  184. ['FuelTypeId', '=', 2], // 가스
  185. ['CreatedDate', '=', today]
  186. ]);
  187. BemsEnergyDaily.load().done(function (result) {
  188. _.each(result, function (x) {
  189. // 가스는 환산해서 보여준다
  190. var gas_m3 = x.Prediction_Regression() * toe_power / toe_gas;
  191. $("#NumberBox_TodayGasPrediction").dxNumberBox({ value: gas_m3.toFixed(2) });
  192. });
  193. });
  194. // 수도
  195. BemsEnergyDaily.filter([
  196. ['SiteId', '=', BWA.UserInfo.SiteId()],
  197. ['BuildingId', '=', 1],
  198. ['ServiceTypeId', '=', 1],
  199. ['FuelTypeId', '=', 3], // 수도
  200. ['CreatedDate', '=', today]
  201. ]);
  202. BemsEnergyDaily.load().done(function (result) {
  203. _.each(result, function (x) {
  204. $("#NumberBox_TodayWaterPrediction").dxNumberBox({ value: parseFloat(x.Prediction_Regression()).toFixed(2) });
  205. });
  206. });
  207. BemsEnergyDaily.filter([
  208. ['SiteId', '=', BWA.UserInfo.SiteId()],
  209. ['BuildingId', '=', 1],
  210. ['ServiceTypeId', '=', 1],
  211. ['FuelTypeId', '=', 1],
  212. ['CreatedDate', '=', tomorrow]
  213. ]);
  214. BemsEnergyDaily.load().done(function (result) {
  215. _.each(result, function (x) {
  216. $("#NumberBox_TomorrowMeanT").dxNumberBox({ value: x.MeanT() });
  217. $("#NumberBox_TomorrowHDD").dxNumberBox({ value: x.HDD() });
  218. $("#NumberBox_TomorrowCDD").dxNumberBox({ value: x.CDD() });
  219. $("#NumberBox_TomorrowPowerPrediction").dxNumberBox({ value: parseFloat(x.Prediction_Regression()).toFixed(2) });
  220. });
  221. });
  222. // 가스
  223. BemsEnergyDaily.filter([
  224. ['SiteId', '=', BWA.UserInfo.SiteId()],
  225. ['BuildingId', '=', 1],
  226. ['ServiceTypeId', '=', 1],
  227. ['FuelTypeId', '=', 2], // 가스
  228. ['CreatedDate', '=', tomorrow]
  229. ]);
  230. BemsEnergyDaily.load().done(function (result) {
  231. _.each(result, function (x) {
  232. // 가스는 환산해서 보여준다
  233. var gas_m3 = x.Prediction_Regression() * toe_power / toe_gas;
  234. $("#NumberBox_TomorrowGasPrediction").dxNumberBox({ value: gas_m3.toFixed(2) });
  235. });
  236. });
  237. // 수도
  238. BemsEnergyDaily.filter([
  239. ['SiteId', '=', BWA.UserInfo.SiteId()],
  240. ['BuildingId', '=', 1],
  241. ['ServiceTypeId', '=', 1],
  242. ['FuelTypeId', '=', 3], // 수도
  243. ['CreatedDate', '=', tomorrow]
  244. ]);
  245. BemsEnergyDaily.load().done(function (result) {
  246. _.each(result, function (x) {
  247. $("#NumberBox_TomorrowWaterPrediction").dxNumberBox({ value: parseFloat(x.Prediction_Regression()).toFixed(2) });
  248. });
  249. });
  250. });
  251. $SideMenu.showSideMenuIfWill(params.view);
  252. }
  253. }
  254. };