SEND FRO — различия между версиями

Материал из Фабиус wiki
Перейти к: навигация, поиск
м (Смотрите также)
м
Строка 1: Строка 1:
 
[[SEND_FRO]] - это программа из справочника [[R266]]
 
[[SEND_FRO]] - это программа из справочника [[R266]]
 
+
= Текст =
  local ip, my, end_data, fro, filt, sql, conn, path, msg
+
  local ip, my, end_data, fro, filt, sql, conn, path, msg, nrmtid
 +
// NRMT
 +
nrmtid := GetFromIniFile( 'NRMTID' )
 +
path := GetPrm( 'CASHBOX', 'CASH_SHOP' )
 +
nrmtid := 0
 
   
 
   
// path := [[GetPrm]]( 'SHP_PATH', 'SHOPOPER' )
+
  ip := InputPeriod( true )
path := [[GetPrm]]( 'CASHBOX', 'CASH_SHOP' )
+
  if Empty( ip )
+
  ip := [[InputPeriod]]( true )
+
  if [[Empty]]( ip )
+
 
   return
 
   return
 
  endif
 
  endif
  my := [[StoD]]( ip[1] )
+
  my := StoD( ip[1] )
  end_data := [[StoD]]( ip[2] ) + 1
+
  end_data := StoD( ip[2] ) + 1
 
  while my <> end_data
 
  while my <> end_data
 
   
 
   
 
   try
 
   try
     conn := CreateConnection( path, 'adm1user', "ora=11" )
+
     conn := CreateConnection( path, 'admuser', "ora=111" )
 
     fro := OpenFData( 'DOCP' + Ret_f_ext( my ), 'DOCS', false, OpdataPath, 'DOCS' )
 
     fro := OpenFData( 'DOCP' + Ret_f_ext( my ), 'DOCS', false, OpdataPath, 'DOCS' )
     filt := [ KINDDOC = '[[FRO]]' and DtoS( DATDOC ) = '] + DtoS( my ) + [' ]
+
     filt := [ KINDDOC = 'FRO' and DtoS( DATDOC ) = '] + DtoS( my ) + [' ]
 
     ( fro )->( SetFilter( filt ) )
 
     ( fro )->( SetFilter( filt ) )
 
     ( fro )->( DbGoTop() )
 
     ( fro )->( DbGoTop() )
 
   
 
   
 
     WaitMsg( 'Очистка документов FRO', msg )
 
     WaitMsg( 'Очистка документов FRO', msg )
     sql := [ Delete From DOCP] + Ret_f_ext( my ) + [ Where KINDDOC = 'FRO' and DATDOC = '] + SqlDate( my )+ [' and DREFL2 = 'R179' and DANAL2 = ] + ( fro )->DANAL2
+
     if !Empty( nrmtid )
 +
      sql := [ Delete From DOCP] + Ret_f_ext( my ) + [ Where KINDDOC = 'FRO' and DATDOC = '] + SqlDate( my )+ [' and NRMT = '] + nrmtid + [' ]
 +
    else
 +
      sql := [ Delete From DOCP] + Ret_f_ext( my ) + [ Where KINDDOC = 'FRO' and DATDOC = '] + SqlDate( my )+ [' and DREFL2 = 'R179' and DANAL2 = ] + ( fro )->DANAL2
 +
    endif
 
     SimpleSql( sql, conn )
 
     SimpleSql( sql, conn )
 
   
 
   
