KOLOMNA2
Материал из Фабиус wiki
Версия от 10:21, 26 апреля 2018; Hisava (обсуждение | вклад)
KOLOMNA2 - это программа из справочника R266
Заполнить показания счетчика за дату
KOLOMNA2( data )
Текст
parameters data local _, fld, q, sql, path, connection_string, msg, aa, my, pac fld := ' _1,D,4; _2,C,5; _3,N,14,4; _4,N,14,4; _5,C,8; _6,N,14,4; _7,N,14,4; ' try _ := CreateTmpFile( fld, '_', ~IsFreeDel := true ) // --- СЧЕТЧИК 1 --- path := "\\CountWhite\Data\viko\v1\Base" connection_string := [ ; Provider = VFPOLEDB.1 ;; Data Source = ] + path + [ ;; Mode = Share Deny None ;; Extended Properties = "" ;; User ID = "" ;; Password = "" ;; Mask Password = False ;; Cache Authentication = False ;; Encrypt Password = False ;; Collating Sequence = RUSSIAN ] // вчера my := data - 1 sql := [ Select * ; From "0001] + Year( my ) + [.DBF" ; Where Year( DATE ) = ] + Year( my ) + [ and Month( DATE ) = ] + Month( my ) + [ and ; Day( DATE ) = ] + Day( my ) aa := my + 1 aa := Date_Str( aa ) + ' года' msg := WaitMsg( 'Выполняется анализ показаний счетчика номер 1 за ' + aa ) try q := OpenADOQuery( connection_string, sql ) ( q )->( DbGoTop() ) while !( q )->( eof() ) ( _ )->( DbAppend() ) ( _ )->_1 := ( q )->DATE ( _ )->_2 := ( q )->TIME ( _ )->_3 := ( q )->COUNT ( q )->( DbSkip() ) end finally CloseTable( q ) end // сегодня my := my + 1 sql := [ Select * ; From "0001] + Year( my ) + [.DBF" ; Where Year( DATE ) = ] + Year( my ) + [ and Month( DATE ) = ] + Month( my ) + [ and ; Day( DATE ) = ] + Day( my ) try q := OpenADOQuery( connection_string, sql ) ( q )->( DbGoTop() ) while !( q )->( eof() ) ( _ )->( DbAppend() ) ( _ )->_1 := ( q )->DATE ( _ )->_2 := ( q )->TIME ( _ )->_3 := ( q )->COUNT ( q )->( DbSkip() ) end finally CloseTable( q ) end // *** СЧЕТЧИК 1 *** // --- СЧЕТЧИК 2 --- path := "\\CountWhite\Data\viko\v2\Base" connection_string := [ ; Provider = VFPOLEDB.1 ;; Data Source = ] + path + [ ;; Mode = Share Deny None ;; Extended Properties = "" ;; User ID = "" ;; Password = "" ;; Mask Password = False ;; Cache Authentication = False ;; Encrypt Password = False ;; Collating Sequence = RUSSIAN ] // вчера my := my - 1 sql := [ Select * ; From "0002] + Year( my ) + [.DBF" ; Where Year( DATE ) = ] + Year( my ) + [ and Month( DATE ) = ] + Month( my ) + [ and ; Day( DATE ) = ] + Day( my ) WaitMsg( 'Выполняется анализ показаний счетчика номер 2 за ' + aa, msg, 'Выполняется процесс' ) try q := OpenADOQuery( connection_string, sql ) ( q )->( DbGoTop() ) while !( q )->( eof() ) ( _ )->( DbAppend() ) ( _ )->_1 := ( q )->DATE ( _ )->_2 := ( q )->TIME ( _ )->_3 := ( q )->COUNT ( q )->( DbSkip() ) end finally CloseTable( q ) end my := my + 1 sql := [ Select * ; From "0002] + Year( my ) + [.DBF" ; Where Year( DATE ) = ] + Year( my ) + [ and Month( DATE ) = ] + Month( my ) + [ and ; Day( DATE ) = ] + Day( my ) try q := OpenADOQuery( connection_string, sql ) ( q )->( DbGoTop() ) while !( q )->( eof() ) ( _ )->( DbAppend() ) ( _ )->_1 := ( q )->DATE ( _ )->_2 := ( q )->TIME ( _ )->_3 := ( q )->COUNT ( q )->( DbSkip() ) end finally CloseTable( q ) end // *** СЧЕТЧИК 2 *** sql := [ Update _ ; Set _4 = Convert( Left( _2, 2 ), sql_integer ) ; From ] + TmpFilePath( _ ) + [ _ ] SimpleSql( sql, TempPath ) // вчера до 20:00 не работали, так как до 19:00 работала предыдущая смена sql := [ Delete ; From ] + TmpFilePath( _ ) + [ ; Where _1 = '] + SqlDate( my - 1 )+ [' and _4 < 19 ] SimpleSql( sql, TempPath ) // сегодня с 19:00 уже не работали sql := [ Delete ; From ] + TmpFilePath( _ ) + [ ; Where _1 = '] + SqlDate( my )+ [' and _4 >= 19 ] SimpleSql( sql, TempPath ) sql := [ Update _ ; Set _5 = '] + DtoS( my ) + [' ; From ] + TmpFilePath( _ ) + [ _ ] SimpleSql( sql, TempPath ) sql := [ Select SUM( _3 ) ; From ] + TmpFilePath( _ ) aa := SqlToArr( sql ) pac := OpenChildDoc( 'PAC', '1', ~ParentForm := , ~Month := Month( my ), ~Year := Year( my ) ) ( pac )->( SetFilter( [ KINDDOC = 'PAC' and LVLNUM = '1' and DREFL1 = 'R10 ' and ; DANAL1 = 11 and DSHIFT = '] + DtoS( data ) + [1' ] ) ) if !Empty( aa ) ( pac )->NATTR5 := aa endif finally CloseTable( _ ) CloseTable( q ) HideMsg( msg ) end // смена начинается с 19:00 // _1 - date // _2 - time // _3 - count // _4 - часы // _5 - дата символьная 8 знаков // _6 - отчет // _7 - разница // _8 - брак