class OperationsController < ApplicationController
    before_filter :check_access, :set_locale
    def perfomance
    end

    def activity
  	     @user=User.find(session[:user_id])
  	     if @user[:from_date] != @user[:to_date]
  		     redirect_to  :action=>'map_period' 
  	     end
    end

    def map
   	     @user=User.find(session[:user_id])
   	     if @user[:from_date] != @user[:to_date]
   		     redirect_to  :action=>'map_period', operation_id: params[:operation_id] 
   	     end
    end
    
    def map_period
  	     @user=User.find(session[:user_id])
  	     if @user[:from_date] == @user[:to_date]
  		     redirect_to  :action=>'map', operation_id: params[:operation_id]  
  	     end
    end

    def prediction
    end
  
    def set_test_data
        @oper_list=[
            'Выгрузка отчета', 
            'Форма 502', 
            'Заведение Транзакций', 
            'Журнал операций', 
            'Конветация валют',
            'Статистика по кассовым документам',
            'Выдача кредита',
            'Статистика по кассовым документам',
            'Загрузка Договоров купли-продажи автомобиля',
            'Загрузка договоров страхования',
            'Расчет кредитного портфеля',  
        ]
        
        @user_list=[
            'aignatov',
            'vsmirnov',
            'vasiliev',
            'nzadov',
            'nsmagin',
            'apetrov',
            'iivanov',
            'apopov',
            'michalin',
            'rkotov',
            'bliz',
            'amedvedev'
        ]
        
        @office_list=[
            'Москва',
            'Королев',
            'Тверь',
            'Химки',
            'Сергиев-Посад'
        ]
        @oper_type=[
            'Операция',
            'Отчет'
        ]
        
        modules = [
            'Главный модуль',
            'Биржевой рынок',
            'Вексельный рынок',
        ]
        nodes = [
            'Начало процесса;HIDDEN_CHECK;Список типов задач;Завершение процесса',
            "Начало процесса;Чтение настроек;ФОРМА ПОИСКА;Получение настроек;ФОРМА ПОИСКА",
            "Начало процесса;Заполняем филиал и даты;1 шаг",
            ";Введен;Принять;Введен;Отклонить",
            "Начало процесса;Группы настроек;Список настроек;Список настроек"
        ]
        proc_cont_errors = [
            'ERROR (ProcessFlowController.java:845) - Error occured while calling service http://lpar-was:9083/corews/corews?dsAccountFindByID! FaultCode=500, FaultMessage=""',
            'ERROR (ProcessFlowController.java:187) - exiting with error 2285698, node name = -???????? USERACCOUNTID FaultCode=500, FaultMessage=""',
            'DEBUG (ProcessFlowController.java:?) - EXTRAPARAM = <?xml version=1.0 encoding=UTF-8?><BODY version="2.11"><APPLICATIONID type="java.lang.Long">138027</APPLICATIONID><ASSIGNOBJECT type="java.lang.String">102004</ASSIGNOBJECT><CLIENTID type="java.lang.Long">100012</CLIENTID><CLIENTLINKTYPE type="java.lang.String">-?????</CLIENTLINKTYPE><COMMENTARY_PROCESS type="java.lang.String">¦? ??? ¦138027, -????? -???°??? +???? ¦?????????, -?????? ¦14/¦-/000030.</COMMENTARY_PROCESS><DOCPACKAGEID type="java.lang.String">133025</DOCPACKAGEID><EDIT_PATH type="java.lang.String">serviceLoanApp\applicationEarlyPayingOff\task\editApplicationInfo</EDIT_PATH><EXPIRATIONDATE type="java.util.Date">2014-07-16T10:39:42:647+0400</EXPIRATIONDATE><HT_DATA type="java.util.Map"><application type="java.util.Map"><clientMainDocSeries type="java.lang.String">70 01</clientMainDocSeries><departmentId type="java.lang.String">0</departmentId><CREATIONDATE type="java.util.Date">2014-07-16T10:36:53:279+0400</CREATIONDATE><ownerFullName type="java.lang.String">-???°??? +???? ¦?????????</ownerFullName><clientFactAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientFactAddressString><clientEmail type="java.lang.String"></clientEmail><clientMainDocIssueDate type="java.util.Date">2001-08-04T04:00:00:000+0400</clientMainDocIssueDate><SYSTEM_PARAMS type="java.util.Map"><PROFILING type="java.lang.Boolean">false</PROFILING></SYSTEM_PARAMS><IncludePlanPay type="java.lang.Boolean">false</IncludePlanPay><clientINN type="java.lang.String">-? ??????</clientINN><CREATEDBY type="java.lang.Long">105004</CREATEDBY><CONTRACTSTATE type="java.lang.String">¦???¦???</CONTRACTSTATE><clientMobilePhone type="java.lang.String">8 (910) 5535894</clientMobilePhone><DOCUMENTNUMBER type="java.lang.String">138027</DOCUMENTNUMBER><CURRENTUSER type="java.lang.String">++-+-+-+- +-++ </CURRENTUSER><clientFullName type="java.lang.String">-???°??? +???? ¦?????????</clientFullName><DOCTYPESYSNAME type="java.lang.String">dishargeServiceLoanApp</DOCTYPESYSNAME><cbAddAgreementLook type="java.lang.String">full</cbAddAgreementLook><clientLastName type="java.lang.String">-???°???</clientLastName><CONTRACTID type="java.lang.String">111006</CONTRACTID><AccInfo type="java.lang.String">&lt;b>40817810000012075838&lt;/b>, ???????: &lt;b>8 696.60&lt;/b>, ????? ???: &lt;b>?? ??????????&lt;/b>,&lt;br> ???? ?????????? ?????????  ?????: &lt;b>10.07.2014&lt;/b>, ?? ?????: &lt;b>8 650.00&lt;/b>.</AccInfo><SigningDate type="java.util.Date">2014-05-20T00:00:00:000+0400</SigningDate><addAgreementDate type="java.util.Date">2014-07-21T04:00:00:000+0400</addAgreementDate><CONTRACTDOCTYPESYSNAME type="java.lang.String">loanContract</CONTRACTDOCTYPESYSNAME><RestOut type="java.math.BigDecimal">8696.6</RestOut><BRANCHID type="java.lang.String">0</BRANCHID><STRING1 type="java.lang.String">FTLoanManagement</STRING1><CONTRACTDATE type="java.util.Date">2014-05-20T10:49:15:594+0400</CONTRACTDATE><STRING3 type="java.lang.String">-???°???</STRING3><STRING4 type="java.lang.String">+????</STRING4><STRING5 type="java.lang.String">¦?????????</STRING5><BankProductBrief type="java.lang.String">+????????? "-?? ?????????"</BankProductBrief><EarlyPayingOffAmount type="java.lang.String">361941.86</EarlyPayingOffAmount><ContractExtraInfo type="java.lang.String">?????: &lt;b>366 211.22&lt;/b>, ????: &lt;b>60 ???.&lt;/b>, ????? ?????? ????? ???????: &lt;b>8 623.76&lt;/b></ContractExtraInfo><branchName type="java.lang.String">¦++ ¦- -??? -??</branchName><CURRENTUSERPOSITION type="java.lang.String">-????????</CURRENTUSERPOSITION><clientMainDocType type="java.lang.String">-?????? ?????????? -+</clientMainDocType><clientPostalAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientPostalAddressString><clientFirstName type="java.lang.String">+????</clientFirstName><DOCUMENTTYPE type="java.lang.Long">2218</DOCUMENTTYPE><ClientInputAmount type="java.lang.String">353245.26</ClientInputAmount><clientMainDocIssuerCode type="java.lang.String">713-017</clientMainDocIssuerCode><CONTRACTNUMBER type="java.lang.String">14/¦-/000030</CONTRACTNUMBER><clientRegAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientRegAddressString><DOCTYPENAME type="java.lang.String">-???????? ????°????</DOCTYPENAME><clientMainDocNumber type="java.lang.String">169586</clientMainDocNumber><branchId type="java.lang.String">0</branchId><clientKPP type="java.lang.String">0</clientKPP><CONTRACTTYPEID type="java.lang.String">3002</CONTRACTTYPEID><RecalcMode type="java.lang.String"></RecalcMode><clientMiddleName type="java.lang.String">¦?????????</clientMiddleName><ResponsibleRole type="java.lang.String">LoanAdmContractSupportGroup</ResponsibleRole><WIZARDSYSNAME type="java.lang.String">dishargeServiceLoanApp</WIZARDSYSNAME><OwnerID type="java.lang.Long">100012</OwnerID><EXTCONTRACTID type="java.lang.Long">10000020072</EXTCONTRACTID><INVOKED_FROM_METADATA type="java.lang.Boolean">true</INVOKED_FROM_METADATA><STATE type="java.lang.String">-??????</STATE><curPaymentDate type="java.lang.String">21.07.2014</curPaymentDate><InformationApp type="java.lang.String">-??????, ?????? ??????? ?? ?????? ?? ?????? ????????? ????°????, ???? ????????. -?????? ??????????? ?????????? ????°???  ???????  21.07.2014.</InformationApp><clientMainDocIssuedBy type="java.lang.String">-??????????? ?????????? ??????? +????????? -+-- -??????? ???.</clientMainDocIssuedBy><DOCUMENTID type="java.lang.Long">138027</DOCUMENTID><clientFlagAdditionalDoc type="java.lang.Boolean">true</clientFlagAdditionalDoc><departmentName type="java.lang.String">¦++ ¦- -??? -??</departmentName></application><TaskInfo type="java.lang.String">&lt;table cellspacing="10" cellpadding="10">&lt;tr>&lt;td>-?????:&lt;/td>&lt;td>&amp;nbsp;&lt;/td>&lt;td>&lt;b>-???°??? +???? ¦?????????&lt;/b>&lt;/td>&lt;/tr>&lt;tr>&lt;td>-???? ????????:&lt;/td>&lt;td>&amp;nbsp;&lt;/td>&lt;td>&lt;b>14/¦-/000030&lt;/b>&lt;/td>&lt;/tr>&lt;tr>&lt;td>-??????:&lt;/td>&lt;td>&amp;nbsp;&lt;/td>&lt;td>&lt;b>+????????? "-?? ?????????"&lt;/b>&lt;/td>&lt;/tr>&lt;/table></TaskInfo><APPLICATIONID type="java.lang.Long">138027</APPLICATIONID></HT_DATA><INIT_STATESYSNAME type="java.lang.String">inputApp</INIT_STATESYSNAME><PROCESSID type="java.lang.Long">225820</PROCESSID><ROLEID type="java.lang.Long">2018</ROLEID><ResponsibleRole type="java.lang.String">LoanAdmContractSupportGroup</ResponsibleRole><STAGEDATE type="java.util.Date">2014-07-16T10:39:42:648+0400</STAGEDATE><STAGEDETAILS type="java.lang.String">-??????, ?????? ??????? ?? ?????? ?? ?????? ????????? ????°????, ???? ????????. -?????? ??????????? ?????????? ????°???  ???????  21.07.2014.</STAGEDETAILS><STAGEID type="java.lang.String">167729</STAGEID><STAGERESULT type="java.lang.String">+????????</STAGERESULT><STATE type="java.lang.String">-??????</STATE><SYSTEM_PARAMS type="java.util.Map"><PROFILING type="java.lang.Boolean">false</PROFILING></SYSTEM_PARAMS><TASKID type="java.lang.Long">83795</TASKID><TYPESYSNAME type="java.lang.String">dishargeServiceLoanApp</TYPESYSNAME><TaskTimeSettingsResult type="java.util.Map"/><USERACCOUNTID type="java.lang.String">105004</USERACCOUNTID><USERFIO type="java.lang.String">++-+-+-+- +-++ </USERFIO><USERNAME type="java.lang.String">ogolovanov</USERNAME><WIZARDSYSNAME type="java.lang.String">dishargeServiceLoanApp</WIZARDSYSNAME><application type="java.util.Map"><clientMainDocSeries type="java.lang.String">70 01</clientMainDocSeries><departmentId type="java.lang.String">0</departmentId><CREATIONDATE type="java.util.Date">2014-07-16T10:36:53:279+0400</CREATIONDATE><ownerFullName type="java.lang.String">-???°??? +???? ¦?????????</ownerFullName><clientFactAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientFactAddressString><clientEmail type="java.lang.String"></clientEmail><clientMainDocIssueDate type="java.util.Date">2001-08-04T04:00:00:000+0400</clientMainDocIssueDate><SYSTEM_PARAMS type="java.util.Map"><PROFILING type="java.lang.Boolean">false</PROFILING></SYSTEM_PARAMS><IncludePlanPay type="java.lang.Boolean">false</IncludePlanPay><clientINN type="java.lang.String">-? ??????</clientINN><CREATEDBY type="java.lang.Long">105004</CREATEDBY><CONTRACTSTATE type="java.lang.String">¦???¦???</CONTRACTSTATE><clientMobilePhone type="java.lang.String">8 (910) 5535894</clientMobilePhone><DOCUMENTNUMBER type="java.lang.String">138027</DOCUMENTNUMBER><CURRENTUSER type="java.lang.String">++-+-+-+- +-++ </CURRENTUSER><clientFullName type="java.lang.String">-???°??? +???? ¦?????????</clientFullName><DOCTYPESYSNAME type="java.lang.String">dishargeServiceLoanApp</DOCTYPESYSNAME><cbAddAgreementLook type="java.lang.String">full</cbAddAgreementLook><clientLastName type="java.lang.String">-???°???</clientLastName><CONTRACTID type="java.lang.String">111006</CONTRACTID><AccInfo type="java.lang.String">&lt;b>40817810000012075838&lt;/b>, ???????: &lt;b>8 696.60&lt;/b>, ????? ???: &lt;b>?? ??????????&lt;/b>,&lt;br> ???? ?????????? ?????????  ?????: &lt;b>10.07.2014&lt;/b>, ?? ?????: &lt;b>8 650.00&lt;/b>.</AccInfo><SigningDate type="java.util.Date">2014-05-20T00:00:00:000+0400</SigningDate><addAgreementDate type="java.util.Date">2014-07-21T04:00:00:000+0400</addAgreementDate><CONTRACTDOCTYPESYSNAME type="java.lang.String">loanContract</CONTRACTDOCTYPESYSNAME><RestOut type="java.math.BigDecimal">8696.6</RestOut><BRANCHID type="java.lang.String">0</BRANCHID><STRING1 type="java.lang.String">FTLoanManagement</STRING1><CONTRACTDATE type="java.util.Date">2014-05-20T10:49:15:594+0400</CONTRACTDATE><STRING3 type="java.lang.String">-???°???</STRING3><STRING4 type="java.lang.String">+????</STRING4><STRING5 type="java.lang.String">¦?????????</STRING5><BankProductBrief type="java.lang.String">+????????? "-?? ?????????"</BankProductBrief><EarlyPayingOffAmount type="java.lang.String">361941.86</EarlyPayingOffAmount><ContractExtraInfo type="java.lang.String">?????: &lt;b>366 211.22&lt;/b>, ????: &lt;b>60 ???.&lt;/b>, ????? ?????? ????? ???????: &lt;b>8 623.76&lt;/b></ContractExtraInfo><branchName type="java.lang.String">¦++ ¦- -??? -??</branchName><CURRENTUSERPOSITION type="java.lang.String">-????????</CURRENTUSERPOSITION><clientMainDocType type="java.lang.String">-?????? ?????????? -+</clientMainDocType><clientPostalAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientPostalAddressString><clientFirstName type="java.lang.String">+????</clientFirstName><DOCUMENTTYPE type="java.lang.Long">2218</DOCUMENTTYPE><ClientInputAmount type="java.lang.String">353245.26</ClientInputAmount><clientMainDocIssuerCode type="java.lang.String">713-017</clientMainDocIssuerCode><CONTRACTNUMBER type="java.lang.String">14/¦-/000030</CONTRACTNUMBER><clientRegAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientRegAddressString><DOCTYPENAME type="java.lang.String">-???????? ????°????</DOCTYPENAME><clientMainDocNumber type="java.lang.String">169586</clientMainDocNumber><branchId type="java.lang.String">0</branchId><clientKPP type="java.lang.String">0</clientKPP><CONTRACTTYPEID type="java.lang.String">3002</CONTRACTTYPEID><RecalcMode type="java.lang.String"></RecalcMode><clientMiddleName type="java.lang.String">¦?????????</clientMiddleName><ResponsibleRole type="java.lang.String">LoanAdmContractSupportGroup</ResponsibleRole><WIZARDSYSNAME type="java.lang.String">dishargeServiceLoanApp</WIZARDSYSNAME><OwnerID type="java.lang.Long">100012</OwnerID><EXTCONTRACTID type="java.lang.Long">10000020072</EXTCONTRACTID><INVOKED_FROM_METADATA type="java.lang.Boolean">true</INVOKED_FROM_METADATA><STATE type="java.lang.String">-??????</STATE><curPaymentDate type="java.lang.String">21.07.2014</curPaymentDate><InformationApp type="java.lang.String">-??????, ?????? ??????? ?? ?????? ?? ?????? ????????? ????°????, ???? ????????. -?????? ??????????? ?????????? ????°???  ???????  21.07.2014.</InformationApp><clientMainDocIssuedBy type="java.lang.String">-??????????? ?????????? ??????? +????????? -+-- -??????? ???.</clientMainDocIssuedBy><DOCUMENTID type="java.lang.Long">138027</DOCUMENTID><clientFlagAdditionalDoc type="java.lang.Boolean">true</clientFlagAdditionalDoc><departmentName type="java.lang.String">¦++ ¦- -??? -??</departmentName></application><extraParams type="java.util.Map"><clientBirthDate type="java.lang.String">28.03.1976</clientBirthDate><clientPostalAddressCityType type="java.lang.String">+????</clientPostalAddressCityType><clientRegAddressFlat type="java.lang.String">16</clientRegAddressFlat><isFirstRun type="java.lang.Boolean">true</isFirstRun><clientState type="java.lang.String"></clientState><clientPostalAddressRegionType type="java.lang.String">+??????</clientPostalAddressRegionType><clientFactHousePhoneNumber type="java.lang.String">64719</clientFactHousePhoneNumber><clientFactAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientFactAddressString><FORMS type="java.util.List"><ListItems><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80020</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80021</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80022</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80023</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80024</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item></ListItems></FORMS><clientFactLiveAddressHouse type="java.lang.String">4</clientFactLiveAddressHouse><clientPostalAddressPostalCode type="java.lang.String">301212</clientPostalAddressPostalCode><clientPostalAddressCountry type="java.lang.String">-+--+?</clientPostalAddressCountry><clientRegAddressDistrict type="java.lang.String">-????</clientRegAddressDistrict><clientRegAddressRegionType type="java.lang.String">+??????</clientRegAddressRegionType><clientFactLiveAddressDistrictType type="java.lang.String">-????</clientFactLiveAddressDistrictType><clientPostalAddressStreetType type="java.lang.String">-???????</clientPostalAddressStreetType><clientRegAddressTown type="java.lang.String">-???????????</clientRegAddressTown><clientFactLiveAddressTownType type="java.lang.String">-?????? ???????</clientFactLiveAddressTownType><clientAdditionalDocsTable type="java.util.List"><ListItems><Item type="java.util.Map"><documentTypeName type="java.lang.String">-??????????? ?????????????</documentTypeName><documentSeries type="java.lang.String">71 BA</documentSeries><documentNumber type="java.lang.String">039987</documentNumber><documentType type="java.lang.String">DrivingLicence</documentType><documentIssueDate type="java.util.Date">2008-08-14T04:00:00:000+0400</documentIssueDate><documentIssuedBy type="java.lang.String">++--- 0303</documentIssuedBy></Item></ListItems></clientAdditionalDocsTable><clientPostalAddressHouse type="java.lang.String">4</clientPostalAddressHouse><clientWorkPhoneExt2 type="java.lang.String"></clientWorkPhoneExt2><clientRegAddressPostalCode type="java.lang.String">301212</clientRegAddressPostalCode><clientPostalAddressDistrictType type="java.lang.String">-????</clientPostalAddressDistrictType><clientMobilePhoneNumber2 type="java.lang.String"></clientMobilePhoneNumber2><clientRegAddressStreetType type="java.lang.String">-???????</clientRegAddressStreetType><clientPostalAddressTownType type="java.lang.String">-?????? ???????</clientPostalAddressTownType><clientFactLiveAddressFlat type="java.lang.String">16</clientFactLiveAddressFlat><clientRegAddressCountry type="java.lang.String">-+--+?</clientRegAddressCountry><PAGELIST type="java.lang.String">+???????????  ??????? (+-);80020',
            'DEBUG (ProcessFlowController.java:?) - pars extraparam = <?xml version=1.0 encoding=UTF-8?><BODY version="2.11"><APPLICATIONID type="java.lang.Long">138027</APPLICATIONID><ASSIGNOBJECT type="java.lang.String">102004</ASSIGNOBJECT><CLIENTID type="java.lang.Long">100012</CLIENTID><CLIENTLINKTYPE type="java.lang.String">-?????</CLIENTLINKTYPE><COMMENTARY_PROCESS type="java.lang.String">¦? ??? ¦138027, -????? -???°??? +???? ¦?????????, -?????? ¦14/¦-/000030.</COMMENTARY_PROCESS><DOCPACKAGEID type="java.lang.String">133025</DOCPACKAGEID><EDIT_PATH type="java.lang.String">serviceLoanApp\applicationEarlyPayingOff\task\editApplicationInfo</EDIT_PATH><EXPIRATIONDATE type="java.util.Date">2014-07-16T10:39:42:647+0400</EXPIRATIONDATE><HT_DATA type="java.util.Map"><application type="java.util.Map"><clientMainDocSeries type="java.lang.String">70 01</clientMainDocSeries><departmentId type="java.lang.String">0</departmentId><CREATIONDATE type="java.util.Date">2014-07-16T10:36:53:279+0400</CREATIONDATE><ownerFullName type="java.lang.String">-???°??? +???? ¦?????????</ownerFullName><clientFactAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientFactAddressString><clientEmail type="java.lang.String"></clientEmail><clientMainDocIssueDate type="java.util.Date">2001-08-04T04:00:00:000+0400</clientMainDocIssueDate><SYSTEM_PARAMS type="java.util.Map"><PROFILING type="java.lang.Boolean">false</PROFILING></SYSTEM_PARAMS><IncludePlanPay type="java.lang.Boolean">false</IncludePlanPay><clientINN type="java.lang.String">-? ??????</clientINN><CREATEDBY type="java.lang.Long">105004</CREATEDBY><CONTRACTSTATE type="java.lang.String">¦???¦???</CONTRACTSTATE><clientMobilePhone type="java.lang.String">8 (910) 5535894</clientMobilePhone><DOCUMENTNUMBER type="java.lang.String">138027</DOCUMENTNUMBER><CURRENTUSER type="java.lang.String">++-+-+-+- +-++ </CURRENTUSER><clientFullName type="java.lang.String">-???°??? +???? ¦?????????</clientFullName><DOCTYPESYSNAME type="java.lang.String">dishargeServiceLoanApp</DOCTYPESYSNAME><cbAddAgreementLook type="java.lang.String">full</cbAddAgreementLook><clientLastName type="java.lang.String">-???°???</clientLastName><CONTRACTID type="java.lang.String">111006</CONTRACTID><AccInfo type="java.lang.String">&lt;b>40817810000012075838&lt;/b>, ???????: &lt;b>8 696.60&lt;/b>, ????? ???: &lt;b>?? ??????????&lt;/b>,&lt;br> ???? ?????????? ?????????  ?????: &lt;b>10.07.2014&lt;/b>, ?? ?????: &lt;b>8 650.00&lt;/b>.</AccInfo><SigningDate type="java.util.Date">2014-05-20T00:00:00:000+0400</SigningDate><addAgreementDate type="java.util.Date">2014-07-21T04:00:00:000+0400</addAgreementDate><CONTRACTDOCTYPESYSNAME type="java.lang.String">loanContract</CONTRACTDOCTYPESYSNAME><RestOut type="java.math.BigDecimal">8696.6</RestOut><BRANCHID type="java.lang.String">0</BRANCHID><STRING1 type="java.lang.String">FTLoanManagement</STRING1><CONTRACTDATE type="java.util.Date">2014-05-20T10:49:15:594+0400</CONTRACTDATE><STRING3 type="java.lang.String">-???°???</STRING3><STRING4 type="java.lang.String">+????</STRING4><STRING5 type="java.lang.String">¦?????????</STRING5><BankProductBrief type="java.lang.String">+????????? "-?? ?????????"</BankProductBrief><EarlyPayingOffAmount type="java.lang.String">361941.86</EarlyPayingOffAmount><ContractExtraInfo type="java.lang.String">?????: &lt;b>366 211.22&lt;/b>, ????: &lt;b>60 ???.&lt;/b>, ????? ?????? ????? ???????: &lt;b>8 623.76&lt;/b></ContractExtraInfo><branchName type="java.lang.String">¦++ ¦- -??? -??</branchName><CURRENTUSERPOSITION type="java.lang.String">-????????</CURRENTUSERPOSITION><clientMainDocType type="java.lang.String">-?????? ?????????? -+</clientMainDocType><clientPostalAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientPostalAddressString><clientFirstName type="java.lang.String">+????</clientFirstName><DOCUMENTTYPE type="java.lang.Long">2218</DOCUMENTTYPE><ClientInputAmount type="java.lang.String">353245.26</ClientInputAmount><clientMainDocIssuerCode type="java.lang.String">713-017</clientMainDocIssuerCode><CONTRACTNUMBER type="java.lang.String">14/¦-/000030</CONTRACTNUMBER><clientRegAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientRegAddressString><DOCTYPENAME type="java.lang.String">-???????? ????°????</DOCTYPENAME><clientMainDocNumber type="java.lang.String">169586</clientMainDocNumber><branchId type="java.lang.String">0</branchId><clientKPP type="java.lang.String">0</clientKPP><CONTRACTTYPEID type="java.lang.String">3002</CONTRACTTYPEID><RecalcMode type="java.lang.String"></RecalcMode><clientMiddleName type="java.lang.String">¦?????????</clientMiddleName><ResponsibleRole type="java.lang.String">LoanAdmContractSupportGroup</ResponsibleRole><WIZARDSYSNAME type="java.lang.String">dishargeServiceLoanApp</WIZARDSYSNAME><OwnerID type="java.lang.Long">100012</OwnerID><EXTCONTRACTID type="java.lang.Long">10000020072</EXTCONTRACTID><INVOKED_FROM_METADATA type="java.lang.Boolean">true</INVOKED_FROM_METADATA><STATE type="java.lang.String">-??????</STATE><curPaymentDate type="java.lang.String">21.07.2014</curPaymentDate><InformationApp type="java.lang.String">-??????, ?????? ??????? ?? ?????? ?? ?????? ????????? ????°????, ???? ????????. -?????? ??????????? ?????????? ????°???  ???????  21.07.2014.</InformationApp><clientMainDocIssuedBy type="java.lang.String">-??????????? ?????????? ??????? +????????? -+-- -??????? ???.</clientMainDocIssuedBy><DOCUMENTID type="java.lang.Long">138027</DOCUMENTID><clientFlagAdditionalDoc type="java.lang.Boolean">true</clientFlagAdditionalDoc><departmentName type="java.lang.String">¦++ ¦- -??? -??</departmentName></application><TaskInfo type="java.lang.String">&lt;table cellspacing="10" cellpadding="10">&lt;tr>&lt;td>-?????:&lt;/td>&lt;td>&amp;nbsp;&lt;/td>&lt;td>&lt;b>-???°??? +???? ¦?????????&lt;/b>&lt;/td>&lt;/tr>&lt;tr>&lt;td>-???? ????????:&lt;/td>&lt;td>&amp;nbsp;&lt;/td>&lt;td>&lt;b>14/¦-/000030&lt;/b>&lt;/td>&lt;/tr>&lt;tr>&lt;td>-??????:&lt;/td>&lt;td>&amp;nbsp;&lt;/td>&lt;td>&lt;b>+????????? "-?? ?????????"&lt;/b>&lt;/td>&lt;/tr>&lt;/table></TaskInfo><APPLICATIONID type="java.lang.Long">138027</APPLICATIONID></HT_DATA><INIT_STATESYSNAME type="java.lang.String">inputApp</INIT_STATESYSNAME><PROCESSID type="java.lang.Long">225820</PROCESSID><ROLEID type="java.lang.Long">2018</ROLEID><ResponsibleRole type="java.lang.String">LoanAdmContractSupportGroup</ResponsibleRole><STAGEDATE type="java.util.Date">2014-07-16T10:39:42:648+0400</STAGEDATE><STAGEDETAILS type="java.lang.String">-??????, ?????? ??????? ?? ?????? ?? ?????? ????????? ????°????, ???? ????????. -?????? ??????????? ?????????? ????°???  ???????  21.07.2014.</STAGEDETAILS><STAGEID type="java.lang.String">167729</STAGEID><STAGERESULT type="java.lang.String">+????????</STAGERESULT><STATE type="java.lang.String">-??????</STATE><SYSTEM_PARAMS type="java.util.Map"><PROFILING type="java.lang.Boolean">false</PROFILING></SYSTEM_PARAMS><TASKID type="java.lang.Long">83795</TASKID><TYPESYSNAME type="java.lang.String">dishargeServiceLoanApp</TYPESYSNAME><TaskTimeSettingsResult type="java.util.Map"/><USERACCOUNTID type="java.lang.String">105004</USERACCOUNTID><USERFIO type="java.lang.String">++-+-+-+- +-++ </USERFIO><USERNAME type="java.lang.String">ogolovanov</USERNAME><WIZARDSYSNAME type="java.lang.String">dishargeServiceLoanApp</WIZARDSYSNAME><application type="java.util.Map"><clientMainDocSeries type="java.lang.String">70 01</clientMainDocSeries><departmentId type="java.lang.String">0</departmentId><CREATIONDATE type="java.util.Date">2014-07-16T10:36:53:279+0400</CREATIONDATE><ownerFullName type="java.lang.String">-???°??? +???? ¦?????????</ownerFullName><clientFactAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientFactAddressString><clientEmail type="java.lang.String"></clientEmail><clientMainDocIssueDate type="java.util.Date">2001-08-04T04:00:00:000+0400</clientMainDocIssueDate><SYSTEM_PARAMS type="java.util.Map"><PROFILING type="java.lang.Boolean">false</PROFILING></SYSTEM_PARAMS><IncludePlanPay type="java.lang.Boolean">false</IncludePlanPay><clientINN type="java.lang.String">-? ??????</clientINN><CREATEDBY type="java.lang.Long">105004</CREATEDBY><CONTRACTSTATE type="java.lang.String">¦???¦???</CONTRACTSTATE><clientMobilePhone type="java.lang.String">8 (910) 5535894</clientMobilePhone><DOCUMENTNUMBER type="java.lang.String">138027</DOCUMENTNUMBER><CURRENTUSER type="java.lang.String">++-+-+-+- +-++ </CURRENTUSER><clientFullName type="java.lang.String">-???°??? +???? ¦?????????</clientFullName><DOCTYPESYSNAME type="java.lang.String">dishargeServiceLoanApp</DOCTYPESYSNAME><cbAddAgreementLook type="java.lang.String">full</cbAddAgreementLook><clientLastName type="java.lang.String">-???°???</clientLastName><CONTRACTID type="java.lang.String">111006</CONTRACTID><AccInfo type="java.lang.String">&lt;b>40817810000012075838&lt;/b>, ???????: &lt;b>8 696.60&lt;/b>, ????? ???: &lt;b>?? ??????????&lt;/b>,&lt;br> ???? ?????????? ?????????  ?????: &lt;b>10.07.2014&lt;/b>, ?? ?????: &lt;b>8 650.00&lt;/b>.</AccInfo><SigningDate type="java.util.Date">2014-05-20T00:00:00:000+0400</SigningDate><addAgreementDate type="java.util.Date">2014-07-21T04:00:00:000+0400</addAgreementDate><CONTRACTDOCTYPESYSNAME type="java.lang.String">loanContract</CONTRACTDOCTYPESYSNAME><RestOut type="java.math.BigDecimal">8696.6</RestOut><BRANCHID type="java.lang.String">0</BRANCHID><STRING1 type="java.lang.String">FTLoanManagement</STRING1><CONTRACTDATE type="java.util.Date">2014-05-20T10:49:15:594+0400</CONTRACTDATE><STRING3 type="java.lang.String">-???°???</STRING3><STRING4 type="java.lang.String">+????</STRING4><STRING5 type="java.lang.String">¦?????????</STRING5><BankProductBrief type="java.lang.String">+????????? "-?? ?????????"</BankProductBrief><EarlyPayingOffAmount type="java.lang.String">361941.86</EarlyPayingOffAmount><ContractExtraInfo type="java.lang.String">?????: &lt;b>366 211.22&lt;/b>, ????: &lt;b>60 ???.&lt;/b>, ????? ?????? ????? ???????: &lt;b>8 623.76&lt;/b></ContractExtraInfo><branchName type="java.lang.String">¦++ ¦- -??? -??</branchName><CURRENTUSERPOSITION type="java.lang.String">-????????</CURRENTUSERPOSITION><clientMainDocType type="java.lang.String">-?????? ?????????? -+</clientMainDocType><clientPostalAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientPostalAddressString><clientFirstName type="java.lang.String">+????</clientFirstName><DOCUMENTTYPE type="java.lang.Long">2218</DOCUMENTTYPE><ClientInputAmount type="java.lang.String">353245.26</ClientInputAmount><clientMainDocIssuerCode type="java.lang.String">713-017</clientMainDocIssuerCode><CONTRACTNUMBER type="java.lang.String">14/¦-/000030</CONTRACTNUMBER><clientRegAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientRegAddressString><DOCTYPENAME type="java.lang.String">-???????? ????°????</DOCTYPENAME><clientMainDocNumber type="java.lang.String">169586</clientMainDocNumber><branchId type="java.lang.String">0</branchId><clientKPP type="java.lang.String">0</clientKPP><CONTRACTTYPEID type="java.lang.String">3002</CONTRACTTYPEID><RecalcMode type="java.lang.String"></RecalcMode><clientMiddleName type="java.lang.String">¦?????????</clientMiddleName><ResponsibleRole type="java.lang.String">LoanAdmContractSupportGroup</ResponsibleRole><WIZARDSYSNAME type="java.lang.String">dishargeServiceLoanApp</WIZARDSYSNAME><OwnerID type="java.lang.Long">100012</OwnerID><EXTCONTRACTID type="java.lang.Long">10000020072</EXTCONTRACTID><INVOKED_FROM_METADATA type="java.lang.Boolean">true</INVOKED_FROM_METADATA><STATE type="java.lang.String">-??????</STATE><curPaymentDate type="java.lang.String">21.07.2014</curPaymentDate><InformationApp type="java.lang.String">-??????, ?????? ??????? ?? ?????? ?? ?????? ????????? ????°????, ???? ????????. -?????? ??????????? ?????????? ????°???  ???????  21.07.2014.</InformationApp><clientMainDocIssuedBy type="java.lang.String">-??????????? ?????????? ??????? +????????? -+-- -??????? ???.</clientMainDocIssuedBy><DOCUMENTID type="java.lang.Long">138027</DOCUMENTID><clientFlagAdditionalDoc type="java.lang.Boolean">true</clientFlagAdditionalDoc><departmentName type="java.lang.String">¦++ ¦- -??? -??</departmentName></application><extraParams type="java.util.Map"><clientBirthDate type="java.lang.String">28.03.1976</clientBirthDate><clientPostalAddressCityType type="java.lang.String">+????</clientPostalAddressCityType><clientRegAddressFlat type="java.lang.String">16</clientRegAddressFlat><isFirstRun type="java.lang.Boolean">true</isFirstRun><clientState type="java.lang.String"></clientState><clientPostalAddressRegionType type="java.lang.String">+??????</clientPostalAddressRegionType><clientFactHousePhoneNumber type="java.lang.String">64719</clientFactHousePhoneNumber><clientFactAddressString type="java.lang.String">301212, -+--+?, +?????? -?????? , -???? +????????, -?????? ??????? -???????????, -??????? +??????, ?.4, ??.16</clientFactAddressString><FORMS type="java.util.List"><ListItems><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80020</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80021</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80022</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80023</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item><Item type="java.util.Map"><ISMAININFO type="java.lang.Boolean">false</ISMAININFO><FORM type="java.lang.Long">80024</FORM><ERROR type="java.lang.String"></ERROR><VERIFIED type="java.lang.Boolean">false</VERIFIED></Item></ListItems></FORMS><clientFactLiveAddressHouse type="java.lang.String">4</clientFactLiveAddressHouse><clientPostalAddressPostalCode type="java.lang.String">301212</clientPostalAddressPostalCode><clientPostalAddressCountry type="java.lang.String">-+--+?</clientPostalAddressCountry><clientRegAddressDistrict type="java.lang.String">-????</clientRegAddressDistrict><clientRegAddressRegionType type="java.lang.String">+??????</clientRegAddressRegionType><clientFactLiveAddressDistrictType type="java.lang.String">-????</clientFactLiveAddressDistrictType><clientPostalAddressStreetType type="java.lang.String">-???????</clientPostalAddressStreetType><clientRegAddressTown type="java.lang.String">-???????????</clientRegAddressTown><clientFactLiveAddressTownType type="java.lang.String">-?????? ???????</clientFactLiveAddressTownType><clientAdditionalDocsTable type="java.util.List"><ListItems><Item type="java.util.Map"><documentTypeName type="java.lang.String">-??????????? ?????????????</documentTypeName><documentSeries type="java.lang.String">71 BA</documentSeries><documentNumber type="java.lang.String">039987</documentNumber><documentType type="java.lang.String">DrivingLicence</documentType><documentIssueDate type="java.util.Date">2008-08-14T04:00:00:000+0400</documentIssueDate><documentIssuedBy type="java.lang.String">++--- 0303</documentIssuedBy></Item></ListItems></clientAdditionalDocsTable><clientPostalAddressHouse type="java.lang.String">4</clientPostalAddressHouse><clientWorkPhoneExt2 type="java.lang.String"></clientWorkPhoneExt2><clientRegAddressPostalCode type="java.lang.String">301212</clientRegAddressPostalCode><clientPostalAddressDistrictType type="java.lang.String">-????</clientPostalAddressDistrictType><clientMobilePhoneNumber2 type="java.lang.String"></clientMobilePhoneNumber2><clientRegAddressStreetType type="java.lang.String">-???????</clientRegAddressStreetType><clientPostalAddressTownType type="java.lang.String">-?????? ???????</clientPostalAddressTownType><clientFactLiveAddressFlat type="java.lang.String">16</clientFactLiveAddressFlat><clientRegAddressCountry type="java.lang.String">-+--+?</clientRegAddressCountry><PAGELIST type="java.lang.String">+???????????  ??????? (+-);80020',
            '[pool-9-thread-31] ERROR (ProcessFlowController.java:187) - exiting with error 4044871, node name = -??????? ????????',
            '[WebContainer : 113] ERROR (ProcessFlowController.java:187) - exiting with error 4061539, node name = +???????  ?????',
            '[WebContainer : 239] ERROR (ProcessFlowController.java:187) - exiting with error 4546723, node name = -???????? USERACCOUNTIDFaultCode=500, FaultMessage=""',
            '[WebContainer : 22] ERROR (ProcessFlowController.java:184) - exiting with error 6759143, node name = Сценарий найден?'
        ]
        page_flow_errors = [
            'DEBUG (PageFlowExtActionNode.java:?) - login = verus3 result = {Status=OK, lastErrorStack={Result=[{PARAMS={MSGTXT=Parameter: clientGender and default value is null.  }, MSGCODE=500}]}, RetCode=0}',
            'DEBUG (PageFlowExtActionNode.java:?) - login = lrgafarova result = {Status=OK, lastErrorStack={Result=[{PARAMS={MSGTXT=Value autoLoanApp is not a number.}, MSGCODE=500}]}, RetCode=0}',
            'ERROR (PageFlowNode.java:314) - login = frontadmin Error occured while calling service http://lpar-was:9083/adminws/adminws?dsUserList!
FaultCode=403, FaultMessage="Error occured while calling service http://lpar-was:9083/corews/corews?checksession!
FaultCode=500, FaultMessage=""
Caused by: ru.diasoft.fa.platform.auth.AuthenticationFailedException: User is not authenticated
FaultCode=500, FaultMessage=""
Caused by: ru.diasoft.fa.platform.auth.AuthenticationFailedException: User is not authenticated
FaultCode=403, FaultMessage="Error occured while calling service http://lpar-was:9083/corews/corews?checksession!
FaultCode=500, FaultMessage=""
Caused by: ru.diasoft.fa.platform.auth.AuthenticationFailedException: User is not authenticated
FaultCode=500, FaultMessage=""
Caused by: ru.diasoft.fa.platform.auth.AuthenticationFailedException: User is not authenticated  ERROR (PageFlowNode.java:315) - login = frontadmin exiting with error pageflow COMMON/TASK/taskList2 node -???????? ?????????????',
            'DEBUG (PageFlowExtActionNode.java:?) - login = nfrolov result = {Status=OK, lastErrorStack={Result=[{PARAMS={MSGTXT=Value autoLoanApp is not a number.}, MSGCODE=500}]}, RetCode=0}',
            'DEBUG (PageFlowExtActionNode.java:?) - login = evvolchenkova5 result = {Status=OK, lastErrorStack={Result=[{PARAMS={MSGTXT=Value autoLoanApp is not a number.}, MSGCODE=500}]}, RetCode=0}',
            'DEBUG (PageFlowExtActionNode.java:?) - login = aimalyshev result = {Status=OK, lastErrorStack={Result=[{PARAMS={MSGTXT=Value autoLoanApp is not a number.}, MSGCODE=500}]}, RetCode=0}',
            ' ERROR (PageFlowNode.java:257) - login = AChuchelina pageflow loanApp/autoLoanApp/showApplication/showDoc node Обработка данных has no error links and no parent process, stop work on process'
        ]
        
        #for i in 1..rand(5000..20000)
        #            @start_time=DateTime.new(2016,rand(9..11),rand(1..30),rand(8..21),rand(0..59),rand(0..59))
        #
        #            FlexteraPageFlowError.create(
        #                :message => page_flow_errors[rand(1..page_flow_errors.length) - 1],
        #                :date => @start_time
        #            )
        #            FlexteraProcContError.create(
        #                :message => proc_cont_errors[rand(1..proc_cont_errors.length) - 1],
        #                :date => @start_time
        #            )
        #end
        
        #ActiveRecord::Base.transaction do
        #    ActiveDatum.joins(:operation).where('"operations"."operation_source_id" = 1').all.each do |row|
        #        row.update(:module => modules[rand(1..modules.length) - 1], :node => nodes[rand(1..nodes.length) - 1])
        #    end
        #end
        
        #if OperationType.count == 0
        #    @oper_type.each do |type|
        #        OperationType.create(:name => type)
        #    end
        #end
        #if Office.count == 0
        #    @office_list.each do |office|
        #        Office.create(:name => office)
        #    end
        #end
        #if Login.count == 0
        #    @user_list.each do |user|
        #        Login.create(:name => user, :office_id => rand(1..@office_list.length))
        #    end
        #end
        #if Operation.count == 0
        #    @oper_list.each do |oper|
        #        @sys_avg=rand(1..100)
        #        @user_avg=rand(1..1000)
        #        Operation.create(
        #            :name => oper, 
        #            :time_avg => @sys_avg+@user_avg, 
        #            :sys_time_avg => @sys_avg, 
        #            :user_time_avg => @user_avg, 
        #            :count_avg => rand(1..1000), 
        #            :operation_type_id => rand(1..@oper_type.length),
        #            :kpi => 1.15,
        #            :operation_source_id => rand(1..2)
        #        )
        #    end
        #end
        #if OperationServer.count == 0
        #    OperationServer.create(:name => 'Продуктивный')
        #    OperationServer.create(:name => 'Тестовый')
        #    OperationServer.create(:name => 'Разработки')
        #end
        
        #ActiveDatum.all.each do |row|
         #   if row[:operation_server_id] == nil
        #        row.update(:operation_server_id => rand(1..3))
        #    end
        #end
       # Operation.all.each do |row|
        #    if row[:operation_source_id] == nil
       #         row.update(:operation_source_id => rand(1..2))
       #     end
       # end
       # for i in 1..rand(100000..100000)
       #     @date = Date.today
       #     @start_time=DateTime.new(2016,rand(10..11),rand(1..30),rand(8..21),rand(0..59),rand(0..59))
       #     @sys_time=rand(1..100)*@start_time.wday*(rand(1..@user_list.length)/3.14)
       #     @user_time=rand(1..1000)*@start_time.wday*(rand(1..@user_list.length)/3.14)
       #     @end_time=@start_time + (@sys_time+@user_time).seconds
       #     ActiveDatum.create(
       #         :operation_id => rand(1..@oper_list.length),
       #         :login_id => rand(1..@user_list.length), 
       #         :start_time => @start_time,
       #         :end_time => @end_time,
       #         :duration => @sys_time+@user_time,
       #         :sys_time => @sys_time,
       #         :user_time => @user_time,
       #         :operation_server_id => rand(1..3),
       #         :module => modules[rand(1..modules.length) - 1], 
       #         :node => nodes[rand(1..nodes.length) - 1]
       #     )
       # end
        
       
        render :text => 'ok'
        
    end
    def get_perfomance_data
        @result=[]
        @source_array=ActiveDatum.global_filter(session[:user_id]).check_period(params[:start_time],params[:end_time])
        @page_offset=(params[:page].to_f-1)*params[:offset].to_f
        @data=@source_array\
        .group(:operation_id).time_select('avg') \
        .select(
            'COUNT(login_id) as count',
            :operation_id 
        )
        if params[:foid].to_i > 0 
            @data=@data.where(:operation_id => params[:foid])
        end
        @opers=Operation.joins(:operation_type,:operation_source).operation_name('name').select(:short_name,:color,:time_avg,:sys_time_avg,:user_time_avg,:count_avg,:kpi,:id,'"operation_types"."name" as type_name')
        @detailed_info={:red => 0,:yellow => 0, :green => 0, :unique => @data.length, :count => 0}
        @data.each do |row|
            for i in 0..@opers.length-1
                if row[:operation_id] == @opers[i][:id]
                    @result.push({
                        'name' => @opers[i][:name],
                        'type_name' => @opers[i][:type_name],
                        'duration' => row[:duration],
                        'sys_time' => row[:sys_time],
                        'user_time' => row[:user_time],
                        'count' => row[:count],
                        'duration_avg' => @opers[i][:time_avg],
                        'sys_time_avg' => @opers[i][:sys_time_avg],
                        'user_time_avg' => @opers[i][:user_time_avg],
                        'count_avg' => @opers[i][:count_avg],
                        'status' => row[:user_time]/@opers[i][:user_time_avg],
                        'kpi' => @opers[i][:kpi],
                        'operation_id' => row[:operation_id],
                        'short_name' => @opers[i][:short_name],
                        'color' => @opers[i][:color],
                    })
                    
                    @detailed_info[:count]+=row[:count]
                    @status=row[:duration]/@opers[i][:time_avg]
                    if @status <= 1
                        @detailed_info[:green]+=1
                    elsif @status <= @opers[i][:kpi] && @status > 1
                        @detailed_info[:yellow]+=1
                    else
                        @detailed_info[:red]+=1
                    end
                    i=@opers.length
                end
            end
        end
        page_offset=(params[:page].to_f-1)*params[:offset].to_f
        
        gt_table_export(params[:export],@result,params[:headers]) && return
        
        render :text => {
                            :data => format_array_for_table(@result,params[:order],params[:page],params[:offset]), 
                            :count => @result.length, 
                            :detailed_info => @detailed_info
                        }.to_json
    end
    
    
    ######### Operations Activity ###################
      def get_activity_hour
    		output_array=[]
		
    		count_array=ActiveDatum.global_filter(session[:user_id]).check_period(params[:start_time],params[:end_time])
    		if params[:foid].to_f > 0
    			count_array=count_array.where(:operation_id => params[:foid])
    		end
    		count_array=count_array\
    			.select(
    				'COUNT(login_id) as count'
				
    			).perfomance_data('count')\
    			.time_part_group('hour','end_time')\
    			.joins(:operation)
		
    		history_start=(params[:end_time].to_date - 84)
    		history_end=(params[:end_time].to_date - 1)
    		week_day=params[:end_time].to_date.wday
		
    		history_array=ActiveDatum.global_filter(session[:user_id]).check_period(history_start.strftime("%d.%m.%Y"),history_end.strftime("%d.%m.%Y"))
    		if params[:foid].to_f > 0
    			history_array=history_array.where(:operation_id => params[:foid])
    		end
    		history_array=history_array\
    			.time_part_group('hour','end_time')\
    			.time_part_where('day week','end_time',week_day,'=')
        if $active_db == "sqlserver"
            history_array=history_array.select('COUNT(login_id)/count(distinct(cast(end_time as date))) as count')
        else
            history_array=history_array.select('COUNT(login_id)/count(distinct(end_time::date)) as count')
        end
    		output_array.push({:count => count_array, :history => history_array})
    		render :text=> output_array.to_json(:except => [ :created_at, :updated_at ])	
      end
  
      def get_activity_top
    		output_array=[]
    		count_array=ActiveDatum.global_filter(session[:user_id]).check_period(params[:start_time],params[:end_time])
    		count_array=count_array.joins(:operation).operation_name('name')\
    			.select(
    				'COUNT(login_id) as count',
    				:operation_id
    			).time_part_group('hour','end_time')\
          .time_part_where('hour','end_time',params[:hour],'=')\
    			.operation_name_group.group(:operation_id).order('count DESC').take(30)
    		render :text=> count_array.to_json(:except => [ :created_at, :updated_at ])
      end

    #################################
    
    ######### Operations Map ###################
      def get_operation_map
    	source_array=ActiveDatum.global_filter(session[:user_id]).check_period(params[:start_time],params[:end_time])
    	data=source_array.joins(:login,:operation).login_name('loginname').start_end_time().select(
    		 :duration,
             'user_time/user_time_avg as status',
             :kpi,
    		 :user_time,
    		 :sys_time,
             :time_avg,
             :user_time_avg,
             :sys_time_avg,
    		 :id,
             :login_id
    		).where(:operation_id => params[:FO_ID])
    	systime=source_array.select(
    			'SUM(sys_time)/SUM(duration) as percents'
    		).where(:operation_id => params[:FO_ID])
    	graph=source_array.joins(:login,:operation).login_name('loginname').start_end_time().select(
    			'duration as duration',
    			:user_time,
    			:sys_time,
                :login_id,
    			:id,
				'(CASE 	
                    WHEN (user_time/user_time_avg) <= 1 THEN 1 
					WHEN (user_time/user_time_avg) > 1 and (user_time/user_time_avg) <= kpi THEN 2
					ELSE 3
				END) as status'
    		).where(:operation_id => params[:FO_ID]).order('end_time ASC')
       data_json=data.as_json
       count_oper=0
       full_time=0
       user_time=0
       sys_time=0
       users=[]
       data_json.each do |item|
          count_oper+=1
          full_time+=item["duration"]
          user_time+=item["user_time"]
          sys_time+=item["sys_time"]
          users.push({:user => item["login_id"], :name => item["loginname"]})

       end
       users=users.uniq
       full_info={:full => full_time,:user => user_time, :sys => sys_time, :count => count_oper, :users => users.length, :users_list => users}
       if params[:FO_ID].to_i > 0
           midline=Operation.find(params[:FO_ID])[:time_avg]
       end
       
       gt_table_export(params[:export],data,params[:headers]) && return
       
       render :text=> {
                       :count => source_array.where(:operation_id => params[:FO_ID]).count, 
                       :data => format_array_for_table(data,params[:order],params[:page],params[:offset]), 
                       :systime => systime, 
                       :graph => graph, 
                       :midline => midline, 
                       :full_info => full_info
                   }.to_json
    end 
    
    ######### Operations prediction ###################
	def get_oper_prediction
		output_array=[]
		source_array=ActiveDatum.global_filter(session[:user_id]).check_period(params[:start_time],params[:end_time])
		data=source_array\
		.group_by_date.time_select('avg')\
		.select(
			'COUNT(login_id) as opercount'
		)
		if params[:foid].to_i > 0
			data=data.where(:operation_id => params[:foid])
		end
		if params[:loginid].to_i > 0
			data=data.where(:login_id => params[:loginid])
		end
		render :text=> data.to_json(:except => [ :created_at, :updated_at ])
	end
    
    
    
    ############ Operations map/period #######################
    def get_oper_map_period_graph
        data = oper_map_period_get_data(params[:operation_id],params[:start_time],params[:end_time])
        render :text=> data.to_json
    end
    def get_oper_map_period_table
		graph_array = oper_map_period_get_data(params[:operation_id],params[:start_time],params[:end_time]) 
        gt_table_export(params[:export],graph_array,params[:headers]) && return
    	render :text=> 	{:data => format_array_for_table(graph_array,params[:order],params[:page],params[:offset]), :count => graph_array.length}.to_json
    end
    
end


private

def oper_map_period_get_data(id,start_time,end_time)
	source_array=ActiveDatum.global_filter(session[:user_id]).check_period(start_time,end_time)
	data=source_array\
	.group_by_date.time_select('avg')\
	.select(
        'COUNT(DISTINCT(login_id)) as unique_user',
		'COUNT(login_id) as opercount'
	)
    if id.to_i > 0
        data=data.where(:operation_id => id)
    end
    return data
end
