b0e0e51b7a690466ddd8532ac10e02dfa5d8b0fb.svn-base 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481
  1. BemsWebApplication.SimulatorIceStorage = 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 BemsIceThermalStorageDataSource = BemsWebApplication.db.createDataSource('BemsIceThermalStorageSimulation');
  10. var timeBoxForSearch = BWA.SearchView.createDateTimeBox($G.TimeTypesForDayOnly);
  11. var visibleConfigPopup = ko.observable(false);
  12. var timer;
  13. var initialized = false;
  14. var initializedforPopUp = false;
  15. var iceThermalStorage_SimulationValueGet = new BWA.Chart.IceThermalStorage_SimulationValueGet(BWA.UserInfo.SiteId());
  16. var chart = BWA.Chart.Instance('chartIS', 'dxChart');
  17. // 그리드 도표 작업 : 팝업창 추가
  18. // 팝업창뷰 보이기 속성 제어용 변수 선언
  19. var DataGridPopup_Visible = ko.observable(false);
  20. // 그래프 출력 이후 엑셀출력을 위한 팝업창을 위해 임시 저장용 배열 선언
  21. var dataArrayresult = ko.observableArray();
  22. // 그리드 도표 작업 : 팝업창 추가
  23. var dataArrayforPopup = []; // 도표에 들어갈 변수
  24. var visibleHourGlassPopup = ko.observable(false);
  25. var visibleEditButton = ko.observable(true); // 수정 버튼 활성화 여부 플래그
  26. var hasnotModificationPermission = ko.observable(false); // 수정버튼 비활성화 플래그
  27. var isEditModeInPopup = ko.observable(false); // 저장버튼 활성화 플래그
  28. var isNotModifyMode = ko.observable(true); // 저장버튼 비활성화 플래그
  29. var visibleCancelButton = ko.observable(false); // 취소버튼 활성화 플래그
  30. var simulatoricestoragePopupToolbarItems = [
  31. { location: 'before', text: '사용자 시뮬레이터 변수 설정' },
  32. { location: 'after', widget: 'button', options: { text: $G('edit'), icon: 'edit', visible: visibleEditButton, disabled: hasnotModificationPermission, clickAction: handlePopupButtonEdit } },
  33. { location: 'after', widget: 'button', options: { text: $G('cancel'), icon: 'cancel', visible: visibleCancelButton, clickAction: handlePopupButtonCancel } },
  34. { location: 'after', widget: 'button', options: { text: $G('save'), icon: 'save', visible: isEditModeInPopup, disabled: isNotModifyMode, clickAction: handlePopupButtonSave } },
  35. { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', visible: true, disabled: false, clickAction: PopupButtonClose } }
  36. ];
  37. var CurrntRowStatusAsSave = 1; // 저장했을때 최종 row 인덱스 (취소, 닫기했을때 이전 최종 행 위치를 알기 위함)
  38. // 편집 중인 행과 활성화 여부 플래그
  39. var EditingFirstRow = ko.observable(true);
  40. var EditingSecondRow = ko.observable(false);
  41. var EditingThirdRow = ko.observable(false);
  42. var EditingFourthRow = ko.observable(false);
  43. var EditingFifthRow = ko.observable(false);
  44. var isSecondRow = ko.observable(false);
  45. var isThirdRow = ko.observable(false);
  46. var isFourthRow = ko.observable(false);
  47. var isFifthRow = ko.observable(false);
  48. //Initial Date는 지금 시점 이후부터 입력(initialDate와 finalDate는 기준 시작, 종료 일시)
  49. var initialDate = new Date();
  50. initialDate.setMinutes((parseInt(initialDate.getMinutes() / 15)) * 15);
  51. var finalDate = new Date();
  52. if (finalDate.getHours() < 21) {
  53. finalDate.setHours(0)
  54. finalDate.setMinutes(45);
  55. finalDate.setSeconds(0);
  56. finalDate = moment(finalDate).add(20, 'hours').toDate();
  57. }
  58. else {
  59. finalDate.setHours(0)
  60. finalDate.setMinutes(45);
  61. finalDate.setSeconds(0);
  62. finalDate = moment(finalDate).add(1, 'days').toDate();
  63. finalDate = moment(finalDate).add(20, 'hours').toDate();
  64. }
  65. // 행 추가, 제거시 기억할 변수 선언
  66. var initDate_prev = new Array();
  67. var finalDate_prev = new Array();
  68. var operationMode_prev = new Array();
  69. var ref1Status_prev = new Array();
  70. var ref2Status_prev = new Array();
  71. // 저장시 기억할 변수 선언 (~_asSave)
  72. var initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
  73. var finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
  74. var operationMode_asSave = new Array(null, null, null, null, null);
  75. var ref1Status_asSave = new Array(null, null, null, null, null);
  76. var ref2Status_asSave = new Array(null, null, null, null, null);
  77. var treeOperationMode = [
  78. {
  79. id: 0,
  80. text: "OFF",
  81. value: 0
  82. },
  83. {
  84. id: 1,
  85. text: "제빙운전",
  86. value: 10
  87. },
  88. {
  89. id: 2,
  90. text: "축단운전",
  91. value: 20
  92. },
  93. {
  94. id: 3,
  95. text: "병렬운전",
  96. value: 30
  97. },
  98. {
  99. id: 4,
  100. text: "냉단운전",
  101. value: 40
  102. }
  103. ];
  104. // 현재시점에 최종 수정 row 플래그
  105. function EditingRowArrange() {
  106. var Edit_idx = [false, false, false, false, false];
  107. var EnDis_idx = [false, false, false, false, false];
  108. Edit_idx[CurrntRowStatusAsSave - 1] = true;
  109. for (var i = 0; i < CurrntRowStatusAsSave; i++) {
  110. EnDis_idx[i] = true;
  111. }
  112. EditingFirstRow(Edit_idx[0]);
  113. EditingSecondRow(Edit_idx[1]);
  114. EditingThirdRow(Edit_idx[2]);
  115. EditingFourthRow(Edit_idx[3]);
  116. EditingFifthRow(Edit_idx[4]);
  117. isSecondRow(EnDis_idx[1]);
  118. isThirdRow(EnDis_idx[2]);
  119. isFourthRow(EnDis_idx[3]);
  120. isFifthRow(EnDis_idx[4]);
  121. }
  122. // 팝업뜰 때마다 호출 (수정모드 템플릿)
  123. function InitializedTemplate() {
  124. visibleEditButton(true);
  125. hasnotModificationPermission(false);
  126. isEditModeInPopup(false);
  127. isNotModifyMode(true);
  128. visibleCancelButton(false);
  129. EditingRowArrange(); // 현재시점에 최종 수정 row 플래그
  130. // 팝업뜰때는 수정모드가 아니므로 모두 disabled
  131. for (var i = 0; i < 5; i++) {
  132. EnableDisableRow(i + 1, true);
  133. }
  134. }
  135. //초기 데이터 initialize
  136. function InitializedData() {
  137. var initialDate_ = new Date();
  138. initialDate_.setMinutes((parseInt(initialDate_.getMinutes() / 15)) * 15); // 15분 단위 맞춰주기 위함
  139. initialDate_.setSeconds(0);
  140. var finalDate_ = new Date();
  141. if (finalDate_.getHours() < 21) {
  142. finalDate_.setHours(0)
  143. finalDate_.setMinutes(45);
  144. finalDate_.setSeconds(0);
  145. finalDate_ = moment(finalDate_).add(20, 'hours').toDate();
  146. }
  147. else {
  148. finalDate_.setHours(0)
  149. finalDate_.setMinutes(45);
  150. finalDate_.setSeconds(0);
  151. finalDate_ = moment(finalDate_).add(1, 'days').toDate();
  152. finalDate_ = moment(finalDate_).add(20, 'hours').toDate();
  153. }
  154. for (var i = 0; i < 5; i++) {
  155. BoxInitialize(i + 1, initialDate_, finalDate_);
  156. EnableDisableRow(i + 1, true); // 초기는 수정모드가 아니므로 모두 disabled
  157. }
  158. }
  159. // 수정 버튼 클릭시 호출 함수
  160. function handlePopupButtonEdit() {
  161. visibleEditButton(false);
  162. hasnotModificationPermission(true);
  163. isEditModeInPopup(true);
  164. isNotModifyMode(false);
  165. visibleCancelButton(true);
  166. EditingRowArrange(); // 현재시점에 최종 수정 row 플래그
  167. EnableDisableRow(CurrntRowStatusAsSave, false); // 현재시점에 최종 수정 row 활성화
  168. }
  169. // ~_prev 변수 입력
  170. function prevDataWrite(row_num) {
  171. $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initDate_prev[row_num - 1]);
  172. $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initDate_prev[row_num - 1]);
  173. $("#FinalDate" + (row_num).toString()).dxDateBox('instance').option('value', finalDate_prev[row_num - 1]);
  174. $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value', finalDate_prev[row_num - 1]);
  175. $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value', operationMode_prev[row_num - 1]);
  176. $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value', ref1Status_prev[row_num - 1]);
  177. $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value', ref2Status_prev[row_num - 1]);
  178. }
  179. function DeleteRow() {
  180. var now_ = new Date();
  181. var finalDate_ = new Date(now_.getFullYear(), now_.getMonth(), now_.getDate(), 20, 45, 0);
  182. if (now_.getHours() >= 21) {
  183. finalDate_ = moment(finalDate_).add(1, 'days').toDate();
  184. }
  185. if (EditingFirstRow() === true) {
  186. $("#FinalDate1").dxDateBox('instance').option('value', finalDate_);
  187. $("#FinalTime1").dxDateBox('instance').option('value', finalDate_);
  188. $("#OperationMode1").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
  189. $("#Ref1_Status1").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
  190. $("#Ref2_Status1").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
  191. }
  192. else if (EditingSecondRow() === true) {
  193. $("#FinalDate2").dxDateBox('instance').option('value', finalDate_);
  194. $("#FinalTime2").dxDateBox('instance').option('value', finalDate_);
  195. $("#OperationMode2").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
  196. $("#Ref1_Status2").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
  197. $("#Ref2_Status2").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
  198. EnableDisableRow(1, false);
  199. EditingFirstRow(true);
  200. EditingSecondRow(false);
  201. isSecondRow(false);
  202. prevDataWrite(1); // 행 삭제시 이전 행의 변수 초기화로 다시 쓰기
  203. }
  204. else if (EditingThirdRow() === true) {
  205. $("#FinalDate3").dxDateBox('instance').option('value', finalDate_);
  206. $("#FinalTime3").dxDateBox('instance').option('value', finalDate_);
  207. $("#OperationMode3").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
  208. $("#Ref1_Status3").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
  209. $("#Ref2_Status3").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
  210. EnableDisableRow(2, false);
  211. EditingSecondRow(true);
  212. EditingThirdRow(false);
  213. isThirdRow(false);
  214. prevDataWrite(2); // 행 삭제시 이전 행의 변수 초기화로 다시 쓰기
  215. }
  216. else if (EditingFourthRow() === true) {
  217. $("#FinalDate4").dxDateBox('instance').option('value', finalDate_);
  218. $("#FinalTime4").dxDateBox('instance').option('value', finalDate_);
  219. $("#OperationMode4").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
  220. $("#Ref1_Status4").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
  221. $("#Ref2_Status4").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
  222. EnableDisableRow(3, false);
  223. EditingThirdRow(true);
  224. EditingFourthRow(false);
  225. isFourthRow(false);
  226. prevDataWrite(3); // 행 삭제시 이전 행의 변수 초기화로 다시 쓰기
  227. }
  228. else if (EditingFifthRow() === true) {
  229. $("#FinalDate5").dxDateBox('instance').option('value', finalDate_);
  230. $("#FinalTime5").dxDateBox('instance').option('value', finalDate_);
  231. $("#OperationMode5").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
  232. $("#Ref1_Status5").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
  233. $("#Ref2_Status5").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
  234. EnableDisableRow(4, false);
  235. EditingFourthRow(true);
  236. EditingFifthRow(false);
  237. isFifthRow(false);
  238. prevDataWrite(4); // 행 삭제시 이전 행의 변수 초기화로 다시 쓰기
  239. }
  240. }
  241. function FilledRow(row_num) {
  242. $("#InitialDate" + row_num.toString()).dxDateBox('instance').option('value', initDate_asSave[row_num - 1]);
  243. $("#InitialTime" + row_num.toString()).dxDateBox('instance').option('value', initDate_asSave[row_num - 1]);
  244. $("#FinalDate" + row_num.toString()).dxDateBox('instance').option('value', finalDate_asSave[row_num - 1]);
  245. $("#FinalTime" + row_num.toString()).dxDateBox('instance').option('value', finalDate_asSave[row_num - 1]);
  246. $("#OperationMode" + row_num.toString()).dxSelectBox('instance').option('value', operationMode_asSave[row_num - 1]);
  247. $("#Ref1_Status" + row_num.toString()).dxSwitch('instance').option('value', ref1Status_asSave[row_num - 1]);
  248. $("#Ref2_Status" + row_num.toString()).dxSwitch('instance').option('value', ref2Status_asSave[row_num - 1]);
  249. }
  250. // 취소 버튼 클릭시 호출 함수
  251. function handlePopupButtonCancel() {
  252. // 전체 열에 대해서 모두 삭제하고 저장된 열들만 다시 채워준다
  253. for (var i = 0; i < 5; i++) {
  254. DeleteRow();
  255. }
  256. for (var i = 0; i < 5; i++) {
  257. if (operationMode_asSave[i] != null) {
  258. FilledRow(i + 1);
  259. }
  260. }
  261. visibleEditButton(true);
  262. hasnotModificationPermission(false);
  263. isEditModeInPopup(false);
  264. isNotModifyMode(true);
  265. visibleCancelButton(false);
  266. EditingRowArrange(); // 현재시점에 최종 수정 row 플래그
  267. for (var i = 0; i < 5; i++) {
  268. EnableDisableRow(i + 1, true);
  269. }
  270. }
  271. // 데이터 DB 입력 함수
  272. function insert(postData) {
  273. BemsIceThermalStorageDataSource.filter([
  274. ["SiteId", "=", BWA.UserInfo.SiteId()],
  275. "and",
  276. ["FacilityCode", "=", postData.FacilityCode],
  277. "and",
  278. ["PropertyId", "=", postData.PropertyId],
  279. "and",
  280. ["SimulationCase", "=", postData.SimulationCase],
  281. "and",
  282. ["TargetDateTime", "=", postData.TargetDateTime]
  283. ]);
  284. //BemsIceThermalStorageDataSource.sort({ getter: "TargetDateTime", desc: true });
  285. BemsIceThermalStorageDataSource.load()
  286. .done(function (result) {
  287. var store = new DevExpress.data.ODataStore({
  288. url: endpointSelector + "/BemsIceThermalStorageSimulation",
  289. key: ["SiteId", "FacilityCode", "PropertyId", "CreatedDateTime", "TargetDateTime", "SimulationCase"],
  290. keyType: {
  291. SiteId: "Int32", FacilityCode: "Int32", PropertyId: "Int32", CreatedDateTime: "DateTime", TargetDateTime: "DateTime", SimulationCase: "Int32"
  292. }
  293. });
  294. if (result.length != 0) {
  295. var removeData = {
  296. SiteId: result[0].SiteId(),
  297. FacilityTypeId: result[0].FacilityTypeId(),
  298. FacilityCode: result[0].FacilityCode(),
  299. PropertyId: result[0].PropertyId(),
  300. CreatedDateTime: new Date(result[0].CreatedDateTime()),
  301. TargetDateTime: new Date(result[0].TargetDateTime()),
  302. SimulationValue: result[0].SimulationValue(),
  303. SimulationCase: result[0].SimulationCase()
  304. };
  305. store.remove(removeData).done(function (values, key) {
  306. store.insert(postData).done(function (key, result) {
  307. //utils.toast.show($G('successDatabaseInsertionMsg'));
  308. visibleConfigPopup(false);
  309. })
  310. .fail(function (error) {
  311. utils.toast.show(error, 'error');
  312. });
  313. })
  314. .fail(function (error) {
  315. utils.toast.show(error, 'error');
  316. });
  317. }
  318. else {
  319. store.insert(postData).done(function (key, result) {
  320. //utils.toast.show($G('successDatabaseInsertionMsg'));
  321. visibleConfigPopup(false);
  322. })
  323. .fail(function (error) {
  324. utils.toast.show(error, 'error');
  325. });
  326. }
  327. });
  328. }
  329. function DataArrange(initialDate_, finalDate_, facilityTypeId, facilityCode, propertyId, value, simulationCase) {
  330. var now_date = new Date();
  331. var comparedDate = new Date(initialDate_.getFullYear(), initialDate_.getMonth(), initialDate_.getDate(), initialDate_.getHours(), initialDate_.getMinutes(), 0);
  332. while (comparedDate <= finalDate_) {
  333. //insert
  334. var nowDate_tmp = new Date(now_date.getFullYear(), now_date.getMonth(), now_date.getDate(), now_date.getHours(), now_date.getMinutes(), now_date.getSeconds());
  335. var tmpDate = new Date(comparedDate.getFullYear(), comparedDate.getMonth(), comparedDate.getDate(), comparedDate.getHours(), comparedDate.getMinutes(), 0);
  336. var postViewModel = new BemsWebApplication.BemsIceThermalStorageSimulationViewModel();
  337. postViewModel.SiteId(BWA.UserInfo.SiteId());
  338. postViewModel.FacilityTypeId(facilityTypeId);
  339. postViewModel.FacilityCode(facilityCode);
  340. postViewModel.PropertyId(propertyId);
  341. postViewModel.CreatedDateTime(nowDate_tmp);
  342. postViewModel.TargetDateTime(tmpDate);
  343. postViewModel.SimulationValue(value);
  344. postViewModel.SimulationCase(simulationCase);
  345. var postData = postViewModel.toJS();
  346. insert(postData);
  347. comparedDate.setMinutes(comparedDate.getMinutes() + 15);
  348. }
  349. }
  350. function DataExtract(row_num) {
  351. var islastRow = false;
  352. if (EditingFirstRow() == true && row_num == 1) { islastRow = true; }
  353. else if (EditingSecondRow() == true && row_num == 2) { islastRow = true; }
  354. else if (EditingThirdRow() == true && row_num == 3) { islastRow = true; }
  355. else if (EditingFourthRow() == true && row_num == 4) { islastRow = true; }
  356. else if (EditingFifthRow() == true && row_num == 5) { islastRow = true; }
  357. // 데이터 저장
  358. // 현재 활성화된 마지막 행만 ~_prev 데이터에 저장하고 DB 입력을 위한 부분, 이전행은 '행 추가' 버튼 클릭시 저장됨
  359. if (islastRow) {
  360. var tmp_initDate_ = $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value');
  361. initDate_prev[row_num - 1] = new Date(tmp_initDate_.getFullYear(), tmp_initDate_.getMonth(), tmp_initDate_.getDate(), tmp_initDate_.getHours(), tmp_initDate_.getMinutes(), 0);
  362. initDate_asSave[row_num - 1] = new Date(tmp_initDate_.getFullYear(), tmp_initDate_.getMonth(), tmp_initDate_.getDate(), tmp_initDate_.getHours(), tmp_initDate_.getMinutes(), 0);
  363. var tmp_finalDate_ = $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value');
  364. finalDate_prev[row_num - 1] = new Date(tmp_finalDate_.getFullYear(), tmp_finalDate_.getMonth(), tmp_finalDate_.getDate(), tmp_finalDate_.getHours(), tmp_finalDate_.getMinutes(), 0);
  365. finalDate_asSave[row_num - 1] = new Date(tmp_finalDate_.getFullYear(), tmp_finalDate_.getMonth(), tmp_finalDate_.getDate(), tmp_finalDate_.getHours(), tmp_finalDate_.getMinutes(), 0);
  366. operationMode_prev[row_num - 1] = $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value');
  367. operationMode_asSave[row_num - 1] = $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value');
  368. ref1Status_prev[row_num - 1] = $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value');
  369. ref1Status_asSave[row_num - 1] = $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value');
  370. ref2Status_prev[row_num - 1] = $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value');
  371. ref2Status_asSave[row_num - 1] = $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value');
  372. if (ref1Status_prev[row_num - 1]) { var ref1Status_int = 1; } else { var ref1Status_int = 0; }
  373. if (ref2Status_prev[row_num - 1]) { var ref2Status_int = 1; } else { var ref2Status_int = 0; }
  374. DataArrange(initDate_prev[row_num - 1], finalDate_prev[row_num - 1], 3, 4478, 16, parseInt(operationMode_prev[row_num - 1] * 10), 1); // 0: OFF, 10: 제빙, 20: 축단, 30:병렬, 40: 냉단
  375. DataArrange(initDate_prev[row_num - 1], finalDate_prev[row_num - 1], 2, 4479, 15, ref1Status_int, 1);
  376. DataArrange(initDate_prev[row_num - 1], finalDate_prev[row_num - 1], 2, 4480, 15, ref2Status_int, 1);
  377. }
  378. else {
  379. // 날짜 박스에서 불러올 경우 enable된 열의 날짜를 불러오기때문에 ~_prev 변수에서 불러옴
  380. var initDate_ = initDate_prev[row_num - 1];
  381. var finalDate_ = finalDate_prev[row_num - 1];
  382. initDate_asSave[row_num - 1] = initDate_prev[row_num - 1];
  383. finalDate_asSave[row_num - 1] = finalDate_prev[row_num - 1];
  384. var operationMode = $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value');
  385. operationMode_asSave[row_num - 1] = $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value');
  386. var ref1Status = $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value');
  387. ref1Status_asSave[row_num - 1] = $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value');
  388. var ref2Status = $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value');
  389. ref2Status_asSave[row_num - 1] = $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value');
  390. if (ref1Status) { var ref1Status_int = 1; } else { var ref1Status_int = 0; }
  391. if (ref2Status) { var ref2Status_int = 1; } else { var ref2Status_int = 0; }
  392. DataArrange(initDate_, finalDate_, 3, 4478, 16, parseInt(operationMode * 10), 1); // 0: OFF, 10: 제빙, 20: 축단, 30:병렬, 40: 냉단
  393. DataArrange(initDate_, finalDate_, 2, 4479, 15, ref1Status_int, 1);
  394. DataArrange(initDate_, finalDate_, 2, 4480, 15, ref2Status_int, 1);
  395. }
  396. }
  397. function handlePopupButtonSave() {
  398. var now_date = new Date();
  399. if (now_date.getHours() != 0 && now_date.getMinutes() % 15 == 1 && now_date.getSeconds() > 0 && now_date.getSeconds() < 40) {
  400. utils.toast.show('데이터 모델이 업데이트 중입니다. 잠시후 다시 시도해주세요. (약 40초 소요 예정)', 'error');
  401. }
  402. else {
  403. // 0, 4, 8, 12 ...초 시간에만 동작
  404. visibleHourGlassPopup(true); // 모래시계 팝업 활성화
  405. if (EditingFirstRow() === true) {
  406. if (enabledDateRange(1, "save")) {
  407. initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
  408. finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
  409. operationMode_asSave = new Array(null, null, null, null, null);
  410. ref1Status_asSave = new Array(null, null, null, null, null);
  411. ref2Status_asSave = new Array(null, null, null, null, null);
  412. DataExtract(1);
  413. $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
  414. visibleHourGlassPopup(true); // 모래시계 팝업 활성화
  415. // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
  416. setTimeout(function () {
  417. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  418. visibleHourGlassPopup(false);
  419. handleSearchInSearchView();
  420. }, 12000);
  421. CurrntRowStatusAsSave = 1;
  422. }
  423. }
  424. else if (EditingSecondRow() === true) {
  425. if (enabledDateRange(2, "save")) {
  426. initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
  427. finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
  428. operationMode_asSave = new Array(null, null, null, null, null);
  429. ref1Status_asSave = new Array(null, null, null, null, null);
  430. ref2Status_asSave = new Array(null, null, null, null, null);
  431. DataExtract(1);
  432. DataExtract(2);
  433. $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
  434. visibleHourGlassPopup(true); // 모래시계 팝업 활성화
  435. // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
  436. setTimeout(function () {
  437. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  438. visibleHourGlassPopup(false);
  439. handleSearchInSearchView();
  440. }, 12000);
  441. CurrntRowStatusAsSave = 2;
  442. }
  443. }
  444. else if (EditingThirdRow() === true) {
  445. if (enabledDateRange(3, "save")) {
  446. initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
  447. finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
  448. operationMode_asSave = new Array(null, null, null, null, null);
  449. ref1Status_asSave = new Array(null, null, null, null, null);
  450. ref2Status_asSave = new Array(null, null, null, null, null);
  451. DataExtract(1);
  452. DataExtract(2);
  453. DataExtract(3);
  454. $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
  455. visibleHourGlassPopup(true); // 모래시계 팝업 활성화
  456. // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
  457. setTimeout(function () {
  458. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  459. visibleHourGlassPopup(false);
  460. handleSearchInSearchView();
  461. }, 12000);
  462. CurrntRowStatusAsSave = 3;
  463. }
  464. }
  465. else if (EditingFourthRow() === true) {
  466. if (enabledDateRange(4, "save")) {
  467. initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
  468. finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
  469. operationMode_asSave = new Array(null, null, null, null, null);
  470. ref1Status_asSave = new Array(null, null, null, null, null);
  471. ref2Status_asSave = new Array(null, null, null, null, null);
  472. DataExtract(1);
  473. DataExtract(2);
  474. DataExtract(3);
  475. DataExtract(4);
  476. $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
  477. visibleHourGlassPopup(true); // 모래시계 팝업 활성화
  478. // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
  479. setTimeout(function () {
  480. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  481. visibleHourGlassPopup(false);
  482. handleSearchInSearchView();
  483. }, 12000);
  484. CurrntRowStatusAsSave = 4;
  485. }
  486. }
  487. else if (EditingFifthRow() === true) {
  488. if (enabledDateRange(5, "save")) {
  489. initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
  490. finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
  491. operationMode_asSave = new Array(null, null, null, null, null);
  492. ref1Status_asSave = new Array(null, null, null, null, null);
  493. ref2Status_asSave = new Array(null, null, null, null, null);
  494. DataExtract(1);
  495. DataExtract(2);
  496. DataExtract(3);
  497. DataExtract(4);
  498. DataExtract(5);
  499. $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
  500. visibleHourGlassPopup(true); // 모래시계 팝업 활성화
  501. // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
  502. setTimeout(function () {
  503. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  504. visibleHourGlassPopup(false);
  505. handleSearchInSearchView();
  506. }, 12000);
  507. CurrntRowStatusAsSave = 5;
  508. }
  509. }
  510. }
  511. visibleHourGlassPopup(false); // 모래시계 팝업 비활성화
  512. }
  513. // 데이터 범위 및 필수 입력사항 체크 함수
  514. function enabledDateRange(row_num, mode) {
  515. var now_ = new Date();
  516. var finalDate_ = new Date(now_.getFullYear(), now_.getMonth(), now_.getDate(), 20, 45, 0);
  517. if (now_.getHours() >= 21) {
  518. finalDate_ = moment(finalDate_).add(1, 'days').toDate();
  519. }
  520. var BoxInitDate_tmp = $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value');
  521. var BoxInitTime_tmp = $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value');
  522. var BoxFinalDate_tmp = $("#FinalDate" + (row_num).toString()).dxDateBox('instance').option('value');
  523. var BoxFinalTime_tmp = $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value');
  524. var input_inialDateTime = new Date(BoxInitDate_tmp.getFullYear(), BoxInitDate_tmp.getMonth(), BoxInitDate_tmp.getDate(), BoxInitTime_tmp.getHours(), BoxInitTime_tmp.getMinutes(), 0);
  525. var input_finalDateTime = new Date(BoxFinalDate_tmp.getFullYear(), BoxFinalDate_tmp.getMonth(), BoxFinalDate_tmp.getDate(), BoxFinalTime_tmp.getHours(), BoxFinalTime_tmp.getMinutes(), 0);
  526. var comparedDate = new Date(now_.getFullYear(), now_.getMonth(), now_.getDate(), 20, 45, 0);
  527. if (now_.getHours() >= 21) {
  528. comparedDate = moment(comparedDate).add(1, 'days').toDate();
  529. }
  530. var BoxDate_tmp = $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value');
  531. var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
  532. if ($("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value') == null) {
  533. utils.toast.show('항목이 모두 입력되지 않았습니다.', 'error');
  534. return false;
  535. }
  536. else if (BoxDate.getTime() == finalDate_.getTime() && mode == "edit") {
  537. utils.toast.show('마지막 종료시점이 시뮬레이션 허용 마지막 시간(당일 21시 혹은 익일 21시)이므로 행 추가가 불가합니다.', 'error');
  538. return false;
  539. }
  540. else if (BoxDate.getTime() != finalDate_.getTime() && mode == "save") {
  541. utils.toast.show('마지막 행의 종료 시점이 시뮬레이션 마지막 시간(21시)과 일치하지 않습니다.', 'error');
  542. return false;
  543. }
  544. else if (input_finalDateTime.getTime() > comparedDate.getTime()) {
  545. utils.toast.show("입력 최대 기간(당일 21시 혹은 익일 21시)을 초과하였습니다.", 'error');
  546. $("#FinalTime" + (row_num).toString()).dxDateBox("instance").option('value', comparedDate);
  547. return false;
  548. }
  549. else if (input_finalDateTime.getTime() < input_inialDateTime.getTime()) {
  550. utils.toast.show("마지막 행의 종료 시간이 시작 시간보다 빠릅니다.", 'error');
  551. $("#FinalTime" + (row_num).toString()).dxDateBox("instance").option('value', comparedDate);
  552. return false;
  553. }
  554. else {
  555. return true;
  556. }
  557. }
  558. function handlePopupButtonAdd() {
  559. // 행추가시 기존 제어 변수 입력 열에 미입력 사항이 있는지 확인하는 기능
  560. var now_ = new Date();
  561. var finalDate_ = new Date(now_.getFullYear(), now_.getMonth(), now_.getDate(), 20, 45, 0);
  562. if (now_.getHours() >= 21) {
  563. finalDate_ = moment(finalDate_).add(1, 'days').toDate();
  564. }
  565. if (EditingFirstRow() === true) {
  566. if (enabledDateRange(1, "edit")) {
  567. var InitDate_tmp = $("#InitialTime1").dxDateBox('instance').option('value');
  568. var BoxDate_tmp = $("#FinalTime1").dxDateBox('instance').option('value');
  569. var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
  570. initDate_prev[0] = new Date(InitDate_tmp.getFullYear(), InitDate_tmp.getMonth(), InitDate_tmp.getDate(), InitDate_tmp.getHours(), InitDate_tmp.getMinutes(), 0);
  571. finalDate_prev[0] = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
  572. operationMode_prev[0] = $("#OperationMode1").dxSelectBox('instance').option('value');;
  573. ref1Status_prev[0] = $("#Ref1_Status1").dxSwitch("instance").option('value');
  574. ref2Status_prev[0] = $("#Ref2_Status1").dxSwitch("instance").option('value');
  575. EnableDisableRow(1, true);
  576. EnableDisableRow(2, false);
  577. EditingFirstRow(false);
  578. EditingSecondRow(true);
  579. isSecondRow(true);
  580. BoxDate.setMinutes(BoxDate.getMinutes() + 15);
  581. $("#InitialDate2").dxDateBox('instance').option('value', BoxDate);
  582. $("#InitialTime2").dxDateBox('instance').option('value', BoxDate);
  583. $("#FinalDate2").dxDateBox('instance').option('value', finalDate_);
  584. $("#FinalTime2").dxDateBox('instance').option('value', finalDate_);
  585. }
  586. else {
  587. return;
  588. }
  589. }
  590. else if (EditingSecondRow() === true) {
  591. if (enabledDateRange(2, "edit")) {
  592. var InitDate_tmp = $("#InitialTime2").dxDateBox('instance').option('value');
  593. var BoxDate_tmp = $("#FinalTime2").dxDateBox('instance').option('value');
  594. var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
  595. initDate_prev[1] = new Date(InitDate_tmp.getFullYear(), InitDate_tmp.getMonth(), InitDate_tmp.getDate(), InitDate_tmp.getHours(), InitDate_tmp.getMinutes(), 0);
  596. finalDate_prev[1] = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
  597. operationMode_prev[1] = $("#OperationMode2").dxSelectBox('instance').option('value');;
  598. ref1Status_prev[1] = $("#Ref1_Status2").dxSwitch("instance").option('value');
  599. ref2Status_prev[1] = $("#Ref2_Status2").dxSwitch("instance").option('value');
  600. EnableDisableRow(2, true);
  601. EnableDisableRow(3, false);
  602. EditingSecondRow(false);
  603. EditingThirdRow(true);
  604. isThirdRow(true);
  605. BoxDate.setMinutes(BoxDate.getMinutes() + 15);
  606. $("#InitialDate3").dxDateBox('instance').option('value', BoxDate);
  607. $("#InitialTime3").dxDateBox('instance').option('value', BoxDate);
  608. $("#FinalDate3").dxDateBox('instance').option('value', finalDate_);
  609. $("#FinalTime3").dxDateBox('instance').option('value', finalDate_);
  610. }
  611. }
  612. else if (EditingThirdRow() === true) {
  613. if (enabledDateRange(3, "edit")) {
  614. var InitDate_tmp = $("#InitialTime3").dxDateBox('instance').option('value');
  615. var BoxDate_tmp = $("#FinalTime3").dxDateBox('instance').option('value');
  616. var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
  617. initDate_prev[2] = new Date(InitDate_tmp.getFullYear(), InitDate_tmp.getMonth(), InitDate_tmp.getDate(), InitDate_tmp.getHours(), InitDate_tmp.getMinutes(), 0);
  618. finalDate_prev[2] = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
  619. operationMode_prev[2] = $("#OperationMode3").dxSelectBox('instance').option('value');;
  620. ref1Status_prev[2] = $("#Ref1_Status3").dxSwitch("instance").option('value');
  621. ref2Status_prev[2] = $("#Ref2_Status3").dxSwitch("instance").option('value');
  622. EnableDisableRow(3, true);
  623. EnableDisableRow(4, false);
  624. EditingThirdRow(false);
  625. EditingFourthRow(true);
  626. isFourthRow(true);
  627. BoxDate.setMinutes(BoxDate.getMinutes() + 15);
  628. $("#InitialDate4").dxDateBox('instance').option('value', BoxDate);
  629. $("#InitialTime4").dxDateBox('instance').option('value', BoxDate);
  630. $("#FinalDate4").dxDateBox('instance').option('value', finalDate_);
  631. $("#FinalTime4").dxDateBox('instance').option('value', finalDate_);
  632. }
  633. }
  634. else if (EditingFourthRow() === true) {
  635. if (enabledDateRange(4, "edit")) {
  636. var InitDate_tmp = $("#InitialTime4").dxDateBox('instance').option('value');
  637. var BoxDate_tmp = $("#FinalTime4").dxDateBox('instance').option('value');
  638. var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
  639. initDate_prev[3] = new Date(InitDate_tmp.getFullYear(), InitDate_tmp.getMonth(), InitDate_tmp.getDate(), InitDate_tmp.getHours(), InitDate_tmp.getMinutes(), 0);
  640. finalDate_prev[3] = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
  641. operationMode_prev[3] = $("#OperationMode4").dxSelectBox('instance').option('value');;
  642. ref1Status_prev[3] = $("#Ref1_Status4").dxSwitch("instance").option('value');
  643. ref2Status_prev[3] = $("#Ref2_Status4").dxSwitch("instance").option('value');
  644. EnableDisableRow(4, true);
  645. EnableDisableRow(5, false);
  646. EditingFourthRow(false);
  647. EditingFifthRow(true);
  648. isFifthRow(true);
  649. BoxDate.setMinutes(BoxDate.getMinutes() + 15);
  650. $("#InitialDate5").dxDateBox('instance').option('value', BoxDate);
  651. $("#InitialTime5").dxDateBox('instance').option('value', BoxDate);
  652. $("#FinalDate5").dxDateBox('instance').option('value', finalDate_);
  653. $("#FinalTime5").dxDateBox('instance').option('value', finalDate_);
  654. }
  655. }
  656. else if (EditingFifthRow() === true) {
  657. utils.toast.show('최대 행 추가 수는 5개입니다.', 'error');
  658. return;
  659. }
  660. }
  661. // 열 삭제
  662. function handlePopupButtonDelete() {
  663. if (EditingFirstRow() === true) {
  664. utils.toast.show('최소 1개 이상 행을 입력해야합니다.', 'error');
  665. }
  666. else {
  667. DeleteRow(); // 현재 열 삭제
  668. }
  669. return;
  670. }
  671. function EnableDisableRow(row_num, disabled) {
  672. // 모든 행의 시작일은 고정
  673. $("#InitialDate" + (row_num).toString()).dxDateBox("instance").option('disabled', true);
  674. $("#InitialTime" + (row_num).toString()).dxDateBox("instance").option('disabled', true);
  675. $("#FinalDate" + (row_num).toString()).dxDateBox("instance").option('disabled', disabled);
  676. $("#FinalTime" + (row_num).toString()).dxDateBox("instance").option('disabled', disabled);
  677. $("#OperationMode" + (row_num).toString()).dxSelectBox("instance").option('disabled', disabled);
  678. if ($("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value') == 0
  679. || $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value') == 2) {
  680. $("#Ref1_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', true);
  681. $("#Ref2_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', true);
  682. }
  683. else {
  684. $("#Ref1_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', disabled);
  685. $("#Ref2_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', disabled);
  686. }
  687. }
  688. // 닫기버튼
  689. function PopupButtonClose() {
  690. visibleConfigPopup(false);
  691. // 전체 열에 대해서 모두 삭제하고 저장된 열들만 다시 채워준다
  692. for (var i = 0; i < 5; i++) {
  693. DeleteRow();
  694. }
  695. for (var i = 0; i < 5; i++) {
  696. if (operationMode_asSave[i] != null) {
  697. FilledRow(i + 1);
  698. }
  699. }
  700. visibleEditButton(true);
  701. hasnotModificationPermission(false);
  702. isEditModeInPopup(false);
  703. isNotModifyMode(true);
  704. visibleCancelButton(false);
  705. if (EditingFirstRow() == true) {
  706. EnableDisableRow(1, false);
  707. }
  708. else if (EditingSecondRow() == true) {
  709. EnableDisableRow(2, false);
  710. }
  711. else if (EditingThirdRow() == true) {
  712. EnableDisableRow(3, false);
  713. }
  714. else if (EditingFourthRow() == true) {
  715. EnableDisableRow(4, false);
  716. }
  717. else if (EditingFifthRow() == true) {
  718. EnableDisableRow(5, false);
  719. }
  720. }
  721. function SetPointer() {
  722. var now = new Date();
  723. var target_date;
  724. var isRecentData = ko.observable(false);
  725. if (now.getHours() < 21) {
  726. target_date = now
  727. }
  728. else {
  729. target_date = now.setDate(now.getDate() - 1);
  730. }
  731. var dataSource = new DevExpress.data.DataSource({
  732. store: {
  733. type: "odata",
  734. url: endpointSelector + "/BemsMonitoringPointWeatherForecasted",
  735. },
  736. requireTotalCount: true,
  737. pageSize: 99,
  738. });
  739. dataSource.filter([
  740. ["SiteId", "=", BWA.UserInfo.SiteId()],
  741. "and",
  742. ["nx", "=", 89],
  743. "and",
  744. ["ny", "=", 91]
  745. ]);
  746. dataSource.sort({ getter: "ForecastedDateTime", desc: true });
  747. dataSource.load()
  748. .done(function (WeatherForecasted) {
  749. if (WeatherForecasted.length != 0) {
  750. var WFTemperature_tmp = new Array();
  751. var WFHumidity_tmp = new Array();
  752. for (var i = 0; i < 16; i++) { // 예보데이터는 3시간 단위로 8포인트씩 2세트(기온, 습도)이므로
  753. if (WeatherForecasted[i].ForecastedDateTime.getFullYear() == target_date.getFullYear()
  754. && WeatherForecasted[i].ForecastedDateTime.getMonth() == target_date.getMonth()
  755. && WeatherForecasted[i].ForecastedDateTime.getDate() == target_date.getDate()
  756. && WeatherForecasted[i].Category == 'Temperature') {
  757. WFTemperature_tmp.push(WeatherForecasted[i].ForecastedValue);
  758. }
  759. if (WeatherForecasted[i].ForecastedDateTime.getFullYear() == target_date.getFullYear()
  760. && WeatherForecasted[i].ForecastedDateTime.getMonth() == target_date.getMonth()
  761. && WeatherForecasted[i].ForecastedDateTime.getDate() == target_date.getDate()
  762. && WeatherForecasted[i].Category == 'Humidity') {
  763. WFHumidity_tmp.push(WeatherForecasted[i].ForecastedValue);
  764. }
  765. }
  766. if (WFTemperature_tmp.length != 0) {
  767. $('#pointerText1').text("익일 예상 최고 기온 : " + Math.max.apply(null, WFTemperature_tmp).toFixed(2).toString() + " °C, ");
  768. $('#pointerText2').text("익일 예상 최저 기온 : " + Math.min.apply(null, WFTemperature_tmp).toFixed(2).toString() + " °C, ");
  769. }
  770. else {
  771. $('#pointerText1').text("익일 예상 최고 기온 : ? °C, ");
  772. $('#pointerText2').text("익일 예상 최저 기온 : ? °C, ");
  773. utils.toast.show("데이터가 없습니다. (익일 기상 예보 데이터 - 기온)", 'error');
  774. }
  775. if (WFHumidity_tmp.length != 0) {
  776. $('#pointerText3').text("익일 예상 최고 습도 : " + Math.max.apply(null, WFHumidity_tmp).toFixed(2).toString() + " %, ");
  777. $('#pointerText4').text("익일 예상 최저 습도 : " + Math.min.apply(null, WFHumidity_tmp).toFixed(2).toString() + " %, ");
  778. }
  779. else {
  780. $('#pointerText3').text("익일 예상 최고 습도 : ? %, ");
  781. $('#pointerText4').text("익일 예상 최저 습도 : ? %, ");
  782. utils.toast.show("데이터가 없습니다. (익일 기상 예보 데이터 - 습도)", 'error');
  783. }
  784. }
  785. else {
  786. $('#pointerText1').text("익일 예상 최고 기온 : ? °C, ");
  787. $('#pointerText2').text("익일 예상 최저 기온 : ? °C, ");
  788. $('#pointerText3').text("익일 예상 최고 습도 : ? %, ");
  789. $('#pointerText4').text("익일 예상 최저 습도 : ? %, ");
  790. utils.toast.show("데이터가 없습니다. (익일 기상 예보 데이터 - 기온, 습도)", 'error');
  791. }
  792. })
  793. .fail(function (error) {
  794. utils.toast.show(error);
  795. });
  796. var dataSource = new DevExpress.data.DataSource({
  797. store: {
  798. type: "odata",
  799. url: endpointSelector + "/BemsMonitoringPointForecastingDayAhead",
  800. },
  801. requireTotalCount: true,
  802. pageSize: 99,
  803. });
  804. dataSource.filter([
  805. ["SiteId", "=", BWA.UserInfo.SiteId()],
  806. "and",
  807. ["PropertyId", "=", 0]
  808. ]);
  809. dataSource.sort({ getter: "TargetDateTime", desc: true });
  810. dataSource.load()
  811. .done(function (PredictedDeicing) {
  812. if (PredictedDeicing.length != 0
  813. && PredictedDeicing[0].TargetDateTime.getFullYear() == target_date.getFullYear()
  814. && PredictedDeicing[0].TargetDateTime.getMonth() == target_date.getMonth()
  815. && PredictedDeicing[0].TargetDateTime.getDate() == target_date.getDate()) {
  816. $('#pointerText5').text("익일 예상 방냉량 : " + PredictedDeicing[0].ForecastedValue.toFixed(2).toString() + "%");
  817. }
  818. else {
  819. $('#pointerText5').text("익일 예상 방냉량 : 0%");
  820. utils.toast.show("데이터가 없습니다. (익일 예상 방냉량)", 'error');
  821. }
  822. })
  823. .fail(function (error) {
  824. utils.toast.show(error);
  825. });
  826. var now_15min = new Date();
  827. now_15min.setMinutes(parseInt(now_15min.getMinutes() / 15) * 15); // 15분 단위 맞춰주기 위함
  828. var now_15min_ = new Date(now_15min.getFullYear(), now_15min.getMonth(), now_15min.getDate(), now_15min.getHours(), now_15min.getMinutes(), 0);
  829. var finalDate_ = new Date(now_15min_.getFullYear(), now_15min_.getMonth(), now_15min_.getDate(), 20, 45, 0);
  830. if (now_15min.getHours() >= 21) {
  831. finalDate_ = moment(finalDate_).add(1, 'days').toDate();
  832. }
  833. // 추천 가동 시간 로드
  834. var dataSource = new DevExpress.data.DataSource({
  835. store: {
  836. type: "odata",
  837. url: endpointSelector + "/BemsIceThermalStorageSimulation",
  838. },
  839. requireTotalCount: true,
  840. pageSize: 99,
  841. });
  842. dataSource.sort({ getter: "TargetDateTime", desc: true });
  843. dataSource.filter([
  844. ["SiteId", "=", BWA.UserInfo.SiteId()],
  845. "and",
  846. ["FacilityTypeId", "=", 3],
  847. "and",
  848. ["PropertyId", "=", 16],
  849. "and",
  850. ["SimulationCase", "=", 0], // recommend
  851. "and",
  852. ["TargetDateTime", ">=", now_15min_],
  853. "and",
  854. ["TargetDateTime", "<=", finalDate_],
  855. ]);
  856. dataSource.load()
  857. .done(function (Recommended) {
  858. if (Recommended.length != 0) {
  859. var isRecommended = false;
  860. var RecommendedTime = new Date(now_15min.getFullYear(), now_15min.getMonth(), now_15min.getDate(), 0, 0, 0); // 추천 축열조 운영 모드 (제빙 모드)
  861. for (var i = 0; i < Recommended.length; i++) {
  862. if (Recommended[i].SimulationValue == 10) {
  863. RecommendedTime.settMinutes(RecommendedTime.getMinutes() + 15);
  864. isRecommended = true;
  865. }
  866. }
  867. if (isRecommended == true) {
  868. $('#RecommendedTime').text("추천 가동 시간(제빙모드) : " + RecommendedTime.getHours().toString() + "시간 " + RecommendedTime.getMinutes().toString() + "분,");
  869. }
  870. else {
  871. $('#RecommendedTime').text("추천 가동 시간 : 현재 익일 예상 방냉량 초과 저장,");
  872. }
  873. }
  874. else {
  875. $('#RecommendedTime').text("추천 가동 시간 : ?,");
  876. utils.toast.show("데이터가 없습니다. (추천 가동 시간)", 'error');
  877. }
  878. })
  879. .fail(function (error) {
  880. utils.toast.show(error);
  881. });
  882. // 냉동기1,2 전력량 로드
  883. var dataSource = new DevExpress.data.DataSource({
  884. store: {
  885. type: "odata",
  886. url: endpointSelector + "/BemsIceThermalStorageSimulation",
  887. },
  888. requireTotalCount: true,
  889. pageSize: 99,
  890. });
  891. dataSource.sort({ getter: "TargetDateTime", desc: true });
  892. dataSource.filter([
  893. ["SiteId", "=", BWA.UserInfo.SiteId()],
  894. "and",
  895. ["FacilityTypeId", "=", 2],
  896. "and",
  897. ["PropertyId", "=", 11],
  898. "and",
  899. ["SimulationCase", "=", 1], // simulation
  900. "and",
  901. ["TargetDateTime", ">=", now_15min_],
  902. "and",
  903. ["TargetDateTime", "<=", finalDate_],
  904. ]);
  905. dataSource.load()
  906. .done(function (RefPowerConsume) {
  907. if (RefPowerConsume.length != 0) {
  908. var RefPowerConsumeSum = 0; // 냉동기 전력량 합계 (시뮬레이션 모드)
  909. for (var i = 0; i < RefPowerConsume.length; i++) {
  910. RefPowerConsumeSum += RefPowerConsume[i].SimulationValue;
  911. }
  912. if (RefPowerConsumeSum == 0) {
  913. $('#RefPowerConsume').text("냉동기 계산 전력량(시뮬레이션 모드) : 0 kWh");
  914. }
  915. else {
  916. $('#RefPowerConsume').text("냉동기 계산 전력량(시뮬레이션 모드) : " + RefPowerConsumeSum.toFixed(2).toString() + " kWh");
  917. }
  918. }
  919. else {
  920. $('#RefPowerConsume').text("냉동기 계산 전력량(시뮬레이션 모드) : ?");
  921. utils.toast.show("데이터가 없습니다. (냉동기 계산 전력량)", 'error');
  922. }
  923. })
  924. .fail(function (error) {
  925. utils.toast.show(error);
  926. });
  927. }
  928. function handleViewShown() {
  929. $("#LoadPanel").dxLoadPanel({
  930. message: '로딩 중...',
  931. showIndicator: true,
  932. visible: false
  933. });
  934. $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
  935. visibleHourGlassPopup(true);
  936. // 초기 화면에서 기존 사용자 제어변수 삭제
  937. RemoveData(3, 4478, 16, 1); // 운전모드
  938. RemoveData(2, 4479, 15, 1); // 냉동기1 상태
  939. RemoveData(2, 4480, 15, 1); // 냉동기2 상태
  940. RemoveData(2, 4479, 11, 1); // 냉동기1 전력량
  941. RemoveData(2, 4480, 11, 1); // 냉동기2 전력량
  942. RemoveData(3, 4478, 2, 1); // 축열량
  943. if (initialized === false) {
  944. setTimeout(function () {
  945. chart = chart(BWA.ChartOptions.SimulatorIceStorage.getChartOptions());
  946. initialized = true;
  947. // 날짜 초기화 (오늘)
  948. timeBoxForSearch.setDefaultDateToday();
  949. handleSearchInSearchView();
  950. }, 4000);
  951. }
  952. else {
  953. setTimeout(function () {
  954. // 날짜 초기화 (오늘)
  955. timeBoxForSearch.setDefaultDateToday();
  956. handleSearchInSearchView();
  957. // 저장 변수 초기화
  958. initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
  959. finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
  960. operationMode_asSave = new Array(null, null, null, null, null);
  961. ref1Status_asSave = new Array(null, null, null, null, null);
  962. ref2Status_asSave = new Array(null, null, null, null, null);
  963. }, 4000);
  964. }
  965. timer = setInterval(function () {
  966. //alert('timer'); // For Debugging
  967. var now = new Date();
  968. //if ((now.getMinutes() == 1 && now.getSeconds() == 30) || (now.getMinutes() == 5 && now.getSeconds() == 30)) {
  969. if (now.getMinutes() % 15 == 2 && now.getSeconds() == 30) {
  970. handleSearchInSearchView();
  971. }
  972. }, 1000);
  973. $("#UserCfgBtn").dxButton({
  974. text: "시뮬레이터 변수 설정",
  975. onClick: function () {
  976. visibleConfigPopup(true);
  977. }
  978. });
  979. }
  980. function handleViewHidden() {
  981. $SearchView.visibleObservable(false); // hcLee 2015 03 23
  982. visibleConfigPopup(false);
  983. clearInterval(timer); // hcLee 2015 06 12
  984. }
  985. function RemoveData(facilityTypeId, facilityCode, propertyId, simulationCase) {
  986. var now_15min = new Date();
  987. now_15min.setMinutes(parseInt(now_15min.getMinutes() / 15) * 15); // 15분 단위 맞춰주기 위함
  988. var targetDate_ = new Date(now_15min.getFullYear(), now_15min.getMonth(), now_15min.getDate(), now_15min.getHours(), now_15min.getMinutes(), 0);
  989. var finalDate_ = new Date(now_15min.getFullYear(), now_15min.getMonth(), now_15min.getDate(), 20, 45, 0);
  990. if (now_15min.getHours() >= 21) {
  991. finalDate_ = moment(finalDate_).add(1, 'days').toDate();
  992. }
  993. BemsIceThermalStorageDataSource.filter([
  994. ["SiteId", "=", BWA.UserInfo.SiteId()],
  995. "and",
  996. ["FacilityCode", "=", facilityCode],
  997. "and",
  998. ["PropertyId", "=", propertyId],
  999. "and",
  1000. ["SimulationCase", "=", simulationCase],
  1001. "and",
  1002. ["TargetDateTime", ">=", targetDate_],
  1003. "and",
  1004. ["TargetDateTime", "<=", finalDate_]
  1005. ]);
  1006. BemsIceThermalStorageDataSource.load()
  1007. .done(function (result) {
  1008. var store = new DevExpress.data.ODataStore({
  1009. url: endpointSelector + "/BemsIceThermalStorageSimulation",
  1010. key: ["SiteId", "FacilityCode", "PropertyId", "CreatedDateTime", "TargetDateTime", "SimulationCase"],
  1011. keyType: {
  1012. SiteId: "Int32", FacilityCode: "Int32", PropertyId: "Int32", CreatedDateTime: "DateTime", TargetDateTime: "DateTime", SimulationCase: "Int32"
  1013. }
  1014. });
  1015. if (result.length != 0) {
  1016. for (var i = 0; i < result.length; i++) {
  1017. var removeData = {
  1018. SiteId: result[i].SiteId(),
  1019. FacilityTypeId: result[i].FacilityTypeId(),
  1020. FacilityCode: result[i].FacilityCode(),
  1021. PropertyId: result[i].PropertyId(),
  1022. CreatedDateTime: new Date(result[i].CreatedDateTime()),
  1023. TargetDateTime: new Date(result[i].TargetDateTime()),
  1024. SimulationValue: result[i].SimulationValue(),
  1025. SimulationCase: result[i].SimulationCase()
  1026. };
  1027. store.remove(removeData).done(function (values, key) {
  1028. })
  1029. .fail(function (error) {
  1030. utils.toast.show(error, 'error');
  1031. });
  1032. }
  1033. }
  1034. });
  1035. }
  1036. // 다른 페이지 갔다 들어오면 시뮬레이션 데이터 및 팝업 초기화
  1037. function handleViewShowing() {
  1038. SetPointer();
  1039. initializedforPopUp = false;
  1040. CurrntRowStatusAsSave = 1;
  1041. }
  1042. function refreshList() {
  1043. }
  1044. var searchViewOptions = {
  1045. searchViewItems: [
  1046. //{ id: 'TimeTypeId', defaultValue: 0, value: timeTypeIdForSearch, dataSource: timeTypesForSearch },
  1047. //{ id: 'DateForHour', type: 'dateRange', isOnlyDate: true },
  1048. ],
  1049. };
  1050. function handleSearchInSearchView() {
  1051. $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
  1052. visibleHourGlassPopup(true);
  1053. var dataArray = [];
  1054. dataArrayforPopup = [];
  1055. var date = timeBoxForSearch.getDate();
  1056. var start_date = moment(date.startDate).add(-3, 'hours').toDate();
  1057. var end_date = moment(date.endDate).add(-3, 'hours').toDate();
  1058. SetPointer();
  1059. var commonParameters = {
  1060. TimeIntervalType: $Code.TimeIntervalType.QUARTERMIN,
  1061. StartDate: start_date,
  1062. EndDate: end_date
  1063. };
  1064. var IceThermalStorageParameters_obs = {
  1065. FacilityTypeId: 3,
  1066. FacilityCode: 4478,
  1067. PropertyId: 2,
  1068. SimulationCase: 0 // observed and recommended schedule
  1069. };
  1070. var IceThermalStorageParameters_sim = {
  1071. FacilityTypeId: 3,
  1072. FacilityCode: 4478,
  1073. PropertyId: 2,
  1074. SimulationCase: 1 // simulated schedule
  1075. };
  1076. var now_sub = new Date();
  1077. now_sub.setMinutes(now_sub.getMinutes() - 15); // 15분까지 데이터 확인 가능
  1078. $.when(
  1079. iceThermalStorage_SimulationValueGet.apiGet(_.extend(IceThermalStorageParameters_obs, commonParameters)),
  1080. iceThermalStorage_SimulationValueGet.apiGet(_.extend(IceThermalStorageParameters_sim, commonParameters))
  1081. ).done(function (Candidate_obs, Candidate_sim) {
  1082. if (Candidate_obs.length == 0) {
  1083. utils.toast.show("[BemsIceThermalStorageSimulation] 데이터가 없습니다.", 'error');
  1084. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  1085. }
  1086. else {
  1087. if (Candidate_obs.length != 0) {
  1088. _.each(Candidate_obs[0][0], function (x) {
  1089. if (moment(x.DateTime).toDate() < now_sub) {
  1090. dataArray.push({
  1091. DateTime: moment(x.DateTime).toDate(),
  1092. ObservedValue: x.Value
  1093. });
  1094. }
  1095. });
  1096. // 2017.09.08 : 그리드 도표 작업 : 팝업창 추가
  1097. _.each(Candidate_obs[0][0], function (x) {
  1098. if (moment(x.DateTime).toDate() < now_sub) {
  1099. dataArrayforPopup.push({
  1100. DateTime: BWA.Chart.getCustermTimeArgumentAxisString($Code.TimeType.QUARTERMIN, moment(x.DateTime).toDate()),
  1101. Value: x.Value,
  1102. Case: 'Obs'
  1103. });
  1104. }
  1105. });
  1106. }
  1107. if (Candidate_sim.length != 0) {
  1108. _.each(Candidate_sim[0][0], function (x) {
  1109. if (moment(x.DateTime).toDate() >= now_sub) {
  1110. dataArray.push({
  1111. DateTime: moment(x.DateTime).toDate(),
  1112. SimulationValue: x.Value
  1113. });
  1114. }
  1115. });
  1116. // 2017.09.08 : 그리드 도표 작업 : 팝업창 추가
  1117. _.each(Candidate_sim[0][0], function (x) {
  1118. if (moment(x.DateTime).toDate() >= now_sub) {
  1119. dataArrayforPopup.push({
  1120. DateTime: BWA.Chart.getCustermTimeArgumentAxisString($Code.TimeType.QUARTERMIN, moment(x.DateTime).toDate()),
  1121. Value: x.Value,
  1122. Case: 'Sim'
  1123. });
  1124. }
  1125. });
  1126. }
  1127. // 2017.09.08 : 그리드 도표 작업 : 팝업창 추가
  1128. var options = BWA.ChartOptions.SimulatorIceStorage.getSeriesOptions();
  1129. if (!_.isNull(start_date) && !_.isNull(end_date)) {
  1130. options.argumentAxis.min = start_date;
  1131. options.argumentAxis.max = end_date;
  1132. }
  1133. chart().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  1134. options.dataSource = dataArray;
  1135. chart().option(options);
  1136. }
  1137. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  1138. visibleHourGlassPopup(false);
  1139. })
  1140. .fail(function (error) {
  1141. utils.toast.show("데이터를 불러오는데 실패 하였습니다.", 'error');
  1142. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  1143. visibleConfigPopup(false);
  1144. $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
  1145. visibleHourGlassPopup(false);
  1146. });
  1147. }
  1148. // 2017.09.08 : 그리드 도표 작업 : 팝업창 추가
  1149. function DataGridPopup_ButtonClick() {
  1150. DataGridPopup_Visible(true);
  1151. }
  1152. function handlePopupShown() {
  1153. // 도표 컬럼명 업데이트
  1154. viewModel.SimulatorIceStorageDataGridOptions.columns[0].caption = "날짜";
  1155. viewModel.SimulatorIceStorageDataGridOptions.columns[1].caption = "실/계산 축열량";
  1156. // 도표 데이터소스 업데이트
  1157. $("#SimulatorIceStorageDataGrid_Container").dxDataGrid("instance").option("dataSource", dataArrayforPopup);
  1158. // 도표 팝업창 갱신
  1159. //DataGridPopup_Visible(true);
  1160. }
  1161. // Box Initialize
  1162. function BoxInitialize(row_num, initial_Date, final_Date) {
  1163. $("#InitialDate" + (row_num).toString()).dxDateBox({
  1164. value: initial_Date,
  1165. maxZoomLevel: 'month',
  1166. formatString: "yyyy-MM-dd",
  1167. onValueChanged: function (data) {
  1168. initial_Date.setFullYear(data.value.getFullYear());
  1169. initial_Date.setMonth(data.value.getMonth());
  1170. initial_Date.setDate(data.value.getDate());
  1171. $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
  1172. $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
  1173. }
  1174. });
  1175. $("#InitialTime" + (row_num).toString()).dxDateBox({
  1176. value: initial_Date,
  1177. format: "time",
  1178. formatString: "HH:mm",
  1179. onValueChanged: function (data) {
  1180. initial_Date.setHours(data.value.getHours());
  1181. initial_Date.setMinutes(data.value.getMinutes());
  1182. $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
  1183. $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
  1184. }
  1185. });
  1186. $("#FinalDate" + (row_num).toString()).dxDateBox({
  1187. value: final_Date,
  1188. maxZoomLevel: 'month',
  1189. formatString: "yyyy-MM-dd",
  1190. min: new Date(moment().add(-1, 'd')),
  1191. max: new Date(moment().add(1, 'd')),
  1192. onValueChanged: function (data) {
  1193. final_Date.setFullYear(data.value.getFullYear());
  1194. final_Date.setMonth(data.value.getMonth());
  1195. final_Date.setDate(data.value.getDate());
  1196. $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
  1197. $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
  1198. $("#FinalDate" + (row_num).toString()).dxDateBox('instance').option('value', final_Date);
  1199. $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value', final_Date);
  1200. }
  1201. });
  1202. $("#FinalTime" + (row_num).toString()).dxDateBox({
  1203. value: final_Date,
  1204. format: "time",
  1205. formatString: "HH:mm",
  1206. onValueChanged: function (data) {
  1207. final_Date.setHours(data.value.getHours());
  1208. final_Date.setMinutes(data.value.getMinutes());
  1209. $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
  1210. $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
  1211. $("#FinalDate" + (row_num).toString()).dxDateBox('instance').option('value', final_Date);
  1212. $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value', final_Date);
  1213. }
  1214. });
  1215. $("#OperationMode" + (row_num).toString()).dxSelectBox({
  1216. placeholder: "운전 모드",
  1217. dataSource: treeOperationMode,
  1218. displayExpr: "text",
  1219. valueExpr: "id",
  1220. onValueChanged: function (data) {
  1221. $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value', data.value);
  1222. // OFF, 축단운전시 냉동기 모두 OFF
  1223. if (data.value == 0 || data.value == 2) {
  1224. $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value', false);
  1225. $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value', false);
  1226. $("#Ref1_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', true);
  1227. $("#Ref2_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', true);
  1228. }
  1229. else {
  1230. $("#Ref1_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', false);
  1231. $("#Ref2_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', false);
  1232. }
  1233. }
  1234. });
  1235. $("#Ref1_Status" + (row_num).toString()).dxSwitch({
  1236. onText: $G('use'),
  1237. offText: $G('nonUse'),
  1238. onValueChanged: function (data) {
  1239. $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value', data.value);
  1240. }
  1241. });
  1242. $("#Ref2_Status" + (row_num).toString()).dxSwitch({
  1243. onText: $G('use'),
  1244. offText: $G('nonUse'),
  1245. onValueChanged: function (data) {
  1246. $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value', data.value);
  1247. }
  1248. });
  1249. // 초기 시작 시점은 고정
  1250. $("#InitialDate" + (row_num).toString()).dxDateBox("instance").option('disabled', true);
  1251. $("#InitialTime" + (row_num).toString()).dxDateBox("instance").option('disabled', true);
  1252. $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value', null);// 운전 모드 클리어
  1253. $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
  1254. $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
  1255. initDate_prev[row_num - 1] = new Date(initial_Date);
  1256. finalDate_prev[row_num - 1] = new Date(final_Date);
  1257. operationMode_prev[row_num - 1] = null;
  1258. ref1Status_prev[row_num - 1] = false;
  1259. ref2Status_prev[row_num - 1] = false;
  1260. return 0;
  1261. }
  1262. var viewModel = $.extend(BWA.CommonView.create(
  1263. params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null,
  1264. handleSearchInSearchView), {
  1265. refreshList: refreshList,
  1266. viewShowing: handleViewShowing,
  1267. viewHidden: handleViewHidden, // hcLee 2015 03 23
  1268. //viewDisposing: handleViewHidden, // hcLee 2015 03 23
  1269. //locationEnableForSearch: locationEnableForSearch,
  1270. // 그리드 도표 작업 : 팝업창 추가
  1271. SimulatorIceStorageDataGridPopup_ButtonClicked: DataGridPopup_ButtonClick
  1272. // 그리드 도표 작업 : 팝업창 추가
  1273. });
  1274. viewModel.SimulatorIceStoragePopupOptions = {
  1275. width: 1500,//1250,
  1276. height: 350,
  1277. visible: visibleConfigPopup,
  1278. dragEnabled: true,
  1279. shading: true,
  1280. closeOnOutsideClick: false,
  1281. shadingColor: 'transparent',
  1282. showTitle: true,
  1283. //title: "사용자 시뮬레이터 변수 설정",
  1284. showCloseButton: true,
  1285. onShowing: function () {
  1286. if (initializedforPopUp === false) {
  1287. setTimeout(function () {
  1288. var initialDate_ = new Date();
  1289. initialDate_.setMinutes((parseInt(initialDate_.getMinutes() / 15)) * 15); // 15분 단위 맞춰주기 위함
  1290. initialDate_.setSeconds(0);
  1291. var finalDate_ = new Date(finalDate);
  1292. for (var i = 0; i < 5; i++) {
  1293. BoxInitialize(i + 1, initialDate_, finalDate_);
  1294. }
  1295. InitializedTemplate();
  1296. InitializedData();
  1297. initializedforPopUp = true;
  1298. }, 100);
  1299. }
  1300. else {
  1301. InitializedTemplate();
  1302. }
  1303. },
  1304. onShown: function () {
  1305. },
  1306. onHidden: function () {
  1307. }
  1308. }
  1309. // 2020.08.03 : 그리드 도표 작업 : 팝업창 추가
  1310. // 그래프 도표 팝업창
  1311. viewModel.SimulatorIceStorageDataGridPopupOptions = {
  1312. width: '480px',
  1313. height: '830px', // cyim 2017.05.30 : 테스트 결과 Devextreme 버그임. px 로 지정하면 초기 출력시 정확하게 가운데에 있지만, auto 설정시 화면아래에 위치하게 됨
  1314. contentTemplate: "content",
  1315. showTitle: true,
  1316. title: "도표",
  1317. visible: DataGridPopup_Visible,
  1318. dragEnabled: true,
  1319. closeOnOutsideClick: true,
  1320. shownAction: handlePopupShown,
  1321. animation: window.utils.popup.createAnimation(),
  1322. shading: false
  1323. };
  1324. // 2020.08.03 : 그리드 도표 작업 : 팝업창 추가
  1325. // 2020.08.03 : 그리드 도표 작업 : 팝업창 추가
  1326. viewModel.SimulatorIceStorageDataGridOptions = {
  1327. dataSource: dataArrayforPopup,
  1328. columns: [
  1329. { dataField: 'DateTime', width: '40%', alignment: 'center' },// dataType: 'date', format: 'yyyy-MM-dd HH:mm' },
  1330. { dataField: 'Value', width: '60%', alignment: 'center', format: 'fixedPoint', precision: 2 }
  1331. //{ dataField: 'ObservedValue', width: '30%', alignment: 'center', format: 'fixedPoint', precision: 2 },
  1332. //{ dataField: 'SimulationValue', width: '30%', alignment: 'center', format: 'fixedPoint', precision: 2 }
  1333. ],
  1334. rowPrepared: function (rowElement, rowInfo) {
  1335. if (rowInfo.rowType == 'data') {
  1336. var data = rowInfo.data;
  1337. if (data['Case'] == 'Sim') {
  1338. //rowElement.css('background-color', 'rgba(255,0,0,0.1)');
  1339. rowElement.css('background-color', 'rgba(153,102,255,0.1)');
  1340. }
  1341. }
  1342. },
  1343. // 엑셀 출력
  1344. "export": {
  1345. enabled: true,
  1346. fileName: '축열량 시뮬레이션 결과'
  1347. }
  1348. };
  1349. /// 2020.08.03 : 그리드 도표 작업 : 팝업창 추가
  1350. viewModel.simulatoricestoragePopupToolbarItems = simulatoricestoragePopupToolbarItems;
  1351. viewModel.timeBoxForSearch = timeBoxForSearch;
  1352. viewModel.handlePopupButtonAdd = handlePopupButtonAdd;
  1353. viewModel.handlePopupButtonDelete = handlePopupButtonDelete;
  1354. viewModel.isSecondRow = isSecondRow;
  1355. viewModel.isThirdRow = isThirdRow;
  1356. viewModel.isFourthRow = isFourthRow;
  1357. viewModel.isFifthRow = isFifthRow;
  1358. viewModel.visibleHourGlassPopup = visibleHourGlassPopup;
  1359. viewModel.isEditModeInPopup = isEditModeInPopup;
  1360. return viewModel;
  1361. };