СОРМ Яхонт, версия 2020 (архивная)

Ключ
Эта строка удалена.
Это слово было удалено. Это слово было добавлено.
Эта строка добавлена.

Изменения (45)

просмотр истории страницы
ls -l /app/asr_billing/cfg/sorm3/data/abonents.csv >> $LOGFILE 2>&1
printf 'Количество строк в файле: ' >> $LOGFILE 2>&1 && cat /app/asr_billing/cfg/sorm3/data/abonents.csv | wc -l >> $LOGFILE 2>&1
cp /app/asr_billing/cfg/sorm3/data/abonents.csv /app/asr_billing/cfg/sorm3/data/done/abonents.csv-`date +"%Y%m%d_%H%M%S"`
cp /app/asr_billing/cfg/sorm3/data/abonents.csv /app/asr_billing/cfg/sorm3/data/done/abonents-`date +"%Y%m%d_%H%M%S"`.csv
curl -v -sS --user $ftplogin:$ftppass -T /app/asr_billing/cfg/sorm3/data/abonents.csv ftp://$ftpip/abonents/abonents/ >> $LOGFILE 2>&1
>| /app/asr_billing/cfg/sorm3/data/abonents.csv
ls -l /app/asr_billing/cfg/sorm3/data/balance-fillup.csv >> $LOGFILE 2>&1
printf 'Количество строк в файле: ' >> $LOGFILE 2>&1 && cat /app/asr_billing/cfg/sorm3/data/balance-fillup.csv | wc -l >> $LOGFILE 2>&1
cp /app/asr_billing/cfg/sorm3/data/balance-fillup.csv /app/asr_billing/cfg/sorm3/data/done/balance-fillup.csv-`date +"%Y%m%d_%H%M%S"`
cp /app/asr_billing/cfg/sorm3/data/balance-fillup.csv /app/asr_billing/cfg/sorm3/data/done/balance-fillup-`date +"%Y%m%d_%H%M%S"`.csv
curl -v -sS --user $ftplogin:$ftppass -T /app/asr_billing/cfg/sorm3/data/balance-fillup.csv ftp://$ftpip/payments/balance-fillup/ >> $LOGFILE 2>&1
>| /app/asr_billing/cfg/sorm3/data/balance-fillup.csv
ls -l /app/asr_billing/cfg/sorm3/data/supplement-services.csv
printf 'Количество строк в файле: ' && cat /app/asr_billing/cfg/sorm3/data/supplement-services.csv | wc -l
cp /app/asr_billing/cfg/sorm3/data/supplement-services.csv /app/asr_billing/cfg/sorm3/data/done/supplement-services.csv-`date +"%Y%m%d_%H%M%S"`
cp /app/asr_billing/cfg/sorm3/data/supplement-services.csv /app/asr_billing/cfg/sorm3/data/done/supplement-services-`date +"%Y%m%d_%H%M%S"`.csv
curl -v -sS --user $ftplogin:$ftppass -T /app/asr_billing/cfg/sorm3/data/supplement-services.csv ftp://$ftpip/dictionaries/supplement-services/
>| /app/asr_billing/cfg/sorm3/data/supplement-services.csv
ls -l /app/asr_billing/cfg/sorm3/data/services.csv
printf 'Количество строк в файле: ' && cat /app/asr_billing/cfg/sorm3/data/services.csv | wc -l
cp /app/asr_billing/cfg/sorm3/data/services.csv /app/asr_billing/cfg/sorm3/data/done/services.csv-`date +"%Y%m%d_%H%M%S"`
cp /app/asr_billing/cfg/sorm3/data/services.csv /app/asr_billing/cfg/sorm3/data/done/services-`date +"%Y%m%d_%H%M%S"`.csv
curl -v -sS --user $ftplogin:$ftppass -T /app/asr_billing/cfg/sorm3/data/services.csv ftp://$ftpip/abonents/services/
>| /app/asr_billing/cfg/sorm3/data/services.csv
ls -l /app/asr_billing/cfg/sorm3/data/static-data/doc-types.csv
printf 'Количество строк в файле: ' && cat /app/asr_billing/cfg/sorm3/data/static-data/doc-types.csv | wc -l
cp /app/asr_billing/cfg/sorm3/data/static-data/doc-types.csv /app/asr_billing/cfg/sorm3/data/done/doc-types.csv-`date +"%Y%m%d_%H%M%S"`
cp /app/asr_billing/cfg/sorm3/data/static-data/doc-types.csv /app/asr_billing/cfg/sorm3/data/done/doc-types-`date +"%Y%m%d_%H%M%S"`.csv
curl -v -sS --user $ftplogin:$ftppass -T /app/asr_billing/cfg/sorm3/data/static-data/doc-types.csv ftp://$ftpip/dictionaries/doc-types/
fi
ls -l /app/asr_billing/cfg/sorm3/data/static-data/ip-numbering-plan.csv
printf 'Количество строк в файле: ' && cat /app/asr_billing/cfg/sorm3/data/static-data/ip-numbering-plan.csv | wc -l
cp /app/asr_billing/cfg/sorm3/data/static-data/ip-numbering-plan.csv /app/asr_billing/cfg/sorm3/data/done/ip-numberins-plan.csv-`date +"%Y%m%d_%H%M%S"`
cp /app/asr_billing/cfg/sorm3/data/static-data/ip-numbering-plan.csv /app/asr_billing/cfg/sorm3/data/done/ip-numberins-plan-`date +"%Y%m%d_%H%M%S"`.csv
curl -v -sS --user $ftplogin:$ftppass -T /app/asr_billing/cfg/sorm3/data/static-data/ip-numbering-plan.csv ftp://$ftpip/dictionaries/ip-numbering-plan/