Строка 30: Строка 35:
 
       ( fro )->EXTPARENT := ( fro )->RGNUM
 
       ( fro )->EXTPARENT := ( fro )->RGNUM
 
       sql := [ Insert into DOCP] + Ret_f_ext( my ) + [ ;
 
       sql := [ Insert into DOCP] + Ret_f_ext( my ) + [ ;
         ( "SUM", AMNT, DSHIFT, KSHIFT, M_TEXT, NUMDOC, NATTR1, NATTR2, NATTR3, NATTR4, ;
+
         ( NRMT, "SUM", AMNT, DSHIFT, KSHIFT, M_TEXT, NUMDOC, NATTR1, NATTR2, NATTR3, NATTR4, ;
 
           NATTR5, NATTR6, NATTR7, NATTR8, NATTR9, NATTR10, KINDDOC, LVLNUM, PARENT, ;
 
           NATTR5, NATTR6, NATTR7, NATTR8, NATTR9, NATTR10, KINDDOC, LVLNUM, PARENT, ;
 
           DATDOC, EXTPARENT, DREFL1, DANAL1, D1NAME, DREFL2, DANAL2, D2NAME, DREFL3, DANAL3, D3NAME, ;
 
           DATDOC, EXTPARENT, DREFL1, DANAL1, D1NAME, DREFL2, DANAL2, D2NAME, DREFL3, DANAL3, D3NAME, ;
 
           KREFL1, KANAL1, K1NAME, KREFL2, KANAL2, K2NAME, KREFL3, KANAL3, K3NAME ) ;
 
           KREFL1, KANAL1, K1NAME, KREFL2, KANAL2, K2NAME, KREFL3, KANAL3, K3NAME ) ;
         VALUES ( ] + atr( str( ( fro )->SUM, 19, 4, '.' ) ) + [, ] + ;
+
         VALUES ( '] + ( fro )->NRMT + [', ] + atr( str( ( fro )->SUM, 19, 4, '.' ) ) + [, ] + ;
 
         atr( str( ( fro )->AMNT, 19, 4, '.' ) ) + [, '] + ;
 
         atr( str( ( fro )->AMNT, 19, 4, '.' ) ) + [, '] + ;
 
         ( fro )->DSHIFT + [', '] + ;
 
         ( fro )->DSHIFT + [', '] + ;
 
         ( fro )->KSHIFT + [', '] + ;
 
         ( fro )->KSHIFT + [', '] + ;
         ( fro )->M_TEXT + [', '] + ;
+
         STRTRAN( ( fro )->M_TEXT, ['], ["] ) + [', '] + ;
 
         ( fro )->NUMDOC + [', ] + ;
 
         ( fro )->NUMDOC + [', ] + ;
 
         atr( str( ( fro )->NATTR1, 19, 4, '.' ) ) + [, ] + ;
 
         atr( str( ( fro )->NATTR1, 19, 4, '.' ) ) + [, ] + ;
Строка 69: Строка 74:
 
         ( fro )->KREFL2 + [', ] + ;
 
         ( fro )->KREFL2 + [', ] + ;
 
         ( fro )->KANAL2 + [, '] + ;
 
         ( fro )->KANAL2 + [, '] + ;
         ( fro )->K2NAME + [', '] + ;
+
         STRTRAN( ( fro )->K2NAME, ['], ["] ) + [', '] + ;
 
         ( fro )->KREFL3 + [', ] + ;
 
         ( fro )->KREFL3 + [', ] + ;
 
         ( fro )->KANAL3 + [, '] + ;
 
         ( fro )->KANAL3 + [, '] + ;
Строка 81: Строка 86:
 
   
 
   
 
     // заполняем RGNUM'ы
 
     // заполняем RGNUM'ы
     sql := [ Update DOCP] + Ret_f_ext( my ) + [ Set RGNUM = Right( '        ' + Trim( Convert( AUTOID, sql_char ) ), 8 ) Where RGNUM = '' ]
+
     sql := [ Update DOCP] + Ret_f_ext( my ) + [ Set RGNUM = Right( '        ' + Trim( Convert( AUTOID, sql_char ) ), 8 ) ;
 +
      Where KINDDOC = 'FRO' and RGNUM = '' and DATDOC= '] + SqlDate( my ) + [' and DREFL2 = 'R179' and DANAL2 = ] + ( fro )->DANAL2
 
     SimpleSql( sql, conn )
 
     SimpleSql( sql, conn )
 
   
 
   
 +
    // BIG BUG
 +
    // так как я не указал KINDDOC то ломались случайные документы в базе DOCP
 
     sql := [ Update d Set d.PARENT = dd.RGNUM From DOCP] + Ret_f_ext( my ) + [ d left outer join DOCP] + Ret_f_ext( my ) + [ dd ON d.PARENT = dd.EXTPARENT ;
 
     sql := [ Update d Set d.PARENT = dd.RGNUM From DOCP] + Ret_f_ext( my ) + [ d left outer join DOCP] + Ret_f_ext( my ) + [ dd ON d.PARENT = dd.EXTPARENT ;
       Where d.LVLNUM = '2' and dd.LVLNUM = '1' ]
+
       Where d.KINDDOC = 'FRO' and dd.KINDDOC = 'FRO' and d.LVLNUM = '2' and dd.LVLNUM = '1' and d.DATDOC = '] + SqlDate( my ) + [' and ;
 +
        dd.DATDOC = '] + SqlDate( my ) + [' and d.DREFL2 = 'R179' and d.DANAL2 = ] + ( fro )->DANAL2 + [ and dd.DREFL2 = 'R179' and dd.DANAL2 = ] + ( fro )->DANAL2
 +
    SimpleSql( sql, conn )
 +
 +
    // очищаем EXTPARENT
 +
    sql := [ Update DOCP] + Ret_f_ext( my ) + [ Set EXTPARENT = '' Where KINDDOC = 'FRO' and DATDOC = '] + SqlDate( my ) + [' and DREFL2 = 'R179' and DANAL2 = ] + ( fro )->DANAL2
 
     SimpleSql( sql, conn )
 
     SimpleSql( sql, conn )
 
   
 
   
Строка 105: Строка 118:
 
  // path := '\\192.168.234.15:5050\vol1\FabiusWIN\data\srg\reflis\dict.add'
 
  // path := '\\192.168.234.15:5050\vol1\FabiusWIN\data\srg\reflis\dict.add'
 
  // try
 
  // try
  //  conn := CreateConnection( path, 'adm1user', "ora=11" )
+
  //  conn := CreateConnection( path, 'admuser', "ora=1" )
 
  //  sql := [ Select * From R09 ]
 
  //  sql := [ Select * From R09 ]
 
  //  t := SelectSql( sql, conn )
 
  //  t := SelectSql( sql, conn )
Строка 112: Строка 125:
 
  //  CloseTable( t )
 
  //  CloseTable( t )
 
  // end
 
  // end
 
+
= Смотрите также =
+
// наш сервер
 +
// path := '\\192.168.234.15:5050\vol1\FabiusWIN\data\srg\reflis\dict.add'
 +
 +
// Жуковский
 +
// path := '\\4.7.47.51:5050\data\fabius\reflis\dict.add'= Смотрите также =
 
[[Полезные функции]]
 
[[Полезные функции]]
  
 
[[Функции Delphi]]
 
[[Функции Delphi]]

Версия 16:13, 17 июля 2017

SEND_FRO - это программа из справочника R266

Текст

local ip, my, end_data, fro, filt, sql, conn, path, msg, nrmtid
// NRMT
nrmtid := GetFromIniFile( 'NRMTID' )
path := GetPrm( 'CASHBOX', 'CASH_SHOP' )
nrmtid := 0

ip := InputPeriod( true )
if Empty( ip )
  return
endif
my := StoD( ip[1] )
end_data := StoD( ip[2] ) + 1
while my <> end_data

  try
    conn := CreateConnection( path, 'admuser', "ora=111" )
    fro := OpenFData( 'DOCP' + Ret_f_ext( my ), 'DOCS', false, OpdataPath, 'DOCS' )
    filt := [ KINDDOC = 'FRO' and DtoS( DATDOC ) = '] + DtoS( my ) + [' ]
    ( fro )->( SetFilter( filt ) )
    ( fro )->( DbGoTop() )

    WaitMsg( 'Очистка документов FRO', msg )
    if !Empty( nrmtid )
      sql := [ Delete From DOCP] + Ret_f_ext( my ) + [ Where KINDDOC = 'FRO' and DATDOC = '] + SqlDate( my )+ [' and NRMT = '] + nrmtid + [' ]
    else
      sql := [ Delete From DOCP] + Ret_f_ext( my ) + [ Where KINDDOC = 'FRO' and DATDOC = '] + SqlDate( my )+ [' and DREFL2 = 'R179' and DANAL2 = ] + ( fro )->DANAL2
    endif
    SimpleSql( sql, conn )

    while !( fro )->( eof() )
      WaitMsg( a_s( ( fro )->AUTOID ), msg )

      ( fro )->EXTPARENT := ( fro )->RGNUM
      sql := [ Insert into DOCP] + Ret_f_ext( my ) + [ ;
        ( NRMT, "SUM", AMNT, DSHIFT, KSHIFT, M_TEXT, NUMDOC, NATTR1, NATTR2, NATTR3, NATTR4, ;
          NATTR5, NATTR6, NATTR7, NATTR8, NATTR9, NATTR10, KINDDOC, LVLNUM, PARENT, ;
          DATDOC, EXTPARENT, DREFL1, DANAL1, D1NAME, DREFL2, DANAL2, D2NAME, DREFL3, DANAL3, D3NAME, ;
          KREFL1, KANAL1, K1NAME, KREFL2, KANAL2, K2NAME, KREFL3, KANAL3, K3NAME ) ;
        VALUES ( '] + ( fro )->NRMT + [', ] + atr( str( ( fro )->SUM, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->AMNT, 19, 4, '.' ) ) + [, '] + ;
        ( fro )->DSHIFT + [', '] + ;
        ( fro )->KSHIFT + [', '] + ;
        STRTRAN( ( fro )->M_TEXT, ['], ["] ) + [', '] + ;
        ( fro )->NUMDOC + [', ] + ;
        atr( str( ( fro )->NATTR1, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->NATTR2, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->NATTR3, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->NATTR4, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->NATTR5, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->NATTR6, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->NATTR7, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->NATTR8, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->NATTR9, 19, 4, '.' ) ) + [, ] + ;
        atr( str( ( fro )->NATTR10, 19, 4, '.' ) ) + [, '] + ;
        ( fro )->KINDDOC + [', '] + ;
        ( fro )->LVLNUM + [', '] + ;
        ( fro )->PARENT + [', '] + ;
        SqlDate( ( fro )->DATDOC ) + [', '] + ;
        ( fro )->EXTPARENT + [', '] + ;
        ( fro )->DREFL1 + [', ] + ;
        ( fro )->DANAL1 + [, '] + ;
        ( fro )->D1NAME + [', '] + ;
        ( fro )->DREFL2 + [', ] + ;
        ( fro )->DANAL2 + [, '] + ;
        ( fro )->D2NAME + [', '] + ;
        ( fro )->DREFL3 + [', ] + ;
        ( fro )->DANAL3 + [, '] + ;
        ( fro )->D3NAME + [', '] + ;
        ( fro )->KREFL1 + [', ] + ;
        ( fro )->KANAL1 + [, '] + ;
        ( fro )->K1NAME + [', '] + ;
        ( fro )->KREFL2 + [', ] + ;
        ( fro )->KANAL2 + [, '] + ;
        STRTRAN( ( fro )->K2NAME, ['], ["] ) + [', '] + ;
        ( fro )->KREFL3 + [', ] + ;
        ( fro )->KANAL3 + [, '] + ;
        ( fro )->K3NAME + [' ) ]


      SimpleSql( sql, conn )

      ( fro )->( DbSkip() )
    end

    // заполняем RGNUM'ы
    sql := [ Update DOCP] + Ret_f_ext( my ) + [ Set RGNUM = Right( '        ' + Trim( Convert( AUTOID, sql_char ) ), 8 ) ;
      Where KINDDOC = 'FRO' and RGNUM =  and DATDOC= '] + SqlDate( my ) + [' and DREFL2 = 'R179' and DANAL2 = ] + ( fro )->DANAL2
    SimpleSql( sql, conn )

    // BIG BUG
    // так как я не указал KINDDOC то ломались случайные документы в базе DOCP
    sql := [ Update d Set d.PARENT = dd.RGNUM From DOCP] + Ret_f_ext( my ) + [ d left outer join DOCP] + Ret_f_ext( my ) + [ dd ON d.PARENT = dd.EXTPARENT ;
      Where d.KINDDOC = 'FRO' and dd.KINDDOC = 'FRO' and d.LVLNUM = '2' and dd.LVLNUM = '1' and d.DATDOC = '] + SqlDate( my ) + [' and ;
        dd.DATDOC = '] + SqlDate( my ) + [' and d.DREFL2 = 'R179' and d.DANAL2 = ] + ( fro )->DANAL2 + [ and dd.DREFL2 = 'R179' and dd.DANAL2 = ] + ( fro )->DANAL2
    SimpleSql( sql, conn )

    // очищаем EXTPARENT
    sql := [ Update DOCP] + Ret_f_ext( my ) + [ Set EXTPARENT =  Where KINDDOC = 'FRO' and DATDOC = '] + SqlDate( my ) + [' and DREFL2 = 'R179' and DANAL2 = ] + ( fro )->DANAL2
    SimpleSql( sql, conn )

  finally
    CloseTable( fro )
    FreeAndNil( conn )
    HideMsg( msg )
  end

  my := my + 1
end

Message( 'Документы FRO успешно перенесены' )

    // Select Right( '        ' + Trim( Convert( AUTOID, sql_char ) ), 8 )  From DOCP0117


// local conn, path, sql, t
// path := '\\192.168.234.15:5050\vol1\FabiusWIN\data\srg\reflis\dict.add'
// try
//   conn := CreateConnection( path, 'admuser', "ora=1" )
//   sql := [ Select * From R09 ]
//   t := SelectSql( sql, conn )
// finally
//   FreeAndNil( conn )
//   CloseTable( t )
// end

// наш сервер
// path := '\\192.168.234.15:5050\vol1\FabiusWIN\data\srg\reflis\dict.add'

// Жуковский
// path := '\\4.7.47.51:5050\data\fabius\reflis\dict.add'= Смотрите также =

Полезные функции

Функции Delphi