From 849a4c2796192c42b369c6880f98c87c4c733beb Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 26 Jul 2026 23:04:05 +0300 Subject: [PATCH] 024 improvements --- Application.cfc | 23 ++++++--- mod/compute_payg.cfm | 109 +++++++++++++++++++++++++++---------------- mod/crm_contract.cfm | 4 +- payg.cfm | 84 ++++++++++++++++++++++++++++----- 4 files changed, 160 insertions(+), 60 deletions(-) diff --git a/Application.cfc b/Application.cfc index 32eb3dc..628df0e 100644 --- a/Application.cfc +++ b/Application.cfc @@ -28,6 +28,8 @@ + + @@ -92,7 +94,7 @@ - + @@ -241,7 +243,9 @@ } result = prefix.filecontent; var idpUserData=deserializeJson(result); - //request.auth.wz=idpUserData.userInfo.ClientId;//GUID! + request.auth.wz=idpUserData.userInfo.ClientId; + + //writeDump(idpUserData); request.auth.login = idpUserData.userInfo.login; @@ -342,11 +346,16 @@ // после возвращения от IDP нам нужно будет зачистить сессию SSO, сделаем это по слову logout } - request.auth.wz='WZ01348'; //******************* - request.auth.wz='WZ01005'; //******************* - request.auth.wz='WZ01653'; //******************* - request.auth.wz='WZ02319'; //******************* - request.auth.wz='WZ01762'; //******************* + //request.auth.wz='WZ01348'; //******************* + //request.auth.wz='WZ01005'; //******************* + //request.auth.wz='WZ01653'; //******************* + //request.auth.wz='WZ02319'; //******************* + //request.auth.wz='WZ01762'; //******************* + //writedump(request.auth);abort; + //******************** + //костыль + if (structKeyExists(URL,"wz")) { request.auth.wz=URL.wz } + //********************* diff --git a/mod/compute_payg.cfm b/mod/compute_payg.cfm index 5a3051c..98104ae 100644 --- a/mod/compute_payg.cfm +++ b/mod/compute_payg.cfm @@ -6,6 +6,7 @@ + @@ -102,7 +103,6 @@ AND s.serviceType = 3 - qSpec (Left Outer Join with Free Tier) #getTickCount() - request.startTickCount# @@ -110,9 +110,6 @@ - - select 'WZ'||to_char(tenant.wzcode,'FM00000') as wz, vdc.name as vdc_name, @@ -121,7 +118,7 @@ WHEN vdc.name LIKE '%-v1cl2%' THEN 'iaas.ngc.i31' WHEN vdc.name LIKE '%-v1cl4%' THEN 'iaas.ngc.a28' WHEN vdc.name LIKE '%-v1cl5%' THEN 'iaas.ngc.a45' - WHEN vdc.name LIKE '%-v1cl6%' THEN 'iaas.ngc.i28' -- *** смапить все кластера + WHEN vdc.name LIKE '%-v1cl6%' THEN 'iaas.ngc.i28' WHEN vdc.name LIKE '%-v1cl7%' THEN 'iaas.ngc.a40' -- *** смапить все кластера ELSE '['||vdc.name||']' end as code, sum(cpu_used/cpu_speed)/4. as core_h, @@ -146,6 +143,20 @@ + @@ -159,9 +170,10 @@ WHEN vdc.name LIKE '%-v1cl7%' THEN 'iaas.ngc.a40' ELSE '['||vdc.name||']' END || CASE - WHEN storage_profile_types.name ILIKE '%-SSD%' THEN '.ssd-m' - WHEN storage_profile_types.name ILIKE '%-SAS' THEN '.sas-m' - WHEN storage_profile_types.name ILIKE '%-SATA' THEN '.sata-m' + WHEN storage_profile_types.name ILIKE '%FASTSSD%' THEN '.fstssd-m' + WHEN storage_profile_types.name ILIKE '%SSD%' THEN '.ssd-m' + WHEN storage_profile_types.name ILIKE '%SAS%' THEN '.sas-m' + WHEN storage_profile_types.name ILIKE '%SATA%' THEN '.sata-m' ELSE '.['|| storage_profile_types.name ||']' END as code, storage_profile_types.name, -- *** это не тип, а профайл @@ -201,8 +213,12 @@ --,bucket_stat.placement_id ,'WZ'||lpad(bucket_stat.owner, 5, '0') as wz -- *** здесь не число, а строка, поэтому другая формула обратной сборки WZ ,bucket_stat.timestamp_addition::date as dt - ,bucket_info.name as dimension_1, - null as dimension_2 + ,bucket_info.name || ' - ' || case + when bucket_stat.placement_id = 1 then 'paas.s3.ceph' + when bucket_stat.placement_id = 2 then 'paas.s3.cphc' + else '['|| TO_CHAR(bucket_stat.placement_id,'FM9') ||']' end + as dimension_1 + ,null as dimension_2 from s3billing.bucket_stat join s3billing.placement ON s3billing.placement.id=bucket_stat.placement_id join s3billing.bucket_info ON bucket_info.id=bucket_stat.bucket_id @@ -285,7 +301,11 @@ --category.name, bucket_info.name ,'WZ'||lpad(user_info.name, 5, '0') as wz ,usage_bucket_by_user.time::date as dt - ,bucket_info.name as dimension_1 + ,bucket_info.name || ' - ' || case + when bucket_info.placement_id = 1 then 'paas.s3.ceph' + when bucket_info.placement_id = 2 then 'paas.s3.cphc' + else '['|| TO_CHAR(bucket_info.placement_id,'FM9') ||']' end + as dimension_1 ,null as dimension_2 from s3billing.usage_bucket_by_user join s3billing.user_info on usage_bucket_by_user.user_id=user_info.id @@ -310,39 +330,40 @@ + - select dt, wz, code || '.vcpu-m' as code, core_h as raw_metric, core_h as metric, - dimension_1, 'vdc' as dimension_1_name, dimension_2, NULL as dimension_2_name + select dt, wz, code + '.vcpu-m' as code, core_h as raw_metric, core_h as metric, + dimension_1, 'vdc' as dimension_1_name, dimension_2, NULL as dimension_2_name, 'ядро-ч' as unit from qComputing union all - select dt, wz, code || '.ram-m' as code, gb_h as raw_metric, gb_h as metric, - dimension_1, 'vdc' as dimension_1_name, dimension_2, NULL as dimension_2_name + select dt, wz, code + '.ram-m' as code, gb_h as raw_metric, gb_h as metric, + dimension_1, 'vdc' as dimension_1_name, dimension_2, NULL as dimension_2_name, 'ГБайт-ч' as unit from qComputing union all select dt, wz, code, gb_m_used as raw_metric, gb_m_used as metric, - dimension_1, 'vdc' as dimension_1_name, dimension_2, 'storage policy' as dimension_2_name + dimension_1, 'vdc' as dimension_1_name, dimension_2, 'storage policy' as dimension_2_name, 'ГБайт-м' as unit from qStorage union all - select dt, wz, code || '.vol-m', vol_b as raw_metric, vol_gb as metric, - dimension_1, 'bucket' as dimension_1_name, dimension_2, NULL as dimension_2_name + select dt, wz, code + '.vol-m', vol_b as raw_metric, vol_gb as metric, + dimension_1, 'bucket' as dimension_1_name, dimension_2, NULL as dimension_2_name, 'ГБайт-м' as unit from qS3Vol union all - select dt, wz, code || '.get-m', get as raw_metric, get_10k as metric, - dimension_1, 'bucket' as dimension_1_name, dimension_2, NULL as dimension_2_name + select dt, wz, code + '.get-m', get as raw_metric, get_10k as metric, + dimension_1, 'bucket' as dimension_1_name, dimension_2, NULL as dimension_2_name, '10тыс.шт.' as unit from qS3OpsTrf union all - select dt, wz, code || '.put-m', put as raw_metric, put_10k as metric, - dimension_1, 'bucket' as dimension_1_name, dimension_2, NULL as dimension_2_name + select dt, wz, code + '.put-m', put as raw_metric, put_10k as metric, + dimension_1, 'bucket' as dimension_1_name, dimension_2, NULL as dimension_2_name, '10тыс.шт.' as unit from qS3OpsTrf union all - select dt, wz, code || '.trf-m', bytes_sent as raw_metric, bytes_sent_gb as metric, - dimension_1, 'bucket' as dimension_1_name, dimension_2, NULL as dimension_2_name + select dt, wz, code + '.trf-m', bytes_sent as raw_metric, bytes_sent_gb as metric, + dimension_1, 'bucket' as dimension_1_name, dimension_2, NULL as dimension_2_name, 'ГБайт' as unit from qS3OpsTrf order by dt, code, dimension_1, dimension_2 @@ -383,12 +404,12 @@ SELECT - s.code + s.code as s_code m.code as m_code s.service_code as service_code s.svc s.component - s.unit + m.unit s.price*(100-s.discount)/100 as discounted_price @@ -408,22 +429,28 @@ m.dimension_2_name FROM qSpec as s, qUnifiedMetric as m - WHERE m.wz= - AND s.code=m.code + WHERE s.code=m.code AND s.serviceStart <= m.dt AND (m.dt <= s.serviceEnd OR s.serviceEnd IS NULL) - + + AND m.wz= + UNION ALL + SELECT NULL, m.code, NULL, NULL, NULL, NULL, 0, NULL, NULL, m.raw_metric, m.metric, NULL, NULL, NULL, NULL, m.dt, 0, m.dimension_1, m.dimension_1_name, m.dimension_2, m.dimension_2_name - FROM qUnifiedMetric as m where m.code NOT IN () + FROM qUnifiedMetric as m + WHERE m.code NOT IN () UNION ALL + SELECT s.code, NULL, s.service_code, s.svc, s.component, s.unit, s.price*(100-s.discount)/100 as discounted_price, s.price, s.discount, NULL, NULL, s.serviceStart, s.serviceEnd, s.serviceHash, s.serviceCustomName, NULL, 0, NULL, NULL, NULL, NULL - FROM qSpec as s where s.code NOT IN () - order by dt, code, dimension_1, dimension_2 + FROM qSpec as s + WHERE s.code NOT IN () + + ORDER by dt, s_code, m_code, dimension_1, dimension_2 @@ -440,8 +467,9 @@ SELECT - code + s_code m_code + s_code as code service_code svc serviceCustomName @@ -464,15 +492,14 @@ month(dt) as month from qChargeDaily - group by m_code, code, svc, service_code, serviceCustomName, component, unit, discounted_price, serviceStart, ServiceEnd, serviceHash, free_tier, year(dt), month(dt), + group by s_code, m_code, svc, service_code, serviceCustomName, component, unit, discounted_price, serviceStart, ServiceEnd, serviceHash, free_tier, year(dt), month(dt), dimension_1_name, dimension_1, dimension_2_name, dimension_2 order by year(dt), month(dt), m_code, code, serviceStart, dimension_1, dimension_2 - - - ---> + + + @@ -491,6 +518,7 @@ + qChargeMonthly #getTickCount() - request.startTickCount# @@ -507,10 +535,11 @@ + - - + diff --git a/mod/crm_contract.cfm b/mod/crm_contract.cfm index 797af18..dd36352 100644 --- a/mod/crm_contract.cfm +++ b/mod/crm_contract.cfm @@ -2,11 +2,11 @@ - + - - + - - - - - + + + + + + + + - Отчет по PAYG #request.auth.wz# + Отчет по PAYG #WZ# @@ -56,11 +59,23 @@
Период с по + + + WZ + + + +
-прошлый месяц + + прошлый месяц + + + текущий месяц +
@@ -71,6 +86,7 @@ tenant_wz_index=#tenant_wz_index# output="report" debug=#structKeyExists(Form,"DEBUG")# + restrict_to_own_instances=#restrict_to_own_instances# /> Часов в периоде: #hours# Строк в отчете: #report.qCharge.recordCount#
@@ -87,6 +103,9 @@ S3 операции и трафик:
+Цены по данным договора из CRM (через elma-cache). Учитываются метрики по S3, vCloud (кроме GPU) +
+ @@ -94,7 +113,7 @@ S3 операции и трафик: - +
Артикул С По @@ -223,6 +242,49 @@ S3 операции и трафик:
+ + +

Спецификация

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ДоговорДоп. соглашениеТип оплатыПользовательское наименованиеКол-во по строкеСкидка по строкеНОУКОУКомпонентАртикулКол-воЕд.изм.Цена с НДССкидка %Цена со скидкой с НДС
#contractOutsideId##additionalAgreementName##serviceType##serviceCustomName##serviceQuantity##serviceDiscount##dateFormat(serviceStart, "YYYY-MM-DD")##dateFormat(serviceEnd, "YYYY-MM-DD")##component##componentCode##quantity##measureShort##gaussianRound(priceWVat,2)##discount##gaussianRound((100-serviceDiscount)/100*(100-discount)/100*priceWVat,4)#
+