ls -l /app/asr_billing/cfg/sorm3/data/static-data/pay-types.csv
printf 'Количество строк в файле: ' && cat /app/asr_billing/cfg/sorm3/data/static-data/pay-types.csv | wc -l
cp /app/asr_billing/cfg/sorm3/data/static-data/pay-types.csv /app/asr_billing/cfg/sorm3/data/done/pay-types.csv-`date +"%Y%m%d_%H%M%S"`
cp /app/asr_billing/cfg/sorm3/data/static-data/pay-types.csv /app/asr_billing/cfg/sorm3/data/done/pay-types-`date +"%Y%m%d_%H%M%S"`.csv
curl -v -sS --user $ftplogin:$ftppass -T /app/asr_billing/cfg/sorm3/data/static-data/pay-types.csv ftp://$ftpip/dictionaries/pay-types/

ls -l /app/asr_billing/cfg/sorm3/data/static-data/gates.csv
printf 'Количество строк в файле: ' && cat /app/asr_billing/cfg/sorm3/data/static-data/gates.csv | wc -l
cp /app/asr_billing/cfg/sorm3/data/static-data/gates.csv /app/asr_billing/cfg/sorm3/data/done/gates.csv-`date +"%Y%m%d_%H%M%S"`
cp /app/asr_billing/cfg/sorm3/data/static-data/gates.csv /app/asr_billing/cfg/sorm3/data/done/gates-`date +"%Y%m%d_%H%M%S"`.csv
curl -v -sS --user $ftplogin:$ftppass -T /app/asr_billing/cfg/sorm3/data/static-data/gates.csv ftp://$ftpip/dictionaries/gates/

A.COMPANY || '";' ||

case when a.company=0 then

'"1";"";"";"";"' ||
A.NAME || '";"' ||
coalesce(av22.attribute_value,'') || '";"1";"";"";"";"' ||

iif(
(coalesce(av14.attribute_value,'') || coalesce(av13.attribute_value,'') || coalesce(av16.attribute_value,'') || coalesce(av17.attribute_value,'')) <> '', iif(coalesce(av14.attribute_value,'') <> '', av14.attribute_value,'') || iif(coalesce(av13.attribute_value,'') <> '', ' ' || av13.attribute_value,'') || iif(coalesce(av16.attribute_value,'') <> '', ' ' || av16.attribute_value,'') || iif(coalesce(av17.attribute_value,'') <> '', ' ' || av17.attribute_value,'')
, '-')

