8d64fe9f04379f8a2dd5d115302535070b81ba93.svn-base 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902
  1. BemsWebApplication.EnergyUsageFactorAnalysis = function (params, viewInfo) {
  2. "use strict";
  3. var endpointSelector = "";
  4. if (BemsWebApplication.config.mode == "production") {
  5. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
  6. } else {
  7. endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
  8. }
  9. var facilityDataSource = BWA.db.createDataSource('CmFacility');
  10. var eq = BWA.DataUtil.constructEqualFilter;
  11. var SITEID = BWA.UserInfo.SiteId();
  12. var visiblePopup = ko.observable(false);
  13. var toe = 0;
  14. var kwh = 0;
  15. var HDDStandard = 0;
  16. var CDDStandard = 0;
  17. var powerFuelTypeId = 1; //전력 고유 구분 코드
  18. var gasFuelTypeId = 2; //가스 고유 구분 코드
  19. var powerFacilityTypeId = $Code.FacilityType.ELECTRICITY; //전력 타입 고유 ID - 100
  20. var gasFacilityTypeId = $Code.FacilityType.GAS; //가스 타입 고유 ID - 101
  21. var powerFacilityCode = 0; //전력 시설 코드
  22. var powerFormulaId = 1; //전력 전체 사용량 수식
  23. var gasFacilityCode = 0; //가스 시설 코드
  24. var gasFormulaId = 1; //가스 전체 사용량 수식
  25. var temperatureFormula = [ //외기온도 조회 정보(외기온도 관제점 추가시 배열형태로 추가할것)
  26. {
  27. FacilityCode: 4864,
  28. PropertyId: 1
  29. }
  30. ]
  31. // 2019.04.16 : 그리드 도표 작업 : 팝업창 추가 ~~~
  32. // 팝업창뷰 보이기 속성 제어용 변수 선언
  33. var DataGridPopup_Visible = ko.observable(false);
  34. var DataGridPopup_Visible1 = ko.observable(false);
  35. var DataGridPopup_Visible2 = ko.observable(false);
  36. // 그래프 출력 이후 엑셀출력을 위한 팝업창을 위해 임시 저장용 배열 선언
  37. var dataArrayresult = ko.observableArray();
  38. var dataArrayresult1 = ko.observableArray();
  39. var dataArrayresult2 = ko.observableArray();
  40. // ~~~ 2019.04.16 : 그리드 도표 작업 : 팝업창 추가
  41. var useFactor = [{ id: 0, value: "인원증감" }, { id: 1, value: "임대율" }, { id: 2, value: "냉방도일" }, { id: 3, value: "난방도일" }, { id: 4, value: "냉/난방도일" }];
  42. var rentalRateYear = "";
  43. var peopleIncreaseYear = "";
  44. var rentalRate =
  45. [{ month: "1", value: 0 },
  46. { month: "2", value: 0 },
  47. { month: "3", value: 0 },
  48. { month: "4", value: 0 },
  49. { month: "5", value: 0 },
  50. { month: "6", value: 0 },
  51. { month: "7", value: 0 },
  52. { month: "8", value: 0 },
  53. { month: "9", value: 0 },
  54. { month: "10", value: 0 },
  55. { month: "11", value: 0 },
  56. { month: "12", value: 0 }];
  57. var peopleIncrease =
  58. [{ month: "1", value: 0 },
  59. { month: "2", value: 0 },
  60. { month: "3", value: 0 },
  61. { month: "4", value: 0 },
  62. { month: "5", value: 0 },
  63. { month: "6", value: 0 },
  64. { month: "7", value: 0 },
  65. { month: "8", value: 0 },
  66. { month: "9", value: 0 },
  67. { month: "10", value: 0 },
  68. { month: "11", value: 0 },
  69. { month: "12", value: 0 }];
  70. var powerDataSource =
  71. [{ month: "1", value: 0 },
  72. { month: "2", value: 0 },
  73. { month: "3", value: 0 },
  74. { month: "4", value: 0 },
  75. { month: "5", value: 0 },
  76. { month: "6", value: 0 },
  77. { month: "7", value: 0 },
  78. { month: "8", value: 0 },
  79. { month: "9", value: 0 },
  80. { month: "10", value: 0 },
  81. { month: "11", value: 0 },
  82. { month: "12", value: 0 }];
  83. var gasDataSource =
  84. [{ month: "1", value: 0 },
  85. { month: "2", value: 0 },
  86. { month: "3", value: 0 },
  87. { month: "4", value: 0 },
  88. { month: "5", value: 0 },
  89. { month: "6", value: 0 },
  90. { month: "7", value: 0 },
  91. { month: "8", value: 0 },
  92. { month: "9", value: 0 },
  93. { month: "10", value: 0 },
  94. { month: "11", value: 0 },
  95. { month: "12", value: 0 }];
  96. var HDDDataSource =
  97. [{ month: "1", value: 0 },
  98. { month: "2", value: 0 },
  99. { month: "3", value: 0 },
  100. { month: "4", value: 0 },
  101. { month: "5", value: 0 },
  102. { month: "6", value: 0 },
  103. { month: "7", value: 0 },
  104. { month: "8", value: 0 },
  105. { month: "9", value: 0 },
  106. { month: "10", value: 0 },
  107. { month: "11", value: 0 },
  108. { month: "12", value: 0 }];
  109. var CDDDataSource =
  110. [{ month: "1", value: 0 },
  111. { month: "2", value: 0 },
  112. { month: "3", value: 0 },
  113. { month: "4", value: 0 },
  114. { month: "5", value: 0 },
  115. { month: "6", value: 0 },
  116. { month: "7", value: 0 },
  117. { month: "8", value: 0 },
  118. { month: "9", value: 0 },
  119. { month: "10", value: 0 },
  120. { month: "11", value: 0 },
  121. { month: "12", value: 0 }];
  122. var chartDataSource =
  123. [{ month: "1", use: 0, factor: 0 },
  124. { month: "2", use: 0, factor: 0 },
  125. { month: "3", use: 0, factor: 0 },
  126. { month: "4", use: 0, factor: 0 },
  127. { month: "5", use: 0, factor: 0 },
  128. { month: "6", use: 0, factor: 0 },
  129. { month: "7", use: 0, factor: 0 },
  130. { month: "8", use: 0, factor: 0 },
  131. { month: "9", use: 0, factor: 0 },
  132. { month: "10", use: 0, factor: 0 },
  133. { month: "11", use: 0, factor: 0 },
  134. { month: "12", use: 0, factor: 0 }];
  135. var chartDataSourceHDDCDD =
  136. [{ month: "1", use: 0, cdd: 0, hdd: 0 },
  137. { month: "2", use: 0, cdd: 0, hdd: 0 },
  138. { month: "3", use: 0, cdd: 0, hdd: 0 },
  139. { month: "4", use: 0, cdd: 0, hdd: 0 },
  140. { month: "5", use: 0, cdd: 0, hdd: 0 },
  141. { month: "6", use: 0, cdd: 0, hdd: 0 },
  142. { month: "7", use: 0, cdd: 0, hdd: 0 },
  143. { month: "8", use: 0, cdd: 0, hdd: 0 },
  144. { month: "9", use: 0, cdd: 0, hdd: 0 },
  145. { month: "10", use: 0, cdd: 0, hdd: 0 },
  146. { month: "11", use: 0, cdd: 0, hdd: 0 },
  147. { month: "12", use: 0, cdd: 0, hdd: 0 }];
  148. var monthInputArray =
  149. [{ month: "1", value: 0 },
  150. { month: "2", value: 0 },
  151. { month: "3", value: 0 },
  152. { month: "4", value: 0 },
  153. { month: "5", value: 0 },
  154. { month: "6", value: 0 },
  155. { month: "7", value: 0 },
  156. { month: "8", value: 0 },
  157. { month: "9", value: 0 },
  158. { month: "10", value: 0 },
  159. { month: "11", value: 0 },
  160. { month: "12", value: 0 }];
  161. function numberWithCommas(x) {
  162. return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  163. }
  164. function SetUseFactorSelect() {
  165. $("#factorSelect").dxSelectBox("instance").option('dataSource', useFactor);
  166. $("#factorSelect").dxSelectBox("instance").option('displayExpr', "value");
  167. $("#factorSelect").dxSelectBox("instance").option('valueExpr', "id");
  168. $("#factorSelect").dxSelectBox("instance").option('value', 0);
  169. }
  170. function GetSiteHDDCDDStandard() {
  171. var dataSource = new DevExpress.data.DataSource({
  172. store: {
  173. type: "odata",
  174. url: endpointSelector + "/CmSite"
  175. },
  176. requireTotalCount: true,
  177. pageSize: 1
  178. });
  179. dataSource.filter([
  180. ["SiteId", "=", SITEID]
  181. ]);
  182. dataSource.load()
  183. .done(function (result) {
  184. HDDStandard = result[0].HDD;
  185. CDDStandard = result[0].CDD;
  186. $("#inputHDD").dxTextBox("instance").option('value', HDDStandard.toString());
  187. $("#inputCDD").dxTextBox("instance").option('value', CDDStandard.toString());
  188. GetHDDCDD();
  189. })
  190. .fail(function (error) {
  191. utils.toast.show(error);
  192. });
  193. }
  194. function GetSitePeopleIncrease() {
  195. var now = new Date();
  196. var dataSource = new DevExpress.data.DataSource({
  197. store: {
  198. type: "odata",
  199. url: endpointSelector + "/BemsPeopleIncrease"
  200. },
  201. requireTotalCount: true,
  202. pageSize: 1
  203. });
  204. dataSource.filter([
  205. ["SiteId", "=", SITEID],
  206. "and",
  207. ["Date", "=", now.getFullYear().toString()]
  208. ]);
  209. dataSource.sort({ getter: "Date", desc: true });
  210. dataSource.load()
  211. .done(function (result) {
  212. if (result.length != 0) {
  213. peopleIncreaseYear = result[0].Date;
  214. peopleIncrease[0].value = result[0].m1;
  215. peopleIncrease[1].value = result[0].m2;
  216. peopleIncrease[2].value = result[0].m3;
  217. peopleIncrease[3].value = result[0].m4;
  218. peopleIncrease[4].value = result[0].m5;
  219. peopleIncrease[5].value = result[0].m6;
  220. peopleIncrease[6].value = result[0].m7;
  221. peopleIncrease[7].value = result[0].m8;
  222. peopleIncrease[8].value = result[0].m9;
  223. peopleIncrease[9].value = result[0].m10;
  224. peopleIncrease[10].value = result[0].m11;
  225. peopleIncrease[11].value = result[0].m12;
  226. var tmpValue;
  227. for (var i = 11; i >= 0; i--) {
  228. if (peopleIncrease[i].value != null) {
  229. tmpValue = peopleIncrease[i].value;
  230. for (var j = i; j <= now.getMonth() ; j++) {
  231. peopleIncrease[j].value = tmpValue;
  232. }
  233. break;
  234. }
  235. }
  236. var store = new DevExpress.data.ODataStore({
  237. url: endpointSelector + "/BemsPeopleIncrease",
  238. key: ["Date", "SiteId"],
  239. keyType: { Date: "String", SiteId: "Int32" }
  240. });
  241. store.update({ Date: peopleIncreaseYear.toString(), SiteId: SITEID },
  242. {
  243. m1: peopleIncrease[0].value,
  244. m2: peopleIncrease[1].value,
  245. m3: peopleIncrease[2].value,
  246. m4: peopleIncrease[3].value,
  247. m5: peopleIncrease[4].value,
  248. m6: peopleIncrease[5].value,
  249. m7: peopleIncrease[6].value,
  250. m8: peopleIncrease[7].value,
  251. m9: peopleIncrease[8].value,
  252. m10: peopleIncrease[9].value,
  253. m11: peopleIncrease[10].value,
  254. m12: peopleIncrease[11].value
  255. })
  256. } else if (result.length == 0) {
  257. var dataSource2 = new DevExpress.data.DataSource({
  258. store: {
  259. type: "odata",
  260. url: endpointSelector + "/BemsPeopleIncrease"
  261. },
  262. requireTotalCount: true,
  263. pageSize: 1
  264. });
  265. dataSource2.filter([
  266. ["SiteId", "=", SITEID],
  267. ]);
  268. dataSource2.sort({ getter: "Date", desc: true });
  269. dataSource2.load()
  270. .done(function (result2) {
  271. if (result2.length != 0) {
  272. peopleIncreaseYear = result2[0].Date;
  273. peopleIncrease[0].value = result2[0].m1;
  274. peopleIncrease[1].value = result2[0].m2;
  275. peopleIncrease[2].value = result2[0].m3;
  276. peopleIncrease[3].value = result2[0].m4;
  277. peopleIncrease[4].value = result2[0].m5;
  278. peopleIncrease[5].value = result2[0].m6;
  279. peopleIncrease[6].value = result2[0].m7;
  280. peopleIncrease[7].value = result2[0].m8;
  281. peopleIncrease[8].value = result2[0].m9;
  282. peopleIncrease[9].value = result2[0].m10;
  283. peopleIncrease[10].value = result2[0].m11;
  284. peopleIncrease[11].value = result2[0].m12;
  285. var tmpValue;
  286. for (var i = 11; i >= 0; i--) {
  287. if (peopleIncrease[i].value != null) {
  288. tmpValue = peopleIncrease[i].value;
  289. for (var j = i; j < peopleIncrease.length; j++) {
  290. peopleIncrease[j].value = tmpValue;
  291. }
  292. break;
  293. }
  294. }
  295. var store = new DevExpress.data.ODataStore({
  296. url: endpointSelector + "/BemsPeopleIncrease",
  297. key: ["Date", "SiteId"],
  298. keyType: { Date: "String", SiteId: "Int32" }
  299. });
  300. store.update({ Date: peopleIncreaseYear.toString(), SiteId: SITEID },
  301. {
  302. m1: peopleIncrease[0].value,
  303. m2: peopleIncrease[1].value,
  304. m3: peopleIncrease[2].value,
  305. m4: peopleIncrease[3].value,
  306. m5: peopleIncrease[4].value,
  307. m6: peopleIncrease[5].value,
  308. m7: peopleIncrease[6].value,
  309. m8: peopleIncrease[7].value,
  310. m9: peopleIncrease[8].value,
  311. m10: peopleIncrease[9].value,
  312. m11: peopleIncrease[10].value,
  313. m12: peopleIncrease[11].value
  314. })
  315. var curYear = new Date().getFullYear() - (parseInt(peopleIncreaseYear));
  316. for (var i = 0; i < curYear; i++) {
  317. if (i == curYear - 1) {
  318. peopleIncreaseYear = new Date().getFullYear();
  319. var tmpMonth = new Date().getMonth();
  320. for (var j = 0; j < peopleIncrease.length; j++) {
  321. if (j <= tmpMonth) {
  322. peopleIncrease[j].value = tmpValue;
  323. } else {
  324. peopleIncrease[j].value = null;
  325. }
  326. }
  327. store.insert({
  328. Date: peopleIncreaseYear.toString(),
  329. SiteId: SITEID,
  330. m1: CheckNull(peopleIncrease[0].value),
  331. m2: CheckNull(peopleIncrease[1].value),
  332. m3: CheckNull(peopleIncrease[2].value),
  333. m4: CheckNull(peopleIncrease[3].value),
  334. m5: CheckNull(peopleIncrease[4].value),
  335. m6: CheckNull(peopleIncrease[5].value),
  336. m7: CheckNull(peopleIncrease[6].value),
  337. m8: CheckNull(peopleIncrease[7].value),
  338. m9: CheckNull(peopleIncrease[8].value),
  339. m10: CheckNull(peopleIncrease[9].value),
  340. m11: CheckNull(peopleIncrease[10].value),
  341. m12: CheckNull(peopleIncrease[11].value)
  342. })
  343. } else {
  344. store.insert({
  345. Date: (parseInt(peopleIncreaseYear.toString()) + (i + 1)).toString(),
  346. SiteId: SITEID,
  347. m1: tmpValue.toString(),
  348. m2: tmpValue.toString(),
  349. m3: tmpValue.toString(),
  350. m4: tmpValue.toString(),
  351. m5: tmpValue.toString(),
  352. m6: tmpValue.toString(),
  353. m7: tmpValue.toString(),
  354. m8: tmpValue.toString(),
  355. m9: tmpValue.toString(),
  356. m10: tmpValue.toString(),
  357. m11: tmpValue.toString(),
  358. m12: tmpValue.toString()
  359. })
  360. }
  361. }
  362. } else {
  363. utils.toast.show("데이터가 없습니다.");
  364. }
  365. })
  366. .fail(function (error) {
  367. utils.toast.show(error);
  368. });
  369. }
  370. })
  371. .fail(function (error) {
  372. utils.toast.show(error);
  373. });
  374. }
  375. function GetSitePeopleIncreaseHistory() {
  376. var selectDate = $("#standardDatePicker").dxDateBox("instance").option('value');
  377. var dataSource = new DevExpress.data.DataSource({
  378. store: {
  379. type: "odata",
  380. url: endpointSelector + "/BemsPeopleIncrease"
  381. },
  382. requireTotalCount: true,
  383. pageSize: 1
  384. });
  385. dataSource.filter([
  386. ["SiteId", "=", SITEID],
  387. "and",
  388. ["Date", "=", selectDate.getFullYear().toString()]
  389. ]);
  390. dataSource.sort({ getter: "Date", desc: true });
  391. dataSource.load()
  392. .done(function (result) {
  393. if (result.length == 0) {
  394. peopleIncreaseYear = selectDate.getFullYear();
  395. peopleIncrease[0].value = null;
  396. peopleIncrease[1].value = null;
  397. peopleIncrease[2].value = null;
  398. peopleIncrease[3].value = null;
  399. peopleIncrease[4].value = null;
  400. peopleIncrease[5].value = null;
  401. peopleIncrease[6].value = null;
  402. peopleIncrease[7].value = null;
  403. peopleIncrease[8].value = null;
  404. peopleIncrease[9].value = null;
  405. peopleIncrease[10].value = null;
  406. peopleIncrease[11].value = null;
  407. } else {
  408. peopleIncreaseYear = result[0].Date;
  409. peopleIncrease[0].value = result[0].m1;
  410. peopleIncrease[1].value = result[0].m2;
  411. peopleIncrease[2].value = result[0].m3;
  412. peopleIncrease[3].value = result[0].m4;
  413. peopleIncrease[4].value = result[0].m5;
  414. peopleIncrease[5].value = result[0].m6;
  415. peopleIncrease[6].value = result[0].m7;
  416. peopleIncrease[7].value = result[0].m8;
  417. peopleIncrease[8].value = result[0].m9;
  418. peopleIncrease[9].value = result[0].m10;
  419. peopleIncrease[10].value = result[0].m11;
  420. peopleIncrease[11].value = result[0].m12;
  421. }
  422. })
  423. .fail(function (error) {
  424. utils.toast.show(error);
  425. });
  426. }
  427. function GetSiteRentalRate() {
  428. var now = new Date();
  429. var dataSource = new DevExpress.data.DataSource({
  430. store: {
  431. type: "odata",
  432. url: endpointSelector + "/BemsRentalRate"
  433. },
  434. requireTotalCount: true,
  435. pageSize: 1
  436. });
  437. dataSource.filter([
  438. ["SiteId", "=", SITEID],
  439. "and",
  440. ["Date", "=", now.getFullYear().toString()]
  441. ]);
  442. dataSource.sort({ getter: "Date", desc: true });
  443. dataSource.load()
  444. .done(function (result) {
  445. if (result.length != 0) {
  446. rentalRateYear = result[0].Date;
  447. rentalRate[0].value = result[0].m1;
  448. rentalRate[1].value = result[0].m2;
  449. rentalRate[2].value = result[0].m3;
  450. rentalRate[3].value = result[0].m4;
  451. rentalRate[4].value = result[0].m5;
  452. rentalRate[5].value = result[0].m6;
  453. rentalRate[6].value = result[0].m7;
  454. rentalRate[7].value = result[0].m8;
  455. rentalRate[8].value = result[0].m9;
  456. rentalRate[9].value = result[0].m10;
  457. rentalRate[10].value = result[0].m11;
  458. rentalRate[11].value = result[0].m12;
  459. var tmpValue;
  460. for (var i = 11; i >= 0; i--) {
  461. if (rentalRate[i].value != null) {
  462. tmpValue = rentalRate[i].value;
  463. for (var j = i; j <= now.getMonth() ; j++) {
  464. rentalRate[j].value = tmpValue;
  465. }
  466. break;
  467. }
  468. }
  469. var store = new DevExpress.data.ODataStore({
  470. url: endpointSelector + "/BemsRentalRate",
  471. key: ["Date", "SiteId"],
  472. keyType: { Date: "String", SiteId: "Int32" }
  473. });
  474. store.update({ Date: rentalRateYear.toString(), SiteId: SITEID },
  475. {
  476. m1: rentalRate[0].value,
  477. m2: rentalRate[1].value,
  478. m3: rentalRate[2].value,
  479. m4: rentalRate[3].value,
  480. m5: rentalRate[4].value,
  481. m6: rentalRate[5].value,
  482. m7: rentalRate[6].value,
  483. m8: rentalRate[7].value,
  484. m9: rentalRate[8].value,
  485. m10: rentalRate[9].value,
  486. m11: rentalRate[10].value,
  487. m12: rentalRate[11].value
  488. })
  489. } else if (result.length == 0) {
  490. var dataSource2 = new DevExpress.data.DataSource({
  491. store: {
  492. type: "odata",
  493. url: endpointSelector + "/BemsRentalRate"
  494. },
  495. requireTotalCount: true,
  496. pageSize: 1
  497. });
  498. dataSource2.filter([
  499. ["SiteId", "=", SITEID],
  500. ]);
  501. dataSource2.sort({ getter: "Date", desc: true });
  502. dataSource2.load()
  503. .done(function (result2) {
  504. if (result2.length != 0) {
  505. rentalRateYear = result2[0].Date;
  506. rentalRate[0].value = result2[0].m1;
  507. rentalRate[1].value = result2[0].m2;
  508. rentalRate[2].value = result2[0].m3;
  509. rentalRate[3].value = result2[0].m4;
  510. rentalRate[4].value = result2[0].m5;
  511. rentalRate[5].value = result2[0].m6;
  512. rentalRate[6].value = result2[0].m7;
  513. rentalRate[7].value = result2[0].m8;
  514. rentalRate[8].value = result2[0].m9;
  515. rentalRate[9].value = result2[0].m10;
  516. rentalRate[10].value = result2[0].m11;
  517. rentalRate[11].value = result2[0].m12;
  518. var tmpValue;
  519. for (var i = 11; i >= 0; i--) {
  520. if (rentalRate[i].value != null) {
  521. tmpValue = rentalRate[i].value;
  522. for (var j = i; j < rentalRate.length; j++) {
  523. rentalRate[j].value = tmpValue;
  524. }
  525. break;
  526. }
  527. }
  528. var store = new DevExpress.data.ODataStore({
  529. url: endpointSelector + "/BemsRentalRate",
  530. key: ["Date", "SiteId"],
  531. keyType: { Date: "String", SiteId: "Int32" }
  532. });
  533. store.update({ Date: rentalRateYear.toString(), SiteId: SITEID },
  534. {
  535. m1: rentalRate[0].value,
  536. m2: rentalRate[1].value,
  537. m3: rentalRate[2].value,
  538. m4: rentalRate[3].value,
  539. m5: rentalRate[4].value,
  540. m6: rentalRate[5].value,
  541. m7: rentalRate[6].value,
  542. m8: rentalRate[7].value,
  543. m9: rentalRate[8].value,
  544. m10: rentalRate[9].value,
  545. m11: rentalRate[10].value,
  546. m12: rentalRate[11].value
  547. })
  548. var curYear = new Date().getFullYear() - (parseInt(rentalRateYear));
  549. for (var i = 0; i < curYear; i++) {
  550. if (i == curYear - 1) {
  551. rentalRateYear = new Date().getFullYear();
  552. var tmpMonth = new Date().getMonth();
  553. for (var j = 0; j < rentalRate.length; j++) {
  554. if (j <= tmpMonth) {
  555. rentalRate[j].value = tmpValue;
  556. } else {
  557. rentalRate[j].value = null;
  558. }
  559. }
  560. store.insert({
  561. Date: rentalRateYear.toString(),
  562. SiteId: SITEID,
  563. m1: CheckNull(rentalRate[0].value),
  564. m2: CheckNull(rentalRate[1].value),
  565. m3: CheckNull(rentalRate[2].value),
  566. m4: CheckNull(rentalRate[3].value),
  567. m5: CheckNull(rentalRate[4].value),
  568. m6: CheckNull(rentalRate[5].value),
  569. m7: CheckNull(rentalRate[6].value),
  570. m8: CheckNull(rentalRate[7].value),
  571. m9: CheckNull(rentalRate[8].value),
  572. m10: CheckNull(rentalRate[9].value),
  573. m11: CheckNull(rentalRate[10].value),
  574. m12: CheckNull(rentalRate[11].value)
  575. })
  576. } else {
  577. store.insert({
  578. Date: (parseInt(rentalRateYear.toString()) + (i + 1)).toString(),
  579. SiteId: SITEID,
  580. m1: tmpValue.toString(),
  581. m2: tmpValue.toString(),
  582. m3: tmpValue.toString(),
  583. m4: tmpValue.toString(),
  584. m5: tmpValue.toString(),
  585. m6: tmpValue.toString(),
  586. m7: tmpValue.toString(),
  587. m8: tmpValue.toString(),
  588. m9: tmpValue.toString(),
  589. m10: tmpValue.toString(),
  590. m11: tmpValue.toString(),
  591. m12: tmpValue.toString()
  592. })
  593. }
  594. }
  595. } else {
  596. utils.toast.show("데이터가 없습니다.");
  597. }
  598. })
  599. .fail(function (error) {
  600. utils.toast.show(error);
  601. });
  602. }
  603. })
  604. .fail(function (error) {
  605. utils.toast.show(error);
  606. });
  607. }
  608. function CheckNull(value) {
  609. if (value == null) {
  610. return null;
  611. } else {
  612. return value;
  613. }
  614. }
  615. function GetSiteRentalRateHistory() {
  616. var selectDate = $("#standardDatePicker").dxDateBox("instance").option('value');
  617. var dataSource = new DevExpress.data.DataSource({
  618. store: {
  619. type: "odata",
  620. url: endpointSelector + "/BemsRentalRate"
  621. },
  622. requireTotalCount: true,
  623. pageSize: 1
  624. });
  625. dataSource.filter([
  626. ["SiteId", "=", SITEID],
  627. "and",
  628. ["Date", "=", selectDate.getFullYear().toString()]
  629. ]);
  630. dataSource.sort({ getter: "Date", desc: true });
  631. dataSource.load()
  632. .done(function (result) {
  633. if (result.length == 0) {
  634. rentalRateYear = selectDate.getFullYear();
  635. rentalRate[0].value = null;
  636. rentalRate[1].value = null;
  637. rentalRate[2].value = null;
  638. rentalRate[3].value = null;
  639. rentalRate[4].value = null;
  640. rentalRate[5].value = null;
  641. rentalRate[6].value = null;
  642. rentalRate[7].value = null;
  643. rentalRate[8].value = null;
  644. rentalRate[9].value = null;
  645. rentalRate[10].value = null;
  646. rentalRate[11].value = null;
  647. } else {
  648. rentalRateYear = result[0].Date;
  649. rentalRate[0].value = result[0].m1;
  650. rentalRate[1].value = result[0].m2;
  651. rentalRate[2].value = result[0].m3;
  652. rentalRate[3].value = result[0].m4;
  653. rentalRate[4].value = result[0].m5;
  654. rentalRate[5].value = result[0].m6;
  655. rentalRate[6].value = result[0].m7;
  656. rentalRate[7].value = result[0].m8;
  657. rentalRate[8].value = result[0].m9;
  658. rentalRate[9].value = result[0].m10;
  659. rentalRate[10].value = result[0].m11;
  660. rentalRate[11].value = result[0].m12;
  661. }
  662. })
  663. .fail(function (error) {
  664. utils.toast.show(error);
  665. });
  666. }
  667. function GetEnergyData(FuelTypeId, FacilityTypeId, FacilityCode, FormulaId) {
  668. var dataSource = new DevExpress.data.DataSource({
  669. store: {
  670. type: "odata",
  671. url: endpointSelector + "/BemsFormulaParameter"
  672. },
  673. requireTotalCount: true,
  674. pageSize: 100
  675. });
  676. dataSource.filter([
  677. ["SiteId", "=", SITEID],
  678. "and",
  679. ["FacilityTypeId", "=", FacilityTypeId],
  680. "and",
  681. ["FacilityCode", "=", FacilityCode],
  682. "and",
  683. ["FormulaId", "=", FormulaId]
  684. ]);
  685. dataSource.sort({ getter: "ParameterId", desc: true });
  686. dataSource.load()
  687. .done(function (result) {
  688. var formulaArray = new Array(result.length);
  689. for (var i = 0; i < formulaArray.length; i++) {
  690. formulaArray[i] = new Array(2);
  691. }
  692. for (var i = 0; i < formulaArray.length; i++) {
  693. formulaArray[i][0] = result[i].ParameterFacilityCode;
  694. formulaArray[i][1] = result[i].ParameterPropertyId;
  695. }
  696. for (var i = 0; i < formulaArray.length; i++) {
  697. GetDailyData(FuelTypeId, formulaArray[i]);
  698. }
  699. })
  700. .fail(function (error) {
  701. utils.toast.show(error);
  702. });
  703. }
  704. function GetDailyData(FuelTypeId, formulaArray) {
  705. var now = new Date();
  706. var dataSource = new DevExpress.data.DataSource({
  707. store: {
  708. type: "odata",
  709. url: endpointSelector + "/BemsMonitoringPointHistoryDaily"
  710. },
  711. requireTotalCount: true,
  712. pageSize: 366
  713. });
  714. dataSource.filter([
  715. ["SiteId", "=", SITEID],
  716. "and",
  717. ["FacilityCode", "=", formulaArray[0]],
  718. "and",
  719. ["PropertyId", "=", formulaArray[1]],
  720. "and",
  721. ["CreatedDateTime", ">=", new Date(now.getFullYear(), 1 - 1, 1)],
  722. "and",
  723. ["CreatedDateTime", "<=", new Date(now.getFullYear(), 12 - 1, 31)]
  724. ]);
  725. dataSource.sort({ getter: "CreatedDateTime", asc: true });
  726. dataSource.load()
  727. .done(function (result) {
  728. for (var i = 0; i < result.length; i++) {
  729. if (FuelTypeId == powerFuelTypeId) {
  730. for (var j = 0; j < powerDataSource.length; j++) {
  731. if (powerDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  732. powerDataSource[j].value = powerDataSource[j].value + result[i].DailyValue;
  733. }
  734. }
  735. } else if (FuelTypeId == gasFuelTypeId) {
  736. for (var j = 0; j < gasDataSource.length; j++) {
  737. if (gasDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  738. gasDataSource[j].value = gasDataSource[j].value + (result[i].DailyValue * toe / kwh);
  739. }
  740. }
  741. } else {
  742. /*for (var j = 0; j < waterDataSource.length; j++) {
  743. if (waterDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  744. waterDataSource[j].value = waterDataSource[j].value + result[i].DailyValue;
  745. }
  746. }*/
  747. }
  748. }
  749. })
  750. .fail(function (error) {
  751. utils.toast.show(error);
  752. });
  753. }
  754. function GetEnergyDataHistory(FuelTypeId, FacilityTypeId, FacilityCode, FormulaId) {
  755. var dataSource = new DevExpress.data.DataSource({
  756. store: {
  757. type: "odata",
  758. url: endpointSelector + "/BemsFormulaParameter"
  759. },
  760. requireTotalCount: true,
  761. pageSize: 100
  762. });
  763. dataSource.filter([
  764. ["SiteId", "=", SITEID],
  765. "and",
  766. ["FacilityTypeId", "=", FacilityTypeId],
  767. "and",
  768. ["FacilityCode", "=", FacilityCode],
  769. "and",
  770. ["FormulaId", "=", FormulaId]
  771. ]);
  772. dataSource.sort({ getter: "ParameterId", desc: true });
  773. dataSource.load()
  774. .done(function (result) {
  775. var formulaArray = new Array(result.length);
  776. for (var i = 0; i < formulaArray.length; i++) {
  777. formulaArray[i] = new Array(2);
  778. }
  779. for (var i = 0; i < formulaArray.length; i++) {
  780. formulaArray[i][0] = result[i].ParameterFacilityCode;
  781. formulaArray[i][1] = result[i].ParameterPropertyId;
  782. }
  783. if (FuelTypeId == powerFuelTypeId) {
  784. for (var i = 0; i < powerDataSource.length; i++) {
  785. powerDataSource[i].value = null;
  786. }
  787. } else if (FuelTypeId == gasFuelTypeId) {
  788. for (var i = 0; i < gasDataSource.length; i++) {
  789. gasDataSource[i].value = null;
  790. }
  791. }
  792. for (var i = 0; i < formulaArray.length; i++) {
  793. GetDailyDataHistory(FuelTypeId, formulaArray[i]);
  794. }
  795. })
  796. .fail(function (error) {
  797. utils.toast.show(error);
  798. });
  799. }
  800. function GetDailyDataHistory(FuelTypeId, formulaArray) {
  801. var selectDate = $("#standardDatePicker").dxDateBox("instance").option('value');
  802. var dataSource = new DevExpress.data.DataSource({
  803. store: {
  804. type: "odata",
  805. url: endpointSelector + "/BemsMonitoringPointHistoryDaily"
  806. },
  807. requireTotalCount: true,
  808. pageSize: 366
  809. });
  810. dataSource.filter([
  811. ["SiteId", "=", SITEID],
  812. "and",
  813. ["FacilityCode", "=", formulaArray[0]],
  814. "and",
  815. ["PropertyId", "=", formulaArray[1]],
  816. "and",
  817. ["CreatedDateTime", ">=", new Date(selectDate.getFullYear(), 1 - 1, 1)],
  818. "and",
  819. ["CreatedDateTime", "<=", new Date(selectDate.getFullYear(), 12 - 1, 31)]
  820. ]);
  821. dataSource.sort({ getter: "CreatedDateTime", asc: true });
  822. dataSource.load()
  823. .done(function (result) {
  824. for (var i = 0; i < result.length; i++) {
  825. if (FuelTypeId == powerFuelTypeId) {
  826. for (var j = 0; j < powerDataSource.length; j++) {
  827. if (powerDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  828. powerDataSource[j].value = powerDataSource[j].value + result[i].DailyValue;
  829. }
  830. }
  831. } else if (FuelTypeId == gasFuelTypeId) {
  832. for (var j = 0; j < gasDataSource.length; j++) {
  833. if (gasDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  834. gasDataSource[j].value = gasDataSource[j].value + (result[i].DailyValue * toe / kwh);
  835. }
  836. }
  837. } else {
  838. /*for (var j = 0; j < waterDataSource.length; j++) {
  839. if (waterDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  840. waterDataSource[j].value = waterDataSource[j].value + result[i].DailyValue;
  841. }
  842. }*/
  843. }
  844. }
  845. })
  846. .fail(function (error) {
  847. utils.toast.show(error);
  848. });
  849. }
  850. function SetChart() {
  851. var selectFactor = $("#factorSelect").dxSelectBox("instance").option('value');
  852. if (selectFactor == 0) {
  853. for (var i = 0; i < chartDataSource.length; i++) {
  854. if (powerDataSource[i].value == null && gasDataSource[i].value == null) {
  855. chartDataSource[i].use = null;
  856. } else {
  857. chartDataSource[i].use = powerDataSource[i].value + gasDataSource[i].value;
  858. }
  859. chartDataSource[i].factor = peopleIncrease[i].value;
  860. }
  861. $("#compareChart").dxChart("instance").option('dataSource', chartDataSource);
  862. var tmpSeries = $("#compareChart").dxChart("instance").option('series');
  863. if (tmpSeries.length == 3) {
  864. tmpSeries.pop();
  865. }
  866. tmpSeries[0].name = "에너지 사용량(kWh/월)";
  867. tmpSeries[0].valueField = "use";
  868. tmpSeries[0].axis = "에너지 사용량";
  869. tmpSeries[1].name = "재실 인원(명/월)";
  870. tmpSeries[1].valueField = "factor";
  871. tmpSeries[1].axis = "재실 인원";
  872. $("#compareChart").dxChart("instance").option('series', tmpSeries);
  873. var tmpValueAxis = $("#compareChart").dxChart("instance").option('valueAxis');
  874. if (tmpValueAxis.length == 3) {
  875. tmpValueAxis.pop();
  876. }
  877. tmpValueAxis[0].name = "에너지 사용량";
  878. tmpValueAxis[0].position = "left";
  879. tmpValueAxis[0].title = "에너지 사용량(kWh/월)";
  880. tmpValueAxis[1].name = "재실 인원";
  881. tmpValueAxis[1].position = "right";
  882. tmpValueAxis[1].inverted = true;
  883. tmpValueAxis[1].title = "재실 인원(명/월)";
  884. $("#compareChart").dxChart("instance").option('valueAxis', tmpValueAxis);
  885. } else if (selectFactor == 1) {
  886. for (var i = 0; i < chartDataSource.length; i++) {
  887. if (powerDataSource[i].value == null && gasDataSource[i].value == null) {
  888. chartDataSource[i].use = null;
  889. } else {
  890. chartDataSource[i].use = powerDataSource[i].value + gasDataSource[i].value;
  891. }
  892. chartDataSource[i].factor = rentalRate[i].value;
  893. }
  894. $("#compareChart").dxChart("instance").option('dataSource', chartDataSource);
  895. var tmpSeries = $("#compareChart").dxChart("instance").option('series');
  896. if (tmpSeries.length == 3) {
  897. tmpSeries.pop();
  898. }
  899. tmpSeries[0].name = "에너지 사용량(kWh/월)";
  900. tmpSeries[0].valueField = "use";
  901. tmpSeries[0].axis = "에너지 사용량";
  902. tmpSeries[1].name = "임대율(%/월)";
  903. tmpSeries[1].valueField = "factor";
  904. tmpSeries[1].axis = "임대율";
  905. $("#compareChart").dxChart("instance").option('series', tmpSeries);
  906. var tmpValueAxis = $("#compareChart").dxChart("instance").option('valueAxis');
  907. if (tmpValueAxis.length == 3) {
  908. tmpValueAxis.pop();
  909. }
  910. tmpValueAxis[0].name = "에너지 사용량";
  911. tmpValueAxis[0].position = "left";
  912. tmpValueAxis[0].title = "에너지 사용량(kWh/월)";
  913. tmpValueAxis[1].name = "임대율";
  914. tmpValueAxis[1].position = "right";
  915. tmpValueAxis[1].inverted = true;
  916. tmpValueAxis[1].title = "임대율(%/월)";
  917. $("#compareChart").dxChart("instance").option('valueAxis', tmpValueAxis);
  918. }
  919. else if (selectFactor == 2) {
  920. for (var i = 0; i < chartDataSource.length; i++) {
  921. if (powerDataSource[i].value == null && gasDataSource[i].value == null) {
  922. chartDataSource[i].use = null;
  923. } else {
  924. chartDataSource[i].use = powerDataSource[i].value + gasDataSource[i].value;
  925. }
  926. chartDataSource[i].factor = CDDDataSource[i].value;
  927. }
  928. $("#compareChart").dxChart("instance").option('dataSource', chartDataSource);
  929. var tmpSeries = $("#compareChart").dxChart("instance").option('series');
  930. if (tmpSeries.length == 3) {
  931. tmpSeries.pop();
  932. }
  933. tmpSeries[0].name = "에너지 사용량(kWh/월)";
  934. tmpSeries[0].valueField = "use";
  935. tmpSeries[0].axis = "에너지 사용량";
  936. tmpSeries[1].name = "냉방도일(월)";
  937. tmpSeries[1].valueField = "factor";
  938. tmpSeries[1].axis = "냉방도일";
  939. $("#compareChart").dxChart("instance").option('series', tmpSeries);
  940. var tmpValueAxis = $("#compareChart").dxChart("instance").option('valueAxis');
  941. if (tmpValueAxis.length == 3) {
  942. tmpValueAxis.pop();
  943. }
  944. tmpValueAxis[0].name = "에너지 사용량";
  945. tmpValueAxis[0].position = "left";
  946. tmpValueAxis[0].title = "에너지 사용량(kWh/월)";
  947. tmpValueAxis[1].name = "냉방도일";
  948. tmpValueAxis[1].position = "right";
  949. tmpValueAxis[1].inverted = false;
  950. tmpValueAxis[1].title = "냉방도일(월)";
  951. $("#compareChart").dxChart("instance").option('valueAxis', tmpValueAxis);
  952. }
  953. else if (selectFactor == 3) {
  954. for (var i = 0; i < chartDataSource.length; i++) {
  955. if (powerDataSource[i].value == null && gasDataSource[i].value == null) {
  956. chartDataSource[i].use = null;
  957. } else {
  958. chartDataSource[i].use = powerDataSource[i].value + gasDataSource[i].value;
  959. }
  960. chartDataSource[i].factor = HDDDataSource[i].value;
  961. }
  962. $("#compareChart").dxChart("instance").option('dataSource', chartDataSource);
  963. var tmpSeries = $("#compareChart").dxChart("instance").option('series');
  964. if (tmpSeries.length == 3) {
  965. tmpSeries.pop();
  966. }
  967. tmpSeries[0].name = "에너지 사용량(kWh/월)";
  968. tmpSeries[0].valueField = "use";
  969. tmpSeries[0].axis = "에너지 사용량";
  970. tmpSeries[1].name = "난방도일(월)";
  971. tmpSeries[1].valueField = "factor";
  972. tmpSeries[1].axis = "난방도일";
  973. $("#compareChart").dxChart("instance").option('series', tmpSeries);
  974. var tmpValueAxis = $("#compareChart").dxChart("instance").option('valueAxis');
  975. if (tmpValueAxis.length == 3) {
  976. tmpValueAxis.pop();
  977. }
  978. tmpValueAxis[0].name = "에너지 사용량";
  979. tmpValueAxis[0].position = "left";
  980. tmpValueAxis[0].title = "에너지 사용량(kWh/월)";
  981. tmpValueAxis[1].name = "난방도일";
  982. tmpValueAxis[1].position = "right";
  983. tmpValueAxis[1].inverted = false;
  984. tmpValueAxis[1].title = "난방도일(월)";
  985. $("#compareChart").dxChart("instance").option('valueAxis', tmpValueAxis);
  986. }
  987. else if (selectFactor == 4) {
  988. for (var i = 0; i < chartDataSourceHDDCDD.length; i++) {
  989. if (powerDataSource[i].value == null && gasDataSource[i].value == null) {
  990. chartDataSourceHDDCDD[i].use = null;
  991. } else {
  992. chartDataSourceHDDCDD[i].use = powerDataSource[i].value + gasDataSource[i].value;
  993. }
  994. chartDataSourceHDDCDD[i].hdd = HDDDataSource[i].value;
  995. chartDataSourceHDDCDD[i].cdd = CDDDataSource[i].value;
  996. }
  997. $("#compareChart").dxChart("instance").option('dataSource', chartDataSourceHDDCDD);
  998. var tmpSeries = $("#compareChart").dxChart("instance").option('series');
  999. if (tmpSeries.length == 2) {
  1000. tmpSeries.push({ valueField: "hdd", name: "난방도일(월)", color: '#FFBB00', axis: "난방도일" });
  1001. }
  1002. tmpSeries[0].name = "에너지 사용량(kWh/월)";
  1003. tmpSeries[0].valueField = "use";
  1004. tmpSeries[0].axis = "에너지 사용량";
  1005. tmpSeries[1].name = "냉방도일(월)";
  1006. tmpSeries[1].valueField = "cdd";
  1007. tmpSeries[1].axis = "냉방도일";
  1008. $("#compareChart").dxChart("instance").option('series', tmpSeries);
  1009. var tmpValueAxis = $("#compareChart").dxChart("instance").option('valueAxis');
  1010. if (tmpValueAxis.length == 2) {
  1011. tmpValueAxis.push({ valueField: "hdd", name: "난방도일", axis: "난방도일", position: "right", title: "난방도일(월)" });
  1012. }
  1013. tmpValueAxis[0].name = "에너지 사용량";
  1014. tmpValueAxis[0].position = "left";
  1015. tmpValueAxis[0].title = "에너지 사용량(kWh/월)";
  1016. tmpValueAxis[1].name = "냉방도일";
  1017. tmpValueAxis[1].position = "right";
  1018. tmpValueAxis[1].inverted = false;
  1019. tmpValueAxis[1].title = "냉방도일(월)";
  1020. $("#compareChart").dxChart("instance").option('valueAxis', tmpValueAxis);
  1021. } else {
  1022. utils.toast.show("소비 요인이 선택되지 않았습니다.");
  1023. }
  1024. }
  1025. function GetTOEKWH() {
  1026. var dataSource = new DevExpress.data.DataSource({
  1027. store: {
  1028. type: "odata",
  1029. url: endpointSelector + "/BemsFactorToe"
  1030. },
  1031. requireTotalCount: true,
  1032. pageSize: 10
  1033. });
  1034. dataSource.filter([
  1035. ["FuelTypeId", "=", powerFuelTypeId],
  1036. "or",
  1037. ["FuelTypeId", "=", gasFuelTypeId]
  1038. ]);
  1039. dataSource.sort({ getter: "FuelTypeId", asc: true });
  1040. dataSource.load()
  1041. .done(function (result) {
  1042. toe = result[1].PureFactor;
  1043. kwh = result[0].PureFactor;
  1044. })
  1045. .fail(function (error) {
  1046. utils.toast.show(error);
  1047. });
  1048. }
  1049. function GetHDDCDD() {
  1050. for (var i = 0; i < temperatureFormula.length; i++) {
  1051. var now = new Date();
  1052. var dataSource = new DevExpress.data.DataSource({
  1053. store: {
  1054. type: "odata",
  1055. url: endpointSelector + "/BemsMonitoringPointHistoryDaily"
  1056. },
  1057. requireTotalCount: true,
  1058. pageSize: 366
  1059. });
  1060. dataSource.filter([
  1061. ["SiteId", "=", SITEID],
  1062. "and",
  1063. ["FacilityCode", "=", temperatureFormula[i].FacilityCode],
  1064. "and",
  1065. ["PropertyId", "=", temperatureFormula[i].PropertyId],
  1066. "and",
  1067. ["CreatedDateTime", ">=", new Date(now.getFullYear(), 1 - 1, 1)],
  1068. "and",
  1069. ["CreatedDateTime", "<=", new Date(now.getFullYear(), 12 - 1, 31)]
  1070. ]);
  1071. dataSource.sort({ getter: "CreatedDateTime", asc: true });
  1072. dataSource.load()
  1073. .done(function (result) {
  1074. for (var i = 0; i < result.length; i++) {
  1075. for (var j = 0; j < HDDDataSource.length; j++) {
  1076. if (HDDDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  1077. HDDDataSource[j].value = HDDDataSource[j].value + (HDDStandard - parseFloat(result[i].DailyValue.toString()));
  1078. }
  1079. }
  1080. for (var j = 0; j < CDDDataSource.length; j++) {
  1081. if (CDDDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  1082. CDDDataSource[j].value = CDDDataSource[j].value + (parseFloat(result[i].DailyValue.toString()) - CDDStandard);
  1083. }
  1084. }
  1085. }
  1086. for (var j = 0; j < HDDDataSource.length; j++) {
  1087. HDDDataSource[j].value = HDDDataSource[j].value / temperatureFormula.length;
  1088. }
  1089. for (var j = 0; j < CDDDataSource.length; j++) {
  1090. CDDDataSource[j].value = CDDDataSource[j].value / temperatureFormula.length;
  1091. }
  1092. })
  1093. .fail(function (error) {
  1094. utils.toast.show(error);
  1095. });
  1096. }
  1097. }
  1098. function GetHDDCDDHistory() {
  1099. for (var i = 0; i < HDDDataSource.length; i++) {
  1100. HDDDataSource[i].value = null;
  1101. }
  1102. for (var i = 0; i < CDDDataSource.length; i++) {
  1103. CDDDataSource[i].value = null;
  1104. }
  1105. for (var i = 0; i < temperatureFormula.length; i++) {
  1106. var selectDate = $("#standardDatePicker").dxDateBox("instance").option('value');
  1107. var dataSource = new DevExpress.data.DataSource({
  1108. store: {
  1109. type: "odata",
  1110. url: endpointSelector + "/BemsMonitoringPointHistoryDaily"
  1111. },
  1112. requireTotalCount: true,
  1113. pageSize: 366
  1114. });
  1115. dataSource.filter([
  1116. ["SiteId", "=", SITEID],
  1117. "and",
  1118. ["FacilityCode", "=", temperatureFormula[i].FacilityCode],
  1119. "and",
  1120. ["PropertyId", "=", temperatureFormula[i].PropertyId],
  1121. "and",
  1122. ["CreatedDateTime", ">=", new Date(selectDate.getFullYear(), 1 - 1, 1)],
  1123. "and",
  1124. ["CreatedDateTime", "<=", new Date(selectDate.getFullYear(), 12 - 1, 31)]
  1125. ]);
  1126. dataSource.sort({ getter: "CreatedDateTime", asc: true });
  1127. dataSource.load()
  1128. .done(function (result) {
  1129. for (var i = 0; i < result.length; i++) {
  1130. for (var j = 0; j < HDDDataSource.length; j++) {
  1131. if (HDDDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  1132. HDDDataSource[j].value = HDDDataSource[j].value + (HDDStandard - parseFloat(result[i].DailyValue.toString()));
  1133. }
  1134. }
  1135. for (var j = 0; j < CDDDataSource.length; j++) {
  1136. if (CDDDataSource[j].month.toString() == (result[i].CreatedDateTime.getMonth() + 1).toString()) {
  1137. CDDDataSource[j].value = CDDDataSource[j].value + (parseFloat(result[i].DailyValue.toString()) - CDDStandard);
  1138. }
  1139. }
  1140. }
  1141. for (var j = 0; j < HDDDataSource.length; j++) {
  1142. if (HDDDataSource[j].value == null) {
  1143. HDDDataSource[j].value = null;
  1144. } else {
  1145. HDDDataSource[j].value = HDDDataSource[j].value / temperatureFormula.length;
  1146. }
  1147. }
  1148. for (var j = 0; j < CDDDataSource.length; j++) {
  1149. if (CDDDataSource[j].value == null) {
  1150. CDDDataSource[j].value = null;
  1151. } else {
  1152. CDDDataSource[j].value = CDDDataSource[j].value / temperatureFormula.length;
  1153. }
  1154. }
  1155. })
  1156. .fail(function (error) {
  1157. utils.toast.show(error);
  1158. });
  1159. }
  1160. }
  1161. function UpdatePeopleIncreseRentalRate() {
  1162. var changeIndex = 0;
  1163. for (var i = 0; i < monthInputArray.length; i++) {
  1164. var inputValue = $("#textBox" + (i + 1).toString()).dxTextBox("instance").option('value');
  1165. if (monthInputArray[i].value.toString() != inputValue.toString()) {
  1166. changeIndex = i + 1;
  1167. break;
  1168. }
  1169. }
  1170. if (changeIndex == 0) {
  1171. visiblePopup(false);
  1172. return;
  1173. }
  1174. for (var i = changeIndex; i <= monthInputArray.length; i++) {
  1175. $("#textBox" + i.toString()).dxTextBox("instance").option('value', $("#textBox" + changeIndex.toString()).dxTextBox("instance").option('value'));
  1176. }
  1177. var selectFactor = $("#factorSelect").dxSelectBox("instance").option('value');
  1178. if (selectFactor == 0) {
  1179. var store = new DevExpress.data.ODataStore({
  1180. url: endpointSelector + "/BemsPeopleIncrease",
  1181. key: ["Date", "SiteId"],
  1182. keyType: { Date: "String", SiteId: "Int32" }
  1183. });
  1184. if (peopleIncreaseYear.toString() != new Date().getFullYear().toString()) {
  1185. store.insert({
  1186. Date: new Date().getFullYear().toString(),
  1187. SiteId: SITEID,
  1188. m1: $("#textBox1").dxTextBox("instance").option('value').toString(),
  1189. m2: $("#textBox2").dxTextBox("instance").option('value').toString(),
  1190. m3: $("#textBox3").dxTextBox("instance").option('value').toString(),
  1191. m4: $("#textBox4").dxTextBox("instance").option('value').toString(),
  1192. m5: $("#textBox5").dxTextBox("instance").option('value').toString(),
  1193. m6: $("#textBox6").dxTextBox("instance").option('value').toString(),
  1194. m7: $("#textBox7").dxTextBox("instance").option('value').toString(),
  1195. m8: $("#textBox8").dxTextBox("instance").option('value').toString(),
  1196. m9: $("#textBox9").dxTextBox("instance").option('value').toString(),
  1197. m10: $("#textBox10").dxTextBox("instance").option('value').toString(),
  1198. m11: $("#textBox11").dxTextBox("instance").option('value').toString(),
  1199. m12: $("#textBox12").dxTextBox("instance").option('value').toString()
  1200. }).done(function (key, result) {
  1201. peopleIncrease[0].value = parseFloat($("#textBox1").dxTextBox("instance").option('value').toString());
  1202. peopleIncrease[1].value = parseFloat($("#textBox2").dxTextBox("instance").option('value').toString());
  1203. peopleIncrease[2].value = parseFloat($("#textBox3").dxTextBox("instance").option('value').toString());
  1204. peopleIncrease[3].value = parseFloat($("#textBox4").dxTextBox("instance").option('value').toString());
  1205. peopleIncrease[4].value = parseFloat($("#textBox5").dxTextBox("instance").option('value').toString());
  1206. peopleIncrease[5].value = parseFloat($("#textBox6").dxTextBox("instance").option('value').toString());
  1207. peopleIncrease[6].value = parseFloat($("#textBox7").dxTextBox("instance").option('value').toString());
  1208. peopleIncrease[7].value = parseFloat($("#textBox8").dxTextBox("instance").option('value').toString());
  1209. peopleIncrease[8].value = parseFloat($("#textBox9").dxTextBox("instance").option('value').toString());
  1210. peopleIncrease[9].value = parseFloat($("#textBox10").dxTextBox("instance").option('value').toString());
  1211. peopleIncrease[10].value = parseFloat($("#textBox11").dxTextBox("instance").option('value').toString());
  1212. peopleIncrease[11].value = parseFloat($("#textBox12").dxTextBox("instance").option('value').toString());
  1213. for (var i = 0; i < chartDataSource.length; i++) {
  1214. chartDataSource[i].factor = peopleIncrease[i].value;
  1215. }
  1216. $("#compareChart").dxChart("instance").option('dataSource', chartDataSource);
  1217. visiblePopup(false);
  1218. })
  1219. .fail(function (error) {
  1220. utils.toast.show(error);
  1221. });
  1222. } else {
  1223. store.update({ Date: peopleIncreaseYear, SiteId: SITEID },
  1224. {
  1225. m1: $("#textBox1").dxTextBox("instance").option('value').toString(),
  1226. m2: $("#textBox2").dxTextBox("instance").option('value').toString(),
  1227. m3: $("#textBox3").dxTextBox("instance").option('value').toString(),
  1228. m4: $("#textBox4").dxTextBox("instance").option('value').toString(),
  1229. m5: $("#textBox5").dxTextBox("instance").option('value').toString(),
  1230. m6: $("#textBox6").dxTextBox("instance").option('value').toString(),
  1231. m7: $("#textBox7").dxTextBox("instance").option('value').toString(),
  1232. m8: $("#textBox8").dxTextBox("instance").option('value').toString(),
  1233. m9: $("#textBox9").dxTextBox("instance").option('value').toString(),
  1234. m10: $("#textBox10").dxTextBox("instance").option('value').toString(),
  1235. m11: $("#textBox11").dxTextBox("instance").option('value').toString(),
  1236. m12: $("#textBox12").dxTextBox("instance").option('value').toString(),
  1237. })
  1238. .done(function (key, result) {
  1239. peopleIncrease[0].value = parseFloat($("#textBox1").dxTextBox("instance").option('value').toString());
  1240. peopleIncrease[1].value = parseFloat($("#textBox2").dxTextBox("instance").option('value').toString());
  1241. peopleIncrease[2].value = parseFloat($("#textBox3").dxTextBox("instance").option('value').toString());
  1242. peopleIncrease[3].value = parseFloat($("#textBox4").dxTextBox("instance").option('value').toString());
  1243. peopleIncrease[4].value = parseFloat($("#textBox5").dxTextBox("instance").option('value').toString());
  1244. peopleIncrease[5].value = parseFloat($("#textBox6").dxTextBox("instance").option('value').toString());
  1245. peopleIncrease[6].value = parseFloat($("#textBox7").dxTextBox("instance").option('value').toString());
  1246. peopleIncrease[7].value = parseFloat($("#textBox8").dxTextBox("instance").option('value').toString());
  1247. peopleIncrease[8].value = parseFloat($("#textBox9").dxTextBox("instance").option('value').toString());
  1248. peopleIncrease[9].value = parseFloat($("#textBox10").dxTextBox("instance").option('value').toString());
  1249. peopleIncrease[10].value = parseFloat($("#textBox11").dxTextBox("instance").option('value').toString());
  1250. peopleIncrease[11].value = parseFloat($("#textBox12").dxTextBox("instance").option('value').toString());
  1251. for (var i = 0; i < chartDataSource.length; i++) {
  1252. chartDataSource[i].factor = peopleIncrease[i].value;
  1253. }
  1254. $("#compareChart").dxChart("instance").option('dataSource', chartDataSource);
  1255. visiblePopup(false);
  1256. })
  1257. .fail(function (error) {
  1258. utils.toast.show(error);
  1259. });
  1260. }
  1261. } else {
  1262. var store = new DevExpress.data.ODataStore({
  1263. url: endpointSelector + "/BemsRentalRate",
  1264. key: ["Date", "SiteId"],
  1265. keyType: { Date: "String", SiteId: "Int32" }
  1266. });
  1267. if (rentalRateYear.toString() != new Date().getFullYear().toString()) {
  1268. store.insert({
  1269. Date: new Date().getFullYear().toString(),
  1270. SiteId: SITEID,
  1271. m1: $("#textBox1").dxTextBox("instance").option('value').toString(),
  1272. m2: $("#textBox2").dxTextBox("instance").option('value').toString(),
  1273. m3: $("#textBox3").dxTextBox("instance").option('value').toString(),
  1274. m4: $("#textBox4").dxTextBox("instance").option('value').toString(),
  1275. m5: $("#textBox5").dxTextBox("instance").option('value').toString(),
  1276. m6: $("#textBox6").dxTextBox("instance").option('value').toString(),
  1277. m7: $("#textBox7").dxTextBox("instance").option('value').toString(),
  1278. m8: $("#textBox8").dxTextBox("instance").option('value').toString(),
  1279. m9: $("#textBox9").dxTextBox("instance").option('value').toString(),
  1280. m10: $("#textBox10").dxTextBox("instance").option('value').toString(),
  1281. m11: $("#textBox11").dxTextBox("instance").option('value').toString(),
  1282. m12: $("#textBox12").dxTextBox("instance").option('value').toString()
  1283. }).done(function (key, result) {
  1284. rentalRate[0].value = parseFloat($("#textBox1").dxTextBox("instance").option('value').toString());
  1285. rentalRate[1].value = parseFloat($("#textBox2").dxTextBox("instance").option('value').toString());
  1286. rentalRate[2].value = parseFloat($("#textBox3").dxTextBox("instance").option('value').toString());
  1287. rentalRate[3].value = parseFloat($("#textBox4").dxTextBox("instance").option('value').toString());
  1288. rentalRate[4].value = parseFloat($("#textBox5").dxTextBox("instance").option('value').toString());
  1289. rentalRate[5].value = parseFloat($("#textBox6").dxTextBox("instance").option('value').toString());
  1290. rentalRate[6].value = parseFloat($("#textBox7").dxTextBox("instance").option('value').toString());
  1291. rentalRate[7].value = parseFloat($("#textBox8").dxTextBox("instance").option('value').toString());
  1292. rentalRate[8].value = parseFloat($("#textBox9").dxTextBox("instance").option('value').toString());
  1293. rentalRate[9].value = parseFloat($("#textBox10").dxTextBox("instance").option('value').toString());
  1294. rentalRate[10].value = parseFloat($("#textBox11").dxTextBox("instance").option('value').toString());
  1295. rentalRate[11].value = parseFloat($("#textBox12").dxTextBox("instance").option('value').toString());
  1296. for (var i = 0; i < chartDataSource.length; i++) {
  1297. chartDataSource[i].factor = rentalRate[i].value;
  1298. }
  1299. $("#compareChart").dxChart("instance").option('dataSource', chartDataSource);
  1300. visiblePopup(false);
  1301. })
  1302. .fail(function (error) {
  1303. utils.toast.show(error);
  1304. });
  1305. } else {
  1306. store.update({ Date: rentalRateYear, SiteId: SITEID },
  1307. {
  1308. m1: $("#textBox1").dxTextBox("instance").option('value').toString(),
  1309. m2: $("#textBox2").dxTextBox("instance").option('value').toString(),
  1310. m3: $("#textBox3").dxTextBox("instance").option('value').toString(),
  1311. m4: $("#textBox4").dxTextBox("instance").option('value').toString(),
  1312. m5: $("#textBox5").dxTextBox("instance").option('value').toString(),
  1313. m6: $("#textBox6").dxTextBox("instance").option('value').toString(),
  1314. m7: $("#textBox7").dxTextBox("instance").option('value').toString(),
  1315. m8: $("#textBox8").dxTextBox("instance").option('value').toString(),
  1316. m9: $("#textBox9").dxTextBox("instance").option('value').toString(),
  1317. m10: $("#textBox10").dxTextBox("instance").option('value').toString(),
  1318. m11: $("#textBox11").dxTextBox("instance").option('value').toString(),
  1319. m12: $("#textBox12").dxTextBox("instance").option('value').toString(),
  1320. })
  1321. .done(function (key, result) {
  1322. rentalRate[0].value = parseFloat($("#textBox1").dxTextBox("instance").option('value').toString());
  1323. rentalRate[1].value = parseFloat($("#textBox2").dxTextBox("instance").option('value').toString());
  1324. rentalRate[2].value = parseFloat($("#textBox3").dxTextBox("instance").option('value').toString());
  1325. rentalRate[3].value = parseFloat($("#textBox4").dxTextBox("instance").option('value').toString());
  1326. rentalRate[4].value = parseFloat($("#textBox5").dxTextBox("instance").option('value').toString());
  1327. rentalRate[5].value = parseFloat($("#textBox6").dxTextBox("instance").option('value').toString());
  1328. rentalRate[6].value = parseFloat($("#textBox7").dxTextBox("instance").option('value').toString());
  1329. rentalRate[7].value = parseFloat($("#textBox8").dxTextBox("instance").option('value').toString());
  1330. rentalRate[8].value = parseFloat($("#textBox9").dxTextBox("instance").option('value').toString());
  1331. rentalRate[9].value = parseFloat($("#textBox10").dxTextBox("instance").option('value').toString());
  1332. rentalRate[10].value = parseFloat($("#textBox11").dxTextBox("instance").option('value').toString());
  1333. rentalRate[11].value = parseFloat($("#textBox12").dxTextBox("instance").option('value').toString());
  1334. for (var i = 0; i < chartDataSource.length; i++) {
  1335. chartDataSource[i].factor = rentalRate[i].value;
  1336. }
  1337. $("#compareChart").dxChart("instance").option('dataSource', chartDataSource);
  1338. visiblePopup(false);
  1339. })
  1340. .fail(function (error) {
  1341. utils.toast.show(error);
  1342. });
  1343. }
  1344. }
  1345. }
  1346. function handleViewShowing() {
  1347. facilityDataSource.filter([
  1348. eq('SiteId', SITEID),
  1349. 'and',
  1350. eq('FacilityTypeId', powerFacilityTypeId),
  1351. 'or',
  1352. eq('FacilityTypeId', gasFacilityTypeId)
  1353. ]);
  1354. facilityDataSource.load().done(function (facilities) {
  1355. if (_.isEmpty(facilities) === false) {
  1356. for (var i = 0; i < facilities.length; i++) {
  1357. if (facilities[i].FacilityTypeId() == powerFacilityTypeId) {
  1358. powerFacilityCode = facilities[i].FacilityCode();
  1359. }
  1360. else {
  1361. gasFacilityCode = facilities[i].FacilityCode();
  1362. }
  1363. }
  1364. }
  1365. });
  1366. GetTOEKWH();
  1367. GetSiteHDDCDDStandard();
  1368. GetSiteRentalRate();
  1369. GetSitePeopleIncrease();
  1370. GetEnergyData(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1371. GetEnergyData(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1372. }
  1373. // 2019.04.16 : 그리드 도표 작업 : 팝업창 추가 ~~~
  1374. function DataGridPopup_ButtonClick() {
  1375. // DevExpress.ui.notify("날짜가 일치하지 않는 데이타가 존재합니다", "fail", 1000);
  1376. var selectFactor = $("#factorSelect").dxSelectBox("instance").option('value');
  1377. // 팝업창 레이아웃 **********kgp
  1378. if (selectFactor == 4)
  1379. DataGridPopup_Visible2(true);
  1380. else if (selectFactor == 2 || selectFactor == 3)
  1381. DataGridPopup_Visible1(true);
  1382. else
  1383. DataGridPopup_Visible(true);
  1384. }
  1385. // 도표를 선택하면 함수호출
  1386. function handlePopupShown() {
  1387. var today = new Date();
  1388. var TodayMonth = today.getMonth();
  1389. var TodayYear = today.getFullYear();
  1390. var selectDate = $("#standardDatePicker").dxDateBox("instance").option('value');
  1391. var selectedYear = selectDate.getFullYear();
  1392. var selectFactor = $("#factorSelect").dxSelectBox("instance").option('value');
  1393. if (selectFactor == 4) {
  1394. dataArrayresult2 = chartDataSourceHDDCDD.slice();
  1395. if (selectedYear == TodayYear)
  1396. dataArrayresult2.splice(TodayMonth, 12 - TodayMonth); // 불필요 데이터 삭제
  1397. }
  1398. else if (selectFactor == 2 || selectFactor == 3) {
  1399. dataArrayresult1 = chartDataSource.slice();
  1400. if (selectedYear == TodayYear)
  1401. dataArrayresult1.splice(TodayMonth, 12 - TodayMonth); // 불필요 데이터 삭제
  1402. }
  1403. else {
  1404. dataArrayresult = chartDataSource.slice();
  1405. if (selectedYear == TodayYear)
  1406. dataArrayresult.splice(TodayMonth, 12 - TodayMonth); // 불필요 데이터 삭제
  1407. }
  1408. // 컬럼명 업데이트
  1409. var ColumnCaptionName = "";
  1410. if (selectFactor == 0) {
  1411. ColumnCaptionName = "재실 인원(명/월)";
  1412. viewModel.EnergyUsageFactorOptions.columns[2].caption = ColumnCaptionName;
  1413. $("#EnergyUsageFactor_Container").dxDataGrid("instance").option("dataSource", dataArrayresult);
  1414. DataGridPopup_Visible(true);
  1415. }
  1416. else if (selectFactor == 1) {
  1417. ColumnCaptionName = "임대율(%/월)";
  1418. viewModel.EnergyUsageFactorOptions.columns[2].caption = ColumnCaptionName;
  1419. $("#EnergyUsageFactor_Container").dxDataGrid("instance").option("dataSource", dataArrayresult);
  1420. DataGridPopup_Visible(true);
  1421. }
  1422. else if (selectFactor == 2) {
  1423. ColumnCaptionName = "냉방도일(월)";
  1424. viewModel.EnergyUsageFactorOptions1.columns[2].caption = ColumnCaptionName;
  1425. $("#EnergyUsageFactor_Container1").dxDataGrid("instance").option("dataSource", dataArrayresult1);
  1426. DataGridPopup_Visible1(true);
  1427. }
  1428. else if (selectFactor == 3) {
  1429. ColumnCaptionName = "난방도일(월)";
  1430. viewModel.EnergyUsageFactorOptions1.columns[2].caption = ColumnCaptionName;
  1431. $("#EnergyUsageFactor_Container1").dxDataGrid("instance").option("dataSource", dataArrayresult1);
  1432. DataGridPopup_Visible1(true);
  1433. }
  1434. else if (selectFactor == 4) {
  1435. viewModel.EnergyUsageFactorOptions2.columns[2].caption = "냉방도일(월)";
  1436. viewModel.EnergyUsageFactorOptions2.columns[3].caption = "난방도일(월)";
  1437. $("#EnergyUsageFactor_Container2").dxDataGrid("instance").option("dataSource", dataArrayresult2);
  1438. DataGridPopup_Visible2(true);
  1439. }
  1440. }
  1441. // ~~~ 2019.04.16 : 그리드 도표 작업 : 팝업창 추가
  1442. function handleViewShown() {
  1443. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1444. setTimeout(function () {
  1445. SetUseFactorSelect();
  1446. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1447. }, 500);
  1448. visiblePopup(false);
  1449. }
  1450. var searchViewOptions = {
  1451. };
  1452. function handleSearchInSearchView() {
  1453. }
  1454. var viewModel = $.extend(BWA.CommonView.create(params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null, handleSearchInSearchView),
  1455. {
  1456. viewShowing: handleViewShowing,
  1457. factorSelect: {
  1458. onSelectionChanged: function () {
  1459. var selectFactor = $("#factorSelect").dxSelectBox("instance").option('value');
  1460. if (selectFactor == 0) {
  1461. $("#insertBtn").show();
  1462. $("#textHDD").hide();
  1463. $("#inputHDD").hide();
  1464. $("#textCDD").hide();
  1465. $("#inputCDD").hide();
  1466. GetSitePeopleIncreaseHistory();
  1467. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1468. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1469. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1470. setTimeout(function () {
  1471. SetChart();
  1472. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1473. }, 500);
  1474. } else if (selectFactor == 1) {
  1475. $("#insertBtn").show();
  1476. $("#textHDD").hide();
  1477. $("#inputHDD").hide();
  1478. $("#textCDD").hide();
  1479. $("#inputCDD").hide();
  1480. GetSiteRentalRateHistory();
  1481. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1482. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1483. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1484. setTimeout(function () {
  1485. SetChart();
  1486. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1487. }, 500);
  1488. } else if (selectFactor == 2) {
  1489. $("#insertBtn").hide();
  1490. $("#textCDD").show();
  1491. $("#inputCDD").show();
  1492. $("#textHDD").hide();
  1493. $("#inputHDD").hide();
  1494. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1495. GetHDDCDDHistory();
  1496. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1497. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1498. setTimeout(function () {
  1499. SetChart();
  1500. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1501. }, 500);
  1502. } else if (selectFactor == 3) {
  1503. $("#insertBtn").hide();
  1504. $("#textCDD").hide();
  1505. $("#inputCDD").hide();
  1506. $("#textHDD").show();
  1507. $("#inputHDD").show();
  1508. GetHDDCDDHistory();
  1509. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1510. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1511. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1512. setTimeout(function () {
  1513. SetChart();
  1514. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1515. }, 500);
  1516. } else if (selectFactor == 4) {
  1517. $("#insertBtn").hide();
  1518. $("#textHDD").show();
  1519. $("#inputHDD").show();
  1520. $("#textCDD").show();
  1521. $("#inputCDD").show();
  1522. GetHDDCDDHistory();
  1523. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1524. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1525. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1526. setTimeout(function () {
  1527. SetChart();
  1528. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1529. }, 500);
  1530. } else {
  1531. utils.toast.show("소비 요인이 선택되지 않았습니다.");
  1532. }
  1533. }
  1534. },
  1535. compareChart: {
  1536. size: {
  1537. height: 650
  1538. },
  1539. commonSeriesSettings: {
  1540. argumentField: "month",
  1541. type: "line"
  1542. },
  1543. series: ko.observable([
  1544. { valueField: "use", name: "에너지 사용량", color: '#5F8B95' },
  1545. { valueField: "factor", name: "재실 인원", color: '#FF5E00', axis: "재실 인원" }
  1546. ]),
  1547. legend: {
  1548. verticalAlignment: "top",
  1549. horizontalAlignment: "center",
  1550. position: "outside",
  1551. border: { visible: false }
  1552. },
  1553. argumentAxis: ko.observable({
  1554. visible: true,
  1555. label: {
  1556. customizeText: function () {
  1557. return this.value + '월';
  1558. }
  1559. },
  1560. min: 1,
  1561. max: 12,
  1562. valueType: 'numeric',
  1563. tickInterval: 1
  1564. }),
  1565. valueAxis: [{
  1566. name: "에너지 사용량",
  1567. position: "left",
  1568. },
  1569. {
  1570. name: "재실 인원",
  1571. position: "right",
  1572. }
  1573. ],
  1574. "export": {
  1575. enabled: true
  1576. },
  1577. tooltip: {
  1578. enabled: true,
  1579. customizeTooltip: function (point) {
  1580. return {
  1581. text: numberWithCommas(parseFloat(point.value.toString()).toFixed(2))
  1582. };
  1583. }
  1584. }
  1585. },
  1586. InsertButtonClicked: function () {
  1587. visiblePopup(true);
  1588. },
  1589. textBox1: {},
  1590. textBox2: {},
  1591. textBox3: {},
  1592. textBox4: {},
  1593. textBox5: {},
  1594. textBox6: {},
  1595. textBox7: {},
  1596. textBox8: {},
  1597. textBox9: {},
  1598. textBox10: {},
  1599. textBox11: {},
  1600. textBox12: {},
  1601. AcceptButtonClicked: function () {
  1602. UpdatePeopleIncreseRentalRate();
  1603. },
  1604. inputHDD: {
  1605. readOnly: true
  1606. },
  1607. inputCDD: {
  1608. readOnly: true
  1609. },
  1610. loadIndicator: {
  1611. visible: false
  1612. },
  1613. standardDatePicker: {
  1614. pickerType: "calendar",
  1615. value: new Date(),
  1616. formatString: "yyyy년",
  1617. maxZoomLevel: "decade",
  1618. width: "8%",
  1619. onValueChanged: function () {
  1620. var selectFactor = $("#factorSelect").dxSelectBox("instance").option('value');
  1621. if (selectFactor == 0) {
  1622. GetSitePeopleIncreaseHistory();
  1623. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1624. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1625. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1626. setTimeout(function () {
  1627. SetChart();
  1628. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1629. }, 500);
  1630. } else if (selectFactor == 1) {
  1631. GetSiteRentalRateHistory();
  1632. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1633. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1634. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1635. setTimeout(function () {
  1636. SetChart();
  1637. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1638. }, 500);
  1639. } else if (selectFactor == 2) {
  1640. GetHDDCDDHistory();
  1641. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1642. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1643. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1644. setTimeout(function () {
  1645. SetChart();
  1646. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1647. }, 500);
  1648. } else if (selectFactor == 3) {
  1649. GetHDDCDDHistory();
  1650. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1651. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1652. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1653. setTimeout(function () {
  1654. SetChart();
  1655. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1656. }, 500);
  1657. } else if (selectFactor == 4) {
  1658. GetHDDCDDHistory();
  1659. GetEnergyDataHistory(powerFuelTypeId, powerFacilityTypeId, powerFacilityCode, powerFormulaId);
  1660. GetEnergyDataHistory(gasFuelTypeId, gasFacilityTypeId, gasFacilityCode, gasFormulaId);
  1661. $("#loadIndicator").dxLoadIndicator("instance").option('visible', true);
  1662. setTimeout(function () {
  1663. SetChart();
  1664. $("#loadIndicator").dxLoadIndicator("instance").option('visible', false);
  1665. }, 500);
  1666. } else {
  1667. utils.toast.show("소비 요인이 선택되지 않았습니다.");
  1668. }
  1669. }
  1670. },
  1671. // 2019.04.16 : 그리드 도표 작업 : 팝업창 추가
  1672. EnergyUsageFactorPopup_ButtonClicked: DataGridPopup_ButtonClick
  1673. });
  1674. // 2019.04.16 : 그리드 도표 작업 : 팝업창 추가 ~~~
  1675. // 그래프 도표 팝업창
  1676. viewModel.EnergyUsageFactorPopupOptions = {
  1677. width: '480px',
  1678. height: '750px', // cyim 2017.05.30 : 테스트 결과 Devextreme 버그임. px 로 지정하면 초기 출력시 정확하게 가운데에 있지만, auto 설정시 화면아래에 위치하게 됨
  1679. contentTemplate: "content",
  1680. showTitle: true,
  1681. title: "도표",
  1682. visible: DataGridPopup_Visible,
  1683. dragEnabled: true,
  1684. closeOnOutsideClick: true,
  1685. shownAction: handlePopupShown,
  1686. animation: window.utils.popup.createAnimation()
  1687. };
  1688. viewModel.EnergyUsageFactorPopupOptions1 = {
  1689. width: '480px',
  1690. height: '750px', // cyim 2017.05.30 : 테스트 결과 Devextreme 버그임. px 로 지정하면 초기 출력시 정확하게 가운데에 있지만, auto 설정시 화면아래에 위치하게 됨
  1691. contentTemplate: "content",
  1692. showTitle: true,
  1693. title: "도표",
  1694. visible: DataGridPopup_Visible1,
  1695. dragEnabled: true,
  1696. closeOnOutsideClick: true,
  1697. shownAction: handlePopupShown,
  1698. animation: window.utils.popup.createAnimation()
  1699. };
  1700. viewModel.EnergyUsageFactorPopupOptions2 = {
  1701. width: '480px',
  1702. height: '750px', // cyim 2017.05.30 : 테스트 결과 Devextreme 버그임. px 로 지정하면 초기 출력시 정확하게 가운데에 있지만, auto 설정시 화면아래에 위치하게 됨
  1703. contentTemplate: "content",
  1704. showTitle: true,
  1705. title: "도표",
  1706. visible: DataGridPopup_Visible2,
  1707. dragEnabled: true,
  1708. closeOnOutsideClick: true,
  1709. shownAction: handlePopupShown,
  1710. animation: window.utils.popup.createAnimation()
  1711. };
  1712. // ~~~ 2019.04.16 : 그리드 도표 작업 : 팝업창 추가
  1713. viewModel.popupOptions = {
  1714. width: 350,
  1715. height: 548,
  1716. visible: visiblePopup,
  1717. dragEnabled: false,
  1718. shading: true,
  1719. showTitle: true,
  1720. title: "월별 자료 입력",
  1721. showCloseButton: true,
  1722. onShowing: function () {
  1723. },
  1724. onShown: function () {
  1725. var selectFactor = $("#factorSelect").dxSelectBox("instance").option('value');
  1726. if (selectFactor == 0) {
  1727. $("#textBox1").dxTextBox("instance").option('value', peopleIncrease[0].value.toString());
  1728. $("#textBox2").dxTextBox("instance").option('value', peopleIncrease[1].value.toString());
  1729. $("#textBox3").dxTextBox("instance").option('value', peopleIncrease[2].value.toString());
  1730. $("#textBox4").dxTextBox("instance").option('value', peopleIncrease[3].value.toString());
  1731. $("#textBox5").dxTextBox("instance").option('value', peopleIncrease[4].value.toString());
  1732. $("#textBox6").dxTextBox("instance").option('value', peopleIncrease[5].value.toString());
  1733. $("#textBox7").dxTextBox("instance").option('value', peopleIncrease[6].value.toString());
  1734. $("#textBox8").dxTextBox("instance").option('value', peopleIncrease[7].value.toString());
  1735. $("#textBox9").dxTextBox("instance").option('value', peopleIncrease[8].value.toString());
  1736. $("#textBox10").dxTextBox("instance").option('value', peopleIncrease[9].value.toString());
  1737. $("#textBox11").dxTextBox("instance").option('value', peopleIncrease[10].value.toString());
  1738. $("#textBox12").dxTextBox("instance").option('value', peopleIncrease[11].value.toString());
  1739. monthInputArray[0].value = parseFloat(peopleIncrease[0].value.toString());
  1740. monthInputArray[1].value = parseFloat(peopleIncrease[1].value.toString());
  1741. monthInputArray[2].value = parseFloat(peopleIncrease[2].value.toString());
  1742. monthInputArray[3].value = parseFloat(peopleIncrease[3].value.toString());
  1743. monthInputArray[4].value = parseFloat(peopleIncrease[4].value.toString());
  1744. monthInputArray[5].value = parseFloat(peopleIncrease[5].value.toString());
  1745. monthInputArray[6].value = parseFloat(peopleIncrease[6].value.toString());
  1746. monthInputArray[7].value = parseFloat(peopleIncrease[7].value.toString());
  1747. monthInputArray[8].value = parseFloat(peopleIncrease[8].value.toString());
  1748. monthInputArray[9].value = parseFloat(peopleIncrease[9].value.toString());
  1749. monthInputArray[10].value = parseFloat(peopleIncrease[10].value.toString());
  1750. monthInputArray[11].value = parseFloat(peopleIncrease[11].value.toString());
  1751. $("#label1").text("1월(명)");
  1752. $("#label2").text("2월(명)");
  1753. $("#label3").text("3월(명)");
  1754. $("#label4").text("4월(명)");
  1755. $("#label5").text("5월(명)");
  1756. $("#label6").text("6월(명)");
  1757. $("#label7").text("7월(명)");
  1758. $("#label8").text("8월(명)");
  1759. $("#label9").text("9월(명)");
  1760. $("#label10").text("10월(명)");
  1761. $("#label11").text("11월(명)");
  1762. $("#label12").text("12월(명)");
  1763. } else if (selectFactor == 1) {
  1764. $("#textBox1").dxTextBox("instance").option('value', rentalRate[0].value.toString());
  1765. $("#textBox2").dxTextBox("instance").option('value', rentalRate[1].value.toString());
  1766. $("#textBox3").dxTextBox("instance").option('value', rentalRate[2].value.toString());
  1767. $("#textBox4").dxTextBox("instance").option('value', rentalRate[3].value.toString());
  1768. $("#textBox5").dxTextBox("instance").option('value', rentalRate[4].value.toString());
  1769. $("#textBox6").dxTextBox("instance").option('value', rentalRate[5].value.toString());
  1770. $("#textBox7").dxTextBox("instance").option('value', rentalRate[6].value.toString());
  1771. $("#textBox8").dxTextBox("instance").option('value', rentalRate[7].value.toString());
  1772. $("#textBox9").dxTextBox("instance").option('value', rentalRate[8].value.toString());
  1773. $("#textBox10").dxTextBox("instance").option('value', rentalRate[9].value.toString());
  1774. $("#textBox11").dxTextBox("instance").option('value', rentalRate[10].value.toString());
  1775. $("#textBox12").dxTextBox("instance").option('value', rentalRate[11].value.toString());
  1776. monthInputArray[0].value = parseFloat(rentalRate[0].value.toString());
  1777. monthInputArray[1].value = parseFloat(rentalRate[1].value.toString());
  1778. monthInputArray[2].value = parseFloat(rentalRate[2].value.toString());
  1779. monthInputArray[3].value = parseFloat(rentalRate[3].value.toString());
  1780. monthInputArray[4].value = parseFloat(rentalRate[4].value.toString());
  1781. monthInputArray[5].value = parseFloat(rentalRate[5].value.toString());
  1782. monthInputArray[6].value = parseFloat(rentalRate[6].value.toString());
  1783. monthInputArray[7].value = parseFloat(rentalRate[7].value.toString());
  1784. monthInputArray[8].value = parseFloat(rentalRate[8].value.toString());
  1785. monthInputArray[9].value = parseFloat(rentalRate[9].value.toString());
  1786. monthInputArray[10].value = parseFloat(rentalRate[10].value.toString());
  1787. monthInputArray[11].value = parseFloat(rentalRate[11].value.toString());
  1788. $("#label1").text("1월(%)");
  1789. $("#label2").text("2월(%)");
  1790. $("#label3").text("3월(%)");
  1791. $("#label4").text("4월(%)");
  1792. $("#label5").text("5월(%)");
  1793. $("#label6").text("6월(%)");
  1794. $("#label7").text("7월(%)");
  1795. $("#label8").text("8월(%)");
  1796. $("#label9").text("9월(%)");
  1797. $("#label10").text("10월(%)");
  1798. $("#label11").text("11월(%)");
  1799. $("#label12").text("12월(%)");
  1800. } else {
  1801. utils.toast.show("소비 요인이 선택되지 않았습니다.");
  1802. }
  1803. },
  1804. onHidden: function () {
  1805. }
  1806. };
  1807. // 2019.04.16 : 그리드 도표 작업 : 팝업창 추가 ~~~
  1808. // 주석이 너무 없음. 나중에 변경 작업을 진행하는 누군가가 시간 소비를 하지 않기 위해...남김
  1809. // 시간 포맷은 그래프에 귀속해야 되므로 포맷은 변경하지 않는 것이 유리함
  1810. // 전기,가스,수도 와 같이 선택적으로 변경해야 된다면 아래와 같이 캡션은 고정하지 말것
  1811. viewModel.EnergyUsageFactorOptions = {
  1812. dataSource: dataArrayresult,
  1813. paging: { pageSize: 17 },
  1814. columns: [
  1815. { dataField: 'month', caption: "월", width: '20%', alignment: 'center', },// dataType: 'date', format: 'yyyy-MM-dd HH:mm' },
  1816. { dataField: 'use', caption: "에너지 사용량(kWh/월)", width: '46%', alignment: 'center', format: 'fixedPoint', precision: 2 },
  1817. { dataField: 'factor', width: '33%', alignment: 'center', format: 'fixedPoint', precision: 2 }
  1818. ],
  1819. // 엑셀 출력
  1820. "export": {
  1821. enabled: true,
  1822. fileName: '에너지 소비요인'
  1823. }
  1824. };
  1825. viewModel.EnergyUsageFactorOptions1 = {
  1826. dataSource: dataArrayresult1,
  1827. paging: { pageSize: 17 },
  1828. columns: [
  1829. { dataField: 'month', caption: "월", width: '20%', alignment: 'center', },// dataType: 'date', format: 'yyyy-MM-dd HH:mm' },
  1830. { dataField: 'use', caption: "에너지 사용량(kWh/월)", width: '46%', alignment: 'center', format: 'fixedPoint', precision: 2 },
  1831. { dataField: 'factor', width: '33%', alignment: 'center', format: 'fixedPoint', precision: 2 }
  1832. ],
  1833. // 엑셀 출력
  1834. "export": {
  1835. enabled: true,
  1836. fileName: '에너지 소비요인'
  1837. }
  1838. };
  1839. viewModel.EnergyUsageFactorOptions2 = {
  1840. dataSource: dataArrayresult2,
  1841. paging: { pageSize: 17 },
  1842. columns: [
  1843. { dataField: 'month', caption: "월", width: '15%', alignment: 'center', },// dataType: 'date', format: 'yyyy-MM-dd HH:mm' },
  1844. { dataField: 'use', caption: "에너지 사용량(kWh/월)", width: '35%', alignment: 'center', format: 'fixedPoint', precision: 2 },
  1845. { dataField: 'cdd', width: '25%', alignment: 'center', format: 'fixedPoint', precision: 2 },
  1846. { dataField: 'hdd', width: '25%', alignment: 'center', format: 'fixedPoint', precision: 2 }
  1847. ],
  1848. // 엑셀 출력
  1849. "export": {
  1850. enabled: true,
  1851. fileName: '에너지 소비요인 분석'
  1852. }
  1853. };
  1854. // ~~~ 2019.04.16 : 그리드 도표 작업 : 팝업창 추가
  1855. return viewModel;
  1856. };