4e746f504cc7d44203a3e856b7ef56e3dce7395a.svn-base 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. BemsWebApplication.ViewOperatingExpensesByFacility = function (params, viewInfo) {
  2. var endpointSelector = "";
  3. if (BemsWebApplication.config.mode == "production") {
  4. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
  5. } else {
  6. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
  7. }
  8. var time_data = [
  9. { time: 0 }, { time: 1 }, { time: 2 }, { time: 3 }, { time: 4 }, { time: 5 }, { time: 6 }, { time: 7 }, { time: 8 }, { time: 9 },
  10. { time: 10 }, { time: 11 }, { time: 12 }, { time: 13 }, { time: 14 }, { time: 15 }, { time: 16 }, { time: 17 }, { time: 18 }, { time: 19 },
  11. { time: 20 }, { time: 21 }, { time: 22 }, { time: 23 }
  12. ];
  13. var PowerMeta = [];
  14. var GasMeta = [];
  15. var facility_type_data = [
  16. {
  17. id: 999,
  18. text: ""
  19. },
  20. {
  21. id: 999,
  22. text: ""
  23. }
  24. ];
  25. var facility_id_data = [{
  26. FacilityTypeId: 999,
  27. FacilityCode: 999,
  28. Name: ""
  29. }];
  30. var mode_data = [
  31. {
  32. id: 1,
  33. text: "병렬운전"
  34. },
  35. {
  36. id: 2,
  37. text: "냉단운전"
  38. },
  39. {
  40. id: 3,
  41. text: "제빙운전"
  42. }
  43. ];
  44. var TodayAdd = new Date();
  45. TodayAdd.setDate(TodayAdd.getDate() + 1);
  46. var MainPowerConsumption = 0, MainGasConsumption = 0, MainGasHeatQuantity = 0, MainPowerPriceTypeId = 99, MainGasPriceTypeId = 99, starthour = 99, endhour = 99;
  47. var MainFacilityType = 0, MainFacilityCode = 0, MainMode = 0, MainStartTime = 0, MainEndTime = 0;
  48. var REFRIGERATOR = 2, BOILER = 8;
  49. function initfacilityid() {
  50. facility_id_data = [{
  51. FacilityTypeId: 999,
  52. FacilityCode: 999,
  53. Name: ""
  54. }];
  55. }
  56. function getFacilityTypeId() {
  57. var dataSource1 = new DevExpress.data.DataSource({
  58. store: {
  59. type: "odata",
  60. url: endpointSelector + "/BemsFacilityType",
  61. },
  62. requireTotalCount: true,
  63. pageSize: 100
  64. });
  65. dataSource1.filter([
  66. ["FacilityTypeId", "=", REFRIGERATOR],
  67. "or",
  68. ["FacilityTypeId", "=", BOILER]
  69. ]);
  70. dataSource1.sort({ getter: "FacilityTypeId", asc: true });
  71. dataSource1.load()
  72. .done(function (result1) {
  73. if (result1.length != 0) {
  74. for (var i = 0; i < result1.length; i++) {
  75. facility_type_data[i].id = result1[i].FacilityTypeId;
  76. facility_type_data[i].text = result1[i].Name;
  77. }
  78. }
  79. else {
  80. utils.toast.show('[BemsFacilityType] 데이터가 없습니다.');
  81. }
  82. })
  83. .fail(function (error) {
  84. utils.toast.show(error);
  85. });
  86. }
  87. function handleViewShowing() {
  88. getFacilityTypeId();
  89. }
  90. function facilityidSourceAdd(cnt) { // 설비 개수만큼 추가
  91. for (var i = 0; i < cnt ; i++) {
  92. facility_id_data.push({
  93. FacilityTypeId: 999,
  94. FacilityCode: 999,
  95. Name: ""
  96. });
  97. }
  98. }
  99. function GetGridData() {
  100. var gridData = new Array();
  101. var tempMainStartTime = MainStartTime;
  102. var tempMainEndTime = MainEndTime;
  103. var DateTime;
  104. if (tempMainStartTime.getDate() == MainEndTime.getDate()) //같은 날짜
  105. {
  106. var TotalPowerPrice = 0, TotalGasPrice = 0;
  107. for (var i = tempMainStartTime.getHours() ; i <= MainEndTime.getHours() ; i++) {
  108. DateTime = new Date(tempMainStartTime.getFullYear(), tempMainStartTime.getMonth(), tempMainStartTime.getDate(), i, 0, 0);
  109. if (MainFacilityType == REFRIGERATOR) {
  110. var tempMonth = DateTime.getMonth();
  111. var tempHour = DateTime.getHours();
  112. var tempPowerBasic = PowerMeta[tempMonth][tempHour];
  113. var setData = {
  114. "DateTime": DateTime,
  115. "PowerBasic": tempPowerBasic,
  116. "PowerPrice": tempPowerBasic * MainPowerConsumption,
  117. "GasBasic": '-',
  118. "GasPrice": '-',
  119. "TotalPrice": Math.round(tempPowerBasic * MainPowerConsumption)
  120. };
  121. TotalPowerPrice += Math.round(setData.PowerPrice);
  122. }
  123. else {
  124. var tempMonth = DateTime.getMonth();
  125. var tempHour = DateTime.getHours();
  126. var tempPowerBasic = PowerMeta[tempMonth][tempHour];
  127. var tempGasBasic = GasMeta[tempMonth][0];
  128. var setData = {
  129. "DateTime": DateTime,
  130. "PowerBasic": tempPowerBasic,
  131. "PowerPrice": tempPowerBasic * MainPowerConsumption,
  132. "GasBasic": tempGasBasic,
  133. "GasPrice": tempGasBasic * MainGasConsumption * MainGasHeatQuantity,
  134. "TotalPrice": Math.round(tempPowerBasic * MainPowerConsumption) + Math.round(tempGasBasic * MainGasConsumption * MainGasHeatQuantity)
  135. };
  136. TotalPowerPrice += Math.round(setData.PowerPrice);
  137. TotalGasPrice += Math.round(setData.GasPrice);
  138. }
  139. gridData.push(setData);
  140. }
  141. }
  142. else { //다른날짜
  143. var TotalPowerPrice = 0, TotalGasPrice = 0;
  144. for (var i = tempMainStartTime.getHours() ; i < 24; i++) {
  145. DateTime = new Date(tempMainStartTime.getFullYear(), tempMainStartTime.getMonth(), tempMainStartTime.getDate(), i, 0, 0);
  146. if (MainFacilityType == REFRIGERATOR) {
  147. var tempMonth = DateTime.getMonth();
  148. var tempHour = DateTime.getHours();
  149. var tempPowerBasic = PowerMeta[tempMonth][tempHour];
  150. var setData = {
  151. "DateTime": DateTime,
  152. "PowerBasic": tempPowerBasic,
  153. "PowerPrice": tempPowerBasic * MainPowerConsumption,
  154. "GasBasic": '-',
  155. "GasPrice": '-',
  156. "TotalPrice": Math.round(tempPowerBasic * MainPowerConsumption)
  157. };
  158. TotalPowerPrice += Math.round(setData.PowerPrice);
  159. }
  160. else {
  161. var tempMonth = DateTime.getMonth();
  162. var tempHour = DateTime.getHours();
  163. var tempPowerBasic = PowerMeta[tempMonth][tempHour];
  164. var tempGasBasic = GasMeta[tempMonth][0];
  165. var setData = {
  166. "DateTime": DateTime,
  167. "PowerBasic": tempPowerBasic,
  168. "PowerPrice": tempPowerBasic * MainPowerConsumption,
  169. "GasBasic": tempGasBasic,
  170. "GasPrice": tempGasBasic * MainGasConsumption * MainGasHeatQuantity,
  171. "TotalPrice": Math.round(tempPowerBasic * MainPowerConsumption) + Math.round(tempGasBasic * MainGasConsumption * MainGasHeatQuantity)
  172. };
  173. TotalPowerPrice += Math.round(setData.PowerPrice);
  174. TotalGasPrice += Math.round(setData.GasPrice);
  175. }
  176. gridData.push(setData);
  177. }
  178. for (var i = 1; i <= 7; i++) //일주일치만 검색가능하니깐
  179. {
  180. tempMainStartTime = new Date(tempMainStartTime.getFullYear(), tempMainStartTime.getMonth(), tempMainStartTime.getDate() + 1, tempMainStartTime.getHours(), tempMainStartTime.getMinutes());
  181. if (tempMainStartTime.getDate() < tempMainEndTime.getDate()) {
  182. for (var j = 0; j < 24; j++) {
  183. DateTime = new Date(tempMainStartTime.getFullYear(), tempMainStartTime.getMonth(), tempMainStartTime.getDate(), j, 0, 0);
  184. if (MainFacilityType == REFRIGERATOR) {
  185. var tempMonth = DateTime.getMonth();
  186. var tempHour = DateTime.getHours();
  187. var tempPowerBasic = PowerMeta[tempMonth][tempHour];
  188. var setData = {
  189. "DateTime": DateTime,
  190. "PowerBasic": tempPowerBasic,
  191. "PowerPrice": tempPowerBasic * MainPowerConsumption,
  192. "GasBasic": '-',
  193. "GasPrice": '-',
  194. "TotalPrice": Math.round(tempPowerBasic * MainPowerConsumption)
  195. };
  196. TotalPowerPrice += Math.round(setData.PowerPrice);
  197. }
  198. else {
  199. var tempMonth = DateTime.getMonth();
  200. var tempHour = DateTime.getHours();
  201. var tempPowerBasic = PowerMeta[tempMonth][tempHour];
  202. var tempGasBasic = GasMeta[tempMonth][0];
  203. var setData = {
  204. "DateTime": DateTime,
  205. "PowerBasic": tempPowerBasic,
  206. "PowerPrice": tempPowerBasic * MainPowerConsumption,
  207. "GasBasic": tempGasBasic,
  208. "GasPrice": tempGasBasic * MainGasConsumption * MainGasHeatQuantity,
  209. "TotalPrice": Math.round(tempPowerBasic * MainPowerConsumption) + Math.round(tempGasBasic * MainGasConsumption * MainGasHeatQuantity)
  210. };
  211. TotalPowerPrice += Math.round(setData.PowerPrice);
  212. TotalGasPrice += Math.round(setData.GasPrice);
  213. }
  214. gridData.push(setData);
  215. }
  216. }
  217. else {
  218. for (var k = 0; k <= tempMainEndTime.getHours() ; k++) {
  219. DateTime = new Date(tempMainStartTime.getFullYear(), tempMainStartTime.getMonth(), tempMainStartTime.getDate(), k, 0, 0);
  220. if (MainFacilityType == REFRIGERATOR) {
  221. var tempMonth = DateTime.getMonth();
  222. var tempHour = DateTime.getHours();
  223. var tempPowerBasic = PowerMeta[tempMonth][tempHour];
  224. var setData = {
  225. "DateTime": DateTime,
  226. "PowerBasic": tempPowerBasic,
  227. "PowerPrice": tempPowerBasic * MainPowerConsumption,
  228. "GasBasic": '-',
  229. "GasPrice": '-',
  230. "TotalPrice": Math.round(tempPowerBasic * MainPowerConsumption)
  231. };
  232. TotalPowerPrice += Math.round(setData.PowerPrice);
  233. }
  234. else {
  235. var tempMonth = DateTime.getMonth();
  236. var tempHour = DateTime.getHours();
  237. var tempPowerBasic = PowerMeta[tempMonth][tempHour];
  238. var tempGasBasic = GasMeta[tempMonth][0];
  239. var setData = {
  240. "DateTime": DateTime,
  241. "PowerBasic": tempPowerBasic,
  242. "PowerPrice": tempPowerBasic * MainPowerConsumption,
  243. "GasBasic": tempGasBasic,
  244. "GasPrice": tempGasBasic * MainGasConsumption * MainGasHeatQuantity,
  245. "TotalPrice": Math.round(tempPowerBasic * MainPowerConsumption) + Math.round(tempGasBasic * MainGasConsumption * MainGasHeatQuantity)
  246. };
  247. TotalPowerPrice += Math.round(setData.PowerPrice);
  248. TotalGasPrice += Math.round(setData.GasPrice);
  249. }
  250. gridData.push(setData);
  251. }
  252. break;
  253. }
  254. }
  255. }
  256. $("#dataGrid").dxDataGrid("instance").option('dataSource', gridData);
  257. $("#Gas").dxTextBox('instance').option('value', numberWithCommas(TotalGasPrice) + '원');
  258. $("#Power").dxTextBox('instance').option('value', numberWithCommas(TotalPowerPrice) + '원');
  259. $("#Total").dxTextBox('instance').option('value', numberWithCommas(TotalGasPrice + TotalPowerPrice) + '원');
  260. var dg = $("#dataGrid").dxDataGrid("instance");
  261. dg.refresh();
  262. }
  263. function numberWithCommas(x) {
  264. return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  265. }
  266. function getPowerPriceMeta(PowerPriceTypeId) {
  267. PowerMeta = new Array(13);
  268. for (var i = 1; i < 13; i++) {
  269. PowerMeta[i] = new Array(24);
  270. }
  271. var dataSource = new DevExpress.data.DataSource({
  272. store: new DevExpress.data.ODataStore({
  273. url: endpointSelector + "/BemsPriceMeta"
  274. }),
  275. requireTotalCount: true,
  276. pageSize: 1
  277. });
  278. dataSource.filter([
  279. ["PriceTypeId", "=", PowerPriceTypeId]
  280. ]);
  281. dataSource.sort({ getter: "PublishDate", desc: true });
  282. dataSource.load()
  283. .done(function (result) {
  284. if (result.length != 0) {
  285. PriceMeta = result[0];
  286. PowerMeta[1][0] = PriceMeta.C01_00; PowerMeta[1][1] = PriceMeta.C01_01; PowerMeta[1][2] = PriceMeta.C01_02; PowerMeta[1][3] = PriceMeta.C01_03; PowerMeta[1][4] = PriceMeta.C01_04; PowerMeta[1][5] = PriceMeta.C01_05; PowerMeta[1][6] = PriceMeta.C01_06; PowerMeta[1][7] = PriceMeta.C01_07; PowerMeta[1][8] = PriceMeta.C01_08; PowerMeta[1][9] = PriceMeta.C01_09; PowerMeta[1][10] = PriceMeta.C01_10; PowerMeta[1][11] = PriceMeta.C01_11; PowerMeta[1][12] = PriceMeta.C01_12; PowerMeta[1][13] = PriceMeta.C01_13; PowerMeta[1][14] = PriceMeta.C01_14; PowerMeta[1][15] = PriceMeta.C01_15; PowerMeta[1][16] = PriceMeta.C01_16; PowerMeta[1][17] = PriceMeta.C01_17; PowerMeta[1][18] = PriceMeta.C01_18; PowerMeta[1][19] = PriceMeta.C01_19; PowerMeta[1][20] = PriceMeta.C01_20; PowerMeta[1][21] = PriceMeta.C01_21; PowerMeta[1][22] = PriceMeta.C01_22; PowerMeta[1][23] = PriceMeta.C01_23;
  287. PowerMeta[2][0] = PriceMeta.C02_00; PowerMeta[2][1] = PriceMeta.C02_01; PowerMeta[2][2] = PriceMeta.C02_02; PowerMeta[2][3] = PriceMeta.C02_03; PowerMeta[2][4] = PriceMeta.C02_04; PowerMeta[2][5] = PriceMeta.C02_05; PowerMeta[2][6] = PriceMeta.C02_06; PowerMeta[2][7] = PriceMeta.C02_07; PowerMeta[2][8] = PriceMeta.C02_08; PowerMeta[2][9] = PriceMeta.C02_09; PowerMeta[2][10] = PriceMeta.C02_10; PowerMeta[2][11] = PriceMeta.C02_11; PowerMeta[2][12] = PriceMeta.C02_12; PowerMeta[2][13] = PriceMeta.C02_13; PowerMeta[2][14] = PriceMeta.C02_14; PowerMeta[2][15] = PriceMeta.C02_15; PowerMeta[2][16] = PriceMeta.C02_16; PowerMeta[2][17] = PriceMeta.C02_17; PowerMeta[2][18] = PriceMeta.C02_18; PowerMeta[2][19] = PriceMeta.C02_19; PowerMeta[2][20] = PriceMeta.C02_20; PowerMeta[2][21] = PriceMeta.C02_21; PowerMeta[2][22] = PriceMeta.C02_22; PowerMeta[2][23] = PriceMeta.C02_23;
  288. PowerMeta[3][0] = PriceMeta.C03_00; PowerMeta[3][1] = PriceMeta.C03_01; PowerMeta[3][2] = PriceMeta.C03_02; PowerMeta[3][3] = PriceMeta.C03_03; PowerMeta[3][4] = PriceMeta.C03_04; PowerMeta[3][5] = PriceMeta.C03_05; PowerMeta[3][6] = PriceMeta.C03_06; PowerMeta[3][7] = PriceMeta.C03_07; PowerMeta[3][8] = PriceMeta.C03_08; PowerMeta[3][9] = PriceMeta.C03_09; PowerMeta[3][10] = PriceMeta.C03_10; PowerMeta[3][11] = PriceMeta.C03_11; PowerMeta[3][12] = PriceMeta.C03_12; PowerMeta[3][13] = PriceMeta.C03_13; PowerMeta[3][14] = PriceMeta.C03_14; PowerMeta[3][15] = PriceMeta.C03_15; PowerMeta[3][16] = PriceMeta.C03_16; PowerMeta[3][17] = PriceMeta.C03_17; PowerMeta[3][18] = PriceMeta.C03_18; PowerMeta[3][19] = PriceMeta.C03_19; PowerMeta[3][20] = PriceMeta.C03_20; PowerMeta[3][21] = PriceMeta.C03_21; PowerMeta[3][22] = PriceMeta.C03_22; PowerMeta[3][23] = PriceMeta.C03_23;
  289. PowerMeta[4][0] = PriceMeta.C04_00; PowerMeta[4][1] = PriceMeta.C04_01; PowerMeta[4][2] = PriceMeta.C04_02; PowerMeta[4][3] = PriceMeta.C04_03; PowerMeta[4][4] = PriceMeta.C04_04; PowerMeta[4][5] = PriceMeta.C04_05; PowerMeta[4][6] = PriceMeta.C04_06; PowerMeta[4][7] = PriceMeta.C04_07; PowerMeta[4][8] = PriceMeta.C04_08; PowerMeta[4][9] = PriceMeta.C04_09; PowerMeta[4][10] = PriceMeta.C04_10; PowerMeta[4][11] = PriceMeta.C04_11; PowerMeta[4][12] = PriceMeta.C04_12; PowerMeta[4][13] = PriceMeta.C04_13; PowerMeta[4][14] = PriceMeta.C04_14; PowerMeta[4][15] = PriceMeta.C04_15; PowerMeta[4][16] = PriceMeta.C04_16; PowerMeta[4][17] = PriceMeta.C04_17; PowerMeta[4][18] = PriceMeta.C04_18; PowerMeta[4][19] = PriceMeta.C04_19; PowerMeta[4][20] = PriceMeta.C04_20; PowerMeta[4][21] = PriceMeta.C04_21; PowerMeta[4][22] = PriceMeta.C04_22; PowerMeta[4][23] = PriceMeta.C04_23;
  290. PowerMeta[5][0] = PriceMeta.C05_00; PowerMeta[5][1] = PriceMeta.C05_01; PowerMeta[5][2] = PriceMeta.C05_02; PowerMeta[5][3] = PriceMeta.C05_03; PowerMeta[5][4] = PriceMeta.C05_04; PowerMeta[5][5] = PriceMeta.C05_05; PowerMeta[5][6] = PriceMeta.C05_06; PowerMeta[5][7] = PriceMeta.C05_07; PowerMeta[5][8] = PriceMeta.C05_08; PowerMeta[5][9] = PriceMeta.C05_09; PowerMeta[5][10] = PriceMeta.C05_10; PowerMeta[5][11] = PriceMeta.C05_11; PowerMeta[5][12] = PriceMeta.C05_12; PowerMeta[5][13] = PriceMeta.C05_13; PowerMeta[5][14] = PriceMeta.C05_14; PowerMeta[5][15] = PriceMeta.C05_15; PowerMeta[5][16] = PriceMeta.C05_16; PowerMeta[5][17] = PriceMeta.C05_17; PowerMeta[5][18] = PriceMeta.C05_18; PowerMeta[5][19] = PriceMeta.C05_19; PowerMeta[5][20] = PriceMeta.C05_20; PowerMeta[5][21] = PriceMeta.C05_21; PowerMeta[5][22] = PriceMeta.C05_22; PowerMeta[5][23] = PriceMeta.C05_23;
  291. PowerMeta[6][0] = PriceMeta.C06_00; PowerMeta[6][1] = PriceMeta.C06_01; PowerMeta[6][2] = PriceMeta.C06_02; PowerMeta[6][3] = PriceMeta.C06_03; PowerMeta[6][4] = PriceMeta.C06_04; PowerMeta[6][5] = PriceMeta.C06_05; PowerMeta[6][6] = PriceMeta.C06_06; PowerMeta[6][7] = PriceMeta.C06_07; PowerMeta[6][8] = PriceMeta.C06_08; PowerMeta[6][9] = PriceMeta.C06_09; PowerMeta[6][10] = PriceMeta.C06_10; PowerMeta[6][11] = PriceMeta.C06_11; PowerMeta[6][12] = PriceMeta.C06_12; PowerMeta[6][13] = PriceMeta.C06_13; PowerMeta[6][14] = PriceMeta.C06_14; PowerMeta[6][15] = PriceMeta.C06_15; PowerMeta[6][16] = PriceMeta.C06_16; PowerMeta[6][17] = PriceMeta.C06_17; PowerMeta[6][18] = PriceMeta.C06_18; PowerMeta[6][19] = PriceMeta.C06_19; PowerMeta[6][20] = PriceMeta.C06_20; PowerMeta[6][21] = PriceMeta.C06_21; PowerMeta[6][22] = PriceMeta.C06_22; PowerMeta[6][23] = PriceMeta.C06_23;
  292. PowerMeta[7][0] = PriceMeta.C07_00; PowerMeta[7][1] = PriceMeta.C07_01; PowerMeta[7][2] = PriceMeta.C07_02; PowerMeta[7][3] = PriceMeta.C07_03; PowerMeta[7][4] = PriceMeta.C07_04; PowerMeta[7][5] = PriceMeta.C07_05; PowerMeta[7][6] = PriceMeta.C07_06; PowerMeta[7][7] = PriceMeta.C07_07; PowerMeta[7][8] = PriceMeta.C07_08; PowerMeta[7][9] = PriceMeta.C07_09; PowerMeta[7][10] = PriceMeta.C07_10; PowerMeta[7][11] = PriceMeta.C07_11; PowerMeta[7][12] = PriceMeta.C07_12; PowerMeta[7][13] = PriceMeta.C07_13; PowerMeta[7][14] = PriceMeta.C07_14; PowerMeta[7][15] = PriceMeta.C07_15; PowerMeta[7][16] = PriceMeta.C07_16; PowerMeta[7][17] = PriceMeta.C07_17; PowerMeta[7][18] = PriceMeta.C07_18; PowerMeta[7][19] = PriceMeta.C07_19; PowerMeta[7][20] = PriceMeta.C07_20; PowerMeta[7][21] = PriceMeta.C07_21; PowerMeta[7][22] = PriceMeta.C07_22; PowerMeta[7][23] = PriceMeta.C07_23;
  293. PowerMeta[8][0] = PriceMeta.C08_00; PowerMeta[8][1] = PriceMeta.C08_01; PowerMeta[8][2] = PriceMeta.C08_02; PowerMeta[8][3] = PriceMeta.C08_03; PowerMeta[8][4] = PriceMeta.C08_04; PowerMeta[8][5] = PriceMeta.C08_05; PowerMeta[8][6] = PriceMeta.C08_06; PowerMeta[8][7] = PriceMeta.C08_07; PowerMeta[8][8] = PriceMeta.C08_08; PowerMeta[8][9] = PriceMeta.C08_09; PowerMeta[8][10] = PriceMeta.C08_10; PowerMeta[8][11] = PriceMeta.C08_11; PowerMeta[8][12] = PriceMeta.C08_12; PowerMeta[8][13] = PriceMeta.C08_13; PowerMeta[8][14] = PriceMeta.C08_14; PowerMeta[8][15] = PriceMeta.C08_15; PowerMeta[8][16] = PriceMeta.C08_16; PowerMeta[8][17] = PriceMeta.C08_17; PowerMeta[8][18] = PriceMeta.C08_18; PowerMeta[8][19] = PriceMeta.C08_19; PowerMeta[8][20] = PriceMeta.C08_20; PowerMeta[8][21] = PriceMeta.C08_21; PowerMeta[8][22] = PriceMeta.C08_22; PowerMeta[8][23] = PriceMeta.C08_23;
  294. PowerMeta[9][0] = PriceMeta.C09_00; PowerMeta[9][1] = PriceMeta.C09_01; PowerMeta[9][2] = PriceMeta.C09_02; PowerMeta[9][3] = PriceMeta.C09_03; PowerMeta[9][4] = PriceMeta.C09_04; PowerMeta[9][5] = PriceMeta.C09_05; PowerMeta[9][6] = PriceMeta.C09_06; PowerMeta[9][7] = PriceMeta.C09_07; PowerMeta[9][8] = PriceMeta.C09_08; PowerMeta[9][9] = PriceMeta.C09_09; PowerMeta[9][10] = PriceMeta.C09_10; PowerMeta[9][11] = PriceMeta.C09_11; PowerMeta[9][12] = PriceMeta.C09_12; PowerMeta[9][13] = PriceMeta.C09_13; PowerMeta[9][14] = PriceMeta.C09_14; PowerMeta[9][15] = PriceMeta.C09_15; PowerMeta[9][16] = PriceMeta.C09_16; PowerMeta[9][17] = PriceMeta.C09_17; PowerMeta[9][18] = PriceMeta.C09_18; PowerMeta[9][19] = PriceMeta.C09_19; PowerMeta[9][20] = PriceMeta.C09_20; PowerMeta[9][21] = PriceMeta.C09_21; PowerMeta[9][22] = PriceMeta.C09_22; PowerMeta[9][23] = PriceMeta.C09_23;
  295. PowerMeta[10][0] = PriceMeta.C10_00; PowerMeta[10][1] = PriceMeta.C10_01; PowerMeta[10][2] = PriceMeta.C10_02; PowerMeta[10][3] = PriceMeta.C10_03; PowerMeta[10][4] = PriceMeta.C10_04; PowerMeta[10][5] = PriceMeta.C10_05; PowerMeta[10][6] = PriceMeta.C10_06; PowerMeta[10][7] = PriceMeta.C10_07; PowerMeta[10][8] = PriceMeta.C10_08; PowerMeta[10][9] = PriceMeta.C10_09; PowerMeta[10][10] = PriceMeta.C10_10; PowerMeta[10][11] = PriceMeta.C10_11; PowerMeta[10][12] = PriceMeta.C10_12; PowerMeta[10][13] = PriceMeta.C10_13; PowerMeta[10][14] = PriceMeta.C10_14; PowerMeta[10][15] = PriceMeta.C10_15; PowerMeta[10][16] = PriceMeta.C10_16; PowerMeta[10][17] = PriceMeta.C10_17; PowerMeta[10][18] = PriceMeta.C10_18; PowerMeta[10][19] = PriceMeta.C10_19; PowerMeta[10][20] = PriceMeta.C10_20; PowerMeta[10][21] = PriceMeta.C10_21; PowerMeta[10][22] = PriceMeta.C10_22; PowerMeta[10][23] = PriceMeta.C10_23;
  296. PowerMeta[11][0] = PriceMeta.C11_00; PowerMeta[11][1] = PriceMeta.C11_01; PowerMeta[11][2] = PriceMeta.C11_02; PowerMeta[11][3] = PriceMeta.C11_03; PowerMeta[11][4] = PriceMeta.C11_04; PowerMeta[11][5] = PriceMeta.C11_05; PowerMeta[11][6] = PriceMeta.C11_06; PowerMeta[11][7] = PriceMeta.C11_07; PowerMeta[11][8] = PriceMeta.C11_08; PowerMeta[11][9] = PriceMeta.C11_09; PowerMeta[11][10] = PriceMeta.C11_10; PowerMeta[11][11] = PriceMeta.C11_11; PowerMeta[11][12] = PriceMeta.C11_12; PowerMeta[11][13] = PriceMeta.C11_13; PowerMeta[11][14] = PriceMeta.C11_14; PowerMeta[11][15] = PriceMeta.C11_15; PowerMeta[11][16] = PriceMeta.C11_16; PowerMeta[11][17] = PriceMeta.C11_17; PowerMeta[11][18] = PriceMeta.C11_18; PowerMeta[11][19] = PriceMeta.C11_19; PowerMeta[11][20] = PriceMeta.C11_20; PowerMeta[11][21] = PriceMeta.C11_21; PowerMeta[11][22] = PriceMeta.C11_22; PowerMeta[11][23] = PriceMeta.C11_23;
  297. PowerMeta[12][0] = PriceMeta.C12_00; PowerMeta[12][1] = PriceMeta.C12_01; PowerMeta[12][2] = PriceMeta.C12_02; PowerMeta[12][3] = PriceMeta.C12_03; PowerMeta[12][4] = PriceMeta.C12_04; PowerMeta[12][5] = PriceMeta.C12_05; PowerMeta[12][6] = PriceMeta.C12_06; PowerMeta[12][7] = PriceMeta.C12_07; PowerMeta[12][8] = PriceMeta.C12_08; PowerMeta[12][9] = PriceMeta.C12_09; PowerMeta[12][10] = PriceMeta.C12_10; PowerMeta[12][11] = PriceMeta.C12_11; PowerMeta[12][12] = PriceMeta.C12_12; PowerMeta[12][13] = PriceMeta.C12_13; PowerMeta[12][14] = PriceMeta.C12_14; PowerMeta[12][15] = PriceMeta.C12_15; PowerMeta[12][16] = PriceMeta.C12_16; PowerMeta[12][17] = PriceMeta.C12_17; PowerMeta[12][18] = PriceMeta.C12_18; PowerMeta[12][19] = PriceMeta.C12_19; PowerMeta[12][20] = PriceMeta.C12_20; PowerMeta[12][21] = PriceMeta.C12_21; PowerMeta[12][22] = PriceMeta.C12_22; PowerMeta[12][23] = PriceMeta.C12_23;
  298. GetGridData();
  299. }
  300. else {
  301. PowerMeta = 0;
  302. utils.toast.show('[BemsPriceMeta-Power] 해당하는 데이터가 없습니다.');
  303. return;
  304. }
  305. })
  306. .fail(function (error) {
  307. alert(error);
  308. });
  309. }
  310. function getGasPriceMeta(PowerPriceTypeId, GasPriceTypeId) {
  311. GasMeta = new Array(13);
  312. for (var i = 1; i < 13; i++) {
  313. GasMeta[i] = new Array(24);
  314. }
  315. var dataSource = new DevExpress.data.DataSource({
  316. store: new DevExpress.data.ODataStore({
  317. url: endpointSelector + "/BemsPriceMeta"
  318. }),
  319. requireTotalCount: true,
  320. pageSize: 1
  321. });
  322. dataSource.filter([
  323. ["PriceTypeId", "=", PowerPriceTypeId]
  324. ]);
  325. dataSource.sort({ getter: "PublishDate", desc: true });
  326. dataSource.load()
  327. .done(function (result) {
  328. if (result.length != 0) {
  329. PriceMeta = result[0];
  330. GasMeta[1][0] = PriceMeta.C01_00; GasMeta[2][0] = PriceMeta.C02_00; GasMeta[3][0] = PriceMeta.C03_00; GasMeta[4][0] = PriceMeta.C04_00;
  331. GasMeta[5][0] = PriceMeta.C05_00; GasMeta[6][0] = PriceMeta.C06_00; GasMeta[7][0] = PriceMeta.C07_00; GasMeta[8][0] = PriceMeta.C08_00;
  332. GasMeta[9][0] = PriceMeta.C09_00; GasMeta[10][0] = PriceMeta.C10_00; GasMeta[11][0] = PriceMeta.C11_00; GasMeta[12][0] = PriceMeta.C12_00;
  333. getPowerPriceMeta(GasPriceTypeId)
  334. }
  335. else {
  336. GasMeta = 0;
  337. utils.toast.show('[BemsPriceMeta-Gas] 해당하는 데이터가 없습니다.');
  338. return;
  339. }
  340. })
  341. .fail(function (error) {
  342. alert(error);
  343. });
  344. }
  345. function handleViewShown() {
  346. $("#Facility_Type_Id").dxSelectBox({
  347. placeholder: "설비 타입",
  348. dataSource: facility_type_data,
  349. displayExpr: "text",
  350. valueExpr: "id",
  351. onValueChanged: function () {
  352. initfacilityid();
  353. var FacilityTypeId = $("#Facility_Type_Id").dxSelectBox('instance').option('value');
  354. switch (FacilityTypeId) {
  355. case REFRIGERATOR:
  356. $("#Mode").dxSelectBox('instance').option('disabled', false);
  357. break;
  358. case BOILER:
  359. $("#Mode").dxSelectBox('instance').option('disabled', true);
  360. $("#Mode").dxSelectBox('instance').option('value', null);
  361. break;
  362. case KITCHEN:
  363. $("#Mode").dxSelectBox('instance').option('disabled', true);
  364. $("#Mode").dxSelectBox('instance').option('value', null);
  365. break;
  366. }
  367. var dataSource2 = new DevExpress.data.DataSource({
  368. store: {
  369. type: "odata",
  370. url: endpointSelector + "/CmFacility",
  371. },
  372. requireTotalCount: true,
  373. pageSize: 5000
  374. });
  375. dataSource2.filter([
  376. ["SiteId", "=", BWA.UserInfo.SiteId()],
  377. "and",
  378. ["FacilityTypeId", "=", FacilityTypeId],
  379. ]);
  380. dataSource2.sort({ getter: "Name", asc: true });
  381. dataSource2.load()
  382. .done(function (result2) {
  383. var cnt = result2.length;
  384. if (cnt != 0) {
  385. if (cnt > 1) {
  386. if (FacilityTypeId != 99) //주방은 1개만
  387. facilityidSourceAdd(cnt - 1);
  388. }
  389. for (var i = 0; i < result2.length; i++) {
  390. facility_id_data[i].FacilityTypeId = result2[i].FacilityTypeId;
  391. facility_id_data[i].FacilityCode = result2[i].FacilityCode
  392. facility_id_data[i].Name = result2[i].Name;
  393. }
  394. $("#Facility_Id").dxSelectBox({
  395. dataSource: facility_id_data,
  396. displayExpr: "Name",
  397. valueExpr: "FacilityCode"
  398. });
  399. }
  400. else {
  401. utils.toast.show('[CmFacility] 데이터가 없습니다.');
  402. }
  403. })
  404. .fail(function (error) {
  405. utils.toast.show(error);
  406. });
  407. }
  408. });
  409. $("#Facility_Id").dxSelectBox({
  410. placeholder: "설비명칭"
  411. });
  412. $("#Mode").dxSelectBox({
  413. placeholder: "운전모드",
  414. dataSource: mode_data,
  415. displayExpr: "text",
  416. valueExpr: "id",
  417. disabled: true
  418. });
  419. $("#Search_Btn").dxButton({
  420. text: "조회",
  421. onClick: function () {
  422. MainFacilityType = 0, MainFacilityCode = 0, MainMode = 0, MainStartTime = 0, MainEndTime = 0;
  423. MainFacilityType = $("#Facility_Type_Id").dxSelectBox('instance').option('value');
  424. MainFacilityCode = $("#Facility_Id").dxSelectBox('instance').option('value');
  425. if (MainFacilityCode == null) {
  426. utils.toast.show('설비 명칭을 선택해야합니다.');
  427. return;
  428. }
  429. MainMode = $("#Mode").dxSelectBox('instance').option('value');
  430. if (MainFacilityType == REFRIGERATOR) {
  431. if (MainMode == null) {
  432. utils.toast.show('운전 모드를 선택해야합니다.');
  433. return;
  434. }
  435. }
  436. var MainStartDay = $("#Start_Day").dxDateBox('instance').option('value');
  437. var MainStartHour = $("#Start_Hour").dxSelectBox('instance').option('value');
  438. if (MainStartHour == null) {
  439. utils.toast.show('시작 시간을 선택해야합니다.');
  440. return;
  441. }
  442. var MainEndDay = $("#End_Day").dxDateBox('instance').option('value');
  443. var MainEndHour = $("#End_Hour").dxSelectBox('instance').option('value');
  444. if (MainEndHour == null) {
  445. utils.toast.show('종료 시간을 선택해야합니다.');
  446. return;
  447. }
  448. MainStartTime = new Date(MainStartDay.getFullYear(), MainStartDay.getMonth(), MainStartDay.getDate(), MainStartHour, 0, 0);
  449. MainEndTime = new Date(MainEndDay.getFullYear(), MainEndDay.getMonth(), MainEndDay.getDate(), MainEndHour, 59, 0);
  450. if (MainStartTime > MainEndTime) {
  451. utils.toast.show('시간 설정이 잘못 되었습니다.');
  452. return;
  453. }
  454. if (MainStartTime < new Date()) {
  455. utils.toast.show('시작 시간이 현재 시간보다 커야합니다.');
  456. return;
  457. }
  458. var MainStartTimeAddSeven = MainStartTime;
  459. MainStartTimeAddSeven.setDate(MainStartTimeAddSeven.getDate() + 7);
  460. if (MainStartTimeAddSeven <= MainEndTime) {
  461. utils.toast.show('일주일 이상 조회할수 없습니다.');
  462. return;
  463. }
  464. MainStartTimeAddSeven.setDate(MainStartTimeAddSeven.getDate() - 7);
  465. //초기화
  466. MainPowerConsumption = 0;
  467. MainGasConsumption = 0;
  468. MainGasHeatQuantity = 0;
  469. MainPowerPriceTypeId = 99;
  470. MainGasPriceTypeId = 99;
  471. var dataSource3 = new DevExpress.data.DataSource({
  472. store: {
  473. type: "odata",
  474. url: endpointSelector + "/BemsEnergyCost",
  475. },
  476. requireTotalCount: true,
  477. pageSize: 1,
  478. });
  479. dataSource3.filter([
  480. ["SiteId", "=", BWA.UserInfo.SiteId()],
  481. "and",
  482. ["FacilityTypeId", "=", MainFacilityType],
  483. "and",
  484. ["FacilityCode", "=", MainFacilityCode],
  485. "and",
  486. ["IsUse", "=", true],
  487. ]);
  488. dataSource3.load()
  489. .done(function (result3) {
  490. if (result3.length != 0) {
  491. if (MainFacilityType == REFRIGERATOR) {
  492. if (MainMode == 3) { //제빙 운전
  493. MainPowerConsumption = result3[0].PowerConsumption2;
  494. }
  495. else {
  496. MainPowerConsumption = result3[0].PowerConsumption1;
  497. }
  498. var MainPowerPriceTypeId = result3[0].PowerPriceTypeId;
  499. getPowerPriceMeta(MainPowerPriceTypeId);
  500. }
  501. else {
  502. MainPowerConsumption = result3[0].PowerConsumption1;
  503. MainGasConsumption = result3[0].GasConsumption;
  504. MainGasHeatQuantity = result3[0].GasHeatQuantity;
  505. MainPowerPriceTypeId = result3[0].PowerPriceTypeId;
  506. MainGasPriceTypeId = result3[0].GasPriceTypeId;
  507. getGasPriceMeta(MainGasPriceTypeId, MainPowerPriceTypeId);
  508. }
  509. }
  510. else {
  511. utils.toast.show('[BemsEnergyCost] 해당하는 데이터가 없습니다.');
  512. return;
  513. }
  514. })
  515. .fail(function (error) {
  516. utils.toast.show(error);
  517. });
  518. }
  519. });
  520. $("#Start_Day").dxDateBox({
  521. value: TodayAdd
  522. });
  523. $("#Start_Hour").dxSelectBox({
  524. dataSource: time_data,
  525. displayExpr: "time",
  526. valueExpr: "time",
  527. onValueChanged: function () {
  528. starthour = $("#Start_Hour").dxSelectBox('instance').option('value');
  529. }
  530. });
  531. $("#End_Day").dxDateBox({
  532. value: TodayAdd
  533. });
  534. $("#End_Hour").dxSelectBox({
  535. dataSource: time_data,
  536. displayExpr: "time",
  537. valueExpr: "time",
  538. onValueChanged: function () {
  539. endhour = $("#End_Hour").dxSelectBox('instance').option('value');
  540. }
  541. });
  542. $("#Power").dxTextBox({
  543. placeholder: "전력비용",
  544. disabled: true
  545. });
  546. $("#Gas").dxTextBox({
  547. placeholder: "가스비용",
  548. disabled: true
  549. });
  550. $("#Total").dxTextBox({
  551. placeholder: "합계",
  552. disabled: true
  553. });
  554. $("#LoadPanel").dxLoadPanel({
  555. message: '로딩 중...',
  556. showIndicator: true,
  557. visible: false
  558. });
  559. $("#dataGrid").dxDataGrid({
  560. paging: {
  561. pageSize: 16
  562. }
  563. });
  564. }
  565. var searchViewOptions = {
  566. };
  567. function handleSearchInSearchView() {
  568. }
  569. var viewModel = $.extend(BWA.CommonView.create(params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null, handleSearchInSearchView),
  570. {
  571. viewShowing: handleViewShowing,
  572. dataGrid: utils.datagrid.defaultOptions({
  573. width: 1200,
  574. height: 600,
  575. columns: [
  576. {
  577. dataField: 'DateTime',
  578. width: '18%',
  579. caption: "날짜",
  580. alignment: 'center',
  581. dataType: 'date',
  582. format: 'yyyy-MM-dd HH:mm:ss',
  583. sortOrder: 'asc',
  584. },
  585. {
  586. dataField: 'PowerBasic',
  587. width: '16%',
  588. caption: "전력 단가(원)",
  589. alignment: 'center'
  590. },
  591. {
  592. dataField: 'PowerPrice',
  593. width: '16%',
  594. caption: "전력 요금(원)",
  595. alignment: 'center',
  596. format: "currency"
  597. },
  598. {
  599. dataField: 'GasBasic',
  600. width: '16%',
  601. caption: "가스 단가(원)",
  602. alignment: 'center'
  603. },
  604. {
  605. dataField: 'GasPrice',
  606. width: '16%',
  607. caption: "가스 요금(원)",
  608. alignment: 'center',
  609. format: "currency"
  610. },
  611. {
  612. dataField: 'TotalPrice',
  613. width: '18%',
  614. caption: "요금합산",
  615. alignment: 'center',
  616. format: "currency"
  617. }
  618. ]
  619. })
  620. });
  621. return viewModel;
  622. };