|| '";"1";"' || coalesce(av7.attribute_value,'') || '";"' || coalesce(av6.attribute_value,'') || '";'

else '"";"";"";"";"";"";"";"";"";"";"";"";"";"";"' end ||

case when a.company = 1 then

a.name || '";"' || coalesce(av4.attribute_value,'') || '";"' || coalesce(av32.attribute_value,'-') || '";"' || coalesce(av1.attribute_value,'') || '";"' || coalesce(av7.attribute_value,'') || '";"' || coalesce(av6.attribute_value,'') || '";'

else '"";"";"";"";"";"";' end

|| '"1";"";"";"";"";"";"";"";"";"";"' ||
|| '"1";"";"";"";"";"";"";"";"";"";"' ||
coalesce(av25.attribute_value,'') ||
case when a.company=0 then
IIF(a.home_id > 0, '"' || IIF(coalesce(h.CITY, '') <> '', h.CITY || ' ', '') || IIF(coalesce(h.STREET,'') <> '', h.STREET || ' ', '') || coalesce(h.S_NUMBER,'') || IIF(coalesce(h.S_LITER,'') <> '', '/' || h.S_LITER, '') || IIF(coalesce(a.A_HOME_NUMBER, '') <> '', ' ' || a.A_HOME_NUMBER,'') || '', '""')

else
coalesce(av25.attribute_value,'') end

||
'";"1";"";"";"";"";"";"";"";"";"";' ||
IIF(a.home_id > 0, '"' || IIF(coalesce(h.CITY, '') <> '', h.CITY || ' ', '') || IIF(coalesce(h.STREET,'') <> '', h.STREET || ' ', '') || coalesce(h.S_NUMBER,'') || IIF(coalesce(h.S_LITER,'') <> '', '/' || h.S_LITER, '') || IIF(coalesce(a.A_HOME_NUMBER, '') <> '', ' ' || a.A_HOME_NUMBER,'') || '"', '""')
and a.id is not null
and a.parent_id!=2;

{code}


*/app/asr_billing/cfg/sorm3/abonents-periodic.sql*
{code} set heading off; select distinct '"1";"' ||
coalesce(U.LOGIN,'-') || '";"' ||
iif(coalesce(u.ip,'') <> '', UF_IP2STRING(U.IP), '') || '";"' ||
coalesce(a.email,'-') ||
'";"' ||
coalesce(a.sms,'') ||
'";"' ||
coalesce(U.MAC,'') || '";"' ||
CAST(lpad(EXTRACT(DAY FROM a.create_date),2,'0') AS varchar(2))||'.'|| CAST(lpad(EXTRACT(MONTH FROM a.create_date),2,'0') AS varchar(2))||'.'|| EXTRACT(YEAR FROM a.create_date) || ' 00:00:00' || '";"' ||
A.CONTRACT_NUMBER || '";"' ||
case when a.id in (select distinct abonent_id from abonents_block where (b_own = 1 or b_admin = 1 or b_sys = 1 or b_own2 = 1)) then '1' else '0' end || '";"' ||
CAST(lpad(EXTRACT(DAY FROM a.create_date),2,'0') AS varchar(2))||'.'|| CAST(lpad(EXTRACT(MONTH FROM a.create_date),2,'0') AS varchar(2))||'.'|| EXTRACT(YEAR FROM a.create_date) || ' 00:00:00";"' ||
case
when a.id in (select distinct abonent_id from abonents_block where (b_own = 1 or b_admin = 1 or b_sys = 1 or b_own2 = 1)) then
(select first 1 CAST(lpad(EXTRACT(DAY FROM abb.b_date),2,'0') AS varchar(2))||'.'|| CAST(lpad(EXTRACT(MONTH FROM abb.b_date),2,'0') AS varchar(2))||'.'|| EXTRACT(YEAR FROM abb.b_date) || ' 00:00:00' from abonents_block abb where abb.abonent_id = a.id and (b_own = 1 or b_admin = 1 or b_sys = 1 or b_own2 = 1))
else
'' end ||

'";"' ||
A.COMPANY || '";' ||

case when a.company=0 then

'"1";"";"";"";"' ||
A.NAME || '";"' ||
coalesce(av22.attribute_value,'') || '";"1";"";"";"";"' ||

iif(
(coalesce(av14.attribute_value,'') || coalesce(av13.attribute_value,'') || coalesce(av16.attribute_value,'') || coalesce(av17.attribute_value,'')) <> '', iif(coalesce(av14.attribute_value,'') <> '', av14.attribute_value,'') || iif(coalesce(av13.attribute_value,'') <> '', ' ' || av13.attribute_value,'') || iif(coalesce(av16.attribute_value,'') <> '', ' ' || av16.attribute_value,'') || iif(coalesce(av17.attribute_value,'') <> '', ' ' || av17.attribute_value,'')
, '-')

|| '";"1";"' || coalesce(av7.attribute_value,'') || '";"' || coalesce(av6.attribute_value,'') || '";'

else '"";"";"";"";"";"";"";"";"";"";"";"";"";"";"' end ||

case when a.company = 1 then

a.name || '";"' || coalesce(av4.attribute_value,'') || '";"' || coalesce(av32.attribute_value,'-') || '";"' || coalesce(av1.attribute_value,'') || '";"' || coalesce(av7.attribute_value,'') || '";"' || coalesce(av6.attribute_value,'') || '";'

else '"";"";"";"";"";"";' end

|| '"1";"";"";"";"";"";"";"";"";"";"' ||

case when a.company=0 then
IIF(a.home_id > 0, '"' || IIF(coalesce(h.CITY, '') <> '', h.CITY || ' ', '') || IIF(coalesce(h.STREET,'') <> '', h.STREET || ' ', '') || coalesce(h.S_NUMBER,'') || IIF(coalesce(h.S_LITER,'') <> '', '/' || h.S_LITER, '') || IIF(coalesce(a.A_HOME_NUMBER, '') <> '', ' ' || a.A_HOME_NUMBER,'') || '', '""')

else
coalesce(av25.attribute_value,'') end

||
'";"1";"";"";"";"";"";"";"";"";"";' ||
IIF(a.home_id > 0, '"' || IIF(coalesce(h.CITY, '') <> '', h.CITY || ' ', '') || IIF(coalesce(h.STREET,'') <> '', h.STREET || ' ', '') || coalesce(h.S_NUMBER,'') || IIF(coalesce(h.S_LITER,'') <> '', '/' || h.S_LITER, '') || IIF(coalesce(a.A_HOME_NUMBER, '') <> '', ' ' || a.A_HOME_NUMBER,'') || '"', '""')
||
coalesce(av25.attribute_value,'') ||
'";"1";"";"";"";"";"";"";"";"";"";' ||
IIF(a.home_id > 0, '"' || IIF(coalesce(h.CITY, '') <> '', h.CITY || ' ', '') || IIF(coalesce(h.STREET,'') <> '', h.STREET || ' ', '') || coalesce(h.S_NUMBER,'') || IIF(coalesce(h.S_LITER,'') <> '', '/' || h.S_LITER, '') || IIF(coalesce(a.A_HOME_NUMBER, '') <> '', ' ' || a.A_HOME_NUMBER,'') || '"', '""')
||
coalesce(av25.attribute_value,'') ||
'";"1";"";"";"";"";"";"";"";"";"";' ||
IIF(a.home_id > 0, '"' || IIF(coalesce(h.CITY, '') <> '', h.CITY || ' ', '') || IIF(coalesce(h.STREET,'') <> '', h.STREET || ' ', '') || coalesce(h.S_NUMBER,'') || IIF(coalesce(h.S_LITER,'') <> '', '/' || h.S_LITER, '') || IIF(coalesce(a.A_HOME_NUMBER, '') <> '', ' ' || a.A_HOME_NUMBER,'') || '"', '""')
||
coalesce(av25.attribute_value,'')


from ABONENTS A
left join USERS U on A.ID = U.ABONENT_ID
left join HOMES H on A.HOME_ID = H.ID
left join TARIF T on A.TARIF_ID=T.ID
left join ATTRIBUTE_VALUES as av1 on a.id=av1.ABONENT_ID and av1.ATTRIBUTE_ID=1
left join ATTRIBUTE_VALUES as av2 on a.id=av2.ABONENT_ID and av2.ATTRIBUTE_ID=2
left join ATTRIBUTE_VALUES as av4 on a.id=av4.ABONENT_ID and av4.ATTRIBUTE_ID=4
left join ATTRIBUTE_VALUES as av6 on a.id=av6.ABONENT_ID and av6.ATTRIBUTE_ID=6
left join ATTRIBUTE_VALUES as av7 on a.id=av7.ABONENT_ID and av7.ATTRIBUTE_ID=7
left join ATTRIBUTE_VALUES as av13 on a.id=av13.ABONENT_ID and av13.ATTRIBUTE_ID=13
left join ATTRIBUTE_VALUES as av14 on a.id=av14.ABONENT_ID and av14.ATTRIBUTE_ID=14
left join ATTRIBUTE_VALUES as av16 on a.id=av16.ABONENT_ID and av16.ATTRIBUTE_ID=16
left join ATTRIBUTE_VALUES as av17 on a.id=av17.ABONENT_ID and av17.ATTRIBUTE_ID=17
left join ATTRIBUTE_VALUES as av15 on a.id=av15.ABONENT_ID and av15.ATTRIBUTE_ID=15
left join ATTRIBUTE_VALUES as av22 on a.id=av22.ABONENT_ID and av22.ATTRIBUTE_ID=22
left join ATTRIBUTE_VALUES as av25 on a.id=av25.ABONENT_ID and av25.ATTRIBUTE_ID=25
left join ATTRIBUTE_VALUES as av32 on a.id=av32.ABONENT_ID and av32.ATTRIBUTE_ID=32
left join abonents_block ab on ab.abonent_id=a.id
where A.IS_FOLDER=0
and a.parent_id not in (244)
and a.deleted=0
and a.id is not null
and a.parent_id!=2
and (u.login in (select uh.login from users_history uh where uh.time_changed between (current_timestamp - 1) and current_timestamp)
or a.id in (select ah.abonents_id from abonents_history ah where ah.time_changed between (current_timestamp - 1) and current_timestamp));
{code}
Будет дополняться
{code}

h2. 2. Данные о подключенных абонентам видах услуг связи
UU.USLUGA_ID not in (-3,-4) and
UU.USLUGA_ID not in (select id from usluga where name = '') and
a.parent_id not in (244) and
order by A.NAME;

Тот же отчёт, который выводит только услуги подключенные за последний час

*/app/asr_billing/cfg/sorm3/services-periodic-id.sql*
{code}Будет дополняться{code}
{code}set heading off;
select distinct
'"1";"' ||
'-' || '";"' ||
A.CONTRACT_NUMBER || '";"' ||
abs(UU.USLUGA_ID) || '";"' ||
CAST(lpad(EXTRACT(DAY FROM UU.ENABLE_DATE),2,'0') AS varchar(2))||'.'|| CAST(lpad(EXTRACT(MONTH FROM UU.ENABLE_DATE),2,'0') AS varchar(2))||'.'|| EXTRACT(YEAR FROM UU.ENABLE_DATE) || ' 00:00:00' ||
'";"'||
case when uu.ACTIVATED=1 then '";""'
else
coalesce((CAST(lpad(EXTRACT(DAY FROM UU.END_TIME),2,'0') AS varchar(2))||'.'|| CAST(lpad(EXTRACT(MONTH FROM UU.END_TIME),2,'0') AS varchar(2))||'.'|| EXTRACT(YEAR FROM UU.END_TIME) || ' ' || '00' || ':' || '00:00' ), '') || '";""'
end
from ABONENTS A
left join USERS_USLUGA UU on UU.ABONENT_ID=A.ID
left join users u on u.abonent_id=a.id
where
A.IS_FOLDER=0 and
A.PARENT_ID!=244 and
A.DELETED=0 and
UU.TARIF_ID is null and
UU.ENABLE_DATE is not null and
UU.ENABLE_DATE <= current_timestamp and
UU.USLUGA_ID not in (-3,-4) and
UU.USLUGA_ID not in (select id from usluga where name = '') and
a.parent_id not in (244)
and uu.id in (select distinct users_usluga_id from users_usluga_history where time_changed between dateadd (-1 hour to current_timestamp) and current_timestamp)
order by A.NAME;{code}

Скрипт для заполнения csv

h2. 3. Пополнение баланса личного счета абонента обобщенная информация.

*/app/asr_billing/cfg/sorm3/balance-fillup-periodic.sql*
{code} Будет дополняться{code}
{code}set heading off;
select distinct
'"1";"' ||
coalesce(case
when fo.operator_name = 'APELSIN' then '1'
when fo.operator_name = 'CITY_PAY' then '2'
when fo.operator_name = 'Comepay' then '3'
when fo.operator_name = 'Elexnet' then '4'
when fo.operator_name = 'ElexnetOld' then '5'
when fo.operator_name = 'EXPRESS_VOLGA' then '6'
when fo.operator_name = 'ForwardMobile' then '7'
when fo.operator_name = 'Gorod' then '8'
when fo.operator_name = 'JCC' then '9'
when fo.operator_name = 'Kassa24' then '10'
when fo.operator_name = 'KAZKOMBANK' then '11'
when fo.operator_name = 'Krasplat' then '12'
when fo.operator_name = 'MINBANK' then '13'
when fo.operator_name = 'MKB_OSMP' then '14'
when fo.operator_name = 'Mobilnik' then '15'
when fo.operator_name = 'MONEY_YANDEX' then '16'
when fo.operator_name = 'NCC' then '17'
when fo.operator_name = 'OSMP_Amigo' then '18'
when fo.operator_name = 'OSMP_CHECK' then '19'
when fo.operator_name = 'OSMP_DELTAPAY' then '20'
when fo.operator_name = 'OSMP_EXPRESS_OPLATA' then '21'
when fo.operator_name = 'OSMP_INTERPAY' then '22'
when fo.operator_name = 'OSMP_MOROZOV' then '23'
when fo.operator_name = 'OSMP_QIWI' then '24'
when fo.operator_name = 'OSMP-QIWI' then '25'
when fo.operator_name = 'OSMP_SBRF' then '26'
when fo.operator_name = 'OSMP_SIPAY' then '27'
when fo.operator_name = 'PAYANYWAY' then '28'
when fo.operator_name = 'PAYCOM_UZ' then '29'
when fo.operator_name = 'Payfon_phone' then '30'
when fo.operator_name = 'PAYKEEPER' then '31'
when fo.operator_name = 'PAYMASTER' then '32'
when fo.operator_name = 'PaymasterAutopay' then '33'
when fo.operator_name = 'PAYNET_UZ' then '34'
when fo.operator_name = 'PayPal' then '35'
when fo.operator_name = 'PayPro' then '36'
when fo.operator_name = 'QIWI_OSMP' then '37'
when fo.operator_name = 'QIWI(REST)' then '38'
when fo.operator_name = 'Qiwiwallet' then '39'
when fo.operator_name = 'QuickPay' then '40'
when fo.operator_name = 'RAPIDA' then '41'
when fo.operator_name = 'Robokassa' then '42'
when fo.operator_name = 'RPS' then '43'
when fo.operator_name = 'SBERBANK_ACQ' then '44'
when fo.operator_name = 'SBRF' then '45'
when fo.operator_name = 'SBRF_BS' then '46'
when fo.operator_name = 'SBRF_KIBERPLAT' then '47'
when fo.operator_name = 'SFOUR' then '48'
when fo.operator_name = 'Simfoniya' then '49'
when fo.operator_name = 'TelePay' then '50'
when fo.operator_name = 'TINKOFF' then '51'
when fo.operator_name = 'UBRIR' then '52'
when fo.operator_name = 'UCS_ACQ' then '53'
when fo.operator_name = 'Unikassa' then '54'
when fo.operator_name = 'Uniteller' then '55'
when fo.operator_name = 'UnitellerAutopay' then '56'
when fo.operator_name = 'VISA-MASTERCARD' then '57'
when fo.operator_name = 'webcreds' then '58'
when fo.operator_name = 'WebRobokassa' then '59'
when fo.operator_name = 'XPLAT' then '60'
when fo.operator_name = 'YAPK' then '61'
when fo.operator_name is null then '62'
else '62'

end,'-')
|| '";"' ||
a.contract_number || '";"' ||
coalesce((select first 1 uf_ip2string(ip) from users u where u.abonent_id = a.id and u.ip is not null),'') || '";"' ||
iif(fo.operator_name<>'' and fo.operator_name is not null,
CAST(lpad(EXTRACT(DAY FROM fo.OP_DATE),2,'0') AS varchar(2))||'.'|| CAST(lpad(EXTRACT(MONTH FROM fo.OP_DATE),2,'0') AS varchar(2))||'.'|| EXTRACT(YEAR FROM fo.OP_DATE) || ' ' || CAST(lpad(EXTRACT(hour FROM fo.OP_DATE),2,'0') AS varchar(2))||':'|| CAST(lpad(EXTRACT(minute FROM fo.OP_DATE),2,'0') AS varchar(2)),
CAST(lpad(EXTRACT(DAY FROM fo.OP_DATE),2,'0') AS varchar(2))||'.'|| CAST(lpad(EXTRACT(MONTH FROM fo.OP_DATE),2,'0') AS varchar(2))||'.'|| EXTRACT(YEAR FROM fo.OP_DATE) || ' ' || CAST(lpad(EXTRACT(hour FROM fo.OP_DATE),2,'0') AS varchar(2))||':'|| CAST(lpad(EXTRACT(minute FROM fo.OP_DATE),2,'0') AS varchar(2))
)||':'|| '00";"' ||
cast(fo.op_summa/10000000000.00 as varchar(40)) || '";"' ||
coalesce(fo.DESCR,'') || '"'
from
finance_operations fo
join
abonents a
on fo.abonent_id = a.id
left join users u on u.abonent_id=a.id
where
fo.abonent_id is not null and
fo.op_type = 2 and
fo.storno = 0 and
a.deleted = 0 and
a.parent_id not in (244)
and upper(fo.descr) not like upper('%Сторнирование%')
and ((fo.op_date between dateadd (-1 hour to current_timestamp) and current_timestamp) or ((fo.operator_name='' or fo.operator_name is null) and (fo.SYSTEM_DATE between dateadd (-1 hour to current_timestamp) and current_timestamp)))
order by fo.op_date;{code}

h2. 4. Формат справочника ДВО (видов услуг)


*/app/asr_billing/cfg/sorm3/supplement-services-periodic.sql*
{code}Будет дополняться
{code}set heading off;
select
'"1";"' ||
abs(usl.id) || '";"' ||
usl.NAME || '";"' ||
'01.01.2015 00:00:00' || '";"' ||
iif(usl.deleted > 0,
(select first 1
cast(lpad(extract(day from time_changed),2,'0') as varchar(2)) || '.' ||
cast(lpad(extract(month from time_changed),2,'0') as varchar(2)) || '.' ||
extract(year from time_changed) from usluga_history where usluga_id = usl.id order by time_changed desc) ||
' 00:00:00";"',
'";"') ||
coalesce(usl.NAME,'') || '"'
from
usluga usl
where
usl.system_type != 13 and
usl.id!=170000 and
usl.id in (select usluga_id from usluga_history union distinct select usluga_id from users_usluga where deleted = 0 and abonent_id is not null) and
(usl.name is not null and usl.name <> '')
and usl.id>0 and
(usl.id in (select usluga_id from usluga_history where time_changed between dateadd (-1 hour to current_timestamp) and current_timestamp))
order by id;
{code}